19 : Producer(name, process) {}
24 output_coll_name_ = parameters.
get<std::string>(
"output_coll_name");
25 input_hit_coll_name_ = parameters.
get<std::string>(
"input_hit_coll_name");
26 input_hit_pass_name_ = parameters.
get<std::string>(
"input_hit_pass_name");
27 track_pass_name_ = parameters.
get<std::string>(
"track_pass_name");
34 default_max_hit_.
clear();
35 default_max_hit_.
setPE(-9999);
40 default_max_hit_.
setEnd(-999);
47 double max_depth = parameters.
get<
double>(
"max_depth", 0.);
48 if (max_depth != 0.) {
51 "Earlier versions of the Hcal veto defined a max depth for "
52 "positions which is no longer implemented. Remove the "
53 "parameter (max_depth) from your configuration. See "
54 "https://github.com/LDMX-Software/Hcal/issues/61 for details");
57 exclude_recoil_ele_ = parameters.
get<
bool>(
"exclude_recoil_ele",
false);
59 parameters.
get<std::string>(
"track_collection",
"RecoilTracks");
60 dr_from_recoil_max_ = parameters.
get<
double>(
"dr_from_recoil_max", 100);
61 inverse_skim_ = parameters.
get<
bool>(
"inverse_skim");
66 const std::vector<ldmx::HcalHit> hcal_rec_hits =
68 input_hit_pass_name_);
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};
78 if (exclude_recoil_ele_) {
79 std::vector<float> recoil_track_states;
82 event.getCollection<
ldmx::Track>(track_collection_, track_pass_name_)};
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];
102 int num_total_hits{0};
103 int num_valid_hits{0};
104 int num_non_recoil_hits{0};
115 float pe = hcal_hit.getPE();
124 if ((
id.section() == ldmx::HcalID::BACK) &&
131 if (exclude_recoil_ele_) {
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;
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";
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";
160 if (d_r < dr_from_recoil_max_) {
164 num_non_recoil_hits++;
169 max_pe_hit = &hcal_hit;
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 "
179 ldmx_log(info) <<
"HCAL veto passed? " << passes_veto;
188 if (!inverse_skim_) {
203 event.add(output_coll_name_, result);
207 ldmx::TrackStateType ts_type,
208 const std::string& ts_title) {
210 std::vector<float> new_track_states;
213 if (tracks.empty())
return new_track_states;
216 for (
auto& track : tracks) {
218 auto trk_ts = track.getTrackState(ts_type);
220 if (!trk_ts.has_value())
continue;
224 if (hcal_track_state.pos_.size() < 3 || hcal_track_state.mom_.size() < 3)
228 new_track_states.push_back(
static_cast<float>(hcal_track_state.pos_[0]));
229 new_track_states.push_back(
static_cast<float>(hcal_track_state.pos_[1]));
230 new_track_states.push_back(
static_cast<float>(hcal_track_state.pos_[2]));
231 new_track_states.push_back(
static_cast<float>(hcal_track_state.mom_[0]));
232 new_track_states.push_back(
static_cast<float>(hcal_track_state.mom_[1]));
233 new_track_states.push_back(
static_cast<float>(hcal_track_state.mom_[2]));
237 return new_track_states;
#define DECLARE_PRODUCER(CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Class that defines an HCal sensitive detector.
Processor that determines if an event is vetoed by the Hcal.
Class used to encapsulate the results obtained from HcalVetoProcessor.
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.
Class which represents the process under execution.
Class encapsulating parameters for configuring a processor.
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
HcalVetoProcessor(const std::string &name, framework::Process &process)
Constructor.
double total_pe_threshold_
Total PE threshold.
float max_time_
Maximum hit time that should be considered by the veto.
void configure(framework::config::Parameters ¶meters) override
Configure the processor using the given user specified parameters.
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.
float back_min_pe_
The minimum number of PE in both bars needed for a hit to be considered in double ended readout mode.
void produce(framework::Event &event) override
Run the processor and create a collection of results which indicate if the event passes/fails the Hca...
Stores reconstructed hit information from the HCAL.
void setSection(int section)
Set the section for this hit.
void setEnd(int end)
Set the end (0 neg, 1 pos_ side).
void setToaNeg(double toaNeg)
Set toa of the negative end.
void clear()
Clear the data in the object.
void setTimeDiff(double timeDiff)
Set time difference (uncorrected)
void setMinPE(float minpe)
Set the minimum number of photoelectrons estimated for this hit.
void setToaPos(double toaPos)
Set toa of the positive end.
void setAmplitudeNeg(double amplitudeNeg)
Set amplitude of the negative end.
void setStrip(int strip)
Set the strip for this hit.
void setAmplitudePos(double amplitudePos)
Set amplitude of the positive end.
void setLayer(int layer)
Set the layer for this hit.
void setPE(float pe)
Set the number of photoelectrons estimated for this hit.
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