Modules/FdSimulation/TelescopeSimulatorKG/Camera.cc
Go to the documentation of this file.
1 
10 //#define DEBUG_RT 1
11 #undef DEBUG_RT
12 #define DEBUG 1
13 //#undef DEBUG
14 
15 #include "Camera.h"
16 #include "RTFunctions.h"
17 #include "RayTracer.h"
18 
19 #include <utl/MathConstants.h>
20 #include <utl/AugerUnits.h>
21 #include <utl/ErrorLogger.h>
22 #include <utl/Photon.h>
23 #include <utl/Point.h>
24 #include <utl/Vector.h>
25 #include <utl/CoordinateSystemPtr.h>
26 #include <utl/AugerException.h>
27 
28 #include <det/Detector.h>
29 
30 #include <fdet/FDetector.h>
31 #include <fdet/Eye.h>
32 #include <fdet/Telescope.h>
33 #include <fdet/Camera.h>
34 #include <fdet/Pixel.h>
35 #include <fdet/Channel.h>
36 
37 #include <TPolyLine3D.h>
38 #include <TLine.h>
39 #include <TMarker.h>
40 #include <TLatex.h>
41 #include <TPolyMarker3D.h>
42 #include <TCanvas.h>
43 #include <TView.h>
44 #include <TPad.h>
45 #include <TObjArray.h>
46 
47 #include <sstream>
48 #include <iostream>
49 #include <iomanip>
50 #include <vector>
51 #include <utility>
52 
53 using namespace std;
54 using namespace TelescopeSimulatorKG;
55 using namespace utl;
56 
57 
58 Camera::Camera(RandomEngine& rndm, const fdet::Telescope& tel) :
59  fRandom(rndm),
60  fTel(tel)
61 {
62  const fdet::Camera& camera = tel.GetCamera();
64  fOrigin = tel.GetPosition();
65  fRFocal = camera.GetRadiusFocal();
67  fSigma = camera.GetSigmaNormal();
68 
69  const double hmerc = camera.GetMercedesHeight();
70  const double ddmerc = camera.GetMercedesBase(); // half base length (full 9.2mm)
71 
72  // Warning: the values of SIN_?? may need some changes to simulate
73  // correctly the camera (shadow and trace_surf).
74  fSinAx = 0.2491262;
75  fSinAy = 0.27966724;
76  fSinBx = 0.25646528973;
77  fSinBy = 0.26704475;
78 
79  // Camera
80  SetMercedesParameter(hmerc, ddmerc);
81 
82  //------------ offset of the center of the camera ---------
83  //fNx0 = 10.0;
84  //fNy0 = 11.66666666666667;
85 
87 
88 } // End of Camera::Camera
89 
90 
91 void
92 Camera::SetMercedesParameter(double height, double width)
93 {
94  fR2 = 26.34*mm;
95 
96  // Find the position of the vertex in the reference frame of the
97  // hexagon. See picture.
98 
99  // Full pixel vertex length
100  //fR2 = sqrt (pixel209Pos.GetR (centerOfCameraCS));
101  //cout << "SetMercParams : " << fR2/mm << endl;
102 
103  //----------------- Set mercedes parameters ------------------
104  fHMerc = height; // : height mercedes
105  fD2 = fR2 * utl::kSqrt3; // 2 * cos(30) * r : horizontal full pixel width
106  fD1 = fD2 - 2.0*width; // : horizontal pixel width (inside mercedes)
107  fR1 = fD1/utl::kSqrt3; // : hexagon vertex (inside mercedes)
108  fNz = (fD2 - fD1)/2.0; // == width : mercedes width (!)
109  fNt = fHMerc; // == height
110  const double aux = sqrt(fNz*fNz + fNt*fNt);
111  fNz /= aux; // (Nz, Nt) : normal on mercedes CHECK !! Seems to be wrong
112  fNt /= aux;
113 
114  /*
115 
116  ^ /\
117  n \ / \
118  \ / \
119  \/ \ height
120  / \
121  ^ / \
122  z| / \
123  | --------------
124  | 2xwidth
125  <----
126  t
127 
128  */
129 }// End of Camera::SetMercedesParameter
130 
131 
132 RTResult
133 Camera::Trace(const Photon& photonIn,
134  Photon& photonOut,
135  int& nreflections,
136  int& col, int& row,
137  double& cosTheta,
138  bool doMercedes)
139 {
140  nreflections = 0;
141 
142  //simulate camera, including/excluding the mercedes
143  // cosTheta : photon hitting PMT angle
144  // error codes:
145 
146  utl::Photon photonCamera;
147  Vector normal;
148  if (!TraceSurf(photonIn, photonCamera, normal)) {
149 #ifdef DEBUG
151  ERROR("RT::Camera> camera sphere not hit!");
152 #endif
153  return eMissedFocalSurface;
154  }
155 
156  Vector incidentPhotonDir(photonCamera.GetPosition() - fOrigin);
157  incidentPhotonDir.Normalize();
158  if (!FindPixelId(incidentPhotonDir, row, col)) {
159  //the ray don't hit any pixel
160  //cout << " no pixel hit " << endl;
161  // but keep point on camera sphere anyway
162  photonOut = photonCamera;
163 #ifdef DEBUG
165  INFO("RT::Camera> no pixle hit on camera!");
166 #endif
167  return eMissedPixels;
168  }
169 
170  // PixelId_new (pCamera-fOrigin, col, row); too slow ...
171 
172  // find the reference frame of PIXEL (oAux,mAux)
173  //double aux1,aux2;
174  const CoordinateSystemPtr& pxlCS = fTel.GetPixel(row, col).GetPixelCoordinateSystem();
175 
176  if (photonCamera.GetDirection().GetZ(pxlCS) >= 0) {
177 #ifdef DEBUG
179  INFO("RT::Camera> photon outgoing in pixel CS ???");
180 #endif
181  return eBackscattered; // the light is going out from the pixel.
182  }
183 
184  if (!doMercedes) { // no mercedes
185 
186  photonOut = photonCamera;
187  cosTheta = -photonOut.GetDirection().GetCosTheta(pxlCS); // hitting the Camera
188 
189  return eOK; // hit camera after 0 reflections
190  }
191 
192  // with mercedes
193 
194  // simulate mercedes
195  utl::Photon photonPMT;
196  const RTResult mercStatus = TraceMerc(pxlCS, photonCamera, photonPMT, nreflections);
197  cosTheta = -photonPMT.GetDirection().GetCosTheta(pxlCS); // hitting the PMT
198 
199  if (mercStatus == eOK) { // HIT THE PMT after nreflections reflections
200 
201  double r_index_12 = 1.0/1.52;
202  Vector normalPMT(0., 0., 1., pxlCS);
203  RTFunctions::PhotonList photonsHittingPhotocathode;
204  RTFunctions::Refraction(r_index_12, photonPMT, normalPMT, photonsHittingPhotocathode);
205  utl::Photon photonHittingPhotocathode = photonsHittingPhotocathode[0];
206 
207 #ifdef DEBUG_RT
208  int pixelId = (col-1)*fNRows + row;
209  cout << "11111111 " << fTel.GetId() << " " << pixelId
210  << " " << col
211  << " " << row
212  << " " << cosTheta
213  << " " << photonHittingPhotocathode.GetWeight()
214  << " " << photonPMT.GetWeight() << endl;
215 #endif
216 
217  photonOut = photonPMT;
218  photonOut.SetWeight(photonHittingPhotocathode.GetWeight());
219 
220 #ifdef DEBUG
222  { ostringstream info;
223  info << "RT::Camera> HIT: photon: wIn=" << photonIn.GetWeight()
224  << " wPMT=" << photonPMT.GetWeight()
225  << " wSignal=" << photonOut.GetWeight()
226  << " angle_cathode=" << acos(cosTheta)/deg << "deg "
227  << " nrefl_merc=" << nreflections;
228  INFO(info.str().c_str());
229  }
230 #endif
231 
232  return eOK;
233  }
234 
235 #ifdef DEBUG
237  INFO("RT::Camera> nref<1 ! photon lost!");
238 #endif
239 
240  return mercStatus; // lost on multi-reflection on mercedes (nreflections<0)
241 
242 } // End of Camera::Trace
243 
244 bool
245 Camera::FindPixelId(const Vector& incidentDir, int& row, int& col)
246  const
247 {
248  static const double fNx0 = 10.0;
249  static const double fNy0 = 11.66666666666667; // optical axis
250  static const double dOmega = fTel.GetCamera().GetEta();
251  static const double dPhi = kSqrt3 * dOmega/2;
252  static const int nCols = fTel.GetLastColumn() - fTel.GetFirstColumn() + 1; // 20
253  static const int nRows = fTel.GetLastRow() - fTel.GetFirstRow() + 1; // 22
254 
255  const double x = incidentDir.GetX(fTelCS);
256  const double y = incidentDir.GetY(fTelCS);
257  const double z = incidentDir.GetZ(fTelCS);
258 
259  const double omegap = asin(y);
260  const double phip = atan2(-x, -z);
261 
262  // find nx and ny from angles omegap, phip.
263  // -------------------------------------------------------------------
264  // ------ algorit. developed by Ronald Shellard, in the FDSim --------
265  // ------------------ (FORTRAN version) ------------------------------
266  // -------------------------------------------------------------------
267  double nxl = 2.*(omegap/dOmega) + 2.0*fNx0;
268  double nyl = fNy0 - phip/dPhi;
269 
270  if (nxl < 0 || nxl > 2*nCols+1 ||
271  nyl < 0 || nyl > nRows+1)
272  return false; // the ray of light does not reach any pmt
273 
274  col = int(nxl);
275  row = int(nyl);
276  nxl -= col;
277  nyl -= row;
278 
279  const double f1 = 3 * nyl - nxl - 1;
280  const double f2 = 3 * nyl + nxl - 2;
281  double f = 0;
282 
283  if (col % 2) { // *col is odd
284 
285  col = (col + 1) / 2;
286  f = (row % 2) ? f1 : f2;
287 
288  } else
289  if (!(row % 2)) {
290 
291  f = f1;
292  col = col/2 + (f > 0 ? 0 : 1);
293 
294  } else {
295 
296  f = f2;
297  col = col/2 + (f > 0 ? 1 : 0);
298 
299  }
300 
301  if (f >= 0)
302  ++row;
303 
304  return (col >=1 && row >= 1 &&
305  col <= nCols && row <= nRows);
306 }
307 
308 
309 RTResult
310 Camera::TraceShadow(const utl::Photon& photonIn, const bool doSupport)
311 {
312  // simulate shadow effect of the camera
313 
314  RTFunctions::IntersectionList intersections;
315  if (RTFunctions::Sphere(fOrigin, fRFocal, photonIn, intersections)) {
316 
317  const Vector normal(intersections.back().second);
318 
319  const double x = normal.GetX(fTelCS);
320  const double y = normal.GetY(fTelCS);
321 
322  if (-fSinAx < x && x < fSinBx&&
323  -fSinAy < y && y < fSinBy) {
324 
325 #ifdef DEBUG
327  INFO("RT::Camera> camera shadow!");
328 #endif
329 
330  return eShadowed; // the light hit the PMT camera
331  }
332  }
333 
334  Photon photonOut(intersections.back().first);
335 
336  if (doSupport) {
337 
338  Point pCamera(0., 0., 0., fCameraSupportCoordinateSystem);
339  Vector nSupport(0., 0., 1., fCameraSupportCoordinateSystem);
340  if (RTFunctions::Plane(pCamera, nSupport, photonIn, photonOut)) {
341 
342  Point pPlane = photonOut.GetPosition();
343 
344  double x = pPlane.GetX(fCameraSupportCoordinateSystem);
345  double y = std::fabs(pPlane.GetY(fCameraSupportCoordinateSystem)); // symetric
346 
347  if (x < 0)
348  return eOK; // camera support is only below the camera !
349 
350  if (y > 30.*cm && y < 35.*cm) {
351 
352 #ifdef DEBUG
354  INFO("RT::Camera> camera support shadow!");
355 #endif
356 
357  return eShadowed;
358  }
359  }
360  }
361 
362  return eOK;
363 } //End of Camera::TraceShadow
364 
365 
366 int
367 Camera::TraceSurf(const utl::Photon& photonIn, utl::Photon& photonOut,
368  Vector& /*normal*/)
369 {
370  // find the point that the light hit the focal surface (pOut)
371  // --------------
372  //pIn = A point where the ray passes
373  //nIn = direction of light propagation
374  // ++++++++++++++y
375  // pOut = Position that the ray hit the focal surface
376  // nOut = ray direction.
377  // **************
378  // 0 -> The ray don't hit the camera.
379  // 1 -> the ray hit the camera
380 
381  RTFunctions::IntersectionList intersections;
382  if (RTFunctions::Sphere(fOrigin, fRFocal, photonIn, intersections) > 0) {
383 
384  photonOut = intersections.front().first;
385  return 1; // hit the camera sphere
386 
387  /*if(-fSinAx<nAux2[0] && nAux2[0]<fSinBx&&
388  -fSinAy<nAux2[1] && nAux2[1]<fSinBy) {
389  */
390  // }
391  }
392 
393  return 0; // miss the camera sphere
394 } // End of Camera::TraceSurf
395 
396 
397 RTResult
399  const utl::Photon& photonIn, utl::Photon& photonOut,
400  int& nreflections)
401 {
402  //simulate Mercedes
403  //-------------
404  // p = a point where the light passes
405  // n = direction of incident light
406  // ++++++++++++
407  // ps = position at photo cathode surface.
408  // ns = direction of light that hit photo cathode surface
409  // ************
410  // 0 -> the light don't hit the photo cathode
411  // >0 -> number of times plus 1 that light hit mercedes bebfore hit
412  // photo cathode surface
413 
414  Vector dir(photonIn.GetDirection());
415 
416  Vector npl;
417  Point o;
418  utl::Photon point(photonIn); // starting point
419 
420  /*
421  //---------- Verify if the light hit the considered pixel ---------
422  ConstrPl (7, npl, o, pxlCS); // find the plane defined by the top of the mercedes.
423 
424  utl::Photon point;
425  RTFunctions::Plane (o, npl, photonIn, point); // move to plane above PMT (top of mercedes)
426 
427  //cout << " p " << point.GetX (fTelCS) << " " << point.GetY (fTelCS) << " " << point.GetZ (fTelCS) << endl;
428 
429  if (Hexagon(point.GetX(pxlCS), point.GetY(pxlCS),fR2) != eInside) {
430  return(0); // the light is out of the limits of the pixel
431  }
432  */
433 
434  //------------- simulate refletions in the mercedes. -----------------
435  nreflections = 0;
436  int nloop = 0;
437  int i_refl = -1; // init
438  utl::Photon point_next; // the next point of ray-tracing
439  int i = 0;
440  do { // loop until the light hit photo cathode
441 
442  bool do_reflection = false;
443 
444  for (i = 0; i <= 6; ++i) { //find the plane that light hit.
445 
446  // 0 to photo cathode surface and 1,2,3,4,5 or 6 to mercedes
447 
448  if (!ConstructPlane(i, npl, o, pxlCS)) {
449  ostringstream err;
450  err << "This can never happen! "
451  << "i: " << i
452  << " nloop: " << nloop
453  << " nrefl: " << nreflections
454  << ". THROW EXCEPTION!";
455  ERROR(err.str().c_str());
456  throw(utl::AugerException(err.str()));
457  }
458 
459  const double dist = RTFunctions::Plane(o, npl, point, point_next);
460  const Point& pNext = point_next.GetPosition();
461 
462  /*
463  cout << " dist: " << setw(8) << setprecision (3) << dist/mm
464  << " i: " << i
465  << " i_refl: " << i_refl
466  << " nloop: " << nloop
467  << " nrefl: " << nrefl
468  << " side: " << Hexagon(pNext.GetX(pxlCS), pNext.GetY(pxlCS), fR1);
469  */
470 
471  if (dist > 0 && // photon will hit mercedes in the future
472  Hexagon(pNext.GetX(pxlCS), pNext.GetY(pxlCS), fR1) == i && // intersection point is on right mercedes
473  i != i_refl) { // this is NOT the same mercedes we were just reflected by !
474  do_reflection = true;
475  //cout << " FOUND " << endl;
476  break;
477  }
478  //cout << endl;
479 
480  } // for loop planes 0 - 6
481 
482  if (!do_reflection) {
483 #ifdef DEBUG
485  { ostringstream err;
486  err << " RT::Camera> NO MERCEDES OR PMT HIT! PHOTON LOST! w=" << photonIn.GetWeight();
487  INFO(err.str().c_str());
488  }
489 #endif
490  return eInvalidHitMercedes;
491  }
492 
493  i_refl = i; // remember the mercedes
494  ++nloop;
495 
496  /*
497  i==0: HIT THE PMT
498  */
499 
500  if (i != 0) { // -> We hit a mercedes
501 
502  //RTFunctions::Normal(npl, fSigma, &fISeed, normal);
503  const Vector normal = npl;
504  const int status = RTFunctions::Reflection(point_next, normal, point_next);
505 
506  if (!status) {
507 
508 #ifdef DEBUG
510  { ostringstream err;
511  err << "RT::Camera> get rid of this: photon hits mercedes from outside "
512  << " " << npl*point_next.GetDirection() << " w=" << photonIn.GetWeight();
513  INFO(err.str().c_str());
514  }
515 #endif
516  return eInvalidMercedes;
517  }
518 
519  if (point_next.GetDirection().GetZ(pxlCS) >= 0) { // backscattered from PMT?
520 
521 #ifdef DEBUG
523  { ostringstream err;
524  err << "RT::Camera> backscattered from Mercedes? "
525  << " theta="<< point_next.GetDirection().GetZ (pxlCS)
526  << " w=" << photonIn.GetWeight();
527  INFO (err.str().c_str());
528  }
529 #endif
530  return eBackscattered; // this photon will not hit the PMT
531  }
532 
533  point = point_next;
534  point.SetWeight(point_next.GetWeight()*fMercedesEff);
535  ++nreflections; // Do next reflection
536  }
537 
538  } while (i != 0); // WHILE we hit the PMT
539 
540  photonOut = point_next;
541 
542  return eOK;
543 
544 } // End of Camera::TraceMerc
545 
546 
547 /*
548 int
549 Camera::PixelId_new(const Vector& vFocal, int& col, int& row)
550 {
551  // find the pixel
552  // --------------
553  // vFocal: position at focal surface
554  // ++++++++++++++
555  // col,row -> identification of column and row of pixel
556  // **************
557  // 0 -> the position vFocal don't hit any pixel
558  // 1 -> found a pixel
559 
560  //double omega, phi;
561  double angleMin = 0;
562  bool first = true;
563  for (int iCol = 1; iCol <= fNCols; ++iCol) {
564  for (int iRow = 1; iRow <= fNRows; ++iRow) {
565 
566  Vector pixelDir = - fTel.GetPixel(iRow, iCol).GetDirection();
567 
568  //double angle = Angle (pixelDir, vFocal);
569  double angle = - std::fabs(pixelDir * vFocal);
570 
571  if (first) {
572 
573  angleMin = angle;
574  col = iCol;
575  row = iRow;
576  first = false;
577 
578  } else {
579 
580  if (angle < angleMin) {
581  angleMin = angle;
582  col = iCol;
583  row = iRow;
584  }
585  }
586  }
587  }
588 
589  const CoordinateSystemPtr& pxlCS = fTel.GetPixel(row, col).GetPixelCoordinateSystem();
590 
591  const Point pFocal = fOrigin + vFocal*fRFocal/vFocal.GetMag();
592 
593  if (eInside != Hexagon(pFocal.GetX(pxlCS), pFocal.GetY(pxlCS), fR2))
594  return 0;
595 
596  return 1;
597 }
598 */
599 
600 
601 
602 /*
603  /\
604  / \
605  / \
606  R/ \R
607  / \
608  / 2 1 \
609  | |
610  | |
611  R| 3 . 6 |R
612  | |
613  | |
614  \ 4 5 /
615  \ /
616  R\ /R
617  Y^ \ /
618  | \ /
619  | \/
620  |____>
621  X
622 
623  R: length of vertex
624 
625 
626  */
627 
628 
630 Camera::Hexagon(double x, double y, double r)
631 {
632  // verify if position x,y is inside or outside of a hexagon,
633  // which the distance from the center (0,0) to the vertex
634  // is smaller than r (see picture)
635  // ***************
636  // 0 -> inside the hexagon
637  // from 1 to 6 -> outside the hexagon
638 
639  double xl = std::fabs(x);
640  double yl = std::fabs(y);
641  double xm = utl::kSqrt3/2.0*r; // cos(30)*r
642  double tmp = 1./utl::kSqrt3; // tan(30)
643 
644  // inside hexagon check
645  if (xl <= xm && yl <= r-tmp*xl)
646  return eInside;
647 
648  if (yl < tmp*xl) // left and right slice
649  return (x > 0) ? eRight : eLeft;
650  else // upper right half
651  return (y > 0) ? (x > 0 ? eTopRight:eTopLeft) : (x > 0 ? eBottomRight:eBottomLeft);
652 }
653 
654 
655 int
657  Vector& n, Point& p,
658  const CoordinateSystemPtr& pxlCS)
659 {
660  //define the plane surfaces to simulate the mercedes
661  //--------------------------
662  // id=0 -> photo-cathode surface
663  // 7 -> focal surface
664  // 1,2,3,4,5 and 6 -> mercedes surfaces (see picture)
665  //++++++++++++++++++++++++++
666  // n -> normal vector of the surface
667  // o -> a point of the plane surface
668  //*************************
669  // 0 -> there is no plano identified by id
670  // 1 -> ok
671 
672  if (id == 0 || id == 7) {
673  p = Point(0, 0, id == 0 ? 0 : fHMerc, pxlCS);
674  n = Vector(0, 0, 1, pxlCS);
675  return 1;
676  }
677 
678  if (id > 0 && id < 7) {
679 
680  double dTheta = 60*deg;
681  double theta = dTheta * id;
682  double sinTheta = sin(theta); // y
683  double cosTheta = cos(theta); // x
684 
685  n = Vector(-fNt*cosTheta, -fNt*sinTheta, fNz, pxlCS);
686  p = Point(cosTheta*fD1/2., sinTheta*fD1/2., 0.0, pxlCS);
687 
688  return 1;
689  }
690 
691  return 0;
692 }
693 
694 
695 
696 
697 TObjArray*
698 Camera::Draw(const bool do3D)
699 {
700  TObjArray* objs = new TObjArray();
701 
702  double xMin = 0, xMax = 0, yMin = 0, yMax = 0, zMin = 0, zMax = 0;
703  bool first = true;
704 
705  const int nCols = fTel.GetLastColumn() - fTel.GetFirstColumn()+1; // 20
706  const int nRows = fTel.GetLastRow() - fTel.GetFirstRow()+1; // 22
707 
708  int color = 0;
709  for (int col = 1; col <= nCols; ++col) {
710 
711  for (int row = 1; row <= nRows; ++row) {
712 
713  const int pixelId = (col-1)*nRows + row;
714  const CoordinateSystemPtr& pxlCS = fTel.GetPixel(row, col).GetPixelCoordinateSystem();
715 
716  double r_in = fR1;
717  double r_out = fR2;
718 
719  for (int i = 0; i < 6; ++i) {
720 
721  double theta1 = 30*deg + 60*deg*i;
722  double theta2 = 30*deg + 60*deg*(i+1);
723 
724  Point p1_in(cos(theta1) * r_in,
725  sin(theta1) * r_in,
726  0, pxlCS);
727  Point p2_in(cos(theta2) * r_in,
728  sin(theta2) * r_in,
729  0, pxlCS);
730 
731  Point p1_out(cos(theta1) * r_out,
732  sin(theta1) * r_out,
733  fHMerc, pxlCS);
734  Point p2_out(cos(theta2) * r_out,
735  sin(theta2) * r_out,
736  fHMerc, pxlCS);
737 
738  // pixel position in telCS
739  double pxl_x = Point(0,0,0, pxlCS).GetX(fTelCS);
740  double pxl_y = Point(0,0,0, pxlCS).GetY(fTelCS);
741  double pxl_z = Point(0,0,0, pxlCS).GetZ(fTelCS);
742 
743  if (first) {
744  first = false;
745  xMin = pxl_x;
746  xMax = pxl_x;
747  yMin = pxl_y;
748  yMax = pxl_y;
749  zMin = pxl_z;
750  zMax = pxl_z;
751  } else {
752  if (pxl_x > xMax)
753  xMax = pxl_x;
754  if (pxl_y > yMax)
755  yMax = pxl_y;
756  if (pxl_z > zMax)
757  zMax = pxl_z;
758  if (pxl_x < xMin)
759  xMin = pxl_x;
760  if (pxl_y < yMin)
761  yMin = pxl_y;
762  if (pxl_z < zMin)
763  zMin = pxl_z;
764  }
765 
766  if (do3D) {
767  TPolyMarker3D *p_pos = new TPolyMarker3D(1);
768  p_pos->SetPoint(0, pxl_x, pxl_y, pxl_z);
769  p_pos->SetMarkerColor(color++);
770  p_pos->SetMarkerStyle(20);
771  p_pos->SetMarkerSize(.3);
772  p_pos->Draw();
773  objs->AddLast(p_pos);
774 
775  } else {
776  //double w, h;
777  ostringstream pxl_txt;
778  pxl_txt << pixelId;
779  TLatex *p_pos = new TLatex(pxl_x, pxl_y, pxl_txt.str().c_str());
780  p_pos->SetX(pxl_x-p_pos->GetXsize()/6.);
781  p_pos->SetY(pxl_y-p_pos->GetYsize()/6.);
782  p_pos->SetTextColor(1);
783  p_pos->SetTextSize(.01);
784  p_pos->SetTextAngle(0);
785  p_pos->Draw();
786  objs->AddLast(p_pos);
787  }
788 
789  if (do3D) { // DO THE 3D PLOT
790 
791  TPolyLine3D *l_in = new TPolyLine3D(1);
792  l_in->SetLineColor(2);
793  l_in->SetPoint(0, p1_in.GetX(fTelCS), p1_in.GetY(fTelCS), p1_in.GetZ(fTelCS));
794  l_in->SetPoint(1, p2_in.GetX(fTelCS), p2_in.GetY(fTelCS), p2_in.GetZ(fTelCS));
795  l_in->Draw();
796  objs->AddLast(l_in);
797 
798  TPolyLine3D *l_out = new TPolyLine3D(1);
799  l_out->SetLineColor(1);
800  l_out->SetLineStyle(2);
801 
802  l_out->SetPoint(0, p1_out.GetX(fTelCS), p1_out.GetY(fTelCS), p1_out.GetZ(fTelCS));
803  l_out->SetPoint(1, p2_out.GetX(fTelCS), p2_out.GetY(fTelCS), p2_out.GetZ(fTelCS));
804  l_out->Draw();
805  objs->AddLast(l_out);
806 
807  TPolyLine3D *l_corner = new TPolyLine3D(1);
808  l_corner->SetLineColor(1);
809  l_corner->SetLineStyle(2);
810 
811  l_corner->SetPoint(0, p1_in.GetX(fTelCS), p1_in.GetY(fTelCS), p1_in.GetZ(fTelCS));
812  l_corner->SetPoint(1, p1_out.GetX(fTelCS), p1_out.GetY(fTelCS), p1_out.GetZ(fTelCS));
813  l_corner->Draw();
814  objs->AddLast(l_corner);
815 
816  } else { // DO THE 2D PLOT
817 
818  TLine *l_in = new TLine(p1_in.GetX(fTelCS), p1_in.GetY(fTelCS),
819  p2_in.GetX(fTelCS), p2_in.GetY(fTelCS));
820  l_in->SetLineColor(2);
821 
822  TLine *l_out = new TLine(p1_out.GetX(fTelCS), p1_out.GetY(fTelCS),
823  p2_out.GetX(fTelCS), p2_out.GetY(fTelCS));
824  l_out->SetLineColor(1);
825  l_out->SetLineStyle(2);
826 
827  l_in->Draw();
828  l_out->Draw();
829  objs->AddLast(l_in);
830  objs->AddLast(l_out);
831 
832  } // do 3D
833  } // loop 6 mercedes
834  } // loop row
835  } // loop col
836 
837  // the camera support --------------------------------------------------------
838 
840 
841  double dx = 5.*cm;
842  //double dy = 10.*cm;
843  double length = 2.*m;
844 
845  for (int i = 0; i < 2; ++i) {
846 
847  double y1 = 30.*cm;
848  double y2 = 30.*cm + dx;
849  double z1 = 0.*cm;
850  double z2 = 10.*cm;
851  double x1 = 0.*cm;
852  double x2 = length;
853 
854  TPolyLine3D *up = new TPolyLine3D(4);
855  TPolyLine3D *down = new TPolyLine3D(4);
856  up->SetLineColor(1);
857  up->SetLineWidth(2);
858  down->SetLineColor(1);
859  down->SetLineWidth(2);
860 
861  double y, z;
862  for (int iy = 0; iy < 2; ++iy) {
863 
864  if (iy == 0)
865  y = y1;
866  else
867  y = y2;
868 
869  if (i == 0)
870  y *= -1;
871 
872  for (int iz = 0; iz < (do3D ? 2 : 1); ++iz) {
873 
874  if (iz == 0)
875  z = z1;
876  else
877  z = z2;
878 
881 
882  if (do3D) { // DO THE 3D PLOT
883 
884  TPolyLine3D *l = new TPolyLine3D(1);
885  l->SetLineColor(1);
886  l->SetLineWidth(2);
887  l->SetPoint(0, p1.GetX(fTelCS), p1.GetY(fTelCS), p1.GetZ(fTelCS));
888  l->SetPoint(1, p2.GetX(fTelCS), p2.GetY(fTelCS), p2.GetZ(fTelCS));
889  l->Draw();
890  objs->AddLast(l);
891 
892  up->SetPoint((1-iy)*2+1-iz, p1.GetX(fTelCS), p1.GetY(fTelCS), p1.GetZ(fTelCS));
893  down->SetPoint((1-iy)*2+1-iz, p2.GetX(fTelCS), p2.GetY(fTelCS), p2.GetZ(fTelCS));
894 
895  } else { // DO THE 2D PLOT
896 
897  TLine *l = new TLine(p1.GetX(fTelCS), p1.GetY(fTelCS),
898  p2.GetX(fTelCS), p2.GetY(fTelCS));
899  l->SetLineColor(1);
900  l->SetLineWidth(1);
901  l->Draw();
902  objs->AddLast(l);
903 
904  //up = new TLine();
905  //down = new TLine();
906 
907  }
908 
909  } // iz
910  } // iy
911 
912  if (do3D) { // DO THE 3D PLOT
913  up->Draw();
914  objs->AddLast(up);
915  down->Draw();
916  objs->AddLast(down);
917  } else { // DO THE 2D PLOT
918  //up->Draw();
919  //down->Draw();
920  }
921  } // iy
922 
923  return objs;
924 } // draw
925 
926 
927 void
929 {
930  double theta = 16.*deg;
931  double shift = fRFocal - 30.*cm;
932 
933  Vector vShift(0, 0, -1, fTelCS);
934  CoordinateSystemPtr auxCS = CoordinateSystem::Translation(vShift*shift, fTelCS);
935  fCameraSupportCoordinateSystem = CoordinateSystem::RotationY(theta, auxCS);
936 }
937 
938 
939 // Configure (x)emacs for this file ...
940 // Local Variables:
941 // mode: c++
942 // compile-command: "cd $AUGER_BASE && make"
943 // End:
RTResult Trace(const utl::Photon &photonIn, utl::Photon &photonOut, int &nreflections, int &col, int &row, double &cosTheta, bool doMercedes=true)
double Plane(const utl::Point &point, const utl::Vector &normal, const utl::Photon &photonIn, utl::Photon &photonOut)
Definition: RTFunctions.cc:41
constexpr double mm
Definition: AugerUnits.h:113
double GetSigmaNormal() const
Variable to model the Mercedes surface imperfection.
void Normalize()
Definition: Vector.h:64
HexagonDirection Hexagon(double x, double y, double r)
Point object.
Definition: Point.h:32
std::vector< utl::Photon > PhotonList
Definition: RTFunctions.h:21
Base class for all exceptions used in the auger offline code.
int Reflection(const utl::Photon &photonIn, const Vector &normal, utl::Photon &photonOut)
Definition: RTFunctions.cc:29
double GetEta() const
Camera angular pixel spacing.
double GetCosTheta(const CoordinateSystemPtr &coordinateSystem) const
cos of zenith (theta) angle
Definition: BasicVector.h:251
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
double GetWeight() const
weight assigned to the photon
Definition: Photon.h:21
double GetMercedesHeight() const
Height of the Mercedes.
const Camera & GetCamera() const
Get the Camera object that belongs to the telescope.
unsigned int GetFirstColumn() const
double GetMercedesEfficiency() const
Average efficiency of the Mercedes.
const Pixel & GetPixel(const unsigned int pixelId) const
Get Pixel by id, throw utl::NonExistentComponentException if n.a.
bool FindPixelId(const utl::Vector &incidentDir, int &row, int &col) const
constexpr double deg
Definition: AugerUnits.h:140
int Sphere(const Point &origin, const double radius, const utl::Photon &photonIn, IntersectionList &intersection)
Definition: RTFunctions.cc:142
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
utl::CoordinateSystemPtr GetTelescopeCoordinateSystem() const
double GetX(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:206
Wraps the random number engine used to generate distributions.
Definition: RandomEngine.h:27
constexpr double kSqrt3
Definition: MathConstants.h:31
RTResult TraceMerc(const utl::CoordinateSystemPtr &pxlCS, const utl::Photon &photonIn, utl::Photon &photonOut, int &nreflections)
void SetWeight(const double w)
source of the photons. Should use Eye::LightSource enum types
Definition: Photon.h:31
unsigned int GetLastRow() const
RTResult TraceShadow(const utl::Photon &photonIn, const bool doSupport=true)
std::vector< PhotonNormalPair > IntersectionList
Definition: RTFunctions.h:28
const utl::Vector & GetDirection() const
Definition: Photon.h:26
int Refraction(const double n12, const utl::Photon &photonIn, const Vector &normal, PhotonList &photonsOut)
Definition: RTFunctions.cc:61
const utl::CoordinateSystemPtr & GetPixelCoordinateSystem() const
double GetMercedesBase() const
Base of the Mercedes.
double GetY(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:209
Detector description interface for Telescope-related data.
int TraceSurf(const utl::Photon &photonIn, utl::Photon &photonOut, utl::Vector &normal)
utl::Point GetPosition() const
constexpr double cm
Definition: AugerUnits.h:117
Vector object.
Definition: Vector.h:30
unsigned int GetLastColumn() const
int ConstructPlane(const int id, utl::Vector &n, utl::Point &p, const utl::CoordinateSystemPtr &pxlCS)
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:212
double GetRadiusFocal() const
Radius of focal surface of the camera.
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
constexpr double m
Definition: AugerUnits.h:121
unsigned int GetFirstRow() const
unsigned int GetId() const
Description of a camera.
const utl::Point & GetPosition() const
Definition: Photon.h:25

, generated on Tue Sep 26 2023.