// ****************************************************** // DecayTreeFitter Package // We thank the original author Wouter Hulsbergen // (BaBar, LHCb) for providing the sources. // http://arxiv.org/abs/physics/0503191v1 (2005) // Adaptation & Development for PANDA: Ralf Kliemt (2015) // ****************************************************** #include "FitParams.h" #include "InteractionPoint.h" //#include "Event/Particle.h" //#include "Event/VertexBase.h" #include #include "TVector3.h" #include "TMath.h" #include "RhoVector3Err.h" using namespace DecayTreeFitter; extern int vtxverbose ; ClassImp(InteractionPoint); DecayTreeFitter::InteractionPoint::InteractionPoint(const RhoVector3Err& ipvertex, RhoCandidate* cand, const Configuration& config) : ParticleBase("IP"), m_ipPosCov(3), m_ipPosCovInv(3), m_ipMomCov(4), m_ipMomCovInv(4), m_haspos(true), m_hasmom(false) { if(vtxverbose>=2) std::cout << "InteractionPoint: start"<=2) std::cout << "InteractionPoint: daughters done"<=2) std::cout << "InteractionPoint: inverting matrix"<=2) { std::cout << "InteractionPoint: initial beam spot = (" <name() << std::endl ; } } DecayTreeFitter::InteractionPoint::InteractionPoint(const RhoLorentzVectorErr& ipmom, RhoCandidate* cand, const Configuration& config) : ParticleBase("IP"), m_ipPosCov(3), m_ipPosCovInv(3), m_ipMomCov(4), m_ipMomCovInv(4), m_haspos(false), m_hasmom(true) { if(vtxverbose>=2) std::cout << "InteractionPoint: start"<=2) std::cout << "InteractionPoint: daughters done"<=2) std::cout << "InteractionPoint: inverting matrix"<=2) { std::cout << "InteractionPoint: initial mom = (" <name() << std::endl ; } } DecayTreeFitter::InteractionPoint::InteractionPoint(const RhoLorentzVectorErr& ipmom, const RhoVector3Err& ipvertex, RhoCandidate* cand, const Configuration& config) : ParticleBase("IP"), m_ipPosCov(3), m_ipPosCovInv(3), m_ipMomCov(4), m_ipMomCovInv(4), m_haspos(true), m_hasmom(true) { if(vtxverbose>=2) std::cout << "InteractionPoint: start"<=2) std::cout << "InteractionPoint: daughters done"<=2) std::cout << "InteractionPoint: inverting matrix"<=2) std::cout << "InteractionPoint: inverting matrix"<=2) { std::cout << "InteractionPoint: initial beam spot = (" <name() << std::endl ; } } ErrCode DecayTreeFitter::InteractionPoint::initPar1(FitParams* fitparams) { ErrCode status ; if(vtxverbose>5){std::cout<<"InteractionPoint::initPar1: - start"<par()(posindex+row) = m_ipPos(row) ; } // Initialize Daugters and the whole tree for(daucontainer::iterator idau = daughters().begin() ; idau != daughters().end(); ++idau ) { if(vtxverbose>5){std::cout<<"InteractionPoint::initPar1: - calling daughter initPar1"<initPar1(fitparams) ; if(vtxverbose>5){std::cout<<"InteractionPoint::initPar1: - calling daughter initPar2"<initPar2(fitparams) ; } return status ; } ErrCode DecayTreeFitter::InteractionPoint::initPar2(FitParams* /*fitparams*/) { if(vtxverbose>5){std::cout<<"InteractionPoint::initPar2: - "<cov()(posindex+row,posindex+row) = 1000*m_ipPosCov(row,row) ; else fitpar->cov()(posindex+row,posindex+row) = 1.; //1cm default? } //int momindex = momIndex() ; //if(m_hasmomcov) for(int row=0; row<4; row++) //fitpar->cov()(momindex+row,momindex+row) = 1000*m_ipMomCov(row,row) ; for(daucontainer::const_iterator it = daughters().begin() ; it != daughters().end() ; ++it) status |= (*it)->initCov(fitpar) ; return status ; } ErrCode DecayTreeFitter::InteractionPoint::projectIPConstraint(const FitParams* fitparams, Projection& p) const { int posindex = posIndex() ; if(vtxverbose>6){std::cout<<"InteractionPoint::projectIPConstraint(): posindex="<par()(posindex+row) - m_ipPos(row); p.H(row,posindex+row) = 1 ; //if(m_hasposcov) for(int col=0; col<3; ++col) p.Vfast(row,col) = m_ipPosCov(row,col) ; } } if(vtxverbose>6){ std::cout<<"InteractionPoint::projectIPConstraint(): projection is:"<6){std::cout<<"InteractionPoint::projectIPConstraint(): daumomindex="<par()(momindex+row) - m_ipMom(row); p.H(row,momindex+row) = 1 ; if(m_hasmomcov) for(int col=0; col<4; ++col) p.Vfast(row,col) = m_ipMomCov(row,col) ; } } if(vtxverbose>6){ std::cout<<"InteractionPoint::projectBeamConstraint(): projection is:"<par()(posindex+row) - m_ipPos(row) ; chisq += m_ipPosCovInv.Similarity(residualpos); } if(m_hasmom&&m_hasmomcov) { // no covariance, no chi2 contribution! int momindex = momIndex() ; TVectorD residualmom(4) ; for(int row=0; row<4; ++row) residualmom(row) = m_ipMom(row) - fitparams->par()(momindex+row) ; chisq += m_ipMomCovInv.Similarity(residualmom); } // add the daughters' chi2 chisq += ParticleBase::chiSquareD(fitparams) ; return chisq ; } void DecayTreeFitter::InteractionPoint::addToConstraintList(constraintlist& alist, int depth) const { // first the daughters for(daucontainer::const_iterator it = daughters().begin() ; it != daughters().end() ; ++it) (*it)->addToConstraintList(alist,depth-1) ; // then the beamspot if(m_haspos) alist.push_back(Constraint(this,Constraint::beamspot,depth,3)) ; if(m_hasmom) alist.push_back(Constraint(this,Constraint::beamenergy,depth,4)) ; } std::string DecayTreeFitter::InteractionPoint::parname(int thisindex) const { int id = thisindex ; // skip the lifetime parameter name if(id>=3) ++id ; return ParticleBase::parname(id) ; }