Belle II Software development
TimeDependentVariables.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9// Own header.
10#include <analysis/variables/TimeDependentVariables.h>
11
12#include <framework/dbobjects/BeamParameters.h>
13
14// dataobjects
15#include <analysis/dataobjects/Particle.h>
16#include <analysis/dataobjects/TagVertex.h>
17
18//utilities
19#include <analysis/utility/DistanceTools.h>
20#include <analysis/utility/PCmsLabTransform.h>
21#include <analysis/utility/RotationTools.h>
22#include <analysis/utility/ReferenceFrame.h>
23
24// framework aux
25#include <framework/gearbox/Const.h>
26#include <framework/geometry/B2Vector3.h>
27#include <mdst/dataobjects/MCParticle.h>
28#include <mdst/dataobjects/TrackFitResult.h>
29
30#include <TMatrixD.h>
31#include <TVectorD.h>
32
33//#include <iostream>
34#include <cmath>
35
36using namespace std;
37
38namespace Belle2 {
43 namespace Variable {
44
45 // from RotationTools.h
46 using RotationTools::getUnitOrthogonal;
47 using RotationTools::toVec;
48
50
51 // ############################################## Time Dependent CPV Analysis Variables ###############################################
52
53 // TagV x, y, z
54 double particleTagVx(const Particle* particle)
55 {
56 auto* vert = particle->getRelatedTo<TagVertex>();
57 if (!vert) return Const::doubleNaN;
58 return vert->getTagVertex().X();
59 }
60
61 double particleTagVy(const Particle* particle)
62 {
63 auto* vert = particle->getRelatedTo<TagVertex>();
64 if (!vert) return Const::doubleNaN;
65 return vert->getTagVertex().Y();
66 }
67
68 double particleTagVz(const Particle* particle)
69 {
70 auto* vert = particle->getRelatedTo<TagVertex>();
71 if (!vert) return Const::doubleNaN;
72 return vert->getTagVertex().Z();
73 }
74
75 double particleTruthTagVx(const Particle* particle)
76 {
77 auto* vert = particle->getRelatedTo<TagVertex>();
78 if (!vert) return Const::doubleNaN;
79 return vert->getMCTagVertex().X();
80 }
81
82 double particleTruthTagVy(const Particle* particle)
83 {
84 auto* vert = particle->getRelatedTo<TagVertex>();
85 if (!vert) return Const::doubleNaN;
86 return vert->getMCTagVertex().Y();
87 }
88
89 double particleTruthTagVz(const Particle* particle)
90 {
91 auto* vert = particle->getRelatedTo<TagVertex>();
92 if (!vert) return Const::doubleNaN;
93 return vert->getMCTagVertex().Z();
94 }
95
96 double particleTagVCov(const Particle* particle, const std::vector<double>& element)
97 {
98 int elementI = int(std::lround(element[0]));
99 int elementJ = int(std::lround(element[1]));
100
101 if (elementI < 0 || elementI > 2) {
102 B2WARNING("Index is out of boundaries [0 - 2]:" << LogVar("i", elementI));
103 return Const::doubleNaN;
104 }
105 if (elementJ < 0 || elementJ > 2) {
106 B2WARNING("Index is out of boundaries [0 - 2]:" << LogVar("j", elementJ));
107 return Const::doubleNaN;
108 }
109
110 auto* vert = particle->getRelatedTo<TagVertex>();
111 if (!vert) return Const::doubleNaN;
112 TMatrixDSym TagVErr = vert->getTagVertexErrMatrix();
113 return TagVErr(elementI, elementJ);
114 }
115
116 double particleTagVxErr(const Particle* particle)
117 {
118 auto* vert = particle->getRelatedTo<TagVertex>();
119 if (!vert) return Const::doubleNaN;
120 TMatrixDSym TagVErr = vert->getTagVertexErrMatrix();
121 return sqrt(TagVErr(0, 0));
122 }
123
124 double particleTagVyErr(const Particle* particle)
125 {
126 auto* vert = particle->getRelatedTo<TagVertex>();
127 if (!vert) return Const::doubleNaN;
128 TMatrixDSym TagVErr = vert->getTagVertexErrMatrix();
129 return sqrt(TagVErr(1, 1));
130 }
131
132 double particleTagVzErr(const Particle* particle)
133 {
134 auto* vert = particle->getRelatedTo<TagVertex>();
135 if (!vert) return Const::doubleNaN;
136 TMatrixDSym TagVErr = vert->getTagVertexErrMatrix();
137 return sqrt(TagVErr(2, 2));
138 }
139
140 double particleTagVpVal(const Particle* particle)
141 {
142 auto* vert = particle->getRelatedTo<TagVertex>();
143 if (!vert) return Const::doubleNaN;
144 return vert->getTagVertexPval();
145 }
146
147 double particleTagVNTracks(const Particle* particle)
148 {
149 auto* vert = particle->getRelatedTo<TagVertex>();
150 if (!vert) return Const::doubleNaN;
151 return vert->getNTracks();
152 }
153
154 double particleTagVNFitTracks(const Particle* particle)
155 {
156 auto* vert = particle->getRelatedTo<TagVertex>();
157 if (!vert) return Const::doubleNaN;
158 return vert->getNFitTracks();
159 }
160
161 double particleTagVType(const Particle* particle)
162 {
163 auto* vert = particle->getRelatedTo<TagVertex>();
164 if (!vert) return Const::doubleNaN;
165 return vert->getFitType();
166 }
167
168 double particleTagVNDF(const Particle* particle)
169 {
170 auto* vert = particle->getRelatedTo<TagVertex>();
171 if (!vert) return Const::doubleNaN;
172 return vert->getTagVNDF();
173 }
174
175 double particleTagVChi2(const Particle* particle)
176 {
177 auto* vert = particle->getRelatedTo<TagVertex>();
178 if (!vert) return Const::doubleNaN;
179 return vert->getTagVChi2();
180 }
181
182 double particleTagVChi2IP(const Particle* particle)
183 {
184 auto* vert = particle->getRelatedTo<TagVertex>();
185 if (!vert) return Const::doubleNaN;
186 return vert->getTagVChi2IP();
187 }
188
189 // Delta t and related
190
191 double particleDeltaT(const Particle* particle)
192 {
193 auto* vert = particle->getRelatedTo<TagVertex>();
194 if (!vert) return Const::doubleNaN;
195 return vert->getDeltaT();
196 }
197
198 double particleDeltaTErr(const Particle* particle)
199 {
200 auto* vert = particle->getRelatedTo<TagVertex>();
201 if (!vert) return Const::doubleNaN;
202 return vert->getDeltaTErr();
203 }
204
205 double particleDeltaTRes(const Particle* particle)
206 {
207 return particleDeltaT(particle) - particleMCDeltaT(particle);
208 }
209
210 double particleDeltaTBelle(const Particle* particle)
211 {
212 double beta = PCmsLabTransform().getBoostVector().Mag();
213 double bg = beta / sqrt(1 - beta * beta);
214 double c = Const::speedOfLight / 1000.; // cm ps-1
215 return particleDeltaZ(particle) / bg / c;
216 }
217
218 double particleMCDeltaTau(const Particle* particle)
219 {
220 auto* vert = particle->getRelatedTo<TagVertex>();
221 if (!vert) return Const::doubleNaN;
222 return vert->getMCDeltaTau();
223 }
224
225 double particleMCDeltaT(const Particle* particle)
226 {
227 auto* vert = particle->getRelatedTo<TagVertex>();
228 if (!vert) return Const::doubleNaN;
229 return vert->getMCDeltaT();
230 }
231
232 double particleMCDeltaBoost(const Particle* particle)
233 {
234 auto* vert = particle->getRelatedTo<TagVertex>();
235 if (!vert) return Const::doubleNaN;
236
237 double beta = PCmsLabTransform().getBoostVector().Mag();
238 double bg = beta / sqrt(1 - beta * beta);
239 double c = Const::speedOfLight / 1000.; // cm ps-1
240 return vert->getMCDeltaT() * bg * c;
241 }
242
243 double particleDeltaZ(const Particle* particle)
244 {
245 auto* vert = particle->getRelatedTo<TagVertex>();
246 if (!vert) return Const::doubleNaN;
247 return particle->getZ() - vert->getTagVertex().Z();
248 }
249
250 double particleDeltaZErr(const Particle* particle)
251 {
252 auto* vert = particle->getRelatedTo<TagVertex>();
253 if (!vert) return Const::doubleNaN;
254
255 double zVariance = particle->getVertexErrorMatrix()(2, 2);
256 double TagVZVariance = vert->getTagVertexErrMatrix()(2, 2);
257 double result = sqrt(zVariance + TagVZVariance);
258 if (!std::isfinite(result)) return Const::doubleNaN;
259
260 return result;
261 }
262
263 double particleDeltaB(const Particle* particle)
264 {
265 auto* vert = particle->getRelatedTo<TagVertex>();
266 if (!vert) return Const::doubleNaN;
267
268 double beta = PCmsLabTransform().getBoostVector().Mag();
269 double bg = beta / sqrt(1 - beta * beta);
270 double c = Const::speedOfLight / 1000.; // cm ps-1
271 return vert->getDeltaT() * bg * c;
272 }
273
274 double particleDeltaBErr(const Particle* particle)
275 {
276 auto* vert = particle->getRelatedTo<TagVertex>();
277 if (!vert) return Const::doubleNaN;
278
279 double beta = PCmsLabTransform().getBoostVector().Mag();
280 double bg = beta / sqrt(1 - beta * beta);
281 double c = Const::speedOfLight / 1000.; // cm ps-1
282 return vert->getDeltaTErr() * bg * c;
283 }
284
285 // Vertex boost direction
286
287 double vertexBoostDirection(const Particle* part)
288 {
289 B2Vector3D boostDir = PCmsLabTransform().getBoostVector().Unit();
290 B2Vector3F pos = part->getVertex();
291 return pos.Dot(boostDir);
292 }
293
294 double vertexOrthogonalBoostDirection(const Particle* part)
295 {
296 B2Vector3D boost = PCmsLabTransform().getBoostVector();
297 B2Vector3D orthBoostDir = getUnitOrthogonal(boost);
298
299 B2Vector3F pos = part->getVertex();
300 return pos.Dot(orthBoostDir);
301 }
302
303 double vertexTruthBoostDirection(const Particle* part)
304 {
305 static DBObjPtr<BeamParameters> beamParamsDB;
306 B2Vector3D boostDir = -(beamParamsDB->getHER() + beamParamsDB->getLER()).BoostToCM().Unit();
307
308 const MCParticle* mcPart = part->getMCParticle();
309 if (!mcPart) return Const::doubleNaN;
310 B2Vector3D pos = mcPart->getDecayVertex();
311 return pos.Dot(boostDir);
312 }
313
314 double vertexTruthOrthogonalBoostDirection(const Particle* part)
315 {
316 static DBObjPtr<BeamParameters> beamParamsDB;
317 B2Vector3D boost = -(beamParamsDB->getHER() + beamParamsDB->getLER()).BoostToCM();
318 B2Vector3D orthBoostDir = getUnitOrthogonal(boost);
319
320 const MCParticle* mcPart = part->getMCParticle();
321 if (!mcPart) return Const::doubleNaN;
322 B2Vector3D pos = mcPart->getDecayVertex();
323 return pos.Dot(orthBoostDir);
324 }
325
326 double vertexErrBoostDirection(const Particle* part)
327 {
328 TVectorD bDir = toVec(PCmsLabTransform().getBoostVector().Unit());
329 // sqrt(bDir^T * Mat * bDir)
330 return sqrt(part->getVertexErrorMatrix().Similarity(bDir));
331 }
332
333 double vertexErrOrthBoostDirection(const Particle* part)
334 {
335 TVectorD oDir = toVec(getUnitOrthogonal(PCmsLabTransform().getBoostVector()));
336 // sqrt(oDir^T * Mat * oDir)
337 return sqrt(part->getVertexErrorMatrix().Similarity(oDir));
338 }
339
340 // TagV boost direction
341
342 double tagVBoostDirection(const Particle* part)
343 {
344 auto* vert = part->getRelatedTo<TagVertex>();
345 if (!vert) return Const::doubleNaN;
346 return vert->getTagVl();
347 }
348
349 double tagVOrthogonalBoostDirection(const Particle* part)
350 {
351 auto* vert = part->getRelatedTo<TagVertex>();
352 if (!vert) return Const::doubleNaN;
353 return vert->getTagVol();
354 }
355
356 double tagVTruthBoostDirection(const Particle* part)
357 {
358 auto* vert = part->getRelatedTo<TagVertex>();
359 if (!vert) return Const::doubleNaN;
360 return vert->getTruthTagVl();
361 }
362
363 double tagVTruthOrthogonalBoostDirection(const Particle* part)
364 {
365 auto* vert = part->getRelatedTo<TagVertex>();
366 if (!vert) return Const::doubleNaN;
367 return vert->getTruthTagVol();
368 }
369
370 double tagVErrBoostDirection(const Particle* part)
371 {
372 auto* vert = part->getRelatedTo<TagVertex>();
373 if (!vert) return Const::doubleNaN;
374 return vert->getTagVlErr();
375 }
376
377 double tagVErrOrthogonalBoostDirection(const Particle* part)
378 {
379 auto* vert = part->getRelatedTo<TagVertex>();
380 if (!vert) return Const::doubleNaN;
381 return vert->getTagVolErr();
382 }
383
384 // cosTheta boost direction
385
386 double particleCosThetaBoostDirection(const Particle* part)
387 {
388 const auto& frame = ReferenceFrame::GetCurrent();
389 B2Vector3D boost = PCmsLabTransform().getBoostVector();
390 ROOT::Math::PxPyPzEVector pxpypze = frame.getMomentum(part);
391 B2Vector3D momentum(pxpypze.Px(), pxpypze.Py(), pxpypze.Pz());
392 return cos(momentum.Angle(boost));
393 }
394
395 double particleInternalTagVMCFlavor(const Particle* part)
396 {
397 auto* vert = part->getRelatedTo<TagVertex>();
398 if (!vert) return Const::doubleNaN;
399 return vert->getMCTagBFlavor();
400 }
401
402 double tagTrackMomentum(const Particle* part, const std::vector<double>& trackIndex)
403 {
404 auto* vert = part->getRelatedTo<TagVertex>();
405 if (!vert) return Const::doubleNaN;
406
407 if (trackIndex.size() != 1) return Const::doubleNaN;
408 unsigned trackIndexInt = trackIndex.at(0);
409
410 return vert->getVtxFitTrackP(trackIndexInt).R();
411 }
412
413 double tagTrackMomentumX(const Particle* part, const std::vector<double>& trackIndex)
414 {
415 auto* vert = part->getRelatedTo<TagVertex>();
416 if (!vert) return Const::doubleNaN;
417
418 if (trackIndex.size() != 1) return Const::doubleNaN;
419 unsigned trackIndexInt = trackIndex.at(0);
420
421 return vert->getVtxFitTrackP(trackIndexInt).X();
422 }
423
424 double tagTrackMomentumY(const Particle* part, const std::vector<double>& trackIndex)
425 {
426 auto* vert = part->getRelatedTo<TagVertex>();
427 if (!vert) return Const::doubleNaN;
428
429 if (trackIndex.size() != 1) return Const::doubleNaN;
430 unsigned trackIndexInt = trackIndex.at(0);
431
432 return vert->getVtxFitTrackP(trackIndexInt).Y();
433 }
434
435 double tagTrackMomentumZ(const Particle* part, const std::vector<double>& trackIndex)
436 {
437 auto* vert = part->getRelatedTo<TagVertex>();
438 if (!vert) return Const::doubleNaN;
439
440 if (trackIndex.size() != 1) return Const::doubleNaN;
441 unsigned trackIndexInt = trackIndex.at(0);
442
443 return vert->getVtxFitTrackP(trackIndexInt).Z();
444 }
445
446 double tagTrackZ0(const Particle* part, const std::vector<double>& trackIndex)
447 {
448 auto* vert = part->getRelatedTo<TagVertex>();
449 if (!vert) return Const::doubleNaN;
450
451 if (trackIndex.size() != 1) return Const::doubleNaN;
452 unsigned trackIndexInt = trackIndex.at(0);
453
454 return vert->getVtxFitTrackZ0(trackIndexInt);
455 }
456
457 double tagTrackD0(const Particle* part, const std::vector<double>& trackIndex)
458 {
459 auto* vert = part->getRelatedTo<TagVertex>();
460 if (!vert) return Const::doubleNaN;
461
462 if (trackIndex.size() != 1) return Const::doubleNaN;
463 unsigned trackIndexInt = trackIndex.at(0);
464
465 return vert->getVtxFitTrackD0(trackIndexInt);
466 }
467
468 double tagTrackRaveWeight(const Particle* part, const std::vector<double>& trackIndex)
469 {
470 auto* vert = part->getRelatedTo<TagVertex>();
471 if (!vert) return Const::doubleNaN;
472
473 if (trackIndex.size() != 1) return Const::doubleNaN;
474 unsigned trackIndexInt = trackIndex.at(0);
475
476 return vert->getRaveWeight(trackIndexInt);
477 }
478
479 double tagTrackDistanceToConstraint(const Particle* part, const std::vector<double>& trackIndex)
480 {
481 auto* vert = part->getRelatedTo<TagVertex>();
482 if (!vert) return Const::doubleNaN;
483
484 if (trackIndex.size() != 1) return Const::doubleNaN;
485 unsigned trackIndexInt = trackIndex.at(0);
486
487 if (vert->getConstraintType() == "noConstraint") return Const::doubleNaN;
488 const Particle* tagParticle(vert->getVtxFitParticle(trackIndexInt));
489 if (!tagParticle) return Const::doubleNaN;
490 const TrackFitResult* tagTrackFitResult = tagParticle->getTrackFitResult();
491 if (!tagTrackFitResult) return Const::doubleNaN;
492
493 return DistanceTools::trackToVtxDist(tagTrackFitResult->getPosition(),
494 tagParticle->getMomentum(),
495 vert->getConstraintCenter());
496 }
497
498 double getY4Sx(const Particle* part)
499 {
500 auto* vert = part->getRelatedTo<TagVertex>();
501 if (!vert) return Const::doubleNaN;
502 return vert->getConstraintCenter().X();
503 }
504
505 double getY4Sy(const Particle* part)
506 {
507 auto* vert = part->getRelatedTo<TagVertex>();
508 if (!vert) return Const::doubleNaN;
509 return vert->getConstraintCenter().Y();
510 }
511
512 double getY4Sz(const Particle* part)
513 {
514 auto* vert = part->getRelatedTo<TagVertex>();
515 if (!vert) return Const::doubleNaN;
516 return vert->getConstraintCenter().Z();
517 }
518
519 double getSigBdecayTime(const Particle* part)
520 {
521 auto* vert = part->getRelatedTo<TagVertex>();
522 if (!vert) return Const::doubleNaN;
523 B2Vector3D vtxY4S = vert->getConstraintCenter(); // Y4Svtx
524 B2Vector3D vtxSigB = part->getVertex(); // SignalB vertex
525 ROOT::Math::PxPyPzEVector p4Sig = part->get4Vector(); // SigB 4-momentum
526 B2Vector3D nSig = p4Sig.Vect().Unit(); // SigB momentum direction
527
528 // Notice that for beta*gamma we use p / m, not p / mPDG which has worse resolution
529 double betaSig = p4Sig.Beta();
530 double gammaSig = 1 / sqrt(1 - betaSig * betaSig);
531 double c = Const::speedOfLight / 1000.; // cm ps-1
532
533 // The projection of the flight path into the SigB momentum direction is used.
534 // I.e. the decay time can be negative
535 double tSig = (vtxSigB - vtxY4S).Dot(nSig) / (c * betaSig * gammaSig);
536 return tSig;
537 }
538
539 double getTagBdecayTime(const Particle* part)
540 {
541 auto* vert = part->getRelatedTo<TagVertex>();
542 if (!vert) return Const::doubleNaN;
543
544 B2Vector3D vtxY4S = vert->getConstraintCenter(); // Y4Svtx
545 B2Vector3D vtxTagB = vert->getTagVertex(); // TagB vertex
546 ROOT::Math::PxPyPzEVector p4Sig = part->get4Vector(); // SigB 4-momentum
547 ROOT::Math::PxPyPzEVector p4SigCms = PCmsLabTransform().labToCms(p4Sig);
548 // Assuming that pSigCms + pTagCms == 0
549 ROOT::Math::PxPyPzEVector p4TagCms(-p4SigCms.px(), -p4SigCms.py(), -p4SigCms.pz(), p4SigCms.E());
550 ROOT::Math::PxPyPzEVector p4Tag = PCmsLabTransform().cmsToLab(p4TagCms);
551 B2Vector3D nTag = p4Tag.Vect().Unit(); // TagB momentum direction
552
553 // Notice that for beta*gamma we use p / m, not p / mPDG which has worse resolution
554 double betaTag = p4Tag.Beta();
555 double gammaTag = 1 / sqrt(1 - betaTag * betaTag);
556 double c = Const::speedOfLight / 1000.; // cm ps-1
557
558 // The projection of the flight path into the TagB momentum direction is used.
559 // I.e. the decay time can be negative
560 double tTag = (vtxTagB - vtxY4S).Dot(nTag) / (c * betaTag * gammaTag);
561 return tTag;
562 }
563
564 double getDeltaT3D(const Particle* part)
565 {
566 return getSigBdecayTime(part) - getTagBdecayTime(part);
567 }
568
569 double tagTrackDistanceToConstraintErr(const Particle* part, const std::vector<double>& trackIndex)
570 {
571 auto* vert = part->getRelatedTo<TagVertex>();
572 if (!vert) return Const::doubleNaN;
573
574 if (trackIndex.size() != 1) return Const::doubleNaN;
575 unsigned trackIndexInt = trackIndex.at(0);
576
577 if (vert->getConstraintType() == "noConstraint") return Const::doubleNaN;
578 const Particle* tagParticle(vert->getVtxFitParticle(trackIndexInt));
579 if (!tagParticle) return Const::doubleNaN;
580 const TrackFitResult* tagTrackFitResult = tagParticle->getTrackFitResult();
581 if (!tagTrackFitResult) return Const::doubleNaN;
582
583 //recover the covariance matrix associated to the position of the tag track
584 TMatrixDSym trackPosCovMat = tagParticle->getVertexErrorMatrix();
585
586 return DistanceTools::trackToVtxDistErr(tagTrackFitResult->getPosition(),
587 tagParticle->getMomentum(),
588 vert->getConstraintCenter(),
589 trackPosCovMat,
590 vert->getConstraintCov());
591 }
592
593 double tagTrackDistanceToConstraintSignificance(const Particle* part, const std::vector<double>& trackIndex)
594 {
595 double val = tagTrackDistanceToConstraint(part, trackIndex);
596 if (isinf(val) || isnan(val)) return Const::doubleNaN;
597 double err = tagTrackDistanceToConstraintErr(part, trackIndex);
598 if (isinf(err) || isnan(err)) return Const::doubleNaN;
599
600 return val / err;
601 }
602
603 double tagVDistanceToConstraint(const Particle* part)
604 {
605 auto* vert = part->getRelatedTo<TagVertex>();
606 if (!vert) return Const::doubleNaN;
607
608 if (vert->getConstraintType() == "noConstraint") return Const::doubleNaN;
609
610 return DistanceTools::vtxToVtxDist(vert->getConstraintCenter(),
611 vert->getTagVertex());
612 }
613
614 double tagVDistanceToConstraintErr(const Particle* part)
615 {
616 auto* vert = part->getRelatedTo<TagVertex>();
617 if (!vert) return Const::doubleNaN;
618
619 if (vert->getConstraintType() == "noConstraint") return Const::doubleNaN;
620
621 //To compute the uncertainty, the tag vtx uncertainty is NOT taken into account
622 //The error computed is the the one used in the chi2.
623 //To change that, emptyMat has to be replaced by m_TagVertexErrMatrix
624 TMatrixDSym emptyMat(3);
625
626 return DistanceTools::vtxToVtxDistErr(vert->getConstraintCenter(),
627 vert->getTagVertex(),
628 vert->getConstraintCov(),
629 emptyMat);
630 }
631
632 double tagVDistanceToConstraintSignificance(const Particle* part)
633 {
634 double val = tagVDistanceToConstraint(part);
635 if (isinf(val) || isnan(val)) return Const::doubleNaN;
636 double err = tagVDistanceToConstraintErr(part);
637 if (isinf(err) || isnan(err)) return Const::doubleNaN;
638
639 return val / err;
640 }
641
642 double tagTrackDistanceToTagV(const Particle* part, const std::vector<double>& trackIndex)
643 {
644 auto* vert = part->getRelatedTo<TagVertex>();
645 if (!vert) return Const::doubleNaN;
646
647 if (trackIndex.size() != 1) return Const::doubleNaN;
648 unsigned trackIndexInt = trackIndex.at(0);
649
650 const Particle* particle = vert->getVtxFitParticle(trackIndexInt);
651 if (!particle) return Const::doubleNaN;
652 const TrackFitResult* trackFitResult = particle->getTrackFitResult();
653 if (!trackFitResult) return Const::doubleNaN;
654
655 return DistanceTools::trackToVtxDist(trackFitResult->getPosition(),
656 particle->getMomentum(),
657 vert->getTagVertex());
658 }
659
660 double tagTrackDistanceToTagVErr(const Particle* part, const std::vector<double>& trackIndex)
661 {
662 auto* vert = part->getRelatedTo<TagVertex>();
663 if (!vert) return Const::doubleNaN;
664
665 if (trackIndex.size() != 1) return Const::doubleNaN;
666 unsigned trackIndexInt = trackIndex.at(0);
667
668 const Particle* tagParticle(vert->getVtxFitParticle(trackIndexInt));
669 if (!tagParticle) return Const::doubleNaN;
670 const TrackFitResult* tagTrackFitResult = tagParticle->getTrackFitResult();
671 if (!tagTrackFitResult) return Const::doubleNaN;
672
673 //recover the covariance matrix associated to the position of the tag track
674 TMatrixDSym trackPosCovMat = tagParticle->getVertexErrorMatrix();
675
676 //To compute the uncertainty, the tag vtx uncertainty is NOT taken into account
677 //The error computed is then the one in the chi2.
678 //To change that, emptyMat has to be replaced by m_TagVertexErrMatrix
679
680 TMatrixDSym emptyMat(3);
681
682 return DistanceTools::trackToVtxDistErr(tagTrackFitResult->getPosition(),
683 tagParticle->getMomentum(),
684 vert->getTagVertex(),
685 trackPosCovMat,
686 emptyMat);
687
688 }
689
690 double tagTrackDistanceToTagVSignificance(const Particle* part, const std::vector<double>& trackIndex)
691 {
692 double val = tagTrackDistanceToTagV(part, trackIndex);
693 if (isinf(val) || isnan(val)) return Const::doubleNaN;
694 double err = tagTrackDistanceToTagVErr(part, trackIndex);
695 if (isinf(err) || isnan(err)) return Const::doubleNaN;
696
697 return val / err;
698 }
699
700 double tagTrackTrueDistanceToTagV(const Particle* part, const std::vector<double>& trackIndex)
701 {
702 auto* vert = part->getRelatedTo<TagVertex>();
703 if (!vert) return Const::doubleNaN;
704
705 if (trackIndex.size() != 1) return Const::doubleNaN;
706 unsigned trackIndexInt = trackIndex.at(0);
707
708 const MCParticle* mcParticle(vert->getVtxFitMCParticle(trackIndexInt));
709 if (!mcParticle) return Const::doubleNaN;
710
711 B2Vector3D mcTagV = vert->getMCTagVertex();
712 if (mcTagV(0) == Const::doubleNaN) return Const::doubleNaN;
713 if (mcTagV(0) == 0 && mcTagV(1) == 0 && mcTagV(2) == 0) return Const::doubleNaN;
714
715 return DistanceTools::trackToVtxDist(mcParticle->getProductionVertex(),
716 mcParticle->getMomentum(),
717 mcTagV);
718 }
719
720 B2Vector3D tagTrackTrueVecToTagV(const Particle* part, const std::vector<double>& trackIndex)
721 {
722 auto* vert = part->getRelatedTo<TagVertex>();
723 if (!vert) return vecNaN;
724
725 if (trackIndex.size() != 1) return vecNaN;
726 unsigned trackIndexInt = trackIndex.at(0);
727
728 const MCParticle* mcParticle(vert->getVtxFitMCParticle(trackIndexInt));
729 if (!mcParticle) return vecNaN;
730
731 B2Vector3D mcTagV = vert->getMCTagVertex();
732 if (mcTagV(0) == Const::doubleNaN) return vecNaN;
733 if (mcTagV(0) == 0 && mcTagV(1) == 0 && mcTagV(2) == 0) return vecNaN;
734
735 return DistanceTools::trackToVtxVec(mcParticle->getProductionVertex(),
736 mcParticle->getMomentum(),
737 mcTagV);
738 }
739
740 double tagTrackTrueVecToTagVX(const Particle* part, const std::vector<double>& trackIndex)
741 {
742 B2Vector3D result = tagTrackTrueVecToTagV(part, trackIndex);
743 return result(0);
744 }
745
746 double tagTrackTrueVecToTagVY(const Particle* part, const std::vector<double>& trackIndex)
747 {
748 B2Vector3D result = tagTrackTrueVecToTagV(part, trackIndex);
749 return result(1);
750 }
751
752 double tagTrackTrueVecToTagVZ(const Particle* part, const std::vector<double>& trackIndex)
753 {
754 B2Vector3D result = tagTrackTrueVecToTagV(part, trackIndex);
755 return result(2);
756 }
757
758 B2Vector3D tagTrackTrueMomentum(const Particle* part, const std::vector<double>& trackIndex)
759 {
760 auto* vert = part->getRelatedTo<TagVertex>();
761 if (!vert) return vecNaN;
762
763 if (trackIndex.size() != 1) return vecNaN;
764 unsigned trackIndexInt = trackIndex.at(0);
765
766 const MCParticle* mcParticle(vert->getVtxFitMCParticle(trackIndexInt));
767 if (!mcParticle) return vecNaN;
768
769 return mcParticle->getMomentum();
770 }
771
772 double tagTrackTrueMomentumX(const Particle* part, const std::vector<double>& trackIndex)
773 {
774 B2Vector3D pTrue = tagTrackTrueMomentum(part, trackIndex);
775 return pTrue(0);
776 }
777
778 double tagTrackTrueMomentumY(const Particle* part, const std::vector<double>& trackIndex)
779 {
780 B2Vector3D pTrue = tagTrackTrueMomentum(part, trackIndex);
781 return pTrue(1);
782 }
783
784 double tagTrackTrueMomentumZ(const Particle* part, const std::vector<double>& trackIndex)
785 {
786 B2Vector3D pTrue = tagTrackTrueMomentum(part, trackIndex);
787 return pTrue(2);
788 }
789
790 B2Vector3D tagTrackTrueOrigin(const Particle* part, const std::vector<double>& trackIndex)
791 {
792 auto* vert = part->getRelatedTo<TagVertex>();
793 if (!vert) return vecNaN;
794
795 if (trackIndex.size() != 1) return vecNaN;
796 unsigned trackIndexInt = trackIndex.at(0);
797
798 const MCParticle* mcParticle(vert->getVtxFitMCParticle(trackIndexInt));
799 if (!mcParticle) return vecNaN;
800
801 return mcParticle->getProductionVertex();
802 }
803
804 double tagTrackTrueOriginX(const Particle* part, const std::vector<double>& trackIndex)
805 {
806 B2Vector3D origin = tagTrackTrueOrigin(part, trackIndex);
807 return origin(0);
808 }
809
810 double tagTrackTrueOriginY(const Particle* part, const std::vector<double>& trackIndex)
811 {
812 B2Vector3D origin = tagTrackTrueOrigin(part, trackIndex);
813 return origin(1);
814 }
815
816 double tagTrackTrueOriginZ(const Particle* part, const std::vector<double>& trackIndex)
817 {
818 B2Vector3D origin = tagTrackTrueOrigin(part, trackIndex);
819 return origin(2);
820 }
821
822 int fitTruthStatus(const Particle* part)
823 {
824 auto* vert = part->getRelatedTo<TagVertex>();
825 if (!vert) return -1;
826 return vert->getFitTruthStatus();
827 }
828
829 int rollbackStatus(const Particle* part)
830 {
831 auto* vert = part->getRelatedTo<TagVertex>();
832 if (!vert) return -1;
833 return vert->getRollBackStatus();
834 }
835
836 //**********************************
837 //Meta variables
838 //**********************************
839
845 TagTrFPtr getTagTrackFunctionFromName(string const& name)
846 {
847 if (name == "TagTrackMomentum") return tagTrackMomentum;
848 else if (name == "TagTrackMomentumX") return tagTrackMomentumX;
849 else if (name == "TagTrackMomentumY") return tagTrackMomentumY;
850 else if (name == "TagTrackMomentumZ") return tagTrackMomentumZ;
851 else if (name == "TagTrackZ0") return tagTrackZ0;
852 else if (name == "TagTrackD0") return tagTrackD0;
853 else if (name == "TagTrackRaveWeight") return tagTrackRaveWeight;
854 else if (name == "TagTrackDistanceToConstraint") return tagTrackDistanceToConstraint;
855 else if (name == "TagTrackDistanceToConstraintErr") return tagTrackDistanceToConstraintErr;
856 else if (name == "TagTrackDistanceToConstraintSignificance") return tagTrackDistanceToConstraintSignificance;
857 else if (name == "TagTrackDistanceToTagV") return tagTrackDistanceToTagV;
858 else if (name == "TagTrackDistanceToTagVErr") return tagTrackDistanceToTagVErr;
859 else if (name == "TagTrackDistanceToTagVSignificance") return tagTrackDistanceToTagVSignificance;
860 else if (name == "TagTrackTrueDistanceToTagV") return tagTrackTrueDistanceToTagV;
861 else if (name == "TagTrackTrueVecToTagVX") return tagTrackTrueVecToTagVX;
862 else if (name == "TagTrackTrueVecToTagVY") return tagTrackTrueVecToTagVY;
863 else if (name == "TagTrackTrueVecToTagVZ") return tagTrackTrueVecToTagVZ;
864 else if (name == "TagTrackTrueMomentumX") return tagTrackTrueMomentumX;
865 else if (name == "TagTrackTrueMomentumY") return tagTrackTrueMomentumY;
866 else if (name == "TagTrackTrueMomentumZ") return tagTrackTrueMomentumZ;
867 else if (name == "TagTrackTrueOriginX") return tagTrackTrueOriginX;
868 else if (name == "TagTrackTrueOriginY") return tagTrackTrueOriginY;
869 else if (name == "TagTrackTrueOriginZ") return tagTrackTrueOriginZ;
870
871 B2ERROR("From TimeDependentVariables: Trying to access unknown tagTrack function");
872 return nullptr;
873 }
874
875 double cumulate(const Particle* part, const std::vector<std::string>& variable, double start,
876 std::function<double(double, double, double)> fun)
877 {
878 TagTrFPtr fptr(getTagTrackFunctionFromName(variable.at(0)));
879 auto* vert = part->getRelatedTo<TagVertex>();
880 if (!vert) return Const::doubleNaN;
881 int nTracks = vert->getNFitTracks();
882
883 //calculate cumulative quantity
884 double acum = start;
885 for (int i = 0; i < nTracks; ++i) {
886 vector<double> indx(1, i);
887 double w = tagTrackRaveWeight(part, indx);
888 double f = (*fptr)(part, indx);
889 if (w > 0) {
890 acum = fun(acum, f, w);
891 }
892 }
893 return acum;
894 }
895
896 Manager::FunctionPtr tagTrackAverage(const std::vector<std::string>& variable)
897 {
898 if (variable.size() != 1) {
899 B2FATAL("Wrong number of arguments for meta function tagTrackAverage");
900 return nullptr;
901 }
902
903 return [variable](const Particle * part) -> double {
904 double sum = cumulate(part, variable, 0, [](double s, double f, double) {return s + f;});
905 double tot = cumulate(part, variable, 0, [](double s, double, double) {return s + 1;});
906 return (tot > 0) ? sum / tot : Const::doubleNaN;
907 };
908 }
909
910 Manager::FunctionPtr tagTrackAverageSquares(const std::vector<std::string>& variable)
911 {
912 if (variable.size() != 1) {
913 B2FATAL("Wrong number of arguments for meta function tagTrackAverageSquares");
914 return nullptr;
915 }
916
917 return [variable](const Particle * part) -> double {
918 double sum = cumulate(part, variable, 0, [](double s, double f, double) {return s + f * f;});
919 double tot = cumulate(part, variable, 0, [](double s, double, double) {return s + 1;});
920 return (tot > 0) ? sum / tot : Const::doubleNaN;
921 };
922 }
923
924
925 Manager::FunctionPtr tagTrackMax(const std::vector<std::string>& variable)
926 {
927 if (variable.size() != 1) {
928 B2FATAL("Wrong number of arguments for meta function tagTrackMax");
929 return nullptr;
930 }
931
932 return [variable](const Particle * part) -> double {
933 double Max = cumulate(part, variable, -DBL_MAX, [](double s, double f, double) {return std::max(s, f);});
934 return (Max != -DBL_MAX) ? Max : Const::doubleNaN;
935 };
936 }
937
938 Manager::FunctionPtr tagTrackMin(const std::vector<std::string>& variable)
939 {
940 if (variable.size() != 1) {
941 B2FATAL("Wrong number of arguments for meta function tagTrackMin");
942 return nullptr;
943 }
944
945 return [variable](const Particle * part) -> double {
946 double Min = cumulate(part, variable, +DBL_MAX, [](double s, double f, double) {return std::min(s, f);});
947 return (Min != DBL_MAX) ? Min : Const::doubleNaN;
948 };
949 }
950
951 Manager::FunctionPtr tagTrackWeightedAverage(const std::vector<std::string>& variable)
952 {
953 if (variable.size() != 1) {
954 B2FATAL("Wrong number of arguments for meta function tagTrackWeightedAverage");
955 return nullptr;
956 }
957
958 return [variable](const Particle * part) -> double {
959 double num = cumulate(part, variable, 0, [](double s, double f, double w) {return s + w * f;});
960 double den = cumulate(part, variable, 0, [](double s, double, double w) {return s + w;});
961 return (den > 0) ? num / den : Const::doubleNaN;
962 };
963 }
964
965 Manager::FunctionPtr tagTrackWeightedAverageSquares(const std::vector<std::string>& variable)
966 {
967 if (variable.size() != 1) {
968 B2FATAL("Wrong number of arguments for meta function tagTrackWeightedAverageSquares");
969 return nullptr;
970 }
971
972 return [variable](const Particle * part) -> double {
973 double num = cumulate(part, variable, 0, [](double s, double f, double w) {return s + w * f * f;});
974 double den = cumulate(part, variable, 0, [](double s, double, double w) {return s + w;});
975 return (den > 0) ? num / den : Const::doubleNaN;
976 };
977 }
978
979 Manager::FunctionPtr tagTrackSum(const std::vector<std::string>& variable)
980 {
981 if (variable.size() != 1) {
982 B2FATAL("Wrong number of arguments for meta function tagTrackSum");
983 return nullptr;
984 }
985
986 return [variable](const Particle * part) -> double {
987 return cumulate(part, variable, 0, [](double s, double f, double) {return s + f;});
988 };
989 }
990
991 //**********************************
992 //VARIABLE REGISTRATION
993 //**********************************
994
995 VARIABLE_GROUP("Time Dependent CPV Analysis Variables");
996
997 REGISTER_VARIABLE("TagVx", particleTagVx, "Tag vertex X component\n\n", "cm");
998 REGISTER_VARIABLE("TagVy", particleTagVy, "Tag vertex Y component\n\n", "cm");
999 REGISTER_VARIABLE("TagVz", particleTagVz, "Tag vertex Z component\n\n", "cm");
1000 REGISTER_VARIABLE("mcTagVx", particleTruthTagVx, "Generated Tag vertex X component\n\n", "cm");
1001 REGISTER_VARIABLE("mcTagVy", particleTruthTagVy, "Generated Tag vertex Y component\n\n", "cm");
1002 REGISTER_VARIABLE("mcTagVz", particleTruthTagVz, "Generated Tag vertex Z component\n\n", "cm");
1003 REGISTER_VARIABLE("TagVxErr", particleTagVxErr, "Tag vertex X component uncertainty\n\n", "cm");
1004 REGISTER_VARIABLE("TagVyErr", particleTagVyErr, "Tag vertex Y component uncertainty\n\n", "cm");
1005 REGISTER_VARIABLE("TagVzErr", particleTagVzErr, "Tag vertex Z component uncertainty\n\n", "cm");
1006 REGISTER_VARIABLE("TagVCov(i,j)", particleTagVCov,
1007 "returns the (i,j)-th element of the Tag vertex covariance matrix (3x3).\n"
1008 "Order of elements in the covariance matrix is: x, y, z.\n\n", "cm, cm, cm");
1009
1010 REGISTER_VARIABLE("TagVpVal", particleTagVpVal, "Tag vertex p-Value");
1011 REGISTER_VARIABLE("TagVNTracks", particleTagVNTracks, "Number of tracks in the tag vertex");
1012 REGISTER_VARIABLE("TagVType", particleTagVType,
1013 R"DOC(Type of algorithm for the tag vertex. -1: failed (1,2: single track, deprecated), 3: standard, 4: standard_PXD, 5: no constraint)DOC");
1014 REGISTER_VARIABLE("TagVNDF", particleTagVNDF, "Number of degrees of freedom in the tag vertex fit");
1015 REGISTER_VARIABLE("TagVChi2", particleTagVChi2, "chi2 value of the tag vertex fit");
1016 REGISTER_VARIABLE("TagVChi2IP", particleTagVChi2IP, "IP component of chi2 value of the tag vertex fit");
1017
1018 REGISTER_VARIABLE("DeltaT", particleDeltaT, R"DOC(
1019 Proper decay time difference :math:`\Delta t` between signal B-meson :math:`(B_{rec})` and tag B-meson :math:`(B_{tag})`.
1020
1021 )DOC", "ps");
1022 REGISTER_VARIABLE("DeltaTErr", particleDeltaTErr, R"DOC(
1023 Proper decay time difference :math:`\Delta t` uncertainty
1024
1025 )DOC", "ps");
1026 REGISTER_VARIABLE("DeltaTRes", particleDeltaTRes, R"DOC(
1027 :math:`\Delta t` residual, to be used for resolution function studies
1028
1029 )DOC", "ps");
1030 REGISTER_VARIABLE("DeltaTBelle", particleDeltaTBelle, R"DOC(
1031 [Legacy] :math:`\Delta t`, as it was used in Belle
1032
1033 )DOC", "ps");
1034 REGISTER_VARIABLE("mcDeltaTau", particleMCDeltaTau,
1035 R"DOC(Generated proper decay time difference :math:`\Delta t`: :math:`\tau(B_{\rm rec})-\tau(B_{\rm tag})`
1036
1037)DOC", "ps");
1038 REGISTER_VARIABLE("mcDeltaT", particleMCDeltaT,
1039 R"DOC(Generated proper decay time difference (in z-difference approximation) :math:`\Delta t`:
1040 :math:`(l(B_{\rm rec}) - l(B_{\rm tag}))/\beta_{\Upsilon(4S)}\gamma_{\Upsilon(4S)}`
1041
1042)DOC","ps");
1043 REGISTER_VARIABLE("mcDeltaBoost", particleMCDeltaBoost,
1044 R"DOC(True difference of decay vertex boost-direction components between signal B-meson :math:`(B_{rec})` and tag B-meson :math:`(B_{tag})`:
1045:math:`\Delta l = l(B_{rec}) - l(B_{tag})`
1046
1047)DOC", "cm");
1048 REGISTER_VARIABLE("DeltaZ", particleDeltaZ,
1049 R"DOC(Difference of decay vertex longitudinal components between signal B-meson :math:`(B_{rec})` and tag B-meson :math:`(B_{tag})`:
1050:math:`\Delta z = z(B_{rec}) - z(B_{tag})`
1051
1052)DOC", "cm");
1053 REGISTER_VARIABLE("DeltaZErr", particleDeltaZErr,
1054 R"DOC(Uncertainty of the difference :math:`z(B_{rec}) - z(B_{tag})`
1055
1056)DOC", "cm");
1057 REGISTER_VARIABLE("DeltaBoost", particleDeltaB, R"DOC(:math:`\Delta z` in the boost direction
1058
1059)DOC", "cm");
1060 REGISTER_VARIABLE("DeltaBoostErr", particleDeltaBErr, R"DOC(Uncertainty of :math:`\Delta z` in the boost direction
1061
1062)DOC", "cm");
1063
1064 REGISTER_VARIABLE("LBoost", vertexBoostDirection,
1065 "Returns the vertex component in the boost direction\n\n", "cm");
1066 REGISTER_VARIABLE("OBoost", vertexOrthogonalBoostDirection,
1067 "Returns the vertex component in the direction orthogonal to the boost\n\n", "cm");
1068 REGISTER_VARIABLE("mcLBoost", vertexTruthBoostDirection,
1069 "Returns the MC vertex component in the boost direction\n\n", "cm");
1070 REGISTER_VARIABLE("mcOBoost", vertexTruthOrthogonalBoostDirection,
1071 "Returns the MC vertex component in the direction orthogonal to the boost\n\n", "cm");
1072 REGISTER_VARIABLE("LBoostErr", vertexErrBoostDirection,
1073 "Returns the error of the vertex in the boost direction\n\n", "cm");
1074 REGISTER_VARIABLE("OBoostErr", vertexErrOrthBoostDirection,
1075 "Returns the error of the vertex in the direction orthogonal to the boost\n\n", "cm");
1076
1077 REGISTER_VARIABLE("Y4SvtxX", getY4Sx, "Returns X component of Y4S vertex.\n"
1078 "The result is meaningful and nontrivial when the signal B vertex "
1079 "is determined by `vertex.treeFit` with ``ipConstraint=True`` and the `vertex.TagV` is called with the ``tube`` constraint.\n\n", "cm");
1080
1081 REGISTER_VARIABLE("Y4SvtxY", getY4Sy, "Returns Y component of Y4S vertex.\n"
1082 "The result is meaningful and nontrivial when the signal B vertex "
1083 "is determined by `vertex.treeFit` with ``ipConstraint=True`` and the `vertex.TagV` is called with the ``tube`` constraint.\n\n", "cm");
1084
1085 REGISTER_VARIABLE("Y4SvtxZ", getY4Sz, "Returns Z component of Y4S vertex.\n"
1086 "The result is meaningful and nontrivial when the signal B vertex "
1087 "is determined by `vertex.treeFit` with ``ipConstraint=True`` and the `vertex.TagV` is called with the ``tube`` constraint.\n\n", "cm");
1088
1089
1090 REGISTER_VARIABLE("tSigB", getSigBdecayTime, "Returns the proper decay time of the fully reconstructed signal B meson.\n"
1091 "The result is meaningful and nontrivial when the signal B vertex "
1092 "is determined by `vertex.treeFit` with ``ipConstraint=True`` and the `vertex.TagV` is called with the ``tube`` constraint.\n\n", "ps");
1093
1094 REGISTER_VARIABLE("tTagB", getTagBdecayTime, "Returns the proper decay time of the tagged B meson.\n"
1095 "The result is meaningful and nontrivial when the signal B vertex "
1096 "is determined by `vertex.treeFit` with ``ipConstraint=True`` and the `vertex.TagV` is called with the ``tube`` constraint.\n\n", "ps");
1097
1098 REGISTER_VARIABLE("DeltaT3D", getDeltaT3D, R"DOC(
1099 Returns the :math:`\Delta t` variable calculated as a difference of :b2:var:`tSigB` and :b2:var:`tTagB`, i.e. not from the projection along boost vector axis.
1100
1101 The result is meaningful and nontrivial when the signal B vertex is determined by `vertex.treeFit` with ``ipConstraint=True`` and the `vertex.TagV` is called with the ``tube`` constraint.
1102
1103 )DOC", "ps");
1104
1105 REGISTER_VARIABLE("TagVLBoost", tagVBoostDirection,
1106 "Returns the TagV component in the boost direction\n\n", "cm");
1107 REGISTER_VARIABLE("TagVOBoost", tagVOrthogonalBoostDirection,
1108 "Returns the TagV component in the direction orthogonal to the boost\n\n", "cm");
1109 REGISTER_VARIABLE("mcTagVLBoost", tagVTruthBoostDirection,
1110 "Returns the MC TagV component in the boost direction\n\n", "cm");
1111 REGISTER_VARIABLE("mcTagVOBoost", tagVTruthOrthogonalBoostDirection,
1112 "Returns the MC TagV component in the direction orthogonal to the boost\n\n", "cm");
1113 REGISTER_VARIABLE("TagVLBoostErr", tagVErrBoostDirection,
1114 "Returns the error of TagV in the boost direction\n\n", "cm");
1115 REGISTER_VARIABLE("TagVOBoostErr", tagVErrOrthogonalBoostDirection,
1116 "Returns the error of TagV in the direction orthogonal to the boost\n\n", "cm");
1117
1118 REGISTER_VARIABLE("cosAngleBetweenMomentumAndBoostVector", particleCosThetaBoostDirection,
1119 "cosine of the angle between momentum and boost vector");
1120
1121 REGISTER_VARIABLE("internalTagVMCFlavor", particleInternalTagVMCFlavor,
1122 "[Expert] [Debugging] This variable is only for internal checks of the TagV module by developers. \n"
1123 "It returns the internal mc flavor information of the tag-side B provided by the TagV module.");
1124
1125 REGISTER_VARIABLE("TagTrackMomentum(i) ", tagTrackMomentum,
1126 "Returns the magnitude of the momentum of the ith track used in the tag vtx fit.\n\n", "GeV/c");
1127 REGISTER_VARIABLE("TagTrackMomentumX(i) ", tagTrackMomentumX,
1128 "Returns the X component of the momentum of the ith track used in the tag vtx fit.\n\n", "GeV/c");
1129 REGISTER_VARIABLE("TagTrackMomentumY(i) ", tagTrackMomentumY,
1130 "Returns the Y component of the momentum of the ith track used in the tag vtx fit.\n\n", "GeV/c");
1131 REGISTER_VARIABLE("TagTrackMomentumZ(i) ", tagTrackMomentumZ,
1132 "Returns the Z component of the momentum of the ith track used in the tag vtx fit.\n\n", "GeV/c");
1133
1134 REGISTER_VARIABLE("TagTrackZ0(i)", tagTrackZ0, "Returns the z0 parameter of the ith track used in the tag vtx fit\n\n", "cm");
1135 REGISTER_VARIABLE("TagTrackD0(i)", tagTrackD0, "Returns the d0 parameter of the ith track used in the tag vtx fit\n\n", "cm");
1136
1137
1138 REGISTER_VARIABLE("TagTrackRaveWeight(i)", tagTrackRaveWeight, "Returns the weight assigned by Rave to track i");
1139
1140 REGISTER_VARIABLE("TagVNFitTracks", particleTagVNFitTracks,
1141 "returns the number of tracks used by rave to fit the vertex (not counting the ones coming from Kshorts)");
1142
1143 REGISTER_VARIABLE("TagTrackDistanceToConstraint(i)", tagTrackDistanceToConstraint,
1144 "Returns the measured distance between the ith tag track and the centre of the constraint.\n\n", "cm");
1145
1146 REGISTER_VARIABLE("TagTrackDistanceToConstraintErr(i)", tagTrackDistanceToConstraintErr,
1147 "Returns the estimated error on the distance between the ith tag track and the centre of the constraint.\n\n", "cm");
1148
1149 REGISTER_VARIABLE("TagTrackDistanceToConstraintSignificance(i)", tagTrackDistanceToConstraintSignificance,
1150 "Returns the significance of the distance between the centre of the constraint and the tag track indexed by track index (computed as distance / uncertainty)");
1151
1152
1153 REGISTER_VARIABLE("TagVDistanceToConstraint", tagVDistanceToConstraint,
1154 "returns the measured distance between the tag vtx and the centre of the constraint.\n\n", "cm");
1155
1156 REGISTER_VARIABLE("TagVDistanceToConstraintErr", tagVDistanceToConstraintErr,
1157 "returns the estimated error on the distance between the tag vtx and the centre of the constraint.\n\n", "cm");
1158
1159 REGISTER_VARIABLE("TagVDistanceToConstraintSignificance", tagVDistanceToConstraintSignificance,
1160 "returns the significance of the distance between the tag vtx and the centre of the constraint (computed as distance / uncertainty)");
1161
1162 REGISTER_VARIABLE("TagTrackDistanceToTagV(i)", tagTrackDistanceToTagV,
1163 "Returns the measured distance between the ith tag track and the tag vtx.\n\n", "cm");
1164
1165 REGISTER_VARIABLE("TagTrackDistanceToTagVErr(i)", tagTrackDistanceToTagVErr, R"DOC(
1166Returns the estimated error on the distance between the ith tag track and the tag vtx.
1167
1168.. warning:: Only the uncertainties on the track position parameters are taken into account.
1169
1170)DOC", "cm");
1171
1172 REGISTER_VARIABLE("TagTrackDistanceToTagVSignificance(i)", tagTrackDistanceToTagVSignificance,
1173 "Returns the significance of the distance between the tag vtx and the tag track indexed by trackIndex (computed as distance / uncertainty)");
1174
1175 REGISTER_VARIABLE("TagTrackTrueDistanceToTagV(i)", tagTrackTrueDistanceToTagV,
1176 "Returns the true distance between the true B Tag decay vertex and the particle corresponding to the ith tag vtx track.\n\n", "cm");
1177
1178 REGISTER_VARIABLE("TagTrackTrueVecToTagVX(i)", tagTrackTrueVecToTagVX,
1179 "Returns the X coordinate of the vector between the mc particle corresponding to the ith tag vtx track and the true tag B decay vertex.\n\n",
1180 "cm");
1181
1182 REGISTER_VARIABLE("TagTrackTrueVecToTagVY(i)", tagTrackTrueVecToTagVY,
1183 "Returns the Y coordinate of the vector between the mc particle corresponding to the ith tag vtx track and the true tag B decay vertex.\n\n",
1184 "cm");
1185
1186 REGISTER_VARIABLE("TagTrackTrueVecToTagVZ(i)", tagTrackTrueVecToTagVZ,
1187 "Returns the Z coordinate of the vector between the mc particle corresponding to the ith tag vtx track and the true tag B decay vertex.\n\n",
1188 "cm");
1189
1190 REGISTER_VARIABLE("TagTrackTrueMomentumX(i)", tagTrackTrueMomentumX,
1191 "Returns the X component of the true momentum of the MC particle corresponding to the ith tag vtx track.\n\n", "GeV/c");
1192
1193 REGISTER_VARIABLE("TagTrackTrueMomentumY(i)", tagTrackTrueMomentumY,
1194 "Returns the Y component of the true momentum of the MC particle corresponding to the ith tag vtx track.\n\n", "GeV/c");
1195
1196 REGISTER_VARIABLE("TagTrackTrueMomentumZ(i)", tagTrackTrueMomentumZ,
1197 "Returns the Z component of the true momentum of the MC particle corresponding to the ith tag vtx track.\n\n", "GeV/c");
1198
1199 REGISTER_VARIABLE("TagTrackTrueOriginX(i)", tagTrackTrueOriginX,
1200 "Returns the X component of the true origin of the MC particle corresponding to the ith tag vtx track.\n\n", "cm");
1201
1202 REGISTER_VARIABLE("TagTrackTrueOriginY(i)", tagTrackTrueOriginY,
1203 "Returns the Y component of the true origin of the MC particle corresponding to the ith tag vtx track.\n\n", "cm");
1204
1205 REGISTER_VARIABLE("TagTrackTrueOriginZ(i)", tagTrackTrueOriginZ,
1206 "Returns the Z component of the true origin of the MC particle corresponding to the ith tag vtx track.\n\n", "cm");
1207
1208 REGISTER_VARIABLE("TagVFitTruthStatus", fitTruthStatus, R"DOC(
1209Returns the status of the fit performed with the truth info. Possible values are:
1210
1211- -1: no related TagVertex found
1212- 0: fit performed with measured parameters
1213- 1: fit performed with true parameters
1214- 2: unable to recover truth parameters
1215)DOC");
1216
1217 REGISTER_VARIABLE("TagVRollBackStatus", rollbackStatus, R"DOC(
1218Returns the status of the fit performed with rolled back tracks. Possible values are:
1219
1220- -1: no related TagVertex found
1221- 0: fit performed with measured parameters
1222- 1: fit performed with true parameters
1223- 2: unable to recover truth parameters
1224)DOC");
1225
1226 REGISTER_METAVARIABLE("TagTrackMax(var)", tagTrackMax,
1227 "return the maximum value of the variable ``var`` evaluated for each tag track. ``var`` must be one of the TagTrackXXX variables, for example: ``TagTrackMax(TagTrackDistanceToConstraint)``. The tracks that are assigned a zero weight are ignored.",
1228 Manager::VariableDataType::c_double);
1229
1230 REGISTER_METAVARIABLE("TagTrackMin(var)", tagTrackMin,
1231 "return the minimum value of the variable ``var`` evaluated for each tag track. ``var`` must be one of the TagTrackXXX variables, for example: ``TagTrackMin(TagTrackDistanceToConstraint)``. The tracks that are assigned a zero weight are ignored.",
1232 Manager::VariableDataType::c_double);
1233
1234 REGISTER_METAVARIABLE("TagTrackAverage(var)", tagTrackAverage,
1235 "return the average over the tag tracks of the variable ``var``. ``var`` must be one of the TagTrackXXX variables, for example: ``TagTrackAverage(TagTrackDistanceToConstraint)``. The tracks that are assigned a zero weight are ignored.",
1236 Manager::VariableDataType::c_double);
1237
1238 REGISTER_METAVARIABLE("TagTrackAverageSquares(var)", tagTrackAverageSquares,
1239 "return the average over the tag tracks of the square of the variable ``var``. ``var`` must be one of the TagTrackXXX variables, for example: ``TagTrackAverageSquares(TagTrackDistanceToConstraint)``. The tracks that are assigned a zero weight are ignored.",
1240 Manager::VariableDataType::c_double);
1241
1242 REGISTER_METAVARIABLE("TagTrackWeightedAverage(var)", tagTrackWeightedAverage,
1243 "return the average over the tag tracks of the variable ``var``, weighted by weights of the tag vertex fitter. ``var`` must be one of the TagTrackXXX variables, for example: ``TagTrackWeightedAverage(TagTrackDistanceToConstraint)``.",
1244 Manager::VariableDataType::c_double);
1245
1246 REGISTER_METAVARIABLE("TagTrackWeightedAverageSquares(var)", tagTrackWeightedAverageSquares,
1247 "return the average over the tag tracks of the variable ``var``, weighted by weights of the tag vertex fitter. ``var`` must be one of the TagTrackXXX variables, for example: ``TagTrackWeightedAverageSquares(TagTrackDistanceToConstraint)``.",
1248 Manager::VariableDataType::c_double);
1249
1250 REGISTER_METAVARIABLE("TagTrackSum(var)", tagTrackSum,
1251 "Returns the sum of the provided variable for all tag tracks. The variable must be one of the TagTrackXXX variables, "
1252 "for example ``TagTrackSum(TagTrackD0)``. The tracks that are assigned a zero weight are ignored.",
1253 Manager::VariableDataType::c_double);
1254 }
1256}
1257
1258
1259
1260
B2Vector3< DataType > Unit() const
Unit vector parallel to this.
Definition: B2Vector3.h:269
static const double speedOfLight
[cm/ns]
Definition: Const.h:695
static const double doubleNaN
quiet_NaN
Definition: Const.h:703
const MCParticle * getMCParticle() const
Returns the pointer to the MCParticle object that was used to create this Particle (ParticleType == c...
Definition: Particle.cc:1027
static const ReferenceFrame & GetCurrent()
Get current rest frame.
std::function< VarVariant(const Particle *)> FunctionPtr
functions stored take a const Particle* and return VarVariant.
Definition: Manager.h:112
Class to store variables with their name which were sent to the logging service.
B2Vector3< float > B2Vector3F
typedef for common usage with float
Definition: B2Vector3.h:519
B2Vector3< double > B2Vector3D
typedef for common usage with double
Definition: B2Vector3.h:516
DataType at(unsigned i) const
safe member access (with boundary check!)
Definition: B2Vector3.h:751
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
double trackToVtxDistErr(B2Vector3D const &trackPos, B2Vector3D const &trackP, B2Vector3D const &vtxPos, TMatrixDSym const &trackPosCovMat, TMatrixDSym const &vtxPosCovMat)
Returns the estimated uncertainty between a vertex and a track's point of closest approach to that ve...
double trackToVtxDist(B2Vector3D const &trackPos, B2Vector3D const &trackP, B2Vector3D const &vtxPos)
Returns the distance between a vertex and a track's point of closest approach to that vertex.
double vtxToVtxDist(B2Vector3D const &vtx1Pos, B2Vector3D const &vtx2Pos)
Returns the distance between two vertices.
B2Vector3D trackToVtxVec(B2Vector3D const &trackPos, B2Vector3D const &trackP, B2Vector3D const &vtxPos)
Returns the 3D vector between a vertex and a track's point of closest approach to that vertex.
double vtxToVtxDistErr(B2Vector3D const &vtx1Pos, B2Vector3D const &vtx2Pos, TMatrixDSym const &vtx1CovMat, TMatrixDSym const &vtx2CovMat)
Returns the estimated uncertainty on the distance between two vertices.
Abstract base class for different kinds of events.
STL namespace.