LDMX Software
Public Member Functions | List of all members
dqm::SampleValidation Class Reference

Public Member Functions

 SampleValidation (const std::string &name, framework::Process &process)
 
virtual void configure (framework::config::Parameters &ps) override
 Callback for the EventProcessor to configure itself from the given set of parameters.
 
virtual void analyze (const framework::Event &event) override
 Process the event and make histograms or summaries.
 
int pdgid_label (const int pdgid)
 
void onProcessStart () override
 Method executed before processing of events begins.
 
- Public Member Functions inherited from framework::Analyzer
 Analyzer (const std::string &name, Process &process)
 Class constructor.
 
- Public Member Functions inherited from framework::EventProcessor
 EventProcessor (const std::string &name, Process &process)
 Class constructor.
 
virtual ~EventProcessor ()
 Class destructor.
 
virtual void onNewRun (const ldmx::RunHeader &runHeader)
 Callback for the EventProcessor to take any necessary action when the run being processed changes.
 
virtual void onFileOpen (EventFile &eventFile)
 Callback for the EventProcessor to take any necessary action when a new event input ROOT file is opened.
 
virtual void onFileClose (EventFile &eventFile)
 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.
 

Additional Inherited Members

- Static Public Member Functions inherited from framework::EventProcessor
static void declare (const std::string &classname, int classtype, EventProcessorMaker *)
 Internal function which is part of the PluginFactory machinery.
 
- Static Public Attributes inherited from framework::Analyzer
static const int CLASSTYPE {2}
 Constant used to track EventProcessor types by the PluginFactory.
 
- Protected Member Functions inherited from framework::EventProcessor
void abortEvent ()
 Abort the event immediately.
 
- Protected Attributes inherited from framework::EventProcessor
HistogramHelper histograms_
 Interface class for making and filling histograms.
 
NtupleManagerntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger theLog_
 The logger for this EventProcessor.
 

Detailed Description

Definition at line 15 of file SampleValidation.h.

Constructor & Destructor Documentation

◆ SampleValidation()

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

Definition at line 17 of file SampleValidation.h.

18 : Analyzer(name, process) {}
Analyzer(const std::string &name, Process &process)
Class constructor.

Member Function Documentation

◆ analyze()

void dqm::SampleValidation::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 15 of file SampleValidation.cxx.

15 {
16 // Grab the SimParticle Map and Target Scoring Plane Hits
17 auto targetSPHits(
18 event.getCollection<ldmx::SimTrackerHit>("TargetScoringPlaneHits"));
19 auto particle_map{event.getMap<int, ldmx::SimParticle>("SimParticles")};
20
21 std::vector<int> primary_daughters;
22
23 double hard_thresh{9999.0};
24
25 // Loop over all SimParticles
26 for (auto const& it : particle_map) {
27 ldmx::SimParticle p = it.second;
28 int pdgid = p.getPdgID();
29 std::vector<double> vertex = p.getVertex();
30 double energy = p.getEnergy();
31 std::vector<int> parents_track_ids = p.getParents();
32 std::vector<int> daughters = p.getDaughters();
33
34 for (auto const& parent_track_id : parents_track_ids) {
35 if (parent_track_id == 0) {
36 histograms_.fill("pdgid_primaries", pdgid_label(pdgid));
37 histograms_.fill("energy_primaries", energy);
38 hard_thresh = (2500. / 4000.) * energy;
39 primary_daughters = daughters;
40 for (const ldmx::SimTrackerHit& sphit : targetSPHits) {
41 if (sphit.getTrackID() == it.first && sphit.getPosition()[2] < 0) {
42 histograms_.fill("beam_smear", vertex[0], vertex[1]);
43 }
44 }
45 }
46 }
47 }
48
49 std::vector<std::vector<int>> hardbrem_daughters;
50
51 for (auto const& it : particle_map) {
52 int trackid = it.first;
53 ldmx::SimParticle p = it.second;
54 for (auto const& primary_daughter : primary_daughters) {
55 if (trackid == primary_daughter) {
56 histograms_.fill("pdgid_primarydaughters", pdgid_label(p.getPdgID()));
57 if (p.getPdgID() == 22) {
58 histograms_.fill("energy_daughterphoton", p.getEnergy());
59 }
60 if (p.getEnergy() >= hard_thresh) {
61 histograms_.fill("pdgid_harddaughters", pdgid_label(p.getPdgID()));
62 histograms_.fill("startZ_hardbrem", p.getVertex()[2]);
63 histograms_.fill("endZ_hardbrem", p.getEndPoint()[2]);
64 histograms_.fill("energy_hardbrem", p.getEnergy());
65 hardbrem_daughters.push_back(p.getDaughters());
66 }
67 }
68 }
69 }
70
71 for (auto const& it : particle_map) {
72 int trackid = it.first;
73 ldmx::SimParticle p = it.second;
74 for (const std::vector<int>& daughter_track_id : hardbrem_daughters) {
75 for (const int& daughter_id : daughter_track_id) {
76 if (trackid == daughter_id) {
77 histograms_.fill("pdgid_hardbremdaughters",
78 pdgid_label(p.getPdgID()));
79 histograms_.fill("startZ_hardbremdaughters", p.getVertex()[2]);
80 }
81 }
82 }
83 }
84
85 return;
86}
HistogramHelper histograms_
Interface class for making and filling histograms.
const std::vector< ContentType > & getCollection(const std::string &collectionName, const std::string &passName="") const
Get a collection (std::vector) of objects from the event bus.
Definition Event.h:386
void fill(const std::string &name, const double &val)
Fill a 1D histogram.
Definition Histograms.h:166
Class representing a simulated particle.
Definition SimParticle.h:23
double getEnergy() const
Get the energy of this particle [MeV].
Definition SimParticle.h:72
std::vector< int > getParents() const
Get a vector containing the track IDs of the parent particles.
std::vector< double > getVertex() const
Get a vector containing the vertex of this particle in mm.
std::vector< int > getDaughters() const
Get a vector containing the track IDs of all daughter particles.
int getPdgID() const
Get the PDG ID of this particle.
Definition SimParticle.h:85
std::vector< double > getEndPoint() const
Get the endpoint of this particle where it was destroyed or left the world volume [mm].
Represents a simulated tracker hit in the simulation.

