Belle II Software  release-05-02-19
TOPPulseHeightAlgorithm.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2019 - Belle II Collaboration *
4  * *
5  * *
6  * Author: The Belle II Collaboration *
7  * Contributors: Marko Staric *
8  * *
9  * This software is provided "as is" without any warranty. *
10  **************************************************************************/
11 
12 #pragma once
13 #include <calibration/CalibrationAlgorithm.h>
14 #include <TH2F.h>
15 #include <TH1D.h>
16 #include <TFile.h>
17 #include <TTree.h>
18 #include <top/dbobjects/TOPCalChannelPulseHeight.h>
19 #include <top/dbobjects/TOPCalChannelThresholdEff.h>
20 
21 namespace Belle2 {
26  namespace TOP {
27 
31  class TOPPulseHeightAlgorithm : public CalibrationAlgorithm {
32  public:
33 
36 
38  virtual ~TOPPulseHeightAlgorithm() {}
39 
43  void setMinEntries(int minEntries) {m_minEntries = minEntries;}
44 
49  void setXmin(double xmin) {m_xmin = xmin;}
50 
55  void setMinFracCalibrated(double minFract) {m_minCalibrated = minFract;}
56 
57  private:
58 
62  virtual EResult calibrate() final;
63 
69  int fitChannels(std::shared_ptr<TH2F> h);
70 
78  int fitPulseHeight(TH1D* h);
79 
86  double getEfficiency(TH1D* h, TF1* func);
87 
88  // algorithm parameters
89  int m_minEntries = 100;
90  double m_xmin = 100.0;
91  double m_minCalibrated = 0.90;
93  // ntuple variables
94  int m_slot = 0;
95  unsigned m_channel = 0;
96  int m_numPhot = 0;
97  float m_x0 = 0;
98  float m_p1 = 0;
99  float m_p2 = 0;
100  float m_x0err = 0;
101  float m_p1err = 0;
102  float m_p2err = 0;
103  float m_effi = 0;
104  float m_meanHist = 0;
105  float m_meanFunc = 0;
106  float m_chi2 = 0;
107  int m_ndf = 0;
108  int m_fitStatus = -1;
109  bool m_good = false;
111  // output file and tree
112  TFile* m_file = 0;
113  TTree* m_tree = 0;
115  // output DB objects
119  };
120 
121  } // end namespace TOP
123 } // end namespace Belle2
Belle2::TOP::TOPPulseHeightAlgorithm::calibrate
virtual EResult calibrate() final
algorithm implementation
Definition: TOPPulseHeightAlgorithm.cc:35
Belle2::TOP::TOPPulseHeightAlgorithm::m_x0err
float m_x0err
error on x0 [ADC counts]
Definition: TOPPulseHeightAlgorithm.h:109
Belle2::TOP::TOPPulseHeightAlgorithm::fitPulseHeight
int fitPulseHeight(TH1D *h)
Fit pulse-height distribution of a single channel with P(x) = (x/x0)^p1 * exp(-(x/x0)^p2) and p1 = 1.
Definition: TOPPulseHeightAlgorithm.cc:150
Belle2::TOPCalChannelPulseHeight
Pulse height parameterizations for all 512 channels of 16 modules.
Definition: TOPCalChannelPulseHeight.h:36
Belle2::TOP::TOPPulseHeightAlgorithm::m_x0
float m_x0
fitted distribution parameter x0 [ADC counts]
Definition: TOPPulseHeightAlgorithm.h:106
Belle2::TOP::TOPPulseHeightAlgorithm::m_fitStatus
int m_fitStatus
fit status
Definition: TOPPulseHeightAlgorithm.h:117
Belle2::TOP::TOPPulseHeightAlgorithm::m_pulseHeight
TOPCalChannelPulseHeight * m_pulseHeight
parametrized PH distributions
Definition: TOPPulseHeightAlgorithm.h:125
Belle2::TOP::TOPPulseHeightAlgorithm::setXmin
void setXmin(double xmin)
Sets the lower bound of the fit range.
Definition: TOPPulseHeightAlgorithm.h:58
Belle2::TOP::TOPPulseHeightAlgorithm::m_xmin
double m_xmin
fit range lower limit [ADC counts]
Definition: TOPPulseHeightAlgorithm.h:99
Belle2::TOP::TOPPulseHeightAlgorithm::m_thresholdEffi
TOPCalChannelThresholdEff * m_thresholdEffi
threshold efficiencies
Definition: TOPPulseHeightAlgorithm.h:126
Belle2::TOP::TOPPulseHeightAlgorithm::m_p1err
float m_p1err
error on p1
Definition: TOPPulseHeightAlgorithm.h:110
Belle2::TOP::TOPPulseHeightAlgorithm::m_p2
float m_p2
fitted distribution parameter p2
Definition: TOPPulseHeightAlgorithm.h:108
Belle2::TOP::TOPPulseHeightAlgorithm::m_chi2
float m_chi2
chi^2
Definition: TOPPulseHeightAlgorithm.h:115
Belle2::TOP::TOPPulseHeightAlgorithm::m_minEntries
int m_minEntries
minimal number of histogram entries to perform fit
Definition: TOPPulseHeightAlgorithm.h:98
Belle2::TOP::TOPPulseHeightAlgorithm::m_slot
int m_slot
module ID
Definition: TOPPulseHeightAlgorithm.h:103
Belle2::TOP::TOPPulseHeightAlgorithm::~TOPPulseHeightAlgorithm
virtual ~TOPPulseHeightAlgorithm()
Destructor.
Definition: TOPPulseHeightAlgorithm.h:47
Belle2::TOP::TOPPulseHeightAlgorithm::setMinFracCalibrated
void setMinFracCalibrated(double minFract)
Sets minimal fraction of calibrated channels to declare this calibration as c_OK.
Definition: TOPPulseHeightAlgorithm.h:64
Belle2::TOP::TOPPulseHeightAlgorithm::m_p2err
float m_p2err
error on p2
Definition: TOPPulseHeightAlgorithm.h:111
Belle2::TOP::TOPPulseHeightAlgorithm::m_p1
float m_p1
fitted distribution parameter p1
Definition: TOPPulseHeightAlgorithm.h:107
Belle2::TOP::TOPPulseHeightAlgorithm::m_meanHist
float m_meanHist
histogram mean value
Definition: TOPPulseHeightAlgorithm.h:113
Belle2::TOP::TOPPulseHeightAlgorithm::TOPPulseHeightAlgorithm
TOPPulseHeightAlgorithm()
Constructor.
Definition: TOPPulseHeightAlgorithm.cc:29
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TOP::TOPPulseHeightAlgorithm::m_ndf
int m_ndf
NDF.
Definition: TOPPulseHeightAlgorithm.h:116
Belle2::TOPCalChannelThresholdEff
Class to store the threshold efficiency (i.e.
Definition: TOPCalChannelThresholdEff.h:38
Belle2::TOP::TOPPulseHeightAlgorithm::m_channel
unsigned m_channel
channel ID
Definition: TOPPulseHeightAlgorithm.h:104
Belle2::TOP::TOPPulseHeightAlgorithm::m_minCalibrated
double m_minCalibrated
min.
Definition: TOPPulseHeightAlgorithm.h:100
Belle2::CalibrationAlgorithm::EResult
EResult
The result of calibration.
Definition: CalibrationAlgorithm.h:50
Belle2::TOP::TOPPulseHeightAlgorithm::m_tree
TTree * m_tree
output ntuple
Definition: TOPPulseHeightAlgorithm.h:122
Belle2::TOP::TOPPulseHeightAlgorithm::m_meanFunc
float m_meanFunc
fitted distribution mean value
Definition: TOPPulseHeightAlgorithm.h:114
Belle2::TOP::TOPPulseHeightAlgorithm::m_effi
float m_effi
threshold efficiency
Definition: TOPPulseHeightAlgorithm.h:112
Belle2::TOP::TOPPulseHeightAlgorithm::m_numPhot
int m_numPhot
number of photons (histogram entries)
Definition: TOPPulseHeightAlgorithm.h:105
Belle2::TOP::TOPPulseHeightAlgorithm::setMinEntries
void setMinEntries(int minEntries)
Sets minimal number of histogram entries to perform a fit.
Definition: TOPPulseHeightAlgorithm.h:52
Belle2::TOP::TOPPulseHeightAlgorithm::getEfficiency
double getEfficiency(TH1D *h, TF1 *func)
Calculate and return threshold efficiency.
Definition: TOPPulseHeightAlgorithm.cc:186
Belle2::TOP::TOPPulseHeightAlgorithm::m_file
TFile * m_file
root file
Definition: TOPPulseHeightAlgorithm.h:121
Belle2::TOP::TOPPulseHeightAlgorithm::fitChannels
int fitChannels(std::shared_ptr< TH2F > h)
Fit pulse-height distributions of a single module.
Definition: TOPPulseHeightAlgorithm.cc:124
Belle2::TOP::TOPPulseHeightAlgorithm::m_good
bool m_good
on true fit is good
Definition: TOPPulseHeightAlgorithm.h:118