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.
 
std::string ecal_presel_coll_
 Collection Name for Preselection Decision.
 
std::string ecal_presel_pass_
 Pass Name for Preselection Decision.
 
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
 
NtupleManager & ntuple_ {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 15 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 22 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 22 of file EcalDigiVerifier.cxx.

22 {
23 // get truth information sorted into an ID based map
24 std::vector<ldmx::SimCalorimeterHit> ecal_sim_hits =
27
28 // sort sim hits by ID
29 std::sort(ecal_sim_hits.begin(), ecal_sim_hits.end(),
30 [](const ldmx::SimCalorimeterHit& lhs,
31 const ldmx::SimCalorimeterHit& rhs) {
32 return lhs.getID() < rhs.getID();
33 });
34
35 std::vector<ldmx::EcalHit> ecal_rec_hits = event.getCollection<ldmx::EcalHit>(
37
38 // sort rec hits by ID
39 std::sort(ecal_rec_hits.begin(), ecal_rec_hits.end(),
40 [](const ldmx::EcalHit& lhs, const ldmx::EcalHit& rhs) {
41 return lhs.getID() < rhs.getID();
42 });
43
44 int num_rec_hits{0};
45 int num_noise_hits{0};
46 double total_rec_energy{0.};
47 int num_mod_with_0hits{0};
48 int num_mod_with_1hits{0};
49 int num_mod_with_2hits{0};
50 int num_mod_with_more_than_2hits{0};
51 std::vector<int> my_costum_mod_ids;
52 // I need a set for the case when there are repeated elements
53 std::set<int> my_costum_mod_ids_set;
54
55 // Loop on the ecal rechits
56 for (const ldmx::EcalHit& rec_hit : ecal_rec_hits) {
57 num_rec_hits++;
58
59 // Building up an ID that has layer + module information
60 ldmx::EcalID ecal_id(rec_hit.getID());
61 int layer = ecal_id.layer() + 1;
62 int module_id = ecal_id.getModuleID() + 1;
63 int my_mod_costum_id = layer * 100 + module_id;
64
65 my_costum_mod_ids.push_back(my_mod_costum_id);
66 my_costum_mod_ids_set.insert(my_mod_costum_id);
67
68 // Measure the sum energy of all rechits (inc noise)
69 total_rec_energy += rec_hit.getEnergy();
70
71 // skip anything that digi flagged as noise
72 if (rec_hit.isNoise()) {
73 num_noise_hits++;
74 histograms_.fill("is_noise_hit", 1.);
75 continue;
76 } // end if noise
77 histograms_.fill("is_noise_hit", 0.);
78
79 int raw_id = rec_hit.getID();
80
81 // energy weighted sim hit positions
82 double sim_pos_x_weighted = 0.;
83 double sim_pos_y_weighted = 0.;
84 double sim_pos_z_weighted = 0.;
85
86 // get information for this hit
87 int num_sim_hits = 0;
88 double total_sim_energy_dep = 0.;
89 for (const ldmx::SimCalorimeterHit& sim_hit : ecal_sim_hits) {
90 if (raw_id == sim_hit.getID()) {
91 num_sim_hits += sim_hit.getNumberOfContribs();
92 total_sim_energy_dep += sim_hit.getEdep();
93 sim_pos_x_weighted += sim_hit.getPosition()[0] * sim_hit.getEdep();
94 sim_pos_y_weighted += sim_hit.getPosition()[1] * sim_hit.getEdep();
95 sim_pos_z_weighted += sim_hit.getPosition()[2] * sim_hit.getEdep();
96
97 } else if (raw_id < sim_hit.getID()) {
98 // later sim hits - all done
99 break;
100 }
101 } // end loop on sim hits
102
103 sim_pos_x_weighted /= total_sim_energy_dep;
104 sim_pos_y_weighted /= total_sim_energy_dep;
105 sim_pos_z_weighted /= total_sim_energy_dep;
106 auto residual_x = rec_hit.getXPos() - sim_pos_x_weighted;
107 auto residual_y = rec_hit.getYPos() - sim_pos_y_weighted;
108 auto residual_z = rec_hit.getZPos() - sim_pos_z_weighted;
109 histograms_.fill("rec_sim_hit_residual_x", residual_x);
110 histograms_.fill("rec_sim_hit_residual_y", residual_y);
111 histograms_.fill("rec_sim_hit_residual_z", residual_z);
112 histograms_.fill("rec_sim_hit_residual_x:layer", residual_x, layer);
113 histograms_.fill("rec_sim_hit_residual_y:layer", residual_y, layer);
114 histograms_.fill("rec_sim_hit_residual_z:layer", residual_z, layer);
115 histograms_.fill("num_sim_hits_per_cell", num_sim_hits);
116 histograms_.fill("sim_edep:rec_amplitude", total_sim_energy_dep,
117 rec_hit.getAmplitude());
118 histograms_.fill("sim_edep:rec_energy", total_sim_energy_dep,
119 rec_hit.getEnergy());
120 } // end loop on rec hits
121
122 std::map<int, int> module_hits;
123 for (const int& my_costum_mod_id : my_costum_mod_ids) {
124 module_hits[my_costum_mod_id]++;
125 }
126
127 // all modules is 34*7 = 238
128 // this would be nice if not hardcoded...
129 num_mod_with_0hits = num_layers_ * 7 - my_costum_mod_ids_set.size();
130
131 for (const auto& module_hit : module_hits) {
132 if (module_hit.second == 1) {
133 num_mod_with_1hits++;
134 } else if (module_hit.second == 2) {
135 num_mod_with_2hits++;
136 } else if (module_hit.second > 2) {
137 histograms_.fill("num_hit_if_more_than_2hits", module_hit.second);
138 num_mod_with_more_than_2hits++;
139 }
140 }
141
142 histograms_.fill("num_rec_hits", num_rec_hits);
143 histograms_.fill("num_noise_hits", num_noise_hits);
144 histograms_.fill("total_rec_energy", total_rec_energy);
145
146 histograms_.fill("num_mod_with_0hits", num_mod_with_0hits);
147 // only fill the histograms in the case there are hits, otherwise it goes to
148 // the other categories
149 if (num_mod_with_1hits > 0)
150 histograms_.fill("num_mod_with_1hits", num_mod_with_1hits);
151 if (num_mod_with_2hits > 0)
152 histograms_.fill("num_mod_with_2hits", num_mod_with_2hits);
153 if (num_mod_with_more_than_2hits > 0)
154 histograms_.fill("num_mod_with_more_than_2hits",
155 num_mod_with_more_than_2hits);
156
157 // Check if preselection decision exists and fill histogram
159 bool presel_passed =
160 event.getObject<bool>(ecal_presel_coll_, ecal_presel_pass_);
161 histograms_.fill("preselection_passed", presel_passed ? 1. : 0.);
162 }
163
164 if (total_rec_energy > 6000.) {
166 } else {
168 }
169
170 return;
171}
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_presel_coll_
Collection Name for Preselection Decision.
std::string ecal_rec_hit_coll_
Collection Name for RecHits.
std::string ecal_presel_pass_
Pass Name for Preselection Decision.
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_.
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.
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_presel_coll_, ecal_presel_pass_, ecal_rec_hit_coll_, ecal_rec_hit_pass_, ecal_sim_hit_coll_, ecal_sim_hit_pass_, framework::Event::exists(), 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 10 of file EcalDigiVerifier.cxx.

10 {
11 ecal_sim_hit_coll_ = ps.get<std::string>("ecal_sim_hit_coll");
12 ecal_sim_hit_pass_ = ps.get<std::string>("ecal_sim_hit_pass");
13 ecal_rec_hit_coll_ = ps.get<std::string>("ecal_rec_hit_coll");
14 ecal_rec_hit_pass_ = ps.get<std::string>("ecal_rec_hit_pass");
15 ecal_presel_coll_ = ps.get<std::string>("ecal_presel_coll");
16 ecal_presel_pass_ = ps.get<std::string>("ecal_presel_pass");
17 num_layers_ = ps.get<int>("num_layers");
18
19 return;
20}
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:75

References ecal_presel_coll_, ecal_presel_pass_, 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_presel_coll_

std::string dqm::EcalDigiVerifier::ecal_presel_coll_
private

Collection Name for Preselection Decision.

Definition at line 49 of file EcalDigiVerifier.h.

Referenced by analyze(), and configure().

◆ ecal_presel_pass_

std::string dqm::EcalDigiVerifier::ecal_presel_pass_
private

Pass Name for Preselection Decision.

Definition at line 52 of file EcalDigiVerifier.h.

Referenced by analyze(), and configure().

◆ ecal_rec_hit_coll_

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

Collection Name for RecHits.

Definition at line 43 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 46 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 37 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 40 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 55 of file EcalDigiVerifier.h.

Referenced by analyze(), and configure().


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