#ifndef _DKinFitConstraints_ #define _DKinFitConstraints_ #include #include #include #include #include "TVector3.h" #include "TLorentzVector.h" using namespace std; class DKinFitter; class DKinFitParticle; class DKinFitConstraint //purely virtual: cannot directly instantiate class, can only inherit from it { friend class DKinFitter; public: inline string Get_ConstraintString(void) const{return dConstraintString;} inline void Set_ConstraintString(string locConstraintString){dConstraintString = locConstraintString;} protected: virtual ~DKinFitConstraint(void) = 0; //forces abstractness string dConstraintString; //e.g. "m_{#it{#Lambda}} }; class DKinFitConstraint_VertexBase : public DKinFitConstraint //purely virtual: cannot directly instantiate class, can only inherit from it { friend class DKinFitter; public: virtual TVector3 Get_CommonVertex(void) const = 0; //inheriting classes MUST define this method inline int Get_VxParamIndex(void) const{return dVxParamIndex;} int Get_FIndex(const DKinFitParticle* locKinFitParticle) const; void Replace_DecayingParticle(const DKinFitParticle* locOriginalParticle, const DKinFitParticle* locTreatAsDetectedParticle); virtual void Set_VertexGuess(TVector3& locVertex) = 0; //inheriting classes MUST define this method inline deque Get_FullConstrainParticles(void) const{return deque(dFullConstrainParticles.begin(), dFullConstrainParticles.end());} inline deque Get_NoConstrainParticles(void) const{return deque(dNoConstrainParticles.begin(), dNoConstrainParticles.end());} inline deque > Get_DecayingParticles(void) const{return deque >(dDecayingParticles.begin(), dDecayingParticles.end());} protected: DKinFitConstraint_VertexBase(void); virtual ~DKinFitConstraint_VertexBase(void){} virtual void Reset(void); inline void Set_FIndex(const DKinFitParticle* locKinFitParticle, unsigned int locFIndex){dConstraintEquationParticleMap[locKinFitParticle] = locFIndex;} inline void Set_VxParamIndex(int locVxParamIndex){dVxParamIndex = locVxParamIndex;} inline void Set_FullConstrainParticles(deque& locFullConstrainParticles){dFullConstrainParticles = locFullConstrainParticles;} inline void Set_NoConstrainParticles(deque& locNoConstrainParticles){dNoConstrainParticles = locNoConstrainParticles;} inline void Set_DecayingParticles(deque >& locDecayingParticles) { dDecayingParticles = locDecayingParticles; for(size_t loc_i = 0; loc_i < dDecayingParticles.size(); ++loc_i) dDecayingParticlesToAssign.insert(dDecayingParticles[loc_i].first); } inline void Add_FullConstrainParticle(DKinFitParticle* locKinFitParticle){dFullConstrainParticles.push_back(locKinFitParticle);} inline void Add_NoConstrainParticle(DKinFitParticle* locKinFitParticle){dNoConstrainParticles.push_back(locKinFitParticle);} int dVxParamIndex; //location of the Vx uncertainty in the dVXi covariance matrix term (Vy & Vz are the subsequent terms) deque > dDecayingParticles; //bool is true if vertex is production vertex / particle in final state, false if decay vertex / initial state deque dFullConstrainParticles; //charged particles, decaying particles, beam particles (not neutral showers!) deque dNoConstrainParticles; //missing particles & neutral showers //not used to constrain vertex or time, but fit vertex is set for this particle set dDecayingParticlesToAssign; //decaying particles not yet assigned to either constrain or be constrained ("no constrain") map dConstraintEquationParticleMap; //key is particle (NULL for RF time), value is the constraint equation index (must check whether decaying or not to see what f-matrix it's in!) }; class DKinFitConstraint_Vertex : public DKinFitConstraint_VertexBase { friend class DKinFitter; public: inline TVector3 Get_CommonVertex(void) const{return dCommonVertex;} inline void Set_VertexGuess(TVector3& locVertex){dCommonVertex = locVertex;} bool Get_DecayingParticleInInitialStateFlag(const DKinFitParticle* locKinFitParticle) const; private: DKinFitConstraint_Vertex(void); ~DKinFitConstraint_Vertex(void){} void Reset(void); void Set_CommonVertex(TVector3 locCommonVertex){dCommonVertex = locCommonVertex;} TVector3 dCommonVertex; //for propagating the track to this point }; class DKinFitConstraint_Spacetime : public DKinFitConstraint_VertexBase { friend class DKinFitter; public: inline void Set_TimeGuess(double locTime){dCommonSpacetimeVertex.SetT(locTime);} inline void Set_VertexGuess(TVector3& locVertex){dCommonSpacetimeVertex.SetVect(locVertex);} inline void Set_SpacetimeGuess(TLorentzVector& locSpacetimeVertex){dCommonSpacetimeVertex = locSpacetimeVertex;} inline TLorentzVector Get_CommonSpacetimeVertex(void) const{return dCommonSpacetimeVertex;} inline TVector3 Get_CommonVertex(void) const{return dCommonSpacetimeVertex.Vect();} inline double Get_CommonTime(void) const{return dCommonSpacetimeVertex.T();} inline bool Get_UseRFTimeFlag(void) const{return dUseRFTimeFlag;} inline const DKinFitParticle* Get_BeamParticle(void) const{return dBeamParticle;} inline int Get_TParamIndex(void) const{return dTParamIndex;} inline deque Get_OnlyConstrainTimeParticles(void) const{return deque(dOnlyConstrainTimeParticles.begin(), dOnlyConstrainTimeParticles.end());} //neutral showers bool Get_DecayingParticleInInitialStateFlag(const DKinFitParticle* locKinFitParticle) const; private: DKinFitConstraint_Spacetime(void); ~DKinFitConstraint_Spacetime(void){} void Reset(void); void Set_CommonVertex(TVector3 locCommonVertex){dCommonSpacetimeVertex.SetVect(locCommonVertex);} inline void Set_CommonTime(double locCommonTime){dCommonSpacetimeVertex.SetT(locCommonTime);} inline void Set_CommonSpacetimeVertex(TLorentzVector locCommonSpacetimeVertex){dCommonSpacetimeVertex = locCommonSpacetimeVertex;} inline void Set_UseRFTimeFlag(bool locUseRFTimeFlag){dUseRFTimeFlag = locUseRFTimeFlag;} inline void Set_TParamIndex(int locTParamIndex){dTParamIndex = locTParamIndex;} inline void Set_OnlyConstrainTimeParticles(deque& locOnlyConstrainTimeParticles){dOnlyConstrainTimeParticles = locOnlyConstrainTimeParticles;} deque dOnlyConstrainTimeParticles; //neutral showers //not used to constrain vertex, but fit vertex is used for time constraint bool dUseRFTimeFlag; //for time constraint TLorentzVector dCommonSpacetimeVertex; //for propagating the track to this point int dTParamIndex; DKinFitParticle* dBeamParticle; //NULL if not included in this constraint }; class DKinFitConstraint_P4 : public DKinFitConstraint //one will be implemented as a p4 constraint, the rest as invariant mass constraints { friend class DKinFitter; public: inline int Get_FIndex(void) const{return dFIndex;} inline void Set_ConstrainInitialParticleMassFlag(bool locConstrainMassFlag){dConstrainMassFlag = locConstrainMassFlag;} inline bool Get_ConstrainInitialParticleMassFlag(void) const{return dConstrainMassFlag;} inline bool Get_ConstrainedParticleIsInInitialStateFlag(void) const{return dConstrainedParticleIsInInitialStateFlag;} inline bool Get_ConstrainMassByInvariantMassFlag(void) const{return dConstrainMassByInvariantMassFlag;} inline bool Get_IsActualP4ConstraintFlag(void) const{return dIsActualP4ConstraintFlag;} inline const DKinFitParticle* Get_ConstrainedP4Particle(void) const{return dConstrainedP4Particle;} inline deque Get_InitialParticles(void) const{return deque(dInitialParticles.begin(), dInitialParticles.end());} inline deque Get_FinalParticles(void) const{return deque(dFinalParticles.begin(), dFinalParticles.end());} void Replace_Particle(const DKinFitParticle* locOriginalParticle, bool locInitialStateFlag, const DKinFitParticle* locTreatAsDetectedParticle); private: DKinFitConstraint_P4(void); ~DKinFitConstraint_P4(void){} void Reset(void); inline void Set_FIndex(int locFIndex){dFIndex = locFIndex;} inline void Set_ConstrainedP4Particle(DKinFitParticle* locConstrainedP4Particle){dConstrainedP4Particle = locConstrainedP4Particle;} inline void Set_InitialParticles(const deque& locInitialParticles){dInitialParticles = locInitialParticles;} inline void Set_FinalParticles(const deque& locFinalParticles){dFinalParticles = locFinalParticles;} inline void Set_ConstrainedParticleIsInInitialStateFlag(bool locFlag){dConstrainedParticleIsInInitialStateFlag = locFlag;} int dFIndex; //starting row index of the equation(s) corresponding to these constraints in the dF matrix term // -1 if a decaying particle mass constraint not applied bool dConstrainMassFlag; bool dIsActualP4ConstraintFlag; //e.g. initial particle is beam or open-ended decaying particle AND this is not an inclusive-p4 fit bool dConstrainedParticleIsInInitialStateFlag; bool dConstrainMassByInvariantMassFlag; //true unless missing particle with unknown mass is a decay product (ignored if dConstrainMassFlag is false) DKinFitParticle* dConstrainedP4Particle; deque dInitialParticles; deque dFinalParticles; }; #endif // _DKinFitConstraints_