Belle II Software  release-08-01-10
XTCalibration.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 #include "string"
9 #include "TH2D.h"
10 #include "TH1D.h"
11 #include "TF1.h"
12 namespace Belle2 {
17  namespace CDC {
21  class XTCalibration {
22  public:
24  XTCalibration();
26  virtual ~XTCalibration() {}
28  virtual void BField(bool bfield) {m_BField = bfield;}
30  virtual void setDebug(bool debug = false) {m_debug = debug; }
32  virtual void setUseDB(bool useDB = false) {m_useDB = useDB; }
34  virtual void setMinimumNDF(double minndf) {m_ndfmin = minndf;}
36  virtual void setMinimumPval(double minPval) {m_Pvalmin = minPval;}
38  virtual void inputFileNames(std::string inputname) {m_inputRootFileNames.assign(inputname);}
40  virtual void profileFileNames(std::string profileFileName) {m_profileFileName.assign(profileFileName);}
42  virtual void useProfileFromInputXT(bool useProfileXTFromInputXT) {m_useProfileXTFromInputXT = useProfileXTFromInputXT;}
44  virtual void setXTFileName(std::string name) {m_xtfile.assign(name);}
46  virtual void setMode(unsigned short mode = 1) {m_xtmode = mode;}
48  virtual void setStoreHisto(bool storeHist = false) {m_storeHisto = storeHist;}
50  void setLRSeparate(bool lr = true) {m_LRseparate = lr;}
51 
52 
54  void execute()
55  {
56  calibrate();
57  }
58 
59  protected:
61  virtual bool calibrate();
63  virtual void readXTFromDB();
65  virtual void readXTFromText();
67  virtual void CreateHisto();
69  virtual void readProfile();
71  virtual void readXT();
73  virtual void Write();
75  virtual void storeHisto();
76 
77  private:
78  double m_ndfmin = 5;
79  double m_Pvalmin = 0.;
80  bool m_debug = false;
81  bool m_storeHisto = false;
82  bool m_useDB = false;
84  bool m_LRseparate = true;
85  bool m_useSliceFit = false;
86  bool m_BField = true;
88  //double m_XT_fit[56][2][18][7][8]; /**< Fitted parameter*/
89  double xtold[56][2][18][7][8];
90  int fitflag[56][2][20][10];
91  TF1* xtf5r[56][2][20][10];
93  TProfile* hprof[56][2][20][10];
94  TH2D* hist2d[56][2][20][10];
95  TH2D* hist2d_draw[56][20][10];
96  TH1D* hist2d_1[56][2][20][10];
97  /*********************************
98  Fit Flag
99  =-1: low statitic
100  =1: good
101  =0: Fit failure
102  =2: Error Outer
103  =3: Error Inner part;
104  **********************************/
105 
106  std::string m_OutputXTFileName = "xt_new.dat";
107  std::string m_inputRootFileNames = "rootfile/output*";
108  std::string m_profileFileName = "xt_profile";
109  std::string m_xtfile = "cdc/data/xt.dat";
111  //int m_firstExperiment; /**< First experiment. */
112  //int m_firstRun; /**< First run. */
113  //int m_lastExperiment; /**< Last experiment */
114  //int m_lastRun; /**< Last run. */
115 
116  // double m_alpha[18][3];//alpha bin, 18bin, 0=low, 1 = up, 2 = alpha
117  //double m_theta[10][3];//alpha bin, 18bin, 0=low, 1 = up, 2 = alpha
118  // unsigned short m_xtParamMode; /*!< Mode for xt parameterization */
119  //unsigned short m_nXtParams; /*!< no. of xt parameters per bin */
120  int m_nalpha;
121  int m_ntheta;
122  double l_alpha[18];
123  double u_alpha[18];
124  double ialpha[18];
125  double l_theta[7];
126  double u_theta[7];
127  double itheta[7];
131  double l_alpha_old[18];
132  double u_alpha_old[18];
133  double ialpha_old[18];
134  double l_theta_old[7];
135  double u_theta_old[7];
136  double itheta_old[7];
138  unsigned short xtmode_old;
139  int m_MAXalpha = 18;
140  int m_MAXtheta = 7;
141  unsigned short m_xtmode = 1;
144  double m_par6[56] = {89, 91, 94, 99, 104, 107, 110, 117,
145  126, 144, 150, 157, 170, 180,
146  160, 167, 183, 205, 200, 194,
147  177, 189, 192, 206, 224, 234,
148  193, 206, 209, 215, 222, 239,
149  204, 212, 217, 227, 235, 240,
150  215, 222, 230, 239, 246, 253,
151  227, 232, 239, 243, 253, 258,
152  231, 243, 246, 256, 263, 300
153  };
154 
155  };
156  }
158 }
Class to perform xt calibration for drift chamber.
Definition: XTCalibration.h:21
bool m_BField
with b field or none
Definition: XTCalibration.h:86
unsigned short xtmode_old
XT mode old, 0-polynomial, 1 Cheb.
virtual void storeHisto()
Store histogram to file.
double ialpha[18]
represented alphas of alpha bins.
virtual void setStoreHisto(bool storeHist=false)
set to store histogram or not.
Definition: XTCalibration.h:48
virtual void useProfileFromInputXT(bool useProfileXTFromInputXT)
if you want to change xt bining, you have to set this to true
Definition: XTCalibration.h:42
std::string m_inputRootFileNames
input root filename
bool m_useProfileXTFromInputXT
use profile from text file or default in input xt
Definition: XTCalibration.h:83
virtual void setMinimumPval(double minPval)
set minimum Prob(Chi2) requirement
Definition: XTCalibration.h:36
double m_par6[56]
boundary parameter for fitting, semi-experiment number
double xtold[56][2][18][7][8]
Old paremeter.
Definition: XTCalibration.h:89
int m_nalpha
number of alpha bins
int m_MAXalpha
max alpha bin
virtual void readXTFromText()
Read old xt parameter from text file, incase text mode is used.
bool m_storeHisto
Store histogram or not.
Definition: XTCalibration.h:81
TProfile * hprof[56][2][20][10]
Profile xt histo.
Definition: XTCalibration.h:93
double u_alpha[18]
Upper boundays of alpha bins.
virtual void setMinimumNDF(double minndf)
set minimum number of degree of freedom requirement
Definition: XTCalibration.h:34
virtual void BField(bool bfield)
set to use BField
Definition: XTCalibration.h:28
virtual void readXT()
read xt paramter (wrap text mode and database mode)
bool m_LRseparate
Separate LR in calibration or mix.
Definition: XTCalibration.h:84
virtual void readProfile()
Read profile xt file.
double m_ndfmin
minimum ndf required
Definition: XTCalibration.h:78
void execute()
Run calibration.
Definition: XTCalibration.h:54
virtual void inputFileNames(std::string inputname)
Input root file name, output of collector.
Definition: XTCalibration.h:38
bool m_debug
run in debug or silent
Definition: XTCalibration.h:80
double l_theta_old[7]
Lower boundays of theta bins from input.
double l_alpha[18]
Lower boundays of alpha bins.
virtual ~XTCalibration()
Destructor.
Definition: XTCalibration.h:26
int m_ntheta
number of theta bins
std::string m_OutputXTFileName
Out put xt filename.
virtual void readXTFromDB()
Read old xt parameter from database.
virtual void Write()
Store calibrated constand.
int nalpha_old
number of alpha bins from input
TH2D * hist2d_draw[56][20][10]
2d histo for draw
Definition: XTCalibration.h:95
double itheta_old[7]
represented alphas of theta bins from input.
virtual void setMode(unsigned short mode=1)
set xt mode, 0 is polynimial, 1 is Chebshev polynomial
Definition: XTCalibration.h:46
virtual void setUseDB(bool useDB=false)
Set to run with database mode or text mode.
Definition: XTCalibration.h:32
double l_alpha_old[18]
Lower boundays of alpha bins from input.
bool m_useSliceFit
Use slice fit or profile.
Definition: XTCalibration.h:85
TH1D * hist2d_1[56][2][20][10]
1D xt histo, results of slice fit
Definition: XTCalibration.h:96
std::string m_xtfile
Input xt file name, incase text mode.
double u_theta_old[7]
Upper boundays of theta bins from input.
virtual bool calibrate()
Run algo on data.
virtual void CreateHisto()
Create histogram for calibration.
double itheta[7]
represented alphas of theta bins.
double ialpha_old[18]
represented alphas of alpha bins from input.
double l_theta[7]
Lower boundays of theta bins.
int m_MAXtheta
max theta bin
void setLRSeparate(bool lr=true)
Set LR separate mode (default is true).
Definition: XTCalibration.h:50
unsigned short m_xtmode
Mode of xt; 0 is polynomial;1 is Chebyshev.
int fitflag[56][2][20][10]
Fit flag.
Definition: XTCalibration.h:90
TF1 * xtf5r[56][2][20][10]
XTFunction.
Definition: XTCalibration.h:91
virtual void profileFileNames(std::string profileFileName)
Profile file name incase you want to change the xt binning.
Definition: XTCalibration.h:40
TH2D * hist2d[56][2][20][10]
2D histo of xt
Definition: XTCalibration.h:94
double m_Pvalmin
minimum pvalue required
Definition: XTCalibration.h:79
double u_alpha_old[18]
Upper boundays of alpha bins from input.
virtual void setDebug(bool debug=false)
Run in debug or silent.
Definition: XTCalibration.h:30
double u_theta[7]
Upper boundays of theta bins.
int ntheta_old
number of theta bins from input
bool m_useDB
Use Database or text mode.
Definition: XTCalibration.h:82
virtual void setXTFileName(std::string name)
input xt file name incase text mode is used.
Definition: XTCalibration.h:44
std::string m_profileFileName
profile file name
int m_smallestEntryRequire
minimum number of hit per hitosgram.
Abstract base class for different kinds of events.