10#include <analysis/modules/ParticleVertexFitter/ParticleVertexFitterModule.h>
13#include <framework/gearbox/Unit.h>
14#include <framework/gearbox/Const.h>
15#include <framework/logging/Logger.h>
16#include <framework/particledb/EvtGenDatabasePDG.h>
19#include <analysis/dataobjects/Particle.h>
20#include <analysis/dataobjects/Btube.h>
21#include <mdst/dataobjects/V0.h>
24#include <analysis/utility/CLHEPToROOT.h>
25#include <analysis/utility/PCmsLabTransform.h>
26#include <analysis/utility/ParticleCopy.h>
27#include <analysis/utility/ROOTToCLHEP.h>
30#include <framework/geometry/BFieldManager.h>
33#include <analysis/VertexFitting/KFit/KFitConst.h>
63 "Confidence level to accept the fit. Particle candidates with "
64 "p-value less than confidenceLevel are removed from the particle "
65 "list. If set to -1, all candidates are kept; if set to 0, "
66 "the candidates failing the fit are removed.",
69 addParam(
"fitType",
m_fitType,
"type of the kinematic fit (vertex, massvertex, mass)",
string(
"vertex"));
71 "additional constraint on vertex: ipprofile, iptube, mother, iptubecut, pointing, btube",
73 addParam(
"decayString",
m_decayString,
"specifies which daughter particles are included in the kinematic fit",
string(
""));
78 "Type::[int]. List of daughter particles to mass constrain with int = pdg code. (only for MassFourCKFit)", {});
93 B2DEBUG(1,
"ParticleVertexFitterModule : magnetic field = " <<
m_Bfield);
101 B2INFO(
"ParticleVertexFitter: Using specified decay string: " <<
m_decayString);
103 B2INFO(
"ParticleVertexFitter: Additional " <<
m_withConstraint <<
" will be applied");
121 TMatrixDSym beamSpotCov(3);
138 std::vector<unsigned int> toRemove;
139 unsigned int nParticles =
m_plist->getListSize();
141 for (
unsigned iPart = 0; iPart < nParticles; iPart++) {
147 else B2ERROR(
"Daughters update works only when all daughters are selected. Daughters will not be updated");
155 TMatrixFSym mother_errMatrix(7);
156 mother_errMatrix = particle->getMomentumVertexErrorMatrix();
157 for (
int k = 0; k < 7; k++) {
158 for (
int j = 0; j < 7; j++) {
159 if (mother_errMatrix[k][j] > 0) {
170 toRemove.push_back(particle->getArrayIndex());
181 particle->setPValue(-1);
183 toRemove.push_back(particle->getArrayIndex());
186 m_plist->removeParticles(toRemove);
198 B2FATAL(
"ParticleVertexFitter: No magnetic field");
208 B2FATAL(
"ParticleVertexFitter: " <<
m_withConstraint <<
" ***invalid Constraint ");
215 B2FATAL(
"ParticleVertexFitter: KFit does not support yet selection of daughters via decay string except for vertex fit!");
231 B2FATAL(
"ParticleVertexFitter: Invalid options - mass-constrained fit using KFit does not work with iptube or ipprofile constraint.");
242 B2FATAL(
"ParticleVertexFitter: Invalid options - mass fit using KFit does not work with iptube or ipprofile constraint.");
251 B2FATAL(
"ParticleVertexFitter: Invalid options - four C fit using KFit does not work with iptube or ipprofile constraint.");
260 B2FATAL(
"ParticleVertexFitter: Invalid options - four C fit using KFit does not work with iptube or ipprofile constraint.");
269 B2FATAL(
"ParticleVertexFitter: Invalid options - recoil mass fit using KFit does not work with iptube or ipprofile constraint.");
282 B2FATAL(
"ParticleVertexFitter: " <<
m_fitType <<
" ***invalid fit type for the vertex fitter ");
289 }
catch (
const rave::CheckedFloatException&) {
290 B2ERROR(
"Invalid inputs (nan/inf)?");
297 B2FATAL(
"ParticleVertexFitter: " <<
m_vertexFitter <<
" ***invalid vertex fitter ");
299 if (!ok)
return false;
309 std::vector<const Particle*>& twoPhotonChildren)
313 for (
unsigned ichild = 0; ichild < mother->
getNDaughters(); ichild++) {
320 fitChildren.push_back(child);
326 auto itr = fitChildren.begin();
327 while (itr != fitChildren.end()) {
330 if (child->getPValue() < 0) {
331 B2WARNING(
"Daughter with PDG code " << child->getPDGCode() <<
" does not have a valid error matrix.");
334 bool isTwoPhotonParticle =
false;
337 if (child->getNDaughters() == 2) {
340 isTwoPhotonParticle =
true;
345 if (isTwoPhotonParticle) {
347 twoPhotonChildren.push_back(child);
348 itr = fitChildren.erase(itr);
358 const std::vector<const Particle*>& fitChildren)
360 if (fitChildren.empty())
361 B2WARNING(
"[ParticleVertexFitterModule::fillNotFitParticles] fitChildren is empty! Please call fillFitParticles firstly");
362 if (!notFitChildren.empty())
363 B2WARNING(
"[ParticleVertexFitterModule::fillNotFitParticles] notFitChildren is NOT empty!"
364 <<
" The function should be called only once");
370 std::function<bool(
const Particle*)> funcCheckInFit =
371 [&funcCheckInFit, ¬FitChildren, fitChildren](
const Particle * part) {
375 if (std::find(fitChildren.begin(), fitChildren.end(), part) != fitChildren.end())
379 if (part->getNDaughters() == 0)
384 bool isAnyChildrenInFit =
false;
385 vector<const Particle*> notFitChildren_tmp;
386 for (
unsigned ichild = 0; ichild < part->getNDaughters(); ichild++) {
388 const Particle* child = part->getDaughter(ichild);
389 bool isChildrenInFit = funcCheckInFit(child);
390 isAnyChildrenInFit = isChildrenInFit or isAnyChildrenInFit;
393 if (!isChildrenInFit)
394 notFitChildren_tmp.push_back(child);
398 if (isAnyChildrenInFit)
399 notFitChildren.insert(notFitChildren.end(), notFitChildren_tmp.begin(), notFitChildren_tmp.end());
403 return isAnyChildrenInFit;
408 for (
unsigned ichild = 0; ichild < mother->
getNDaughters(); ichild++) {
410 bool isGivenParticleOrAnyChildrenInFit = funcCheckInFit(child);
411 if (!isGivenParticleOrAnyChildrenInFit)
412 notFitChildren.push_back(child);
435 TMatrixFSym errMatrix(3);
436 for (
int i = 0; i < 3; i++)
437 for (
int j = 0; j < 3; j++)
438 errMatrix(i, j) = posErrorMatrix[i][j];
440 g1ErrMatrix.SetSub(4, errMatrix);
441 g2ErrMatrix.SetSub(4, errMatrix);
457 int err = km.
doFit();
475 std::vector<const Particle*> fitChildren;
476 std::vector<const Particle*> twoPhotonChildren;
477 bool validChildren =
fillFitParticles(mother, fitChildren, twoPhotonChildren);
482 std::vector<const Particle*> notFitChildren;
486 if (twoPhotonChildren.size() > 1) {
487 B2FATAL(
"[ParticleVertexFitterModule::doKVertexFit] Vertex fit using KFit does not support fit with multiple particles decaying to two photons like pi0 (yet).");
490 if ((fitChildren.size() < 2 && !ipTubeConstraint) || fitChildren.size() < 1) {
491 B2WARNING(
"[ParticleVertexFitterModule::doKVertexFit] Number of particles with valid error matrix entering the vertex fit using KFit is too low.");
499 if (mother->
getV0()) {
503 for (
auto& child : fitChildren)
506 if (ipProfileConstraint)
509 if (ipTubeConstraint)
513 int err = kv.
doFit();
523 if (twoPhotonChildren.size() == 0)
526 else if (twoPhotonChildren.size() == 1) {
532 const Particle* twoPhotonDaughter = twoPhotonChildren[0];
542 for (
auto& child : fitChildren)
547 if (ipProfileConstraint)
559 ROOT::Math::PxPyPzEVector total4Vector(mother->
get4Vector());
560 for (
auto& child : notFitChildren)
561 total4Vector += child->get4Vector();
571 std::vector<const Particle*> fitChildren;
572 std::vector<const Particle*> twoPhotonChildren;
573 bool validChildren =
fillFitParticles(mother, fitChildren, twoPhotonChildren);
578 if (twoPhotonChildren.size() > 1) {
579 B2FATAL(
"[ParticleVertexFitterModule::doKVertexFit] MassVertex fit using KFit does not support fit with multiple particles decaying to two photons like pi0 (yet).");
582 if (fitChildren.size() < 2) {
583 B2WARNING(
"[ParticleVertexFitterModule::doKVertexFit] Number of particles with valid error matrix entering the vertex fit using KFit is less than 2.");
588 if (twoPhotonChildren.size() == 0) {
593 if (mother->
getV0()) {
600 for (
auto child : fitChildren)
604 int err = kmv.
doFit();
610 }
else if (twoPhotonChildren.size() == 1) {
619 for (
auto child : fitChildren)
623 int err = kv.
doFit();
627 const Particle* twoPhotonDaughter = twoPhotonChildren[0];
637 for (
auto child : fitChildren)
662 std::vector<const Particle*> fitChildren;
663 std::vector<const Particle*> twoPhotonChildren;
664 bool validChildren =
fillFitParticles(mother, fitChildren, twoPhotonChildren);
669 if (twoPhotonChildren.size() > 0) {
670 B2FATAL(
"[ParticleVertexFitterModule::doKMassPointingVertexFit] MassPointingVertex fit using KFit does not support fit with two-photon daughters (yet).");
673 if (fitChildren.size() < 2) {
674 B2WARNING(
"[ParticleVertexFitterModule::doKMassPointingVertexFit] Number of particles with valid error matrix entering the vertex fit using KFit is less than 2.");
683 for (
auto child : fitChildren)
691 int err = kmpv.
doFit();
692 if (err != 0)
return false;
706 for (
unsigned ichild = 0; ichild < mother->
getNDaughters(); ichild++) {
709 if (child->getPValue() < 0)
return false;
717 int err = km.
doFit();
719 if (err != 0)
return false;
733 for (
unsigned ichild = 0; ichild < mother->
getNDaughters(); ichild++) {
736 if (child->getNDaughters() > 0) {
738 if (!err)
return false;
740 if (child->getPValue() < 0)
return false;
750 int err = kf.
doFit();
752 if (err != 0)
return false;
766 for (
unsigned ichild = 0; ichild < mother->
getNDaughters(); ichild++) {
769 if (child->getNDaughters() > 0) {
772 std::vector<unsigned> childId;
775 if (!err)
return false;
777 if (child->getPValue() < 0)
return false;
786 int err = kf.
doFit();
788 if (err != 0)
return false;
800 for (
unsigned ichild = 0; ichild < mother->
getNDaughters(); ichild++) {
803 if (child->getPValue() < 0)
return false;
815 int err = kf.
doFit();
817 if (err != 0)
return false;
835 std::vector<Particle*> daughters = mother->
getDaughters();
838 if (daughters.size() != track_count)
841 for (
unsigned iChild = 0; iChild < track_count; iChild++) {
846 ROOT::Math::PxPyPzEVector i4Vector(kv.
getTrackMomentum(iChild).x() - a * dy,
850 daughters[iChild]->set4VectorDividingByMomentumScaling(i4Vector);
852 daughters[iChild]->setVertex(
854 daughters[iChild]->setMomentumVertexErrorMatrix(
863 if (fitChildren.size() != track_count)
866 for (
unsigned iChild = 0; iChild < track_count; iChild++) {
867 auto daughter =
const_cast<Particle*
>(fitChildren[iChild]);
873 ROOT::Math::PxPyPzEVector i4Vector(kv.
getTrackMomentum(iChild).x() - a * dy,
877 daughter->set4VectorDividingByMomentumScaling(i4Vector);
879 daughter->setVertex(CLHEPToROOT::getXYZVector(kv.
getTrackPosition(iChild)));
880 daughter->setMomentumVertexErrorMatrix(CLHEPToROOT::getTMatrixFSym(kv.
getTrackError(iChild)));
884 std::function<bool(
Particle*)> funcUpdateMomentum =
885 [&funcUpdateMomentum, fitChildren](
Particle * part) {
887 if (part->getNDaughters() == 0) {
889 if (std::find(fitChildren.begin(), fitChildren.end(), part) != fitChildren.end())
895 bool includeFitChildren =
false;
898 for (
auto daughter : part->getDaughters())
899 includeFitChildren = funcUpdateMomentum(daughter) || includeFitChildren;
901 if (includeFitChildren) {
903 ROOT::Math::PxPyPzEVector sum4Vector;
904 for (
auto daughter : part->getDaughters())
905 sum4Vector += daughter->get4Vector();
907 part->set4VectorDividingByMomentumScaling(sum4Vector);
910 return includeFitChildren;
915 funcUpdateMomentum(daughter);
934 std::vector<Particle*> daughters = mother->
getDaughters();
937 if (daughters.size() != track_count)
940 for (
unsigned iChild = 0; iChild < track_count; iChild++) {
945 ROOT::Math::PxPyPzEVector i4Vector(kmv.
getTrackMomentum(iChild).x() - a * dy,
949 daughters[iChild]->set4VectorDividingByMomentumScaling(i4Vector);
951 daughters[iChild]->setVertex(
953 daughters[iChild]->setMomentumVertexErrorMatrix(
974 std::vector<Particle*> daughters = mother->
getDaughters();
977 if (daughters.size() != track_count)
980 for (
unsigned iChild = 0; iChild < track_count; iChild++) {
985 ROOT::Math::PxPyPzEVector i4Vector(kmpv.
getTrackMomentum(iChild).x() - a * dy,
989 daughters[iChild]->set4VectorDividingByMomentumScaling(i4Vector);
991 daughters[iChild]->setVertex(
993 daughters[iChild]->setMomentumVertexErrorMatrix(
1013 std::vector<Particle*> daughters = mother->
getDaughters();
1016 if (daughters.size() != track_count)
1019 for (
unsigned iChild = 0; iChild < track_count; iChild++) {
1024 ROOT::Math::PxPyPzEVector i4Vector(km.
getTrackMomentum(iChild).x() - a * dy,
1028 daughters[iChild]->set4VectorDividingByMomentumScaling(i4Vector);
1030 daughters[iChild]->setVertex(
1032 daughters[iChild]->setMomentumVertexErrorMatrix(
1054 std::vector<Particle*> daughters = mother->
getDaughters();
1056 const unsigned nd = daughters.size();
1058 std::vector<std::vector<unsigned>> pars;
1059 std::vector<Particle*> allparticles;
1060 for (
unsigned ichild = 0; ichild < nd; ichild++) {
1062 std::vector<unsigned> pard;
1063 if (daughter->getNDaughters() > 0) {
1065 pars.push_back(pard);
1066 allparticles.push_back(daughters[ichild]);
1069 pars.push_back(pard);
1070 allparticles.push_back(daughters[ichild]);
1076 if (l != track_count)
1079 for (
unsigned iDaug = 0; iDaug < allparticles.size(); iDaug++) {
1080 ROOT::Math::PxPyPzEVector childMoms;
1081 ROOT::Math::XYZVector childPoss;
1082 TMatrixFSym childErrMatrixs(7);
1083 for (
unsigned int iChild : pars[iDaug]) {
1084 childMoms = childMoms +
1085 CLHEPToROOT::getLorentzVector(
1087 childPoss = childPoss +
1088 CLHEPToROOT::getXYZVector(
1090 TMatrixFSym childErrMatrix =
1092 childErrMatrixs = childErrMatrixs + childErrMatrix;
1094 allparticles[iDaug]->set4Vector(childMoms);
1095 allparticles[iDaug]->setVertex(childPoss);
1096 allparticles[iDaug]->setMomentumVertexErrorMatrix(childErrMatrixs);
1116 std::vector<Particle*> daughters = mother->
getDaughters();
1118 const unsigned nd = daughters.size();
1120 std::vector<std::vector<unsigned>> pars;
1121 std::vector<Particle*> allparticles;
1122 for (
unsigned ichild = 0; ichild < nd; ichild++) {
1124 std::vector<unsigned> pard;
1125 if (daughter->getNDaughters() > 0) {
1127 pars.push_back(pard);
1128 allparticles.push_back(daughters[ichild]);
1131 pars.push_back(pard);
1132 allparticles.push_back(daughters[ichild]);
1138 if (l != track_count)
1141 for (
unsigned iDaug = 0; iDaug < allparticles.size(); iDaug++) {
1142 ROOT::Math::PxPyPzEVector childMoms;
1143 ROOT::Math::XYZVector childPoss;
1144 TMatrixFSym childErrMatrixs(7);
1145 for (
unsigned int iChild : pars[iDaug]) {
1146 childMoms = childMoms +
1147 CLHEPToROOT::getLorentzVector(
1149 childPoss = childPoss +
1150 CLHEPToROOT::getXYZVector(
1152 TMatrixFSym childErrMatrix =
1154 childErrMatrixs = childErrMatrixs + childErrMatrix;
1156 allparticles[iDaug]->set4Vector(childMoms);
1157 allparticles[iDaug]->setVertex(childPoss);
1158 allparticles[iDaug]->setMomentumVertexErrorMatrix(childErrMatrixs);
1178 std::vector<Particle*> daughters = mother->
getDaughters();
1181 if (daughters.size() != track_count)
1184 for (
unsigned iChild = 0; iChild < track_count; iChild++) {
1189 ROOT::Math::PxPyPzEVector i4Vector(kf.
getTrackMomentum(iChild).x() - a * dy,
1193 daughters[iChild]->set4VectorDividingByMomentumScaling(i4Vector);
1195 daughters[iChild]->setVertex(
1197 daughters[iChild]->setMomentumVertexErrorMatrix(
1207 std::vector<unsigned>& parm, std::vector<Particle*>& allparticles,
const Particle* daughter)
1209 std::vector <Belle2::Particle*> daughters = daughter->getDaughters();
1210 for (
unsigned ichild = 0; ichild < daughter->getNDaughters(); ichild++) {
1211 const Particle* child = daughter->getDaughter(ichild);
1212 std::vector<unsigned> pard;
1213 if (child->getNDaughters() > 0) {
1215 parm.insert(parm.end(), pard.begin(), pard.end());
1216 pars.push_back(pard);
1217 allparticles.push_back(daughters[ichild]);
1221 pars.push_back(pard);
1222 allparticles.push_back(daughters[ichild]);
1248 for (
auto& itrack : tracksVertex) {
1249 if (itrack != mother) rf.
addTrack(itrack);
1255 bool mothSel =
false;
1257 for (
unsigned itrack = 0; itrack < tracksVertex.size(); itrack++) {
1258 if (tracksVertex[itrack] != mother) {
1259 rsf.
addTrack(tracksVertex[itrack]);
1260 B2DEBUG(1,
"ParticleVertexFitterModule: Adding particle " << tracksName[itrack] <<
" to vertex fit ");
1263 if (tracksVertex[itrack] == mother) mothSel =
true;
1268 bool mothIPfit =
false;
1269 if (tracksVertex.size() == 1 && mothSel ==
true &&
m_withConstraint !=
"" && nTrk == 0) {
1271 if (tracksVertex[0] != mother)
1272 B2FATAL(
"ParticleVertexFitterModule: FATAL Error in IP constrained mother fit");
1278 ROOT::Math::XYZVector pos;
1279 TMatrixDSym RerrMatrix(3);
1285 for (
auto& itrack : tracksVertex) {
1287 nvert = rsg.
fit(
"kalman");
1290 RerrMatrix = rsg.
getCov(0);
1292 ROOT::Math::PxPyPzEVector mom(mother->
get4Vector());
1293 TMatrixDSym errMatrix(7);
1294 for (
int i = 0; i < 7; i++) {
1295 for (
int j = 0; j < 7; j++) {
1296 if (i > 3 && j > 3) {errMatrix[i][j] = RerrMatrix[i - 4][j - 4];}
1297 else {errMatrix[i][j] = 0;}
1317 }
else {
return false;}
1327 ROOT::Math::PxPyPzEVector mom(mother->
get4Vector());
1328 TMatrixDSym errMatrix(7);
1329 for (
int i = 0; i < 7; i++) {
1330 for (
int j = 0; j < 7; j++) {
1331 if (i > 3 && j > 3) {errMatrix[i][j] = RerrMatrix[i - 4][j - 4];}
1332 else {errMatrix[i][j] = 0;}
1336 }
else {
return false;}
1339 if (mothSel && nTrk > 1) {
1342 int nKfit = rf.
fit();
1346 if (nKfit > 0) {
return true;}
1355 int nVert = rf.
fit();
1358 if (nVert != 1)
return false;
1365 int nVert = rf.
fit();
1367 if (nVert != 1)
return false;
1372 int nVert = rf.
fit();
1375 if (nVert != 1)
return false;
1378 B2FATAL(
"fitType : " <<
m_fitType <<
" ***invalid fit type ");
1385 const std::vector<const Particle*>& tracksVertex)
1394 for (
auto& vi : tracksVertex) {
1396 nNotIncluded = nNotIncluded - 1;
1404 if (nNotIncluded == 0) isAll =
true;
1410 for (
unsigned ichild = 0; ichild < particle->getNDaughters(); ichild++) {
1411 const Particle* child = particle->getDaughter(ichild);
1414 if (child->getPValue() < 0)
return false;
1423 std::vector<unsigned>& particleId)
1425 for (
unsigned ichild = 0; ichild < particle->getNDaughters(); ichild++) {
1426 const Particle* child = particle->getDaughter(ichild);
1427 if (child->getNDaughters() > 0) {
1430 std::vector<unsigned> childId;
1433 particleId.insert(particleId.end(), childId.begin(), childId.end());
1435 if (child->getPValue() < 0)
return false;
1446 CLHEP::HepSymMatrix covMatrix = ROOTToCLHEP::getHepSymMatrix(
m_beamSpotCov);
1453 CLHEP::HepSymMatrix err(7, 0);
1455 for (
int i = 0; i < 3; i++) {
1456 for (
int j = 0; j < 3; j++) {
1465 ROOTToCLHEP::getHepLorentzVector(iptube_mom),
1477 TMatrixDSym beamSpotCov =
m_beamSpotDB->getCovVertex();
1478 beamSpotCov(2, 2) = cut * cut;
1479 double thetab = boostDir.Theta();
1480 double phib = boostDir.Phi();
1482 double stb = TMath::Sin(thetab);
1483 double ctb = TMath::Cos(thetab);
1484 double spb = TMath::Sin(phib);
1485 double cpb = TMath::Cos(phib);
1488 TMatrix rz(3, 3); rz(2, 2) = 1;
1489 rz(0, 0) = cpb; rz(0, 1) = spb;
1490 rz(1, 0) = -1 * spb; rz(1, 1) = cpb;
1492 TMatrix ry(3, 3); ry(1, 1) = 1;
1493 ry(0, 0) = ctb; ry(0, 2) = -1 * stb;
1494 ry(2, 0) = stb; ry(2, 2) = ctb;
1496 TMatrix r(3, 3); r.Mult(rz, ry);
1497 TMatrix rt(3, 3); rt.Transpose(r);
1499 TMatrix TubePart(3, 3); TubePart.Mult(rt, beamSpotCov);
1500 TMatrix Tube(3, 3); Tube.Mult(TubePart, r);
1509 TMatrixDSym beamSpotCov =
m_beamSpotDB->getCovVertex();
1510 for (
int i = 0; i < 3; i++)
1511 beamSpotCov(i, i) += width * width;
1518 double chi2TrackL = 0;
1520 for (
int iTrack = 0; iTrack < kv.
getTrackCount(); iTrack++) {
1527 ROOT::Math::XYZVector x_after = CLHEPToROOT::getXYZVector(trk_i.
getPosition());
1528 ROOT::Math::XYZVector dPos = x_after - x_before;
1532 TVectorD boostD(0, 6, 0., 0., 0., 0., boost3.X(), boost3.Y(), boost3.Z(),
"END");
1534 double dLBoost = dPos.Dot(boost3);
1536 chi2TrackL += TMath::Power(dLBoost, 2) / err.Similarity(boostD);
static ROOT::Math::XYZVector getFieldInTesla(const ROOT::Math::XYZVector &pos)
return the magnetic field at a given position in Tesla.
For each MCParticle with hits in the CDC, this class stores some summarising information on those hit...
TMatrixFSym getTubeMatrix() const
Returns Btube matrix.
Eigen::Matrix< double, 3, 1 > getTubeCenter() const
Returns Btube center.
int getPDGCode() const
PDG code.
static const ParticleType pi0
neutral pion particle
static const double speedOfLight
[cm/ns]
static const ParticleType photon
photon particle
bool init(const std::string &str)
Initialise the DecayDescriptor from given string.
std::vector< std::string > getSelectionNames()
Return list of human readable names of selected particles.
std::vector< const Particle * > getSelectionParticles(const Particle *particle)
Get a vector of pointers with selected daughters in the decay tree.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
TMatrixDSym m_beamSpotCov
Beam spot covariance matrix.
bool makeKMassMother(analysis::MassFitKFit &kv, Particle *p)
Update mother particle after mass fit using KFit.
std::string m_withConstraint
additional constraint on vertex
bool doKMassPointingVertexFit(Particle *p)
Mass-constrained vertex fit with additional pointing constraint using KFit.
void smearBeamSpot(double width)
smear beam spot covariance
bool makeMassKFourCMother(analysis::MassFourCFitKFit &kv, Particle *p)
Update mother particle after MassFourC fit using KFit.
void updateMapOfTrackAndDaughter(unsigned &l, std::vector< std::vector< unsigned > > &pars, std::vector< unsigned > &pard, std::vector< Particle * > &allparticles, const Particle *daughter)
update the map of daughter and tracks, find out which tracks belong to each daughter.
bool doKVertexFit(Particle *p, bool ipProfileConstraint, bool ipTubeConstraint)
Unconstrained vertex fit using KFit.
bool doKMassVertexFit(Particle *p)
Mass-constrained vertex fit using KFit.
virtual void initialize() override
Initialize the Module.
void addIPTubeToKFit(analysis::VertexFitKFit &kv)
Adds IPTube constraint to the vertex fit using KFit.
bool addChildofParticletoMassKFit(analysis::MassFourCFitKFit &kf, const Particle *particle, std::vector< unsigned > &particleId)
Adds given particle's child to the MassFourCFitKFit.
virtual void event() override
Event processor.
bool makeKMassPointingVertexMother(analysis::MassPointingVertexFitKFit &kv, Particle *p)
Update mother particle after mass-constrained vertex fit with additional pointing constraint using KF...
bool m_updateDaughters
flag for daughters update
ParticleVertexFitterModule()
Constructor.
std::string m_decayString
daughter particles selection
std::string m_listName
particle list name
std::vector< int > m_massConstraintList
PDG codes of the particles to be mass constraint (massfourC)
bool m_hasCovMatrix
flag for mother covariance matrix (PseudoFitter)
bool makeKVertexMother(analysis::VertexFitKFit &kv, Particle *p)
Update mother particle after unconstrained vertex fit using KFit.
bool redoTwoPhotonDaughterMassFit(Particle *postFit, const Particle *preFit, const analysis::VertexFitKFit &kv)
Combines preFit particle and vertex information from vertex fit kv to create new postFit particle.
bool makeKMassVertexMother(analysis::MassVertexFitKFit &kv, Particle *p)
Update mother particle after mass-constrained vertex fit using KFit.
bool makeKFourCMother(analysis::FourCFitKFit &kv, Particle *p)
Update mother particle after FourC fit using KFit.
bool fillFitParticles(const Particle *mother, std::vector< const Particle * > &fitChildren, std::vector< const Particle * > &twoPhotonChildren)
Fills valid particle's children (with valid error matrix) in the vector of Particles that will enter ...
bool doKFourCFit(Particle *p)
FourC fit using KFit.
ROOT::Math::XYZVector m_BeamSpotCenter
Beam spot position.
virtual void beginRun() override
Called when entering a new run.
bool doKRecoilMassFit(Particle *p)
RecoilMass fit using KFit.
DBObjPtr< BeamSpot > m_beamSpotDB
Beam spot database object.
bool doVertexFit(Particle *p)
Main steering routine.
std::string m_vertexFitter
Vertex Fitter name.
bool doRaveFit(Particle *mother)
Fit using Rave.
bool makeKRecoilMassMother(analysis::RecoilMassKFit &kf, Particle *p)
Update mother particle after RecoilMass fit using KFit.
bool doKMassFit(Particle *p)
Mass fit using KFit.
double m_recoilMass
recoil mass for constraint
double m_confidenceLevel
required fit confidence level
bool doKMassFourCFit(Particle *p)
MassFourC fit using KFit.
DecayDescriptor m_decaydescriptor
Decay descriptor of decays to look for.
bool fillNotFitParticles(const Particle *mother, std::vector< const Particle * > ¬FitChildren, const std::vector< const Particle * > &fitChildren)
Fills valid particle's children (with valid error matrix) in the vector of Particles that will not en...
void findConstraintBoost(double cut)
calculate iptube constraint (quasi cylinder along boost direction) for RAVE fit
double m_Bfield
magnetic field from data base
bool addChildofParticletoKFit(analysis::FourCFitKFit &kv, const Particle *particle)
Adds given particle's child to the FourCFitKFit.
double getChi2TracksLBoost(const analysis::VertexFitKFit &kv)
calculate the chi2 using only lboost information of tracks
double m_smearing
smearing width applied to IP tube
std::string m_fitType
type of the kinematic fit
void addIPProfileToKFit(analysis::VertexFitKFit &kv)
Adds IPProfile constraint to the vertex fit using KFit.
StoreObjPtr< ParticleList > m_plist
particle list
bool allSelectedDaughters(const Particle *mother, const std::vector< const Particle * > &tracksVertex)
check if all the Daughters (o grand-daughters) are selected for the vertex fit
Class to store reconstructed particles.
void writeExtraInfo(const std::string &name, const double value)
Sets the user defined extraInfo.
bool hasExtraInfo(const std::string &name) const
Return whether the extra info with the given name is set.
const V0 * getV0() const
Returns the pointer to the V0 object that was used to create this Particle (if ParticleType == c_V0).
int getPDGCode(void) const
Returns PDG code.
int getProperty() const
Returns particle property as a bit pattern The values are defined in the PropertyFlags enum and descr...
unsigned getNDaughters(void) const
Returns number of daughter particles.
std::vector< Belle2::Particle * > getDaughters() const
Returns a vector of pointers to daughter particles.
double getPDGMass(void) const
Returns uncertainty on the invariant mass (requires valid momentum error matrix)
ROOT::Math::PxPyPzEVector get4Vector() const
Returns Lorentz vector.
void addExtraInfo(const std::string &name, double value)
Sets the user-defined data of given name to the given value.
void set4Vector(const ROOT::Math::PxPyPzEVector &p4)
Sets Lorentz vector.
void updateMomentum(const ROOT::Math::PxPyPzEVector &p4, const ROOT::Math::XYZVector &vertex, const TMatrixFSym &errMatrix, double pValue)
Sets Lorentz vector, position, 7x7 error matrix and p-value.
TMatrixFSym getMomentumVertexErrorMatrix() const
Returns 7x7 error matrix.
@ c_IsUnspecified
Ordinary particles.
const Particle * getDaughter(unsigned i) const
Returns a pointer to the i-th daughter particle.
double getExtraInfo(const std::string &name) const
Return given value if set.
double getFittedVertexX() const
Get the X coordinate of the fitted vertex.
double getFittedVertexY() const
Get the Y coordinate of the fitted vertex.
double getFittedVertexZ() const
Get the Z coordinate of the fitted vertex.
ROOT::Math::XYZVector getFittedVertexPosition() const
Get the fitted vertex position.
FourCFitKFit is a derived class from KFitBase to perform 4 momentum-constraint kinematical fit.
enum KFitError::ECode setFourMomentum(const ROOT::Math::PxPyPzEVector &m)
Set an 4 Momentum for the FourC-constraint fit.
double getCHIsq(void) const override
Get a chi-square of the fit.
enum KFitError::ECode updateMother(Particle *mother)
Update mother particle.
enum KFitError::ECode doFit(void)
Perform a four momentum-constraint fit.
const CLHEP::HepSymMatrix getTrackError(const int id) const
Get an error matrix of the track.
const CLHEP::HepLorentzVector getTrackMomentum(const int id) const
Get a Lorentz vector of the track.
const HepPoint3D getTrackPosition(const int id) const
Get a position of the track.
virtual int getNDF(void) const
Get an NDF of the fit.
enum KFitError::ECode setMagneticField(const double mf)
Change a magnetic field from the default value KFitConst::kDefaultMagneticField.
const KFitTrack getTrack(const int id) const
Get a specified track object.
enum KFitError::ECode addParticle(const Particle *particle)
Add a particle to the fitter.
int getTrackCount(void) const
Get the number of added tracks.
ECode
ECode is a error code enumerate.
KFitTrack is a container of the track information (Lorentz vector, position, and error matrix),...
const CLHEP::HepSymMatrix getError(const int flag=KFitConst::kAfterFit) const
Get an error matrix of the track.
const HepPoint3D getPosition(const int flag=KFitConst::kAfterFit) const
Get a position of the track.
MassFitKFit is a derived class from KFitBase to perform mass-constraint kinematical fit.
enum KFitError::ECode setVertex(const HepPoint3D &v)
Set an initial vertex position for the mass-constraint fit.
enum KFitError::ECode updateMother(Particle *mother)
Update mother particle.
enum KFitError::ECode doFit(void)
Perform a mass-constraint fit.
enum KFitError::ECode setInvariantMass(const double m)
Set an invariant mass for the mass-constraint fit.
enum KFitError::ECode setVertexError(const CLHEP::HepSymMatrix &e)
Set an initial vertex error matrix for the mass-constraint fit.
const HepPoint3D getVertex(const int flag=KFitConst::kAfterFit) const
Get a vertex position.
MassFourCFitKFit is a derived class from KFitBase to perform mass and 4 momentum-constraint kinematic...
enum KFitError::ECode setFourMomentum(const ROOT::Math::PxPyPzEVector &m)
Set an 4 Momentum for the mass-four-constraint fit.
enum KFitError::ECode addMassConstraint(const double m, std::vector< unsigned > &childTrackId)
Set an invariant mass of daughter particle for the mass-four-momentum-constraint fit.
double getCHIsq(void) const override
Get a chi-square of the fit.
enum KFitError::ECode updateMother(Particle *mother)
Update mother particle.
enum KFitError::ECode doFit(void)
Perform a mass-four-momentum-constraint fit.
MassPointingVertexFitKFit is a derived class from KFitBase It performs a kinematical fit with three c...
enum KFitError::ECode updateMother(Particle *mother)
Update mother particle.
enum KFitError::ECode doFit(void)
Perform a mass-vertex-pointing constraint fit.
enum KFitError::ECode setInvariantMass(const double m)
Set an invariant mass for the mass-vertex-pointing constraint fit.
enum KFitError::ECode setProductionVertex(const HepPoint3D &v)
Set the production vertex of the particle.
const HepPoint3D getVertex(const int flag=KFitConst::kAfterFit) const
Get a vertex position.
MassVertexFitKFit is a derived class from KFitBase to perform mass-vertex-constraint kinematical fit.
enum KFitError::ECode setInitialVertex(const HepPoint3D &v)
Set an initial vertex point for the mass-vertex constraint fit.
enum KFitError::ECode updateMother(Particle *mother)
Update mother particle.
enum KFitError::ECode doFit(void)
Perform a mass-vertex-constraint fit.
enum KFitError::ECode setInvariantMass(const double m)
Set an invariant mass for the mass-vertex constraint fit.
const HepPoint3D getVertex(const int flag=KFitConst::kAfterFit) const
Get a vertex position.
The RaveKinematicVertexFitter class is part of the RaveInterface together with RaveSetup.
void updateMother()
update the mother particle
void addMother(const Particle *aMotherParticlePtr)
All daughters of the argument of this function will be used as input for the vertex fit.
ROOT::Math::XYZVector getPos()
get the position of the fitted vertex.
void addTrack(const Particle *aParticlePtr)
add a track (in the format of a Belle2::Particle) to set of tracks that should be fitted to a vertex
void setMother(const Particle *aMotherParticlePtr)
Set Mother particle for Vertex/momentum update.
int fit()
do the kinematic vertex fit with all tracks previously added with the addTrack or addMother function.
void setVertFit(bool isVertFit=true)
Set vertex fit: set false in case of mass fit only.
void setMassConstFit(bool isConstFit=true)
Set mass constrained fit
double getPValue()
get the p value of the fitted vertex.
TMatrixDSym getVertexErrorMatrix()
get the covariance matrix (3x3) of the of the fitted vertex position.
void updateDaughters()
update the Daughters particles
void unsetBeamSpot()
unset beam spot constraint
static void initialize(int verbosity=1, double MagneticField=1.5)
Set everything up so everything needed for vertex fitting is there.
static RaveSetup * getInstance()
get the pointer to the instance to get/set any of options stored in RaveSetup
void setBeamSpot(const ROOT::Math::XYZVector &beamSpot, const TMatrixDSym &beamSpotCov)
The beam spot position and covariance is known you can set it here so that and a vertex in the beam s...
void reset()
frees memory allocated by initialize().
The RaveVertexFitter class is part of the RaveInterface together with RaveSetup.
TMatrixDSym getCov(VecSize vertexId=0) const
get the covariance matrix (3x3) of the of the fitted vertex position.
int fit(std::string options="default")
do the vertex fit with all tracks previously added with the addTrack or addMother function.
ROOT::Math::XYZVector getPos(VecSize vertexId=0) const
get the position of the fitted vertex.
void addTrack(const Particle *const aParticlePtr)
add a track (in the format of a Belle2::Particle) to set of tracks that should be fitted to a vertex
double getPValue(VecSize vertexId=0) const
get the p value of the fitted vertex.
RecoilMassKFit is a derived class from KFitBase to perform a kinematical fit with a recoil mass const...
enum KFitError::ECode setFourMomentum(const ROOT::Math::PxPyPzEVector &m)
Set a recoil mass .
double getCHIsq(void) const override
Get a chi-square of the fit.
enum KFitError::ECode updateMother(Particle *mother)
Update mother particle.
enum KFitError::ECode setRecoilMass(const double m)
Set an invariant mass for the four momentum-constraint fit.
enum KFitError::ECode doFit(void)
Perform a recoil-mass constraint fit.
const HepPoint3D getVertex(const int flag=KFitConst::kAfterFit) const
Get a vertex position.
VertexFitKFit is a derived class from KFitBase to perform vertex-constraint kinematical fit.
enum KFitError::ECode setIpTubeProfile(const CLHEP::HepLorentzVector &p, const HepPoint3D &x, const CLHEP::HepSymMatrix &e, const double q)
Set a virtual IP-tube track for the vertex constraint fit.
enum KFitError::ECode setInitialVertex(const HepPoint3D &v)
Set an initial vertex point for the vertex-vertex constraint fit.
enum KFitError::ECode updateMother(Particle *mother)
Update mother particle.
const CLHEP::HepSymMatrix getVertexError(void) const
Get a fitted vertex error matrix.
enum KFitError::ECode doFit(void)
Perform a vertex-constraint fit.
enum KFitError::ECode setIpProfile(const HepPoint3D &ip, const CLHEP::HepSymMatrix &ipe)
Set an IP-ellipsoid shape for the vertex constraint fit.
const HepPoint3D getVertex(const int flag=KFitConst::kAfterFit) const
Get a vertex position.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
void copyDaughters(Particle *mother)
Function copies all (grand-)^n-daughter particles of the argument mother Particle.
Abstract base class for different kinds of events.
static const int kBeforeFit
Input parameter to specify before-fit when setting/getting a track attribute.