PandaRoot
ParticleBase.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 // ******************************************************
14 // DecayTreeFitter Package
15 // We thank the original author Wouter Hulsbergen
16 // (BaBar, LHCb) for providing the sources.
17 // http://arxiv.org/abs/physics/0503191v1 (2005)
18 // Adaptation & Development for PANDA: Ralf Kliemt (2015)
19 // ******************************************************
20 #ifndef PARTICLEBASE_H
21 #define PARTICLEBASE_H 1
22 #include "Rtypes.h"
23 
24 #include <string>
25 #include <vector>
26 #include "Constraint.h"
27 #include "Projection.h"
28 #include "ChiSquare.h"
29 
30 #include "RhoCandidate.h"
31 
32 namespace DecayTreeFitter {
33 class FitParams;
34 class Configuration;
35 
36 class ParticleBase {
37  public:
39  typedef std::vector<ParticleBase *> ParticleContainer;
40 
41  // 'default' constructor
43 
44  // constructor used for InteractionPoint
45  ParticleBase(const std::string &name);
46 
47  virtual ~ParticleBase();
48 
49  static ParticleBase *createParticle(RhoCandidate *bc, const ParticleBase *mother, const Configuration &config);
50 
51  virtual int dim() const = 0;
52  virtual void updateIndex(int &offset);
53  virtual ErrCode initPar1(FitParams *) = 0; // init everything that does not need mother vtx
54  virtual ErrCode initPar2(FitParams *) = 0; // everything else
55  virtual ErrCode initCov(FitParams *) const;
56  virtual std::string parname(int index) const;
57  virtual void print(const FitParams *) const;
58 
59  const ParticleBase *locate(RhoCandidate *bc) const;
60  // void locate(RhoCandidateID& pid, ParticleContainer& result ) ;
61  RhoCandidate *particle() const { return m_particle; }
62 
63  virtual int index() const { return m_index; }
64  const ParticleBase *mother() const { return m_mother; }
65  const std::string &name() const { return m_name; }
66 
67  virtual ErrCode projectGeoConstraint(const FitParams *, Projection &) const;
68  virtual ErrCode projectMassConstraint(const FitParams *, Projection &) const;
70 
71  // indices to fit parameters
72  virtual int type() const = 0;
73  virtual int posIndex() const { return -1; }
74  virtual int lenIndex() const { return -1; }
75  virtual int momIndex() const { return -1; }
76 
77  // does the particle have a 3-momentum or a 4-momentum ?
78  virtual bool hasEnergy() const { return false; }
79 
80  // does the particle have is own decay vertex ? (resonances and
81  // recoparticles do not)
82  virtual bool hasPosition() const { return false; }
83 
84  int eneIndex() const { return hasEnergy() ? momIndex() + 3 : -1; }
85 
86  // calculates the global chisquare (pretty useless)
87  virtual double chiSquareD(const FitParams *) const;
88 
89  // access to particle PDT parameters
90  double pdtMass() const { return m_pdtMass; }
91  double pdtWidth() const { return m_pdtWidth; }
92  double pdtCLifeTime() const { return m_pdtCLifeTime; }
93  double pdtTau() const { return m_pdtMass > 0 ? m_pdtCLifeTime / m_pdtMass : 0; }
94  int charge() const { return m_charge; }
95 
96  // return a trajectory
97  // virtual const LHCb::Trajectory* trajectory() const { return 0 ; }
98 
99  // access to daughters
100  typedef std::vector<ParticleBase *> daucontainer;
101  typedef daucontainer::const_iterator const_iterator;
102 
103  const daucontainer &daughters() const { return m_daughters; }
104  const_iterator begin() const { return m_daughters.begin(); }
105  const_iterator end() const { return m_daughters.end(); }
107  void removeDaughter(const ParticleBase *pb);
108 
109  typedef std::vector<std::pair<const ParticleBase *, int>> indexmap;
110  virtual void retrieveIndexMap(indexmap &anindexmap) const;
111 
112  void setMother(const ParticleBase *m) { m_mother = m; }
113 
114  typedef std::vector<DecayTreeFitter::Constraint> constraintlist;
115  virtual void addToConstraintList(constraintlist &alist, int depth) const = 0;
116  virtual int nFinalChargedCandidates() const;
117  void setParticle(RhoCandidate *bc) { m_particle = bc; }
118 
119  // collect all particles emitted from vertex with position posindex
120  void collectVertexDaughters(daucontainer &particles, int posindex);
121  // set the mass constraint for this particle. return true if value changed
122  bool setMassConstraint(bool add)
123  {
124  std::swap(add, m_hasMassConstraint);
125  return add != m_hasMassConstraint;
126  }
127  // set the mass of the mass constraint (use with care!)
128  void setMassConstraint(double mass)
129  {
130  m_hasMassConstraint = true;
131  m_pdtMass = mass;
132  }
133 
134  ChiSquare chiSquare(const FitParams *fitparams) const;
135 
136  protected:
137  static double pdtCLifeTime(RhoCandidate *bc);
138  // static bool isAResonance(RhoCandidate* bc) ;
139  static bool isAResonance(const TParticlePDG *bc); // TODO
140  // static double bFieldOverC() { return RhoCalculationTools::GetBz ( TVector3(0.,0.,0.) ) / TMath::C() ; } //FIXME: Is that an issue??? // Bz/c
141  static double bFieldOverC(); // FIXME: Is that an issue??? // Bz/c
142  ErrCode initTau(FitParams *par) const;
143  void makeName(RhoCandidate *bc);
144  daucontainer &daughters() { return m_daughters; }
145  bool hasMassConstraint() const { return m_hasMassConstraint; }
146 
147  protected:
148  void setIndex(int i) { m_index = i; }
149  void setName(const std::string &n) { m_name = n; }
150 
151  private:
152  RhoCandidate *m_particle;
153  const ParticleBase *m_mother;
154  ParticleContainer m_daughters;
155  const TParticlePDG *m_prop;
156  int m_index;
157  double m_pdtMass; // cached mass
158  double m_pdtWidth; // particle width (for mass constraints)
159  double m_pdtCLifeTime; // cached lifetime
160  int m_charge; // charge
161  std::string m_name;
162  bool m_hasMassConstraint;
163  ClassDef(ParticleBase, 1)
164 };
165 
166 } // namespace DecayTreeFitter
167 
168 #endif
std::vector< DecayTreeFitter::Constraint > constraintlist
Definition: ParticleBase.h:114
__m128 m
Definition: P4_F32vec4.h:38
const ParticleBase * mother() const
Definition: ParticleBase.h:64
RhoCandidate * particle() const
Definition: ParticleBase.h:61
virtual int posIndex() const
Definition: ParticleBase.h:73
virtual void addToConstraintList(constraintlist &alist, int depth) const =0
virtual int dim() const =0
const std::string & name() const
Definition: ParticleBase.h:65
virtual int lenIndex() const
Definition: ParticleBase.h:74
void setName(const std::string &n)
Definition: ParticleBase.h:149
virtual int nFinalChargedCandidates() const
unsigned int i
Definition: P4_F32vec4.h:33
void setMother(const ParticleBase *m)
Definition: ParticleBase.h:112
virtual ErrCode initPar2(FitParams *)=0
static bool isAResonance(const TParticlePDG *bc)
std::vector< ParticleBase * > ParticleContainer
Definition: ParticleBase.h:39
const_iterator begin() const
Definition: ParticleBase.h:104
ParticleBase * addDaughter(RhoCandidate *, const Configuration &config)
virtual ErrCode projectConstraint(Constraint::Type, const FitParams *, Projection &) const
daucontainer::const_iterator const_iterator
Definition: ParticleBase.h:101
void collectVertexDaughters(daucontainer &particles, int posindex)
ParticleBase(RhoCandidate *bc, const ParticleBase *mother)
virtual ErrCode initCov(FitParams *) const
void removeDaughter(const ParticleBase *pb)
void setParticle(RhoCandidate *bc)
Definition: ParticleBase.h:117
virtual int type() const =0
ErrCode initTau(FitParams *par) const
virtual ErrCode projectGeoConstraint(const FitParams *, Projection &) const
void setMassConstraint(double mass)
Definition: ParticleBase.h:128
virtual bool hasEnergy() const
Definition: ParticleBase.h:78
const ParticleBase * locate(RhoCandidate *bc) const
virtual ErrCode projectMassConstraint(const FitParams *, Projection &) const
const_iterator end() const
Definition: ParticleBase.h:105
virtual double chiSquareD(const FitParams *) const
const daucontainer & daughters() const
Definition: ParticleBase.h:103
virtual void print(const FitParams *) const
std::vector< std::pair< const ParticleBase *, int > > indexmap
Definition: ParticleBase.h:109
virtual ErrCode initPar1(FitParams *)=0
virtual bool hasPosition() const
Definition: ParticleBase.h:82
virtual int momIndex() const
Definition: ParticleBase.h:75
ChiSquare chiSquare(const FitParams *fitparams) const
bool setMassConstraint(bool add)
Definition: ParticleBase.h:122
virtual void retrieveIndexMap(indexmap &anindexmap) const
static ParticleBase * createParticle(RhoCandidate *bc, const ParticleBase *mother, const Configuration &config)
virtual std::string parname(int index) const
std::vector< ParticleBase * > daucontainer
Definition: ParticleBase.h:100
virtual int index() const
Definition: ParticleBase.h:63
void makeName(RhoCandidate *bc)
virtual void updateIndex(int &offset)