10#include <analysis/variables/V0DaughterTrackVariables.h>
13#include <analysis/VariableManager/Manager.h>
15#include <analysis/dataobjects/Particle.h>
16#include <analysis/variables/TrackVariables.h>
19#include <framework/dataobjects/Helix.h>
22#include <mdst/dataobjects/Track.h>
23#include <mdst/dataobjects/MCParticle.h>
24#include <mdst/dataobjects/TrackFitResult.h>
25#include <mdst/dataobjects/HitPatternCDC.h>
26#include <mdst/dataobjects/HitPatternVXD.h>
29#include <framework/logging/Logger.h>
46 double getV0DaughterTrackDetNHits(
const Particle* particle,
const double daughterID,
const Const::EDetector& det)
48 auto daughter = particle->getDaughter(daughterID);
49 return trackNHits(daughter, det);
52 double v0DaughterTrackNCDCHits(
const Particle* part,
const std::vector<double>& daughterID)
54 return getV0DaughterTrackDetNHits(part, daughterID[0], Const::EDetector::CDC);
57 double v0DaughterTrackNSVDHits(
const Particle* part,
const std::vector<double>& daughterID)
59 return getV0DaughterTrackDetNHits(part, daughterID[0], Const::EDetector::SVD);
62 double v0DaughterTrackNPXDHits(
const Particle* part,
const std::vector<double>& daughterID)
64 return getV0DaughterTrackDetNHits(part, daughterID[0], Const::EDetector::PXD);
67 double v0DaughterTrackNVXDHits(
const Particle* part,
const std::vector<double>& daughterID)
69 return v0DaughterTrackNPXDHits(part, daughterID) + v0DaughterTrackNSVDHits(part, daughterID);
72 double v0DaughterTrackNRemovedHits(
const Particle* part,
const std::vector<double>& daughterID)
75 if (part->getParticleSource() != Particle::EParticleSourceObject::c_V0)
77 auto daughter = part->getDaughter(daughterID[0]);
78 const Track* track = daughter->getTrack();
80 const TrackFitResult* trackFit = track->getTrackFitResultWithClosestMass(Const::ChargedStable(abs(
81 daughter->getPDGCode())));
83 double nHitsBeforeRemoval = trackFit->getHitPatternCDC().getNHits()
84 + trackFit->getHitPatternVXD().getNSVDHits()
85 + trackFit->getHitPatternVXD().getNPXDHits();
86 double nHitsAfterRemoval = trackNVXDHits(daughter) + trackNCDCHits(daughter);
87 return nHitsBeforeRemoval - nHitsAfterRemoval;
90 double v0DaughterTrackFirstSVDLayer(
const Particle* part,
const std::vector<double>& daughterID)
92 auto daughter = part->getDaughter(daughterID[0]);
93 return trackFirstSVDLayer(daughter);
96 double v0DaughterTrackFirstPXDLayer(
const Particle* part,
const std::vector<double>& daughterID)
98 auto daughter = part->getDaughter(daughterID[0]);
99 return trackFirstPXDLayer(daughter);
102 double v0DaughterTrackFirstCDCLayer(
const Particle* part,
const std::vector<double>& daughterID)
104 auto daughter = part->getDaughter(daughterID[0]);
105 return trackFirstCDCLayer(daughter);
108 double v0DaughterTrackLastCDCLayer(
const Particle* part,
const std::vector<double>& daughterID)
110 auto daughter = part->getDaughter(daughterID[0]);
111 return trackLastCDCLayer(daughter);
114 double v0DaughterTrackPValue(
const Particle* part,
const std::vector<double>& daughterID)
116 auto daughter = part->getDaughter(daughterID[0]);
117 return trackPValue(daughter);
120 double v0DaughterTrackD0(
const Particle* part,
const std::vector<double>& daughterID)
122 auto daughter = part->getDaughter(daughterID[0]);
123 return trackD0(daughter);
126 double v0DaughterTrackPhi0(
const Particle* part,
const std::vector<double>& daughterID)
128 auto daughter = part->getDaughter(daughterID[0]);
129 return trackPhi0(daughter);
132 double v0DaughterTrackOmega(
const Particle* part,
const std::vector<double>& daughterID)
134 auto daughter = part->getDaughter(daughterID[0]);
135 return trackOmega(daughter);
138 double v0DaughterTrackZ0(
const Particle* part,
const std::vector<double>& daughterID)
140 auto daughter = part->getDaughter(daughterID[0]);
141 return trackZ0(daughter);
144 double v0DaughterTrackTanLambda(
const Particle* part,
const std::vector<double>& daughterID)
146 auto daughter = part->getDaughter(daughterID[0]);
147 return trackTanLambda(daughter);
150 double v0DaughterTrackD0Error(
const Particle* part,
const std::vector<double>& daughterID)
152 auto daughter = part->getDaughter(daughterID[0]);
153 return trackD0Error(daughter);
156 double v0DaughterTrackPhi0Error(
const Particle* part,
const std::vector<double>& daughterID)
158 auto daughter = part->getDaughter(daughterID[0]);
159 return trackPhi0Error(daughter);
162 double v0DaughterTrackOmegaError(
const Particle* part,
const std::vector<double>& daughterID)
164 auto daughter = part->getDaughter(daughterID[0]);
165 return trackOmegaError(daughter);
168 double v0DaughterTrackZ0Error(
const Particle* part,
const std::vector<double>& daughterID)
170 auto daughter = part->getDaughter(daughterID[0]);
171 return trackZ0Error(daughter);
174 double v0DaughterTrackTanLambdaError(
const Particle* part,
const std::vector<double>& daughterID)
176 auto daughter = part->getDaughter(daughterID[0]);
177 return trackTanLambdaError(daughter);
180 double v0DaughterD0(
const Particle* particle,
const std::vector<double>& daughterID)
185 ROOT::Math::XYZVector v0Vertex = particle->getVertex();
187 const Particle* daug = particle->getDaughter(daughterID[0]);
189 const TrackFitResult* trackFit = daug->getTrackFitResult();
192 UncertainHelix helix = trackFit->getUncertainHelix();
193 helix.passiveMoveBy(v0Vertex);
195 return helix.getD0();
198 double v0DaughterD0Diff(
const Particle* particle)
200 return v0DaughterD0(particle, {0}) - v0DaughterD0(particle, {1});
203 double v0DaughterZ0(
const Particle* particle,
const std::vector<double>& daughterID)
208 ROOT::Math::XYZVector v0Vertex = particle->getVertex();
210 const Particle* daug = particle->getDaughter(daughterID[0]);
212 const TrackFitResult* trackFit = daug->getTrackFitResult();
215 UncertainHelix helix = trackFit->getUncertainHelix();
216 helix.passiveMoveBy(v0Vertex);
218 return helix.getZ0();
221 double v0DaughterZ0Diff(
const Particle* particle)
223 return v0DaughterZ0(particle, {0}) - v0DaughterZ0(particle, {1});
228 double getHelixParameterPullOfV0DaughterWithTrueVertexAsPivotAtIndex(
const Particle* particle,
const double daughterID,
233 const int dID = int(std::lround(daughterID));
244 const TrackFitResult* trackFit = particle->getDaughter(dID)->getTrackFitResult();
248 const ROOT::Math::XYZVector mcProdVertex = mcparticle->getVertex();
249 const ROOT::Math::XYZVector mcMomentum = mcparticle->getMomentum();
250 const double mcParticleCharge = mcparticle->getCharge();
252 Helix mcHelix = Helix(mcProdVertex, mcMomentum, mcParticleCharge, BzAtProdVertex);
253 mcHelix.passiveMoveBy(mcProdVertex);
254 const std::vector<double> mcHelixPars = { mcHelix.getD0(), mcHelix.getPhi0(), mcHelix.getOmega(),
255 mcHelix.getZ0(), mcHelix.getTanLambda()
259 UncertainHelix measHelix = trackFit->getUncertainHelix();
260 measHelix.passiveMoveBy(mcProdVertex);
261 const TMatrixDSym measCovariance = measHelix.getCovariance();
262 const std::vector<double> measHelixPars = {measHelix.getD0(), measHelix.getPhi0(), measHelix.getOmega(),
263 measHelix.getZ0(), measHelix.getTanLambda()
265 const std::vector<double> measErrSquare = {measCovariance[0][0], measCovariance[1][1], measCovariance[2][2],
266 measCovariance[3][3], measCovariance[4][4]
269 if (measErrSquare.at(tauIndex) > 0)
270 return (mcHelixPars.at(tauIndex) - measHelixPars.at(tauIndex)) / std::sqrt(measErrSquare.at(tauIndex));
275 double v0DaughterHelixWithTrueVertexAsPivotD0Pull(
const Particle* part,
const std::vector<double>& daughterID)
277 return getHelixParameterPullOfV0DaughterWithTrueVertexAsPivotAtIndex(part, daughterID[0], 0);
280 double v0DaughterHelixWithTrueVertexAsPivotPhi0Pull(
const Particle* part,
const std::vector<double>& daughterID)
282 return getHelixParameterPullOfV0DaughterWithTrueVertexAsPivotAtIndex(part, daughterID[0], 1);
285 double v0DaughterHelixWithTrueVertexAsPivotOmegaPull(
const Particle* part,
const std::vector<double>& daughterID)
287 return getHelixParameterPullOfV0DaughterWithTrueVertexAsPivotAtIndex(part, daughterID[0], 2);
290 double v0DaughterHelixWithTrueVertexAsPivotZ0Pull(
const Particle* part,
const std::vector<double>& daughterID)
292 return getHelixParameterPullOfV0DaughterWithTrueVertexAsPivotAtIndex(part, daughterID[0], 3);
295 double v0DaughterHelixWithTrueVertexAsPivotTanLambdaPull(
const Particle* part,
const std::vector<double>& daughterID)
297 return getHelixParameterPullOfV0DaughterWithTrueVertexAsPivotAtIndex(part, daughterID[0], 4);
300 double v0DaughterHelixWithOriginAsPivotD0Pull(
const Particle* part,
const std::vector<double>& daughterID)
302 auto daughter = part->getDaughter(daughterID[0]);
303 return getHelixD0Pull(daughter);
306 double v0DaughterHelixWithOriginAsPivotPhi0Pull(
const Particle* part,
const std::vector<double>& daughterID)
308 auto daughter = part->getDaughter(daughterID[0]);
309 return getHelixPhi0Pull(daughter);
312 double v0DaughterHelixWithOriginAsPivotOmegaPull(
const Particle* part,
const std::vector<double>& daughterID)
314 auto daughter = part->getDaughter(daughterID[0]);
315 return getHelixOmegaPull(daughter);
318 double v0DaughterHelixWithOriginAsPivotZ0Pull(
const Particle* part,
const std::vector<double>& daughterID)
320 auto daughter = part->getDaughter(daughterID[0]);
321 return getHelixZ0Pull(daughter);
324 double v0DaughterHelixWithOriginAsPivotTanLambdaPull(
const Particle* part,
const std::vector<double>& daughterID)
326 auto daughter = part->getDaughter(daughterID[0]);
327 return getHelixTanLambdaPull(daughter);
330 double v0DaughterTrackParam5AtIPPerigee(
const Particle* part,
const std::vector<double>& params)
332 auto daughter = part->getDaughter(params[0]);
336 auto trackFit = daughter->getTrackFitResult();
341 const int paramID = int(std::lround(params[1]));
342 if (not(0 <= paramID && paramID < 5))
345 std::vector<float> tau = trackFit->getTau();
349 double v0DaughterTrackParamCov5x5AtIPPerigee(
const Particle* part,
const std::vector<double>& params)
351 auto daughter = part->getDaughter(params[0]);
355 auto trackFit = daughter->getTrackFitResult();
360 const int paramID = int(std::lround(params[1]));
361 if (not(0 <= paramID && paramID < 15))
364 std::vector<float> cov = trackFit->getCov();
368 int convertedPhotonErrorChecks(
const Particle* gamma,
const std::vector<double>& daughterIndices)
371 if (daughterIndices.size() != 2) {
372 B2ERROR(
"Invalid number of daughter indices. Please specify exactly two valid daughter indices.");
377 int daughterIndex1 = int(daughterIndices[0]);
378 int daughterIndex2 = int(daughterIndices[1]);
379 if (
int(gamma->getNDaughters()) <= std::max(daughterIndex1, daughterIndex2)) {
380 B2ERROR(
"Invalid daughter indices provided. Particle does not have that many daughters.");
385 if (!gamma->getDaughter(daughterIndex1)->getTrack()) {
386 B2ERROR(
"There is no track associated with daughter index " << daughterIndex1);
389 if (!gamma->getDaughter(daughterIndex2)->getTrack()) {
390 B2ERROR(
"There is no track associated with daughter index " << daughterIndex2);
395 if (fabs(gamma->getDaughter(daughterIndex1)->getPDGCode()) != 11) {
396 B2INFO(
"The first track provided has not been reconstructed as an electron/positron. It has PDG code " << gamma->getDaughter(
397 daughterIndex1)->getPDGCode() <<
". However, this is still fully admissible.");
399 if (fabs(gamma->getDaughter(daughterIndex2)->getPDGCode()) != 11) {
400 B2INFO(
"The second track provided has not been reconstructed as an electron/positron. It has PDG code " << gamma->getDaughter(
401 daughterIndex1)->getPDGCode() <<
".However, this is still fully admissible.");
408 int convertedPhotonLoadHelixParams(
const Particle* gamma,
int daughterIndex1,
int daughterIndex2,
double& Phi01,
double& D01,
409 double& Omega1,
double& Z01,
double& TanLambda1,
double& Phi02,
double& D02,
double& Omega2,
double& Z02,
414 Helix e1Helix = gamma->getDaughter(daughterIndex1)->getTrackFitResult()->getHelix();
416 Phi01 = e1Helix.getPhi0();
417 D01 = e1Helix.getD0() ;
418 Omega1 = e1Helix.getOmega();
419 Z01 = e1Helix.getZ0();
420 TanLambda1 = e1Helix.getTanLambda();
423 Helix e2Helix = gamma->getDaughter(daughterIndex2)->getTrackFitResult()->getHelix();
425 Phi02 = e2Helix.getPhi0();
426 D02 = e2Helix.getD0() ;
427 Omega2 = e2Helix.getOmega();
428 Z02 = e2Helix.getZ0();
429 TanLambda2 = e2Helix.getTanLambda();
432 if (Omega1 == 0) {
return -1;}
433 else if (Omega2 == 0) {
return -2;}
438 double convertedPhotonInvariantMass(
const Particle* gamma,
const std::vector<double>& daughterIndices)
441 int errFlag = convertedPhotonErrorChecks(gamma, daughterIndices);
445 double Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02, Omega2, Z02, TanLambda2;
446 int daughterIndex1 = int(daughterIndices[0]);
447 int daughterIndex2 = int(daughterIndices[1]);
448 convertedPhotonLoadHelixParams(gamma, daughterIndex1, daughterIndex2, Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02,
449 Omega2, Z02, TanLambda2);
454 double sinlam1 = TanLambda1 / sqrt(1 + (TanLambda1 * TanLambda1));
455 double coslam1 = 1 / sqrt(1 + (TanLambda1 * TanLambda1));
456 double sinlam2 = TanLambda2 / sqrt(1 + (TanLambda2 * TanLambda2));
457 double coslam2 = 1 / sqrt(1 + (TanLambda2 * TanLambda2));
461 double p1 = gamma->getDaughter(daughterIndex1)->getMomentumMagnitude();
462 double pt1 = p1 * coslam1, pz1 = p1 * sinlam1;
465 double p2 = gamma->getDaughter(daughterIndex2)->getMomentumMagnitude();
466 double pt2 = p2 * coslam2, pz2 = p2 * sinlam2;
470 double vtxMass = sqrt(pow(e1 + e2, 2.0) - pow(pt1 + pt2, 2.0) - pow(pz1 + pz2, 2.0));
474 double convertedPhotonDelTanLambda(
const Particle* gamma,
const std::vector<double>& daughterIndices)
477 int errFlag = convertedPhotonErrorChecks(gamma, daughterIndices);
481 double Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02, Omega2, Z02, TanLambda2;
482 int daughterIndex1 = int(daughterIndices[0]);
483 int daughterIndex2 = int(daughterIndices[1]);
484 convertedPhotonLoadHelixParams(gamma, daughterIndex1, daughterIndex2, Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02,
485 Omega2, Z02, TanLambda2);
490 return (TanLambda2 - TanLambda1);
493 double convertedPhotonDelR(
const Particle* gamma,
const std::vector<double>& daughterIndices)
496 int errFlag = convertedPhotonErrorChecks(gamma, daughterIndices);
500 double Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02, Omega2, Z02, TanLambda2;
501 int daughterIndex1 = int(daughterIndices[0]);
502 int daughterIndex2 = int(daughterIndices[1]);
503 errFlag = convertedPhotonLoadHelixParams(gamma, daughterIndex1, daughterIndex2, Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02,
504 Omega2, Z02, TanLambda2);
506 B2ERROR(
"First track provided has curvature zero. Calculation of convertedPhotonDelR failed.");
510 B2ERROR(
"Second track provided has curvature zero. Calculation of convertedPhotonDelR failed.");
515 double radius1 = 1 / Omega1;
516 double radius2 = 1 / Omega2;
518 TVector2 center1((radius1 + D01) * sin(Phi01), -1 * (radius1 + D01) * cos(Phi01));
519 TVector2 center2((radius2 + D02) * sin(Phi02), -1 * (radius2 + D02) * cos(Phi02));
520 TVector2 cenDiff = center1 - center2;
522 double delR = fabs(radius1) + fabs(radius2) - cenDiff.Mod();
526 std::pair<double, double> convertedPhotonZ1Z2(
const Particle* gamma,
const std::vector<double>& daughterIndices)
529 int errFlag = convertedPhotonErrorChecks(gamma, daughterIndices);
533 double Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02, Omega2, Z02, TanLambda2;
534 int daughterIndex1 = int(daughterIndices[0]);
535 int daughterIndex2 = int(daughterIndices[1]);
536 errFlag = convertedPhotonLoadHelixParams(gamma, daughterIndex1, daughterIndex2, Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02,
537 Omega2, Z02, TanLambda2);
539 B2ERROR(
"First track provided has curvature zero. Calculation of convertedPhotonZ1Z2 failed.");
543 B2ERROR(
"Second track provided has curvature zero. Calculation of convertedPhotonZ1Z2 failed.");
549 double radius1 = 1 / Omega1;
550 double radius2 = 1 / Omega2;
552 TVector2 center1((radius1 + D01) * sin(Phi01), -1 * (radius1 + D01) * cos(Phi01));
553 TVector2 center2((radius2 + D02) * sin(Phi02), -1 * (radius2 + D02) * cos(Phi02));
555 TVector2 n1 = center1 - center2; n1 = n1.Unit();
556 TVector2 n2 = -1 * n1;
557 n1 = copysign(1.0, Omega1) * n1;
558 n2 = copysign(1.0, Omega2) * n2;
561 double phiN1 = atan2(n1.X(), -n1.Y());
562 double phiN2 = atan2(n2.X(), -n2.Y());
563 double Phi01Intersect = phiN1 - Phi01;
564 double Phi02Intersect = phiN2 - Phi02;
566 double z1 = Z01 - (radius1 * TanLambda1 * Phi01Intersect);
567 double z2 = Z02 - (radius2 * TanLambda2 * Phi02Intersect);
568 std::pair<double, double> z1z2(z1, z2);
572 double convertedPhotonDelZ(
const Particle* gamma,
const std::vector<double>& daughterIndices)
574 std::pair<double, double> z1z2 = convertedPhotonZ1Z2(gamma, daughterIndices);
575 double z1 = z1z2.first;
double z2 = z1z2.second;
579 double convertedPhotonZ(
const Particle* gamma,
const std::vector<double>& daughterIndices)
581 std::pair<double, double> z1z2 = convertedPhotonZ1Z2(gamma, daughterIndices);
582 double z1 = z1z2.first;
double z2 = z1z2.second;
583 return (z1 + z2) * 0.5;
586 TVector2 convertedPhotonXY(
const Particle* gamma,
const std::vector<double>& daughterIndices)
589 int errFlag = convertedPhotonErrorChecks(gamma, daughterIndices);
593 double Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02, Omega2, Z02, TanLambda2;
594 int daughterIndex1 = int(daughterIndices[0]);
595 int daughterIndex2 = int(daughterIndices[1]);
596 errFlag = convertedPhotonLoadHelixParams(gamma, daughterIndex1, daughterIndex2, Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02,
597 Omega2, Z02, TanLambda2);
599 B2ERROR(
"First track provided has curvature zero. Calculation of convertedPhotonXY failed.");
603 B2ERROR(
"Second track provided has curvature zero. Calculation of convertedPhotonXY failed.");
608 double radius1 = 1 / Omega1;
609 double radius2 = 1 / Omega2;
611 TVector2 center1((radius1 + D01) * sin(Phi01), -1 * (radius1 + D01) * cos(Phi01));
612 TVector2 center2((radius2 + D02) * sin(Phi02), -1 * (radius2 + D02) * cos(Phi02));
613 TVector2 cenDiff = center2 - center1;
614 double delR = fabs(radius1) + fabs(radius2) - cenDiff.Mod();
617 TVector2 n1 = cenDiff.Unit();
618 TVector2 vtxXY = center1 + ((fabs(radius1) - (delR / 2)) * n1);
622 double convertedPhotonX(
const Particle* gamma,
const std::vector<double>& daughterIndices)
624 auto vtxXY = convertedPhotonXY(gamma, daughterIndices);
628 double convertedPhotonY(
const Particle* gamma,
const std::vector<double>& daughterIndices)
630 auto vtxXY = convertedPhotonXY(gamma, daughterIndices);
634 double convertedPhotonRho(
const Particle* gamma,
const std::vector<double>& daughterIndices)
636 auto vtxXY = convertedPhotonXY(gamma, daughterIndices);
640 B2Vector3D convertedPhoton3Momentum(
const Particle* gamma,
const std::vector<double>& daughterIndices)
643 int errFlag = convertedPhotonErrorChecks(gamma, daughterIndices);
647 double Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02, Omega2, Z02, TanLambda2;
648 int daughterIndex1 = int(daughterIndices[0]);
649 int daughterIndex2 = int(daughterIndices[1]);
650 errFlag = convertedPhotonLoadHelixParams(gamma, daughterIndex1, daughterIndex2, Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02,
654 B2ERROR(
"First track provided has curvature zero. Calculation of convertedPhoton3Momentum failed.");
658 B2ERROR(
"Second track provided has curvature zero. Calculation of convertedPhoton3Momentum failed.");
664 double radius1 = 1 / Omega1;
665 double radius2 = 1 / Omega2;
667 TVector2 center1((radius1 + D01) * sin(Phi01), -1 * (radius1 + D01) * cos(Phi01));
668 TVector2 center2((radius2 + D02) * sin(Phi02), -1 * (radius2 + D02) * cos(Phi02));
669 TVector2 n1 = center1 - center2; n1 = n1.Unit();
670 TVector2 n2 = -1 * n1;
671 n1 = copysign(1.0, Omega1) * n1;
672 n2 = copysign(1.0, Omega2) * n2;
675 double phiN1 = atan2(n1.X(), -n1.Y());
676 double phiN2 = atan2(n2.X(), -n2.Y());
679 double sinlam1 = TanLambda1 / sqrt(1 + (TanLambda1 * TanLambda1));
680 double coslam1 = 1 / sqrt(1 + (TanLambda1 * TanLambda1));
681 double sinlam2 = TanLambda2 / sqrt(1 + (TanLambda2 * TanLambda2));
682 double coslam2 = 1 / sqrt(1 + (TanLambda2 * TanLambda2));
685 double p1 = gamma->getDaughter(daughterIndex1)->getMomentumMagnitude();
686 B2Vector3D e1Momentum(coslam1 * cos(phiN1), coslam1 * sin(phiN1), sinlam1);
687 double p2 = gamma->getDaughter(daughterIndex2)->getMomentumMagnitude();
688 B2Vector3D e2Momentum(coslam2 * cos(phiN2), coslam2 * sin(phiN2), sinlam2);
689 B2Vector3D gammaMomentum = (e1Momentum * p1) + (e2Momentum * p2);
691 return gammaMomentum;
694 double convertedPhotonPx(
const Particle* gamma,
const std::vector<double>& daughterIndices)
696 auto gammaMomentum = convertedPhoton3Momentum(gamma, daughterIndices);
697 return gammaMomentum.Px();
700 double convertedPhotonPy(
const Particle* gamma,
const std::vector<double>& daughterIndices)
702 auto gammaMomentum = convertedPhoton3Momentum(gamma, daughterIndices);
703 return gammaMomentum.Py();
706 double convertedPhotonPz(
const Particle* gamma,
const std::vector<double>& daughterIndices)
708 auto gammaMomentum = convertedPhoton3Momentum(gamma, daughterIndices);
709 return gammaMomentum.Pz();
712 int v0DaughtersShareInnermostHit(
const Particle* part)
716 auto daughterPlus = part->getDaughter(0);
717 auto daughterMinus = part->getDaughter(1);
718 if (!daughterPlus || !daughterMinus)
720 auto trackFitPlus = daughterPlus->getTrackFitResult();
721 auto trackFitMinus = daughterMinus->getTrackFitResult();
722 if (!trackFitPlus || !trackFitMinus)
724 int flagPlus = trackFitPlus->getHitPatternVXD().getInnermostHitShareStatus();
725 int flagMinus = trackFitMinus->getHitPatternVXD().getInnermostHitShareStatus();
726 if (flagPlus != flagMinus)
731 bool v0DaughtersShareInnermostUHit(
const Particle* part)
733 return ((v0DaughtersShareInnermostHit(part) / 2) == 1);
736 bool v0DaughtersShareInnermostVHit(
const Particle* part)
738 return ((v0DaughtersShareInnermostHit(part) % 2) == 1);
741 VARIABLE_GROUP(
"V0Daughter");
743 REGISTER_VARIABLE(
"v0DaughterNCDCHits(i)", v0DaughterTrackNCDCHits,
"Number of CDC hits associated to the i-th daughter track");
744 MAKE_DEPRECATED(
"v0DaughterNCDCHits",
false,
"light-2104-poseidon", R
"DOC(
745 The same value can be calculated with the more generic variable `nCDCHits`,
746 so replace the current call with ``daughter(i, nCDCHits)``.)DOC");
747 REGISTER_VARIABLE("v0DaughterNSVDHits(i)", v0DaughterTrackNSVDHits,
"Number of SVD hits associated to the i-th daughter track");
748 MAKE_DEPRECATED(
"v0DaughterNSVDHits",
false,
"light-2104-poseidon", R
"DOC(
749 The same value can be calculated with the more generic variable `nSVDHits`,
750 so replace the current call with ``daughter(i, nSVDHits)``.)DOC");
751 REGISTER_VARIABLE("v0DaughterNPXDHits(i)", v0DaughterTrackNPXDHits,
"Number of PXD hits associated to the i-th daughter track");
752 MAKE_DEPRECATED(
"v0DaughterNPXDHits",
false,
"light-2104-poseidon", R
"DOC(
753 The same value can be calculated with the more generic variable `nPXDHits`,
754 so replace the current call with ``daughter(i, nPXDHits)``.)DOC");
755 REGISTER_VARIABLE("v0DaughterNVXDHits(i)", v0DaughterTrackNVXDHits,
"Number of PXD+SVD hits associated to the i-th daughter track");
756 MAKE_DEPRECATED(
"v0DaughterNVXDHits",
false,
"light-2104-poseidon", R
"DOC(
757 The same value can be calculated with the more generic variable `nVXDHits`,
758 so replace the current call with ``daughter(i, nVXDHits)``.)DOC");
759 REGISTER_VARIABLE("v0DaughterNRemovedHits(i)", v0DaughterTrackNRemovedHits,
760 "The number of the i-th daughter track hits removed in V0Finder. Returns 0 if called for something other than V0 daughters.");
761 REGISTER_VARIABLE(
"v0DaughterFirstSVDLayer(i)", v0DaughterTrackFirstSVDLayer,
762 "First activated SVD layer associated to the i-th daughter track");
763 MAKE_DEPRECATED(
"v0DaughterFirstSVDLayer",
false,
"light-2104-poseidon", R
"DOC(
764 The same value can be calculated with the more generic variable `firstSVDLayer`,
765 so replace the current call with ``daughter(i, firstSVDLayer)``.)DOC");
766 REGISTER_VARIABLE("v0DaughterFirstPXDLayer(i)", v0DaughterTrackFirstPXDLayer,
767 "First activated PXD layer associated to the i-th daughter track");
768 MAKE_DEPRECATED(
"v0DaughterFirstPXDLayer",
false,
"light-2104-poseidon", R
"DOC(
769 The same value can be calculated with the more generic variable `firstPXDLayer`,
770 so replace the current call with ``daughter(i, firstPXDLayer)``.)DOC");
771 REGISTER_VARIABLE("v0DaughterFirstCDCLayer(i)", v0DaughterTrackFirstCDCLayer,
772 "First activated CDC layer associated to the i-th daughter track");
773 MAKE_DEPRECATED(
"v0DaughterFirstCDCLayer",
false,
"light-2104-poseidon", R
"DOC(
774 The same value can be calculated with the more generic variable `firstCDCLayer`,
775 so replace the current call with ``daughter(i, firstCDCLayer)``.)DOC");
776 REGISTER_VARIABLE("v0DaughterLastCDCLayer(i)", v0DaughterTrackLastCDCLayer,
777 "Last CDC layer associated to the i-th daughter track");
778 MAKE_DEPRECATED(
"v0DaughterLastCDCLayer",
false,
"light-2104-poseidon", R
"DOC(
779 The same value can be calculated with the more generic variable `lastCDCLayer`,
780 so replace the current call with ``daughter(i, lastCDCLayer)``.)DOC");
781 REGISTER_VARIABLE("v0DaughterPValue(i)", v0DaughterTrackPValue,
782 "chi2 probalility of the i-th daughter track fit");
783 MAKE_DEPRECATED(
"v0DaughterPValue",
false,
"light-2104-poseidon", R
"DOC(
784 The same value can be calculated with the more generic variable `pValue`,
785 so replace the current call with ``daughter(i, pValue)``.)DOC");
787 REGISTER_VARIABLE("v0DaughterD0(i)", v0DaughterTrackD0,
"d0 of the i-th daughter track fit\n\n",
"cm");
789 The same value can be calculated with the more generic variable `d0`,
790 so replace the current call with ``daughter(i, d0)``.)DOC");
791 REGISTER_VARIABLE("v0DaughterPhi0(i)", v0DaughterTrackPhi0,
"phi0 of the i-th daughter track fit\n\n",
"rad");
793 The same value can be calculated with the more generic variable `phi0`,
794 so replace the current call with ``daughter(i, phi0)``.)DOC");
795 REGISTER_VARIABLE("v0DaughterOmega(i)", v0DaughterTrackOmega,
"omega of the i-th daughter track fit\n\n",
796 ":math:`\\text{cm}^{-1}`");
797 MAKE_DEPRECATED(
"v0DaughterOmega",
false,
"light-2104-poseidon", R
"DOC(
798 The same value can be calculated with the more generic variable `omega`,
799 so replace the current call with ``daughter(i, omega)``.)DOC");
800 REGISTER_VARIABLE("v0DaughterZ0(i)", v0DaughterTrackZ0,
"z0 of the i-th daughter track fit\n\n",
"cm");
802 The same value can be calculated with the more generic variable `z0`,
803 so replace the current call with ``daughter(i, z0)``.)DOC");
804 REGISTER_VARIABLE("v0DaughterTanLambda(i)", v0DaughterTrackTanLambda,
"tan(lambda) of the i-th daughter track fit");
805 MAKE_DEPRECATED(
"v0DaughterTanLambda",
false,
"light-2104-poseidon", R
"DOC(
806 The same value can be calculated with the more generic variable `tanLambda`,
807 so replace the current call with ``daughter(i, tanLambda)``.)DOC");
809 REGISTER_VARIABLE("v0DaughterD0Error(i)", v0DaughterTrackD0Error,
"d0 error of the i-th daughter track fit\n\n",
"cm");
810 MAKE_DEPRECATED(
"v0DaughterD0Error",
false,
"light-2104-poseidon", R
"DOC(
811 The same value can be calculated with the more generic variable `d0Err`,
812 so replace the current call with ``daughter(i, d0Err)``.)DOC");
813 REGISTER_VARIABLE("v0DaughterPhi0Error(i)", v0DaughterTrackPhi0Error,
"phi0 error of the i-th daughter track fit\n\n",
"rad");
814 MAKE_DEPRECATED(
"v0DaughterPhi0Error",
false,
"light-2104-poseidon", R
"DOC(
815 The same value can be calculated with the more generic variable `phi0Err`,
816 so replace the current call with ``daughter(i, phi0Err)``.)DOC");
817 REGISTER_VARIABLE("v0DaughterOmegaError(i)", v0DaughterTrackOmegaError,
"omega error of the i-th daughter track fit\n\n",
818 ":math:`\\text{cm}^{-1}`");
819 MAKE_DEPRECATED(
"v0DaughterOmegaError",
false,
"light-2104-poseidon", R
"DOC(
820 The same value can be calculated with the more generic variable `omegaErr`,
821 so replace the current call with ``daughter(i, omegaErr)``.)DOC");
822 REGISTER_VARIABLE("v0DaughterZ0Error(i)", v0DaughterTrackZ0Error,
"z0 error of the i-th daughter track fit\n\n",
"cm");
823 MAKE_DEPRECATED(
"v0DaughterZ0Error",
false,
"light-2104-poseidon", R
"DOC(
824 The same value can be calculated with the more generic variable `z0Err`,
825 so replace the current call with ``daughter(i, z0Err)``.)DOC");
826 REGISTER_VARIABLE("v0DaughterTanLambdaError(i)", v0DaughterTrackTanLambdaError,
"tan(lambda) error of the i-th daughter track fit");
827 MAKE_DEPRECATED(
"v0DaughterTanLambdaError",
false,
"light-2104-poseidon", R
"DOC(
828 The same value can be calculated with the more generic variable `tanLambdaErr`,
829 so replace the current call with ``daughter(i, tanLambdaErr)``.)DOC");
832 REGISTER_VARIABLE("V0d0(id)", v0DaughterD0,
833 "Return the d0 impact parameter of a V0's daughter with daughterID index with the V0 vertex point as a pivot for the track.\n\n",
835 REGISTER_VARIABLE(
"V0Deltad0", v0DaughterD0Diff,
836 "Return the difference between d0 impact parameters of V0's daughters with the V0 vertex point as a pivot for the track.\n\n",
838 REGISTER_VARIABLE(
"V0z0(id)", v0DaughterZ0,
839 "Return the z0 impact parameter of a V0's daughter with daughterID index with the V0 vertex point as a pivot for the track.\n\n",
841 REGISTER_VARIABLE(
"V0Deltaz0", v0DaughterZ0Diff,
842 "Return the difference between z0 impact parameters of V0's daughters with the V0 vertex point as a pivot for the track.\n\n",
846 REGISTER_VARIABLE(
"v0DaughterD0PullWithTrueVertexAsPivot(i)", v0DaughterHelixWithTrueVertexAsPivotD0Pull,
847 "d0 pull of the i-th daughter track with the true V0 vertex as the track pivot");
848 REGISTER_VARIABLE(
"v0DaughterPhi0PullWithTrueVertexAsPivot(i)", v0DaughterHelixWithTrueVertexAsPivotPhi0Pull,
849 "phi0 pull of the i-th daughter track with the true V0 vertex as the track pivot");
850 REGISTER_VARIABLE(
"v0DaughterOmegaPullWithTrueVertexAsPivot(i)", v0DaughterHelixWithTrueVertexAsPivotOmegaPull,
851 "omega pull of the i-th daughter track with the true V0 vertex as the track pivot");
852 REGISTER_VARIABLE(
"v0DaughterZ0PullWithTrueVertexAsPivot(i)", v0DaughterHelixWithTrueVertexAsPivotZ0Pull,
853 "z0 pull of the i-th daughter track with the true V0 vertex as the track pivot");
854 REGISTER_VARIABLE(
"v0DaughterTanLambdaPullWithTrueVertexAsPivot(i)", v0DaughterHelixWithTrueVertexAsPivotTanLambdaPull,
855 "tan(lambda) pull of the i-th daughter track with the true V0 vertex as the track pivot");
857 REGISTER_VARIABLE(
"v0DaughterD0PullWithOriginAsPivot(i)", v0DaughterHelixWithOriginAsPivotD0Pull,
858 "d0 pull of the i-th daughter track with the origin as the track pivot");
859 MAKE_DEPRECATED(
"v0DaughterD0PullWithOriginAsPivot",
false,
"light-2104-poseidon", R
"DOC(
860 The same value can be calculated with the more generic variable `d0Pull`,
861 so replace the current call with ``daughter(i, d0Pull)``.)DOC");
862 REGISTER_VARIABLE("v0DaughterPhi0PullWithOriginAsPivot(i)", v0DaughterHelixWithOriginAsPivotPhi0Pull,
863 "phi0 pull of the i-th daughter track with the origin as the track pivot");
864 MAKE_DEPRECATED(
"v0DaughterPhi0PullWithOriginAsPivot",
false,
"light-2104-poseidon", R
"DOC(
865 The same value can be calculated with the more generic variable `phi0Pull`,
866 so replace the current call with ``daughter(i, phi0Pull)``.)DOC");
867 REGISTER_VARIABLE("v0DaughterOmegaPullWithOriginAsPivot(i)", v0DaughterHelixWithOriginAsPivotOmegaPull,
868 "omega pull of the i-th daughter track with the origin as the track pivot");
869 MAKE_DEPRECATED(
"v0DaughterOmegaPullWithOriginAsPivot",
false,
"light-2104-poseidon", R
"DOC(
870 The same value can be calculated with the more generic variable `omegaPull`,
871 so replace the current call with ``daughter(i, omegaPull)``.)DOC");
872 REGISTER_VARIABLE("v0DaughterZ0PullWithOriginAsPivot(i)", v0DaughterHelixWithOriginAsPivotZ0Pull,
873 "z0 pull of the i-th daughter track with the origin as the track pivot");
874 MAKE_DEPRECATED(
"v0DaughterZ0PullWithOriginAsPivot",
false,
"light-2104-poseidon", R
"DOC(
875 The same value can be calculated with the more generic variable `z0Pull`,
876 so replace the current call with ``daughter(i, z0Pull)``.)DOC");
877 REGISTER_VARIABLE("v0DaughterTanLambdaPullWithOriginAsPivot(i)", v0DaughterHelixWithOriginAsPivotTanLambdaPull,
878 "tan(lambda) pull of the i-th daughter track with the origin as the track pivot");
879 MAKE_DEPRECATED(
"v0DaughterTanLambdaPullWithOriginAsPivot",
false,
"light-2104-poseidon", R
"DOC(
880 The same value can be calculated with the more generic variable `tanLambdaPull`,
881 so replace the current call with ``daughter(i, tanLambdaPull)``.)DOC");
883 REGISTER_VARIABLE("v0DaughterTau(i,j)", v0DaughterTrackParam5AtIPPerigee,
884 "j-th track parameter (at IP perigee) of the i-th daughter track. "
885 "j: 0:d0, 1:phi0, 2:omega, 3:z0, 4:tanLambda\n\n",
"cm, rad, :math:`\\text{cm}^{-1}`, cm, unitless");
886 REGISTER_VARIABLE(
"v0DaughterCov(i,j)", v0DaughterTrackParamCov5x5AtIPPerigee,
887 "j-th element of the 15 covariance matrix elements (at IP perigee) of the i-th daughter track. "
888 "(0,0), (0,1) ... (1,1), (1,2) ... (2,2) ..."
889 "index order is: 0:d0, 1:phi0, 2:omega, 3:z0, 4:tanLambda\n\n",
"cm, rad, :math:`\\text{cm}^{-1}`, cm, unitless");
891 REGISTER_VARIABLE(
"convertedPhotonInvariantMass(i,j)", convertedPhotonInvariantMass,
892 "Invariant mass of the i-j daughter system as defined in https://indico.belle2.org/event/3644/contributions/18622/attachments/9401/14443/Photon_vertexin_B2GM.pdf, assuming it's a converted photon\n\n",
893 "GeV/:math:`\\text{c}^2`");
894 REGISTER_VARIABLE(
"convertedPhotonDelTanLambda(i,j)", convertedPhotonDelTanLambda,
895 "Discriminating variable Delta-TanLambda calculated for daughters (i,j) as defined in https://indico.belle2.org/event/3644/contributions/18622/attachments/9401/14443/Photon_vertexin_B2GM.pdf, assuming it's a converted photon");
896 REGISTER_VARIABLE(
"convertedPhotonDelR(i,j)", convertedPhotonDelR,
897 "Discriminating variable Delta-R calculated for daughters (i,j) as defined in https://indico.belle2.org/event/3644/contributions/18622/attachments/9401/14443/Photon_vertexin_B2GM.pdf, assuming it's a converted photon\n\n",
899 REGISTER_VARIABLE(
"convertedPhotonDelZ(i,j)", convertedPhotonDelZ,
900 "Discriminating variable Delta-Z calculated for daughters (i,j) as defined in https://indico.belle2.org/event/3644/contributions/18622/attachments/9401/14443/Photon_vertexin_B2GM.pdf, assuming it's a converted photon\n\n",
902 REGISTER_VARIABLE(
"convertedPhotonX(i,j)", convertedPhotonX,
903 "Estimate of vertex X coordinate calculated for daughters (i,j) as defined in https://indico.belle2.org/event/3644/contributions/18622/attachments/9401/14443/Photon_vertexin_B2GM.pdf, assuming it's a converted photon\n\n",
905 REGISTER_VARIABLE(
"convertedPhotonY(i,j)", convertedPhotonY,
906 "Estimate of vertex Y coordinate calculated for daughters (i,j) as defined in https://indico.belle2.org/event/3644/contributions/18622/attachments/9401/14443/Photon_vertexin_B2GM.pdf, assuming it's a converted photon\n\n",
908 REGISTER_VARIABLE(
"convertedPhotonZ(i,j)", convertedPhotonZ,
909 "Estimate of vertex Z coordinate calculated for daughters (i,j) as defined in https://indico.belle2.org/event/3644/contributions/18622/attachments/9401/14443/Photon_vertexin_B2GM.pdf, assuming it's a converted photon\n\n",
911 REGISTER_VARIABLE(
"convertedPhotonRho(i,j)", convertedPhotonRho,
912 "Estimate of vertex Rho calculated for daughters (i,j) as defined in https://indico.belle2.org/event/3644/contributions/18622/attachments/9401/14443/Photon_vertexin_B2GM.pdf, assuming it's a converted photon\n\n",
914 REGISTER_VARIABLE(
"convertedPhotonPx(i,j)", convertedPhotonPx,
915 "Estimate of x-component of photon momentum calculated for daughters (i,j) as defined in https://indico.belle2.org/event/3644/contributions/18622/attachments/9401/14443/Photon_vertexin_B2GM.pdf, assuming it's a converted photon\n\n",
917 REGISTER_VARIABLE(
"convertedPhotonPy(i,j)", convertedPhotonPy,
918 "Estimate of y-component of photon momentum calculated for daughters (i,j) as defined in https://indico.belle2.org/event/3644/contributions/18622/attachments/9401/14443/Photon_vertexin_B2GM.pdf, assuming it's a converted photon\n\n",
920 REGISTER_VARIABLE(
"convertedPhotonPz(i,j)", convertedPhotonPz,
921 "Estimate of z-component of photon momentum calculated for daughters (i,j) as defined in https://indico.belle2.org/event/3644/contributions/18622/attachments/9401/14443/Photon_vertexin_B2GM.pdf, assuming it's a converted photon\n\n",
924 REGISTER_VARIABLE(
"v0DaughtersShare1stHit", v0DaughtersShareInnermostHit,
925 "flag for V0 daughters sharing the first(innermost) VXD hit. 0x1(0x2) bit represents V/z(U/r-phi)-hit share.");
926 REGISTER_VARIABLE(
"v0DaughtersShare1stUHit", v0DaughtersShareInnermostUHit,
927 "flag for V0 daughters sharing the first(innermost) VXD U-side hit.");
928 REGISTER_VARIABLE(
"v0DaughtersShare1stVHit", v0DaughtersShareInnermostVHit,
929 "flag for V0 daughters sharing the first(innermost) VXD V-side hit.");
static ROOT::Math::XYZVector getFieldInTesla(const ROOT::Math::XYZVector &pos)
return the magnetic field at a given position in Tesla.
EDetector
Enum for identifying the detector components (detector and subdetector).
static const double electronMass
electron mass
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...
const Particle * getDaughter(unsigned i) const
Returns a pointer to the i-th daughter particle.
#define MAKE_DEPRECATED(name, make_fatal, version, description)
Registers a variable as deprecated.
B2Vector3< double > B2Vector3D
typedef for common usage with double
Abstract base class for different kinds of events.