14 fit_res_C_ = ps.getParameter<
double>(
"fit_res_C");
15 fit_res_K_ = ps.getParameter<
double>(
"fit_res_K");
16 input_pass_name_ = ps.getParameter<std::string>(
"input_pass_name",
"");
18 ps.getParameter<std::string>(
"track_collection",
"RecoilTruthSeeds");
20 ldmx_log(info) <<
"Track Collection used for TrackDeDxMassEstimator "
25 if (!event.
exists(track_collection_)) {
26 ldmx_log(error) <<
"Track collection " << track_collection_
30 const std::vector<ldmx::Track> tracks{
31 event.getCollection<
ldmx::Track>(track_collection_, input_pass_name_)};
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) {
39 simhit_collection_ =
"TaggerSimHits";
40 }
else if (track_coll_str.find(
"recoil") != std::string::npos) {
42 simhit_collection_ =
"RecoilSimHits";
45 simhit_collection_ =
"";
49 if (!event.
exists(simhit_collection_))
return;
53 std::vector<ldmx::TrackDeDxMassEstimate> mass_estimates_;
56 for (uint i = 0; i < tracks.size(); i++) {
57 auto track = tracks.at(i);
59 auto theQoP = track.getQoP();
61 ldmx_log(debug) <<
"Track " << i <<
"has zero q/p ";
65 float momentum = 1. / std::abs(theQoP) * 1000;
66 ldmx_log(debug) <<
"Track " << i <<
" has momentum " << momentum;
70 float sum_dEdx_inv2 = 0.;
73 for (
auto hit : simhits) {
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);
83 if (sum_dEdx_inv2 == 0) {
84 ldmx_log(debug) <<
"Track " << i <<
" has no dEdx measurements";
89 float theIh = 1. / sqrt(1. / n_simhits * sum_dEdx_inv2);
92 if (theIh > fit_res_C_) {
93 mass = momentum * sqrt((theIh - fit_res_C_) / fit_res_K_);
95 ldmx_log(info) <<
"Track " << i <<
" has Ih " << theIh
96 <<
" which is less than fit_res_C " << fit_res_C_;
101 mass_est.
setIh(theIh);
105 mass_estimates_.push_back(mass_est);
109 event.add(
"TrackDeDxMassEstimate", mass_estimates_);
#define DECLARE_PRODUCER_NS(NS, CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Class that represents the estimated mass of a particle using tracker dE/dx information.
Class that estimates the mass of a particle using tracker dE/dx information.
Implements an event buffer system for storing event data.
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 encapsulating parameters for configuring a processor.
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.
virtual void produce(framework::Event &event) override
Process the event and put new data products into it.
virtual void configure(framework::config::Parameters &ps) override
Callback for the EventProcessor to configure itself from the given set of parameters.