20 if (!event.
exists(ecal_sp_coll_name_, ecal_sp_pass_name_)) {
21 ldmx_log(debug) <<
"SP collection " << ecal_sp_coll_name_ <<
" not found";
26 ecal_sp_coll_name_, ecal_sp_pass_name_);
28 ldmx_log(debug) <<
"SP hits: " << sp_hits.size();
34 for (
const auto& hit : sp_hits) {
36 if (hit_id.
plane() != 31)
continue;
37 if (hit.getPdgID() != 11)
continue;
38 const auto p = hit.getMomentum();
39 if (p[2] <= 0)
continue;
47 ldmx_log(debug) <<
"No forward electron found at ECal SP";
54 double sp_x = sp_pos[0];
55 double sp_y = sp_pos[1];
57 ldmx_log(debug) <<
"SP electron: trackID=" << sp_electron->
getTrackID()
58 <<
" pos=(" << sp_x <<
", " << sp_y <<
") pz=" << best_pz;
59 double sp_px = sp_mom[0];
60 double sp_py = sp_mom[1];
61 double sp_pz = sp_mom[2];
62 double sp_p = std::sqrt(sp_px * sp_px + sp_py * sp_py + sp_pz * sp_pz);
63 double sp_pt = std::sqrt(sp_px * sp_px + sp_py * sp_py);
64 double sp_theta = std::atan2(sp_pt, sp_pz);
65 double sp_phi = std::atan2(sp_py, sp_px);
66 if (sp_phi < 0) sp_phi += 2.0 * M_PI;
76 if (!event.
exists(track_collection_, track_pass_name_)) {
83 event.getCollection<
ldmx::Track>(track_collection_, track_pass_name_);
85 int n_tracks = tracks.size();
97 for (
int i = 0; i < n_tracks; ++i) {
98 const auto& track = tracks[i];
99 double trk_theta = track.getTheta();
100 double trk_phi = track.getPhi();
103 double dtheta = trk_theta - sp_theta;
104 double dphi = trk_phi - sp_phi;
106 while (dphi > M_PI) dphi -= 2.0 * M_PI;
107 while (dphi < -M_PI) dphi += 2.0 * M_PI;
109 double dr = std::sqrt(dtheta * dtheta + dphi * dphi);
119 const auto& best = tracks[best_idx];
122 double trk_d0 = best.getD0();
123 double trk_phi = best.getPhi();
124 double trk_theta = best.getTheta();
125 double trk_qop = best.getQoP();
126 double trk_p = (std::abs(trk_qop) > 1e-9) ? 1.0 / std::abs(trk_qop) : 0.0;
129 auto perigee = best.getPerigeeLocation();
130 double trk_x = perigee[0] + (-trk_d0 * std::sin(trk_phi));
131 double trk_y = perigee[1] + (trk_d0 * std::cos(trk_phi));
133 ldmx_log(debug) <<
"Track perigee: (" << perigee[0] <<
", " << perigee[1]
134 <<
", " << perigee[2] <<
") d0=" << trk_d0;
135 ldmx_log(debug) <<
"Track pos: (" << trk_x <<
", " << trk_y
136 <<
") p=" << trk_p <<
" theta=" << trk_theta
137 <<
" phi=" << trk_phi;
140 double trk_pt = trk_p * std::sin(trk_theta);
143 double dx = trk_x - sp_x;
144 double dy = trk_y - sp_y;
145 double dtheta = trk_theta - sp_theta;
146 double dphi = trk_phi - sp_phi;
147 while (dphi > M_PI) dphi -= 2.0 * M_PI;
148 while (dphi < -M_PI) dphi += 2.0 * M_PI;
149 double dp = trk_p - sp_p;
150 double dpt = trk_pt - sp_pt;
151 double dp_frac = (sp_p > 1.0) ? dp / sp_p : 0.0;
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.