Belle II Software  release-05-02-19
ECLDigitCalibratorModule.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2020 - Belle II Collaboration *
4  * *
5  * Digit Calibration. *
6  * *
7  * This module converts the fitted amplitude into calibrated energy, *
8  * fitted time into calibrated time, and determines the time resolution *
9  * per digit. It furthermore determines the background level by counting *
10  * out of time digits above a certain energy threshold. *
11  * *
12  * Author: The Belle II Collaboration *
13  * Contributors: Torben Ferber (ferber@physics.ubc.ca) (TF) *
14  * Chris Hearty (hearty@physics.ubc.ca) (CH) *
15  * Ewan Hill (ehill@mail.ubc.ca) *
16  * *
17  * This software is provided "as is" without any warranty. *
18  **************************************************************************/
19 
20 #pragma once
21 
22 // STL
23 #include <vector>
24 
25 // FRAMEWORK
26 #include <framework/core/Module.h>
27 #include <framework/datastore/StoreObjPtr.h>
28 #include <framework/datastore/StoreArray.h>
29 #include <framework/database/DBObjPtr.h>
30 
31 #include <ecl/utility/ECLTimingUtilities.h>
32 
33 class TH1F;
34 class TFile;
35 
36 namespace Belle2 {
42  class EventLevelClusteringInfo;
43 
44  class ECLCrystalCalib;
45  class ECLDigit;
46  class ECLDsp;
47  class ECLCalDigit;
48  class ECLPureCsIInfo;
49 
52 
53  public:
54 
58 
62 
64  virtual void initialize() override;
65 
67  virtual void beginRun() override;
68 
71  virtual void event() override;
72 
74  virtual void endRun() override;
75 
77  virtual void terminate() override;
78 
80  virtual const char* eclDigitArrayName() const
81  { return "ECLDigits" ; }
82 
84  virtual const char* eclDspArrayName() const
85  { return "ECLDsps" ; }
86 
88  virtual const char* eclCalDigitArrayName() const
89  { return "ECLCalDigits" ; }
90 
92  virtual const char* eventLevelClusteringInfoName() const
93  { return "EventLevelClusteringInfo" ; }
94 
96  virtual const char* eclPureCsIInfoArrayName() const
97  { return "ECLPureCsIInfo" ; }
98 
99  protected:
100 
101  private:
102 
106  const int c_nCrystals = 8736;
108  std::vector < float > v_calibrationCrystalElectronics;
109  std::vector < float > v_calibrationCrystalElectronicsUnc;
112  std::vector < float > v_calibrationCrystalEnergy;
113  std::vector < float > v_calibrationCrystalEnergyUnc;
116  std::vector < float > v_calibrationCrystalElectronicsTime;
117  std::vector < float >
121  std::vector < float > v_calibrationCrystalTimeOffset;
122  std::vector < float > v_calibrationCrystalTimeOffsetUnc;
125  std::vector < float > v_calibrationCrateTimeOffset;
126  std::vector < float > v_calibrationCrateTimeOffsetUnc;
130  std::vector < float > v_calibrationCrystalFlightTime;
131  std::vector < float > v_calibrationCrystalFlightTimeUnc;
143  double m_pureCsIEnergyCalib = 0.00005;
144  double m_pureCsITimeCalib = 10.;
145  double m_pureCsITimeOffset = 0.31;
147  void initializeCalibration();
148  void callbackCalibration(DBObjPtr<ECLCrystalCalib>& cal, std::vector<float>& constants,
149  std::vector<float>& constantsUnc);
151  double getT99(const int cellid, const double energy, const bool fitfailed, const int bgcount) const;
152  int determineBackgroundECL();
154  const double c_timeResolutionForFitFailed = 1.0e9;
155  const double c_timeForFitFailed = 0.0;
157  // new time calibration from Kim and Chris
158  std::string m_fileBackgroundName;
159  TFile* m_fileBackground{nullptr};
160  TH1F* m_th1fBackground{nullptr};
162  const double c_pol2Var1 = 1684.0;
163  const double c_pol2Var2 = 3080.0;
164  const double c_pol2Var3 = -613.9;
165  double m_pol2Max;
166  const int c_nominalBG = 183;
167  double m_averageBG;
168  const double c_minT99 = 3.5;
170  bool m_simulatePure = 0;
173  std::unique_ptr< Belle2::ECL::ECLTimingUtilities > ECLTimeUtil =
174  std::make_unique<Belle2::ECL::ECLTimingUtilities>();
176  // For the energy dependence correction to the time
177  // t-t0 = p1 + pow( (p3/(amplitude+p2)), p4 ) + p5*exp(-amplitude/p6) ("Energy dependence equation")
178  // Only change the time walk function paramters if they change away from the below dummy values
186  };
187 
190  public:
192  virtual const char* eclDigitArrayName() const override
193  { return "ECLDigitsPureCsI" ; }
194 
196  virtual const char* eclCalDigitArrayName() const override
197  { return "ECLCalDigitsPureCsI" ; }
198 
200  virtual const char* eclDspArrayName() const override
201  { return "ECLDspsPureCsI" ; }
202 
204  virtual const char* eventLevelClusteringInfoName() const override
205  { return "EventLevelClusteringInfoPureCsI" ; }
206 
207  };
208 
210 } // end Belle2 namespace
Belle2::ECLDigitCalibratorModule::m_timeInverseSlope
double m_timeInverseSlope
Time calibration inverse slope "a".
Definition: ECLDigitCalibratorModule.h:141
Belle2::ECLDigitCalibratorModule::initializeCalibration
void initializeCalibration()
reads calibration constants, performs checks, put them into a vector
Definition: ECLDigitCalibratorModule.cc:114
Belle2::ECLDigitCalibratorModule::~ECLDigitCalibratorModule
~ECLDigitCalibratorModule()
Destructor.
Definition: ECLDigitCalibratorModule.cc:109
Belle2::ECLDigitCalibratorModule::v_calibrationCrystalTimeOffset
std::vector< float > v_calibrationCrystalTimeOffset
single crystal time calibration offset as vector
Definition: ECLDigitCalibratorModule.h:121
Belle2::ECLDigitCalibratorModule::m_energyDependenceTimeOffsetFitParam_p2
double m_energyDependenceTimeOffsetFitParam_p2
p2 in "energy dependence equation"
Definition: ECLDigitCalibratorModule.h:180
Belle2::ECLDigitCalibratorModule::m_eclPureCsIInfo
StoreArray< ECLPureCsIInfo > m_eclPureCsIInfo
storearray ECLPureCsIInfo - Special information for pure CsI simulation
Definition: ECLDigitCalibratorModule.h:139
Belle2::ECLDigitCalibratorModule::m_th1fBackground
TH1F * m_th1fBackground
Background histogram.
Definition: ECLDigitCalibratorModule.h:160
Belle2::ECLDigitCalibratorModule::event
virtual void event() override
event per event.
Definition: ECLDigitCalibratorModule.cc:242
Belle2::ECLDigitCalibratorModule::m_calibrationCrystalTimeOffset
DBObjPtr< ECLCrystalCalib > m_calibrationCrystalTimeOffset
single crystal time calibration offset
Definition: ECLDigitCalibratorModule.h:123
Belle2::ECLDigitCalibratorModule::terminate
virtual void terminate() override
terminate.
Definition: ECLDigitCalibratorModule.cc:394
Belle2::ECLDigitCalibratorModule::v_calibrationCrystalElectronics
std::vector< float > v_calibrationCrystalElectronics
single crystal electronics calibration as vector
Definition: ECLDigitCalibratorModule.h:108
Belle2::ECLDigitCalibratorModule::m_eventLevelClusteringInfo
StoreObjPtr< EventLevelClusteringInfo > m_eventLevelClusteringInfo
event level clustering info
Definition: ECLDigitCalibratorModule.h:134
Belle2::ECLDigitCalibratorModule::m_calibrationCrystalElectronicsTime
DBObjPtr< ECLCrystalCalib > m_calibrationCrystalElectronicsTime
single crystal time calibration offset electronics
Definition: ECLDigitCalibratorModule.h:119
Belle2::ECLDigitCalibratorModule::m_eclCalDigits
StoreArray< ECLCalDigit > m_eclCalDigits
storearray ECLCalDigit
Definition: ECLDigitCalibratorModule.h:137
Belle2::ECLDigitCalibratorModule::ECLDigitCalibratorModule
ECLDigitCalibratorModule()
Constructor.
Definition: ECLDigitCalibratorModule.cc:64
Belle2::ECLDigitCalibratorModule::m_calibrationCrateTimeOffset
DBObjPtr< ECLCrystalCalib > m_calibrationCrateTimeOffset
single crate time calibration offset (per crystal)
Definition: ECLDigitCalibratorModule.h:128
Belle2::ECLDigitCalibratorModule::v_calibrationCrystalElectronicsUnc
std::vector< float > v_calibrationCrystalElectronicsUnc
single crystal electronics calibration as vector uncertainty
Definition: ECLDigitCalibratorModule.h:109
Belle2::ECLDigitCalibratorPureCsIModule::eclDigitArrayName
virtual const char * eclDigitArrayName() const override
PureCsI Name of the ECLDigitsPureCsI.
Definition: ECLDigitCalibratorModule.h:192
Belle2::ECLDigitCalibratorModule::eclPureCsIInfoArrayName
virtual const char * eclPureCsIInfoArrayName() const
Name of the ECL pure CsI Information.
Definition: ECLDigitCalibratorModule.h:96
Belle2::ECLDigitCalibratorModule::v_calibrationCrystalTimeOffsetUnc
std::vector< float > v_calibrationCrystalTimeOffsetUnc
single crystal time calibration offset as vector uncertainty
Definition: ECLDigitCalibratorModule.h:122
Belle2::ECLDigitCalibratorModule::endRun
virtual void endRun() override
end run.
Definition: ECLDigitCalibratorModule.cc:388
Belle2::ECLDigitCalibratorModule::m_fileBackgroundName
std::string m_fileBackgroundName
Background filename.
Definition: ECLDigitCalibratorModule.h:158
Belle2::ECLDigitCalibratorModule::m_pureCsIEnergyCalib
double m_pureCsIEnergyCalib
conversion factor from ADC counts to GeV.
Definition: ECLDigitCalibratorModule.h:143
Belle2::ECLDigitCalibratorModule::m_backgroundEnergyCut
double m_backgroundEnergyCut
Energy cut for background level counting.
Definition: ECLDigitCalibratorModule.h:103
Belle2::ECLDigitCalibratorModule::m_backgroundTimingCut
double m_backgroundTimingCut
Timing window for background level counting.
Definition: ECLDigitCalibratorModule.h:104
Belle2::ECLDigitCalibratorModule::determineBackgroundECL
int determineBackgroundECL()
count out of time digits to determine baclground levels
Definition: ECLDigitCalibratorModule.cc:431
Belle2::ECLDigitCalibratorPureCsIModule
Class derived from ECLDigitCalibratorModule, only difference are the names.
Definition: ECLDigitCalibratorModule.h:189
Belle2::ECLDigitCalibratorModule::m_energyDependenceTimeOffsetFitParam_p1
double m_energyDependenceTimeOffsetFitParam_p1
p1 in "energy dependence equation"
Definition: ECLDigitCalibratorModule.h:179
Belle2::DBObjPtr
Class for accessing objects in the database.
Definition: DBObjPtr.h:31
Belle2::ECLDigitCalibratorModule::eventLevelClusteringInfoName
virtual const char * eventLevelClusteringInfoName() const
Name of the EventLevelClusteringInfo.
Definition: ECLDigitCalibratorModule.h:92
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::ECLDigitCalibratorModule::c_timeForFitFailed
const double c_timeForFitFailed
Time for failed fits".
Definition: ECLDigitCalibratorModule.h:155
Belle2::ECLDigitCalibratorModule::m_pureCsITimeOffset
double m_pureCsITimeOffset
ad-hoc offset correction for pureCsI timing/
Definition: ECLDigitCalibratorModule.h:145
Belle2::ECLDigitCalibratorModule::m_calibrationCrystalEnergy
DBObjPtr< ECLCrystalCalib > m_calibrationCrystalEnergy
single crystal energy calibration
Definition: ECLDigitCalibratorModule.h:114
Belle2::ECLDigitCalibratorModule
Class to find calibrate digits and convert waveform fit information to physics quantities.
Definition: ECLDigitCalibratorModule.h:51
Belle2::ECLDigitCalibratorModule::m_energyDependenceTimeOffsetFitParam_p4
double m_energyDependenceTimeOffsetFitParam_p4
p4 in "energy dependence equation"
Definition: ECLDigitCalibratorModule.h:182
Belle2::ECLDigitCalibratorModule::initialize
virtual void initialize() override
Initialize variables.
Definition: ECLDigitCalibratorModule.cc:142
Belle2::ECLDigitCalibratorModule::ECLTimeUtil
std::unique_ptr< Belle2::ECL::ECLTimingUtilities > ECLTimeUtil
ECL timing tools.
Definition: ECLDigitCalibratorModule.h:173
Belle2::ECLDigitCalibratorModule::v_calibrationCrateTimeOffsetUnc
std::vector< float > v_calibrationCrateTimeOffsetUnc
single crate time calibration offset as vector uncertainty (per crystal)
Definition: ECLDigitCalibratorModule.h:126
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::ECLDigitCalibratorPureCsIModule::eclDspArrayName
virtual const char * eclDspArrayName() const override
Name of the ECLDspPureCsI.
Definition: ECLDigitCalibratorModule.h:200
Belle2::StoreObjPtr
Type-safe access to single objects in the data store.
Definition: ParticleList.h:33
Belle2::ECLDigitCalibratorModule::eclCalDigitArrayName
virtual const char * eclCalDigitArrayName() const
Name of the ECLCalDigit.
Definition: ECLDigitCalibratorModule.h:88
Belle2::ECLDigitCalibratorModule::eclDspArrayName
virtual const char * eclDspArrayName() const
Name of the ECLDsp.
Definition: ECLDigitCalibratorModule.h:84
Belle2::ECLDigitCalibratorModule::eclDigitArrayName
virtual const char * eclDigitArrayName() const
Name of the ECLDigit.
Definition: ECLDigitCalibratorModule.h:80
Belle2::ECLDigitCalibratorModule::m_energyDependenceTimeOffsetFitParam_p5
double m_energyDependenceTimeOffsetFitParam_p5
p5 in "energy dependence equation"
Definition: ECLDigitCalibratorModule.h:183
Belle2::ECLDigitCalibratorModule::c_timeResolutionForFitFailed
const double c_timeResolutionForFitFailed
Time resolution for failed fits".
Definition: ECLDigitCalibratorModule.h:154
Belle2::ECLDigitCalibratorModule::callbackCalibration
void callbackCalibration(DBObjPtr< ECLCrystalCalib > &cal, std::vector< float > &constants, std::vector< float > &constantsUnc)
reads calibration constants
Definition: ECLDigitCalibratorModule.cc:133
Belle2::ECLDigitCalibratorModule::c_pol2Var2
const double c_pol2Var2
2-order fit for p1.
Definition: ECLDigitCalibratorModule.h:163
Belle2::ECLDigitCalibratorModule::m_pureCsITimeCalib
double m_pureCsITimeCalib
conversion factor from eclPureCsIDigitizer to ns.
Definition: ECLDigitCalibratorModule.h:144
Belle2::ECLDigitCalibratorModule::m_calibrationCrystalFlightTime
DBObjPtr< ECLCrystalCalib > m_calibrationCrystalFlightTime
single crystal time calibration TOF
Definition: ECLDigitCalibratorModule.h:132
Belle2::ECLDigitCalibratorModule::m_eclDsps
StoreArray< ECLDsp > m_eclDsps
storearray ECLDsp
Definition: ECLDigitCalibratorModule.h:138
Belle2::ECLDigitCalibratorModule::m_averageBG
double m_averageBG
Average dose per crystal calculated from m_th1dBackground.
Definition: ECLDigitCalibratorModule.h:167
Belle2::ECLDigitCalibratorModule::m_simulatePure
bool m_simulatePure
Flag to set pure CsI simulation option.
Definition: ECLDigitCalibratorModule.h:170
Belle2::ECLDigitCalibratorModule::v_calibrationCrystalFlightTimeUnc
std::vector< float > v_calibrationCrystalFlightTimeUnc
single crystal time calibration TOF as vector uncertainty
Definition: ECLDigitCalibratorModule.h:131
Belle2::ECLDigitCalibratorModule::m_pol2Max
double m_pol2Max
Maximum of p1 2-order fit to limit values.
Definition: ECLDigitCalibratorModule.h:165
Belle2::ECLDigitCalibratorModule::m_energyDependenceTimeOffsetFitParam_p6
double m_energyDependenceTimeOffsetFitParam_p6
p6 in "energy dependence equation"
Definition: ECLDigitCalibratorModule.h:184
Belle2::ECLDigitCalibratorModule::v_calibrationCrystalElectronicsTime
std::vector< float > v_calibrationCrystalElectronicsTime
single crystal time calibration offset electronics as vector
Definition: ECLDigitCalibratorModule.h:116
Belle2::ECLDigitCalibratorModule::v_calibrationCrateTimeOffset
std::vector< float > v_calibrationCrateTimeOffset
single crate time calibration offset as vector (per crystal)
Definition: ECLDigitCalibratorModule.h:125
Belle2::ECLDigitCalibratorModule::v_calibrationCrystalEnergy
std::vector< float > v_calibrationCrystalEnergy
single crystal energy calibration as vector
Definition: ECLDigitCalibratorModule.h:112
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::ECLDigitCalibratorModule::getT99
double getT99(const int cellid, const double energy, const bool fitfailed, const int bgcount) const
t99%.
Definition: ECLDigitCalibratorModule.cc:400
Belle2::ECLDigitCalibratorPureCsIModule::eclCalDigitArrayName
virtual const char * eclCalDigitArrayName() const override
PureCsI Name of the ECLCalDigitsPureCsI.
Definition: ECLDigitCalibratorModule.h:196
Belle2::ECLDigitCalibratorModule::v_calibrationCrystalElectronicsTimeUnc
std::vector< float > v_calibrationCrystalElectronicsTimeUnc
single crystal time calibration offset electronics as vector uncertainty
Definition: ECLDigitCalibratorModule.h:118
Belle2::ECLDigitCalibratorModule::m_energyDependenceTimeOffsetFitParam_p3
double m_energyDependenceTimeOffsetFitParam_p3
p3 in "energy dependence equation"
Definition: ECLDigitCalibratorModule.h:181
Belle2::ECLDigitCalibratorModule::c_minT99
const double c_minT99
The minimum t99.
Definition: ECLDigitCalibratorModule.h:168
Belle2::ECLDigitCalibratorModule::c_pol2Var1
const double c_pol2Var1
2-order fit for p1 Var1 + Var2*bg + Var3*bg^2.
Definition: ECLDigitCalibratorModule.h:162
Belle2::ECLDigitCalibratorModule::m_eclDigits
StoreArray< ECLDigit > m_eclDigits
storearray ECLDigit
Definition: ECLDigitCalibratorModule.h:136
Belle2::ECLDigitCalibratorModule::v_calibrationCrystalEnergyUnc
std::vector< float > v_calibrationCrystalEnergyUnc
single crystal energy calibration as vector uncertainty
Definition: ECLDigitCalibratorModule.h:113
Belle2::ECLDigitCalibratorModule::beginRun
virtual void beginRun() override
begin run.
Definition: ECLDigitCalibratorModule.cc:199
Belle2::ECLDigitCalibratorModule::m_calibrationCrystalElectronics
DBObjPtr< ECLCrystalCalib > m_calibrationCrystalElectronics
single crystal electronics calibration
Definition: ECLDigitCalibratorModule.h:110
Belle2::ECLDigitCalibratorModule::c_pol2Var3
const double c_pol2Var3
2-order fit for p1.
Definition: ECLDigitCalibratorModule.h:164
Belle2::ECLDigitCalibratorModule::c_nCrystals
const int c_nCrystals
Number of ECL crystals.
Definition: ECLDigitCalibratorModule.h:106
Belle2::ECLDigitCalibratorModule::m_fileBackground
TFile * m_fileBackground
Background file.
Definition: ECLDigitCalibratorModule.h:159
Belle2::ECLDigitCalibratorModule::c_nominalBG
const int c_nominalBG
Number of out of time digits at BGx1.0.
Definition: ECLDigitCalibratorModule.h:166
Belle2::ECLDigitCalibratorPureCsIModule::eventLevelClusteringInfoName
virtual const char * eventLevelClusteringInfoName() const override
PureCsI Name of the EventLevelClusteringInfoPureCsI.
Definition: ECLDigitCalibratorModule.h:204
Belle2::ECLDigitCalibratorModule::v_calibrationCrystalFlightTime
std::vector< float > v_calibrationCrystalFlightTime
single crystal time calibration TOF as vector
Definition: ECLDigitCalibratorModule.h:130