9#include <cdc/calibration/CDCdEdx/CDCDedxHadSatAlgorithm.h>
22 setDescription(
"A calibration algorithm for CDC dE/dx hadron saturation");
36 B2FATAL(
"There is no valid payload for Hadron saturation");
39 std::vector<std::string> particles = {
"pion",
"kaon",
"muon",
"proton"};
42 for (
int i = 0; i < int(particles.size()); i++) {
43 std::string p = particles[i];
44 auto tree = getObjectPtr<TTree>(Form(
"%s", p.data()));
48 gSystem->Exec(
"mkdir -p plots/HadronSat");
51 std::string filename =
"widget_uncorrected_NoHSpar_2D.root";
55 filename =
"widget_corrected_defHSpar_2D.root";
59 for (
int i = 0; i < 5; ++i) par[i] =
m_DBHadronCor->getHadronPar(i);
63 hadsat.
fillSample(
"widget_uncorrected_NoHSpar_2D.root");
69 filename =
"widget_corrected_newHSpar_2D.root";
72 B2INFO(
"Saving calibration for: " <<
m_suffix <<
"");
84 if (cruns == 0)B2INFO(
"CDCDedxInjectTimeAlgorithm: start exp " << expRun.first <<
" and run " << expRun.second <<
"");
89 int estart = erStart.first;
90 int rstart = erStart.second;
94 m_suffix = Form(
"e%dr%d", estart, rstart);
95 B2INFO(
"tool exp = " << estart <<
", run = " << rstart <<
", m_suffix = " <<
m_suffix <<
"");
102 std::ifstream fin(
"sat-pars.fit.txt");
103 if (!fin.good()) B2FATAL(
"\tWARNING: CANNOT FIND sat-pars.fit.txt!");
106 std::vector<double> v_hadsatpars;
108 B2INFO(
"\t --> Hadron saturation parameters");
109 for (
int i = 0; i < 5; ++i) {
111 v_hadsatpars.push_back(hadsatpars);
112 B2INFO(
"\t\t (" << i <<
")" << v_hadsatpars[i]);
116 B2INFO(
"dE/dx Calibration done for " << v_hadsatpars.size() <<
" CDC Hadron saturation");
123 const std::string& sfx,
126 TFile* outfile =
new TFile(Form(
"%s", filename.data()),
"RECREATE");
128 for (
int i = 0; i < int(particles.size()); i++) {
131 std::string p = particles[i];
132 auto tree = getObjectPtr<TTree>(Form(
"%s", p.data()));
int m_cosBins
bins for cosine
std::map< std::string, std::array< double, 3 > > m_bgpar
bg bins, min, max for different particles
DBObjPtr< CDCDedxHadronCor > m_DBHadronCor
db object for dE/dx hadron saturation parameters
void getExpRunInfo()
function to get exp/run information (payload object, plotting)
double m_cosMax
max range of cosine
CDCDedxHadSatAlgorithm()
Constructor: Sets the description, the properties and the parameters of the algorithm.
void prepareSample(std::vector< std::string > &particles, const std::string &filename, const std::string &sfx, bool correct)
function to prepare sample for bgcurve hadron saturation and monitoring plots
bool m_ismakePlots
produce plots for monitoring
std::string m_suffix
string suffix for object names
double m_cosMin
min range of cosine
double m_cut
cut to clean protons
virtual EResult calibrate() override
CDC dE/dx Hadron saturation algorithm.
void createPayload()
function to store payloads after full calibration
dE/dx hadron saturation parameterization constants
Base class for calibration algorithms.
void saveCalibration(TClonesArray *data, const std::string &name)
Store DBArray payload with given name with default IOV.
void updateDBObjPtrs(const unsigned int event, const int run, const int experiment)
Updates any DBObjPtrs by calling update(event) for DBStore.
void setDescription(const std::string &description)
Set algorithm description (in constructor)
const std::vector< Calibration::ExpRun > & getRunList() const
Get the list of runs for which calibration is called.
EResult
The result of calibration.
@ c_OK
Finished successfully =0 in Python.
@ c_NotEnoughData
Needs more data =2 in Python.
Class to prepare sample for hadron saturation calibration.
void prepareSample(std::shared_ptr< TTree > hadron, TFile *&outfile, const std::string &suffix, const std::string &pdg, bool ismakePlots, bool correct)
function to prepare sample for monitoring plots, bg curve fitting and sigma vs ionz fitting
Class to perform the hadron saturation calibration.
void fillSample(TString infilename)
fill the vectors below
void fitSaturation()
perform the hadron saturation fit
Abstract base class for different kinds of events.