SDetector/Station.h
Go to the documentation of this file.
1 #ifndef _sdet_Station_h_
2 #define _sdet_Station_h_
3 
4 #include <sdet/PMT.h>
5 #include <sdet/Scintillator.h>
6 #include <sdet/PMTConstants.h>
7 #include <sdet/SDetectorConstants.h>
8 #include <det/VManager.h>
9 #include <det/Detector.h>
10 #include <utl/AugerException.h>
11 #include <utl/CoordinateSystemPtr.h>
12 #include <utl/ReferenceEllipsoid.h>
13 #include <utl/Validated.h>
14 #include <utl/Point.h>
15 #include <utl/Vector.h>
16 #include <utl/TimeStamp.h>
17 #include <utl/TimeRange.h>
18 #include <utl/TabulatedFunction.h>
19 #include <utl/ShadowPtr.h>
20 #include <utl/IteratorRange.h>
21 
22 #include <boost/iterator/indirect_iterator.hpp>
23 #include <boost/iterator/transform_iterator.hpp>
24 
25 #include <vector>
26 #include <map>
27 #include <string>
28 #include <bitset>
29 
30 
31 namespace sevt {
32  class PMT;
33 }
34 
35 namespace sdet {
36 
37  class PMT;
38  class Unlock;
39 
40 
52  class Station {
53 
54  private:
55  typedef std::vector<const PMT*> InternalPMTVector;
56  typedef InternalPMTVector::const_iterator InternalPMTIterator;
57 
59  const Station& operator()(const int stationId) const;
60  };
61 
62  /* These constants are to be read from external file ....
63  all code that uses them must be changed accordingly */
64  static const unsigned int kFirstWaterCherenkovLargePMTId = 1;
65  static const unsigned int kLastWaterCherenkovLargePMTId = 3;
66  static const unsigned int kWaterCherenkovSmallPMTId = 4;
67  static const unsigned int kScintillatorPMTId = 5;
68 
69  public:
71  static unsigned int GetFirstPMTId() { return kFirstWaterCherenkovLargePMTId; }
72 
74  unsigned int GetLastPMTId() const { return fPMTVector.size(); }
75 
77  unsigned int GetNPMTs(const PMTConstants::PMTType type = PMTConstants::eAnyType) const;
78 
79  template<typename T>
80  const std::vector<T>&
81  GetMuonPeakHistogramBinning(const PMTConstants::PMTType pmtType, const int calibrationVersion)
82  const
83  {
84  const short int normalBins = 100;
85  const short int stridedBins = 50;
86 
87  if (!IsUUB()) { // UB
88  static std::vector<T> muonPeakBinningUb;
89  return InitializeIfNeeded(muonPeakBinningUb, normalBins, 1, stridedBins, 3);
90  }
91 
92  if (calibrationVersion < 262) { // old version of UUB
93  static std::vector<T> muonPeakBinningUubOld;
94  return InitializeIfNeeded(muonPeakBinningUubOld, normalBins, 4, stridedBins, 4);
95  }
96 
97  switch (pmtType) {
99  static std::vector<T> muonPeakBinningUubWcd;
100  return InitializeIfNeeded(muonPeakBinningUubWcd, normalBins, 4, stridedBins, 4);
102  static std::vector<T> muonPeakBinningUubSsd;
103  return InitializeIfNeeded(muonPeakBinningUubSsd, normalBins, 2, stridedBins, 4);
104  default:
105  throw utl::DoesNotComputeException("unhandled PMT type");
106  }
107 
108  static std::vector<T> emptyVector;
109  return emptyVector;
110  }
111 
112  template<typename T>
113  const std::vector<T>&
114  GetMuonChargeHistogramBinning(const PMTConstants::PMTType pmtType, const int calibrationVersion)
115  const
116  {
117  const short int normalBins = 400;
118  const short int stridedBins = 200;
119 
120  if (!IsUUB()) { // UB
121  static std::vector<T> muonChargeBinningUb;
122  return InitializeIfNeeded(muonChargeBinningUb, normalBins, 1, stridedBins, 3);
123  }
124 
125  if (calibrationVersion < 262) { // old version of UUB
126  static std::vector<T> muonChargeBinningUubOld;
127  return InitializeIfNeeded(muonChargeBinningUubOld, normalBins, 8, stridedBins, 4);
128  }
129 
130  switch (pmtType) {
132  static std::vector<T> muonChargeBinningUubWcd;
133  return InitializeIfNeeded(muonChargeBinningUubWcd, normalBins, 8, stridedBins, 4);
135  static std::vector<T> muonChargeBinningUubSsd;
136  return InitializeIfNeeded(muonChargeBinningUubSsd, normalBins, 2, stridedBins, 4);
137  default:
138  throw utl::DoesNotComputeException("unhandled PMT type");
139  }
140 
141  static std::vector<T> emptyVector;
142  return emptyVector;
143  }
144 
145  template<typename T>
146  const std::vector<T>&
147  GetBaselineHistogramBinning()
148  const
149  {
150  static std::vector<T> baseHisto;
151  if (baseHisto.empty()) {
152  baseHisto.resize(20 + 1);
153  std::iota(baseHisto.begin(), baseHisto.end(), T(0));
154  }
155  return baseHisto;
156  }
157 
158  const std::vector<double>&
159  GetMuonShapeHistogramBinning(const int calibrationVersion) const;
160 
162  const std::string& GetName() const;
163 
165  int GetId() const { return fId; }
166 
167  /* First implementation of IsUUB, HasSmallPMTData, and HasScintillator
168  just returns hardware version, cast as a boolean
169  since a hardware version of 0 corresponds to
170  a UB and all other values correspond to a UUB. The plan is to
171  largely replace the concept of hardware version by updating the
172  values returned by IsUUB()/HasScintillator()/HasSmallPMTData() and
173  constructing/deconstructing the relevant classes during
174  read-in of CDAS events or from information stored in the station
175  list for simulations. */
176  bool IsUUB() const { return fIsUUB; }
177 
178  bool HasSmallPMT() const;
179 
180  bool HasScintillator() const { return bool(fScintillator); }
181 
182  unsigned int GetFADCTraceLength() const;
183 
184  double GetFADCBinSize() const;
185 
186  double GetTimingUncertainty() const;
187 
188  unsigned int GetSaturationValue() const;
189 
190  int GetLatchBin() const;
191 
193 
195  typedef boost::indirect_iterator<InternalPMTIterator, const PMT&> PMTIterator;
196 
199  { return PMTIterator(fPMTVector.begin()); }
202  { return PMTIterator(fPMTVector.end()); }
204 
205 
206  typedef boost::transform_iterator<InternalPartnerStationFunctor,
207  std::vector<int>::const_iterator,
209 
211  PartnerIterator PartnersBegin() const
212  { return PartnerIterator(SetPartnerIds().begin()); }
215  { return PartnerIterator(SetPartnerIds().end()); }
217 
218 
220 
222  const std::vector<int>& GetPartnerIds() const
223  { return SetPartnerIds(); }
224 
226  int GetGroupId() const;
227 
230  { return GetCommissionTimeRange().GetStartTime(); }
231 
234  { return GetCommissionTimeRange().GetStopTime(); }
235 
237  const utl::TimeRange& GetCommissionTimeRange() const;
238 
239  const utl::TimeStamp& GetUUBCommissionTime() const;
240 
241  typedef std::vector<int> StationIdCollection;
243  const StationIdCollection& GetCrown(const int level) const;
244 
246 
249  double GetRadius() const;
250 
252 
255  double GetHeight() const;
256 
258  double GetThickness() const;
259 
260  const Scintillator& GetScintillator() const { return *fScintillator; }
261 
263  // temporary solution for detector creeping (bug #307) is to *not* to return reference
264  utl::Point GetPosition() const;
265 
268 
271 
274 
277 
279 
283  double GetLinerSigmaAlpha() const;
284 
287 
290 
293 
295 
298  bool IsDense() const { return fDense; }
299 
300  const std::vector<double>& GetAxes() const;
301 
302  bool IsHit(const utl::Point& from, const utl::Vector& direction, utl::Point& where) const;
303 
304  bool IsHit(const utl::Point& from, const utl::Vector& direction) const
305  { utl::Point p; return IsHit(from, direction, p); }
306 
307  bool IsInsideStation(const utl::Point& pos) const;
308 
310  bool IsInAcquisition() const;
311 
313  bool ExistsAssociatedCounter() const;
314 
316  int GetAssociatedCounterId() const;
317 
319  const PMT& GetPMT(const int id) const;
320 
322  const PMT& GetPMT(const sevt::PMT& pmt) const;
323 
324  const PMT& GetSmallPMT() const;
325 
326  const PMT& GetScintillatorPMT() const;
327 
328  private:
329  typedef std::map<int, StationIdCollection> InternalCrownCollection;
330 
331  Station(const int id);
332  ~Station();
333 
334  Station(const Station&);
335  Station operator=(const Station&);
336 
337  void Update() const;
338 
339  void UpdateElectronics(const bool isuub) const;
340 
341  void MakeScintillator() const;
342 
343  void RemoveScintillator() const;
344 
345  void MakeSmallPMT() const;
346 
347  void RemoveSmallPMT() const;
348 
349  const std::vector<int>& SetPartnerIds() const;
350 
356  template<typename T>
358  GetStationData(T& requestedData,
359  const std::string& property,
360  const std::string& component,
361  const std::string& errorMsg, const bool throwOnFailure = true)
362  const
363  {
364  const auto& manager = det::Detector::GetInstance().GetSManagerRegister();
365  const auto status = manager.GetData(requestedData, property, component, fStationIndexMap);
366  if (throwOnFailure && status == det::VManager::eNotFound)
367  NotFoundAndThrow(errorMsg);
368  return status;
369  }
370 
371  void NotFoundAndThrow(const std::string& msg) const;
372 
373  template<typename T>
374  static
375  const std::vector<T>&
376  InitializeIfNeeded(std::vector<T>& histox,
377  const short int normalBins, const short int step,
378  const short int stridedBins, const short int stride)
379  {
380  if (histox.empty()) {
381  histox.reserve(normalBins + stridedBins + 1);
382  for (short i = 0; i < normalBins; ++i)
383  histox.push_back(step*i);
384  for (short i = 0; i <= stridedBins; ++i)
385  histox.push_back(step*(normalBins + stride*i));
386  }
387  return histox;
388  }
389 
390  static void InitializeShape(std::vector<double>& histox, const int nBins, const double dt);
391 
392  //
393 
394  int fId = 0;
395  mutable bool fIsUUB = false;
396  /* Station id and hardware version held also as strings in fStationIndexMap
397  with keys "stationId" and "isUUB", respectively. Don't forget to update
398  "isUUB" accordingly to changes in fIsUUB. */
406 
408 
410 
412 
413  // Quantities filled by lazy evaluation
415  typedef std::bitset<SDetectorConstants::kGridIndexSize> InGridType;
420 
422 
424 
425  private:
426  // used in UTM conversions
428 
431 
436 
438 
440 
442 
444 
445  bool fDense = false;
446 
447  protected:
450 
451  friend class SDetector;
452  friend class Unlock;
453 
454  };
455 
456 }
457 
458 
459 #endif
unsigned int GetNPMTs(const PMTConstants::PMTType type=PMTConstants::eAnyType) const
Number of pmts in station.
const utl::TimeRange & GetCommissionTimeRange() const
Station commission time range.
const StationIdCollection & GetCrown(const int level) const
Returns a list of station id&#39;s in the crown. If the argument is 0, it returns the station id...
InternalPMTVector fPMTVector
static const unsigned int kWaterCherenkovSmallPMTId
double GetTimingUncertainty() const
void NotFoundAndThrow(const std::string &msg) const
Point object.
Definition: Point.h:32
int GetAssociatedCounterId() const
the identifier of the associated muon Counter.
class to hold data at PMT level
Definition: SEvent/PMT.h:28
Detector description interface for Station-related data.
utl::Validated< double > fFADCBinSize
const std::vector< int > & GetPartnerIds() const
returns vector of partner station ids
int GetGroupId() const
returns unique identifier of a group of stations or zero (if single)
Time interval defined by two TimeStamps.
Definition: TimeRange.h:23
bool IsUUB() const
Detector description interface for PMT-related data.
Definition: SDetector/PMT.h:26
bool IsInsideStation(const utl::Point &pos) const
Station(const int id)
void UpdateElectronics(const bool isuub) const
bool HasSmallPMT() const
utl::Validated< utl::TimeRange > fCommissionTimeRange
utl::Validated< int > fGroupId
Class to hold collection (x,y) points and provide interpolation between them.
utl::Validated< utl::TimeStamp > fUUBCommissionTime
const utl::TabulatedFunction & GetLinerSpecularLobe() const
Tyvek liner specular lobe constant as a function of photon energy.
void RemoveScintillator() const
const TimeStamp & GetStopTime() const
Definition: TimeRange.h:36
bool IsInGrid(const SDetectorConstants::GridIndex index=SDetectorConstants::eStandard) const
Tells whether the station is in the regular triangular grid.
utl::ShadowPtr< utl::TabulatedFunction > fLinerSpecularLobe
const PMT & GetPMT(const int id) const
Get specified PMT by id.
utl::Validated< double > fHeight
det::VManager::IndexMap fStationIndexMap
static void InitializeShape(std::vector< double > &histox, const int nBins, const double dt)
utl::Validated< double > fTimingUncertainty
bool IsHit(const utl::Point &from, const utl::Vector &direction) const
const utl::TabulatedFunction & GetWaterAbsorptionLength() const
Water absorption length as a function of photon energy.
const utl::TimeStamp & GetUUBCommissionTime() const
const std::vector< T > & const
utl::Validated< double > fThickness
A TimeStamp holds GPS second and nanosecond for some event.
Definition: TimeStamp.h:110
const std::string & GetName() const
Station name.
utl::Point GetPosition() const
Tank position.
const utl::TimeStamp & GetDecommissionTime() const
Station decommission time.
utl::ShadowPtr< utl::TabulatedFunction > fWaterAbsLength
static const unsigned int kFirstWaterCherenkovLargePMTId
utl::ShadowPtr< utl::TabulatedFunction > fWaterRefractionIndex
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
utl::ShadowPtr< utl::TabulatedFunction > fLinerSpecularSpike
utl::Validated< std::vector< int > > fPartnerIds
utl::Validated< int > fLatchBin
bool IsHit(const utl::Point &from, const utl::Vector &direction, utl::Point &where) const
const utl::TabulatedFunction & GetLinerReflectivity() const
Tyvek liner reflectivity as a function of photon energy.
const std::vector< int > & SetPartnerIds() const
static std::vector< T > emptyVector
InternalCrownCollection fCrowns
static const unsigned int kScintillatorPMTId
PMTIterator PMTsEnd() const
End of the collection of pointers to PMTs.
unsigned int GetSaturationValue() const
utl::Validated< InGridType > fInGrid
std::vector< int > StationIdCollection
const std::vector< double > & GetAxes() const
utl::CoordinateSystemPtr fReferenceSystem
const Station & operator()(const int stationId) const
const std::vector< double > & GetMuonShapeHistogramBinning(const int calibrationVersion) const
PartnerIterator PartnersEnd() const
End of the collection of Partners in multiplet.
utl::ReferenceEllipsoid::EllipsoidID fEllipsoid
int GetLatchBin() const
const TimeStamp & GetStartTime() const
Definition: TimeRange.h:35
utl::CoordinateSystemPtr GetLocalCoordinateSystem() const
Get the Auger reference system centered on the tank.
double GetRadius() const
Radius of the tank (water only)
const Scintillator & GetScintillator() const
double GetHeight() const
Height of the tank (water only)
#define OFFLINE_MAKE_CONST_ITERATOR_RANGE(_ConstIterator_, _NamePrefix_)
Definition: IteratorRange.h:28
static const unsigned int kLastWaterCherenkovLargePMTId
bool ExistsAssociatedCounter() const
if this Station has an associated muon Counter.
boost::transform_iterator< InternalPartnerStationFunctor, std::vector< int >::const_iterator, const Station & > PartnerIterator
PartnerIterator returns a pointer to a station.
void Update() const
utl::Validated< std::vector< double > > fAxes
bool IsInAcquisition() const
Station in data acquisition.
Base class for inconsistency/illogicality exceptions.
InternalPMTVector::const_iterator InternalPMTIterator
utl::Validated< double > fRadius
utl::ShadowPtr< utl::TabulatedFunction > fElectronicsImpulseResponse
const utl::TabulatedFunction & GetLinerSpecularSpike() const
Tyvek liner specular spike constant as a function of photon energy.
std::vector< const PMT * > InternalPMTVector
PMTIterator PMTsBegin() const
Beginning of the collection of pointers to PMTs.
const PMT & GetScintillatorPMT() const
std::bitset< SDetectorConstants::kGridIndexSize > InGridType
utl::Validated< unsigned int > fSaturationValue
double GetFADCBinSize() const
PartnerIterator PartnersBegin() const
Beginning of the collection of Partners in multiplet.
utl::Validated< std::string > fName
static unsigned int GetFirstPMTId()
Id of first pmt in station.
const utl::TimeStamp & GetCommissionTime() const
Station commission time.
void MakeScintillator() const
boost::indirect_iterator< InternalPMTIterator, const PMT & > PMTIterator
PMTIterator returns a pointer to a PMT.
double GetThickness() const
Thickness of the tank walls.
static const std::vector< T > & InitializeIfNeeded(std::vector< T > &histox, const short int normalBins, const short int step, const short int stridedBins, const short int stride)
std::map< std::string, std::string > IndexMap
Definition: VManager.h:133
utl::Validated< int > fIsInAcquisition
const utl::TabulatedFunction & GetWaterRefractionIndex() const
Water refraction index as a function of photon energy.
bool IsDense() const
Tells whether the station belongs to set of hypothetical &quot;dense&quot; stations.
bool HasScintillator() const
Vector object.
Definition: Vector.h:30
Detector description interface for SDetector-related data.
Definition: SDetector.h:42
const PMT & GetSmallPMT() const
unsigned int GetFADCTraceLength() const
utl::ShadowPtr< Scintillator > fScintillator
utl::Validated< unsigned int > fFADCTraceLength
EllipsoidID
ID&#39;s of known reference ellipsoid&#39;s.
double GetLinerSigmaAlpha() const
Tyvek liner sigma_alpha roughness parameter.
void MakeSmallPMT() const
unsigned int GetLastPMTId() const
Id of last PMT in station.
int GetId() const
Station ID.
det::VManager::Status GetStationData(T &requestedData, const std::string &property, const std::string &component, const std::string &errorMsg, const bool throwOnFailure=true) const
int GetNumberOfPartners() const
Number of partners the station has.
const utl::TabulatedFunction & GetElectronicsImpulseResponse() const
utl::ShadowPtr< utl::TabulatedFunction > fLinerReflectivity
Status
Specifies success or (eventually) various possible failure modes.
Definition: VManager.h:127
utl::Validated< double > fLinerSigmaAlpha
std::map< int, StationIdCollection > InternalCrownCollection
void RemoveSmallPMT() const
Station operator=(const Station &)
utl::Validated< utl::Point > fPosition
const short int stridedBins

, generated on Tue Sep 26 2023.