#ifndef GEOMETRYMANAGER_HH #define GEOMETRYMANAGER_HH // // $Id: GeometryManager.hpp,v 1.19 2001/06/12 21:18:49 russo Exp $ // // File: GeometryManager.hh // Purpose: Interface to the geometry system. This is a singleton which controls // all access to geometry and alignment constants. In production // environments, check_geometry() should be called with each event. // Users of the geometry systems are notified of updates via the // class absGeometryMessenger. When the GeometryManager is created // it is passed a pointer to an absGeometryMessenger (chain). This // messenger is then owned by the GeometryManager and must not be // destroyed. // Created: 13-OCT-1997 John Hobbs // // $Revision: 1.19 $ // // #include "d0_geometry/base/BaseGeometry.hpp" #include "d0om/d0_Ref.hpp" #include "geometry_db/GeometryVersionTable.hpp" #include #include #include namespace edm { class RCP; // #include class Event; // Simply passed through to the version checking } class GeometryIdentifier; class absGeometryMessenger; class d0StreamName; /** Interface to the geometry system. This is a singleton which controls all access to reco geometry. The method {\em check\_geometry()} should be called with each event. Users of the geometry systems are notified of updates via the class {\bf absGeometryMessenger}. When the {\bf GeometryManager} is created it is passed a pointer to an {\bf absGeometryMessenger} (chain of active Geometers). This messenger is then owned by the {\bf GeometryManager} and must not be destroyed. The {\bf GeometryManager} gets a geometry in one of three means: \begin{enumerate} \item being given BaseGeometry rcp file \item being given the name of an EVPACK file with a geometry tree \item being given the name of a GeometryVersionTable file. This scheme is used by production code to make the association between a given event and the corresponding (aligned) geometry. \end{enumerate} */ class GeometryManager { public: /// Returns pointer to (singleton) GeometryManager static GeometryManager* get_instance(); // Create me and return true if it worked. typedef absGeometryMessenger aGM; /** Create GeometryManager given RCP. Creates the GeometryManager, which initializes the BaseGeometry using the specified RCP. @param initRCP RCP used to initialize the BaseGeometry @param notary GeometryMessenger used to inform sub-detectors */ static bool make_instance(const edm::RCP& initRCP, const aGM* notary); /** Create GeometryManager given BaseGeometry. Creates the GeometryManager, which initializes the BaseGeometry using the specified BaseGeometry. @param BaseGeom BaseGeometry @param notary GeometryMessenger chain used to inform sub-detectors This method is used only for specific cases. */ static bool make_instance(d0_Ref,const aGM* notary); /// Check if new geometry is needed. Load it and notify subdets if needed. void check_geometry(GeometryVersionRecord::recType dtype,const int runnum, const std::vector tags, const edm::Event *anEvt=0); private: /// For MC, a pseudo-run number is generated based on release tag. Get it. /// If versioning isn't supported, -1 is returned. check_geometry knows /// about this. int pseudo_run(const std::string version_tag) const; /** The geometry manager must check for all possible refresh types, including base, channel and material geometries. Dedicate separate functions for the constants and RCP-based geometries */ /// See if the position constants have changed void check_base_geometers(const int runnum, GeometryVersionRecord::recType dtype); /// See if the RCP-based (channel and material constants) have changed void check_rcp_geometers(bool isMC, const int runnum, const std::vector tags, const edm::Event *anEvt/*0*/); /// The singleton GeometryManager friend class std::auto_ptr; //static GeometryManager* _instance; /// The currently active D0 BaseGeometry d0_Ref _d0; /// The GeometryMessenger list to notify subdetectors const absGeometryMessenger* _hermes; /// How is the geometry state being maintained? enum geoType{UNKNOWN,DETRCP,DB,DIRECT,TYPE_COUNT}; /// Flag the management scheme. (See the {\em make\_instance} methods) geoType _geometry_type; /** Current ID. For RCP-instantiated and single-file geometries this is always zero. For reco, it is the geometry environment ID. */ int _current_geometry_id; /// Controls behaviour when a subdetector geometry is absent. bool _passnull; // The remaining attributes are used only when reading a geometry // master database. In all other cases, these are empty/null. This // also caches some "current state" information for speed which is not // really required to implement the logic. /// If the management scheme is db-based, this is the master file name. std::string _master_db; /// If the management scheme is db-based, this is the actual path of the db. std::string _opened_db_path; /** If the management scheme is db-based, this is the top level directory string passed in the RCP */ std::string _db_path; /// keep the currently loaded run int _oldrun; /// and geometry type GeometryVersionRecord::recType _oldtype; /// and the list of tags (empty for data, prod_history for MC) std::vector _oldtags; /// The class used to handle the event to geometry association. NULL => Not used d0_Ref _version_controller; /** Override the default event type selection by forcing a given state or version. These are used only in conjuction with database geometries */ bool _alwaysData; /// Force data type to be MC. Overrides data vs. MC detection result. bool _alwaysMC; /// If reading from a geometry DB, this is the ID of the default geometry int _default_version; /// Force a specific version. Overrides all other qualifiers int _force_version; /// Default constructor GeometryManager(); /// Default destructor ~GeometryManager(); /// Internal management wrappers aGM* defaultMessengers(); /// Retrieve the default geometry for either DATA or MC. d0_Ref get_default_geometry(const bool isMC); /// This helper retrieves the geometry given an ID in the current table. d0_Ref get_geometry(const int id=(-1)); /// Helper to set dbids to unknown state void dbids_unknown(); }; // Constructors/Destructors // Accessors #endif //GEOMETRYMANAGER_HH