LDMX Software
TrigScintDigiVerifier.cxx
1#include "DQM/TrigScintDigiVerifier.h"
2
3#include <algorithm>
4
6#include "TrigScint/Event/TrigScintHit.h"
7
8namespace dqm {
9
11 ts_simhit_coll_ = ps.get<std::string>("ts_simhit_coll");
12 ts_simhit_pass_ = ps.get<std::string>("ts_simhit_pass");
13 ts_digi_coll_ = ps.get<std::string>("ts_digi_coll");
14 ts_digi_pass_ = ps.get<std::string>("ts_digi_pass");
15
16 return;
17}
18
20 // get truth information sorted into an ID based map
21 auto ts_simhits = event.getCollection<ldmx::SimCalorimeterHit>(
23
24 // sort sim hits by ID
25 std::sort(ts_simhits.begin(), ts_simhits.end(),
26 [](const ldmx::SimCalorimeterHit& lhs,
27 const ldmx::SimCalorimeterHit& rhs) {
28 return lhs.getID() < rhs.getID();
29 });
30
31 auto ts_digis{
32 event.getCollection<ldmx::TrigScintHit>(ts_digi_coll_, ts_digi_pass_)};
33
34 // sort digi hits by ID
35 std::sort(ts_digis.begin(), ts_digis.end(),
36 [](const ldmx::TrigScintHit& lhs, const ldmx::TrigScintHit& rhs) {
37 return lhs.getID() < rhs.getID();
38 });
39
40 // Loop on the ts rechits
41 ldmx_log(info) << "There are " << ts_digis.size()
42 << " ts digis in this event";
43 for (const auto& ts_digi : ts_digis) {
44 // skip anything that digi flagged as noise
45 if (ts_digi.isNoise()) {
46 ldmx_log(debug) << "Digi with raw ID " << ts_digi.getID()
47 << " and bar ID " << ts_digi.getBarID()
48 << " is flagged as noise, skipping";
49 continue;
50 }
51 int raw_id = ts_digi.getID();
52 ldmx_log(debug) << "Digi with raw ID " << raw_id << " and bar ID "
53 << ts_digi.getBarID() << " has energy "
54 << ts_digi.getEnergy() << " and amplitude "
55 << ts_digi.getAmplitude();
56
57 // get information for this hit
58
59 double total_sim_energy_dep = 0.;
60 for (const auto& ts_simhit : ts_simhits) {
61 if (raw_id == ts_simhit.getID()) {
62 total_sim_energy_dep += ts_simhit.getEdep();
63 } else if (raw_id < ts_simhit.getID()) {
64 // later sim hits - all done
65 break;
66 }
67 }
68
69 ldmx_log(info) << " There are " << ts_simhits.size()
70 << " sim hits in this event, adding up to a total energy of "
71 << total_sim_energy_dep;
72
73 histograms_.fill("sim_edep:rec_amplitude", total_sim_energy_dep,
74 ts_digi.getAmplitude());
75 histograms_.fill("sim_edep:rec_energy", total_sim_energy_dep,
76 ts_digi.getEnergy());
77 } // end of loop on ts digis
78
79 return;
80}
81
82} // namespace dqm
83
#define DECLARE_ANALYZER(CLASS)
Macro which allows the framework to construct an analyzer given its name during configuration.
Class which stores simulated calorimeter hit information.
Generate histograms to check digi pipeline performance.
std::string ts_simhit_pass_
Pass Name for SimHits.
virtual void analyze(const framework::Event &event)
Fills histograms.
virtual void configure(framework::config::Parameters &ps)
Input python configuration parameters.
std::string ts_simhit_coll_
Collection Name for SimHits.
std::string ts_digi_coll_
Collection Name for digis.
std::string ts_digi_pass_
Pass Name for digis.
HistogramPool histograms_
helper object for making and filling histograms
Implements an event buffer system for storing event data.
Definition Event.h:40
void fill(const std::string &name, const T &val)
Fill a 1D histogram.
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:26
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:75
Stores simulated calorimeter hit information.