Belle II Software  release-05-01-25
LaserCalibratorFit.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Wenlong Yuan *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <TH1F.h>
14 #include <TF1.h>
15 #include <string>
16 
17 namespace Belle2 {
22  namespace TOP {
23 
30  double fcnCB(double* x, double* par);
31 
38  double fcnCB2(double* x, double* par);
39 
46  class LaserCalibratorFit {
47  public:
52  explicit LaserCalibratorFit(unsigned moduleID);
53 
58 
63  void setHist(const std::vector<TH1F*>& hist);
64 
69  void setFitMethod(const std::string& method) {m_fitMethod = method;}
70 
76  void setFitRange(double xmin = -200, double xmax = 200) {m_xmin = xmin; m_xmax = xmax;}
77 
82  int fitChannel(unsigned channel);
83 
88  void writeFile(const std::string& outfile);
89 
93  int getModuleID() const {return m_moduleID;}
94 
99  double getFitChisq(unsigned channel);
100 
104  std::string getFitMethod() const {return m_fitMethod;}
105 
109  std::vector<double> getMaxPos() {return m_maxpos;}
110 
114  double getFitT() {return m_fitT;}
115 
119  double getFitTErr() {return m_fitTErr;}
120 
121 
122  private:
123 
128  TF1* makeGFit(unsigned channel);
129 
134  TF1* makeCBFit(unsigned channel);
135 
142  TF1* makeCB2Fit(unsigned channel, bool minOut);
143 
144  unsigned m_moduleID = 0;
145  std::vector<double> m_maxpos;
146  std::vector<double> m_maxpos_error;
147  double m_xmin = 0;
148  double m_xmax = 0;
149  double m_fitT = 0;
150  double m_fitTErr = 0.;
151  std::vector<TH1F*> m_hist;
152  std::vector<TF1*> m_func;
153  std::string m_fitMethod;
154  };
155  }// TOP namespace
157 }//Belle2 namespace
Belle2::TOP::LaserCalibratorFit::m_xmin
double m_xmin
fitting low-edge
Definition: LaserCalibratorFit.h:155
Belle2::TOP::LaserCalibratorFit::getModuleID
int getModuleID() const
get the module ID in the fit
Definition: LaserCalibratorFit.h:101
Belle2::TOP::LaserCalibratorFit::m_maxpos_error
std::vector< double > m_maxpos_error
error on the center positon of hist max bin
Definition: LaserCalibratorFit.h:154
Belle2::TOP::LaserCalibratorFit::m_moduleID
unsigned m_moduleID
one moduleID/slot
Definition: LaserCalibratorFit.h:152
Belle2::TOP::LaserCalibratorFit::fitChannel
int fitChannel(unsigned channel)
fit for a specific channel
Definition: LaserCalibratorFit.cc:100
Belle2::TOP::LaserCalibratorFit::getFitChisq
double getFitChisq(unsigned channel)
get chi^2 in the fit
Definition: LaserCalibratorFit.cc:91
Belle2::TOP::LaserCalibratorFit::writeFile
void writeFile(const std::string &outfile)
write fit result to a root file
Definition: LaserCalibratorFit.cc:133
Belle2::TOP::LaserCalibratorFit::getFitTErr
double getFitTErr()
returns the error mean positon after fit
Definition: LaserCalibratorFit.h:127
Belle2::TOP::LaserCalibratorFit::getMaxPos
std::vector< double > getMaxPos()
get the center positon of hist max bin
Definition: LaserCalibratorFit.h:117
Belle2::TOP::LaserCalibratorFit::getFitT
double getFitT()
get mean positon after fit
Definition: LaserCalibratorFit.h:122
Belle2::TOP::LaserCalibratorFit::LaserCalibratorFit
LaserCalibratorFit(unsigned moduleID)
Constructor.
Definition: LaserCalibratorFit.cc:62
Belle2::TOP::LaserCalibratorFit::makeCB2Fit
TF1 * makeCB2Fit(unsigned channel, bool minOut)
Fit process using double Crystal Ball fuction.
Definition: LaserCalibratorFit.cc:299
Belle2::TOP::LaserCalibratorFit::makeCBFit
TF1 * makeCBFit(unsigned channel)
Fit process using single Crystal Ball fuction.
Definition: LaserCalibratorFit.cc:261
Belle2::TOP::LaserCalibratorFit::m_func
std::vector< TF1 * > m_func
fitting function
Definition: LaserCalibratorFit.h:160
Belle2::TOP::LaserCalibratorFit::m_hist
std::vector< TH1F * > m_hist
time hist of 512 channels
Definition: LaserCalibratorFit.h:159
Belle2::TOP::LaserCalibratorFit::getFitMethod
std::string getFitMethod() const
get the fit method used in recent module
Definition: LaserCalibratorFit.h:112
Belle2::TOP::LaserCalibratorFit::setHist
void setHist(const std::vector< TH1F * > &hist)
set time hist of all channels in one moduleID
Definition: LaserCalibratorFit.cc:81
Belle2::TOP::LaserCalibratorFit::setFitRange
void setFitRange(double xmin=-200, double xmax=200)
set x range in the fit
Definition: LaserCalibratorFit.h:84
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TOP::LaserCalibratorFit::m_fitMethod
std::string m_fitMethod
fitting method
Definition: LaserCalibratorFit.h:161
Belle2::TOP::LaserCalibratorFit::m_fitT
double m_fitT
mean position after fit
Definition: LaserCalibratorFit.h:157
Belle2::TOP::LaserCalibratorFit::m_fitTErr
double m_fitTErr
error on the mean position estimated by the fit
Definition: LaserCalibratorFit.h:158
Belle2::TOP::LaserCalibratorFit::makeGFit
TF1 * makeGFit(unsigned channel)
Fit process using single gaussian function.
Definition: LaserCalibratorFit.cc:243
Belle2::TOP::LaserCalibratorFit::~LaserCalibratorFit
~LaserCalibratorFit()
Destructor.
Definition: LaserCalibratorFit.cc:67
Belle2::TOP::LaserCalibratorFit::m_xmax
double m_xmax
fitting upper-edge
Definition: LaserCalibratorFit.h:156
Belle2::TOP::LaserCalibratorFit::setFitMethod
void setFitMethod(const std::string &method)
set time fit function
Definition: LaserCalibratorFit.h:77
Belle2::TOP::LaserCalibratorFit::m_maxpos
std::vector< double > m_maxpos
center positon of hist max bin
Definition: LaserCalibratorFit.h:153