Belle II Software development
SpaceResolutionCalibrationAlgorithm.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 <TH1F.h>
12#include <TH2F.h>
13#include <TGraphErrors.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
29 // typedef std::array<float, 3> array3; /**< angle bin info. */
30 public:
31
34
37
39 void setDebug(bool debug = false) {m_debug = debug; }
40
42 void setMinimumNDF(double ndf) {m_minNdf = ndf;}
43
45 void setMinimumPval(double pval) {m_minPval = pval;}
46
48 void setBinWidth(double bw) {m_binWidth = bw;}
49
51 void setBField(bool bfield) {m_bField = bfield;}
52
54 void setStoreHisto(bool storeHist = false) {m_storeHisto = storeHist;}
55
57 void enableTextOutput(bool output = true) {m_textOutput = output;}
58
60 void setOutputFileName(std::string outputname) {m_outputFileName.assign(outputname);}
61
63 void setHistFileName(const std::string& name) {m_histName = "histSigma_" + name + ".root";}
64
66 void setThreshold(double th = 0.6) {m_threshold = th;}
67
68 protected:
70 EResult calibrate() override;
72 void createHisto();
74 void storeHisto();
76 void write();
78 void prepare();
79
81 double getUpperBoundaryForFit(TGraphErrors* graph)
82 {
83 double ymax = 0;
84 double xmax = 0;
85 int imax = 0;
86 double x, y;
87 int unCount = floor(0.05 / m_binWidth);
88 int N = graph->GetN();
89 int Nstart = floor(0.5 * (N - unCount));
90 int Nend = N - unCount;
91 for (int i = Nstart; i < Nend; ++i) {
92 graph->GetPoint(i, x, y);
93 if (graph->GetErrorY(i) > 0.06E-3) continue;
94 if (y > ymax) {
95 xmax = x; ymax = y;
96 imax = i;
97 }
98 }
99 if (imax <= Nstart) {
100 graph->GetPoint(Nend, x, y);
101 xmax = x;
102 }
103 return xmax;
104 }
105
106 private:
107 static const int Max_nalpha = 18;
108 static const int Max_ntheta = 7;
109 static const unsigned short Max_np = 40;
111 double m_minNdf = 5;
112 double m_minPval = 0.;
113 double m_binWidth = 0.05;
114 bool m_debug = false;
115 bool m_storeHisto = false;
116 bool m_bField = true;
117 double m_threshold = 0.6 ;
118 double m_sigma[56][2][18][7][8];
119 TGraphErrors* m_gFit[56][2][18][7];
120 TGraphErrors* m_graph[56][2][18][7];
127 int m_fitStatus[56][2][Max_nalpha][Max_ntheta] = {{{{0}}}} ;
131 float m_lowerAlpha[18];
132 float m_upperAlpha[18];
133 float m_iAlpha[18];
134 float m_lowerTheta[7];
135 float m_upperTheta[7];
136 float m_iTheta[7];
137 unsigned short m_sigmaParamMode = 0;
139 double m_sigmaPost[56][2][18][7][8];
140 unsigned short m_sigmaParamModePost;
142 bool m_textOutput = false;
143 std::string m_outputFileName = "sigma_new.dat";
144 std::string m_histName = "histSigma.root";
146 };
147 }
149}
void setStoreHisto(bool storeHist=false)
Store histograms durring the calibration or not.
TH1F * m_hSigmaBiased[56][2][Max_nalpha][Max_ntheta]
sigma histogram of biased residual
void setOutputFileName(std::string outputname)
output file name
void prepare()
Prepare the calibration of space resolution.
double m_threshold
minimal requirement for the fraction of fitted results
unsigned short m_sigmaParamMode
sigma mode for this calibration.
unsigned short m_sigmaParamModePost
sigma mode before this calibration.
TH1F * m_hMeanBiased[56][2][Max_nalpha][Max_ntheta]
mean histogram biased residual
double m_sigmaPost[56][2][18][7][8]
sigma prameters before calibration
double getUpperBoundaryForFit(TGraphErrors *graph)
search max point at boundary region
void setMinimumNDF(double ndf)
minimum NDF required for track
TH2F * m_hBiased[56][2][Max_nalpha][Max_ntheta]
2D histogram of biased residual
static const unsigned short Max_np
Maximum number of point =1/binwidth.
void enableTextOutput(bool output=true)
Enable text output of calibration result.
bool m_bField
Work with BField, fit range and initial parameters is different incase B and noB.
TH1F * m_hSigmaUnbiased[56][2][Max_nalpha][Max_ntheta]
sigma histogram of ubiased residual
void setHistFileName(const std::string &name)
Set name for histogram output.
TH1F * m_hMeanUnbiased[56][2][Max_nalpha][Max_ntheta]
mean histogram of unbiased residual
void setThreshold(double th=0.6)
Set threshold for the fraction of fitted results.
TGraphErrors * m_gFit[56][2][18][7]
sigma*sigma graph for fit
int m_fitStatus[56][2][Max_nalpha][Max_ntheta]
Fit flag; 1:OK ; 0:error.
TH2F * m_hUnbiased[56][2][Max_nalpha][Max_ntheta]
2D histogram of unbiased residual
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.