Belle II Software  release-05-02-19
ParticleVertexFitterModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Marko Staric, Luigi Li Gioi, Anze Zupanc, Yu Hu *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 // Own include
12 #include <analysis/modules/ParticleVertexFitter/ParticleVertexFitterModule.h>
13 
14 // framework - DataStore
15 #include <framework/datastore/StoreArray.h>
16 #include <framework/datastore/StoreObjPtr.h>
17 
18 // framework aux
19 #include <framework/gearbox/Unit.h>
20 #include <framework/gearbox/Const.h>
21 #include <framework/logging/Logger.h>
22 
23 // dataobjects
24 #include <analysis/dataobjects/Particle.h>
25 #include <analysis/dataobjects/ParticleList.h>
26 #include <analysis/dataobjects/Btube.h>
27 // utilities
28 #include <analysis/utility/CLHEPToROOT.h>
29 #include <analysis/utility/PCmsLabTransform.h>
30 #include <analysis/utility/ParticleCopy.h>
31 #include <analysis/utility/ROOTToCLHEP.h>
32 
33 // Magnetic field
34 #include <framework/geometry/BFieldManager.h>
35 
36 #include <TMath.h>
37 
38 using namespace std;
39 
40 namespace Belle2 {
47  //-----------------------------------------------------------------
48  // Register module
49  //-----------------------------------------------------------------
50 
51  REG_MODULE(ParticleVertexFitter)
52 
53  //-----------------------------------------------------------------
54  // Implementation
55  //-----------------------------------------------------------------
56 
58  m_Bfield(0)
59  {
60  // set module description (e.g. insert text)
61  setDescription("Vertex fitter for modular analysis");
62  setPropertyFlags(c_ParallelProcessingCertified);
63 
64  // Add parameters
65  addParam("listName", m_listName, "name of particle list", string(""));
66  addParam("confidenceLevel", m_confidenceLevel,
67  "Confidence level to accept the fit. Particle candidates with "
68  "p-value less than confidenceLevel are removed from the particle "
69  "list. If set to -1, all candidates are kept; if set to 0, "
70  "the candidates failing the fit are removed.",
71  0.001);
72  addParam("vertexFitter", m_vertexFitter, "KFit or Rave", string("KFit"));
73  addParam("fitType", m_fitType, "type of the kinematic fit (vertex, massvertex, mass)", string("vertex"));
74  addParam("withConstraint", m_withConstraint,
75  "additional constraint on vertex: ipprofile, iptube, mother, iptubecut, pointing, btube",
76  string(""));
77  addParam("decayString", m_decayString, "specifies which daughter particles are included in the kinematic fit", string(""));
78  addParam("updateDaughters", m_updateDaughters, "true: update the daughters after the vertex fit", false);
79  addParam("smearing", m_smearing, "smear IP tube width by given length", 0.002);
80  }
81 
82  void ParticleVertexFitterModule::initialize()
83  {
84  // magnetic field
85  m_Bfield = BFieldManager::getField(TVector3(0, 0, 0)).Z() / Unit::T;
86 
87  // RAVE setup
88  if (m_vertexFitter == "Rave")
89  analysis::RaveSetup::initialize(1, m_Bfield);
90 
91  B2DEBUG(1, "ParticleVertexFitterModule : magnetic field = " << m_Bfield);
92 
93 
94  if (m_decayString != "")
95  m_decaydescriptor.init(m_decayString);
96 
97  B2INFO("ParticleVertexFitter: Performing " << m_fitType << " fit on " << m_listName << " using " << m_vertexFitter);
98  if (m_decayString != "")
99  B2INFO("ParticleVertexFitter: Using specified decay string: " << m_decayString);
100  if (m_withConstraint != "")
101  B2INFO("ParticleVertexFitter: Additional " << m_withConstraint << " will be applied");
102 
103  }
104 
105  void ParticleVertexFitterModule::beginRun()
106  {
107  //TODO: set magnetic field for each run
108  //m_Bfield = BFieldMap::Instance().getBField(TVector3(0,0,0)).Z();
109  //TODO: set IP spot size for each run
110  }
111 
112  void ParticleVertexFitterModule::event()
113  {
114 
115  StoreObjPtr<ParticleList> plist(m_listName);
116  if (!plist) {
117  B2ERROR("ParticleList " << m_listName << " not found");
118  return;
119  }
120 
121  if (m_vertexFitter == "Rave")
122  analysis::RaveSetup::initialize(1, m_Bfield);
123 
124  m_BeamSpotCenter = m_beamSpotDB->getIPPosition();
125  m_beamSpotCov.ResizeTo(3, 3);
126  TMatrixDSym beamSpotCov(3);
127  if (m_withConstraint == "ipprofile") m_beamSpotCov = m_beamSpotDB->getCovVertex();
128  if (m_withConstraint == "iptube") {
129  if (m_smearing > 0 && m_vertexFitter == "KFit") {
130  ParticleVertexFitterModule::smearBeamSpot(m_smearing);
131  } else {
132  ParticleVertexFitterModule::findConstraintBoost(2.);
133  }
134  }
135  if (m_withConstraint == "iptubecut") { // for development purpose only
136  m_BeamSpotCenter = TVector3(0.001, 0., .013);
137  findConstraintBoost(0.03);
138  }
139  if ((m_vertexFitter == "Rave") && (m_withConstraint == "ipprofile" || m_withConstraint == "iptube"
140  || m_withConstraint == "mother" || m_withConstraint == "iptubecut" || m_withConstraint == "btube"))
141  analysis::RaveSetup::getInstance()->setBeamSpot(m_BeamSpotCenter, m_beamSpotCov);
142  std::vector<unsigned int> toRemove;
143  unsigned int n = plist->getListSize();
144  for (unsigned i = 0; i < n; i++) {
145  Particle* particle = plist->getParticle(i);
146  m_hasCovMatrix = false;
147  if (m_updateDaughters == true) {
148  if (m_decayString.empty()) ParticleCopy::copyDaughters(particle);
149  else B2ERROR("Daughters update works only when all daughters are selected. Daughters will not be updated");
150  }
151 
152  if (m_withConstraint == "mother") {
153  m_BeamSpotCenter = particle->getVertex();
154  m_beamSpotCov = particle->getVertexErrorMatrix();
155  }
156 
157  TMatrixFSym mother_errMatrix(7);
158  mother_errMatrix = particle->getMomentumVertexErrorMatrix();
159  for (int k = 0; k < 7; k++) {
160  for (int j = 0; j < 7; j++) {
161  if (mother_errMatrix[k][j] > 0) {
162  m_hasCovMatrix = true;
163  }
164  }
165  }
166  bool hasTube = true;
167  if (m_withConstraint == "btube") {
168  Btube* Ver = particle->getRelatedTo<Btube>();
169  if (!Ver) {
170  hasTube = false;
171  toRemove.push_back(particle->getArrayIndex());
172  } else {
173  m_BeamSpotCenter.SetXYZ(Ver->getTubeCenter()(0, 0), Ver->getTubeCenter()(1, 0), Ver->getTubeCenter()(2, 0));
174  m_beamSpotCov = Ver->getTubeMatrix();
175  }
176  }
177  bool ok = false;
178  if (hasTube) {
179  ok = doVertexFit(particle);
180  }
181  if (!ok)
182  particle->setPValue(-1);
183  if (particle->getPValue() < m_confidenceLevel)
184  toRemove.push_back(particle->getArrayIndex());
185  }
186  plist->removeParticles(toRemove);
187 
188  //free memory allocated by rave. initialize() would be enough, except that we must clean things up before program end...
189  if (m_vertexFitter == "Rave")
190  analysis::RaveSetup::getInstance()->reset();
191  }
192 
193  bool ParticleVertexFitterModule::doVertexFit(Particle* mother)
194  {
195  // steering starts here
196 
197  if (m_Bfield == 0) {
198  B2FATAL("ParticleVertexFitter: No magnetic field");
199  }
200 
201  if (m_withConstraint != "ipprofile" &&
202  m_withConstraint != "iptube" &&
203  m_withConstraint != "mother" &&
204  m_withConstraint != "iptubecut" &&
205  m_withConstraint != "pointing" &&
206  m_withConstraint != "btube" &&
207  m_withConstraint != "")
208  B2FATAL("ParticleVertexFitter: " << m_withConstraint << " ***invalid Constraint ");
209 
210  bool ok = false;
211  // fits with KFit
212  if (m_vertexFitter == "KFit") {
213 
214  // vertex fit
215  if (m_fitType == "vertex") {
216  if (m_withConstraint == "ipprofile") {
217  ok = doKVertexFit(mother, true, false);
218  } else if (m_withConstraint == "iptube") {
219  ok = doKVertexFit(mother, false, true);
220  } else {
221  ok = doKVertexFit(mother, false, false);
222  }
223  }
224 
225  // mass-constrained vertex fit
226  if (m_fitType == "massvertex") {
227  if (m_withConstraint == "ipprofile" || m_withConstraint == "iptube" || m_withConstraint == "iptubecut") {
228  B2FATAL("ParticleVertexFitter: Invalid options - mass-constrained fit using KFit does not work with iptube or ipprofile constraint.");
229  } else if (m_withConstraint == "pointing") {
230  ok = doKMassPointingVertexFit(mother);
231  } else {
232  ok = doKMassVertexFit(mother);
233  }
234  }
235 
236  // mass fit
237  if (m_fitType == "mass") {
238  if (m_withConstraint == "ipprofile" || m_withConstraint == "iptube" || m_withConstraint == "iptubecut") {
239  B2FATAL("ParticleVertexFitter: Invalid options - mass fit using KFit does not work with iptube or ipprofile constraint.");
240  } else {
241  ok = doKMassFit(mother);
242  }
243  }
244 
245  // four C fit
246  if (m_fitType == "fourC") {
247  if (m_withConstraint == "ipprofile" || m_withConstraint == "iptube" || m_withConstraint == "iptubecut") {
248  B2FATAL("ParticleVertexFitter: Invalid options - four C fit using KFit does not work with iptube or ipprofile constraint.");
249  } else {
250  ok = doKFourCFit(mother);
251  }
252  }
253 
254  // invalid KFit fit type
255  if (m_fitType != "vertex"
256  && m_fitType != "massvertex"
257  && m_fitType != "mass"
258  && m_fitType != "fourC")
259  B2FATAL("ParticleVertexFitter: " << m_fitType << " ***invalid fit type for the vertex fitter ");
260  }
261 
262  // fits using Rave
263  if (m_vertexFitter == "Rave") {
264  try {
265  ok = doRaveFit(mother);
266  } catch (const rave::CheckedFloatException&) {
267  B2ERROR("Invalid inputs (nan/inf)?");
268  ok = false;
269  }
270  }
271 
272  // invalid fitter
273  if (m_vertexFitter != "KFit" && m_vertexFitter != "Rave")
274  B2FATAL("ParticleVertexFitter: " << m_vertexFitter << " ***invalid vertex fitter ");
275 
276  if (!ok) return false;
277 
278  // steering ends here
279 
280  //if (mother->getPValue() < m_confidenceLevel) return false;
281  return true;
282 
283  }
284 
285  bool ParticleVertexFitterModule::fillFitParticles(const Particle* mother, std::vector<const Particle*>& fitChildren,
286  std::vector<const Particle*>& pi0Children)
287  {
288  if (m_decayString.empty()) {
289  // if decayString is empty, just use all primary daughters
290  for (unsigned ichild = 0; ichild < mother->getNDaughters(); ichild++) {
291  const Particle* child = mother->getDaughter(ichild);
292  // This if allows to skip the daughters, which cannot be used in the fits, particularly K_L0 from KLM.
293  // Useful for fully-inclusive particles.
294  if (mother->getProperty() == Particle::PropertyFlags::c_IsUnspecified and child->getPValue() < 0) {
295  continue;
296  }
297  fitChildren.push_back(child);
298  }
299  } else {
300  fitChildren = m_decaydescriptor.getSelectionParticles(mother);
301  }
302 
303  auto itr = fitChildren.begin();
304  while (itr != fitChildren.end()) {
305  const Particle* child = *itr;
306 
307  if (child->getPValue() < 0) {
308  B2WARNING("Daughter with PDG code " << child->getPDGCode() << " does not have a valid error matrix.");
309  return false; // error matrix not valid
310  }
311  bool isPi0 = false;
312  if (m_hasCovMatrix == false) {
313  if (child->getPDGCode() == Const::pi0.getPDGCode() && child->getNDaughters() == 2) {
314  if (child->getDaughter(0)->getPDGCode() == Const::photon.getPDGCode()
315  && child->getDaughter(1)->getPDGCode() == Const::photon.getPDGCode()) {
316  isPi0 = true;
317  }
318  }
319  }
320  if (isPi0) {
321  // move children from fitChildren to pi0Children
322  pi0Children.push_back(child);
323  itr = fitChildren.erase(itr);
324  } else {
325  itr++;
326  }
327  }
328 
329  return true;
330  }
331 
332  bool ParticleVertexFitterModule::redoPi0MassFit(Particle* pi0Temp, const Particle* pi0Orig, const analysis::VertexFitKFit& kv)
333  {
334  // TODO: something like setGammaError is necessary
335  // this is just workaround for the moment
336 
337  const Particle* g1Orig = pi0Orig->getDaughter(0);
338  const Particle* g2Orig = pi0Orig->getDaughter(1);
339  Particle g1Temp(g1Orig->get4Vector(), 22);
340  Particle g2Temp(g2Orig->get4Vector(), 22);
341 
342  TMatrixFSym g1ErrMatrix = g1Orig->getMomentumVertexErrorMatrix();
343  TMatrixFSym g2ErrMatrix = g2Orig->getMomentumVertexErrorMatrix();
344 
345  TVector3 pos(kv.getVertex().x(), kv.getVertex().y(), kv.getVertex().z());
346  CLHEP::HepSymMatrix posErrorMatrix = kv.getVertexError();
347 
348  TMatrixFSym errMatrix(3);
349  for (int i = 0; i < 3; i++)
350  for (int j = 0; j < 3; j++)
351  errMatrix(i, j) = posErrorMatrix[i][j];
352 
353  g1ErrMatrix.SetSub(4, errMatrix);
354  g2ErrMatrix.SetSub(4, errMatrix);
355 
356  g1Temp.updateMomentum(g1Orig->get4Vector(), pos, g1ErrMatrix, 1.0);
357  g2Temp.updateMomentum(g2Orig->get4Vector(), pos, g2ErrMatrix, 1.0);
358 
359  // perform the mass fit for pi0
361  km.setMagneticField(m_Bfield);
362 
363  km.addParticle(&g1Temp);
364  km.addParticle(&g2Temp);
365 
366  km.setVertex(kv.getVertex());
368  km.setInvariantMass(pi0Orig->getPDGMass());
369 
370  int err = km.doFit();
371  if (err != 0) {
372  return false;
373  }
374 
375  // The update of the daughters is disabled for the pi0 mass fit.
376  bool updateDaughters = m_updateDaughters;
377  m_updateDaughters = false;
378  bool ok = makeKMassMother(km, pi0Temp);
379  m_updateDaughters = updateDaughters;
380 
381  return ok;
382  }
383 
384  bool ParticleVertexFitterModule::doKVertexFit(Particle* mother, bool ipProfileConstraint, bool ipTubeConstraint)
385  {
386  if ((mother->getNDaughters() < 2 && !ipTubeConstraint) || mother->getNDaughters() < 1) return false;
387 
388  std::vector<const Particle*> fitChildren;
389  std::vector<const Particle*> pi0Children;
390  bool validChildren = fillFitParticles(mother, fitChildren, pi0Children);
391 
392  if (!validChildren)
393  return false;
394 
395  if (pi0Children.size() > 1) {
396  B2FATAL("[ParticleVertexFitterModule::doKVertexFit] Vertex fit using KFit does not support fit with multiple pi0s (yet).");
397  }
398 
399  if ((fitChildren.size() < 2 && !ipTubeConstraint) || fitChildren.size() < 1) {
400  B2WARNING("[ParticleVertexFitterModule::doKVertexFit] Number of particles with valid error matrix entering the vertex fit using KFit is too low.");
401  return false;
402  }
403 
404  // Initialise the Fitter
406  kv.setMagneticField(m_Bfield);
407 
408  for (auto& child : fitChildren)
409  kv.addParticle(child);
410 
411  if (ipProfileConstraint)
412  addIPProfileToKFit(kv);
413 
414  if (ipTubeConstraint)
415  addIPTubeToKFit(kv);
416 
417  // Perform vertex fit using only the particles with valid error matrices
418  int err = kv.doFit();
419  if (err != 0)
420  return false;
421 
422  bool ok = false;
423  if (pi0Children.size() == 0)
424  // in the case daughters do not include pi0 - this is it (fit done)
425  ok = makeKVertexMother(kv, mother);
426  else if (pi0Children.size() == 1) {
427  // the daughters contain pi0:
428  // 1. refit pi0 to previously determined vertex
429  // 2. redo the fit using all particles (including pi0 this time)
430 
431  const Particle* pi0 = pi0Children[0];
432  Particle pi0Temp(pi0->get4Vector(), 111);
433  ok = redoPi0MassFit(&pi0Temp, pi0, kv) ;
434  if (!ok)
435  return false;
436 
437  // finally perform the fit using all daughter particles
439  kv2.setMagneticField(m_Bfield);
440 
441  for (auto& child : fitChildren)
442  kv2.addParticle(child);
443 
444  kv2.addParticle(&pi0Temp);
445 
446  if (ipProfileConstraint)
447  addIPProfileToKFit(kv2);
448 
449  err = kv2.doFit();
450 
451  if (err != 0)
452  return false;
453 
454  ok = makeKVertexMother(kv2, mother);
455  }
456 
457  return ok;
458  }
459 
460  bool ParticleVertexFitterModule::doKMassVertexFit(Particle* mother)
461  {
462  if (mother->getNDaughters() < 2) return false;
463 
464  std::vector<const Particle*> fitChildren;
465  std::vector<const Particle*> pi0Children;
466  bool validChildren = fillFitParticles(mother, fitChildren, pi0Children);
467 
468  if (!validChildren)
469  return false;
470 
471  if (pi0Children.size() > 1) {
472  B2FATAL("[ParticleVertexFitterModule::doKVertexFit] MassVertex fit using KFit does not support fit with multiple pi0s (yet).");
473  }
474 
475  if (fitChildren.size() < 2) {
476  B2WARNING("[ParticleVertexFitterModule::doKVertexFit] Number of particles with valid error matrix entering the vertex fit using KFit is less than 2.");
477  return false;
478  }
479 
480  bool ok = false;
481  if (pi0Children.size() == 0) {
482  // Initialise the Fitter
484  kmv.setMagneticField(m_Bfield);
485 
486  for (auto child : fitChildren)
487  kmv.addParticle(child);
488 
489  kmv.setInvariantMass(mother->getPDGMass());
490  int err = kmv.doFit();
491  if (err != 0)
492  return false;
493 
494  // in the case daughters do not include pi0 - this is it (fit done)
495  ok = makeKMassVertexMother(kmv, mother);
496  } else if (pi0Children.size() == 1) {
497  // the daughters contain pi0:
498  // 1. refit pi0 to previously determined vertex
499  // 2. redo the fit using all particles (including pi0 this time)
500 
502  kv.setMagneticField(m_Bfield);
503 
504  for (auto child : fitChildren)
505  kv.addParticle(child);
506 
507  // Perform vertex fit using only the particles with valid error matrices
508  int err = kv.doFit();
509  if (err != 0)
510  return false;
511 
512  const Particle* pi0 = pi0Children[0];
513  Particle pi0Temp(pi0->get4Vector(), 111);
514  ok = redoPi0MassFit(&pi0Temp, pi0, kv) ;
515  if (!ok)
516  return false;
517 
518  // finally perform the fit using all daughter particles
520  kmv2.setMagneticField(m_Bfield);
521 
522  for (auto child : fitChildren)
523  kmv2.addParticle(child);
524  kmv2.addParticle(&pi0Temp);
525 
526  kmv2.setInvariantMass(mother->getPDGMass());
527  err = kmv2.doFit();
528 
529  if (err != 0)
530  return false;
531 
532  ok = makeKMassVertexMother(kmv2, mother);
533  }
534 
535  return ok;
536 
537  }
538 
539  bool ParticleVertexFitterModule::doKMassPointingVertexFit(Particle* mother)
540  {
541  if (!(mother->hasExtraInfo("prodVertX") && mother->hasExtraInfo("prodVertY") && mother->hasExtraInfo("prodVertZ"))) {
542  return false;
543  }
544 
545  if (mother->getNDaughters() < 2) return false;
546 
547  std::vector<const Particle*> fitChildren;
548  std::vector<const Particle*> pi0Children;
549  bool validChildren = fillFitParticles(mother, fitChildren, pi0Children);
550 
551  if (!validChildren)
552  return false;
553 
554  if (pi0Children.size() > 0) {
555  B2FATAL("[ParticleVertexFitterModule::doKMassPointingVertexFit] MassPointingVertex fit using KFit does not support fit with pi0s (yet).");
556  }
557 
558  if (fitChildren.size() < 2) {
559  B2WARNING("[ParticleVertexFitterModule::doKMassPointingVertexFit] Number of particles with valid error matrix entering the vertex fit using KFit is less than 2.");
560  return false;
561  }
562 
563  bool ok = false;
564  // Initialise the Fitter
566  kmpv.setMagneticField(m_Bfield);
567 
568  for (auto child : fitChildren)
569  kmpv.addParticle(child);
570 
571  kmpv.setInvariantMass(mother->getPDGMass());
572  HepPoint3D productionVertex(mother->getExtraInfo("prodVertX"),
573  mother->getExtraInfo("prodVertY"),
574  mother->getExtraInfo("prodVertZ"));
575  kmpv.setProductionVertex(productionVertex);
576  int err = kmpv.doFit();
577  if (err != 0) return false;
578 
579  ok = makeKMassPointingVertexMother(kmpv, mother);
580 
581  return ok;
582  }
583 
584  bool ParticleVertexFitterModule::doKMassFit(Particle* mother)
585  {
586  if (mother->getNDaughters() < 2) return false;
587 
589  km.setMagneticField(m_Bfield);
590 
591  for (unsigned ichild = 0; ichild < mother->getNDaughters(); ichild++) {
592  const Particle* child = mother->getDaughter(ichild);
593 
594  if (child->getPValue() < 0) return false; // error matrix not valid
595 
596  km.addParticle(child);
597  }
598 
599  // apply mass constraint
600  km.setInvariantMass(mother->getPDGMass());
601 
602  int err = km.doFit();
603 
604  if (err != 0) return false;
605 
606  bool ok = makeKMassMother(km, mother);
607 
608  return ok;
609  }
610 
611  bool ParticleVertexFitterModule::doKFourCFit(Particle* mother)
612  {
613  if (mother->getNDaughters() < 2) return false;
614 
616  kf.setMagneticField(m_Bfield);
617 
618  for (unsigned ichild = 0; ichild < mother->getNDaughters(); ichild++) {
619  const Particle* child = mother->getDaughter(ichild);
620 
621  if (child->getNDaughters() > 0) {
622  bool err = addChildofParticletoKFit(kf, child);
623  if (!err) return false;
624  } else {
625  if (child->getPValue() < 0) return false; // error matrix not valid
626 
627  kf.addParticle(child);
628  }
629  }
630 
631  // apply four momentum constraint
634 
635  int err = kf.doFit();
636 
637  if (err != 0) return false;
638 
639  bool ok = makeKFourCMother(kf, mother);
640 
641  return ok;
642  }
643 
644  bool ParticleVertexFitterModule::makeKVertexMother(analysis::VertexFitKFit& kv,
645  Particle* mother)
646  {
647  enum analysis::KFitError::ECode fitError;
648  fitError = kv.updateMother(mother);
649  if (fitError != analysis::KFitError::kNoError)
650  return false;
651  if (m_decayString.empty() && m_updateDaughters == true) {
652  // update daughter momenta as well
653  // the order of daughters in the *fitter is the same as in the mother Particle
654 
655  std::vector<Particle*> daughters = mother->getDaughters();
656 
657  unsigned track_count = kv.getTrackCount();
658  if (daughters.size() != track_count)
659  return false;
660 
661  for (unsigned iChild = 0; iChild < track_count; iChild++) {
662  daughters[iChild]->set4Vector(
663  CLHEPToROOT::getTLorentzVector(kv.getTrackMomentum(iChild)));
664  daughters[iChild]->setVertex(
665  CLHEPToROOT::getTVector3(kv.getTrackPosition(iChild)));
666  daughters[iChild]->setMomentumVertexErrorMatrix(
667  CLHEPToROOT::getTMatrixFSym(kv.getTrackError(iChild)));
668  }
669  }
670 
671  return true;
672  }
673 
674  bool ParticleVertexFitterModule::makeKMassVertexMother(analysis::MassVertexFitKFit& kmv,
675  Particle* mother)
676  {
677  enum analysis::KFitError::ECode fitError;
678  fitError = kmv.updateMother(mother);
679  if (fitError != analysis::KFitError::kNoError)
680  return false;
681  if (m_decayString.empty() && m_updateDaughters == true) {
682  // update daughter momenta as well
683  // the order of daughters in the *fitter is the same as in the mother Particle
684 
685  std::vector<Particle*> daughters = mother->getDaughters();
686 
687  unsigned track_count = kmv.getTrackCount();
688  if (daughters.size() != track_count)
689  return false;
690 
691  for (unsigned iChild = 0; iChild < track_count; iChild++) {
692  daughters[iChild]->set4Vector(
693  CLHEPToROOT::getTLorentzVector(kmv.getTrackMomentum(iChild)));
694  daughters[iChild]->setVertex(
695  CLHEPToROOT::getTVector3(kmv.getTrackPosition(iChild)));
696  daughters[iChild]->setMomentumVertexErrorMatrix(
697  CLHEPToROOT::getTMatrixFSym(kmv.getTrackError(iChild)));
698  }
699  }
700 
701  return true;
702  }
703 
704  bool ParticleVertexFitterModule::makeKMassPointingVertexMother(analysis::MassPointingVertexFitKFit& kmpv,
705  Particle* mother)
706  {
707  enum analysis::KFitError::ECode fitError;
708  fitError = kmpv.updateMother(mother);
709  if (fitError != analysis::KFitError::kNoError) {
710  return false;
711  }
712 
713  if (m_decayString.empty() && m_updateDaughters == true) {
714  // update daughter momenta as well
715  // the order of daughters in the *fitter is the same as in the mother Particle
716 
717  std::vector<Particle*> daughters = mother->getDaughters();
718 
719  unsigned track_count = kmpv.getTrackCount();
720  if (daughters.size() != track_count)
721  return false;
722 
723  for (unsigned iChild = 0; iChild < track_count; iChild++) {
724  daughters[iChild]->set4Vector(
725  CLHEPToROOT::getTLorentzVector(kmpv.getTrackMomentum(iChild)));
726  daughters[iChild]->setVertex(
727  CLHEPToROOT::getTVector3(kmpv.getTrackPosition(iChild)));
728  daughters[iChild]->setMomentumVertexErrorMatrix(
729  CLHEPToROOT::getTMatrixFSym(kmpv.getTrackError(iChild)));
730  }
731  }
732 
733  return true;
734  }
735 
736 
737  bool ParticleVertexFitterModule::makeKMassMother(analysis::MassFitKFit& km,
738  Particle* mother)
739  {
740  enum analysis::KFitError::ECode fitError;
741  fitError = km.updateMother(mother);
742  if (fitError != analysis::KFitError::kNoError)
743  return false;
744  if (m_decayString.empty() && m_updateDaughters == true) {
745  // update daughter momenta as well
746  // the order of daughters in the *fitter is the same as in the mother Particle
747 
748  std::vector<Particle*> daughters = mother->getDaughters();
749 
750  unsigned track_count = km.getTrackCount();
751  if (daughters.size() != track_count)
752  return false;
753 
754  for (unsigned iChild = 0; iChild < track_count; iChild++) {
755  daughters[iChild]->set4Vector(
756  CLHEPToROOT::getTLorentzVector(km.getTrackMomentum(iChild)));
757  daughters[iChild]->setVertex(
758  CLHEPToROOT::getTVector3(km.getTrackPosition(iChild)));
759  daughters[iChild]->setMomentumVertexErrorMatrix(
760  CLHEPToROOT::getTMatrixFSym(km.getTrackError(iChild)));
761  }
762  }
763 
764  return true;
765  }
766 
767 
768 
769  bool ParticleVertexFitterModule::makeKFourCMother(analysis::FourCFitKFit& kf, Particle* mother)
770  {
771  enum analysis::KFitError::ECode fitError;
772  fitError = kf.updateMother(mother);
773  if (fitError != analysis::KFitError::kNoError)
774  return false;
775  mother->addExtraInfo("FourCFitProb", kf.getCHIsq());
776  mother->addExtraInfo("FourCFitChi2", kf.getNDF());
777  if (m_decayString.empty() && m_updateDaughters == true) {
778  // update daughter momenta as well
779  // the order of daughters in the *fitter is the same as in the mother Particle
780 
781  std::vector<Particle*> daughters = mother->getDaughters();
782 
783  const unsigned nd = daughters.size();
784  unsigned l = 0;
785  std::vector<std::vector<unsigned>> pars;
786  std::vector<Particle*> allparticles;
787  for (unsigned ichild = 0; ichild < nd; ichild++) {
788  const Particle* daughter = mother->getDaughter(ichild);
789  std::vector<unsigned> pard;
790  if (daughter->getNDaughters() > 0) {
791  updateMapOfTrackAndDaughter(l, pars, pard, allparticles, daughter);
792  pars.push_back(pard);
793  allparticles.push_back(daughters[ichild]);
794  } else {
795  pard.push_back(l);
796  pars.push_back(pard);
797  allparticles.push_back(daughters[ichild]);
798  l++;
799  }
800  }
801 
802  unsigned track_count = kf.getTrackCount();
803  if (l != track_count)
804  return false;
805 
806  for (unsigned iDaug = 0; iDaug < allparticles.size(); iDaug++) {
807  TLorentzVector childMoms;
808  TVector3 childPoss;
809  TMatrixFSym childErrMatrixs(7);
810  for (unsigned int iChild : pars[iDaug]) {
811  childMoms = childMoms +
812  CLHEPToROOT::getTLorentzVector(
813  kf.getTrackMomentum(iChild));
814  childPoss = childPoss +
815  CLHEPToROOT::getTVector3(
816  kf.getTrackPosition(iChild));
817  TMatrixFSym childErrMatrix =
818  CLHEPToROOT::getTMatrixFSym(kf.getTrackError(iChild));
819  childErrMatrixs = childErrMatrixs + childErrMatrix;
820  }
821  allparticles[iDaug]->set4Vector(childMoms);
822  allparticles[iDaug]->setVertex(childPoss);
823  allparticles[iDaug]->setMomentumVertexErrorMatrix(childErrMatrixs);
824  }
825  }
826 
827  return true;
828  }
829 
830  void ParticleVertexFitterModule::updateMapOfTrackAndDaughter(unsigned& l, std::vector<std::vector<unsigned>>& pars,
831  std::vector<unsigned>& parm, std::vector<Particle*>& allparticles, const Particle* daughter)
832  {
833  std::vector <Belle2::Particle*> childs = daughter->getDaughters();
834  for (unsigned ichild = 0; ichild < daughter->getNDaughters(); ichild++) {
835  const Particle* child = daughter->getDaughter(ichild);
836  std::vector<unsigned> pard;
837  if (child->getNDaughters() > 0) {
838  updateMapOfTrackAndDaughter(l, pars, pard, allparticles, child);
839  parm.insert(parm.end(), pard.begin(), pard.end());
840  pars.push_back(pard);
841  allparticles.push_back(childs[ichild]);
842  } else {
843  pard.push_back(l);
844  parm.push_back(l);
845  pars.push_back(pard);
846  allparticles.push_back(childs[ichild]);
847  l++;
848  }
849  }
850  }
851 
852 
853  bool ParticleVertexFitterModule::doRaveFit(Particle* mother)
854  {
855  if ((m_decayString.empty() ||
856  (m_withConstraint == "" && m_fitType != "mass")) && mother->getNDaughters() < 2) return false;
857  if (m_withConstraint == "") analysis::RaveSetup::getInstance()->unsetBeamSpot();
858  if (m_withConstraint == "ipprofile" || m_withConstraint == "iptube" || m_withConstraint == "mother"
859  || m_withConstraint == "iptubecut" || m_withConstraint == "btube")
860  analysis::RaveSetup::getInstance()->setBeamSpot(m_BeamSpotCenter, m_beamSpotCov);
861 
863  if (m_fitType == "mass") rf.setVertFit(false);
864 
865  if (m_decayString.empty()) {
866  rf.addMother(mother);
867  } else {
868  std::vector<const Particle*> tracksVertex = m_decaydescriptor.getSelectionParticles(mother);
869  std::vector<std::string> tracksName = m_decaydescriptor.getSelectionNames();
870 
871  if (allSelectedDaughters(mother, tracksVertex)) {
872  for (auto& itrack : tracksVertex) {
873  if (itrack != mother) rf.addTrack(itrack);
874  }
875  rf.setMother(mother);
876  } else {
877 
879  bool mothSel = false;
880  int nTrk = 0;
881  for (unsigned itrack = 0; itrack < tracksVertex.size(); itrack++) {
882  if (tracksVertex[itrack] != mother) {
883  rsf.addTrack(tracksVertex[itrack]);
884  B2DEBUG(1, "ParticleVertexFitterModule: Adding particle " << tracksName[itrack] << " to vertex fit ");
885  nTrk++;
886  }
887  if (tracksVertex[itrack] == mother) mothSel = true;
888  }
889 
890 
891  // Fit one particle constrained to originate from the beam spot
892  bool mothIPfit = false;
893  if (tracksVertex.size() == 1 && mothSel == true && m_withConstraint != "" && nTrk == 0) {
894  rsf.addTrack(tracksVertex[0]);
895  if (tracksVertex[0] != mother)
896  B2FATAL("ParticleVertexFitterModule: FATAL Error in IP constrained mother fit");
897  nTrk++;
898  mothIPfit = true;
899  }
900 
901 
902  TVector3 pos;
903  TMatrixDSym RerrMatrix(3);
904  int nvert = 0;
905 
906  // one track fit is not kinematic
907  if (nTrk == 1) {
909  for (auto& itrack : tracksVertex) {
910  rsg.addTrack(itrack);
911  nvert = rsg.fit("kalman");
912  if (nvert > 0) {
913  pos = rsg.getPos(0);
914  RerrMatrix = rsg.getCov(0);
915  double prob = rsg.getPValue(0);
916  TLorentzVector mom(mother->getMomentum(), mother->getEnergy());
917  TMatrixDSym errMatrix(7);
918  for (int i = 0; i < 7; i++) {
919  for (int j = 0; j < 7; j++) {
920  if (i > 3 && j > 3) {errMatrix[i][j] = RerrMatrix[i - 4][j - 4];}
921  else {errMatrix[i][j] = 0;}
922  }
923  }
924  if (mothIPfit) {
925  mother->writeExtraInfo("prodVertX", pos.X());
926  mother->writeExtraInfo("prodVertY", pos.Y());
927  mother->writeExtraInfo("prodVertZ", pos.Z());
928  mother->writeExtraInfo("prodVertSxx", RerrMatrix[0][0]);
929  mother->writeExtraInfo("prodVertSxy", RerrMatrix[0][1]);
930  mother->writeExtraInfo("prodVertSxz", RerrMatrix[0][2]);
931  mother->writeExtraInfo("prodVertSyx", RerrMatrix[1][0]);
932  mother->writeExtraInfo("prodVertSyy", RerrMatrix[1][1]);
933  mother->writeExtraInfo("prodVertSyz", RerrMatrix[1][2]);
934  mother->writeExtraInfo("prodVertSzx", RerrMatrix[2][0]);
935  mother->writeExtraInfo("prodVertSzy", RerrMatrix[2][1]);
936  mother->writeExtraInfo("prodVertSzz", RerrMatrix[2][2]);
937  } else {
938  mother->updateMomentum(mom, pos, errMatrix, prob);
939  }
940  return true;
941  } else {return false;}
942  }
943  } else {
944  nvert = rsf.fit();
945  }
946 
947  if (nvert > 0) {
948  pos = rsf.getPos();
949  RerrMatrix = rsf.getVertexErrorMatrix();
950  double prob = rsf.getPValue();
951  TLorentzVector mom(mother->getMomentum(), mother->getEnergy());
952  TMatrixDSym errMatrix(7);
953  for (int i = 0; i < 7; i++) {
954  for (int j = 0; j < 7; j++) {
955  if (i > 3 && j > 3) {errMatrix[i][j] = RerrMatrix[i - 4][j - 4];}
956  else {errMatrix[i][j] = 0;}
957  }
958  }
959  mother->updateMomentum(mom, pos, errMatrix, prob);
960  } else {return false;}
961 
962 
963  if (mothSel && nTrk > 1) {
964  analysis::RaveSetup::getInstance()->setBeamSpot(pos, RerrMatrix);
965  rf.addMother(mother);
966  int nKfit = rf.fit();
967  rf.updateMother();
968  analysis::RaveSetup::getInstance()->unsetBeamSpot();
969 
970  if (nKfit > 0) {return true;}
971  else return false;
972  } else return true;
973  }
974  }
975 
976  bool okFT = false;
977  if (m_fitType == "vertex") {
978  okFT = true;
979  int nVert = rf.fit();
980  rf.updateMother();
981  if (m_decayString.empty() && m_updateDaughters == true) rf.updateDaughters();
982  if (nVert != 1) return false;
983  }
984  if (m_fitType == "mass") {
985  // add protection
986  okFT = true;
987  rf.setMassConstFit(true);
988  rf.setVertFit(false);
989  int nVert = rf.fit();
990  rf.updateMother();
991  if (nVert != 1) return false;
992  };
993  if (m_fitType == "massvertex") {
994  okFT = true;
995  rf.setMassConstFit(true);
996  int nVert = rf.fit();
997  rf.updateMother();
998  if (m_decayString.empty() && m_updateDaughters == true) rf.updateDaughters();
999  if (nVert != 1) return false;
1000  };
1001  if (!okFT) {
1002  B2FATAL("fitType : " << m_fitType << " ***invalid fit type ");
1003  }
1004 
1005  return true;
1006  }
1007 
1008  bool ParticleVertexFitterModule::allSelectedDaughters(const Particle* mother,
1009  const std::vector<const Particle*>& tracksVertex)
1010  {
1011  bool isAll = false;
1012  if (mother->getNDaughters() == 0) return false;
1013 
1014  int nNotIncluded = mother->getNDaughters();
1015 
1016  for (unsigned i = 0; i < mother->getNDaughters(); i++) {
1017  bool dauOk = false;
1018  for (auto& vi : tracksVertex) {
1019  if (vi == mother->getDaughter(i)) {
1020  nNotIncluded = nNotIncluded - 1;
1021  dauOk = true;
1022  }
1023  }
1024  if (!dauOk) {
1025  if (allSelectedDaughters(mother->getDaughter(i), tracksVertex)) nNotIncluded--;
1026  }
1027  }
1028  if (nNotIncluded == 0) isAll = true;
1029  return isAll;
1030  }
1031 
1032  bool ParticleVertexFitterModule::addChildofParticletoKFit(analysis::FourCFitKFit& kf, const Particle* particle)
1033  {
1034  for (unsigned ichild = 0; ichild < particle->getNDaughters(); ichild++) {
1035  const Particle* child = particle->getDaughter(ichild);
1036  if (child->getNDaughters() > 0) addChildofParticletoKFit(kf, child);
1037  else {
1038  if (child->getPValue() < 0) return false; // error matrix not valid
1039 
1040  kf.addParticle(child);
1041  }
1042  }
1043  return true;
1044  }
1045 
1046  void ParticleVertexFitterModule::addIPProfileToKFit(analysis::VertexFitKFit& kv)
1047  {
1048  HepPoint3D pos(0.0, 0.0, 0.0);
1049  CLHEP::HepSymMatrix covMatrix(3, 0);
1050 
1051  for (int i = 0; i < 3; i++) {
1052  pos[i] = m_BeamSpotCenter(i);
1053  for (int j = 0; j < 3; j++) {
1054  covMatrix[i][j] = m_beamSpotCov(i, j);
1055  }
1056  }
1057 
1058  kv.setIpProfile(pos, covMatrix);
1059  }
1060 
1061  void ParticleVertexFitterModule::addIPTubeToKFit(analysis::VertexFitKFit& kv)
1062  {
1063  CLHEP::HepSymMatrix err(7, 0);
1064 
1065  for (int i = 0; i < 3; i++) {
1066  for (int j = 0; j < 3; j++) {
1067  err[i + 4][j + 4] = m_beamSpotCov(i, j);
1068  }
1069  }
1070 
1071  PCmsLabTransform T;
1072  TLorentzVector iptube_mom = T.getBeamFourMomentum();
1073 
1074  kv.setIpTubeProfile(
1075  ROOTToCLHEP::getHepLorentzVector(iptube_mom),
1076  ROOTToCLHEP::getPoint3D(m_BeamSpotCenter),
1077  err,
1078  0.);
1079  }
1080 
1081  void ParticleVertexFitterModule::findConstraintBoost(double cut)
1082  {
1083  PCmsLabTransform T;
1084 
1085  TVector3 boost = T.getBoostVector();
1086  TVector3 boostDir = boost.Unit();
1087 
1088  TMatrixDSym beamSpotCov = m_beamSpotDB->getCovVertex();
1089  beamSpotCov(2, 2) = cut * cut;
1090  double thetab = boostDir.Theta();
1091  double phib = boostDir.Phi();
1092 
1093  double stb = TMath::Sin(thetab);
1094  double ctb = TMath::Cos(thetab);
1095  double spb = TMath::Sin(phib);
1096  double cpb = TMath::Cos(phib);
1097 
1098 
1099  TMatrix rz(3, 3); rz(2, 2) = 1;
1100  rz(0, 0) = cpb; rz(0, 1) = spb;
1101  rz(1, 0) = -1 * spb; rz(1, 1) = cpb;
1102 
1103  TMatrix ry(3, 3); ry(1, 1) = 1;
1104  ry(0, 0) = ctb; ry(0, 2) = -1 * stb;
1105  ry(2, 0) = stb; ry(2, 2) = ctb;
1106 
1107  TMatrix r(3, 3); r.Mult(rz, ry);
1108  TMatrix rt(3, 3); rt.Transpose(r);
1109 
1110  TMatrix TubePart(3, 3); TubePart.Mult(rt, beamSpotCov);
1111  TMatrix Tube(3, 3); Tube.Mult(TubePart, r);
1112 
1113  m_beamSpotCov(0, 0) = Tube(0, 0); m_beamSpotCov(0, 1) = Tube(0, 1); m_beamSpotCov(0, 2) = Tube(0, 2);
1114  m_beamSpotCov(1, 0) = Tube(1, 0); m_beamSpotCov(1, 1) = Tube(1, 1); m_beamSpotCov(1, 2) = Tube(1, 2);
1115  m_beamSpotCov(2, 0) = Tube(2, 0); m_beamSpotCov(2, 1) = Tube(2, 1); m_beamSpotCov(2, 2) = Tube(2, 2);
1116  }
1117 
1118  void ParticleVertexFitterModule::smearBeamSpot(double width)
1119  {
1120  TMatrixDSym beamSpotCov = m_beamSpotDB->getCovVertex();
1121  for (int i = 0; i < 3; i++)
1122  beamSpotCov(i, i) += width * width;
1123 
1124  m_beamSpotCov = beamSpotCov;
1125  }
1127 } // end Belle2 namespace
Belle2::analysis::MassPointingVertexFitKFit::setProductionVertex
enum KFitError::ECode setProductionVertex(const HepPoint3D &v)
Set the production vertex of the particle.
Definition: MassPointingVertexFitKFit.cc:52
Belle2::analysis::VertexFitKFit::getVertexError
const CLHEP::HepSymMatrix getVertexError(void) const
Get a fitted vertex error matrix.
Definition: VertexFitKFit.cc:133
Belle2::analysis::VertexFitKFit::setIpTubeProfile
enum KFitError::ECode setIpTubeProfile(const CLHEP::HepLorentzVector &p, const HepPoint3D &x, const CLHEP::HepSymMatrix &e, const double q)
Set a virtual IP-tube track for the vertex constraint fit.
Definition: VertexFitKFit.cc:82
Belle2::analysis::RaveVertexFitter::getPValue
double getPValue(VecSize vertexId=0) const
get the p value of the fitted vertex.
Definition: RaveVertexFitter.cc:206
Belle2::analysis::VertexFitKFit::getVertex
const HepPoint3D getVertex(const int flag=KFitConst::kAfterFit) const
Get a vertex position.
Definition: VertexFitKFit.cc:114
Belle2::analysis::RaveKinematicVertexFitter::getPValue
double getPValue()
get the p value of the fitted vertex.
Definition: RaveKinematicVertexFitter.cc:418
Belle2::analysis::RaveVertexFitter::getPos
TVector3 getPos(VecSize vertexId=0) const
get the position of the fitted vertex.
Definition: RaveVertexFitter.cc:169
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::analysis::MassFitKFit
MassFitKFit is a derived class from KFitBase to perform mass-constraint kinematical fit.
Definition: MassFitKFit.h:34
Belle2::analysis::KFitBase::getTrackError
const CLHEP::HepSymMatrix getTrackError(const int id) const
Get an error matrix of the track.
Definition: KFitBase.cc:169
Belle2::analysis::FourCFitKFit
FourCFitKFit is a derived class from KFitBase to perform 4 momentum-constraint kinematical fit.
Definition: FourCFitKFit.h:32
Belle2::analysis::RaveKinematicVertexFitter::getVertexErrorMatrix
TMatrixDSym getVertexErrorMatrix()
get the covariance matrix (3x3) of the of the fitted vertex position.
Definition: RaveKinematicVertexFitter.cc:438
Belle2::analysis::RaveKinematicVertexFitter::updateMother
void updateMother()
update the mother particle
Definition: RaveKinematicVertexFitter.cc:326
Belle2::Btube
For each MCParticle with hits in the CDC, this class stores some summarising information on those hit...
Definition: Btube.h:38
Belle2::analysis::MassPointingVertexFitKFit::setInvariantMass
enum KFitError::ECode setInvariantMass(const double m)
Set an invariant mass for the mass-vertex-pointing constraint fit.
Definition: MassPointingVertexFitKFit.cc:44
Belle2::analysis::MassVertexFitKFit::updateMother
enum KFitError::ECode updateMother(Particle *mother)
Update mother particle.
Definition: MassVertexFitKFit.cc:571
Belle2::Particle::updateMomentum
void updateMomentum(const TLorentzVector &p4, const TVector3 &vertex, const TMatrixFSym &errMatrix, float pValue)
Sets Lorentz vector, position, 7x7 error matrix and p-value.
Definition: Particle.h:328
Belle2::Particle::getDaughter
const Particle * getDaughter(unsigned i) const
Returns a pointer to the i-th daughter particle.
Definition: Particle.cc:595
Belle2::analysis::FourCFitKFit::doFit
enum KFitError::ECode doFit(void)
Perform a four momentum-constraint fit.
Definition: FourCFitKFit.cc:291
Belle2::analysis::VertexFitKFit::setIpProfile
enum KFitError::ECode setIpProfile(const HepPoint3D &ip, const CLHEP::HepSymMatrix &ipe)
Set an IP-ellipsoid shape for the vertex constraint fit.
Definition: VertexFitKFit.cc:65
Belle2::analysis::MassPointingVertexFitKFit::updateMother
enum KFitError::ECode updateMother(Particle *mother)
Update mother particle.
Definition: MassPointingVertexFitKFit.cc:604
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::analysis::MassPointingVertexFitKFit
MassPointingVertexFitKFit is a derived class from KFitBase It performs a kinematical fit with three c...
Definition: MassPointingVertexFitKFit.h:36
Belle2::analysis::FourCFitKFit::updateMother
enum KFitError::ECode updateMother(Particle *mother)
Update mother particle.
Definition: FourCFitKFit.cc:665
Belle2::analysis::RaveKinematicVertexFitter::addTrack
void addTrack(const Particle *aParticlePtr)
add a track (in the format of a Belle2::Particle) to set of tracks that should be fitted to a vertex
Definition: RaveKinematicVertexFitter.cc:70
Belle2::analysis::KFitBase::getTrackCount
int getTrackCount(void) const
Get the number of added tracks.
Definition: KFitBase.cc:108
Belle2::analysis::MassFitKFit::setInvariantMass
enum KFitError::ECode setInvariantMass(const double m)
Set an invariant mass for the mass-constraint fit.
Definition: MassFitKFit.cc:68
Belle2::analysis::KFitBase::setMagneticField
enum KFitError::ECode setMagneticField(const double mf)
Change a magnetic field from the default value KFitConst::kDefaultMagneticField.
Definition: KFitBase.cc:94
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::analysis::KFitBase::addParticle
enum KFitError::ECode addParticle(const Particle *particle)
Add a particle to the fitter.
Definition: KFitBase.cc:60
Belle2::analysis::VertexFitKFit::updateMother
enum KFitError::ECode updateMother(Particle *mother)
Update mother particle.
Definition: VertexFitKFit.cc:906
Belle2::analysis::KFitBase::getNDF
virtual int getNDF(void) const
Get an NDF of the fit.
Definition: KFitBase.cc:115
Belle2::Particle::getMomentumVertexErrorMatrix
TMatrixFSym getMomentumVertexErrorMatrix() const
Returns 7x7 error matrix.
Definition: Particle.cc:386
Belle2::PCmsLabTransform::getBeamFourMomentum
TLorentzVector getBeamFourMomentum() const
Returns LAB four-momentum of e+e-.
Definition: PCmsLabTransform.h:65
Belle2::analysis::MassFitKFit::setVertex
enum KFitError::ECode setVertex(const HepPoint3D &v)
Set an initial vertex position for the mass-constraint fit.
Definition: MassFitKFit.cc:44
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::ParticleVertexFitterModule
Vertex fitter module.
Definition: ParticleVertexFitterModule.h:55
Belle2::analysis::MassFitKFit::setVertexError
enum KFitError::ECode setVertexError(const CLHEP::HepSymMatrix &e)
Set an initial vertex error matrix for the mass-constraint fit.
Definition: MassFitKFit.cc:52
Belle2::analysis::MassFitKFit::updateMother
enum KFitError::ECode updateMother(Particle *mother)
Update mother particle.
Definition: MassFitKFit.cc:696
Belle2::analysis::RaveKinematicVertexFitter::setVertFit
void setVertFit(bool isVertFit=true)
Set vertex fit: set false in case of mass fit only.
Definition: RaveKinematicVertexFitter.cc:63
Belle2::Btube::getTubeMatrix
TMatrixFSym getTubeMatrix() const
Returns Btube matrix.
Definition: Btube.h:89
Belle2::analysis::MassVertexFitKFit::setInvariantMass
enum KFitError::ECode setInvariantMass(const double m)
Set an invariant mass for the mass-vertex constraint fit.
Definition: MassVertexFitKFit.cc:54
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::Btube::getTubeCenter
Eigen::Matrix< double, 3, 1 > getTubeCenter() const
Returns Btube center.
Definition: Btube.h:75
Belle2::analysis::RaveKinematicVertexFitter::fit
int fit()
do the kinematic vertex fit with all tracks previously added with the addTrack or addMother function.
Definition: RaveKinematicVertexFitter.cc:131
Belle2::analysis::VertexFitKFit::doFit
enum KFitError::ECode doFit(void)
Perform a vertex-constraint fit.
Definition: VertexFitKFit.cc:216
Belle2::analysis::MassPointingVertexFitKFit::doFit
enum KFitError::ECode doFit(void)
Perform a mass-vertex-pointing constraint fit.
Definition: MassPointingVertexFitKFit.cc:199
Belle2::analysis::RaveKinematicVertexFitter::addMother
void addMother(const Particle *aMotherParticlePtr)
All daughters of the argument of this function will be used as input for the vertex fit.
Definition: RaveKinematicVertexFitter.cc:107
Belle2::Particle
Class to store reconstructed particles.
Definition: Particle.h:77
Belle2::analysis::RaveKinematicVertexFitter::updateDaughters
void updateDaughters()
update the Daughters particles
Definition: RaveKinematicVertexFitter.cc:331
Belle2::analysis::RaveKinematicVertexFitter
The RaveKinematicVertexFitter class is part of the RaveInterface together with RaveSetup.
Definition: RaveKinematicVertexFitter.h:52
Belle2::PCmsLabTransform
Class to hold Lorentz transformations from/to CMS and boost vector.
Definition: PCmsLabTransform.h:37
Belle2::analysis::MassFitKFit::doFit
enum KFitError::ECode doFit(void)
Perform a mass-constraint fit.
Definition: MassFitKFit.cc:280
Belle2::analysis::RaveKinematicVertexFitter::getPos
TVector3 getPos()
get the position of the fitted vertex.
Definition: RaveKinematicVertexFitter.cc:413
Belle2::analysis::FourCFitKFit::getCHIsq
double getCHIsq(void) const override
Get a chi-square of the fit.
Definition: FourCFitKFit.cc:204
Belle2::analysis::KFitBase::getTrackPosition
const HepPoint3D getTrackPosition(const int id) const
Get a position of the track.
Definition: KFitBase.cc:162
Belle2::Particle::getPDGMass
float getPDGMass(void) const
Returns uncertaint on the invariant mass (requiers valid momentum error matrix)
Definition: Particle.cc:577
Belle2::analysis::RaveKinematicVertexFitter::setMother
void setMother(const Particle *aMotherParticlePtr)
Set Mother particle for Vertex/momentum update.
Definition: RaveKinematicVertexFitter.cc:123
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::analysis::KFitError::ECode
ECode
ECode is a error code enumerate.
Definition: KFitError.h:43
HepGeom::Point3D< double >
Belle2::analysis::RaveKinematicVertexFitter::setMassConstFit
void setMassConstFit(bool isConstFit=true)
Set mass constrained fit
Definition: RaveKinematicVertexFitter.cc:58
Belle2::Particle::get4Vector
TLorentzVector get4Vector() const
Returns Lorentz vector.
Definition: Particle.h:464
Belle2::analysis::FourCFitKFit::setFourMomentum
enum KFitError::ECode setFourMomentum(const TLorentzVector &m)
Set an 4 Momentum for the FourC-constraint fit.
Definition: FourCFitKFit.cc:79
Belle2::analysis::MassVertexFitKFit::doFit
enum KFitError::ECode doFit(void)
Perform a mass-vertex-constraint fit.
Definition: MassVertexFitKFit.cc:201
Belle2::analysis::RaveVertexFitter
The RaveVertexFitter class is part of the RaveInterface together with RaveSetup.
Definition: RaveVertexFitter.h:46
Belle2::analysis::MassVertexFitKFit
MassVertexFitKFit is a derived class from KFitBase to perform mass-vertex-constraint kinematical fit.
Definition: MassVertexFitKFit.h:34
Belle2::analysis::VertexFitKFit
VertexFitKFit is a derived class from KFitBase to perform vertex-constraint kinematical fit.
Definition: VertexFitKFit.h:33
Belle2::analysis::KFitBase::getTrackMomentum
const CLHEP::HepLorentzVector getTrackMomentum(const int id) const
Get a Lorentz vector of the track.
Definition: KFitBase.cc:155