LDMX Software
dqm::GenieTruthDQM Class Reference

Generate histograms/ntuple to extract genie output info. More...

#include <GenieTruthDQM.h>

Public Member Functions

 GenieTruthDQM (const std::string &name, framework::Process &process)
 Constructor.
 
virtual void configure (framework::config::Parameters &ps)
 Input python configuration parameters.
 
virtual void onProcessStart ()
 Construct histograms/ntuples.
 
virtual void onNewRun (const ldmx::RunHeader &runHeader)
 Grab the run number...
 
virtual void analyze (const framework::Event &event)
 Fills histograms/ntuples.
 
- Public Member Functions inherited from framework::Analyzer
 Analyzer (const std::string &name, Process &process)
 Class constructor.
 
virtual void process (Event &event) final
 Processing an event for an Analyzer is calling analyze.
 
virtual void beforeNewRun (ldmx::RunHeader &run_header) final
 Don't allow Analyzers to add parameters to the run header.
 
- 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 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 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 hepmc3_coll_name_
 Pass Name for genie objects.
 
std::string hepmc3_pass_name_
 
int run_number_
 

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
 
NtupleManager & ntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger the_log_
 The logger for this EventProcessor.
 

Detailed Description

Generate histograms/ntuple to extract genie output info.

Definition at line 18 of file GenieTruthDQM.h.

Constructor & Destructor Documentation

◆ GenieTruthDQM()

dqm::GenieTruthDQM::GenieTruthDQM ( const std::string & name,
framework::Process & process )
inline

Constructor.

Blank Analyzer constructor

Definition at line 25 of file GenieTruthDQM.h.

Base class for a module which does not produce a data product.
virtual void process(Event &event) final
Processing an event for an Analyzer is calling analyze.

Member Function Documentation

◆ analyze()

void dqm::GenieTruthDQM::analyze ( const framework::Event & event)
virtual

Fills histograms/ntuples.

Implements framework::Analyzer.

Definition at line 72 of file GenieTruthDQM.cxx.

