14 fit_res_c_ = ps.
get<
double>(
"fit_res_C");
15 fit_res_k_ = ps.
get<
double>(
"fit_res_K");
16 input_pass_name_ = ps.
get<std::string>(
"input_pass_name",
"");
18 ps.
get<std::string>(
"track_collection",
"RecoilTruthSeeds");
20 ldmx_log(info) <<
"Track Collection used for TrackDeDxMassEstimator "
25 if (!event.
exists(track_collection_, input_pass_name_)) {
26 ldmx_log(error) <<
"Track collection " << track_collection_ <<
"_"
27 << input_pass_name_ <<
" not in event, exiting...";
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_, input_pass_name_)) {
50 ldmx_log(error) <<
" SimHit collection (" << simhit_collection_ <<
"_"
51 << input_pass_name_ <<
") does not exists, exiting...";
57 std::vector<ldmx::TrackDeDxMassEstimate> mass_estimates;
60 for (uint i = 0; i < tracks.size(); i++) {
61 auto track = tracks.at(i);
63 auto the_qo_p = track.getQoP();
65 ldmx_log(debug) <<
"Track " << i <<
"has zero q/p ";
69 int pdg_id = track.getPdgID();
70 float momentum = 1. / std::abs(the_qo_p) * 1000;
71 ldmx_log(debug) <<
"Track " << i <<
" has momentum " << momentum;
75 float sum_d_edx_inv2 = 0.;
78 for (
auto hit : simhits) {
80 if (hit.getTrackID() != track.getTrackID())
continue;
81 if (hit.getEdep() >= 0 && hit.getPathLength() > 0) {
82 d_edx = hit.getEdep() / hit.getPathLength() * 10;
83 sum_d_edx_inv2 += 1. / (d_edx * d_edx);
88 if (sum_d_edx_inv2 == 0) {
89 ldmx_log(debug) <<
"Track " << i <<
" has no dEdx measurements";
94 float the_ih = 1. / sqrt(1. / n_simhits * sum_d_edx_inv2);
97 if (the_ih > fit_res_c_) {
98 mass = momentum * sqrt((the_ih - fit_res_c_) / fit_res_k_);
100 ldmx_log(info) <<
"Track " << i <<
" has Ih " << the_ih
101 <<
" which is less than fit_res_C " << fit_res_c_;
106 mass_est.
setIh(the_ih);
111 mass_estimates.push_back(mass_est);
115 event.add(
"TrackDeDxMassEstimate", mass_estimates);
#define DECLARE_PRODUCER(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.
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
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 setPdgId(int pdg_id)
Set the PDG ID of the track.
void setIh(float the_ih)
Set the Ih of the particle/track.
void setMomentum(float momentum)
Set the momentum 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.