Belle II Software development
XTCalibrationAlgorithm.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#include "string"
11#include "TH2D.h"
12#include "TH1D.h"
13#include "TF1.h"
14#include <calibration/CalibrationAlgorithm.h>
15#include <cdc/dbobjects/CDCGeometry.h>
16#include <framework/database/DBObjPtr.h>
17
18namespace Belle2 {
23 namespace CDC {
24
28 enum {c_Left = 0, c_Right = 1};
29
33 enum {c_Polynomial = 0, c_Chebyshev = 1};
34
44 enum FitStatus {c_lowStat = -1, c_fitFailure = 0, c_OK = 1,
45 c_errorOuter = 2, c_errorInner = 3
46 };
47
52 public:
55
58
60 void setBField(bool bfield) {m_bField = bfield;}
61
63 void setDebug(bool debug = false) {m_debug = debug; }
64
66 void setMinimumNDF(double ndf) {m_minNdf = ndf;}
67
69 void setMinimumPval(double pval) {m_minPval = pval;}
70
72 void setXtMode(unsigned short mode = c_Chebyshev) {m_xtMode = mode;}
73
75 void setStoreHisto(bool storeHist = false) {m_storeHisto = storeHist;}
76
78 void enableTextOutput(bool output = true) {m_textOutput = output;}
79
81 void setOutputFileName(std::string outputname) {m_outputFileName.assign(outputname);}
82
84 void setHistFileName(const std::string& name) {m_histName = "histXT_" + name + ".root";}
85
87 void setLRSeparate(bool lr = true) {m_LRseparate = lr;}
88
90 void setThreshold(double th = 0.6) {m_threshold = th;}
91
92
93 protected:
94
96 EResult calibrate() override;
97
99 void createHisto();
100
102 void write();
103
105 void storeHisto();
106
108 void prepare();
109
112
114 void sanitaryCheck();
115 private:
116 double m_minNdf = 5;
117 double m_minPval = 0.;
118 bool m_debug = false;
119 bool m_storeHisto = true;
120 bool m_LRseparate = true;
121 bool m_bField = true;
122 double m_threshold = 0.6;
124 TProfile* m_hProf[56][2][20][10];
125 TH2F* m_hist2d[56][2][20][10];
126 TH2F* m_hist2dDraw[56][20][10];
127 TH1F* m_hist2d_1[56][2][20][10];
128 TF1* m_xtFunc[56][2][20][10];
130 double m_xtPrior[56][2][18][7][8];
132 int m_fitStatus[56][2][20][10];
133 bool m_useSliceFit = false;
137 int m_xtMode = c_Chebyshev;
139 float m_lowerAlpha[18];
140 float m_upperAlpha[18];
141 float m_iAlpha[18];
142 float m_lowerTheta[7];
143 float m_upperTheta[7];
144 float m_iTheta[7];
146 double m_par6[56] = {89, 91, 94, 99, 104, 107, 110, 117,
147 126, 144, 150, 157, 170, 180,
148 160, 167, 183, 205, 200, 194,
149 177, 189, 192, 206, 224, 234,
150 193, 206, 209, 215, 222, 239,
151 204, 212, 217, 227, 235, 240,
152 215, 222, 230, 239, 246, 253,
153 227, 232, 239, 243, 253, 258,
154 231, 243, 246, 256, 263, 300
155 };
156
157 bool m_textOutput = false;
158 std::string m_outputFileName = "xt_new.dat";
159 std::string m_histName = "histXT.root";
161 };
162 }
164}
Class to perform xt calibration for drift chamber.
void setStoreHisto(bool storeHist=false)
set to store histogram or not.
void storeHisto()
Store histogram to file.
void setOutputFileName(std::string outputname)
output file name
void prepare()
Prepare the calibration of XT.
void sanitaryCheck()
Check if there are any wrong xt functions.
double m_par6[56]
boundary parameter for fitting, semi-experiment number
float m_lowerTheta[7]
Lower boundays of theta bins.
double m_xtPrior[56][2][18][7][8]
paremeters of XT before calibration
TF1 * m_xtFunc[56][2][20][10]
XTFunction.
void setDebug(bool debug=false)
Run in debug or silent.
bool m_storeHisto
Store histogram or not.
double m_threshold
minimal requirement for the fraction of fitted results
bool m_LRseparate
Separate LR in calibration or mix.
void createHisto()
Create histogram for calibration.
void setMinimumPval(double pval)
set minimum Prob(Chi2) requirement
int m_minEntriesRequired
minimum number of hit per hitosgram.
int m_fitStatus[56][2][20][10]
Fit flag.
TH2F * m_hist2d[56][2][20][10]
2D histo of xt
double m_minPval
minimum pvalue required
TProfile * m_hProf[56][2][20][10]
Profile xt histo.
float m_iAlpha[18]
Represented alpha in alpha bins.
void setMinimumNDF(double ndf)
set minimum number of degree of freedom requirement
float m_lowerAlpha[18]
Lower boundays of alpha bins.
DBObjPtr< CDCGeometry > m_cdcGeo
Geometry of CDC.
void enableTextOutput(bool output=true)
Enable text output of calibration result.
bool m_useSliceFit
Use slice fit or profile.
void setHistFileName(const std::string &name)
Set name for histogram output.
void setBField(bool bfield)
set to use BField
void write()
Store calibrated constand.
float m_upperAlpha[18]
Upper boundays of alpha bins.
void setLRSeparate(bool lr=true)
Set LR separate mode (default is true).
void setThreshold(double th=0.6)
Set threshold for the fraction of fitted results.
bool m_textOutput
output text file if true
EResult calibrate() override
Run algo on data.
EResult checkConvergence()
Check the convergence of XT fit.
int m_xtModePrior
Mode of xt before calibration; 0 is polynomial;1 is Chebyshev.
void setXtMode(unsigned short mode=c_Chebyshev)
set xt mode, 0 is polynimial, 1 is Chebshev polynomial
TH2F * m_hist2dDraw[56][20][10]
2d histo for draw
float m_upperTheta[7]
Upper boundays of theta bins.
int m_xtMode
Mode of xt; 0 is polynomial;1 is Chebyshev.
TH1F * m_hist2d_1[56][2][20][10]
1D xt histo, results of slice fit
std::string m_outputFileName
Output xt filename.
float m_iTheta[7]
Represented theta in theta bins.
Base class for calibration algorithms.
EResult
The result of calibration.
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
Abstract base class for different kinds of events.