#ifndef TGeometryDatabase_hxx #define TGeometryDatabase_hxx #include #include #include #include #include #include #include #include #include #include #include namespace COMET { class IGeometryDatabase; } /// Singleton class to do channel id <----> geometry id lookups class COMET::IGeometryDatabase { public: virtual ~IGeometryDatabase(); /// Get the singleton instance of this class static IGeometryDatabase& Get(); /// Whether to use offline DB for mapping. Must be called before construction static void UseOfflineDatabase(bool useDB); /// Get a generic channel id from a geometry id bool GetChannelId(COMET::IChannelId& channelId, COMET::IGeometryId geomId); /// Get a CDC channel id from a geometry id bool GetCDCChannelId(COMET::ICDCChannelId& channelId, COMET::IGeometryId geomId); /// Get a CTH channel id from a geometry id bool GetCTHChannelId(COMET::ICTHChannelId& channelId, COMET::IGeometryId geomId); /// Get a Straw Tracker channel id from a geometry id bool GetStrawTrkChannelId(COMET::IStrawTrkChannelId& channelId, COMET::IGeometryId geomId); /// Get a ECAL channel id from a geometry id bool GetECALChannelId(COMET::IECALChannelId& channelId, COMET::IGeometryId geomId); /// Get a TOF channel id from a geometry id bool GetTOFChannelId(COMET::ITOFChannelId& channelId, COMET::IGeometryId geomId); /// Get a geometry id from a channel id bool GetGeometryId(COMET::IGeometryId& geomId, COMET::IChannelId channelId); /// Get the CDC Channel Map const COMET::ICDCChannelMap& CDC(); /// Get the CTH Channel Map const COMET::ICTHChannelMap& CTH(); /// Get the Straw Tracker Channel Map const COMET::IStrawTrkChannelMap& StrawTrk(); /// Get the ECAL Channel Map const COMET::IECALChannelMap& ECAL(); /// Get the TOF Channel Map const COMET::ITOFChannelMap& TOF(); protected: IGeometryDatabase(); private: IGeometryDatabase(const IGeometryDatabase& src) { MayNotUse("IGeometryDatabase copy c'tor"); } IGeometryDatabase operator()(const IGeometryDatabase& src) { MayNotUse("IGeometryDatabase copy ass't operator"); return IGeometryDatabase(); //oh, silly! } static enum ESourceOfMapping { kUndefined = -1, kFromFlatFile, kFromOfflineDatabase } fSourceOfMapping; ///Utility for obtaining modifiable TChannelMaps in the same lazy ///way as the public const accessors. Example: /// \code /// void COMET::IGeometryDatabase::MemberFunction() /// { /// ECal()->Moidifier(); // Fails Modifier() not const. /// fECalMap->Modifier(); // Bad - maybe pointer is null /// Mutable(ECal())->Modifier(); // Works /// } /// \endcode // Could avoid this if all TChannelMaps could be accesed in a // const way, but not currently true(!). template T& Mutable(const T& channelMap) { return const_cast(channelMap); } ///The instance pointer. static IGeometryDatabase* fGeoDB; ///CDC map ICDCChannelMap* fCDCMap; ///CTH map ICTHChannelMap* fCTHMap; ///StrawTrk map IStrawTrkChannelMap* fStrawTrkMap; ///ECAL map IECALChannelMap* fECALMap; ///TOF map ITOFChannelMap* fTOFMap; }; #endif // TGeometryDatabase_hxx_seen