Belle II Software  release-08-01-10
eclAutocovarianceCalibrationC1Collector.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 /* Own header. */
10 #include <ecl/modules/eclAutocovarianceCalibrationC1Collector/eclAutocovarianceCalibrationC1Collector.h>
11 
12 /* ECL headers. */
13 #include <ecl/dataobjects/ECLDsp.h>
14 #include <ecl/dataobjects/ECLElementNumbers.h>
15 
16 /* Basf2 headers. */
17 #include <framework/dataobjects/EventMetaData.h>
18 
19 using namespace std;
20 using namespace Belle2;
21 
22 //-----------------------------------------------------------------
23 // Register the Modules
24 //-----------------------------------------------------------------
25 REG_MODULE(eclAutocovarianceCalibrationC1Collector);
26 //-----------------------------------------------------------------
27 // Implementation
28 //-----------------------------------------------------------------
29 
30 // constructor
31 eclAutocovarianceCalibrationC1CollectorModule::eclAutocovarianceCalibrationC1CollectorModule()
32 {
33  // Set module properties
34  setDescription("Module to export histogram of noise level of ECL waveforms in delayed Bhabha events");
35  setPropertyFlags(c_ParallelProcessingCertified);
36 }
37 
38 void eclAutocovarianceCalibrationC1CollectorModule::prepare()
39 {
40 
43  PPVsCrysID = new TH2F("PPVsCrysID", "Peak to peak amplitude for each crystal;crystal ID;Peak to peak Amplitud (ADC)",
44  ECLElementNumbers::c_NCrystals, 0,
45  ECLElementNumbers::c_NCrystals, MaxPeaktoPeakValue, 0, MaxPeaktoPeakValue);
46  registerObject<TH2F>("PPVsCrysID", PPVsCrysID);
47  m_eclDsps.isRequired();
48 }
49 
50 void eclAutocovarianceCalibrationC1CollectorModule::startRun()
51 {
53  B2INFO("eclAutocovarianceCalibrationC1Collector: Experiment = " << m_evtMetaData->getExperiment() << " run = " <<
54  m_evtMetaData->getRun());
55 }
56 
57 void eclAutocovarianceCalibrationC1CollectorModule::collect()
58 {
59 
60  //Checking how many waveforms saved in event
61  const int NumDsp = m_eclDsps.getEntries();
62 
63  //Random Trigger Events have waveform for each crystal
64  if (NumDsp == ECLElementNumbers::c_NCrystals) {
65 
66  for (auto& aECLDsp : m_eclDsps) {
67 
68  const int id = aECLDsp.getCellId() - 1;
69 
70  //Peak to peak amplitude used to gauge noise level
71  float PeakToPeak = (float) aECLDsp.computePeaktoPeakAmp();
72 
73  // I avoid using getObjectPtr<TH2>("PPVsCrysID")->Fill(id, PeakToPeak); to improve on run time as getObjectPtr is very slow
74  PPVsCrysID->Fill(id, PeakToPeak);
75 
76  }
77  }
78 }
79 
80 void eclAutocovarianceCalibrationC1CollectorModule::closeRun()
81 {
82  for (int i = 0; i < ECLElementNumbers::c_NCrystals; i++) {
83  for (int j = 0; j < MaxPeaktoPeakValue; j++) {
84  getObjectPtr<TH2>("PPVsCrysID")->SetBinContent(i + 1, j + 1, PPVsCrysID->GetBinContent(i + 1, j + 1));
85  }
86  }
87 }
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.