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 {
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
67 virtual void initialize() override;
68
73 virtual void beginRun() override;
74
79 virtual void event() override;
80
84 virtual void endRun() override;
85
90 virtual void terminate() override;
91
96 virtual void defineHisto() override;
97
103 void LoadHistograms(const std::string& histotype);//histotype {Height_gain,Height_efficiency,Integral_gain:}
104
108 void FitHistograms(EHistogramType LoadHisto);
109
113 void DummyFillBranch(EHistogramType LoadHisto);
114
118 void DrawResult(const std::string& histotype, EHistogramType LoadHisto);
119
125 static double TOPGainFunc(double* var, double* par);
126
130 static double FindPeakForSmallerXThan(TH1* histo, double xmax = 0);
131
132 private:
133
134 TTree* m_tree = 0;
135 std::vector<TBranch*> m_branch[4];
137 TH2F* m_timeChargeHistogram[c_NChannelPerPMT] = {};
138 TH1D* m_timeHistogram[c_NChannelPerPMT] = {};
139 TH1D* m_chargeHistogram[c_NChannelPerPMT] = {};
141 0;
142 TF1* m_funcForLaser[c_NChannelPerPMT] = {};
143 TF1* m_funcForFitRange[c_NChannelPerPMT] = {};
144 TF1* m_funcForFullRange[c_NChannelPerPMT] = {};
146 std::string m_inputFile = "";
147 std::string m_outputPDFFile =
148 "";
150 std::string m_fitoption =
151 "L";
153 short m_targetSlotId = 0;
154 short m_targetPmtId = 0;
155 short m_targetPmtChId = -1;
156 short m_hvDiff = 0;
158 float m_fitHalfWidth = 1.;
159 float m_threshold = 100;
161 550;
162 float m_p0HeightIntegral = -50.0;
163 float m_p1HeightIntegral = 6.0;
164 float m_fitMax = 0;
165 float m_fracFit = 0.99;
166 float m_initialP0 = (float)(-1.);
167 float m_initialP1 = (float)(-1.);
168 float m_initialP2 = (float)(-1.);
169 float m_initialX0 = (float)(-1.);
170 float m_pedestalSigma = 10.;
172 short m_pixelId = 0;
173 short m_pmtChId = 0;
174 float m_hitTiming = 0;
176 int m_nEntries = 0;
177 int m_nCalPulse = 0;
181 float m_gain = 0;
182 float m_efficiency = 0;
183 float m_p0 = 0;
184 float m_p1 = 0;
185 float m_p2 = 0;
186 float m_x0 = 0;
187 float m_p0Error = 0;
188 float m_p1Error = 0;
189 float m_p2Error = 0;
190 float m_x0Error = 0;
191 float m_chisquare = 0;
192 int m_ndf = 0;
197 };
198
200} //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.