9 #include <analysis/modules/TagVertex/TagVertexModule.h> 
   15 #include <framework/gearbox/Unit.h> 
   16 #include <framework/gearbox/Const.h> 
   17 #include <framework/logging/Logger.h> 
   20 #include <analysis/dataobjects/RestOfEvent.h> 
   21 #include <analysis/dataobjects/FlavorTaggerInfo.h> 
   24 #include <analysis/utility/PCmsLabTransform.h> 
   25 #include <analysis/variables/TrackVariables.h> 
   26 #include <analysis/utility/ParticleCopy.h> 
   27 #include <analysis/utility/CLHEPToROOT.h> 
   28 #include <analysis/utility/ROOTToCLHEP.h> 
   29 #include <analysis/utility/DistanceTools.h> 
   30 #include <analysis/utility/RotationTools.h> 
   33 #include <analysis/VertexFitting/KFit/VertexFitKFit.h> 
   36 #include <mdst/dataobjects/HitPatternVXD.h> 
   39 #include <framework/geometry/BFieldManager.h> 
   42 #include <TRotation.h> 
   43 #include <Math/Vector4D.h> 
   49 static const double    realNaN = std::numeric_limits<double>::quiet_NaN();
 
   51 static const B2Vector3D  vecNaN(realNaN, realNaN, realNaN);
 
   53 static const TMatrixDSym matNaN(3, (
double [])
 
   55   realNaN, realNaN, realNaN,
 
   56            realNaN, realNaN, realNaN,
 
   57            realNaN, realNaN, realNaN
 
   61 using RotationTools::rotateTensor;
 
   62 using RotationTools::rotateTensorInv;
 
   63 using RotationTools::toSymMatrix;
 
   64 using RotationTools::toVec;
 
   65 using RotationTools::getUnitOrthogonal;
 
   76 TagVertexModule::TagVertexModule() : 
Module(),
 
   77   m_Bfield(0), m_fitTruthStatus(0), m_rollbackStatus(0), m_fitPval(0), m_mcTagLifeTime(-1), m_mcPDG(0), m_mcLifeTimeReco(-1),
 
   78   m_deltaT(0), m_deltaTErr(0), m_mcDeltaTau(0), m_mcDeltaT(0),
 
   79   m_shiftZ(0), m_FitType(0), m_tagVl(0),
 
   80   m_truthTagVl(0), m_tagVlErr(0), m_tagVol(0), m_truthTagVol(0), m_tagVolErr(0), m_tagVNDF(0), m_tagVChi2(0), m_tagVChi2IP(0),
 
   89            "required confidence level of fit to keep particles in the list. Note that even with confidenceLevel == 0.0, errors during the fit might discard Particles in the list. confidenceLevel = -1 if an error occurs during the fit",
 
   92            "'': no MC association. breco: use standard Breco MC association. internal: use internal MC association", 
string(
"breco"));
 
   94            "Choose the type of the constraint: noConstraint, IP (tag tracks constrained to be within the beam spot), tube (long tube along the BTag line of flight, only for fully reconstruced B rec), boost (long tube along the Upsilon(4S) boost direction), (breco)",
 
   97            "Choose how to reconstruct the tracks on the tag side: standard, standard_PXD",
 
   98            string(
"standard_PXD"));
 
  102            "TRUE when requesting MC Information from the tracks performing the vertex fit", 
false);
 
  104            "Minimum number of PXD hits for a track to be used in the vertex fit", 0);
 
  106            "Fitter used for the tag vertex fit: Rave or KFit", 
string(
"Rave"));
 
  108            "Use the true track parameters in the vertex fit", 
false);
 
  110            "Use rolled back non-primary tracks", 
