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 maxtotalEnergyCompare_ =
25 parameters.getParameter<double>("max_total_energy_compare");
26 mintotalEnergyCompare_ =
27 parameters.getParameter<double>("min_total_energy_compare");
28 maxnClusters_ = parameters.getParameter<double>("n_clusters");
29 maxMeanHitsPerCluster_ =
30 parameters.getParameter<double>("mean_hits_per_cluster");
31 maxMeanEnergyPerCluster_ =
32 parameters.getParameter<double>("mean_energy_per_cluster");
33 outputCollName_ = parameters.getParameter<std::string>("outputCollName");
34 inputHCALClusterCollName_ =
35 parameters.getParameter<std::string>("inputHCALClusterCollName");
36 inputHCALHitCollName_ =
37 parameters.getParameter<std::string>("inputHCALHitCollName");
38 inputECALHitCollName_ =
39 parameters.getParameter<std::string>("inputECALHitCollName");
40}
41
43 // Get the collection of sim particles from the event
44 // HCAL:
45 const std::vector<ldmx::HcalHit> hcalRecHits =
46 event.getCollection<ldmx::HcalHit>(inputHCALHitCollName_);
47 // ECAL:
48 const std::vector<ldmx::EcalHit> ecalRecHits =
49 event.getCollection<ldmx::EcalHit>(inputECALHitCollName_);
50 // Clusters:
51 const std::vector<ldmx::HcalCluster> hcalClusters =
52 event.getCollection<ldmx::HcalCluster>(inputHCALClusterCollName_);
53
54 // Loop over all of the Hcal hits and calculate to total photoelectrons
55 // in the event.
56 float totalHCALEnergy{0};
57 float totalECALEnergy{0};
58 float maxPE{-1000};
59 const ldmx::HcalHit *maxPEHit = nullptr;
60 for (const ldmx::HcalHit &hcalHit : hcalRecHits) {
61 if (hcalHit.isNoise() == 0) {
62 totalHCALEnergy += hcalHit.getPE();
63 }
64
65 // Find the maximum PE in the list
66 if (maxPE < hcalHit.getPE()) {
67 maxPE = hcalHit.getPE();
68 maxPEHit = const_cast<ldmx::HcalHit *>(&hcalHit);
69 }
70 }
71
72 for (const ldmx::EcalHit &ecalHit : ecalRecHits) {
73 if (ecalHit.isNoise() == 0) {
74 totalECALEnergy += ecalHit.getEnergy();
75 }
76 }
77 std::vector<double> nhits;
78 std::vector<double> energies;
79 unsigned int nClusters = 0;
80 for (const ldmx::HcalCluster &hcalCluster : hcalClusters) {
81 nClusters += 1;
82 energies.push_back(hcalCluster.getEnergy());
83 nhits.push_back(hcalCluster.getNHits());
84 }
85
86 double meanEnergy =
87 std::accumulate(energies.begin(), energies.end(), 0.0) / energies.size();
88 double meanNhits =
89 std::accumulate(nhits.begin(), nhits.end(), 0.0) / nhits.size();
90 bool passesEnergyCombo =
91 (((totalECALEnergy + totalHCALEnergy) < maxtotalEnergyCompare_));
92 bool passesnClusters = (nClusters < maxnClusters_);
93 bool passesNHits = ((meanNhits < maxMeanHitsPerCluster_) or isnan(meanNhits));
94 bool passesEnergy =
95 ((meanEnergy < maxMeanEnergyPerCluster_) or isnan(meanEnergy));
96
97 // total veto:
98 bool passesVeto =
99 (passesEnergyCombo and passesnClusters and passesNHits and passesEnergy);
100 // set result:
102 result.setVetoResult(passesVeto);
103 result.setMaxPEHit(*maxPEHit);
104 if (passesVeto) {
106
107 } else {
109 }
110
111 event.add(outputCollName_, result);
112}
113} // namespace hcal
114
115DECLARE_PRODUCER_NS(hcal, HcalWABVetoProcessor);
#define DECLARE_PRODUCER_NS(NS, 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:41
Class which represents the process under execution.
Definition Process.h:36
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:27
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:89
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.
float getEnergy() const
Get the calorimetric energy of the hit, corrected for sampling factors [MeV].
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:23
float getPE() const
Get the number of photoelectrons estimated for this hit.
Definition HcalHit.h:50
void setVetoResult(const bool &passesVeto=true)
Sets whether the Hcal veto was passed or not.
void setMaxPEHit(const ldmx::HcalHit maxPEHit)
Set the maximum PE hit.
constexpr StorageControl::Hint hint_shouldKeep
storage control hint alias for backwards compatibility
constexpr StorageControl::Hint hint_shouldDrop
storage control hint alias for backwards compatibility