LDMX Software
HcalWABVetoProcessor.cxx
Go to the documentation of this file.
1
8
9//-------------//
10// ldmx-sw //
11//-------------//
12#include <cmath>
13#include <numeric>
14
15#include "Ecal/Event/EcalHit.h"
17#include "Hcal/Event/HcalHit.h"
19using namespace std;
20namespace hcal {
21
23 framework::Process& process)
24 : Producer(name, process) {}
25
28 maxtotal_energy_compare_ = parameters.get<double>("max_total_energy_compare");
29 mintotal_energy_compare_ = parameters.get<double>("min_total_energy_compare");
30 maxn_clusters_ = parameters.get<double>("n_clusters");
31 max_mean_hits_per_cluster_ = parameters.get<double>("mean_hits_per_cluster");
32 max_mean_energy_per_cluster_ =
33 parameters.get<double>("mean_energy_per_cluster");
34 output_coll_name_ = parameters.get<std::string>("output_coll_name");
35 input_hcal_cluster_coll_name_ =
36 parameters.get<std::string>("input_hcal_cluster_coll_name");
37 input_hcal_hit_coll_name_ =
38 parameters.get<std::string>("input_hcal_hit_coll_name");
39 input_ecal_hit_coll_name_ =
40 parameters.get<std::string>("input_ecal_hit_coll_name");
41 hcal_hit_passname_ = parameters.get<std::string>("hcal_hit_passname");
42 ecal_hit_passname_ = parameters.get<std::string>("ecal_hit_passname");
43 hcal_cluster_passname_ = parameters.get<std::string>("hcal_cluster_passname");
44}
45
47 // Get the collection of sim particles from the event
48 // HCAL:
49 const std::vector<ldmx::HcalHit> hcal_rec_hits =
50 event.getCollection<ldmx::HcalHit>(input_hcal_hit_coll_name_,
51 hcal_hit_passname_);
52 // ECAL:
53 const std::vector<ldmx::EcalHit> ecal_rec_hits =
54 event.getCollection<ldmx::EcalHit>(input_ecal_hit_coll_name_,
55 ecal_hit_passname_);
56
57 // Clusters:
58 const std::vector<ldmx::HcalCluster> hcal_clusters =
59 event.getCollection<ldmx::HcalCluster>(input_hcal_cluster_coll_name_,
60 hcal_cluster_passname_);
61
62 // Loop over all of the Hcal hits_ and calculate to total photoelectrons
63 // in the event.
64 float total_hcal_energy{0};
65 float total_ecal_energy{0};
66 float max_pe{-1000};
67 const ldmx::HcalHit* max_pe_hit = nullptr;
68 for (const ldmx::HcalHit& hcal_hit : hcal_rec_hits) {
69 if (hcal_hit.isNoise() == 0) {
70 total_hcal_energy += hcal_hit.getPE();
71 }
72
73 // Find the maximum PE in the list
74 if (max_pe < hcal_hit.getPE()) {
75 max_pe = hcal_hit.getPE();
76 max_pe_hit = const_cast<ldmx::HcalHit*>(&hcal_hit);
77 }
78 }
79
80 for (const ldmx::EcalHit& ecal_hit : ecal_rec_hits) {
81 if (ecal_hit.isNoise() == 0) {
82 total_ecal_energy += ecal_hit.getEnergy();
83 }
84 }
85 std::vector<double> nhits;
86 std::vector<double> energies;
87 unsigned int n_clusters = 0;
88 for (const ldmx::HcalCluster& hcal_cluster : hcal_clusters) {
89 n_clusters += 1;
90 energies.push_back(hcal_cluster.getEnergy());
91 nhits.push_back(hcal_cluster.getNHits());
92 }
93
94 double mean_energy =
95 std::accumulate(energies.begin(), energies.end(), 0.0) / energies.size();
96 double mean_nhits =
97 std::accumulate(nhits.begin(), nhits.end(), 0.0) / nhits.size();
98 bool passes_energy_combo =
99 (((total_ecal_energy + total_hcal_energy) < maxtotal_energy_compare_));
100 bool passesn_clusters = (n_clusters < maxn_clusters_);
101 bool passes_n_hits =
102 ((mean_nhits < max_mean_hits_per_cluster_) or isnan(mean_nhits));
103 bool passes_energy =
104 ((mean_energy < max_mean_energy_per_cluster_) or isnan(mean_energy));
105
106 // total veto:
107 bool passes_veto = (passes_energy_combo and passesn_clusters and
108 passes_n_hits and passes_energy);
109 // set result:
111 result.setVetoResult(passes_veto);
112 result.setMaxPEHit(*max_pe_hit);
113 if (passes_veto) {
115
116 } else {
118 }
119
120 event.add(output_coll_name_, result);
121}
122} // namespace hcal
123
#define DECLARE_PRODUCER(CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Class that stores cluster information from the ECal.
Class that stores Stores reconstructed hit information from the HCAL.
Class used to encapsulate the results obtained from HcalVetoProcessor.
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:40
Class which represents the process under execution.
Definition Process.h:34
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:26
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:75
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