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