Belle II Software development
CDCDedxCosLayerAlgorithm.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 <array>
16#include <vector>
17#include <TLegend.h>
18
19namespace Belle2 {
24
29
30 public:
31
32 static constexpr int m_kNGroups = 3;
33
38
43
47 void setLayerTrunc(bool value = false) {isFixTrunc = value;}
48
52 void setMergePayload(bool value = true) {isMerge = value;}
53
57 void setMonitoringPlots(bool value = false) {isMakePlots = value;}
58
62 void setMethodSep(bool value = true) {isMethodSep = value;}
63
67 void setUseTruncForInner(bool value = false) { isUseTrunc = value; }
68
72 void setTrucationBins(double lowedge, double upedge)
73 {
74 m_truncMin = lowedge; m_truncMax = upedge ;
75 }
76
80 void setCosineBins(unsigned int value = 100) {m_cosBin = value;}
81
85 void setCosineRange(double min = -1.0, double max = 1.0) {m_cosMin = min; m_cosMax = max;}
86
90 void setHistBins(int value = 250) {m_dedxBin = value;}
91
95 void setHistRange(double min = 0.0, double max = 5.0) {m_dedxMin = min; m_dedxMax = max;}
96
100 void setSuffix(const std::string& value) {m_suffix = value;}
101
106 unsigned int getRepresentativeLayer(unsigned int igroup) const
107 {
108 static const std::array<unsigned int, m_kNGroups> repLayer = {1, 9, 17};
109 return repLayer.at(igroup);
110 }
111
115 void getExpRunInfo();
116
120 void defineHisto(std::array<std::vector<TH1D*>, m_kNGroups>& hdedx, const std::string& tag, const std::string& chargeLabel);
121
125 TH1D* defineCosthHist(const std::string& tag, const std::string& chargeLabel);
126
130 void getTruncatedBins(TH1D* hist, int& binlow, int& binhigh);
131
135 double getTruncationMean(TH1D* hist, int binlow, int binhigh);
136
140 double extractCosMean(TH1D*& hist, int fixedLow = 1, int fixedHigh = 1);
141
145 void createPayload();
146
150 void plotdedxHist(std::array<std::vector<TH1D*>, m_kNGroups>& hdedx, const std::string& tag);
151
155 void plotLayerDist(std::array<TH1D*, m_kNGroups>& hdedxlay, int iter);
156
160 void plotQaPars(TH1D* hCosth_all, TH1D* hCosth_pos, TH1D* hCosth_neg);
161
165 void plotRelConst(const std::array<std::vector<double>, m_kNGroups>& cosine, int iter);
166
170 void plotmeanChargeOverlay(const std::array<std::vector<double>, 3>& cosine_pos, const std::string& sltag, int iter);
171
175 void plotConstants();
176
180 void plotEventStats();
181
182
183 protected:
184
188 virtual EResult calibrate() override;
189
190 private:
193 bool isMerge;
196
197 double m_truncMin;
198 double m_truncMax;
199
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 std::string m_runExp;
210
211 const std::array<std::string, m_kNGroups> m_label = {"SL0", "SL1", "SL2-8"};
212
213 std::vector<std::vector<double>> m_coscors;
214
216
217 };
218
219} // namespace Belle2
void plotdedxHist(std::array< std::vector< TH1D * >, m_kNGroups > &hdedx, const std::string &tag)
function to draw the dE/dx histogram in costh bins
void plotRelConst(const std::array< std::vector< double >, m_kNGroups > &cosine, int iter)
Plot relative calibration constants vs costh for all SL groups (overlayed)
void setCosineRange(double min=-1.0, double max=1.0)
function to set min/max range of cosine for calibration
void plotQaPars(TH1D *hCosth_all, TH1D *hCosth_pos, TH1D *hCosth_neg)
function to costh distribution for Inner/Outer layer
double m_truncMax
upper threshold on truncation
void plotLayerDist(std::array< TH1D *, m_kNGroups > &hdedxlay, int iter)
function to draw dedx dist.
double m_truncMin
lower threshold on truncation
void setSuffix(const std::string &value)
adding suffix to control plots
void getTruncatedBins(TH1D *hist, int &binlow, int &binhigh)
function to get bins of truncation from histogram
void defineHisto(std::array< std::vector< TH1D * >, m_kNGroups > &hdedx, const std::string &tag, const std::string &chargeLabel)
function to define dE/dx histograms
void getExpRunInfo()
function to get extract calibration run/exp
void setHistRange(double min=0.0, double max=5.0)
function to set min/max range of dedx dist calibration
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 calibration
void plotmeanChargeOverlay(const std::array< std::vector< double >, 3 > &cosine_pos, const std::string &sltag, int iter)
Plot overlay of positive, negative, and average cosine means for one SL group.
unsigned int getRepresentativeLayer(unsigned int igroup) const
Representative CDC layer for each SL group (used to access group-wise constants): SL0 => 1,...
CDCDedxCosLayerAlgorithm()
Constructor: Sets the description, the properties and the parameters of the algorithm.
TH1D * defineCosthHist(const std::string &tag, const std::string &chargeLabel)
function to define cosine histograms
std::string m_suffix
add suffix to all plot name
double extractCosMean(TH1D *&hist, int fixedLow=1, int fixedHigh=1)
Extract mean dE/dx vs costh for a given group from the histogram.
double getTruncationMean(TH1D *hist, int binlow, int binhigh)
function to get truncated mean
void setLayerTrunc(bool value=false)
function to set truncation method (local vs global)
DBObjPtr< CDCDedxCosineCor > m_DBCosineCor
Electron saturation correction DB object.
void plotConstants()
function to draw the old/new final constants
bool isFixTrunc
true = fix window for all out/inner layers
void setUseTruncForInner(bool value=false)
Enable/disable truncated mean usage for inner superlayers (e.g.
std::string m_runExp
add run and exp to title of plot
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.
bool isMethodSep
if e+e- need to be consider sep
double m_dedxMax
max dedx range for gain cal
void createPayload()
function to store new payload after full calibration
void setTrucationBins(double lowedge, double upedge)
function to set bins of truncation from histogram
bool isMakePlots
produce plots for status
bool isMerge
merge payload at the of calibration
void setMonitoringPlots(bool value=false)
function to make flag active for plotting
bool isUseTrunc
true if truncated mean for SL0,1
double m_dedxMin
min dedx range for gain cal
unsigned int m_cosBin
number of bins across cosine range
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.