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
11#include <calibration/CalibrationAlgorithm.h>
12#include <cdc/dbobjects/CDCGeometry.h>
13#include <framework/database/DBObjPtr.h>
14
15#include <TF1.h>
16#include <TH1F.h>
17#include <TH2F.h>
18
19namespace Belle2 {
24 namespace CDC {
25
29 enum {c_Left = 0, c_Right = 1};
30
34 enum {c_Polynomial = 0, c_Chebyshev = 1};
35
44
45 enum FitStatus {c_lowStat = -1, c_fitFailure = 0, c_OK = 1,
46 c_errorOuter = 2, c_errorInner = 3
47 };
48
53 public:
56
59
61 void setBField(bool bfield) {m_bField = bfield;}
62
64 void setDebug(bool debug = false) {m_debug = debug; }
65
67 void setMinimumNDF(double ndf) {m_minNdf = ndf;}
68
70 void setMinimumPval(double pval) {m_minPval = pval;}
71
73 void setXtMode(unsigned short mode = c_Chebyshev) {m_xtMode = mode;}
74
76 void setStoreHisto(bool storeHist = false) {m_storeHisto = storeHist;}
77
79 void enableTextOutput(bool output = true) {m_textOutput = output;}
80
82 void setOutputFileName(std::string outputname) {m_outputFileName.assign(outputname);}
83
85 void setHistFileName(const std::string& name) {m_histName = "histXT_" + name + ".root";}
86
88 void setLRSeparate(bool lr = true) {m_LRseparate = lr;}
89
91 void setThreshold(double th = 0.6) {m_threshold = th;}
92
93
94 protected:
95
97 EResult calibrate() override;
98
100 void createHisto();
101
103 void write();
104
106 void storeHisto();
107
109 void prepare();
110
113
115 void sanitaryCheck();
116 private:
117 double m_minNdf = 5;
118 double m_minPval = 0.;
119 bool m_debug = false;
120 bool m_storeHisto = true;
121 bool m_LRseparate = true;
122 bool m_bField = true;
123 double m_threshold = 0.6;
124
125 TProfile* m_hProf[56][2][20][10];
126 TH2F* m_hist2d[56][2][20][10];
127 TH2F* m_hist2dDraw[56][20][10];
128 TH1F* m_hist2d_1[56][2][20][10];
129 TF1* m_xtFunc[56][2][20][10];
130
131 double m_xtPrior[56][2][18][7][8];
132
133 int m_fitStatus[56][2][20][10];
134 bool m_useSliceFit = false;
138 int m_xtMode = c_Chebyshev;
140 float m_lowerAlpha[18];
141 float m_upperAlpha[18];
142 float m_iAlpha[18];
143 float m_lowerTheta[7];
144 float m_upperTheta[7];
145 float m_iTheta[7];
147 double m_par6[56] = {89, 91, 94, 99, 104, 107, 110, 117,
148 126, 144, 150, 157, 170, 180,
149 160, 167, 183, 205, 200, 194,
150 177, 189, 192, 206, 224, 234,
151 193, 206, 209, 215, 222, 239,
152 204, 212, 217, 227, 235, 240,
153 215, 222, 230, 239, 246, 253,
154 227, 232, 239, 243, 253, 258,
155 231, 243, 246, 256, 263, 300
156 };
157
158 bool m_textOutput = false;
159 std::string m_outputFileName = "xt_new.dat";
160 std::string m_histName = "histXT.root";
162 };
163 }
165}
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 boundaries of theta bins.
double m_xtPrior[56][2][18][7][8]
parameters of XT before calibration
TF1 * m_xtFunc[56][2][20][10]
XTFunction.
void setDebug(bool debug=false)
Run in debug or silent.
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.
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 boundaries 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 constant.
float m_upperAlpha[18]
Upper boundaries 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 boundaries 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.
EResult
The result of calibration.
CalibrationAlgorithm(const std::string &collectorModuleName)
Constructor - sets the prefix for collected objects (won't be accesses until execute(....
Class for accessing objects in the database.
Definition DBObjPtr.h:21
Abstract base class for different kinds of events.