LDMX Software
RecoilFiducialityProcessor.cxx
Go to the documentation of this file.
1
8
9namespace recon {
10
13 min_p_mag_ = parameters.getParameter<double>("min_p_mag");
14 min_tracker_hits_ = parameters.getParameter<int>("min_tracker_hits");
15 input_pass_name_ = parameters.getParameter<std::string>("input_pass_name");
16 ecal_collection_ = parameters.getParameter<std::string>("ecal_collection");
17 hcal_collection_ = parameters.getParameter<std::string>("hcal_collection");
19 parameters.getParameter<std::string>("recoil_collection");
21 parameters.getParameter<std::string>("output_collection");
22 inverse_skim_ = parameters.getParameter<bool>("inverse_skim");
23}
24
26 // Get the collection of simulated particles from the event
27 auto particleMap{
28 event.getMap<int, ldmx::SimParticle>("SimParticles", input_pass_name_)};
29
30 // Search for the recoil electron
31 auto [recoil_track_id, recoil_electron] = Analysis::getRecoil(particleMap);
32
33 // Get the collection of simulated Ecal hits from the event.
34 const std::vector<ldmx::SimCalorimeterHit> ecal_sim_hits =
35 event.getCollection<ldmx::SimCalorimeterHit>(ecal_collection_,
37
38 // Get the collection of simulated Ecal hits from the event.
39 const std::vector<ldmx::SimCalorimeterHit> hcal_sim_hits =
40 event.getCollection<ldmx::SimCalorimeterHit>(hcal_collection_,
42
43 // Get the collection of simulated tracker hits from the event.
44 const std::vector<ldmx::SimTrackerHit> recoil_sim_hits =
45 event.getCollection<ldmx::SimTrackerHit>(recoil_collection_,
47
48 // Loop through the Ecal hits and check if the recoil electron is
49 // associated with any of them.
50 bool has_ecal_hit = false;
51 int ecal_hit_id = -1;
52 for (const ldmx::SimCalorimeterHit &sim_hit : ecal_sim_hits) {
53 for (int iContrib = 0; iContrib < sim_hit.getNumberOfContribs();
54 ++iContrib) {
55 ldmx::SimCalorimeterHit::Contrib contrib = sim_hit.getContrib(iContrib);
56
57 if (contrib.trackID == recoil_track_id) {
58 has_ecal_hit = true;
59 ecal_hit_id = sim_hit.getID();
60 }
61 }
62 }
63
64 // Loop through the Hcal hits and check if the recoil electron is
65 // associated with any of them.
66 bool has_hcal_hit = false;
67 int hcal_hit_id = -1;
68 for (const ldmx::SimCalorimeterHit &sim_hit : hcal_sim_hits) {
69 for (int iContrib = 0; iContrib < sim_hit.getNumberOfContribs();
70 ++iContrib) {
71 ldmx::SimCalorimeterHit::Contrib contrib = sim_hit.getContrib(iContrib);
72
73 if (contrib.trackID == recoil_track_id) {
74 has_hcal_hit = true;
75 hcal_hit_id = sim_hit.getID();
76 }
77 }
78 }
79
80 // Loop through the recoil tracker hits and count how many
81 // the recoil electron is associated with
82 std::set<int> layers_hit;
83 for (const ldmx::SimTrackerHit &sim_hit : recoil_sim_hits) {
84 if (sim_hit.getTrackID() == recoil_track_id) {
85 // int sensorID = tracking::sim::utils::getSensorID(sim_hit);
86 if ((sim_hit.getTime() < 0.8) && (sim_hit.getMomentum()[2] > 0)) {
87 layers_hit.insert(sim_hit.getLayerID());
88 }
89 }
90 }
91 bool has_min_tracker_hits = false;
92 if (layers_hit.size() >= min_tracker_hits_) {
93 has_min_tracker_hits = true;
94 }
95
96 // Checking if the recoil electron energy is > min energy
97 bool has_min_energy = false;
98 if (recoil_electron->getEnergy() >= min_p_mag_) {
99 has_min_energy = true;
100 }
101
102 // Configure outputs
103 bool is_fiducial = has_min_energy && has_min_tracker_hits && has_ecal_hit;
104
105 int mask_tracker_E = has_min_energy << 0;
106 int mask_tracker_hits = has_min_tracker_hits << 1;
107 int mask_ecal = has_ecal_hit << 2;
108 int mask_hcal = has_hcal_hit << 3;
109 int fiducial_flag =
110 mask_tracker_E | mask_tracker_hits | mask_ecal | mask_hcal;
111
113 flag.setFiducialFlag(fiducial_flag, 6);
114 flag.setAlgoVar(0, recoil_electron->getEnergy());
115 flag.setAlgoVar(1, min_p_mag_);
116 flag.setAlgoVar(2, layers_hit.size());
118 flag.setAlgoVar(4, ecal_hit_id);
119 flag.setAlgoVar(5, hcal_hit_id);
120
121 flag.setIsFiducial(is_fiducial);
122 flag.setHasMinEnergy(has_min_energy);
123 flag.setHasMinTrackerHits(has_min_tracker_hits);
124 flag.setHasEcalHit(has_ecal_hit);
125 flag.setHasHcalHit(has_hcal_hit);
126
127 event.add(output_collection_, flag);
128
129 // Tell the skimmer to keep or drop the event based on whether there
130 // were recoil electron was fiducial.
131
132 if (!inverse_skim_) {
133 if (is_fiducial) {
135 } else {
137 }
138 } else {
139 if (is_fiducial) {
141 } else {
143 }
144 }
145}
146} // namespace recon
147
148DECLARE_PRODUCER_NS(recon, RecoilFiducialityProcessor);
#define DECLARE_PRODUCER_NS(NS, CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Class that flags events with a fiducial recoil electron.
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:42
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
Holds truth-level fiduciality flags on the signal recoil electron.
void setHasHcalHit(bool has_hcal_hit)
Set hcal hit flag.
void setAlgoVar(int element, double value)
Set an algorithm variable.
void setHasMinTrackerHits(bool has_min_tracker_hits)
Set tracker hit flag.
void setIsFiducial(bool is_fiducial)
Set fiduciality flag.
void setFiducialFlag(int fiducial_flag, int nvar)
Set fiduciality bit mask.
void setHasEcalHit(bool has_ecal_hit)
Set ecal hit flag.
void setHasMinEnergy(bool has_min_energy)
Set recoil min.
Stores simulated calorimeter hit information.
Class representing a simulated particle.
Definition SimParticle.h:23
Represents a simulated tracker hit in the simulation.
bool inverse_skim_
Inverse option for skimming.
std::string ecal_collection_
The name of the ecal collection.
std::string hcal_collection_
The name of the hcal collection.
std::string output_collection_
The name of the output collection.
std::string recoil_collection_
The name of the recoil tracker collection.
int min_tracker_hits_
Minimum number of recoil electron hits in the recoil tracker.
void configure(framework::config::Parameters &parameters) override
Configure the processor using the given user specified parameters.
double min_p_mag_
Minimum recoil electron momentum at production.
void produce(framework::Event &event) override
Create a FiducialFlag object to contain info about whether the recoil electron satisfies certain fidu...
std::string input_pass_name_
The pass name of the input collections.
constexpr StorageControl::Hint hint_shouldKeep
storage control hint alias for backwards compatibility
constexpr StorageControl::Hint hint_shouldDrop
storage control hint alias for backwards compatibility
Information about a contribution to the hit in the associated cell.
int trackID
track ID of this contributor