23#include <calibration/CalibrationAlgorithm.h>
24#include <framework/database/DBObjPtr.h>
25#include <reconstruction/dbobjects/CDCDedxInjectionTime.h>
26#include <reconstruction/utility/CDCDedxMeanPred.h>
27#include <reconstruction/utility/CDCDedxSigmaPred.h>
28#include <framework/gearbox/Const.h>
32 static const int nrings = 2;
33 static const int nvectors = 6;
36enum fstatus {fitOK, fitFailed};
118 void defineHisto(std::array<std::vector<TH1D*>, numdedx::nrings>& htemp, std::string var);
123 void defineTimeHisto(std::array<std::array<TH1D*, 3>, numdedx::nrings>& htemp);
128 void checkStatistics(std::array<std::vector<TH1D*>, numdedx::nrings>& hvar);
133 void correctBinBias(std::map<
int, std::vector<double>>& varcorr, std::map<
int, std::vector<double>>& var,
134 std::map<
int, std::vector<double>>& time, TH1D*& htimes);
139 void createPayload(std::array<double, numdedx::nrings>& scale, std::map<
int, std::vector<double>>& vmeans,
140 std::map<
int, std::vector<double>>& varscal, std::string svar);
145 void getMeanReso(std::array<std::vector<TH1D*>, numdedx::nrings>& hvar,
146 std::map<
int, std::vector<double>>& vmeans, std::map<
int, std::vector<double>>& vresos);
156 void plotBinLevelDist(std::array<std::vector<TH1D*>, numdedx::nrings>& hvar, std::string var);
161 void plotRelConstants(std::map<
int, std::vector<double>>& vmeans, std::map<
int, std::vector<double>>& vresos,
162 std::map<
int, std::vector<double>>& corr, std::string svar);
167 void plotTimeStat(std::array<std::vector<TH1D*>, numdedx::nrings>& htime);
172 void plotFinalConstants(std::map<
int, std::vector<double>>& vmeans, std::map<
int, std::vector<double>>& vresos,
173 std::array<double, numdedx::nrings>& scale, std::array<double, numdedx::nrings>& scale_reso);
183 void setHistStyle(TH1D*& htemp,
const int ic,
const int is,
const double min,
const double max)
186 htemp->LabelsDeflate();
187 htemp->SetMarkerColor(ic);
188 htemp->SetMarkerStyle(is);
189 htemp->GetXaxis()->SetLabelOffset(-0.055);
190 htemp->GetYaxis()->SetTitleOffset(0.75);
191 htemp->SetMinimum(min);
192 htemp->SetMaximum(max);
200 std::string label =
"";
201 if (tedges < 2e4)label = Form(
"%0.01f-%0.01fK",
m_tedges[it] / 1e3,
m_tedges[it + 1] / 1e3);
202 else if (tedges < 1e5)label = Form(
"%0.0f-%0.0fK",
m_tedges[it] / 1e3,
m_tedges[it + 1] / 1e3);
203 else label = Form(
"%0.01f-%0.01fM",
m_tedges[it] / 1e6,
m_tedges[it + 1] / 1e6);
210 void deleteHisto(std::array<std::vector<TH1D*>, numdedx::nrings>& htemp)
212 for (
unsigned int ir = 0; ir <
c_rings; ir++) {
213 for (
unsigned int it = 0; it <
m_tbins; it++) {
214 delete htemp[ir][it];
225 for (
unsigned int ir = 0; ir <
c_rings; ir++) {
226 for (
int wt = 0; wt < tzoom; wt++) {
227 delete htemp[ir][wt];
235 double getCorrection(
unsigned int ring,
unsigned int time, std::map<
int, std::vector<double>>& vmeans);
248 std::array<std::string, numdedx::nrings>
m_sring{
"ler",
"her"};
A calibration algorithm for CDC dE/dx injection time (HER/LER)
void setChiPars(int value, double min, double max)
function to set chi hist parameters
void setDedxPars(int value, double min, double max)
function to set dedx hist parameters
bool m_isMerge
merge payload when rel constant
virtual ~CDCDedxInjectTimeAlgorithm()
Destructor.
void plotBinLevelDist(std::array< std::vector< TH1D * >, numdedx::nrings > &hvar, std::string var)
function to draw dedx, chi and time dist.
std::vector< double > m_vtlocaledges
internal time vector
double m_sigmaR
fit dedx dist in sigma range
void correctBinBias(std::map< int, std::vector< double > > &varcorr, std::map< int, std::vector< double > > &var, std::map< int, std::vector< double > > &time, TH1D *&htimes)
function to correct dedx mean/reso and return corrected vector map
void defineHisto(std::array< std::vector< TH1D * >, numdedx::nrings > &htemp, std::string var)
function to define histograms for dedx and time dist.
double getCorrection(unsigned int ring, unsigned int time, std::map< int, std::vector< double > > &vmeans)
function to get the correction factor of mean
double m_chiMax
max range of chi
std::string m_prefix
string prefix for plot names
void getExpRunInfo()
function to get exp/run information (payload object, plotting)
void setHistStyle(TH1D *&htemp, const int ic, const int is, const double min, const double max)
function to set histogram cosmetics
void plotFinalConstants(std::map< int, std::vector< double > > &vmeans, std::map< int, std::vector< double > > &vresos, std::array< double, numdedx::nrings > &scale, std::array< double, numdedx::nrings > &scale_reso)
function to final constant from merging or abs fits
int m_countR
a hack for running functions once
double * m_tedges
internal time array (copy of vtlocaledges)
double m_chiMin
min range of chi
bool m_ismakePlots
produce plots for monitoring
std::string m_suffix
string suffix for object names
int m_chiBins
bins for chi histogram
void setMinTracks(int value)
function to set min # of tracks in time bins (0-40ms)
static const int c_rings
injection ring constants
int m_dedxBins
bins for dedx histogram
void createPayload(std::array< double, numdedx::nrings > &scale, std::map< int, std::vector< double > > &vmeans, std::map< int, std::vector< double > > &varscal, std::string svar)
function to store payloads after full calibration
void plotInjectionTime(std::array< std::array< TH1D *, 3 >, numdedx::nrings > &hvar)
function to injection time distributions (HER/LER in three bins)
void plotTimeStat(std::array< std::vector< TH1D * >, numdedx::nrings > &htime)
function to draw time stats
void fitGaussianWRange(TH1D *&temphist, fstatus &status)
function to perform gauss fit for input histogram
void defineTimeBins()
function to set/reset time bins
void plotRelConstants(std::map< int, std::vector< double > > &vmeans, std::map< int, std::vector< double > > &vresos, std::map< int, std::vector< double > > &corr, std::string svar)
function to relative constant from dedx fit mean and chi fit reso
void defineTimeHisto(std::array< std::array< TH1D *, 3 >, numdedx::nrings > &htemp)
function to define injection time bins histograms (monitoring only)
void deleteHisto(std::array< std::vector< TH1D * >, numdedx::nrings > &htemp)
function to delete histograms for dedx and time dist.
void setMergePayload(bool value=true)
function to decide merged vs relative calibration
void deleteTimeHisto(std::array< std::array< TH1D *, 3 >, numdedx::nrings > &htemp)
function to define injection time bins histograms (monitoring only)
void plotEventStats()
function to draw event/track statistics plots
virtual EResult calibrate() override
CDC dE/dx Injection time algorithm.
void checkStatistics(std::array< std::vector< TH1D * >, numdedx::nrings > &hvar)
check statistics for obtaining calibration const.
std::vector< double > m_vtedges
external time vector
std::vector< std::vector< double > > m_vinjPayload
vector to store payload values
double m_dedxMax
max range of dedx
bool m_isminStat
flag to merge runs for statistics thershold
CDCDedxInjectTimeAlgorithm()
Constructor: Sets the description, the properties and the parameters of the algorithm.
std::array< std::string, numdedx::nrings > m_sring
injection ring name
DBObjPtr< CDCDedxInjectionTime > m_DBInjectTime
Injection time DB object.
void setMonitoringPlots(bool value=false)
function to enable monitoring plots
double m_dedxMin
min range of dedx
unsigned int m_tbins
internal time bins
int m_thersE
min tracks to start calibration
void getMeanReso(std::array< std::vector< TH1D * >, numdedx::nrings > &hvar, std::map< int, std::vector< double > > &vmeans, std::map< int, std::vector< double > > &vresos)
function to get mean and reso of histogram
std::string getTimeBinLabel(const double &tedges, const int &it)
function to return time label for histograms labeling
void setFitWidth(double value)
function to set fit range (sigma)
Base class for calibration algorithms.
EResult
The result of calibration.
Class for accessing objects in the database.
Abstract base class for different kinds of events.