LDMX Software
recon::PFTrackProducer Class Reference

Public Member Functions

 PFTrackProducer (const std::string &name, framework::Process &process)
 
virtual void configure (framework::config::Parameters &ps)
 Callback for the EventProcessor to configure itself from the given set of parameters.
 
virtual void produce (framework::Event &event)
 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 process (Event &event) final
 Processing an event for a Producer is calling produce.
 
- Public Member Functions inherited from framework::EventProcessor
 DECLARE_FACTORY (EventProcessor, EventProcessor *, const std::string &, Process &)
 declare that we have a factory for this class
 
 EventProcessor (const std::string &name, Process &process)
 Class constructor.
 
virtual ~EventProcessor ()=default
 Class destructor.
 
virtual void beforeNewRun (ldmx::RunHeader &run_header)
 Callback for Producers to add parameters to the run header before conditions are initialized.
 
virtual void onNewRun (const ldmx::RunHeader &run_header)
 Callback for the EventProcessor to take any necessary action when the run being processed changes.
 
virtual void onFileOpen (EventFile &event_file)
 Callback for the EventProcessor to take any necessary action when a new event input ROOT file is opened.
 
virtual void onFileClose (EventFile &event_file)
 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

bool truth_tracking_ {true}
 
std::string input_track_coll_name_
 
std::string input_pass_name_
 
std::string output_track_coll_name_
 
bool do_electron_tracking_ {}
 
double min_electron_momentum_z_ {}
 
int max_electron_track_id_ {}
 

Additional Inherited Members

- Protected Member Functions inherited from framework::EventProcessor
void abortEvent ()
 Abort the event immediately.
 
- Protected Attributes inherited from framework::EventProcessor
HistogramPool histograms_
 helper object for making and filling histograms
 
NtupleManagerntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger the_log_
 The logger for this EventProcessor.
 

Detailed Description

Definition at line 21 of file PFTrackProducer.h.

Constructor & Destructor Documentation

◆ PFTrackProducer()

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

Definition at line 23 of file PFTrackProducer.h.

Base class for a module which produces a data product.
virtual void process(Event &event) final
Processing an event for a Producer is calling produce.

Member Function Documentation

◆ configure()

void recon::PFTrackProducer::configure ( framework::config::Parameters & parameters)
virtual

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 8 of file PFTrackProducer.cxx.

8 {
9 input_track_coll_name_ = ps.get<std::string>("inputTrackCollName");
10 input_pass_name_ = ps.get<std::string>("input_pass_name");
11 output_track_coll_name_ = ps.get<std::string>("outputTrackCollName");
12 do_electron_tracking_ = ps.get<bool>("doElectronTracking");
13 min_electron_momentum_z_ = ps.get<double>("minElectronMomentumZ");
14 max_electron_track_id_ = ps.get<int>("maxElectronTrackID");
15}

References framework::config::Parameters::get().

◆ produce()

void recon::PFTrackProducer::produce ( framework::Event & event)
virtual

Process the event and put new data products into it.

Parameters
eventThe Event to process.

Implements framework::Producer.

Definition at line 22 of file PFTrackProducer.cxx.

22 {
23 if (!event.exists(input_track_coll_name_, input_pass_name_)) {
24 ldmx_log(fatal) << "Couldn't find input collection "
25 << input_track_coll_name_ << "_" << input_pass_name_;
26 return;
27 }
28 const auto ecal_sp_hits = event.getCollection<ldmx::SimTrackerHit>(
29 input_track_coll_name_, input_pass_name_);
30
31 std::vector<ldmx::SimTrackerHit> pf_tracks;
32 if (truth_tracking_) {
33 for (const auto& sp_hit : ecal_sp_hits) {
34 if (sp_hit.getPdgID() == 22 || sp_hit.getPdgID() == 2112) continue;
35 if (fabs(240 - sp_hit.getPosition()[2]) > 0.1) continue;
36 if (do_electron_tracking_) { // only select electron SP hits_
37 if (sp_hit.getPdgID() != 11) continue;
38 if (sp_hit.getTrackID() < 2 &&
39 sp_hit.getMomentum()[2] > min_electron_momentum_z_) {
40 // this is almost guaranteed to be a pileup beam electron! keep it
41 pf_tracks.push_back(sp_hit);
42 ldmx_log(debug) << "Added beam electron SP hit: trackID="
43 << sp_hit.getTrackID()
44 << ", pz = " << sp_hit.getMomentum()[2];
45 } else if (sp_hit.getTrackID() <= max_electron_track_id_ &&
46 sp_hit.getMomentum()[2] > 5) {
47 // require more than minimum forward momentum to catch recoil electron
48 // candidates
49 pf_tracks.push_back(sp_hit);
50 ldmx_log(debug) << "Adding SP hit: trackID=" << sp_hit.getTrackID()
51 << ", pdgID= " << sp_hit.getPdgID()
52 << ", pz = " << sp_hit.getMomentum()[2];
53 continue;
54 }
55 } // if electron tracking
56 else {
57 if (sp_hit.getTrackID() != 1 ||
58 fabs(240 - sp_hit.getPosition()[2]) > 0.1 ||
59 sp_hit.getMomentum()[2] < 0)
60 continue;
61 pf_tracks.push_back(sp_hit);
62 ldmx_log(debug) << "Adding SP hit: trackID=" << sp_hit.getTrackID()
63 << ", pdgID= " << sp_hit.getPdgID()
64 << ", pz = " << sp_hit.getMomentum()[2];
65 break;
66 }
67 } // over SP hits_
68 } // do truth tracking
69 std::sort(pf_tracks.begin(), pf_tracks.end(),
71 return getP(a) > getP(b);
72 });
73 event.add(output_track_coll_name_, pf_tracks);
74}
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.

References framework::Event::exists().

Member Data Documentation

◆ do_electron_tracking_

bool recon::PFTrackProducer::do_electron_tracking_ {}
private

Definition at line 41 of file PFTrackProducer.h.

41{};

◆ input_pass_name_

std::string recon::PFTrackProducer::input_pass_name_
private

Definition at line 36 of file PFTrackProducer.h.

◆ input_track_coll_name_

std::string recon::PFTrackProducer::input_track_coll_name_
private

Definition at line 34 of file PFTrackProducer.h.

◆ max_electron_track_id_

int recon::PFTrackProducer::max_electron_track_id_ {}
private

Definition at line 45 of file PFTrackProducer.h.

45{};

◆ min_electron_momentum_z_

double recon::PFTrackProducer::min_electron_momentum_z_ {}
private

Definition at line 43 of file PFTrackProducer.h.

43{};

◆ output_track_coll_name_

std::string recon::PFTrackProducer::output_track_coll_name_
private

Definition at line 38 of file PFTrackProducer.h.

◆ truth_tracking_

bool recon::PFTrackProducer::truth_tracking_ {true}
private

Definition at line 31 of file PFTrackProducer.h.

31{true};

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