LDMX Software
dqm::CascadeHistoryDQM Class Reference

DQM analyzer for Bertini cascade history data. More...

#include <CascadeHistoryDQM.h>

Public Member Functions

 CascadeHistoryDQM (const std::string &name, framework::Process &process)
 
void configure (framework::config::Parameters &parameters) override
 Callback for the EventProcessor to configure itself from the given set of parameters.
 
void analyze (const framework::Event &event) override
 Process the event and make histograms or summaries.
 
- 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 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.
 

Private Member Functions

void analyzeCascade (const ldmx::CascadeHistory &history)
 
int getParticleCategory (int pdgId) const
 Get particle category for histogram binning Returns: 0=proton, 1=neutron, 2=pi+, 3=pi-, 4=pi0, 5=kaon, 6=other.
 

Private Attributes

std::string cascade_coll_name_
 
std::string cascade_pass_name_
 

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

DQM analyzer for Bertini cascade history data.

Histograms cascade step counts, particle types, generations, energies, interaction/escape rates, and de-excitation products from BertiniWithHistoryModel.

Definition at line 19 of file CascadeHistoryDQM.h.

Constructor & Destructor Documentation

◆ CascadeHistoryDQM()

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

Definition at line 9 of file CascadeHistoryDQM.cxx.

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::CascadeHistoryDQM::analyze ( const framework::Event & event)
overridevirtual

Process the event and make histograms or summaries.

Parameters
eventThe Event to analyze

Implements framework::Analyzer.

Definition at line 19 of file CascadeHistoryDQM.cxx.

19 {
20 if (!event.exists(cascade_coll_name_, cascade_pass_name_)) {
21 return;
22 }
23
24 auto cascade_map = event.getMap<int, ldmx::CascadeHistory>(
25 cascade_coll_name_, cascade_pass_name_);
26 if (cascade_map.empty()) {
27 return;
28 }
29
30 histograms_.fill("n_cascades", cascade_map.size());
31
32 for (const auto& [trackId, history] : cascade_map) {
33 analyzeCascade(history);
34 }
35}
HistogramPool histograms_
helper object for making and filling histograms
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:107
void fill(const std::string &name, const T &val)
Fill a 1D histogram.
All CascadeSteps from a single photonuclear interaction.

References framework::Event::exists().

◆ analyzeCascade()

void dqm::CascadeHistoryDQM::analyzeCascade ( const ldmx::CascadeHistory & history)
private

Definition at line 37 of file CascadeHistoryDQM.cxx.

