FairRoot/PandaRoot
Public Member Functions | Private Types | Private Attributes | List of all members
DecayTreeFitter::DecayChain Class Reference

#include <DecayChain.h>

Public Member Functions

 DecayChain ()
 
 DecayChain (RhoCandidate *bc, const Configuration &config)
 
 DecayChain (RhoCandidate *bc, const RhoVector3Err &pv, const Configuration &config)
 
 DecayChain (RhoCandidate *bc, const RhoLorentzVectorErr &lv, const Configuration &config)
 
 DecayChain (RhoCandidate *bc, const RhoLorentzVectorErr &lv, const RhoVector3Err &pv, const Configuration &config)
 
virtual ~DecayChain ()
 
int dim () const
 
void initConstraintList ()
 
ErrCode init (FitParams *par)
 
ErrCode filter (FitParams *par, bool firstpass=true)
 
double chiSquare (const FitParams *par) const
 
ParticleBasemother ()
 
const ParticleBasecand ()
 
const ParticleBasemother () const
 
const ParticleBaselocate (RhoCandidate *bc) const
 
int index (RhoCandidate *bc) const
 
int posIndex (RhoCandidate *bc) const
 
int momIndex (RhoCandidate *bc) const
 
int lenIndex (RhoCandidate *bc) const
 
void setOwner (bool b)
 
void printConstraints (std::ostream &os=std::cout) const
 
void setMassConstraint (RhoCandidate *bc, bool add=true)
 
void setMassConstraint (RhoCandidate *bc, double mass)
 
ChiSquare chiSquare (RhoCandidate *bc, const FitParams *fitpars) const
 

Private Types

typedef std::map< RhoCandidate
*, const ParticleBase * > 
ParticleMap
 

Private Attributes

int m_dim
 
ParticleBasem_mother
 
const ParticleBasem_cand
 
ParticleBase::constraintlist m_constraintlist
 
std::vector< Constraint * > m_mergedconstraintlist
 
MergedConstraint m_mergedconstraint
 
ParticleMap m_particleMap
 
bool m_isOwner
 

Detailed Description

Definition at line 26 of file DecayChain.h.

Member Typedef Documentation

Definition at line 72 of file DecayChain.h.

Constructor & Destructor Documentation

DecayTreeFitter::DecayChain::DecayChain ( )
inline

Definition at line 29 of file DecayChain.h.

29 : m_mother(0) {}
ParticleBase * m_mother
Definition: DecayChain.h:67
DecayTreeFitter::DecayChain::DecayChain ( RhoCandidate bc,
const Configuration config 
)

Definition at line 30 of file DecayChain.cxx.

References locate(), m_cand, m_dim, m_mother, and DecayTreeFitter::ParticleBase::updateIndex().

31 : m_dim(0),m_mother(0),m_isOwner(true)
32 {
33  //std::cout<<"DecayTreeFitter::DecayChain::DecayChain(RhoCandidate* bc="<<bc<<")"<<std::endl;
34  m_mother = (ParticleBase*) new InteractionPoint(bc,config) ;
35  //m_mother = ParticleBase::createParticle(bc,0,config) ;
36  //std::cout<<"DecayTreeFitter::DecayChain::DecayChain(RhoCandidate*) - updateIndex() now"<<std::endl;
38  //std::cout<<"DecayTreeFitter::DecayChain::DecayChain(RhoCandidate*) - locate() now"<<std::endl;
39  m_cand = locate(bc) ;
40  //std::cout<<"DecayTreeFitter::DecayChain::DecayChain(RhoCandidate*) - done"<<std::endl;
41 }
ParticleBase * m_mother
Definition: DecayChain.h:67
virtual void updateIndex(int &offset)
const ParticleBase * m_cand
Definition: DecayChain.h:68
const ParticleBase * locate(RhoCandidate *bc) const
Definition: DecayChain.cxx:201
DecayTreeFitter::DecayChain::DecayChain ( RhoCandidate bc,
const RhoVector3Err pv,
const Configuration config 
)

Definition at line 43 of file DecayChain.cxx.

References locate(), m_cand, m_dim, m_mother, and DecayTreeFitter::ParticleBase::updateIndex().

