10#include <analysis/variables/TimeDependentVariables.h>
12#include <framework/dbobjects/BeamParameters.h>
15#include <analysis/dataobjects/Particle.h>
16#include <analysis/dataobjects/TagVertex.h>
17#include <mdst/dataobjects/MCParticle.h>
20#include <analysis/utility/DistanceTools.h>
21#include <analysis/utility/PCmsLabTransform.h>
22#include <analysis/utility/RotationTools.h>
23#include <analysis/utility/ReferenceFrame.h>
26#include <framework/gearbox/Const.h>
27#include <framework/geometry/B2Vector3.h>
45 using RotationTools::getUnitOrthogonal;
46 using RotationTools::toVec;
53 double particleTagVx(
const Particle* particle)
55 auto* vert = particle->getRelatedTo<TagVertex>();
57 return vert->getTagVertex().X();
60 double particleTagVy(
const Particle* particle)
62 auto* vert = particle->getRelatedTo<TagVertex>();
64 return vert->getTagVertex().Y();
67 double particleTagVz(
const Particle* particle)
69 auto* vert = particle->getRelatedTo<TagVertex>();
71 return vert->getTagVertex().Z();
74 double particleTruthTagVx(
const Particle* particle)
76 auto* vert = particle->getRelatedTo<TagVertex>();
78 return vert->getMCTagVertex().X();
81 double particleTruthTagVy(
const Particle* particle)
83 auto* vert = particle->getRelatedTo<TagVertex>();
85 return vert->getMCTagVertex().Y();
88 double particleTruthTagVz(
const Particle* particle)
90 auto* vert = particle->getRelatedTo<TagVertex>();
92 return vert->getMCTagVertex().Z();
95 double particleTagVCov(
const Particle* particle,
const std::vector<double>& element)
97 int elementI = int(std::lround(element[0]));
98 int elementJ = int(std::lround(element[1]));
100 if (elementI < 0 || elementI > 2) {
101 B2WARNING(
"Index is out of boundaries [0 - 2]:" <<
LogVar(
"i", elementI));
104 if (elementJ < 0 || elementJ > 2) {
105 B2WARNING(
"Index is out of boundaries [0 - 2]:" <<
LogVar(
"j", elementJ));
109 auto* vert = particle->getRelatedTo<TagVertex>();
111 TMatrixDSym TagVErr = vert->getTagVertexErrMatrix();
112 return TagVErr(elementI, elementJ);
115 double particleTagVxErr(
const Particle* particle)
117 auto* vert = particle->getRelatedTo<TagVertex>();
119 TMatrixDSym TagVErr = vert->getTagVertexErrMatrix();
120 return sqrt(TagVErr(0, 0));
123 double particleTagVyErr(
const Particle* particle)
125 auto* vert = particle->getRelatedTo<TagVertex>();
127 TMatrixDSym TagVErr = vert->getTagVertexErrMatrix();
128 return sqrt(TagVErr(1, 1));
131 double particleTagVzErr(
const Particle* particle)
133 auto* vert = particle->getRelatedTo<TagVertex>();
135 TMatrixDSym TagVErr = vert->getTagVertexErrMatrix();
136 return sqrt(TagVErr(2, 2));
139 double particleTagVpVal(
const Particle* particle)
141 auto* vert = particle->getRelatedTo<TagVertex>();
143 return vert->getTagVertexPval();
146 double particleTagVNTracks(
const Particle* particle)
148 auto* vert = particle->getRelatedTo<TagVertex>();
150 return vert->getNTracks();
153 double particleTagVNFitTracks(
const Particle* particle)
155 auto* vert = particle->getRelatedTo<TagVertex>();
157 return vert->getNFitTracks();
160 double particleTagVType(
const Particle* particle)
162 auto* vert = particle->getRelatedTo<TagVertex>();
164 return vert->getFitType();
167 double particleTagVNDF(
const Particle* particle)
169 auto* vert = particle->getRelatedTo<TagVertex>();
171 return vert->getTagVNDF();
174 double particleTagVChi2(
const Particle* particle)
176 auto* vert = particle->getRelatedTo<TagVertex>();
178 return vert->getTagVChi2();
181 double particleTagVChi2IP(
const Particle* particle)
183 auto* vert = particle->getRelatedTo<TagVertex>();
185 return vert->getTagVChi2IP();
190 double particleDeltaT(
const Particle* particle)
192 auto* vert = particle->getRelatedTo<TagVertex>();
194 return vert->getDeltaT();
197 double particleDeltaTErr(
const Particle* particle)
199 auto* vert = particle->getRelatedTo<TagVertex>();
201 return vert->getDeltaTErr();
204 double particleDeltaTRes(
const Particle* particle)
206 return particleDeltaT(particle) - particleMCDeltaT(particle);
209 double particleDeltaTBelle(
const Particle* particle)
211 double beta = PCmsLabTransform().getBoostVector().Mag();
212 double bg = beta / sqrt(1 - beta * beta);
214 return particleDeltaZ(particle) / bg / c;
217 double particleMCDeltaTau(
const Particle* particle)
219 auto* vert = particle->getRelatedTo<TagVertex>();
221 return vert->getMCDeltaTau();
224 double particleMCDeltaT(
const Particle* particle)
226 auto* vert = particle->getRelatedTo<TagVertex>();
228 return vert->getMCDeltaT();
231 double particleMCDeltaBoost(
const Particle* particle)
233 auto* vert = particle->getRelatedTo<TagVertex>();
236 double beta = PCmsLabTransform().getBoostVector().Mag();
237 double bg = beta / sqrt(1 - beta * beta);
239 return vert->getMCDeltaT() * bg * c;
242 double particleDeltaZ(
const Particle* particle)
244 auto* vert = particle->getRelatedTo<TagVertex>();
246 return particle->getZ() - vert->getTagVertex().Z();
249 double particleDeltaZErr(
const Particle* particle)
251 auto* vert = particle->getRelatedTo<TagVertex>();
254 double zVariance = particle->getVertexErrorMatrix()(2, 2);
255 double TagVZVariance = vert->getTagVertexErrMatrix()(2, 2);
256 double result = sqrt(zVariance + TagVZVariance);
262 double particleDeltaB(
const Particle* particle)
264 auto* vert = particle->getRelatedTo<TagVertex>();
267 double beta = PCmsLabTransform().getBoostVector().Mag();
268 double bg = beta / sqrt(1 - beta * beta);
270 return vert->getDeltaT() * bg * c;
273 double particleDeltaBErr(
const Particle* particle)
275 auto* vert = particle->getRelatedTo<TagVertex>();
278 double beta = PCmsLabTransform().getBoostVector().Mag();
279 double bg = beta / sqrt(1 - beta * beta);
281 return vert->getDeltaTErr() * bg * c;
286 double vertexBoostDirection(
const Particle* part)
290 return pos.
Dot(boostDir);
293 double vertexOrthogonalBoostDirection(
const Particle* part)
295 B2Vector3D boost = PCmsLabTransform().getBoostVector();
296 B2Vector3D orthBoostDir = getUnitOrthogonal(boost);
299 return pos.
Dot(orthBoostDir);
302 double vertexTruthBoostDirection(
const Particle* part)
304 static DBObjPtr<BeamParameters> beamParamsDB;
305 B2Vector3D boostDir = -(beamParamsDB->getHER() + beamParamsDB->getLER()).BoostToCM().
Unit();
310 return pos.
Dot(boostDir);
313 double vertexTruthOrthogonalBoostDirection(
const Particle* part)
315 static DBObjPtr<BeamParameters> beamParamsDB;
316 B2Vector3D boost = -(beamParamsDB->getHER() + beamParamsDB->getLER()).BoostToCM();
317 B2Vector3D orthBoostDir = getUnitOrthogonal(boost);
322 return pos.
Dot(orthBoostDir);
325 double vertexErrBoostDirection(
const Particle* part)
327 TVectorD bDir = toVec(PCmsLabTransform().getBoostVector().Unit());
329 return sqrt(part->getVertexErrorMatrix().Similarity(bDir));
332 double vertexErrOrthBoostDirection(
const Particle* part)
334 TVectorD oDir = toVec(getUnitOrthogonal(PCmsLabTransform().getBoostVector()));
336 return sqrt(part->getVertexErrorMatrix().Similarity(oDir));
341 double tagVBoostDirection(
const Particle* part)
343 auto* vert = part->getRelatedTo<TagVertex>();
345 return vert->getTagVl();
348 double tagVOrthogonalBoostDirection(
const Particle* part)
350 auto* vert = part->getRelatedTo<TagVertex>();
352 return vert->getTagVol();
355 double tagVTruthBoostDirection(
const Particle* part)
357 auto* vert = part->getRelatedTo<TagVertex>();
359 return vert->getTruthTagVl();
362 double tagVTruthOrthogonalBoostDirection(
const Particle* part)
364 auto* vert = part->getRelatedTo<TagVertex>();
366 return vert->getTruthTagVol();
369 double tagVErrBoostDirection(
const Particle* part)
371 auto* vert = part->getRelatedTo<TagVertex>();
373 return vert->getTagVlErr();
376 double tagVErrOrthogonalBoostDirection(
const Particle* part)
378 auto* vert = part->getRelatedTo<TagVertex>();
380 return vert->getTagVolErr();
385 double particleCosThetaBoostDirection(
const Particle* part)
388 B2Vector3D boost = PCmsLabTransform().getBoostVector();
389 ROOT::Math::PxPyPzEVector pxpypze = frame.getMomentum(part);
390 B2Vector3D momentum(pxpypze.Px(), pxpypze.Py(), pxpypze.Pz());
391 return cos(momentum.Angle(boost));
394 double particleInternalTagVMCFlavor(
const Particle* part)
396 auto* vert = part->getRelatedTo<TagVertex>();
398 return vert->getMCTagBFlavor();
401 double tagTrackMomentum(
const Particle* part,
const std::vector<double>& trackIndex)
403 auto* vert = part->getRelatedTo<TagVertex>();
407 unsigned trackIndexInt = trackIndex.at(0);
409 return vert->getVtxFitTrackP(trackIndexInt).R();
412 double tagTrackMomentumX(
const Particle* part,
const std::vector<double>& trackIndex)
414 auto* vert = part->getRelatedTo<TagVertex>();
418 unsigned trackIndexInt = trackIndex.at(0);
420 return vert->getVtxFitTrackP(trackIndexInt).X();
423 double tagTrackMomentumY(
const Particle* part,
const std::vector<double>& trackIndex)
425 auto* vert = part->getRelatedTo<TagVertex>();
429 unsigned trackIndexInt = trackIndex.at(0);
431 return vert->getVtxFitTrackP(trackIndexInt).Y();
434 double tagTrackMomentumZ(
const Particle* part,
const std::vector<double>& trackIndex)
436 auto* vert = part->getRelatedTo<TagVertex>();
440 unsigned trackIndexInt = trackIndex.at(0);
442 return vert->getVtxFitTrackP(trackIndexInt).Z();
445 double tagTrackZ0(
const Particle* part,
const std::vector<double>& trackIndex)
447 auto* vert = part->getRelatedTo<TagVertex>();
451 unsigned trackIndexInt = trackIndex.at(0);
453 return vert->getVtxFitTrackZ0(trackIndexInt);
456 double tagTrackD0(
const Particle* part,
const std::vector<double>& trackIndex)
458 auto* vert = part->getRelatedTo<TagVertex>();
462 unsigned trackIndexInt = trackIndex.at(0);
464 return vert->getVtxFitTrackD0(trackIndexInt);
467 double tagTrackRaveWeight(
const Particle* part,
const std::vector<double>& trackIndex)
469 auto* vert = part->getRelatedTo<TagVertex>();
473 unsigned trackIndexInt = trackIndex.at(0);
475 return vert->getRaveWeight(trackIndexInt);
478 double tagTrackDistanceToConstraint(
const Particle* part,
const std::vector<double>& trackIndex)
480 auto* vert = part->getRelatedTo<TagVertex>();
484 unsigned trackIndexInt = trackIndex.at(0);
487 const Particle* tagParticle(vert->getVtxFitParticle(trackIndexInt));
491 tagParticle->getMomentum(),
492 vert->getConstraintCenter());
495 double getY4Sx(
const Particle* part)
497 auto* vert = part->getRelatedTo<TagVertex>();
499 return vert->getConstraintCenter().X();
502 double getY4Sy(
const Particle* part)
504 auto* vert = part->getRelatedTo<TagVertex>();
506 return vert->getConstraintCenter().Y();
509 double getY4Sz(
const Particle* part)
511 auto* vert = part->getRelatedTo<TagVertex>();
513 return vert->getConstraintCenter().Z();
516 double getSigBdecayTime(
const Particle* part)
518 auto* vert = part->getRelatedTo<TagVertex>();
520 B2Vector3D vtxY4S = vert->getConstraintCenter();
522 ROOT::Math::PxPyPzEVector p4Sig = part->get4Vector();
526 double betaSig = p4Sig.Beta();
527 double gammaSig = 1 / sqrt(1 - betaSig * betaSig);
532 double tSig = (vtxSigB - vtxY4S).Dot(nSig) / (c * betaSig * gammaSig);
536 double getTagBdecayTime(
const Particle* part)
538 auto* vert = part->getRelatedTo<TagVertex>();
541 B2Vector3D vtxY4S = vert->getConstraintCenter();
543 ROOT::Math::PxPyPzEVector p4Sig = part->get4Vector();
544 ROOT::Math::PxPyPzEVector p4SigCms = PCmsLabTransform().labToCms(p4Sig);
546 ROOT::Math::PxPyPzEVector p4TagCms(-p4SigCms.px(), -p4SigCms.py(), -p4SigCms.pz(), p4SigCms.E());
547 ROOT::Math::PxPyPzEVector p4Tag = PCmsLabTransform().cmsToLab(p4TagCms);
551 double betaTag = p4Tag.Beta();
552 double gammaTag = 1 / sqrt(1 - betaTag * betaTag);
557 double tTag = (vtxTagB - vtxY4S).Dot(nTag) / (c * betaTag * gammaTag);
561 double getDeltaT3D(
const Particle* part)
563 return getSigBdecayTime(part) - getTagBdecayTime(part);
566 double tagTrackDistanceToConstraintErr(
const Particle* part,
const std::vector<double>& trackIndex)
568 auto* vert = part->getRelatedTo<TagVertex>();
572 unsigned trackIndexInt = trackIndex.at(0);
575 const Particle* tagParticle(vert->getVtxFitParticle(trackIndexInt));
579 TMatrixDSym trackPosCovMat = tagParticle->getVertexErrorMatrix();
582 tagParticle->getMomentum(),
583 vert->getConstraintCenter(),
585 vert->getConstraintCov());
588 double tagTrackDistanceToConstraintSignificance(
const Particle* part,
const std::vector<double>& trackIndex)
590 double val = tagTrackDistanceToConstraint(part, trackIndex);
592 double err = tagTrackDistanceToConstraintErr(part, trackIndex);
598 double tagVDistanceToConstraint(
const Particle* part)
600 auto* vert = part->getRelatedTo<TagVertex>();
606 vert->getTagVertex());
609 double tagVDistanceToConstraintErr(
const Particle* part)
611 auto* vert = part->getRelatedTo<TagVertex>();
619 TMatrixDSym emptyMat(3);
622 vert->getTagVertex(),
623 vert->getConstraintCov(),
627 double tagVDistanceToConstraintSignificance(
const Particle* part)
629 double val = tagVDistanceToConstraint(part);
631 double err = tagVDistanceToConstraintErr(part);
637 double tagTrackDistanceToTagV(
const Particle* part,
const std::vector<double>& trackIndex)
639 auto* vert = part->getRelatedTo<TagVertex>();
643 unsigned trackIndexInt = trackIndex.at(0);
645 const Particle* particle = vert->getVtxFitParticle(trackIndexInt);
649 particle->getMomentum(),
650 vert->getTagVertex());
653 double tagTrackDistanceToTagVErr(
const Particle* part,
const std::vector<double>& trackIndex)
655 auto* vert = part->getRelatedTo<TagVertex>();
659 unsigned trackIndexInt = trackIndex.at(0);
661 const Particle* tagParticle(vert->getVtxFitParticle(trackIndexInt));
665 TMatrixDSym trackPosCovMat = tagParticle->getVertexErrorMatrix();
671 TMatrixDSym emptyMat(3);
674 tagParticle->getMomentum(),
675 vert->getTagVertex(),
681 double tagTrackDistanceToTagVSignificance(
const Particle* part,
const std::vector<double>& trackIndex)
683 double val = tagTrackDistanceToTagV(part, trackIndex);
685 double err = tagTrackDistanceToTagVErr(part, trackIndex);
691 double tagTrackTrueDistanceToTagV(
const Particle* part,
const std::vector<double>& trackIndex)
693 auto* vert = part->getRelatedTo<TagVertex>();
697 unsigned trackIndexInt = trackIndex.at(0);
699 const MCParticle* mcParticle(vert->getVtxFitMCParticle(trackIndexInt));
704 if (mcTagV(0) == 0 && mcTagV(1) == 0 && mcTagV(2) == 0)
return Const::doubleNaN;
707 mcParticle->getMomentum(),
711 B2Vector3D tagTrackTrueVecToTagV(
const Particle* part,
const std::vector<double>& trackIndex)
713 auto* vert = part->getRelatedTo<TagVertex>();
714 if (!vert)
return vecNaN;
716 if (trackIndex.size() != 1)
return vecNaN;
717 unsigned trackIndexInt = trackIndex.
at(0);
719 const MCParticle* mcParticle(vert->getVtxFitMCParticle(trackIndexInt));
720 if (!mcParticle)
return vecNaN;
724 if (mcTagV(0) == 0 && mcTagV(1) == 0 && mcTagV(2) == 0)
return vecNaN;
727 mcParticle->getMomentum(),
731 double tagTrackTrueVecToTagVX(
const Particle* part,
const std::vector<double>& trackIndex)
733 B2Vector3D result = tagTrackTrueVecToTagV(part, trackIndex);
737 double tagTrackTrueVecToTagVY(
const Particle* part,
const std::vector<double>& trackIndex)
739 B2Vector3D result = tagTrackTrueVecToTagV(part, trackIndex);
743 double tagTrackTrueVecToTagVZ(
const Particle* part,
const std::vector<double>& trackIndex)
745 B2Vector3D result = tagTrackTrueVecToTagV(part, trackIndex);
749 B2Vector3D tagTrackTrueMomentum(
const Particle* part,
const std::vector<double>& trackIndex)
751 auto* vert = part->getRelatedTo<TagVertex>();
752 if (!vert)
return vecNaN;
754 if (trackIndex.size() != 1)
return vecNaN;
755 unsigned trackIndexInt = trackIndex.
at(0);
757 const MCParticle* mcParticle(vert->getVtxFitMCParticle(trackIndexInt));
758 if (!mcParticle)
return vecNaN;
760 return mcParticle->getMomentum();
763 double tagTrackTrueMomentumX(
const Particle* part,
const std::vector<double>& trackIndex)
765 B2Vector3D pTrue = tagTrackTrueMomentum(part, trackIndex);
769 double tagTrackTrueMomentumY(
const Particle* part,
const std::vector<double>& trackIndex)
771 B2Vector3D pTrue = tagTrackTrueMomentum(part, trackIndex);
775 double tagTrackTrueMomentumZ(
const Particle* part,
const std::vector<double>& trackIndex)
777 B2Vector3D pTrue = tagTrackTrueMomentum(part, trackIndex);
781 B2Vector3D tagTrackTrueOrigin(
const Particle* part,
const std::vector<double>& trackIndex)
783 auto* vert = part->getRelatedTo<TagVertex>();
784 if (!vert)
return vecNaN;
786 if (trackIndex.size() != 1)
return vecNaN;
787 unsigned trackIndexInt = trackIndex.
at(0);
789 const MCParticle* mcParticle(vert->getVtxFitMCParticle(trackIndexInt));
790 if (!mcParticle)
return vecNaN;
792 return mcParticle->getProductionVertex();
795 double tagTrackTrueOriginX(
const Particle* part,
const std::vector<double>& trackIndex)
797 B2Vector3D origin = tagTrackTrueOrigin(part, trackIndex);
801 double tagTrackTrueOriginY(
const Particle* part,
const std::vector<double>& trackIndex)
803 B2Vector3D origin = tagTrackTrueOrigin(part, trackIndex);
807 double tagTrackTrueOriginZ(
const Particle* part,
const std::vector<double>& trackIndex)
809 B2Vector3D origin = tagTrackTrueOrigin(part, trackIndex);
813 int fitTruthStatus(
const Particle* part)
815 auto* vert = part->getRelatedTo<TagVertex>();
816 if (!vert)
return -1;
817 return vert->getFitTruthStatus();
820 int rollbackStatus(
const Particle* part)
822 auto* vert = part->getRelatedTo<TagVertex>();
823 if (!vert)
return -1;
824 return vert->getRollBackStatus();
836 TagTrFPtr getTagTrackFunctionFromName(
string const& name)
838 if (name ==
"TagTrackMomentum")
return tagTrackMomentum;
839 else if (name ==
"TagTrackMomentumX")
return tagTrackMomentumX;
840 else if (name ==
"TagTrackMomentumY")
return tagTrackMomentumY;
841 else if (name ==
"TagTrackMomentumZ")
return tagTrackMomentumZ;
842 else if (name ==
"TagTrackZ0")
return tagTrackZ0;
843 else if (name ==
"TagTrackD0")
return tagTrackD0;
844 else if (name ==
"TagTrackRaveWeight")
return tagTrackRaveWeight;
845 else if (name ==
"TagTrackDistanceToConstraint")
return tagTrackDistanceToConstraint;
846 else if (name ==
"TagTrackDistanceToConstraintErr")
return tagTrackDistanceToConstraintErr;
847 else if (name ==
"TagTrackDistanceToConstraintSignificance")
return tagTrackDistanceToConstraintSignificance;
848 else if (name ==
"TagTrackDistanceToTagV")
return tagTrackDistanceToTagV;
849 else if (name ==
"TagTrackDistanceToTagVErr")
return tagTrackDistanceToTagVErr;
850 else if (name ==
"TagTrackDistanceToTagVSignificance")
return tagTrackDistanceToTagVSignificance;
851 else if (name ==
"TagTrackTrueDistanceToTagV")
return tagTrackTrueDistanceToTagV;
852 else if (name ==
"TagTrackTrueVecToTagVX")
return tagTrackTrueVecToTagVX;
853 else if (name ==
"TagTrackTrueVecToTagVY")
return tagTrackTrueVecToTagVY;
854 else if (name ==
"TagTrackTrueVecToTagVZ")
return tagTrackTrueVecToTagVZ;
855 else if (name ==
"TagTrackTrueMomentumX")
return tagTrackTrueMomentumX;
856 else if (name ==
"TagTrackTrueMomentumY")
return tagTrackTrueMomentumY;
857 else if (name ==
"TagTrackTrueMomentumZ")
return tagTrackTrueMomentumZ;
858 else if (name ==
"TagTrackTrueOriginX")
return tagTrackTrueOriginX;
859 else if (name ==
"TagTrackTrueOriginY")
return tagTrackTrueOriginY;
860 else if (name ==
"TagTrackTrueOriginZ")
return tagTrackTrueOriginZ;
862 B2ERROR(
"From TimeDependentVariables: Trying to access unknown tagTrack function");
866 double cumulate(
const Particle* part,
const std::vector<std::string>& variable,
double start,
867 std::function<
double(
double,
double,
double)> fun)
869 TagTrFPtr fptr(getTagTrackFunctionFromName(variable.at(0)));
870 auto* vert = part->getRelatedTo<TagVertex>();
872 int nTracks = vert->getNFitTracks();
876 for (
int i = 0; i < nTracks; ++i) {
877 vector<double> indx(1, i);
878 double w = tagTrackRaveWeight(part, indx);
879 double f = (*fptr)(part, indx);
881 acum = fun(acum, f, w);
889 if (variable.size() != 1) {
890 B2FATAL(
"Wrong number of arguments for meta function tagTrackAverage");
894 return [variable](
const Particle * part) ->
double {
895 double sum = cumulate(part, variable, 0, [](
double s,
double f,
double) {
return s + f;});
896 double tot = cumulate(part, variable, 0, [](
double s,
double,
double) {
return s + 1;});
903 if (variable.size() != 1) {
904 B2FATAL(
"Wrong number of arguments for meta function tagTrackAverageSquares");
908 return [variable](
const Particle * part) ->
double {
909 double sum = cumulate(part, variable, 0, [](
double s,
double f,
double) {
return s + f * f;});
910 double tot = cumulate(part, variable, 0, [](
double s,
double,
double) {
return s + 1;});
918 if (variable.size() != 1) {
919 B2FATAL(
"Wrong number of arguments for meta function tagTrackMax");
923 return [variable](
const Particle * part) ->
double {
924 double Max = cumulate(part, variable, -DBL_MAX, [](
double s,
double f,
double) {
return std::max(s, f);});
931 if (variable.size() != 1) {
932 B2FATAL(
"Wrong number of arguments for meta function tagTrackMin");
936 return [variable](
const Particle * part) ->
double {
937 double Min = cumulate(part, variable, +DBL_MAX, [](
double s,
double f,
double) {
return std::min(s, f);});
944 if (variable.size() != 1) {
945 B2FATAL(
"Wrong number of arguments for meta function tagTrackWeightedAverage");
949 return [variable](
const Particle * part) ->
double {
950 double num = cumulate(part, variable, 0, [](
double s,
double f,
double w) {
return s + w * f;});
951 double den = cumulate(part, variable, 0, [](
double s,
double,
double w) {
return s + w;});
958 if (variable.size() != 1) {
959 B2FATAL(
"Wrong number of arguments for meta function tagTrackWeightedAverageSquares");
963 return [variable](
const Particle * part) ->
double {
964 double num = cumulate(part, variable, 0, [](
double s,
double f,
double w) {
return s + w * f * f;});
965 double den = cumulate(part, variable, 0, [](
double s,
double,
double w) {
return s + w;});
972 if (variable.size() != 1) {
973 B2FATAL(
"Wrong number of arguments for meta function tagTrackSum");
977 return [variable](
const Particle * part) ->
double {
978 return cumulate(part, variable, 0, [](
double s,
double f,
double) {
return s + f;});
986 VARIABLE_GROUP(
"Time Dependent CPV Analysis Variables");
988 REGISTER_VARIABLE(
"TagVx", particleTagVx,
"Tag vertex X component\n\n",
"cm");
989 REGISTER_VARIABLE(
"TagVy", particleTagVy,
"Tag vertex Y component\n\n",
"cm");
990 REGISTER_VARIABLE(
"TagVz", particleTagVz,
"Tag vertex Z component\n\n",
"cm");
991 REGISTER_VARIABLE(
"mcTagVx", particleTruthTagVx,
"Generated Tag vertex X component\n\n",
"cm");
992 REGISTER_VARIABLE(
"mcTagVy", particleTruthTagVy,
"Generated Tag vertex Y component\n\n",
"cm");
993 REGISTER_VARIABLE(
"mcTagVz", particleTruthTagVz,
"Generated Tag vertex Z component\n\n",
"cm");
994 REGISTER_VARIABLE(
"TagVxErr", particleTagVxErr,
"Tag vertex X component uncertainty\n\n",
"cm");
995 REGISTER_VARIABLE(
"TagVyErr", particleTagVyErr,
"Tag vertex Y component uncertainty\n\n",
"cm");
996 REGISTER_VARIABLE(
"TagVzErr", particleTagVzErr,
"Tag vertex Z component uncertainty\n\n",
"cm");
997 REGISTER_VARIABLE(
"TagVCov(i,j)", particleTagVCov,
998 "returns the (i,j)-th element of the Tag vertex covariance matrix (3x3).\n"
999 "Order of elements in the covariance matrix is: x, y, z.\n\n",
"cm, cm, cm");
1001 REGISTER_VARIABLE(
"TagVpVal", particleTagVpVal,
"Tag vertex p-Value");
1002 REGISTER_VARIABLE(
"TagVNTracks", particleTagVNTracks,
"Number of tracks in the tag vertex");
1003 REGISTER_VARIABLE(
"TagVType", particleTagVType,
1004 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");
1005 REGISTER_VARIABLE("TagVNDF", particleTagVNDF,
"Number of degrees of freedom in the tag vertex fit");
1006 REGISTER_VARIABLE(
"TagVChi2", particleTagVChi2,
"chi2 value of the tag vertex fit");
1007 REGISTER_VARIABLE(
"TagVChi2IP", particleTagVChi2IP,
"IP component of chi2 value of the tag vertex fit");
1009 REGISTER_VARIABLE(
"DeltaT", particleDeltaT, R
"DOC(
1010 Proper decay time difference :math:`\Delta t` between signal B-meson :math:`(B_{rec})` and tag B-meson :math:`(B_{tag})`.
1013 REGISTER_VARIABLE(
"DeltaTErr", particleDeltaTErr, R
"DOC(
1014 Proper decay time difference :math:`\Delta t` uncertainty
1017 REGISTER_VARIABLE(
"DeltaTRes", particleDeltaTRes, R
"DOC(
1018 :math:`\Delta t` residual, to be used for resolution function studies
1021 REGISTER_VARIABLE(
"DeltaTBelle", particleDeltaTBelle, R
"DOC(
1022 [Legacy] :math:`\Delta t`, as it was used in Belle
1025 REGISTER_VARIABLE(
"mcDeltaTau", particleMCDeltaTau,
1026 R
"DOC(Generated proper decay time difference :math:`\Delta t`: :math:`\tau(B_{\rm rec})-\tau(B_{\rm tag})`
1029 REGISTER_VARIABLE(
"mcDeltaT", particleMCDeltaT,
1030 R
"DOC(Generated proper decay time difference (in z-difference approximation) :math:`\Delta t`:
1031 :math:`(l(B_{\rm rec}) - l(B_{\rm tag}))/\beta_{\Upsilon(4S)}\gamma_{\Upsilon(4S)}`
1034 REGISTER_VARIABLE("mcDeltaBoost", particleMCDeltaBoost,
1035 R"DOC(True difference of decay vertex boost-direction components between signal B-meson :math:`(B_{rec})` and tag B-meson :math:`(B_{tag})`:
1036:math:`\Delta l = l(B_{rec}) - l(B_{tag})`
1039 REGISTER_VARIABLE(
"DeltaZ", particleDeltaZ,
1040 R
"DOC(Difference of decay vertex longitudinal components between signal B-meson :math:`(B_{rec})` and tag B-meson :math:`(B_{tag})`:
1041:math:`\Delta z = z(B_{rec}) - z(B_{tag})`
1044 REGISTER_VARIABLE(
"DeltaZErr", particleDeltaZErr,
1045 R
"DOC(Uncertainty of the difference :math:`z(B_{rec}) - z(B_{tag})`
1048 REGISTER_VARIABLE(
"DeltaBoost", particleDeltaB, R
"DOC(:math:`\Delta z` in the boost direction
1051 REGISTER_VARIABLE(
"DeltaBoostErr", particleDeltaBErr, R
"DOC(Uncertainty of :math:`\Delta z` in the boost direction
1055 REGISTER_VARIABLE(
"LBoost", vertexBoostDirection,
1056 "Returns the vertex component in the boost direction\n\n",
"cm");
1057 REGISTER_VARIABLE(
"OBoost", vertexOrthogonalBoostDirection,
1058 "Returns the vertex component in the direction orthogonal to the boost\n\n",
"cm");
1059 REGISTER_VARIABLE(
"mcLBoost", vertexTruthBoostDirection,
1060 "Returns the MC vertex component in the boost direction\n\n",
"cm");
1061 REGISTER_VARIABLE(
"mcOBoost", vertexTruthOrthogonalBoostDirection,
1062 "Returns the MC vertex component in the direction orthogonal to the boost\n\n",
"cm");
1063 REGISTER_VARIABLE(
"LBoostErr", vertexErrBoostDirection,
1064 "Returns the error of the vertex in the boost direction\n\n",
"cm");
1065 REGISTER_VARIABLE(
"OBoostErr", vertexErrOrthBoostDirection,
1066 "Returns the error of the vertex in the direction orthogonal to the boost\n\n",
"cm");
1068 REGISTER_VARIABLE(
"Y4SvtxX", getY4Sx,
"Returns X component of Y4S vertex.\n"
1069 "The result is meaningful and nontrivial when the signal B vertex "
1070 "is determined by `vertex.treeFit` with ``ipConstraint=True`` and the `vertex.TagV` is called with the ``tube`` constraint.\n\n",
"cm");
1072 REGISTER_VARIABLE(
"Y4SvtxY", getY4Sy,
"Returns Y component of Y4S vertex.\n"
1073 "The result is meaningful and nontrivial when the signal B vertex "
1074 "is determined by `vertex.treeFit` with ``ipConstraint=True`` and the `vertex.TagV` is called with the ``tube`` constraint.\n\n",
"cm");
1076 REGISTER_VARIABLE(
"Y4SvtxZ", getY4Sz,
"Returns Z component of Y4S vertex.\n"
1077 "The result is meaningful and nontrivial when the signal B vertex "
1078 "is determined by `vertex.treeFit` with ``ipConstraint=True`` and the `vertex.TagV` is called with the ``tube`` constraint.\n\n",
"cm");
1081 REGISTER_VARIABLE(
"tSigB", getSigBdecayTime,
"Returns the proper decay time of the fully reconstructed signal B meson.\n"
1082 "The result is meaningful and nontrivial when the signal B vertex "
1083 "is determined by `vertex.treeFit` with ``ipConstraint=True`` and the `vertex.TagV` is called with the ``tube`` constraint.\n\n",
"ps");
1085 REGISTER_VARIABLE(
"tTagB", getTagBdecayTime,
"Returns the proper decay time of the tagged B meson.\n"
1086 "The result is meaningful and nontrivial when the signal B vertex "
1087 "is determined by `vertex.treeFit` with ``ipConstraint=True`` and the `vertex.TagV` is called with the ``tube`` constraint.\n\n",
"ps");
1089 REGISTER_VARIABLE(
"DeltaT3D", getDeltaT3D, R
"DOC(
1090 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.
1092 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.
1096 REGISTER_VARIABLE(
"TagVLBoost", tagVBoostDirection,
1097 "Returns the TagV component in the boost direction\n\n",
"cm");
1098 REGISTER_VARIABLE(
"TagVOBoost", tagVOrthogonalBoostDirection,
1099 "Returns the TagV component in the direction orthogonal to the boost\n\n",
"cm");
1100 REGISTER_VARIABLE(
"mcTagVLBoost", tagVTruthBoostDirection,
1101 "Returns the MC TagV component in the boost direction\n\n",
"cm");
1102 REGISTER_VARIABLE(
"mcTagVOBoost", tagVTruthOrthogonalBoostDirection,
1103 "Returns the MC TagV component in the direction orthogonal to the boost\n\n",
"cm");
1104 REGISTER_VARIABLE(
"TagVLBoostErr", tagVErrBoostDirection,
1105 "Returns the error of TagV in the boost direction\n\n",
"cm");
1106 REGISTER_VARIABLE(
"TagVOBoostErr", tagVErrOrthogonalBoostDirection,
1107 "Returns the error of TagV in the direction orthogonal to the boost\n\n",
"cm");
1109 REGISTER_VARIABLE(
"cosAngleBetweenMomentumAndBoostVector", particleCosThetaBoostDirection,
1110 "cosine of the angle between momentum and boost vector");
1112 REGISTER_VARIABLE(
"internalTagVMCFlavor", particleInternalTagVMCFlavor,
1113 "[Expert] [Debugging] This variable is only for internal checks of the TagV module by developers. \n"
1114 "It returns the internal mc flavor information of the tag-side B provided by the TagV module.");
1116 REGISTER_VARIABLE(
"TagTrackMomentum(i) ", tagTrackMomentum,
1117 "Returns the magnitude of the momentum of the ith track used in the tag vtx fit.\n\n",
"GeV/c");
1118 REGISTER_VARIABLE(
"TagTrackMomentumX(i) ", tagTrackMomentumX,
1119 "Returns the X component of the momentum of the ith track used in the tag vtx fit.\n\n",
"GeV/c");
1120 REGISTER_VARIABLE(
"TagTrackMomentumY(i) ", tagTrackMomentumY,
1121 "Returns the Y component of the momentum of the ith track used in the tag vtx fit.\n\n",
"GeV/c");
1122 REGISTER_VARIABLE(
"TagTrackMomentumZ(i) ", tagTrackMomentumZ,
1123 "Returns the Z component of the momentum of the ith track used in the tag vtx fit.\n\n",
"GeV/c");
1125 REGISTER_VARIABLE(
"TagTrackZ0(i)", tagTrackZ0,
"Returns the z0 parameter of the ith track used in the tag vtx fit\n\n",
"cm");
1126 REGISTER_VARIABLE(
"TagTrackD0(i)", tagTrackD0,
"Returns the d0 parameter of the ith track used in the tag vtx fit\n\n",
"cm");
1129 REGISTER_VARIABLE(
"TagTrackRaveWeight(i)", tagTrackRaveWeight,
"Returns the weight assigned by Rave to track i");
1131 REGISTER_VARIABLE(
"TagVNFitTracks", particleTagVNFitTracks,
1132 "returns the number of tracks used by rave to fit the vertex (not counting the ones coming from Kshorts)");
1134 REGISTER_VARIABLE(
"TagTrackDistanceToConstraint(i)", tagTrackDistanceToConstraint,
1135 "Returns the measured distance between the ith tag track and the centre of the constraint.\n\n",
"cm");
1137 REGISTER_VARIABLE(
"TagTrackDistanceToConstraintErr(i)", tagTrackDistanceToConstraintErr,
1138 "Returns the estimated error on the distance between the ith tag track and the centre of the constraint.\n\n",
"cm");
1140 REGISTER_VARIABLE(
"TagTrackDistanceToConstraintSignificance(i)", tagTrackDistanceToConstraintSignificance,
1141 "Returns the significance of the distance between the centre of the constraint and the tag track indexed by track index (computed as distance / uncertainty)");
1144 REGISTER_VARIABLE(
"TagVDistanceToConstraint", tagVDistanceToConstraint,
1145 "returns the measured distance between the tag vtx and the centre of the constraint.\n\n",
"cm");
1147 REGISTER_VARIABLE(
"TagVDistanceToConstraintErr", tagVDistanceToConstraintErr,
1148 "returns the estimated error on the distance between the tag vtx and the centre of the constraint.\n\n",
"cm");
1150 REGISTER_VARIABLE(
"TagVDistanceToConstraintSignificance", tagVDistanceToConstraintSignificance,
1151 "returns the significance of the distance between the tag vtx and the centre of the constraint (computed as distance / uncertainty)");
1153 REGISTER_VARIABLE(
"TagTrackDistanceToTagV(i)", tagTrackDistanceToTagV,
1154 "Returns the measured distance between the ith tag track and the tag vtx.\n\n",
"cm");
1156 REGISTER_VARIABLE(
"TagTrackDistanceToTagVErr(i)", tagTrackDistanceToTagVErr, R
"DOC(
1157Returns the estimated error on the distance between the ith tag track and the tag vtx.
1159.. warning:: Only the uncertainties on the track position parameters are taken into account.
1163 REGISTER_VARIABLE(
"TagTrackDistanceToTagVSignificance(i)", tagTrackDistanceToTagVSignificance,
1164 "Returns the significance of the distance between the tag vtx and the tag track indexed by trackIndex (computed as distance / uncertainty)");
1166 REGISTER_VARIABLE(
"TagTrackTrueDistanceToTagV(i)", tagTrackTrueDistanceToTagV,
1167 "Returns the true distance between the true B Tag decay vertex and the particle corresponding to the ith tag vtx track.\n\n",
"cm");
1169 REGISTER_VARIABLE(
"TagTrackTrueVecToTagVX(i)", tagTrackTrueVecToTagVX,
1170 "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",
1173 REGISTER_VARIABLE(
"TagTrackTrueVecToTagVY(i)", tagTrackTrueVecToTagVY,
1174 "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",
1177 REGISTER_VARIABLE(
"TagTrackTrueVecToTagVZ(i)", tagTrackTrueVecToTagVZ,
1178 "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",
1181 REGISTER_VARIABLE(
"TagTrackTrueMomentumX(i)", tagTrackTrueMomentumX,
1182 "Returns the X component of the true momentum of the MC particle corresponding to the ith tag vtx track.\n\n",
"GeV/c");
1184 REGISTER_VARIABLE(
"TagTrackTrueMomentumY(i)", tagTrackTrueMomentumY,
1185 "Returns the Y component of the true momentum of the MC particle corresponding to the ith tag vtx track.\n\n",
"GeV/c");
1187 REGISTER_VARIABLE(
"TagTrackTrueMomentumZ(i)", tagTrackTrueMomentumZ,
1188 "Returns the Z component of the true momentum of the MC particle corresponding to the ith tag vtx track.\n\n",
"GeV/c");
1190 REGISTER_VARIABLE(
"TagTrackTrueOriginX(i)", tagTrackTrueOriginX,
1191 "Returns the X component of the true origin of the MC particle corresponding to the ith tag vtx track.\n\n",
"cm");
1193 REGISTER_VARIABLE(
"TagTrackTrueOriginY(i)", tagTrackTrueOriginY,
1194 "Returns the Y component of the true origin of the MC particle corresponding to the ith tag vtx track.\n\n",
"cm");
1196 REGISTER_VARIABLE(
"TagTrackTrueOriginZ(i)", tagTrackTrueOriginZ,
1197 "Returns the Z component of the true origin of the MC particle corresponding to the ith tag vtx track.\n\n",
"cm");
1199 REGISTER_VARIABLE(
"TagVFitTruthStatus", fitTruthStatus, R
"DOC(
1200Returns the status of the fit performed with the truth info. Possible values are:
1202- -1: no related TagVertex found
1203- 0: fit performed with measured parameters
1204- 1: fit performed with true parameters
1205- 2: unable to recover truth parameters
1208 REGISTER_VARIABLE("TagVRollBackStatus", rollbackStatus, R
"DOC(
1209Returns the status of the fit performed with rolled back tracks. Possible values are:
1211- -1: no related TagVertex found
1212- 0: fit performed with measured parameters
1213- 1: fit performed with true parameters
1214- 2: unable to recover truth parameters
1217 REGISTER_METAVARIABLE("TagTrackMax(var)", tagTrackMax,
1218 "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.",
1219 Manager::VariableDataType::c_double);
1221 REGISTER_METAVARIABLE(
"TagTrackMin(var)", tagTrackMin,
1222 "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.",
1223 Manager::VariableDataType::c_double);
1225 REGISTER_METAVARIABLE(
"TagTrackAverage(var)", tagTrackAverage,
1226 "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.",
1227 Manager::VariableDataType::c_double);
1229 REGISTER_METAVARIABLE(
"TagTrackAverageSquares(var)", tagTrackAverageSquares,
1230 "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.",
1231 Manager::VariableDataType::c_double);
1233 REGISTER_METAVARIABLE(
"TagTrackWeightedAverage(var)", tagTrackWeightedAverage,
1234 "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)``.",
1235 Manager::VariableDataType::c_double);
1237 REGISTER_METAVARIABLE(
"TagTrackWeightedAverageSquares(var)", tagTrackWeightedAverageSquares,
1238 "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)``.",
1239 Manager::VariableDataType::c_double);
1241 REGISTER_METAVARIABLE(
"TagTrackSum(var)", tagTrackSum,
1242 "Returns the sum of the provided variable for all tag tracks. The variable must be one of the TagTrackXXX variables, "
1243 "for example ``TagTrackSum(TagTrackD0)``. The tracks that are assigned a zero weight are ignored.",
1244 Manager::VariableDataType::c_double);
DataType Dot(const B2Vector3< DataType > &p) const
Scalar product.
B2Vector3< DataType > Unit() const
Unit vector parallel to this.
static const double speedOfLight
[cm/ns]
static const double doubleNaN
quiet_NaN
const MCParticle * getMCParticle() const
Returns the pointer to the MCParticle object that was used to create this Particle (ParticleType == c...
static const ReferenceFrame & GetCurrent()
Get current rest frame.
std::function< VarVariant(const Particle *)> FunctionPtr
functions stored take a const Particle* and return VarVariant.
Class to store variables with their name which were sent to the logging service.
B2Vector3< float > B2Vector3F
typedef for common usage with float
B2Vector3< double > B2Vector3D
typedef for common usage with double
DataType at(unsigned i) const
safe member access (with boundary check!)
Abstract base class for different kinds of events.