Belle II Software development
TOPLocalCalFitter.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#include <top/calibration/TOPLocalCalFitter.h>
11#include <calibration/CalibrationAlgorithm.h>
12
13namespace Belle2 {
18 namespace TOP {
19
28 public:
29
32
34 virtual ~TOPLocalCalFitter() {}
35
37 void setMinEntries(int minEntries)
38 {
39 m_minEntries = minEntries;
40 }
41
43 void setOutputFileName(const std::string& output)
44 {
45 m_output = output;
46 }
47
51 void setFitConstraintsFileName(const std::string& fitConstraints)
52 {
53 m_fitConstraints = fitConstraints;
54 }
55
57 void setTTSFileName(const std::string& TTSData)
58 {
59 m_TTSData = TTSData;
60 }
61
70 void setFitMode(const std::string& fitterMode)
71 {
72 if (fitterMode == "calibration")
73 B2INFO("Fitter set to calibration mode");
74 else if (fitterMode == "monitoring")
75 B2INFO("Fitter set to monitoring mode");
76 else if (fitterMode == "MC")
77 B2INFO("Fitter set to MC mode");
78 else
79 B2ERROR("Unknown fitter type " << fitterMode << ". The valid options are calibration, monitoring or MC");
80
81 m_fitterMode = fitterMode;
82 }
83
85 void fitInAmpliduteBins(bool isFitInAmplitudeBins)
86 {
87 m_isFitInAmplitudeBins = isFitInAmplitudeBins;
88 }
89
90
91 protected:
92
95
97 void loadMCInfoTrees();
98
100 void determineFitStatus();
101
103 void fitChannel(short, short, TH1*);
104
106 void fitPulser(TH1*, TH1*);
107
111 void calculateChennelT0();
112
115 virtual EResult calibrate() override;
116
117 private:
118
119 int m_minEntries = 50;
120 std::string m_output = "laserFitResult.root";
121 std::string m_fitConstraints =
122 "/group/belle2/group/detector/TOP/calibration/MCreferences/LaserMCParameters.root";
123 std::string m_TTSData =
124 "/group/belle2/group/detector/TOP/calibration/MCreferences/TTSParametrization.root";
125 std::string m_fitterMode = "calibration";
127 std::vector<float> m_binEdges = {50, 100, 130, 160, 190, 220, 250, 280, 310, 340, 370, 400, 430, 460, 490, 520, 550, 580, 610, 640, 670, 700, 800, 900, 1000, 1200, 1500, 2000};
128 TFile* m_inputTTS = nullptr;
129 TFile* m_inputConstraints = nullptr;
131 TTree* m_treeTTS = nullptr;
133 nullptr;
134 TFile* m_histFile = nullptr;
135 TTree* m_fitTree = nullptr;
137 nullptr;
140 // Variables for the TTS parametrization tree
141 float m_mean2 = 0;
142 float m_sigma1 = 0;
143 float m_sigma2 = 0;
144 float m_f1 = 0;
145 float m_f2 = 0;
146 short m_pixelRow = 0;
147 short m_pixelCol = 0;
149 // Variables for the MC truth infos
161 // Variables for the output tree
162 float m_binLowerEdge = 0;
163 float m_binUpperEdge = 0;
164 short m_channel = 0;
165 short m_slot = 0;
166 short m_row = 0;
167 short m_col = 0;
168 float m_peakTime = 0;
169 float m_deltaT =
170 0;
171 float m_sigma = 0.;
172 float m_fraction = 0.;
173 float m_yieldLaser = 0.;
174 float m_histoIntegral = 0.;
176 float m_peakTimeErr = 0;
177 float m_deltaTErr = 0;
178 float m_sigmaErr = 0.;
179 float m_fractionErr = 0.;
180 float m_yieldLaserErr = 0.;
182 float m_timeExtra = 0.;
183 float m_sigmaExtra = 0.;
184 float m_yieldLaserExtra = 0.;
185 float m_alphaExtra = 0.;
186 float m_nExtra = 0.;
188 float m_timeBackground = 0.;
189 float m_sigmaBackground = 0.;
192 float m_fractionMC = 0.;
193 float m_deltaTMC = 0.;
195 0.;
197 float m_chi2 = 0;
198 float m_rms = 0;
201 0.;
202 float m_channelT0Err = 0.;
204 float m_firstPulserTime = 0.;
208 0.;
211 short m_fitStatus = 1;
212 };
213 }
215} // namespace Belle2
216
217
Base class for calibration algorithms.
EResult
The result of calibration.
This module is the fitter for the CAF collector TOPLaserCalibratorCollector.
short m_fitStatus
Fit quality flag, propagated to the constants.
float m_yieldLaserErr
Statistical error on yield.
float m_binLowerEdge
Lower edge of the amplitude bin in which this fit is performed.
void fitChannel(short, short, TH1 *)
Fits the laser light on one channel.
float m_nExtraConstraints
parameter n of the tail of the extra peak
float m_chi2
Reduced chi2 of the fit.
float m_timeExtraConstraints
Position of the guassian used to describe the extra peak on the timing distribution tail.
int m_minEntries
Minimum number of entries to perform the fit.
float m_f1
Fraction of the first gaussian on the TTS parametrization.
float m_fraction
Fraction of events in the secondary peak.
float m_sigmaExtra
Gaussian sigma of the extra peak in the timing tail
float m_secondPulserSigma
Time resolution from the fit of the first electronic pulse, from a Gaussian fit.
float m_yieldLaserBackground
Integral of the background gaussian.
float m_sigma
Gaussian time resolution, fitted.
void setMinEntries(int minEntries)
Sets the minimum number of entries to perform the calibration in one channel.
float m_peakTimeMC
Time of the main peak in teh MC simulation, i.e.
std::string m_output
Name of the output file.
float m_timeBackground
Position of the gaussian used to describe the background, w/ respect to peakTime.
void loadMCInfoTrees()
loads the TTS parameters and the MC truth info
float m_deltaTMC
Time difference between the main peak and the secondary peak in the MC simulation.
float m_peakTimeErr
Statistical error on peakTime.
short m_channel
Channel number (0-511)
float m_channelT0Err
Statistical error on channelT0.
std::string m_TTSData
File with the Fit constraints and MC info.
std::vector< float > m_binEdges
Amplitude bins.
float m_sigmaBackground
Sigma of the gaussian used to describe the background.
float m_peakTime
Fitted time of the main (i.e.
float m_fractionErr
Statistical error on fraction.
bool m_isFitInAmplitudeBins
Enables the fit in amplitude bins.
void calculateChennelT0()
Calculates the commonT0 calibration after the fits have been done.
float m_alphaExtra
alpha parameter of the tail of the extra peak.
float m_rms
RMS of the histogram used for the fit.
float m_mean2
Position of the second gaussian of the TTS parametrization with respect to the first one.
std::string m_fitConstraints
File with the TTS parametrization.
TTree * m_timewalkTree
Output of the fitter.
void setFitConstraintsFileName(const std::string &fitConstraints)
Sets the name of the root file containing the laser MC time corrections and the fit constraints.
float m_yieldLaser
Total number of laser hits from the fitting function integral.
TFile * m_inputTTS
File containing m_treeTTS.
float m_nExtra
parameter n of the tail of the extra peak
void fitInAmpliduteBins(bool isFitInAmplitudeBins)
Enables the fit amplitude bins.
float m_alphaExtraConstraints
alpha parameter of the tail of the extra peak.
float m_channelT0
Raw, channelT0 calibration, defined as peakTime-peakTimeMC.
float m_sigmaErr
Statistical error on sigma.
std::string m_fitterMode
Fit mode.
float m_binUpperEdge
Upper edge of the amplitude bin in which this fit is performed.
TFile * m_histFile
Output of the fitter.
TTree * m_treeConstraints
Input to the fitter.
float m_sigmaExtraConstraints
Width of the guassian used to describe the extra peak on the timing distribution tail.
float m_firstPulserSigma
Time resolution from the fit of the first electronic pulse, from a Gaussian fit.
float m_deltaT
Time difference between the main peak and the secondary peak.
TTree * m_fitTree
Output of the fitter.
float m_f2
Fraction of the second gaussian on the TTS parametrization.
void setOutputFileName(const std::string &output)
Sets the name of the output root file.
void determineFitStatus()
determines if the constant obtained by the fit are good or not
virtual ~TOPLocalCalFitter()
Destructor.
void setFitMode(const std::string &fitterMode)
Sets the fitter mode.
float m_secondPulserTime
Average time of the second electronic pulse respect to the reference pulse, from a gaussian fit.
float m_peakTimeConstraints
Time of the main laser peak in the MC simulation (aka MC correction)
float m_sigma1
Width of the first gaussian on the TTS parametrization.
float m_fractionMC
Fraction of events in the secondary peak form the MC simulation.
float m_sigmaBackgroundConstraints
Sigma of the gaussian used to describe the background.
virtual EResult calibrate() override
Runs the algorithm on events.
TTree * m_treeTTS
Input to the fitter.
void setupOutputTreeAndFile()
prepares the output tree
float m_timeBackgroundConstraints
Position of the gaussian used to describe the background, w/ respect to peakTime.
TFile * m_inputConstraints
File containing m_treeConstraints.
float m_deltaTErr
Statistical error on deltaT.
float m_firstPulserTime
Average time of the first electronic pulse respect to the reference pulse, from a Gaussian fit.
float m_histoIntegral
Integral of the fitted histogram.
float m_yieldLaserExtra
Integral of the extra peak.
float m_sigma2
Width of the second gaussian on the TTS parametrization.
void fitPulser(TH1 *, TH1 *)
Fits the two pulsers.
float m_timeExtra
Position of the extra peak seen in the timing tail, w/ respect to peakTime.
float m_fractionConstraints
Fraction of the main peak.
float m_deltaTConstraints
Distance between the main and the secondary laser peak.
void setTTSFileName(const std::string &TTSData)
Sets the name of the root file containing the TTS parameters.
Abstract base class for different kinds of events.