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

Public Attributes

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

Private Attributes

std::string sim_particles_passname_
 
std::string input_collection_events_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

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.
virtual void process(Event &event) final
Processing an event for a Producer is calling produce.

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 input_collection_ = parameters.get<std::string>("input_collection");
12 input_pass_name_ = parameters.get<std::string>("input_pass_name");
13 output_collection_ = parameters.get<std::string>("output_collection");
14 sim_particles_passname_ =
15 parameters.get<std::string>("sim_particles_passname");
16 input_collection_events_passname_ =
17 parameters.get<std::string>("input_collection_events_passname");
18
19 verbose_ = parameters.get<bool>("verbose");
20
21 if (verbose_) {
22 ldmx_log(info) << "In TruthHitProducer: configure done!";
23 ldmx_log(info) << "Got parameters: " << "\nInput collection: "
25 << "\nInput pass name: " << input_pass_name_
26 << "\nOutput collection: " << output_collection_
27 << "\nVerbose: " << verbose_;
28 }
29}
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78
std::string input_collection_
Name of the input collection containing the sim hits.
std::string input_pass_name_
Name of the pass that the input collection is on (empty string means take any pass)
bool verbose_
Class to set the verbosity level.
std::string output_collection_
Name of the output collection that will be used to store the selected sim hits.

References framework::config::Parameters::get(), input_collection_, input_pass_name_, output_collection_, 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 31 of file TruthHitProducer.cxx.

31 {
32 // Check if the collection exists. If not, don't bother processing the event.
33 if (!event.exists(input_collection_, input_collection_events_passname_)) {
34 ldmx_log(error) << "No input collection called " << input_collection_
35 << " found; skipping!";
36 return;
37 }
38 // looper over sim hits and aggregate energy depositions for each detID
39 const auto sim_hits{event.getCollection<ldmx::SimCalorimeterHit>(
41 auto particle_map{event.getMap<int, ldmx::SimParticle>(
42 "SimParticles", sim_particles_passname_)};
43
44 std::vector<ldmx::SimCalorimeterHit> truth_beam_electrons;
45
46 // TODO: Convert this to using a for_each and lambda
47 for (const auto &sim_hit : sim_hits) {
48 bool keep{false};
49 // check if hit is from beam electron and, if so, add to output collection
50 for (int i = 0; i < sim_hit.getNumberOfContribs(); i++) {
51 auto contrib = sim_hit.getContrib(i);
52 if (verbose_) {
53 ldmx_log(debug) << "contrib " << i << " trackID: " << contrib.track_id_
54 << " pdgID: " << contrib.pdg_code_
55 << " edep: " << contrib.edep_;
56 ldmx_log(debug) << "\t particle id: "
57 << particle_map[contrib.track_id_].getPdgID()
58 << " particle status: "
59 << particle_map[contrib.track_id_].getGenStatus();
60 }
61 // if the trackID is in the map
62 if (particle_map.find(contrib.track_id_) != particle_map.end()) {
63 // beam electron (PDGID = 11, genStatus == 1)
64 if (particle_map[contrib.track_id_].getPdgID() == 11 &&
65 particle_map[contrib.track_id_].getGenStatus() == 1) {
66 keep = true;
67 }
68 }
69 if (keep) truth_beam_electrons.push_back(sim_hit);
70 }
71 }
72 event.add(output_collection_, truth_beam_electrons);
73}
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(), input_collection_, input_pass_name_, output_collection_, and verbose_.

Member Data Documentation

◆ input_collection_

std::string trigscint::TruthHitProducer::input_collection_

Name of the input collection containing the sim hits.

Definition at line 60 of file TruthHitProducer.h.

Referenced by configure(), and produce().

◆ input_collection_events_passname_

std::string trigscint::TruthHitProducer::input_collection_events_passname_
private

Definition at line 72 of file TruthHitProducer.h.

◆ input_pass_name_

std::string trigscint::TruthHitProducer::input_pass_name_

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

◆ output_collection_

std::string trigscint::TruthHitProducer::output_collection_

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

◆ sim_particles_passname_

std::string trigscint::TruthHitProducer::sim_particles_passname_
private

Definition at line 71 of file TruthHitProducer.h.

◆ 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: