LDMX Software
dqm::SimObjects Class Reference

Generate histograms to check simulation output. More...

#include <SimObjects.h>

Public Member Functions

 SimObjects (const std::string &name, framework::Process &process)
 Constructor.
 
virtual void configure (framework::config::Parameters &ps)
 Input python configuration parameters.
 
virtual void onProcessStart ()
 Construct histograms depending on which objects are requested.
 
virtual void analyze (const framework::Event &event)
 Fills histograms.
 
- 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 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 createCalorimeterHists (const std::string &coll_name)
 new calorimeter histograms
 
void createTrackerHists (const std::string &coll_name)
 new tracker histograms
 

Private Attributes

std::string sim_pass_
 Pass Name for sim objects.
 
std::string sim_particles_map_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

Generate histograms to check simulation output.

Definition at line 14 of file SimObjects.h.

Constructor & Destructor Documentation

◆ SimObjects()

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

Constructor.

Blank Analyzer constructor

Definition at line 21 of file SimObjects.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::SimObjects::analyze ( const framework::Event & event)
virtual

Fills histograms.

Implements framework::Analyzer.

Definition at line 129 of file SimObjects.cxx.

129 {
130 static std::vector<framework::ProductTag> sp_maps, calo_colls, track_colls;
131 if (sp_maps.empty()) {
132 sp_maps = event.searchProducts("SimParticles", "", "");
133 if (sp_maps.size() != 1) {
134 ldmx_log(warn) << sp_maps.size() << " SimParticle maps which is not one!";
135 }
136 }
137 if (calo_colls.empty()) {
138 calo_colls = event.searchProducts("", sim_pass_, ".*SimCalorimeterHit.*");
139 for (auto pt : calo_colls) createCalorimeterHists(pt.name());
140 }
141 if (track_colls.empty()) {
142 track_colls = event.searchProducts("", sim_pass_, ".*SimTrackerHit.*");
143 for (auto pt : track_colls) createTrackerHists(pt.name());
144 }
145
146 auto const& particle_map{event.getMap<int, ldmx::SimParticle>(
147 "SimParticles", sim_particles_map_passname_)};
148 for (auto const& [track_id, particle] : particle_map) {
149 auto const& momentum{particle.getMomentum()};
150 auto const& vertex{particle.getVertex()};
151 histograms_.fill("SimParticles.E", particle.getEnergy());
152 histograms_.fill("SimParticles.px", momentum.at(0));
153 histograms_.fill("SimParticles.py", momentum.at(1));
154 histograms_.fill("SimParticles.pz", momentum.at(2));
155 histograms_.fill("SimParticles.time", particle.getTime());
156 histograms_.fill("SimParticles.pdg", particle.getPdgID());
157 histograms_.fill("SimParticles.x", vertex.at(0));
158 histograms_.fill("SimParticles.y", vertex.at(1));
159 histograms_.fill("SimParticles.z", vertex.at(2));
160 histograms_.fill("SimParticles.process", particle.getProcessType());
161 histograms_.fill("SimParticles.track_id", track_id);
162 for (auto const& parent : particle.getParents())
163 histograms_.fill("SimParticles.parent", parent);
164 for (auto const& child : particle.getDaughters())
165 histograms_.fill("SimParticles.children", child);
166
167 // PN particles are special
168 if (particle.getProcessType() ==
169 ldmx::SimParticle::ProcessType::photonNuclear) {
170 histograms_.fill("pn_child.E", particle.getEnergy());
171 histograms_.fill("pn_child.px", momentum.at(0));
172 histograms_.fill("pn_child.py", momentum.at(1));
173 histograms_.fill("pn_child.pz", momentum.at(2));
174 histograms_.fill("pn_child.time", particle.getTime());
175 histograms_.fill("pn_child.pdg", particle.getPdgID());
176 histograms_.fill("pn_child.x", vertex.at(0));
177 histograms_.fill("pn_child.y", vertex.at(1));
178 histograms_.fill("pn_child.z", vertex.at(2));
179 histograms_.fill("pn_child.track_id", track_id);
180 for (auto const& parent : particle.getParents())
181 histograms_.fill("pn_child.parent", parent);
182 for (auto const& child : particle.getDaughters())
183 histograms_.fill("pn_child.children", child);
184 }
185 } // loop over sim particle map
186
187 for (auto const& pt : calo_colls) {
188 auto const& coll{
189 event.getCollection<ldmx::SimCalorimeterHit>(pt.name(), sim_pass_)};
190 for (auto const& hit : coll) {
191 unsigned int n_contribs{hit.getNumberOfContribs()};
192 histograms_.fill(pt.name() + ".n_contribs", n_contribs);
193 for (unsigned int i_contrib{0}; i_contrib < n_contribs; i_contrib++) {
194 ldmx::SimCalorimeterHit::Contrib contrib{hit.getContrib(i_contrib)};
195 histograms_.fill(pt.name() + ".incidents", contrib.incident_id_);
196 histograms_.fill(pt.name() + ".tracks", contrib.track_id_);
197 histograms_.fill(pt.name() + ".pdg", contrib.pdg_code_);
198 }
199
200 histograms_.fill(pt.name() + ".edep", hit.getEdep());
201 auto pos{hit.getPosition()};
202 histograms_.fill(pt.name() + ".x", pos.at(0));
203 histograms_.fill(pt.name() + ".y", pos.at(1));
204 histograms_.fill(pt.name() + ".z", pos.at(2));
205 histograms_.fill(pt.name() + ".time", hit.getTime());
206 } // loop over hits in the calorimeter collection
207 } // loop over different calorimeter hit collections
208
209 for (auto const& pt : track_colls) {
210 auto const& coll{
211 event.getCollection<ldmx::SimTrackerHit>(pt.name(), sim_pass_)};
212 for (auto const& hit : coll) {
213 histograms_.fill(pt.name() + ".particle_E", hit.getEnergy());
214 auto momentum{hit.getMomentum()};
215 histograms_.fill(pt.name() + ".particle_px", momentum.at(0));
216 histograms_.fill(pt.name() + ".particle_py", momentum.at(1));
217 histograms_.fill(pt.name() + ".particle_pz", momentum.at(2));
218 histograms_.fill(pt.name() + ".edep", hit.getEdep());
219 histograms_.fill(pt.name() + ".time", hit.getTime());
220 auto pos{hit.getPosition()};
221 histograms_.fill(pt.name() + ".x", pos.at(0));
222 histograms_.fill(pt.name() + ".y", pos.at(1));
223 histograms_.fill(pt.name() + ".z", pos.at(2));
224 histograms_.fill(pt.name() + ".track", hit.getTrackID());
225 histograms_.fill(pt.name() + ".pdg", hit.getPdgID());
226 } // loop over hits in the tracker collection
227 } // loop over different tracker hit collections
228
229 return;
230}
void createCalorimeterHists(const std::string &coll_name)
new calorimeter histograms
std::string sim_pass_
Pass Name for sim objects.
Definition SimObjects.h:48
void createTrackerHists(const std::string &coll_name)
new tracker histograms
HistogramPool histograms_
helper object for making and filling histograms
void fill(const std::string &name, const T &val)
Fill a 1D histogram.
Stores simulated calorimeter hit information.
Class representing a simulated particle.
Definition SimParticle.h:23
Represents a simulated tracker hit in the simulation.
Information about a contribution to the hit in the associated cell.

