10 #include <analysis/variables/V0DaughterTrackVariables.h>
11 #include <analysis/VariableManager/Manager.h>
13 #include <analysis/variables/TrackVariables.h>
16 #include <framework/dataobjects/Helix.h>
19 #include <mdst/dataobjects/MCParticle.h>
20 #include <mdst/dataobjects/TrackFitResult.h>
21 #include <mdst/dataobjects/HitPatternVXD.h>
24 #include <framework/logging/Logger.h>
41 double getV0DaughterTrackDetNHits(
const Particle* particle,
const double daughterID,
const Const::EDetector& det)
43 auto daughter = particle->getDaughter(daughterID);
44 return trackNHits(daughter, det);
47 double v0DaughterTrackNCDCHits(
const Particle* part,
const std::vector<double>& daughterID)
49 return getV0DaughterTrackDetNHits(part, daughterID[0], Const::EDetector::CDC);
52 double v0DaughterTrackNSVDHits(
const Particle* part,
const std::vector<double>& daughterID)
54 return getV0DaughterTrackDetNHits(part, daughterID[0], Const::EDetector::SVD);
57 double v0DaughterTrackNPXDHits(
const Particle* part,
const std::vector<double>& daughterID)
59 return getV0DaughterTrackDetNHits(part, daughterID[0], Const::EDetector::PXD);
62 double v0DaughterTrackNVXDHits(
const Particle* part,
const std::vector<double>& daughterID)
64 return v0DaughterTrackNPXDHits(part, daughterID) + v0DaughterTrackNSVDHits(part, daughterID);
67 double v0DaughterTrackFirstSVDLayer(
const Particle* part,
const std::vector<double>& daughterID)
69 auto daughter = part->getDaughter(daughterID[0]);
70 return trackFirstSVDLayer(daughter);
73 double v0DaughterTrackFirstPXDLayer(
const Particle* part,
const std::vector<double>& daughterID)
75 auto daughter = part->getDaughter(daughterID[0]);
76 return trackFirstPXDLayer(daughter);
79 double v0DaughterTrackFirstCDCLayer(
const Particle* part,
const std::vector<double>& daughterID)
81 auto daughter = part->getDaughter(daughterID[0]);
82 return trackFirstCDCLayer(daughter);
85 double v0DaughterTrackLastCDCLayer(
const Particle* part,
const std::vector<double>& daughterID)
87 auto daughter = part->getDaughter(daughterID[0]);
88 return trackLastCDCLayer(daughter);
91 double v0DaughterTrackPValue(
const Particle* part,
const std::vector<double>& daughterID)
93 auto daughter = part->getDaughter(daughterID[0]);
94 return trackPValue(daughter);
97 double v0DaughterTrackD0(
const Particle* part,
const std::vector<double>& daughterID)
99 auto daughter = part->getDaughter(daughterID[0]);
100 return trackD0(daughter);
103 double v0DaughterTrackPhi0(
const Particle* part,
const std::vector<double>& daughterID)
105 auto daughter = part->getDaughter(daughterID[0]);
106 return trackPhi0(daughter);
109 double v0DaughterTrackOmega(
const Particle* part,
const std::vector<double>& daughterID)
111 auto daughter = part->getDaughter(daughterID[0]);
112 return trackOmega(daughter);
115 double v0DaughterTrackZ0(
const Particle* part,
const std::vector<double>& daughterID)
117 auto daughter = part->getDaughter(daughterID[0]);
118 return trackZ0(daughter);
121 double v0DaughterTrackTanLambda(
const Particle* part,
const std::vector<double>& daughterID)
123 auto daughter = part->getDaughter(daughterID[0]);
124 return trackTanLambda(daughter);
127 double v0DaughterTrackD0Error(
const Particle* part,
const std::vector<double>& daughterID)
129 auto daughter = part->getDaughter(daughterID[0]);
130 return trackD0Error(daughter);
133 double v0DaughterTrackPhi0Error(
const Particle* part,
const std::vector<double>& daughterID)
135 auto daughter = part->getDaughter(daughterID[0]);
136 return trackPhi0Error(daughter);
139 double v0DaughterTrackOmegaError(
const Particle* part,
const std::vector<double>& daughterID)
141 auto daughter = part->getDaughter(daughterID[0]);
142 return trackOmegaError(daughter);
145 double v0DaughterTrackZ0Error(
const Particle* part,
const std::vector<double>& daughterID)
147 auto daughter = part->getDaughter(daughterID[0]);
148 return trackZ0Error(daughter);
151 double v0DaughterTrackTanLambdaError(
const Particle* part,
const std::vector<double>& daughterID)
153 auto daughter = part->getDaughter(daughterID[0]);
154 return trackTanLambdaError(daughter);
157 double v0DaughterD0(
const Particle* particle,
const std::vector<double>& daughterID)
160 return std::numeric_limits<float>::quiet_NaN();
162 TVector3 v0Vertex = particle->getVertex();
164 const Particle* daug = particle->getDaughter(daughterID[0]);
166 const TrackFitResult* trackFit = daug->getTrackFitResult();
167 if (!trackFit)
return std::numeric_limits<float>::quiet_NaN();
169 UncertainHelix helix = trackFit->getUncertainHelix();
170 helix.passiveMoveBy(v0Vertex);
172 return helix.getD0();
175 double v0DaughterD0Diff(
const Particle* particle)
177 return v0DaughterD0(particle, {0}) - v0DaughterD0(particle, {1});
180 double v0DaughterZ0(
const Particle* particle,
const std::vector<double>& daughterID)
183 return std::numeric_limits<float>::quiet_NaN();
185 TVector3 v0Vertex = particle->getVertex();
187 const Particle* daug = particle->getDaughter(daughterID[0]);
189 const TrackFitResult* trackFit = daug->getTrackFitResult();
190 if (!trackFit)
return std::numeric_limits<float>::quiet_NaN();
192 UncertainHelix helix = trackFit->getUncertainHelix();
193 helix.passiveMoveBy(v0Vertex);
195 return helix.getZ0();
198 double v0DaughterZ0Diff(
const Particle* particle)
200 return v0DaughterZ0(particle, {0}) - v0DaughterZ0(particle, {1});
205 double getHelixParameterPullOfV0DaughterWithTrueVertexAsPivotAtIndex(
const Particle* particle,
const double daughterID,
208 if (!particle) {
return std::numeric_limits<double>::quiet_NaN(); }
210 const int dID = int(std::lround(daughterID));
211 if (not(dID == 0 || dID == 1)) {
return std::numeric_limits<double>::quiet_NaN(); }
213 const MCParticle* mcparticle_v0 = particle->getMCParticle();
214 if (!mcparticle_v0) {
return std::numeric_limits<double>::quiet_NaN(); }
216 if (!(particle->getDaughter(dID))) {
return std::numeric_limits<double>::quiet_NaN(); }
218 const MCParticle* mcparticle = particle->getDaughter(dID)->getMCParticle();
219 if (!mcparticle) {
return std::numeric_limits<double>::quiet_NaN(); }
221 const TrackFitResult* trackFit = particle->getDaughter(dID)->getTrackFitResult();
222 if (!trackFit) {
return std::numeric_limits<double>::quiet_NaN(); }
225 const TVector3 mcProdVertex = mcparticle->getVertex();
226 const TVector3 mcMomentum = mcparticle->getMomentum();
227 const double mcParticleCharge = mcparticle->getCharge();
228 const double BzAtProdVertex = BFieldManager::getFieldInTesla(mcProdVertex).Z();
229 Helix mcHelix = Helix(mcProdVertex, mcMomentum, mcParticleCharge, BzAtProdVertex);
230 mcHelix.passiveMoveBy(mcProdVertex);
231 const std::vector<double> mcHelixPars = { mcHelix.getD0(), mcHelix.getPhi0(), mcHelix.getOmega(),
232 mcHelix.getZ0(), mcHelix.getTanLambda()
236 UncertainHelix measHelix = trackFit->getUncertainHelix();
237 measHelix.passiveMoveBy(mcProdVertex);
238 const TMatrixDSym measCovariance = measHelix.getCovariance();
239 const std::vector<double> measHelixPars = {measHelix.getD0(), measHelix.getPhi0(), measHelix.getOmega(),
240 measHelix.getZ0(), measHelix.getTanLambda()
242 const std::vector<double> measErrSquare = {measCovariance[0][0], measCovariance[1][1], measCovariance[2][2],
243 measCovariance[3][3], measCovariance[4][4]
246 if (measErrSquare.at(tauIndex) > 0)
247 return (mcHelixPars.at(tauIndex) - measHelixPars.at(tauIndex)) / std::sqrt(measErrSquare.at(tauIndex));
249 return std::numeric_limits<double>::quiet_NaN();
252 double v0DaughterHelixWithTrueVertexAsPivotD0Pull(
const Particle* part,
const std::vector<double>& daughterID)
254 return getHelixParameterPullOfV0DaughterWithTrueVertexAsPivotAtIndex(part, daughterID[0], 0);
257 double v0DaughterHelixWithTrueVertexAsPivotPhi0Pull(
const Particle* part,
const std::vector<double>& daughterID)
259 return getHelixParameterPullOfV0DaughterWithTrueVertexAsPivotAtIndex(part, daughterID[0], 1);
262 double v0DaughterHelixWithTrueVertexAsPivotOmegaPull(
const Particle* part,
const std::vector<double>& daughterID)
264 return getHelixParameterPullOfV0DaughterWithTrueVertexAsPivotAtIndex(part, daughterID[0], 2);
267 double v0DaughterHelixWithTrueVertexAsPivotZ0Pull(
const Particle* part,
const std::vector<double>& daughterID)
269 return getHelixParameterPullOfV0DaughterWithTrueVertexAsPivotAtIndex(part, daughterID[0], 3);
272 double v0DaughterHelixWithTrueVertexAsPivotTanLambdaPull(
const Particle* part,
const std::vector<double>& daughterID)
274 return getHelixParameterPullOfV0DaughterWithTrueVertexAsPivotAtIndex(part, daughterID[0], 4);
277 double v0DaughterHelixWithOriginAsPivotD0Pull(
const Particle* part,
const std::vector<double>& daughterID)
279 auto daughter = part->getDaughter(daughterID[0]);
280 return getHelixD0Pull(daughter);
283 double v0DaughterHelixWithOriginAsPivotPhi0Pull(
const Particle* part,
const std::vector<double>& daughterID)
285 auto daughter = part->getDaughter(daughterID[0]);
286 return getHelixPhi0Pull(daughter);
289 double v0DaughterHelixWithOriginAsPivotOmegaPull(
const Particle* part,
const std::vector<double>& daughterID)
291 auto daughter = part->getDaughter(daughterID[0]);
292 return getHelixOmegaPull(daughter);
295 double v0DaughterHelixWithOriginAsPivotZ0Pull(
const Particle* part,
const std::vector<double>& daughterID)
297 auto daughter = part->getDaughter(daughterID[0]);
298 return getHelixZ0Pull(daughter);
301 double v0DaughterHelixWithOriginAsPivotTanLambdaPull(
const Particle* part,
const std::vector<double>& daughterID)
303 auto daughter = part->getDaughter(daughterID[0]);
304 return getHelixTanLambdaPull(daughter);
307 double v0DaughterTrackParam5AtIPPerigee(
const Particle* part,
const std::vector<double>& params)
309 auto daughter = part->getDaughter(params[0]);
311 return std::numeric_limits<double>::quiet_NaN();
313 auto trackFit = daughter->getTrackFitResult();
315 return std::numeric_limits<double>::quiet_NaN();
318 const int paramID = int(std::lround(params[1]));
319 if (not(0 <= paramID && paramID < 5))
320 return std::numeric_limits<double>::quiet_NaN();
322 std::vector<float> tau = trackFit->getTau();
326 double v0DaughterTrackParamCov5x5AtIPPerigee(
const Particle* part,
const std::vector<double>& params)
328 auto daughter = part->getDaughter(params[0]);
330 return std::numeric_limits<double>::quiet_NaN();
332 auto trackFit = daughter->getTrackFitResult();
334 return std::numeric_limits<double>::quiet_NaN();
337 const int paramID = int(std::lround(params[1]));
338 if (not(0 <= paramID && paramID < 15))
339 return std::numeric_limits<double>::quiet_NaN();
341 std::vector<float> cov = trackFit->getCov();
345 int convertedPhotonErrorChecks(
const Particle* gamma,
const std::vector<double>& daughterIndices)
348 if (daughterIndices.size() != 2) {
349 B2ERROR(
"Invalid number of daughter indices. Please specify exactly two valid daughter indices.");
354 int daughterIndex1 = int(daughterIndices[0]);
355 int daughterIndex2 = int(daughterIndices[1]);
356 if (
int(gamma->getNDaughters()) <= std::max(daughterIndex1, daughterIndex2)) {
357 B2ERROR(
"Invalid daughter indices provided. Particle does not have that many daughters.");
362 if (!gamma->getDaughter(daughterIndex1)->getTrack()) {
363 B2ERROR(
"There is no track associated with daughter index " << daughterIndex1);
366 if (!gamma->getDaughter(daughterIndex2)->getTrack()) {
367 B2ERROR(
"There is no track associated with daughter index " << daughterIndex2);
372 if (fabs(gamma->getDaughter(daughterIndex1)->getPDGCode()) != 11) {
373 B2INFO(
"The first track provided has not been reconstructed as an electron/positron. It has PDG code " << gamma->getDaughter(
374 daughterIndex1)->getPDGCode() <<
". However, this is still fully admissible.");
376 if (fabs(gamma->getDaughter(daughterIndex2)->getPDGCode()) != 11) {
377 B2INFO(
"The second track provided has not been reconstructed as an electron/positron. It has PDG code " << gamma->getDaughter(
378 daughterIndex1)->getPDGCode() <<
".However, this is still fully admissible.");
385 int convertedPhotonLoadHelixParams(
const Particle* gamma,
int daughterIndex1,
int daughterIndex2,
double& Phi01,
double& D01,
386 double& Omega1,
double& Z01,
double& TanLambda1,
double& Phi02,
double& D02,
double& Omega2,
double& Z02,
391 Helix e1Helix = gamma->getDaughter(daughterIndex1)->getTrackFitResult()->getHelix();
393 Phi01 = e1Helix.getPhi0();
394 D01 = e1Helix.getD0() ;
395 Omega1 = e1Helix.getOmega();
396 Z01 = e1Helix.getZ0();
397 TanLambda1 = e1Helix.getTanLambda();
400 Helix e2Helix = gamma->getDaughter(daughterIndex2)->getTrackFitResult()->getHelix();
402 Phi02 = e2Helix.getPhi0();
403 D02 = e2Helix.getD0() ;
404 Omega2 = e2Helix.getOmega();
405 Z02 = e2Helix.getZ0();
406 TanLambda2 = e2Helix.getTanLambda();
409 if (Omega1 == 0) {
return -1;}
410 else if (Omega2 == 0) {
return -2;}
415 double convertedPhotonInvariantMass(
const Particle* gamma,
const std::vector<double>& daughterIndices)
418 int errFlag = convertedPhotonErrorChecks(gamma, daughterIndices);
419 if (errFlag == -1) {
return std::numeric_limits<double>::quiet_NaN();}
422 double Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02, Omega2, Z02, TanLambda2;
423 int daughterIndex1 = int(daughterIndices[0]);
424 int daughterIndex2 = int(daughterIndices[1]);
425 convertedPhotonLoadHelixParams(gamma, daughterIndex1, daughterIndex2, Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02,
426 Omega2, Z02, TanLambda2);
431 double sinlam1 = TanLambda1 / sqrt(1 + (TanLambda1 * TanLambda1));
432 double coslam1 = 1 / sqrt(1 + (TanLambda1 * TanLambda1));
433 double sinlam2 = TanLambda2 / sqrt(1 + (TanLambda2 * TanLambda2));
434 double coslam2 = 1 / sqrt(1 + (TanLambda2 * TanLambda2));
438 double p1 = gamma->getDaughter(daughterIndex1)->getMomentumMagnitude();
439 double pt1 = p1 * coslam1, pz1 = p1 * sinlam1;
440 double e1 = sqrt((p1 * p1) + (Const::electronMass * Const::electronMass));
442 double p2 = gamma->getDaughter(daughterIndex2)->getMomentumMagnitude();
443 double pt2 = p2 * coslam2, pz2 = p2 * sinlam2;
444 double e2 = sqrt((p2 * p2) + (Const::electronMass * Const::electronMass));
447 double vtxMass = sqrt(pow(e1 + e2, 2.0) - pow(pt1 + pt2, 2.0) - pow(pz1 + pz2, 2.0));
451 double convertedPhotonDelTanLambda(
const Particle* gamma,
const std::vector<double>& daughterIndices)
454 int errFlag = convertedPhotonErrorChecks(gamma, daughterIndices);
455 if (errFlag == -1) {
return std::numeric_limits<double>::quiet_NaN();}
458 double Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02, Omega2, Z02, TanLambda2;
459 int daughterIndex1 = int(daughterIndices[0]);
460 int daughterIndex2 = int(daughterIndices[1]);
461 convertedPhotonLoadHelixParams(gamma, daughterIndex1, daughterIndex2, Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02,
462 Omega2, Z02, TanLambda2);
467 return (TanLambda2 - TanLambda1);
470 double convertedPhotonDelR(
const Particle* gamma,
const std::vector<double>& daughterIndices)
473 int errFlag = convertedPhotonErrorChecks(gamma, daughterIndices);
474 if (errFlag == -1) {
return std::numeric_limits<double>::quiet_NaN();}
477 double Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02, Omega2, Z02, TanLambda2;
478 int daughterIndex1 = int(daughterIndices[0]);
479 int daughterIndex2 = int(daughterIndices[1]);
480 errFlag = convertedPhotonLoadHelixParams(gamma, daughterIndex1, daughterIndex2, Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02,
481 Omega2, Z02, TanLambda2);
483 B2ERROR(
"First track provided has curvature zero. Calculation of convertedPhotonDelR failed.");
484 return std::numeric_limits<double>::quiet_NaN();
487 B2ERROR(
"Second track provided has curvature zero. Calculation of convertedPhotonDelR failed.");
488 return std::numeric_limits<double>::quiet_NaN();
492 double radius1 = 1 / Omega1;
493 double radius2 = 1 / Omega2;
495 TVector2 center1((radius1 + D01) * sin(Phi01) , -1 * (radius1 + D01) * cos(Phi01));
496 TVector2 center2((radius2 + D02) * sin(Phi02) , -1 * (radius2 + D02) * cos(Phi02));
497 TVector2 cenDiff = center1 - center2;
499 double delR = fabs(radius1) + fabs(radius2) - cenDiff.Mod();
503 std::pair<double, double> convertedPhotonZ1Z2(
const Particle* gamma,
const std::vector<double>& daughterIndices)
506 int errFlag = convertedPhotonErrorChecks(gamma, daughterIndices);
507 if (errFlag == -1) {
return std::pair<double, double>(std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN());}
510 double Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02, Omega2, Z02, TanLambda2;
511 int daughterIndex1 = int(daughterIndices[0]);
512 int daughterIndex2 = int(daughterIndices[1]);
513 errFlag = convertedPhotonLoadHelixParams(gamma, daughterIndex1, daughterIndex2, Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02,
514 Omega2, Z02, TanLambda2);
516 B2ERROR(
"First track provided has curvature zero. Calculation of convertedPhotonZ1Z2 failed.");
517 return std::pair<double, double>(std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN());
520 B2ERROR(
"Second track provided has curvature zero. Calculation of convertedPhotonZ1Z2 failed.");
521 return std::pair<double, double>(std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN());
526 double radius1 = 1 / Omega1;
527 double radius2 = 1 / Omega2;
529 TVector2 center1((radius1 + D01) * sin(Phi01) , -1 * (radius1 + D01) * cos(Phi01));
530 TVector2 center2((radius2 + D02) * sin(Phi02) , -1 * (radius2 + D02) * cos(Phi02));
532 TVector2 n1 = center1 - center2; n1 = n1.Unit();
533 TVector2 n2 = -1 * n1;
534 n1 = copysign(1.0, Omega1) * n1;
535 n2 = copysign(1.0, Omega2) * n2;
538 double phiN1 = atan2(n1.X(), -n1.Y());
539 double phiN2 = atan2(n2.X(), -n2.Y());
540 double Phi01Intersect = phiN1 - Phi01;
541 double Phi02Intersect = phiN2 - Phi02;
543 double z1 = Z01 - (radius1 * TanLambda1 * Phi01Intersect);
544 double z2 = Z02 - (radius2 * TanLambda2 * Phi02Intersect);
545 std::pair<double, double> z1z2(z1, z2);
549 double convertedPhotonDelZ(
const Particle* gamma,
const std::vector<double>& daughterIndices)
551 std::pair<double, double> z1z2 = convertedPhotonZ1Z2(gamma, daughterIndices);
552 double z1 = z1z2.first;
double z2 = z1z2.second;
556 double convertedPhotonZ(
const Particle* gamma,
const std::vector<double>& daughterIndices)
558 std::pair<double, double> z1z2 = convertedPhotonZ1Z2(gamma, daughterIndices);
559 double z1 = z1z2.first;
double z2 = z1z2.second;
560 return (z1 + z2) * 0.5;
563 TVector2 convertedPhotonXY(
const Particle* gamma,
const std::vector<double>& daughterIndices)
566 int errFlag = convertedPhotonErrorChecks(gamma, daughterIndices);
567 if (errFlag == -1) {
return TVector2(std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN());}
570 double Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02, Omega2, Z02, TanLambda2;
571 int daughterIndex1 = int(daughterIndices[0]);
572 int daughterIndex2 = int(daughterIndices[1]);
573 errFlag = convertedPhotonLoadHelixParams(gamma, daughterIndex1, daughterIndex2, Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02,
574 Omega2, Z02, TanLambda2);
576 B2ERROR(
"First track provided has curvature zero. Calculation of convertedPhotonXY failed.");
577 return TVector2(std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN());
580 B2ERROR(
"Second track provided has curvature zero. Calculation of convertedPhotonXY failed.");
581 return TVector2(std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN());
585 double radius1 = 1 / Omega1;
586 double radius2 = 1 / Omega2;
588 TVector2 center1((radius1 + D01) * sin(Phi01) , -1 * (radius1 + D01) * cos(Phi01));
589 TVector2 center2((radius2 + D02) * sin(Phi02) , -1 * (radius2 + D02) * cos(Phi02));
590 TVector2 cenDiff = center2 - center1;
591 double delR = fabs(radius1) + fabs(radius2) - cenDiff.Mod();
594 TVector2 n1 = cenDiff.Unit();
595 TVector2 vtxXY = center1 + ((fabs(radius1) - (delR / 2)) * n1);
599 double convertedPhotonX(
const Particle* gamma,
const std::vector<double>& daughterIndices)
601 auto vtxXY = convertedPhotonXY(gamma, daughterIndices);
605 double convertedPhotonY(
const Particle* gamma,
const std::vector<double>& daughterIndices)
607 auto vtxXY = convertedPhotonXY(gamma, daughterIndices);
611 double convertedPhotonRho(
const Particle* gamma,
const std::vector<double>& daughterIndices)
613 auto vtxXY = convertedPhotonXY(gamma, daughterIndices);
617 TVector3 convertedPhoton3Momentum(
const Particle* gamma,
const std::vector<double>& daughterIndices)
620 int errFlag = convertedPhotonErrorChecks(gamma, daughterIndices);
621 if (errFlag == -1) {
return TVector3(std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN());}
624 double Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02, Omega2, Z02, TanLambda2;
625 int daughterIndex1 = int(daughterIndices[0]);
626 int daughterIndex2 = int(daughterIndices[1]);
627 errFlag = convertedPhotonLoadHelixParams(gamma, daughterIndex1, daughterIndex2, Phi01, D01, Omega1, Z01, TanLambda1, Phi02, D02,
631 B2ERROR(
"First track provided has curvature zero. Calculation of convertedPhoton3Momentum failed.");
632 return TVector3(std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(),
633 std::numeric_limits<double>::quiet_NaN());
636 B2ERROR(
"Second track provided has curvature zero. Calculation of convertedPhoton3Momentum failed.");
637 return TVector3(std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(),
638 std::numeric_limits<double>::quiet_NaN());
643 double radius1 = 1 / Omega1;
644 double radius2 = 1 / Omega2;
646 TVector2 center1((radius1 + D01) * sin(Phi01) , -1 * (radius1 + D01) * cos(Phi01));
647 TVector2 center2((radius2 + D02) * sin(Phi02) , -1 * (radius2 + D02) * cos(Phi02));
648 TVector2 n1 = center1 - center2; n1 = n1.Unit();
649 TVector2 n2 = -1 * n1;
650 n1 = copysign(1.0, Omega1) * n1;
651 n2 = copysign(1.0, Omega2) * n2;
654 double phiN1 = atan2(n1.X(), -n1.Y());
655 double phiN2 = atan2(n2.X(), -n2.Y());
658 double sinlam1 = TanLambda1 / sqrt(1 + (TanLambda1 * TanLambda1));
659 double coslam1 = 1 / sqrt(1 + (TanLambda1 * TanLambda1));
660 double sinlam2 = TanLambda2 / sqrt(1 + (TanLambda2 * TanLambda2));
661 double coslam2 = 1 / sqrt(1 + (TanLambda2 * TanLambda2));
664 double p1 = gamma->getDaughter(daughterIndex1)->getMomentumMagnitude();
665 TVector3 e1Momentum(coslam1 * cos(phiN1), coslam1 * sin(phiN1), sinlam1);
666 double p2 = gamma->getDaughter(daughterIndex2)->getMomentumMagnitude();
667 TVector3 e2Momentum(coslam2 * cos(phiN2), coslam2 * sin(phiN2), sinlam2);
668 TVector3 gammaMomentum = (e1Momentum * p1) + (e2Momentum * p2);
670 return gammaMomentum;
673 double convertedPhotonPx(
const Particle* gamma,
const std::vector<double>& daughterIndices)
675 auto gammaMomentum = convertedPhoton3Momentum(gamma, daughterIndices);
676 return gammaMomentum.Px();
679 double convertedPhotonPy(
const Particle* gamma,
const std::vector<double>& daughterIndices)
681 auto gammaMomentum = convertedPhoton3Momentum(gamma, daughterIndices);
682 return gammaMomentum.Py();
685 double convertedPhotonPz(
const Particle* gamma,
const std::vector<double>& daughterIndices)
687 auto gammaMomentum = convertedPhoton3Momentum(gamma, daughterIndices);
688 return gammaMomentum.Pz();
691 int v0DaughtersShareInnermostHit(
const Particle* part)
694 return std::numeric_limits<int>::quiet_NaN();
695 auto daughterPlus = part->getDaughter(0);
696 auto daughterMinus = part->getDaughter(1);
697 if (!daughterPlus || !daughterMinus)
698 return std::numeric_limits<int>::quiet_NaN();
699 auto trackFitPlus = daughterPlus->getTrackFitResult();
700 auto trackFitMinus = daughterMinus->getTrackFitResult();
701 if (!trackFitPlus || !trackFitMinus)
702 return std::numeric_limits<int>::quiet_NaN();
703 int flagPlus = trackFitPlus->getHitPatternVXD().getInnermostHitShareStatus();
704 int flagMinus = trackFitMinus->getHitPatternVXD().getInnermostHitShareStatus();
705 if (flagPlus != flagMinus)
706 return std::numeric_limits<int>::quiet_NaN();
710 bool v0DaughtersShareInnermostUHit(
const Particle* part)
712 return ((v0DaughtersShareInnermostHit(part) / 2) == 1);
715 bool v0DaughtersShareInnermostVHit(
const Particle* part)
717 return ((v0DaughtersShareInnermostHit(part) % 2) == 1);
720 VARIABLE_GROUP(
"V0Daughter");
722 REGISTER_VARIABLE(
"v0DaughterNCDCHits(i)", v0DaughterTrackNCDCHits,
"Number of CDC hits associated to the i-th daughter track");
723 MAKE_DEPRECATED(
"v0DaughterNCDCHits(i)",
false,
"light-2104-poseidon", R
"DOC(
724 The same value can be calculated with the more generic variable `nCDCHits`,
725 so replace the current call with ``daughter(i, nCDCHits)``.)DOC");
726 REGISTER_VARIABLE("v0DaughterNSVDHits(i)", v0DaughterTrackNSVDHits,
"Number of SVD hits associated to the i-th daughter track");
727 MAKE_DEPRECATED(
"v0DaughterNSVDHits(i)",
false,
"light-2104-poseidon", R
"DOC(
728 The same value can be calculated with the more generic variable `nSVDHits`,
729 so replace the current call with ``daughter(i, nSVDHits)``.)DOC");
730 REGISTER_VARIABLE("v0DaughterNPXDHits(i)", v0DaughterTrackNPXDHits,
"Number of PXD hits associated to the i-th daughter track");
731 MAKE_DEPRECATED(
"v0DaughterNPXDHits(i)",
false,
"light-2104-poseidon", R
"DOC(
732 The same value can be calculated with the more generic variable `nPXDHits`,
733 so replace the current call with ``daughter(i, nPXDHits)``.)DOC");
734 REGISTER_VARIABLE("v0DaughterNVXDHits(i)", v0DaughterTrackNVXDHits,
"Number of PXD+SVD hits associated to the i-th daughter track");
735 MAKE_DEPRECATED(
"v0DaughterNVXDHits(i)",
false,
"light-2104-poseidon", R
"DOC(
736 The same value can be calculated with the more generic variable `nVXDHits`,
737 so replace the current call with ``daughter(i, nVXDHits)``.)DOC");
738 REGISTER_VARIABLE("v0DaughterFirstSVDLayer(i)", v0DaughterTrackFirstSVDLayer,
739 "First activated SVD layer associated to the i-th daughter track");
740 MAKE_DEPRECATED(
"v0DaughterFirstSVDLayer(i)",
false,
"light-2104-poseidon", R
"DOC(
741 The same value can be calculated with the more generic variable `firstSVDLayer`,
742 so replace the current call with ``daughter(i, firstSVDLayer)``.)DOC");
743 REGISTER_VARIABLE("v0DaughterFirstPXDLayer(i)", v0DaughterTrackFirstPXDLayer,
744 "First activated PXD layer associated to the i-th daughter track");
745 MAKE_DEPRECATED(
"v0DaughterFirstPXDLayer(i)",
false,
"light-2104-poseidon", R
"DOC(
746 The same value can be calculated with the more generic variable `firstPXDLayer`,
747 so replace the current call with ``daughter(i, firstPXDLayer)``.)DOC");
748 REGISTER_VARIABLE("v0DaughterFirstCDCLayer(i)", v0DaughterTrackFirstCDCLayer,
749 "First activated CDC layer associated to the i-th daughter track");
750 MAKE_DEPRECATED(
"v0DaughterFirstCDCLayer(i)",
false,
"light-2104-poseidon", R
"DOC(
751 The same value can be calculated with the more generic variable `firstCDCLayer`,
752 so replace the current call with ``daughter(i, firstCDCLayer)``.)DOC");
753 REGISTER_VARIABLE("v0DaughterLastCDCLayer(i)", v0DaughterTrackLastCDCLayer,
754 "Last CDC layer associated to the i-th daughter track");
755 MAKE_DEPRECATED(
"v0DaughterLastCDCLayer(i)",
false,
"light-2104-poseidon", R
"DOC(
756 The same value can be calculated with the more generic variable `lastCDCLayer`,
757 so replace the current call with ``daughter(i, lastCDCLayer)``.)DOC");
758 REGISTER_VARIABLE("v0DaughterPValue(i)", v0DaughterTrackPValue,
759 "chi2 probalility of the i-th daughter track fit");
760 MAKE_DEPRECATED(
"v0DaughterPValue(i)",
false,
"light-2104-poseidon", R
"DOC(
761 The same value can be calculated with the more generic variable `pValue`,
762 so replace the current call with ``daughter(i, pValue)``.)DOC");
764 REGISTER_VARIABLE("v0DaughterD0(i)", v0DaughterTrackD0,
"d0 of the i-th daughter track fit");
765 MAKE_DEPRECATED(
"v0DaughterD0(i)",
false,
"light-2104-poseidon", R
"DOC(
766 The same value can be calculated with the more generic variable `d0`,
767 so replace the current call with ``daughter(i, d0)``.)DOC");
768 REGISTER_VARIABLE("v0DaughterPhi0(i)", v0DaughterTrackPhi0,
"phi0 of the i-th daughter track fit");
769 MAKE_DEPRECATED(
"v0DaughterPhi0(i)",
false,
"light-2104-poseidon", R
"DOC(
770 The same value can be calculated with the more generic variable `phi0`,
771 so replace the current call with ``daughter(i, phi0)``.)DOC");
772 REGISTER_VARIABLE("v0DaughterOmega(i)", v0DaughterTrackOmega,
"omega of the i-th daughter track fit");
773 MAKE_DEPRECATED(
"v0DaughterOmega(i)",
false,
"light-2104-poseidon", R
"DOC(
774 The same value can be calculated with the more generic variable `omega`,
775 so replace the current call with ``daughter(i, omega)``.)DOC");
776 REGISTER_VARIABLE("v0DaughterZ0(i)", v0DaughterTrackZ0,
"z0 of the i-th daughter track fit");
777 MAKE_DEPRECATED(
"v0DaughterZ0(i)",
false,
"light-2104-poseidon", R
"DOC(
778 The same value can be calculated with the more generic variable `z0`,
779 so replace the current call with ``daughter(i, z0)``.)DOC");
780 REGISTER_VARIABLE("v0DaughterTanLambda(i)", v0DaughterTrackTanLambda,
"tan(lambda) of the i-th daughter track fit");
781 MAKE_DEPRECATED(
"v0DaughterTanLambda(i)",
false,
"light-2104-poseidon", R
"DOC(
782 The same value can be calculated with the more generic variable `tanLambda`,
783 so replace the current call with ``daughter(i, tanLambda)``.)DOC");
785 REGISTER_VARIABLE("v0DaughterD0Error(i)", v0DaughterTrackD0Error,
"d0 error of the i-th daughter track fit");
786 MAKE_DEPRECATED(
"v0DaughterD0Error(i)",
false,
"light-2104-poseidon", R
"DOC(
787 The same value can be calculated with the more generic variable `d0Err`,
788 so replace the current call with ``daughter(i, d0Err)``.)DOC");
789 REGISTER_VARIABLE("v0DaughterPhi0Error(i)", v0DaughterTrackPhi0Error,
"phi0 error of the i-th daughter track fit");
790 MAKE_DEPRECATED(
"v0DaughterPhi0Error(i)",
false,
"light-2104-poseidon", R
"DOC(
791 The same value can be calculated with the more generic variable `phi0Err`,
792 so replace the current call with ``daughter(i, phi0Err)``.)DOC");
793 REGISTER_VARIABLE("v0DaughterOmegaError(i)", v0DaughterTrackOmegaError,
"omega error of the i-th daughter track fit");
794 MAKE_DEPRECATED(
"v0DaughterOmegaError(i)",
false,
"light-2104-poseidon", R
"DOC(
795 The same value can be calculated with the more generic variable `omegaErr`,
796 so replace the current call with ``daughter(i, omegaErr)``.)DOC");
797 REGISTER_VARIABLE("v0DaughterZ0Error(i)", v0DaughterTrackZ0Error,
"z0 error of the i-th daughter track fit");
798 MAKE_DEPRECATED(
"v0DaughterZ0Error(i)",
false,
"light-2104-poseidon", R
"DOC(
799 The same value can be calculated with the more generic variable `z0Err`,
800 so replace the current call with ``daughter(i, z0Err)``.)DOC");
801 REGISTER_VARIABLE("v0DaughterTanLambdaError(i)", v0DaughterTrackTanLambdaError,
"tan(lambda) error of the i-th daughter track fit");
802 MAKE_DEPRECATED(
"v0DaughterTanLambdaError(i)",
false,
"light-2104-poseidon", R
"DOC(
803 The same value can be calculated with the more generic variable `tanLambdaErr`,
804 so replace the current call with ``daughter(i, tanLambdaErr)``.)DOC");
807 REGISTER_VARIABLE("V0d0(id)", v0DaughterD0,
808 "Return the d0 impact parameter of a V0's daughter with daughterID index with the V0 vertex point as a pivot for the track.");
809 REGISTER_VARIABLE(
"V0Deltad0", v0DaughterD0Diff,
810 "Return the difference between d0 impact parameters of V0's daughters with the V0 vertex point as a pivot for the track.");
811 REGISTER_VARIABLE(
"V0z0(id)", v0DaughterZ0,
812 "Return the z0 impact parameter of a V0's daughter with daughterID index with the V0 vertex point as a pivot for the track.");
813 REGISTER_VARIABLE(
"V0Deltaz0", v0DaughterZ0Diff,
814 "Return the difference between z0 impact parameters of V0's daughters with the V0 vertex point as a pivot for the track.");
817 REGISTER_VARIABLE(
"v0DaughterD0PullWithTrueVertexAsPivot(i)", v0DaughterHelixWithTrueVertexAsPivotD0Pull,
818 "d0 pull of the i-th daughter track with the true V0 vertex as the track pivot");
819 REGISTER_VARIABLE(
"v0DaughterPhi0PullWithTrueVertexAsPivot(i)", v0DaughterHelixWithTrueVertexAsPivotPhi0Pull,
820 "phi0 pull of the i-th daughter track with the true V0 vertex as the track pivot");
821 REGISTER_VARIABLE(
"v0DaughterOmegaPullWithTrueVertexAsPivot(i)", v0DaughterHelixWithTrueVertexAsPivotOmegaPull,
822 "omega pull of the i-th daughter track with the true V0 vertex as the track pivot");
823 REGISTER_VARIABLE(
"v0DaughterZ0PullWithTrueVertexAsPivot(i)", v0DaughterHelixWithTrueVertexAsPivotZ0Pull,
824 "z0 pull of the i-th daughter track with the true V0 vertex as the track pivot");
825 REGISTER_VARIABLE(
"v0DaughterTanLambdaPullWithTrueVertexAsPivot(i)", v0DaughterHelixWithTrueVertexAsPivotTanLambdaPull,
826 "tan(lambda) pull of the i-th daughter track with the true V0 vertex as the track pivot");
828 REGISTER_VARIABLE(
"v0DaughterD0PullWithOriginAsPivot(i)", v0DaughterHelixWithOriginAsPivotD0Pull,
829 "d0 pull of the i-th daughter track with the origin as the track pivot");
830 MAKE_DEPRECATED(
"v0DaughterD0PullWithOriginAsPivot(i)",
false,
"light-2104-poseidon", R
"DOC(
831 The same value can be calculated with the more generic variable `d0Pull`,
832 so replace the current call with ``daughter(i, d0Pull)``.)DOC");
833 REGISTER_VARIABLE("v0DaughterPhi0PullWithOriginAsPivot(i)", v0DaughterHelixWithOriginAsPivotPhi0Pull,
834 "phi0 pull of the i-th daughter track with the origin as the track pivot");
835 MAKE_DEPRECATED(
"v0DaughterPhi0PullWithOriginAsPivot(i)",
false,
"light-2104-poseidon", R
"DOC(
836 The same value can be calculated with the more generic variable `phi0Pull`,
837 so replace the current call with ``daughter(i, phi0Pull)``.)DOC");
838 REGISTER_VARIABLE("v0DaughterOmegaPullWithOriginAsPivot(i)", v0DaughterHelixWithOriginAsPivotOmegaPull,
839 "omega pull of the i-th daughter track with the origin as the track pivot");
840 MAKE_DEPRECATED(
"v0DaughterOmegaPullWithOriginAsPivot(i)",
false,
"light-2104-poseidon", R
"DOC(
841 The same value can be calculated with the more generic variable `omegaPull`,
842 so replace the current call with ``daughter(i, omegaPull)``.)DOC");
843 REGISTER_VARIABLE("v0DaughterZ0PullWithOriginAsPivot(i)", v0DaughterHelixWithOriginAsPivotZ0Pull,
844 "z0 pull of the i-th daughter track with the origin as the track pivot");
845 MAKE_DEPRECATED(
"v0DaughterZ0PullWithOriginAsPivot(i)",
false,
"light-2104-poseidon", R
"DOC(
846 The same value can be calculated with the more generic variable `z0Pull`,
847 so replace the current call with ``daughter(i, z0Pull)``.)DOC");
848 REGISTER_VARIABLE("v0DaughterTanLambdaPullWithOriginAsPivot(i)", v0DaughterHelixWithOriginAsPivotTanLambdaPull,
849 "tan(lambda) pull of the i-th daughter track with the origin as the track pivot");
850 MAKE_DEPRECATED(
"v0DaughterTanLambdaPullWithOriginAsPivot(i)",
false,
"light-2104-poseidon", R
"DOC(
851 The same value can be calculated with the more generic variable `tanLambdaPull`,
852 so replace the current call with ``daughter(i, tanLambdaPull)``.)DOC");
854 REGISTER_VARIABLE("v0DaughterTau(i,j)", v0DaughterTrackParam5AtIPPerigee,
855 "j-th track parameter (at IP perigee) of the i-th daughter track. "
856 "j: 0:d0, 1:phi0, 2:omega, 3:z0, 4:tanLambda");
857 REGISTER_VARIABLE(
"v0DaughterCov(i,j)", v0DaughterTrackParamCov5x5AtIPPerigee,
858 "j-th element of the 15 covariance matrix elements (at IP perigee) of the i-th daughter track. "
859 "(0,0), (0,1) ... (1,1), (1,2) ... (2,2) ...");
861 REGISTER_VARIABLE(
"convertedPhotonInvariantMass(i,j)", convertedPhotonInvariantMass,
862 "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");
863 REGISTER_VARIABLE(
"convertedPhotonDelTanLambda(i,j)", convertedPhotonDelTanLambda,
864 "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");
865 REGISTER_VARIABLE(
"convertedPhotonDelR(i,j)", convertedPhotonDelR,
866 "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");
867 REGISTER_VARIABLE(
"convertedPhotonDelZ(i,j)", convertedPhotonDelZ,
868 "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");
869 REGISTER_VARIABLE(
"convertedPhotonX(i,j)", convertedPhotonX,
870 "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");
871 REGISTER_VARIABLE(
"convertedPhotonY(i,j)", convertedPhotonY,
872 "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");
873 REGISTER_VARIABLE(
"convertedPhotonZ(i,j)", convertedPhotonZ,
874 "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");
875 REGISTER_VARIABLE(
"convertedPhotonRho(i,j)", convertedPhotonRho,
876 "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");
877 REGISTER_VARIABLE(
"convertedPhotonPx(i,j)", convertedPhotonPx,
878 "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");
879 REGISTER_VARIABLE(
"convertedPhotonPy(i,j)", convertedPhotonPy,
880 "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");
881 REGISTER_VARIABLE(
"convertedPhotonPz(i,j)", convertedPhotonPz,
882 "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");
884 REGISTER_VARIABLE(
"v0DaughtersShare1stHit", v0DaughtersShareInnermostHit,
885 "flag for V0 daughters sharing the first(innermost) VXD hit. 0x1(0x2) bit represents V/z(U/r-phi)-hit share.");
886 REGISTER_VARIABLE(
"v0DaughtersShare1stUHit", v0DaughtersShareInnermostHit,
887 "flag for V0 daughters sharing the first(innermost) VXD U-side hit.");
888 REGISTER_VARIABLE(
"v0DaughtersShare1stVHit", v0DaughtersShareInnermostHit,
889 "flag for V0 daughters sharing the first(innermost) VXD V-side hit.");
#define MAKE_DEPRECATED(name, make_fatal, version, description)
Registers a variable as deprecated.
Abstract base class for different kinds of events.