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