30 if (!event.
exists(
"TargetScoringPlaneHits", target_sp_hits_event_passname_))
32 if (!event.
exists(
"EcalScoringPlaneHits", ecal_sp_hits_event_passname_))
34 if (!event.
exists(
"SimParticles", sim_particles_event_passname_))
return;
36 "TargetScoringPlaneHits", target_sp_passname_);
38 "EcalScoringPlaneHits", ecal_sp_passname_);
40 "SimParticles", sim_particles_passname_);
42 std::map<int, ldmx::SimParticle> primaries;
43 std::set<int> sim_i_ds;
44 std::vector<ldmx::SimTrackerHit> at_target;
45 std::vector<ldmx::SimTrackerHit> at_ecal;
46 std::vector<ldmx::SimTrackerHit> at_hcal;
47 for (
const auto &pm : particle_map) {
48 const auto &p = pm.second;
50 auto parents = p.getParents();
51 auto parent = parents.at(0);
54 primaries[pm.first] = p;
55 sim_i_ds.insert(pm.first);
58 for (
const auto &sp_hit : targ_sp_hits) {
59 if (sim_i_ds.count(sp_hit.getTrackID()) &&
60 fabs(0.18 - sp_hit.getPosition()[2]) < 0.1 &&
61 sp_hit.getMomentum()[2] > 0) {
62 at_target.push_back(sp_hit);
65 for (
const auto &sp_hit : ecal_sp_hits) {
66 if (sim_i_ds.count(sp_hit.getTrackID()) &&
67 fabs(240 - sp_hit.getPosition()[2]) < 0.1 &&
68 sp_hit.getMomentum()[2] > 0) {
69 at_ecal.push_back(sp_hit);
71 if (sim_i_ds.count(sp_hit.getTrackID()) &&
72 fabs(840 - sp_hit.getPosition()[2]) < 0.1 &&
73 sp_hit.getMomentum()[2] > 0) {
74 at_hcal.push_back(sp_hit);
81 event.add(primary_coll_name_, primaries);
82 event.add(target_coll_name_, at_target);
83 event.add(ecal_coll_name_, at_ecal);
84 event.add(hcal_coll_name_, at_hcal);
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.
Class representing a simulated particle.