References framework::HistogramHelper::fill(), framework::Event::getCollection(), ldmx::SimParticle::getDaughters(), ldmx::SimParticle::getEndPoint(), ldmx::SimParticle::getEnergy(), ldmx::SimParticle::getParents(), ldmx::SimParticle::getPdgID(), ldmx::SimParticle::getVertex(), and framework::EventProcessor::histograms_.

◆ configure()

void dqm::SampleValidation::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 className 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 SampleValidation.cxx.

13{ return; }

◆ onProcessStart()

void dqm::SampleValidation::onProcessStart ( )
overridevirtual

Method executed before processing of events begins.

Reimplemented from framework::EventProcessor.

Definition at line 128 of file SampleValidation.cxx.

128 {
129 std::vector<std::string> labels = {"",
130 "e^{+}", // 1
131 "e^{-}", // 2
132 "#mu^{+}", // 3
133 "#mu^{-}", // 4
134 "#gamma", // 5
135 "p^{+}", // 6
136 "n^{0}", // 7
137 "#pi^{+}", // 8
138 "#pi^{-}", // 9
139 "#pi^{0}", // 10
140 "K^{+}", // 11
141 "K^{-}", // 12
142 "K_{L}", // 13
143 "K_{S}", // 14
144 "light-N", // 15
145 "heavy-N", // 16
146 "#Lambda / #Sigma / #Xi", // 17
147 "A'", // 18
148 "else",
149 ""};
150
151 std::vector<TH1*> hists = {
152 histograms_.get("pdgid_primaries"),
153 histograms_.get("pdgid_primarydaughters"),
154 histograms_.get("pdgid_harddaughters"),
155 histograms_.get("pdgid_hardbremdaughters"),
156
157 };
158
159 for (int ilabel{1}; ilabel < labels.size(); ++ilabel) {
160 for (auto& hist : hists) {
161 hist->GetXaxis()->SetBinLabel(ilabel, labels[ilabel - 1].c_str());
162 }
163 }
164}
TH1 * get(const std::string &name)
Get a pointer to a histogram by name.
Definition Histograms.h:194

References framework::HistogramHelper::get(), and framework::EventProcessor::histograms_.

◆ pdgid_label()

int dqm::SampleValidation::pdgid_label ( const int  pdgid)

Definition at line 88 of file SampleValidation.cxx.

88 {
89 // initially assign label as "anything else"/overflow value,
90 // only change if the pdg id is something of interest
91 int label = 19;
92 if (pdgid == -11) label = 1; // e+
93 if (pdgid == 11) label = 2; // e-
94 if (pdgid == -13) label = 3; // μ+
95 if (pdgid == 13) label = 4; // μ-
96 if (pdgid == 22) label = 5; // γ
97 if (pdgid == 2212) label = 6; // proton
98 if (pdgid == 2112) label = 7; // neutron
99 if (pdgid == 211) label = 8; //π+
100 if (pdgid == -211) label = 9; //π-
101 if (pdgid == 111) label = 10; //π0
102 if (pdgid == 321) label = 11; // K+
103 if (pdgid == -321) label = 12; // K-
104 if (pdgid == 130) label = 13; // K-Long
105 if (pdgid == 310) label = 14; // K-Short
106 if (pdgid == 3122 || pdgid == 3222 || pdgid == 3212 || pdgid == 3112 ||
107 pdgid == 3322 || pdgid == 3312)
108 label = 17; // strange baryon
109 /*
110 * Nuclear PDG codes are given by ±10LZZZAAAI so to find the atomic
111 * number, we divide by 10 (to lose I) and then take the modulo
112 * with 1000.
113 */
114 if (pdgid > 1000000000) { // nuclei
115 if (((pdgid / 10) % 1000) <= 4) {
116 label = 15; // light nuclei
117 } else {
118 label = 16; // heavy nuclei
119 }
120 }
121 if (pdgid == 622)
122 label =
123 18; // dark photon, need pdg id for other models like ALPs and SIMPs
124
125 return label;
126}

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