Belle II Software  release-08-01-10
TimeWalkCalibrationAlgorithm.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 <calibration/CalibrationAlgorithm.h>
11 #include <cdc/dbobjects/CDCGeometry.h>
12 #include <framework/database/DBObjPtr.h>
13 #include <TH1D.h>
14 #include <TH2D.h>
15 #include "string"
16 
17 namespace Belle2 {
22  namespace CDC {
28  public:
31 
34 
36  void setDebug(bool debug) {m_debug = debug; }
37 
40 
42  void setMinimumNDF(double ndf) {m_minNdf = ndf;}
43 
45  void setMinimumPval(double pval) {m_minPval = pval;}
46 
48  void enableTextOutput(bool output = true) {m_textOutput = output;}
49 
51  void outputTWFileName(std::string tw_out_name) {m_outputTWFileName.assign(tw_out_name);}
53  void outputT0FileName(std::string t0_out_name) {m_outputT0FileName.assign(t0_out_name);}
54 
56  void setHistFileName(const std::string& name) {m_histName = "histTW_" + name + ".root";}
57 
59  void setMode(unsigned short mode)
60  {
61  m_twParamMode = mode;
62  if (mode == 0)
63  m_nTwParams = 1;
64  else if (mode == 1)
65  m_nTwParams = 2;
66  else
67  B2FATAL("Mode hasn't implemented yet");
68  }
69 
70  protected:
72  EResult calibrate() override;
73 
75  void createHisto();
76 
78  void write();
79 
81  void updateT0();
82 
84  void fitToExponentialFunc(TH1D* h1);
85 
87  void prepare();
88 
91 
93  void storeHist();
94 
95  private:
96 
97  TH1D* m_h1[300];
98  TH2D* m_h2[300];
100  double m_xmin = 0.07;
101  double m_minNdf = 20;
102  double m_minPval = 0.;
103  double m_constTerm[300] = {0.};
104  unsigned short m_flag[300] = {0};
105  std::vector<float> m_tw_old[300];
106  std::vector<float> m_tw_new[300];
107  bool m_storeHisto = true;
108  std::string m_inputTWFileName = "tw.dat";
109  std::string m_inputT0FileName = "t0.dat";
110  std::string m_outputTWFileName = "tw_new.dat";
111  std::string m_outputT0FileName = "t0_new.dat";
112  std::string m_histName = "histTW.root";
113  bool m_debug = false;
114  bool m_textOutput = false;
115  unsigned short m_twParamMode = 1;
116  unsigned short m_nTwParams = 2;
118  };
119  }
121 }
122 
double m_xmin
minimum value cut of drift length.
std::string m_outputT0FileName
t0 file name after calibration.
TH2D * m_h2[300]
2D histogram of residual vs ADC for each board.
unsigned short m_twParamMode
=0 for P0/Sqrt(ADC); =1 for P0*Exp(-P1*ADC).
void setStoreHisto(bool storeHist)
Store Histogram or not.
double m_constTerm[300]
const term in fitting, it will be added to T0 instead tw
void setMode(unsigned short mode)
Set time walk mode.
double m_minNdf
minimum number of degree of freedom required for track.
unsigned short m_flag[300]
flag for fit status
void setMinimumPval(double pval)
minimum chi2 prob requirement for track
double m_minPval
minimum number of Prob(chi2) of fitted track.
void updateT0()
update constant term to t0 database.
std::vector< float > m_tw_old[300]
tw list before calibration.
void setMinimumNDF(double ndf)
minimum number of degree freedom requirement for track
void setDebug(bool debug)
change flag for debug
DBObjPtr< CDCGeometry > m_cdcGeo
Geometry of CDC.
void enableTextOutput(bool output=true)
Enable text output of calibration result.
std::string m_outputTWFileName
tw file name after calibration.
std::vector< float > m_tw_new[300]
tw list after calibration.
void setHistFileName(const std::string &name)
Set name for histogram output.
void outputTWFileName(std::string tw_out_name)
output tw file name, for text mode
TH1D * m_h1[300]
Mean of residual as function of ADC of each board.
void outputT0FileName(std::string t0_out_name)
output t0 file name, for text mode
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.