Belle II Software  release-05-02-19
TagVertexModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2014 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Luigi Li Gioi, Thibaud Humair *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <analysis/modules/TagVertex/TagVertexModule.h>
12 
13 //to help printing out stuff
14 #include<sstream>
15 
16 // framework - DataStore
17 #include <framework/datastore/StoreArray.h>
18 #include <framework/datastore/StoreObjPtr.h>
19 
20 // framework aux
21 #include <framework/gearbox/Unit.h>
22 #include <framework/gearbox/Const.h>
23 #include <framework/logging/Logger.h>
24 
25 // dataobjects
26 #include <analysis/dataobjects/Particle.h>
27 #include <analysis/dataobjects/ParticleList.h>
28 #include <analysis/dataobjects/RestOfEvent.h>
29 #include <analysis/dataobjects/TagVertex.h>
30 #include <analysis/dataobjects/FlavorTaggerInfo.h>
31 
32 // utilities
33 #include <analysis/utility/PCmsLabTransform.h>
34 #include <analysis/variables/TrackVariables.h>
35 #include <analysis/utility/ParticleCopy.h>
36 #include <analysis/utility/CLHEPToROOT.h>
37 #include <analysis/utility/ROOTToCLHEP.h>
38 #include <analysis/utility/DistanceTools.h>
39 #include <analysis/utility/RotationTools.h>
40 
41 // vertex fitting
42 #include <analysis/VertexFitting/KFit/VertexFitKFit.h>
43 
44 // mdst dataobject
45 #include <mdst/dataobjects/MCParticle.h>
46 #include <mdst/dataobjects/HitPatternVXD.h>
47 
48 // Magnetic field
49 #include <framework/geometry/BFieldManager.h>
50 
51 #include <TVector.h>
52 #include <TRotation.h>
53 
54 
55 using namespace std;
56 
57 namespace Belle2 {
64  static const double realNaN = std::numeric_limits<double>::quiet_NaN();
66  static const TVector3 vecNaN(realNaN, realNaN, realNaN);
68  static const TMatrixDSym matNaN(3, (double [])
69  {
73  });
74 
75  // import tools from RotationTools.h
76  using RotationTools::rotateTensor;
77  using RotationTools::rotateTensorInv;
78  using RotationTools::toSymMatrix;
79  using RotationTools::toVec;
80  using RotationTools::getUnitOrthogonal;
81 
82  //-----------------------------------------------------------------
83  // Register the Module
84  //-----------------------------------------------------------------
85  REG_MODULE(TagVertex)
86 
87  //-----------------------------------------------------------------
88  // Implementation
89  //-----------------------------------------------------------------
90 
92  m_Bfield(0), m_fitTruthStatus(0), m_rollbackStatus(0), m_fitPval(0), m_mcTagLifeTime(-1), m_mcPDG(0), m_mcLifeTimeReco(-1),
93  m_deltaT(0), m_deltaTErr(0), m_mcDeltaTau(0), m_mcDeltaT(0),
94  m_shiftZ(0), m_FitType(0), m_tagVl(0),
95  m_truthTagVl(0), m_tagVlErr(0), m_tagVol(0), m_truthTagVol(0), m_tagVolErr(0), m_tagVNDF(0), m_tagVChi2(0), m_tagVChi2IP(0),
96  m_verbose(true)
97  {
98  // Set module properties
99  setDescription("Tag side Vertex Fitter for modular analysis");
100 
101  // Parameter definitions
102  addParam("listName", m_listName, "name of particle list", string(""));
103  addParam("confidenceLevel", m_confidenceLevel,
104  "required confidence level of fit to keep particles in the list. Note that even with confidenceLevel == 0.0, errors during the fit might discard Particles in the list. confidenceLevel = -1 if an error occurs during the fit",
105  0.001);
106  addParam("MCAssociation", m_useMCassociation,
107  "'': no MC association. breco: use standard Breco MC association. internal: use internal MC association", string("breco"));
108  addParam("constraintType", m_constraintType,
109  "Choose the type of the constraint: noConstraint, IP (tag tracks constrained to be within the beam spot), tube (long tube along the BTag line of flight, only for fully reconstruced B rec), boost (long tube along the Upsilon(4S) boost direction), (breco)",
110  string("IP"));
111  addParam("trackFindingType", m_trackFindingType,
112  "Choose how to reconstruct the tracks on the tag side: standard, standard_PXD",
113  string("standard_PXD"));
114  addParam("maskName", m_roeMaskName,
115  "Choose ROE mask to get particles from ", string(""));
116  addParam("askMCInformation", m_mcInfo,
117  "TRUE when requesting MC Information from the tracks performing the vertex fit", false);
118  addParam("reqPXDHits", m_reqPXDHits,
119  "Minimum number of PXD hits for a track to be used in the vertex fit", 0);
120  addParam("fitAlgorithm", m_fitAlgo,
121  "Fitter used for the tag vertex fit: Rave or KFit", string("Rave"));
122  addParam("useTruthInFit", m_useTruthInFit,
123  "Use the true track parameters in the vertex fit", false);
124  addParam("useRollBack", m_useRollBack,
125  "Use rolled back non-primary tracks", false);
126  }
127 
128  void TagVertexModule::initialize()
129  {
130  // magnetic field
131  m_Bfield = BFieldManager::getField(m_BeamSpotCenter).Z() / Unit::T;
132  // RAVE setup
133  analysis::RaveSetup::initialize(1, m_Bfield);
134  B2INFO("TagVertexModule : magnetic field = " << m_Bfield);
135  // truth fit status will be set to 2 only if the MC info cannot be recovered
136  if (m_useTruthInFit) m_fitTruthStatus = 1;
137  // roll back status will be set to 2 only if the MC info cannot be recovered
138  if (m_useRollBack) m_rollbackStatus = 1;
139 
140  //TODO: this won't work with nonstandard name for Particle array (e.g. will fail when adding relations)
141  //input
142  StoreArray<Particle> particles;
143  particles.isRequired();
144  // output
145  StoreArray<TagVertex> verArray;
146  verArray.registerInDataStore();
147  particles.registerRelationTo(verArray);
148  //check if the fitting algorithm name is set correctly
149  if (m_fitAlgo != "Rave" && m_fitAlgo != "KFit")
150  B2FATAL("TagVertexModule: invalid fitting algorithm (must be set to either Rave or KFit).");
151  if (m_useRollBack && m_useTruthInFit)
152  B2FATAL("TagVertexModule: invalid fitting option (useRollBack and useTruthInFit cannot be simultaneously set to true).");
153  //temporary while the one track fit is broken
154  if (m_trackFindingType == "singleTrack" || m_trackFindingType == "singleTrack_PXD")
155  B2FATAL("TagVertexModule : the singleTrack option is temporarily broken.");
156  }
157 
158  void TagVertexModule::beginRun()
159  {
160  //TODO: set magnetic field for each run
161  //m_Bfield = BFieldMap::Instance().getBField(m_BeamSpotCenter).Z();
162  }
163 
164  void TagVertexModule::event()
165  {
166  StoreObjPtr<ParticleList> plist(m_listName);
167  if (!plist) {
168  B2ERROR("TagVertexModule: ParticleList " << m_listName << " not found");
169  return;
170  }
171 
172  // output
173  StoreArray<TagVertex> verArray;
174  analysis::RaveSetup::initialize(1, m_Bfield);
175 
176  std::vector<unsigned int> toRemove;
177 
178  for (unsigned i = 0; i < plist->getListSize(); ++i) {
179  resetReturnParams();
180 
181  Particle* particle = plist->getParticle(i);
182  if (m_useMCassociation == "breco" || m_useMCassociation == "internal") BtagMCVertex(particle);
183  bool ok = doVertexFit(particle);
184  if (ok) deltaT(particle);
185 
186  if ((m_fitPval < m_confidenceLevel && m_confidenceLevel != 0)
187  || (m_fitPval <= m_confidenceLevel && m_confidenceLevel == 0)) {
188  toRemove.push_back(particle->getArrayIndex());
189  } else {
190  // save information in the Vertex StoreArray
191  TagVertex* ver = verArray.appendNew();
192  // create relation: Particle <-> Vertex
193  particle->addRelationTo(ver);
194  // fill Vertex with content
195  if (ok) {
196  ver->setTagVertex(m_tagV);
197  ver->setTagVertexErrMatrix(m_tagVErrMatrix);
198  ver->setTagVertexPval(m_fitPval);
199  ver->setDeltaT(m_deltaT);
200  ver->setDeltaTErr(m_deltaTErr);
201  ver->setMCTagVertex(m_mcTagV);
202  ver->setMCTagBFlavor(m_mcPDG);
203  ver->setMCDeltaTau(m_mcDeltaTau);
204  ver->setMCDeltaT(m_mcDeltaT);
205  ver->setFitType(m_FitType);
206  ver->setNTracks(m_tagParticles.size());
207  ver->setTagVl(m_tagVl);
208  ver->setTruthTagVl(m_truthTagVl);
209  ver->setTagVlErr(m_tagVlErr);
210  ver->setTagVol(m_tagVol);
211  ver->setTruthTagVol(m_truthTagVol);
212  ver->setTagVolErr(m_tagVolErr);
213  ver->setTagVNDF(m_tagVNDF);
214  ver->setTagVChi2(m_tagVChi2);
215  ver->setTagVChi2IP(m_tagVChi2IP);
216  ver->setVertexFitParticles(m_raveParticles);
217  ver->setVertexFitMCParticles(m_raveMCParticles);
218  ver->setRaveWeights(m_raveWeights);
219  ver->setConstraintType(m_constraintType);
220  ver->setConstraintCenter(m_constraintCenter);
221  ver->setConstraintCov(m_constraintCov);
222  ver->setFitTruthStatus(m_fitTruthStatus);
223  ver->setRollBackStatus(m_rollbackStatus);
224  } else {
225  ver->setTagVertex(m_tagV);
226  ver->setTagVertexPval(-1.);
227  ver->setDeltaT(m_deltaT);
228  ver->setDeltaTErr(m_deltaTErr);
229  ver->setMCTagVertex(m_mcTagV);
230  ver->setMCTagBFlavor(0.);
231  ver->setMCDeltaTau(m_mcDeltaTau);
232  ver->setMCDeltaT(m_mcDeltaT);
233  ver->setFitType(m_FitType);
234  ver->setNTracks(m_tagParticles.size());
235  ver->setTagVl(m_tagVl);
236  ver->setTruthTagVl(m_truthTagVl);
237  ver->setTagVlErr(m_tagVlErr);
238  ver->setTagVol(m_tagVol);
239  ver->setTruthTagVol(m_truthTagVol);
240  ver->setTagVolErr(m_tagVolErr);
241  ver->setTagVNDF(-1111.);
242  ver->setTagVChi2(-1111.);
243  ver->setTagVChi2IP(-1111.);
244  ver->setVertexFitParticles(m_raveParticles);
245  ver->setVertexFitMCParticles(m_raveMCParticles);
246  ver->setRaveWeights(m_raveWeights);
247  ver->setConstraintType(m_constraintType);
248  ver->setConstraintCenter(m_constraintCenter);
249  ver->setConstraintCov(m_constraintCov);
250  ver->setFitTruthStatus(m_fitTruthStatus);
251  ver->setRollBackStatus(m_rollbackStatus);
252  }
253  }
254  }
255  plist->removeParticles(toRemove);
256 
257  //free memory allocated by rave. initialize() would be enough, except that we must clean things up before program end...
258  //
259  analysis::RaveSetup::getInstance()->reset();
260  }
261 
262  bool TagVertexModule::doVertexFit(const Particle* Breco)
263  {
264  //reset the fit truth status in case it was set to 2 in a previous fit
265 
266  if (m_useTruthInFit) m_fitTruthStatus = 1;
267 
268  //reset the roll back status in case it was set to 2 in a previous fit
269 
270  if (m_useRollBack) m_rollbackStatus = 1;
271 
272  //set constraint type, reset pVal and B field
273 
274  m_fitPval = 1;
275 
276  if (!(Breco->getRelatedTo<RestOfEvent>())) {
277  m_FitType = -1;
278  return false;
279  }
280 
281  if (m_Bfield == 0) {
282  B2ERROR("TagVertex: No magnetic field");
283  return false;
284  }
285 
286  // recover beam spot info
287 
288  m_BeamSpotCenter = m_beamSpotDB->getIPPosition();
289  m_BeamSpotCov.ResizeTo(3, 3);
290  m_BeamSpotCov = m_beamSpotDB->getCovVertex();
291 
292  //make the beam spot bigger for the standard constraint
293 
294  double beta = PCmsLabTransform().getBoostVector().Mag();
295  double bg = beta / sqrt(1 - beta * beta);
296 
297  //TODO: What's the origin of these numbers?
298  double cut = 8.717575e-02 * bg;
299  m_shiftZ = 4.184436e+02 * bg * 0.0001;
300 
301  //tube length here set to 20 * 2 * c tau beta gamma ~= 0.5 cm, should be enough to not bias the decay
302  //time but should still help getting rid of some pions from kshorts
303  m_constraintCov.ResizeTo(3, 3);
304  if (m_constraintType == "IP") tie(m_constraintCenter, m_constraintCov) = findConstraintBoost(cut);
305  else if (m_constraintType == "tube") tie(m_constraintCenter, m_constraintCov) = findConstraintBTube(Breco, 1000 * cut);
306  else if (m_constraintType == "boost") tie(m_constraintCenter, m_constraintCov) = findConstraintBoost(cut * 200000.);
307  else if (m_constraintType == "breco") tie(m_constraintCenter, m_constraintCov) = findConstraint(Breco, cut * 2000.);
308  else if (m_constraintType == "noConstraint") m_constraintCenter = TVector3(); //zero vector
309  else {
310  B2ERROR("TagVertex: Invalid constraintType selected");
311  return false;
312  }
313 
314  if (m_constraintCenter == vecNaN) {
315  B2ERROR("TagVertex: No correct fit constraint");
316  return false;
317  }
318 
319  /* Depending on the user's choice, one of the possible algorithms is chosen for the fit. In case the algorithm does not converge, in order to assure
320  high efficiency, the next algorithm less restrictive is used. I.e, if standard_PXD does not work, the program tries with standard.
321  */
322 
323  m_FitType = 0;
324  double minPVal = (m_fitAlgo != "KFit") ? 0.001 : 0.;
325  bool ok = false;
326 
327  if (m_trackFindingType == "standard_PXD") {
328  m_tagParticles = getTagTracks_standardAlgorithm(Breco, 1);
329  if (m_tagParticles.size() > 0) {
330  ok = makeGeneralFit();
331  m_FitType = 3;
332  }
333  }
334 
335  if (ok == false || m_fitPval < minPVal || m_trackFindingType == "standard") {
336  m_tagParticles = getTagTracks_standardAlgorithm(Breco, m_reqPXDHits);
337  ok = m_tagParticles.size() > 0;
338  if (ok) {
339  ok = makeGeneralFit();
340  m_FitType = 4;
341  }
342  }
343 
344  if ((ok == false || (m_fitPval <= 0. && m_fitAlgo == "Rave")) && m_constraintType != "noConstraint") {
345  tie(m_constraintCenter, m_constraintCov) = findConstraintBoost(cut * 200000.);
346  ok = (m_constraintCenter != vecNaN);
347  if (ok) {
348  m_tagParticles = getTagTracks_standardAlgorithm(Breco, m_reqPXDHits);
349  ok = (m_tagParticles.size() > 0);
350  }
351  if (ok) {
352  ok = makeGeneralFit();
353  m_FitType = 5;
354  }
355  }
356 
357  return ok;
358  }
359 
360 
361  // get vector which is oposite to vIn in CMS ref frame
362  // Be aware that input vIn and output are in the Lab frame
363  static TLorentzVector flipVector(TLorentzVector vIn)
364  {
365  TLorentzVector vCMS = PCmsLabTransform::labToCms(vIn);
366  vCMS.SetVect(-vCMS.Vect());
367  return PCmsLabTransform::cmsToLab(vCMS);
368  }
369 
370 
371  pair<TVector3, TMatrixDSym> TagVertexModule::findConstraint(const Particle* Breco, double cut) const
372  {
373  if (Breco->getPValue() < 0.) return make_pair(vecNaN, matNaN);
374 
375  TMatrixDSym beamSpotCov(3);
376  beamSpotCov = m_beamSpotDB->getCovVertex();
377 
378  analysis::RaveSetup::getInstance()->setBeamSpot(m_BeamSpotCenter, beamSpotCov);
379 
380  double pmag = Breco->getMomentumMagnitude();
381  double xmag = (Breco->getVertex() - m_BeamSpotCenter).Mag();
382 
383 
384  TMatrixDSym TerrMatrix = Breco->getMomentumVertexErrorMatrix();
385  TMatrixDSym PerrMatrix(7);
386 
387  for (int i = 0; i < 3; ++i) {
388  for (int j = 0; j < 3; ++j) {
389  if (i == j) {
390  PerrMatrix(i, j) = (beamSpotCov(i, j) + TerrMatrix(i, j)) * pmag / xmag;
391  } else {
392  PerrMatrix(i, j) = TerrMatrix(i, j);
393  }
394  PerrMatrix(i + 4, j + 4) = TerrMatrix(i + 4, j + 4);
395  }
396  }
397 
398  PerrMatrix(3, 3) = 0.;
399 
400  //Copy Breco, but use errors as are in PerrMatrix
401  Particle* Breco2 = ParticleCopy::copyParticle(Breco);
402  Breco2->setMomentumVertexErrorMatrix(PerrMatrix);
403 
404 
405  const Particle* BRecoRes = doVertexFitForBTube(Breco2, "kalman");
406  if (BRecoRes->getPValue() < 0) return make_pair(vecNaN, matNaN); //problems
407 
408  // Overall error matrix
409  TMatrixDSym errFinal = TMatrixDSym(Breco->getVertexErrorMatrix() + BRecoRes->getVertexErrorMatrix());
410 
411  // TODO : to be developed the extraction of the momentum from the rave fitted track
412 
413  // Get expected pBtag 4-momentum using transverse-momentum conservation
414  TVector3 BvertDiff = Breco->getVertex() - BRecoRes->getVertex();
415  TLorentzVector pBrecEstimate(pmag / BvertDiff.Mag() * BvertDiff, Breco->getPDGMass());
416  TLorentzVector pBtagEstimate = flipVector(pBrecEstimate);
417 
418  // rotate err-matrix such that pBrecEstimate goes to eZ
419  TMatrixD TubeZ = rotateTensorInv(pBrecEstimate.Vect(), errFinal);
420 
421  TubeZ(2, 2) = cut * cut;
422  TubeZ(2, 0) = 0; TubeZ(0, 2) = 0;
423  TubeZ(2, 1) = 0; TubeZ(1, 2) = 0;
424 
425 
426  // rotate err-matrix such that eZ goes to pBtagEstimate
427  TMatrixD Tube = rotateTensor(pBtagEstimate.Vect(), TubeZ);
428 
429  // Standard algorithm needs no shift
430  return make_pair(m_BeamSpotCenter, toSymMatrix(Tube));
431  }
432 
433  pair<TVector3, TMatrixDSym> TagVertexModule::findConstraintBTube(const Particle* Breco, double cut)
434  {
435  //Use Breco as the creator of the B tube.
436  if ((Breco->getVertexErrorMatrix()(2, 2)) == 0.0) {
437  B2WARNING("In TagVertexModule::findConstraintBTube: cannot get a proper vertex for BReco. BTube constraint replaced by Boost.");
438  return findConstraintBoost(cut);
439  }
440 
441 
442  //vertex fit will give the intersection between the beam spot and the trajectory of the B
443  //(base of the BTube, or primary vtx cov matrix)
444  const Particle* tubecreatorBCopy = doVertexFitForBTube(Breco, "avf");
445  if (tubecreatorBCopy->getPValue() < 0) return make_pair(vecNaN, matNaN); //if problems
446 
447 
448  //get direction of B tag = opposite direction of B rec in CMF
449  TLorentzVector pBrec = tubecreatorBCopy->get4Vector();
450 
451  //if we want the true info, replace the 4vector by the true one
452  if (m_useTruthInFit) {
453  const MCParticle* mcBr = Breco->getRelated<MCParticle>();
454  if (mcBr)
455  pBrec = mcBr->get4Vector();
456  else
457  m_fitTruthStatus = 2;
458  }
459  TLorentzVector pBtag = flipVector(pBrec);
460 
461  //To create the B tube, strategy is: take the primary vtx cov matrix, and add to it a cov
462  //matrix corresponding to an very big error in the direction of the B tag
463  TMatrixDSym pv = tubecreatorBCopy->getVertexErrorMatrix();
464 
465  //print some stuff if wanted
466  if (m_verbose) {
467  B2DEBUG(10, "Brec decay vertex before fit: " << printVector(Breco->getVertex()));
468  B2DEBUG(10, "Brec decay vertex after fit: " << printVector(tubecreatorBCopy->getVertex()));
469  B2DEBUG(10, "Brec direction before fit: " << printVector((1. / Breco->getP()) * Breco->getMomentum()));
470  B2DEBUG(10, "Brec direction after fit: " << printVector((1. / tubecreatorBCopy->getP()) * tubecreatorBCopy->getMomentum()));
471  B2DEBUG(10, "IP position: " << printVector(m_BeamSpotCenter));
472  B2DEBUG(10, "IP covariance: " << printMatrix(m_BeamSpotCov));
473  B2DEBUG(10, "Brec primary vertex: " << printVector(tubecreatorBCopy->getVertex()));
474  B2DEBUG(10, "Brec PV covariance: " << printMatrix(pv));
475  B2DEBUG(10, "BTag direction: " << printVector((1. / pBtag.P())*pBtag.Vect()));
476  }
477 
478  //make a long error matrix along BTag direction
479  TMatrixD longerror(3, 3); longerror(2, 2) = cut * cut;
480 
481 
482  // make rotation matrix from z axis to BTag line of flight
483  TMatrixD longerrorRotated = rotateTensor(pBtag.Vect(), longerror);
484 
485  //pvNew will correspond to the covariance matrix of the B tube
486  TMatrixD pvNew = TMatrixD(pv) + longerrorRotated;
487 
488  //set the constraint
489  TVector3 constraintCenter = tubecreatorBCopy->getVertex();
490 
491  //if we want the true info, set the centre of the constraint to the primary vertex
492  if (m_useTruthInFit) {
493  const MCParticle* mcBr = Breco->getRelated<MCParticle>();
494  if (mcBr) {
495  constraintCenter = mcBr->getProductionVertex();
496  }
497  }
498 
499  if (m_verbose) {
500  B2DEBUG(10, "IPTube covariance: " << printMatrix(pvNew));
501  }
502 
503  //The following is done to do the BTube constraint with a virtual track
504  //(ie KFit way)
505 
506  m_tagMomentum = pBtag;
507 
508  m_pvCov.ResizeTo(pv);
509  m_pvCov = pv;
510 
511  return make_pair(constraintCenter, toSymMatrix(pvNew));
512  }
513 
514  pair<TVector3, TMatrixDSym> TagVertexModule::findConstraintBoost(double cut, double shiftAlongBoost) const
515  {
516  //make a long error matrix along boost direction
517  TMatrixD longerror(3, 3); longerror(2, 2) = cut * cut;
518  TVector3 boostDir = PCmsLabTransform().getBoostVector().Unit();
519  TMatrixD longerrorRotated = rotateTensor(boostDir, longerror);
520 
521  //Extend error of BeamSpotCov matrix in the boost direction
522  TMatrixDSym beamSpotCov = m_beamSpotDB->getCovVertex();
523  TMatrixD Tube = TMatrixD(beamSpotCov) + longerrorRotated;
524 
525  // Standard algorithm needs no shift
526  TVector3 constraintCenter = m_BeamSpotCenter;
527 
528  // The constraint used in the Single Track Fit needs to be shifted in the boost direction.
529  if (shiftAlongBoost > -1000) {
530  constraintCenter += shiftAlongBoost * boostDir;
531  }
532 
533  return make_pair(constraintCenter, toSymMatrix(Tube));
534  }
535 
537  static double getProperLifeTime(const MCParticle* mc)
538  {
539  double beta = mc->getMomentum().Mag() / mc->getEnergy();
540  return 1e3 * mc->getLifetime() * sqrt(1 - pow(beta, 2));
541  }
542 
543  void TagVertexModule::BtagMCVertex(const Particle* Breco)
544  {
545  //fill vector with mcB (intended order: Reco, Tag)
546  StoreArray<Belle2::MCParticle> mcParticles("");
547  vector<const MCParticle*> mcBs;
548  for (const MCParticle& mc : mcParticles) {
549  if (abs(mc.getPDG()) == abs(Breco->getPDGCode()))
550  mcBs.push_back(&mc);
551  }
552  //too few Bs
553  if (mcBs.size() < 2) return;
554 
555  if (mcBs.size() > 2) {
556  B2WARNING("TagVertexModule:: Too many Bs found in MC");
557  }
558 
559  auto isReco = [&](const MCParticle * mc) {
560  return (m_useMCassociation == "breco") ? (mc == Breco->getRelated<MCParticle>())
561  : compBrecoBgen(Breco, mc); //internal association
562  };
563 
564  //nothing matched?
565  if (!isReco(mcBs[0]) && !isReco(mcBs[1])) {
566  return;
567  }
568 
569  //first is Tag, second Reco -> swap the order
570  if (!isReco(mcBs[0]) && isReco(mcBs[1]))
571  swap(mcBs[0], mcBs[1]);
572 
573  //both matched -> use closest vertex dist as Reco
574  if (isReco(mcBs[0]) && isReco(mcBs[1])) {
575  double dist0 = (mcBs[0]->getDecayVertex() - Breco->getVertex()).Mag2();
576  double dist1 = (mcBs[1]->getDecayVertex() - Breco->getVertex()).Mag2();
577  if (dist0 > dist1)
578  swap(mcBs[0], mcBs[1]);
579  }
580 
581  m_mcVertReco = mcBs[0]->getDecayVertex();
582  m_mcLifeTimeReco = getProperLifeTime(mcBs[0]);
583  m_mcTagV = mcBs[1]->getDecayVertex();
584  m_mcTagLifeTime = getProperLifeTime(mcBs[1]);
585  m_mcPDG = mcBs[1]->getPDG();
586  }
587 
588  // static
589  bool TagVertexModule::compBrecoBgen(const Particle* Breco, const MCParticle* Bgen)
590  {
591 
592  bool isDecMode = true;
593 
594  const std::vector<Belle2::Particle*> recDau = Breco->getDaughters();
595  const std::vector<Belle2::MCParticle*> genDau = Bgen->getDaughters();
596 
597  if (recDau.size() > 0 && genDau.size() > 0) {
598  for (auto dauRec : recDau) {
599  bool isDau = false;
600  for (auto dauGen : genDau) {
601  if (dauGen->getPDG() == dauRec->getPDGCode())
602  isDau = compBrecoBgen(dauRec, dauGen) ;
603  }
604  if (!isDau) isDecMode = false;
605  }
606  } else {
607  if (recDau.size() == 0) { //&& genDau.size()==0){
608  if (Bgen->getPDG() != Breco->getPDGCode()) isDecMode = false;;
609  } else {isDecMode = false;}
610  }
611 
612  return isDecMode;
613  }
614 
615  // STANDARD FIT ALGORITHM
616  /* This algorithm basically takes all the tracks coming from the Rest Of Events and send them to perform a multi-track fit
617  The option to request PXD hits for the tracks can be chosen by the user.
618  */
619  std::vector<const Particle*> TagVertexModule::getTagTracks_standardAlgorithm(const Particle* Breco, int reqPXDHits) const
620  {
621  std::vector<const Particle*> fitParticles;
622  const RestOfEvent* roe = Breco->getRelatedTo<RestOfEvent>();
623  if (!roe) return fitParticles;
624  //load all particles from the ROE
625  std::vector<const Particle*> ROEParticles = roe->getChargedParticles(m_roeMaskName, 0 , false);
626  if (ROEParticles.size() == 0) return fitParticles;
627 
628  for (auto& ROEParticle : ROEParticles) {
629  HitPatternVXD roeTrackPattern = ROEParticle->getTrackFitResult()->getHitPatternVXD();
630 
631  if (roeTrackPattern.getNPXDHits() >= reqPXDHits) {
632  fitParticles.push_back(ROEParticle);
633  }
634  }
635  return fitParticles;
636  }
637 
638  vector<ParticleAndWeight> TagVertexModule::getParticlesWithoutKS(const vector<const Particle*>& tagParticles,
639  double massWindowWidth) const
640  {
641  vector<ParticleAndWeight> particleAndWeights;
642 
643  ParticleAndWeight particleAndWeight;
644  particleAndWeight.mcParticle = 0;
645  particleAndWeight.weight = -1111.;
646 
647  // remove tracks from KS
648  for (unsigned i = 0; i < tagParticles.size(); ++i) {
649  const Particle* particle1 = tagParticles.at(i);
650  if (!particle1) continue;
651  TLorentzVector mom1 = particle1->get4Vector();
652  if (!isfinite(mom1.Mag2())) continue;
653 
654  //is from Ks decay?
655  bool isKsDau = false;
656  for (unsigned j = 0; j < tagParticles.size(); ++j) {
657  if (i == j) continue;
658  const Particle* particle2 = tagParticles.at(j);
659  if (!particle2) continue;
660  TLorentzVector mom2 = particle2->get4Vector();
661  if (!isfinite(mom2.Mag2())) continue;
662  double mass = (mom1 + mom2).M();
663  if (abs(mass - Const::K0Mass) < massWindowWidth) {
664  isKsDau = true;
665  break;
666  }
667  }
668  //if from Ks decay, skip
669  if (isKsDau) continue;
670 
671  particleAndWeight.particle = particle1;
672 
673  if (m_useMCassociation == "breco" || m_useMCassociation == "internal")
674  particleAndWeight.mcParticle = particle1->getRelatedTo<MCParticle>();
675 
676  particleAndWeights.push_back(particleAndWeight);
677 
678  }
679 
680  return particleAndWeights;
681  }
682 
683  bool TagVertexModule::makeGeneralFit()
684  {
685  if (m_fitAlgo == "Rave") return makeGeneralFitRave();
686  else if (m_fitAlgo == "KFit") return makeGeneralFitKFit();
687  return false;
688  }
689 
690  void TagVertexModule::fillParticles(vector<ParticleAndWeight>& particleAndWeights)
691  {
692  unsigned n = particleAndWeights.size();
693  sort(particleAndWeights.begin(), particleAndWeights.end(),
694  [](const ParticleAndWeight & a, const ParticleAndWeight & b) { return a.weight > b.weight; });
695 
696  m_raveParticles.resize(n);
697  m_raveWeights.resize(n);
698  m_raveMCParticles.resize(n);
699 
700  for (unsigned i = 0; i < n; ++i) {
701  m_raveParticles.at(i) = particleAndWeights.at(i).particle;
702  m_raveMCParticles.at(i) = particleAndWeights.at(i).mcParticle;
703  m_raveWeights.at(i) = particleAndWeights.at(i).weight;
704  }
705  }
706 
707  void TagVertexModule::fillTagVinfo(const TVector3& tagVpos, const TMatrixDSym& tagVposErr)
708  {
709  m_tagV = tagVpos;
710 
711  if (m_constraintType != "noConstraint") {
712  TMatrixDSym tubeInv = m_constraintCov;
713  tubeInv.Invert();
714  TVectorD dV = toVec(m_tagV - m_BeamSpotCenter);
715  m_tagVChi2IP = tubeInv.Similarity(dV);
716  }
717 
718  m_tagVErrMatrix.ResizeTo(tagVposErr);
719  m_tagVErrMatrix = tagVposErr;
720  }
721 
722  bool TagVertexModule::makeGeneralFitRave()
723  {
724  // apply constraint
725  analysis::RaveSetup::getInstance()->unsetBeamSpot();
726  if (m_constraintType != "noConstraint")
727  analysis::RaveSetup::getInstance()->setBeamSpot(m_constraintCenter, m_constraintCov);
729 
730  //feed rave with tracks without Kshorts
731  vector<ParticleAndWeight> particleAndWeights = getParticlesWithoutKS(m_tagParticles);
732 
733  for (const auto& pw : particleAndWeights) {
734  try {
735  if (m_useTruthInFit) {
736  if (pw.mcParticle) {
737  TrackFitResult tfr(getTrackWithTrueCoordinates(pw));
738  rFit.addTrack(&tfr);
739  } else
740  m_fitTruthStatus = 2;
741  } else if (m_useRollBack) {
742  if (pw.mcParticle) {
743  TrackFitResult tfr(getTrackWithRollBackCoordinates(pw));
744  rFit.addTrack(&tfr);
745  } else
746  m_rollbackStatus = 2;
747  } else {
748  rFit.addTrack(pw.particle->getTrackFitResult());
749  }
750  } catch (const rave::CheckedFloatException&) {
751  B2ERROR("Exception caught in TagVertexModule::makeGeneralFitRave(): Invalid inputs (nan/inf)?");
752  }
753  }
754 
755  //perform fit
756 
757  int isGoodFit(-1);
758 
759  try {
760  isGoodFit = rFit.fit("avf");
761  // if problems
762  if (isGoodFit < 1) return false;
763  } catch (const rave::CheckedFloatException&) {
764  B2ERROR("Exception caught in TagVertexModule::makeGeneralFitRave(): Invalid inputs (nan/inf)?");
765  return false;
766  }
767 
768  //save the track info for later use
769 
770  for (unsigned int i(0); i < particleAndWeights.size() && isGoodFit >= 1; ++i)
771  particleAndWeights.at(i).weight = rFit.getWeight(i);
772 
773  //Tracks are sorted from highest rave weight to lowest
774 
775  fillParticles(particleAndWeights);
776 
777  //if the fit is good, save the infos related to the vertex
778  fillTagVinfo(rFit.getPos(0), rFit.getCov(0));
779 
780  //fill quality variables
781  m_tagVNDF = rFit.getNdf(0);
782  m_tagVChi2 = rFit.getChi2(0);
783  m_fitPval = rFit.getPValue();
784 
785  return true;
786  }
787 
788  bool TagVertexModule::makeGeneralFitKFit()
789  {
790  //initialize KFit
792  kFit.setMagneticField(m_Bfield);
793 
794  // apply constraint
795  if (m_constraintType != "noConstraint") {
796  if (m_constraintType == "tube") {
797  CLHEP::HepSymMatrix err(7, 0);
798  //copy m_pvCov to the end of err matrix
799  err.sub(5, ROOTToCLHEP::getHepSymMatrix(m_pvCov));
800  kFit.setIpTubeProfile(
801  ROOTToCLHEP::getHepLorentzVector(m_tagMomentum),
802  ROOTToCLHEP::getPoint3D(m_constraintCenter),
803  err,
804  0.);
805  } else {
806  kFit.setIpProfile(ROOTToCLHEP::getPoint3D(m_constraintCenter),
807  ROOTToCLHEP::getHepSymMatrix(m_constraintCov));
808  }
809  }
810 
811  //feed KFit with tracks without Kshorts
812  vector<ParticleAndWeight> particleAndWeights = getParticlesWithoutKS(m_tagParticles);
813 
814  int nTracksAdded = 0;
815  for (auto& pawi : particleAndWeights) {
816  int addedOK = 1;
817  if (m_useTruthInFit) {
818  if (pawi.mcParticle) {
819  addedOK = kFit.addTrack(
820  ROOTToCLHEP::getHepLorentzVector(pawi.mcParticle->get4Vector()),
821  ROOTToCLHEP::getPoint3D(getTruePoca(pawi)),
822  ROOTToCLHEP::getHepSymMatrix(pawi.particle->getMomentumVertexErrorMatrix()),
823  pawi.particle->getCharge());
824  } else {
825  m_fitTruthStatus = 2;
826  }
827  } else if (m_useRollBack) {
828  if (pawi.mcParticle) {
829  addedOK = kFit.addTrack(
830  ROOTToCLHEP::getHepLorentzVector(pawi.mcParticle->get4Vector()),
831  ROOTToCLHEP::getPoint3D(getRollBackPoca(pawi)),
832  ROOTToCLHEP::getHepSymMatrix(pawi.particle->getMomentumVertexErrorMatrix()),
833  pawi.particle->getCharge());
834  } else {
835  m_rollbackStatus = 2;
836  }
837  } else {
838  addedOK = kFit.addParticle(pawi.particle);
839  }
840 
841  if (addedOK == 0) {
842  ++nTracksAdded;
843  pawi.weight = 1.;
844  } else {
845  B2WARNING("TagVertexModule::makeGeneralFitKFit: failed to add a track");
846  pawi.weight = 0.;
847  }
848  }
849 
850  //perform fit if there are enough tracks
851  if ((nTracksAdded < 2 && m_constraintType == "noConstraint") || nTracksAdded < 1)
852  return false;
853 
854  int isGoodFit = kFit.doFit();
855  if (isGoodFit != 0) return false;
856 
857  //save the track info for later use
858  //Tracks are sorted by weight, ie pushing the tracks with 0 weight (from KS) to the end of the list
859  fillParticles(particleAndWeights);
860 
861  //Save the infos related to the vertex
862  fillTagVinfo(CLHEPToROOT::getTVector3(kFit.getVertex()),
863  CLHEPToROOT::getTMatrixDSym(kFit.getVertexError()));
864 
865  m_tagVNDF = kFit.getNDF();
866  m_tagVChi2 = kFit.getCHIsq();
867  m_fitPval = TMath::Prob(m_tagVChi2, m_tagVNDF);
868 
869  return true;
870  }
871 
872  void TagVertexModule::deltaT(const Particle* Breco)
873  {
874 
875  TVector3 boost = PCmsLabTransform().getBoostVector();
876  TVector3 boostDir = boost.Unit();
877  double bg = boost.Mag() / sqrt(1 - boost.Mag2());
878  double c = Const::speedOfLight / 1000.; // cm ps-1
879 
880  //Reconstructed DeltaL & DeltaT in the boost direction
881  TVector3 dVert = Breco->getVertex() - m_tagV; //reconstructed vtxReco - vtxTag
882  double dl = dVert.Dot(boostDir);
883  m_deltaT = dl / (bg * c);
884 
885  //Truth DeltaL & approx DeltaT in the boost direction
886  TVector3 MCdVert = m_mcVertReco - m_mcTagV; //truth vtxReco - vtxTag
887  double MCdl = MCdVert.Dot(boostDir);
888  m_mcDeltaT = MCdl / (bg * c);
889 
890  // MCdeltaTau=tauRec-tauTag
891  m_mcDeltaTau = m_mcLifeTimeReco - m_mcTagLifeTime;
892  if (m_mcLifeTimeReco == -1 || m_mcTagLifeTime == -1)
893  m_mcDeltaTau = realNaN;
894 
895  TVectorD bVec = toVec(boostDir);
896 
897  //TagVertex error in boost dir
898  m_tagVlErr = sqrt(m_tagVErrMatrix.Similarity(bVec));
899 
900  //bReco error in boost dir
901  double bRecoErrL = sqrt(Breco->getVertexErrorMatrix().Similarity(bVec));
902 
903  //Delta t error
904  m_deltaTErr = hypot(m_tagVlErr, bRecoErrL) / (bg * c);
905 
906  m_tagVl = m_tagV.Dot(boostDir);
907  m_truthTagVl = m_mcTagV.Dot(boostDir);
908 
909  // calculate tagV component and error in the direction orthogonal to the boost
910  TVector3 oboost = getUnitOrthogonal(boostDir);
911  TVectorD oVec = toVec(oboost);
912 
913  //TagVertex error in boost-orthogonal dir
914  m_tagVolErr = sqrt(m_tagVErrMatrix.Similarity(oVec));
915 
916  m_tagVol = m_tagV.Dot(oboost);
917  m_truthTagVol = m_mcTagV.Dot(oboost);
918  }
919 
920  Particle* TagVertexModule::doVertexFitForBTube(const Particle* motherIn, std::string fitType) const
921  {
922  //make a copy of motherIn to not modify the original object
923  Particle* mother = ParticleCopy::copyParticle(motherIn);
924 
925  //Here rave is used to find the upsilon(4S) vtx as the intersection
926  //between the mother B trajectory and the beam spot
927  analysis::RaveSetup::getInstance()->setBeamSpot(m_BeamSpotCenter, m_BeamSpotCov);
928 
930  rsg.addTrack(mother);
931  int nvert = rsg.fit(fitType);
932  if (nvert != 1) {
933  mother->setPValue(-1); //error
934  return mother;
935  } else {
936  rsg.updateDaughters();
937  return mother;
938  }
939  }
940 
941 
942 
943  TrackFitResult TagVertexModule::getTrackWithTrueCoordinates(ParticleAndWeight const& paw) const
944  {
945  if (!paw.mcParticle) {
946  B2ERROR("In TagVertexModule::getTrackWithTrueCoordinate: no MC particle set");
947  return TrackFitResult();
948  }
949 
950  const TrackFitResult* tfr(paw.particle->getTrackFitResult());
951 
952  return TrackFitResult(getTruePoca(paw),
953  paw.mcParticle->getMomentum(),
954  tfr->getCovariance6(),
955  tfr->getChargeSign(),
956  tfr->getParticleType(),
957  tfr->getPValue(),
958  m_Bfield, 0, 0, tfr->getNDF());
959  }
960 
961  // static
962  TVector3 TagVertexModule::getTruePoca(ParticleAndWeight const& paw)
963  {
964  if (!paw.mcParticle) {
965  B2ERROR("In TagVertexModule::getTruePoca: no MC particle set");
966  return TVector3(0., 0., 0.);
967  }
968 
969  return DistanceTools::poca(paw.mcParticle->getProductionVertex(),
970  paw.mcParticle->getMomentum(),
972  }
973 
974  TrackFitResult TagVertexModule::getTrackWithRollBackCoordinates(ParticleAndWeight const& paw)
975  {
976  const TrackFitResult* tfr(paw.particle->getTrackFitResult());
977 
978  return TrackFitResult(getRollBackPoca(paw),
979  tfr->getMomentum(),
980  tfr->getCovariance6(),
981  tfr->getChargeSign(),
982  tfr->getParticleType(),
983  tfr->getPValue(),
984  m_Bfield, 0, 0, tfr->getNDF());
985  }
986 
987  TVector3 TagVertexModule::getRollBackPoca(ParticleAndWeight const& paw)
988  {
989  if (!paw.mcParticle) {
990  B2ERROR("In TagVertexModule::getTruePoca: no MC particle set");
991  return TVector3(0., 0., 0.);
992  }
993 
994  return paw.particle->getTrackFitResult()->getPosition() - paw.mcParticle->getProductionVertex() + m_mcTagV;
995  }
996 
997  void TagVertexModule::resetReturnParams()
998  {
999  m_raveParticles.resize(0);
1000  m_raveMCParticles.resize(0);
1001  m_tagParticles.resize(0);
1002  m_raveWeights.resize(0);
1003 
1004  m_fitPval = realNaN;
1005  m_tagV = vecNaN;
1006  m_tagVErrMatrix.ResizeTo(matNaN);
1007  m_tagVErrMatrix = matNaN;
1008  m_mcTagV = vecNaN;
1009  m_mcVertReco = vecNaN;
1010  m_deltaT = realNaN;
1011  m_deltaTErr = realNaN;
1012  m_mcDeltaTau = realNaN;
1013  m_constraintCov.ResizeTo(matNaN);
1014  m_constraintCov = matNaN;
1015  m_constraintCenter = vecNaN;
1016  m_tagVl = realNaN;
1017  m_truthTagVl = realNaN;
1018  m_tagVlErr = realNaN;
1019  m_tagVol = realNaN;
1020  m_truthTagVol = realNaN;
1021  m_tagVolErr = realNaN;
1022  m_tagVNDF = realNaN;
1023  m_tagVChi2 = realNaN;
1024  m_tagVChi2IP = realNaN;
1025  m_pvCov.ResizeTo(matNaN);
1026  m_pvCov = matNaN;
1027  m_tagMomentum = TLorentzVector(vecNaN, realNaN);
1028  }
1029 
1030  //The following functions are just here to help printing stuff
1031 
1032  // static
1033  std::string TagVertexModule::printVector(const TVector3& vec)
1034  {
1035  std::ostringstream oss;
1036  int w = 14;
1037  oss << "(" << std::setw(w) << vec[0] << ", " << std::setw(w) << vec[1] << ", " << std::setw(w) << vec[2] << ")" << std::endl;
1038  return oss.str();
1039  }
1040 
1041  // static
1042  std::string TagVertexModule::printMatrix(const TMatrixD& mat)
1043  {
1044  std::ostringstream oss;
1045  int w = 14;
1046  for (int i = 0; i < mat.GetNrows(); ++i) {
1047  for (int j = 0; j < mat.GetNcols(); ++j) {
1048  oss << std::setw(w) << mat(i, j) << " ";
1049  }
1050  oss << endl;
1051  }
1052  return oss.str();
1053  }
1054 
1055  // static
1056  std::string TagVertexModule::printMatrix(const TMatrixDSym& mat)
1057  {
1058  std::ostringstream oss;
1059  int w = 14;
1060  for (int i = 0; i < mat.GetNrows(); ++i) {
1061  for (int j = 0; j < mat.GetNcols(); ++j) {
1062  oss << std::setw(w) << mat(i, j) << " ";
1063  }
1064  oss << endl;
1065  }
1066  return oss.str();
1067  }
1069 } // end Belle2 namespace
Belle2::StoreArray::appendNew
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:256
Belle2::TrackFitResult::getNDF
int getNDF() const
Getter for number of degrees of freedom of the track fit.
Definition: TrackFitResult.cc:85
Belle2::TagVertex::setTagVol
void setTagVol(float TagVol)
Set the tagV component in the direction orthogonal to the boost.
Definition: TagVertex.cc:270
Belle2::Particle::getPDGCode
int getPDGCode(void) const
Returns PDG code.
Definition: Particle.h:380
Belle2::TagVertex::setRaveWeights
void setRaveWeights(const std::vector< double > &raveWeights)
Set the weights used by Rave in the tag vtx fit.
Definition: TagVertex.cc:311
Belle2::TagVertex::setTagVl
void setTagVl(float TagVl)
Set the tagV component in the boost direction.
Definition: TagVertex.cc:255
Belle2::TagVertex::setVertexFitMCParticles
void setVertexFitMCParticles(const std::vector< const MCParticle * > &vtxFitMCParticles)
Set a vector of pointers to the MC p'cles corresponding to the tracks in the tag vtx fit.
Definition: TagVertex.cc:306
Belle2::TagVertex::setFitTruthStatus
void setFitTruthStatus(int truthStatus)
Set the status of the fit performed with the truth info of the tracks.
Definition: TagVertex.cc:346
Belle2::HitPatternVXD::getNPXDHits
unsigned short getNPXDHits() const
Get total number of hits in the PXD.
Definition: HitPatternVXD.cc:147
Belle2::analysis::RaveVertexFitter::getPValue
double getPValue(VecSize vertexId=0) const
get the p value of the fitted vertex.
Definition: RaveVertexFitter.cc:206
Belle2::Particle::getTrackFitResult
const TrackFitResult * getTrackFitResult() const
Returns the pointer to the TrackFitResult that was used to create this Particle (ParticleType == c_Tr...
Definition: Particle.cc:779
Belle2::Particle::getVertex
TVector3 getVertex() const
Returns vertex position (POCA for charged, IP for neutral FS particles)
Definition: Particle.h:529
Belle2::analysis::RaveVertexFitter::getPos
TVector3 getPos(VecSize vertexId=0) const
get the position of the fitted vertex.
Definition: RaveVertexFitter.cc:169
Belle2::TrackFitResult::getMomentum
TVector3 getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
Definition: TrackFitResult.h:116
Belle2::ParticleAndWeight::weight
double weight
rave weight associated to the track, for sorting purposes
Definition: TagVertexModule.h:284
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::TagVertex::setTagVolErr
void setTagVolErr(float TagVolErr)
Set the error of the tagV component in the direction orthogonal to the boost.
Definition: TagVertex.cc:280
Belle2::ParticleAndWeight::mcParticle
const MCParticle * mcParticle
mc particle matched to the tag track, for sorting purposes
Definition: TagVertexModule.h:286
Belle2::TrackFitResult::getPValue
double getPValue() const
Getter for Chi2 Probability of the track fit.
Definition: TrackFitResult.h:163
Belle2::TagVertex::setTagVertexPval
void setTagVertexPval(float TagVertexPval)
Set BTag Vertex P value.
Definition: TagVertex.cc:210
Belle2::TagVertex::setMCTagBFlavor
void setMCTagBFlavor(int mcTagBFlavor)
Set generated Btag PDG code.
Definition: TagVertex.cc:230
Belle2::TagVertex::setFitType
void setFitType(float FitType)
Set fit algo type.
Definition: TagVertex.cc:245
Belle2::getProperLifeTime
static double getProperLifeTime(const MCParticle *mc)
proper life time, i.e.
Definition: TagVertexModule.cc:537
Belle2::RelationsInterface::getRelated
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
Definition: RelationsObject.h:280
Belle2::RestOfEvent
This is a general purpose class for collecting reconstructed MDST data objects that are not used in r...
Definition: RestOfEvent.h:59
Belle2::RelationsInterface::getRelatedTo
TO * getRelatedTo(const std::string &name="", const std::string &namedRelation="") const
Get the object to which this object has a relation.
Definition: RelationsObject.h:250
Belle2::TagVertex::setRollBackStatus
void setRollBackStatus(int backStatus)
Set the status of the fit performed with the rolled back tracks.
Definition: TagVertex.cc:351
Belle2::TagVertex::setTagVNDF
void setTagVNDF(float TagVNDF)
Set the number of degrees of freedom in the tag vertex fit.
Definition: TagVertex.cc:285
Belle2::analysis::RaveVertexFitter::getChi2
double getChi2(VecSize vertexId=0) const
get the χ² of the fitted vertex.
Definition: RaveVertexFitter.cc:222
Belle2::TrackFitResult
Values of the result of a track fit with a given particle hypothesis.
Definition: TrackFitResult.h:59
Belle2::Particle::getP
float getP() const
Returns momentum magnitude (same as getMomentumMagnitude but with shorter name)
Definition: Particle.h:493
Belle2::TrackFitResult::getPosition
TVector3 getPosition() const
Getter for vector of position at closest approach of track in r/phi projection.
Definition: TrackFitResult.h:109
Belle2::TagVertex::setTagVChi2
void setTagVChi2(float TagVChi2)
Set the chi^2 value of the tag vertex fit result.
Definition: TagVertex.cc:290
Belle2::TagVertex::setTagVlErr
void setTagVlErr(float TagVlErr)
Set the error of the tagV component in the boost direction.
Definition: TagVertex.cc:265
Belle2::matNaN
static const TMatrixDSym matNaN(3,(double[]) { realNaN, realNaN, realNaN, realNaN, realNaN, realNaN, realNaN, realNaN, realNaN })
3x3 matrix with NaN entries
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::TagVertex::setConstraintType
void setConstraintType(const std::string &constraintType)
Set the type of the constraint for the tag fit.
Definition: TagVertex.cc:327
Belle2::TagVertexModule
Tag side Vertex Fitter module for modular analysis.
Definition: TagVertexModule.h:61
Belle2::TagVertex::setTruthTagVol
void setTruthTagVol(float TruthTagVol)
Set the tagV component in the direction orthogonal to the boost.
Definition: TagVertex.cc:275
Belle2::TagVertex::setConstraintCenter
void setConstraintCenter(const TVector3 &constraintCenter)
Set the centre of the constraint for the tag fit.
Definition: TagVertex.cc:316
Belle2::TagVertex::setTagVertex
void setTagVertex(const TVector3 &TagVertex)
Set BTag Vertex.
Definition: TagVertex.cc:200
Belle2::TrackFitResult::getParticleType
Const::ParticleType getParticleType() const
Getter for ParticleType of the mass hypothesis of the track fit.
Definition: TrackFitResult.h:154
Belle2::Particle::getDaughters
std::vector< Belle2::Particle * > getDaughters() const
Returns a vector of pointers to daughter particles.
Definition: Particle.cc:601
Belle2::TagVertex::setNTracks
void setNTracks(int nTracks)
Set number of tracks used in the fit.
Definition: TagVertex.cc:250
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::StoreObjPtr
Type-safe access to single objects in the data store.
Definition: ParticleList.h:33
Belle2::Particle::getMomentumVertexErrorMatrix
TMatrixFSym getMomentumVertexErrorMatrix() const
Returns 7x7 error matrix.
Definition: Particle.cc:386
Belle2::TagVertex::setTruthTagVl
void setTruthTagVl(float TruthTagVl)
Set the MC tagV component in the boost direction.
Definition: TagVertex.cc:260
Belle2::analysis::RaveVertexFitter::getNdf
double getNdf(VecSize vertexId=0) const
get the number of degrees of freedom (NDF) of the fitted vertex.
Definition: RaveVertexFitter.cc:214
Belle2::analysis::RaveVertexFitter::addTrack
void addTrack(const Particle *const aParticlePtr)
add a track (in the format of a Belle2::Particle) to set of tracks that should be fitted to a vertex
Definition: RaveVertexFitter.cc:87
Belle2::Particle::setMomentumVertexErrorMatrix
void setMomentumVertexErrorMatrix(const TMatrixFSym &errMatrix)
Sets 7x7 error matrix.
Definition: Particle.cc:373
Belle2::TagVertex::setDeltaT
void setDeltaT(float DeltaT)
Set DeltaT.
Definition: TagVertex.cc:215
Belle2::MCParticle::getProductionVertex
TVector3 getProductionVertex() const
Return production vertex position.
Definition: MCParticle.h:200
Belle2::MCParticle::getPDG
int getPDG() const
Return PDG code of particle.
Definition: MCParticle.h:123
Belle2::Particle::getMomentumMagnitude
float getMomentumMagnitude() const
Returns momentum magnitude.
Definition: Particle.h:484
Belle2::PCmsLabTransform::getBoostVector
TVector3 getBoostVector() const
Returns boost vector (beta=p/E)
Definition: PCmsLabTransform.h:49
Belle2::analysis::RaveVertexFitter::getCov
TMatrixDSym getCov(VecSize vertexId=0) const
get the covariance matrix (3x3) of the of the fitted vertex position.
Definition: RaveVertexFitter.cc:230
Belle2::realNaN
static const double realNaN
shortcut for NaN of double type
Definition: TagVertexModule.cc:64
Belle2::Particle::getMomentum
TVector3 getMomentum() const
Returns momentum vector.
Definition: Particle.h:475
Belle2::TagVertex::setConstraintCov
void setConstraintCov(const TMatrixDSym &constraintCov)
Set the covariance matrix of the constraint for the tag fit.
Definition: TagVertex.cc:321
Belle2::ParticleAndWeight
this struct is used to store and sort the tag tracks
Definition: TagVertexModule.h:283
Belle2::analysis::RaveVertexFitter::updateDaughters
void updateDaughters()
update the Daughters particles
Definition: RaveVertexFitter.cc:250
Belle2::MCParticle::getDaughters
std::vector< Belle2::MCParticle * > getDaughters() const
Get vector of all daughter particles, empty vector if none.
Definition: MCParticle.cc:51
Belle2::TagVertex::setMCDeltaTau
void setMCDeltaTau(float mcDeltaTau)
Set generated DeltaT.
Definition: TagVertex.cc:235
Belle2::Particle
Class to store reconstructed particles.
Definition: Particle.h:77
Belle2::Particle::getVertexErrorMatrix
TMatrixFSym getVertexErrorMatrix() const
Returns the 3x3 position error sub-matrix.
Definition: Particle.cc:413
Belle2::MCParticle::get4Vector
TLorentzVector get4Vector() const
Return 4Vector of particle.
Definition: MCParticle.h:218
Belle2::PCmsLabTransform
Class to hold Lorentz transformations from/to CMS and boost vector.
Definition: PCmsLabTransform.h:37
Belle2::TagVertex
TagVertex data object: contains Btag Vertex and DeltaT.
Definition: TagVertex.h:44
Belle2::vecNaN
static const TVector3 vecNaN(realNaN, realNaN, realNaN)
vector with NaN entries
Belle2::MCParticle::getMomentum
TVector3 getMomentum() const
Return momentum.
Definition: MCParticle.h:209
Belle2::TagVertex::setDeltaTErr
void setDeltaTErr(float DeltaTErr)
Set DeltaTErr.
Definition: TagVertex.cc:220
Belle2::Particle::getPDGMass
float getPDGMass(void) const
Returns uncertaint on the invariant mass (requiers valid momentum error matrix)
Definition: Particle.cc:577
Belle2::analysis::RaveVertexFitter::fit
int fit(std::string options="default")
do the vertex fit with all tracks previously added with the addTrack or addMother function.
Definition: RaveVertexFitter.cc:121
Belle2::MCParticle
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:43
Belle2::StoreArray< Particle >
Belle2::TagVertex::setMCDeltaT
void setMCDeltaT(float mcDeltaT)
Set generated DeltaT (in kin.
Definition: TagVertex.cc:240
Belle2::Particle::get4Vector
TLorentzVector get4Vector() const
Returns Lorentz vector.
Definition: Particle.h:464
Belle2::TagVertex::setTagVChi2IP
void setTagVChi2IP(float TagVChi2IP)
Set the IP component of the chi^2 value of the tag vertex fit result.
Definition: TagVertex.cc:295
Belle2::TagVertex::setTagVertexErrMatrix
void setTagVertexErrMatrix(const TMatrixDSym &TagVertexErrMatrix)
Set BTag Vertex (3x3) error matrix.
Definition: TagVertex.cc:205
Belle2::RestOfEvent::getChargedParticles
std::vector< const Particle * > getChargedParticles(const std::string &maskName="", unsigned int pdg=0, bool unpackComposite=true) const
Get charged particles from ROE mask.
Definition: RestOfEvent.cc:109
Belle2::TrackFitResult::getCovariance6
TMatrixDSym getCovariance6() const
Position and Momentum Covariance Matrix.
Definition: TrackFitResult.h:147
Belle2::analysis::RaveVertexFitter
The RaveVertexFitter class is part of the RaveInterface together with RaveSetup.
Definition: RaveVertexFitter.h:46
Belle2::analysis::RaveVertexFitter::getWeight
double getWeight(int trackId, VecSize vertexId=0) const
get the weight Rave assigned to a specific input track.
Definition: RaveVertexFitter.cc:178
Belle2::HitPatternVXD
Hit pattern of the VXD within a track.
Definition: HitPatternVXD.h:44
Belle2::TrackFitResult::getChargeSign
short getChargeSign() const
Return track charge (1 or -1).
Definition: TrackFitResult.h:160
Belle2::Particle::getPValue
float getPValue() const
Returns chi^2 probability of fit if done or -1.
Definition: Particle.h:565
Belle2::analysis::VertexFitKFit
VertexFitKFit is a derived class from KFitBase to perform vertex-constraint kinematical fit.
Definition: VertexFitKFit.h:33
Belle2::TagVertex::setVertexFitParticles
void setVertexFitParticles(const std::vector< const Particle * > &vtxFitParticles)
Set a vector of pointers to the tracks used in the tag vtx fit.
Definition: TagVertex.cc:300
Belle2::ParticleAndWeight::particle
const Particle * particle
tag track fit result with pion mass hypo, for sorting purposes
Definition: TagVertexModule.h:285
Belle2::TagVertex::setMCTagVertex
void setMCTagVertex(const TVector3 &mcTagVertex)
Set generated BTag Vertex.
Definition: TagVertex.cc:225