#ifndef TReconState_hxx_seen #define TReconState_hxx_seen //////////////////////////////////////////////////////////////// // // A class to hold the state information for the reconstruction objects. This // file defines several classes and needs to be split into multiple files // after the design is complete. #include #include #include #include #include #include "ICorrValues.hxx" #include "IHandle.hxx" #include "ICOMETLog.hxx" namespace COMET { class IReconState; class IMReconState; class IMEDepositState; class IMPositionState; class IMDirectionState; class IMPositionDirectionState; class IMConeState; class IMCurvatureState; class IMPosDirCurvState; class IMWidthState; class IMMomentumState; class IMChargeState; class IClusterState; class IShowerState; class ITrackState; class IPIDState; class IVertexState; } /// The IReconState class represents the value of parameters and covariances /// associated with reconstruction objects. It does not contain general /// status information such as the goodness, degree's of freedom, or objects /// which contributed to the reconstruction. The values saved in the particle /// states are described in \ref recObjGeometric and \ref recObjPhysics. /// /// This is the polymorphic base class that all other state classes are /// derived from, and it provides minimal operations. The main purpose of /// this class is to allow polymorphic vectors of states. However, it /// provides some minimal access to the contained data. class COMET::IReconState: public TObject { public: IReconState(); IReconState(const COMET::IReconState& state); virtual ~IReconState(); /// Return a string with all of the state field names. This name is used /// to build a type has for the state. std::string GetStateFields() const; /// Return the number of dimensions in the state (the size of the state). int GetDimensions() const; /// Not the preferred interface, but get the value by index. The best way /// to get a value is through the Get method provided by the mix-in /// classes (e.g. COMET::IMEDepositState::GetEDeposit()). double GetValue(int i) const; /// Not the preferred interface, but set the value by index. The best way /// to get a value is through the Set method provided by the mix-in /// classes (e.g. COMET::IMEDepositState::SetEDeposit()). void SetValue(int i, double value); /// Not the preferred interface: get the covariance by index. double GetCovarianceValue(int i, int j) const; /// Not the preferred interface: set the covariance by index. void SetCovarianceValue(int i, int j, double value); /// The projection operator to get the full state. static COMET::ICorrValues ProjectState(const COMET::IHandle& state); /// Set a parameter to be free (unconstrained). void SetFree(int i); /// Check if a parameter is free. bool IsFree(int i) const; /// Check if a variance corresponds to a free parameter. bool IsFree(double v) const; /// Set a parameter to be fixed. void SetFixed(int i); /// Check if a parameter is fixed. bool IsFixed(int i) const; /// Check if a variance corresponds to a fixed parameter. bool IsFixed(double v) const; /// Validate the covariance. void Validate(); /// Print the object information. virtual void ls(Option_t *opt = "") const; protected: friend class IMReconState; friend class IMEDepositState; friend class IMPositionState; friend class IMDirectionState; friend class IMPositionDirectionState; friend class IMConeState; friend class IMCurvatureState; friend class IMPosDirCurvState; friend class IMWidthState; friend class IMMomentumState; friend class IMChargeState; friend class IClusterState; friend class IShowerState; friend class ITrackState; friend class IPIDState; friend class IVertexState; /// A final initialization routine that is called in the constructor of /// the instantiated class. This builds the actual state vector. void Init(); /// The vector of correlated values (a vector and a covariance) that holds /// the state information. ICorrValues fValues; /// A vector of parameter names. This identifies the fields in the state. std::vector fFieldNames; ClassDef(IReconState,1); }; /// A mixable base class class COMET::IMReconState { public: IMReconState(); IMReconState(IReconState* state); virtual ~IMReconState(); IReconState& GetThis() const; private: IReconState* fThis; //! do not save protected: std::vector fLocalNames; //! do not save // ClassDef(IMReconState,0); }; /// A mixable base class that adds the energy deposit property to a state. /// The position state is defined as a scaler and the /// associated uncertainty. /// /// \bug The units of the energy deposit depend on the context. For instance, /// before particle ID in the P0D, the deposit is in photo-electrons. After /// particle ID, the deposit can be in uncalibrated or calibrated energy. In /// the TPC the deposit might be in terms of fempto-coulombs. class COMET::IMEDepositState: virtual public IMReconState { public: IMEDepositState(); virtual ~IMEDepositState(); /// Get the value of the EDeposit. double GetEDeposit() const; /// Set the value of the EDeposit. void SetEDeposit(double enr); /// Get the variance of the EDeposit. double GetEDepositVariance(void) const; /// Set the variance of the EDeposit. void SetEDepositVariance(double var); /// Get the index of the EDeposit field in the ICorrValues vector. int GetEDepositIndex() const {return fEDepositIndex;} /// Return the number of entries for the EDeposit in the ICorrValues /// vector. static int GetSize() {return 1;} /// The projection operator to get the full state. static COMET::ICorrValues ProjectState(const COMET::IHandle& state); protected: /// The index of the EDeposit field in the ICorrValues object. int fEDepositIndex; //! Do not save. // ClassDef(IMEDepositState,0); }; /// A mixable base class that adds the position property to a state. The /// position state is defined as a four vector (X,Y,Z,T) and the associated /// uncertainties. class COMET::IMPositionState: virtual public IMReconState { public: IMPositionState(); virtual ~IMPositionState(); /// Get the value of the Position. TLorentzVector GetPosition() const; /// Set the value of the Position. void SetPosition(double x, double y, double z, double t); /// Set the value of the Position. void SetPosition(const TLorentzVector& pos); /// Get the variance of the Position. TLorentzVector GetPositionVariance(void) const; /// Set the variance of the Position. void SetPositionVariance(double x, double y, double z, double t); /// Set the covariance of the position variables. The indices run from 0 /// to 3 (0: X, 1: Y, 2: Z, 3: T). void SetPositionCovariance(int i, int j, double v); /// Get the covariance of the position variables. The indices run from 0 /// to 3 (0: X, 1: Y, 2: Z, 3: T). double GetPositionCovariance(int i, int j); /// Get the index of the Position field in the ICorrValues vector. int GetPositionIndex() const {return fPositionIndex;} /// Get the index of the X,Y,Z,T fields in the ICorrValues vector. int GetXIndex() const {return fPositionIndex;} int GetYIndex() const {return fPositionIndex+1;} int GetZIndex() const {return fPositionIndex+2;} int GetTIndex() const {return fPositionIndex+3;} /// Return the number of entries for the Position in the ICorrValues /// vector. static int GetSize() {return 4;} /// The projection operator to get the full state. static COMET::ICorrValues ProjectState(const COMET::IHandle& state); protected: /// The index of the Position field in the ICorrValues object. int fPositionIndex; //! Do not save. // ClassDef(IMPositionState,0); }; /// A mixable base class that adds the direction property to a state. The /// direction state is defined as a three vector (dX,dY,dZ) and the associated /// uncertainties. The corelations between the components are enforced in the /// covariance matrix. class COMET::IMDirectionState: virtual public IMReconState { public: IMDirectionState(); virtual ~IMDirectionState(); /// Get the value of the Direction. TVector3 GetDirection() const; /// Set the value of the Direction. void SetDirection(double x, double y, double z); /// Set the value of the Direction. void SetDirection(const TVector3&); /// Get the variance of the Direction. TVector3 GetDirectionVariance(void) const; /// Set the variance of the Direction. void SetDirectionVariance(double x, double y, double z); /// Set the covariance of the direction variables. The indices run from 0 /// to 2 (0: X, 1: Y, 2: Z). void SetDirectionCovariance(int i, int j, double v); /// Get the covariance of the direction variables. The indices run from 0 /// to 2 (0: X, 1: Y, 2: Z). double GetDirectionCovariance(int i, int j); /// Get the index of the Direction field in the ICorrValues vector. int GetDirectionIndex() const {return fDirectionIndex;} /// Return the number of entries for the Direction in the ICorrValues /// vector. static int GetSize() {return 3;} /// The projection operator to get the full state. static COMET::ICorrValues ProjectState(const COMET::IHandle& state); protected: /// The index of the Direction field in the ICorrValues object. int fDirectionIndex; //! Do not save. // ClassDef(IMDirectionState,0); }; /// A mixable base class that adds the position and direction properties to a /// state using the TPositionState and TDirectionState classes. class COMET::IMPositionDirectionState: virtual public IMPositionState, virtual public IMDirectionState { public: IMPositionDirectionState() {}; virtual ~IMPositionDirectionState(); /// Get the index of the Direction field in the ICorrValues vector. int GetPositionDirectionIndex() const {return GetPositionIndex();} /// Return the number of entries for the Direction in the ICorrValues /// vector. static int GetSize() { return IMPositionState::GetSize() + IMDirectionState::GetSize(); } /// The projection operator to get the full state. static COMET::ICorrValues ProjectState(const COMET::IHandle& state); // ClassDef(IMPositionDirectionState,0); }; /// A mixable base class that adds the opening angle of a IReconShower object. class COMET::IMConeState: virtual public IMReconState { public: IMConeState(); virtual ~IMConeState(); /// Get the value of the Cone. TVector3 GetCone() const; /// Set the value of the Cone. void SetCone(double c1, double c2); /// Get the variance of the Cone. TVector3 GetConeVariance(void) const; /// Set the variance of the Cone. void SetConeVariance(double c1, double c2); /// Get the index of the Cone field in the ICorrValues vector. int GetConeIndex() const {return fConeIndex;} /// Return the number of entries for the Cone in the ICorrValues /// vector. static int GetSize() {return 2;} /// The projection operator to get the full state. static COMET::ICorrValues ProjectState(const COMET::IHandle& state); protected: /// The index of the Cone field in the ICorrValues object. int fConeIndex; //! Do not save. // ClassDef(IMConeState,0); }; /// A mixable base class that adds the curvature property to a state. The /// curvature state is defined around the X axis and also holds the associated /// uncertainties. class COMET::IMCurvatureState: virtual public IMReconState { public: IMCurvatureState(); virtual ~IMCurvatureState(); /// Get the value of the Curvature. double GetCurvature() const; /// Set the value of the Curvature. void SetCurvature(double enr); /// Get the variance of the Curvature. double GetCurvatureVariance(void) const; /// Set the variance of the Curvature. void SetCurvatureVariance(double var); /// Get the index of the Curvature field in the ICorrValues vector. int GetCurvatureIndex() const {return fCurvatureIndex;} /// Return the number of entries for the Curvature in the ICorrValues /// vector. static int GetSize() {return 1;} /// The projection operator to get the full state. static COMET::ICorrValues ProjectState(const COMET::IHandle& state); protected: /// The index of the Curvature field in the ICorrValues object. int fCurvatureIndex; //! Do not save. // ClassDef(IMCurvatureState,0); }; /// A mixable base class that adds the position, direction and curvature /// properties to a state using the IMPositionDirectionState and /// IMCurvatureState classes. class COMET::IMPosDirCurvState: virtual public IMPositionDirectionState, virtual public IMCurvatureState { public: IMPosDirCurvState() {} virtual ~IMPosDirCurvState(); int GetPosDirCurvIndex() const {return GetPositionDirectionIndex();} /// Return the number of entries for the Direction in the ICorrValues /// vector. static int GetSize() { return IMPositionDirectionState::GetSize() + IMCurvatureState::GetSize(); } /// The projection operator to get the full state. static COMET::ICorrValues ProjectState(const COMET::IHandle& state); // ClassDef(IMPosDirCurvState,0); }; /// A mixable base class that adds the width of a curvilinear energy deposit /// property to a state. The width is a 2 component vector the extent of an /// energy deposition perpendicular to local direction and the associated /// uncertainties. class COMET::IMWidthState: virtual public IMReconState { public: IMWidthState(); virtual ~IMWidthState(); /// Get the value of the Width. TVector3 GetWidth() const; /// Set the value of the Width. void SetWidth(double w1, double w2); /// Get the variance of the Width. TVector3 GetWidthVariance(void) const; /// Set the variance of the Width. void SetWidthVariance(double w1, double w2); /// Get the index of the Width field in the ICorrValues vector. int GetWidthIndex() const {return fWidthIndex;} /// Return the number of entries for the Width in the ICorrValues /// vector. static int GetSize() {return 2;} /// The projection operator to get the full state. static COMET::ICorrValues ProjectState(const COMET::IHandle& state); protected: /// The index of the Width field in the ICorrValues object. int fWidthIndex; //! Do not save. // ClassDef(IMWidthState,0); }; /// A mixable base class that adds a property for the magnitude of the /// momentum to a state. class COMET::IMMomentumState: virtual public IMReconState { public: IMMomentumState(); virtual ~IMMomentumState(); /// Get the value of the Momentum. double GetMomentum() const; /// Set the value of the Momentum. void SetMomentum(double enr); /// Get the variance of the Momentum. double GetMomentumVariance(void) const; /// Set the variance of the Momentum. void SetMomentumVariance(double var); /// Get the index of the Momentum field in the ICorrValues vector. int GetMomentumIndex() const {return fMomentumIndex;} /// Return the number of entries for the Momentum in the ICorrValues /// vector. static int GetSize() {return 1;} /// The projection operator to get the full state. static COMET::ICorrValues ProjectState(const COMET::IHandle& state); protected: /// The index of the Momentum field in the ICorrValues object. int fMomentumIndex; //! Do not save. // ClassDef(IMMomentumState,0); }; /// A mixable base class that adds a property for the magnitude of the /// particle charge to a state. class COMET::IMChargeState: virtual public IMReconState { public: IMChargeState(); virtual ~IMChargeState(); /// Get the value of the Charge. double GetCharge() const; /// Set the value of the Charge. void SetCharge(double enr); /// Get the variance of the Charge. double GetChargeVariance(void) const; /// Set the variance of the Charge. void SetChargeVariance(double var); /// Get the index of the Charge field in the ICorrValues vector. int GetChargeIndex() const {return fChargeIndex;} /// Return the number of entries for the Charge in the ICorrValues /// vector. static int GetSize() {return 1;} /// The projection operator to get the full state. static COMET::ICorrValues ProjectState(const COMET::IHandle& state); protected: /// The index of the Charge field in the ICorrValues object. int fChargeIndex; //! Do not save. // ClassDef(IMChargeState,0); }; #endif