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
 
NtupleManagerntuple_ {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 74 of file GenieTruthDQM.cxx.

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

14 {
15 hepmc3_coll_name_ = ps.get<std::string>("hepmc3CollName");
16 hepmc3_pass_name_ = ps.get<std::string>("hepmc3PassName");
17 return;
18}
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78

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 70 of file GenieTruthDQM.cxx.

70 {
71 run_number_ = runHeader.getRunNumber();
72}
int getRunNumber() const
Definition RunHeader.h:77

References ldmx::RunHeader::getRunNumber().

◆ onProcessStart()

void dqm::GenieTruthDQM::onProcessStart ( )
virtual

Construct histograms/ntuples.

Reimplemented from framework::EventProcessor.

Definition at line 20 of file GenieTruthDQM.cxx.

20 {
22
23 ntuple_.create("genie_truth");
24
25 // event info
26 ntuple_.addVar<int>("genie_truth", "run");
27 ntuple_.addVar<int>("genie_truth", "event");
28
29 ntuple_.addVar<int>("genie_truth", "interaction_type");
30 ntuple_.addVar<int>("genie_truth", "scattering_type");
31 ntuple_.addVar<int>("genie_truth", "rescatter_code");
32
33 ntuple_.addVar<double>("genie_truth", "x_bj");
34 ntuple_.addVar<double>("genie_truth", "y_inel");
35 ntuple_.addVar<double>("genie_truth", "Q2");
36 ntuple_.addVar<double>("genie_truth", "W");
37
38 ntuple_.addVar<int>("genie_truth", "lep_pdg");
39
40 ntuple_.addVar<double>("genie_truth", "lep_i_px");
41 ntuple_.addVar<double>("genie_truth", "lep_i_py");
42 ntuple_.addVar<double>("genie_truth", "lep_i_pz");
43 ntuple_.addVar<double>("genie_truth", "lep_i_e");
44
45 ntuple_.addVar<double>("genie_truth", "lep_f_px");
46 ntuple_.addVar<double>("genie_truth", "lep_f_py");
47 ntuple_.addVar<double>("genie_truth", "lep_f_pz");
48 ntuple_.addVar<double>("genie_truth", "lep_f_e");
49
50 ntuple_.addVar<int>("genie_truth", "tgt_pdg");
51 ntuple_.addVar<double>("genie_truth", "tgt_px");
52 ntuple_.addVar<double>("genie_truth", "tgt_py");
53 ntuple_.addVar<double>("genie_truth", "tgt_pz");
54 ntuple_.addVar<double>("genie_truth", "tgt_e");
55
56 ntuple_.addVar<int>("genie_truth", "hnuc_pdg");
57 ntuple_.addVar<double>("genie_truth", "hnuc_px");
58 ntuple_.addVar<double>("genie_truth", "hnuc_py");
59 ntuple_.addVar<double>("genie_truth", "hnuc_pz");
60 ntuple_.addVar<double>("genie_truth", "hnuc_e");
61
62 ntuple_.addVar<int>("genie_truth", "hqrk_pdg");
63 ntuple_.addVar<int>("genie_truth", "hqrk_sea");
64 ntuple_.addVar<double>("genie_truth", "hadsys_px");
65 ntuple_.addVar<double>("genie_truth", "hadsys_py");
66 ntuple_.addVar<double>("genie_truth", "hadsys_pz");
67 ntuple_.addVar<double>("genie_truth", "hadsys_e");
68}
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: