LDMX Software
HcalWABVetoProcessor.cxx
Go to the documentation of this file.
1
8
9//-------------//
10// ldmx-sw //
11//-------------//
12#include <numeric>
13
14#include "DetDescr/HcalID.h"
15using namespace std;
16namespace hcal {
17
19 framework::Process &process)
20 : Producer(name, process) {}
21
24 maxtotal_energy_compare_ = parameters.get<double>("max_total_energy_compare");
25 mintotal_energy_compare_ = parameters.get<double>("min_total_energy_compare");
26 maxn_clusters_ = parameters.get<double>("n_clusters");
27 max_mean_hits_per_cluster_ = parameters.get<double>("mean_hits_per_cluster");
28 max_mean_energy_per_cluster_ =
29 parameters.get<double>("mean_energy_per_cluster");
30 output_coll_name_ = parameters.get<std::string>("outputCollName");
31 input_hcal_cluster_coll_name_ =
32 parameters.get<std::string>("inputHCALClusterCollName");
33 input_hcal_hit_coll_name_ =
34 parameters.get<std::string>("inputHCALHitCollName");
35 input_ecal_hit_coll_name_ =
36 parameters.get<std::string>("inputECALHitCollName");
37 hcal_hit_passname_ = parameters.get<std::string>("hcal_hit_passname");
38 ecal_hit_passname_ = parameters.get<std::string>("ecal_hit_passname");
39 hcal_cluster_passname_ = parameters.get<std::string>("hcal_cluster_passname");
40}
41
43 // Get the collection of sim particles from the event
44 // HCAL:
45 const std::vector<ldmx::HcalHit> hcal_rec_hits =
46 event.getCollection<ldmx::HcalHit>(input_hcal_hit_coll_name_,
47 hcal_hit_passname_);
48 // ECAL:
49 const std::vector<ldmx::EcalHit> ecal_rec_hits =
50 event.getCollection<ldmx::EcalHit>(input_ecal_hit_coll_name_,
51 ecal_hit_passname_);
52
53 // Clusters:
54 const std::vector<ldmx::HcalCluster> hcal_clusters =
55 event.getCollection<ldmx::HcalCluster>(input_hcal_cluster_coll_name_,
56 hcal_cluster_passname_);
57
58 // Loop over all of the Hcal hits_ and calculate to total photoelectrons
59 // in the event.
60 float total_hcal_energy{0};
61 float total_ecal_energy{0};
62 float max_pe{-1000};
63 const ldmx::HcalHit *max_pe_hit = nullptr;
64 for (const ldmx::HcalHit &hcal_hit : hcal_rec_hits) {
65 if (hcal_hit.isNoise() == 0) {
66 total_hcal_energy += hcal_hit.getPE();
67 }
68
69 // Find the maximum PE in the list
70 if (max_pe < hcal_hit.getPE()) {
71 max_pe = hcal_hit.getPE();
72 max_pe_hit = const_cast<ldmx::HcalHit *>(&hcal_hit);
73 }
74 }
75
76 for (const ldmx::EcalHit &ecal_hit : ecal_rec_hits) {
77 if (ecal_hit.isNoise() == 0) {
78 total_ecal_energy += ecal_hit.getEnergy();
79 }
80 }
81 std::vector<double> nhits;
82 std::vector<double> energies;
83 unsigned int n_clusters = 0;
84 for (const ldmx::HcalCluster &hcal_cluster : hcal_clusters) {
85 n_clusters += 1;
86 energies.push_back(hcal_cluster.getEnergy());
87 nhits.push_back(hcal_cluster.getNHits());
88 }
89
90 double mean_energy =
91 std::accumulate(energies.begin(), energies.end(), 0.0) / energies.size();
92 double mean_nhits =
93 std::accumulate(nhits.begin(), nhits.end(), 0.0) / nhits.size();
94 bool passes_energy_combo =
95 (((total_ecal_energy + total_hcal_energy) < maxtotal_energy_compare_));
96 bool passesn_clusters = (n_clusters < maxn_clusters_);
97 bool passes_n_hits =
98 ((mean_nhits < max_mean_hits_per_cluster_) or isnan(mean_nhits));
99 bool passes_energy =
100 ((mean_energy < max_mean_energy_per_cluster_) or isnan(mean_energy));
101
102 // total veto:
103 bool passes_veto = (passes_energy_combo and passesn_clusters and
104 passes_n_hits and passes_energy);
105 // set result:
107 result.setVetoResult(passes_veto);
108 result.setMaxPEHit(*max_pe_hit);
109 if (passes_veto) {
111
112 } else {
114 }
115
116 event.add(output_coll_name_, result);
117}
118} // namespace hcal
119
#define DECLARE_PRODUCER(CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Class that defines an HCal sensitive detector.
Processor that determines if an event is vetoed by the Hcal.
void setStorageHint(framework::StorageControl::Hint hint)
Mark the current event as having the given storage control hint from this module_.
Implements an event buffer system for storing event data.
Definition Event.h:42
Class which represents the process under execution.
Definition Process.h:36
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78
void configure(framework::config::Parameters &parameters) override
Configure the processor using the given user specified parameters.
void produce(framework::Event &event) override
Run the processor and create a collection of results which indicate if the event passes/fails the Hca...
HcalWABVetoProcessor(const std::string &name, framework::Process &process)
Constructor.
Stores reconstructed hit information from the ECAL.
Definition EcalHit.h:19
Stores cluster information from the HCal.
Definition HcalCluster.h:21
Stores reconstructed hit information from the HCAL.
Definition HcalHit.h:24
void setVetoResult(const bool &passes_veto=true)
Sets whether the Hcal veto was passed or not.
void setMaxPEHit(const ldmx::HcalHit max_PE_hit)
Set the maximum PE hit.
constexpr StorageControl::Hint HINT_SHOULD_DROP
storage control hint alias for backwards compatibility
constexpr StorageControl::Hint HINT_SHOULD_KEEP
storage control hint alias for backwards compatibility