References createCalorimeterHists(), createTrackerHists(), framework::HistogramPool::fill(), framework::EventProcessor::histograms_, and sim_pass_.

◆ configure()

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

Input python configuration parameters.

Reimplemented from framework::EventProcessor.

Definition at line 11 of file SimObjects.cxx.

11 {
12 sim_pass_ = ps.get<std::string>("sim_pass");
13 sim_particles_map_passname_ =
14 ps.get<std::string>("sim_particles_map_passname");
15 return;
16}
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 sim_pass_.

◆ createCalorimeterHists()

void dqm::SimObjects::createCalorimeterHists ( const std::string & coll_name)
private

new calorimeter histograms

Definition at line 89 of file SimObjects.cxx.

89 {
91 histograms_.create(coll_name + ".incidents", "Incident Track IDs", 100, 0,
92 1000);
93 histograms_.create(coll_name + ".tracks", "Contributing Track IDs", 100, 0,
94 1000);
95 histograms_.create(coll_name + ".pdg", "Contributing PDG IDs", 401, -200,
96 200);
97 histograms_.create(coll_name + ".edep", "Energy Deposited [MeV]", 100, 0,
98 200);
99 histograms_.create(coll_name + ".x", "Hit x-Position [mm]", 401, -200, 200);
100 histograms_.create(coll_name + ".y", "Hit y-Position [mm]", 401, -200, 200);
101 histograms_.create(coll_name + ".z", "Hit z-Position [mm]", 171, -700, 1000.);
102 histograms_.create(coll_name + ".time", "Hit Time [ns]", 50, 0., 10.);
103 histograms_.create(coll_name + ".n_contribs", "Number of Contributors", 20,
104 0., 20.);
105 return;
106}
TDirectory * getHistoDirectory()
Access/create a directory in the histogram file for this event processor to create histograms and ana...
void create(const config::Parameters &p)
Create a histogram from the input configuration parameters.

