LDMX Software
recon::TrackDeDxMassEstimator Class Reference

Public Member Functions

 TrackDeDxMassEstimator (const std::string &name, framework::Process &process)
 
virtual void configure (framework::config::Parameters &ps) override
 Callback for the EventProcessor to configure itself from the given set of parameters.
 
virtual void produce (framework::Event &event) override
 Process the event and put new data products into it.
 
- Public Member Functions inherited from framework::Producer
 Producer (const std::string &name, Process &process)
 Class constructor.
 
virtual void beforeNewRun (ldmx::RunHeader &header)
 Handle allowing producers to modify run headers before the run begins.
 
- Public Member Functions inherited from framework::EventProcessor
 EventProcessor (const std::string &name, Process &process)
 Class constructor.
 
virtual ~EventProcessor ()
 Class destructor.
 
virtual void onNewRun (const ldmx::RunHeader &runHeader)
 Callback for the EventProcessor to take any necessary action when the run being processed changes.
 
virtual void onFileOpen (EventFile &eventFile)
 Callback for the EventProcessor to take any necessary action when a new event input ROOT file is opened.
 
virtual void onFileClose (EventFile &eventFile)
 Callback for the EventProcessor to take any necessary action when a event input ROOT file is closed.
 
virtual void onProcessStart ()
 Callback for the EventProcessor to take any necessary action when the processing of events starts, such as creating histograms.
 
virtual void onProcessEnd ()
 Callback for the EventProcessor to take any necessary action when the processing of events finishes, such as calculating job-summary quantities.
 
template<class T >
const T & getCondition (const std::string &condition_name)
 Access a conditions object for the current event.
 
TDirectory * getHistoDirectory ()
 Access/create a directory in the histogram file for this event processor to create histograms and analysis tuples.
 
void setStorageHint (framework::StorageControl::Hint hint)
 Mark the current event as having the given storage control hint from this module.
 
void setStorageHint (framework::StorageControl::Hint hint, const std::string &purposeString)
 Mark the current event as having the given storage control hint from this module and the given purpose string.
 
int getLogFrequency () const
 Get the current logging frequency from the process.
 
int getRunNumber () const
 Get the run number from the process.
 
std::string getName () const
 Get the processor name.
 
void createHistograms (const std::vector< framework::config::Parameters > &histos)
 Internal function which is used to create histograms passed from the python configuration @parma histos vector of Parameters that configure histograms to create.
 

Private Attributes

float fit_res_C_ {0.}
 
float fit_res_K_ {-9999.}
 
std::string track_collection_
 
std::string simhit_collection_
 
std::string input_pass_name_
 

Additional Inherited Members

- Static Public Member Functions inherited from framework::EventProcessor
static void declare (const std::string &classname, int classtype, EventProcessorMaker *)
 Internal function which is part of the PluginFactory machinery.
 
- Static Public Attributes inherited from framework::Producer
static const int CLASSTYPE {1}
 Constant used to track EventProcessor types by the PluginFactory.
 
- Protected Member Functions inherited from framework::EventProcessor
void abortEvent ()
 Abort the event immediately.
 
- Protected Attributes inherited from framework::EventProcessor
HistogramHelper histograms_
 Interface class for making and filling histograms.
 
NtupleManagerntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger theLog_
 The logger for this EventProcessor.
 

Detailed Description

Definition at line 24 of file TrackDeDxMassEstimator.h.

Constructor & Destructor Documentation

◆ TrackDeDxMassEstimator()

recon::TrackDeDxMassEstimator::TrackDeDxMassEstimator ( const std::string & name,
framework::Process & process )
inline

Definition at line 26 of file TrackDeDxMassEstimator.h.

27 : framework::Producer(name, process) {}
Base class for a module which produces a data product.

Member Function Documentation

◆ configure()

void recon::TrackDeDxMassEstimator::configure ( framework::config::Parameters & parameters)
overridevirtual

