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));
236 const MCParticle* mcparticle_v0 = particle->getMCParticle();
241 const MCParticle* mcparticle = particle->getDaughter(dID)->getMCParticle();
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 const TrackFitResult* e1TrackFit = gamma->getDaughter(daughterIndex1)->getTrackFitResult();
415 if (!e1TrackFit)
return -1;
416 Helix e1Helix = e1TrackFit->getHelix();
418 Phi01 = e1Helix.getPhi0();
419 D01 = e1Helix.getD0() ;
420 Omega1 = e1Helix.getOmega();
421 Z01 = e1Helix.getZ0();
422 TanLambda1 = e1Helix.getTanLambda();
425 const TrackFitResult* e2TrackFit = gamma->getDaughter(daughterIndex2)->getTrackFitResult();
426 if (!e2TrackFit)
return -2;
427 Helix e2Helix = e2TrackFit->getHelix();
429 Phi02 = e2Helix.getPhi0();
430 D02 = e2Helix.getD0() ;
431 Omega2 = e2Helix.getOmega();
432 Z02 = e2Helix.getZ0();
433 TanLambda2 = e2Helix.getTanLambda();
436 if (Omega1 == 0) {
return -1;}
437 else if (Omega2 == 0) {
return -2;}
442 double convertedPhotonInvariantMass(
const Particle* gamma,
const std::vector<double>& daughterIndices)
445 int errFlag = convertedPhotonErrorChecks(gamma, daughterIndices);
449 double Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02, Omega2, Z02, TanLambda2;
450 int daughterIndex1 = int(daughterIndices[0]);
451 int daughterIndex2 = int(daughterIndices[1]);
452 errFlag = convertedPhotonLoadHelixParams(gamma, daughterIndex1, daughterIndex2, Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02,
453 Omega2, Z02, TanLambda2);
458 double sinlam1 = TanLambda1 /
sqrt(1 + (TanLambda1 * TanLambda1));
459 double coslam1 = 1 /
sqrt(1 + (TanLambda1 * TanLambda1));
460 double sinlam2 = TanLambda2 /
sqrt(1 + (TanLambda2 * TanLambda2));
461 double coslam2 = 1 /
sqrt(1 + (TanLambda2 * TanLambda2));
465 double p1 = gamma->getDaughter(daughterIndex1)->getMomentumMagnitude();
466 double pt1 = p1 * coslam1, pz1 = p1 * sinlam1;
469 double p2 = gamma->getDaughter(daughterIndex2)->getMomentumMagnitude();
470 double pt2 = p2 * coslam2, pz2 = p2 * sinlam2;
474 double vtxMass =
sqrt(pow(e1 + e2, 2.0) - pow(pt1 + pt2, 2.0) - pow(pz1 + pz2, 2.0));
478 double convertedPhotonDelTanLambda(
const Particle* gamma,
const std::vector<double>& daughterIndices)
481 int errFlag = convertedPhotonErrorChecks(gamma, daughterIndices);
485 double Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02, Omega2, Z02, TanLambda2;
486 int daughterIndex1 = int(daughterIndices[0]);
487 int daughterIndex2 = int(daughterIndices[1]);
488 errFlag = convertedPhotonLoadHelixParams(gamma, daughterIndex1, daughterIndex2, Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02,
489 Omega2, Z02, TanLambda2);
493 return (TanLambda2 - TanLambda1);
496 double convertedPhotonDelR(
const Particle* gamma,
const std::vector<double>& daughterIndices)
499 int errFlag = convertedPhotonErrorChecks(gamma, daughterIndices);
503 double Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02, Omega2, Z02, TanLambda2;
504 int daughterIndex1 = int(daughterIndices[0]);
505 int daughterIndex2 = int(daughterIndices[1]);
506 errFlag = convertedPhotonLoadHelixParams(gamma, daughterIndex1, daughterIndex2, Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02,
507 Omega2, Z02, TanLambda2);
509 B2ERROR(
"First track provided has curvature zero. Calculation of convertedPhotonDelR failed.");
513 B2ERROR(
"Second track provided has curvature zero. Calculation of convertedPhotonDelR failed.");
518 double radius1 = 1 / Omega1;
519 double radius2 = 1 / Omega2;
521 TVector2 center1((radius1 + D01) * sin(Phi01), -1 * (radius1 + D01) * cos(Phi01));
522 TVector2 center2((radius2 + D02) * sin(Phi02), -1 * (radius2 + D02) * cos(Phi02));
523 TVector2 cenDiff = center1 - center2;
525 double delR = fabs(radius1) + fabs(radius2) - cenDiff.Mod();
529 std::pair<double, double> convertedPhotonZ1Z2(
const Particle* gamma,
const std::vector<double>& daughterIndices)
532 int errFlag = convertedPhotonErrorChecks(gamma, daughterIndices);
536 double Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02, Omega2, Z02, TanLambda2;
537 int daughterIndex1 = int(daughterIndices[0]);
538 int daughterIndex2 = int(daughterIndices[1]);
539 errFlag = convertedPhotonLoadHelixParams(gamma, daughterIndex1, daughterIndex2, Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02,
540 Omega2, Z02, TanLambda2);
542 B2ERROR(
"First track provided has curvature zero. Calculation of convertedPhotonZ1Z2 failed.");
546 B2ERROR(
"Second track provided has curvature zero. Calculation of convertedPhotonZ1Z2 failed.");
552 double radius1 = 1 / Omega1;
553 double radius2 = 1 / Omega2;
555 TVector2 center1((radius1 + D01) * sin(Phi01), -1 * (radius1 + D01) * cos(Phi01));
556 TVector2 center2((radius2 + D02) * sin(Phi02), -1 * (radius2 + D02) * cos(Phi02));
558 TVector2 n1 = center1 - center2; n1 = n1.Unit();
559 TVector2 n2 = -1 * n1;
560 n1 = copysign(1.0, Omega1) * n1;
561 n2 = copysign(1.0, Omega2) * n2;
564 double phiN1 = atan2(n1.X(), -n1.Y());
565 double phiN2 = atan2(n2.X(), -n2.Y());
566 double Phi01Intersect = phiN1 - Phi01;
567 double Phi02Intersect = phiN2 - Phi02;
569 double z1 = Z01 - (radius1 * TanLambda1 * Phi01Intersect);
570 double z2 = Z02 - (radius2 * TanLambda2 * Phi02Intersect);
571 std::pair<double, double> z1z2(z1, z2);
575 double convertedPhotonDelZ(
const Particle* gamma,
const std::vector<double>& daughterIndices)
577 std::pair<double, double> z1z2 = convertedPhotonZ1Z2(gamma, daughterIndices);
578 double z1 = z1z2.first;
double z2 = z1z2.second;
582 double convertedPhotonZ(
const Particle* gamma,
const std::vector<double>& daughterIndices)
584 std::pair<double, double> z1z2 = convertedPhotonZ1Z2(gamma, daughterIndices);
585 double z1 = z1z2.first;
double z2 = z1z2.second;
586 return (z1 + z2) * 0.5;
589 TVector2 convertedPhotonXY(
const Particle* gamma,
const std::vector<double>& daughterIndices)
592 int errFlag = convertedPhotonErrorChecks(gamma, daughterIndices);
596 double Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02, Omega2, Z02, TanLambda2;
597 int daughterIndex1 = int(daughterIndices[0]);
598 int daughterIndex2 = int(daughterIndices[1]);
599 errFlag = convertedPhotonLoadHelixParams(gamma, daughterIndex1, daughterIndex2, Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02,
600 Omega2, Z02, TanLambda2);
602 B2ERROR(
"First track provided has curvature zero. Calculation of convertedPhotonXY failed.");
606 B2ERROR(
"Second track provided has curvature zero. Calculation of convertedPhotonXY failed.");
611 double radius1 = 1 / Omega1;
612 double radius2 = 1 / Omega2;
614 TVector2 center1((radius1 + D01) * sin(Phi01), -1 * (radius1 + D01) * cos(Phi01));
615 TVector2 center2((radius2 + D02) * sin(Phi02), -1 * (radius2 + D02) * cos(Phi02));
616 TVector2 cenDiff = center2 - center1;
617 double delR = fabs(radius1) + fabs(radius2) - cenDiff.Mod();
620 TVector2 n1 = cenDiff.Unit();
621 TVector2 vtxXY = center1 + ((fabs(radius1) - (delR / 2)) * n1);
625 double convertedPhotonX(
const Particle* gamma,
const std::vector<double>& daughterIndices)
627 auto vtxXY = convertedPhotonXY(gamma, daughterIndices);
631 double convertedPhotonY(
const Particle* gamma,
const std::vector<double>& daughterIndices)
633 auto vtxXY = convertedPhotonXY(gamma, daughterIndices);
637 double convertedPhotonRho(
const Particle* gamma,
const std::vector<double>& daughterIndices)
639 auto vtxXY = convertedPhotonXY(gamma, daughterIndices);
643 B2Vector3D convertedPhoton3Momentum(
const Particle* gamma,
const std::vector<double>& daughterIndices)
646 int errFlag = convertedPhotonErrorChecks(gamma, daughterIndices);
650 double Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02, Omega2, Z02, TanLambda2;
651 int daughterIndex1 = int(daughterIndices[0]);
652 int daughterIndex2 = int(daughterIndices[1]);
653 errFlag = convertedPhotonLoadHelixParams(gamma, daughterIndex1, daughterIndex2, Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02,
657 B2ERROR(
"First track provided has curvature zero. Calculation of convertedPhoton3Momentum failed.");
661 B2ERROR(
"Second track provided has curvature zero. Calculation of convertedPhoton3Momentum failed.");
667 double radius1 = 1 / Omega1;
668 double radius2 = 1 / Omega2;
670 TVector2 center1((radius1 + D01) * sin(Phi01), -1 * (radius1 + D01) * cos(Phi01));
671 TVector2 center2((radius2 + D02) * sin(Phi02), -1 * (radius2 + D02) * cos(Phi02));
672 TVector2 n1 = center1 - center2; n1 = n1.Unit();
673 TVector2 n2 = -1 * n1;
674 n1 = copysign(1.0, Omega1) * n1;
675 n2 = copysign(1.0, Omega2) * n2;
678 double phiN1 = atan2(n1.X(), -n1.Y());
679 double phiN2 = atan2(n2.X(), -n2.Y());
682 double sinlam1 = TanLambda1 /
sqrt(1 + (TanLambda1 * TanLambda1));
683 double coslam1 = 1 /
sqrt(1 + (TanLambda1 * TanLambda1));
684 double sinlam2 = TanLambda2 /
sqrt(1 + (TanLambda2 * TanLambda2));
685 double coslam2 = 1 /
sqrt(1 + (TanLambda2 * TanLambda2));
688 double p1 = gamma->getDaughter(daughterIndex1)->getMomentumMagnitude();
689 B2Vector3D e1Momentum(coslam1 * cos(phiN1), coslam1 * sin(phiN1), sinlam1);
690 double p2 = gamma->getDaughter(daughterIndex2)->getMomentumMagnitude();
691 B2Vector3D e2Momentum(coslam2 * cos(phiN2), coslam2 * sin(phiN2), sinlam2);
692 B2Vector3D gammaMomentum = (e1Momentum * p1) + (e2Momentum * p2);
694 return gammaMomentum;
697 double convertedPhotonPx(
const Particle* gamma,
const std::vector<double>& daughterIndices)
699 auto gammaMomentum = convertedPhoton3Momentum(gamma, daughterIndices);
700 return gammaMomentum.Px();
703 double convertedPhotonPy(
const Particle* gamma,
const std::vector<double>& daughterIndices)
705 auto gammaMomentum = convertedPhoton3Momentum(gamma, daughterIndices);
706 return gammaMomentum.Py();
709 double convertedPhotonPz(
const Particle* gamma,
const std::vector<double>& daughterIndices)
711 auto gammaMomentum = convertedPhoton3Momentum(gamma, daughterIndices);
712 return gammaMomentum.Pz();
715 int v0DaughtersShareInnermostHit(
const Particle* part)
719 auto daughterPlus = part->getDaughter(0);
720 auto daughterMinus = part->getDaughter(1);
721 if (!daughterPlus || !daughterMinus)
723 auto trackFitPlus = daughterPlus->getTrackFitResult();
724 auto trackFitMinus = daughterMinus->getTrackFitResult();
725 if (!trackFitPlus || !trackFitMinus)
727 int flagPlus = trackFitPlus->getHitPatternVXD().getInnermostHitShareStatus();
728 int flagMinus = trackFitMinus->getHitPatternVXD().getInnermostHitShareStatus();
729 if (flagPlus != flagMinus)
734 bool v0DaughtersShareInnermostUHit(
const Particle* part)
736 return ((v0DaughtersShareInnermostHit(part) / 2) == 1);
739 bool v0DaughtersShareInnermostVHit(
const Particle* part)
741 return ((v0DaughtersShareInnermostHit(part) % 2) == 1);
744 VARIABLE_GROUP(
"V0Daughter");
746 REGISTER_VARIABLE(
"v0DaughterNCDCHits(i)", v0DaughterTrackNCDCHits,
"Number of CDC hits associated to the i-th daughter track");
747 MAKE_DEPRECATED(
"v0DaughterNCDCHits",
true,
"light-2104-poseidon", R
"DOC(
748 The same value can be calculated with the more generic variable `nCDCHits`,
749 so replace the current call with ``daughter(i, nCDCHits)``.)DOC");
750 REGISTER_VARIABLE("v0DaughterNSVDHits(i)", v0DaughterTrackNSVDHits,
"Number of SVD hits associated to the i-th daughter track");
751 MAKE_DEPRECATED(
"v0DaughterNSVDHits",
true,
"light-2104-poseidon", R
"DOC(
752 The same value can be calculated with the more generic variable `nSVDHits`,
753 so replace the current call with ``daughter(i, nSVDHits)``.)DOC");
754 REGISTER_VARIABLE("v0DaughterNPXDHits(i)", v0DaughterTrackNPXDHits,
"Number of PXD hits associated to the i-th daughter track");
755 MAKE_DEPRECATED(
"v0DaughterNPXDHits",
true,
"light-2104-poseidon", R
"DOC(
756 The same value can be calculated with the more generic variable `nPXDHits`,
757 so replace the current call with ``daughter(i, nPXDHits)``.)DOC");
758 REGISTER_VARIABLE("v0DaughterNVXDHits(i)", v0DaughterTrackNVXDHits,
"Number of PXD+SVD hits associated to the i-th daughter track");
759 MAKE_DEPRECATED(
"v0DaughterNVXDHits",
true,
"light-2104-poseidon", R
"DOC(
760 The same value can be calculated with the more generic variable `nVXDHits`,
761 so replace the current call with ``daughter(i, nVXDHits)``.)DOC");
762 REGISTER_VARIABLE("v0DaughterNRemovedHits(i)", v0DaughterTrackNRemovedHits,
763 "The number of the i-th daughter track hits removed in V0Finder. Returns 0 if called for something other than V0 daughters.");
764 REGISTER_VARIABLE(
"v0DaughterFirstSVDLayer(i)", v0DaughterTrackFirstSVDLayer,
765 "First activated SVD layer associated to the i-th daughter track");
766 MAKE_DEPRECATED(
"v0DaughterFirstSVDLayer",
true,
"light-2104-poseidon", R
"DOC(
767 The same value can be calculated with the more generic variable `firstSVDLayer`,
768 so replace the current call with ``daughter(i, firstSVDLayer)``.)DOC");
769 REGISTER_VARIABLE("v0DaughterFirstPXDLayer(i)", v0DaughterTrackFirstPXDLayer,
770 "First activated PXD layer associated to the i-th daughter track");
771 MAKE_DEPRECATED(
"v0DaughterFirstPXDLayer",
true,
"light-2104-poseidon", R
"DOC(
772 The same value can be calculated with the more generic variable `firstPXDLayer`,
773 so replace the current call with ``daughter(i, firstPXDLayer)``.)DOC");
774 REGISTER_VARIABLE("v0DaughterFirstCDCLayer(i)", v0DaughterTrackFirstCDCLayer,
775 "First activated CDC layer associated to the i-th daughter track");
776 MAKE_DEPRECATED(
"v0DaughterFirstCDCLayer",
true,
"light-2104-poseidon", R
"DOC(
777 The same value can be calculated with the more generic variable `firstCDCLayer`,
778 so replace the current call with ``daughter(i, firstCDCLayer)``.)DOC");
779 REGISTER_VARIABLE("v0DaughterLastCDCLayer(i)", v0DaughterTrackLastCDCLayer,
780 "Last CDC layer associated to the i-th daughter track");
781 MAKE_DEPRECATED(
"v0DaughterLastCDCLayer",
true,
"light-2104-poseidon", R
"DOC(
782 The same value can be calculated with the more generic variable `lastCDCLayer`,
783 so replace the current call with ``daughter(i, lastCDCLayer)``.)DOC");
784 REGISTER_VARIABLE("v0DaughterPValue(i)", v0DaughterTrackPValue,
785 "chi2 probalility of the i-th daughter track fit");
786 MAKE_DEPRECATED(
"v0DaughterPValue",
true,
"light-2104-poseidon", R
"DOC(
787 The same value can be calculated with the more generic variable `pValue`,
788 so replace the current call with ``daughter(i, pValue)``.)DOC");
790 REGISTER_VARIABLE("v0DaughterD0(i)", v0DaughterTrackD0,
"d0 of the i-th daughter track fit\n\n",
"cm");
792 The same value can be calculated with the more generic variable `d0`,
793 so replace the current call with ``daughter(i, d0)``.)DOC");
794 REGISTER_VARIABLE("v0DaughterPhi0(i)", v0DaughterTrackPhi0,
"phi0 of the i-th daughter track fit\n\n",
"rad");
796 The same value can be calculated with the more generic variable `phi0`,
797 so replace the current call with ``daughter(i, phi0)``.)DOC");
798 REGISTER_VARIABLE("v0DaughterOmega(i)", v0DaughterTrackOmega,
"omega of the i-th daughter track fit\n\n",
799 ":math:`\\text{cm}^{-1}`");
801 The same value can be calculated with the more generic variable `omega`,
802 so replace the current call with ``daughter(i, omega)``.)DOC");
803 REGISTER_VARIABLE("v0DaughterZ0(i)", v0DaughterTrackZ0,
"z0 of the i-th daughter track fit\n\n",
"cm");
805 The same value can be calculated with the more generic variable `z0`,
806 so replace the current call with ``daughter(i, z0)``.)DOC");
807 REGISTER_VARIABLE("v0DaughterTanLambda(i)", v0DaughterTrackTanLambda,
"tan(lambda) of the i-th daughter track fit");
808 MAKE_DEPRECATED(
"v0DaughterTanLambda",
true,
"light-2104-poseidon", R
"DOC(
809 The same value can be calculated with the more generic variable `tanLambda`,
810 so replace the current call with ``daughter(i, tanLambda)``.)DOC");
812 REGISTER_VARIABLE("v0DaughterD0Error(i)", v0DaughterTrackD0Error,
"d0 error of the i-th daughter track fit\n\n",
"cm");
813 MAKE_DEPRECATED(
"v0DaughterD0Error",
true,
"light-2104-poseidon", R
"DOC(
814 The same value can be calculated with the more generic variable `d0Err`,
815 so replace the current call with ``daughter(i, d0Err)``.)DOC");
816 REGISTER_VARIABLE("v0DaughterPhi0Error(i)", v0DaughterTrackPhi0Error,
"phi0 error of the i-th daughter track fit\n\n",
"rad");
817 MAKE_DEPRECATED(
"v0DaughterPhi0Error",
true,
"light-2104-poseidon", R
"DOC(
818 The same value can be calculated with the more generic variable `phi0Err`,
819 so replace the current call with ``daughter(i, phi0Err)``.)DOC");
820 REGISTER_VARIABLE("v0DaughterOmegaError(i)", v0DaughterTrackOmegaError,
"omega error of the i-th daughter track fit\n\n",
821 ":math:`\\text{cm}^{-1}`");
822 MAKE_DEPRECATED(
"v0DaughterOmegaError",
true,
"light-2104-poseidon", R
"DOC(
823 The same value can be calculated with the more generic variable `omegaErr`,
824 so replace the current call with ``daughter(i, omegaErr)``.)DOC");
825 REGISTER_VARIABLE("v0DaughterZ0Error(i)", v0DaughterTrackZ0Error,
"z0 error of the i-th daughter track fit\n\n",
"cm");
826 MAKE_DEPRECATED(
"v0DaughterZ0Error",
true,
"light-2104-poseidon", R
"DOC(
827 The same value can be calculated with the more generic variable `z0Err`,
828 so replace the current call with ``daughter(i, z0Err)``.)DOC");
829 REGISTER_VARIABLE("v0DaughterTanLambdaError(i)", v0DaughterTrackTanLambdaError,
"tan(lambda) error of the i-th daughter track fit");
830 MAKE_DEPRECATED(
"v0DaughterTanLambdaError",
true,
"light-2104-poseidon", R
"DOC(
831 The same value can be calculated with the more generic variable `tanLambdaErr`,
832 so replace the current call with ``daughter(i, tanLambdaErr)``.)DOC");
835 REGISTER_VARIABLE("V0d0(id)", v0DaughterD0,
836 "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",
838 REGISTER_VARIABLE(
"V0Deltad0", v0DaughterD0Diff,
839 "Return the difference between d0 impact parameters of V0's daughters with the V0 vertex point as a pivot for the track.\n\n",
841 REGISTER_VARIABLE(
"V0z0(id)", v0DaughterZ0,
842 "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",
844 REGISTER_VARIABLE(
"V0Deltaz0", v0DaughterZ0Diff,
845 "Return the difference between z0 impact parameters of V0's daughters with the V0 vertex point as a pivot for the track.\n\n",
849 REGISTER_VARIABLE(
"v0DaughterD0PullWithTrueVertexAsPivot(i)", v0DaughterHelixWithTrueVertexAsPivotD0Pull,
850 "d0 pull of the i-th daughter track with the true V0 vertex as the track pivot");
851 REGISTER_VARIABLE(
"v0DaughterPhi0PullWithTrueVertexAsPivot(i)", v0DaughterHelixWithTrueVertexAsPivotPhi0Pull,
852 "phi0 pull of the i-th daughter track with the true V0 vertex as the track pivot");
853 REGISTER_VARIABLE(
"v0DaughterOmegaPullWithTrueVertexAsPivot(i)", v0DaughterHelixWithTrueVertexAsPivotOmegaPull,
854 "omega pull of the i-th daughter track with the true V0 vertex as the track pivot");
855 REGISTER_VARIABLE(
"v0DaughterZ0PullWithTrueVertexAsPivot(i)", v0DaughterHelixWithTrueVertexAsPivotZ0Pull,
856 "z0 pull of the i-th daughter track with the true V0 vertex as the track pivot");
857 REGISTER_VARIABLE(
"v0DaughterTanLambdaPullWithTrueVertexAsPivot(i)", v0DaughterHelixWithTrueVertexAsPivotTanLambdaPull,
858 "tan(lambda) pull of the i-th daughter track with the true V0 vertex as the track pivot");
860 REGISTER_VARIABLE(
"v0DaughterD0PullWithOriginAsPivot(i)", v0DaughterHelixWithOriginAsPivotD0Pull,
861 "d0 pull of the i-th daughter track with the origin as the track pivot");
862 MAKE_DEPRECATED(
"v0DaughterD0PullWithOriginAsPivot",
true,
"light-2104-poseidon", R
"DOC(
863 The same value can be calculated with the more generic variable `d0Pull`,
864 so replace the current call with ``daughter(i, d0Pull)``.)DOC");
865 REGISTER_VARIABLE("v0DaughterPhi0PullWithOriginAsPivot(i)", v0DaughterHelixWithOriginAsPivotPhi0Pull,
866 "phi0 pull of the i-th daughter track with the origin as the track pivot");
867 MAKE_DEPRECATED(
"v0DaughterPhi0PullWithOriginAsPivot",
true,
"light-2104-poseidon", R
"DOC(
868 The same value can be calculated with the more generic variable `phi0Pull`,
869 so replace the current call with ``daughter(i, phi0Pull)``.)DOC");
870 REGISTER_VARIABLE("v0DaughterOmegaPullWithOriginAsPivot(i)", v0DaughterHelixWithOriginAsPivotOmegaPull,
871 "omega pull of the i-th daughter track with the origin as the track pivot");
872 MAKE_DEPRECATED(
"v0DaughterOmegaPullWithOriginAsPivot",
true,
"light-2104-poseidon", R
"DOC(
873 The same value can be calculated with the more generic variable `omegaPull`,
874 so replace the current call with ``daughter(i, omegaPull)``.)DOC");
875 REGISTER_VARIABLE("v0DaughterZ0PullWithOriginAsPivot(i)", v0DaughterHelixWithOriginAsPivotZ0Pull,
876 "z0 pull of the i-th daughter track with the origin as the track pivot");
877 MAKE_DEPRECATED(
"v0DaughterZ0PullWithOriginAsPivot",
true,
"light-2104-poseidon", R
"DOC(
878 The same value can be calculated with the more generic variable `z0Pull`,
879 so replace the current call with ``daughter(i, z0Pull)``.)DOC");
880 REGISTER_VARIABLE("v0DaughterTanLambdaPullWithOriginAsPivot(i)", v0DaughterHelixWithOriginAsPivotTanLambdaPull,
881 "tan(lambda) pull of the i-th daughter track with the origin as the track pivot");
882 MAKE_DEPRECATED(
"v0DaughterTanLambdaPullWithOriginAsPivot",
true,
"light-2104-poseidon", R
"DOC(
883 The same value can be calculated with the more generic variable `tanLambdaPull`,
884 so replace the current call with ``daughter(i, tanLambdaPull)``.)DOC");
886 REGISTER_VARIABLE("v0DaughterTau(i,j)", v0DaughterTrackParam5AtIPPerigee,
887 "j-th track parameter (at IP perigee) of the i-th daughter track. "
888 "j: 0:d0, 1:phi0, 2:omega, 3:z0, 4:tanLambda\n\n",
"cm, rad, :math:`\\text{cm}^{-1}`, cm, unitless");
889 REGISTER_VARIABLE(
"v0DaughterCov(i,j)", v0DaughterTrackParamCov5x5AtIPPerigee,
890 "j-th element of the 15 covariance matrix elements (at IP perigee) of the i-th daughter track. "
891 "(0,0), (0,1) ... (1,1), (1,2) ... (2,2) ..."
892 "index order is: 0:d0, 1:phi0, 2:omega, 3:z0, 4:tanLambda\n\n",
"cm, rad, :math:`\\text{cm}^{-1}`, cm, unitless");
894 REGISTER_VARIABLE(
"convertedPhotonInvariantMass(i,j)", convertedPhotonInvariantMass,
895 "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",
896 "GeV/:math:`\\text{c}^2`");
897 REGISTER_VARIABLE(
"convertedPhotonDelTanLambda(i,j)", convertedPhotonDelTanLambda,
898 "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");
899 REGISTER_VARIABLE(
"convertedPhotonDelR(i,j)", convertedPhotonDelR,
900 "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",
902 REGISTER_VARIABLE(
"convertedPhotonDelZ(i,j)", convertedPhotonDelZ,
903 "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",
905 REGISTER_VARIABLE(
"convertedPhotonX(i,j)", convertedPhotonX,
906 "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",
908 REGISTER_VARIABLE(
"convertedPhotonY(i,j)", convertedPhotonY,
909 "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",
911 REGISTER_VARIABLE(
"convertedPhotonZ(i,j)", convertedPhotonZ,
912 "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",
914 REGISTER_VARIABLE(
"convertedPhotonRho(i,j)", convertedPhotonRho,
915 "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",
917 REGISTER_VARIABLE(
"convertedPhotonPx(i,j)", convertedPhotonPx,
918 "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",
920 REGISTER_VARIABLE(
"convertedPhotonPy(i,j)", convertedPhotonPy,
921 "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",
923 REGISTER_VARIABLE(
"convertedPhotonPz(i,j)", convertedPhotonPz,
924 "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",
927 REGISTER_VARIABLE(
"v0DaughtersShare1stHit", v0DaughtersShareInnermostHit,
928 "flag for V0 daughters sharing the first(innermost) VXD hit. 0x1(0x2) bit represents V/z(U/r-phi)-hit share.");
929 REGISTER_VARIABLE(
"v0DaughtersShare1stUHit", v0DaughtersShareInnermostUHit,
930 "flag for V0 daughters sharing the first(innermost) VXD U-side hit.");
931 REGISTER_VARIABLE(
"v0DaughtersShare1stVHit", v0DaughtersShareInnermostVHit,
932 "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
#define MAKE_DEPRECATED(name, make_fatal, version, description)
Registers a variable as deprecated.
B2Vector3< double > B2Vector3D
typedef for common usage with double
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.