Run the processor and create a collection of results which indicate if the event passes/fails the Hcal veto.
61 {
62
63 const std::vector<ldmx::HcalHit> hcal_rec_hits =
65 input_hit_pass_name_);
66
67
68 float recoil_pos_x{0.0};
69 float recoil_pos_y{0.0};
70 float recoil_pos_z{-9999.0};
71 float recoil_mom_x{-9999.0};
72 float recoil_mom_y{-9999.0};
73 float recoil_mom_z{-9999.0};
74
75 if (exclude_recoil_ele_) {
76 std::vector<float> recoil_track_states;
77
78 auto recoil_tracks{
event.getCollection<
ldmx::Track>(track_collection_)};
79
80 ldmx::TrackStateType ts_type = ldmx::TrackStateType::AtHCAL;
81 recoil_track_states =
trackProp(recoil_tracks, ts_type,
"hcal");
82 if (!recoil_track_states.empty()) {
83 recoil_pos_x = recoil_track_states[0];
84 recoil_pos_y = recoil_track_states[1];
85 recoil_pos_z = recoil_track_states[2];
86 recoil_mom_x = recoil_track_states[3];
87 recoil_mom_y = recoil_track_states[4];
88 recoil_mom_z = recoil_track_states[5];
89 }
90 }
91
92
93
94 float total_PE{0.0};
95 float max_PE{-1000};
96 int num_total_hits{0};
97 int num_valid_hits{0};
98 int num_non_recoil_hits{0};
99
102 num_total_hits++;
103
105 continue;
106 }
107
108
109 float pe = hcal_hit.getPE();
110
111 total_PE += pe;
112
113
114
115
116
118 if ((id.section() == ldmx::HcalID::BACK) &&
120 continue;
121
122 num_valid_hits++;
123
124
125 if (exclude_recoil_ele_) {
126
127 auto hit_pos_x = hcal_hit.getXPos();
128 auto hit_pos_y = hcal_hit.getYPos();
129 auto hit_pos_z = hcal_hit.getZPos();
130 auto dZ = recoil_pos_z - hit_pos_z;
131
132 auto drift_recoil_x = (dZ * (recoil_mom_x / recoil_mom_z)) + recoil_pos_x;
133 auto drift_recoil_y = (dZ * (recoil_mom_y / recoil_mom_z)) + recoil_pos_y;
134 auto dx = drift_recoil_x - hit_pos_x;
135 auto dy = drift_recoil_y - hit_pos_y;
136 auto dR_squared = dx * dx + dy * dy + dZ * dZ;
137 auto dR = sqrt(dR_squared);
138 ldmx_log(debug) << " This hit is at " << hit_pos_x << " / "
139 << hit_pos_y << " / " << hit_pos_z << " mm";
140 ldmx_log(debug) << " Ele is projected at " << drift_recoil_x << " / "
141 << drift_recoil_y << " / " << recoil_pos_z - dZ;
142 ldmx_log(debug) << " from " << recoil_pos_x << " / " << recoil_pos_y
143 << " / " << recoil_pos_z << " / "
144 << " mm";
145
146 ldmx_log(debug) << " Ele had momentum of " << recoil_mom_x << " / "
147 << recoil_mom_y << " / " << recoil_mom_z << " MeV";
148 ldmx_log(debug) << " This hit has PE = " << pe << " and dR from ele = "
149 << "is " << dR << " mm";
150
151
152
153 if (dR < dr_from_recoil_max_) {
154 continue;
155 }
156 }
157 num_non_recoil_hits++;
158
159
160 if (max_PE < pe) {
161 max_PE = pe;
162 max_PE_hit = &hcal_hit;
163 }
164 }
165
166 ldmx_log(info) << "There are " << num_valid_hits << " / " << num_total_hits
167 << " HCal hits read out. " << num_non_recoil_hits
168 << " are not associated with the recoil ele. Total PE of "
169 << total_PE;
170
172 ldmx_log(info) << "HCAL veto passed? " << passes_veto;
173
179
180
181 if (!inverse_skim_) {
182 if (passes_veto) {
184 } else {
186 }
187 } else {
188
189 if (passes_veto) {
191 } else {
193 }
194 }
195
196 event.add(output_coll_name_, result);
197}
void setStorageHint(framework::StorageControl::Hint hint)
Mark the current event as having the given storage control hint from this module.
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.
Stores reconstructed hit information from the HCAL.
Implements detector ids for HCal subdetector.
void setVetoResult(const bool &passes_veto=true)
Sets whether the Hcal veto was passed or not.
void setTotalPE(const float total_PE)
Set the total number of PE.
void setNumValidHits(const float num_valid_hits)
Set the number of valid hits.
void setMaxPEHit(const ldmx::HcalHit max_PE_hit)
Set the maximum PE hit.
Implementation of a track object.
constexpr StorageControl::Hint hint_shouldKeep
storage control hint alias for backwards compatibility
constexpr StorageControl::Hint hint_shouldDrop
storage control hint alias for backwards compatibility