Belle II Software development
eclWaveformTemplateCalibrationC1Collector.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9//This module`
10#include <ecl/modules/eclWaveformTemplateCalibrationC1Collector/eclWaveformTemplateCalibrationC1Collector.h>
11
12//Framework
13#include <framework/dataobjects/EventMetaData.h>
14
15//ECL
16#include <ecl/dataobjects/ECLDigit.h>
17#include <ecl/dataobjects/ECLDsp.h>
18#include <ecl/dbobjects/ECLCrystalCalib.h>
19
20using namespace std;
21using namespace Belle2;
22
23//-----------------------------------------------------------------
24// Register the Modules
25//-----------------------------------------------------------------
26REG_MODULE(eclWaveformTemplateCalibrationC1Collector);
27//-----------------------------------------------------------------
28// Implementation
29//-----------------------------------------------------------------
30
31// constructor
33{
34 // Set module properties
35 setDescription("Module to export histogram of baseline noise of energetic waveforms from ee->gg events. First step in photon template calculation.");
36 addParam("MinEnergyThreshold", m_MinEnergyThreshold, "Minimum energy threshold of online fit result for Fitting Waveforms (GeV).",
37 2.0);
38 addParam("MaxEnergyThreshold", m_MaxEnergyThreshold, "Maximum energy threshold of online fit result for Fitting Waveforms (GeV).",
39 4.0);
40 addParam("baselineLimit", m_baselineLimit, "Number of ADC points used to define baseline.", 12);
41 addParam("maxResvsCrysIDHistogramLimit", m_maxResvsCrysIDHistogramLimit, "upper limit of histogram.", 100);
42 addParam("maxResvsCrysIDHistogramNBins", m_maxResvsCrysIDHistogramNBins, "histogram number of bins.", 1000);
43 addParam("ADCFloorThreshold", m_ADCFloorThreshold, "Used to determine if waveform hit ADC floor", 10);
45}
46
48{
49
54 registerObject<TH2F>("maxResvsCrysID", maxResvsCrysID);
55
56 m_eclDsps.isRequired();
57 m_eclDigits.isRequired();
58
59}
60
62{
64 B2INFO("eclWaveformTemplateCalibrationC1Collector: Experiment = " << m_evtMetaData->getExperiment() << " run = " <<
65 m_evtMetaData->getRun());
66
67 // Loading crystal calibration constants from database
69 if (m_CrystalElectronics.isValid()) {
70 for (int i = 0; i < ECLElementNumbers::c_NCrystals; i++)
71 m_ADCtoEnergy[i] = m_CrystalElectronics->getCalibVector()[i];
72 }
73 if (m_CrystalEnergy.isValid()) {
74 for (int i = 0; i < ECLElementNumbers::c_NCrystals; i++)
75 m_ADCtoEnergy[i] *= m_CrystalEnergy->getCalibVector()[i];
76 }
77
78}
79
80
82{
83
84 for (auto& aECLDsp : m_eclDsps) {
85
86 const int id = aECLDsp.getCellId() - 1;
87
88 //estimating crystal energy
89 double energy = 0.0;
90 for (const auto& aECLDigit : m_eclDigits) {
91 if (aECLDigit.getCellId() - 1 == id) {
92 energy = aECLDigit.getAmp() * m_ADCtoEnergy[id];
93 break;
94 }
95 }
96
97 // only select high energy crystals
98 if (energy < m_MinEnergyThreshold) continue;
99 // avoid very high energy crystals due to potential photodiode interactions
100 if (energy > m_MaxEnergyThreshold) continue;
101
102 // check if waveform has point below m_ADCFloorThreshold (indicates waveform hit ADC floor)
103 bool skipWaveform = false;
104 for (int i = 0; i < m_numberofADCPoints; i++) {
105 if (aECLDsp.getDspA()[i] < m_ADCFloorThreshold) skipWaveform = true;
106 }
107 if (skipWaveform) continue;
108
109 //compute mean of baseline
110 float baseline = 0.0;
111 for (int i = 0; i < m_baselineLimit; i++) baseline += aECLDsp.getDspA()[i];
112 baseline /= ((float) m_baselineLimit);
113
114 //compute max residual in baseline
115 float maxRes = 0.0;
116 for (int i = 0; i < m_baselineLimit; i++) {
117 float temp = fabs(aECLDsp.getDspA()[i] - baseline);
118 if (temp > maxRes) maxRes = temp;
119 }
120
121 //save result to histogram
122 maxResvsCrysID->Fill(id, maxRes);
123
124 }
125
126}
127
129{
130 for (int i = 0; i < ECLElementNumbers::c_NCrystals; i++) {
131 for (int j = 0; j < m_maxResvsCrysIDHistogramNBins; j++) {
132 getObjectPtr<TH2>("maxResvsCrysID")->SetBinContent(i + 1, j + 1, maxResvsCrysID->GetBinContent(i + 1, j + 1));
133 }
134 }
135}
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
double m_MaxEnergyThreshold
Maximum energy threshold of online fit result for Fitting Waveforms.
StoreArray< ECLDigit > m_eclDigits
Required input array of ECLDigits.
void collect() override
Select events and crystals and accumulate histograms.
void prepare() override
Define histograms and read payloads from DB.
double m_MinEnergyThreshold
Minimum energy threshold of online fit result for Fitting Waveforms.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
const int c_NCrystals
Number of crystals.
Abstract base class for different kinds of events.
STL namespace.