44 : m_dim(0),m_mother(0),m_isOwner(true)
45 {
46  //std::cout<<"DecayTreeFitter::DecayChain::DecayChain(RhoCandidate* bc="<<bc<<",RhoVector3Err v("<<pv.x()<<","<<pv.y()<<","<<pv.z()<<"))"<<std::endl;
47  m_mother = (ParticleBase*) new InteractionPoint(pv,bc,config) ;
48  //std::cout<<"DecayTreeFitter::DecayChain::DecayChain(RhoCandidate*,RhoVector3Err) - updateIndex() now"<<std::endl;
50  //std::cout<<"DecayTreeFitter::DecayChain::DecayChain(RhoCandidate*,RhoVector3Err) - locate() now"<<std::endl;
51  m_cand = locate(bc) ;
52  //std::cout<<"DecayTreeFitter::DecayChain::DecayChain(RhoCandidate*,RhoVector3Err) - done"<<std::endl;
53 }
ParticleBase * m_mother
Definition: DecayChain.h:67
virtual void updateIndex(int &offset)
const ParticleBase * m_cand
Definition: DecayChain.h:68
const ParticleBase * locate(RhoCandidate *bc) const
Definition: DecayChain.cxx:201
DecayTreeFitter::DecayChain::DecayChain ( RhoCandidate bc,
const RhoLorentzVectorErr lv,
const Configuration config 
)

Definition at line 55 of file DecayChain.cxx.

References locate(), m_cand, m_dim, m_mother, and DecayTreeFitter::ParticleBase::updateIndex().

56 : m_dim(0),m_mother(0),m_isOwner(true)
57 {
58  //std::cout<<"DecayTreeFitter::DecayChain::DecayChain(RhoCandidate* bc="<<bc<<",RhoLorentzVectorErr p("<<lv.X()<<","<<lv.Y()<<","<<lv.Z()<<","<<lv.E()<<"))"<<std::endl;
59  m_mother = (ParticleBase*) new InteractionPoint(lv,bc,config) ;
60  //std::cout<<"DecayTreeFitter::DecayChain::DecayChain(RhoCandidate*,RhoVector3Err) - updateIndex() now"<<std::endl;
62  //std::cout<<"DecayTreeFitter::DecayChain::DecayChain(RhoCandidate*,RhoVector3Err) - locate() now"<<std::endl;
63  m_cand = locate(bc) ;
64  //std::cout<<"DecayTreeFitter::DecayChain::DecayChain(RhoCandidate*,RhoVector3Err) - done"<<std::endl;
65 }
ParticleBase * m_mother
Definition: DecayChain.h:67
virtual void updateIndex(int &offset)
const ParticleBase * m_cand
Definition: DecayChain.h:68
const ParticleBase * locate(RhoCandidate *bc) const
Definition: DecayChain.cxx:201
DecayTreeFitter::DecayChain::DecayChain ( RhoCandidate bc,
const RhoLorentzVectorErr lv,
const RhoVector3Err pv,
const Configuration config 
)

Definition at line 67 of file DecayChain.cxx.

References locate(), m_cand, m_dim, m_mother, and DecayTreeFitter::ParticleBase::updateIndex().

68 : m_dim(0),m_mother(0),m_isOwner(true)
69 {
70  //std::cout<<"DecayTreeFitter::DecayChain::DecayChain(RhoCandidate* bc="<<bc<<",RhoLorentzVectorErr p("<<lv.X()<<","<<lv.Y()<<","<<lv.Z()<<","<<lv.E()<<")"<<",RhoVector3Err v("<<pv.x()<<","<<pv.y()<<","<<pv.z()<<"))"<<std::endl;
71  m_mother = (ParticleBase*) new InteractionPoint(lv,pv,bc,config) ;
72  //std::cout<<"DecayTreeFitter::DecayChain::DecayChain(RhoCandidate*,RhoVector3Err) - updateIndex() now"<<std::endl;
74  //std::cout<<"DecayTreeFitter::DecayChain::DecayChain(RhoCandidate*,RhoVector3Err) - locate() now"<<std::endl;
75  m_cand = locate(bc) ;
76  //std::cout<<"DecayTreeFitter::DecayChain::DecayChain(RhoCandidate*,RhoVector3Err) - done"<<std::endl;
77 }
ParticleBase * m_mother
Definition: DecayChain.h:67
virtual void updateIndex(int &offset)
const ParticleBase * m_cand
Definition: DecayChain.h:68
const ParticleBase * locate(RhoCandidate *bc) const
Definition: DecayChain.cxx:201
DecayTreeFitter::DecayChain::~DecayChain ( )
virtual

Definition at line 79 of file DecayChain.cxx.

80 {
81  if(m_mother && m_isOwner) delete m_mother ;
82 }
ParticleBase * m_mother
Definition: DecayChain.h:67

Member Function Documentation

const ParticleBase* DecayTreeFitter::DecayChain::cand ( )
inline

Definition at line 46 of file DecayChain.h.

References m_cand.

46 { return m_cand ; }
const ParticleBase * m_cand
Definition: DecayChain.h:68
double DecayTreeFitter::DecayChain::chiSquare ( const FitParams par) const

Definition at line 195 of file DecayChain.cxx.

196 {
197  return m_mother->chiSquareD(par) ;
198 }
ParticleBase * m_mother
Definition: DecayChain.h:67
virtual double chiSquareD(const FitParams *) const
ChiSquare DecayTreeFitter::DecayChain::chiSquare ( RhoCandidate bc,
const FitParams fitpars 
) const

Definition at line 298 of file DecayChain.cxx.

References DecayTreeFitter::ParticleBase::chiSquare(), DecayTreeFitter::ParticleBase::mother(), and DecayTreeFitter::ParticleBase::posIndex().

298  {
299  const ParticleBase* base = locate(bc) ;
300  ChiSquare chisq ;
301  if( base ) {
302  chisq = base->chiSquare(fitpars) ;
303  // uhh: need to subtract the lifetime dof if this particle has a
304  // mother with a different vertex
305  if( base->mother() && base->posIndex()>=0 &&
306  base->posIndex() != base->mother()->posIndex() )
307  chisq += ChiSquare(0,1) ;
308  }
309  return chisq ;
310 }
virtual int posIndex() const
Definition: ParticleBase.h:69
ChiSquare chiSquare(const FitParams *fitparams) const
const ParticleBase * locate(RhoCandidate *bc) const
Definition: DecayChain.cxx:201
const ParticleBase * mother() const
Definition: ParticleBase.h:60
int DecayTreeFitter::DecayChain::dim ( ) const
inline

Definition at line 38 of file DecayChain.h.

References m_dim.

38 { return m_dim ; }
ErrCode DecayTreeFitter::DecayChain::filter ( FitParams par,
bool  firstpass = true 
)

Definition at line 145 of file DecayChain.cxx.

References DecayTreeFitter::ErrCode::failure(), DecayTreeFitter::ErrCode::Print(), DecayTreeFitter::FitParams::resetCov(), status, DecayTreeFitter::FitParams::testCov(), and vtxverbose.

