Belle II Software  release-08-01-10
ECLDigitCalibratorModule.h
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 #pragma once
10 
11 /* ECL headers. */
12 #include <ecl/dataobjects/ECLElementNumbers.h>
13 #include <ecl/utility/ECLTimingUtilities.h>
14 
15 /* Basf2 headers. */
16 #include <framework/core/Module.h>
17 #include <framework/database/DBObjPtr.h>
18 #include <framework/datastore/StoreArray.h>
19 #include <framework/datastore/StoreObjPtr.h>
20 
21 /* C++ headers. */
22 #include <vector>
23 
24 class TH1F;
25 class TFile;
26 
27 namespace Belle2 {
33  class EventLevelClusteringInfo;
34 
35  class ECLCrystalCalib;
36  class ECLDigit;
37  class ECLDsp;
38  class ECLCalDigit;
39  class ECLPureCsIInfo;
40 
43 
44  public:
45 
49 
53 
55  virtual void initialize() override;
56 
58  virtual void beginRun() override;
59 
62  virtual void event() override;
63 
65  virtual void endRun() override;
66 
68  virtual void terminate() override;
69 
71  virtual const char* eclDigitArrayName() const
72  { return "ECLDigits" ; }
73 
75  virtual const char* eclDspArrayName() const
76  { return "ECLDsps" ; }
77 
79  virtual const char* eclCalDigitArrayName() const
80  { return "ECLCalDigits" ; }
81 
83  virtual const char* eventLevelClusteringInfoName() const
84  { return "EventLevelClusteringInfo" ; }
85 
87  virtual const char* eclPureCsIInfoArrayName() const
88  { return "ECLPureCsIInfo" ; }
89 
90  protected:
91 
92  private:
93 
99  std::vector < float > v_calibrationCrystalElectronics;
100  std::vector < float > v_calibrationCrystalElectronicsUnc;
103  std::vector < float > v_calibrationCrystalEnergy;
104  std::vector < float > v_calibrationCrystalEnergyUnc;
107  std::vector < float > v_calibrationCrystalElectronicsTime;
108  std::vector < float >
112  std::vector < float > v_calibrationCrystalTimeOffset;
113  std::vector < float > v_calibrationCrystalTimeOffsetUnc;
116  std::vector < float > v_calibrationCrateTimeOffset;
117  std::vector < float > v_calibrationCrateTimeOffsetUnc;
121  std::vector < float > v_calibrationCrystalFlightTime;
122  std::vector < float > v_calibrationCrystalFlightTimeUnc;
134  double m_pureCsIEnergyCalib = 0.00005;
135  double m_pureCsITimeCalib = 10.;
136  double m_pureCsITimeOffset = 0.31;
138  void initializeCalibration();
139  void callbackCalibration(DBObjPtr<ECLCrystalCalib>& cal, std::vector<float>& constants,
140  std::vector<float>& constantsUnc);
142  double getT99(const int cellid, const double energy, const bool fitfailed, const int bgcount) const;
143  int determineBackgroundECL();
145  const double c_timeResolutionForFitFailed = 1.0e9;
146  const double c_timeForFitFailed = 0.0;
148  // new time calibration from Kim and Chris
149  std::string m_fileBackgroundName;
150  TFile* m_fileBackground{nullptr};
151  TH1F* m_th1fBackground{nullptr};
153  const double c_pol2Var1 = 1684.0;
154  const double c_pol2Var2 = 3080.0;
155  const double c_pol2Var3 = -613.9;
156  double m_pol2Max;
157  const int c_nominalBG = 183;
158  double m_averageBG;
159  const double c_minT99 = 3.5;
161  bool m_simulatePure = 0;
164  std::unique_ptr< Belle2::ECL::ECLTimingUtilities > ECLTimeUtil =
165  std::make_unique<Belle2::ECL::ECLTimingUtilities>();
167  // For the energy dependence correction to the time
168  // t-t0 = p1 + pow( (p3/(amplitude+p2)), p4 ) + p5*exp(-amplitude/p6) ("Energy dependence equation")
169  // Only change the time walk function paramters if they change away from the below dummy values
177  };
178 
181  public:
183  virtual const char* eclDigitArrayName() const override
184  { return "ECLDigitsPureCsI" ; }
185 
187  virtual const char* eclCalDigitArrayName() const override
188  { return "ECLCalDigitsPureCsI" ; }
189 
191  virtual const char* eclDspArrayName() const override
192  { return "ECLDspsPureCsI" ; }
193 
195  virtual const char* eventLevelClusteringInfoName() const override
196  { return "EventLevelClusteringInfoPureCsI" ; }
197 
198  };
199 
201 } // end Belle2 namespace
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
Class to find calibrate digits and convert waveform fit information to physics quantities.
double m_pureCsITimeCalib
conversion factor from eclPureCsIDigitizer to ns.
double m_energyDependenceTimeOffsetFitParam_p5
p5 in "energy dependence equation"
const double c_pol2Var2
2-order fit for p1.
StoreArray< ECLDsp > m_eclDsps
storearray ECLDsp
virtual const char * eclDigitArrayName() const
Name of the ECLDigit.
DBObjPtr< ECLCrystalCalib > m_calibrationCrateTimeOffset
single crate time calibration offset (per crystal)
double m_pureCsITimeOffset
ad-hoc offset correction for pureCsI timing/
TH1F * m_th1fBackground
Background histogram.
DBObjPtr< ECLCrystalCalib > m_calibrationCrystalElectronics
single crystal electronics calibration
double m_energyDependenceTimeOffsetFitParam_p2
p2 in "energy dependence equation"
const double c_minT99
The minimum t99.
virtual void initialize() override
Initialize variables.
std::vector< float > v_calibrationCrystalElectronicsUnc
single crystal electronics calibration as vector uncertainty
std::string m_fileBackgroundName
Background filename.
std::vector< float > v_calibrationCrateTimeOffsetUnc
single crate time calibration offset as vector uncertainty (per crystal)
double m_energyDependenceTimeOffsetFitParam_p3
p3 in "energy dependence equation"
double m_energyDependenceTimeOffsetFitParam_p6
p6 in "energy dependence equation"
std::vector< float > v_calibrationCrystalElectronicsTimeUnc
single crystal time calibration offset electronics as vector uncertainty
virtual void event() override
event per event.
DBObjPtr< ECLCrystalCalib > m_calibrationCrystalEnergy
single crystal energy calibration
StoreArray< ECLPureCsIInfo > m_eclPureCsIInfo
storearray ECLPureCsIInfo - Special information for pure CsI simulation
virtual void endRun() override
end run.
double getT99(const int cellid, const double energy, const bool fitfailed, const int bgcount) const
t99%.
virtual void terminate() override
terminate.
const double c_pol2Var1
2-order fit for p1 Var1 + Var2*bg + Var3*bg^2.
StoreArray< ECLDigit > m_eclDigits
storearray ECLDigit
const double c_timeResolutionForFitFailed
Time resolution for failed fits".
std::vector< float > v_calibrationCrystalElectronicsTime
single crystal time calibration offset electronics as vector
std::vector< float > v_calibrationCrystalFlightTime
single crystal time calibration TOF as vector
void callbackCalibration(DBObjPtr< ECLCrystalCalib > &cal, std::vector< float > &constants, std::vector< float > &constantsUnc)
reads calibration constants
std::unique_ptr< Belle2::ECL::ECLTimingUtilities > ECLTimeUtil
ECL timing tools.
double m_energyDependenceTimeOffsetFitParam_p4
p4 in "energy dependence equation"
void initializeCalibration()
reads calibration constants, performs checks, put them into a vector
std::vector< float > v_calibrationCrystalEnergy
single crystal energy calibration as vector
std::vector< float > v_calibrationCrystalEnergyUnc
single crystal energy calibration as vector uncertainty
virtual void beginRun() override
begin run.
virtual const char * eclPureCsIInfoArrayName() const
Name of the ECL pure CsI Information.
const double c_pol2Var3
2-order fit for p1.
std::vector< float > v_calibrationCrateTimeOffset
single crate time calibration offset as vector (per crystal)
const double c_timeForFitFailed
Time for failed fits".
int determineBackgroundECL()
count out of time digits to determine baclground levels
double m_timeInverseSlope
Time calibration inverse slope "a".
DBObjPtr< ECLCrystalCalib > m_calibrationCrystalTimeOffset
single crystal time calibration offset
double m_backgroundTimingCut
Timing window for background level counting.
std::vector< float > v_calibrationCrystalElectronics
single crystal electronics calibration as vector
DBObjPtr< ECLCrystalCalib > m_calibrationCrystalElectronicsTime
single crystal time calibration offset electronics
virtual const char * eventLevelClusteringInfoName() const
Name of the EventLevelClusteringInfo.
double m_pureCsIEnergyCalib
conversion factor from ADC counts to GeV.
double m_energyDependenceTimeOffsetFitParam_p1
p1 in "energy dependence equation"
const int c_nCrystals
Number of ECL crystals.
std::vector< float > v_calibrationCrystalTimeOffset
single crystal time calibration offset as vector
virtual const char * eclDspArrayName() const
Name of the ECLDsp.
DBObjPtr< ECLCrystalCalib > m_calibrationCrystalFlightTime
single crystal time calibration TOF
double m_averageBG
Average dose per crystal calculated from m_th1dBackground.
double m_pol2Max
Maximum of p1 2-order fit to limit values.
std::vector< float > v_calibrationCrystalFlightTimeUnc
single crystal time calibration TOF as vector uncertainty
double m_backgroundEnergyCut
Energy cut for background level counting.
virtual const char * eclCalDigitArrayName() const
Name of the ECLCalDigit.
StoreObjPtr< EventLevelClusteringInfo > m_eventLevelClusteringInfo
event level clustering info
StoreArray< ECLCalDigit > m_eclCalDigits
storearray ECLCalDigit
const int c_nominalBG
Number of out of time digits at BGx1.0.
std::vector< float > v_calibrationCrystalTimeOffsetUnc
single crystal time calibration offset as vector uncertainty
bool m_simulatePure
Flag to set pure CsI simulation option.
Class derived from ECLDigitCalibratorModule, only difference are the names.
virtual const char * eclCalDigitArrayName() const override
PureCsI Name of the ECLCalDigitsPureCsI.
virtual const char * eclDspArrayName() const override
Name of the ECLDspPureCsI.
virtual const char * eventLevelClusteringInfoName() const override
PureCsI Name of the EventLevelClusteringInfoPureCsI.
virtual const char * eclDigitArrayName() const override
PureCsI Name of the ECLDigitsPureCsI.
Base class for Modules.
Definition: Module.h:72
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
const int c_NCrystals
Number of crystals.
Abstract base class for different kinds of events.