false);
 
  119   B2INFO(
"TagVertexModule : magnetic field = " << 
m_Bfield);
 
  133     B2FATAL(
"TagVertexModule: invalid fitting algorithm (must be set to either Rave or KFit).");
 
  135     B2FATAL(
"TagVertexModule: invalid fitting option (useRollBack and useTruthInFit cannot be simultaneously set to true).");
 
  138     B2FATAL(
"TagVertexModule : the singleTrack option is temporarily broken.");
 
  150     B2ERROR(
"TagVertexModule: ParticleList " << 
m_listName << 
" not found");
 
  157   std::vector<unsigned int> toRemove;
 
  159   for (
unsigned i = 0; i < 
m_plist->getListSize(); ++i) {
 
  236   m_plist->removeParticles(toRemove);
 
  263     B2ERROR(
"TagVertex: No magnetic field");
 
  276   double bg = beta / sqrt(1 - beta * beta);
 
  279   double cut = 8.717575e-02 * bg;
 
  280   m_shiftZ = 4.184436e+02 * bg *  0.0001;
 
  291     B2ERROR(
"TagVertex: Invalid constraintType selected");
 
  296     B2ERROR(
"TagVertex: No correct fit constraint");
 
  305   double minPVal = (
m_fitAlgo != 
"KFit") ? 0.001 : 0.;
 
  343   if (Breco->
getPValue() < 0.) 
return make_pair(vecNaN, matNaN);
 
  345   TMatrixDSym beamSpotCov(3);
 
  355   TMatrixDSym PerrMatrix(7);
 
  357   for (
int i = 0; i < 3; ++i) {
 
  358     for (
int j = 0; j < 3; ++j) {
 
  360         PerrMatrix(i, j) = (beamSpotCov(i, j) + TerrMatrix(i, j)) * pmag / xmag;
 
  362         PerrMatrix(i, j) = TerrMatrix(i, j);
 
  364       PerrMatrix(i + 4, j + 4) = TerrMatrix(i + 4, j + 4);
 
  368   PerrMatrix(3, 3) = 0.;
 
  376   if (BRecoRes->
getPValue() < 0) 
return make_pair(vecNaN, matNaN); 
 
  385   ROOT::Math::PxPyPzMVector pBrecEstimate(BvertDiff.x(), BvertDiff.y(), BvertDiff.z(), Breco->
getPDGMass());
 
  387   pBtagEstimate.SetPxPyPzE(-pBtagEstimate.px(), -pBtagEstimate.py(), -pBtagEstimate.pz(), pBtagEstimate.E());
 
  391   TMatrixD TubeZ = rotateTensorInv(pBrecEstimate.Vect(), errFinal);
 
  393   TubeZ(2, 2) = cut * cut;
 
  394   TubeZ(2, 0) = 0; TubeZ(0, 2) = 0;
 
  395   TubeZ(2, 1) = 0; TubeZ(1, 2) = 0;
 
  399   TMatrixD Tube = rotateTensor(
B2Vector3D(pBtagEstimate.Vect()), TubeZ);
 
  409     B2WARNING(
"In TagVertexModule::findConstraintBTube: cannot get a proper vertex for BReco. BTube constraint replaced by Boost.");
 
  417   if (tubecreatorBCopy->
getPValue() < 0) 
return make_pair(vecNaN, matNaN); 
 
  421   ROOT::Math::PxPyPzEVector pBrec = tubecreatorBCopy->
get4Vector();
 
  432   pBtag.SetPxPyPzE(-pBtag.px(), -pBtag.py(), -pBtag.pz(), pBtag.E());
 
  444     B2DEBUG(10, 
"Brec direction after fit: " << 
printVector(
float(1. / tubecreatorBCopy->
getP()) * tubecreatorBCopy->
getMomentum()));
 
  449     B2DEBUG(10, 
"Brec PV covariance: " << 
printMatrix(pv));
 
  450     B2DEBUG(10, 
"BTag direction: " << 
printVector((1. / pBtag.P())*pBtag.Vect()));
 
  454   TMatrixD longerror(3, 3); longerror(2, 2) = cut * cut;
 
  458   TMatrixD longerrorRotated = rotateTensor(
B2Vector3D(pBtag.Vect()), longerror);
 
  461   TMatrixD pvNew = TMatrixD(pv) + longerrorRotated;
 
  464   ROOT::Math::XYZVector constraintCenter = tubecreatorBCopy->
getVertex();
 
  475     B2DEBUG(10, 
"IPTube covariance: " << 
printMatrix(pvNew));
 
  486   return make_pair(
B2Vector3D(constraintCenter), toSymMatrix(pvNew));
 
  492   TMatrixD longerror(3, 3); longerror(2, 2) = cut * cut;
 
  494   TMatrixD longerrorRotated = rotateTensor(boostDir, longerror);
 
  498   TMatrixD Tube = TMatrixD(beamSpotCov) + longerrorRotated;
 
  504   if (shiftAlongBoost > -1000) {
 
  505     constraintCenter +=  shiftAlongBoost * boostDir;
 
  508   return make_pair(constraintCenter,   toSymMatrix(Tube));
 
  512 static double getProperLifeTime(
const MCParticle* mc)
 
  514   double beta = mc->getMomentum().Mag() / mc->getEnergy();
 
  515   return 1e3 * mc->getLifetime() * sqrt(1 - pow(beta, 2));
 
  521   vector<const MCParticle*> mcBs;
 
  523     if (abs(mc.getPDG()) == abs(Breco->
getPDGCode()))
 
  527   if (mcBs.size() < 2) 
return;
 
  529   if (mcBs.size() > 2) {
 
  530     B2WARNING(
"TagVertexModule:: Too many Bs found in MC");
 
  539   if (!isReco(mcBs[0]) && !isReco(mcBs[1])) {
 
  544   if (!isReco(mcBs[0]) && isReco(mcBs[1]))
 
  545     swap(mcBs[0], mcBs[1]);
 
  548   if (isReco(mcBs[0]) && isReco(mcBs[1])) {
 
  552       swap(mcBs[0], mcBs[1]);
 
  557   m_mcTagV = mcBs[1]->getDecayVertex();
 
  566   bool isDecMode = 
true;
 
  568   const std::vector<Belle2::Particle*> recDau = Breco->
getDaughters();
 
  569   const std::vector<Belle2::MCParticle*> genDau = Bgen->
getDaughters();
 
  571   if (recDau.size() > 0 && genDau.size() > 0) {
 
  572     for (
auto dauRec : recDau) {
 
  574       for (
auto dauGen : genDau) {
 
  575         if (dauGen->getPDG() == dauRec->getPDGCode())
 
  578       if (!isDau) isDecMode = 
false;
 
  581     if (recDau.size() == 0) { 
 
  583     } 
else {isDecMode = 
false;}
 
  595   std::vector<const Particle*> fitParticles;
 
  597   if (!roe) 
return fitParticles;
 
  600   if (ROEParticles.size() == 0) 
return fitParticles;
 
  602   for (
auto& ROEParticle : ROEParticles) {
 
  603     HitPatternVXD roeTrackPattern = ROEParticle->getTrackFitResult()->getHitPatternVXD();
 
  606       fitParticles.push_back(ROEParticle);
 
  613     double massWindowWidth)
 const 
  615   vector<ParticleAndWeight> particleAndWeights;
 
  619   particleAndWeight.
weight = -1111.;
 
  622   for (
unsigned i = 0; i < tagParticles.size(); ++i) {
 
  623     const Particle* particle1 = tagParticles.at(i);
 
  624     if (!particle1) 
continue;
 
  625     ROOT::Math::PxPyPzEVector mom1 = particle1->
get4Vector();
 
  626     if (!isfinite(mom1.mag2())) 
continue;
 
  629     bool isKsDau = 
false;
 
  630     for (
unsigned j = 0; j < tagParticles.size(); ++j) {
 
  631       if (i == j) 
continue;
 
  632       const Particle* particle2 = tagParticles.at(j);
 
  633       if (!particle2) 
continue;
 
  634       ROOT::Math::PxPyPzEVector mom2 = particle2->
get4Vector();
 
  635       if (!isfinite(mom2.mag2())) 
continue;
 
  636       double mass = (mom1 + mom2).M();
 
  643     if (isKsDau) 
continue;
 
  645     particleAndWeight.
particle = particle1;
 
  650     particleAndWeights.push_back(particleAndWeight);
 
  654   return particleAndWeights;
 
  666   unsigned n = particleAndWeights.size();
 
  667   sort(particleAndWeights.begin(), particleAndWeights.end(),
 
  674   for (
unsigned i = 0; i < n; ++i) {
 
  707   for (
const auto& pw : particleAndWeights) {
 
  722         rFit.
addTrack(pw.particle->getTrackFitResult());
 
  724     } 
catch (
const rave::CheckedFloatException&) {
 
  725       B2ERROR(
"Exception caught in TagVertexModule::makeGeneralFitRave(): Invalid inputs (nan/inf)?");
 
  734     isGoodFit = rFit.
fit(
"avf");
 
  736     if (isGoodFit < 1) 
return false;
 
  737   } 
catch (
const rave::CheckedFloatException&) {
 
  738     B2ERROR(
"Exception caught in TagVertexModule::makeGeneralFitRave(): Invalid inputs (nan/inf)?");
 
  744   for (
unsigned int i(0); i < particleAndWeights.size() && isGoodFit >= 1; ++i)
 
  745     particleAndWeights.at(i).weight = rFit.
getWeight(i);
 
  771       CLHEP::HepSymMatrix err(7, 0);
 
  773       err.sub(5, ROOTToCLHEP::getHepSymMatrix(
m_pvCov));
 
  774       kFit.setIpTubeProfile(
 
  788   int nTracksAdded = 0;
 
  789   for (
auto& pawi : particleAndWeights) {
 
  792       if (pawi.mcParticle) {
 
  793         addedOK = kFit.addTrack(
 
  794                     ROOTToCLHEP::getHepLorentzVector(pawi.mcParticle->get4Vector()),
 
  795                     ROOTToCLHEP::getPoint3DFromB2Vector(
getTruePoca(pawi)),
 
  796                     ROOTToCLHEP::getHepSymMatrix(pawi.particle->getMomentumVertexErrorMatrix()),
 
  797                     pawi.particle->getCharge());
 
  802       if (pawi.mcParticle) {
 
  803         addedOK = kFit.addTrack(
 
  804                     ROOTToCLHEP::getHepLorentzVector(pawi.mcParticle->get4Vector()),
 
  806                     ROOTToCLHEP::getHepSymMatrix(pawi.particle->getMomentumVertexErrorMatrix()),
 
  807                     pawi.particle->getCharge());
 
  812       addedOK = kFit.addParticle(pawi.particle);
 
  819       B2WARNING(
"TagVertexModule::makeGeneralFitKFit: failed to add a track");
 
  825   if ((nTracksAdded < 2 && 
m_constraintType == 
"noConstraint") || nTracksAdded < 1)
 
  828   int isGoodFit = kFit.doFit();
 
  829   if (isGoodFit != 0) 
return false;
 
  836   fillTagVinfo(CLHEPToROOT::getXYZVector(kFit.getVertex()),
 
  837                CLHEPToROOT::getTMatrixDSym(kFit.getVertexError()));
 
  851   double bg = boost.
Mag() / sqrt(1 - boost.
Mag2());
 
  856   double dl = dVert.
Dot(boostDir);
 
  861   double MCdl = MCdVert.
Dot(boostDir);
 
  869   TVectorD bVec = toVec(boostDir);
 
  884   B2Vector3D oboost = getUnitOrthogonal(boostDir);
 
  885   TVectorD oVec = toVec(oboost);
 
  905   int nvert = rsg.
fit(fitType);
 
  920     B2ERROR(
"In TagVertexModule::getTrackWithTrueCoordinate: no MC particle set");
 
  939     B2ERROR(
"In TagVertexModule::getTruePoca: no MC particle set");
 
  964     B2ERROR(
"In TagVertexModule::getTruePoca: no MC particle set");
 
 1001   m_tagMomentum = ROOT::Math::PxPyPzEVector(realNaN, realNaN, realNaN, realNaN);
 
 1009   std::ostringstream oss;
 
 1011   oss << 
"(" << std::setw(w) << vec.x() << 
", " << std::setw(w) << vec.y() << 
", " << std::setw(w) << vec.z() << 
")" << std::endl;
 
 1018   std::ostringstream oss;
 
 1020   for (
int i = 0; i < mat.GetNrows(); ++i) {
 
 1021     for (
int j = 0; j < mat.GetNcols(); ++j) {
 
 1022       oss << std::setw(w) << mat(i, j) << 
" ";
 
 1032   std::ostringstream oss;
 
 1034   for (
int i = 0; i < mat.GetNrows(); ++i) {
 
 1035     for (
int j = 0; j < mat.GetNcols(); ++j) {
 
 1036       oss << std::setw(w) << mat(i, j) << 
" ";
 
DataType Z() const
access variable Z (= .at(2) without boundary check)
DataType y() const
access variable Y (= .at(1) without boundary check)
DataType z() const
access variable Z (= .at(2) without boundary check)
DataType Mag() const
The magnitude (rho in spherical coordinate system).
DataType x() const
access variable X (= .at(0) without boundary check)
DataType Mag2() const
The magnitude squared (rho^2 in spherical coordinate system).
B2Vector3< DataType > Unit() const
Unit vector parallel to this.
DataType Dot(const B2Vector3< DataType > &p) const
Scalar product.
static B2Vector3D getFieldInTesla(const B2Vector3D &pos)
return the magnetic field at a given position in Tesla.
static const double K0Mass
neutral kaon mass
static const double speedOfLight
[cm/ns]
Hit pattern of the VXD within a track.
unsigned short getNPXDHits() const
Get total number of hits in the PXD.
A Class to store the Monte Carlo particle information.
std::vector< Belle2::MCParticle * > getDaughters() const
Get vector of all daughter particles, empty vector if none.
ROOT::Math::XYZVector getProductionVertex() const
Return production vertex position.
TVector3 getMomentum() const
Return momentum.
ROOT::Math::PxPyPzEVector get4Vector() const
Return 4Vector of particle.
int getPDG() const
Return PDG code of particle.
void setDescription(const std::string &description)
Sets the description of the module.
Class to store reconstructed particles.
TMatrixFSym getVertexErrorMatrix() const
Returns the 3x3 position error sub-matrix.
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)
int getPDGCode(void) const
Returns PDG code.
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 setMomentumVertexErrorMatrix(const TMatrixFSym &errMatrix)
Sets 7x7 error matrix.
ROOT::Math::XYZVector getMomentum() const
Returns momentum vector.
void setPValue(double pValue)
Sets chi^2 probability of fit.
TMatrixFSym getMomentumVertexErrorMatrix() const
Returns 7x7 error matrix.
const TrackFitResult * getTrackFitResult() const
Returns the pointer to the TrackFitResult that was used to create this Particle (ParticleType == c_Tr...
double getMomentumMagnitude() const
Returns momentum magnitude.
double getP() const
Returns momentum magnitude (same as getMomentumMagnitude but with shorter name)
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
TO * getRelatedTo(const std::string &name="", const std::string &namedRelation="") const
Get the object to which this object has a relation.
This is a general purpose class for collecting reconstructed MDST data objects that are not used in r...
std::vector< const Particle * > getChargedParticles(const std::string &maskName=c_defaultMaskName, unsigned int pdg=0, bool unpackComposite=true) const
Get charged particles from ROE mask.
static constexpr const char * c_defaultMaskName
Default mask name.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Accessor to arrays stored in the data store.
bool registerRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut, const std::string &namedRelation="") const
Register a relation to the given StoreArray.
int m_fitTruthStatus
Store info about whether the fit was performed with the truth info 0 fit performed with measured para...
TMatrixDSym m_constraintCov
constraint to be used in the tag vertex fit
double m_truthTagVol
MC tagV component in the direction orthogonal to the boost.
std::vector< const Particle * > m_tagParticles
tracks of the rest of the event
double m_shiftZ
parameter for testing the systematic error from the IP measurement
double m_tagVl
tagV component in the boost direction
bool doVertexFit(const Particle *Breco)
central method for the tag side vertex fit
std::vector< const Particle * > getTagTracks_standardAlgorithm(const Particle *Breco, int nPXDHits) const
performs the fit using the standard algorithm - using all tracks in RoE The user can specify a reques...
double m_truthTagVl
MC tagV component in the boost direction
B2Vector3D getRollBackPoca(ParticleAndWeight const &paw)
This shifts the position of tracks by the vector difference of mother B and production point of track...
bool m_useTruthInFit
Set to true if the tag fit is to be made with the TRUE tag track momentum and position.
void fillTagVinfo(const B2Vector3D &tagVpos, const TMatrixDSym &tagVposErr)
Fill tagV vertex info.
std::vector< double > m_raveWeights
Store the weights used by Rave in the vtx fit so that they can be accessed later.
TrackFitResult getTrackWithRollBackCoordinates(ParticleAndWeight const &paw)
If the fit has to be done with the rolled back tracks, Rave or KFit is fed with a track where the pos...
virtual void initialize() override
Initialize the Module.
TMatrixDSym m_pvCov
covariance matrix of the PV (useful with tube and KFit)
double m_mcDeltaT
generated DeltaT with boost-direction approximation
static std::string printVector(const ROOT::Math::XYZVector &vec)
Print a XYZVector (useful for debugging)
static B2Vector3D getTruePoca(ParticleAndWeight const &paw)
This finds the point on the true particle trajectory closest to the measured track position.
std::vector< ParticleAndWeight > getParticlesWithoutKS(const std::vector< const Particle * > &tagParticles, double massWindowWidth=0.01) const
Get a list of pions from a list of pions removing the Kshorts Warning: this assumes all the particles...
virtual void event() override
Event processor.
Particle * doVertexFitForBTube(const Particle *mother, std::string fitType) const
it returns an intersection between B rec and beam spot (= origin of BTube)
std::string m_listName
Breco particle list name.
std::pair< B2Vector3D, TMatrixDSym > findConstraint(const Particle *Breco, double cut) const
calculate the constraint for the vertex fit on the tag side using Breco information
bool m_useRollBack
Set to true if the tag fit is to be made with the tag track position rolled back to mother B.
double m_tagVlErr
Error of the tagV component in the boost direction
std::string m_roeMaskName
ROE particles from this mask will be used for vertex fitting.
double m_tagVChi2
chi^2 value of the tag vertex fit result
void BtagMCVertex(const Particle *Breco)
get the vertex of the MC B particle associated to Btag.
bool m_mcInfo
true if user wants to retrieve MC information out from the tracks used in the fit
B2Vector3D m_tagV
tag side fit result
std::string m_useMCassociation
No MC association or standard Breco particle or internal MCparticle association.
double m_tagVolErr
Error of the tagV component in the direction orthogonal to the boost.
double m_mcTagLifeTime
generated tag side life time of B-decay
B2Vector3D m_BeamSpotCenter
Beam spot position.
double m_tagVNDF
Number of degrees of freedom in the tag vertex fit.
double m_deltaTErr
reconstructed DeltaT error
std::string m_fitAlgo
Algorithm used for the tag fit (Rave or KFit)
bool makeGeneralFit()
TO DO: tag side vertex fit in the case of semileptonic tag side decay.
virtual void beginRun() override
Called when entering a new run.
B2Vector3D m_constraintCenter
centre position of the constraint for the tag Vertex fit
double m_mcDeltaTau
generated DeltaT
std::pair< B2Vector3D, TMatrixDSym > findConstraintBoost(double cut, double shiftAlongBoost=-2000.) const
calculate the standard constraint for the vertex fit on the tag side
double m_fitPval
P value of the tag side fit result.
StoreArray< TagVertex > m_verArray
StoreArray of TagVertexes.
DBObjPtr< BeamSpot > m_beamSpotDB
Beam spot database object.
B2Vector3D m_mcTagV
generated tag side vertex
void deltaT(const Particle *Breco)
calculate DeltaT and MC-DeltaT (rec - tag) in ps from Breco and Btag vertices DT = Dl / gamma beta c ...
std::vector< const Particle * > m_raveParticles
tracks given to rave for the track fit (after removing Kshorts
void fillParticles(std::vector< ParticleAndWeight > &particleAndWeights)
Fill sorted list of particles into external variable.
int m_reqPXDHits
N of PXD hits for a track to be used.
double m_confidenceLevel
required fit confidence level
double m_tagVChi2IP
IP component of the chi^2 of the tag vertex fit result.
double m_tagVol
tagV component in the direction orthogonal to the boost
std::string m_constraintType
Choose constraint: noConstraint, IP, tube, boost, (breco)
void resetReturnParams()
Reset all parameters that are computed in each event and then used to compute tuple variables.
ROOT::Math::PxPyPzEVector m_tagMomentum
B tag momentum computed from fully reconstructed B sig.
bool makeGeneralFitRave()
make the vertex fit on the tag side: RAVE AVF tracks coming from Ks removed all other tracks used
TrackFitResult getTrackWithTrueCoordinates(ParticleAndWeight const &paw) const
If the fit has to be done with the truth info, Rave is fed with a track where the momentum is replace...
std::pair< B2Vector3D, TMatrixDSym > findConstraintBTube(const Particle *Breco, double cut)
calculate constraint for the vertex fit on the tag side using the B tube (cylinder along the expected...
StoreArray< MCParticle > m_mcParticles
StoreArray of MCParticles.
double m_mcLifeTimeReco
generated Breco life time
static bool compBrecoBgen(const Particle *Breco, const MCParticle *Bgen)
compare Breco with the two MC B particles
double m_Bfield
magnetic field from data base
TMatrixDSym m_tagVErrMatrix
Error matrix of the tag side fit result.
int m_mcPDG
generated tag side B flavor
StoreObjPtr< ParticleList > m_plist
input particle list
static std::string printMatrix(const TMatrixD &mat)
Print a TMatrix (useful for debugging)
int m_rollbackStatus
Store info about whether the fit was performed with the rolled back tracks 0 fit performed with measu...
std::string m_trackFindingType
Choose how to find the tag tracks: standard, standard_PXD.
bool m_verbose
choose if you want to print extra infos
int m_FitType
fit algo used
bool makeGeneralFitKFit()
make the vertex fit on the tag side: KFit tracks coming from Ks removed all other tracks used
std::vector< const MCParticle * > m_raveMCParticles
Store the MC particles corresponding to each track used by Rave in the vtx fit.
B2Vector3D m_mcVertReco
generated Breco decay vertex
TMatrixDSym m_BeamSpotCov
size of the beam spot == covariance matrix on the beam spot position
double m_deltaT
reconstructed DeltaT
TagVertex data object: contains Btag Vertex and DeltaT.
void setConstraintType(const std::string &constraintType)
Set the type of the constraint for the tag fit.
void setTagVlErr(float TagVlErr)
Set the error of the tagV component in the boost direction.
void setTruthTagVl(float TruthTagVl)
Set the MC tagV component in the boost direction.
void setTagVertex(const B2Vector3D &TagVertex)
Set BTag Vertex.
void setConstraintCenter(const B2Vector3D &constraintCenter)
Set the centre of the constraint for the tag fit.
void setTruthTagVol(float TruthTagVol)
Set the tagV component in the direction orthogonal to the boost.
void setMCTagBFlavor(int mcTagBFlavor)
Set generated Btag PDG code.
void setTagVolErr(float TagVolErr)
Set the error of the tagV component in the direction orthogonal to the boost.
void setMCTagVertex(const B2Vector3D &mcTagVertex)
Set generated BTag Vertex.
void setTagVNDF(float TagVNDF)
Set the number of degrees of freedom in the tag vertex fit.
void setDeltaTErr(float DeltaTErr)
Set DeltaTErr.
void setNTracks(int nTracks)
Set number of tracks used in the fit.
void setTagVChi2(float TagVChi2)
Set the chi^2 value of the tag vertex fit result.
void setMCDeltaT(float mcDeltaT)
Set generated DeltaT (in kin.
void setRollBackStatus(int backStatus)
Set the status of the fit performed with the rolled back tracks.
void setVertexFitMCParticles(const std::vector< const MCParticle * > &vtxFitMCParticles)
Set a vector of pointers to the MC p'cles corresponding to the tracks in the tag vtx fit.
void setTagVol(float TagVol)
Set the tagV component in the direction orthogonal to the boost.
void setDeltaT(float DeltaT)
Set DeltaT.
void setRaveWeights(const std::vector< double > &raveWeights)
Set the weights used by Rave in the tag vtx fit.
void setTagVertexPval(float TagVertexPval)
Set BTag Vertex P value.
void setMCDeltaTau(float mcDeltaTau)
Set generated DeltaT.
void setTagVl(float TagVl)
Set the tagV component in the boost direction.
void setTagVertexErrMatrix(const TMatrixDSym &TagVertexErrMatrix)
Set BTag Vertex (3x3) error matrix.
void setConstraintCov(const TMatrixDSym &constraintCov)
Set the covariance matrix of the constraint for the tag fit.
void setFitType(float FitType)
Set fit algo type.
void setVertexFitParticles(const std::vector< const Particle * > &vtxFitParticles)
Set a vector of pointers to the tracks used in the tag vtx fit.
void setTagVChi2IP(float TagVChi2IP)
Set the IP component of the chi^2 value of the tag vertex fit result.
void setFitTruthStatus(int truthStatus)
Set the status of the fit performed with the truth info of the tracks.
Values of the result of a track fit with a given particle hypothesis.
short getChargeSign() const
Return track charge (1 or -1).
double getPValue() const
Getter for Chi2 Probability of the track fit.
TMatrixDSym getCovariance6() const
Position and Momentum Covariance Matrix.
TVector3 getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
int getNDF() const
Getter for number of degrees of freedom of the track fit.
TVector3 getPosition() const
Getter for vector of position at closest approach of track in r/phi projection.
Const::ParticleType getParticleType() const
Getter for ParticleType of the mass hypothesis of the track fit.
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
double getNdf(VecSize vertexId=0) const
get the number of degrees of freedom (NDF) of the fitted vertex.
double getChi2(VecSize vertexId=0) const
get the χ² of the fitted vertex.
B2Vector3D getPos(VecSize vertexId=0) const
get the position of the fitted vertex.
void updateDaughters()
update the Daughters particles
double getWeight(int trackId, VecSize vertexId=0) const
get the weight Rave assigned to a specific input track.
double getPValue(VecSize vertexId=0) const
get the p value of the fitted vertex.
VertexFitKFit is a derived class from KFitBase to perform vertex-constraint kinematical fit.
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
Particle * copyParticle(const Particle *original)
Function takes argument Particle and creates a copy of it and copies of all its (grand-)^n-daughters.
Abstract base class for different kinds of events.
this struct is used to store and sort the tag tracks
const Particle * particle
tag track fit result with pion mass hypo, for sorting purposes
const MCParticle * mcParticle
mc particle matched to the tag track, for sorting purposes
double weight
rave weight associated to the track, for sorting purposes