Belle II Software development
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
21namespace Belle2 {
26
33
34 public:
35
39 enum { c_NParameterGainFit = 6 };
40
44 enum { c_NPlotsPerChannel = 3, c_NChannelPerPage = 4 };
45
49 enum EHistogramType { c_LoadForFitHeight = 1, c_LoadHitRateHeight = 2,
50 c_LoadForFitIntegral = 3, c_LoadHitRateIntegral = 4
51 };
52
57
62 virtual void initialize() override;
63
68 virtual void terminate() override;
69
74 virtual void defineHisto() override;
75
81 void LoadHistograms(const std::string& histotype);//histotype {Height_gain,Height_efficiency,Integral_gain:}
82
86 void FitHistograms(EHistogramType LoadHisto);
87
91 void DummyFillBranch(EHistogramType LoadHisto);
92
96 void DrawResult(const std::string& histotype, EHistogramType LoadHisto);
97
103 static double TOPGainFunc(double* var, double* par);
104
108 static double FindPeakForSmallerXThan(TH1* histo, double xmax = 0);
109
110 private:
111
112 TTree* m_tree = 0;
113 std::vector<TBranch*> m_branch[4];
114
115 TH2F* m_timeChargeHistogram[c_NChannelPerPMT] = {};
116 TH1D* m_timeHistogram[c_NChannelPerPMT] = {};
117 TH1D* m_chargeHistogram[c_NChannelPerPMT] = {};
119 0;
120 TF1* m_funcForLaser[c_NChannelPerPMT] = {};
121 TF1* m_funcForFitRange[c_NChannelPerPMT] = {};
122 TF1* m_funcForFullRange[c_NChannelPerPMT] = {};
123
124 std::string m_inputFile = "";
125 std::string m_outputPDFFile =
126 "";
127
128 std::string m_fitoption =
129 "L";
130
131 short m_targetSlotId = 0;
132 short m_targetPmtId = 0;
133 short m_targetPmtChId = -1;
134 short m_hvDiff = 0;
135
136 float m_fitHalfWidth = 1.;
137 float m_threshold = 100;
139 550;
140 float m_p0HeightIntegral = -50.0;
141 float m_p1HeightIntegral = 6.0;
142 float m_fitMax = 0;
143 float m_fracFit = 0.99;
144 float m_initialP0 = (float)(-1.);
145 float m_initialP1 = (float)(-1.);
146 float m_initialP2 = (float)(-1.);
147 float m_initialX0 = (float)(-1.);
148 float m_pedestalSigma = 10.;
149
150 short m_pixelId = 0;
151 short m_pmtChId = 0;
152 float m_hitTiming = 0;
154 int m_nEntries = 0;
155 int m_nCalPulse = 0;
159 float m_gain = 0;
160 float m_efficiency = 0;
161 float m_p0 = 0;
162 float m_p1 = 0;
163 float m_p2 = 0;
164 float m_x0 = 0;
165 float m_p0Error = 0;
166 float m_p1Error = 0;
167 float m_p2Error = 0;
168 float m_x0Error = 0;
169 float m_chisquare = 0;
170 int m_ndf = 0;
175 };
176
178} //namespace Belle2
HistoModule()
Constructor.
Definition HistoModule.h:32
float m_efficiency
calculated efficiency from fitting 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 charge) distribution for channel(pixel)-by-channel gain extraction,...
virtual void initialize() override
Load time vs charge 2D histogram from a given input file (parameter "inputFile") and prepare hit timi...
virtual void terminate() override
Termination action.
void FitHistograms(EHistogramType LoadHisto)
Fit charge (or integrated charged) distribution to calculate gain and efficiency for each channel.
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.