Belle II Software  release-08-01-10
TOPGainEfficiencyCalculatorModule.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 <framework/core/HistoModule.h>
12 #include <top/modules/TOPGainEfficiencyMonitor/TOPLaserHitSelectorModule.h>
13 
14 #include <string>
15 
16 #include <TTree.h>
17 #include <TH1.h>
18 #include <TH2.h>
19 #include <TF1.h>
20 
21 namespace Belle2 {
36 
37  public:
38 
42  enum { c_NParameterGainFit = 6 };
43 
47  enum { c_NPlotsPerChannel = 3, c_NChannelPerPage = 4 };
48 
52  enum EHistogramType { c_LoadForFitHeight = 1, c_LoadHitRateHeight = 2,
53  c_LoadForFitIntegral = 3, c_LoadHitRateIntegral = 4
54  };
55 
60 
65 
70  virtual void initialize() override;
71 
76  virtual void beginRun() override;
77 
82  virtual void event() override;
83 
87  virtual void endRun() override;
88 
93  virtual void terminate() override;
94 
99  virtual void defineHisto() override;
100 
106  void LoadHistograms(const std::string& histotype);//histotype {Height_gain,Height_efficiency,Integral_gain:}
107 
111  void FitHistograms(EHistogramType LoadHisto);
112 
116  void DummyFillBranch(EHistogramType LoadHisto);
117 
121  void DrawResult(const std::string& histotype, EHistogramType LoadHisto);
122 
128  static double TOPGainFunc(double* var, double* par);
129 
133  static double FindPeakForSmallerXThan(TH1* histo, double xmax = 0);
134 
135  private:
136 
137  TTree* m_tree = 0;
138  std::vector<TBranch*> m_branch[4];
140  TH2F* m_timeChargeHistogram[c_NChannelPerPMT] = {};
141  TH1D* m_timeHistogram[c_NChannelPerPMT] = {};
142  TH1D* m_chargeHistogram[c_NChannelPerPMT] = {};
144  0;
145  TF1* m_funcForLaser[c_NChannelPerPMT] = {};
146  TF1* m_funcForFitRange[c_NChannelPerPMT] = {};
147  TF1* m_funcForFullRange[c_NChannelPerPMT] = {};
149  std::string m_inputFile = "";
150  std::string m_outputPDFFile =
151  "";
153  std::string m_fitoption =
154  "L";
156  short m_targetSlotId = 0;
157  short m_targetPmtId = 0;
158  short m_targetPmtChId = -1;
159  short m_hvDiff = 0;
161  float m_fitHalfWidth = 1.;
162  float m_threshold = 100;
164  550;
165  float m_p0HeightIntegral = -50.0;
166  float m_p1HeightIntegral = 6.0;
167  float m_fitMax = 0;
168  float m_fracFit = 0.99;
169  float m_initialP0 = (float)(-1.);
170  float m_initialP1 = (float)(-1.);
171  float m_initialP2 = (float)(-1.);
172  float m_initialX0 = (float)(-1.);
173  float m_pedestalSigma = 10.;
175  short m_pixelId = 0;
176  short m_pmtChId = 0;
177  float m_hitTiming = 0;
178  float m_hitTimingSigma = 0;
179  int m_nEntries = 0;
180  int m_nCalPulse = 0;
182  float m_meanPulseHeight = 0;
184  float m_gain = 0;
185  float m_efficiency = 0;
186  float m_p0 = 0;
187  float m_p1 = 0;
188  float m_p2 = 0;
189  float m_x0 = 0;
190  float m_p0Error = 0;
191  float m_p1Error = 0;
192  float m_p2Error = 0;
193  float m_x0Error = 0;
194  float m_chisquare = 0;
195  int m_ndf = 0;
200  };
201 
203 } //namespace Belle2
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Definition: HistoModule.h:29
Module for channel-by-channel gain/efficiency analysis.
float m_efficiency
calculated efficiency from fitting of pulse charge distribution
int m_nEntries
entries of pulse charge distribution
float m_initialX0
initial value of the fit parameter x0
float m_p1HeightIntegral
Parameter from p0 + x*p1 function that fits height-integral distribution.
float m_funcFitRangeIntegral
integral of fit function for a range [threshold, fitMax]
float m_thresholdForIntegral
pulse integral threshold, which defines lower limit of fit region and efficiency calculation
TF1 * m_funcForFitRange[c_NChannelPerPMT]
array of TF1 pointer to store fit function for pulse charge distribution, defined only for fit region
TH2F * m_timeChargeHistogram[c_NChannelPerPMT]
2D histogram of hit timing and pulse charge (or charge), taken from an output file of TOPLaserHitSele...
float m_threshold
pulse charge threshold, which defines lower limit of fit region and efficiency calculation
float m_fitMax
upper limit of fit region for pulse charge distribution, determined based on m_fracFit value
float m_gain
calculated gain from fitting of pulse charge distribution
std::vector< TBranch * > m_branch[4]
ntuple to store summary of gain using height distribution.
float m_fitHalfWidth
half fit width for direct laser hit peak in [ns] unit
int m_nCalPulse
the number of events with calibration pulse(s) identified
float m_initialP2
initial value of the fit parameter p2
float m_funcFullRangeIntegral
integral of fit function for its full range
float m_histoFitRangeIntegral
integral of histogram for a range [threshold, fitMax]
float m_initialP0
initial value of the fit parameter p0
float m_meanPulseHeight
histogram mean of pulse height distribution
float m_hitTimingSigma
Gaussian fit sigma for a peak of laser direct photons in hit timing distribution.
short m_pixelId
pixel ID, calculated from PMT ID and PMT channel ID
float m_p0HeightIntegral
Parameter from p0 + x*p1 function that fits height-integral distribution.
float m_fracFit
fraction of events which are covered by an area [0,m_fitMax]
std::string m_inputFile
input file containing timing vs charge 2D histograms (output of TOPLaserHitSelector)
std::string m_fitoption
charge histograms fitting option.
float m_meanPulseHeightError
histogram mean error of pulse height distribution
std::string m_outputPDFFile
output PDF file to store plots of 2D histogram, timing, and charge distribution for each channel
short m_hvDiff
HV difference from nominal HV value.
TF1 * m_funcForFullRange[c_NChannelPerPMT]
array of TF1 pointer to store fit function for pulse charge distribution, defined only for full range...
TF1 * m_funcForLaser[c_NChannelPerPMT]
array of TF1 pointer to store fit function for hit timing distribution
float m_initialP1
initial value of the fit parameter p1
TH1D * m_chargeHistogram[c_NChannelPerPMT]
pulse charge distribution, extracted from m_timeChargeHistogram as a projection along its y-axis with...
float m_histoMeanAboveThre
mean of histogram above threshold, ignore overflow bin
float m_hitTiming
timing of laser direct photon hits, given by Gaussian fit mean
TH1F * m_nCalPulseHistogram
histogram to store the number of events with calibration pulse(s) identified for each asic (1,...
int m_nOverflowEvents
the number of events outside histogram range
TH1D * m_timeHistogram[c_NChannelPerPMT]
hit timing distribution, extracted from m_timeChargeHistogram as a projection along its x-axis.
static double TOPGainFunc(double *var, double *par)
Fit function of pulse charge (or charnge) distribution for channel(pixel)-by-channel gain extraction,...
virtual void initialize() override
Load time vs charge 2D histogram from a given input file (paramter "inputFile") and prepare hit timin...
virtual void event() override
This will be empty as the all the processes are done in beginRun() function thus input file can be a ...
virtual void endRun() override
Draw plots to show fitting results for each channel and save them into a given PDF file (outputPDFFil...
virtual void terminate() override
Termination action.
void FitHistograms(EHistogramType LoadHisto)
Fit charge (or integrated charged) distribution to calculate gain and efficiency for each channel.
virtual void beginRun() override
The main processes, fitting charge distribution and calculating gain/efficiency, are done in this fun...
static double FindPeakForSmallerXThan(TH1 *histo, double xmax=0)
Find peak and return its position for a limited range of x (x smaller than the given value (xmax))
void DrawResult(const std::string &histotype, EHistogramType LoadHisto)
Draw results of gain/efficiency calculation for each channel to a given output file.
void LoadHistograms(const std::string &histotype)
Load 2D histograms from a given input file (output of TOPLaserHitSelector) and create timing and char...
void DummyFillBranch(EHistogramType LoadHisto)
Fill Dummy for Branch.
virtual void defineHisto() override
Define TTree branches to store fit results for each channel This TTree is saved in an output file giv...
Abstract base class for different kinds of events.