Run the processor and create a collection of results which indicate if the event passes/fails the Hcal veto.
64 {
65
66 const std::vector<ldmx::HcalHit> hcal_rec_hits =
68 input_hit_pass_name_);
69
70
71 float recoil_pos_x{0.0};
72 float recoil_pos_y{0.0};
73 float recoil_pos_z{-9999.0};
74 float recoil_mom_x{-9999.0};
75 float recoil_mom_y{-9999.0};
76 float recoil_mom_z{-9999.0};
77
78 if (exclude_recoil_ele_) {
79 std::vector<float> recoil_track_states;
80
81 auto recoil_tracks{
82 event.getCollection<
ldmx::Track>(track_collection_, track_pass_name_)};
83
84
85
86 ldmx::TrackStateType ts_type = ldmx::AtECAL;
87 recoil_track_states =
trackProp(recoil_tracks, ts_type,
"ecal");
88 if (!recoil_track_states.empty()) {
89 recoil_pos_x = recoil_track_states[0];
90 recoil_pos_y = recoil_track_states[1];
91 recoil_pos_z = recoil_track_states[2];
92 recoil_mom_x = recoil_track_states[3];
93 recoil_mom_y = recoil_track_states[4];
94 recoil_mom_z = recoil_track_states[5];
95 }
96 }
97
98
99
100 float total_pe{0.0};
101 float max_pe{-1000};
102 int num_total_hits{0};
103 int num_valid_hits{0};
104 int num_non_recoil_hits{0};
105
108 num_total_hits++;
109
111 continue;
112 }
113
114
115 float pe = hcal_hit.getPE();
116
117 total_pe += pe;
118
119
120
121
122
124 if ((id.section() == ldmx::HcalID::BACK) &&
126 continue;
127
128 num_valid_hits++;
129
130
131 if (exclude_recoil_ele_) {
132
133 auto hit_pos_x = hcal_hit.getXPos();
134 auto hit_pos_y = hcal_hit.getYPos();
135 auto hit_pos_z = hcal_hit.getZPos();
136 auto d_z = recoil_pos_z - hit_pos_z;
137
138 auto drift_recoil_x =
139 (d_z * (recoil_mom_x / recoil_mom_z)) + recoil_pos_x;
140 auto drift_recoil_y =
141 (d_z * (recoil_mom_y / recoil_mom_z)) + recoil_pos_y;
142 auto dx = drift_recoil_x - hit_pos_x;
143 auto dy = drift_recoil_y - hit_pos_y;
144 auto d_r_squared = dx * dx + dy * dy + d_z * d_z;
145 auto d_r = sqrt(d_r_squared);
146 ldmx_log(debug) << " This hit is at " << hit_pos_x << " / "
147 << hit_pos_y << " / " << hit_pos_z << " mm";
148 ldmx_log(debug) << " Ele is projected at " << drift_recoil_x << " / "
149 << drift_recoil_y << " / " << recoil_pos_z - d_z;
150 ldmx_log(debug) << " from " << recoil_pos_x << " / " << recoil_pos_y
151 << " / " << recoil_pos_z << " / " << " mm";
152
153 ldmx_log(debug) << " Ele had momentum of " << recoil_mom_x << " / "
154 << recoil_mom_y << " / " << recoil_mom_z << " MeV";
155 ldmx_log(debug) << " This hit has PE = " << pe
156 << " and dR from ele = " << "is " << d_r << " mm";
157
158
159
160 if (d_r < dr_from_recoil_max_) {
161 continue;
162 }
163 }
164 num_non_recoil_hits++;
165
166
167 if (max_pe < pe) {
168 max_pe = pe;
169 max_pe_hit = &hcal_hit;
170 }
171 }
172
173 ldmx_log(info) << "There are " << num_valid_hits << " / " << num_total_hits
174 << " HCal hits read out. " << num_non_recoil_hits
175 << " are not associated with the recoil ele. Total PE of "
176 << total_pe;
177
179 ldmx_log(info) << "HCAL veto passed? " << passes_veto;
180
186
187
188 if (!inverse_skim_) {
189 if (passes_veto) {
191 } else {
193 }
194 } else {
195
196 if (passes_veto) {
198 } else {
200 }
201 }
202
203 event.add(output_coll_name_, result);
204}
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_SHOULD_DROP
storage control hint alias for backwards compatibility
constexpr StorageControl::Hint HINT_SHOULD_KEEP
storage control hint alias for backwards compatibility