146 {
147  if(vtxverbose>=4){std::cout<<"DecayChain::filter(): - ok, let's do this! Btw. we're "<<( firstpass ? "" : "not ")<<"on first pass."<<std::endl;}
148  ErrCode status ;
149  if(m_constraintlist.empty()){
150  if(vtxverbose>=4){std::cout<<"DecayChain::filter(): - init constrains"<<std::endl;}
152  }
153 
154  par->resetCov(1000) ; //FIXME: this scales the cov with a factor 1000. WHY???
155  //par->resetCov(100) ; //FIXME: this scales the cov with a factor 1000. WHY???
156  if(firstpass || !par->testCov()){
157  status |= m_mother->initCov(par) ;
158  if(vtxverbose>=3){std::cout<<"DecayChain::filter(): - initcov done"<<std::endl;}
159  }
160 
161  if( vtxverbose>=4 || (vtxverbose>=2&&firstpass) ) {
162  std::cout << "DecayTreeFitter::DecayChain::filter, after initialization: " << std::endl ;
163  m_mother->print(par) ;
164  }
165 
166  FitParams* reference = new FitParams(*par) ;
167 
168  if(m_mergedconstraintlist.empty() ) {
169  for( ParticleBase::constraintlist::const_iterator it = m_constraintlist.begin() ;
170  it != m_constraintlist.end(); ++it) {
171  status |= it->filter(par,reference) ;
172  if( vtxverbose>=2 && status.failure() ) {
173  std::cout << "DecayChain::filter(): status is failure after parsing constraint: " ;
174  it->print() ;
175  }
176  }
177  } else {
178  for( std::vector<Constraint*>::const_iterator it = m_mergedconstraintlist.begin() ;
179  it != m_mergedconstraintlist.end(); ++it) {
180  status |= (*it)->filter(par,reference) ;
181  if( vtxverbose>=2 && status.failure() ) {
182  std::cout << "DecayChain::filter(): status is failure after parsing constraint: " ;
183  (*it)->print() ;
184  }
185  }
186  }
187 
188 
189  if(vtxverbose>=3) {std::cout << "DecayChain::filter: status = "; status.Print(std::cout); std::cout<< std::endl ;}
190  if(reference) delete reference;
191  return status ;
192 }
ParticleBase * m_mother
Definition: DecayChain.h:67
ParticleBase::constraintlist m_constraintlist
Definition: DecayChain.h:69
bool failure() const
Definition: ErrCode.h:45
virtual ErrCode initCov(FitParams *) const
void Print(std::ostream &os)
Definition: ErrCode.cxx:34
int vtxverbose
void resetCov(double scale=100)
Definition: FitParams.cxx:43
virtual void print(const FitParams *) const
std::vector< Constraint * > m_mergedconstraintlist
Definition: DecayChain.h:70
int status[10]
Definition: f_Init.h:28
int DecayTreeFitter::DecayChain::index ( RhoCandidate bc) const

Definition at line 272 of file DecayChain.cxx.

References DecayTreeFitter::ParticleBase::index().

272  {
273  int rc = -1 ;
274  const ParticleBase* base = locate(bc) ;
275  if(base) rc = base->index() ;
276  return rc ;
277 }
virtual int index() const
Definition: ParticleBase.h:59
const ParticleBase * locate(RhoCandidate *bc) const
Definition: DecayChain.cxx:201
ErrCode DecayTreeFitter::DecayChain::init ( FitParams par)

FIXME Here we have some bad behavior: We're using automatic copy constructor, implicit copied objects etc. How to do cleanly? Pointers directly with delete/new?

Definition at line 114 of file DecayChain.cxx.

References DecayTreeFitter::FitParams::dim(), DecayTreeFitter::ErrCode::Print(), DecayTreeFitter::FitParams::reset(), DecayTreeFitter::FitParams::resetCov(), DecayTreeFitter::FitParams::resetPar(), status, and vtxverbose.

115 {
116  if(vtxverbose>5){std::cout<<"DecayChain::init(): - start"<<std::endl;}
117  ErrCode status ;
119  if( m_dim==0 ){
120  if(vtxverbose>5){std::cout<<"DecayChain::init(): - update index"<<std::endl;}
122  }
123  //if( par.dim() != m_dim ) par = FitParams(m_dim) ;
124  if( par->dim() != m_dim ){
125  if(vtxverbose>5){std::cout<<"DecayChain::init(): - reset 1"<<std::endl;}
126  par->reset(m_dim);
127  } else {
128  // set everything to 0
129  if(vtxverbose>5){std::cout<<"DecayChain::init(): - reset 2"<<std::endl;}
130  par->resetPar() ;
131  par->resetCov() ;
132  }
133  // let the mother do it
134  if(vtxverbose>5){std::cout<<"DecayChain::init(): - initpar"<<std::endl;}
135  status |= m_mother->initPar1(par) ;
136  if(vtxverbose>5){std::cout<<"DecayChain::init(): - initcov"<<std::endl;}
137  status |= m_mother->initCov(par) ;
138 
139  if(vtxverbose>=2){ std::cout << "status after init: "; status.Print(std::cout); std::cout<< std::endl ;}
140 
141  return status ;
142 }
ParticleBase * m_mother
Definition: DecayChain.h:67
virtual ErrCode initCov(FitParams *) const
void Print(std::ostream &os)
Definition: ErrCode.cxx:34
int vtxverbose
virtual void updateIndex(int &offset)
void resetCov(double scale=100)
Definition: FitParams.cxx:43
virtual ErrCode initPar1(FitParams *)=0
void reset(int newdim)
Definition: FitParams.cxx:100
int status[10]
Definition: f_Init.h:28
void DecayTreeFitter::DecayChain::initConstraintList ( )

