LDMX Software
Public Member Functions | Private Attributes | List of all members
ldmx::ecal::TrigPrimResolutionAnalyzer Class Reference

Analyze the trigger primitives by comparing them to the precision hits. More...

Public Member Functions

 TrigPrimResolutionAnalyzer (const std::string &name, framework::Process &process)
 
void configure (framework::config::Parameters &parameters) final
 Callback for the EventProcessor to configure itself from the given set of parameters.
 
void onProcessStart () final
 Callback for the EventProcessor to take any necessary action when the processing of events starts, such as creating histograms.
 
void analyze (const framework::Event &event) final
 Process the event and make histograms or summaries.
 
double calculate_energy (int layer, double amplitude)
 Calculate the energy deposited estimate from a hit's amplitude.
 
- 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 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 trig_collection_name_ = "ecalTrigDigis"
 
std::string trig_pass_name_ = ""
 
std::string hit_collection_name_ = "EcalRecHits"
 
std::string hit_pass_name_ = ""
 
double total_trigger_mean_ = 876.28120
 
double total_ampl_mean_ = 48.805244
 
double nominal_ {1.0}
 
double secondOrderEnergyCorrection_ = 4000. / 3940.5
 
double mip_si_energy_ = 0.13
 
std::vector< double > layerWeights_
 

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

Analyze the trigger primitives by comparing them to the precision hits.

This analyzer goes through and compares differents sums between the trigger primitive level (groups of 9 cells for the ECal) and the precision hit level (individual cells).

Definition at line 17 of file TrigPrimResolutionAnalyzer.cxx.

Constructor & Destructor Documentation

◆ TrigPrimResolutionAnalyzer()

ldmx::ecal::TrigPrimResolutionAnalyzer::TrigPrimResolutionAnalyzer ( const std::string &  name,
framework::Process process 
)
inline

Definition at line 34 of file TrigPrimResolutionAnalyzer.cxx.

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

Member Function Documentation

◆ analyze()

void ldmx::ecal::TrigPrimResolutionAnalyzer::analyze ( const framework::Event event)
finalvirtual

Process the event and make histograms or summaries.

Parameters
eventThe Event to analyze

add this trigger primitive to module sums

Implements framework::Analyzer.

Definition at line 223 of file TrigPrimResolutionAnalyzer.cxx.

