11 #include <b2bii/modules/B2BIIMdstInput/B2BIIConvertMdstModule.h>
13 #include <framework/datastore/StoreObjPtr.h>
14 #include <framework/datastore/RelationArray.h>
15 #include <framework/database/Database.h>
16 #include <framework/pcore/ProcHandler.h>
18 #include <mdst/dataobjects/HitPatternVXD.h>
19 #include <mdst/dataobjects/HitPatternCDC.h>
22 #include <framework/gearbox/Unit.h>
23 #include <framework/gearbox/Const.h>
24 #include <analysis/dataobjects/ParticleExtraInfoMap.h>
27 #include <framework/dataobjects/EventMetaData.h>
28 #include <framework/dataobjects/Helix.h>
29 #include <framework/dataobjects/UncertainHelix.h>
32 #include <b2bii/utility/BelleMdstToGenHepevt.h>
36 #include <TLorentzVector.h>
44 #include "belle_legacy/eid/eid.h"
48 #include "belle_legacy/kid/kid_acc.h"
49 #include "belle_legacy/kid/kid_cdc.h"
53 #include "belle_legacy/findKs/findKs.h"
56 #ifdef HAVE_NISKSFINDER
57 #include "belle_legacy/nisKsFinder/nisKsFinder.h"
60 #ifdef HAVE_GOODLAMBDA
61 #include "belle_legacy/findLambda/findLambda.h"
64 #include "belle_legacy/benergy/BeamEnergy.h"
65 #include "belle_legacy/ip/IpProfile.h"
66 #include "belle_legacy/tables/evtcls.h"
67 #include "belle_legacy/tables/trg.h"
77 bool approximatelyEqual(
float a,
float b,
float epsilon)
79 return fabs(a - b) <= ((fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
82 double adjustAngleRange(
double phi)
84 phi = phi - int(phi / TMath::TwoPi()) * TMath::TwoPi();
85 return phi - int(phi / TMath::Pi()) * TMath::TwoPi();
88 void fill7x7ErrorMatrix(
const TrackFitResult* tfr, TMatrixDSym& error7x7,
const double mass,
const double bField)
92 double d0 = tfr->
getD0();
98 double alpha = tfr->
getHelix().getAlpha(bField);
100 double cosPhi0 = TMath::Cos(phi0);
101 double sinPhi0 = TMath::Sin(phi0);
105 rho = 1.0 / alpha / omega;
109 double energy = TMath::Sqrt(mass * mass + (1.0 + tanl * tanl) * rho * rho);
121 const int iOmega = 2;
125 TMatrixD jacobian(7, 5);
128 jacobian(iPx, iPhi0) = - fabs(rho) * sinPhi0;
129 jacobian(iPx, iOmega) = -
charge * rho * rho * cosPhi0 * alpha;
130 jacobian(iPy, iPhi0) = fabs(rho) * cosPhi0;
131 jacobian(iPy, iOmega) = -
charge * rho * rho * sinPhi0 * alpha;
132 jacobian(iPz, iOmega) = -
charge * rho * rho * tanl * alpha;
133 jacobian(iPz, iTanl) = fabs(rho);
134 if (omega != 0 && energy != 0) {
135 jacobian(iE, iOmega) = - (1.0 + tanl * tanl) * rho * rho / omega / energy;
136 jacobian(iE, iTanl) = tanl * rho * rho / energy;
138 jacobian(iE, iOmega) = (DBL_MAX);
139 jacobian(iE, iTanl) = (DBL_MAX);
141 jacobian(iX, iD0) = sinPhi0;
142 jacobian(iX, iPhi0) = d0 * cosPhi0;
143 jacobian(iY, iD0) = - cosPhi0;
144 jacobian(iY, iPhi0) = d0 * sinPhi0;
145 jacobian(iZ, iZ0) = 1.0;
149 error7x7 = error5x5.Similarity(jacobian);
161 m_mcMatchingMode(c_Direct)
164 setDescription(
"Converts Belle mDST objects (Panther tables and records) to Belle II mDST objects.");
166 addParam(
"convertBeamParameters", m_convertBeamParameters,
167 "Convert beam parameters or use information stored in "
168 "Belle II database.",
true);
169 addParam(
"use6x6CovarianceMatrix4Tracks", m_use6x6CovarianceMatrix4Tracks,
170 "Use 6x6 (position, momentum) covariance matrix for charged tracks instead of 5x5 (helix parameters) covariance matrix",
false);
171 addParam(
"mcMatchingMode", m_mcMatchingModeString,
172 "MC matching mode: 'Direct', or 'GeneratorLevel'",
173 std::string(
"Direct"));
174 addParam(
"matchType2E9oE25Threshold", m_matchType2E9oE25Threshold,
175 "clusters with a E9/E25 value above this threshold are classified as neutral even if tracks are matched to their connected region (matchType == 2)",
178 addParam(
"convertEvtcls", m_convertEvtcls,
"Flag to switch on conversion of Mdst_evtcls",
true);
179 addParam(
"nisKsInfo", m_nisEnable,
"Flag to switch on conversion of nisKsFinder info",
true);
180 addParam(
"RecTrg", m_convertRecTrg,
"Flag to switch on conversion of rectrg_summary3",
false);
181 addParam(
"TrkExtra", m_convertTrkExtra,
" Flag to switch on conversion of first_x,y,z and last_x,y,z from Mdst_trk_fit",
true);
185 B2DEBUG(1,
"B2BIIConvertMdst: Constructor done.");
203 B2INFO(
"B2BIIConvertMdst: initialized.");
205 B2WARNING(
"nisKsFinder output has been disabled. ksnbVLike, ksnbNoLam, ksnbStandard will not be converted.");
210 B2DEBUG(99,
"[B2BIIConvertMdstModule::initializeDataStore] initialization of DataStore started");
217 m_v0s.registerInDataStore();
221 extraInfoMap.registerInDataStore();
228 gammaParticleList.registerInDataStore();
230 pi0ParticleList.registerInDataStore();
232 kShortParticleList.registerInDataStore();
234 kLongParticleList.registerInDataStore();
236 lambdaParticleList.registerInDataStore();
238 antiLambdaParticleList.registerInDataStore();
240 gammaConversionsParticleList.registerInDataStore();
258 B2DEBUG(99,
"[B2BIIConvertMdstModule::initializeDataStore] initialization of DataStore ended");
264 B2DEBUG(99,
"B2BIIConvertMdst: beginRun called.");
268 Belle::BeamEnergy::begin_run();
270 Belle::BeamEnergy::dump();
273 Belle::IpProfile::begin_run();
275 Belle::IpProfile::dump();
276 bool usableIP = Belle::IpProfile::usable();
277 B2DEBUG(99,
"B2BIIConvertMdst: IpProfile is usable = " << usableIP);
282 Belle::eid::init_data();
283 Belle::eid::show_use(
"ALL");
292 Belle::Belle_event_Manager& evman = Belle::Belle_event_Manager::get_manager();
293 Belle::Belle_event& evt = evman[0];
295 if (evt.ExpMC() == 2)
308 B2INFO(
"No database entry for this run yet, create one");
316 B2ERROR(
"BeamParameters from condition database are different from converted "
317 "ones, overriding database. Did you make sure the globaltag B2BII is used?");
319 B2INFO(
"BeamSpot, BoostVector, and InvariantMass from condition database are different from converted "
320 "ones, overriding database");
323 B2FATAL(
"Cannot reliably override the Database content in parallel processing "
324 "mode, please run the conversion in single processing mode");
376 const double Eher = Belle::BeamEnergy::E_HER();
377 const double Eler = Belle::BeamEnergy::E_LER();
378 const double crossingAngle = Belle::BeamEnergy::Cross_angle();
379 const double angleLer = M_PI;
380 const double angleHer = crossingAngle;
382 TMatrixDSym covariance(0);
383 HepLorentzVector p_beam = Belle::BeamEnergy::p_beam();
386 TLorentzVector P_her(0.0, 0.0, TMath::Sqrt(Eher * Eher - mass_e * mass_e), Eher);
387 P_her.RotateY(angleHer);
388 TLorentzVector P_ler(0.0, 0.0, TMath::Sqrt(Eler * Eler - mass_e * mass_e), Eler);
389 P_ler.RotateY(angleLer);
392 TLorentzVector P_beam = P_her + P_ler;
397 B2DEBUG(99,
"Beam Energy: E_HER = " << Eher <<
"; E_LER = " << Eler <<
"; angle = " << crossingAngle);
398 B2DEBUG(99,
"Beam Momentum (pre-convert) : P_X = " << p_beam.px() <<
"; P_Y = " << p_beam.py() <<
"; P_Z = " << p_beam.pz());
399 B2DEBUG(99,
"Beam Momentum (post-convert) : P_X = " << P_beam.Px() <<
"; P_Y = " << P_beam.Py() <<
"; P_Z = " << P_beam.Pz());
404 if (!Belle::IpProfile::usable()) {
409 TVector3(std::numeric_limits<double>::quiet_NaN(),
410 std::numeric_limits<double>::quiet_NaN(),
411 std::numeric_limits<double>::quiet_NaN()
412 ), TMatrixTSym<double>()
418 CLHEP::HepSymMatrix ipErr;
421 ip = Belle::IpProfile::position();
422 ipErr = Belle::IpProfile::position_err();
425 Belle::IpProfile::set_evtbin_number();
429 ip = Belle::IpProfile::e_position();
430 ipErr = Belle::IpProfile::e_position_err();
435 TMatrixDSym cov(ipErr.num_col());
436 for (
int i = 0; i < ipErr.num_row(); ++i) {
437 for (
int j = 0; j < ipErr.num_col(); ++j) {
438 cov(i, j) = ipErr(i + 1, j + 1);
450 Belle::Mdst_charged_Manager& m = Belle::Mdst_charged_Manager::get_manager();
451 for (Belle::Mdst_charged_Manager::iterator chargedIterator = m.begin(); chargedIterator != m.end(); ++chargedIterator) {
452 Belle::Mdst_charged belleTrack = *chargedIterator;
466 const Belle::Gen_hepevt& hep0 = get_hepevt(belleTrack);
469 const Belle::Gen_hepevt* hep =
nullptr;
475 hep = &gen_level(hep0);
483 tracksToMCParticles.
add(track->getArrayIndex(), matchedMCParticle);
487 B2DEBUG(99,
"Can not find MCParticle corresponding to this gen_hepevt (Panther ID = " << hep->get_ID() <<
")");
488 B2DEBUG(99,
"Gen_hepevt: Panther ID = " << hep->get_ID() <<
"; idhep = " << hep->idhep() <<
"; isthep = " << hep->isthep());
498 ksPList->initialize(310, ksPList.getName());
502 lambda0PList.create();
503 lambda0PList->initialize(3122, lambda0PList.getName());
506 antiLambda0PList.create();
507 antiLambda0PList->initialize(-3122, antiLambda0PList.getName());
509 antiLambda0PList->bindAntiParticleList(*lambda0PList);
513 convGammaPList.create();
514 convGammaPList->initialize(22, convGammaPList.getName());
517 Belle::Mdst_vee2_Manager& m = Belle::Mdst_vee2_Manager::get_manager();
518 for (Belle::Mdst_vee2_Manager::iterator vee2Iterator = m.begin(); vee2Iterator != m.end(); ++vee2Iterator) {
519 Belle::Mdst_vee2 belleV0 = *vee2Iterator;
522 Belle::Mdst_charged belleTrackP = belleV0.chgd(0);
524 Belle::Mdst_charged belleTrackM = belleV0.chgd(1);
532 switch (belleV0.kind()) {
558 B2WARNING(
"Conversion of vee2 candidate of unknown kind! kind = " << belleV0.kind());
562 int trackID[2] = {0, 0};
564 Belle::Mdst_charged_Manager& charged_mag = Belle::Mdst_charged_Manager::get_manager();
565 for (std::vector<Belle::Mdst_charged>::iterator chgIterator = charged_mag.begin(); chgIterator != charged_mag.end();
567 if (belleV0.chgd(0).get_ID() >= 1 && trackID[0] == 0 && belleV0.chgd(0).get_ID() == chgIterator->get_ID()) {
568 trackID[0] = (int)(chgIterator->get_ID());
571 if (belleV0.chgd(1).get_ID() >= 1 && trackID[1] == 0 && belleV0.chgd(1).get_ID() == chgIterator->get_ID()) {
572 trackID[1] = (int)(chgIterator->get_ID());
579 HepPoint3D dauPivot(belleV0.vx(), belleV0.vy(), belleV0.vz());
580 int trackFitPIndex = -1;
581 int trackFitMIndex = -1;
583 CLHEP::HepLorentzVector momentumP;
584 CLHEP::HepSymMatrix error7x7P(7, 0);
586 TMatrixFSym errMatrixP(7);
587 CLHEP::HepLorentzVector momentumM;
588 CLHEP::HepSymMatrix error7x7M(7, 0);
590 TMatrixFSym errMatrixM(7);
591 CLHEP::HepSymMatrix error5x5(5, 0);
592 if (trackID[0] >= 1) {
593 if (belleV0.daut()) {
594 std::vector<float> helixParam(5);
595 std::vector<float> helixError(15);
598 auto trackFitP =
m_trackFitResults.appendNew(helixParam, helixError, pTypeP, 0.5, -1, -1, 0);
599 trackFitPIndex = trackFitP->getArrayIndex();
606 for (
unsigned i = 0; i < 7; i++)
607 for (
unsigned j = 0; j < 7; j++)
608 errMatrixP(i, j) = error7x7P[i][j];
610 daughterP =
Particle(trackID[0] - 1, tmpTFR, pTypeP);
611 daughterP.
updateMomentum(TLorentzVector(momentumP.px(), momentumP.py(), momentumP.pz(), momentumP.e()),
612 TVector3(positionP.x(), positionP.y(), positionP.z()),
616 Belle::Mdst_trk_fit& trk_fit = charged_mag[trackID[0] - 1].trk().mhyp(belleHypP);
617 double pValue = TMath::Prob(trk_fit.chisq(), trk_fit.ndf());
619 std::vector<float> helixParam(5);
620 std::vector<float> helixError(15);
624 if (helixParam[2] == 0) {
625 B2WARNING(
"Helix parameter for curvature == 0. Skipping Track! The parameter is: " << helixParam[2] <<
"...");
629 auto trackFitP =
m_trackFitResults.appendNew(helixParam, helixError, pTypeP, pValue, -1, -1, 0);
631 trackFitPIndex = trackFitP->getArrayIndex();
633 daughterP =
Particle(trackID[0] - 1, trackFitP, pTypeP);
636 helixParam, error5x5,
637 momentumP, positionP, error7x7P);
639 for (
unsigned i = 0; i < 7; i++)
640 for (
unsigned j = 0; j < 7; j++)
641 errMatrixP(i, j) = error7x7P[i][j];
643 daughterP.
updateMomentum(TLorentzVector(momentumP.px(), momentumP.py(), momentumP.pz(), momentumP.e()),
644 TVector3(positionP.x(), positionP.y(), positionP.z()),
648 if (trackID[1] >= 1) {
649 if (belleV0.daut()) {
650 std::vector<float> helixParam(5);
651 std::vector<float> helixError(15);
654 auto trackFitM =
m_trackFitResults.appendNew(helixParam, helixError, pTypeM, 0.5, -1, -1, 0);
655 trackFitMIndex = trackFitM->getArrayIndex();
661 for (
unsigned i = 0; i < 7; i++)
662 for (
unsigned j = 0; j < 7; j++)
663 errMatrixM(i, j) = error7x7M[i][j];
665 daughterM =
Particle(trackID[1] - 1, tmpTFR, pTypeM);
666 daughterM.
updateMomentum(TLorentzVector(momentumM.px(), momentumM.py(), momentumM.pz(), momentumM.e()),
667 TVector3(positionM.x(), positionM.y(), positionM.z()),
671 Belle::Mdst_trk_fit& trk_fit = charged_mag[trackID[1] - 1].trk().mhyp(belleHypM);
672 double pValue = TMath::Prob(trk_fit.chisq(), trk_fit.ndf());
674 std::vector<float> helixParam(5);
675 std::vector<float> helixError(15);
679 if (helixParam[2] == 0) {
680 B2WARNING(
"Helix parameter for curvature == 0. Skipping Track! The parameter is: " << helixParam[2] <<
"...");
684 auto trackFitM =
m_trackFitResults.appendNew(helixParam, helixError, pTypeM, pValue, -1, -1, 0);
686 trackFitMIndex = trackFitM->getArrayIndex();
688 daughterM =
Particle(trackID[1] - 1, trackFitM, pTypeM);
691 helixParam, error5x5,
692 momentumM, positionM, error7x7M);
694 for (
unsigned i = 0; i < 7; i++)
695 for (
unsigned j = 0; j < 7; j++)
696 errMatrixM(i, j) = error7x7M[i][j];
698 daughterM.
updateMomentum(TLorentzVector(momentumM.px(), momentumM.py(), momentumM.pz(), momentumM.e()),
699 TVector3(positionM.x(), positionM.y(), positionM.z()),
710 m_v0s.appendNew(std::make_pair(trackP, trackFitP), std::make_pair(trackM, trackFitM));
722 newDaugP->addRelationTo(mcParticleP);
729 TLorentzVector v0Momentum(belleV0.px(), belleV0.py(), belleV0.pz(), belleV0.energy());
730 TVector3 v0Vertex(belleV0.vx(), belleV0.vy(), belleV0.vz());
736 auto appendVertexFitInfo = [](Belle::Mdst_vee2 & _belle_V0,
Particle & _belle2_V0) {
738 _belle2_V0.addExtraInfo(
"chiSquared", _belle_V0.chisq());
740 _belle2_V0.addExtraInfo(
"ndf", 1);
742 double prob = TMath::Prob(_belle_V0.chisq(), 1);
743 _belle2_V0.setPValue(prob);
747 if (belleV0.kind() == 1) {
752 appendVertexFitInfo(belleV0, KS);
754 ksPList->addParticle(newV0);
757 Belle::FindKs belleKSFinder;
758 belleKSFinder.candidates(belleV0, Belle::IpProfile::position(1));
795 }
else if (belleV0.kind() == 2) {
800 appendVertexFitInfo(belleV0, Lambda0);
802 lambda0PList->addParticle(newV0);
805 Belle::FindLambda lambdaFinder;
806 lambdaFinder.candidates(belleV0, Belle::IpProfile::position(1));
807 newV0->
addExtraInfo(
"goodLambda", lambdaFinder.goodLambda());
808 }
else if (belleV0.kind() == 3) {
809 Particle antiLambda0(v0Momentum, -3122);
813 appendVertexFitInfo(belleV0, antiLambda0);
815 antiLambda0PList->addParticle(newV0);
818 Belle::FindLambda lambdaFinder;
819 lambdaFinder.candidates(belleV0, Belle::IpProfile::position(1));
820 newV0->
addExtraInfo(
"goodLambda", lambdaFinder.goodLambda());
821 }
else if (belleV0.kind() == 4) {
823 gamma.appendDaughter(newDaugP);
824 gamma.appendDaughter(newDaugM);
825 gamma.setVertex(v0Vertex);
826 appendVertexFitInfo(belleV0, gamma);
828 convGammaPList->addParticle(newV0);
832 if (belleV0.kind() <= 3) {
833 Belle::nisKsFinder ksnb;
834 double protIDP =
atcPID(pidP, 2, 4);
835 double protIDM =
atcPID(pidM, 2, 4);
836 ksnb.candidates(belleV0, Belle::IpProfile::position(1), momentumP, protIDP, protIDM);
841 if (belleV0.kind() == 1)
857 Belle::Gen_hepevt_Manager& genMgr = Belle::Gen_hepevt_Manager::get_manager();
858 if (genMgr.count() == 0)
861 typedef std::pair<MCParticleGraph::GraphParticle*, Belle::Gen_hepevt> halfFamily;
862 halfFamily currFamily;
864 std::queue < halfFamily > heritancesQueue;
870 for (Belle::Gen_hepevt_Manager::iterator genIterator = genMgr.begin();
871 genIterator != genMgr.end(); ++genIterator) {
872 Belle::Gen_hepevt hep = *genIterator;
874 if (!(hep.moFirst() == 0 && hep.moLast() == 0))
877 if (hep.idhep() == 911)
884 for (
int iDaughter = hep.daFirst(); iDaughter <= hep.daLast();
886 if (iDaughter == 0) {
887 B2DEBUG(95,
"Trying to access generated daughter with Panther ID == 0");
890 currFamily.first = graphParticle;
891 currFamily.second = genMgr(Belle::Panther_ID(iDaughter));
892 heritancesQueue.push(currFamily);
897 while (!heritancesQueue.empty()) {
898 currFamily = heritancesQueue.front();
899 heritancesQueue.pop();
902 Belle::Gen_hepevt& currDaughter = currFamily.second;
905 if (currDaughter.idhep() == 0 || currDaughter.idhep() == 911)
919 int nGrandChildren = currDaughter.daLast() - currDaughter.daFirst() + 1;
921 if (nGrandChildren > 0 && currDaughter.daFirst() != 0) {
922 for (
int igrandchild = currDaughter.daFirst(); igrandchild <= currDaughter.daLast(); ++igrandchild) {
923 if (igrandchild == 0) {
924 B2DEBUG(95,
"Trying to access generated daughter with Panther ID == 0");
928 family.first = graphDaughter;
929 family.second = genMgr(Belle::Panther_ID(igrandchild));
930 heritancesQueue.push(family);
947 Belle::Mdst_ecl_Manager& ecl_manager = Belle::Mdst_ecl_Manager::get_manager();
948 Belle::Mdst_ecl_aux_Manager& ecl_aux_manager = Belle::Mdst_ecl_aux_Manager::get_manager();
950 for (Belle::Mdst_ecl_Manager::iterator eclIterator = ecl_manager.begin(); eclIterator != ecl_manager.end(); ++eclIterator) {
953 Belle::Mdst_ecl mdstEcl = *eclIterator;
954 Belle::Mdst_ecl_aux mdstEclAux(ecl_aux_manager(mdstEcl.get_ID()));
965 B2EclCluster->setConnectedRegionId(B2EclCluster->getArrayIndex() + 1);
966 B2EclCluster->setClusterId(1);
973 const Belle::Gen_hepevt& hep0 = get_hepevt(mdstEcl);
976 const Belle::Gen_hepevt* hep =
nullptr;
982 hep = &gen_level(hep0);
989 eclClustersToMCParticles.
add(B2EclCluster->getArrayIndex(), matchedMCParticleID);
992 B2DEBUG(79,
"Cannot find MCParticle corresponding to this gen_hepevt (Panther ID = " << hep->get_ID() <<
")");
993 B2DEBUG(79,
"Gen_hepevt: Panther ID = " << hep->get_ID() <<
"; idhep = " << hep->idhep() <<
"; isthep = " << hep->isthep());
1006 Belle::Mdst_klm_cluster_Manager& klm_cluster_manager = Belle::Mdst_klm_cluster_Manager::get_manager();
1008 for (Belle::Mdst_klm_cluster_Manager::iterator klmC_Ite = klm_cluster_manager.begin(); klmC_Ite != klm_cluster_manager.end();
1012 Belle::Mdst_klm_cluster mdstKlm_cluster = *klmC_Ite;
1035 plist->initialize(22,
"gamma:mdst");
1038 Belle::Mdst_gamma_Manager& gamma_manager = Belle::Mdst_gamma_Manager::get_manager();
1040 for (Belle::Mdst_gamma_Manager::iterator gammaIterator = gamma_manager.begin(); gammaIterator != gamma_manager.end();
1044 Belle::Mdst_gamma mdstGamma = *gammaIterator;
1045 Belle::Mdst_ecl mdstEcl = mdstGamma.ecl();
1059 plist->addParticle(B2Gamma);
1066 if (matchedMCParticle)
1076 plist->initialize(111,
"pi0:mdst");
1079 Belle::Mdst_pi0_Manager& pi0_manager = Belle::Mdst_pi0_Manager::get_manager();
1080 for (Belle::Mdst_pi0_Manager::iterator pi0Iterator = pi0_manager.begin(); pi0Iterator != pi0_manager.end(); ++pi0Iterator) {
1083 Belle::Mdst_pi0 mdstPi0 = *pi0Iterator;
1084 Belle::Mdst_gamma mdstGamma1 = mdstPi0.gamma(0);
1085 Belle::Mdst_gamma mdstGamma2 = mdstPi0.gamma(1);
1086 if (!mdstGamma1 || !mdstGamma2)
1089 TLorentzVector p4(mdstPi0.px(), mdstPi0.py(), mdstPi0.pz(), mdstPi0.energy());
1097 if (!B2Gamma1 || !B2Gamma2)
1111 double prob = TMath::Prob(mdstPi0.chisq(), 1);
1115 plist->addParticle(B2Pi0);
1128 plist->initialize(130,
"K_L0:mdst");
1130 Belle::Mdst_klong_Manager& klong_manager = Belle::Mdst_klong_Manager::get_manager();
1131 for (Belle::Mdst_klong_Manager::iterator klong_Ite = klong_manager.begin(); klong_Ite != klong_manager.end(); ++klong_Ite) {
1134 Belle::Mdst_klong mdstKlong = *klong_Ite;
1135 Belle::Mdst_klm_cluster mdstKlm = mdstKlong.klmc();
1147 B2KlmCluster->
setClusterPosition(mdstKlong.cos_x(), mdstKlong.cos_y(), mdstKlong.cos_z());
1154 plist->addParticle(B2Klong);
1165 Belle::Gen_hepevt_Manager& GenMgr = Belle::Gen_hepevt_Manager::get_manager();
1166 const double dang(15. / 180.*M_PI);
1168 for (Belle::Gen_hepevt_Manager::iterator klong_hep_it = GenMgr.begin(); klong_hep_it != GenMgr.end(); ++klong_hep_it) {
1170 if (abs((*klong_hep_it).idhep()) == 130 && klong_hep_it->isthep() > 0) {
1172 CLHEP::HepLorentzVector gp4(klong_hep_it->PX(), klong_hep_it->PY(), klong_hep_it->PZ(), klong_hep_it->E());
1174 int bestRecKlongID(0);
1176 for (Belle::Mdst_klong_Manager::iterator klong_rec_it = klong_manager.begin(); klong_rec_it != klong_manager.end();
1180 if ((*klong_rec_it).ecl())
1182 CLHEP::Hep3Vector klp3(klong_rec_it->cos_x(), klong_rec_it->cos_y(), klong_rec_it->cos_z());
1184 if (cos(gp4.theta() - klp3.theta()) > cos(dang) && cos(gp4.phi() - klp3.phi()) > cos(dang)) {
1186 double tmp_sum = cos(gp4.theta() - klp3.theta()) + cos(gp4.phi() - klp3.phi());
1187 if (tmp_sum > sum) {
1196 particlesToMCParticles.
add(bestRecKlongID, matchedMCParticleID);
1211 Belle::Evtcls_flag_Manager& EvtFlagMgr = Belle::Evtcls_flag_Manager::get_manager();
1212 Belle::Evtcls_flag2_Manager& EvtFlag2Mgr = Belle::Evtcls_flag2_Manager::get_manager();
1215 Belle::Evtcls_hadronic_flag_Manager& EvtHadFlagMgr = Belle::Evtcls_hadronic_flag_Manager::get_manager();
1217 std::string name =
"evtcls_flag";
1218 std::string name_had =
"evtcls_hadronic_flag";
1220 std::vector<Belle::Evtcls_flag>::iterator eflagIterator = EvtFlagMgr.begin();
1221 std::vector<Belle::Evtcls_flag2>::iterator eflag2Iterator = EvtFlag2Mgr.begin();
1222 std::vector<Belle::Evtcls_hadronic_flag>::iterator ehadflagIterator = EvtHadFlagMgr.begin();
1225 std::vector<int> flag(20);
1226 for (
int index = 0; index < 20; ++index) {
1228 if (index == 14 || index == 16)
continue;
1229 std::string iVar = name + std::to_string(index);
1232 m_evtInfo->addExtraInfo(iVar, (*eflagIterator).flag(index));
1235 m_evtInfo->addExtraInfo(iVar, (*eflag2Iterator).flag(index - 10));
1237 B2DEBUG(99,
"evtcls_flag(" << index <<
") = " <<
m_evtInfo->getExtraInfo(iVar));
1241 for (
int index = 0; index < 6; ++index) {
1242 std::string iVar = name_had + std::to_string(index);
1243 m_evtInfo->addExtraInfo(iVar, (*ehadflagIterator).hadronic_flag(index));
1244 B2DEBUG(99,
"evtcls_hadronic_flag(" << index <<
") = " <<
m_evtInfo->getExtraInfo(iVar));
1258 Belle::Rectrg_summary3_Manager& RecTrgSummary3Mgr = Belle::Rectrg_summary3_Manager::get_manager();
1260 std::string name =
"rectrg_summary3_m_final";
1262 std::vector<Belle::Rectrg_summary3>::iterator eflagIterator = RecTrgSummary3Mgr.begin();
1265 for (
int index = 0; index < 3; ++index) {
1266 std::string iVar = name + std::to_string(index);
1267 m_evtInfo->addExtraInfo(iVar, (*eflagIterator).final(index));
1268 B2DEBUG(99,
"m_final(" << index <<
") = " <<
m_evtInfo->getExtraInfo(iVar));
1281 static Belle::kid_acc acc_pdf(0);
1284 const double pmass[5] = { 0.00051099907, 0.105658389, 0.13956995, 0.493677, 0.93827231 };
1286 CLHEP::Hep3Vector mom(chg.px(), chg.py(), chg.pz());
1287 double cos_theta = mom.cosTheta();
1288 double pval = mom.mag();
1290 double npe = chg.acc().photo_electron();
1291 double beta = pval / sqrt(pval * pval + pmass[idp] * pmass[idp]);
1292 double pdfval = acc_pdf.npe2pdf(cos_theta, beta, npe);
1300 CLHEP::Hep3Vector mom(chg.px(), chg.py(), chg.pz());
1301 double pval = mom.mag();
1303 Belle::kid_cdc kidCdc(5);
1304 float factor0 = kidCdc.factor0();
1305 float factor1 = kidCdc.factor1(idp, pval);
1307 if (factor0 == 1.0 && factor1 == 1.0)
return chg.trk().pid(idp);
1309 double m = chg.trk().dEdx() / factor0;
1310 double e = chg.trk().dEdx_exp(idp) * factor1;
1311 double s = chg.trk().sigma_dEdx(idp);
1312 double val = 1. / sqrt(2.*M_PI) / s * exp(-0.5 * (m - e) * (m - e) / s / s);
1319 bool discard_allzero)
1321 if (discard_allzero) {
1322 const double max_l = *std::max_element(likelihoods, likelihoods +
c_nHyp);
1328 for (
int i = 0; i <
c_nHyp; i++) {
1329 float logl = log(likelihoods[i]);
1339 track->addRelationTo(pid);
1345 double likelihoods[
c_nHyp];
1349 for (
int i = 0; i <
c_nHyp; i++) {
1350 accL[i] = tofL[i] = cdcL[i] = 1.0;
1354 const auto& acc = belleTrack.acc();
1355 if (acc and acc.quality() == 0) {
1356 for (
int i = 0; i <
c_nHyp; i++)
1357 accL[i] = likelihoods[i] =
acc_pid(belleTrack, i);
1364 const Belle::Mdst_tof& tof = belleTrack.tof();
1365 if (tof and tof.quality() == 0) {
1366 for (
int i = 0; i <
c_nHyp; i++)
1367 tofL[i] = likelihoods[i] = tof.pid(i);
1374 const Belle::Mdst_trk& trk = belleTrack.trk();
1375 if (trk.dEdx() > 0) {
1376 for (
int i = 0; i <
c_nHyp; i++) {
1377 likelihoods[i] = trk.pid(i);
1378 cdcL[i] =
cdc_pid(belleTrack, i);
1392 Belle::eid electronID(belleTrack);
1393 float eclID_e_pdf = electronID.pdf_e_ecl();
1394 float eclID_h_pdf = electronID.pdf_h_ecl();
1395 float atcID_e_pdf = electronID.atc_pid_pdf(
true, accL, tofL, cdcL);
1396 float atcID_h_pdf = electronID.atc_pid_pdf(
false, accL, tofL, cdcL);
1399 float eclProb = eclID_e_pdf / (eclID_e_pdf + eclID_h_pdf);
1400 float atcProb = atcID_e_pdf / (atcID_e_pdf + atcID_h_pdf);
1402 if (atcProb > 0.999999) atcProb = 0.999999;
1404 double eidCombinedSig = eclProb * atcProb;
1405 double eidCombinedBkg = (1. - eclProb) * (1. - atcProb);
1407 likelihoods[0] = eidCombinedSig;
1409 likelihoods[2] = eidCombinedBkg;
1423 int muid_trackid = belleTrack.muid_ID();
1427 Belle::Mdst_klm_mu_ex_Manager& ex_mgr = Belle::Mdst_klm_mu_ex_Manager::get_manager();
1428 Belle::Mdst_klm_mu_ex& ex = ex_mgr(Belle::Panther_ID(muid_trackid));
1431 if (ex.Chi_2() > 0) {
1433 likelihoods[1] = ex.Muon_likelihood();
1434 likelihoods[2] = ex.Pion_likelihood();
1435 likelihoods[3] = ex.Kaon_likelihood();
1440 for (
int i = 0; i < 5; i++)
1441 if (likelihoods[i] < 0)
1467 std::vector<float>& helixParams,
1468 CLHEP::HepSymMatrix& error5x5,
1469 CLHEP::HepLorentzVector& momentum,
1471 CLHEP::HepSymMatrix& error7x7,
const double dPhi)
1477 CLHEP::HepVector a(5);
1478 a[0] = trk_fit.helix(0);
1479 a[1] = trk_fit.helix(1);
1480 a[2] = trk_fit.helix(2);
1481 a[3] = trk_fit.helix(3);
1482 a[4] = trk_fit.helix(4);
1483 CLHEP::HepSymMatrix Ea(5, 0);
1484 Ea[0][0] = trk_fit.error(0);
1485 Ea[1][0] = trk_fit.error(1);
1486 Ea[1][1] = trk_fit.error(2);
1487 Ea[2][0] = trk_fit.error(3);
1488 Ea[2][1] = trk_fit.error(4);
1489 Ea[2][2] = trk_fit.error(5);
1490 Ea[3][0] = trk_fit.error(6);
1491 Ea[3][1] = trk_fit.error(7);
1492 Ea[3][2] = trk_fit.error(8);
1493 Ea[3][3] = trk_fit.error(9);
1494 Ea[4][0] = trk_fit.error(10);
1495 Ea[4][1] = trk_fit.error(11);
1496 Ea[4][2] = trk_fit.error(12);
1497 Ea[4][3] = trk_fit.error(13);
1498 Ea[4][4] = trk_fit.error(14);
1500 Belle::Helix helix(pivot, a, Ea);
1503 if (helix.kappa() > 0)
1508 if (newPivot.x() != 0. || newPivot.y() != 0. || newPivot.z() != 0.) {
1509 helix.pivot(newPivot);
1510 momentum = helix.momentum(dPhi, mass, position, error7x7);
1512 if (pivot.x() != 0. || pivot.y() != 0. || pivot.z() != 0.) {
1514 momentum = helix.momentum(dPhi, mass, position, error7x7);
1516 momentum = helix.momentum(dPhi, mass, position, error7x7);
1527 std::vector<float>& helixParams, std::vector<float>& helixError)
1533 CLHEP::HepVector a(5);
1534 a[0] = trk_fit.helix(0);
1535 a[1] = trk_fit.helix(1);
1536 a[2] = trk_fit.helix(2);
1537 a[3] = trk_fit.helix(3);
1538 a[4] = trk_fit.helix(4);
1539 CLHEP::HepSymMatrix Ea(5, 0);
1540 Ea[0][0] = trk_fit.error(0);
1541 Ea[1][0] = trk_fit.error(1);
1542 Ea[1][1] = trk_fit.error(2);
1543 Ea[2][0] = trk_fit.error(3);
1544 Ea[2][1] = trk_fit.error(4);
1545 Ea[2][2] = trk_fit.error(5);
1546 Ea[3][0] = trk_fit.error(6);
1547 Ea[3][1] = trk_fit.error(7);
1548 Ea[3][2] = trk_fit.error(8);
1549 Ea[3][3] = trk_fit.error(9);
1550 Ea[4][0] = trk_fit.error(10);
1551 Ea[4][1] = trk_fit.error(11);
1552 Ea[4][2] = trk_fit.error(12);
1553 Ea[4][3] = trk_fit.error(13);
1554 Ea[4][4] = trk_fit.error(14);
1556 Belle::Helix helix(pivot, a, Ea);
1558 if (newPivot.x() != 0. || newPivot.y() != 0. || newPivot.z() != 0.) {
1559 helix.pivot(newPivot);
1561 if (pivot.x() != 0. || pivot.y() != 0. || pivot.z() != 0.) {
1566 CLHEP::HepSymMatrix error5x5(5, 0);
1569 unsigned int size = 5;
1570 unsigned int counter = 0;
1571 for (
unsigned int i = 0; i < size; i++)
1572 for (
unsigned int j = i; j < size; j++)
1573 helixError[counter++] = error5x5[i][j];
1578 CLHEP::HepVector a(5);
1579 CLHEP::HepSymMatrix Ea(5, 0);
1585 helixParams[0] = a[0];
1588 helixParams[1] = adjustAngleRange(a[1] + TMath::Pi() / 2.0);
1594 helixParams[3] = a[3];
1597 helixParams[4] = a[4];
1599 unsigned int size = 5;
1600 for (
unsigned int i = 0; i < size; i++) {
1601 for (
unsigned int j = 0; j < size; j++) {
1602 error5x5[i][j] = Ea[i][j];
1608 if (std::isinf(error5x5[i][j])) {
1609 B2DEBUG(99,
"Helix covariance matrix element found to be infinite. Setting value to DBL_MAX/2.0.");
1610 error5x5[i][j] = DBL_MAX / 2.0;
1618 Belle::Mdst_trk& trk = belleTrack.trk();
1620 for (
int mhyp = 0 ; mhyp <
c_nHyp; ++mhyp) {
1622 double thisMass = pType.
getMass();
1624 Belle::Mdst_trk_fit& trk_fit = trk.mhyp(mhyp);
1627 std::vector<float> helixParam(5);
1629 CLHEP::HepSymMatrix error5x5(5, 0);
1631 CLHEP::HepLorentzVector momentum;
1633 CLHEP::HepSymMatrix error7x7(7, 0);
1638 helixParam, error5x5,
1639 momentum, position, error7x7, 0.0);
1641 std::vector<float> helixError(15);
1642 unsigned int size = 5;
1643 unsigned int counter = 0;
1644 for (
unsigned int i = 0; i < size; i++)
1645 for (
unsigned int j = i; j < size; j++)
1646 helixError[counter++] = error5x5[i][j];
1648 double pValue = TMath::Prob(trk_fit.chisq(), trk_fit.ndf());
1655 for (
unsigned int i = 0; i < 3; i++)
1656 cdcNHits += trk_fit.nhits(i);
1663 auto cdcExtraInfo =
m_belleTrkExtra.appendNew(trk_fit.first_x(), trk_fit.first_y(), trk_fit.first_z(),
1664 trk_fit.last_x(), trk_fit.last_y(), trk_fit.last_z());
1665 track->addRelationTo(cdcExtraInfo);
1668 int svdHitPattern = trk_fit.hit_svd();
1672 std::bitset<32> svdBitSet(svdHitPattern);
1676 unsigned short svdLayers;
1680 std::bitset<32> svdUMask(
static_cast<std::string
>(
"00000000000000000000000000000011"));
1682 std::bitset<32> svdVMask;
1685 if (
event->getExperiment() <= 27) {
1686 svdVMask = svdUMask << 6;
1689 svdVMask = svdUMask << 8;
1694 for (
unsigned short layerId = 0; layerId < svdLayers; layerId++) {
1695 unsigned short uHits = (svdBitSet & svdUMask).count();
1696 unsigned short vHits = (svdBitSet & svdVMask).count();
1697 patternVxd.
setSVDLayer(layerId + 3, uHits, vHits);
1706 TMatrixDSym cartesianCovariance(6);
1707 for (
unsigned i = 0; i < 7; i++) {
1710 for (
unsigned j = 0; j < 7; j++) {
1718 BFIELD, cartesianCovariance, pValue);
1720 TMatrixDSym helixCovariance = helixFromCartesian.
getCovariance();
1723 for (
unsigned int i = 0; i < 5; ++i)
1724 for (
unsigned int j = i; j < 5; ++j)
1725 helixError[counter++] = helixCovariance(i, j);
1730 track->setTrackFitResultIndex(pType, trackFit->getArrayIndex());
1758 B2WARNING(
"Trying to convert Gen_hepevt with idhep = " << idHep <<
1759 ". This should never happen.");
1762 mcParticle->
setPDG(idHep);
1765 if (genHepevt.isthep() > 0) {
1769 mcParticle->
setMass(genHepevt.M());
1771 TLorentzVector p4(genHepevt.PX(), genHepevt.PY(), genHepevt.PZ(), genHepevt.E());
1778 if (genHepevt.daFirst() > 0) {
1779 Belle::Gen_hepevt_Manager& genMgr = Belle::Gen_hepevt_Manager::get_manager();
1780 Belle::Gen_hepevt daughterParticle = genMgr(Belle::Panther_ID(genHepevt.daFirst()));
1785 mcParticle->
setDecayTime(std::numeric_limits<float>::infinity());
1800 eclCluster->
setPhi(ecl.phi());
1802 eclCluster->
setR(ecl.r());
1805 double covarianceMatrix[6];
1806 covarianceMatrix[0] = ecl.error(0);
1807 covarianceMatrix[1] = ecl.error(1);
1808 covarianceMatrix[2] = ecl.error(2);
1809 covarianceMatrix[3] = ecl.error(3);
1810 covarianceMatrix[4] = ecl.error(4);
1811 covarianceMatrix[5] = ecl.error(5);
1814 eclCluster->
setLAT(eclAux.width());
1818 eclCluster->
setTime(eclAux.property(0));
1825 klmCluster->
setLayers(klm_cluster.layers());
1838 Belle::Mdst_ecl_trk_Manager& m = Belle::Mdst_ecl_trk_Manager::get_manager();
1839 Belle::Mdst_charged_Manager& chgMg = Belle::Mdst_charged_Manager::get_manager();
1844 std::vector<int> insert_order_types = {1, 2, 0};
1845 for (
auto& insert_type : insert_order_types) {
1846 for (Belle::Mdst_ecl_trk_Manager::iterator ecltrkIterator = m.begin(); ecltrkIterator != m.end(); ++ecltrkIterator) {
1847 Belle::Mdst_ecl_trk mECLTRK = *ecltrkIterator;
1849 if (mECLTRK.type() != insert_type)
1852 Belle::Mdst_ecl mdstEcl = mECLTRK.ecl();
1853 Belle::Mdst_trk mTRK = mECLTRK.trk();
1861 for (Belle::Mdst_charged_Manager::iterator chgIterator = chgMg.begin(); chgIterator != chgMg.end(); ++chgIterator) {
1862 Belle::Mdst_charged mChar = *chgIterator;
1863 Belle::Mdst_trk mTRK_in_charged = mChar.trk();
1865 if (mTRK_in_charged.get_ID() == mTRK.get_ID()) {
1867 tracksToECLClusters.
add(mChar.get_ID() - 1, mdstEcl.get_ID() - 1, 1.0);
1882 Belle::Mdst_klm_cluster_Manager& klm_cluster_manager = Belle::Mdst_klm_cluster_Manager::get_manager();
1885 for (Belle::Mdst_klm_cluster_Manager::iterator klmC_Ite = klm_cluster_manager.begin(); klmC_Ite != klm_cluster_manager.end();
1888 Belle::Mdst_klm_cluster mdstKlm_cluster = *klmC_Ite;
1889 Belle::Mdst_trk mTRK = mdstKlm_cluster.trk();
1890 Belle::Mdst_ecl mECL = mdstKlm_cluster.ecl();
1892 if (mTRK) klmClustersToTracks.
add(mdstKlm_cluster.get_ID() - 1, mTRK.get_ID() - 1);
1893 if (mECL) klmClustersToEclClusters.
add(mdstKlm_cluster.get_ID() - 1, mECL.get_ID() - 1);
1910 const int mask = 0x00f00000;
1911 int high_bits =
id & mask;
1912 if (high_bits == 0 || high_bits == mask)
return id;
1972 int bellePDGCode = belleMC.idhep();
1973 int belleIIPDGCode = mcP->
getPDG();
1975 if (bellePDGCode == 0)
1976 B2WARNING(
"[B2BIIConvertMdstModule] " << objectName <<
" matched to Gen_hepevt with idhep = 0.");
1978 if (bellePDGCode != belleIIPDGCode)
1979 B2WARNING(
"[B2BIIConvertMdstModule] " << objectName <<
" matched to different MCParticle! " << bellePDGCode <<
" vs. " <<
1982 double belleMomentum[] = { belleMC.PX(), belleMC.PY(), belleMC.PZ() };
1985 for (
unsigned i = 0; i < 3; i++) {
1986 double relDev = (belle2Momentum[i] - belleMomentum[i]) / belleMomentum[i];
1988 if (relDev > 1e-3) {
1989 B2WARNING(
"[B2BIIConvertMdstModule] " << objectName <<
" matched to different MCParticle!");
1990 B2INFO(
" - Gen_hepevt [" << bellePDGCode <<
"] px/py/pz = " << belleMC.PX() <<
"/" << belleMC.PY() <<
"/" << belleMC.PZ());
1991 B2INFO(
" - TrackFitResult [" << belleIIPDGCode <<
"] px/py/pz = " << mcP->
get4Vector().Px() <<
"/" << mcP->
get4Vector().Py() <<
"/"
1999 CLHEP::HepLorentzVector& momentum,
HepPoint3D& position, CLHEP::HepSymMatrix& error)
2001 const HepPoint3D pivot(vee.vx(), vee.vy(), vee.vz());
2002 CLHEP::HepVector a(5);
2003 CLHEP::HepSymMatrix Ea(5, 0);
2005 a[0] = vee.daut().helix_p(0); a[1] = vee.daut().helix_p(1);
2006 a[2] = vee.daut().helix_p(2); a[3] = vee.daut().helix_p(3);
2007 a[4] = vee.daut().helix_p(4);
2008 Ea[0][0] = vee.daut().error_p(0); Ea[1][0] = vee.daut().error_p(1);
2009 Ea[1][1] = vee.daut().error_p(2); Ea[2][0] = vee.daut().error_p(3);
2010 Ea[2][1] = vee.daut().error_p(4); Ea[2][2] = vee.daut().error_p(5);
2011 Ea[3][0] = vee.daut().error_p(6); Ea[3][1] = vee.daut().error_p(7);
2012 Ea[3][2] = vee.daut().error_p(8); Ea[3][3] = vee.daut().error_p(9);
2013 Ea[4][0] = vee.daut().error_p(10); Ea[4][1] = vee.daut().error_p(11);
2014 Ea[4][2] = vee.daut().error_p(12); Ea[4][3] = vee.daut().error_p(13);
2015 Ea[4][4] = vee.daut().error_p(14);
2017 a[0] = vee.daut().helix_m(0); a[1] = vee.daut().helix_m(1);
2018 a[2] = vee.daut().helix_m(2); a[3] = vee.daut().helix_m(3);
2019 a[4] = vee.daut().helix_m(4);
2020 Ea[0][0] = vee.daut().error_m(0); Ea[1][0] = vee.daut().error_m(1);
2021 Ea[1][1] = vee.daut().error_m(2); Ea[2][0] = vee.daut().error_m(3);
2022 Ea[2][1] = vee.daut().error_m(4); Ea[2][2] = vee.daut().error_m(5);
2023 Ea[3][0] = vee.daut().error_m(6); Ea[3][1] = vee.daut().error_m(7);
2024 Ea[3][2] = vee.daut().error_m(8); Ea[3][3] = vee.daut().error_m(9);
2025 Ea[4][0] = vee.daut().error_m(10); Ea[4][1] = vee.daut().error_m(11);
2026 Ea[4][2] = vee.daut().error_m(12); Ea[4][3] = vee.daut().error_m(13);
2027 Ea[4][4] = vee.daut().error_m(14);
2030 Belle::Helix helix(pivot, a, Ea);
2033 momentum = helix.momentum(0., pType.
getMass(), position, error);
2037 std::vector<float>& helixError)
2039 const HepPoint3D pivot(vee.vx(), vee.vy(), vee.vz());
2040 CLHEP::HepVector a(5);
2041 CLHEP::HepSymMatrix Ea(5, 0);
2043 a[0] = vee.daut().helix_p(0); a[1] = vee.daut().helix_p(1);
2044 a[2] = vee.daut().helix_p(2); a[3] = vee.daut().helix_p(3);
2045 a[4] = vee.daut().helix_p(4);
2046 Ea[0][0] = vee.daut().error_p(0);
2047 Ea[1][0] = vee.daut().error_p(1);
2048 Ea[1][1] = vee.daut().error_p(2);
2049 Ea[2][0] = vee.daut().error_p(3);
2050 Ea[2][1] = vee.daut().error_p(4);
2051 Ea[2][2] = vee.daut().error_p(5);
2052 Ea[3][0] = vee.daut().error_p(6);
2053 Ea[3][1] = vee.daut().error_p(7);
2054 Ea[3][2] = vee.daut().error_p(8);
2055 Ea[3][3] = vee.daut().error_p(9);
2056 Ea[4][0] = vee.daut().error_p(10);
2057 Ea[4][1] = vee.daut().error_p(11);
2058 Ea[4][2] = vee.daut().error_p(12);
2059 Ea[4][3] = vee.daut().error_p(13);
2060 Ea[4][4] = vee.daut().error_p(14);
2062 a[0] = vee.daut().helix_m(0); a[1] = vee.daut().helix_m(1);
2063 a[2] = vee.daut().helix_m(2); a[3] = vee.daut().helix_m(3);
2064 a[4] = vee.daut().helix_m(4);
2065 Ea[0][0] = vee.daut().error_m(0);
2066 Ea[1][0] = vee.daut().error_m(1);
2067 Ea[1][1] = vee.daut().error_m(2);
2068 Ea[2][0] = vee.daut().error_m(3);
2069 Ea[2][1] = vee.daut().error_m(4);
2070 Ea[2][2] = vee.daut().error_m(5);
2071 Ea[3][0] = vee.daut().error_m(6);
2072 Ea[3][1] = vee.daut().error_m(7);
2073 Ea[3][2] = vee.daut().error_m(8);
2074 Ea[3][3] = vee.daut().error_m(9);
2075 Ea[4][0] = vee.daut().error_m(10);
2076 Ea[4][1] = vee.daut().error_m(11);
2077 Ea[4][2] = vee.daut().error_m(12);
2078 Ea[4][3] = vee.daut().error_m(13);
2079 Ea[4][4] = vee.daut().error_m(14);
2082 Belle::Helix helix(pivot, a, Ea);
2087 CLHEP::HepSymMatrix error5x5(5, 0);
2090 unsigned int size = 5;
2091 unsigned int counter = 0;
2092 for (
unsigned int i = 0; i < size; i++)
2093 for (
unsigned int j = i; j < size; j++)
2094 helixError[counter++] = error5x5[i][j];
2098 std::vector<float>& helixParam, std::vector<float>& helixError)
2104 CLHEP::HepVector a(5);
2105 a[0] = trk_fit.helix(0);
2106 a[1] = trk_fit.helix(1);
2107 a[2] = trk_fit.helix(2);
2108 a[3] = trk_fit.helix(3);
2109 a[4] = trk_fit.helix(4);
2110 CLHEP::HepSymMatrix Ea(5, 0);
2111 Ea[0][0] = trk_fit.error(0);
2112 Ea[1][0] = trk_fit.error(1);
2113 Ea[1][1] = trk_fit.error(2);
2114 Ea[2][0] = trk_fit.error(3);
2115 Ea[2][1] = trk_fit.error(4);
2116 Ea[2][2] = trk_fit.error(5);
2117 Ea[3][0] = trk_fit.error(6);
2118 Ea[3][1] = trk_fit.error(7);
2119 Ea[3][2] = trk_fit.error(8);
2120 Ea[3][3] = trk_fit.error(9);
2121 Ea[4][0] = trk_fit.error(10);
2122 Ea[4][1] = trk_fit.error(11);
2123 Ea[4][2] = trk_fit.error(12);
2124 Ea[4][3] = trk_fit.error(13);
2125 Ea[4][4] = trk_fit.error(14);
2126 Belle::Helix helix(pivot, a, Ea);
2132 helixParam[0] = helix.a()[0];
2135 helixParam[1] = helix.a()[1] + TMath::Pi() / 2.0;
2141 helixParam[3] = helix.a()[3];
2144 helixParam[4] = helix.a()[4];
2148 helixError[0] = Ea[0][0];
2149 helixError[1] = Ea[1][0];
2151 helixError[3] = Ea[3][0];
2152 helixError[4] = Ea[4][0];
2153 helixError[5] = Ea[1][1];
2155 helixError[7] = Ea[3][1];
2156 helixError[8] = Ea[4][1];
2160 helixError[12] = Ea[3][3];
2161 helixError[13] = Ea[4][3];
2162 helixError[14] = Ea[4][4];
2167 CLHEP::HepLorentzVector& momentum,
HepPoint3D& position, CLHEP::HepSymMatrix& error,
double dPhi)
2173 CLHEP::HepVector a(5);
2174 a[0] = trk_fit.helix(0);
2175 a[1] = trk_fit.helix(1);
2176 a[2] = trk_fit.helix(2);
2177 a[3] = trk_fit.helix(3);
2178 a[4] = trk_fit.helix(4);
2179 CLHEP::HepSymMatrix Ea(5, 0);
2180 Ea[0][0] = trk_fit.error(0);
2181 Ea[1][0] = trk_fit.error(1);
2182 Ea[1][1] = trk_fit.error(2);
2183 Ea[2][0] = trk_fit.error(3);
2184 Ea[2][1] = trk_fit.error(4);
2185 Ea[2][2] = trk_fit.error(5);
2186 Ea[3][0] = trk_fit.error(6);
2187 Ea[3][1] = trk_fit.error(7);
2188 Ea[3][2] = trk_fit.error(8);
2189 Ea[3][3] = trk_fit.error(9);
2190 Ea[4][0] = trk_fit.error(10);
2191 Ea[4][1] = trk_fit.error(11);
2192 Ea[4][2] = trk_fit.error(12);
2193 Ea[4][3] = trk_fit.error(13);
2194 Ea[4][4] = trk_fit.error(14);
2196 Belle::Helix helix(pivot, a, Ea);
2199 if (helix.kappa() > 0)
2204 if (newPivot.x() != 0. || newPivot.y() != 0. || newPivot.z() != 0.) {
2205 helix.pivot(newPivot);
2206 momentum = helix.momentum(dPhi, mass, position, error);
2208 if (pivot.x() != 0. || pivot.y() != 0. || pivot.z() != 0.) {
2210 momentum = helix.momentum(dPhi, mass, position, error);
2212 momentum = helix.momentum(dPhi, mass, position, error);
2220 const CLHEP::HepSymMatrix& error,
2221 const short int charge,
2224 const uint64_t hitPatternCDCInitializer,
2225 const uint32_t hitPatternVXDInitializer,
2228 TVector3 pos(position.x(), position.y(), position.z());
2229 TVector3 mom(momentum.px(), momentum.py(), momentum.pz());
2231 TMatrixDSym errMatrix(6);
2232 for (
unsigned i = 0; i < 7; i++) {
2235 for (
unsigned j = 0; j < 7; j++) {
2246 return TrackFitResult(pos, mom, errMatrix, charge, pType, pValue,
BFIELD, hitPatternCDCInitializer, hitPatternVXDInitializer, ndf);
2251 if (!pid)
return 0.5;
2258 if (acc_sig + acc_bkg > 0.0)
2259 acc = acc_sig / (acc_sig + acc_bkg);
2266 double tof_all = tof_sig + tof_bkg;
2268 tof = tof_sig / tof_all;
2269 if (tof < 0.001) tof = 0.001;
2270 if (tof > 0.999) tof = 0.999;
2278 double cdc_all = cdc_sig + cdc_bkg;
2280 cdc = cdc_sig / cdc_all;
2281 if (cdc < 0.001) cdc = 0.001;
2282 if (cdc > 0.999) cdc = 0.999;
2286 double pid_sig = acc * tof * cdc;
2287 double pid_bkg = (1. - acc) * (1. - tof) * (1. - cdc);
2289 return pid_sig / (pid_sig + pid_bkg);
2295 B2DEBUG(99,
"B2BIIConvertMdst: endRun done.");
2301 B2DEBUG(99,
"B2BIIConvertMdst: terminate called");