2 #include "trg/cdc/Fitter3DUtility.h"
3 #include "trg/cdc/FpgaUtility.h"
4 #include "trg/cdc/JLUT.h"
5 #include "trg/cdc/JSignal.h"
6 #include "trg/cdc/JSignalData.h"
9 #include "Fitter3DUtility.h"
12 #include "JSignalData.h"
17 #include "TLorentzVector.h"
34 using std::make_tuple;
38 double Trg_PI = 3.141592653589793;
42 if ((phi2[0] - phi2[4]) > Trg_PI || (phi2[0] - phi2[4]) < -Trg_PI) {
43 if (phi2[0] > Trg_PI) {sign_phi[0] = phi2[0] - 2 * Trg_PI;}
44 else {sign_phi[0] = phi2[0];}
45 if (phi2[4] > Trg_PI) {sign_phi[1] = phi2[4] - 2 * Trg_PI;}
46 else {sign_phi[1] = phi2[4];}
48 sign_phi[0] = phi2[0];
49 sign_phi[1] = phi2[4];
51 if ((sign_phi[1] - sign_phi[0]) > 0) {mysign = 0;}
60 cout <<
"Fitter3DUtility::rPhiFit() will be deprecated. Please use Fitter3DUtility::rPhiFitter(). phierror was changed to inv phi error."
62 double invphierror[5];
63 for (
unsigned i = 0; i < 5; i++) {
64 invphierror[i] = 1 / phierror[i];
66 rPhiFitter(rr, phi2, invphierror, rho, myphi0);
73 rPhiFitter(rr, phi2, invphierror, rho, myphi0, chi2);
85 double Trg_PI = 3.141592653589793;
86 double A, B, C, D, E, hcx, hcy;
87 double invFiterror[5];
90 for (
unsigned i = 0; i < 5; i++) {
95 invFiterror[i] = invphierror[i] / rr[i];
99 A = 0, B = 0, C = 0, D = 0, E = 0, hcx = 0, hcy = 0;
101 for (
unsigned i = 0; i < 5; i++) {
102 A += cos(phi2[i]) * cos(phi2[i]) * (invFiterror[i] * invFiterror[i]);
103 B += sin(phi2[i]) * sin(phi2[i]) * (invFiterror[i] * invFiterror[i]);
104 C += cos(phi2[i]) * sin(phi2[i]) * (invFiterror[i] * invFiterror[i]);
105 D += rr[i] * cos(phi2[i]) * (invFiterror[i] * invFiterror[i]);
106 E += rr[i] * sin(phi2[i]) * (invFiterror[i] * invFiterror[i]);
110 hcx /= 2 * (A * B - C * C);
112 hcy /= 2 * (A * B - C * C);
113 rho = sqrt(hcx * hcx + hcy * hcy);
114 myphi0 = atan2(hcy, hcx);
115 if (myphi0 < 0) myphi0 += 2 * Trg_PI;
127 for (
unsigned iAx = 0; iAx < 5; iAx++) {
128 if (invphierror[iAx] != 0) nTSHits++;
132 for (
unsigned i = 0; i < 5; i++) {
133 chi2 += (2 * (hcx * cos(phi2[i]) + hcy * sin(phi2[i])) - rr[i]) * (2 * (hcx * cos(phi2[i]) + hcy * sin(phi2[i])) - rr[i]) /
134 (invFiterror[i] * invFiterror[i]);
143 double Trg_PI = 3.141592653589793;
144 vector<double> tsPhi(5);
145 vector<double> dPhi(5);
146 vector<double> dPhi_c(5);
147 vector<double> charge(5);
148 for (
unsigned iAx = 0; iAx < 5; iAx++) {
151 tsPhi[iAx] = tsIds[iAx] * 2 * Trg_PI / nTSs[iAx];
152 dPhi[iAx] = tsPhi[iAx] - phi0;
155 if (dPhi[iAx] < -Trg_PI) dPhi_c[iAx] = dPhi[iAx] + 2 * Trg_PI;
156 else if (dPhi[iAx] > Trg_PI) dPhi_c[iAx] = dPhi[iAx] - 2 * Trg_PI;
157 else dPhi_c[iAx] = dPhi[iAx];
160 if (tsHitmap[iAx] == 0) charge[iAx] = 0;
161 else if (dPhi_c[iAx] == 0) charge[iAx] = 0;
162 else if (dPhi_c[iAx] > 0) charge[iAx] = 1;
163 else charge[iAx] = -1;
167 double sumCharge = charge[0] + charge[1] + charge[2] + charge[3] + charge[4];
170 if (sumCharge == 0) foundCharge = inCharge;
171 else if (sumCharge > 0) foundCharge = 1;
172 else foundCharge = -1;
181 double Trg_PI = 3.141592653589793;
182 double A, B, C, D, E, hcx, hcy;
186 for (
int i = 0; i < nTS; i++) {
188 fiterror[i] = 1 + 0 * phierror[i];
192 A = 0, B = 0, C = 0, D = 0, E = 0, hcx = 0, hcy = 0;
194 for (
int i = 0; i < nTS; i++) {
195 A += cos(phi2[i]) * cos(phi2[i]) / (fiterror[i] * fiterror[i]);
196 B += sin(phi2[i]) * sin(phi2[i]) / (fiterror[i] * fiterror[i]);
197 C += cos(phi2[i]) * sin(phi2[i]) / (fiterror[i] * fiterror[i]);
198 D += rr[i] * cos(phi2[i]) / (fiterror[i] * fiterror[i]);
199 E += rr[i] * sin(phi2[i]) / (fiterror[i] * fiterror[i]);
203 hcx /= 2 * (A * B - C * C);
205 hcy /= 2 * (A * B - C * C);
206 rho = sqrt(hcx * hcx + hcy * hcy);
207 myphi0 = atan2(hcy, hcx);
208 if (myphi0 < 0) myphi0 += 2 * Trg_PI;
229 int tdcMax = pow(2, nBits) - 1;
232 if (resultTdc > tdcMax) resultTdc -= (tdcMax + 1);
233 else if (resultTdc < 0) resultTdc += (tdcMax + 1);
236 return (
unsigned) resultTdc;
242 double result = wirePhi;
245 double t_dPhi = driftLength;
249 t_dPhi = atan(t_dPhi / rr);
252 if (lr == 1) result -= t_dPhi;
253 else if (lr == 2) result += t_dPhi;
261 double t_driftLength = (driftTime - eventTime) * 1000 / 1017.774 * 2 * 40 / 1000 / 10;
262 return calPhi(wirePhi, t_driftLength, rr, lr);
267 double wirePhi = (double)localId / nWires * 4 * M_PI;
272 std::map<std::string, std::vector<double> >
const& mConstV, std::map<std::string, Belle2::TRGCDCJSignal>& mSignalStorage,
273 std::map<std::string, Belle2::TRGCDCJLUT* >& mLutStorage)
280 if (mSignalStorage.find(
"phiFactor_0") == mSignalStorage.end()) {
281 for (
unsigned iSt = 0; iSt < 4; iSt++) {
282 int nShiftBits = int(log(pow(2, 24) / 2 / mConstD.at(
"Trg_PI") * mConstV.at(
"nTSs")[2 * iSt + 1] *
283 mSignalStorage[
"phi0"].getToReal()) / log(2));
285 t_name =
"phiFactor_" + to_string(iSt);
286 mSignalStorage[t_name] =
Belle2::TRGCDCJSignal(2 * mConstD.at(
"Trg_PI") / mConstV.at(
"nTSs")[2 * iSt + 1],
287 mSignalStorage[
"phi0"].getToReal() / pow(2, nShiftBits), commonData);
292 for (
unsigned iSt = 0; iSt < 4;
293 iSt++) mSignalStorage[
"wirePhi_" + to_string(iSt)] <= mSignalStorage[
"tsId_" + to_string(iSt)] * mSignalStorage[
"phiFactor_" +
301 for (
unsigned iSt = 0; iSt < 4;
302 iSt++) mSignalStorage[
"driftTimeRaw_" + to_string(iSt)] <= mSignalStorage[
"tdc_" + to_string(iSt)] - mSignalStorage[
"eventTime"];
308 if (mSignalStorage.find(
"maxDriftTimeLow") == mSignalStorage.end()) {
309 int maxDriftTime = 287;
310 mSignalStorage[
"maxDriftTimeLow"] =
Belle2::TRGCDCJSignal(-512 + maxDriftTime + 1, mSignalStorage[
"eventTime"].getToReal(),
312 mSignalStorage[
"maxDriftTimeHigh"] =
Belle2::TRGCDCJSignal(maxDriftTime, mSignalStorage[
"eventTime"].getToReal(), commonData);
313 mSignalStorage[
"maxDriftTimeMax"] =
Belle2::TRGCDCJSignal(512, mSignalStorage[
"eventTime"].getToReal(), commonData);
315 for (
unsigned iSt = 0; iSt < 4; iSt++) {
316 string t_in1Name =
"driftTimeRaw_" + to_string(iSt);
317 string t_valueName =
"driftTime_c_" + to_string(iSt);
319 vector<pair<Belle2::TRGCDCJSignal, vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > > > t_data;
322 mSignalStorage[
"eventTimeValid"].getToReal(), commonData));
324 vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > t_assigns = {
325 make_pair(&mSignalStorage[t_valueName],
Belle2::TRGCDCJSignal(0, mSignalStorage[
"eventTime"].getToReal(), commonData))
328 t_data.push_back(make_pair(t_compare, t_assigns));
333 make_pair(&mSignalStorage[t_valueName], (mSignalStorage[t_in1Name] + mSignalStorage[
"maxDriftTimeMax"]).limit(mSignalStorage[
"maxDriftTimeLow"], mSignalStorage[
"maxDriftTimeHigh"]))
336 t_data.push_back(make_pair(t_compare, t_assigns));
341 make_pair(&mSignalStorage[t_valueName], mSignalStorage[t_in1Name].limit(mSignalStorage[
"maxDriftTimeLow"], mSignalStorage[
"maxDriftTimeHigh"]))
344 t_data.push_back(make_pair(t_compare, t_assigns));
349 make_pair(&mSignalStorage[t_valueName], (mSignalStorage[t_in1Name] - mSignalStorage[
"maxDriftTimeMax"]).limit(mSignalStorage[
"maxDriftTimeLow"], mSignalStorage[
"maxDriftTimeHigh"]))
352 t_data.push_back(make_pair(t_compare, t_assigns));
367 if (mSignalStorage.find(
"minDriftTime") == mSignalStorage.end()) {
368 int minDriftTime = -8;
369 mSignalStorage[
"minDriftTime"] =
Belle2::TRGCDCJSignal(minDriftTime, mSignalStorage[
"eventTime"].getToReal(), commonData);
370 mSignalStorage[
"minDriftTimeLow"] =
Belle2::TRGCDCJSignal(0, mSignalStorage[
"eventTime"].getToReal(), commonData);
372 for (
unsigned iSt = 0; iSt < 4; iSt++) {
373 string t_in1Name =
"driftTime_c_" + to_string(iSt);
374 string t_valueName =
"driftTime_" + to_string(iSt);
375 string t_in2Name =
"invErrorRho_" + to_string(iSt);
376 string t_value2Name =
"iZError2_" + to_string(iSt);
377 string t_noneErrorName =
"iZNoneError2_" + to_string(iSt);
379 vector<pair<Belle2::TRGCDCJSignal, vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > > > t_data;
383 vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > t_assigns = {
384 make_pair(&mSignalStorage[t_valueName], mSignalStorage[t_in1Name].limit(mSignalStorage[
"minDriftTimeLow"], mSignalStorage[
"maxDriftTimeHigh"])),
385 make_pair(&mSignalStorage[t_value2Name], mSignalStorage[t_in2Name])
388 t_data.push_back(make_pair(t_compare, t_assigns));
393 make_pair(&mSignalStorage[t_valueName], mSignalStorage[
"minDriftTimeLow"]),
394 make_pair(&mSignalStorage[t_value2Name], mSignalStorage[t_in2Name])
397 t_data.push_back(make_pair(t_compare, t_assigns));
402 make_pair(&mSignalStorage[t_valueName], mSignalStorage[
"minDriftTimeLow"]),
403 make_pair(&mSignalStorage[t_value2Name], mSignalStorage[t_noneErrorName])
406 t_data.push_back(make_pair(t_compare, t_assigns));
420 if (mSignalStorage.find(
"invDriftPhiMin") == mSignalStorage.end()) {
421 mSignalStorage[
"invDriftPhiMin"] =
Belle2::TRGCDCJSignal(0, mSignalStorage[
"driftTime_0"].getToReal(), commonData);
423 mSignalStorage[
"driftTime_0"].getToReal(), commonData);
428 for (
unsigned iSt = 0; iSt < 4; iSt++) {
429 string t_valueName =
"driftPhi_" + to_string(iSt);
430 string t_inName =
"driftTime_" + to_string(iSt);
431 if (mLutStorage.find(t_valueName) == mLutStorage.end()) {
434 double t_parameter = mConstV.at(
"rr3D")[iSt];
435 mLutStorage[t_valueName]->setFloatFunction(
437 [ = ](
double aValue) ->
double{
return atan(mConstV.at(
"driftLengthTableSL" + to_string(2 * iSt + 1))[aValue] / t_parameter);},
438 mSignalStorage[t_inName],
439 mSignalStorage[
"invDriftPhiMin"], mSignalStorage[
"invDriftPhiMax"], mSignalStorage[
"phi0"].getToReal(),
440 (int)mConstD.at(
"driftPhiLUTInBitSize"), (int)mConstD.at(
"driftPhiLUTOutBitSize"));
446 for (
unsigned iSt = 0; iSt < 4; iSt++) {
449 mLutStorage[
"driftPhi_" + to_string(iSt)]->operate(mSignalStorage[
"driftTime_" + to_string(iSt)],
450 mSignalStorage[
"driftPhi_" + to_string(iSt)]);
456 for (
unsigned iSt = 0; iSt < 4; iSt++) {
457 string t_in1Name =
"lr_" + to_string(iSt);
458 string t_valueName =
"finePhi_" + to_string(iSt);
460 vector<pair<Belle2::TRGCDCJSignal, vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > > > t_data;
463 mSignalStorage[t_in1Name].getToReal(), commonData));
465 vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > t_assigns = {
466 make_pair(&mSignalStorage[t_valueName], mSignalStorage[
"wirePhi_" + to_string(iSt)] - mSignalStorage[
"driftPhi_" + to_string(iSt)])
469 t_data.push_back(make_pair(t_compare, t_assigns));
472 mSignalStorage[t_in1Name].getToReal(), commonData));
475 make_pair(&mSignalStorage[t_valueName], mSignalStorage[
"wirePhi_" + to_string(iSt)] + mSignalStorage[
"driftPhi_" + to_string(iSt)])
478 t_data.push_back(make_pair(t_compare, t_assigns));
483 make_pair(&mSignalStorage[t_valueName], mSignalStorage[
"wirePhi_" + to_string(iSt)])
486 t_data.push_back(make_pair(t_compare, t_assigns));
493 if (mSignalStorage.find(
"phiMax_0") == mSignalStorage.end()) {
494 for (
unsigned iSt = 0; iSt < 4; iSt++) {
495 string t_valueName =
"finePhi_" + to_string(iSt);
496 string t_maxName =
"phiMax_" + to_string(iSt);
497 string t_minName =
"phiMin_" + to_string(iSt);
498 string t_2PiName =
"phi2Pi_" + to_string(iSt);
499 mSignalStorage[t_maxName] =
Belle2::TRGCDCJSignal(mConstD.at(
"Trg_PI"), mSignalStorage[t_valueName].getToReal(), commonData);
500 mSignalStorage[t_minName] =
Belle2::TRGCDCJSignal(-mConstD.at(
"Trg_PI"), mSignalStorage[t_valueName].getToReal(), commonData);
501 mSignalStorage[t_2PiName] =
Belle2::TRGCDCJSignal(2 * mConstD.at(
"Trg_PI"), mSignalStorage[t_valueName].getToReal(), commonData);
504 for (
unsigned iSt = 0; iSt < 4; iSt++) {
505 string t_in1Name =
"finePhi_" + to_string(iSt);
506 string t_valueName =
"phi_" + to_string(iSt);
507 string t_maxName =
"phiMax_" + to_string(iSt);
508 string t_minName =
"phiMin_" + to_string(iSt);
509 string t_2PiName =
"phi2Pi_" + to_string(iSt);
511 vector<pair<Belle2::TRGCDCJSignal, vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > > > t_data;
515 vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > t_assigns = {
516 make_pair(&mSignalStorage[t_valueName], (mSignalStorage[t_in1Name] - mSignalStorage[t_2PiName]).limit(mSignalStorage[t_minName], mSignalStorage[t_maxName])),
519 t_data.push_back(make_pair(t_compare, t_assigns));
524 make_pair(&mSignalStorage[t_valueName], mSignalStorage[t_in1Name].limit(mSignalStorage[t_minName], mSignalStorage[t_maxName])),
527 t_data.push_back(make_pair(t_compare, t_assigns));
532 make_pair(&mSignalStorage[t_valueName], (mSignalStorage[t_in1Name] + mSignalStorage[t_2PiName]).limit(mSignalStorage[t_minName], mSignalStorage[t_maxName])),
535 t_data.push_back(make_pair(t_compare, t_assigns));
545 for (
unsigned iSt = 0; iSt < stXts.size(); ++iSt) {
546 string filename = filePrefix +
".st" + to_string(iSt);
548 cout <<
"Fitter3DUtility::saveStereoXt() Saving xt file to " << filename << endl;
549 xtFile.open(filename);
550 for (
unsigned iTick = 0; iTick < stXts[iSt].size(); ++iTick) {
551 xtFile << stXts[iSt][iTick] << endl;
559 stXts = vector<vector<double> > (nFiles);
560 for (
unsigned iSt = 0; iSt < stXts.size(); ++iSt) {
561 string filename = filePrefix +
".st" + to_string(iSt);
563 xtFile.open(filename.c_str());
565 cout <<
"Fitter3DUtility::loadStereoXt() Cannot load " << filename << endl;
569 while (getline(xtFile, line)) {
570 stXts[iSt].push_back(std::stof(line));
578 return (
double)
id / stNWires[iSt] * 4 * M_PI;
584 int eventTime, vector<vector<int> >
const& rawStTSs, vector<double>& stTSs)
586 stTSs = vector<double> (4, 9999);
587 if (eventTimeValid == 0) {
588 for (
unsigned iSt = 0; iSt < 4; iSt++) {
589 stTSs[iSt] =
stereoIdToPhi(stGeometry[
"nWires"], iSt, rawStTSs[iSt][0]);
593 for (
unsigned iSt = 0; iSt < 4; iSt++) {
594 if (rawStTSs[iSt][1] != 0) {
596 int t = rawStTSs[iSt][2] - eventTime;
599 if (t > 511) t = 511;
600 double driftLength = stXts[iSt][t];
602 stGeometry[
"cdcRadius"][iSt], rawStTSs[iSt][1]);
611 double Trg_PI = 3.141592653589793;
612 double phiMin = -Trg_PI;
613 double phiMax = Trg_PI;
614 double result = value - refPhi;
616 while (rangeOK == 0) {
617 if (result > phiMax) result -= 2 * Trg_PI;
618 else if (result < phiMin) result += 2 * Trg_PI;
626 double refPhi = (double)refId / nTSs * 2 * M_PI;
632 int result = value - refId;
634 while (rangeOk == 0) {
635 if (result >= nTSs) result -= nTSs;
636 else if (result < 0) result += nTSs;
645 double Trg_PI = 3.141592653589793;
646 double phiMin = -Trg_PI;
647 double phiMax = Trg_PI;
649 while (rangeOK == 0) {
650 if (value > phiMax) value -= 2 * Trg_PI;
651 else if (value < phiMin) value += 2 * Trg_PI;
656 if (value > Trg_PI / 2) result = 2;
657 else if (value > 0) result = 1;
658 else if (value > -Trg_PI / 2) result = 4;
659 else if (value > -Trg_PI) result = 3;
666 std::vector<double>& invZError2)
668 vector<double> driftZError({0.7676, 0.9753, 1.029, 1.372});
669 vector<double> wireZError({0.7676, 0.9753, 1.029, 1.372});
670 vector<double> zError(4, 9999);
671 invZError2 = vector<double> (4, 0);
672 for (
unsigned iSt = 0; iSt < 4; ++iSt) {
673 if (rawStTSs[iSt][1] != 0) {
675 if (rawStTSs[iSt][1] != 3 && eventTimeValid != 0) zError[iSt] = driftZError[iSt];
676 else zError[iSt] = wireZError[iSt];
678 invZError2[iSt] = 1 / pow(zError[iSt], 2);
684 std::map<std::string, std::vector<double> >
const& mConstV, std::map<std::string, Belle2::TRGCDCJSignal>& mSignalStorage)
688 if (mSignalStorage.find(
"iZWireError2_0") == mSignalStorage.end()) {
689 for (
unsigned iSt = 0; iSt < 4; iSt++) {
691 t_name =
"iZWireError2_" + to_string(iSt);
692 mSignalStorage[t_name] =
Belle2::TRGCDCJSignal(mConstD.at(
"iError2BitSize"), 1 / pow(mConstV.at(
"wireZError")[iSt], 2), 0,
693 mConstD.at(
"iError2Max"), -1, commonData);
694 t_name =
"iZDriftError2_" + to_string(iSt);
695 mSignalStorage[t_name] =
Belle2::TRGCDCJSignal(mConstD.at(
"iError2BitSize"), 1 / pow(mConstV.at(
"driftZError")[iSt], 2), 0,
696 mConstD.at(
"iError2Max"), -1, commonData);
697 t_name =
"iZNoneError2_" + to_string(iSt);
698 mSignalStorage[t_name] =
Belle2::TRGCDCJSignal(mConstD.at(
"iError2BitSize"), 0, 0, mConstD.at(
"iError2Max"), -1, commonData);
707 for (
unsigned iSt = 0; iSt < 4; iSt++) {
708 string t_in1Name =
"lr_" + to_string(iSt);
709 string t_valueName =
"invErrorLR_" + to_string(iSt);
710 string t_noneErrorName =
"iZNoneError2_" + to_string(iSt);
711 string t_driftErrorName =
"iZDriftError2_" + to_string(iSt);
712 string t_wireErrorName =
"iZWireError2_" + to_string(iSt);
714 vector<pair<Belle2::TRGCDCJSignal, vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > > > t_data;
717 mSignalStorage[t_in1Name].getToReal(), commonData));
719 vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > t_assigns = {
720 make_pair(&mSignalStorage[t_valueName], mSignalStorage[t_noneErrorName])
723 t_data.push_back(make_pair(t_compare, t_assigns));
726 mSignalStorage[t_in1Name].getToReal(), commonData));
729 make_pair(&mSignalStorage[t_valueName], mSignalStorage[t_wireErrorName])
732 t_data.push_back(make_pair(t_compare, t_assigns));
737 make_pair(&mSignalStorage[t_valueName], mSignalStorage[t_driftErrorName])
740 t_data.push_back(make_pair(t_compare, t_assigns));
747 if (mSignalStorage.find(
"halfRadius_0") == mSignalStorage.end()) {
748 for (
unsigned iSt = 0; iSt < 4; iSt++) {
750 t_name =
"halfRadius_" + to_string(iSt);
751 mSignalStorage[t_name] =
Belle2::TRGCDCJSignal(mConstV.at(
"rr")[iSt * 2 + 1] / 2, mSignalStorage[
"rho"].getToReal(), commonData);
757 for (
unsigned iSt = 0; iSt < 4; iSt++) {
758 string t_compareName =
"halfRadius_" + to_string(iSt);
760 string t_valueName =
"invErrorRho_" + to_string(iSt);
761 string t_noneErrorName =
"iZNoneError2_" + to_string(iSt);
762 string t_in1Name =
"invErrorLR_" + to_string(iSt);
764 vector<pair<Belle2::TRGCDCJSignal, vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > > > t_data;
768 vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > t_assigns = {
769 make_pair(&mSignalStorage[t_valueName], mSignalStorage[t_noneErrorName])
772 t_data.push_back(make_pair(t_compare, t_assigns));
777 make_pair(&mSignalStorage[t_valueName], mSignalStorage[t_in1Name])
780 t_data.push_back(make_pair(t_compare, t_assigns));
789 if (
false) cout << anglest << ztostraw << endl;
791 double myphiz, acos_real;
792 double Trg_PI = 3.141592653589793;
795 if (rr > (2 * rho)) t_rho = rr / 2;
796 acos_real = acos(rr / (2 * t_rho));
798 myphiz = +acos_real + myphi0;
800 myphiz = -acos_real + myphi0;
802 if (myphiz > Trg_PI) myphiz -= 2 * Trg_PI;
803 if (myphiz < -Trg_PI) myphiz += 2 * Trg_PI;
810 if (
false) cout << anglest << ztostraw << endl;
812 double myphiz, acos_real;
813 double Trg_PI = 3.141592653589793;
816 if (rr > (2 * rho)) t_rho = rr / 2;
817 acos_real = acos(rr / (2 * t_rho));
819 myphiz = -acos_real - myphi0 + phi2;
821 myphiz = +acos_real - myphi0 + phi2;
823 if (myphiz > Trg_PI) myphiz -= 2 * Trg_PI;
824 if (myphiz < -Trg_PI) myphiz += 2 * Trg_PI;
830 std::map<std::string, Belle2::TRGCDCJSignal>& mSignalStorage)
834 if (mSignalStorage.find(
"rhoMin_0") == mSignalStorage.end()) {
835 for (
unsigned iSt = 0; iSt < 4; iSt++) {
837 string t_minName =
"rhoMin_" + to_string(iSt);
838 double t_actual = (mConstV.find(
"rr")->second)[2 * iSt + 1] / 2;
839 double t_toReal = mSignalStorage[
"rho"].getToReal();
842 if (mSignalStorage[t_minName].getRealInt() < t_actual) {
843 t_actual += 1 * t_toReal;
849 string t_maxName =
"rhoMax_" + to_string(iSt);
850 t_actual = mSignalStorage[
"rho"].getMaxActual();
859 for (
unsigned iSt = 0; iSt < 4; iSt++) {
860 string t_in1Name =
"rho";
861 string t_valueName =
"rho_c_" + to_string(iSt);
862 string t_maxName =
"rhoMax_" + to_string(iSt);
863 string t_minName =
"rhoMin_" + to_string(iSt);
865 vector<pair<Belle2::TRGCDCJSignal, vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > > > t_data;
869 vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > t_assigns = {
870 make_pair(&mSignalStorage[t_valueName], mSignalStorage[t_maxName]),
873 t_data.push_back(make_pair(t_compare, t_assigns));
878 make_pair(&mSignalStorage[t_valueName], mSignalStorage[t_in1Name].limit(mSignalStorage[t_minName], mSignalStorage[t_maxName]))
881 t_data.push_back(make_pair(t_compare, t_assigns));
886 make_pair(&mSignalStorage[t_valueName], mSignalStorage[t_minName])
889 t_data.push_back(make_pair(t_compare, t_assigns));
896 double Fitter3DUtility::calZ(
int mysign,
double anglest,
double ztostraw,
double rr,
double phi2,
double rho,
double myphi0)
898 double myphiz = 0, acos_real = 0, dPhiAx = 0;
899 double Trg_PI = 3.141592653589793;
902 if (rr > (2 * rho)) t_rho = rr / 2;
903 acos_real = acos(rr / (2 * t_rho));
905 dPhiAx = -acos_real - myphi0;
907 dPhiAx = acos_real - myphi0;
909 myphiz = dPhiAx + phi2;
910 if (myphiz > Trg_PI) myphiz -= 2 * Trg_PI;
911 if (myphiz < -Trg_PI) myphiz += 2 * Trg_PI;
913 return (ztostraw - rr * 2 * sin(myphiz / 2) / anglest);
916 void Fitter3DUtility::calZ(std::map<std::string, double>
const& mConstD, std::map<std::string, std::vector<double> >
const& mConstV,
917 std::map<std::string, Belle2::TRGCDCJSignal>& mSignalStorage, std::map<std::string, Belle2::TRGCDCJLUT* >& mLutStorage)
921 if (mSignalStorage.find(
"invPhiAxMin_0") == mSignalStorage.end()) {
938 for (
unsigned iSt = 0; iSt < 4; iSt++) {
939 string t_invMinName =
"invPhiAxMin_" + to_string(iSt);
941 double t_actual = mSignalStorage[
"rho_c_" + to_string(iSt)].getMinActual();
942 double t_toReal = mSignalStorage[
"rho_c_" + to_string(iSt)].getToReal();
944 string t_invMaxName =
"invPhiAxMax_" + to_string(iSt);
945 t_actual = mSignalStorage[
"rho_c_" + to_string(iSt)].getMaxActual();
953 for (
unsigned iSt = 0; iSt < 4; iSt++) {
954 string t_valueName =
"phiAx_" + to_string(iSt);
955 string t_minName =
"phiAxMin_" + to_string(iSt);
956 string t_maxName =
"phiAxMax_" + to_string(iSt);
957 string t_invMinName =
"invPhiAxMin_" + to_string(iSt);
958 string t_invMaxName =
"invPhiAxMax_" + to_string(iSt);
959 if (mLutStorage.find(t_valueName) == mLutStorage.end()) {
962 double t_parameter = mConstV.at(
"rr3D")[iSt];
963 mLutStorage[t_valueName]->setFloatFunction(
964 [ = ](
double aValue) ->
double{
return acos(t_parameter / 2 / aValue);},
966 mSignalStorage[
"rho_c_" + to_string(iSt)],
967 mSignalStorage[t_invMinName], mSignalStorage[t_invMaxName], mSignalStorage[
"phi0"].getToReal(),
968 (int)mConstD.at(
"acosLUTInBitSize"), (int)mConstD.at(
"acosLUTOutBitSize"));
974 for (
unsigned iSt = 0; iSt < 4; iSt++) {
976 string t_valueName =
"phiAx_" + to_string(iSt);
978 mLutStorage[t_valueName]->operate(mSignalStorage[
"rho_c_" + to_string(iSt)], mSignalStorage[t_valueName]);
986 vector<pair<Belle2::TRGCDCJSignal, vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > > > t_data;
989 commonData),
"=", mSignalStorage[
"charge"]);
991 vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > t_assigns = {
992 make_pair(&mSignalStorage[
"dPhiAx_0"], -mSignalStorage[
"phiAx_0"] - mSignalStorage[
"phi0"]),
993 make_pair(&mSignalStorage[
"dPhiAx_1"], -mSignalStorage[
"phiAx_1"] - mSignalStorage[
"phi0"]),
994 make_pair(&mSignalStorage[
"dPhiAx_2"], -mSignalStorage[
"phiAx_2"] - mSignalStorage[
"phi0"]),
995 make_pair(&mSignalStorage[
"dPhiAx_3"], -mSignalStorage[
"phiAx_3"] - mSignalStorage[
"phi0"])
998 t_data.push_back(make_pair(t_compare, t_assigns));
1003 make_pair(&mSignalStorage[
"dPhiAx_0"], mSignalStorage[
"phiAx_0"] - mSignalStorage[
"phi0"]),
1004 make_pair(&mSignalStorage[
"dPhiAx_1"], mSignalStorage[
"phiAx_1"] - mSignalStorage[
"phi0"]),
1005 make_pair(&mSignalStorage[
"dPhiAx_2"], mSignalStorage[
"phiAx_2"] - mSignalStorage[
"phi0"]),
1006 make_pair(&mSignalStorage[
"dPhiAx_3"], mSignalStorage[
"phiAx_3"] - mSignalStorage[
"phi0"])
1009 t_data.push_back(make_pair(t_compare, t_assigns));
1016 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1017 mSignalStorage[
"dPhi_" + to_string(iSt)] <= mSignalStorage[
"dPhiAx_" + to_string(iSt)] + mSignalStorage[
"phi_" + to_string(iSt)];
1022 if (mSignalStorage.find(
"dPhiPiMax_0") == mSignalStorage.end()) {
1023 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1024 string t_valueName =
"dPhi_" + to_string(iSt);
1025 string t_maxName =
"dPhiPiMax_" + to_string(iSt);
1026 string t_minName =
"dPhiPiMin_" + to_string(iSt);
1027 string t_2PiName =
"dPhiPi2Pi_" + to_string(iSt);
1028 mSignalStorage[t_maxName] =
Belle2::TRGCDCJSignal(mConstD.at(
"Trg_PI"), mSignalStorage[t_valueName].getToReal(), commonData);
1029 mSignalStorage[t_minName] =
Belle2::TRGCDCJSignal(-mConstD.at(
"Trg_PI"), mSignalStorage[t_valueName].getToReal(), commonData);
1030 mSignalStorage[t_2PiName] =
Belle2::TRGCDCJSignal(2 * mConstD.at(
"Trg_PI"), mSignalStorage[t_valueName].getToReal(), commonData);
1033 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1034 string t_in1Name =
"dPhi_" + to_string(iSt);
1035 string t_valueName =
"dPhiPi_c_" + to_string(iSt);
1036 string t_maxName =
"dPhiPiMax_" + to_string(iSt);
1037 string t_minName =
"dPhiPiMin_" + to_string(iSt);
1038 string t_2PiName =
"dPhiPi2Pi_" + to_string(iSt);
1040 vector<pair<Belle2::TRGCDCJSignal, vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > > > t_data;
1044 vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > t_assigns = {
1045 make_pair(&mSignalStorage[t_valueName], (mSignalStorage[t_in1Name] - mSignalStorage[t_2PiName]).limit(mSignalStorage[t_minName], mSignalStorage[t_maxName])),
1048 t_data.push_back(make_pair(t_compare, t_assigns));
1053 make_pair(&mSignalStorage[t_valueName], mSignalStorage[t_in1Name].limit(mSignalStorage[t_minName], mSignalStorage[t_maxName])),
1056 t_data.push_back(make_pair(t_compare, t_assigns));
1061 make_pair(&mSignalStorage[t_valueName], (mSignalStorage[t_in1Name] + mSignalStorage[t_2PiName]).limit(mSignalStorage[t_minName], mSignalStorage[t_maxName])),
1064 t_data.push_back(make_pair(t_compare, t_assigns));
1071 if (mSignalStorage.find(
"dPhiMax_0") == mSignalStorage.end()) {
1072 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1073 string t_maxName =
"dPhiMax_" + to_string(iSt);
1074 string t_minName =
"dPhiMin_" + to_string(iSt);
1075 string t_valueName =
"dPhi_" + to_string(iSt);
1076 double t_value = 2 * mConstD.at(
"Trg_PI") * fabs(mConstV.at(
"nShift")[iSt]) / (mConstV.at(
"nWires")[2 * iSt + 1]);
1077 mSignalStorage[t_maxName] =
Belle2::TRGCDCJSignal(t_value, mSignalStorage[t_valueName].getToReal(), commonData);
1078 mSignalStorage[t_minName] =
Belle2::TRGCDCJSignal(0, mSignalStorage[t_valueName].getToReal(), commonData);
1082 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1083 string t_maxName =
"dPhiMax_" + to_string(iSt);
1084 string t_minName =
"dPhiMin_" + to_string(iSt);
1085 string t_valueName =
"dPhi_c_" + to_string(iSt);
1086 string t_in1Name =
"dPhiPi_c_" + to_string(iSt);
1090 vector<pair<Belle2::TRGCDCJSignal, vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > > > t_data;
1093 mSignalStorage[t_in1Name].getToReal(), commonData));
1095 vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > t_assigns = {
1096 make_pair(&mSignalStorage[t_valueName], mSignalStorage[t_minName]),
1099 t_data.push_back(make_pair(t_compare, t_assigns));
1104 make_pair(&mSignalStorage[t_valueName],
Belle2::TRGCDCJSignal::absolute(mSignalStorage[t_in1Name]).limit(mSignalStorage[t_minName], mSignalStorage[t_maxName])),
1107 t_data.push_back(make_pair(t_compare, t_assigns));
1112 make_pair(&mSignalStorage[t_valueName], mSignalStorage[t_maxName]),
1115 t_data.push_back(make_pair(t_compare, t_assigns));
1121 vector<pair<Belle2::TRGCDCJSignal, vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > > > t_data;
1125 vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > t_assigns = {
1126 make_pair(&mSignalStorage[t_valueName], mSignalStorage[t_maxName]),
1129 t_data.push_back(make_pair(t_compare, t_assigns));
1132 mSignalStorage[t_in1Name].getToReal(), commonData));
1135 make_pair(&mSignalStorage[t_valueName],
Belle2::TRGCDCJSignal::absolute(mSignalStorage[t_in1Name]).limit(mSignalStorage[t_minName], mSignalStorage[t_maxName])),
1138 t_data.push_back(make_pair(t_compare, t_assigns));
1143 make_pair(&mSignalStorage[t_valueName], mSignalStorage[t_minName]),
1146 t_data.push_back(make_pair(t_compare, t_assigns));
1156 if (mSignalStorage.find(
"invZMin_0") == mSignalStorage.end()) {
1157 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1158 string t_minName =
"invZMin_" + to_string(iSt);
1159 string t_maxName =
"invZMax_" + to_string(iSt);
1160 string t_valueName =
"dPhi_c_" + to_string(iSt);
1161 unsigned long long t_int = mSignalStorage[t_valueName].getMinInt();
1162 double t_toReal = mSignalStorage[t_valueName].getToReal();
1163 double t_actual = mSignalStorage[t_valueName].getMinActual();
1164 mSignalStorage[t_minName] =
Belle2::TRGCDCJSignal(t_int, t_toReal, t_int, t_int, t_actual, t_actual, t_actual, -1, commonData);
1165 t_int = mSignalStorage[t_valueName].getMaxInt();
1166 t_actual = mSignalStorage[t_valueName].getMaxActual();
1167 mSignalStorage[t_maxName] =
Belle2::TRGCDCJSignal(t_int, t_toReal, t_int, t_int, t_actual, t_actual, t_actual, -1, commonData);
1171 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1172 string t_inputName =
"dPhi_c_" + to_string(iSt);
1173 string t_outputName =
"zz_" + to_string(iSt);
1174 string t_invMinName =
"invZMin_" + to_string(iSt);
1175 string t_invMaxName =
"invZMax_" + to_string(iSt);
1177 if (mLutStorage.find(t_outputName) == mLutStorage.end()) {
1180 double t_zToStraw = mConstV.at(
"zToStraw")[iSt];
1181 double t_rr3D = mConstV.at(
"rr3D")[iSt];
1182 double t_angleSt = mConstV.at(
"angleSt")[iSt];
1185 mLutStorage[t_outputName]->setFloatFunction(
1186 [ = ](
double aValue) ->
double{
return t_zToStraw + t_rr3D * 2 * sin(aValue / 2) / t_angleSt;},
1187 mSignalStorage[t_inputName],
1188 mSignalStorage[t_invMinName], mSignalStorage[t_invMaxName], mSignalStorage[
"rho"].getToReal(),
1189 (int) mConstD.at(
"zLUTInBitSize"), (int) mConstD.at(
"zLUTOutBitSize"));
1191 mLutStorage[t_outputName]->setFloatFunction(
1192 [ = ](
double aValue) ->
double{
return t_zToStraw - t_rr3D * 2 * sin(aValue / 2) / t_angleSt;},
1193 mSignalStorage[t_inputName],
1194 mSignalStorage[t_invMinName], mSignalStorage[t_invMaxName], mSignalStorage[
"rho"].getToReal(),
1195 (int) mConstD.at(
"zLUTInBitSize"), (int) mConstD.at(
"zLUTOutBitSize"));
1202 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1203 string t_outputName =
"zz_" + to_string(iSt);
1204 string t_inputName =
"dPhi_c_" + to_string(iSt);
1205 mLutStorage[t_outputName]->operate(mSignalStorage[t_inputName], mSignalStorage[t_outputName]);
1212 result = rho * 2 * asin(rr / 2 / rho);
1216 void Fitter3DUtility::calS(std::map<std::string, double>
const& mConstD, std::map<std::string, std::vector<double> >
const& mConstV,
1217 std::map<std::string, Belle2::TRGCDCJSignal>& mSignalStorage, std::map<std::string, Belle2::TRGCDCJLUT* >& mLutStorage)
1221 if (mSignalStorage.find(
"invArcSMin_0") == mSignalStorage.end()) {
1238 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1239 string t_invMinName =
"invArcSMin_" + to_string(iSt);
1241 double t_actual = mSignalStorage[
"rho_c_" + to_string(iSt)].getMaxActual();
1242 double t_toReal = mSignalStorage[
"rho_c_" + to_string(iSt)].getToReal();
1244 string t_invMaxName =
"invArcSMax_" + to_string(iSt);
1245 t_actual = mSignalStorage[
"rho_c_" + to_string(iSt)].getMinActual();
1253 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1254 string t_valueName =
"arcS_" + to_string(iSt);
1255 string t_invMinName =
"invArcSMin_" + to_string(iSt);
1256 string t_invMaxName =
"invArcSMax_" + to_string(iSt);
1257 if (mLutStorage.find(t_valueName) == mLutStorage.end()) {
1260 double t_parameter = mConstV.at(
"rr3D")[iSt];
1261 mLutStorage[t_valueName]->setFloatFunction(
1262 [ = ](
double aValue) ->
double{
return 2 * aValue * asin(t_parameter / 2 / aValue);},
1264 mSignalStorage[
"rho_c_" + to_string(iSt)],
1265 mSignalStorage[t_invMinName], mSignalStorage[t_invMaxName], mSignalStorage[
"rho"].getToReal(),
1266 (int)mConstD.at(
"acosLUTInBitSize"), (int)mConstD.at(
"acosLUTOutBitSize"));
1272 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1274 string t_valueName =
"arcS_" + to_string(iSt);
1276 mLutStorage[t_valueName]->operate(mSignalStorage[
"rho_c_" + to_string(iSt)], mSignalStorage[t_valueName]);
1286 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1287 t_sum1 += pow(1 / zError[iSt], 2);
1288 t_sumSS += pow(arcS[iSt] / zError[iSt], 2);
1289 t_sumS += arcS[iSt] / pow(zError[iSt], 2);
1291 return t_sum1 * t_sumSS - pow(t_sumS, 2);
1299 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1300 t_sum1 += pow(iZError[iSt], 2);
1301 t_sumSS += pow(arcS[iSt] * iZError[iSt], 2);
1302 t_sumS += arcS[iSt] * pow(iZError[iSt], 2);
1304 return t_sum1 * t_sumSS - pow(t_sumS, 2);
1311 double ss = 0, sx = 0, sxx = 0, cotnum = 0, z0num = 0;
1312 double z0nump1[4], z0nump2[4];
1313 double z0den, iz0den;
1315 for (
unsigned i = 0; i < 4; i++) {
1317 sx += arcS[i] * iezz2[i];
1318 sxx += arcS[i] * arcS[i] * iezz2[i];
1321 for (
unsigned i = 0; i < 4; i++) {
1322 cotnum += (ss * arcS[i] - sx) * iezz2[i] * zz[i];
1323 z0nump1[i] = sxx - sx * arcS[i];
1324 z0nump2[i] = z0nump1[i] * iezz2[i] * zz[i];
1325 z0num += z0nump2[i];
1327 z0den = (ss * sxx) - (sx * sx);
1328 iz0den = 1. / z0den;
1336 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1337 if (iezz2[iSt] != 0) nTSHits++;
1341 for (
unsigned i = 0; i < 4; i++) {
1342 zchi2 += (zz[i] - z0 - cot * arcS[i]) * (zz[i] - z0 - cot * arcS[i]) * iezz2[i];
1344 zchi2 /= (nTSHits - 2);
1353 double ss = 0, sx = 0, sxx = 0, cotnum = 0, z0num = 0;
1354 double z0nump1[4], z0nump2[4];
1355 double z0den, iz0den;
1357 for (
unsigned i = 0; i < 4; i++) {
1360 sx += arcS[i] * iezz21[i];
1361 sxx += arcS[i] * arcS[i] * iezz21[i];
1364 sx += arcS[i] * iezz22[i];
1365 sxx += arcS[i] * arcS[i] * iezz22[i];
1369 for (
unsigned i = 0; i < 4; i++) {
1371 cotnum += (ss * arcS[i] - sx) * iezz21[i] * zz[i];
1372 z0nump1[i] = sxx - sx * arcS[i];
1373 z0nump2[i] = z0nump1[i] * iezz21[i] * zz[i];
1374 z0num += z0nump2[i];
1376 cotnum += (ss * arcS[i] - sx) * iezz22[i] * zz[i];
1377 z0nump1[i] = sxx - sx * arcS[i];
1378 z0nump2[i] = z0nump1[i] * iezz22[i] * zz[i];
1379 z0num += z0nump2[i];
1382 z0den = (ss * sxx) - (sx * sx);
1383 iz0den = 1. / z0den;
1391 for (
unsigned i = 0; i < 4; i++) {
1393 zchi2 += (zz[i] - z0 - cot * arcS[i]) * (zz[i] - z0 - cot * arcS[i]) * iezz21[i];
1395 zchi2 += (zz[i] - z0 - cot * arcS[i]) * (zz[i] - z0 - cot * arcS[i]) * iezz22[i];
1402 std::map<std::string, std::vector<double> >
const& mConstV, std::map<std::string, Belle2::TRGCDCJSignal>& mSignalStorage,
1403 std::map<std::string, Belle2::TRGCDCJLUT* >& mLutStorage)
1407 mSignalStorage[
"sum1_p1_0"] <= mSignalStorage[
"iZError2_0"] + mSignalStorage[
"iZError2_1"];
1409 mSignalStorage[
"sum1_p1_1"] <= mSignalStorage[
"iZError2_2"] + mSignalStorage[
"iZError2_3"];
1412 mSignalStorage[
"sum1"] <= mSignalStorage[
"sum1_p1_0"] + mSignalStorage[
"sum1_p1_1"];
1415 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1416 mSignalStorage[
"sumS_p1_" + to_string(iSt)] <= mSignalStorage[
"arcS_" + to_string(iSt)] * mSignalStorage[
"iZError2_" + to_string(
1420 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1421 mSignalStorage[
"sumSS_p1_" + to_string(iSt)] <= mSignalStorage[
"arcS_" + to_string(iSt)] * mSignalStorage[
"arcS_" + to_string(iSt)];
1424 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1425 mSignalStorage[
"cotNumS_p1_" + to_string(iSt)] <= mSignalStorage[
"sum1"] * mSignalStorage[
"arcS_" + to_string(iSt)];
1431 mSignalStorage[
"sumS_p2_0"] <= mSignalStorage[
"sumS_p1_0"] + mSignalStorage[
"sumS_p1_1"];
1433 mSignalStorage[
"sumS_p2_1"] <= mSignalStorage[
"sumS_p1_2"] + mSignalStorage[
"sumS_p1_3"];
1435 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1436 mSignalStorage[
"sumSS_p2_" + to_string(iSt)] <= mSignalStorage[
"sumSS_p1_" + to_string(iSt)] * mSignalStorage[
"iZError2_" +
1442 mSignalStorage[
"sumS"] <= mSignalStorage[
"sumS_p2_0"] + mSignalStorage[
"sumS_p2_1"];
1444 mSignalStorage[
"sumSS_p3_0"] <= mSignalStorage[
"sumSS_p2_0"] + mSignalStorage[
"sumSS_p2_1"];
1446 mSignalStorage[
"sumSS_p3_1"] <= mSignalStorage[
"sumSS_p2_2"] + mSignalStorage[
"sumSS_p2_3"];
1451 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1452 mSignalStorage[
"z0NumS_p1_" + to_string(iSt)] <= mSignalStorage[
"arcS_" + to_string(iSt)] * mSignalStorage[
"sumS"];
1455 mSignalStorage[
"den_p1"] <= mSignalStorage[
"sumS"] * mSignalStorage[
"sumS"];
1457 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1458 mSignalStorage[
"cotNumS_" + to_string(iSt)] <= mSignalStorage[
"cotNumS_p1_" + to_string(iSt)] - mSignalStorage[
"sumS"];
1461 mSignalStorage[
"sumSS"] <= mSignalStorage[
"sumSS_p3_0"] + mSignalStorage[
"sumSS_p3_1"];
1463 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1464 mSignalStorage[
"zxiZError_" + to_string(iSt)] <= mSignalStorage[
"zz_" + to_string(iSt)] * mSignalStorage[
"iZError2_" + to_string(
1473 mSignalStorage[
"den_p2"] <= mSignalStorage[
"sum1"] * mSignalStorage[
"sumSS"];
1475 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1476 mSignalStorage[
"z0NumS_" + to_string(iSt)] <= mSignalStorage[
"sumSS"] - mSignalStorage[
"z0NumS_p1_" + to_string(iSt)];
1481 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1482 mSignalStorage[
"cotNumSZ_" + to_string(iSt)] <= mSignalStorage[
"cotNumS_" + to_string(iSt)] * mSignalStorage[
"zxiZError_" +
1486 mSignalStorage[
"den"] <= mSignalStorage[
"den_p2"] - mSignalStorage[
"den_p1"];
1488 if (mSignalStorage.find(
"denMin") == mSignalStorage.end()) {
1490 double t_rr3D[4], t_wireZError[4];
1491 for (
int iSt = 0; iSt < 2; iSt++) {
1492 t_rr3D[iSt] = mConstV.at(
"rr3D")[iSt];
1493 t_wireZError[iSt] = 1 / mConstV.at(
"wireZError")[iSt];
1495 for (
int iSt = 2; iSt < 4; iSt++) {
1496 t_rr3D[iSt] = mConstV.at(
"rr3D")[iSt];
1497 t_wireZError[iSt] = 0;
1500 mSignalStorage[
"denMin"] =
Belle2::TRGCDCJSignal(t_denMin, mSignalStorage[
"den"].getToReal(), commonData);
1501 double t_arcSMax[4], t_driftZError[4];
1502 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1503 t_arcSMax[iSt] = mConstD.at(
"Trg_PI") * mConstV.at(
"rr3D")[iSt] / 2;
1504 t_driftZError[iSt] = 1 / mConstV.at(
"driftZError")[iSt];
1507 mSignalStorage[
"denMax"] =
Belle2::TRGCDCJSignal(t_denMax, mSignalStorage[
"den"].getToReal(), commonData);
1512 vector<pair<Belle2::TRGCDCJSignal, vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > > > t_data;
1516 vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > t_assigns = {
1517 make_pair(&mSignalStorage[
"den_c"], mSignalStorage[
"denMax"])
1520 t_data.push_back(make_pair(t_compare, t_assigns));
1525 make_pair(&mSignalStorage[
"den_c"], mSignalStorage[
"den"].limit(mSignalStorage[
"denMin"], mSignalStorage[
"denMax"]))
1528 t_data.push_back(make_pair(t_compare, t_assigns));
1533 make_pair(&mSignalStorage[
"den_c"], mSignalStorage[
"denMin"])
1536 t_data.push_back(make_pair(t_compare, t_assigns));
1540 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1541 mSignalStorage[
"z0NumSZ_" + to_string(iSt)] <= mSignalStorage[
"z0NumS_" + to_string(iSt)] * mSignalStorage[
"zxiZError_" + to_string(
1552 mSignalStorage[
"cot_p1_0"] <= mSignalStorage[
"cotNumSZ_0"] + mSignalStorage[
"cotNumSZ_1"];
1554 mSignalStorage[
"cot_p1_1"] <= mSignalStorage[
"cotNumSZ_2"] + mSignalStorage[
"cotNumSZ_3"];
1556 mSignalStorage[
"z0_p1_0"] <= mSignalStorage[
"z0NumSZ_0"] + mSignalStorage[
"z0NumSZ_1"];
1558 mSignalStorage[
"z0_p1_1"] <= mSignalStorage[
"z0NumSZ_2"] + mSignalStorage[
"z0NumSZ_3"];
1563 if (mSignalStorage.find(
"invIDenMin") == mSignalStorage.end()) {
1564 unsigned long long t_int = mSignalStorage[
"den_c"].getMaxInt();
1565 double t_toReal = mSignalStorage[
"den_c"].getToReal();
1566 double t_actual = mSignalStorage[
"den_c"].getMaxActual();
1567 mSignalStorage[
"invIDenMin"] =
Belle2::TRGCDCJSignal(t_int, t_toReal, t_int, t_int, t_actual, t_actual, t_actual, -1, commonData);
1568 t_int = mSignalStorage[
"den_c"].getMinInt();
1569 t_actual = mSignalStorage[
"den_c"].getMinActual();
1570 mSignalStorage[
"invIDenMax"] =
Belle2::TRGCDCJSignal(t_int, t_toReal, t_int, t_int, t_actual, t_actual, t_actual, -1, commonData);
1575 if (mLutStorage.find(
"iDen") == mLutStorage.end()) {
1577 mLutStorage[
"iDen"]->setFloatFunction(
1578 [ = ](
double aValue) ->
double{
return 1 / aValue;},
1579 mSignalStorage[
"den_c"],
1580 mSignalStorage[
"invIDenMin"], mSignalStorage[
"invIDenMax"],
1581 pow(1 / mSignalStorage[
"rho"].getToReal() / mSignalStorage[
"iZError2_0"].getToReal(), 2),
1582 (int)mConstD.at(
"iDenLUTInBitSize"), (int)mConstD.at(
"iDenLUTOutBitSize"));
1586 mLutStorage[
"iDen"]->operate(mSignalStorage[
"den_c"], mSignalStorage[
"iDen"]);
1594 mSignalStorage[
"cot_p2"] <= mSignalStorage[
"cot_p1_0"] + mSignalStorage[
"cot_p1_1"];
1596 mSignalStorage[
"z0_p2"] <= mSignalStorage[
"z0_p1_0"] + mSignalStorage[
"z0_p1_1"];
1600 mSignalStorage[
"cot"] <= mSignalStorage[
"cot_p2"] * mSignalStorage[
"iDen"];
1602 mSignalStorage[
"z0"] <= mSignalStorage[
"z0_p2"] * mSignalStorage[
"iDen"];
1603 if (mConstD.at(
"JB") == 1) {cout <<
"<<<cot>>>" << endl; mSignalStorage[
"cot"].dump();}
1604 if (mConstD.at(
"JB") == 1) {cout <<
"<<<z0>>>" << endl; mSignalStorage[
"z0"].dump();}
1612 if (mSignalStorage.find(
"z0Min") == mSignalStorage.end()) {
1613 mSignalStorage[
"z0Min"] =
Belle2::TRGCDCJSignal(z0Min, mSignalStorage[
"z0"].getToReal(), commonData);
1614 mSignalStorage[
"z0Max"] =
Belle2::TRGCDCJSignal(z0Max, mSignalStorage[
"z0"].getToReal(), commonData);
1618 vector<pair<Belle2::TRGCDCJSignal, vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > > > t_data;
1622 vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > t_assigns = {
1623 make_pair(&mSignalStorage[
"z0_c"], mSignalStorage[
"z0Max"])
1626 t_data.push_back(make_pair(t_compare, t_assigns));
1631 make_pair(&mSignalStorage[
"z0_c"], mSignalStorage[
"z0"].limit(mSignalStorage[
"z0Min"], mSignalStorage[
"z0Max"]))
1634 t_data.push_back(make_pair(t_compare, t_assigns));
1639 make_pair(&mSignalStorage[
"z0_c"], mSignalStorage[
"z0Min"])
1642 t_data.push_back(make_pair(t_compare, t_assigns));
1649 double cotMin = cos(127 * mConstD.at(
"Trg_PI") / 180) / sin(127 * mConstD.at(
"Trg_PI") / 180);
1650 double cotMax = cos(35 * mConstD.at(
"Trg_PI") / 180) / sin(35 * mConstD.at(
"Trg_PI") / 180);
1651 if (mSignalStorage.find(
"cotMin") == mSignalStorage.end()) {
1652 mSignalStorage[
"cotMin"] =
Belle2::TRGCDCJSignal(cotMin, mSignalStorage[
"cot"].getToReal(), commonData);
1653 mSignalStorage[
"cotMax"] =
Belle2::TRGCDCJSignal(cotMax, mSignalStorage[
"cot"].getToReal(), commonData);
1657 vector<pair<Belle2::TRGCDCJSignal, vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > > > t_data;
1661 vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > t_assigns = {
1662 make_pair(&mSignalStorage[
"cot_c"], mSignalStorage[
"cotMax"])
1665 t_data.push_back(make_pair(t_compare, t_assigns));
1670 make_pair(&mSignalStorage[
"cot_c"], mSignalStorage[
"cot"].limit(mSignalStorage[
"cotMin"], mSignalStorage[
"cotMax"]))
1673 t_data.push_back(make_pair(t_compare, t_assigns));
1678 make_pair(&mSignalStorage[
"cot_c"], mSignalStorage[
"cotMin"])
1681 t_data.push_back(make_pair(t_compare, t_assigns));
1693 int z0Shift = mSignalStorage[
"z0_c"].getBitsize() - z0Bits;
1694 mSignalStorage[
"z0_r"] <= mSignalStorage[
"z0_c"].shift(z0Shift, 0);
1695 int cotShift = mSignalStorage[
"cot_c"].getBitsize() - cotBits;
1696 mSignalStorage[
"cot_r"] <= mSignalStorage[
"cot_c"].shift(cotShift, 0);
1705 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1706 mSignalStorage[
"fitDistFromZ0_" + to_string(iSt)] <= mSignalStorage[
"cot"] * mSignalStorage[
"arcS_" + to_string(iSt)];
1709 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1710 mSignalStorage[
"distFromZ0_" + to_string(iSt)] <= mSignalStorage[
"zz_" + to_string(iSt)] - mSignalStorage[
"z0"];
1715 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1716 mSignalStorage[
"chiNum_" + to_string(iSt)] <= mSignalStorage[
"distFromZ0_" + to_string(iSt)] - mSignalStorage[
"fitDistFromZ0_" +
1721 if (mSignalStorage.find(
"chiNumMax_0") == mSignalStorage.end()) {
1722 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1723 string t_maxName =
"chiNumMax_" + to_string(iSt);
1724 string t_minName =
"chiNumMin_" + to_string(iSt);
1725 string t_valueName =
"chiNum_" + to_string(iSt);
1726 double t_maxValue = 2 * mConstV.at(
"zToOppositeStraw")[iSt];
1727 double t_minValue = 2 * mConstV.at(
"zToStraw")[iSt];
1728 mSignalStorage[t_maxName] =
Belle2::TRGCDCJSignal(t_maxValue, mSignalStorage[t_valueName].getToReal(), commonData);
1729 mSignalStorage[t_minName] =
Belle2::TRGCDCJSignal(t_minValue, mSignalStorage[t_valueName].getToReal(), commonData);
1733 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1734 string t_maxName =
"chiNumMax_" + to_string(iSt);
1735 string t_minName =
"chiNumMin_" + to_string(iSt);
1736 string t_valueName =
"chiNum_c_" + to_string(iSt);
1737 string t_in1Name =
"chiNum_" + to_string(iSt);
1739 vector<pair<Belle2::TRGCDCJSignal, vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > > > t_data;
1743 vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > t_assigns = {
1744 make_pair(&mSignalStorage[t_valueName], mSignalStorage[t_maxName]),
1747 t_data.push_back(make_pair(t_compare, t_assigns));
1752 make_pair(&mSignalStorage[t_valueName], mSignalStorage[t_in1Name].limit(mSignalStorage[t_minName], mSignalStorage[t_maxName])),
1755 t_data.push_back(make_pair(t_compare, t_assigns));
1760 make_pair(&mSignalStorage[t_valueName], mSignalStorage[t_minName]),
1763 t_data.push_back(make_pair(t_compare, t_assigns));
1771 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1772 mSignalStorage[
"chi2_p1_" + to_string(iSt)] <= mSignalStorage[
"chiNum_c_" + to_string(iSt)] * mSignalStorage[
"chiNum_c_" +
1777 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1778 mSignalStorage[
"chi2_" + to_string(iSt)] <= mSignalStorage[
"chi2_p1_" + to_string(iSt)] * mSignalStorage[
"iZError2_" + to_string(
1783 mSignalStorage[
"chi2Sum_p1_0"] <= mSignalStorage[
"chi2_0"] + mSignalStorage[
"chi2_1"];
1785 mSignalStorage[
"chi2Sum_p1_1"] <= mSignalStorage[
"chi2_2"] + mSignalStorage[
"chi2_3"];
1789 mSignalStorage[
"zChi2"] <= (mSignalStorage[
"chi2Sum_p1_0"] + mSignalStorage[
"chi2Sum_p1_1"]).shift(1);
1790 if (mConstD.at(
"JB") == 1) {cout <<
"<<<zChi2>>>" << endl; mSignalStorage[
"zChi2"].dump();}
1794 double zChi2Min = 0;
1796 double zChi2Max = 100;
1800 if (mSignalStorage.find(
"zChi2Min") == mSignalStorage.end()) {
1801 mSignalStorage[
"zChi2Min"] =
Belle2::TRGCDCJSignal(zChi2Min, mSignalStorage[
"zChi2"].getToReal(), commonData);
1802 mSignalStorage[
"zChi2Max"] =
Belle2::TRGCDCJSignal(zChi2Max, mSignalStorage[
"zChi2"].getToReal(), commonData);
1806 vector<pair<Belle2::TRGCDCJSignal, vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > > > t_data;
1810 vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > t_assigns = {
1811 make_pair(&mSignalStorage[
"zChi2_c"], mSignalStorage[
"zChi2Max"])
1814 t_data.push_back(make_pair(t_compare, t_assigns));
1819 make_pair(&mSignalStorage[
"zChi2_c"], mSignalStorage[
"zChi2"].limit(mSignalStorage[
"zChi2Min"], mSignalStorage[
"zChi2Max"]))
1822 t_data.push_back(make_pair(t_compare, t_assigns));
1827 make_pair(&mSignalStorage[
"zChi2_c"], mSignalStorage[
"zChi2Min"])
1830 t_data.push_back(make_pair(t_compare, t_assigns));
1837 int zChi2Shift = mSignalStorage[
"zChi2_c"].getBitsize() - zChi2Bits;
1838 mSignalStorage[
"zChi2_r"] <= mSignalStorage[
"zChi2_c"].shift(zChi2Shift, 0);
1846 std::vector<std::vector<double> >
const& stXts,
1847 int eventTimeValid,
int eventTime,
1848 std::vector<std::vector<int> >
const& rawStTSs,
1849 int charge,
double radius,
double phi_c,
double& z0,
double& cot,
double& chi2)
1852 vector<double> arcS;
1853 vector<double> invZError2;
1854 fitter3D(stGeometry, stXts, eventTimeValid, eventTime, rawStTSs, charge, radius, phi_c, z0, cot, chi2, arcS, zz, invZError2);
1858 std::vector<std::vector<double> >
const& stXts,
1859 int eventTimeValid,
int eventTime,
1860 std::vector<std::vector<int> >
const& rawStTSs,
1861 int charge,
double radius,
double phi_c,
double& z0,
double& cot,
double& chi2, vector<double>& arcS, vector<double>& zz,
1862 vector<double>& invZError2)
1864 vector<double> stTSs(4);
1867 zz = vector<double> (4, 0);
1868 arcS = vector<double> (4, 0);
1869 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1870 if (rawStTSs[iSt][1] != 0) {
1872 stGeometry[
"cdcRadius"][iSt], stTSs[iSt], radius, phi_c);
1880 int eventTimeValid,
int eventTime,
1881 std::vector<std::vector<int> >
const& rawStTSs,
1882 int charge,
double radius,
double phi_c,
1884 std::map<std::string, Belle2::TRGCDCJLUT*>& mLutStorage)
1888 vector<tuple<string, double, int, double, double, int> > t_values = {
1889 make_tuple(
"phi0", phi_c, mConstD[
"phiBitSize"], mConstD[
"phiMin"], mConstD[
"phiMax"], 0),
1890 make_tuple(
"rho", radius, mConstD[
"rhoBitSize"], mConstD[
"rhoMin"], mConstD[
"rhoMax"], 0),
1891 make_tuple(
"charge", (
int)(charge == 1 ? 1 : 0), 1, 0, 1.5, 0),
1892 make_tuple(
"lr_0", rawStTSs[0][1], 2, 0, 3.5, 0),
1893 make_tuple(
"lr_1", rawStTSs[1][1], 2, 0, 3.5, 0),
1894 make_tuple(
"lr_2", rawStTSs[2][1], 2, 0, 3.5, 0),
1895 make_tuple(
"lr_3", rawStTSs[3][1], 2, 0, 3.5, 0),
1896 make_tuple(
"tsId_0", rawStTSs[0][0], ceil(log(mConstV[
"nTSs"][1]) / log(2)), 0, pow(2, ceil(log(mConstV[
"nTSs"][1]) / log(2))) - 0.5, 0),
1897 make_tuple(
"tsId_1", rawStTSs[1][0], ceil(log(mConstV[
"nTSs"][3]) / log(2)), 0, pow(2, ceil(log(mConstV[
"nTSs"][3]) / log(2))) - 0.5, 0),
1898 make_tuple(
"tsId_2", rawStTSs[2][0], ceil(log(mConstV[
"nTSs"][5]) / log(2)), 0, pow(2, ceil(log(mConstV[
"nTSs"][5]) / log(2))) - 0.5, 0),
1899 make_tuple(
"tsId_3", rawStTSs[3][0], ceil(log(mConstV[
"nTSs"][7]) / log(2)), 0, pow(2, ceil(log(mConstV[
"nTSs"][7]) / log(2))) - 0.5, 0),
1900 make_tuple(
"tdc_0", rawStTSs[0][2], mConstD[
"tdcBitSize"], 0, pow(2, mConstD[
"tdcBitSize"]) - 0.5, 0),
1901 make_tuple(
"tdc_1", rawStTSs[1][2], mConstD[
"tdcBitSize"], 0, pow(2, mConstD[
"tdcBitSize"]) - 0.5, 0),
1902 make_tuple(
"tdc_2", rawStTSs[2][2], mConstD[
"tdcBitSize"], 0, pow(2, mConstD[
"tdcBitSize"]) - 0.5, 0),
1903 make_tuple(
"tdc_3", rawStTSs[3][2], mConstD[
"tdcBitSize"], 0, pow(2, mConstD[
"tdcBitSize"]) - 0.5, 0),
1904 make_tuple(
"eventTime", eventTime, mConstD[
"tdcBitSize"], 0, pow(2, mConstD[
"tdcBitSize"]) - 0.5, 0),
1905 make_tuple(
"eventTimeValid", eventTimeValid, 1, 0, 1.5, 0),
1917 if ((*mSignalStorage.begin()).second.getName() ==
"") {
1918 for (
auto it = mSignalStorage.begin(); it != mSignalStorage.end(); ++it) {
1919 (*it).second.setName((*it).first);
1925 TVector3& impactPosition)
1935 double rho = sqrt(pow(mcMomentum->Px(), 2) + pow(mcMomentum->Py(), 2)) / 0.3 / 1.5 * 100;
1936 double hcx = mcPosition->X() + rho * cos(atan2(mcMomentum->Py(), mcMomentum->Px()) - charge * TMath::Pi() / 2);
1937 double hcy = mcPosition->Y() + rho * sin(atan2(mcMomentum->Py(), mcMomentum->Px()) - charge * TMath::Pi() / 2);
1938 helixCenter.Set(hcx, hcy);
1939 double impactX = (helixCenter.Mod() - rho) / helixCenter.Mod() * helixCenter.X();
1940 double impactY = (helixCenter.Mod() - rho) / helixCenter.Mod() * helixCenter.Y();
1942 if (atan2(impactY, impactX) < atan2(mcPosition->Y(), mcPosition->X())) signdS = -1;
1944 double dS = 2 * rho * asin(sqrt(pow(impactX - mcPosition->X(), 2) + pow(impactY - mcPosition->Y(), 2)) / 2 / rho);
1945 double impactZ = mcMomentum->Pz() / mcMomentum->Pt() * dS * signdS + mcPosition->Z();
1946 impactPosition.SetXYZ(impactX, impactY, impactZ);
1952 double Trg_PI = 3.141592653589793;
1954 double t_alpha = 1 / 0.3 / 1.5 * 100;
1955 double t_pT = momentum.Perp();
1956 double t_R = t_pT * t_alpha;
1957 helixParameters.Clear();
1958 helixParameters.ResizeTo(5);
1959 helixParameters[2] = t_alpha / t_R;
1960 helixParameters[1] = atan2(position.Y() - t_R * momentum.X() / t_pT * charge, position.X() + t_R * momentum.Y() / t_pT * charge);
1961 helixParameters[0] = (position.X() + t_R * momentum.Y() / t_pT * charge) / cos(helixParameters[1]) - t_R;
1962 double t_phi = atan2(-momentum.X() * charge, momentum.Y() * charge) - helixParameters[1];
1963 if (t_phi > Trg_PI) t_phi -= 2 * Trg_PI;
1964 if (t_phi < -Trg_PI) t_phi += 2 * Trg_PI;
1965 helixParameters[4] = momentum.Z() / t_pT * charge;
1966 helixParameters[3] = position.Z() + helixParameters[4] * t_R * t_phi;
1971 double t_alpha = 1 / 0.3 / 1.5 * 100;
1972 double t_R = t_alpha / helixParameters[2];
1973 double t_pT = t_R / t_alpha;
1974 double t_phi = -1 * charge * acos((-pow(cdcRadius, 2) + pow(t_R + helixParameters[0], 2) + pow(t_R,
1975 2)) / (2 * t_R * (t_R + helixParameters[0])));
1976 double t_X = (helixParameters[0] + t_R) * cos(helixParameters[1]) - t_R * cos(helixParameters[1] + t_phi);
1977 double t_Y = (helixParameters[0] + t_R) * sin(helixParameters[1]) - t_R * sin(helixParameters[1] + t_phi);
1978 double t_Z = helixParameters[3] - helixParameters[4] * t_R * t_phi;
1979 double t_Px = -t_pT * sin(helixParameters[1] + t_phi) * charge;
1980 double t_Py = t_pT * cos(helixParameters[1] + t_phi) * charge;
1981 double t_Pz = t_pT * helixParameters[4] * charge;
1982 position.SetXYZ(t_X, t_Y, t_Z);
1983 momentum.SetXYZ(t_Px, t_Py, t_Pz);
1990 for (
int i = 0; i < numberBits - 1; i++) {
1994 }
else if (mode == 0) {
1995 for (
int i = 0; i < numberBits; i++) {
2010 double range = maxValue - minValue;
2011 double convert = (
bitSize - 0.5) / range;
2022 double range = maxValue - minValue;
2023 double convert = (
bitSize - 0.5) / range;
2024 real = (integer / convert) + minValue;
2030 if (value > m_max) m_max = value;
2031 if (value < m_min) m_min = value;