10 #include <analysis/modules/ParticleVertexFitter/ParticleVertexFitterModule.h>
13 #include <framework/gearbox/Unit.h>
14 #include <framework/gearbox/Const.h>
15 #include <framework/geometry/B2Vector3.h>
16 #include <framework/logging/Logger.h>
17 #include <framework/particledb/EvtGenDatabasePDG.h>
20 #include <analysis/dataobjects/Particle.h>
21 #include <analysis/dataobjects/Btube.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 <TRotation.h>
50 ParticleVertexFitterModule::ParticleVertexFitterModule() :
Module(),
60 "Confidence level to accept the fit. Particle candidates with "
61 "p-value less than confidenceLevel are removed from the particle "
62 "list. If set to -1, all candidates are kept; if set to 0, "
63 "the candidates failing the fit are removed.",
66 addParam(
"fitType",
m_fitType,
"type of the kinematic fit (vertex, massvertex, mass)",
string(
"vertex"));
68 "additional constraint on vertex: ipprofile, iptube, mother, iptubecut, pointing, btube",
70 addParam(
"decayString",
m_decayString,
"specifies which daughter particles are included in the kinematic fit",
string(
""));
75 "Type::[int]. List of daughter particles to mass constrain with int = pdg code. (only for MassFourCKFit)", {});
77 "Type::[string]. List of daughter particles to mass constrain with string = particle name. (only for MassFourCKFit)", {});
92 B2DEBUG(1,
"ParticleVertexFitterModule : magnetic field = " <<
m_Bfield);
100 TParticlePDG* particletemp = TDatabasePDG::Instance()->GetParticle((containedParticle).c_str());
107 B2INFO(
"ParticleVertexFitter: Using specified decay string: " <<
m_decayString);
109 B2INFO(
"ParticleVertexFitter: Additional " <<
m_withConstraint <<
" will be applied");
127 TMatrixDSym beamSpotCov(3);
143 std::vector<unsigned int> toRemove;
144 unsigned int n =
m_plist->getListSize();
145 for (
unsigned i = 0; i < n; i++) {
150 else B2ERROR(
"Daughters update works only when all daughters are selected. Daughters will not be updated");
158 TMatrixFSym mother_errMatrix(7);
160 for (
int k = 0; k < 7; k++) {
161 for (
int j = 0; j < 7; j++) {
162 if (mother_errMatrix[k][j] > 0) {
187 m_plist->removeParticles(toRemove);
199 B2FATAL(
"ParticleVertexFitter: No magnetic field");
209 B2FATAL(
"ParticleVertexFitter: " <<
m_withConstraint <<
" ***invalid Constraint ");
216 B2FATAL(
"ParticleVertexFitter: KFit does not support yet selection of daughters via decay string except for vertex fit!");
232 B2FATAL(
"ParticleVertexFitter: Invalid options - mass-constrained fit using KFit does not work with iptube or ipprofile constraint.");
243 B2FATAL(
"ParticleVertexFitter: Invalid options - mass fit using KFit does not work with iptube or ipprofile constraint.");
252 B2FATAL(
"ParticleVertexFitter: Invalid options - four C fit using KFit does not work with iptube or ipprofile constraint.");
261 B2FATAL(
"ParticleVertexFitter: Invalid options - four C fit using KFit does not work with iptube or ipprofile constraint.");
270 B2FATAL(
"ParticleVertexFitter: Invalid options - recoil mass fit using KFit does not work with iptube or ipprofile constraint.");
283 B2FATAL(
"ParticleVertexFitter: " <<
m_fitType <<
" ***invalid fit type for the vertex fitter ");
290 }
catch (
const rave::CheckedFloatException&) {
291 B2ERROR(
"Invalid inputs (nan/inf)?");
298 B2FATAL(
"ParticleVertexFitter: " <<
m_vertexFitter <<
" ***invalid vertex fitter ");
300 if (!ok)
return false;
310 std::vector<const Particle*>& twoPhotonChildren)
314 for (
unsigned ichild = 0; ichild < mother->
getNDaughters(); ichild++) {
318 if (mother->
getProperty() == Particle::PropertyFlags::c_IsUnspecified and child->
getPValue() < 0) {
321 fitChildren.push_back(child);
327 auto itr = fitChildren.begin();
328 while (itr != fitChildren.end()) {
332 B2WARNING(
"Daughter with PDG code " << child->
getPDGCode() <<
" does not have a valid error matrix.");
335 bool isTwoPhotonParticle =
false;
341 isTwoPhotonParticle =
true;
346 if (isTwoPhotonParticle) {
348 twoPhotonChildren.push_back(child);
349 itr = fitChildren.erase(itr);
359 const std::vector<const Particle*>& fitChildren)
361 if (fitChildren.empty())
362 B2WARNING(
"[ParticleVertexFitterModule::fillNotFitParticles] fitChildren is empty! Please call fillFitParticles firstly");
363 if (!notFitChildren.empty())
364 B2WARNING(
"[ParticleVertexFitterModule::fillNotFitParticles] notFitChildren is NOT empty!"
365 <<
" The function should be called only once");
371 std::function<bool(
const Particle*)> funcCheckInFit =
372 [&funcCheckInFit, ¬FitChildren, fitChildren](
const Particle * part) {
376 if (std::find(fitChildren.begin(), fitChildren.end(), part) != fitChildren.end())
380 if (part->getNDaughters() == 0)
385 bool isAnyChildrenInFit =
false;
386 vector<const Particle*> notFitChildren_tmp;
387 for (
unsigned ichild = 0; ichild < part->getNDaughters(); ichild++) {
390 bool isChildrenInFit = funcCheckInFit(child);
391 isAnyChildrenInFit = isChildrenInFit or isAnyChildrenInFit;
394 if (!isChildrenInFit)
395 notFitChildren_tmp.push_back(child);
399 if (isAnyChildrenInFit)
400 notFitChildren.insert(notFitChildren.end(), notFitChildren_tmp.begin(), notFitChildren_tmp.end());
404 return isAnyChildrenInFit;
409 for (
unsigned ichild = 0; ichild < mother->
getNDaughters(); ichild++) {
411 bool isGivenParticleOrAnyChildrenInFit = funcCheckInFit(child);
412 if (!isGivenParticleOrAnyChildrenInFit)
413 notFitChildren.push_back(child);
436 TMatrixFSym errMatrix(3);
437 for (
int i = 0; i < 3; i++)
438 for (
int j = 0; j < 3; j++)
439 errMatrix(i, j) = posErrorMatrix[i][j];
441 g1ErrMatrix.SetSub(4, errMatrix);
442 g2ErrMatrix.SetSub(4, errMatrix);
458 int err = km.
doFit();
476 std::vector<const Particle*> fitChildren;
477 std::vector<const Particle*> twoPhotonChildren;
478 bool validChildren =
fillFitParticles(mother, fitChildren, twoPhotonChildren);
483 std::vector<const Particle*> notFitChildren;
487 if (twoPhotonChildren.size() > 1) {
488 B2FATAL(
"[ParticleVertexFitterModule::doKVertexFit] Vertex fit using KFit does not support fit with multiple particles decaying to two photons like pi0 (yet).");
491 if ((fitChildren.size() < 2 && !ipTubeConstraint) || fitChildren.size() < 1) {
492 B2WARNING(
"[ParticleVertexFitterModule::doKVertexFit] Number of particles with valid error matrix entering the vertex fit using KFit is too low.");
500 for (
auto& child : fitChildren)
503 if (ipProfileConstraint)
506 if (ipTubeConstraint)
510 int err = kv.
doFit();
520 if (twoPhotonChildren.size() == 0)
523 else if (twoPhotonChildren.size() == 1) {
529 const Particle* twoPhotonDaughter = twoPhotonChildren[0];
539 for (
auto& child : fitChildren)
544 if (ipProfileConstraint)
556 ROOT::Math::PxPyPzEVector total4Vector(mother->
get4Vector());
557 for (
auto& child : notFitChildren)
558 total4Vector += child->get4Vector();
568 std::vector<const Particle*> fitChildren;
569 std::vector<const Particle*> twoPhotonChildren;
570 bool validChildren =
fillFitParticles(mother, fitChildren, twoPhotonChildren);
575 if (twoPhotonChildren.size() > 1) {
576 B2FATAL(
"[ParticleVertexFitterModule::doKVertexFit] MassVertex fit using KFit does not support fit with multiple particles decaying to two photons like pi0 (yet).");
579 if (fitChildren.size() < 2) {
580 B2WARNING(
"[ParticleVertexFitterModule::doKVertexFit] Number of particles with valid error matrix entering the vertex fit using KFit is less than 2.");
585 if (twoPhotonChildren.size() == 0) {
590 for (
auto child : fitChildren)
594 int err = kmv.
doFit();
600 }
else if (twoPhotonChildren.size() == 1) {
609 for (
auto child : fitChildren)
613 int err = kv.
doFit();
617 const Particle* twoPhotonDaughter = twoPhotonChildren[0];
627 for (
auto child : fitChildren)
652 std::vector<const Particle*> fitChildren;
653 std::vector<const Particle*> twoPhotonChildren;
654 bool validChildren =
fillFitParticles(mother, fitChildren, twoPhotonChildren);
659 if (twoPhotonChildren.size() > 0) {
660 B2FATAL(
"[ParticleVertexFitterModule::doKMassPointingVertexFit] MassPointingVertex fit using KFit does not support fit with two-photon daughters (yet).");
663 if (fitChildren.size() < 2) {
664 B2WARNING(
"[ParticleVertexFitterModule::doKMassPointingVertexFit] Number of particles with valid error matrix entering the vertex fit using KFit is less than 2.");
673 for (
auto child : fitChildren)
677 HepPoint3D productionVertex(mother->
getExtraInfo(
"prodVertX"),
681 int err = kmpv.
doFit();
682 if (err != 0)
return false;
696 for (
unsigned ichild = 0; ichild < mother->
getNDaughters(); ichild++) {
699 if (child->
getPValue() < 0)
return false;
707 int err = km.
doFit();
709 if (err != 0)
return false;
723 for (
unsigned ichild = 0; ichild < mother->
getNDaughters(); ichild++) {
728 if (!err)
return false;
730 if (child->
getPValue() < 0)
return false;
740 int err = kf.
doFit();
742 if (err != 0)
return false;
756 for (
unsigned ichild = 0; ichild < mother->
getNDaughters(); ichild++) {
762 std::vector<unsigned> childId;
765 if (!err)
return false;
767 if (child->
getPValue() < 0)
return false;
776 int err = kf.
doFit();
778 if (err != 0)
return false;
790 for (
unsigned ichild = 0; ichild < mother->
getNDaughters(); ichild++) {
793 if (child->
getPValue() < 0)
return false;
805 int err = kf.
doFit();
807 if (err != 0)
return false;
825 std::vector<Particle*> daughters = mother->
getDaughters();
828 if (daughters.size() != track_count)
831 for (
unsigned iChild = 0; iChild < track_count; iChild++) {
832 daughters[iChild]->set4Vector(
834 daughters[iChild]->setVertex(
836 daughters[iChild]->setMomentumVertexErrorMatrix(
855 std::vector<Particle*> daughters = mother->
getDaughters();
858 if (daughters.size() != track_count)
861 for (
unsigned iChild = 0; iChild < track_count; iChild++) {
862 daughters[iChild]->set4Vector(
864 daughters[iChild]->setVertex(
866 daughters[iChild]->setMomentumVertexErrorMatrix(
887 std::vector<Particle*> daughters = mother->
getDaughters();
890 if (daughters.size() != track_count)
893 for (
unsigned iChild = 0; iChild < track_count; iChild++) {
894 daughters[iChild]->set4Vector(
896 daughters[iChild]->setVertex(
898 daughters[iChild]->setMomentumVertexErrorMatrix(
918 std::vector<Particle*> daughters = mother->
getDaughters();
921 if (daughters.size() != track_count)
924 for (
unsigned iChild = 0; iChild < track_count; iChild++) {
925 daughters[iChild]->set4Vector(
927 daughters[iChild]->setVertex(
929 daughters[iChild]->setMomentumVertexErrorMatrix(
951 std::vector<Particle*> daughters = mother->
getDaughters();
953 const unsigned nd = daughters.size();
955 std::vector<std::vector<unsigned>> pars;
956 std::vector<Particle*> allparticles;
957 for (
unsigned ichild = 0; ichild < nd; ichild++) {
959 std::vector<unsigned> pard;
960 if (daughter->getNDaughters() > 0) {
962 pars.push_back(pard);
963 allparticles.push_back(daughters[ichild]);
966 pars.push_back(pard);
967 allparticles.push_back(daughters[ichild]);
973 if (l != track_count)
976 for (
unsigned iDaug = 0; iDaug < allparticles.size(); iDaug++) {
977 ROOT::Math::PxPyPzEVector childMoms;
978 ROOT::Math::XYZVector childPoss;
979 TMatrixFSym childErrMatrixs(7);
980 for (
unsigned int iChild : pars[iDaug]) {
981 childMoms = childMoms +
982 CLHEPToROOT::getLorentzVector(
984 childPoss = childPoss +
985 CLHEPToROOT::getXYZVector(
987 TMatrixFSym childErrMatrix =
989 childErrMatrixs = childErrMatrixs + childErrMatrix;
991 allparticles[iDaug]->set4Vector(childMoms);
992 allparticles[iDaug]->setVertex(childPoss);
993 allparticles[iDaug]->setMomentumVertexErrorMatrix(childErrMatrixs);
1013 std::vector<Particle*> daughters = mother->
getDaughters();
1015 const unsigned nd = daughters.size();
1017 std::vector<std::vector<unsigned>> pars;
1018 std::vector<Particle*> allparticles;
1019 for (
unsigned ichild = 0; ichild < nd; ichild++) {
1021 std::vector<unsigned> pard;
1022 if (daughter->getNDaughters() > 0) {
1024 pars.push_back(pard);
1025 allparticles.push_back(daughters[ichild]);
1028 pars.push_back(pard);
1029 allparticles.push_back(daughters[ichild]);
1035 if (l != track_count)
1038 for (
unsigned iDaug = 0; iDaug < allparticles.size(); iDaug++) {
1039 ROOT::Math::PxPyPzEVector childMoms;
1040 ROOT::Math::XYZVector childPoss;
1041 TMatrixFSym childErrMatrixs(7);
1042 for (
unsigned int iChild : pars[iDaug]) {
1043 childMoms = childMoms +
1044 CLHEPToROOT::getLorentzVector(
1046 childPoss = childPoss +
1047 CLHEPToROOT::getXYZVector(
1049 TMatrixFSym childErrMatrix =
1051 childErrMatrixs = childErrMatrixs + childErrMatrix;
1053 allparticles[iDaug]->set4Vector(childMoms);
1054 allparticles[iDaug]->setVertex(childPoss);
1055 allparticles[iDaug]->setMomentumVertexErrorMatrix(childErrMatrixs);
1075 std::vector<Particle*> daughters = mother->
getDaughters();
1078 if (daughters.size() != track_count)
1081 for (
unsigned iChild = 0; iChild < track_count; iChild++) {
1082 daughters[iChild]->set4Vector(
1084 daughters[iChild]->setVertex(
1086 daughters[iChild]->setMomentumVertexErrorMatrix(
1096 std::vector<unsigned>& parm, std::vector<Particle*>& allparticles,
const Particle* daughter)
1098 std::vector <Belle2::Particle*> childs = daughter->getDaughters();
1099 for (
unsigned ichild = 0; ichild < daughter->getNDaughters(); ichild++) {
1100 const Particle* child = daughter->getDaughter(ichild);
1101 std::vector<unsigned> pard;
1104 parm.insert(parm.end(), pard.begin(), pard.end());
1105 pars.push_back(pard);
1106 allparticles.push_back(childs[ichild]);
1110 pars.push_back(pard);
1111 allparticles.push_back(childs[ichild]);
1137 for (
auto& itrack : tracksVertex) {
1138 if (itrack != mother) rf.
addTrack(itrack);
1144 bool mothSel =
false;
1146 for (
unsigned itrack = 0; itrack < tracksVertex.size(); itrack++) {
1147 if (tracksVertex[itrack] != mother) {
1148 rsf.
addTrack(tracksVertex[itrack]);
1149 B2DEBUG(1,
"ParticleVertexFitterModule: Adding particle " << tracksName[itrack] <<
" to vertex fit ");
1152 if (tracksVertex[itrack] == mother) mothSel =
true;
1157 bool mothIPfit =
false;
1158 if (tracksVertex.size() == 1 && mothSel ==
true &&
m_withConstraint !=
"" && nTrk == 0) {
1160 if (tracksVertex[0] != mother)
1161 B2FATAL(
"ParticleVertexFitterModule: FATAL Error in IP constrained mother fit");
1167 ROOT::Math::XYZVector pos;
1168 TMatrixDSym RerrMatrix(3);
1174 for (
auto& itrack : tracksVertex) {
1176 nvert = rsg.
fit(
"kalman");
1179 RerrMatrix = rsg.
getCov(0);
1181 ROOT::Math::PxPyPzEVector mom(mother->
get4Vector());
1182 TMatrixDSym errMatrix(7);
1183 for (
int i = 0; i < 7; i++) {
1184 for (
int j = 0; j < 7; j++) {
1185 if (i > 3 && j > 3) {errMatrix[i][j] = RerrMatrix[i - 4][j - 4];}
1186 else {errMatrix[i][j] = 0;}
1206 }
else {
return false;}
1216 ROOT::Math::PxPyPzEVector mom(mother->
get4Vector());
1217 TMatrixDSym errMatrix(7);
1218 for (
int i = 0; i < 7; i++) {
1219 for (
int j = 0; j < 7; j++) {
1220 if (i > 3 && j > 3) {errMatrix[i][j] = RerrMatrix[i - 4][j - 4];}
1221 else {errMatrix[i][j] = 0;}
1225 }
else {
return false;}
1228 if (mothSel && nTrk > 1) {
1231 int nKfit = rf.
fit();
1235 if (nKfit > 0) {
return true;}
1244 int nVert = rf.
fit();
1247 if (nVert != 1)
return false;
1254 int nVert = rf.
fit();
1256 if (nVert != 1)
return false;
1261 int nVert = rf.
fit();
1264 if (nVert != 1)
return false;
1267 B2FATAL(
"fitType : " <<
m_fitType <<
" ***invalid fit type ");
1274 const std::vector<const Particle*>& tracksVertex)
1283 for (
auto& vi : tracksVertex) {
1285 nNotIncluded = nNotIncluded - 1;
1293 if (nNotIncluded == 0) isAll =
true;
1299 for (
unsigned ichild = 0; ichild < particle->
getNDaughters(); ichild++) {
1303 if (child->
getPValue() < 0)
return false;
1312 std::vector<unsigned>& particleId)
1314 for (
unsigned ichild = 0; ichild < particle->
getNDaughters(); ichild++) {
1319 std::vector<unsigned> childId;
1322 particleId.insert(particleId.end(), childId.begin(), childId.end());
1324 if (child->
getPValue() < 0)
return false;
1334 HepPoint3D pos(0.0, 0.0, 0.0);
1335 CLHEP::HepSymMatrix covMatrix(3, 0);
1337 for (
int i = 0; i < 3; i++) {
1339 for (
int j = 0; j < 3; j++) {
1349 CLHEP::HepSymMatrix err(7, 0);
1351 for (
int i = 0; i < 3; i++) {
1352 for (
int j = 0; j < 3; j++) {
1361 ROOTToCLHEP::getHepLorentzVector(iptube_mom),
1374 TMatrixDSym beamSpotCov =
m_beamSpotDB->getCovVertex();
1375 beamSpotCov(2, 2) = cut * cut;
1376 double thetab = boostDir.
Theta();
1377 double phib = boostDir.
Phi();
1379 double stb = TMath::Sin(thetab);
1380 double ctb = TMath::Cos(thetab);
1381 double spb = TMath::Sin(phib);
1382 double cpb = TMath::Cos(phib);
1385 TMatrix rz(3, 3); rz(2, 2) = 1;
1386 rz(0, 0) = cpb; rz(0, 1) = spb;
1387 rz(1, 0) = -1 * spb; rz(1, 1) = cpb;
1389 TMatrix ry(3, 3); ry(1, 1) = 1;
1390 ry(0, 0) = ctb; ry(0, 2) = -1 * stb;
1391 ry(2, 0) = stb; ry(2, 2) = ctb;
1393 TMatrix r(3, 3); r.Mult(rz, ry);
1394 TMatrix rt(3, 3); rt.Transpose(r);
1396 TMatrix TubePart(3, 3); TubePart.Mult(rt, beamSpotCov);
1397 TMatrix Tube(3, 3); Tube.Mult(TubePart, r);
1406 TMatrixDSym beamSpotCov =
m_beamSpotDB->getCovVertex();
1407 for (
int i = 0; i < 3; i++)
1408 beamSpotCov(i, i) += width * width;
1415 double chi2TrackL = 0;
1417 for (
int iTrack = 0; iTrack < kv.
getTrackCount(); iTrack++) {
1429 TVectorD boostD(0, 6, 0., 0., 0., 0., boost3.
X(), boost3.
Y(), boost3.
Z(),
"END");
1431 double dLBoost = dPos.
Dot(boost3);
1433 chi2TrackL += TMath::Power(dLBoost, 2) / err.Similarity(boostD);
DataType Phi() const
The azimuth angle.
DataType Z() const
access variable Z (= .at(2) without boundary check)
DataType Theta() const
The polar angle.
DataType X() const
access variable X (= .at(0) without boundary check)
DataType Y() const
access variable Y (= .at(1) without boundary check)
B2Vector3< DataType > Unit() const
Unit vector parallel to this.
DataType Dot(const B2Vector3< DataType > &p) const
Scalar product.
void SetXYZ(DataType x, DataType y, DataType z)
set all coordinates using data type
static B2Vector3D getFieldInTesla(const B2Vector3D &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 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.
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
std::string m_decayString
daughter particles selection
std::vector< std::string > m_massConstraintListParticlename
Name of the particles to be mass constraint (massfourC)
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.
B2Vector3D m_BeamSpotCenter
Beam spot position.
virtual void beginRun() override
Called when entering a new run.
bool doKRecoilMassFit(Particle *p)
RecoilMass 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.
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.
TMatrixFSym getVertexErrorMatrix() const
Returns the 3x3 position error sub-matrix.
void writeExtraInfo(const std::string &name, const double value)
Sets the user defined extraInfo.
double getPValue() const
Returns chi^2 probability of fit if done or -1.
ROOT::Math::XYZVector getVertex() const
Returns vertex position (POCA for charged, IP for neutral FS particles)
bool hasExtraInfo(const std::string &name) const
Return whether the extra info with the given name is set.
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 setPValue(double pValue)
Sets chi^2 probability of fit.
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.
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.
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
TO * getRelatedTo(const std::string &name="", const std::string &namedRelation="") const
Get the object to which this object has a relation.
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.
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.
MassVertexFitKFit is a derived class from KFitBase to perform mass-vertex-constraint kinematical 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.
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 B2Vector3D &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.
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
B2Vector3D getPos(VecSize vertexId=0) const
get the position of the fitted 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.
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 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.
B2Vector3< double > B2Vector3D
typedef for common usage with double
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.