References framework::HistogramPool::create(), framework::EventProcessor::getHistoDirectory(), and framework::EventProcessor::histograms_.

Referenced by analyze().

◆ createTrackerHists()

void dqm::SimObjects::createTrackerHists ( const std::string & coll_name)
private

new tracker histograms

Definition at line 108 of file SimObjects.cxx.

108 {
110 histograms_.create(coll_name + ".particle_E", "Particle E at Hit [MeV]", 400,
111 0, 4000);
112 histograms_.create(coll_name + ".particle_px", "Particle Momentum in x [MeV]",
113 50, 0., 500.);
114 histograms_.create(coll_name + ".particle_py", "Particle Momentum in y [MeV]",
115 50, 0., 500.);
116 histograms_.create(coll_name + ".particle_pz", "Particle Momentum in z [MeV]",
117 400, 0., 4000.);
118 histograms_.create(coll_name + ".edep", "Energy Deposited [MeV]", 100, 0,
119 200);
120 histograms_.create(coll_name + ".time", "Hit Time [ns]", 50, 0., 10.);
121 histograms_.create(coll_name + ".x", "Hit x-Position [mm]", 401, -200, 200);
122 histograms_.create(coll_name + ".y", "Hit y-Position [mm]", 401, -200, 200);
123 histograms_.create(coll_name + ".z", "Hit z-Position [mm]", 171, -700, 1000.);
124 histograms_.create(coll_name + ".track", "Particle Track ID", 100, 0, 1000);
125 histograms_.create(coll_name + ".pdg", "Particle PDG ID", 401, -200, 200);
126 return;
127}

References framework::HistogramPool::create(), framework::EventProcessor::getHistoDirectory(), and framework::EventProcessor::histograms_.

Referenced by analyze().

◆ onProcessStart()

void dqm::SimObjects::onProcessStart ( )
virtual

Construct histograms depending on which objects are requested.

Reimplemented from framework::EventProcessor.

Definition at line 18 of file SimObjects.cxx.

