10#include <analysis/variables/TimeDependentVariables.h>
12#include <framework/dbobjects/BeamParameters.h>
15#include <analysis/dataobjects/Particle.h>
16#include <analysis/dataobjects/TagVertex.h>
19#include <analysis/utility/DistanceTools.h>
20#include <analysis/utility/PCmsLabTransform.h>
21#include <analysis/utility/RotationTools.h>
22#include <analysis/utility/ReferenceFrame.h>
25#include <framework/gearbox/Const.h>
26#include <mdst/dataobjects/MCParticle.h>
27#include <mdst/dataobjects/TrackFitResult.h>
29#include <Math/VectorUtil.h>
46 using RotationTools::getUnitOrthogonal;
47 using RotationTools::toVec;
54 double particleTagVx(
const Particle* particle)
56 auto* vert = particle->getRelatedTo<TagVertex>();
58 return vert->getTagVertex().X();
61 double particleTagVy(
const Particle* particle)
63 auto* vert = particle->getRelatedTo<TagVertex>();
65 return vert->getTagVertex().Y();
68 double particleTagVz(
const Particle* particle)
70 auto* vert = particle->getRelatedTo<TagVertex>();
72 return vert->getTagVertex().Z();
75 double particleTruthTagVx(
const Particle* particle)
77 auto* vert = particle->getRelatedTo<TagVertex>();
79 return vert->getMCTagVertex().X();
82 double particleTruthTagVy(
const Particle* particle)
84 auto* vert = particle->getRelatedTo<TagVertex>();
86 return vert->getMCTagVertex().Y();
89 double particleTruthTagVz(
const Particle* particle)
91 auto* vert = particle->getRelatedTo<TagVertex>();
93 return vert->getMCTagVertex().Z();
96 double particleTagVCov(
const Particle* particle,
const std::vector<double>& element)
98 int elementI = int(std::lround(element[0]));
99 int elementJ = int(std::lround(element[1]));
101 if (elementI < 0 || elementI > 2) {
102 B2WARNING(
"Index is out of boundaries [0 - 2]:" << LogVar(
"i", elementI));
105 if (elementJ < 0 || elementJ > 2) {
106 B2WARNING(
"Index is out of boundaries [0 - 2]:" << LogVar(
"j", elementJ));
110 auto* vert = particle->getRelatedTo<TagVertex>();
112 TMatrixDSym TagVErr = vert->getTagVertexErrMatrix();
113 return TagVErr(elementI, elementJ);
116 double particleTagVxErr(
const Particle* particle)
118 auto* vert = particle->getRelatedTo<TagVertex>();
120 TMatrixDSym TagVErr = vert->getTagVertexErrMatrix();
121 return sqrt(TagVErr(0, 0));
124 double particleTagVyErr(
const Particle* particle)
126 auto* vert = particle->getRelatedTo<TagVertex>();
128 TMatrixDSym TagVErr = vert->getTagVertexErrMatrix();
129 return sqrt(TagVErr(1, 1));
132 double particleTagVzErr(
const Particle* particle)
134 auto* vert = particle->getRelatedTo<TagVertex>();
136 TMatrixDSym TagVErr = vert->getTagVertexErrMatrix();
137 return sqrt(TagVErr(2, 2));
140 double particleTagVpVal(
const Particle* particle)
142 auto* vert = particle->getRelatedTo<TagVertex>();
144 return vert->getTagVertexPval();
147 double particleTagVNTracks(
const Particle* particle)
149 auto* vert = particle->getRelatedTo<TagVertex>();
151 return vert->getNTracks();
154 double particleTagVNFitTracks(
const Particle* particle)
156 auto* vert = particle->getRelatedTo<TagVertex>();
158 return vert->getNFitTracks();
161 double particleTagVType(
const Particle* particle)
163 auto* vert = particle->getRelatedTo<TagVertex>();
165 return vert->getFitType();
168 double particleTagVNDF(
const Particle* particle)
170 auto* vert = particle->getRelatedTo<TagVertex>();
172 return vert->getTagVNDF();
175 double particleTagVChi2(
const Particle* particle)
177 auto* vert = particle->getRelatedTo<TagVertex>();
179 return vert->getTagVChi2();
182 double particleTagVChi2IP(
const Particle* particle)
184 auto* vert = particle->getRelatedTo<TagVertex>();
186 return vert->getTagVChi2IP();
191 double particleDeltaT(
const Particle* particle)
193 auto* vert = particle->getRelatedTo<TagVertex>();
195 return vert->getDeltaT();
198 double particleDeltaTErr(
const Particle* particle)
200 auto* vert = particle->getRelatedTo<TagVertex>();
202 return vert->getDeltaTErr();
205 double particleDeltaTRes(
const Particle* particle)
207 return particleDeltaT(particle) - particleMCDeltaT(particle);
210 double particleDeltaTBelle(
const Particle* particle)
212 double beta = PCmsLabTransform().getBoostVector().R();
213 double bg = beta /
sqrt(1 - beta * beta);
215 return particleDeltaZ(particle) / bg / c;
218 double particleMCDeltaTau(
const Particle* particle)
220 auto* vert = particle->getRelatedTo<TagVertex>();
222 return vert->getMCDeltaTau();
225 double particleMCDeltaT(
const Particle* particle)
227 auto* vert = particle->getRelatedTo<TagVertex>();
229 return vert->getMCDeltaT();
232 double particleMCDeltaBoost(
const Particle* particle)
234 auto* vert = particle->getRelatedTo<TagVertex>();
237 double beta = PCmsLabTransform().getBoostVector().R();
238 double bg = beta /
sqrt(1 - beta * beta);
240 return vert->getMCDeltaT() * bg * c;
243 double particleDeltaZ(
const Particle* particle)
245 auto* vert = particle->getRelatedTo<TagVertex>();
247 return particle->getZ() - vert->getTagVertex().Z();
250 double particleDeltaZErr(
const Particle* particle)
252 auto* vert = particle->getRelatedTo<TagVertex>();
255 double zVariance = particle->getVertexErrorMatrix()(2, 2);
256 double TagVZVariance = vert->getTagVertexErrMatrix()(2, 2);
257 double result =
sqrt(zVariance + TagVZVariance);
263 double particleDeltaB(
const Particle* particle)
265 auto* vert = particle->getRelatedTo<TagVertex>();
268 double beta = PCmsLabTransform().getBoostVector().R();
269 double bg = beta /
sqrt(1 - beta * beta);
271 return vert->getDeltaT() * bg * c;
274 double particleDeltaBErr(
const Particle* particle)
276 auto* vert = particle->getRelatedTo<TagVertex>();
279 double beta = PCmsLabTransform().getBoostVector().R();
280 double bg = beta /
sqrt(1 - beta * beta);
282 return vert->getDeltaTErr() * bg * c;
287 double vertexBoostDirection(
const Particle* part)
289 ROOT::Math::XYZVector boostDir = PCmsLabTransform().getBoostVector().Unit();
290 ROOT::Math::XYZVector pos = part->getVertex();
291 return pos.Dot(boostDir);
294 double vertexOrthogonalBoostDirection(
const Particle* part)
296 ROOT::Math::XYZVector boost = PCmsLabTransform().getBoostVector();
297 ROOT::Math::XYZVector orthBoostDir = getUnitOrthogonal(boost);
299 ROOT::Math::XYZVector pos = part->getVertex();
300 return pos.Dot(orthBoostDir);
303 double vertexTruthBoostDirection(
const Particle* part)
305 static DBObjPtr<BeamParameters> beamParamsDB;
306 if (!beamParamsDB.isValid())
308 ROOT::Math::XYZVector boostDir = -(beamParamsDB->getHER() + beamParamsDB->getLER()).BoostToCM().Unit();
309 const MCParticle* mcPart = part->getMCParticle();
311 ROOT::Math::XYZVector pos = mcPart->getDecayVertex();
312 return pos.Dot(boostDir);
315 double vertexTruthOrthogonalBoostDirection(
const Particle* part)
317 static DBObjPtr<BeamParameters> beamParamsDB;
318 if (!beamParamsDB.isValid())
320 ROOT::Math::XYZVector boost = -(beamParamsDB->getHER() + beamParamsDB->getLER()).BoostToCM();
321 ROOT::Math::XYZVector orthBoostDir = getUnitOrthogonal(boost);
322 const MCParticle* mcPart = part->getMCParticle();
324 ROOT::Math::XYZVector pos = mcPart->getDecayVertex();
325 return pos.Dot(orthBoostDir);
328 double vertexErrBoostDirection(
const Particle* part)
330 TVectorD bDir = toVec(PCmsLabTransform().getBoostVector().Unit());
332 return sqrt(part->getVertexErrorMatrix().Similarity(bDir));
335 double vertexErrOrthBoostDirection(
const Particle* part)
337 TVectorD oDir = toVec(getUnitOrthogonal(PCmsLabTransform().getBoostVector()));
339 return sqrt(part->getVertexErrorMatrix().Similarity(oDir));
344 double tagVBoostDirection(
const Particle* part)
346 auto* vert = part->getRelatedTo<TagVertex>();
348 return vert->getTagVl();
351 double tagVOrthogonalBoostDirection(
const Particle* part)
353 auto* vert = part->getRelatedTo<TagVertex>();
355 return vert->getTagVol();
358 double tagVTruthBoostDirection(
const Particle* part)
360 auto* vert = part->getRelatedTo<TagVertex>();
362 return vert->getTruthTagVl();
365 double tagVTruthOrthogonalBoostDirection(
const Particle* part)
367 auto* vert = part->getRelatedTo<TagVertex>();
369 return vert->getTruthTagVol();
372 double tagVErrBoostDirection(
const Particle* part)
374 auto* vert = part->getRelatedTo<TagVertex>();
376 return vert->getTagVlErr();
379 double tagVErrOrthogonalBoostDirection(
const Particle* part)
381 auto* vert = part->getRelatedTo<TagVertex>();
383 return vert->getTagVolErr();
388 double particleCosThetaBoostDirection(
const Particle* part)
391 ROOT::Math::XYZVector boost = PCmsLabTransform().getBoostVector();
392 ROOT::Math::PxPyPzEVector pxpypze = frame.getMomentum(part);
393 return ROOT::Math::VectorUtil::CosTheta(pxpypze, boost);
396 double particleInternalTagVMCFlavor(
const Particle* part)
398 auto* vert = part->getRelatedTo<TagVertex>();
400 return vert->getMCTagBFlavor();
403 double tagTrackMomentum(
const Particle* part,
const std::vector<double>& trackIndex)
405 auto* vert = part->getRelatedTo<TagVertex>();
409 unsigned trackIndexInt = trackIndex.at(0);
411 return vert->getVtxFitTrackP(trackIndexInt).R();
414 double tagTrackMomentumX(
const Particle* part,
const std::vector<double>& trackIndex)
416 auto* vert = part->getRelatedTo<TagVertex>();
420 unsigned trackIndexInt = trackIndex.at(0);
422 return vert->getVtxFitTrackP(trackIndexInt).X();
425 double tagTrackMomentumY(
const Particle* part,
const std::vector<double>& trackIndex)
427 auto* vert = part->getRelatedTo<TagVertex>();
431 unsigned trackIndexInt = trackIndex.at(0);
433 return vert->getVtxFitTrackP(trackIndexInt).Y();
436 double tagTrackMomentumZ(
const Particle* part,
const std::vector<double>& trackIndex)
438 auto* vert = part->getRelatedTo<TagVertex>();
442 unsigned trackIndexInt = trackIndex.at(0);
444 return vert->getVtxFitTrackP(trackIndexInt).Z();
447 double tagTrackZ0(
const Particle* part,
const std::vector<double>& trackIndex)
449 auto* vert = part->getRelatedTo<TagVertex>();
453 unsigned trackIndexInt = trackIndex.at(0);
455 return vert->getVtxFitTrackZ0(trackIndexInt);
458 double tagTrackD0(
const Particle* part,
const std::vector<double>& trackIndex)
460 auto* vert = part->getRelatedTo<TagVertex>();
464 unsigned trackIndexInt = trackIndex.at(0);
466 return vert->getVtxFitTrackD0(trackIndexInt);
469 double tagTrackRaveWeight(
const Particle* part,
const std::vector<double>& trackIndex)
471 auto* vert = part->getRelatedTo<TagVertex>();
475 unsigned trackIndexInt = trackIndex.at(0);
477 return vert->getRaveWeight(trackIndexInt);
480 double tagTrackDistanceToConstraint(
const Particle* part,
const std::vector<double>& trackIndex)
482 auto* vert = part->getRelatedTo<TagVertex>();
486 unsigned trackIndexInt = trackIndex.at(0);
489 const Particle* tagParticle(vert->getVtxFitParticle(trackIndexInt));
491 const TrackFitResult* tagTrackFitResult = tagParticle->getTrackFitResult();
495 tagParticle->getMomentum(),
496 vert->getConstraintCenter());
499 double getY4Sx(
const Particle* part)
501 auto* vert = part->getRelatedTo<TagVertex>();
503 return vert->getConstraintCenter().X();
506 double getY4Sy(
const Particle* part)
508 auto* vert = part->getRelatedTo<TagVertex>();
510 return vert->getConstraintCenter().Y();
513 double getY4Sz(
const Particle* part)
515 auto* vert = part->getRelatedTo<TagVertex>();
517 return vert->getConstraintCenter().Z();
520 double getSigBdecayTime(
const Particle* part)
522 auto* vert = part->getRelatedTo<TagVertex>();
524 ROOT::Math::XYZVector vtxY4S = vert->getConstraintCenter();
525 ROOT::Math::XYZVector vtxSigB = part->getVertex();
526 ROOT::Math::PxPyPzEVector p4Sig = part->get4Vector();
527 ROOT::Math::XYZVector nSig = p4Sig.Vect().Unit();
530 double betaSig = p4Sig.Beta();
531 double gammaSig = 1 /
sqrt(1 - betaSig * betaSig);
536 double tSig = (vtxSigB - vtxY4S).Dot(nSig) / (c * betaSig * gammaSig);
540 double getTagBdecayTime(
const Particle* part)
542 auto* vert = part->getRelatedTo<TagVertex>();
545 ROOT::Math::XYZVector vtxY4S = vert->getConstraintCenter();
546 ROOT::Math::XYZVector vtxTagB = vert->getTagVertex();
547 ROOT::Math::PxPyPzEVector p4Sig = part->get4Vector();
548 ROOT::Math::PxPyPzEVector p4SigCms = PCmsLabTransform().labToCms(p4Sig);
550 ROOT::Math::PxPyPzEVector p4TagCms(-p4SigCms.px(), -p4SigCms.py(), -p4SigCms.pz(), p4SigCms.E());
551 ROOT::Math::PxPyPzEVector p4Tag = PCmsLabTransform().cmsToLab(p4TagCms);
552 ROOT::Math::XYZVector nTag = p4Tag.Vect().Unit();
555 double betaTag = p4Tag.Beta();
556 double gammaTag = 1 /
sqrt(1 - betaTag * betaTag);
561 double tTag = (vtxTagB - vtxY4S).Dot(nTag) / (c * betaTag * gammaTag);
565 double getDeltaT3D(
const Particle* part)
567 return getSigBdecayTime(part) - getTagBdecayTime(part);
570 double tagTrackDistanceToConstraintErr(
const Particle* part,
const std::vector<double>& trackIndex)
572 auto* vert = part->getRelatedTo<TagVertex>();
576 unsigned trackIndexInt = trackIndex.at(0);
579 const Particle* tagParticle(vert->getVtxFitParticle(trackIndexInt));
581 const TrackFitResult* tagTrackFitResult = tagParticle->getTrackFitResult();
585 TMatrixDSym trackPosCovMat = tagParticle->getVertexErrorMatrix();
588 tagParticle->getMomentum(),
589 vert->getConstraintCenter(),
591 vert->getConstraintCov());
594 double tagTrackDistanceToConstraintSignificance(
const Particle* part,
const std::vector<double>& trackIndex)
596 double val = tagTrackDistanceToConstraint(part, trackIndex);
598 double err = tagTrackDistanceToConstraintErr(part, trackIndex);
604 double tagVDistanceToConstraint(
const Particle* part)
606 auto* vert = part->getRelatedTo<TagVertex>();
612 vert->getTagVertex());
615 double tagVDistanceToConstraintErr(
const Particle* part)
617 auto* vert = part->getRelatedTo<TagVertex>();
625 TMatrixDSym emptyMat(3);
628 vert->getTagVertex(),
629 vert->getConstraintCov(),
633 double tagVDistanceToConstraintSignificance(
const Particle* part)
635 double val = tagVDistanceToConstraint(part);
637 double err = tagVDistanceToConstraintErr(part);
643 double tagTrackDistanceToTagV(
const Particle* part,
const std::vector<double>& trackIndex)
645 auto* vert = part->getRelatedTo<TagVertex>();
649 unsigned trackIndexInt = trackIndex.at(0);
651 const Particle* particle = vert->getVtxFitParticle(trackIndexInt);
653 const TrackFitResult* trackFitResult = particle->getTrackFitResult();
657 particle->getMomentum(),
658 vert->getTagVertex());
661 double tagTrackDistanceToTagVErr(
const Particle* part,
const std::vector<double>& trackIndex)
663 auto* vert = part->getRelatedTo<TagVertex>();
667 unsigned trackIndexInt = trackIndex.at(0);
669 const Particle* tagParticle(vert->getVtxFitParticle(trackIndexInt));
671 const TrackFitResult* tagTrackFitResult = tagParticle->getTrackFitResult();
675 TMatrixDSym trackPosCovMat = tagParticle->getVertexErrorMatrix();
681 TMatrixDSym emptyMat(3);
684 tagParticle->getMomentum(),
685 vert->getTagVertex(),
691 double tagTrackDistanceToTagVSignificance(
const Particle* part,
const std::vector<double>& trackIndex)
693 double val = tagTrackDistanceToTagV(part, trackIndex);
695 double err = tagTrackDistanceToTagVErr(part, trackIndex);
701 double tagTrackTrueDistanceToTagV(
const Particle* part,
const std::vector<double>& trackIndex)
703 auto* vert = part->getRelatedTo<TagVertex>();
707 unsigned trackIndexInt = trackIndex.at(0);
709 const MCParticle* mcParticle(vert->getVtxFitMCParticle(trackIndexInt));
712 ROOT::Math::XYZVector mcTagV = vert->getMCTagVertex();
714 if (mcTagV.X() == 0 && mcTagV.Y() == 0 && mcTagV.Z() == 0)
return Const::doubleNaN;
717 mcParticle->getMomentum(),
721 ROOT::Math::XYZVector tagTrackTrueVecToTagV(
const Particle* part,
const std::vector<double>& trackIndex)
723 auto* vert = part->getRelatedTo<TagVertex>();
724 if (!vert)
return vecNaN;
726 if (trackIndex.size() != 1)
return vecNaN;
727 unsigned trackIndexInt = trackIndex.at(0);
729 const MCParticle* mcParticle(vert->getVtxFitMCParticle(trackIndexInt));
730 if (!mcParticle)
return vecNaN;
732 ROOT::Math::XYZVector mcTagV = vert->getMCTagVertex();
734 if (mcTagV.X() == 0 && mcTagV.Y() == 0 && mcTagV.Z() == 0)
return vecNaN;
737 mcParticle->getMomentum(),
741 double tagTrackTrueVecToTagVX(
const Particle* part,
const std::vector<double>& trackIndex)
743 ROOT::Math::XYZVector result = tagTrackTrueVecToTagV(part, trackIndex);
747 double tagTrackTrueVecToTagVY(
const Particle* part,
const std::vector<double>& trackIndex)
749 ROOT::Math::XYZVector result = tagTrackTrueVecToTagV(part, trackIndex);
753 double tagTrackTrueVecToTagVZ(
const Particle* part,
const std::vector<double>& trackIndex)
755 ROOT::Math::XYZVector result = tagTrackTrueVecToTagV(part, trackIndex);
759 ROOT::Math::XYZVector tagTrackTrueMomentum(
const Particle* part,
const std::vector<double>& trackIndex)
761 auto* vert = part->getRelatedTo<TagVertex>();
762 if (!vert)
return vecNaN;
764 if (trackIndex.size() != 1)
return vecNaN;
765 unsigned trackIndexInt = trackIndex.at(0);
767 const MCParticle* mcParticle(vert->getVtxFitMCParticle(trackIndexInt));
768 if (!mcParticle)
return vecNaN;
770 return mcParticle->getMomentum();
773 double tagTrackTrueMomentumX(
const Particle* part,
const std::vector<double>& trackIndex)
775 ROOT::Math::XYZVector pTrue = tagTrackTrueMomentum(part, trackIndex);
779 double tagTrackTrueMomentumY(
const Particle* part,
const std::vector<double>& trackIndex)
781 ROOT::Math::XYZVector pTrue = tagTrackTrueMomentum(part, trackIndex);
785 double tagTrackTrueMomentumZ(
const Particle* part,
const std::vector<double>& trackIndex)
787 ROOT::Math::XYZVector pTrue = tagTrackTrueMomentum(part, trackIndex);
791 ROOT::Math::XYZVector tagTrackTrueOrigin(
const Particle* part,
const std::vector<double>& trackIndex)
793 auto* vert = part->getRelatedTo<TagVertex>();
794 if (!vert)
return vecNaN;
796 if (trackIndex.size() != 1)
return vecNaN;
797 unsigned trackIndexInt = trackIndex.at(0);
799 const MCParticle* mcParticle(vert->getVtxFitMCParticle(trackIndexInt));
800 if (!mcParticle)
return vecNaN;
802 return mcParticle->getProductionVertex();
805 double tagTrackTrueOriginX(
const Particle* part,
const std::vector<double>& trackIndex)
807 ROOT::Math::XYZVector origin = tagTrackTrueOrigin(part, trackIndex);
811 double tagTrackTrueOriginY(
const Particle* part,
const std::vector<double>& trackIndex)
813 ROOT::Math::XYZVector origin = tagTrackTrueOrigin(part, trackIndex);
817 double tagTrackTrueOriginZ(
const Particle* part,
const std::vector<double>& trackIndex)
819 ROOT::Math::XYZVector origin = tagTrackTrueOrigin(part, trackIndex);
823 int fitTruthStatus(
const Particle* part)
825 auto* vert = part->getRelatedTo<TagVertex>();
826 if (!vert)
return -1;
827 return vert->getFitTruthStatus();
830 int rollbackStatus(
const Particle* part)
832 auto* vert = part->getRelatedTo<TagVertex>();
833 if (!vert)
return -1;
834 return vert->getRollBackStatus();
846 TagTrFPtr getTagTrackFunctionFromName(
string const& name)
848 if (name ==
"TagTrackMomentum")
return tagTrackMomentum;
849 else if (name ==
"TagTrackMomentumX")
return tagTrackMomentumX;
850 else if (name ==
"TagTrackMomentumY")
return tagTrackMomentumY;
851 else if (name ==
"TagTrackMomentumZ")
return tagTrackMomentumZ;
852 else if (name ==
"TagTrackZ0")
return tagTrackZ0;
853 else if (name ==
"TagTrackD0")
return tagTrackD0;
854 else if (name ==
"TagTrackRaveWeight")
return tagTrackRaveWeight;
855 else if (name ==
"TagTrackDistanceToConstraint")
return tagTrackDistanceToConstraint;
856 else if (name ==
"TagTrackDistanceToConstraintErr")
return tagTrackDistanceToConstraintErr;
857 else if (name ==
"TagTrackDistanceToConstraintSignificance")
return tagTrackDistanceToConstraintSignificance;
858 else if (name ==
"TagTrackDistanceToTagV")
return tagTrackDistanceToTagV;
859 else if (name ==
"TagTrackDistanceToTagVErr")
return tagTrackDistanceToTagVErr;
860 else if (name ==
"TagTrackDistanceToTagVSignificance")
return tagTrackDistanceToTagVSignificance;
861 else if (name ==
"TagTrackTrueDistanceToTagV")
return tagTrackTrueDistanceToTagV;
862 else if (name ==
"TagTrackTrueVecToTagVX")
return tagTrackTrueVecToTagVX;
863 else if (name ==
"TagTrackTrueVecToTagVY")
return tagTrackTrueVecToTagVY;
864 else if (name ==
"TagTrackTrueVecToTagVZ")
return tagTrackTrueVecToTagVZ;
865 else if (name ==
"TagTrackTrueMomentumX")
return tagTrackTrueMomentumX;
866 else if (name ==
"TagTrackTrueMomentumY")
return tagTrackTrueMomentumY;
867 else if (name ==
"TagTrackTrueMomentumZ")
return tagTrackTrueMomentumZ;
868 else if (name ==
"TagTrackTrueOriginX")
return tagTrackTrueOriginX;
869 else if (name ==
"TagTrackTrueOriginY")
return tagTrackTrueOriginY;
870 else if (name ==
"TagTrackTrueOriginZ")
return tagTrackTrueOriginZ;
872 B2ERROR(
"From TimeDependentVariables: Trying to access unknown tagTrack function");
876 double cumulate(
const Particle* part,
const std::vector<std::string>& variable,
double start,
877 std::function<
double(
double,
double,
double)> fun)
879 TagTrFPtr fptr(getTagTrackFunctionFromName(variable.at(0)));
880 auto* vert = part->getRelatedTo<TagVertex>();
882 int nTracks = vert->getNFitTracks();
886 for (
int i = 0; i < nTracks; ++i) {
887 vector<double> indx(1, i);
888 double w = tagTrackRaveWeight(part, indx);
889 double f = (*fptr)(part, indx);
891 acum = fun(acum, f, w);
899 if (variable.size() != 1) {
900 B2FATAL(
"Wrong number of arguments for meta function tagTrackAverage");
904 return [variable](
const Particle * part) ->
double {
905 double sum = cumulate(part, variable, 0, [](
double s,
double f,
double) {
return s + f;});
906 double tot = cumulate(part, variable, 0, [](
double s,
double,
double) {
return s + 1;});
913 if (variable.size() != 1) {
914 B2FATAL(
"Wrong number of arguments for meta function tagTrackAverageSquares");
918 return [variable](
const Particle * part) ->
double {
919 double sum = cumulate(part, variable, 0, [](
double s,
double f,
double) {
return s + f * f;});
920 double tot = cumulate(part, variable, 0, [](
double s,
double,
double) {
return s + 1;});
928 if (variable.size() != 1) {
929 B2FATAL(
"Wrong number of arguments for meta function tagTrackMax");
933 return [variable](
const Particle * part) ->
double {
934 double Max = cumulate(part, variable, -DBL_MAX, [](
double s,
double f,
double) {
return std::max(s, f);});
941 if (variable.size() != 1) {
942 B2FATAL(
"Wrong number of arguments for meta function tagTrackMin");
946 return [variable](
const Particle * part) ->
double {
947 double Min = cumulate(part, variable, +DBL_MAX, [](
double s,
double f,
double) {
return std::min(s, f);});
954 if (variable.size() != 1) {
955 B2FATAL(
"Wrong number of arguments for meta function tagTrackWeightedAverage");
959 return [variable](
const Particle * part) ->
double {
960 double num = cumulate(part, variable, 0, [](
double s,
double f,
double w) {
return s + w * f;});
961 double den = cumulate(part, variable, 0, [](
double s,
double,
double w) {
return s + w;});
968 if (variable.size() != 1) {
969 B2FATAL(
"Wrong number of arguments for meta function tagTrackWeightedAverageSquares");
973 return [variable](
const Particle * part) ->
double {
974 double num = cumulate(part, variable, 0, [](
double s,
double f,
double w) {
return s + w * f * f;});
975 double den = cumulate(part, variable, 0, [](
double s,
double,
double w) {
return s + w;});
982 if (variable.size() != 1) {
983 B2FATAL(
"Wrong number of arguments for meta function tagTrackSum");
987 return [variable](
const Particle * part) ->
double {
988 return cumulate(part, variable, 0, [](
double s,
double f,
double) {
return s + f;});
996 VARIABLE_GROUP(
"Time Dependent CPV Analysis Variables");
998 REGISTER_VARIABLE(
"TagVx", particleTagVx,
"Tag vertex X component\n\n",
"cm");
999 REGISTER_VARIABLE(
"TagVy", particleTagVy,
"Tag vertex Y component\n\n",
"cm");
1000 REGISTER_VARIABLE(
"TagVz", particleTagVz,
"Tag vertex Z component\n\n",
"cm");
1001 REGISTER_VARIABLE(
"mcTagVx", particleTruthTagVx,
"Generated Tag vertex X component\n\n",
"cm");
1002 REGISTER_VARIABLE(
"mcTagVy", particleTruthTagVy,
"Generated Tag vertex Y component\n\n",
"cm");
1003 REGISTER_VARIABLE(
"mcTagVz", particleTruthTagVz,
"Generated Tag vertex Z component\n\n",
"cm");
1004 REGISTER_VARIABLE(
"TagVxErr", particleTagVxErr,
"Tag vertex X component uncertainty\n\n",
"cm");
1005 REGISTER_VARIABLE(
"TagVyErr", particleTagVyErr,
"Tag vertex Y component uncertainty\n\n",
"cm");
1006 REGISTER_VARIABLE(
"TagVzErr", particleTagVzErr,
"Tag vertex Z component uncertainty\n\n",
"cm");
1007 REGISTER_VARIABLE(
"TagVCov(i,j)", particleTagVCov,
1008 "returns the (i,j)-th element of the Tag vertex covariance matrix (3x3).\n"
1009 "Order of elements in the covariance matrix is: x, y, z.\n\n",
"cm, cm, cm");
1011 REGISTER_VARIABLE(
"TagVpVal", particleTagVpVal,
"Tag vertex p-Value");
1012 REGISTER_VARIABLE(
"TagVNTracks", particleTagVNTracks,
"Number of tracks in the tag vertex");
1013 REGISTER_VARIABLE(
"TagVType", particleTagVType,
1014 R
"DOC(Type of algorithm for the tag vertex. -1: failed (1,2: single track, deprecated), 3: standard, 4: standard_PXD, 5: no constraint)DOC");
1015 REGISTER_VARIABLE("TagVNDF", particleTagVNDF,
"Number of degrees of freedom in the tag vertex fit");
1016 REGISTER_VARIABLE(
"TagVChi2", particleTagVChi2,
"chi2 value of the tag vertex fit");
1017 REGISTER_VARIABLE(
"TagVChi2IP", particleTagVChi2IP,
"IP component of chi2 value of the tag vertex fit");
1019 REGISTER_VARIABLE(
"DeltaT", particleDeltaT, R
"DOC(
1020 Proper decay time difference :math:`\Delta t` between signal B-meson :math:`(B_{rec})` and tag B-meson :math:`(B_{tag})`.
1023 REGISTER_VARIABLE(
"DeltaTErr", particleDeltaTErr, R
"DOC(
1024 Proper decay time difference :math:`\Delta t` uncertainty
1027 REGISTER_VARIABLE(
"DeltaTRes", particleDeltaTRes, R
"DOC(
1028 :math:`\Delta t` residual, to be used for resolution function studies
1031 REGISTER_VARIABLE(
"DeltaTBelle", particleDeltaTBelle, R
"DOC(
1032 [Legacy] :math:`\Delta t`, as it was used in Belle
1035 REGISTER_VARIABLE(
"mcDeltaTau", particleMCDeltaTau,
1036 R
"DOC(Generated proper decay time difference :math:`\Delta t`: :math:`\tau(B_{\rm rec})-\tau(B_{\rm tag})`
1039 REGISTER_VARIABLE(
"mcDeltaT", particleMCDeltaT,
1040 R
"DOC(Generated proper decay time difference (in z-difference approximation) :math:`\Delta t`:
1041 :math:`(l(B_{\rm rec}) - l(B_{\rm tag}))/\beta_{\Upsilon(4S)}\gamma_{\Upsilon(4S)}`
1044 REGISTER_VARIABLE("mcDeltaBoost", particleMCDeltaBoost,
1045 R"DOC(True difference of decay vertex boost-direction components between signal B-meson :math:`(B_{rec})` and tag B-meson :math:`(B_{tag})`:
1046:math:`\Delta l = l(B_{rec}) - l(B_{tag})`
1049 REGISTER_VARIABLE(
"DeltaZ", particleDeltaZ,
1050 R
"DOC(Difference of decay vertex longitudinal components between signal B-meson :math:`(B_{rec})` and tag B-meson :math:`(B_{tag})`:
1051:math:`\Delta z = z(B_{rec}) - z(B_{tag})`
1054 REGISTER_VARIABLE(
"DeltaZErr", particleDeltaZErr,
1055 R
"DOC(Uncertainty of the difference :math:`z(B_{rec}) - z(B_{tag})`
1058 REGISTER_VARIABLE(
"DeltaBoost", particleDeltaB, R
"DOC(:math:`\Delta z` in the boost direction
1061 REGISTER_VARIABLE(
"DeltaBoostErr", particleDeltaBErr, R
"DOC(Uncertainty of :math:`\Delta z` in the boost direction
1065 REGISTER_VARIABLE(
"LBoost", vertexBoostDirection,
1066 "Returns the vertex component in the boost direction\n\n",
"cm");
1067 REGISTER_VARIABLE(
"OBoost", vertexOrthogonalBoostDirection,
1068 "Returns the vertex component in the direction orthogonal to the boost\n\n",
"cm");
1069 REGISTER_VARIABLE(
"mcLBoost", vertexTruthBoostDirection,
1070 "Returns the MC vertex component in the boost direction\n\n",
"cm");
1071 REGISTER_VARIABLE(
"mcOBoost", vertexTruthOrthogonalBoostDirection,
1072 "Returns the MC vertex component in the direction orthogonal to the boost\n\n",
"cm");
1073 REGISTER_VARIABLE(
"LBoostErr", vertexErrBoostDirection,
1074 "Returns the error of the vertex in the boost direction\n\n",
"cm");
1075 REGISTER_VARIABLE(
"OBoostErr", vertexErrOrthBoostDirection,
1076 "Returns the error of the vertex in the direction orthogonal to the boost\n\n",
"cm");
1078 REGISTER_VARIABLE(
"Y4SvtxX", getY4Sx,
"Returns X component of Y4S vertex.\n"
1079 "The result is meaningful and nontrivial when the signal B vertex "
1080 "is determined by `vertex.treeFit` with ``ipConstraint=True`` and the `vertex.TagV` is called with the ``tube`` constraint.\n\n",
"cm");
1082 REGISTER_VARIABLE(
"Y4SvtxY", getY4Sy,
"Returns Y component of Y4S vertex.\n"
1083 "The result is meaningful and nontrivial when the signal B vertex "
1084 "is determined by `vertex.treeFit` with ``ipConstraint=True`` and the `vertex.TagV` is called with the ``tube`` constraint.\n\n",
"cm");
1086 REGISTER_VARIABLE(
"Y4SvtxZ", getY4Sz,
"Returns Z component of Y4S vertex.\n"
1087 "The result is meaningful and nontrivial when the signal B vertex "
1088 "is determined by `vertex.treeFit` with ``ipConstraint=True`` and the `vertex.TagV` is called with the ``tube`` constraint.\n\n",
"cm");
1091 REGISTER_VARIABLE(
"tSigB", getSigBdecayTime,
"Returns the proper decay time of the fully reconstructed signal B meson.\n"
1092 "The result is meaningful and nontrivial when the signal B vertex "
1093 "is determined by `vertex.treeFit` with ``ipConstraint=True`` and the `vertex.TagV` is called with the ``tube`` constraint.\n\n",
"ps");
1095 REGISTER_VARIABLE(
"tTagB", getTagBdecayTime,
"Returns the proper decay time of the tagged B meson.\n"
1096 "The result is meaningful and nontrivial when the signal B vertex "
1097 "is determined by `vertex.treeFit` with ``ipConstraint=True`` and the `vertex.TagV` is called with the ``tube`` constraint.\n\n",
"ps");
1099 REGISTER_VARIABLE(
"DeltaT3D", getDeltaT3D, R
"DOC(
1100 Returns the :math:`\Delta t` variable calculated as a difference of :b2:var:`tSigB` and :b2:var:`tTagB`, i.e. not from the projection along boost vector axis.
1102 The result is meaningful and nontrivial when the signal B vertex is determined by `vertex.treeFit` with ``ipConstraint=True`` and the `vertex.TagV` is called with the ``tube`` constraint.
1106 REGISTER_VARIABLE(
"TagVLBoost", tagVBoostDirection,
1107 "Returns the TagV component in the boost direction\n\n",
"cm");
1108 REGISTER_VARIABLE(
"TagVOBoost", tagVOrthogonalBoostDirection,
1109 "Returns the TagV component in the direction orthogonal to the boost\n\n",
"cm");
1110 REGISTER_VARIABLE(
"mcTagVLBoost", tagVTruthBoostDirection,
1111 "Returns the MC TagV component in the boost direction\n\n",
"cm");
1112 REGISTER_VARIABLE(
"mcTagVOBoost", tagVTruthOrthogonalBoostDirection,
1113 "Returns the MC TagV component in the direction orthogonal to the boost\n\n",
"cm");
1114 REGISTER_VARIABLE(
"TagVLBoostErr", tagVErrBoostDirection,
1115 "Returns the error of TagV in the boost direction\n\n",
"cm");
1116 REGISTER_VARIABLE(
"TagVOBoostErr", tagVErrOrthogonalBoostDirection,
1117 "Returns the error of TagV in the direction orthogonal to the boost\n\n",
"cm");
1119 REGISTER_VARIABLE(
"cosAngleBetweenMomentumAndBoostVector", particleCosThetaBoostDirection,
1120 "cosine of the angle between momentum and boost vector");
1122 REGISTER_VARIABLE(
"internalTagVMCFlavor", particleInternalTagVMCFlavor,
1123 "[Expert] [Debugging] This variable is only for internal checks of the TagV module by developers. \n"
1124 "It returns the internal mc flavor information of the tag-side B provided by the TagV module.");
1126 REGISTER_VARIABLE(
"TagTrackMomentum(i) ", tagTrackMomentum,
1127 "Returns the magnitude of the momentum of the ith track used in the tag vtx fit.\n\n",
"GeV/c");
1128 REGISTER_VARIABLE(
"TagTrackMomentumX(i) ", tagTrackMomentumX,
1129 "Returns the X component of the momentum of the ith track used in the tag vtx fit.\n\n",
"GeV/c");
1130 REGISTER_VARIABLE(
"TagTrackMomentumY(i) ", tagTrackMomentumY,
1131 "Returns the Y component of the momentum of the ith track used in the tag vtx fit.\n\n",
"GeV/c");
1132 REGISTER_VARIABLE(
"TagTrackMomentumZ(i) ", tagTrackMomentumZ,
1133 "Returns the Z component of the momentum of the ith track used in the tag vtx fit.\n\n",
"GeV/c");
1135 REGISTER_VARIABLE(
"TagTrackZ0(i)", tagTrackZ0,
"Returns the z0 parameter of the ith track used in the tag vtx fit\n\n",
"cm");
1136 REGISTER_VARIABLE(
"TagTrackD0(i)", tagTrackD0,
"Returns the d0 parameter of the ith track used in the tag vtx fit\n\n",
"cm");
1139 REGISTER_VARIABLE(
"TagTrackRaveWeight(i)", tagTrackRaveWeight,
"Returns the weight assigned by Rave to track i");
1141 REGISTER_VARIABLE(
"TagVNFitTracks", particleTagVNFitTracks,
1142 "returns the number of tracks used by rave to fit the vertex (not counting the ones coming from Kshorts)");
1144 REGISTER_VARIABLE(
"TagTrackDistanceToConstraint(i)", tagTrackDistanceToConstraint,
1145 "Returns the measured distance between the ith tag track and the centre of the constraint.\n\n",
"cm");
1147 REGISTER_VARIABLE(
"TagTrackDistanceToConstraintErr(i)", tagTrackDistanceToConstraintErr,
1148 "Returns the estimated error on the distance between the ith tag track and the centre of the constraint.\n\n",
"cm");
1150 REGISTER_VARIABLE(
"TagTrackDistanceToConstraintSignificance(i)", tagTrackDistanceToConstraintSignificance,
1151 "Returns the significance of the distance between the centre of the constraint and the tag track indexed by track index (computed as distance / uncertainty)");
1154 REGISTER_VARIABLE(
"TagVDistanceToConstraint", tagVDistanceToConstraint,
1155 "returns the measured distance between the tag vtx and the centre of the constraint.\n\n",
"cm");
1157 REGISTER_VARIABLE(
"TagVDistanceToConstraintErr", tagVDistanceToConstraintErr,
1158 "returns the estimated error on the distance between the tag vtx and the centre of the constraint.\n\n",
"cm");
1160 REGISTER_VARIABLE(
"TagVDistanceToConstraintSignificance", tagVDistanceToConstraintSignificance,
1161 "returns the significance of the distance between the tag vtx and the centre of the constraint (computed as distance / uncertainty)");
1163 REGISTER_VARIABLE(
"TagTrackDistanceToTagV(i)", tagTrackDistanceToTagV,
1164 "Returns the measured distance between the ith tag track and the tag vtx.\n\n",
"cm");
1166 REGISTER_VARIABLE(
"TagTrackDistanceToTagVErr(i)", tagTrackDistanceToTagVErr, R
"DOC(
1167Returns the estimated error on the distance between the ith tag track and the tag vtx.
1169.. warning:: Only the uncertainties on the track position parameters are taken into account.
1173 REGISTER_VARIABLE(
"TagTrackDistanceToTagVSignificance(i)", tagTrackDistanceToTagVSignificance,
1174 "Returns the significance of the distance between the tag vtx and the tag track indexed by trackIndex (computed as distance / uncertainty)");
1176 REGISTER_VARIABLE(
"TagTrackTrueDistanceToTagV(i)", tagTrackTrueDistanceToTagV,
1177 "Returns the true distance between the true B Tag decay vertex and the particle corresponding to the ith tag vtx track.\n\n",
"cm");
1179 REGISTER_VARIABLE(
"TagTrackTrueVecToTagVX(i)", tagTrackTrueVecToTagVX,
1180 "Returns the X coordinate of the vector between the mc particle corresponding to the ith tag vtx track and the true tag B decay vertex.\n\n",
1183 REGISTER_VARIABLE(
"TagTrackTrueVecToTagVY(i)", tagTrackTrueVecToTagVY,
1184 "Returns the Y coordinate of the vector between the mc particle corresponding to the ith tag vtx track and the true tag B decay vertex.\n\n",
1187 REGISTER_VARIABLE(
"TagTrackTrueVecToTagVZ(i)", tagTrackTrueVecToTagVZ,
1188 "Returns the Z coordinate of the vector between the mc particle corresponding to the ith tag vtx track and the true tag B decay vertex.\n\n",
1191 REGISTER_VARIABLE(
"TagTrackTrueMomentumX(i)", tagTrackTrueMomentumX,
1192 "Returns the X component of the true momentum of the MC particle corresponding to the ith tag vtx track.\n\n",
"GeV/c");
1194 REGISTER_VARIABLE(
"TagTrackTrueMomentumY(i)", tagTrackTrueMomentumY,
1195 "Returns the Y component of the true momentum of the MC particle corresponding to the ith tag vtx track.\n\n",
"GeV/c");
1197 REGISTER_VARIABLE(
"TagTrackTrueMomentumZ(i)", tagTrackTrueMomentumZ,
1198 "Returns the Z component of the true momentum of the MC particle corresponding to the ith tag vtx track.\n\n",
"GeV/c");
1200 REGISTER_VARIABLE(
"TagTrackTrueOriginX(i)", tagTrackTrueOriginX,
1201 "Returns the X component of the true origin of the MC particle corresponding to the ith tag vtx track.\n\n",
"cm");
1203 REGISTER_VARIABLE(
"TagTrackTrueOriginY(i)", tagTrackTrueOriginY,
1204 "Returns the Y component of the true origin of the MC particle corresponding to the ith tag vtx track.\n\n",
"cm");
1206 REGISTER_VARIABLE(
"TagTrackTrueOriginZ(i)", tagTrackTrueOriginZ,
1207 "Returns the Z component of the true origin of the MC particle corresponding to the ith tag vtx track.\n\n",
"cm");
1209 REGISTER_VARIABLE(
"TagVFitTruthStatus", fitTruthStatus, R
"DOC(
1210Returns the status of the fit performed with the truth info. Possible values are:
1212- -1: no related TagVertex found
1213- 0: fit performed with measured parameters
1214- 1: fit performed with true parameters
1215- 2: unable to recover truth parameters
1218 REGISTER_VARIABLE("TagVRollBackStatus", rollbackStatus, R
"DOC(
1219Returns the status of the fit performed with rolled back tracks. Possible values are:
1221- -1: no related TagVertex found
1222- 0: fit performed with measured parameters
1223- 1: fit performed with true parameters
1224- 2: unable to recover truth parameters
1227 REGISTER_METAVARIABLE("TagTrackMax(var)", tagTrackMax,
1228 "return the maximum value of the variable ``var`` evaluated for each tag track. ``var`` must be one of the TagTrackXXX variables, for example: ``TagTrackMax(TagTrackDistanceToConstraint)``. The tracks that are assigned a zero weight are ignored.",
1229 Manager::VariableDataType::c_double);
1231 REGISTER_METAVARIABLE(
"TagTrackMin(var)", tagTrackMin,
1232 "return the minimum value of the variable ``var`` evaluated for each tag track. ``var`` must be one of the TagTrackXXX variables, for example: ``TagTrackMin(TagTrackDistanceToConstraint)``. The tracks that are assigned a zero weight are ignored.",
1233 Manager::VariableDataType::c_double);
1235 REGISTER_METAVARIABLE(
"TagTrackAverage(var)", tagTrackAverage,
1236 "return the average over the tag tracks of the variable ``var``. ``var`` must be one of the TagTrackXXX variables, for example: ``TagTrackAverage(TagTrackDistanceToConstraint)``. The tracks that are assigned a zero weight are ignored.",
1237 Manager::VariableDataType::c_double);
1239 REGISTER_METAVARIABLE(
"TagTrackAverageSquares(var)", tagTrackAverageSquares,
1240 "return the average over the tag tracks of the square of the variable ``var``. ``var`` must be one of the TagTrackXXX variables, for example: ``TagTrackAverageSquares(TagTrackDistanceToConstraint)``. The tracks that are assigned a zero weight are ignored.",
1241 Manager::VariableDataType::c_double);
1243 REGISTER_METAVARIABLE(
"TagTrackWeightedAverage(var)", tagTrackWeightedAverage,
1244 "return the average over the tag tracks of the variable ``var``, weighted by weights of the tag vertex fitter. ``var`` must be one of the TagTrackXXX variables, for example: ``TagTrackWeightedAverage(TagTrackDistanceToConstraint)``.",
1245 Manager::VariableDataType::c_double);
1247 REGISTER_METAVARIABLE(
"TagTrackWeightedAverageSquares(var)", tagTrackWeightedAverageSquares,
1248 "return the average over the tag tracks of the variable ``var``, weighted by weights of the tag vertex fitter. ``var`` must be one of the TagTrackXXX variables, for example: ``TagTrackWeightedAverageSquares(TagTrackDistanceToConstraint)``.",
1249 Manager::VariableDataType::c_double);
1251 REGISTER_METAVARIABLE(
"TagTrackSum(var)", tagTrackSum,
1252 "Returns the sum of the provided variable for all tag tracks. The variable must be one of the TagTrackXXX variables, "
1253 "for example ``TagTrackSum(TagTrackD0)``. The tracks that are assigned a zero weight are ignored.",
1254 Manager::VariableDataType::c_double);
static const double speedOfLight
[cm/ns]
static const double doubleNaN
quiet_NaN
static const ReferenceFrame & GetCurrent()
Get current rest frame.
std::function< VarVariant(const Particle *)> FunctionPtr
functions stored take a const Particle* and return VarVariant.
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.