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.
 
- 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 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 ecalSimHitColl_
 Collection Name for SimHits.
 
std::string ecalSimHitPass_
 Pass Name for SimHits.
 
std::string ecalRecHitColl_
 Collection Name for RecHits.
 
std::string ecalRecHitPass_
 Pass Name for RecHits.
 

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

Generate histograms to check digi pipeline performance.

Definition at line 14 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 21 of file EcalDigiVerifier.h.

22 : framework::Analyzer(name, process) {}
Base class for a module which does not produce a data product.

Member Function Documentation

◆ analyze()

void dqm::EcalDigiVerifier::analyze ( const framework::Event & event)
virtual

Fills histograms.

Implements framework::Analyzer.

Definition at line 19 of file EcalDigiVerifier.cxx.

19 {
20 // get truth information sorted into an ID based map
21 std::vector<ldmx::SimCalorimeterHit> ecalSimHits =
22 event.getCollection<ldmx::SimCalorimeterHit>(ecalSimHitColl_,
24
25 // sort sim hits by ID
26 std::sort(ecalSimHits.begin(), ecalSimHits.end(),
27 [](const ldmx::SimCalorimeterHit &lhs,
28 const ldmx::SimCalorimeterHit &rhs) {
29 return lhs.getID() < rhs.getID();
30 });
31
32 std::vector<ldmx::EcalHit> ecalRecHits =
33 event.getCollection<ldmx::EcalHit>(ecalRecHitColl_, ecalRecHitPass_);
34
35 // sort rec hits by ID
36 std::sort(ecalRecHits.begin(), ecalRecHits.end(),
37 [](const ldmx::EcalHit &lhs, const ldmx::EcalHit &rhs) {
38 return lhs.getID() < rhs.getID();
39 });
40
41 int numRecHits{0};
42 int numNoiseHits{0};
43 double totalRecEnergy{0.};
44 int numModWith0Hits{0};
45 int numModWith1Hits{0};
46 int numModWith2Hits{0};
47 int numModWithMoreThan2Hits{0};
48 std::vector<int> myCostumModIDs;
49 // I need a set for the case when there are repeated elements
50 std::set<int> myCostumModIDsSet;
51
52 // Loop on the ecal rechits
53 for (const ldmx::EcalHit &recHit : ecalRecHits) {
54 numRecHits++;
55
56 // Building up an ID that has layer + module information
57 ldmx::EcalID ecal_id(recHit.getID());
58 int layer = ecal_id.layer() + 1;
59 int moduleID = ecal_id.getModuleID() + 1;
60 int myModConstumID = layer * 100 + moduleID;
61
62 myCostumModIDs.push_back(myModConstumID);
63 myCostumModIDsSet.insert(myModConstumID);
64
65 // Measure the sum energy of all rechits (inc noise)
66 totalRecEnergy += recHit.getEnergy();
67
68 // skip anything that digi flagged as noise
69 if (recHit.isNoise()) {
70 numNoiseHits++;
71 histograms_.fill("is_noise_hit", 1.);
72 continue;
73 }
74 histograms_.fill("is_noise_hit", 0.);
75
76 int rawID = recHit.getID();
77
78 // get information for this hit
79 int numSimHits = 0;
80 double totalSimEDep = 0.;
81 for (const ldmx::SimCalorimeterHit &simHit : ecalSimHits) {
82 if (rawID == simHit.getID()) {
83 numSimHits += simHit.getNumberOfContribs();
84 totalSimEDep += simHit.getEdep();
85 auto residualX = recHit.getXPos() - simHit.getPosition()[0];
86 auto residualY = recHit.getYPos() - simHit.getPosition()[1];
87 auto residualZ = recHit.getZPos() - simHit.getPosition()[2];
88 histograms_.fill("rec_sim_hit_residual_x", residualX);
89 histograms_.fill("rec_sim_hit_residual_y", residualY);
90 histograms_.fill("rec_sim_hit_residual_z", residualZ);
91 } else if (rawID < simHit.getID()) {
92 // later sim hits - all done
93 break;
94 }
95 }
96
97 histograms_.fill("num_sim_hits_per_cell", numSimHits);
98 histograms_.fill("sim_edep__rec_amplitude", totalSimEDep,
99 recHit.getAmplitude());
100 }
101
102 std::map<int, int> moduleHits;
103 for (const int &myCostumModID : myCostumModIDs) {
104 moduleHits[myCostumModID]++;
105 }
106
107 // all modules is 34*7 = 238
108 // this would be nice if not hardcoded...
109 numModWith0Hits = 34 * 7 - myCostumModIDsSet.size();
110
111 for (const auto &moduleHit : moduleHits) {
112 if (moduleHit.second == 1) {
113 numModWith1Hits++;
114 } else if (moduleHit.second == 2) {
115 numModWith2Hits++;
116 } else if (moduleHit.second > 2) {
117 histograms_.fill("num_hit_if_more_than_2hits", moduleHit.second);
118 numModWithMoreThan2Hits++;
119 }
120 }
121
122 histograms_.fill("num_rec_hits", numRecHits);
123 histograms_.fill("num_noise_hits", numNoiseHits);
124 histograms_.fill("total_rec_energy", totalRecEnergy);
125
126 histograms_.fill("num_mod_with_0hits", numModWith0Hits);
127 // only fill the histograms in the case there are hits, otherwise it goes to
128 // the other categories
129 if (numModWith1Hits > 0)
130 histograms_.fill("num_mod_with_1hits", numModWith1Hits);
131 if (numModWith2Hits > 0)
132 histograms_.fill("num_mod_with_2hits", numModWith2Hits);
133 if (numModWithMoreThan2Hits > 0)
134 histograms_.fill("num_mod_with_more_than_2hits", numModWithMoreThan2Hits);
135
136 if (totalRecEnergy > 6000.) {
138 } else {
140 }
141
142 return;
143}
std::string ecalSimHitPass_
Pass Name for SimHits.
std::string ecalRecHitColl_
Collection Name for RecHits.
std::string ecalSimHitColl_
Collection Name for SimHits.
std::string ecalRecHitPass_
Pass Name for RecHits.
HistogramHelper histograms_
Interface class 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 double &val)
Fill a 1D histogram.
Definition Histograms.h:166
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_shouldKeep
storage control hint alias for backwards compatibility
constexpr StorageControl::Hint hint_shouldDrop
storage control hint alias for backwards compatibility