Callback for the EventProcessor to configure itself from the given set of parameters.

The parameters a processor has access to are the member variables of the python class in the sequence that has className equal to the EventProcessor class name.

For an example, look at MyProcessor.

Parameters
parametersParameters for configuration.

Reimplemented from framework::EventProcessor.

Definition at line 13 of file TrackDeDxMassEstimator.cxx.

13 {
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", "");
17 track_collection_ =
18 ps.getParameter<std::string>("track_collection", "RecoilTruthSeeds");
19
20 ldmx_log(info) << "Track Collection used for TrackDeDxMassEstimator "
21 << track_collection_;
22}

◆ produce()

void recon::TrackDeDxMassEstimator::produce ( framework::Event & event)
overridevirtual

Process the event and put new data products into it.

Parameters
eventThe Event to process.

Get the hits associated with the truth track

Implements framework::Producer.

Definition at line 24 of file TrackDeDxMassEstimator.cxx.

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 // Retrieve the simhits
49 if (!event.exists(simhit_collection_)) return;
50 auto simhits{event.getCollection<ldmx::SimTrackerHit>(simhit_collection_,
51 input_pass_name_)};
52
53 std::vector<ldmx::TrackDeDxMassEstimate> mass_estimates_;
54
55 // Loop over the collection of tracks
56 for (uint i = 0; i < tracks.size(); i++) {
57 auto track = tracks.at(i);
58 // If track momentum doen't exist, skip
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; // unit: MeV
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 // Check if the hit is associated with the track
75 if (hit.getTrackID() != track.getTrackID()) continue;
76 if (hit.getEdep() >= 0 && hit.getPathLength() > 0) {
77 dEdx = hit.getEdep() / hit.getPathLength() * 10; // unit: MeV/cm
78 sum_dEdx_inv2 += 1. / (dEdx * dEdx);
79 n_simhits++;
80 }
81 } // end of loop over measurements
82
83 if (sum_dEdx_inv2 == 0) {
84 ldmx_log(debug) << "Track " << i << " has no dEdx measurements";
85 continue;
86 }
87
88 // Ih = (1/N * sum_i^N(dE/dx_i)^-2)^-1/2
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
100 mass_est.setMomentum(momentum);
101 mass_est.setIh(theIh);
102 mass_est.setMass(mass);
103 mass_est.setTrackIndex(i);
104 mass_est.setTrackType(track_type);
105 mass_estimates_.push_back(mass_est);
106 }
107
108 // Add the mass estimates to the event
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.
Definition Event.cxx:92
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.
Definition Track.h:53

References framework::Event::exists(), ldmx::TrackDeDxMassEstimate::setIh(), ldmx::TrackDeDxMassEstimate::setMass(), ldmx::TrackDeDxMassEstimate::setMomentum(), ldmx::TrackDeDxMassEstimate::setTrackIndex(), and ldmx::TrackDeDxMassEstimate::setTrackType().

Member Data Documentation

◆ fit_res_C_

float recon::TrackDeDxMassEstimator::fit_res_C_ {0.}
private

Definition at line 34 of file TrackDeDxMassEstimator.h.

34{0.};

◆ fit_res_K_

float recon::TrackDeDxMassEstimator::fit_res_K_ {-9999.}
private

Definition at line 35 of file TrackDeDxMassEstimator.h.

35{-9999.};

◆ input_pass_name_

std::string recon::TrackDeDxMassEstimator::input_pass_name_
private

Definition at line 44 of file TrackDeDxMassEstimator.h.

◆ simhit_collection_

std::string recon::TrackDeDxMassEstimator::simhit_collection_
private

Definition at line 41 of file TrackDeDxMassEstimator.h.

◆ track_collection_

std::string recon::TrackDeDxMassEstimator::track_collection_
private

Definition at line 38 of file TrackDeDxMassEstimator.h.


The documentation for this class was generated from the following files: