Process the event and put new data products into it.
36 {
38
40 ldmx::EcalGeometry::CONDITIONS_OBJECT_NAME);
41
42
43 const auto ecal_rec_hits =
event.getCollection<
ldmx::EcalHit>(
44 rec_coll_name_, ecal_rec_hits_passname_);
45 auto nhits = std::count_if(
46 ecal_rec_hits.begin(), ecal_rec_hits.end(),
47 [](
const ldmx::EcalHit& hit) { return hit.getEnergy() > 0; });
48
49
50 ldmx_log(debug) <<
"nhits = " << nhits <<
" MAX_NUM_HITS = " <<
MAX_NUM_HITS;
52 std::array<double, 3> etraj = {-999., -999., -999.};
53 std::array<double, 3> enorm = {-999., -999., -999.};
54
56
57 if (!recoil_from_tracking_ &&
58 event.
exists(
"EcalScoringPlaneHits", ecal_sp_hits_passname_)) {
60 "EcalScoringPlaneHits", ecal_sp_hits_passname_);
61 double electron_pz_max = -1.0;
62 for (auto const& hit : ecal_sp_hits) {
63
64 if (hit.getPdgID() != 11) continue;
65 double electron_z = hit.getPosition()[2];
66
67 if (electron_z <= 239.0 || electron_z >= 240.0) continue;
68 double electron_pz = hit.getMomentum()[2];
69
70 if (electron_pz > electron_pz_max) {
71 electron_pz_max = electron_pz;
72 electron_hit = &hit;
73 }
74 }
75
76 if (electron_hit) {
77
78 ldmx_log(debug) << "Electron Found in the Ecal SP!";
81 ldmx_log(debug) << "ECAL SP pos_=(" << pos[0] << "," << pos[1] << ","
82 << pos[2] << ")";
83 ldmx_log(debug) << "ECAL SP mom=(" << mom[0] << "," << mom[1] << ","
84 << mom[2] << ")";
85 etraj = {pos[0], pos[1], pos[2]};
86 double pz = mom[2];
87 if (pz != 0) {
88
89 enorm = {mom[0] / pz, mom[1] / pz, 1.0};
90 }
91 }
92 } else if (recoil_from_tracking_) {
93
94 auto recoil_tracks{
event.getCollection<
ldmx::Track>(track_collection_,
95 track_pass_name_)};
96 ldmx::TrackStateType ts_at_ecal = ldmx::TrackStateType::AtECAL;
97 auto recoil_track_states_ecal =
99 if (!recoil_track_states_ecal.empty()) {
100 std::array<double, 3> pos = {recoil_track_states_ecal[0],
101 recoil_track_states_ecal[1],
102 recoil_track_states_ecal[2]};
103 std::array<double, 3> mom = {(recoil_track_states_ecal[3]),
104 (recoil_track_states_ecal[4]),
105 (recoil_track_states_ecal[5])};
106 ldmx_log(debug) << "Electron track pos_=(" << pos[0] << "," << pos[1]
107 << "," << pos[2] << ")";
108 ldmx_log(debug) << "Electron track mom=(" << mom[0] << "," << mom[1]
109 << "," << mom[2] << ")";
110 etraj = pos;
111 double pz = mom[2];
112 if (pz != 0) {
113 enorm = {mom[0] / pz, mom[1] / pz, 1.0};
114 }
115 } else {
116 ldmx_log(info) << " No recoil track at ECAL";
117 }
118 } else {
119 ldmx_log(fatal) << " No electron hit at scoring plane or no tracking";
120 }
121
122
123 makeInputs(ecal_geometry, ecal_rec_hits, etraj, enorm);
124
125 auto logits = rt_->run(INPUT_NAMES, data_)[0];
126
127
128 auto prob = std::exp((
logSoftmax(logits)[1]));
129 result.setDiscValue(prob);
130 } else {
131 result.setDiscValue(-99);
132 }
133
134 ldmx_log(debug) << "ParticleNet disc value = " << result.getDisc();
135
136 result.setVetoResult(result.getDisc() > disc_cut_);
137
138
141 } else {
143 }
144
146}
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