11 #include <reconstruction/calibration/CDCDedxMomentumAlgorithm.h>
13 #include <reconstruction/dbobjects/CDCDedxMomentumCor.h>
29 setDescription(
"A calibration algorithm for CDC dE/dx electron cos(theta) dependence");
39 auto ttree = getObjectPtr<TTree>(
"tree");
42 if (ttree->GetEntries() < 100)
46 ttree->SetBranchAddress(
"dedx", &dedx);
47 ttree->SetBranchAddress(
"p", &p);
51 const int nbins = 100;
53 for (
unsigned int i = 0; i < nbins; ++i) {
54 dedxp[i] = TH1F(TString::Format(
"dedxp%d", i),
"dE/dx in bins of momentum", 200, 0, 4);
58 for (
int i = 0; i < ttree->GetEntries(); ++i) {
60 if (dedx == 0)
continue;
61 if (p <= 0.0 || p > 10.0)
continue;
62 int bin = std::floor(p / (10.0 / nbins));
63 if (bin < 0 || bin >= nbins)
continue;
64 dedxp[bin].Fill(dedx);
68 TCanvas* ctmp =
new TCanvas(
"tmp",
"tmp", 900, 900);
70 std::stringstream psname; psname <<
"dedx_momentum.ps[";
71 ctmp->Print(psname.str().c_str());
72 psname.str(
""); psname <<
"dedx_momentum.ps";
75 std::vector<double> momentum;
76 for (
unsigned int i = 0; i < nbins; ++i) {
78 dedxp[i].DrawCopy(
"hist");
81 if (dedxp[i].Integral() < 10)
82 momentum.push_back(mean);
84 if (dedxp[i].Fit(
"gaus")) {
85 B2WARNING(
"Fit failed...");
86 momentum.push_back(mean);
88 B2WARNING(
"Fit succeeded: " << mean <<
"\t" << dedxp[i].GetFunction(
"gaus")->GetParameter(1));
89 mean *= dedxp[i].GetFunction(
"gaus")->GetParameter(1);
90 momentum.push_back(mean);
94 ctmp->Print(psname.str().c_str());
97 psname.str(
""); psname <<
"dedx_momentum.ps]";
98 ctmp->Print(psname.str().c_str());
100 B2INFO(
"dE/dx Calibration done for CDC dE/dx momentum correction");
101 std::cout <<
"dE/dx Calibration done for CDC dE/dx momentum correction" << std::endl;