223 {
224 // called once on each event, get objects and fill histograms
225 const auto& trigs = event.getCollection<ldmx::HgcrocTrigDigi>(
226 trig_collection_name_, trig_pass_name_);
227 // trigs are a std::vector<ldmx::HgcrocTrigDigi>
228 const auto& hits =
229 event.getCollection<ldmx::EcalHit>(hit_collection_name_, hit_pass_name_);
230 // hits are a std::vector<ldmx::EcalHit>
231 const ::ecal::EcalTriggerGeometry& geom =
232 getCondition<::ecal::EcalTriggerGeometry>(
233 ::ecal::EcalTriggerGeometry::CONDITIONS_OBJECT_NAME);
234
235 std::map<UniqueModule, std::pair<int, double>> module_sums;
236 int trig_prim_total{0};
237 int trig_prim_total_first20{0};
238 for (const auto& trig : trigs) {
239 EcalTriggerID tid{trig.getId()};
240 UniqueModule mod{tid};
241 double trig_ampl = get_estimate(trig);
242 double trig_energy = calculate_energy(mod.layer_, trig_ampl) / nominal_;
243
245 if (module_sums.find(mod) == module_sums.end()) {
246 module_sums[mod] = {0, 0.0};
247 }
248
249 module_sums[mod].first += trig_energy;
250 trig_prim_total += trig_energy;
251 if (mod.layer_ <= 20) {
252 trig_prim_total_first20 += trig_energy;
253 }
254
255 // calculate the sum of precision hits for the 9 cells in this
256 // trigger grouping
257 double trig_group_prec_total{0};
258 double trig_group_prec_total_unweight{0};
259 for (auto& prec_id : geom.contentsOfTriggerCell(tid)) {
260 for (const auto& hit : hits) {
261 if (prec_id == hit.getID()) {
262 trig_group_prec_total +=
263 calculate_energy(mod.layer_, hit.getAmplitude());
264 trig_group_prec_total_unweight += hit.getAmplitude();
265 }
266 }
267 }
268
269 // have trig_group_prec_total which is the sum of the precision hits
270 // in that trigger group and trig_ampl is the sum
271 // as reported by the trigger itself
272 double ratio_energy = trig_energy / trig_group_prec_total,
273 ratio_ampl = trig_ampl / trig_group_prec_total_unweight / nominal_;
274 histograms_.fill("trig_group", trig_group_prec_total);
275 histograms_.fill("trig_group_trigger", trig_energy * nominal_);
276 histograms_.fill("trig_group_v_trig", trig_group_prec_total,
277 trig_energy * nominal_);
278 histograms_.fill("trig_group_ampl_v_ampl", trig_group_prec_total,
279 ratio_energy);
280 histograms_.fill("trig_group_ampl_v_ampl_varbin", trig_group_prec_total,
281 ratio_energy);
282 histograms_.fill("trig_group_ampl_v_ampl_varbin_fin", trig_group_prec_total,
283 ratio_energy);
284 histograms_.fill("trig_group_ampl_unweight", trig_group_prec_total_unweight,
285 ratio_ampl);
286 }
287
288 double prec_ampl_total{0.};
289 double prec_ampl_total_first20{0.};
290 for (const auto& hit : hits) {
291 EcalID id{static_cast<unsigned int>(hit.getID())};
292 UniqueModule mod{id};
293 if (module_sums.find(mod) == module_sums.end()) {
294 module_sums[mod] = {0, 0.0};
295 }
296 double prec_energy = calculate_energy(mod.layer_, hit.getAmplitude());
297 module_sums[mod].second += prec_energy;
298 prec_ampl_total += prec_energy;
299 if (mod.layer_ <= 20) {
300 prec_ampl_total_first20 += prec_energy;
301 }
302 }
303
304 std::map<int, std::pair<int, double>> layer_sums;
305 for (const auto& [unique_module, sum_pair] : module_sums) {
306 if (layer_sums.find(unique_module.layer_) == layer_sums.end()) {
307 // layer is not found in layer_sums map so start the sum at 0
308 layer_sums[unique_module.layer_] = {0, 0.0};
309 }
310 // add this module total to running total for the layer
311 layer_sums[unique_module.layer_].first += sum_pair.first;
312 layer_sums[unique_module.layer_].second += sum_pair.second;
313 }
314
315 int layer_id_tmp = {0};
316 int module_id_tmp = {0};
317 for (const auto& [mod_id, sum_pair] : module_sums) {
318 /* std::cout << " layer id " << mod_id.layer_ << " mod id " <<
319 * mod_id.module_ << std::endl; */
320 layer_id_tmp = mod_id.layer_;
321 module_id_tmp = mod_id.module_;
322 histograms_.fill("layer_id", layer_id_tmp);
323 histograms_.fill("module_id", module_id_tmp);
324 histograms_.fill("trig_sum_per_module", sum_pair.first);
325 histograms_.fill("ampl_sum_per_module", sum_pair.second);
326 histograms_.fill("trig_v_ampl_module", sum_pair.second, sum_pair.first);
327 histograms_.fill("trig_ampl_v_ampl", sum_pair.second,
328 sum_pair.first / sum_pair.second);
329 histograms_.fill("trig_ampl_v_ampl_binadjust", sum_pair.second,
330 sum_pair.first / sum_pair.second);
331 }
332
333 for (const auto& [layer, layer_sum_pair] : layer_sums) {
334 histograms_.fill("trig_sum_per_layer", layer_sum_pair.first);
335 histograms_.fill("ampl_sum_per_layer", layer_sum_pair.second);
336 histograms_.fill("trig_v_ampl_layer", layer_sum_pair.first,
337 layer_sum_pair.second);
338 histograms_.fill("trig_ampl_v_ampl_layer", layer_sum_pair.second,
339 layer_sum_pair.first / layer_sum_pair.second);
340 }
341
342 histograms_.fill("total_trig_energy", trig_prim_total);
343 histograms_.fill("total_ampl_energy", prec_ampl_total);
344 histograms_.fill("total_trig_v_total_ampl", trig_prim_total, prec_ampl_total);
345 histograms_.fill("trig_ampl_nominal", trig_prim_total / prec_ampl_total);
346 histograms_.fill("trig_ampl_v_ampl_total", prec_ampl_total,
347 trig_prim_total / prec_ampl_total);
348 histograms_.fill("trig_ampl_v_ampl_total_first20", prec_ampl_total_first20,
349 trig_prim_total_first20 / prec_ampl_total_first20);
350}
HistogramHelper histograms_
Interface class for making and filling histograms.
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
Contains the trigger output for a single trigger hgcroc channel.
double calculate_energy(int layer, double amplitude)
Calculate the energy deposited estimate from a hit's amplitude.