72 {
74
75 ntuple_.clear();
76 ntuple_.setVar<int>("run", run_number_);
77 ntuple_.setVar<int>("event", event.getEventNumber());
78
79 auto hepmc3_col = event.getObject<std::vector<ldmx::HepMC3GenEvent> >(
80 hepmc3_coll_name_, hepmc3_pass_name_);
81
82 if (hepmc3_col.size() < 1) {
83 ntuple_.fill();
84 return;
85 }
86
87 auto const& hepmc3_ev = hepmc3_col.at(0).getHepMCGenEvent();
88
89 // set interaction/scattering codes
90 auto interaction_type_ptr = hepmc3_ev.attribute<HepMC3::IntAttribute>(
91 "GENIE.Interaction.InteractionType");
92 if (interaction_type_ptr)
93 ntuple_.setVar<int>("interaction_type", interaction_type_ptr->value());
94 auto scattering_type_ptr = hepmc3_ev.attribute<HepMC3::IntAttribute>(
95 "GENIE.Interaction.ScatteringType");
96 if (scattering_type_ptr)
97 ntuple_.setVar<int>("scattering_type", scattering_type_ptr->value());
98 auto rescatter_code_ptr =
99 hepmc3_ev.attribute<HepMC3::IntAttribute>("GENIE.RescatterCode");
100 if (rescatter_code_ptr)
101 ntuple_.setVar<int>("rescatter_code", rescatter_code_ptr->value());
102
103 // get kinematic vars
104 auto kvar_labels_ptr = hepmc3_ev.attribute<HepMC3::VectorIntAttribute>(
105 "GENIE.Interaction.KineVarLabels");
106 auto kvar_values_ptr = hepmc3_ev.attribute<HepMC3::VectorDoubleAttribute>(
107 "GENIE.Interaction.KineVarValues");
108 if (kvar_labels_ptr && kvar_values_ptr) {
109 auto kvar_labels = kvar_labels_ptr->value();
110 auto kvar_values = kvar_values_ptr->value();
111 for (size_t i = 0; i < kvar_labels.size(); ++i) {
112 if (kvar_labels[i] == genie::EKineVar::kKVSelx)
113 ntuple_.setVar<double>("x_bj", kvar_values[i]);
114 else if (kvar_labels[i] == genie::EKineVar::kKVSely)
115 ntuple_.setVar<double>("y_inel", kvar_values[i]);
116 else if (kvar_labels[i] == genie::EKineVar::kKVSelQ2)
117 ntuple_.setVar<double>("Q2", kvar_values[i]);
118 else if (kvar_labels[i] == genie::EKineVar::kKVSelW)
119 ntuple_.setVar<double>("W", kvar_values[i]);
120 }
121 }
122
123 // electron info
124 auto lep_pdg_ptr =
125 hepmc3_ev.attribute<HepMC3::IntAttribute>("GENIE.Interaction.ProbePDG");
126 if (lep_pdg_ptr) ntuple_.setVar<int>("lep_pdg", lep_pdg_ptr->value());
127
128 auto lep_i_4vec_ptr = hepmc3_ev.attribute<HepMC3::VectorDoubleAttribute>(
129 "GENIE.Interaction.ProbeP4");
130 if (lep_i_4vec_ptr) {
131 auto lep_i_4vec = lep_i_4vec_ptr->value();
132 ntuple_.setVar<double>("lep_i_px", lep_i_4vec[0]);
133 ntuple_.setVar<double>("lep_i_py", lep_i_4vec[1]);
134 ntuple_.setVar<double>("lep_i_pz", lep_i_4vec[2]);
135 ntuple_.setVar<double>("lep_i_e", lep_i_4vec[3]);
136 }
137 auto lep_f_4vec_ptr = hepmc3_ev.attribute<HepMC3::VectorDoubleAttribute>(
138 "GENIE.Interaction.FSLeptonP4");
139 if (lep_f_4vec_ptr) {
140 auto lep_f_4vec = lep_f_4vec_ptr->value();
141 ntuple_.setVar<double>("lep_f_px", lep_f_4vec[0]);
142 ntuple_.setVar<double>("lep_f_py", lep_f_4vec[1]);
143 ntuple_.setVar<double>("lep_f_pz", lep_f_4vec[2]);
144 ntuple_.setVar<double>("lep_f_e", lep_f_4vec[3]);
145 }
146
147 // target info
148 auto tgt_pdg_ptr =
149 hepmc3_ev.attribute<HepMC3::IntAttribute>("GENIE.Interaction.TargetPDG");
150 if (tgt_pdg_ptr) ntuple_.setVar<int>("tgt_pdg", tgt_pdg_ptr->value());
151
152 auto tgt_4vec_ptr = hepmc3_ev.attribute<HepMC3::VectorDoubleAttribute>(
153 "GENIE.Interaction.TargetP4");
154 if (tgt_4vec_ptr) {
155 auto tgt_4vec = tgt_4vec_ptr->value();
156 ntuple_.setVar<double>("tgt_px", tgt_4vec[0]);
157 ntuple_.setVar<double>("tgt_py", tgt_4vec[1]);
158 ntuple_.setVar<double>("tgt_pz", tgt_4vec[2]);
159 ntuple_.setVar<double>("tgt_e", tgt_4vec[3]);
160 }
161
162 // hit nucleon info
163 auto hnuc_pdg_ptr = hepmc3_ev.attribute<HepMC3::IntAttribute>(
164 "GENIE.Interaction.HitNucleonPDG");
165 if (hnuc_pdg_ptr) ntuple_.setVar<int>("hnuc_pdg", hnuc_pdg_ptr->value());
166
167 auto hitnuc_4vec_ptr = hepmc3_ev.attribute<HepMC3::VectorDoubleAttribute>(
168 "GENIE.Interaction.HitNucleonP4");
169 if (hitnuc_4vec_ptr) {
170 auto hitnuc_4vec = hitnuc_4vec_ptr->value();
171 ntuple_.setVar<double>("hnuc_px", hitnuc_4vec[0]);
172 ntuple_.setVar<double>("hnuc_py", hitnuc_4vec[1]);
173 ntuple_.setVar<double>("hnuc_pz", hitnuc_4vec[2]);
174 ntuple_.setVar<double>("hnuc_e", hitnuc_4vec[3]);
175 }
176 // hit quark info
177 // note: it's only there for some interaction types!
178 auto hqrkpdg_ptr = hepmc3_ev.attribute<HepMC3::IntAttribute>(
179 "GENIE.Interaction.HitQuarkPDG");
180 if (hqrkpdg_ptr) ntuple_.setVar<int>("hqrk_pdg", hqrkpdg_ptr->value());
181 auto hqrksea_ptr = hepmc3_ev.attribute<HepMC3::IntAttribute>(
182 "GENIE.Interaction.HitSeaQuark");
183 if (hqrksea_ptr) ntuple_.setVar<int>("hqrk_sea", hqrksea_ptr->value());
184
185 auto hadsys_4vec_ptr = hepmc3_ev.attribute<HepMC3::VectorDoubleAttribute>(
186 "GENIE.Interaction.HadSystP4");
187 if (hadsys_4vec_ptr) {
188 auto hadsys_4vec = hadsys_4vec_ptr->value();
189 ntuple_.setVar<double>("hadsys_px", hadsys_4vec[0]);
190 ntuple_.setVar<double>("hadsys_py", hadsys_4vec[1]);
191 ntuple_.setVar<double>("hadsys_pz", hadsys_4vec[2]);
192 ntuple_.setVar<double>("hadsys_e", hadsys_4vec[3]);
193 }
194 ntuple_.fill();
195
196 return;
197}
std::string hepmc3_coll_name_
Pass Name for genie objects.
NtupleManager & ntuple_
Manager for any ntuples.
TDirectory * getHistoDirectory()
Access/create a directory in the histogram file for this event processor to create histograms and ana...
void clear()
Reset all of the variables to their limits.
void setVar(const std::string &vname, const T &value)
Set the value of the variable named 'vname'.

