LDMX Software
EcalVetoProcessor.h
Go to the documentation of this file.
1
8#ifndef EVENTPROC_ECALVETOPROCESSOR_H_
9#define EVENTPROC_ECALVETOPROCESSOR_H_
10
11// LDMX
13#include "DetDescr/EcalID.h"
14#include "DetDescr/SimSpecialID.h"
15#include "Ecal/EcalHelper.h"
16#include "Ecal/Event/EcalHit.h"
19#include "Framework/Configure/Parameters.h"
21#include "SimCore/Event/SimParticle.h"
23#include "Tools/AnalysisUtils.h"
24#include "Tools/ONNXRuntime.h"
25
26// C++
27#include <stdlib.h>
28
29#include <algorithm>
30#include <cmath>
31#include <fstream>
32#include <iomanip>
33#include <map>
34#include <memory>
35
36// ROOT (for angle calculations)
37#include "Math/Vector3D.h"
38
39namespace ecal {
40
46 public:
47 typedef std::pair<ldmx::EcalID, float> CellEnergyPair;
48
49 typedef std::pair<float, float> XYCoords;
50
51 EcalVetoProcessor(const std::string& name, framework::Process& process)
52 : Producer(name, process) {}
53
54 virtual ~EcalVetoProcessor() {}
55
62 void onNewRun(const ldmx::RunHeader& rh) override;
63
67 void onProcessEnd() override;
68
74 void configure(framework::config::Parameters& parameters) override;
75
76 void produce(framework::Event& event) override;
77
78 private:
79 void clearProcessor();
80
81 /* Function to calculate the energy weighted shower centroid */
82 ldmx::EcalID getShowerCentroidIdAndRms(
83 const std::vector<ldmx::EcalHit>& ecal_rec_hits, float& shower_rms);
84
85 /* Function to load up empty vector of hit maps */
86 void fillHitMap(const std::vector<ldmx::EcalHit>& ecal_rec_hits,
87 std::map<ldmx::EcalID, float>& cell_map_);
88
89 /* Function to take loaded hit maps and find isolated hits in them */
90 void fillIsolatedHitMap(const std::vector<ldmx::EcalHit>& ecal_rec_hits,
91 ldmx::EcalID global_centroid,
92 std::map<ldmx::EcalID, float>& cell_map,
93 std::map<ldmx::EcalID, float>& cell_map_iso,
94 bool doTight = false);
95
96 std::vector<XYCoords> getTrajectory(std::array<float, 3> momentum,
97 std::array<float, 3> position);
98
100
101 private:
102 int nevents_{0};
103 float processing_time_{0.};
104
105 std::map<std::string, float> profiling_map_;
106 std::map<ldmx::EcalID, float> cell_map_;
107 std::map<ldmx::EcalID, float> cell_map_tight_iso_;
108
109 std::vector<float> ecal_layer_edep_raw_;
110 std::vector<float> ecal_layer_edep_readout_;
111 std::vector<float> ecal_layer_time_;
112
113 std::vector<std::vector<float>> roc_range_values_;
114
115 int n_ecal_layers_{0};
116 int n_readout_hits_{0};
117 int deepest_layer_hit_{0};
118
119 float summed_det_{0};
120 float summed_tight_iso_{0};
121 float max_cell_dep_{0};
122 float shower_rms_{0};
123 float x_std_{0};
124 float y_std_{0};
125 float avg_layer_hit_{0};
126 float std_layer_hit_{0};
127 float ecal_back_energy_{0};
128
134 float ep_ang_{0};
140 float ep_sep_{0};
142 float ep_dot_{0};
145
146 float bdt_cut_val_{0};
147
148 float beam_energy_mev_{0};
149
150 std::string bdt_file_name_;
151 std::string roc_file_name_;
152 std::vector<float> bdt_features_;
153 std::string feature_list_name_;
154
155 // Pass and collection names
156 std::string sp_pass_name_;
157 std::string rec_pass_name_;
158 std::string rec_coll_name_;
159 bool recoil_from_tracking_;
160 std::string track_pass_name_;
161 std::string track_collection_;
162
163 std::string sim_particles_passname_;
164 bool inverse_skim_{false};
165
167 std::string collection_name_{"EcalVeto"};
168
169 std::unique_ptr<ldmx::ort::ONNXRuntime> rt_;
170
173};
174
175} // namespace ecal
176
177#endif
Collection of utility functions useful for analysis.
Class that translates raw positions of ECal module hits into cells in a hexagonal readout.
Class that propagates tracks to the ECAL face.
Class that defines an ECal detector ID with a cell number.
Class that determines MIP tracking information using ECAL hit information.
Class used to encapsulate the results obtained from EcalVetoProcessor.
Base classes for all user event processing components to extend.
Class which encapsulates information from a hit in a simulated tracking detector.
Determines if event is vetoable using ECAL hit information.
float ep_ang_
Angular separation between the projected photon and electron trajectories as projected at ECAL.
std::string collection_name_
Name of the collection which will containt the results.
float ep_ang_at_target_
Angular separation between the projected photon and electron trajectories as at Target.
void configure(framework::config::Parameters &parameters) override
Configure the processor using the given user specified parameters.
float ep_dot_
Dot product of the photon and electron momenta unit vectors at Ecal.
void produce(framework::Event &event) override
Process the event and put new data products into it.
float ep_sep_
Distance between the projected photon and electron trajectories at the ECal face.
void fillHitMap(const std::vector< ldmx::EcalHit > &ecal_rec_hits, std::map< ldmx::EcalID, float > &cell_map_)
Function to load up empty vector of hit maps.
int n_tracking_hits_
Number of hits outside of the electron roc in the Ecal or if the electron trajectory is missing,...
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)
float ep_dot_at_target_
Dot product of the photon and electron momenta unit vectors at Target.
void onProcessEnd() override
Callback for the EventProcessor to take any necessary action when the processing of events finishes,...
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.
virtual void process(Event &event) final
Processing an event for a Producer is calling produce.
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