SDetector.h
Go to the documentation of this file.
1 #ifndef _sdet_SDetector_h_
2 #define _sdet_SDetector_h_
3 
4 #include <sdet/Station.h>
5 #include <sdet/SDetectorConstants.h>
6 #include <utl/Validated.h>
7 #include <utl/IteratorRange.h>
8 #include <boost/iterator/transform_iterator.hpp>
9 #include <iterator>
10 #include <cstddef>
11 #include <string>
12 #include <vector>
13 #include <map>
14 #include <set>
15 
16 
17 namespace det {
18  class Detector;
19 }
20 
21 namespace utl {
22  class NonExistentComponentException;
23 }
24 
25 namespace sevt {
26  class Station;
27  class PMT;
28 }
29 
30 namespace sdet {
31 
42  class SDetector {
43 
44  private:
45  typedef std::map<int, const sdet::Station*> InternalStationMap;
46  typedef InternalStationMap::const_iterator InternalStationIterator;
47 
48  public:
50  public std::iterator<std::input_iterator_tag, const sdet::Station&, ptrdiff_t, const sdet::Station*, const sdet::Station& > {
51 
52  public:
53  // use this to loop over all stations
55  : fInternalIterator(it), fEnd(it) { }
56 
57  // use this to loop only over stations that match the GridIndex
59  const InternalStationIterator& end,
61  : fInternalIterator(begin), fEnd(end), fIndex(index), fFilter(true) { }
62 
65  {
67  if (fFilter)
68  // step further to next hit or end
70  if (fInternalIterator->second->IsInGrid(fIndex) || fInternalIterator->second->IsDense())
71  break;
72  return *this;
73  }
74 
75  bool operator==(const StationIterator& other) const
76  { return fInternalIterator == other.fInternalIterator; }
77 
78  bool operator!=(const StationIterator& other) const
79  { return !operator==(other); }
80 
81  const Station& operator*() const
82  { return *fInternalIterator->second; }
83 
84  const Station* operator->() const
85  { return fInternalIterator->second; }
86 
87  private:
91  bool fFilter = false;
92  };
93 
95 
98  { return StationIterator(fCommissionedStationList.begin()); }
100 
103  { return StationIterator(fCommissionedStationList.end()); }
104  OFFLINE_MAKE_CONST_ITERATOR_RANGE(StationIterator, Stations)
105 
106 
107 
109  StationIterator GridStationsBegin(const SDetectorConstants::GridIndex index) const
110  { return StationIterator(fCommissionedStationList.begin(), fCommissionedStationList.end(), index); }
112 
115  { return StationIterator(fCommissionedStationList.end(), fCommissionedStationList.end(), index); }
116  OFFLINE_MAKE_CONST_ITERATOR_RANGE_ARG(StationIterator, GridStations, const SDetectorConstants::GridIndex arg)
117 
118 
119 
122  { return StationIterator(fFullStationMap.begin()); }
124 
127  { return StationIterator(fFullStationMap.end()); }
128  OFFLINE_MAKE_CONST_ITERATOR_RANGE(StationIterator, AllStations)
129 
130 
131  bool IsStationCommissioned(const int stationId) const
132  { return fCommissionedStationList.find(stationId) != fCommissionedStationList.end(); }
133 
135  bool IsStationDense(const int stationId) const
136  { return std::find(fDenseStationSubList.begin(), fDenseStationSubList.end(),
137  stationId) != fDenseStationSubList.end(); }
138 
140  const Station& GetStation(const int stationId) const;
141 
143  const Station& GetStation(const sevt::Station& station) const;
144 
145  const Station& GetAllStation(const int stationId) const;
146 
148  const std::vector<int>& GetFullStationList() const;
149 
150  const std::vector<int>& GetDenseStationList() const
151  { return fDenseStationSubList; }
152 
154  typedef std::map<int, std::set<int> > StationGroups;
155  typedef StationGroups::const_iterator StationGroupsIterator;
156 
157  const StationGroups& GetStationGroups() const { return fStationGroups; }
158 
159  const PMT& GetPMT(const sevt::PMT& pmt) const;
160 
161  private:
162  SDetector() = default;
163  ~SDetector();
164 
165  SDetector(const SDetector& sdetector);
166  SDetector& operator=(const SDetector& sdetector);
167 
168  void Update();
169  void UpdateDense();
170 
171  void FetchStationGroups() const;
172 
173  // Container for all stations commissioned at the
174  // current detector time.
176 
177  // List of all stations available in the external sources
178  // (external sources are, for example, the XML file with
179  // station list or perhaps some MySQL database)
183 
184  // list of all dense stations. Used to set the IsDense flag
185  mutable std::vector<int> fDenseStationSubList;
186 
187  friend class det::Detector;
188 
189  };
190 
191 }
192 
193 
194 #endif
StationIterator GridStationsBegin(const SDetectorConstants::GridIndex index) const
Beginning of the collection of pointers to commissioned stations in a specific grid.
Definition: SDetector.h:109
const StationGroups & GetStationGroups() const
Definition: SDetector.h:157
std::map< int, std::set< int > > StationGroups
StationGroups: map key = groupId, value = stationId set.
Definition: SDetector.h:154
class to hold data at PMT level
Definition: SEvent/PMT.h:28
#define OFFLINE_MAKE_CONST_ITERATOR_RANGE_ARG(_ConstIterator_, _NamePrefix_, _Arg_)
Definition: IteratorRange.h:65
Detector description interface for Station-related data.
StationIterator(const InternalStationIterator &it)
Definition: SDetector.h:54
const std::vector< int > & GetFullStationList() const
Get list of ID&#39;s for all stations available in the database or configuration file.
Definition: SDetector.cc:110
Detector description interface for PMT-related data.
Definition: SDetector/PMT.h:26
InternalStationIterator fInternalIterator
Definition: SDetector.h:88
InternalStationIterator fEnd
Definition: SDetector.h:89
StationGroups::const_iterator StationGroupsIterator
Definition: SDetector.h:155
StationIterator AllStationsEnd() const
End of the collection of pointers to all stations in the history of the array.
Definition: SDetector.h:126
void UpdateDense()
Definition: SDetector.cc:30
InternalStationMap fCommissionedStationList
Definition: SDetector.h:175
void FetchStationGroups() const
Definition: SDetector.cc:152
const Station * operator->() const
Definition: SDetector.h:84
bool operator==(const StationIterator &other) const
Definition: SDetector.h:75
StationIterator & operator++()
Definition: SDetector.h:64
StationIterator GridStationsEnd(const SDetectorConstants::GridIndex index) const
End of the collection of pointers to commissioned stations in a specific grid.
Definition: SDetector.h:114
Wrapper class for initially unset data.
Definition: ResponseMap.h:17
StationIterator AllStationsBegin() const
Beginning of the collection of pointers to all stations in the history of the array.
Definition: SDetector.h:121
StationIterator(const InternalStationIterator &begin, const InternalStationIterator &end, const SDetectorConstants::GridIndex index)
Definition: SDetector.h:58
class to hold data at Station level
utl::Validated< std::vector< int > > fFullStationList
Definition: SDetector.h:180
bool IsStationDense(const int stationId) const
Check if station is Dense.
Definition: SDetector.h:135
Top of the hierarchy of the detector description interface.
Definition: Detector.h:81
StationIterator StationsEnd() const
End of the collection of pointers to commissioned stations.
Definition: SDetector.h:102
#define OFFLINE_MAKE_CONST_ITERATOR_RANGE(_ConstIterator_, _NamePrefix_)
Definition: IteratorRange.h:28
StationGroups fStationGroups
Definition: SDetector.h:182
StationIterator StationsBegin() const
Beginning of the collection of pointers to commissioned stations.
Definition: SDetector.h:97
SDetectorConstants::GridIndex fIndex
Definition: SDetector.h:90
std::map< int, const sdet::Station * > InternalStationMap
Definition: SDetector.h:45
SDetector & operator=(const SDetector &sdetector)
const Station & GetAllStation(const int stationId) const
Definition: SDetector.cc:282
bool IsStationCommissioned(const int stationId) const
Check if station with id is commisioned.
Definition: SDetector.h:131
const std::vector< int > & GetDenseStationList() const
Definition: SDetector.h:150
std::vector< int > fDenseStationSubList
Definition: SDetector.h:185
Detector description interface for SDetector-related data.
Definition: SDetector.h:42
const PMT & GetPMT(const sevt::PMT &pmt) const
Definition: SDetector.cc:296
InternalStationMap fFullStationMap
Definition: SDetector.h:181
bool operator!=(const StationIterator &other) const
Definition: SDetector.h:78
const Station & GetStation(const int stationId) const
Get station by Station Id.
Definition: SDetector.cc:192
SDetector()=default
const Station & operator*() const
Definition: SDetector.h:81
Definition: XbArray.h:7
InternalStationMap::const_iterator InternalStationIterator
Definition: SDetector.h:46

, generated on Tue Sep 26 2023.