References framework::NtupleManager::clear(), framework::EventProcessor::getHistoDirectory(), hepmc3_coll_name_, framework::EventProcessor::ntuple_, and framework::NtupleManager::setVar().

◆ configure()

void dqm::GenieTruthDQM::configure ( framework::config::Parameters & ps)
virtual

Input python configuration parameters.

Reimplemented from framework::EventProcessor.

Definition at line 12 of file GenieTruthDQM.cxx.

12 {
13 hepmc3_coll_name_ = ps.get<std::string>("hepmc3_coll_name");
14 hepmc3_pass_name_ = ps.get<std::string>("hepmc3_pass_name");
15 return;
16}
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:75

References framework::config::Parameters::get(), and hepmc3_coll_name_.

◆ onNewRun()

void dqm::GenieTruthDQM::onNewRun ( const ldmx::RunHeader & runHeader)
virtual

Grab the run number...

Reimplemented from framework::EventProcessor.

Definition at line 68 of file GenieTruthDQM.cxx.

68 {
69 run_number_ = runHeader.getRunNumber();
70}
int getRunNumber() const
Definition RunHeader.h:96

References ldmx::RunHeader::getRunNumber().

◆ onProcessStart()

void dqm::GenieTruthDQM::onProcessStart ( )
virtual

Construct histograms/ntuples.

Reimplemented from framework::EventProcessor.

Definition at line 18 of file GenieTruthDQM.cxx.

18 {
20
21 ntuple_.create("genie_truth");
22
23 // event info
24 ntuple_.addVar<int>("genie_truth", "run");
25 ntuple_.addVar<int>("genie_truth", "event");
26
27 ntuple_.addVar<int>("genie_truth", "interaction_type");
28 ntuple_.addVar<int>("genie_truth", "scattering_type");
29 ntuple_.addVar<int>("genie_truth", "rescatter_code");
30
31 ntuple_.addVar<double>("genie_truth", "x_bj");
32 ntuple_.addVar<double>("genie_truth", "y_inel");
33 ntuple_.addVar<double>("genie_truth", "Q2");
34 ntuple_.addVar<double>("genie_truth", "W");
35
36 ntuple_.addVar<int>("genie_truth", "lep_pdg");
37
38 ntuple_.addVar<double>("genie_truth", "lep_i_px");
39 ntuple_.addVar<double>("genie_truth", "lep_i_py");
40 ntuple_.addVar<double>("genie_truth", "lep_i_pz");
41 ntuple_.addVar<double>("genie_truth", "lep_i_e");
42
43 ntuple_.addVar<double>("genie_truth", "lep_f_px");
44 ntuple_.addVar<double>("genie_truth", "lep_f_py");
45 ntuple_.addVar<double>("genie_truth", "lep_f_pz");
46 ntuple_.addVar<double>("genie_truth", "lep_f_e");
47
48 ntuple_.addVar<int>("genie_truth", "tgt_pdg");
49 ntuple_.addVar<double>("genie_truth", "tgt_px");
50 ntuple_.addVar<double>("genie_truth", "tgt_py");
51 ntuple_.addVar<double>("genie_truth", "tgt_pz");
52 ntuple_.addVar<double>("genie_truth", "tgt_e");
53
54 ntuple_.addVar<int>("genie_truth", "hnuc_pdg");
55 ntuple_.addVar<double>("genie_truth", "hnuc_px");
56 ntuple_.addVar<double>("genie_truth", "hnuc_py");
57 ntuple_.addVar<double>("genie_truth", "hnuc_pz");
58 ntuple_.addVar<double>("genie_truth", "hnuc_e");
59
60 ntuple_.addVar<int>("genie_truth", "hqrk_pdg");
61 ntuple_.addVar<int>("genie_truth", "hqrk_sea");
62 ntuple_.addVar<double>("genie_truth", "hadsys_px");
63 ntuple_.addVar<double>("genie_truth", "hadsys_py");
64 ntuple_.addVar<double>("genie_truth", "hadsys_pz");
65 ntuple_.addVar<double>("genie_truth", "hadsys_e");
66}
void addVar(const std::string &tname, const std::string &vname)
Add a variable of type VarType to the ROOT tree with name 'tname'.
void create(const std::string &tname)
Create a ROOT tree to hold the ntuple variables (ROOT leaves).

References framework::NtupleManager::addVar(), framework::NtupleManager::create(), framework::EventProcessor::getHistoDirectory(), and framework::EventProcessor::ntuple_.

Member Data Documentation

◆ hepmc3_coll_name_

std::string dqm::GenieTruthDQM::hepmc3_coll_name_
private

Pass Name for genie objects.

Definition at line 50 of file GenieTruthDQM.h.

Referenced by analyze(), and configure().

◆ hepmc3_pass_name_

std::string dqm::GenieTruthDQM::hepmc3_pass_name_
private

Definition at line 51 of file GenieTruthDQM.h.

◆ run_number_

int dqm::GenieTruthDQM::run_number_
private

Definition at line 53 of file GenieTruthDQM.h.


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