16#include <calibration/CalibrationAlgorithm.h>
17#include <framework/database/DBObjPtr.h>
18#include <cdc/dbobjects/CDCDedxInjectionTime.h>
22 static const int nrings = 2;
23 static const int nvectors = 6;
26enum fstatus {fitOK, fitFailed};
108 void defineHisto(std::array<std::vector<TH1D*>, numdedx::nrings>& htemp, std::string var);
113 void defineTimeHisto(std::array<std::array<TH1D*, 3>, numdedx::nrings>& htemp);
118 void checkStatistics(std::array<std::vector<TH1D*>, numdedx::nrings>& hvar);
123 void correctBinBias(std::map<
int, std::vector<double>>& varcorr, std::map<
int, std::vector<double>>& var,
124 std::map<
int, std::vector<double>>& time, TH1D*& htimes);
129 void createPayload(std::array<double, numdedx::nrings>& scale, std::map<
int, std::vector<double>>& vmeans,
130 std::map<
int, std::vector<double>>& varscal, std::string svar);
135 void getMeanReso(std::array<std::vector<TH1D*>, numdedx::nrings>& hvar,
136 std::map<
int, std::vector<double>>& vmeans, std::map<
int, std::vector<double>>& vresos);
146 void plotBinLevelDist(std::array<std::vector<TH1D*>, numdedx::nrings>& hvar, std::string var);
151 void plotRelConstants(std::map<
int, std::vector<double>>& vmeans, std::map<
int, std::vector<double>>& vresos,
152 std::map<
int, std::vector<double>>& corr, std::string svar);
157 void plotTimeStat(std::array<std::vector<TH1D*>, numdedx::nrings>& htime);
162 void plotFinalConstants(std::map<
int, std::vector<double>>& vmeans, std::map<
int, std::vector<double>>& vresos,
163 std::array<double, numdedx::nrings>& scale, std::array<double, numdedx::nrings>& scale_reso);
173 void setHistStyle(TH1D*& htemp,
const int ic,
const int is,
const double min,
const double max)
176 htemp->LabelsDeflate();
177 htemp->SetMarkerColor(ic);
178 htemp->SetMarkerStyle(is);
179 htemp->GetXaxis()->SetLabelOffset(-0.055);
180 htemp->GetYaxis()->SetTitleOffset(0.75);
181 htemp->SetMinimum(min);
182 htemp->SetMaximum(max);
190 std::string label =
"";
191 if (tedges < 2e4)label = Form(
"%0.01f-%0.01fK",
m_tedges[it] / 1e3,
m_tedges[it + 1] / 1e3);
192 else if (tedges < 1e5)label = Form(
"%0.0f-%0.0fK",
m_tedges[it] / 1e3,
m_tedges[it + 1] / 1e3);
193 else label = Form(
"%0.01f-%0.01fM",
m_tedges[it] / 1e6,
m_tedges[it + 1] / 1e6);
200 void deleteHisto(std::array<std::vector<TH1D*>, numdedx::nrings>& htemp)
202 for (
unsigned int ir = 0; ir <
c_rings; ir++) {
203 for (
unsigned int it = 0; it <
m_tbins; it++) {
204 delete htemp[ir][it];
215 for (
unsigned int ir = 0; ir <
c_rings; ir++) {
216 for (
int wt = 0; wt < tzoom; wt++) {
217 delete htemp[ir][wt];
225 double getCorrection(
unsigned int ring,
unsigned int time, std::map<
int, std::vector<double>>& vmeans);
238 std::array<std::string, numdedx::nrings>
m_sring{
"ler",
"her"};
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)
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.
Abstract base class for different kinds of events.