Belle II Software development
CDCDedxCosineAlgorithm.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 <cdc/dbobjects/CDCDedxCosineCor.h>
12#include <calibration/CalibrationAlgorithm.h>
13#include <framework/database/DBObjPtr.h>
14#include <TH1D.h>
15#include <TLegend.h>
16
17namespace Belle2 {
22
27
28 public:
29
30 static constexpr int m_kNGroups = 3;
31
36
41
45 void setMethodSep(bool value = true) {isMethodSep = value;}
46
50 void setMonitoringPlots(bool value = false) {isMakePlots = value;}
51
55 void setMergePayload(bool value = true) {isMergePayload = value;}
56
60 void setFitWidth(double value = 2.5) {m_sigLim = value;}
61
65 void setCosineBins(unsigned int value = 100) {m_cosBin = value;}
66
70 void setCosineRange(double min = -1.0, double max = 1.0) {m_cosMin = min; m_cosMax = max;}
71
75 void setHistBins(int value = 250) {m_dedxBin = value;}
76
80 void setHistRange(double min = 0.0, double max = 5.0) {m_dedxMin = min; m_dedxMax = max;}
81
85 void setSuffix(const std::string& value) {m_suffix = value;}
86
90 void getExpRunInfo();
91
95 void defineHisto(std::vector<TH1D*>& hdedx, const std::string& tag, const std::string& chargeLabel);
96
100 TH1D* defineCosthHist(const std::string& tag);
101
105 void fitGaussianWithRange(TH1D*& temphist, TString& status);
106
110 void createPayload(std::vector<double> cosine);
111
115 void plotdedxHist(std::vector<TH1D*>& hDedxCos_all, std::vector<TH1D*>& hDedxCos_neg, std::vector<TH1D*>& hDedxCos_pos);
116
120 void setHist(TH1D* h, int color, const char* title,
121 double ymin, double ymax, int marker = 20)
122 {
123 h->SetLineColor(color);
124 h->SetLineWidth(2);
125 h->SetMarkerColor(color);
126 h->SetMarkerStyle(marker);
127 h->SetMarkerSize(0.7);
128 h->SetStats(0);
129
130 if (strlen(title) > 0)
131 h->SetTitle(title);
132
133 h->GetYaxis()->SetRangeUser(ymin, ymax);
134 }
135
139 void plotCosThetaDist(TH1D* hCosth_all, TH1D* hCosth_pos, TH1D* hCosth_neg);
140
144 void plotFitResults(const std::vector<std::vector<double>>& dedxAll, const std::vector<std::vector<double>>& dedxNeg,
145 const std::vector<std::vector<double>>& dedxPos);
146
150 void plotEventStats();
151
155 void plotConstants();
156
161 unsigned int getRepresentativeLayer(unsigned int igroup) const
162 {
163 static const std::array<unsigned int, m_kNGroups> repLayer = {1, 9, 17};
164 return repLayer.at(igroup);
165 }
166
167 protected:
168
172 virtual EResult calibrate() override;
173
174 private:
175
182
183 struct FitValues {
184 double mean = 1.0;
185 double meanErr = 0.0;
186 double sigma = 0.0;
187 double sigmaErr = 0.0;
188 TString status;
189 };
190
194 FitValues fitHistogram(TH1D*& hist);
195
199 double m_sigLim;
200 unsigned int m_cosBin;
201 double m_cosMin;
202 double m_cosMax;
203
205 double m_dedxMin;
206 double m_dedxMax;
207
208 std::string m_suffix;
209
210 std::vector<std::vector<double>> m_coscors;
211
212 const std::array<std::string, m_kNGroups> m_label = {"SL0", "SL1", "SL2-8"};
213
215 };
216
217} // namespace Belle2
void setCosineRange(double min=-1.0, double max=1.0)
function to set min/max range of cosine for calibration
void setSuffix(const std::string &value)
adding suffix to control plots
FitValues fitHistogram(TH1D *&hist)
Fit histogram with Gaussian and return mean, error, and width.
void setFitWidth(double value=2.5)
set sigma to restrict fit range around mean
void getExpRunInfo()
function to extract calibration run/exp
void setHistRange(double min=0.0, double max=5.0)
function to set min/max range of dedx dist for calibration
TH1D * defineCosthHist(const std::string &tag)
function to define cosine histograms
static constexpr int m_kNGroups
SL grouping: inner (SL0), middle (SL1), outer (SL2–8)
void setCosineBins(unsigned int value=100)
function to set number of cosine bins for calibration
int m_dedxBin
number of bins for dedx histogram
double m_cosMax
max cosine angle for cal
void setHistBins(int value=250)
function to set nbins of dedx dist for calibration
void plotCosThetaDist(TH1D *hCosth_all, TH1D *hCosth_pos, TH1D *hCosth_neg)
Plot cos(theta) distributions for all, positive, and negative tracks.
bool isMergePayload
merge payload at the time of calibration
unsigned int getRepresentativeLayer(unsigned int igroup) const
Representative CDC layer for each SL group (used to access group-wise constants): SL0 => 1,...
std::string m_suffix
add suffix to all plot name
DBObjPtr< CDCDedxCosineCor > m_DBCosineCor
Electron saturation correction DB object.
void plotConstants()
function to draw the old/new final constants
CDCDedxCosineAlgorithm()
Constructor: Sets the description, the properties and the parameters of the algorithm.
void fitGaussianWithRange(TH1D *&temphist, TString &status)
function to fit histogram in each cosine bin
const std::array< std::string, m_kNGroups > m_label
add inner/outer superlayer label
double m_cosMin
min cosine angle for cal
void setMergePayload(bool value=true)
function to decide merge vs relative gains
void plotEventStats()
function to draw the stats plots
void setMethodSep(bool value=true)
function to make flag active for method of sep
virtual EResult calibrate() override
Cosine algorithm.
double m_sigLim
gaussian fit sigma limit
void plotFitResults(const std::vector< std::vector< double > > &dedxAll, const std::vector< std::vector< double > > &dedxNeg, const std::vector< std::vector< double > > &dedxPos)
Plot dE/dx fit results for all, negative, and positive tracks.
void plotdedxHist(std::vector< TH1D * > &hDedxCos_all, std::vector< TH1D * > &hDedxCos_neg, std::vector< TH1D * > &hDedxCos_pos)
function to draw the dE/dx histogram in costh bins
bool isMethodSep
if e+ e- need to be consider sep
void createPayload(std::vector< double > cosine)
function to store new payload after full calibration
double m_dedxMax
max dedx range for gain cal
virtual ~CDCDedxCosineAlgorithm()
Destructor.
bool isMakePlots
produce plots for status
void setMonitoringPlots(bool value=false)
function to make flag active for plotting
double m_dedxMin
min dedx range for gain cal
void setHist(TH1D *h, int color, const char *title, double ymin, double ymax, int marker=20)
Set basic style (color, marker, title, y-range) for a TH1D histogram.
unsigned int m_cosBin
number of bins across cosine range
void defineHisto(std::vector< TH1D * > &hdedx, const std::string &tag, const std::string &chargeLabel)
function to define dE/dx histograms
std::vector< std::vector< double > > m_coscors
final vectors of calibration
EResult
The result of calibration.
CalibrationAlgorithm(const std::string &collectorModuleName)
Constructor - sets the prefix for collected objects (won't be accesses until execute(....
Class for accessing objects in the database.
Definition DBObjPtr.h:21
Abstract base class for different kinds of events.
Container for Gaussian fit results of a histogram.
double meanErr
meanErr : uncertainty on the mean
double sigmaErr
sigmaErr : uncertainty on the width
TString status
status : fit status flag (e.g.