LDMX Software
HcalVetoProcessor.cxx
Go to the documentation of this file.
1
8
9//-------------//
10// ldmx-sw //
11//-------------//
12#include "DetDescr/HcalID.h"
13
14namespace hcal {
15
17 framework::Process &process)
18 : Producer(name, process) {}
19
21 totalPEThreshold_ = parameters.getParameter<double>("pe_threshold");
22 maxTime_ = parameters.getParameter<double>("max_time");
23 outputCollName_ = parameters.getParameter<std::string>("output_coll_name");
24 inputHitCollName_ =
25 parameters.getParameter<std::string>("input_hit_coll_name");
26 inputHitPassName_ =
27 parameters.getParameter<std::string>("input_hit_pass_name");
28 // A fake-hit that gets added for the rare case where no hit actually reaches
29 // the maxPE < pe check to avoid producing uninitialized memory
30 //
31 // Default constructed hits have nonsense-but predictable values and are
32 // harder to mistake for real hits
33 defaultMaxHit_.Clear();
34 defaultMaxHit_.setPE(-9999);
35 defaultMaxHit_.setMinPE(-9999);
36 defaultMaxHit_.setSection(-9999);
37 defaultMaxHit_.setLayer(-9999);
38 defaultMaxHit_.setStrip(-9999);
39 defaultMaxHit_.setEnd(-999);
40 defaultMaxHit_.setTimeDiff(-9999);
41 defaultMaxHit_.setToaPos(-9999);
42 defaultMaxHit_.setToaNeg(-9999);
43 defaultMaxHit_.setAmplitudePos(-9999);
44 defaultMaxHit_.setAmplitudeNeg(-9999);
45
46 double maxDepth_ = parameters.getParameter<double>("max_depth", 0.);
47 if (maxDepth_ != 0.) {
48 EXCEPTION_RAISE(
49 "InvalidParam",
50 "Earlier versions of the Hcal veto defined a max depth for "
51 "positions which is no longer implemented. Remove the "
52 "parameter (max_depth) from your configuration. See "
53 "https://github.com/LDMX-Software/Hcal/issues/61 for details");
54 }
55 backMinPE_ = parameters.getParameter<double>("back_min_pe");
56}
57
59 // Get the collection of sim particles from the event
60 const std::vector<ldmx::HcalHit> hcalRecHits =
61 event.getCollection<ldmx::HcalHit>(inputHitCollName_, inputHitPassName_);
62
63 // Loop over all of the Hcal hits and calculate to total photoelectrons
64 // in the event.
65 [[maybe_unused]] float totalPe{0};
66 float maxPE{-1000};
67
68 const ldmx::HcalHit *maxPEHit{&defaultMaxHit_};
69 for (const ldmx::HcalHit &hcalHit : hcalRecHits) {
70 // If the hit time is outside the readout window, don't consider it.
71 if (hcalHit.getTime() >= maxTime_) {
72 continue;
73 }
74
75 // Get the total PE in the bar
76 float pe = hcalHit.getPE();
77
78 // Keep track of the total PE
79 // TODO: This is currently not used anywhere
80 totalPe += pe;
81
82 // Check that both sides of the bar have a PE value above threshold.
83 // If not, don't consider the hit. Double sided readout is only
84 // being used for the back HCal bars. For the side HCal, just
85 // use the maximum PE as before.
86 ldmx::HcalID id(hcalHit.getID());
87 if ((id.section() == ldmx::HcalID::BACK) &&
88 (hcalHit.getMinPE() < backMinPE_))
89 continue;
90
91 // Find the maximum PE in the list
92 if (maxPE < pe) {
93 maxPE = pe;
94 maxPEHit = &hcalHit;
95 }
96 }
97
98 // If the maximum PE found is below threshold, it passes the veto.
99 bool passesVeto = (maxPE < totalPEThreshold_);
100
102 result.setVetoResult(passesVeto);
103 result.setMaxPEHit(*maxPEHit);
104
105 if (passesVeto) {
107 } else {
109 }
110
111 event.add(outputCollName_, result);
112}
113} // namespace hcal
114
115DECLARE_PRODUCER_NS(hcal, HcalVetoProcessor);
#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
HcalVetoProcessor(const std::string &name, framework::Process &process)
Constructor.
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...
float maxTime_
Maximum hit time that should be considered by the veto.
float backMinPE_
The minimum number of PE in both bars needed for a hit to be considered in double ended readout mode.
double totalPEThreshold_
Total PE threshold.
Stores reconstructed hit information from the HCAL.
Definition HcalHit.h:23
void setSection(int section)
Set the section for this hit.
Definition HcalHit.h:132
void Clear()
Clear the data in the object.
Definition HcalHit.cxx:9
void setEnd(int end)
Set the end (0 neg, 1 pos side).
Definition HcalHit.h:150
void setToaNeg(double toaNeg)
Set toa of the negative end.
Definition HcalHit.h:174
void setTimeDiff(double timeDiff)
Set time difference (uncorrected)
Definition HcalHit.h:162
void setMinPE(float minpe)
Set the minimum number of photoelectrons estimated for this hit.
Definition HcalHit.h:126
void setToaPos(double toaPos)
Set toa of the positive end.
Definition HcalHit.h:168
void setAmplitudeNeg(double amplitudeNeg)
Set amplitude of the negative end.
Definition HcalHit.h:186
void setStrip(int strip)
Set the strip for this hit.
Definition HcalHit.h:144
float getPE() const
Get the number of photoelectrons estimated for this hit.
Definition HcalHit.h:50
void setAmplitudePos(double amplitudePos)
Set amplitude of the positive end.
Definition HcalHit.h:180
void setLayer(int layer)
Set the layer for this hit.
Definition HcalHit.h:138
void setPE(float pe)
Set the number of photoelectrons estimated for this hit.
Definition HcalHit.h:119
Implements detector ids for HCal subdetector.
Definition HcalID.h:19
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