Belle II Software development
TimeWalkCalibration.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#include <framework/logging/Logger.h>
12
13#include <TH1D.h>
14#include <TH2D.h>
15#include "string"
16
17namespace Belle2 {
22 namespace CDC {
28 public:
34 virtual void setUseDB(bool useDB) {m_useDB = useDB; }
36 virtual void setStoreHisto(bool storeHist) {m_storeHisto = storeHist;}
38 virtual void setMinimumNDF(double minndf) {m_ndfmin = minndf;}
40 virtual void setMinimumPval(double minPval) {m_Pvalmin = minPval;}
42 virtual void InputFileNames(std::string inputname) {m_InputRootFileName.assign(inputname);}
44 virtual void InputTWFileName(std::string tw_name) {m_InputTWFileName.assign(tw_name);}
46 virtual void OutputTWFileName(std::string tw_out_name) {m_outputTWFileName.assign(tw_out_name);}
48 virtual void OutputT0FileName(std::string t0_out_name) {m_outputT0FileName.assign(t0_out_name);}
50 virtual void setMode(unsigned short mode)
51 {
52 m_twParamMode_new = mode;
53 if (mode == 0)
55 else if (mode == 1)
57 else
58 B2FATAL("Mode hasn't implemented yet");
59 }
61 virtual void execute()
62 {
63 calibrate();
64 }
65
66 protected:
68 virtual bool calibrate();
70 virtual void CreateHisto();
72 virtual void Write();
74 virtual void updateT0();
76 virtual void readTW();
78 virtual void fitToExponentialFunc(TH1D* h1);
79
80 private:
81 TH1D* m_h1[300];
82 TH2D* m_h2[300];
84 double m_xmin = 0.07;
85 double m_ndfmin = 20;
86 double m_Pvalmin = 0.;
87 // double m_oldTW[300][2] = {{0.}}; /**< Time Walk params of previous iteration*/
88 // double m_tw[300][3] = {{0.}}; /**< Time Walk params, result after fitting*
89 double m_constTerm[300] = {0.};
90 std::vector<float> m_tw_old[300];
91 std::vector<float> m_tw_new[300];
92 bool m_storeHisto = true;
93 bool m_useDB = false;
94 unsigned short m_flag[300];
95 std::string m_InputTWFileName = "tw.dat";
96 std::string m_InputT0FileName = "t0.dat";
97 std::string m_outputTWFileName = "tw_new.dat";
98 std::string m_outputT0FileName = "t0.dat";
99 std::string m_InputRootFileName = "rootfile/output*";
101 int m_firstRun = 0;
103 int m_lastRun = -1;
104 unsigned short m_twParamMode_old;
105 unsigned short m_twParamMode_new = 1;
106 unsigned short m_nTwParams_new = 2;
107 unsigned short m_nTwParams_old;
108 };
109 }//namespace CDC
111} // namespace Belle2
112
Class for Time walk calibration.
unsigned short m_twParamMode_new
=0 for P0/Sqrt(ADC); =1 for P0*Exp(-P1*ADC).
double m_xmin
minimum value cut of drift length.
virtual void readTW()
read tw from database
std::string m_outputT0FileName
Output tw file name for time walk.
TH2D * m_h2[300]
2D histogram of residual vs ADC for each board
virtual void setMinimumPval(double minPval)
minimum chi2 prob requirement for track
double m_constTerm[300]
const term in fitting, it will be added to T0 instead tw
bool m_storeHisto
Store all Histogram or not.
virtual void setMinimumNDF(double minndf)
minimum number of degree freedom requirement for track
double m_ndfmin
minimum number of degree of freedom required for track.
unsigned short m_flag[300]
flag for fit status
virtual void setStoreHisto(bool storeHist)
Store Histogram or not.
std::string m_InputT0FileName
Old t0 file name.
virtual void InputTWFileName(std::string tw_name)
Input tw file name, incase use text mode.
virtual void updateT0()
update constant term to t0 database.
std::vector< float > m_tw_old[300]
tw list old.
virtual void setUseDB(bool useDB)
setting for use database or text mode
virtual void Write()
save calibration
std::string m_InputTWFileName
Old tw file name.
virtual ~TimeWalkCalibration()
Destructor.
std::string m_outputTWFileName
Output tw file name for time walk.
virtual void OutputT0FileName(std::string t0_out_name)
output t0 file name, for text mode
std::vector< float > m_tw_new[300]
tw list new.
virtual void InputFileNames(std::string inputname)
input root file names, output of collector
virtual bool calibrate()
Run algorithm.
virtual void CreateHisto()
Create histo for calibrate.
std::string m_InputRootFileName
root input file name.
virtual void fitToExponentialFunc(TH1D *h1)
fit tw histogram
unsigned short m_twParamMode_old
=0 for P0/Sqrt(ADC); =1 for P0*Exp(-P1*ADC).
virtual void execute()
function to run algorithm
TH1D * m_h1[300]
Mean of residual as function of ADC of each board.
double m_Pvalmin
minimum number of Prob(chi2) of fitted track.
virtual void setMode(unsigned short mode)
Set time walk mode.
virtual void OutputTWFileName(std::string tw_out_name)
output tw file name, for text mode
bool m_useDB
flag to switch btw text mode and database.
Abstract base class for different kinds of events.