Framework/FDetector/Camera.cc
Go to the documentation of this file.
1 #include <sstream>
2 
3 #include <boost/lexical_cast.hpp>
4 
5 #include <fdet/Camera.h>
6 
7 #include <utl/ErrorLogger.h>
8 #include <utl/Md5Sum.h>
9 
10 #include <det/VManager.h>
11 #include <det/Detector.h>
12 #include <fdet/FDetector.h>
13 #include <fdet/Eye.h>
14 #include <fdet/Telescope.h>
15 #include <fdet/Pixel.h>
16 #include <fdet/Channel.h>
17 
18 #include <fevt/Pixel.h>
19 #include <fevt/Channel.h>
20 
21 using namespace std;
22 using namespace utl;
23 using namespace fdet;
24 using namespace det;
25 
26 
27 Camera::Camera(const unsigned int eyeId, const unsigned int telId,
28  const std::string& physEyeIdString,
29  const std::string& physTelIdString) :
30  fEyeId(eyeId),
31  fTelescopeId(telId),
32  fPhysicalEyeIdString(physEyeIdString),
33  fPhysicalTelescopeIdString(physTelIdString),
34  fRadiusFocal(0),
35  fMercedesBase(0),
36  fMercedesHeight(0),
37  fSigmaNormal(0),
38  fMercedesEfficiency(0),
39  fMercedesReflections(0),
40  fPixelEta(0),
41  fCenterRow(0),
42  fCenterColumn(0),
43  fFieldOfView(0),
44  fSLTTriggerBin(0),
45  fSLTTraceLenth(0),
46  fSLTBinSize(0),
47  fFADCTraceLenth(0),
48  fFADCBinSize(0),
49  fFLTBoxCarmSumLength(0),
50  fFLTProlongation(0),
51  fFLTTriggerRate(0),
52  fCutoffFrequency(0),
53  fGainVar(0),
54  fElectNoiseVar(0),
55  fADCDynamicRange(0),
56  fElecGain(0),
57  fVirtualChannelGainRatio(0),
58  fNRows(0),
59  fNColumns(0)
60 { }
61 
62 
64 {
65  delete fRadiusFocal;
66  delete fMercedesBase;
67  delete fMercedesHeight;
68  delete fSigmaNormal;
69  delete fMercedesEfficiency;
70  delete fMercedesReflections;
71  delete fPixelEta;
72  delete fCenterRow;
73  delete fCenterColumn;
74  delete fFieldOfView;
75  delete fSLTTriggerBin;
76  delete fSLTTraceLenth;
77  delete fSLTBinSize;
78  delete fFADCBinSize;
79  delete fFADCTraceLenth;
80  delete fFLTBoxCarmSumLength;
81  delete fFLTProlongation;
82  delete fFLTTriggerRate;
83  delete fCutoffFrequency;
84  delete fGainVar;
85  delete fElectNoiseVar;
86  delete fADCDynamicRange;
87  delete fElecGain;
89  delete fNRows;
90  delete fNColumns;
91 }
92 
93 
95 }
96 
97 // camera geometry/optics
98 double
100  const
101 {
102  return GetCameraData(fMercedesBase, "mercedesBase", "camera", "Mercedes base width");
103 }
104 
105 
106 double
108  const
109 {
110  return GetCameraData(fMercedesHeight, "mercedesHeight", "camera", "Mercedes height");
111 }
112 
113 
114 double
116  const
117 {
118  return GetCameraData(fRadiusFocal, "radiusFocal", "camera", "Radius focal");
119 }
120 
121 
122 double
124  const
125 {
126  return GetCameraData(fSigmaNormal, "sigmaNormal", "camera", "sigma normal");
127 }
128 
129 
130 double
132  const
133 {
134  return GetCameraData(fMercedesEfficiency, "mercedesEfficiency", "camera", "mercedes efficiency");
135 }
136 
137 double
139  const
140 {
141  return GetCameraDataDiaphragm(fMercedesReflections, "mercedesReflections", "camera", "average number of mercedes reflections");
142 }
143 
144 
145 double
147  const
148 {
149  return GetCameraData(fFieldOfView, "fieldOfView", "camera", "field of view");
150 }
151 
152 
153 
154 
155 double
157  const
158 {
159  return GetCameraData(fPixelEta, "eta", "camera", "pixel eta");
160 }
161 
162 double
164  const
165 {
166  return GetCameraData(fCenterRow, "centerRow", "camera", "center row");
167 }
168 
169 double
171  const
172 {
173  return GetCameraData(fCenterColumn, "centerColumn", "camera", "center row");
174 }
175 
176 
177 // camera electronics
178 
179 int
181  const
182 {
183  return GetCameraData(fSLTTriggerBin, "SLTTriggerBin", "electronics", "SLT trigger bin");
184 }
185 
186 
187 int
189  const
190 {
191  /*
192  * SLT trace langth is 100 (*1mu s) for old and new (HEAT) electronics.
193  * TODO: Should be in FModelConfig!
194  */
195  /*
196  * double size = GetSLTBinSize();
197  * double tracelength = GetFADCBinSize() * GetFADCTraceLength();
198  * return (int) ceil(tracelength/size);
199  */
200 
201  return 100;
202 }
203 
204 double
206  const
207 {
208  return GetCameraData(fSLTBinSize, "SLTBinWidth", "electronics", "SLT bin width");
209 }
210 
211 
212 int
214  const
215 {
216  return GetCameraData(fFADCTraceLenth, "numTraceBins", "electronics", "FADC trace size");
217 }
218 
219 
220 double
222  const
223 {
224  return GetCameraData(fFADCBinSize, "traceBinWidth", "electronics", "FADC bin width");
225 }
226 
227 
228 int
230  const
231 {
232  return GetCameraData(fFLTBoxCarmSumLength, "FLTBoxCarWidth", "electronics", "FLT boxcar length");
233 }
234 
235 double
237  const
238 {
239  return GetCameraData(fFLTTriggerRate, "FLTTriggerRate", "electronics", "FLT Trigger Rate");
240 }
241 
242 int
244  const
245 {
246  return GetCameraData(fFLTProlongation, "FLTProlongation", "electronics", "FLT prolongation for SLT");
247 }
248 
249 
251  return GetCameraData(fCutoffFrequency, "cutoffFrequency", "electronics", "Gaussian filter 3dB cutoff frequency");
252 }
253 
254 double Camera::GetGainVariance() const {
255  return GetCameraData(fGainVar, "gainVar", "electronics", "additional Gaussian fluctuantion to Poisson fluctuations");
256 }
257 
259  return GetCameraData(fElectNoiseVar, "elecNoiseVar", "electronics", "Electronic noise variance");
260 }
261 
263  return GetCameraData(fADCDynamicRange, "ADCDynamicRange", "electronics", "ADC dynamic range w/o virtual channels");
264 }
265 
266 double
268  const
269 {
270  return GetCameraData(fElecGain, "gain", "electronics", "electronics gain");
271 }
272 
273 double
275  const
276 {
277  return GetCameraData(fVirtualChannelGainRatio, "VirtualChannelGainRatio", "electronics",
278  "virtual channel gain ratio");
279 }
280 
281 
282 // camera cabling
283 
284 unsigned int
285 Camera::GetChannelId(const unsigned int pixelId)
286  const
287 {
288  // no caching !
289  int channelId;
290  GetCameraPixelData(channelId, "pixel_mapping", "electronics", "pixel mapping", pixelId);
291  return channelId;
292 }
293 
294 
295 unsigned int
297  const
298 {
299  // no caching !
300  int channelId;
301  GetCameraPixelData(channelId, "pixel_mapping", "electronics", "pixel mapping", pixel.GetId());
302  return channelId;
303 }
304 
305 
306 unsigned int
308  const
309 {
310  // no caching !
311  int channelId;
312  GetCameraPixelData(channelId, "pixel_mapping", "electronics", "pixel mapping", pixel.GetId());
313  return channelId;
314 }
315 
316 
317 unsigned int
318 Camera::GetPixelId(unsigned int channelId)
319  const
320 {
321  // no caching !
322  int pixelId;
323  GetCameraChannelData(pixelId, "channel_mapping", "electronics", "channel mapping", channelId);
324  return pixelId;
325 }
326 
327 
328 unsigned int
330  const
331 {
332  // no caching !
333  int pixelId;
334  GetCameraChannelData(pixelId, "channel_mapping", "electronics", "channel mapping", channel.GetId());
335  return pixelId;
336 }
337 
338 
339 unsigned int
341  const
342 {
343  // no caching
344  int pixelId;
345  GetCameraChannelData(pixelId, "channel_mapping", "electronics", "channel mapping", channel.GetId());
346  return pixelId;
347 }
348 
349 
350 // Camera layout info
351 unsigned int
353  const
354 {
355  const int row = GetCameraData(fNRows,
356  "pixelRows", "camera", "number of pixel rows");
357  return (unsigned int)row;
358 }
359 
360 
361 unsigned int
363  const
364 {
365  const int col = GetCameraData(fNColumns,
366  "pixelColumns", "camera", "number of pixel columns");
367  return (unsigned int)col;
368 }
369 
370 
371 std::string
373  const
374 {
375  ostringstream configString;
376  configString << "Threshold:"
377  << " Gain = " << GetElectronicsGain()
378  << " GainVariance = " << GetGainVariance()
379  << " ElectronicNoise = " << GetElectronicNoiseVariance()
380  << " CutoffFrequency = " << GetCutoffFrequency()
381  << " FLTTriggerRate = " << GetFLTTriggerRate()
382  << " FLTBoxcarSize = " << GetFLTBoxcarSumLength();
383  if(fEyeId>0 && fEyeId<5){
384  if(fTelescopeId>0 && fTelescopeId<7){
385  configString << " Telescopetype = standard";
386  }
387  }else if(fEyeId==5){
388  if(fTelescopeId>0 && fTelescopeId<4){
389  configString << " Telescopetype = HEAT";
390  }
391  }
392  return Md5Sum(configString.str()).GetHexDigest();
393 }
394 
395 // data getters
396 
397 template<typename T>
398 inline
399 const T&
400 Camera::GetCameraData(T*& requestedData,
401  const std::string& property,
402  const std::string& component,
403  const std::string& errorMsg)
404  const
405 {
406  if (!requestedData) {
407  requestedData = new T;
408  GetCameraData(*requestedData, property, component, errorMsg);
409  }
410  return *requestedData;
411 }
412 
413 
414 template<typename T>
415 inline
416 void
417 Camera::GetCameraData(T& requestedData,
418  const std::string& property,
419  const std::string& component,
420  const std::string& errorMsg)
421  const
422 {
423  const VManager& manager = Detector::GetInstance().GetFManagerRegister();
424 
425  VManager::IndexMap indexMap;
426  indexMap["telescopeId"] = fPhysicalTelescopeIdString;
427  indexMap["eyeId"] = fPhysicalEyeIdString;
428 
429  const VManager::Status foundFlag =
430  manager.GetData(requestedData, property, component, indexMap);
431 
432  if (foundFlag == VManager::eNotFound) {
433  ostringstream err;
434  err << "Did not find requested component for " << errorMsg<< "; "
435  << VManager::QueryInfoMessage(property, component, indexMap);
436  ERROR(err);
437  throw NonExistentComponentException(err.str());
438  }
439 }
440 
441 template<typename T>
442 inline
443 const T&
445  const std::string& property,
446  const std::string& component,
447  const std::string& errorMsg)
448  const
449 {
450  if (!requestedData) {
451  requestedData = new T;
452  GetCameraDataDiaphragm(*requestedData, property, component, errorMsg);
453  }
454  return *requestedData;
455 }
456 
457 
458 template<typename T>
459 inline
460 void
462  const std::string& property,
463  const std::string& component,
464  const std::string& errorMsg)
465  const
466 {
467  const VManager& manager = Detector::GetInstance().GetFManagerRegister();
468 
469  VManager::IndexMap indexMap;
470  indexMap["telescopeId"] = fPhysicalTelescopeIdString;
471  indexMap["eyeId"] = fPhysicalEyeIdString;
472  const fdet::FDetector& detFD = Detector::GetInstance().GetFDetector();
473  const bool hasCorrectorRing =
475  indexMap["correctorId"] = (hasCorrectorRing ? "large" : "small");
476 
477  const VManager::Status foundFlag =
478  manager.GetData(requestedData, property, component, indexMap);
479 
480  if (foundFlag == VManager::eNotFound) {
481  ostringstream err;
482  err << "Did not find requested component for " << errorMsg<< "; "
483  << VManager::QueryInfoMessage(property, component, indexMap);
484  ERROR(err);
485  throw NonExistentComponentException(err.str());
486  }
487 }
488 
489 
490 template<typename T>
491 inline
492 void
494  const std::string& property,
495  const std::string& component,
496  const std::string& errorMsg,
497  const unsigned int channelId)
498  const
499 {
500  const VManager& manager = Detector::GetInstance().GetFManagerRegister();
501 
502  VManager::IndexMap indexMap;
503  indexMap["telescopeId"] = fPhysicalTelescopeIdString;
504  indexMap["eyeId"] = fPhysicalEyeIdString;
505  indexMap["channelId"] = boost::lexical_cast<string>(channelId);
506 
507  const VManager::Status foundFlag =
508  manager.GetData(requestedData, property, component, indexMap);
509 
510  if (foundFlag == VManager::eNotFound) {
511  ostringstream err;
512  err << "Did not find requested component for " << errorMsg << "; "
513  << VManager::QueryInfoMessage(property, component, indexMap);
514  ERROR(err);
515  throw NonExistentComponentException(err.str());
516  }
517 }
518 
519 
520 template<typename T>
521 inline
522 void
523 Camera::GetCameraPixelData(T& requestedData,
524  const std::string& property,
525  const std::string& component,
526  const std::string& errorMsg,
527  const unsigned int pixelId)
528  const
529 {
530  const VManager& manager =
531  Detector::GetInstance().GetFManagerRegister();
532 
533  VManager::IndexMap indexMap;
534  indexMap["telescopeId"] = fPhysicalTelescopeIdString;
535  indexMap["eyeId"] = fPhysicalEyeIdString;
536  indexMap["pixelId"] = boost::lexical_cast<string>(pixelId);
537 
538  const VManager::Status foundFlag =
539  manager.GetData(requestedData, property, component, indexMap);
540 
541  if (foundFlag == VManager::eNotFound) {
542  ostringstream err;
543  err << "Did not find requested component for " << errorMsg << "; "
544  << VManager::QueryInfoMessage(property, component, indexMap);
545  ERROR(err);
546  throw NonExistentComponentException(err.str());
547  }
548 }
549 
550 
551 // Configure (x)emacs for this file ...
552 // Local Variables:
553 // mode: c++
554 // compile-command: "make -C .. FDetector/Camera.o -k"
555 // End:
unsigned int GetId() const
By default from 1..440.
std::string fPhysicalEyeIdString
Class to compute MD5 checksum Based on the RSA C code, wrapped in an OO fashion.
Definition: Md5Sum.h:27
double GetFADCBinSize() const
double GetSigmaNormal() const
Variable to model the Mercedes surface imperfection.
Description of the electronic channel for the 480 channels of the crate.
double GetFieldOfView() const
unsigned int GetLastColumn() const
double GetElectronicsGain() const
double GetEta() const
Camera angular pixel spacing.
unsigned int GetId() const
double GetCutoffFrequency() const
double GetGainVariance() const
double GetCenterRow() const
central pixel row
double GetMercedesHeight() const
Height of the Mercedes.
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
Interface for detector managers.
Definition: VManager.h:115
double GetFLTTriggerRate() const
int GetFLTBoxcarSumLength() const
Detector description interface for FDetector-related data.
Definition: FDetector.h:44
double GetCenterColumn() const
central pixel column
bool HasCorrectorRing() const
flag for corrector ring presence
double GetMercedesEfficiency() const
Average efficiency of the Mercedes.
void GetCameraPixelData(T &requestedData, const std::string &property, const std::string &component, const std::string &errorMsg, const unsigned int pixelId) const
double GetMercedesReflections() const
Average number of reflections from Mercedes.
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
Fluorescence Detector Pixel event.
Definition: FEvent/Pixel.h:28
const T & GetCameraData(T *&requestedData, const std::string &property, const std::string &component, const std::string &errorMsg) const
const Telescope & GetTelescope(const unsigned int telescopeId) const
Find Telescope by numerical Id.
double GetVirtualChannelGainRatio() const
unsigned int GetId() const
Fluorescence Detector Channel Event.
unsigned int GetLastRow() const
double GetElectronicNoiseVariance() const
fTelescopeId(t.GetTelescopeId())
unsigned int GetChannelId(const unsigned int pixelId) const
double GetMercedesBase() const
Base of the Mercedes.
const T & GetCameraDataDiaphragm(T *&requestedData, const std::string &property, const std::string &component, const std::string &errorMsg) const
std::map< std::string, std::string > IndexMap
Definition: VManager.h:133
Description of a pixel.
std::string GetThresholdConfigSignature() const
double GetRadiusFocal() const
Radius of focal surface of the camera.
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
std::string fPhysicalTelescopeIdString
unsigned int GetPixelId(const unsigned int channelId) const
void GetCameraChannelData(T &requestedData, const std::string &property, const std::string &component, const std::string &errorMsg, const unsigned int channelId) const
Status
Specifies success or (eventually) various possible failure modes.
Definition: VManager.h:127
double GetSLTBinSize() const

, generated on Tue Sep 26 2023.