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