LDMX Software
Public Member Functions | Private Attributes | List of all members
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 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

std::string primaryCollName_
 
std::string targetCollName_
 
std::string ecalCollName_
 
std::string hcalCollName_
 

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

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

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 primaryCollName_ = ps.getParameter<std::string>("outputPrimaryCollName");
10 targetCollName_ = ps.getParameter<std::string>("outputTargetCollName");
11 ecalCollName_ = ps.getParameter<std::string>("outputEcalCollName");
12 hcalCollName_ = ps.getParameter<std::string>("outputHcalCollName");
13}

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

◆ 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 20 of file PFTruthProducer.cxx.

20 {
21 if (!event.exists("TargetScoringPlaneHits")) return;
22 if (!event.exists("EcalScoringPlaneHits")) return;
23 if (!event.exists("SimParticles")) return;
24 const auto targSpHits =
25 event.getCollection<ldmx::SimTrackerHit>("TargetScoringPlaneHits");
26 const auto ecalSpHits =
27 event.getCollection<ldmx::SimTrackerHit>("EcalScoringPlaneHits");
28 const auto particle_map =
29 event.getMap<int, ldmx::SimParticle>("SimParticles");
30
31 std::map<int, ldmx::SimParticle> primaries;
32 std::set<int> simIDs;
33 std::vector<ldmx::SimTrackerHit> atTarget;
34 std::vector<ldmx::SimTrackerHit> atEcal;
35 std::vector<ldmx::SimTrackerHit> atHcal;
36 for (const auto &pm : particle_map) {
37 const auto &p = pm.second;
38 // the only parent of a primary is "track 0"
39 if (p.getParents().size() == 1 && p.getParents()[0] == 0) {
40 primaries[pm.first] = p;
41 simIDs.insert(pm.first);
42 }
43 }
44 for (const auto &spHit : targSpHits) {
45 if (simIDs.count(spHit.getTrackID()) &&
46 fabs(0.18 - spHit.getPosition()[2]) < 0.1 &&
47 spHit.getMomentum()[2] > 0) {
48 atTarget.push_back(spHit);
49 }
50 }
51 for (const auto &spHit : ecalSpHits) {
52 if (simIDs.count(spHit.getTrackID()) &&
53 fabs(240 - spHit.getPosition()[2]) < 0.1 &&
54 spHit.getMomentum()[2] > 0) {
55 atEcal.push_back(spHit);
56 }
57 if (simIDs.count(spHit.getTrackID()) &&
58 fabs(840 - spHit.getPosition()[2]) < 0.1 &&
59 spHit.getMomentum()[2] > 0) {
60 atHcal.push_back(spHit);
61 }
62 }
63 // sortHits(primaries); // use map instead
64 sortHits(atTarget);
65 sortHits(atEcal);
66 sortHits(atHcal);
67 event.add(primaryCollName_, primaries);
68 event.add(targetCollName_, atTarget);
69 event.add(ecalCollName_, atEcal);
70 event.add(hcalCollName_, atHcal);
71}
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

◆ ecalCollName_

std::string recon::PFTruthProducer::ecalCollName_
private

Definition at line 34 of file PFTruthProducer.h.

◆ hcalCollName_

std::string recon::PFTruthProducer::hcalCollName_
private

Definition at line 35 of file PFTruthProducer.h.

◆ primaryCollName_

std::string recon::PFTruthProducer::primaryCollName_
private

Definition at line 32 of file PFTruthProducer.h.

◆ targetCollName_

std::string recon::PFTruthProducer::targetCollName_
private

Definition at line 33 of file PFTruthProducer.h.


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