18 {
20 std::vector<std::string> creator_process_labels = {
21 "Unknown", // 0: Unknown
22 "e+ e- -> γγ", // 1: annihil
23 "γ e -> γ e", // 2: compt
24 "γ -> e+ e- ", // 3: conv
25 "e Z -> X (eN)", // 4: electronNuclear
26 "e Z -> e Z γ", // 5: eBrem
27 "e- ionization", // 6: eIoni
28 "Multiple scattering", // 7: msc
29 "γ Z -> e Z ", // 8: phot
30 "γ Z -> X (PN)", // 9: photonNuclear
31 "γ -> mumu", // 10: GammaToMuPair
32 "e Z -> e Z A'", // 11: eDarkBrem
33 "Decay", // 12: Decay
34 "Primary", // 13: Primary
35 "mu Z -> X", // 14: muonNuclear
36 "n Z -> X", // 15: neutronInelastic
37 "n Z -> Z*", // 16: neutronCapture
38 "K Z -> X", // 17: kaonInelastic
39 "pi Z -> X", // 18: pionInelastic
40 "p Z -> X", // 19: protonInelastic
41 };
42
43 // create sim particles histograms
44 histograms_.create("SimParticles.E", "Vertex Total Energy [MeV]", 800, 0.,
45 8000.);
46 histograms_.create("SimParticles.px", "Vertex Momentum in x-Direction [MeV]",
47 50, 0., 500.);
48 histograms_.create("SimParticles.py", "Vertex Momentum in y-Direction [MeV]",
49 50, 0., 500.);
50 histograms_.create("SimParticles.pz", "Vertex Momentum in z-Direction [MeV]",
51 400, 0., 4000.);
52 histograms_.create("SimParticles.time", "Global Time of Creation [ns]", 50,
53 0., 10.);
54 histograms_.create("SimParticles.pdg", "PDG ID of Particle", 201, -100, 100);
55 histograms_.create("SimParticles.x", "Vertex x-Position [mm]", 401, -200,
56 200);
57 histograms_.create("SimParticles.y", "Vertex y-Position [mm]", 401, -200,
58 200);
59 histograms_.create("SimParticles.z", "Vertex z-Position [mm]", 171, -700,
60 1000.);
61 histograms_.create("SimParticles.process", "Creator Process Type",
62 creator_process_labels);
63 histograms_.create("SimParticles.track_id", "Track ID of Particle", 100, 0,
64 1000);
65 histograms_.create("SimParticles.parent", "Track ID of Parent", 100, 0, 1000);
66 histograms_.create("SimParticles.children", "Track IDs of Children", 100, 0,
67 1000);
68
69 // create pn children histograms
70 histograms_.create("pn_child.E", "Vertex Total Energy [MeV]", 800, 0., 8000.);
71 histograms_.create("pn_child.px", "Vertex Momentum in x-Direction [MeV]", 50,
72 0., 500.);
73 histograms_.create("pn_child.py", "Vertex Momentum in y-Direction [MeV]", 50,
74 0., 500.);
75 histograms_.create("pn_child.pz", "Vertex Momentum in z-Direction [MeV]", 400,
76 0., 4000.);
77 histograms_.create("pn_child.time", "Global Time of Creation [ns]", 50, 0.,
78 10.);
79 histograms_.create("pn_child.pdg", "PDG ID of Particle", 201, -100, 100);
80 histograms_.create("pn_child.x", "Vertex x-Position [mm]", 401, -200, 200);
81 histograms_.create("pn_child.y", "Vertex y-Position [mm]", 401, -200, 200);
82 histograms_.create("pn_child.z", "Vertex z-Position [mm]", 171, -700, 1000.);
83 histograms_.create("pn_child.track_id", "Track ID of Particle", 100, 0, 1000);
84 histograms_.create("pn_child.parent", "Track ID of Parent", 100, 0, 1000);
85 histograms_.create("pn_child.children", "Track IDs of Children", 100, 0,
86 1000);
87}

References framework::HistogramPool::create(), framework::EventProcessor::getHistoDirectory(), and framework::EventProcessor::histograms_.

Member Data Documentation

◆ sim_particles_map_passname_

std::string dqm::SimObjects::sim_particles_map_passname_
private

Definition at line 50 of file SimObjects.h.

◆ sim_pass_

std::string dqm::SimObjects::sim_pass_
private

Pass Name for sim objects.

Definition at line 48 of file SimObjects.h.

Referenced by analyze(), and configure().


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