37 {
38 const auto& steps = history.getSteps();
39 if (steps.empty()) {
40 return;
41 }
42
43 // Basic cascade properties
44 histograms_.fill("cascade_n_steps", steps.size());
45 histograms_.fill("cascade_target_A", history.getTargetA());
46 histograms_.fill("cascade_target_Z", history.getTargetZ());
47
48 double incident_energy = history.getIncidentEnergy();
49 if (incident_energy > 0) {
50 histograms_.fill("incident_photon_energy", incident_energy);
51 }
52
53 // Count particles by type and status
54 int n_protons = 0, n_neutrons = 0, n_pions = 0, n_kaons = 0, n_other = 0;
55 int n_interacted = 0, n_escaped = 0;
56 int max_generation = 0;
57
58 // Primary reaction analysis
59 int primary_n_protons = 0, primary_n_neutrons = 0;
60 int primary_n_piplus = 0, primary_n_piminus = 0, primary_n_pizero = 0;
61 int primary_n_kaons = 0, primary_n_other = 0;
62 double primary_total_ke = 0;
63 double primary_max_ke = 0;
64
65 // De-excitation analysis
66 int n_deexcitation = 0;
67 int n_deexcitation_neutrons = 0, n_deexcitation_protons = 0;
68 int n_deexcitation_gammas = 0, n_deexcitation_alphas = 0;
69 double deexcitation_total_energy = 0;
70
71 for (const auto& step : steps) {
72 int pdg = step.getPdgId();
73 int abs_pdg = std::abs(pdg);
74 int category = getParticleCategory(pdg);
75 double ke = step.getKineticEnergy();
76
77 switch (category) {
78 case 0:
79 n_protons++;
80 break;
81 case 1:
82 n_neutrons++;
83 break;
84 case 2:
85 case 3:
86 case 4:
87 n_pions++;
88 break;
89 case 5:
90 n_kaons++;
91 break;
92 default:
93 n_other++;
94 break;
95 }
96
97 histograms_.fill("step_pdg_category", category);
98 histograms_.fill("step_generation", step.getGeneration());
99 histograms_.fill("step_stage", step.getStageInt());
100 histograms_.fill("step_ke", ke);
101 histograms_.fill("step_zone", step.getZone());
102
103 // Position within nucleus
104 double x = step.getX();
105 double y = step.getY();
106 double z = step.getZ();
107 double radius = std::sqrt(x * x + y * y + z * z);
108 histograms_.fill("step_radius", radius);
109 histograms_.fill("step_x", x);
110 histograms_.fill("step_y", y);
111 histograms_.fill("step_z", z);
112
113 if (step.getGeneration() > max_generation) {
114 max_generation = step.getGeneration();
115 }
116
117 if (step.didInteract()) {
118 n_interacted++;
119 }
120 if (step.didEscape()) {
121 n_escaped++;
122 histograms_.fill("escaped_pdg_category", category);
123 histograms_.fill("escaped_ke", ke);
124 }
125
126 // Primary reaction products (generation 1, from the initial gamma-nucleon
127 // interaction)
128 if (step.getStage() == ldmx::CascadeStage::PRIMARY) {
129 histograms_.fill("primary_daughter_pdg", category);
130 histograms_.fill("primary_daughter_ke", ke);
131 primary_total_ke += ke;
132 if (ke > primary_max_ke) primary_max_ke = ke;
133
134 if (pdg == 2212)
135 primary_n_protons++;
136 else if (pdg == 2112)
137 primary_n_neutrons++;
138 else if (pdg == 211)
139 primary_n_piplus++;
140 else if (pdg == -211)
141 primary_n_piminus++;
142 else if (pdg == 111)
143 primary_n_pizero++;
144 else if (abs_pdg == 321 || abs_pdg == 311 || abs_pdg == 310 ||
145 abs_pdg == 130)
146 primary_n_kaons++;
147 else
148 primary_n_other++;
149 }
150
151 // De-excitation products
152 if (step.getStage() == ldmx::CascadeStage::DEEXCITATION) {
153 n_deexcitation++;
154 deexcitation_total_energy += ke;
155 histograms_.fill("deexcitation_pdg", category);
156 histograms_.fill("deexcitation_ke", ke);
157
158 if (pdg == 2112) {
159 n_deexcitation_neutrons++;
160 histograms_.fill("deexcitation_neutron_ke", ke);
161 } else if (pdg == 2212) {
162 n_deexcitation_protons++;
163 histograms_.fill("deexcitation_proton_ke", ke);
164 } else if (pdg == 22) {
165 n_deexcitation_gammas++;
166 histograms_.fill("deexcitation_gamma_energy", ke);
167 } else if (abs_pdg == 1000020040) { // alpha
168 n_deexcitation_alphas++;
169 histograms_.fill("deexcitation_alpha_ke", ke);
170 }
171 }
172 }
173
174 // Per-cascade summary
175 histograms_.fill("cascade_n_protons", n_protons);
176 histograms_.fill("cascade_n_neutrons", n_neutrons);
177 histograms_.fill("cascade_n_pions", n_pions);
178 histograms_.fill("cascade_n_kaons", n_kaons);
179 histograms_.fill("cascade_n_other", n_other);
180 histograms_.fill("cascade_n_interacted", n_interacted);
181 histograms_.fill("cascade_n_escaped", n_escaped);
182 histograms_.fill("cascade_max_generation", max_generation);
183
184 // Primary reaction summary
185 int primary_n_daughters =
186 primary_n_protons + primary_n_neutrons + primary_n_piplus +
187 primary_n_piminus + primary_n_pizero + primary_n_kaons + primary_n_other;
188 int primary_n_pions = primary_n_piplus + primary_n_piminus + primary_n_pizero;
189
190 histograms_.fill("primary_n_daughters", primary_n_daughters);
191 histograms_.fill("primary_n_protons", primary_n_protons);
192 histograms_.fill("primary_n_neutrons", primary_n_neutrons);
193 histograms_.fill("primary_n_piplus", primary_n_piplus);
194 histograms_.fill("primary_n_piminus", primary_n_piminus);
195 histograms_.fill("primary_n_pizero", primary_n_pizero);
196 histograms_.fill("primary_n_pions", primary_n_pions);
197 histograms_.fill("primary_n_kaons", primary_n_kaons);
198 histograms_.fill("primary_n_other", primary_n_other);
199 histograms_.fill("primary_total_daughter_ke", primary_total_ke);
200 histograms_.fill("primary_max_daughter_ke", primary_max_ke);
201
202 // De-excitation summary
203 histograms_.fill("n_deexcitation", n_deexcitation);
204 histograms_.fill("n_deexcitation_neutrons", n_deexcitation_neutrons);
205 histograms_.fill("n_deexcitation_protons", n_deexcitation_protons);
206 histograms_.fill("n_deexcitation_gammas", n_deexcitation_gammas);
207 histograms_.fill("n_deexcitation_alphas", n_deexcitation_alphas);
208 histograms_.fill("deexcitation_total_energy", deexcitation_total_energy);
209
210 // Excitation and residual nucleus
211 histograms_.fill("excitation_energy", history.getExcitationEnergy());
212 histograms_.fill("residual_A", history.getResidualA());
213 histograms_.fill("residual_Z", history.getResidualZ());
214}
int getParticleCategory(int pdgId) const
Get particle category for histogram binning Returns: 0=proton, 1=neutron, 2=pi+, 3=pi-,...

