LDMX Software
Public Member Functions | Public Attributes | List of all members
trigscint::TruthHitProducer Class Reference

Producer making a collection based on some truth info cuts. More...

#include <TruthHitProducer.h>

Public Member Functions

 TruthHitProducer (const std::string &name, framework::Process &process)
 Constructor.
 
 ~TruthHitProducer ()=default
 Destructor.
 
void configure (framework::config::Parameters &parameters) override
 Configure the processor using the given user specified parameters.
 
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.
 

Public Attributes

bool verbose_ {false}
 Class to set the verbosity level.
 
std::string inputCollection_
 Name of the input collection containing the sim hits.
 
std::string inputPassName_
 Name of the pass that the input collection is on (empty string means take any pass)
 
std::string outputCollection_
 Name of the output collection that will be used to store the selected sim hits.
 

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

Producer making a collection based on some truth info cuts.

Like, skimming out only the beam electrons. This producer creates a new hit collection, that can then be fed to digi etc like anything else.

Definition at line 23 of file TruthHitProducer.h.

Constructor & Destructor Documentation

◆ TruthHitProducer()

trigscint::TruthHitProducer::TruthHitProducer ( const std::string &  name,
framework::Process process 
)

Constructor.

Parameters
nameName for this instance of the class.
processThe Process class associated with EventProcessor, provided by the framework.

Definition at line 6 of file TruthHitProducer.cxx.

8 : Producer(name, process) {}
Producer(const std::string &name, Process &process)
Class constructor.

Member Function Documentation

◆ configure()

void trigscint::TruthHitProducer::configure ( framework::config::Parameters parameters)
overridevirtual

Configure the processor using the given user specified parameters.

The user specified parameters that are availabed are defined in the python configuration class. Look at the my_processor.py module of the EventProc python for the python structure.

Parameters
parametersSet of parameters used to configure this processor.

Reimplemented from framework::EventProcessor.

Definition at line 10 of file TruthHitProducer.cxx.

10 {
11 inputCollection_ = parameters.getParameter<std::string>("input_collection");
12 inputPassName_ = parameters.getParameter<std::string>("input_pass_name");
13 outputCollection_ = parameters.getParameter<std::string>("output_collection");
14 verbose_ = parameters.getParameter<bool>("verbose");
15
16 if (verbose_) {
17 ldmx_log(info) << "In TruthHitProducer: configure done!";
18 ldmx_log(info) << "Got parameters: "
19 << "\nInput collection: " << inputCollection_
20 << "\nInput pass name: " << inputPassName_
21 << "\nOutput collection: " << outputCollection_
22 << "\nVerbose: " << verbose_;
23 }
24}
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:89
std::string inputCollection_
Name of the input collection containing the sim hits.
std::string inputPassName_
Name of the pass that the input collection is on (empty string means take any pass)
std::string outputCollection_
Name of the output collection that will be used to store the selected sim hits.
bool verbose_
Class to set the verbosity level.

References framework::config::Parameters::getParameter(), inputCollection_, inputPassName_, outputCollection_, and verbose_.

◆ produce()

void trigscint::TruthHitProducer::produce ( framework::Event event)
overridevirtual

Process the event and put new data products into it.

Parameters
eventThe event to process.

Implements framework::Producer.

Definition at line 26 of file TruthHitProducer.cxx.

26 {
27 // Check if the collection exists. If not, don't bother processing the event.
28 if (!event.exists(inputCollection_)) {
29 ldmx_log(error) << "No input collection called " << inputCollection_
30 << " found; skipping!";
31 return;
32 }
33 // looper over sim hits and aggregate energy depositions for each detID
34 const auto simHits{event.getCollection<ldmx::SimCalorimeterHit>(
36 auto particleMap{event.getMap<int, ldmx::SimParticle>("SimParticles")};
37
38 std::vector<ldmx::SimCalorimeterHit> truthBeamElectrons;
39
40 // TODO: Convert this to using a for_each and lambda
41 for (const auto &simHit : simHits) {
42 bool keep{false};
43 // check if hit is from beam electron and, if so, add to output collection
44 for (int i = 0; i < simHit.getNumberOfContribs(); i++) {
45 auto contrib = simHit.getContrib(i);
46 if (verbose_) {
47 ldmx_log(debug) << "contrib " << i << " trackID: " << contrib.trackID
48 << " pdgID: " << contrib.pdgCode
49 << " edep: " << contrib.edep;
50 ldmx_log(debug) << "\t particle id: "
51 << particleMap[contrib.trackID].getPdgID()
52 << " particle status: "
53 << particleMap[contrib.trackID].getGenStatus();
54 }
55 // if the trackID is in the map
56 if (particleMap.find(contrib.trackID) != particleMap.end()) {
57 // beam electron (PDGID = 11, genStatus == 1)
58 if (particleMap[contrib.trackID].getPdgID() == 11 &&
59 particleMap[contrib.trackID].getGenStatus() == 1) {
60 keep = true;
61 }
62 }
63 if (keep) truthBeamElectrons.push_back(simHit);
64 }
65 }
66 event.add(outputCollection_, truthBeamElectrons);
67}
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
Stores simulated calorimeter hit information.
Class representing a simulated particle.
Definition SimParticle.h:23

References framework::Event::exists(), inputCollection_, inputPassName_, outputCollection_, and verbose_.

Member Data Documentation

◆ inputCollection_

std::string trigscint::TruthHitProducer::inputCollection_

Name of the input collection containing the sim hits.

Definition at line 60 of file TruthHitProducer.h.

Referenced by configure(), and produce().

◆ inputPassName_

std::string trigscint::TruthHitProducer::inputPassName_

Name of the pass that the input collection is on (empty string means take any pass)

Definition at line 64 of file TruthHitProducer.h.

Referenced by configure(), and produce().

◆ outputCollection_

std::string trigscint::TruthHitProducer::outputCollection_

Name of the output collection that will be used to store the selected sim hits.

Definition at line 68 of file TruthHitProducer.h.

Referenced by configure(), and produce().

◆ verbose_

bool trigscint::TruthHitProducer::verbose_ {false}

Class to set the verbosity level.

Definition at line 57 of file TruthHitProducer.h.

57{false};

Referenced by configure(), and produce().


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