9 rec_hit_coll_name_ = ps.getParameter<std::string>(
"rec_hit_coll_name");
10 rec_hit_pass_name_ = ps.getParameter<std::string>(
"rec_hit_pass_name");
11 pf_cand_coll_name_ = ps.getParameter<std::string>(
"pf_cand_coll_name");
12 pf_cand_pass_name_ = ps.getParameter<std::string>(
"pf_cand_pass_name");
13 cluster_coll_name_ = ps.getParameter<std::string>(
"cluster_coll_name");
14 cluster_pass_name_ = ps.getParameter<std::string>(
"cluster_pass_name");
15 output_rec_hit_coll_name_ =
16 ps.getParameter<std::string>(
"output_rec_hit_coll_name");
18 min_mom_ = ps.getParameter<
double>(
"min_momentum");
23 if (!event.
exists(rec_hit_coll_name_, rec_hit_pass_name_)) {
24 ldmx_log(error) <<
"Unable to find (one) collection named "
25 << rec_hit_coll_name_ <<
"_" << rec_hit_pass_name_;
28 if (!event.
exists(pf_cand_coll_name_, pf_cand_pass_name_)) {
29 ldmx_log(error) <<
"Unable to find (one) collection named "
30 << pf_cand_coll_name_ <<
"_" << pf_cand_pass_name_;
33 if (!event.
exists(cluster_coll_name_, cluster_pass_name_)) {
34 ldmx_log(error) <<
"Unable to find (one) collection named "
35 << cluster_coll_name_ <<
"_" << cluster_pass_name_;
39 const auto& ecal_hits{
event.getCollection<
ldmx::EcalHit>(rec_hit_coll_name_,
43 pf_cand_coll_name_, pf_cand_pass_name_)};
46 cluster_coll_name_, cluster_pass_name_)};
51 std::vector<ldmx::EcalHit> output_hits;
52 std::vector<unsigned int> pileup_hit_i_ds;
58 for (
const auto& pf_cand : pf_cands) {
59 if (pf_cand.getPID() == 3 || pf_cand.getPID() == 7) {
61 std::vector<float> mom_vec = pf_cand.getTrackPxPyPz();
62 float mom = mom_vec[0] * mom_vec[0] + mom_vec[1] * mom_vec[1] +
63 mom_vec[2] * mom_vec[2];
66 if (mom < min_mom_)
continue;
67 ldmx_log(trace) <<
"Got pileup candidate with PID = " << pf_cand.getPID()
68 <<
" and momentum = " << mom <<
" MeV.";
71 int pf_cl_idx = pf_cand.getEcalIndex();
72 ldmx_log(trace) <<
"Got Ecal cluster with index " << pf_cl_idx
73 <<
" while cluster array length is " << clusters.size();
76 auto cl = clusters[pf_cl_idx];
77 auto hit_i_ds = cl.getHitIDs();
79 pileup_hit_i_ds.insert(pileup_hit_i_ds.end(), hit_i_ds.begin(),
84 for (
auto hit : ecal_hits) {
85 auto found_index = std::find(std::begin(pileup_hit_i_ds),
86 std::end(pileup_hit_i_ds), hit.getID());
89 std::end(pileup_hit_i_ds)) {
90 output_hits.emplace_back(hit);
91 ldmx_log(trace) <<
"Got no-pileup hit! ";
94 event.add(output_rec_hit_coll_name_, output_hits);
bool exists(const std::string &name, const std::string &passName, bool unique=true) const
Check for the existence of an object or collection with the given name and pass name in the event.