10 #include <ecl/modules/eclWaveformTemplateCalibrationC1Collector/eclWaveformTemplateCalibrationC1Collector.h>
13 #include <framework/dataobjects/EventMetaData.h>
16 #include <ecl/dataobjects/ECLDigit.h>
17 #include <ecl/dataobjects/ECLDsp.h>
18 #include <ecl/dbobjects/ECLCrystalCalib.h>
26 REG_MODULE(eclWaveformTemplateCalibrationC1Collector);
32 eclWaveformTemplateCalibrationC1CollectorModule::eclWaveformTemplateCalibrationC1CollectorModule()
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).",
38 addParam(
"MaxEnergyThreshold", m_MaxEnergyThreshold,
"Maximum energy threshold of online fit result for Fitting Waveforms (GeV).",
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);
44 setPropertyFlags(c_ParallelProcessingCertified);
47 void eclWaveformTemplateCalibrationC1CollectorModule::prepare()
52 maxResvsCrysID =
new TH2F(
"maxResvsCrysID",
"", ECLElementNumbers::c_NCrystals, 0, ECLElementNumbers::c_NCrystals,
53 m_maxResvsCrysIDHistogramNBins, 0, m_maxResvsCrysIDHistogramLimit);
54 registerObject<TH2F>(
"maxResvsCrysID", maxResvsCrysID);
56 m_eclDsps.isRequired();
57 m_eclDigits.isRequired();
61 void eclWaveformTemplateCalibrationC1CollectorModule::startRun()
64 B2INFO(
"eclWaveformTemplateCalibrationC1Collector: Experiment = " << m_evtMetaData->getExperiment() <<
" run = " <<
65 m_evtMetaData->getRun());
68 m_ADCtoEnergy.resize(ECLElementNumbers::c_NCrystals);
69 if (m_CrystalElectronics.isValid()) {
70 for (
int i = 0; i < ECLElementNumbers::c_NCrystals; i++)
71 m_ADCtoEnergy[i] = m_CrystalElectronics->getCalibVector()[i];
73 if (m_CrystalEnergy.isValid()) {
74 for (
int i = 0; i < ECLElementNumbers::c_NCrystals; i++)
75 m_ADCtoEnergy[i] *= m_CrystalEnergy->getCalibVector()[i];
81 void eclWaveformTemplateCalibrationC1CollectorModule::collect()
84 for (
auto& aECLDsp : m_eclDsps) {
86 const int id = aECLDsp.getCellId() - 1;
90 for (
const auto& aECLDigit : m_eclDigits) {
91 if (aECLDigit.getCellId() - 1 ==
id) {
92 energy = aECLDigit.getAmp() * m_ADCtoEnergy[id];
98 if (energy < m_MinEnergyThreshold)
continue;
100 if (energy > m_MaxEnergyThreshold)
continue;
103 bool skipWaveform =
false;
104 for (
int i = 0; i < m_numberofADCPoints; i++) {
105 if (aECLDsp.getDspA()[i] < m_ADCFloorThreshold) skipWaveform =
true;
107 if (skipWaveform)
continue;
110 float baseline = 0.0;
111 for (
int i = 0; i < m_baselineLimit; i++) baseline += aECLDsp.getDspA()[i];
112 baseline /= ((float) m_baselineLimit);
116 for (
int i = 0; i < m_baselineLimit; i++) {
117 float temp = fabs(aECLDsp.getDspA()[i] - baseline);
118 if (temp > maxRes) maxRes = temp;
122 maxResvsCrysID->Fill(
id, maxRes);
128 void eclWaveformTemplateCalibrationC1CollectorModule::closeRun()
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));
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.