LDMX Software
recon::PFTruthProducer Class Reference

Public Member Functions

 PFTruthProducer (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

std::string primary_coll_name_
 
std::string target_coll_name_
 
std::string ecal_coll_name_
 
std::string hcal_coll_name_
 
std::string target_sp_passname_
 
std::string ecal_sp_passname_
 
std::string sim_particles_passname_
 
std::string target_sp_hits_event_passname_
 
std::string ecal_sp_hits_event_passname_
 
std::string sim_particles_event_passname_
 

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 PFTruthProducer.h.

Constructor & Destructor Documentation

◆ PFTruthProducer()

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

Definition at line 23 of file PFTruthProducer.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::PFTruthProducer::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 PFTruthProducer.cxx.

8 {
9 primary_coll_name_ = ps.get<std::string>("outputPrimaryCollName");
10 target_coll_name_ = ps.get<std::string>("outputTargetCollName");
11 ecal_coll_name_ = ps.get<std::string>("outputEcalCollName");
12 hcal_coll_name_ = ps.get<std::string>("outputHcalCollName");
13 target_sp_passname_ = ps.get<std::string>("target_sp_passname");
14 ecal_sp_passname_ = ps.get<std::string>("ecal_sp_passname");
15 sim_particles_passname_ = ps.get<std::string>("sim_particles_passname");
16 sim_particles_event_passname_ =
17 ps.get<std::string>("sim_particles_event_passname");
18 ecal_sp_hits_event_passname_ =
19 ps.get<std::string>("ecal_sp_hits_event_passname");
20 target_sp_hits_event_passname_ =
21 ps.get<std::string>("target_sp_hits_event_passname");
22}

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

◆ produce()

void recon::PFTruthProducer::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 29 of file PFTruthProducer.cxx.

29 {
30 if (!event.exists("TargetScoringPlaneHits", target_sp_hits_event_passname_))
31 return;
32 if (!event.exists("EcalScoringPlaneHits", ecal_sp_hits_event_passname_))
33 return;
34 if (!event.exists("SimParticles", sim_particles_event_passname_)) return;
35 const auto targ_sp_hits = event.getCollection<ldmx::SimTrackerHit>(
36 "TargetScoringPlaneHits", target_sp_passname_);
37 const auto ecal_sp_hits = event.getCollection<ldmx::SimTrackerHit>(
38 "EcalScoringPlaneHits", ecal_sp_passname_);
39 const auto particle_map = event.getMap<int, ldmx::SimParticle>(
40 "SimParticles", sim_particles_passname_);
41
42 std::map<int, ldmx::SimParticle> primaries;
43 std::set<int> sim_i_ds;
44 std::vector<ldmx::SimTrackerHit> at_target;
45 std::vector<ldmx::SimTrackerHit> at_ecal;
46 std::vector<ldmx::SimTrackerHit> at_hcal;
47 for (const auto &pm : particle_map) {
48 const auto &p = pm.second;
49 // sim particles only ever have exactly one parent
50 auto parents = p.getParents();
51 auto parent = parents.at(0);
52 // the parent of a primary is "track 0"
53 if (parent == 0) {
54 primaries[pm.first] = p;
55 sim_i_ds.insert(pm.first);
56 }
57 }
58 for (const auto &sp_hit : targ_sp_hits) {
59 if (sim_i_ds.count(sp_hit.getTrackID()) &&
60 fabs(0.18 - sp_hit.getPosition()[2]) < 0.1 &&
61 sp_hit.getMomentum()[2] > 0) {
62 at_target.push_back(sp_hit);
63 }
64 }
65 for (const auto &sp_hit : ecal_sp_hits) {
66 if (sim_i_ds.count(sp_hit.getTrackID()) &&
67 fabs(240 - sp_hit.getPosition()[2]) < 0.1 &&
68 sp_hit.getMomentum()[2] > 0) {
69 at_ecal.push_back(sp_hit);
70 }
71 if (sim_i_ds.count(sp_hit.getTrackID()) &&
72 fabs(840 - sp_hit.getPosition()[2]) < 0.1 &&
73 sp_hit.getMomentum()[2] > 0) {
74 at_hcal.push_back(sp_hit);
75 }
76 }
77 // sortHits(primaries); // use map instead
78 sortHits(at_target);
79 sortHits(at_ecal);
80 sortHits(at_hcal);
81 event.add(primary_coll_name_, primaries);
82 event.add(target_coll_name_, at_target);
83 event.add(ecal_coll_name_, at_ecal);
84 event.add(hcal_coll_name_, at_hcal);
85}
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
Class representing a simulated particle.
Definition SimParticle.h:23
Represents a simulated tracker hit in the simulation.

References framework::Event::exists().

Member Data Documentation

◆ ecal_coll_name_

std::string recon::PFTruthProducer::ecal_coll_name_
private

Definition at line 35 of file PFTruthProducer.h.

◆ ecal_sp_hits_event_passname_

std::string recon::PFTruthProducer::ecal_sp_hits_event_passname_
private

Definition at line 41 of file PFTruthProducer.h.

◆ ecal_sp_passname_

std::string recon::PFTruthProducer::ecal_sp_passname_
private

Definition at line 38 of file PFTruthProducer.h.

◆ hcal_coll_name_

std::string recon::PFTruthProducer::hcal_coll_name_
private

Definition at line 36 of file PFTruthProducer.h.

◆ primary_coll_name_

std::string recon::PFTruthProducer::primary_coll_name_
private

Definition at line 33 of file PFTruthProducer.h.

◆ sim_particles_event_passname_

std::string recon::PFTruthProducer::sim_particles_event_passname_
private

Definition at line 42 of file PFTruthProducer.h.

◆ sim_particles_passname_

std::string recon::PFTruthProducer::sim_particles_passname_
private

Definition at line 39 of file PFTruthProducer.h.

◆ target_coll_name_

std::string recon::PFTruthProducer::target_coll_name_
private

Definition at line 34 of file PFTruthProducer.h.

◆ target_sp_hits_event_passname_

std::string recon::PFTruthProducer::target_sp_hits_event_passname_
private

Definition at line 40 of file PFTruthProducer.h.

◆ target_sp_passname_

std::string recon::PFTruthProducer::target_sp_passname_
private

Definition at line 37 of file PFTruthProducer.h.


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