LDMX Software
EcalVetoProcessor.h
Go to the documentation of this file.
1
7#ifndef EVENTPROC_ECALVETOPROCESSOR_H_
8#define EVENTPROC_ECALVETOPROCESSOR_H_
9
10// LDMX
12#include "DetDescr/EcalID.h"
13#include "Ecal/Event/EcalHit.h"
15#include "Framework/Configure/Parameters.h"
17#include "Tools/ONNXRuntime.h"
18
19// ROOT (MIP tracking)
20#include "TVector3.h"
21
22// For recoil tracking
23#include "Tracking/Event/Track.h"
24
25// C++
26#include <map>
27#include <memory>
28
29namespace ecal {
30
36 public:
37 typedef std::pair<ldmx::EcalID, float> CellEnergyPair;
38
39 typedef std::pair<float, float> XYCoords;
40
41 EcalVetoProcessor(const std::string& name, framework::Process& process)
42 : Producer(name, process) {}
43
44 virtual ~EcalVetoProcessor() {}
45
52 void onNewRun(const ldmx::RunHeader& rh) override;
53
57 void onProcessEnd() override;
58
64 void configure(framework::config::Parameters& parameters) override;
65
66 void produce(framework::Event& event) override;
67
68 // MIP tracking: Class for storing hit information for tracking in a
69 // convenient way
70 struct HitData {
71 int layer;
72 TVector3 pos;
73 };
74
75 private:
76 void clearProcessor();
77
78 /* Function to calculate the energy weighted shower centroid */
79 ldmx::EcalID GetShowerCentroidIDAndRMS(
80 const std::vector<ldmx::EcalHit>& ecalRecHits, float& showerRMS);
81
82 /* Function to load up empty vector of hit maps */
83 void fillHitMap(const std::vector<ldmx::EcalHit>& ecalRecHits,
84 std::map<ldmx::EcalID, float>& cellMap_);
85
86 /* Function to take loaded hit maps and find isolated hits in them */
87 void fillIsolatedHitMap(const std::vector<ldmx::EcalHit>& ecalRecHits,
88 ldmx::EcalID globalCentroid,
89 std::map<ldmx::EcalID, float>& cellMap,
90 std::map<ldmx::EcalID, float>& cellMapIso,
91 bool doTight = false);
92
93 std::vector<XYCoords> getTrajectory(std::array<float, 3> momentum,
94 std::array<float, 3> position);
95
97
98 // MIP tracking
109 float distTwoLines(TVector3 v1, TVector3 v2, TVector3 w1, TVector3 w2);
119 float distPtToLine(TVector3 h1, TVector3 p1, TVector3 p2);
120
128 std::vector<float> trackProp(const ldmx::Tracks& tracks,
129 ldmx::TrackStateType ts_type,
130 const std::string& ts_title);
131
132 private:
133 int nevents_{0};
134 float processing_time_{0.};
135
136 std::map<std::string, float> profiling_map_;
137 std::map<ldmx::EcalID, float> cellMap_;
138 std::map<ldmx::EcalID, float> cellMapTightIso_;
139
140 std::vector<float> ecalLayerEdepRaw_;
141 std::vector<float> ecalLayerEdepReadout_;
142 std::vector<float> ecalLayerTime_;
143
144 std::vector<std::vector<float>> roc_range_values_;
145
146 int nEcalLayers_{0};
147 int nReadoutHits_{0};
148 int deepestLayerHit_{0};
149
150 float summedDet_{0};
151 float summedTightIso_{0};
152 float maxCellDep_{0};
153 float showerRMS_{0};
154 float xStd_{0};
155 float yStd_{0};
156 float avgLayerHit_{0};
157 float stdLayerHit_{0};
158 float ecalBackEnergy_{0};
159 // MIP tracking
170 float epAng_{0};
176 float epSep_{0};
178 float epDot_{0};
183
184 float bdtCutVal_{0};
185
186 float beamEnergyMeV_{0};
187 bool run_lin_reg_{true};
188 float linreg_radius_{0};
189
190 std::string bdtFileName_;
191 std::string rocFileName_;
192 std::vector<float> bdtFeatures_;
193 std::string featureListName_;
194
195 // Pass and collection names
196 std::string sp_pass_name_;
197 std::string rec_pass_name_;
198 std::string rec_coll_name_;
199 bool recoil_from_tracking_;
200 std::string track_pass_name_;
201 std::string track_collection_;
202 bool inverse_skim_{false};
203
205 std::string collectionName_{"EcalVeto"};
206
207 std::unique_ptr<ldmx::Ort::ONNXRuntime> rt_;
208
211};
212
213} // namespace ecal
214
215#endif
Class that translates raw positions of ECal module hits into cells in a hexagonal readout.
Class that defines an ECal detector ID with a cell number.
Class used to encapsulate the results obtained from EcalVetoProcessor.
Base classes for all user event processing components to extend.
Determines if event is vetoable using ECAL hit information.
std::vector< float > trackProp(const ldmx::Tracks &tracks, ldmx::TrackStateType ts_type, const std::string &ts_title)
Return a vector of parameters for a propagated recoil track.
float epSep_
Distance between the projected photon and electron trajectories at the ECal face.
float distTwoLines(TVector3 v1, TVector3 v2, TVector3 w1, TVector3 w2)
Returns the distance between the lines v and w, with v defined to pass through the points (v1,...
void configure(framework::config::Parameters &parameters) override
Configure the processor using the given user specified parameters.
void produce(framework::Event &event) override
Process the event and put new data products into it.
void onNewRun(const ldmx::RunHeader &rh) override
onNewRun is the first function called for each processor after the conditions are fully configured an...
void buildBDTFeatureVector(const ldmx::EcalVetoResult &result)
int photonTerritoryHits_
Number of hits in the photon territory.
float epDotAtTarget_
Dot product of the photon and electron momenta unit vectors at Target.
float epAng_
Angular separation between the projected photon and electron trajectories as projected at ECAL.
int nStraightTracks_
Number of "straight" tracks found in the event.
int nLinregTracks_
Number of "linreg" tracks found in the event.
int firstNearPhLayer_
First ECal layer in which a hit is found near the photon.
float epDot_
Dot product of the photon and electron momenta unit vectors at Ecal.
float distPtToLine(TVector3 h1, TVector3 p1, TVector3 p2)
Return the minimum distance between the point h1 and the line passing through points p1 and p2.
std::string collectionName_
Name of the collection which will containt the results.
void onProcessEnd() override
Callback for the EventProcessor to take any necessary action when the processing of events finishes,...
void fillHitMap(const std::vector< ldmx::EcalHit > &ecalRecHits, std::map< ldmx::EcalID, float > &cellMap_)
Function to load up empty vector of hit maps.
float epAngAtTarget_
Angular separation between the projected photon and electron trajectories as at Target.
int nNearPhHits_
Number of hits near the photon trajectory.
const ldmx::EcalGeometry * geometry_
handle to current geometry (to share with member functions)
Implements an event buffer system for storing event data.
Definition Event.h:42
Class which represents the process under execution.
Definition Process.h:36
Base class for a module which produces a data product.
Producer(const std::string &name, Process &process)
Class constructor.
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
Translation between real-space positions and cell IDs within the ECal.
Extension of DetectorID providing access to ECal layers and cell numbers in a hex grid.
Definition EcalID.h:20
Run-specific configuration and data stored in its own output TTree alongside the event TTree in the o...
Definition RunHeader.h:57