10 #include <analysis/variables/TimeDependentVariables.h>
11 #include <analysis/VariableManager/Manager.h>
13 #include <analysis/utility/PCmsLabTransform.h>
14 #include <framework/dbobjects/BeamParameters.h>
17 #include <analysis/dataobjects/Particle.h>
18 #include <analysis/dataobjects/TagVertex.h>
19 #include <mdst/dataobjects/MCParticle.h>
22 #include <analysis/utility/DistanceTools.h>
23 #include <analysis/utility/RotationTools.h>
26 #include <framework/gearbox/Const.h>
45 using RotationTools::getUnitOrthogonal;
46 using RotationTools::toVec;
48 static const double realNaN = std::numeric_limits<double>::quiet_NaN();
55 double particleTagVx(
const Particle* particle)
57 auto* vert = particle->getRelatedTo<TagVertex>();
59 return vert->getTagVertex().X();
62 double particleTagVy(
const Particle* particle)
64 auto* vert = particle->getRelatedTo<TagVertex>();
66 return vert->getTagVertex().Y();
69 double particleTagVz(
const Particle* particle)
71 auto* vert = particle->getRelatedTo<TagVertex>();
73 return vert->getTagVertex().Z();
76 double particleTruthTagVx(
const Particle* particle)
78 auto* vert = particle->getRelatedTo<TagVertex>();
80 return vert->getMCTagVertex().X();
83 double particleTruthTagVy(
const Particle* particle)
85 auto* vert = particle->getRelatedTo<TagVertex>();
87 return vert->getMCTagVertex().Y();
90 double particleTruthTagVz(
const Particle* particle)
92 auto* vert = particle->getRelatedTo<TagVertex>();
94 return vert->getMCTagVertex().Z();
97 double particleTagVxErr(
const Particle* particle)
99 auto* vert = particle->getRelatedTo<TagVertex>();
101 TMatrixDSym TagVErr = vert->getTagVertexErrMatrix();
102 return sqrt(TagVErr(0, 0));
105 double particleTagVyErr(
const Particle* particle)
107 auto* vert = particle->getRelatedTo<TagVertex>();
109 TMatrixDSym TagVErr = vert->getTagVertexErrMatrix();
110 return sqrt(TagVErr(1, 1));
113 double particleTagVzErr(
const Particle* particle)
115 auto* vert = particle->getRelatedTo<TagVertex>();
117 TMatrixDSym TagVErr = vert->getTagVertexErrMatrix();
118 return sqrt(TagVErr(2, 2));
121 double particleTagVpVal(
const Particle* particle)
123 auto* vert = particle->getRelatedTo<TagVertex>();
125 return vert->getTagVertexPval();
128 double particleTagVNTracks(
const Particle* particle)
130 auto* vert = particle->getRelatedTo<TagVertex>();
132 return vert->getNTracks();
135 double particleTagVNFitTracks(
const Particle* particle)
137 auto* vert = particle->getRelatedTo<TagVertex>();
139 return vert->getNFitTracks();
142 double particleTagVType(
const Particle* particle)
144 auto* vert = particle->getRelatedTo<TagVertex>();
146 return vert->getFitType();
149 double particleTagVNDF(
const Particle* particle)
151 auto* vert = particle->getRelatedTo<TagVertex>();
153 return vert->getTagVNDF();
156 double particleTagVChi2(
const Particle* particle)
158 auto* vert = particle->getRelatedTo<TagVertex>();
160 return vert->getTagVChi2();
163 double particleTagVChi2IP(
const Particle* particle)
165 auto* vert = particle->getRelatedTo<TagVertex>();
167 return vert->getTagVChi2IP();
173 double particleDeltaT(
const Particle* particle)
175 auto* vert = particle->getRelatedTo<TagVertex>();
177 return vert->getDeltaT();
180 double particleDeltaTErr(
const Particle* particle)
182 auto* vert = particle->getRelatedTo<TagVertex>();
184 return vert->getDeltaTErr();
186 double particleDeltaTRes(
const Particle* particle)
188 return particleDeltaT(particle) - particleMCDeltaT(particle);
191 double particleDeltaTBelle(
const Particle* particle)
193 double beta = PCmsLabTransform().getBoostVector().Mag();
194 double bg = beta / sqrt(1 - beta * beta);
195 double c = Const::speedOfLight / 1000.;
196 return particleDeltaZ(particle) / bg / c;
198 double particleMCDeltaTau(
const Particle* particle)
200 auto* vert = particle->getRelatedTo<TagVertex>();
202 return vert->getMCDeltaTau();
205 double particleMCDeltaT(
const Particle* particle)
207 auto* vert = particle->getRelatedTo<TagVertex>();
209 return vert->getMCDeltaT();
212 double particleMCDeltaBoost(
const Particle* particle)
214 auto* vert = particle->getRelatedTo<TagVertex>();
217 double beta = PCmsLabTransform().getBoostVector().Mag();
218 double bg = beta / sqrt(1 - beta * beta);
219 double c = Const::speedOfLight / 1000.;
220 return vert->getMCDeltaT() * bg * c;
224 double particleDeltaZ(
const Particle* particle)
226 auto* vert = particle->getRelatedTo<TagVertex>();
228 return particle->getZ() - vert->getTagVertex().Z();
231 double particleDeltaZErr(
const Particle* particle)
233 auto* vert = particle->getRelatedTo<TagVertex>();
236 double zVariance = particle->getVertexErrorMatrix()(2, 2);
237 double TagVZVariance = vert->getTagVertexErrMatrix()(2, 2);
238 double result = sqrt(zVariance + TagVZVariance);
239 if (!std::isfinite(result))
return realNaN;
244 double particleDeltaB(
const Particle* particle)
246 auto* vert = particle->getRelatedTo<TagVertex>();
249 double beta = PCmsLabTransform().getBoostVector().Mag();
250 double bg = beta / sqrt(1 - beta * beta);
251 double c = Const::speedOfLight / 1000.;
252 return vert->getDeltaT() * bg * c;
255 double particleDeltaBErr(
const Particle* particle)
257 auto* vert = particle->getRelatedTo<TagVertex>();
260 double beta = PCmsLabTransform().getBoostVector().Mag();
261 double bg = beta / sqrt(1 - beta * beta);
262 double c = Const::speedOfLight / 1000.;
263 return vert->getDeltaTErr() * bg * c;
268 double vertexBoostDirection(
const Particle* part)
270 TVector3 boostDir = PCmsLabTransform().getBoostVector().Unit();
271 TVector3 pos = part->getVertex();
272 return pos.Dot(boostDir);
275 double vertexOrthogonalBoostDirection(
const Particle* part)
277 TVector3 boost = PCmsLabTransform().getBoostVector();
278 TVector3 orthBoostDir = getUnitOrthogonal(boost);
280 TVector3 pos = part->getVertex();
281 return pos.Dot(orthBoostDir);
284 double vertexTruthBoostDirection(
const Particle* part)
286 static DBObjPtr<BeamParameters> beamParamsDB;
287 TVector3 boostDir = (beamParamsDB->getHER() + beamParamsDB->getLER()).BoostVector().Unit();
289 const MCParticle* mcPart = part->getMCParticle();
291 TVector3 pos = mcPart->getDecayVertex();
292 return pos.Dot(boostDir);
295 double vertexTruthOrthogonalBoostDirection(
const Particle* part)
297 static DBObjPtr<BeamParameters> beamParamsDB;
298 TVector3 boost = (beamParamsDB->getHER() + beamParamsDB->getLER()).BoostVector();
299 TVector3 orthBoostDir = getUnitOrthogonal(boost);
301 const MCParticle* mcPart = part->getMCParticle();
303 TVector3 pos = mcPart->getDecayVertex();
304 return pos.Dot(orthBoostDir);
308 double vertexErrBoostDirection(
const Particle* part)
310 TVectorD bDir = toVec(PCmsLabTransform().getBoostVector().Unit());
312 return sqrt(part->getVertexErrorMatrix().Similarity(bDir));
316 double vertexErrOrthBoostDirection(
const Particle* part)
318 TVectorD oDir = toVec(getUnitOrthogonal(PCmsLabTransform().getBoostVector()));
320 return sqrt(part->getVertexErrorMatrix().Similarity(oDir));
327 double tagVBoostDirection(
const Particle* part)
329 auto* vert = part->getRelatedTo<TagVertex>();
331 return vert->getTagVl();
335 double tagVOrthogonalBoostDirection(
const Particle* part)
337 auto* vert = part->getRelatedTo<TagVertex>();
339 return vert->getTagVol();
343 double tagVTruthBoostDirection(
const Particle* part)
345 auto* vert = part->getRelatedTo<TagVertex>();
347 return vert->getTruthTagVl();
351 double tagVTruthOrthogonalBoostDirection(
const Particle* part)
353 auto* vert = part->getRelatedTo<TagVertex>();
355 return vert->getTruthTagVol();
358 double tagVErrBoostDirection(
const Particle* part)
360 auto* vert = part->getRelatedTo<TagVertex>();
362 return vert->getTagVlErr();
366 double tagVErrOrthogonalBoostDirection(
const Particle* part)
368 auto* vert = part->getRelatedTo<TagVertex>();
370 return vert->getTagVolErr();
374 double particleInternalTagVMCFlavor(
const Particle* part)
376 auto* vert = part->getRelatedTo<TagVertex>();
378 return vert->getMCTagBFlavor();
381 double tagTrackMomentum(
const Particle* part,
const std::vector<double>& trackIndex)
383 auto* vert = part->getRelatedTo<TagVertex>();
386 if (trackIndex.size() != 1)
return realNaN;
387 unsigned trackIndexInt = trackIndex.at(0);
389 return vert->getVtxFitTrackP(trackIndexInt).Mag();
392 double tagTrackMomentumX(
const Particle* part,
const std::vector<double>& trackIndex)
394 auto* vert = part->getRelatedTo<TagVertex>();
397 if (trackIndex.size() != 1)
return realNaN;
398 unsigned trackIndexInt = trackIndex.at(0);
400 return vert->getVtxFitTrackPComponent(trackIndexInt, 0);
403 double tagTrackMomentumY(
const Particle* part,
const std::vector<double>& trackIndex)
405 auto* vert = part->getRelatedTo<TagVertex>();
408 if (trackIndex.size() != 1)
return realNaN;
409 unsigned trackIndexInt = trackIndex.at(0);
411 return vert->getVtxFitTrackPComponent(trackIndexInt, 1);
414 double tagTrackMomentumZ(
const Particle* part,
const std::vector<double>& trackIndex)
416 auto* vert = part->getRelatedTo<TagVertex>();
419 if (trackIndex.size() != 1)
return realNaN;
420 unsigned trackIndexInt = trackIndex.at(0);
422 return vert->getVtxFitTrackPComponent(trackIndexInt, 2);
425 double tagTrackZ0(
const Particle* part,
const std::vector<double>& trackIndex)
427 auto* vert = part->getRelatedTo<TagVertex>();
430 if (trackIndex.size() != 1)
return realNaN;
431 unsigned trackIndexInt = trackIndex.at(0);
433 return vert->getVtxFitTrackZ0(trackIndexInt);
436 double tagTrackD0(
const Particle* part,
const std::vector<double>& trackIndex)
438 auto* vert = part->getRelatedTo<TagVertex>();
441 if (trackIndex.size() != 1)
return realNaN;
442 unsigned trackIndexInt = trackIndex.at(0);
444 return vert->getVtxFitTrackD0(trackIndexInt);
447 double tagTrackRaveWeight(
const Particle* part,
const std::vector<double>& trackIndex)
449 auto* vert = part->getRelatedTo<TagVertex>();
452 if (trackIndex.size() != 1)
return realNaN;
453 unsigned trackIndexInt = trackIndex.at(0);
455 return vert->getRaveWeight(trackIndexInt);
458 double tagTrackDistanceToConstraint(
const Particle* part,
const std::vector<double>& trackIndex)
460 auto* vert = part->getRelatedTo<TagVertex>();
463 if (trackIndex.size() != 1)
return realNaN;
464 unsigned trackIndexInt = trackIndex.at(0);
466 if (vert->getConstraintType() ==
"noConstraint")
return realNaN;
467 const Particle* tagParticle(vert->getVtxFitParticle(trackIndexInt));
468 if (!tagParticle)
return realNaN;
470 return DistanceTools::trackToVtxDist(tagParticle->getTrackFitResult()->getPosition(),
471 tagParticle->getMomentum(),
472 vert->getConstraintCenter());
475 double tagTrackDistanceToConstraintErr(
const Particle* part,
const std::vector<double>& trackIndex)
477 auto* vert = part->getRelatedTo<TagVertex>();
480 if (trackIndex.size() != 1)
return realNaN;
481 unsigned trackIndexInt = trackIndex.at(0);
483 if (vert->getConstraintType() ==
"noConstraint")
return realNaN;
484 const Particle* tagParticle(vert->getVtxFitParticle(trackIndexInt));
485 if (!tagParticle)
return realNaN;
488 TMatrixDSym trackPosCovMat = tagParticle->getVertexErrorMatrix();
490 return DistanceTools::trackToVtxDistErr(tagParticle->getTrackFitResult()->getPosition(),
491 tagParticle->getMomentum(),
492 vert->getConstraintCenter(),
494 vert->getConstraintCov());
497 double tagTrackDistanceToConstraintSignificance(
const Particle* part,
const std::vector<double>& trackIndex)
499 double val = tagTrackDistanceToConstraint(part, trackIndex);
500 if (isinf(val) || isnan(val))
return realNaN;
501 double err = tagTrackDistanceToConstraintErr(part, trackIndex);
502 if (isinf(err) || isnan(err))
return realNaN;
507 double tagVDistanceToConstraint(
const Particle* part)
509 auto* vert = part->getRelatedTo<TagVertex>();
512 if (vert->getConstraintType() ==
"noConstraint")
return realNaN;
514 return DistanceTools::vtxToVtxDist(vert->getConstraintCenter(),
515 vert->getTagVertex());
518 double tagVDistanceToConstraintErr(
const Particle* part)
520 auto* vert = part->getRelatedTo<TagVertex>();
523 if (vert->getConstraintType() ==
"noConstraint")
return realNaN;
528 TMatrixDSym emptyMat(3);
530 return DistanceTools::vtxToVtxDistErr(vert->getConstraintCenter(),
531 vert->getTagVertex(),
532 vert->getConstraintCov(),
536 double tagVDistanceToConstraintSignificance(
const Particle* part)
538 double val = tagVDistanceToConstraint(part);
539 if (isinf(val) || isnan(val))
return realNaN;
540 double err = tagVDistanceToConstraintErr(part);
541 if (isinf(err) || isnan(err))
return realNaN;
546 double tagTrackDistanceToTagV(
const Particle* part,
const std::vector<double>& trackIndex)
548 auto* vert = part->getRelatedTo<TagVertex>();
551 if (trackIndex.size() != 1)
return realNaN;
552 unsigned trackIndexInt = trackIndex.at(0);
554 const Particle* particle = vert->getVtxFitParticle(trackIndexInt);
557 return DistanceTools::trackToVtxDist(particle->getTrackFitResult()->getPosition(),
558 particle->getMomentum(),
559 vert->getTagVertex());
562 double tagTrackDistanceToTagVErr(
const Particle* part,
const std::vector<double>& trackIndex)
564 auto* vert = part->getRelatedTo<TagVertex>();
567 if (trackIndex.size() != 1)
return realNaN;
568 unsigned trackIndexInt = trackIndex.at(0);
570 const Particle* tagParticle(vert->getVtxFitParticle(trackIndexInt));
571 if (!tagParticle)
return realNaN;
574 TMatrixDSym trackPosCovMat = tagParticle->getVertexErrorMatrix();
580 TMatrixDSym emptyMat(3);
582 return DistanceTools::trackToVtxDistErr(tagParticle->getTrackFitResult()->getPosition(),
583 tagParticle->getMomentum(),
584 vert->getTagVertex(),
590 double tagTrackDistanceToTagVSignificance(
const Particle* part,
const std::vector<double>& trackIndex)
592 double val = tagTrackDistanceToTagV(part, trackIndex);
593 if (isinf(val) || isnan(val))
return realNaN;
594 double err = tagTrackDistanceToTagVErr(part, trackIndex);
595 if (isinf(err) || isnan(err))
return realNaN;
600 double tagTrackTrueDistanceToTagV(
const Particle* part,
const std::vector<double>& trackIndex)
602 auto* vert = part->getRelatedTo<TagVertex>();
605 if (trackIndex.size() != 1)
return realNaN;
606 unsigned trackIndexInt = trackIndex.at(0);
608 const MCParticle* mcParticle(vert->getVtxFitMCParticle(trackIndexInt));
609 if (!mcParticle)
return realNaN;
611 TVector3 mcTagV = vert->getMCTagVertex();
613 if (mcTagV(0) == 0 && mcTagV(1) == 0 && mcTagV(2) == 0)
return realNaN;
615 return DistanceTools::trackToVtxDist(mcParticle->getProductionVertex(),
616 mcParticle->getMomentum(),
620 TVector3 tagTrackTrueVecToTagV(
const Particle* part,
const std::vector<double>& trackIndex)
622 auto* vert = part->getRelatedTo<TagVertex>();
625 if (trackIndex.size() != 1)
return vecNaN;
626 unsigned trackIndexInt = trackIndex.at(0);
628 const MCParticle* mcParticle(vert->getVtxFitMCParticle(trackIndexInt));
629 if (!mcParticle)
return vecNaN;
631 TVector3 mcTagV = vert->getMCTagVertex();
633 if (mcTagV(0) == 0 && mcTagV(1) == 0 && mcTagV(2) == 0)
return vecNaN;
635 return DistanceTools::trackToVtxVec(mcParticle->getProductionVertex(),
636 mcParticle->getMomentum(),
640 double tagTrackTrueVecToTagVX(
const Particle* part,
const std::vector<double>& trackIndex)
642 TVector3 result = tagTrackTrueVecToTagV(part, trackIndex);
646 double tagTrackTrueVecToTagVY(
const Particle* part,
const std::vector<double>& trackIndex)
648 TVector3 result = tagTrackTrueVecToTagV(part, trackIndex);
652 double tagTrackTrueVecToTagVZ(
const Particle* part,
const std::vector<double>& trackIndex)
654 TVector3 result = tagTrackTrueVecToTagV(part, trackIndex);
658 TVector3 tagTrackTrueMomentum(
const Particle* part,
const std::vector<double>& trackIndex)
660 auto* vert = part->getRelatedTo<TagVertex>();
663 if (trackIndex.size() != 1)
return vecNaN;
664 unsigned trackIndexInt = trackIndex.at(0);
666 const MCParticle* mcParticle(vert->getVtxFitMCParticle(trackIndexInt));
667 if (!mcParticle)
return vecNaN;
669 return mcParticle->getMomentum();
672 double tagTrackTrueMomentumX(
const Particle* part,
const std::vector<double>& trackIndex)
674 TVector3 pTrue = tagTrackTrueMomentum(part, trackIndex);
678 double tagTrackTrueMomentumY(
const Particle* part,
const std::vector<double>& trackIndex)
680 TVector3 pTrue = tagTrackTrueMomentum(part, trackIndex);
684 double tagTrackTrueMomentumZ(
const Particle* part,
const std::vector<double>& trackIndex)
686 TVector3 pTrue = tagTrackTrueMomentum(part, trackIndex);
690 TVector3 tagTrackTrueOrigin(
const Particle* part,
const std::vector<double>& trackIndex)
692 auto* vert = part->getRelatedTo<TagVertex>();
695 if (trackIndex.size() != 1)
return vecNaN;
696 unsigned trackIndexInt = trackIndex.at(0);
698 const MCParticle* mcParticle(vert->getVtxFitMCParticle(trackIndexInt));
699 if (!mcParticle)
return vecNaN;
701 return mcParticle->getProductionVertex();
704 double tagTrackTrueOriginX(
const Particle* part,
const std::vector<double>& trackIndex)
706 TVector3 origin = tagTrackTrueOrigin(part, trackIndex);
710 double tagTrackTrueOriginY(
const Particle* part,
const std::vector<double>& trackIndex)
712 TVector3 origin = tagTrackTrueOrigin(part, trackIndex);
716 double tagTrackTrueOriginZ(
const Particle* part,
const std::vector<double>& trackIndex)
718 TVector3 origin = tagTrackTrueOrigin(part, trackIndex);
722 int fitTruthStatus(
const Particle* part)
724 auto* vert = part->getRelatedTo<TagVertex>();
725 if (!vert)
return std::numeric_limits<int>::quiet_NaN();
726 return vert->getFitTruthStatus();
729 int rollbackStatus(
const Particle* part)
731 auto* vert = part->getRelatedTo<TagVertex>();
732 if (!vert)
return std::numeric_limits<int>::quiet_NaN();
733 return vert->getRollBackStatus();
745 TagTrFPtr getTagTrackFunctionFromName(
string const& name)
747 if (name ==
"TagTrackMomentum")
return tagTrackMomentum;
748 else if (name ==
"TagTrackMomentumX")
return tagTrackMomentumX;
749 else if (name ==
"TagTrackMomentumY")
return tagTrackMomentumY;
750 else if (name ==
"TagTrackMomentumZ")
return tagTrackMomentumZ;
751 else if (name ==
"TagTrackZ0")
return tagTrackZ0;
752 else if (name ==
"TagTrackD0")
return tagTrackD0;
753 else if (name ==
"TagTrackRaveWeight")
return tagTrackRaveWeight;
754 else if (name ==
"TagTrackDistanceToConstraint")
return tagTrackDistanceToConstraint;
755 else if (name ==
"TagTrackDistanceToConstraintErr")
return tagTrackDistanceToConstraintErr;
756 else if (name ==
"TagTrackDistanceToConstraintSignificance")
return tagTrackDistanceToConstraintSignificance;
757 else if (name ==
"TagTrackDistanceToTagV")
return tagTrackDistanceToTagV;
758 else if (name ==
"TagTrackDistanceToTagVErr")
return tagTrackDistanceToTagVErr;
759 else if (name ==
"TagTrackDistanceToTagVSignificance")
return tagTrackDistanceToTagVSignificance;
760 else if (name ==
"TagTrackTrueDistanceToTagV")
return tagTrackTrueDistanceToTagV;
761 else if (name ==
"TagTrackTrueVecToTagVX")
return tagTrackTrueVecToTagVX;
762 else if (name ==
"TagTrackTrueVecToTagVY")
return tagTrackTrueVecToTagVY;
763 else if (name ==
"TagTrackTrueVecToTagVZ")
return tagTrackTrueVecToTagVZ;
764 else if (name ==
"TagTrackTrueMomentumX")
return tagTrackTrueMomentumX;
765 else if (name ==
"TagTrackTrueMomentumY")
return tagTrackTrueMomentumY;
766 else if (name ==
"TagTrackTrueMomentumZ")
return tagTrackTrueMomentumZ;
767 else if (name ==
"TagTrackTrueOriginX")
return tagTrackTrueOriginX;
768 else if (name ==
"TagTrackTrueOriginY")
return tagTrackTrueOriginY;
769 else if (name ==
"TagTrackTrueOriginZ")
return tagTrackTrueOriginZ;
771 B2ERROR(
"From TimeDependentVariables: Trying to access unknown tagTrack function");
776 double cumulate(
const Particle* part,
const std::vector<std::string>& variable,
double start,
777 std::function<
double(
double,
double,
double)> fun)
779 TagTrFPtr fptr(getTagTrackFunctionFromName(variable.at(0)));
780 auto* vert = part->getRelatedTo<TagVertex>();
782 int nTracks = vert->getNFitTracks();
786 for (
int i = 0; i < nTracks; ++i) {
787 vector<double> indx(1, i);
788 double w = tagTrackRaveWeight(part, indx);
789 double f = (*fptr)(part, indx);
791 acum = fun(acum, f, w);
797 Manager::FunctionPtr tagTrackAverage(
const std::vector<std::string>& variable)
799 if (variable.size() != 1) {
800 B2FATAL(
"Wrong number of arguments for meta function tagTrackAverage");
804 return [variable](
const Particle * part) {
805 double sum = cumulate(part, variable, 0, [](
double s,
double f,
double) {
return s + f;});
806 double tot = cumulate(part, variable, 0, [](
double s,
double ,
double) {
return s + 1;});
807 return (tot > 0) ? sum / tot :
realNaN;
811 Manager::FunctionPtr tagTrackAverageSquares(
const std::vector<std::string>& variable)
813 if (variable.size() != 1) {
814 B2FATAL(
"Wrong number of arguments for meta function tagTrackAverageSquares");
818 return [variable](
const Particle * part) {
819 double sum = cumulate(part, variable, 0, [](
double s,
double f,
double) {
return s + f * f;});
820 double tot = cumulate(part, variable, 0, [](
double s,
double ,
double) {
return s + 1;});
821 return (tot > 0) ? sum / tot :
realNaN;
826 Manager::FunctionPtr tagTrackMax(
const std::vector<std::string>& variable)
828 if (variable.size() != 1) {
829 B2FATAL(
"Wrong number of arguments for meta function tagTrackMax");
833 return [variable](
const Particle * part) {
834 double Max = cumulate(part, variable, -DBL_MAX, [](
double s,
double f,
double) {
return std::max(s, f);});
835 return (Max != -DBL_MAX) ? Max :
realNaN;
839 Manager::FunctionPtr tagTrackMin(
const std::vector<std::string>& variable)
841 if (variable.size() != 1) {
842 B2FATAL(
"Wrong number of arguments for meta function tagTrackMin");
846 return [variable](
const Particle * part) {
847 double Min = cumulate(part, variable, +DBL_MAX, [](
double s,
double f,
double) {
return std::min(s, f);});
848 return (Min != DBL_MAX) ? Min :
realNaN;
852 Manager::FunctionPtr tagTrackWeightedAverage(
const std::vector<std::string>& variable)
854 if (variable.size() != 1) {
855 B2FATAL(
"Wrong number of arguments for meta function tagTrackWeightedAverage");
859 return [variable](
const Particle * part) {
860 double num = cumulate(part, variable, 0, [](
double s,
double f,
double w) {
return s + w * f;});
861 double den = cumulate(part, variable, 0, [](
double s,
double ,
double w) {
return s + w;});
862 return (den > 0) ? num / den :
realNaN;
866 Manager::FunctionPtr tagTrackWeightedAverageSquares(
const std::vector<std::string>& variable)
868 if (variable.size() != 1) {
869 B2FATAL(
"Wrong number of arguments for meta function tagTrackWeightedAverageSquares");
873 return [variable](
const Particle * part) ->
double {
874 double num = cumulate(part, variable, 0, [](
double s,
double f,
double w) {
return s + w * f * f;});
875 double den = cumulate(part, variable, 0, [](
double s,
double ,
double w) {
return s + w;});
876 return (den > 0) ? num / den :
realNaN;
880 Manager::FunctionPtr tagTrackSum(
const std::vector<std::string>& variable)
882 if (variable.size() != 1) {
883 B2FATAL(
"Wrong number of arguments for meta function tagTrackSum");
887 return [variable](
const Particle * part) {
888 return cumulate(part, variable, 0, [](
double s,
double f,
double) {
return s + f;});
897 VARIABLE_GROUP(
"Time Dependent CPV Analysis Variables");
899 REGISTER_VARIABLE(
"TagVx", particleTagVx,
"Tag vertex X component");
900 REGISTER_VARIABLE(
"TagVy", particleTagVy,
"Tag vertex Y component");
901 REGISTER_VARIABLE(
"TagVz", particleTagVz,
"Tag vertex Z component");
902 REGISTER_VARIABLE(
"mcTagVx", particleTruthTagVx,
"Generated Tag vertex X component");
903 REGISTER_VARIABLE(
"mcTagVy", particleTruthTagVy,
"Generated Tag vertex Y component");
904 REGISTER_VARIABLE(
"mcTagVz", particleTruthTagVz,
"Generated Tag vertex Z component");
905 REGISTER_VARIABLE(
"TagVxErr", particleTagVxErr,
"Tag vertex X component uncertainty");
906 REGISTER_VARIABLE(
"TagVyErr", particleTagVyErr,
"Tag vertex Y component uncertainty");
907 REGISTER_VARIABLE(
"TagVzErr", particleTagVzErr,
"Tag vertex Z component uncertainty");
908 REGISTER_VARIABLE(
"TagVpVal", particleTagVpVal,
"Tag vertex p-Value");
909 REGISTER_VARIABLE(
"TagVNTracks", particleTagVNTracks,
"Number of tracks in the tag vertex");
910 REGISTER_VARIABLE(
"TagVType", particleTagVType,
911 R
"DOC(Type of algo for the tag vertex. -1: failed (1,2: single track, deprecated), 3: standard, 4: standard_PXD, 5: no constraint)DOC");
912 REGISTER_VARIABLE("TagVNDF", particleTagVNDF,
"Number of degrees of freedom in the tag vertex fit");
913 REGISTER_VARIABLE(
"TagVChi2", particleTagVChi2,
"chi2 value of the tag vertex fit");
914 REGISTER_VARIABLE(
"TagVChi2IP", particleTagVChi2IP,
"IP component of chi2 value of the tag vertex fit");
916 REGISTER_VARIABLE(
"DeltaT", particleDeltaT,
917 R
"DOC(Proper decay time difference :math:`\Delta t` between signal B-meson :math:`(B_{rec})` and tag B-meson :math:`(B_{tag})` in ps.)DOC");
918 REGISTER_VARIABLE("DeltaTErr", particleDeltaTErr,
919 R
"DOC(Proper decay time difference :math:`\Delta t` uncertainty in ps)DOC");
920 REGISTER_VARIABLE("DeltaTRes", particleDeltaTRes,
921 R
"DOC(:math:`\Delta t` residual in ps, to be used for resolution function studies)DOC");
922 REGISTER_VARIABLE("DeltaTBelle", particleDeltaTBelle,
923 R
"DOC([Legacy] :math:`\Delta t` in ps, as it was used in Belle)DOC");
924 REGISTER_VARIABLE("mcDeltaTau", particleMCDeltaTau,
925 R
"DOC(Generated proper decay time difference :math:`\Delta t` in ps: :math:`\tau(B_{\rm rec})-\tau(B_{\rm tag})`)DOC");
926 REGISTER_VARIABLE("mcDeltaT", particleMCDeltaT,
927 R
"DOC(Generated proper decay time difference (in z-difference approximation) :math:`\Delta t` in ps: :math:`(l(B_{\rm rec}) - l(B_{\rm tag}))/\beta_{\Upsilon(4S)}\gamma_{\Upsilon(4S)}`)DOC");
928 REGISTER_VARIABLE("mcDeltaBoost", particleMCDeltaBoost,
929 R
"DOC(True difference of decay vertex boost-direction components between signal B-meson :math:`(B_{rec})` and tag B-meson :math:`(B_{tag})`:
930 :math:`\Delta l = l(B_{rec}) - l(B_{tag})`)DOC");
931 REGISTER_VARIABLE("DeltaZ", particleDeltaZ,
932 R
"DOC(Difference of decay vertex longitudinal components between signal B-meson :math:`(B_{rec})` and tag B-meson :math:`(B_{tag})`:
933 :math:`\Delta z = z(B_{rec}) - z(B_{tag})`)DOC");
934 REGISTER_VARIABLE("DeltaZErr", particleDeltaZErr,
935 R
"DOC(Uncertainty of the difference :math:`z(B_{rec}) - z(B_{tag})`)DOC");
936 REGISTER_VARIABLE("DeltaBoost", particleDeltaB, R
"DOC(:math:`\Delta z` in the boost direction)DOC");
937 REGISTER_VARIABLE("DeltaBoostErr", particleDeltaBErr, R
"DOC(Uncertanty of :math:`\Delta z` in the boost direction)DOC");
939 REGISTER_VARIABLE("LBoost", vertexBoostDirection,
940 "Returns the vertex component in the boost direction");
941 REGISTER_VARIABLE(
"OBoost", vertexOrthogonalBoostDirection,
942 "Returns the vertex component in the direction orthogonal to the boost");
943 REGISTER_VARIABLE(
"mcLBoost", vertexTruthBoostDirection,
944 "Returns the MC vertex component in the boost direction");
945 REGISTER_VARIABLE(
"mcOBoost", vertexTruthOrthogonalBoostDirection,
946 "Returns the MC vertex component in the direction orthogonal to the boost");
947 REGISTER_VARIABLE(
"LBoostErr", vertexErrBoostDirection,
948 "Returns the error of the vertex in the boost direction");
949 REGISTER_VARIABLE(
"OBoostErr", vertexErrOrthBoostDirection,
950 "Returns the error of the vertex in the direction orthogonal to the boost");
952 REGISTER_VARIABLE(
"TagVLBoost", tagVBoostDirection,
953 "Returns the TagV component in the boost direction");
954 REGISTER_VARIABLE(
"TagVOBoost", tagVOrthogonalBoostDirection,
955 "Returns the TagV component in the direction orthogonal to the boost");
956 REGISTER_VARIABLE(
"mcTagVLBoost", tagVTruthBoostDirection,
957 "Returns the MC TagV component in the boost direction");
958 REGISTER_VARIABLE(
"mcTagVOBoost", tagVTruthOrthogonalBoostDirection,
959 "Returns the MC TagV component in the direction orthogonal to the boost");
960 REGISTER_VARIABLE(
"TagVLBoostErr", tagVErrBoostDirection,
961 "Returns the error of TagV in the boost direction");
962 REGISTER_VARIABLE(
"TagVOBoostErr", tagVErrOrthogonalBoostDirection,
963 "Returns the error of TagV in the direction orthogonal to the boost");
965 REGISTER_VARIABLE(
"internalTagVMCFlavor", particleInternalTagVMCFlavor,
966 "[Expert] [Debugging] This variable is only for internal checks of the TagV module by developers. \n"
967 "It returns the internal mc flavor information of the tag-side B provided by the TagV module.");
969 REGISTER_VARIABLE(
"TagTrackMomentum(i) ", tagTrackMomentum,
970 "return the magnitude of the momentum of the ith track used in the tag vtx fit.");
971 REGISTER_VARIABLE(
"TagTrackMomentumX(i) ", tagTrackMomentumX,
972 "return the X component of the momentum of the ith track used in the tag vtx fit.");
973 REGISTER_VARIABLE(
"TagTrackMomentumY(i) ", tagTrackMomentumY,
974 "return the Y component of the momentum of the ith track used in the tag vtx fit.");
975 REGISTER_VARIABLE(
"TagTrackMomentumZ(i) ", tagTrackMomentumZ,
976 "return the Z component of the momentum of the ith track used in the tag vtx fit.");
978 REGISTER_VARIABLE(
"TagTrackZ0(i)", tagTrackZ0,
"return the z0 parameter of the ith track used in the tag vtx fit");
979 REGISTER_VARIABLE(
"TagTrackD0(i)", tagTrackD0,
"return the d0 parameter of the ith track used in the tag vtx fit");
982 REGISTER_VARIABLE(
"TagTrackRaveWeight(i)", tagTrackRaveWeight,
"returns the weight assigned by Rave to track i");
984 REGISTER_VARIABLE(
"TagVNFitTracks", particleTagVNFitTracks,
985 "returns the number of tracks used by rave to fit the vertex (not counting the ones coming from Kshorts)");
987 REGISTER_VARIABLE(
"TagTrackDistanceToConstraint(i)", tagTrackDistanceToConstraint,
988 "returns the measured distance between the ith tag track and the centre of the constraint.");
990 REGISTER_VARIABLE(
"TagTrackDistanceToConstraintErr(i)", tagTrackDistanceToConstraintErr,
991 "returns the estimated error on the distance between the ith tag track and the centre of the constraint.");
993 REGISTER_VARIABLE(
"TagTrackDistanceToConstraintSignificance(i)", tagTrackDistanceToConstraintSignificance,
994 "returns the significance of the distance between the centre of the constraint and the tag track indexed by track index (computed as distance / uncertainty)");
997 REGISTER_VARIABLE(
"TagVDistanceToConstraint", tagVDistanceToConstraint,
998 "returns the measured distance between the tag vtx and the centre of the constraint.");
1000 REGISTER_VARIABLE(
"TagVDistanceToConstraintErr", tagVDistanceToConstraintErr,
1001 "returns the estimated error on the distance between the tag vtx and the centre of the constraint.");
1003 REGISTER_VARIABLE(
"TagVDistanceToConstraintSignificance", tagVDistanceToConstraintSignificance,
1004 "returns the significance of the distance between the tag vtx and the centre of the constraint (computed as distance / uncertainty)");
1006 REGISTER_VARIABLE(
"TagTrackDistanceToTagV(i)", tagTrackDistanceToTagV,
1007 "returns the measured distance between the ith tag track and the tag vtx.");
1009 REGISTER_VARIABLE(
"TagTrackDistanceToTagVErr(i)", tagTrackDistanceToTagVErr,
1010 "returns the estimated error on the distance between the ith tag track and the tag vtx. Warning: only the uncertainties on the track position parameters are taken into account.");
1012 REGISTER_VARIABLE(
"TagTrackDistanceToTagVSignificance(i)", tagTrackDistanceToTagVSignificance,
1013 "returns the significance of the distance between the tag vtx and the tag track indexed by trackIndex (computed as distance / uncertainty)");
1015 REGISTER_VARIABLE(
"TagTrackTrueDistanceToTagV(i)", tagTrackTrueDistanceToTagV,
1016 "return the true distance between the true B Tag decay vertex and the p'cle corresponding to the ith tag vtx track.")
1018 REGISTER_VARIABLE("TagTrackTrueVecToTagVX(i)", tagTrackTrueVecToTagVX,
1019 "return the X coordinate of the vector between the mc particle corresponding to the ith tag vtx track and the true tag B decay vertex.")
1021 REGISTER_VARIABLE("TagTrackTrueVecToTagVY(i)", tagTrackTrueVecToTagVY,
1022 "return the Y coordinate of the vector between the mc particle corresponding to the ith tag vtx track and the true tag B decay vertex.")
1024 REGISTER_VARIABLE("TagTrackTrueVecToTagVZ(i)", tagTrackTrueVecToTagVZ,
1025 "return the Z coordinate of the vector between the mc particle corresponding to the ith tag vtx track and the true tag B decay vertex.")
1027 REGISTER_VARIABLE("TagTrackTrueMomentumX(i)", tagTrackTrueMomentumX,
1028 "return the X component of the true momentum of the MC particle corresponding to the ith tag vtx track.")
1030 REGISTER_VARIABLE("TagTrackTrueMomentumY(i)", tagTrackTrueMomentumY,
1031 "return the Y component of the true momentum of the MC particle corresponding to the ith tag vtx track.")
1033 REGISTER_VARIABLE("TagTrackTrueMomentumZ(i)", tagTrackTrueMomentumZ,
1034 "return the Z component of the true momentum of the MC particle corresponding to the ith tag vtx track.")
1036 REGISTER_VARIABLE("TagTrackTrueOriginX(i)", tagTrackTrueOriginX,
1037 "return the X component of the true origin of the MC particle corresponding to the ith tag vtx track.")
1039 REGISTER_VARIABLE("TagTrackTrueOriginY(i)", tagTrackTrueOriginY,
1040 "return the Y component of the true origin of the MC particle corresponding to the ith tag vtx track.")
1042 REGISTER_VARIABLE("TagTrackTrueOriginZ(i)", tagTrackTrueOriginZ,
1043 "return the Z component of the true origin of the MC particle corresponding to the ith tag vtx track.")
1045 REGISTER_VARIABLE("TagVFitTruthStatus", fitTruthStatus,
1046 "Returns the status of the fit performed with the truth info. Possible values are: 0: fit performed with measured parameters, 1: fit performed with true parameters, 2: unable to recover truth parameters")
1048 REGISTER_VARIABLE("TagVRollBackStatus", rollbackStatus,
1049 "Returns the status of the fit performed with rolled back tracks. Possible values are: 0: fit performed with measured parameters, 1: fit performed with rolled back tracks, 2: unable to recover truth parameters")
1051 REGISTER_VARIABLE("TagTrackMax(var)", tagTrackMax,
1052 "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.")
1054 REGISTER_VARIABLE("TagTrackMin(var)", tagTrackMin,
1055 "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.")
1057 REGISTER_VARIABLE("TagTrackAverage(var)", tagTrackAverage,
1058 "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.")
1060 REGISTER_VARIABLE("TagTrackAverageSquares(var)", tagTrackAverageSquares,
1061 "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.")
1063 REGISTER_VARIABLE("TagTrackWeightedAverage(var)", tagTrackWeightedAverage,
1064 "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)``.")
1066 REGISTER_VARIABLE("TagTrackWeightedAverageSquares(var)", tagTrackWeightedAverageSquares,
1067 "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)``.")
static const double realNaN
shortcut for NaN of double type
static const TVector3 vecNaN(realNaN, realNaN, realNaN)
vector with NaN entries
Abstract base class for different kinds of events.