#ifndef _sdet_SDetector_h_ #define _sdet_SDetector_h_ #include #include #include #include #include #include #include #include #include #include namespace det { class Detector; } namespace utl { class NonExistentComponentException; } namespace sevt { class Station; } namespace sdet { /** \class SDetector SDetector.h "sdet/SDetector.h" \brief Detector description interface for SDetector-related data \author T. Paul \date 04 Mar 2003 \version $Id$ \ingroup sdet */ class SDetector { private: typedef std::map InternalStationMap; typedef InternalStationMap::const_iterator InternalStationIterator; public: class StationIterator : public std::iterator { public: // use this to loop over all stations StationIterator(const InternalStationIterator& it) : fInternalIterator(it), fEnd(it), fIndex(SDetectorConstants::eAny), fFilter(false) { } // use this to loop only over stations that match the GridIndex StationIterator(const InternalStationIterator& begin, const InternalStationIterator& end, const SDetectorConstants::GridIndex index) : fInternalIterator(begin), fEnd(end), fIndex(index), fFilter(true) { } StationIterator& operator++() { ++fInternalIterator; if (fFilter) // step further to next hit or end for ( ; fInternalIterator != fEnd; ++fInternalIterator) if (fInternalIterator->second->IsInGrid(fIndex) || fInternalIterator->second->IsDense()) break; return *this; } bool operator==(const StationIterator& other) const { return fInternalIterator == other.fInternalIterator; } bool operator!=(const StationIterator& other) const { return !operator==(other); } const Station& operator*() const { return *fInternalIterator->second; } const Station* operator->() const { return fInternalIterator->second; } private: InternalStationIterator fInternalIterator; InternalStationIterator fEnd; SDetectorConstants::GridIndex fIndex; bool fFilter; }; /// Beginning of the collection of pointers to commissioned stations /*! Use this iterator if you want to step through only those stations that were commissioned for the current detector time */ StationIterator StationsBegin() const { return StationIterator(fCommissionedStationList.begin()); } /// End of the collection of pointers to commissioned stations /*! Use this iterator if you want to step through only those stations that were commissioned for the current detector time */ StationIterator StationsEnd() const { return StationIterator(fCommissionedStationList.end()); } /// Beginning of the collection of pointers to commissioned stations in a specific grid /*! Use this iterator if you want to step through only those stations that were commissioned for the current detector time and belong to a certain grid */ StationIterator GridStationsBegin(const SDetectorConstants::GridIndex index) const { return StationIterator(fCommissionedStationList.begin(), fCommissionedStationList.end(), index); } /// End of the collection of pointers to commissioned stations in a specific grid /*! Use this iterator if you want to step through only those stations that were commissioned for the current detector time and belong to a certain grid */ StationIterator GridStationsEnd() const { return StationsEnd(); } /// Beginning of the collection of pointers to all stations in the history of the array /*! Use this iterator if you want to step through all stations that ever existed in the array (the current detector time is ignored) */ StationIterator AllStationsBegin() const { return StationIterator(fFullStationMap.begin()); } /// End of the collection of pointers to all stations in the history of the array /*! Use this iterator if you want to step through all stations that ever existed in the array (the current detector time is ignored) */ StationIterator AllStationsEnd() const { return StationIterator(fFullStationMap.end()); } /// Check if station with id is commisioned bool IsStationCommissioned(const int stationId) const { return fCommissionedStationList.find(stationId) != fCommissionedStationList.end(); } /// Check if station is Dense bool IsStationDense(const int stationId) const { return std::find(fDenseStationSubList.begin(), fDenseStationSubList.end(), stationId) != fDenseStationSubList.end(); } /// Get station by Station Id const Station& GetStation(const int stationId) const; /// Get sdet::Station from a sevt::Station const Station& GetStation(const sevt::Station& station) const; const Station& GetAllStation(const int stationId) const; /// Get list of ID's for all stations available in the database or configuration file const std::vector& GetFullStationList() const; const std::vector& GetDenseStationList() const { return fDenseStationSubList; } /// StationGroups: map key = groupId, value = stationId set typedef std::map > StationGroups; typedef StationGroups::const_iterator StationGroupsIterator; const StationGroups& GetStationGroups() const { return fStationGroups; } private: SDetector() { } ~SDetector(); SDetector(const SDetector& sdetector); SDetector& operator=(const SDetector& sdetector); void Update(); void UpdateDense(); void FetchStationGroups() const; // Container for all stations commissioned at the // current detector time. mutable InternalStationMap fCommissionedStationList; // List of all stations available in the external sources // (external sources are, for example, the XML file with // station list or perhaps some MySQL database) mutable utl::Validated > fFullStationList; mutable InternalStationMap fFullStationMap; mutable StationGroups fStationGroups; // list of all dense stations. Used to set the IsDense flag mutable std::vector fDenseStationSubList; friend class det::Detector; }; } #endif // Configure (x)emacs for this file ... // Local Variables: // mode: c++ // End: