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