◆ configure()

void dqm::CascadeHistoryDQM::configure ( framework::config::Parameters & parameters)
overridevirtual

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 class_name equal to the EventProcessor class name.

For an example, look at MyProcessor.

Parameters
parametersParameters for configuration.

Reimplemented from framework::EventProcessor.

Definition at line 13 of file CascadeHistoryDQM.cxx.

13 {
14 cascade_coll_name_ = parameters.get<std::string>(
15 "cascade_coll_name", "PhotonuclearCascadeHistories");
16 cascade_pass_name_ = parameters.get<std::string>("cascade_pass_name", "");
17}
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:75

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

◆ getParticleCategory()

int dqm::CascadeHistoryDQM::getParticleCategory ( int pdgId) const
private

Get particle category for histogram binning Returns: 0=proton, 1=neutron, 2=pi+, 3=pi-, 4=pi0, 5=kaon, 6=other.

Definition at line 216 of file CascadeHistoryDQM.cxx.

216 {
217 int abs_pdg = std::abs(pdgId);
218 if (pdgId == 2212) return 0; // proton
219 if (pdgId == 2112) return 1; // neutron
220 if (pdgId == 211) return 2; // pi+
221 if (pdgId == -211) return 3; // pi-
222 if (pdgId == 111) return 4; // pi0
223 if (abs_pdg == 321 || abs_pdg == 311 || abs_pdg == 310 || abs_pdg == 130)
224 return 5; // kaons
225 return 6; // other
226}

Member Data Documentation

◆ cascade_coll_name_

std::string dqm::CascadeHistoryDQM::cascade_coll_name_
private

Definition at line 36 of file CascadeHistoryDQM.h.

◆ cascade_pass_name_

std::string dqm::CascadeHistoryDQM::cascade_pass_name_
private

Definition at line 37 of file CascadeHistoryDQM.h.


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