Process the event and put new data products into it.
37 {
39
41 ldmx::EcalGeometry::CONDITIONS_OBJECT_NAME);
42
43
44 const auto ecal_rec_hits =
event.getCollection<
ldmx::EcalHit>(
45 rec_coll_name_, ecal_rec_hits_passname_);
46 auto nhits = std::count_if(
47 ecal_rec_hits.begin(), ecal_rec_hits.end(),
48 [](
const ldmx::EcalHit& hit) { return hit.getEnergy() > 0; });
49
50
51 ldmx_log(debug) <<
"nhits = " << nhits <<
" MAX_NUM_HITS = " <<
MAX_NUM_HITS;
53 std::array<double, 3> etraj = {-999., -999., -999.};
54 std::array<double, 3> enorm = {-999., -999., -999.};
55
57
58 if (!recoil_from_tracking_ &&
59 event.
exists(ecal_sp_coll_name_, ecal_sp_hits_passname_)) {
61 ecal_sp_coll_name_, ecal_sp_hits_passname_);
62 double electron_pz_max = -1.0;
63 for (auto const& hit : ecal_sp_hits) {
64
65 if (hit.getPdgID() != 11) continue;
66 double electron_z = hit.getPosition()[2];
67
68 if (electron_z <= 239.0 || electron_z >= 240.0) continue;
69 double electron_pz = hit.getMomentum()[2];
70
71 if (electron_pz > electron_pz_max) {
72 electron_pz_max = electron_pz;
73 electron_hit = &hit;
74 }
75 }
76
77 if (electron_hit) {
78
79 ldmx_log(debug) << "Electron Found in the Ecal SP!";
82 ldmx_log(debug) << "ECAL SP pos_=(" << pos[0] << "," << pos[1] << ","
83 << pos[2] << ")";
84 ldmx_log(debug) << "ECAL SP mom=(" << mom[0] << "," << mom[1] << ","
85 << mom[2] << ")";
86 etraj = {pos[0], pos[1], pos[2]};
87 double pz = mom[2];
88 if (pz != 0) {
89
90 enorm = {mom[0] / pz, mom[1] / pz, 1.0};
91 }
92 }
93 } else if (recoil_from_tracking_) {
94
95 auto recoil_tracks{
event.getCollection<
ldmx::Track>(track_collection_,
96 track_pass_name_)};
97 ldmx::TrackStateType ts_at_ecal = ldmx::TrackStateType::AtECAL;
98 auto recoil_track_states_ecal =
100 if (!recoil_track_states_ecal.empty()) {
101 std::array<double, 3> pos = {recoil_track_states_ecal[0],
102 recoil_track_states_ecal[1],
103 recoil_track_states_ecal[2]};
104 std::array<double, 3> mom = {(recoil_track_states_ecal[3]),
105 (recoil_track_states_ecal[4]),
106 (recoil_track_states_ecal[5])};
107 ldmx_log(debug) << "Electron track pos_=(" << pos[0] << "," << pos[1]
108 << "," << pos[2] << ")";
109 ldmx_log(debug) << "Electron track mom=(" << mom[0] << "," << mom[1]
110 << "," << mom[2] << ")";
111 etraj = pos;
112 double pz = mom[2];
113 if (pz != 0) {
114 enorm = {mom[0] / pz, mom[1] / pz, 1.0};
115 }
116 } else {
117 ldmx_log(info) << " No recoil track at ECAL";
118 }
119 } else {
120 ldmx_log(fatal) << " No electron hit at scoring plane or no tracking";
121 }
122
123
124 makeInputs(ecal_geometry, ecal_rec_hits, etraj, enorm);
125
126 auto logits = rt_->run(INPUT_NAMES, data_)[0];
127
128
129 auto prob = std::exp((
logSoftmax(logits)[1]));
130 result.setDiscValue(prob);
131 } else {
132 result.setDiscValue(-99);
133 }
134
135 ldmx_log(debug) << "ParticleNet disc value = " << result.getDisc();
136
137 result.setVetoResult(result.getDisc() > disc_cut_);
138
139
142 } else {
144 }
145
147}
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.
std::vector< float > logSoftmax(const std::vector< float > &logits)
Transform logits to a probability.
void makeInputs(const ldmx::EcalGeometry &geom, const std::vector< ldmx::EcalHit > &ecalRecHits, std::array< double, 3 > etraj, std::array< double, 3 > enorm)
Make inputs to the DNN from ECAL RecHits.
const T & getCondition(const std::string &condition_name)
Access a conditions object for the current event.
void setStorageHint(framework::StorageControl::Hint hint)
Mark the current event as having the given storage control hint from this module_.
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.
Stores reconstructed hit information from the ECAL.
bool passesVeto() const
Checks if the event passes the Ecal veto.
Represents a simulated tracker hit in the simulation.
std::vector< float > getPosition() const
Get the XYZ position of the hit [mm].
std::vector< double > getMomentum() const
Get the XYZ momentum of the particle at the position at which the hit took place [MeV].
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