References calculate_energy(), framework::HistogramHelper::fill(), ldmx::HgcrocTrigDigi::getId(), and framework::EventProcessor::histograms_.

◆ calculate_energy()

double ldmx::ecal::TrigPrimResolutionAnalyzer::calculate_energy ( int  layer,
double  amplitude 
)
inline

Calculate the energy deposited estimate from a hit's amplitude.

We scale the amplitude by the layer weight with a few other factors.

Definition at line 47 of file TrigPrimResolutionAnalyzer.cxx.

47 {
48 return (1 + layerWeights_[layer] / mip_si_energy_) * amplitude *
49 secondOrderEnergyCorrection_;
50 }

Referenced by analyze().

◆ configure()

void ldmx::ecal::TrigPrimResolutionAnalyzer::configure ( framework::config::Parameters parameters)
finalvirtual

Callback for the EventProcessor to configure itself from the given set of parameters.

The parameters a processor has access to are the member variables of the python class in the sequence that has className equal to the EventProcessor class name.

For an example, look at MyProcessor.

Parameters
parametersParameters for configuration.

Reimplemented from framework::EventProcessor.

Definition at line 65 of file TrigPrimResolutionAnalyzer.cxx.

66 {
67 optional_update(trig_collection_name);
68 optional_update(trig_pass_name);
69 optional_update(hit_collection_name);
70 optional_update(hit_pass_name);
71 optional_update(total_trigger_mean);
72 optional_update(total_ampl_mean);
73 optional_update(secondOrderEnergyCorrection);
74 optional_update(mip_si_energy);
75 optional_update(layerWeights);
76
77 // nominal scale separation between trigger and precision would be
78 // determined experimentally by comparing their values
79 // nominal_ = total_trigger_mean_ / total_ampl_mean_;
80 // this has already been done so we just hardcode in the value
81 // determined by Steven Metallo in 2024, but it can be updated
82 // to use the ratio of the totals like above
83 nominal_ = 18.14;
84}

◆ onProcessStart()

void ldmx::ecal::TrigPrimResolutionAnalyzer::onProcessStart ( )
finalvirtual

Callback for the EventProcessor to take any necessary action when the processing of events starts, such as creating histograms.

Reimplemented from framework::EventProcessor.

Definition at line 86 of file TrigPrimResolutionAnalyzer.cxx.