Definition at line 85 of file DecayChain.cxx.

References vtxverbose.

86 {
87  if( m_dim==0 ) m_mother->updateIndex(m_dim) ;
88  m_constraintlist.clear() ;
90 
91  // the order of the constraints is a rather delicate thing
92  std::sort(m_constraintlist.begin(),m_constraintlist.end()) ;
93 
94  // merge all non-lineair constraints
95  m_mergedconstraintlist.clear() ;
96  if(false) {
98  for( ParticleBase::constraintlist::iterator it = m_constraintlist.begin() ;
99  it != m_constraintlist.end(); ++it) {
100  if( it->isLineair() ) m_mergedconstraintlist.push_back(&(*it)) ;
101  else m_mergedconstraint.push_back(&(*it)) ;
102  }
103  if( m_mergedconstraint.dim()>0 )
105  }
106  if(vtxverbose>=2) {
107  std::cout << "DecayTreeFitter::DecayChain::initConstraintList(): " << m_constraintlist.size() << " "
108  << m_mergedconstraintlist.size()<< std::endl ;
109  printConstraints() ;
110  }
111 }
ParticleBase * m_mother
Definition: DecayChain.h:67
ParticleBase::constraintlist m_constraintlist
Definition: DecayChain.h:69
virtual void addToConstraintList(constraintlist &alist, int depth) const =0
int vtxverbose
MergedConstraint m_mergedconstraint
Definition: DecayChain.h:71
virtual void updateIndex(int &offset)
unsigned int dim() const
Definition: Constraint.h:51
void printConstraints(std::ostream &os=std::cout) const
Definition: DecayChain.cxx:21
std::vector< Constraint * > m_mergedconstraintlist
Definition: DecayChain.h:70
int DecayTreeFitter::DecayChain::lenIndex ( RhoCandidate bc) const

Definition at line 292 of file DecayChain.cxx.

References DecayTreeFitter::ParticleBase::lenIndex().

292  {
293  const ParticleBase* base = locate(bc) ;
294  return base ? base->lenIndex() : 0 ;
295 }
virtual int lenIndex() const
Definition: ParticleBase.h:70
const ParticleBase * locate(RhoCandidate *bc) const
Definition: DecayChain.cxx:201
const ParticleBase * DecayTreeFitter::DecayChain::locate ( RhoCandidate bc) const

Definition at line 201 of file DecayChain.cxx.

References DecayTreeFitter::ParticleBase::locate(), and DecayTreeFitter::ParticleBase::particle().

Referenced by DecayChain().

201  {
202  const ParticleBase* rc(0) ;
203  // return m_mother->locate(bc) ;
204  ParticleMap::const_iterator it = m_particleMap.find(bc) ;
205  if( it == m_particleMap.end() ) {
206  rc = m_mother->locate(bc) ;
207  // used to add every candidate here, but something goes wrong
208  // somewhere. now only cache pointers that we internally reference.
209  if(rc) m_particleMap[rc->particle()] = rc ;
210  } else {
211  rc = it->second ;
212  }
213  return rc ;
214 }
ParticleBase * m_mother
Definition: DecayChain.h:67
const ParticleBase * locate(RhoCandidate *bc) const
int DecayTreeFitter::DecayChain::momIndex ( RhoCandidate bc) const

Definition at line 286 of file DecayChain.cxx.

References DecayTreeFitter::ParticleBase::momIndex().

286  {
287  const ParticleBase* base = locate(bc) ;
288  return base ? base->momIndex() : -1 ;
289 }
virtual int momIndex() const
Definition: ParticleBase.h:71
const ParticleBase * locate(RhoCandidate *bc) const
Definition: DecayChain.cxx:201
ParticleBase* DecayTreeFitter::DecayChain::mother ( )
inline

Definition at line 45 of file DecayChain.h.

References m_mother.

45 { return m_mother ; }
ParticleBase * m_mother
Definition: DecayChain.h:67
const ParticleBase* DecayTreeFitter::DecayChain::mother ( ) const
inline