References ecalRecHitColl_, ecalRecHitPass_, ecalSimHitColl_, ecalSimHitPass_, framework::HistogramHelper::fill(), ldmx::EcalID::getModuleID(), framework::hint_shouldDrop, framework::hint_shouldKeep, framework::EventProcessor::histograms_, ldmx::EcalID::layer(), 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 ecalSimHitColl_ = ps.getParameter<std::string>("ecalSimHitColl");
12 ecalSimHitPass_ = ps.getParameter<std::string>("ecalSimHitPass");
13 ecalRecHitColl_ = ps.getParameter<std::string>("ecalRecHitColl");
14 ecalRecHitPass_ = ps.getParameter<std::string>("ecalRecHitPass");
15
16 return;
17}

References ecalRecHitColl_, ecalRecHitPass_, ecalSimHitColl_, and ecalSimHitPass_.

Member Data Documentation

◆ ecalRecHitColl_

std::string dqm::EcalDigiVerifier::ecalRecHitColl_
private

Collection Name for RecHits.

Definition at line 42 of file EcalDigiVerifier.h.

Referenced by analyze(), and configure().

◆ ecalRecHitPass_

std::string dqm::EcalDigiVerifier::ecalRecHitPass_
private

Pass Name for RecHits.

Definition at line 45 of file EcalDigiVerifier.h.

Referenced by analyze(), and configure().

◆ ecalSimHitColl_

std::string dqm::EcalDigiVerifier::ecalSimHitColl_
private

Collection Name for SimHits.

Definition at line 36 of file EcalDigiVerifier.h.

Referenced by analyze(), and configure().

◆ ecalSimHitPass_

std::string dqm::EcalDigiVerifier::ecalSimHitPass_
private

Pass Name for SimHits.

Definition at line 39 of file EcalDigiVerifier.h.

Referenced by analyze(), and configure().


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