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