Definition at line 47 of file DecayChain.h.

References m_mother.

47 { return m_mother ; }
ParticleBase * m_mother
Definition: DecayChain.h:67
int DecayTreeFitter::DecayChain::posIndex ( RhoCandidate bc) const

Definition at line 280 of file DecayChain.cxx.

References DecayTreeFitter::ParticleBase::posIndex().

280  {
281  const ParticleBase* base = locate(bc) ;
282  return base ? base->posIndex() : -1 ;
283 }
virtual int posIndex() const
Definition: ParticleBase.h:69
const ParticleBase * locate(RhoCandidate *bc) const
Definition: DecayChain.cxx:201
void DecayTreeFitter::DecayChain::printConstraints ( std::ostream os = std::cout) const

Definition at line 21 of file DecayChain.cxx.

22 {
23  os << "Constraints in decay tree: " << m_constraintlist.size() << std::endl ;
24  for( ParticleBase::constraintlist::const_iterator
25  it = m_constraintlist.begin() ;
26  it != m_constraintlist.end(); ++it)
27  it->print(os) ;
28 }
ParticleBase::constraintlist m_constraintlist
Definition: DecayChain.h:69
void DecayTreeFitter::DecayChain::setMassConstraint ( RhoCandidate bc,
bool  add = true 
)

Definition at line 217 of file DecayChain.cxx.

References DecayTreeFitter::ParticleBase::setMassConstraint().

218 {
219  ParticleBase* part = const_cast<ParticleBase*>(locate(bc)) ;
220  if(part && part->setMassConstraint(add)) {
221  m_dim = 0 ;
222  m_constraintlist.clear() ;
223  }
224 }
ParticleBase::constraintlist m_constraintlist
Definition: DecayChain.h:69
bool setMassConstraint(bool add)
Definition: ParticleBase.h:118
const ParticleBase * locate(RhoCandidate *bc) const
Definition: DecayChain.cxx:201
void DecayTreeFitter::DecayChain::setMassConstraint ( RhoCandidate bc,
double  mass 
)

Definition at line 227 of file DecayChain.cxx.

References DecayTreeFitter::ParticleBase::setMassConstraint().

228 {
229  ParticleBase* part = const_cast<ParticleBase*>(locate(bc)) ;
230  if(part) {
231  part->setMassConstraint(mass) ;
232  m_dim = 0 ;
233  m_constraintlist.clear() ;
234  }
235 }
ParticleBase::constraintlist m_constraintlist
Definition: DecayChain.h:69
bool setMassConstraint(bool add)
Definition: ParticleBase.h:118
const ParticleBase * locate(RhoCandidate *bc) const
Definition: DecayChain.cxx:201
void DecayTreeFitter::DecayChain::setOwner ( bool  b)
inline

Definition at line 55 of file DecayChain.h.

References b, and m_isOwner.

55 { m_isOwner=b ;}
TTree * b

Member Data Documentation

const ParticleBase* DecayTreeFitter::DecayChain::m_cand
private

Definition at line 68 of file DecayChain.h.

Referenced by cand(), and DecayChain().

ParticleBase::constraintlist DecayTreeFitter::DecayChain::m_constraintlist
private

Definition at line 69 of file DecayChain.h.

int DecayTreeFitter::DecayChain::m_dim
private

Definition at line 66 of file DecayChain.h.

Referenced by DecayChain(), and dim().

bool DecayTreeFitter::DecayChain::m_isOwner
private

Definition at line 74 of file DecayChain.h.

Referenced by setOwner().

MergedConstraint DecayTreeFitter::DecayChain::m_mergedconstraint
private

Definition at line 71 of file DecayChain.h.

std::vector<Constraint*> DecayTreeFitter::DecayChain::m_mergedconstraintlist
private

Definition at line 70 of file DecayChain.h.

ParticleBase* DecayTreeFitter::DecayChain::m_mother
private

Definition at line 67 of file DecayChain.h.

Referenced by DecayChain(), and mother().

ParticleMap DecayTreeFitter::DecayChain::m_particleMap
mutableprivate

Definition at line 73 of file DecayChain.h.


The documentation for this class was generated from the following files: