#ifndef TReconNode_hxx_seen #define TReconNode_hxx_seen #include "TObject.h" #include "EoaCore.hxx" #include "IHandle.hxx" #include "IReconBase.hxx" #include "IReconState.hxx" #include "ICOMETLog.hxx" namespace COMET { class IReconNode; class IReconNodeContainer; /// An exception base class for IReconNode. OA_EXCEPTION(EReconNode, EReconObject); /// An exception thrown when a IReconNode object being added to a /// IReconNodeContainer has a state with the wrong type. The type of the /// state must match the state type of the containing IReconBase object. OA_EXCEPTION(EWrongStateType, EReconNode); /// An exception thrown when a IReconNode object being added to a /// IReconNodeContainer without an associated reconstruction object. OA_EXCEPTION(EObjectEmpty, EReconNode); } /// Class to contain the association between a IReconState and the object /// assocated with the state. This class is used to encode information /// required to refit an object (e.g. refit a track as part of a global fit), /// as well as to encode the path of extended objects. This class can be /// thought of as representing one point in a fit. class COMET::IReconNode: public TObject { public: IReconNode(); virtual ~IReconNode(); /// Get the state associated with this node. COMET::IHandle GetState() const {return fState;} /// Set the state associated with this node. void SetState(COMET::IHandle& state) {fState = state;} /// Get the reconstruction object associated with this node. COMET::IHandle GetObject() const {return fObject;} /// Set the reconstruction object associates with this node. void SetObject(COMET::IHandle& object) {fObject = object;} /// Get the goodness associated with the connection between the state and /// the object. double GetQuality() const {return fQuality;} /// Set the goodness associated with the connection between this state /// and object. void SetQuality(double quality) {fQuality = quality;} /// Print the object information. virtual void ls(Option_t *opt = "") const; private: /// The state associated with the object. COMET::IHandle fState; /// The object that is associated with the state. COMET::IHandle fObject; /// A log likelihood for the association of the object with the state. float fQuality; ClassDef(IReconNode,2); }; /// A base class for containers of IReconNode objects. class COMET::IReconNodeContainer : public TObject, public std::vector< IHandle > { public: IReconNodeContainer(); virtual ~IReconNodeContainer(); /// Add a node to the container. The std::vector::push_back method is /// overloaded so that it can check that the correct type of IReconState /// object is being added to the container. This is overloaded by the /// IReconNodeContainerImpl template. virtual void push_back(const COMET::IHandle& node) { //COMET::IHandle obj = node->GetObject(); //if (!obj) { // COMETSevere("Node added to a IReconNodeContainer" // " without an associated recon object"); // throw EObjectEmpty(); //} //std::vector< COMET::IHandle >::push_back(node); COMETError("Never directly call IReconNodeContainer::push_back()"); throw std::exception(); } /// Print the object information. virtual void ls(Option_t *opt = "") const; ClassDef(IReconNodeContainer,1); }; namespace COMET { /// Provide a class specific container for IReconNode objects. This /// checks that all of the nodes contain the right class of state before /// they are added to the container. template class IReconNodeContainerImpl : public IReconNodeContainer { public: IReconNodeContainerImpl() {} virtual ~IReconNodeContainerImpl() {} /// Add a node to the container. The std::vector::push_back method is /// overloaded so that it can make sure that the node contains the /// correct type of IReconState object. virtual void push_back(const COMET::IHandle& node) { // Check that node has a state if (node->GetState()){ COMET::IHandle n(node->GetState()); // Check that the state handle is valid (correct state type) if (!n) { COMETSevere("Wrong type of state being added to a " "IReconNodeContainer"); throw EWrongStateType(); } } COMET::IHandle obj = node->GetObject(); if (!obj) { COMETSevere("Node added to a IReconNodeContainer" " without an associated recon object"); throw EObjectEmpty(); } std::vector< COMET::IHandle >::push_back(node); } ClassDefT(IReconNodeContainerImpl,1) }; ClassDefT2(IReconNodeContainerImpl,T) } #endif