9#include <reconstruction/calibration/CDCdEdx/CDCDedxMomentumAlgorithm.h>
11#include <reconstruction/dbobjects/CDCDedxMomentumCor.h>
27 setDescription(
"A calibration algorithm for CDC dE/dx electron cos(theta) dependence");
37 auto ttree = getObjectPtr<TTree>(
"tree");
40 if (ttree->GetEntries() < 100)
44 ttree->SetBranchAddress(
"dedx", &dedx);
45 ttree->SetBranchAddress(
"p", &p);
49 const int nbins = 100;
51 for (
unsigned int i = 0; i < nbins; ++i) {
52 dedxp[i] = TH1F(TString::Format(
"dedxp%d", i),
"dE/dx in bins of momentum", 200, 0, 4);
56 for (
int i = 0; i < ttree->GetEntries(); ++i) {
58 if (dedx == 0)
continue;
59 if (p <= 0.0 || p > 10.0)
continue;
60 int bin = std::floor(p / (10.0 / nbins));
61 if (bin < 0 || bin >= nbins)
continue;
62 dedxp[bin].Fill(dedx);
66 TCanvas* ctmp =
new TCanvas(
"tmp",
"tmp", 900, 900);
68 std::stringstream psname; psname <<
"dedx_momentum.ps[";
69 ctmp->Print(psname.str().c_str());
70 psname.str(
""); psname <<
"dedx_momentum.ps";
73 std::vector<double> momentum;
74 for (
unsigned int i = 0; i < nbins; ++i) {
76 dedxp[i].DrawCopy(
"hist");
79 if (dedxp[i].Integral() < 10)
80 momentum.push_back(mean);
82 if (dedxp[i].Fit(
"gaus")) {
83 B2WARNING(
"Fit failed...");
84 momentum.push_back(mean);
86 B2WARNING(
"Fit succeeded: " << mean <<
"\t" << dedxp[i].GetFunction(
"gaus")->GetParameter(1));
87 mean *= dedxp[i].GetFunction(
"gaus")->GetParameter(1);
88 momentum.push_back(mean);
92 ctmp->Print(psname.str().c_str());
95 psname.str(
""); psname <<
"dedx_momentum.ps]";
96 ctmp->Print(psname.str().c_str());
98 B2INFO(
"dE/dx Calibration done for CDC dE/dx momentum correction");
99 std::cout <<
"dE/dx Calibration done for CDC dE/dx momentum correction" << std::endl;
CDCDedxMomentumAlgorithm()
Constructor: Sets the description, the properties and the parameters of the algorithm.
virtual EResult calibrate() override
Scale Momentum algorithm.
dE/dx wire gain calibration constants
Base class for calibration algorithms.
void saveCalibration(TClonesArray *data, const std::string &name)
Store DBArray payload with given name with default IOV.
void setDescription(const std::string &description)
Set algorithm description (in constructor)
EResult
The result of calibration.
@ c_OK
Finished successfully =0 in Python.
@ c_NotEnoughData
Needs more data =2 in Python.
Abstract base class for different kinds of events.