Process the event and put new data products into it.
24 {
25 if (!event.
exists(track_collection_)) {
26 ldmx_log(error) << "Track collection " << track_collection_
27 << " not in event";
28 return;
29 }
30 const std::vector<ldmx::Track> tracks{
31 event.getCollection<
ldmx::Track>(track_collection_, input_pass_name_)};
32
33 int track_type;
34 std::string track_coll_str = track_collection_;
35 std::transform(track_coll_str.begin(), track_coll_str.end(),
36 track_coll_str.begin(), ::tolower);
37 if (track_coll_str.find("tagger") != std::string::npos) {
38 track_type = 1;
39 simhit_collection_ = "TaggerSimHits";
40 } else if (track_coll_str.find("recoil") != std::string::npos) {
41 track_type = 2;
42 simhit_collection_ = "RecoilSimHits";
43 } else {
44 track_type = 0;
45 simhit_collection_ = "";
46 }
47
48
49 if (!event.
exists(simhit_collection_))
return;
51 input_pass_name_)};
52
53 std::vector<ldmx::TrackDeDxMassEstimate> mass_estimates_;
54
55
56 for (uint i = 0; i < tracks.size(); i++) {
57 auto track = tracks.at(i);
58
59 auto theQoP = track.getQoP();
60 if (theQoP == 0) {
61 ldmx_log(debug) << "Track " << i << "has zero q/p ";
62 continue;
63 }
64
65 float momentum = 1. / std::abs(theQoP) * 1000;
66 ldmx_log(debug) << "Track " << i << " has momentum " << momentum;
67
70 float sum_dEdx_inv2 = 0.;
71 float dEdx;
72 float n_simhits = 0;
73 for (auto hit : simhits) {
74
75 if (hit.getTrackID() != track.getTrackID()) continue;
76 if (hit.getEdep() >= 0 && hit.getPathLength() > 0) {
77 dEdx = hit.getEdep() / hit.getPathLength() * 10;
78 sum_dEdx_inv2 += 1. / (dEdx * dEdx);
79 n_simhits++;
80 }
81 }
82
83 if (sum_dEdx_inv2 == 0) {
84 ldmx_log(debug) << "Track " << i << " has no dEdx measurements";
85 continue;
86 }
87
88
89 float theIh = 1. / sqrt(1. / n_simhits * sum_dEdx_inv2);
90
91 float mass = 0.;
92 if (theIh > fit_res_C_) {
93 mass = momentum * sqrt((theIh - fit_res_C_) / fit_res_K_);
94 } else {
95 ldmx_log(info) << "Track " << i << " has Ih " << theIh
96 << " which is less than fit_res_C " << fit_res_C_;
97 mass = -100.;
98 }
99
101 mass_est.
setIh(theIh);
105 mass_estimates_.push_back(mass_est);
106 }
107
108
109 event.add("TrackDeDxMassEstimate", mass_estimates_);
110}
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.
Represents a simulated tracker hit in the simulation.
Represents the estimated mass of a particle using tracker dE/dx information.
void setTrackType(int track_type)
Set the type of the track.
void setMomentum(float momentum)
Set the momentum of the particle/track.
void setIh(float theIh)
Set the Ih of the particle/track.
void setMass(float mass)
Set the estimated mass of the particle/track.
void setTrackIndex(int track_index)
Set the index of the track.
Implementation of a track object.