86 {
87 // variable bins
88 std::vector<double> binsx = {0., 10., 20., 30., 40., 50., 60.,
89 70., 80., 90., 100., 110., 120., 130.,
90 140., 150., 300., 575., 1000.};
91 std::vector<double> binsy = {
92 0.6, 0.608, 0.616, 0.624, 0.632, 0.64, 0.648, 0.656, 0.664, 0.672,
93 0.68, 0.688, 0.696, 0.704, 0.712, 0.72, 0.728, 0.736, 0.744, 0.752,
94 0.76, 0.768, 0.776, 0.784, 0.792, 0.8, 0.808, 0.816, 0.824, 0.832,
95 0.84, 0.848, 0.856, 0.864, 0.872, 0.88, 0.888, 0.896, 0.904, 0.912,
96 0.92, 0.928, 0.936, 0.944, 0.952, 0.96, 0.968, 0.976, 0.984, 0.992,
97 1., 1.008, 1.016, 1.024, 1.032, 1.04, 1.048, 1.056, 1.064, 1.072,
98 1.08, 1.088, 1.096, 1.104, 1.112, 1.12, 1.128, 1.136, 1.144, 1.152,
99 1.16, 1.168, 1.176, 1.184, 1.192, 1.2, 1.208, 1.216, 1.224, 1.232,
100 1.24, 1.248, 1.256, 1.264, 1.272, 1.28, 1.288, 1.296, 1.304, 1.312,
101 1.32, 1.328, 1.336, 1.344, 1.352, 1.36, 1.368, 1.376, 1.384, 1.392,
102 1.4};
103 std::vector<double> binsx_fin = {0., 10., 20., 30., 40., 50., 60., 70.,
104 80., 90., 100., 150., 300., 575., 1000.};
105
106 // initialize processing by making histograms and such
107 // first, we get the directory for this processor in the histogram file
109 // then we can create histograms within it
111 "total_trig_energy" /* name - as written in output ROOT file */,
112 "Total of all Trig Digis [MeV]" /* xlabel - axis label of histogram */,
113 100 /* number of bins */, 0 /* minimum value */, 8000 /* maximum value */
114 );
115 histograms_.create("total_ampl_energy",
116 "Total of Precision Hit Amplitudes [MeV]", 100, 0, 8000);
117 histograms_.create("total_trig_v_total_ampl", "Total of all Trig Digis [MeV]",
118 1000, 0, 8000, "Total of Precision Hit Amplitudes [MeV]",
119 100, 0, 8000);
120 histograms_.create("trig_ampl_nominal", "Total trig / total ampl", 100, 0.85,
121 1.15);
122 histograms_.create("module_id", "Module id", 7, 0, 7);
123 histograms_.create("layer_id", "Layer id", 34, 0, 34);
124 histograms_.create("trig_sum_per_module", "module trigger sum [MeV]", 100, 0,
125 2000);
126 histograms_.create("ampl_sum_per_module", "module precision ampl sum [MeV]",
127 100, 0, 2000);
128 histograms_.create("trig_v_ampl_module", "Module-sum full readout [MeV]", 100,
129 0, 2000, "Module-sum trigger [MeV]", 100, 0, 2000);
130 histograms_.create("trig_sum_per_layer", "layer trigger sum [MeV]", 100, 0,
131 2000);
132 histograms_.create("ampl_sum_per_layer", "layer precision ampl sum [MeV]",
133 100, 0, 2000);
134 histograms_.create("trig_v_ampl_layer", "Layer trigger total [MeV]", 100, 0,
135 2500, "Layer ampl total [MeV]", 100, 0, 2500);
136 histograms_.create("trig_ampl_v_ampl", "module precision ampl sum [MeV]", 100,
137 0, 1000, "module trigger / module precision ampl", 100,
138 0.4, 1.2);
139 histograms_.create("trig_ampl_v_ampl_binadjust",
140 "module precision trig sum [MeV]", 100, 0, 2000,
141 "module trigger / module precision ampl", 100, 0.4, 1.2);
142 histograms_.create("trig_ampl_v_ampl_layer", "layer precision ampl sum [MeV]",
143 100, 0, 1000, "layer trigger / layer precision ampl", 100,
144 0.4, 1.2);
145 histograms_.create("trig_ampl_v_ampl_total", "total precision ampl sum [MeV]",
146 100, 0, 8000, "total trigger / total precision ampl", 100,
147 0.9, 1.1);
148 histograms_.create("trig_ampl_v_ampl_total_first20", "Full readout sum [MeV]",
149 100, 0, 6000, "Trigger / Full readout", 100, 0.95, 1.05);
150 histograms_.create("trig_group", "trigger group total precision hits [MeV]",
151 100, 0, 2000);
152 histograms_.create("trig_group_trigger", "trigger group trigger [MeV]", 100,
153 0, 8000);
154 histograms_.create("trig_group_v_trig",
155 "trigger group total precision hits [MeV]", 100, 0, 2000,
156 "trigger group trigger [MeV]", 100, 0, 8000);
157 histograms_.create("trig_group_ampl_v_ampl",
158 "Trigger group full readout [MeV]", 100, 0, 1000,
159 "Trigger group ratio / nominal", 200, 0.6, 1.4);
160 histograms_.create("trig_group_ampl_v_ampl_varbin",
161 "Trigger group full readout [MeV]", binsx,
162 "Trigger group ratio / nominal", binsy);
163 histograms_.create("trig_group_ampl_unweight",
164 "unweighted trigger group total precision hits [MeV]", 100,
165 0, 20,
166 "trigger group trigger / unweighted trigger group total "
167 "prec hits / nominal",
168 200, 0.6, 1.4);
169 histograms_.create("trig_group_ampl_v_ampl_varbin_fin",
170 "Trigger group full readout [MeV]", binsx_fin,
171 "Trigger group ratio / nominal", binsy);
172}
TDirectory * getHistoDirectory()
Access/create a directory in the histogram file for this event processor to create histograms and ana...
void create(const std::string &name, const std::string &xLabel, const double &bins, const double &xmin, const double &xmax)
Create a ROOT 1D histogram of type TH1F and pool it for later use.

