FDetector.cc
Go to the documentation of this file.
1 #include <fdet/Eye.h>
2 #include <fdet/FDetector.h>
3 #include <fdet/Telescope.h>
4 #include <fdet/Pixel.h>
5 #include <fdet/FDetComponentSelector.h>
6 
7 #include <det/VManager.h>
8 #include <det/Detector.h>
9 
10 #include <fevt/Eye.h>
11 #include <fevt/Telescope.h>
12 #include <fevt/Pixel.h>
13 #include <fevt/Channel.h>
14 
15 #include <utl/AugerException.h>
16 #include <utl/ErrorLogger.h>
17 
18 using namespace fdet;
19 using namespace std;
20 using namespace det;
21 using namespace utl;
22 
23 
24 unsigned int
26  const
27 {
28  if (!fFullEyeList)
29  return 0;
30  return *std::min_element(fFullEyeList->begin(), fFullEyeList->end());
31 }
32 
33 
34 unsigned int
36  const
37 {
38  if (!fFullEyeList)
39  return 0;
40  return *std::max_element(fFullEyeList->begin(), fFullEyeList->end());
41 }
42 
43 
45 {
46  for (InternalEyeIterator it = fCommissionedEyeList.begin();
47  it != fCommissionedEyeList.end(); ++it)
48  delete *it;
49  delete fFullEyeList;
50  delete fReferenceLambda;
51 }
52 
53 
54 void
56 {
57  // Get all eyes indicated in the XML file (uses lazy evaluation)
58  //
59  GetFullEyeList();
60 
61  for (InternalEyeIterator it = fCommissionedEyeList.begin();
62  it != fCommissionedEyeList.end(); ++it)
63  (*it)->Update();
64 }
65 
66 
67 const Eye&
68 FDetector::GetEye(const unsigned int eyeId)
69  const
70 {
71  for (AllEyeIterator it = AllEyesBegin(); it != AllEyesEnd(); ++it)
72  if (eyeId == it->GetId())
73  return *it;
74 
75  ostringstream err;
76  err << "Eye with Id = " << eyeId << " does not exist, "
77  "or else detector description was not properly configured. "
78  "detector time = " << Detector::GetInstance().GetTime();
79  ERROR(err);
80  throw utl::NonExistentComponentException(err.str());
81 
82 }
83 
84 
85 const Eye&
86 FDetector::GetEye(const string& eyeName)
87  const
88 {
89  for (AllEyeIterator it = AllEyesBegin(); it != AllEyesEnd(); ++it)
90  if (eyeName == it->GetName())
91  return *it;
92 
93  ostringstream err;
94  err << "Eye with name = " << eyeName << " does not exist, "
95  "or else detector description was not properly configured. "
96  "detector time = " << Detector::GetInstance().GetTime();
97  ERROR(err);
98  throw utl::NonExistentComponentException(err.str());
99 }
100 
101 
112  const
113 {
114  if (!fFullEyeList) {
115 
116  const VManager& manager =
117  Detector::GetInstance().GetFManagerRegister();
118 
119  fFullEyeList = new InternalEyeIdCollection;
120 
121  VManager::IndexMap indexMap;
122  const VManager::Status foundFlag =
123  manager.GetData(*fFullEyeList, "eyeList", "", indexMap);
124 
125  if (foundFlag == VManager::eNotFound) {
126  DEBUGLOG("Could not find a list of Eye Id's. "
127  "No eye information will be available!");
128  }
129 
130  for (InternalEyeIdCollection::iterator it = fFullEyeList->begin();
131  it != fFullEyeList->end(); ++it) {
132  Eye* const eye = new Eye(*it);
133  fCommissionedEyeList.push_back(eye);
134  }
135 
136  }
137  return *fFullEyeList;
138 }
139 
140 
141 const Eye&
142 FDetector::GetEye(const fevt::Eye& eventEye)
143  const
144 {
145  return GetEye(eventEye.GetId());
146 }
147 
148 
149 const Telescope&
151  const
152 {
153  const unsigned int eyeid = eventTel.GetEyeId();
154  const unsigned int telid = eventTel.GetId();
155 
156  return GetEye(eyeid).GetTelescope(telid);
157 }
158 
159 
160 const Channel&
162  const
163 {
164  const unsigned int eyeid = eventChannel.GetEyeId();
165  const unsigned int telid = eventChannel.GetTelescopeId();
166  const unsigned int chid = eventChannel.GetId();
167 
168  return GetEye(eyeid).GetTelescope(telid).GetChannel(chid);
169 }
170 
171 
172 const Channel&
174  const
175 {
176  const unsigned int eyeid = p.GetEyeId();
177  const unsigned int telid = p.GetTelescopeId();
178  const unsigned int chid = p.GetChannelId();
179 
180  return GetEye(eyeid).GetTelescope(telid).GetChannel(chid);
181 }
182 
183 
184 const Channel&
186  const
187 {
188  const unsigned int eyeid = p.GetEyeId();
189  const unsigned int telid = p.GetTelescopeId();
190  const unsigned int chid =
191  det::Detector::GetInstance().GetFDetector().GetEye(eyeid).GetTelescope(telid).GetPixel(p.GetId()).GetChannelId();
192 
193  return GetEye(eyeid).GetTelescope(telid).GetChannel(chid);
194 }
195 
196 
197 const Pixel&
199  const
200 {
201  const unsigned int eyeid = eventPixel.GetEyeId();
202  const unsigned int telid = eventPixel.GetTelescopeId();
203  const unsigned int pixid = eventPixel.GetId();
204 
205  return GetEye(eyeid).GetTelescope(telid).GetPixel(pixid);
206 }
207 
208 
209 const Pixel&
211  const
212 {
213  const unsigned int eyeid = c.GetEyeId();
214  const unsigned int telid = c.GetTelescopeId();
215  const unsigned int pixid =
216  det::Detector::GetInstance().GetFDetector().GetEye(eyeid).GetTelescope(telid).GetChannel(c.GetId()).GetPixelId();
217 
218  return GetEye(eyeid).GetTelescope(telid).GetPixel(pixid);
219 }
220 
221 
222 const Pixel&
224  const
225 {
226  const unsigned int eyeid = c.GetEyeId();
227  const unsigned int telid = c.GetTelescopeId();
228  const unsigned int pixid = c.GetPixelId();
229 
230  return GetEye(eyeid).GetTelescope(telid).GetPixel(pixid);
231 }
232 
233 
234 double
236  const
237 {
238  UpdateFdUpTime();
239  return fUpTimeFraction;
240 }
241 
242 
243 bool
245  const
246 {
247  UpdateFdUpTime();
248  return fUpTimeFraction > 0;
249 }
250 
251 
252 int
254  const
255 {
256  UpdateFdUpTime();
257  return fStatus;
258 }
259 
260 
261 bool
263  const
264 {
265  UpdateFdUpTime();
266  return fHasFdUpTime;
267 }
268 
269 
270 void
272  const
273 {
274  if (fUpTimeValidityStamp.IsValid())
275  return;
276 
277  GetFDetectorData(fHasFdUpTime, "has_fduptime", "CDAS", "set events up time bit");
278  int startTime;
279  GetFDetectorData(startTime, "uptime_gpsStart", "CDAS", "start validity CDAS up time");
280  int endTime;
281  GetFDetectorData(endTime, "uptime_gpsStop", "CDAS", "end validity CDAS up time");
282  GetFDetectorData(fUpTimeFraction, "uptime_fraction", "CDAS", "CDAS up time fraction");
283  //GetFDetectorData(fVetoFraction, "veto_fraction", "CDAS", "CDAS Veto fraction");
284  GetFDetectorData(fStatus, "status", "CDAS", "CDAS DAQ status");
285  fUpTimeValidityStamp.SetValidityInterval(startTime, endTime);
286 }
287 
288 
289 // returns the maximum minimal-wavelength validity of all FDet-Components
290 double
292  const
293 {
294  double minWavelength = 0;
295  bool first = true;
296  for (InternalEyeIterator it = fCommissionedEyeList.begin();
297  it != fCommissionedEyeList.end(); ++it) {
298  if (first) {
299  first = false;
300  minWavelength = (*it)->GetModelMinWavelength();
301  }
302  else {
303  minWavelength = max(minWavelength, (*it)->GetModelMinWavelength());
304  }
305  }
306  return minWavelength;
307 }
308 
309 
310 // returns the minimum maximal-wavelength validity of all FDet-Components
311 double
313  const
314 {
315  double maxWavelength = 0;
316  bool first = true;
317  for (InternalEyeIterator it = fCommissionedEyeList.begin();
318  it != fCommissionedEyeList.end(); ++it) {
319  if (first) {
320  first = false;
321  maxWavelength = (*it)->GetModelMaxWavelength();
322  }
323  else {
324  maxWavelength = min(maxWavelength, (*it)->GetModelMaxWavelength());
325  }
326  }
327  return maxWavelength;
328 }
329 
330 
331 double
333  const
334 {
335  if (!fReferenceLambda)
336  GetFDetectorData(fReferenceLambda, "referenceLambda", "telescopeList", "reference lambda");
337 
338  return *fReferenceLambda;
339 }
340 
341 
342 template<typename T>
343 inline
344 const T&
345 FDetector::GetFDetectorData(T*& requestedData,
346  const string& property,
347  const string& component,
348  const string& errorMsg)
349  const
350 {
351  if (!requestedData) {
352  requestedData = new T;
353  GetFDetectorData(*requestedData, property, component, errorMsg);
354  }
355  return *requestedData;
356 }
357 
358 
359 template<typename T>
360 inline
361 void
363  const string& property,
364  const string& component,
365  const string& errorMsg)
366  const
367 {
368  const VManager& manager = Detector::GetInstance().GetFManagerRegister();
369  VManager::IndexMap indexMap; // empty (there is only one CDAS !)
370  const VManager::Status status =
371  manager.GetData(requestedData, property, component, indexMap);
372 
373  // ERROR
374  if (status == VManager::eNotFound) {
375  ostringstream err;
376  err << "Did not find requested component: '" << errorMsg << "' for CDAS";
377  ERROR(err);
378  throw NonExistentComponentException(err.str());
379  }
380 }
381 
382 
383 // Configure (x)emacs for this file ...
384 // Local Variables:
385 // mode: c++
386 // compile-command: "make -C .. -k"
387 // End:
unsigned int GetId() const
Definition: FEvent/Eye.h:54
unsigned int GetEyeId() const
Description of the electronic channel for the 480 channels of the crate.
unsigned int GetTelescopeId() const
1..6 for normal FD, 1..3 for HEAT
Fluorescence Detector Eye Event.
Definition: FEvent/Eye.h:29
bool IsCDASInAquisition() const
Definition: FDetector.cc:244
const Pixel & GetPixel(const fevt::Pixel &eventPixel) const
Get fdet::Pixel from fevt::Channel.
Definition: FDetector.cc:198
unsigned int GetId() const
unsigned int GetEyeId() const
double GetModelMinWavelength() const
Definition: FDetector.cc:291
unsigned int GetLastEyeId() const
Get Id of last eye.
Definition: FDetector.cc:35
Base class for exceptions trying to access non-existing components.
const Eye & GetEye(const unsigned int eyeId) const
Find eye by numerical Id.
Definition: FDetector.cc:68
Detector description interface for Eye-related data.
Definition: FDetector/Eye.h:45
Interface for detector managers.
Definition: VManager.h:115
const T & GetFDetectorData(T *&requestedData, const std::string &property, const std::string &component, const std::string &errorMsg) const
Definition: FDetector.cc:345
void UpdateFdUpTime() const
Definition: FDetector.cc:271
virtual Status GetData(double &returnData, const std::string &componentProperty, const std::string &componentName, const IndexMap &componentIndex) const =0
unsigned int GetId() const
Definition: FEvent/Pixel.h:31
#define max(a, b)
Fluorescence Detector Pixel event.
Definition: FEvent/Pixel.h:28
unsigned int GetChannelId() const
double GetModelMaxWavelength() const
Definition: FDetector.cc:312
#define DEBUGLOG(message)
Macro for logging debugging messages.
Definition: ErrorLogger.h:157
double GetCDASUpTimeFraction() const
Definition: FDetector.cc:235
unsigned int GetTelescopeId() const
const Channel & GetChannel(const fevt::Channel &eventChannel) const
Get fdet::Channel from fevt::Channel.
Definition: FDetector.cc:161
unsigned int GetTelescopeId() const
std::list< int > InternalEyeIdCollection
Definition: FDetector.h:48
Fluorescence Detector Channel Event.
unsigned int GetEyeId() const
Definition: FEvent/Pixel.h:33
const InternalEyeIdCollection & GetFullEyeList() const
Definition: FDetector.cc:111
double GetReferenceLambda() const
Definition: FDetector.cc:332
unsigned int GetFirstEyeId() const
Get Id of first eye.
Definition: FDetector.cc:25
unsigned int GetTelescopeId() const
Definition: FEvent/Pixel.h:32
Detector description interface for Telescope-related data.
const Telescope & GetTelescope(const fevt::Telescope &eventTel) const
Get fdet::Telescope from fevt::Telescope.
Definition: FDetector.cc:150
unsigned int GetId() const
InternalEyeCollection::const_iterator InternalEyeIterator
Definition: FDetector.h:50
std::map< std::string, std::string > IndexMap
Definition: VManager.h:133
Description of a pixel.
unsigned int GetEyeId() const
Fluorescence Detector Telescope Event.
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
int GetCDASDAQStatus() const
Definition: FDetector.cc:253
unsigned int GetEyeId() const
1..5 (4x normal FD, 1x HEAT)
boost::indirect_iterator< InternalEyeIterator, const Eye & > AllEyeIterator
An iterator over eyes for read only.
Definition: FDetector.h:53
Status
Specifies success or (eventually) various possible failure modes.
Definition: VManager.h:127
bool HasFdUpTime() const
Definition: FDetector.cc:262
unsigned int GetPixelId() const

, generated on Tue Sep 26 2023.