FDetector/Pixel.cc
Go to the documentation of this file.
1 
8 #include <boost/lexical_cast.hpp>
9 
10 #include <det/VManager.h>
11 #include <det/Detector.h>
12 
13 #include <fdet/Pixel.h>
14 #include <fdet/Camera.h>
15 #include <fdet/Eye.h>
16 #include <fdet/Telescope.h>
17 #include <fdet/FDetector.h>
18 
19 #include <utl/CoordinateSystem.h>
20 #include <utl/AugerException.h>
21 #include <utl/MathConstants.h>
22 #include <utl/Math.h>
23 
24 #include <fwk/CoordinateSystemRegistry.h>
25 
26 using namespace fdet;
27 using namespace det;
28 using namespace std;
29 using namespace utl;
30 using namespace fwk;
31 
32 
33 Pixel::Pixel(const unsigned int eyeId, const unsigned int telescopeId,
34  const unsigned int pixelId,
35  const std::string& physEyeIdString,
36  const std::string& physTelIdString) :
37  //fDirection()
38  //fCoordinateSystem()
39  //fWavelengthCalib
40  fTimeOffset(0),
41  fPixelStatus(Pixel::eUnknown),
42  fPixelOpticalEfficiencyStatus(Pixel::eUnknown),
43  fSimulatedEndToEnd(0),
44  fEyeId(eyeId),
45  fTelescopeId(telescopeId),
46  fPixelId(pixelId),
47  fPhysicalEyeIdString(physEyeIdString),
48  fPhysicalTelescopeIdString(physTelIdString),
49  fSolidAngle(0),
50  fQEfficiency(0)
51 {
52  fPixelIdString = boost::lexical_cast<string>(pixelId);
53 }
54 
55 
57 {
58  delete fTimeOffset;
59  delete fSimulatedEndToEnd;
60  delete fSolidAngle;
61  delete fQEfficiency;
62 }
63 
64 
65 void
67 {
68  delete fTimeOffset;
69  delete fSimulatedEndToEnd;
70  delete fSolidAngle;
71  delete fQEfficiency;
73  fCoordinateSystem.reset();
74  fTimeOffset = 0;
75  // pixel status is cached via fdet::Telescope!!
76  // fPixelStatus = Pixel::eUnknown;
78  fSolidAngle = 0;
79  fQEfficiency = 0;
80 }
81 
82 
83 unsigned int
85  const
86 {
88 }
89 
90 
91 const Vector&
93  const
94 {
95  if (!fDirection.GetMag2())
97  return fDirection;
98 }
99 
100 
101 const CoordinateSystemPtr&
103  const
104 {
105  if (!fCoordinateSystem) {
106  const Telescope& telDet = GetTelescope();
107  const CoordinateSystemPtr telCS = telDet.GetTelescopeCoordinateSystem();
108  const Camera& camera = telDet.GetCamera();
109 
110  const double rFocal = camera.GetRadiusFocal();
111  const double heightMercedes = camera.GetMercedesHeight();
112  const double pixelVertex = 26.34*mm;
113 
114  const Vector direction = -GetDirection();
115 
116  const double fat = sqrt (Sqr(rFocal-heightMercedes) - Sqr(pixelVertex));
117 
118  CoordinateSystemPtr auxCS = CoordinateSystem::Translation(direction*fat, telCS);
119  CoordinateSystemPtr backCS = CoordinateSystem::RotationY(180.*deg, auxCS);
120 
121  const double phi_rot = direction.GetPhi(backCS);
122  const double theta_rot = direction.GetTheta(backCS);
123 
124  CoordinateSystemPtr auxCS2 = CoordinateSystem::RotationZ(phi_rot, backCS);
125  CoordinateSystemPtr auxCS3 = CoordinateSystem::RotationY(theta_rot, auxCS2);
126  fCoordinateSystem = CoordinateSystem::RotationZ(kPi/2 - phi_rot, auxCS3);
127  }
128  return fCoordinateSystem;
129 }
130 
131 
132 double
133 Pixel::GetSimulatedDiaPhoton2ADC(const string& configSignature, const double wavelength)
134  const
135 {
136  const Telescope& tel = GetTelescope();
138  const double cosTheta = GetDirection().GetCosTheta(telCS);
139  const double calib = GetSimulatedEndToEndCalibration(configSignature);
140  return tel.GetModelRelativeEfficiency(wavelength) / (calib * cosTheta);
141 }
142 
143 
144 double
146  const
147 {
148  const double refWl = Detector::GetInstance().GetFDetector().GetReferenceLambda();
149  return GetEndToEndCalibration(refWl);
150 }
151 
152 
153 double
155  const
156 {
157  const double refWl = Detector::GetInstance().GetFDetector().GetReferenceLambda();
158  return GetEndToEndCalibrationConstant(refWl);
159 }
160 
161 
162 double
164  const
165 {
166  const double refWl = Detector::GetInstance().GetFDetector().GetReferenceLambda();
167  return GetOpticalEfficiencyCorrection(refWl);
168 }
169 
170 
171 const TabulatedFunction&
173  const
174 {
175  // Pass job of filling all calib consts to the parent telescopes
177  return fWavelengthCalib;
178 }
179 
180 
181 const TabulatedFunction&
183  const
184 {
185  // Pass job of filling all optical efficiency corrections to the parent telescopes
188 }
189 
190 
191 //for particular wavelength we multiply calibration constant by optical efficiency correction
192 double
193 Pixel::GetEndToEndCalibration(const double wavelength)
194  const
195 {
196  const Telescope& telDet = GetTelescope();
197  telDet.CachePixelCalibrations();
199 
200  double opticalEfficiencyCorrection = 0;
201  if (wavelength < fWavelengthOpticalEfficiencyCorrection.XFront()) {
202  opticalEfficiencyCorrection = fWavelengthOpticalEfficiencyCorrection.YFront();
203  } else if (wavelength > fWavelengthOpticalEfficiencyCorrection.XBack()) {
204  opticalEfficiencyCorrection = fWavelengthOpticalEfficiencyCorrection.YBack();
205  } else {
206  opticalEfficiencyCorrection = fWavelengthOpticalEfficiencyCorrection(wavelength);
207  }
208 
209  const double wavelengthFront = fWavelengthCalib.XFront();
210  if (wavelength < wavelengthFront) {
211 
212  // wavelength outside (below) of the absolute calibration boundaries
213  // => extrapolate with the relative calibration
214  return fWavelengthCalib.YFront() / telDet.GetMeasuredRelativeEfficiency(wavelengthFront) * opticalEfficiencyCorrection;
215  }
216 
217  const double wavelengthBack = fWavelengthCalib.XBack();
218  if (wavelength > wavelengthBack) {
219 
220  // ... above ...
221  return fWavelengthCalib.YBack() / telDet.GetMeasuredRelativeEfficiency(wavelengthBack) * opticalEfficiencyCorrection;
222  }
223 
224  // wavelength is within tabulated function boundaries => interpolate
225  return fWavelengthCalib(wavelength) * opticalEfficiencyCorrection;
226 }
227 
228 
229 double
231  const
232 {
233  const Telescope& telDet = GetTelescope();
234  telDet.CachePixelCalibrations();
235 
236  const double wavelengthFront = fWavelengthCalib.XFront();
237  if (wavelength < wavelengthFront) {
238 
239  // wavelength outside (below) of the absolute calibration boundaries
240  // => extrapolate with the relative calibration
241  return fWavelengthCalib.YFront() / telDet.GetMeasuredRelativeEfficiency(wavelengthFront);
242  }
243 
244  const double wavelengthBack = fWavelengthCalib.XBack();
245  if (wavelength > wavelengthBack) {
246 
247  // ... above ...
248  return fWavelengthCalib.YBack() / telDet.GetMeasuredRelativeEfficiency(wavelengthBack);
249  }
250 
251  // wavelength is within tabulated function boundaries => interpolate
252  return fWavelengthCalib(wavelength);
253 }
254 
255 
256 double
258  const
259 {
260  const Telescope& telDet = GetTelescope();
262 
263  if (wavelength < fWavelengthOpticalEfficiencyCorrection.XFront()) {
265  } else if (wavelength > fWavelengthOpticalEfficiencyCorrection.XBack()) {
267  }
268 
269  // wavelength is within tabulated function boundaries => interpolate
270  return fWavelengthOpticalEfficiencyCorrection(wavelength);
271 }
272 
273 
274 double
275 Pixel::GetDiaPhoton2PEFactor(const double wavelength, const std::string& configSignature)
276  const
277 {
278 
279  const Telescope& telDet = GetTelescope();
280  const Camera& camera = telDet.GetCamera();
281  double eff = 0.;
282  if (configSignature.empty())
283  eff = GetSimulatedDiaPhoton2ADC(telDet.GetConfigSignature("TelescopeSimulatorKG"),
284  wavelength);
285  else
286  eff = GetSimulatedDiaPhoton2ADC(configSignature, wavelength);
287 
288  return eff / camera.GetElectronicsGain();
289  /*
290  const Telescope& tel = GetTelescope();
291  const CoordinateSystemPtr& telCS = tel.GetTelescopeCoordinateSystem();
292  const double cosTheta = GetDirection().GetCosTheta(telCS);
293  const double calib = GetEndToEndCalibration(wavelength);
294  const double diaPhoton2ADC = 1 / (calib * cosTheta);
295  const double diaPhoton2PE = diaPhoton2ADC / tel.GetCamera().GetElectronicsGain();
296  return diaPhoton2PE;
297  */
298 }
299 
300 
301 double
302 Pixel::GetSimulatedEndToEndCalibration(const string& configSignature)
303  const
304 {
305  return GetPixelData(fSimulatedEndToEnd, "sim_pixel_calibs", "fd_sim_calib",
306  "simulated pixel calibration", configSignature);
307 }
308 
309 
310 /*
311 double
312 Pixel::GetSimulatedEndToEndCalibration(const std::string& configSignature, const double wl)
313  const
314 {
315  return GetSimulatedEndToEndCalibration(configSignature);
316  return fWavelengthCalib.YFront() / telDet.GetMeasuredRelativeEfficiency(wavelengthFront);
317 }
318 */
319 
320 
323  const
324 {
325  // Pass job of filling pixel status to the parent telescopes
327  return fPixelStatus;
328 }
329 
332  const
333 {
334  // Pass job of filling pixel optical efficiency status to the parent telescopes
337 }
338 
339 
340 double
342  const
343 {
344  return GetPixelData(fTimeOffset, "pixel_t_offset", "fd_calib", "pixel time offset");
345 }
346 
347 
348 unsigned int
349 Pixel::GetRow(const unsigned int pixelId)
350  const
351 {
352  const Telescope& tel = GetTelescope();
353  return (pixelId - tel.GetFirstPixelId()) % tel.GetLastRow() + tel.GetFirstRow();
354 }
355 
356 
357 unsigned int
358 Pixel::GetColumn(const unsigned int pixelId)
359  const
360 {
361  const Telescope& tel = GetTelescope();
362  return (pixelId - tel.GetFirstPixelId()) / tel.GetLastRow() + tel.GetFirstColumn();
363 }
364 
365 
366 const TabulatedFunction&
368  const
369 {
370  return GetPixelData(fQEfficiency, "qEfficiency", "pixel", "PMT quantum efficiciency");
371 }
372 
373 
374 double
376  const
377 {
378  if (!fSolidAngle) {
379  vector<double> tmpSolidAngleList;
380  GetPixelData(tmpSolidAngleList, "pixelSolidAngle", "camera", "PMT solid angle");
381  fSolidAngle = new double(tmpSolidAngleList[fPixelId - 1]);
382  }
383  return *fSolidAngle;
384 }
385 
386 
387 int
389  const
390 {
391  if (!fCloudValidityStamp.IsValid()) {
392  std::ostringstream err;
393  err << "no cloud index present (try with HasCloudFraction())";
394  throw utl::DataNotFoundInDBException(err.str());
395  }
396 
397  return fCloudIndex;
398 }
399 
400 
406 float
408  const
409 {
410  const float indexToFraction[6] = {
411  0.00, // 0-10
412  0.20, // 10-30
413  0.40, // 30-50
414  0.60, // 50-70
415  0.80, // 70-90
416  1.00, // 90-100
417  };
418 
419  return indexToFraction[GetCloudIndex()];
420 }
421 
422 
423 bool
425  const
426 {
428  return true;
429  else
431 }
432 
433 
434 const Telescope&
436  const
437 {
438  const Telescope& tel =
439  Detector::GetInstance().GetFDetector().GetEye(fEyeId).GetTelescope(fTelescopeId);
440  return tel;
441 }
442 
443 
444 template<typename T>
445 const T& Pixel::GetPixelData(T*& requestedData,
446  const std::string& property,
447  const std::string& component,
448  const std::string& errorMsg,
449  const std::string& extraIndex)
450  const
451 {
452  if (!requestedData) {
453  requestedData = new T;
454  GetPixelData(*requestedData, property, component, errorMsg, extraIndex);
455  }
456  return *requestedData;
457 }
458 
459 
460 template<typename T>
461 void Pixel::GetPixelData(T& requestedData,
462  const std::string& property,
463  const std::string& component,
464  const std::string& errorMsg,
465  const std::string& extraIndex)
466  const
467 {
468  const det::VManager& manager = det::Detector::GetInstance().GetFManagerRegister();
469  det::VManager::IndexMap indexMap;
470  indexMap["pixelId"] = fPixelIdString;
471  indexMap["eyeId"] = fPhysicalEyeIdString;
472  indexMap["telescopeId"] = fPhysicalTelescopeIdString;
473  if (!extraIndex.empty())
474  indexMap["signature"] = extraIndex;
475 
476  const det::VManager::Status foundFlag =
477  manager.GetData(requestedData, property, component, indexMap);
478 
479  // ERROR
480  if (foundFlag == det::VManager::eNotFound) {
481  std::ostringstream err;
482  err << "Did not find requested component for " << errorMsg<< "; "
483  << det::VManager::QueryInfoMessage(property, component, indexMap);
484  ERROR(err);
485  throw utl::NonExistentComponentException(err.str());
486  }
487 }
488 
489 
490 template<typename T>
491 const T&
493  const std::string& property,
494  const std::string& component,
495  const std::string& errorMsg)
496  const
497 {
498  if (!requestedData) {
499  requestedData = new T;
500  GetPixelDataDiaphragm(*requestedData, property, component, errorMsg);
501  }
502  return *requestedData;
503 }
504 
505 
506 template<typename T>
507 void
509  const std::string& property,
510  const std::string& component,
511  const std::string& errorMsg)
512  const
513 {
514  const det::VManager& manager = det::Detector::GetInstance().GetFManagerRegister();
515  det::VManager::IndexMap indexMap;
516  indexMap["pixelId"] = fPixelIdString;
517  indexMap["eyeId"] = fPhysicalEyeIdString;
518  indexMap["telescopeId"] = fPhysicalTelescopeIdString;
519  const fdet::FDetector& detFD = Detector::GetInstance().GetFDetector();
520  const bool hasCorrectorRing =
522  indexMap["correctorId"] = (hasCorrectorRing ? "large" : "small");
523 
524  const det::VManager::Status foundFlag =
525  manager.GetData(requestedData, property, component, indexMap);
526 
527  // ERROR
528  if (foundFlag == det::VManager::eNotFound) {
529 
530  std::ostringstream err;
531  err << "Did not find requested component for " << errorMsg<< "; "
532  << det::VManager::QueryInfoMessage(property, component, indexMap);
533  ERROR(err);
534  throw utl::NonExistentComponentException(err.str());
535  }
536 }
537 
538 
539 // Configure (x)emacs for this file ...
540 // Local Variables:
541 // mode: c++
542 // compile-command: "make -C .. FDetector/Pixel.o -k"
543 // End:
double GetModelRelativeEfficiency(const double wl) const
Status GetStatus() const
Get the pixel status flag.
utl::Vector GetCameraPixelDirection(const unsigned int pixelId) const
unsigned int GetId() const
By default from 1..440.
const utl::Vector & GetDirection() const
pointing direction of this pixel
constexpr double mm
Definition: AugerUnits.h:113
utl::Vector fDirection
constexpr T Sqr(const T &x)
unsigned int GetRow() const
double GetPhi(const CoordinateSystemPtr &coordinateSystem) const
azimuth (phi) angle in spherical and cylindrical coordinates
Definition: BasicVector.h:254
utl::CoordinateSystemPtr fCoordinateSystem
ArrayConstReference XBack() const
read-only reference to back of array of X
const T & GetPixelDataDiaphragm(T *&requestedData, const std::string &property, const std::string &component, const std::string &errorMsg) const
const utl::TabulatedFunction & GetEndToEndCalibrationConstant() const
end to end calibration function
double GetElectronicsGain() const
unsigned int GetFirstPixelId() const
double GetTheta(const CoordinateSystemPtr &coordinateSystem) const
zenith (theta) angle in spherical coordinates
Definition: BasicVector.h:248
void CachePixelCalibrations() const
Cache calibration constants for pixels in one go (minimize DB access)
Class to hold collection (x,y) points and provide interpolation between them.
utl::TabulatedFunction fWavelengthOpticalEfficiencyCorrection
bool HasCloudFraction() const
double * fTimeOffset
double GetCosTheta(const CoordinateSystemPtr &coordinateSystem) const
cos of zenith (theta) angle
Definition: BasicVector.h:251
const std::string & GetConfigSignature(const std::string &module) const
double GetSimulatedEndToEndCalibration(const std::string &configSignature) const
for the simulated end-to-end calibration constant
double GetMeasuredRelativeEfficiency(const double wl) const
Status fPixelOpticalEfficiencyStatus
bool CachePixelCloudData() const
Cache cloud coverage for pixels in one go (minimize DB access)
std::string fPhysicalTelescopeIdString
double GetEndToEndCalibration(const double wavelength) const
multiplication of calA(+drum) constant and optical efficiency correction is returned ...
double GetEndToEndCalibrationAtReferenceWavelength() const
int GetCloudIndex() const
Cloud index in strange units. To access please use GetCloudFraction()
utl::TabulatedFunction fWavelengthCalib
double GetMercedesHeight() const
Height of the Mercedes.
det::ValidityStamp fCloudValidityStamp
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
std::string fPhysicalEyeIdString
Interface for detector managers.
Definition: VManager.h:115
double GetEndToEndCalibrationConstantAtReferenceWavelength() const
calA(+drum) constant is returned
const Camera & GetCamera() const
Get the Camera object that belongs to the telescope.
unsigned int GetFirstColumn() const
Detector description interface for FDetector-related data.
Definition: FDetector.h:44
bool HasCorrectorRing() const
flag for corrector ring presence
constexpr double deg
Definition: AugerUnits.h:140
std::string fPixelIdString
utl::TabulatedFunction * fQEfficiency
virtual Status GetData(double &returnData, const std::string &componentProperty, const std::string &componentName, const IndexMap &componentIndex) const =0
double GetSolidAngle() const
The solid angle viewed by this pixel.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
void CachePixelOpticalEfficiencyCorrections() const
Cache optical efficiency corrections for pixels in one go (minimize DB access)
Exception to use in case requested data not found in the database with detailed printout.
utl::CoordinateSystemPtr GetTelescopeCoordinateSystem() const
ArrayConstReference XFront() const
read-only reference to front of array of X
unsigned int GetChannelId() const
const utl::TabulatedFunction & GetQEfficiency() const
Average quantum efficiency as a function of the wavelength.
unsigned int fTelescopeId
static std::string QueryInfoMessage(const Handle &returnData, const std::string &component)
Definition: VManager.cc:108
Pixel(const unsigned int eyeId, const unsigned int telescopeId, const unsigned int pixelId, const std::string &physEyeIdString, const std::string &physTelIdString)
constexpr double kPi
Definition: MathConstants.h:24
const Telescope & GetTelescope(const unsigned int telescopeId) const
Find Telescope by numerical Id.
double * fSolidAngle
ArrayConstReference YFront() const
read-only reference to front of array of Y
bool IsValid() const
True if detector time is between start and end validity times.
unsigned int GetLastRow() const
const Telescope & GetTelescope() const
Access the telescope this Pixel belongs to.
Status fPixelStatus
fTelescopeId(t.GetTelescopeId())
unsigned int GetChannelId(const unsigned int pixelId) const
const utl::CoordinateSystemPtr & GetPixelCoordinateSystem() const
double * fSimulatedEndToEnd
float GetCloudFraction() const
how much of pixel is obscured by clouds
Detector description interface for Telescope-related data.
ArrayConstReference YBack() const
read-only reference to back of array of Y
unsigned int GetColumn() const
std::map< std::string, std::string > IndexMap
Definition: VManager.h:133
Description of a pixel.
const utl::TabulatedFunction & GetOpticalEfficiencyCorrection() const
optical efficiency correction is returned as a function of wavelength
Vector object.
Definition: Vector.h:30
double GetTimeOffset() const
pixel time offset
double GetSimulatedDiaPhoton2ADC(const std::string &configSignature, const double wavelength) const
const T & GetPixelData(T *&requestedData, const std::string &property, const std::string &component, const std::string &errorMsg, const std::string &extraIndex="") const
double GetRadiusFocal() const
Radius of focal surface of the camera.
double GetDiaPhoton2PEFactor(const double wavelength, const std::string &configSignature="") const
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
unsigned int GetFirstRow() const
Status
Specifies success or (eventually) various possible failure modes.
Definition: VManager.h:127
Status GetOpticalEfficiencyStatus() const
Description of a camera.
unsigned int fPixelId
unsigned int fEyeId
double GetMag2() const
Definition: Vector.h:61
double GetOpticalEfficiencyCorrectionAtReferenceWavelength() const
optical efficiency correction is returned

, generated on Tue Sep 26 2023.