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));
1259 if (
event->getExperiment() <= 27) {
1261 Belle::Rectrg_summary_Manager& RecTrgSummaryMgr = Belle::Rectrg_summary_Manager::get_manager();
1262 std::vector<Belle::Rectrg_summary>::iterator eflagIterator = RecTrgSummaryMgr.begin();
1263 std::string name_summary =
"rectrg_summary_m_final";
1266 for (
int index = 0; index < 2; ++index) {
1267 std::string iVar = name_summary + std::to_string(index);
1268 m_evtInfo->addExtraInfo(iVar, (*eflagIterator).final(index));
1269 B2DEBUG(99,
"m_final(" << index <<
") = " <<
m_evtInfo->getExtraInfo(iVar));
1273 Belle::Rectrg_summary3_Manager& RecTrgSummary3Mgr = Belle::Rectrg_summary3_Manager::get_manager();
1275 std::string name_summary3 =
"rectrg_summary3_m_final";
1277 std::vector<Belle::Rectrg_summary3>::iterator eflagIterator3 = RecTrgSummary3Mgr.begin();
1280 for (
int index = 0; index < 3; ++index) {
1281 std::string iVar = name_summary3 + std::to_string(index);
1282 m_evtInfo->addExtraInfo(iVar, (*eflagIterator3).final(index));
1283 B2DEBUG(99,
"m_final(" << index <<
") = " <<
m_evtInfo->getExtraInfo(iVar));
1297 static Belle::kid_acc acc_pdf(0);
1300 const double pmass[5] = { 0.00051099907, 0.105658389, 0.13956995, 0.493677, 0.93827231 };
1302 CLHEP::Hep3Vector mom(chg.px(), chg.py(), chg.pz());
1303 double cos_theta = mom.cosTheta();
1304 double pval = mom.mag();
1306 double npe = chg.acc().photo_electron();
1307 double beta = pval / sqrt(pval * pval + pmass[idp] * pmass[idp]);
1308 double pdfval = acc_pdf.npe2pdf(cos_theta, beta, npe);
1316 CLHEP::Hep3Vector mom(chg.px(), chg.py(), chg.pz());
1317 double pval = mom.mag();
1319 Belle::kid_cdc kidCdc(5);
1320 float factor0 = kidCdc.factor0();
1321 float factor1 = kidCdc.factor1(idp, pval);
1323 if (factor0 == 1.0 && factor1 == 1.0)
return chg.trk().pid(idp);
1325 double m = chg.trk().dEdx() / factor0;
1326 double e = chg.trk().dEdx_exp(idp) * factor1;
1327 double s = chg.trk().sigma_dEdx(idp);
1328 double val = 1. / sqrt(2.*M_PI) / s * exp(-0.5 * (m - e) * (m - e) / s / s);
1335 bool discard_allzero)
1337 if (discard_allzero) {
1338 const double max_l = *std::max_element(likelihoods, likelihoods +
c_nHyp);
1344 for (
int i = 0; i <
c_nHyp; i++) {
1345 float logl = log(likelihoods[i]);
1355 track->addRelationTo(pid);
1361 double likelihoods[
c_nHyp];
1365 for (
int i = 0; i <
c_nHyp; i++) {
1366 accL[i] = tofL[i] = cdcL[i] = 1.0;
1370 const auto& acc = belleTrack.acc();
1371 if (acc and acc.quality() == 0) {
1372 for (
int i = 0; i <
c_nHyp; i++)
1373 accL[i] = likelihoods[i] =
acc_pid(belleTrack, i);
1380 const Belle::Mdst_tof& tof = belleTrack.tof();
1381 if (tof and tof.quality() == 0) {
1382 for (
int i = 0; i <
c_nHyp; i++)
1383 tofL[i] = likelihoods[i] = tof.pid(i);
1390 const Belle::Mdst_trk& trk = belleTrack.trk();
1391 if (trk.dEdx() > 0) {
1392 for (
int i = 0; i <
c_nHyp; i++) {
1393 likelihoods[i] = trk.pid(i);
1394 cdcL[i] =
cdc_pid(belleTrack, i);
1408 Belle::eid electronID(belleTrack);
1409 float eclID_e_pdf = electronID.pdf_e_ecl();
1410 float eclID_h_pdf = electronID.pdf_h_ecl();
1411 float atcID_e_pdf = electronID.atc_pid_pdf(
true, accL, tofL, cdcL);
1412 float atcID_h_pdf = electronID.atc_pid_pdf(
false, accL, tofL, cdcL);
1415 float eclProb = eclID_e_pdf / (eclID_e_pdf + eclID_h_pdf);
1416 float atcProb = atcID_e_pdf / (atcID_e_pdf + atcID_h_pdf);
1418 if (atcProb > 0.999999) atcProb = 0.999999;
1420 double eidCombinedSig = eclProb * atcProb;
1421 double eidCombinedBkg = (1. - eclProb) * (1. - atcProb);
1423 likelihoods[0] = eidCombinedSig;
1425 likelihoods[2] = eidCombinedBkg;
1439 int muid_trackid = belleTrack.muid_ID();
1443 Belle::Mdst_klm_mu_ex_Manager& ex_mgr = Belle::Mdst_klm_mu_ex_Manager::get_manager();
1444 Belle::Mdst_klm_mu_ex& ex = ex_mgr(Belle::Panther_ID(muid_trackid));
1447 if (ex.Chi_2() > 0) {
1449 likelihoods[1] = ex.Muon_likelihood();
1450 likelihoods[2] = ex.Pion_likelihood();
1451 likelihoods[3] = ex.Kaon_likelihood();
1456 for (
int i = 0; i < 5; i++)
1457 if (likelihoods[i] < 0)
1483 std::vector<float>& helixParams,
1484 CLHEP::HepSymMatrix& error5x5,
1485 CLHEP::HepLorentzVector& momentum,
1487 CLHEP::HepSymMatrix& error7x7,
const double dPhi)
1493 CLHEP::HepVector a(5);
1494 a[0] = trk_fit.helix(0);
1495 a[1] = trk_fit.helix(1);
1496 a[2] = trk_fit.helix(2);
1497 a[3] = trk_fit.helix(3);
1498 a[4] = trk_fit.helix(4);
1499 CLHEP::HepSymMatrix Ea(5, 0);
1500 Ea[0][0] = trk_fit.error(0);
1501 Ea[1][0] = trk_fit.error(1);
1502 Ea[1][1] = trk_fit.error(2);
1503 Ea[2][0] = trk_fit.error(3);
1504 Ea[2][1] = trk_fit.error(4);
1505 Ea[2][2] = trk_fit.error(5);
1506 Ea[3][0] = trk_fit.error(6);
1507 Ea[3][1] = trk_fit.error(7);
1508 Ea[3][2] = trk_fit.error(8);
1509 Ea[3][3] = trk_fit.error(9);
1510 Ea[4][0] = trk_fit.error(10);
1511 Ea[4][1] = trk_fit.error(11);
1512 Ea[4][2] = trk_fit.error(12);
1513 Ea[4][3] = trk_fit.error(13);
1514 Ea[4][4] = trk_fit.error(14);
1516 Belle::Helix helix(pivot, a, Ea);
1519 if (helix.kappa() > 0)
1524 if (newPivot.x() != 0. || newPivot.y() != 0. || newPivot.z() != 0.) {
1525 helix.pivot(newPivot);
1526 momentum = helix.momentum(dPhi, mass, position, error7x7);
1528 if (pivot.x() != 0. || pivot.y() != 0. || pivot.z() != 0.) {
1530 momentum = helix.momentum(dPhi, mass, position, error7x7);
1532 momentum = helix.momentum(dPhi, mass, position, error7x7);
1543 std::vector<float>& helixParams, std::vector<float>& helixError)
1549 CLHEP::HepVector a(5);
1550 a[0] = trk_fit.helix(0);
1551 a[1] = trk_fit.helix(1);
1552 a[2] = trk_fit.helix(2);
1553 a[3] = trk_fit.helix(3);
1554 a[4] = trk_fit.helix(4);
1555 CLHEP::HepSymMatrix Ea(5, 0);
1556 Ea[0][0] = trk_fit.error(0);
1557 Ea[1][0] = trk_fit.error(1);
1558 Ea[1][1] = trk_fit.error(2);
1559 Ea[2][0] = trk_fit.error(3);
1560 Ea[2][1] = trk_fit.error(4);
1561 Ea[2][2] = trk_fit.error(5);
1562 Ea[3][0] = trk_fit.error(6);
1563 Ea[3][1] = trk_fit.error(7);
1564 Ea[3][2] = trk_fit.error(8);
1565 Ea[3][3] = trk_fit.error(9);
1566 Ea[4][0] = trk_fit.error(10);
1567 Ea[4][1] = trk_fit.error(11);
1568 Ea[4][2] = trk_fit.error(12);
1569 Ea[4][3] = trk_fit.error(13);
1570 Ea[4][4] = trk_fit.error(14);
1572 Belle::Helix helix(pivot, a, Ea);
1574 if (newPivot.x() != 0. || newPivot.y() != 0. || newPivot.z() != 0.) {
1575 helix.pivot(newPivot);
1577 if (pivot.x() != 0. || pivot.y() != 0. || pivot.z() != 0.) {
1582 CLHEP::HepSymMatrix error5x5(5, 0);
1585 unsigned int size = 5;
1586 unsigned int counter = 0;
1587 for (
unsigned int i = 0; i < size; i++)
1588 for (
unsigned int j = i; j < size; j++)
1589 helixError[counter++] = error5x5[i][j];
1594 CLHEP::HepVector a(5);
1595 CLHEP::HepSymMatrix Ea(5, 0);
1601 helixParams[0] = a[0];
1604 helixParams[1] = adjustAngleRange(a[1] + TMath::Pi() / 2.0);
1610 helixParams[3] = a[3];
1613 helixParams[4] = a[4];
1615 unsigned int size = 5;
1616 for (
unsigned int i = 0; i < size; i++) {
1617 for (
unsigned int j = 0; j < size; j++) {
1618 error5x5[i][j] = Ea[i][j];
1624 if (std::isinf(error5x5[i][j])) {
1625 B2DEBUG(99,
"Helix covariance matrix element found to be infinite. Setting value to DBL_MAX/2.0.");
1626 error5x5[i][j] = DBL_MAX / 2.0;
1634 Belle::Mdst_trk& trk = belleTrack.trk();
1636 for (
int mhyp = 0 ; mhyp <
c_nHyp; ++mhyp) {
1638 double thisMass = pType.
getMass();
1640 Belle::Mdst_trk_fit& trk_fit = trk.mhyp(mhyp);
1643 std::vector<float> helixParam(5);
1645 CLHEP::HepSymMatrix error5x5(5, 0);
1647 CLHEP::HepLorentzVector momentum;
1649 CLHEP::HepSymMatrix error7x7(7, 0);
1654 helixParam, error5x5,
1655 momentum, position, error7x7, 0.0);
1657 std::vector<float> helixError(15);
1658 unsigned int size = 5;
1659 unsigned int counter = 0;
1660 for (
unsigned int i = 0; i < size; i++)
1661 for (
unsigned int j = i; j < size; j++)
1662 helixError[counter++] = error5x5[i][j];
1664 double pValue = TMath::Prob(trk_fit.chisq(), trk_fit.ndf());
1671 for (
unsigned int i = 0; i < 3; i++)
1672 cdcNHits += trk_fit.nhits(i);
1679 auto cdcExtraInfo =
m_belleTrkExtra.appendNew(trk_fit.first_x(), trk_fit.first_y(), trk_fit.first_z(),
1680 trk_fit.last_x(), trk_fit.last_y(), trk_fit.last_z());
1681 track->addRelationTo(cdcExtraInfo);
1684 int svdHitPattern = trk_fit.hit_svd();
1688 std::bitset<32> svdBitSet(svdHitPattern);
1692 unsigned short svdLayers;
1696 std::bitset<32> svdUMask(
static_cast<std::string
>(
"00000000000000000000000000000011"));
1698 std::bitset<32> svdVMask;
1701 if (
event->getExperiment() <= 27) {
1702 svdVMask = svdUMask << 6;
1705 svdVMask = svdUMask << 8;
1710 for (
unsigned short layerId = 0; layerId < svdLayers; layerId++) {
1711 unsigned short uHits = (svdBitSet & svdUMask).count();
1712 unsigned short vHits = (svdBitSet & svdVMask).count();
1713 patternVxd.
setSVDLayer(layerId + 3, uHits, vHits);
1722 TMatrixDSym cartesianCovariance(6);
1723 for (
unsigned i = 0; i < 7; i++) {
1726 for (
unsigned j = 0; j < 7; j++) {
1734 BFIELD, cartesianCovariance, pValue);
1736 TMatrixDSym helixCovariance = helixFromCartesian.
getCovariance();
1739 for (
unsigned int i = 0; i < 5; ++i)
1740 for (
unsigned int j = i; j < 5; ++j)
1741 helixError[counter++] = helixCovariance(i, j);
1746 track->setTrackFitResultIndex(pType, trackFit->getArrayIndex());
1774 B2WARNING(
"Trying to convert Gen_hepevt with idhep = " << idHep <<
1775 ". This should never happen.");
1778 mcParticle->
setPDG(idHep);
1781 if (genHepevt.isthep() > 0) {
1785 mcParticle->
setMass(genHepevt.M());
1787 TLorentzVector p4(genHepevt.PX(), genHepevt.PY(), genHepevt.PZ(), genHepevt.E());
1794 if (genHepevt.daFirst() > 0) {
1795 Belle::Gen_hepevt_Manager& genMgr = Belle::Gen_hepevt_Manager::get_manager();
1796 Belle::Gen_hepevt daughterParticle = genMgr(Belle::Panther_ID(genHepevt.daFirst()));
1801 mcParticle->
setDecayTime(std::numeric_limits<float>::infinity());
1816 eclCluster->
setPhi(ecl.phi());
1818 eclCluster->
setR(ecl.r());
1821 double covarianceMatrix[6];
1822 covarianceMatrix[0] = ecl.error(0);
1823 covarianceMatrix[1] = ecl.error(1);
1824 covarianceMatrix[2] = ecl.error(2);
1825 covarianceMatrix[3] = ecl.error(3);
1826 covarianceMatrix[4] = ecl.error(4);
1827 covarianceMatrix[5] = ecl.error(5);
1830 eclCluster->
setLAT(eclAux.width());
1834 eclCluster->
setTime(eclAux.property(0));
1841 klmCluster->
setLayers(klm_cluster.layers());
1854 Belle::Mdst_ecl_trk_Manager& m = Belle::Mdst_ecl_trk_Manager::get_manager();
1855 Belle::Mdst_charged_Manager& chgMg = Belle::Mdst_charged_Manager::get_manager();
1860 std::vector<int> insert_order_types = {1, 2, 0};
1861 for (
auto& insert_type : insert_order_types) {
1862 for (Belle::Mdst_ecl_trk_Manager::iterator ecltrkIterator = m.begin(); ecltrkIterator != m.end(); ++ecltrkIterator) {
1863 Belle::Mdst_ecl_trk mECLTRK = *ecltrkIterator;
1865 if (mECLTRK.type() != insert_type)
1868 Belle::Mdst_ecl mdstEcl = mECLTRK.ecl();
1869 Belle::Mdst_trk mTRK = mECLTRK.trk();
1877 for (Belle::Mdst_charged_Manager::iterator chgIterator = chgMg.begin(); chgIterator != chgMg.end(); ++chgIterator) {
1878 Belle::Mdst_charged mChar = *chgIterator;
1879 Belle::Mdst_trk mTRK_in_charged = mChar.trk();
1881 if (mTRK_in_charged.get_ID() == mTRK.get_ID()) {
1883 tracksToECLClusters.
add(mChar.get_ID() - 1, mdstEcl.get_ID() - 1, 1.0);
1898 Belle::Mdst_klm_cluster_Manager& klm_cluster_manager = Belle::Mdst_klm_cluster_Manager::get_manager();
1901 for (Belle::Mdst_klm_cluster_Manager::iterator klmC_Ite = klm_cluster_manager.begin(); klmC_Ite != klm_cluster_manager.end();
1904 Belle::Mdst_klm_cluster mdstKlm_cluster = *klmC_Ite;
1905 Belle::Mdst_trk mTRK = mdstKlm_cluster.trk();
1906 Belle::Mdst_ecl mECL = mdstKlm_cluster.ecl();
1908 if (mTRK) klmClustersToTracks.
add(mdstKlm_cluster.get_ID() - 1, mTRK.get_ID() - 1);
1909 if (mECL) klmClustersToEclClusters.
add(mdstKlm_cluster.get_ID() - 1, mECL.get_ID() - 1);
1926 const int mask = 0x00f00000;
1927 int high_bits =
id & mask;
1928 if (high_bits == 0 || high_bits == mask)
return id;
1988 int bellePDGCode = belleMC.idhep();
1989 int belleIIPDGCode = mcP->
getPDG();
1991 if (bellePDGCode == 0)
1992 B2WARNING(
"[B2BIIConvertMdstModule] " << objectName <<
" matched to Gen_hepevt with idhep = 0.");
1994 if (bellePDGCode != belleIIPDGCode)
1995 B2WARNING(
"[B2BIIConvertMdstModule] " << objectName <<
" matched to different MCParticle! " << bellePDGCode <<
" vs. " <<
1998 double belleMomentum[] = { belleMC.PX(), belleMC.PY(), belleMC.PZ() };
2001 for (
unsigned i = 0; i < 3; i++) {
2002 double relDev = (belle2Momentum[i] - belleMomentum[i]) / belleMomentum[i];
2004 if (relDev > 1e-3) {
2005 B2WARNING(
"[B2BIIConvertMdstModule] " << objectName <<
" matched to different MCParticle!");
2006 B2INFO(
" - Gen_hepevt [" << bellePDGCode <<
"] px/py/pz = " << belleMC.PX() <<
"/" << belleMC.PY() <<
"/" << belleMC.PZ());
2007 B2INFO(
" - TrackFitResult [" << belleIIPDGCode <<
"] px/py/pz = " << mcP->
get4Vector().Px() <<
"/" << mcP->
get4Vector().Py() <<
"/"
2015 CLHEP::HepLorentzVector& momentum,
HepPoint3D& position, CLHEP::HepSymMatrix& error)
2017 const HepPoint3D pivot(vee.vx(), vee.vy(), vee.vz());
2018 CLHEP::HepVector a(5);
2019 CLHEP::HepSymMatrix Ea(5, 0);
2021 a[0] = vee.daut().helix_p(0); a[1] = vee.daut().helix_p(1);
2022 a[2] = vee.daut().helix_p(2); a[3] = vee.daut().helix_p(3);
2023 a[4] = vee.daut().helix_p(4);
2024 Ea[0][0] = vee.daut().error_p(0); Ea[1][0] = vee.daut().error_p(1);
2025 Ea[1][1] = vee.daut().error_p(2); Ea[2][0] = vee.daut().error_p(3);
2026 Ea[2][1] = vee.daut().error_p(4); Ea[2][2] = vee.daut().error_p(5);
2027 Ea[3][0] = vee.daut().error_p(6); Ea[3][1] = vee.daut().error_p(7);
2028 Ea[3][2] = vee.daut().error_p(8); Ea[3][3] = vee.daut().error_p(9);
2029 Ea[4][0] = vee.daut().error_p(10); Ea[4][1] = vee.daut().error_p(11);
2030 Ea[4][2] = vee.daut().error_p(12); Ea[4][3] = vee.daut().error_p(13);
2031 Ea[4][4] = vee.daut().error_p(14);
2033 a[0] = vee.daut().helix_m(0); a[1] = vee.daut().helix_m(1);
2034 a[2] = vee.daut().helix_m(2); a[3] = vee.daut().helix_m(3);
2035 a[4] = vee.daut().helix_m(4);
2036 Ea[0][0] = vee.daut().error_m(0); Ea[1][0] = vee.daut().error_m(1);
2037 Ea[1][1] = vee.daut().error_m(2); Ea[2][0] = vee.daut().error_m(3);
2038 Ea[2][1] = vee.daut().error_m(4); Ea[2][2] = vee.daut().error_m(5);
2039 Ea[3][0] = vee.daut().error_m(6); Ea[3][1] = vee.daut().error_m(7);
2040 Ea[3][2] = vee.daut().error_m(8); Ea[3][3] = vee.daut().error_m(9);
2041 Ea[4][0] = vee.daut().error_m(10); Ea[4][1] = vee.daut().error_m(11);
2042 Ea[4][2] = vee.daut().error_m(12); Ea[4][3] = vee.daut().error_m(13);
2043 Ea[4][4] = vee.daut().error_m(14);
2046 Belle::Helix helix(pivot, a, Ea);
2049 momentum = helix.momentum(0., pType.
getMass(), position, error);
2053 std::vector<float>& helixError)
2055 const HepPoint3D pivot(vee.vx(), vee.vy(), vee.vz());
2056 CLHEP::HepVector a(5);
2057 CLHEP::HepSymMatrix Ea(5, 0);
2059 a[0] = vee.daut().helix_p(0); a[1] = vee.daut().helix_p(1);
2060 a[2] = vee.daut().helix_p(2); a[3] = vee.daut().helix_p(3);
2061 a[4] = vee.daut().helix_p(4);
2062 Ea[0][0] = vee.daut().error_p(0);
2063 Ea[1][0] = vee.daut().error_p(1);
2064 Ea[1][1] = vee.daut().error_p(2);
2065 Ea[2][0] = vee.daut().error_p(3);
2066 Ea[2][1] = vee.daut().error_p(4);
2067 Ea[2][2] = vee.daut().error_p(5);
2068 Ea[3][0] = vee.daut().error_p(6);
2069 Ea[3][1] = vee.daut().error_p(7);
2070 Ea[3][2] = vee.daut().error_p(8);
2071 Ea[3][3] = vee.daut().error_p(9);
2072 Ea[4][0] = vee.daut().error_p(10);
2073 Ea[4][1] = vee.daut().error_p(11);
2074 Ea[4][2] = vee.daut().error_p(12);
2075 Ea[4][3] = vee.daut().error_p(13);
2076 Ea[4][4] = vee.daut().error_p(14);
2078 a[0] = vee.daut().helix_m(0); a[1] = vee.daut().helix_m(1);
2079 a[2] = vee.daut().helix_m(2); a[3] = vee.daut().helix_m(3);
2080 a[4] = vee.daut().helix_m(4);
2081 Ea[0][0] = vee.daut().error_m(0);
2082 Ea[1][0] = vee.daut().error_m(1);
2083 Ea[1][1] = vee.daut().error_m(2);
2084 Ea[2][0] = vee.daut().error_m(3);
2085 Ea[2][1] = vee.daut().error_m(4);
2086 Ea[2][2] = vee.daut().error_m(5);
2087 Ea[3][0] = vee.daut().error_m(6);
2088 Ea[3][1] = vee.daut().error_m(7);
2089 Ea[3][2] = vee.daut().error_m(8);
2090 Ea[3][3] = vee.daut().error_m(9);
2091 Ea[4][0] = vee.daut().error_m(10);
2092 Ea[4][1] = vee.daut().error_m(11);
2093 Ea[4][2] = vee.daut().error_m(12);
2094 Ea[4][3] = vee.daut().error_m(13);
2095 Ea[4][4] = vee.daut().error_m(14);
2098 Belle::Helix helix(pivot, a, Ea);
2103 CLHEP::HepSymMatrix error5x5(5, 0);
2106 unsigned int size = 5;
2107 unsigned int counter = 0;
2108 for (
unsigned int i = 0; i < size; i++)
2109 for (
unsigned int j = i; j < size; j++)
2110 helixError[counter++] = error5x5[i][j];
2114 std::vector<float>& helixParam, std::vector<float>& helixError)
2120 CLHEP::HepVector a(5);
2121 a[0] = trk_fit.helix(0);
2122 a[1] = trk_fit.helix(1);
2123 a[2] = trk_fit.helix(2);
2124 a[3] = trk_fit.helix(3);
2125 a[4] = trk_fit.helix(4);
2126 CLHEP::HepSymMatrix Ea(5, 0);
2127 Ea[0][0] = trk_fit.error(0);
2128 Ea[1][0] = trk_fit.error(1);
2129 Ea[1][1] = trk_fit.error(2);
2130 Ea[2][0] = trk_fit.error(3);
2131 Ea[2][1] = trk_fit.error(4);
2132 Ea[2][2] = trk_fit.error(5);
2133 Ea[3][0] = trk_fit.error(6);
2134 Ea[3][1] = trk_fit.error(7);
2135 Ea[3][2] = trk_fit.error(8);
2136 Ea[3][3] = trk_fit.error(9);
2137 Ea[4][0] = trk_fit.error(10);
2138 Ea[4][1] = trk_fit.error(11);
2139 Ea[4][2] = trk_fit.error(12);
2140 Ea[4][3] = trk_fit.error(13);
2141 Ea[4][4] = trk_fit.error(14);
2142 Belle::Helix helix(pivot, a, Ea);
2148 helixParam[0] = helix.a()[0];
2151 helixParam[1] = helix.a()[1] + TMath::Pi() / 2.0;
2157 helixParam[3] = helix.a()[3];
2160 helixParam[4] = helix.a()[4];
2164 helixError[0] = Ea[0][0];
2165 helixError[1] = Ea[1][0];
2167 helixError[3] = Ea[3][0];
2168 helixError[4] = Ea[4][0];
2169 helixError[5] = Ea[1][1];
2171 helixError[7] = Ea[3][1];
2172 helixError[8] = Ea[4][1];
2176 helixError[12] = Ea[3][3];
2177 helixError[13] = Ea[4][3];
2178 helixError[14] = Ea[4][4];
2183 CLHEP::HepLorentzVector& momentum,
HepPoint3D& position, CLHEP::HepSymMatrix& error,
double dPhi)
2189 CLHEP::HepVector a(5);
2190 a[0] = trk_fit.helix(0);
2191 a[1] = trk_fit.helix(1);
2192 a[2] = trk_fit.helix(2);
2193 a[3] = trk_fit.helix(3);
2194 a[4] = trk_fit.helix(4);
2195 CLHEP::HepSymMatrix Ea(5, 0);
2196 Ea[0][0] = trk_fit.error(0);
2197 Ea[1][0] = trk_fit.error(1);
2198 Ea[1][1] = trk_fit.error(2);
2199 Ea[2][0] = trk_fit.error(3);
2200 Ea[2][1] = trk_fit.error(4);
2201 Ea[2][2] = trk_fit.error(5);
2202 Ea[3][0] = trk_fit.error(6);
2203 Ea[3][1] = trk_fit.error(7);
2204 Ea[3][2] = trk_fit.error(8);
2205 Ea[3][3] = trk_fit.error(9);
2206 Ea[4][0] = trk_fit.error(10);
2207 Ea[4][1] = trk_fit.error(11);
2208 Ea[4][2] = trk_fit.error(12);
2209 Ea[4][3] = trk_fit.error(13);
2210 Ea[4][4] = trk_fit.error(14);
2212 Belle::Helix helix(pivot, a, Ea);
2215 if (helix.kappa() > 0)
2220 if (newPivot.x() != 0. || newPivot.y() != 0. || newPivot.z() != 0.) {
2221 helix.pivot(newPivot);
2222 momentum = helix.momentum(dPhi, mass, position, error);
2224 if (pivot.x() != 0. || pivot.y() != 0. || pivot.z() != 0.) {
2226 momentum = helix.momentum(dPhi, mass, position, error);
2228 momentum = helix.momentum(dPhi, mass, position, error);
2236 const CLHEP::HepSymMatrix& error,
2237 const short int charge,
2240 const uint64_t hitPatternCDCInitializer,
2241 const uint32_t hitPatternVXDInitializer,
2244 TVector3 pos(position.x(), position.y(), position.z());
2245 TVector3 mom(momentum.px(), momentum.py(), momentum.pz());
2247 TMatrixDSym errMatrix(6);
2248 for (
unsigned i = 0; i < 7; i++) {
2251 for (
unsigned j = 0; j < 7; j++) {
2262 return TrackFitResult(pos, mom, errMatrix, charge, pType, pValue,
BFIELD, hitPatternCDCInitializer, hitPatternVXDInitializer, ndf);
2267 if (!pid)
return 0.5;
2274 if (acc_sig + acc_bkg > 0.0)
2275 acc = acc_sig / (acc_sig + acc_bkg);
2282 double tof_all = tof_sig + tof_bkg;
2284 tof = tof_sig / tof_all;
2285 if (tof < 0.001) tof = 0.001;
2286 if (tof > 0.999) tof = 0.999;
2294 double cdc_all = cdc_sig + cdc_bkg;
2296 cdc = cdc_sig / cdc_all;
2297 if (cdc < 0.001) cdc = 0.001;
2298 if (cdc > 0.999) cdc = 0.999;
2302 double pid_sig = acc * tof * cdc;
2303 double pid_bkg = (1. - acc) * (1. - tof) * (1. - cdc);
2305 return pid_sig / (pid_sig + pid_bkg);
2311 B2DEBUG(99,
"B2BIIConvertMdst: endRun done.");
2317 B2DEBUG(99,
"B2BIIConvertMdst: terminate called");