LDMX Software
dqm::EcalDigiVerifier Class Reference

Generate histograms to check digi pipeline performance. More...

#include <EcalDigiVerifier.h>

Public Member Functions

 EcalDigiVerifier (const std::string &name, framework::Process &process)
 Constructor.
 
virtual void configure (framework::config::Parameters &ps)
 Input python configuration parameters.
 
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 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 Attributes

std::string ecal_sim_hit_coll_
 Collection Name for SimHits.
 
std::string ecal_sim_hit_pass_
 Pass Name for SimHits.
 
std::string ecal_rec_hit_coll_
 Collection Name for RecHits.
 
std::string ecal_rec_hit_pass_
 Pass Name for RecHits.
 
int num_layers_
 Number of layers in the ECAL.
 

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 digi pipeline performance.

Definition at line 18 of file EcalDigiVerifier.h.

Constructor & Destructor Documentation

◆ EcalDigiVerifier()

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

Constructor.

Blank Analyzer constructor

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

Fills histograms.

Implements framework::Analyzer.

Definition at line 16 of file EcalDigiVerifier.cxx.

16 {
17 // get truth information sorted into an ID based map
18 std::vector<ldmx::SimCalorimeterHit> ecal_sim_hits =
21
22 // sort sim hits by ID
23 std::sort(ecal_sim_hits.begin(), ecal_sim_hits.end(),
24 [](const ldmx::SimCalorimeterHit &lhs,
25 const ldmx::SimCalorimeterHit &rhs) {
26 return lhs.getID() < rhs.getID();
27 });
28
29 std::vector<ldmx::EcalHit> ecal_rec_hits = event.getCollection<ldmx::EcalHit>(
31
32 // sort rec hits by ID
33 std::sort(ecal_rec_hits.begin(), ecal_rec_hits.end(),
34 [](const ldmx::EcalHit &lhs, const ldmx::EcalHit &rhs) {
35 return lhs.getID() < rhs.getID();
36 });
37
38 int num_rec_hits{0};
39 int num_noise_hits{0};
40 double total_rec_energy{0.};
41 int num_mod_with_0hits{0};
42 int num_mod_with_1hits{0};
43 int num_mod_with_2hits{0};
44 int num_mod_with_more_than_2hits{0};
45 std::vector<int> my_costum_mod_ids;
46 // I need a set for the case when there are repeated elements
47 std::set<int> my_costum_mod_ids_set;
48
49 // Loop on the ecal rechits
50 for (const ldmx::EcalHit &rec_hit : ecal_rec_hits) {
51 num_rec_hits++;
52
53 // Building up an ID that has layer + module information
54 ldmx::EcalID ecal_id(rec_hit.getID());
55 int layer = ecal_id.layer() + 1;
56 int module_id = ecal_id.getModuleID() + 1;
57 int my_mod_costum_id = layer * 100 + module_id;
58
59 my_costum_mod_ids.push_back(my_mod_costum_id);
60 my_costum_mod_ids_set.insert(my_mod_costum_id);
61
62 // Measure the sum energy of all rechits (inc noise)
63 total_rec_energy += rec_hit.getEnergy();
64
65 // skip anything that digi flagged as noise
66 if (rec_hit.isNoise()) {
67 num_noise_hits++;
68 histograms_.fill("is_noise_hit", 1.);
69 continue;
70 } // end if noise
71 histograms_.fill("is_noise_hit", 0.);
72
73 int raw_id = rec_hit.getID();
74
75 // energy weighted sim hit positions
76 double sim_pos_x_weighted = 0.;
77 double sim_pos_y_weighted = 0.;
78 double sim_pos_z_weighted = 0.;
79
80 // get information for this hit
81 int num_sim_hits = 0;
82 double total_sim_energy_dep = 0.;
83 for (const ldmx::SimCalorimeterHit &sim_hit : ecal_sim_hits) {
84 if (raw_id == sim_hit.getID()) {
85 num_sim_hits += sim_hit.getNumberOfContribs();
86 total_sim_energy_dep += sim_hit.getEdep();
87 sim_pos_x_weighted += sim_hit.getPosition()[0] * sim_hit.getEdep();
88 sim_pos_y_weighted += sim_hit.getPosition()[1] * sim_hit.getEdep();
89 sim_pos_z_weighted += sim_hit.getPosition()[2] * sim_hit.getEdep();
90
91 } else if (raw_id < sim_hit.getID()) {
92 // later sim hits - all done
93 break;
94 }
95 } // end loop on sim hits
96
97 sim_pos_x_weighted /= total_sim_energy_dep;
98 sim_pos_y_weighted /= total_sim_energy_dep;
99 sim_pos_z_weighted /= total_sim_energy_dep;
100 auto residual_x = rec_hit.getXPos() - sim_pos_x_weighted;
101 auto residual_y = rec_hit.getYPos() - sim_pos_y_weighted;
102 auto residual_z = rec_hit.getZPos() - sim_pos_z_weighted;
103 histograms_.fill("rec_sim_hit_residual_x", residual_x);
104 histograms_.fill("rec_sim_hit_residual_y", residual_y);
105 histograms_.fill("rec_sim_hit_residual_z", residual_z);
106 histograms_.fill("rec_sim_hit_residual_x:layer", residual_x, layer);
107 histograms_.fill("rec_sim_hit_residual_y:layer", residual_y, layer);
108 histograms_.fill("rec_sim_hit_residual_z:layer", residual_z, layer);
109 histograms_.fill("num_sim_hits_per_cell", num_sim_hits);
110 histograms_.fill("sim_edep:rec_amplitude", total_sim_energy_dep,
111 rec_hit.getAmplitude());
112 histograms_.fill("sim_edep:rec_energy", total_sim_energy_dep,
113 rec_hit.getEnergy());
114 } // end loop on rec hits
115
116 std::map<int, int> module_hits;
117 for (const int &my_costum_mod_id : my_costum_mod_ids) {
118 module_hits[my_costum_mod_id]++;
119 }
120
121 // all modules is 34*7 = 238
122 // this would be nice if not hardcoded...
123 num_mod_with_0hits = num_layers_ * 7 - my_costum_mod_ids_set.size();
124
125 for (const auto &module_hit : module_hits) {
126 if (module_hit.second == 1) {
127 num_mod_with_1hits++;
128 } else if (module_hit.second == 2) {
129 num_mod_with_2hits++;
130 } else if (module_hit.second > 2) {
131 histograms_.fill("num_hit_if_more_than_2hits", module_hit.second);
132 num_mod_with_more_than_2hits++;
133 }
134 }
135
136 histograms_.fill("num_rec_hits", num_rec_hits);
137 histograms_.fill("num_noise_hits", num_noise_hits);
138 histograms_.fill("total_rec_energy", total_rec_energy);
139
140 histograms_.fill("num_mod_with_0hits", num_mod_with_0hits);
141 // only fill the histograms in the case there are hits, otherwise it goes to
142 // the other categories
143 if (num_mod_with_1hits > 0)
144 histograms_.fill("num_mod_with_1hits", num_mod_with_1hits);
145 if (num_mod_with_2hits > 0)
146 histograms_.fill("num_mod_with_2hits", num_mod_with_2hits);
147 if (num_mod_with_more_than_2hits > 0)
148 histograms_.fill("num_mod_with_more_than_2hits",
149 num_mod_with_more_than_2hits);
150
151 if (total_rec_energy > 6000.) {
153 } else {
155 }
156
157 return;
158}
std::string ecal_sim_hit_coll_
Collection Name for SimHits.
int num_layers_
Number of layers in the ECAL.
std::string ecal_sim_hit_pass_
Pass Name for SimHits.
std::string ecal_rec_hit_pass_
Pass Name for RecHits.
std::string ecal_rec_hit_coll_
Collection Name for RecHits.
HistogramPool histograms_
helper object for making and filling histograms
void setStorageHint(framework::StorageControl::Hint hint)
Mark the current event as having the given storage control hint from this module_.
void fill(const std::string &name, const T &val)
Fill a 1D histogram.
Stores reconstructed hit information from the ECAL.
Definition EcalHit.h:19
Extension of DetectorID providing access to ECal layers and cell numbers in a hex grid.
Definition EcalID.h:20
Stores simulated calorimeter hit information.
constexpr StorageControl::Hint HINT_SHOULD_DROP
storage control hint alias for backwards compatibility
constexpr StorageControl::Hint HINT_SHOULD_KEEP
storage control hint alias for backwards compatibility

References ecal_rec_hit_coll_, ecal_rec_hit_pass_, ecal_sim_hit_coll_, ecal_sim_hit_pass_, framework::HistogramPool::fill(), ldmx::EcalID::getModuleID(), framework::HINT_SHOULD_DROP, framework::HINT_SHOULD_KEEP, framework::EventProcessor::histograms_, ldmx::EcalID::layer(), num_layers_, and framework::EventProcessor::setStorageHint().

◆ configure()

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

Input python configuration parameters.

Reimplemented from framework::EventProcessor.

Definition at line 6 of file EcalDigiVerifier.cxx.

6 {
7 ecal_sim_hit_coll_ = ps.get<std::string>("ecal_sim_hit_coll");
8 ecal_sim_hit_pass_ = ps.get<std::string>("ecal_sim_hit_pass");
9 ecal_rec_hit_coll_ = ps.get<std::string>("ecal_rec_hit_coll");
10 ecal_rec_hit_pass_ = ps.get<std::string>("ecal_rec_hit_pass");
11 num_layers_ = ps.get<int>("num_layers");
12
13 return;
14}
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78

References ecal_rec_hit_coll_, ecal_rec_hit_pass_, ecal_sim_hit_coll_, ecal_sim_hit_pass_, framework::config::Parameters::get(), and num_layers_.

Member Data Documentation

◆ ecal_rec_hit_coll_

std::string dqm::EcalDigiVerifier::ecal_rec_hit_coll_
private

Collection Name for RecHits.

Definition at line 46 of file EcalDigiVerifier.h.

Referenced by analyze(), and configure().

◆ ecal_rec_hit_pass_

std::string dqm::EcalDigiVerifier::ecal_rec_hit_pass_
private

Pass Name for RecHits.

Definition at line 49 of file EcalDigiVerifier.h.

Referenced by analyze(), and configure().

◆ ecal_sim_hit_coll_

std::string dqm::EcalDigiVerifier::ecal_sim_hit_coll_
private

Collection Name for SimHits.

Definition at line 40 of file EcalDigiVerifier.h.

Referenced by analyze(), and configure().

◆ ecal_sim_hit_pass_

std::string dqm::EcalDigiVerifier::ecal_sim_hit_pass_
private

Pass Name for SimHits.

Definition at line 43 of file EcalDigiVerifier.h.

Referenced by analyze(), and configure().

◆ num_layers_

int dqm::EcalDigiVerifier::num_layers_
private

Number of layers in the ECAL.

Definition at line 52 of file EcalDigiVerifier.h.

Referenced by analyze(), and configure().


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