14 rec_hit_coll_name_ = ps.getParameter<std::string>(
"rec_hit_coll_name");
15 rec_hit_pass_name_ = ps.getParameter<std::string>(
"rec_hit_pass_name");
16 pf_cand_coll_name_ = ps.getParameter<std::string>(
"pf_cand_coll_name");
17 pf_cand_pass_name_ = ps.getParameter<std::string>(
"pf_cand_pass_name");
18 cluster_coll_name_ = ps.getParameter<std::string>(
"cluster_coll_name");
19 cluster_pass_name_ = ps.getParameter<std::string>(
"cluster_pass_name");
20 output_rec_hit_coll_name_ =
21 ps.getParameter<std::string>(
"output_rec_hit_coll_name");
23 min_mom_ = ps.getParameter<
double>(
"min_momentum");
28 if (!event.
exists(rec_hit_coll_name_, rec_hit_pass_name_)) {
29 ldmx_log(error) <<
"Unable to find (one) collection named "
30 << rec_hit_coll_name_ <<
"_" << rec_hit_pass_name_;
33 if (!event.
exists(pf_cand_coll_name_, pf_cand_pass_name_)) {
34 ldmx_log(error) <<
"Unable to find (one) collection named "
35 << pf_cand_coll_name_ <<
"_" << pf_cand_pass_name_;
38 if (!event.
exists(cluster_coll_name_, cluster_pass_name_)) {
39 ldmx_log(error) <<
"Unable to find (one) collection named "
40 << cluster_coll_name_ <<
"_" << cluster_pass_name_;
44 const auto& ecal_hits{
event.getCollection<
ldmx::EcalHit>(rec_hit_coll_name_,
48 pf_cand_coll_name_, pf_cand_pass_name_)};
51 cluster_coll_name_, cluster_pass_name_)};
56 std::vector<ldmx::EcalHit> output_hits;
57 std::vector<unsigned int> pileup_hit_i_ds;
63 for (
const auto& pf_cand : pf_cands) {
64 if (pf_cand.getPID() == 3 || pf_cand.getPID() == 7) {
66 std::vector<float> mom_vec = pf_cand.getTrackPxPyPz();
67 float mom = mom_vec[0] * mom_vec[0] + mom_vec[1] * mom_vec[1] +
68 mom_vec[2] * mom_vec[2];
71 if (mom < min_mom_)
continue;
72 ldmx_log(trace) <<
"Got pileup candidate with PID = " << pf_cand.getPID()
73 <<
" and momentum = " << mom <<
" MeV.";
76 int pf_cl_idx = pf_cand.getEcalIndex();
77 ldmx_log(trace) <<
"Got Ecal cluster with index " << pf_cl_idx
78 <<
" while cluster array length is " << clusters.size();
81 auto cl = clusters[pf_cl_idx];
82 auto hit_i_ds = cl.getHitIDs();
84 pileup_hit_i_ds.insert(pileup_hit_i_ds.end(), hit_i_ds.begin(),
89 for (
auto hit : ecal_hits) {
90 auto found_index = std::find(std::begin(pileup_hit_i_ds),
91 std::end(pileup_hit_i_ds), hit.getID());
94 std::end(pileup_hit_i_ds)) {
95 output_hits.emplace_back(hit);
96 ldmx_log(trace) <<
"Got no-pileup hit! ";
99 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.