30 #include <b2bii/modules/B2BIIMdstInput/B2BIIFixMdstModule.h>
31 #include "belle_legacy/panther/panther.h"
39 #include "CLHEP/Vector/ThreeVector.h"
41 #include "belle_legacy/tables/mdst.h"
42 #include "belle_legacy/tables/belletdf.h"
60 Belle::Belle_event_Manager& evtmgr = Belle::Belle_event_Manager::get_manager();
61 if (evtmgr.count() == 0)
return;
63 Belle::Mdst_event_add_Manager& addmgr = Belle::Mdst_event_add_Manager::get_manager();
64 if (addmgr.count() == 0)
return;
65 if (addmgr[0].flag(4) != 0)
return;
68 if (mode < 0 || mode > 2) {
69 B2ERROR(
"shift_tof: invalid mode specified;");
70 B2ERROR(
"mode must be 0, 1, 2");
74 int expmc = evtmgr[0].ExpMC();
75 int expno = evtmgr[0].ExpNo();
76 int runno = evtmgr[0].RunNo();
78 if (expmc == 2)
return;
84 Belle::Mdst_charged_Manager& ChgMgr = Belle::Mdst_charged_Manager::get_manager();
85 for (std::vector<Belle::Mdst_charged>::iterator it = ChgMgr.begin();
86 it != ChgMgr.end(); ++it) {
87 Belle::Mdst_charged& Chg = *it;
90 Belle::Mdst_tof& Tof = Chg.tof();
93 TVector3 Mom(Chg.px(), Chg.py(), Chg.pz());
94 double pmom = Mom.Mag();
95 double sgn = Chg.charge();
97 for (
int im = 0; im < 5; im++) {
100 if (fabs(shift) < .005)
continue;
101 double ot = Tof.tof_exp(im);
102 double odt = ot - Tof.tof();
103 double opid = Tof.pid(im);
105 int ndf = (int)(Tof.ndf(im) + .001);
106 if (opid > 0. && opid < 1.) {
107 double ct = ot + shift;
108 double cdt = ct - Tof.tof();
109 double err = fabs(odt) / sqrt(-2.*log(opid));
110 double cch = pow(cdt / err, 2);
111 double cpid = exp(-.5 * cch);
112 double ccl = TMath::Prob(cch, ndf);
123 const int mode,
const int im,
124 const double pmom,
const double sgn,
127 static const double m[5] = {.000511, .10566, .13957, .49368, .93827};
129 double beta = pmom / sqrt(pmom * pmom + m[im] * m[im]);
135 if (runno < 536) shift = 0.;
136 else if (runno < 1440) shift = .5054 - .5216 * std::min(beta, .955);
137 else shift = .8321 - .8648 * std::min(beta, .96);
140 if (runno < 536) shift = -.0414 * exp(-pow(beta - .538, 2) / .0569);
141 else if (runno < 1440) shift = -12.3 * exp(-pow(beta + .288, 2) / .1197);
146 shift = -.876 * exp(-pow(beta + .1818, 2) / .1947);
149 shift = .01 - .1028 * exp(-pow(beta - .4454, 2) / .00272);
150 else shift = .01 - .064 * exp(-pow(beta - .4273, 2) / .00317);
164 shift = 1.089 - 1.131 * std::min(beta, .955);
167 if (sgn > 0.) shift = -.876 * exp(-pow(beta + .1818, 2) / .1947);
168 else shift = .01 - .1028 * exp(-pow(beta - .4454, 2) / .00272);
182 if (sgn > 0.) shift = -.0183 * exp(-pow(beta - .911, 2) / .00161);
185 shift = -6.6 * exp(-beta / .1);
188 if (sgn > 0.) shift = -.736 * exp(-pow(beta + .04158, 2) / .119);
189 else shift = .02 - .1475 * exp(-pow(beta - .4267, 2) / .00249);
201 if (sgn > 0.) shift = -.3259 * exp(-pow(beta - .1042, 2) / .0817);
202 else shift = .02 - .1475 * exp(-pow(beta - .4267, 2) / .00249);