Belle II Software  release-08-00-05
eclAutocovarianceCalibrationC2Collector.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/eclAutocovarianceCalibrationC2Collector/eclAutocovarianceCalibrationC2Collector.h>
11 
12 //Framework
13 #include <framework/dataobjects/EventMetaData.h>
14 
15 //ECL
16 #include <ecl/dataobjects/ECLDsp.h>
17 #include <ecl/dbobjects/ECLCrystalCalib.h>
18 
19 using namespace std;
20 using namespace Belle2;
21 
22 //-----------------------------------------------------------------
23 // Register the Modules
24 //-----------------------------------------------------------------
25 REG_MODULE(eclAutocovarianceCalibrationC2Collector);
26 //-----------------------------------------------------------------
27 // Implementation
28 //-----------------------------------------------------------------
29 
30 // constructor
31 eclAutocovarianceCalibrationC2CollectorModule::eclAutocovarianceCalibrationC2CollectorModule() : CalibrationCollectorModule(),
32  m_ECLAutocovarianceCalibrationC1Threshold("ECLAutocovarianceCalibrationC1Threshold")
33 {
34  // Set module properties
35  setDescription("Module to export histogram corresponding to sum of waveforms from random trigger events. Used to compute baseline");
37 }
38 
40 {
41 
42 
45  m_BaselineVsCrysID = new TH1D("m_BaselineVsCrysID", "Baseline for each crystal;crystal ID;Baseline (ADC)",
47  registerObject<TH1D>("m_BaselineVsCrysID", m_BaselineVsCrysID);
48  m_CounterVsCrysID = new TH1D("m_CounterVsCrysID", "Baseline for each crystal;crystal ID;Baseline (ADC)",
50  registerObject<TH1D>("m_CounterVsCrysID", m_CounterVsCrysID);
51  m_eclDsps.isRequired();
52 
53 }
54 
56 {
58  B2INFO("eclAutocovarianceCalibrationC2Collector: Experiment = " << m_evtMetaData->getExperiment() << " run = " <<
59  m_evtMetaData->getRun());
61 }
62 
64 {
65 
66  const int NumDsp = m_eclDsps.getEntries();
67 
68  //Random Trigger Events have waveform for each crystal
69  if (NumDsp == ECLElementNumbers::c_NCrystals) {
70 
71  for (auto& aECLDsp : m_eclDsps) {
72 
73  const int id = aECLDsp.getCellId() - 1;
74 
75  float peakToPeakThreshold = m_PeakToPeakThresholds[id];
76 
77  //Peak to peak amplitude used to gauge noise level
78  float PeakToPeak = (float) aECLDsp.computePeaktoPeakAmp();
79 
80  if (PeakToPeak < peakToPeakThreshold) {
81 
82  for (int i = 0; i < m_numberofADCPoints; i++) m_sumOfSamples[id] += aECLDsp.getDspA()[i];
84 
85  }
86 
87  }
88  }
89 }
90 
92 {
93  for (int i = 0; i < ECLElementNumbers::c_NCrystals; i++) {
94  B2INFO(i << " " << getObjectPtr<TH1>("m_BaselineVsCrysID")->GetBinContent(i + 1));
95  getObjectPtr<TH1D>("m_BaselineVsCrysID")->SetBinContent(i + 1, m_sumOfSamples[i]);
96  getObjectPtr<TH1D>("m_CounterVsCrysID")->SetBinContent(i + 1, m_nSelectedWaveforms[i]);
97  }
98 }
Calibration collector module base class.
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
StoreArray< ECLDsp > m_eclDsps
Required input array of ECLDSPs.
double m_sumOfSamples[ECLElementNumbers::c_NCrystals]
sum of 31 samples for selected waveforms
int m_nSelectedWaveforms[ECLElementNumbers::c_NCrystals]
number of selected waveforms for each crystal
DBObjPtr< ECLCrystalCalib > m_ECLAutocovarianceCalibrationC1Threshold
peak to peak noise threshold computed from step C1
void collect() override
Select events and crystals and accumulate histograms.
StoreObjPtr< EventMetaData > m_evtMetaData
dataStore EventMetaData
std::vector< float > m_PeakToPeakThresholds
vector of thresholds obtained from DB object
TH1D * m_CounterVsCrysID
final histogram returned by collector contains counter
void prepare() override
Define histograms and read payloads from DB.
TH1D * m_BaselineVsCrysID
final histogram returned by collector contains baseline
#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.