21 if (!event.
exists(
"TargetScoringPlaneHits"))
return;
22 if (!event.
exists(
"EcalScoringPlaneHits"))
return;
23 if (!event.
exists(
"SimParticles"))
return;
24 const auto targSpHits =
26 const auto ecalSpHits =
28 const auto particle_map =
31 std::map<int, ldmx::SimParticle> primaries;
33 std::vector<ldmx::SimTrackerHit> atTarget;
34 std::vector<ldmx::SimTrackerHit> atEcal;
35 std::vector<ldmx::SimTrackerHit> atHcal;
36 for (
const auto &pm : particle_map) {
37 const auto &p = pm.second;
39 auto parents = p.getParents();
40 auto parent = parents.at(0);
43 primaries[pm.first] = p;
44 simIDs.insert(pm.first);
47 for (
const auto &spHit : targSpHits) {
48 if (simIDs.count(spHit.getTrackID()) &&
49 fabs(0.18 - spHit.getPosition()[2]) < 0.1 &&
50 spHit.getMomentum()[2] > 0) {
51 atTarget.push_back(spHit);
54 for (
const auto &spHit : ecalSpHits) {
55 if (simIDs.count(spHit.getTrackID()) &&
56 fabs(240 - spHit.getPosition()[2]) < 0.1 &&
57 spHit.getMomentum()[2] > 0) {
58 atEcal.push_back(spHit);
60 if (simIDs.count(spHit.getTrackID()) &&
61 fabs(840 - spHit.getPosition()[2]) < 0.1 &&
62 spHit.getMomentum()[2] > 0) {
63 atHcal.push_back(spHit);
70 event.add(primaryCollName_, primaries);
71 event.add(targetCollName_, atTarget);
72 event.add(ecalCollName_, atEcal);
73 event.add(hcalCollName_, atHcal);
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.