References framework::HistogramHelper::create(), framework::EventProcessor::getHistoDirectory(), and framework::EventProcessor::histograms_.

Member Data Documentation

◆ hit_collection_name_

std::string ldmx::ecal::TrigPrimResolutionAnalyzer::hit_collection_name_ = "EcalRecHits"
private

Definition at line 20 of file TrigPrimResolutionAnalyzer.cxx.

◆ hit_pass_name_

std::string ldmx::ecal::TrigPrimResolutionAnalyzer::hit_pass_name_ = ""
private

Definition at line 21 of file TrigPrimResolutionAnalyzer.cxx.

◆ layerWeights_

std::vector<double> ldmx::ecal::TrigPrimResolutionAnalyzer::layerWeights_
private
Initial value:
= {
2.312, 4.312, 6.522, 7.490, 8.595, 10.253, 10.915, 10.915, 10.915,
10.915, 10.915, 10.915, 10.915, 10.915, 10.915, 10.915, 10.915, 10.915,
10.915, 10.915, 10.915, 10.915, 10.915, 14.783, 18.539, 18.539, 18.539,
18.539, 18.539, 18.539, 18.539, 18.539, 18.539, 9.938}

Definition at line 27 of file TrigPrimResolutionAnalyzer.cxx.

27 {
28 2.312, 4.312, 6.522, 7.490, 8.595, 10.253, 10.915, 10.915, 10.915,
29 10.915, 10.915, 10.915, 10.915, 10.915, 10.915, 10.915, 10.915, 10.915,
30 10.915, 10.915, 10.915, 10.915, 10.915, 14.783, 18.539, 18.539, 18.539,
31 18.539, 18.539, 18.539, 18.539, 18.539, 18.539, 9.938};

◆ mip_si_energy_

double ldmx::ecal::TrigPrimResolutionAnalyzer::mip_si_energy_ = 0.13
private

Definition at line 26 of file TrigPrimResolutionAnalyzer.cxx.

◆ nominal_

double ldmx::ecal::TrigPrimResolutionAnalyzer::nominal_ {1.0}
private

Definition at line 24 of file TrigPrimResolutionAnalyzer.cxx.

24{1.0};

◆ secondOrderEnergyCorrection_

double ldmx::ecal::TrigPrimResolutionAnalyzer::secondOrderEnergyCorrection_ = 4000. / 3940.5
private

Definition at line 25 of file TrigPrimResolutionAnalyzer.cxx.

◆ total_ampl_mean_

double ldmx::ecal::TrigPrimResolutionAnalyzer::total_ampl_mean_ = 48.805244
private

Definition at line 23 of file TrigPrimResolutionAnalyzer.cxx.

◆ total_trigger_mean_

double ldmx::ecal::TrigPrimResolutionAnalyzer::total_trigger_mean_ = 876.28120
private

Definition at line 22 of file TrigPrimResolutionAnalyzer.cxx.

◆ trig_collection_name_

std::string ldmx::ecal::TrigPrimResolutionAnalyzer::trig_collection_name_ = "ecalTrigDigis"
private

Definition at line 18 of file TrigPrimResolutionAnalyzer.cxx.

◆ trig_pass_name_

std::string ldmx::ecal::TrigPrimResolutionAnalyzer::trig_pass_name_ = ""
private

Definition at line 19 of file TrigPrimResolutionAnalyzer.cxx.


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