LDMX Software
EcalDigiVerifier.cxx
1
2#include "DQM/EcalDigiVerifier.h"
3
4#include "Ecal/Event/EcalHit.h"
6
7namespace dqm {
8
10 ecalSimHitColl_ = ps.getParameter<std::string>("ecalSimHitColl");
11 ecalSimHitPass_ = ps.getParameter<std::string>("ecalSimHitPass");
12 ecalRecHitColl_ = ps.getParameter<std::string>("ecalRecHitColl");
13 ecalRecHitPass_ = ps.getParameter<std::string>("ecalRecHitPass");
14
15 return;
16}
17
19 // get truth information sorted into an ID based map
20 std::vector<ldmx::SimCalorimeterHit> ecalSimHits =
21 event.getCollection<ldmx::SimCalorimeterHit>(ecalSimHitColl_,
23
24 // sort sim hits by ID
25 std::sort(ecalSimHits.begin(), ecalSimHits.end(),
26 [](const ldmx::SimCalorimeterHit &lhs,
27 const ldmx::SimCalorimeterHit &rhs) {
28 return lhs.getID() < rhs.getID();
29 });
30
31 std::vector<ldmx::EcalHit> ecalRecHits =
32 event.getCollection<ldmx::EcalHit>(ecalRecHitColl_, ecalRecHitPass_);
33
34 // sort rec hits by ID
35 std::sort(ecalRecHits.begin(), ecalRecHits.end(),
36 [](const ldmx::EcalHit &lhs, const ldmx::EcalHit &rhs) {
37 return lhs.getID() < rhs.getID();
38 });
39
40 int numRecHits{0};
41 int numNoiseHits{0};
42 double totalRecEnergy{0.};
43 for (const ldmx::EcalHit &recHit : ecalRecHits) {
44 numRecHits++;
45 // skip anything that digi flagged as noise
46 if (recHit.isNoise()) {
47 numNoiseHits++;
48 continue;
49 }
50
51 int rawID = recHit.getID();
52
53 // get information for this hit
54 int numSimHits = 0;
55 double totalSimEDep = 0.;
56 for (const ldmx::SimCalorimeterHit &simHit : ecalSimHits) {
57 if (rawID == simHit.getID()) {
58 numSimHits += simHit.getNumberOfContribs();
59 totalSimEDep += simHit.getEdep();
60 } else if (rawID < simHit.getID()) {
61 // later sim hits - all done
62 break;
63 }
64 }
65
66 histograms_.fill("num_sim_hits_per_cell", numSimHits);
67 histograms_.fill("sim_edep__rec_amplitude", totalSimEDep,
68 recHit.getAmplitude());
69
70 totalRecEnergy += recHit.getEnergy();
71 }
72 histograms_.fill("num_rec_hits", numRecHits);
73 histograms_.fill("num_noise_hits", numNoiseHits);
74 histograms_.fill("total_rec_energy", totalRecEnergy);
75
76 if (totalRecEnergy > 6000.) {
78 } else {
80 }
81
82 return;
83}
84
85} // namespace dqm
86
87DECLARE_ANALYZER_NS(dqm, EcalDigiVerifier);
#define DECLARE_ANALYZER_NS(NS, CLASS)
Macro which allows the framework to construct an analyzer given its name during configuration.
Class which stores simulated calorimeter hit information.
std::string ecalSimHitPass_
Pass Name for SimHits.
std::string ecalRecHitColl_
Collection Name for RecHits.
virtual void analyze(const framework::Event &event)
Fills histograms.
std::string ecalSimHitColl_
Collection Name for SimHits.
virtual void configure(framework::config::Parameters &ps)
Input python configuration parameters.
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.
Implements an event buffer system for storing event data.
Definition Event.h:41
void fill(const std::string &name, const double &val)
Fill a 1D histogram.
Definition Histograms.h:166
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:27
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:89
Stores reconstructed hit information from the ECAL.
Definition EcalHit.h:19
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