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>
28 #include <det/Detector.h>
30 #include <fdet/FDetector.h>
32 #include <fdet/Telescope.h>
33 #include <fdet/Camera.h>
34 #include <fdet/Pixel.h>
35 #include <fdet/Channel.h>
37 #include <TPolyLine3D.h>
41 #include <TPolyMarker3D.h>
45 #include <TObjArray.h>
54 using namespace TelescopeSimulatorKG;
148 if (!
TraceSurf(photonIn, photonCamera, normal)) {
151 ERROR(
"RT::Camera> camera sphere not hit!");
162 photonOut = photonCamera;
165 INFO(
"RT::Camera> no pixle hit on camera!");
179 INFO(
"RT::Camera> photon outgoing in pixel CS ???");
186 photonOut = photonCamera;
196 const RTResult mercStatus =
TraceMerc(pxlCS, photonCamera, photonPMT, nreflections);
199 if (mercStatus ==
eOK) {
201 double r_index_12 = 1.0/1.52;
202 Vector normalPMT(0., 0., 1., pxlCS);
205 utl::Photon photonHittingPhotocathode = photonsHittingPhotocathode[0];
208 int pixelId = (col-1)*fNRows + row;
209 cout <<
"11111111 " <<
fTel.
GetId() <<
" " << pixelId
213 <<
" " << photonHittingPhotocathode.
GetWeight()
217 photonOut = photonPMT;
222 { ostringstream info;
223 info <<
"RT::Camera> HIT: photon: wIn=" << photonIn.
GetWeight()
226 <<
" angle_cathode=" << acos(cosTheta)/
deg <<
"deg "
227 <<
" nrefl_merc=" << nreflections;
228 INFO(info.str().c_str());
237 INFO(
"RT::Camera> nref<1 ! photon lost!");
248 static const double fNx0 = 10.0;
249 static const double fNy0 = 11.66666666666667;
251 static const double dPhi =
kSqrt3 * dOmega/2;
259 const double omegap = asin(y);
260 const double phip = atan2(-x, -z);
267 double nxl = 2.*(omegap/dOmega) + 2.0*fNx0;
268 double nyl = fNy0 - phip/dPhi;
270 if (nxl < 0 || nxl > 2*nCols+1 ||
271 nyl < 0 || nyl > nRows+1)
279 const double f1 = 3 * nyl - nxl - 1;
280 const double f2 = 3 * nyl + nxl - 2;
286 f = (row % 2) ? f1 : f2;
292 col = col/2 + (f > 0 ? 0 : 1);
297 col = col/2 + (f > 0 ? 1 : 0);
304 return (col >=1 && row >= 1 &&
305 col <= nCols && row <= nRows);
317 const Vector normal(intersections.back().second);
320 const double y = normal.GetY(
fTelCS);
327 INFO(
"RT::Camera> camera shadow!");
334 Photon photonOut(intersections.back().first);
342 Point pPlane = photonOut.GetPosition();
350 if (y > 30.*
cm && y < 35.*
cm) {
354 INFO(
"RT::Camera> camera support shadow!");
384 photonOut = intersections.front().first;
442 bool do_reflection =
false;
444 for (i = 0; i <= 6; ++i) {
450 err <<
"This can never happen! "
452 <<
" nloop: " << nloop
453 <<
" nrefl: " << nreflections
454 <<
". THROW EXCEPTION!";
455 ERROR(err.str().c_str());
474 do_reflection =
true;
482 if (!do_reflection) {
486 err <<
" RT::Camera> NO MERCEDES OR PMT HIT! PHOTON LOST! w=" << photonIn.
GetWeight();
487 INFO(err.str().c_str());
503 const Vector normal = npl;
511 err <<
"RT::Camera> get rid of this: photon hits mercedes from outside "
513 INFO(err.str().c_str());
524 err <<
"RT::Camera> backscattered from Mercedes? "
527 INFO (err.str().c_str());
540 photonOut = point_next;
639 double xl = std::fabs(x);
640 double yl = std::fabs(y);
645 if (xl <= xm && yl <= r-tmp*xl)
672 if (
id == 0 ||
id == 7) {
674 n =
Vector(0, 0, 1, pxlCS);
678 if (
id > 0 &&
id < 7) {
680 double dTheta = 60*
deg;
681 double theta = dTheta * id;
682 double sinTheta = sin(theta);
683 double cosTheta = cos(theta);
686 p =
Point(cosTheta*
fD1/2., sinTheta*
fD1/2., 0.0, pxlCS);
700 TObjArray* objs =
new TObjArray();
702 double xMin = 0, xMax = 0, yMin = 0, yMax = 0, zMin = 0, zMax = 0;
709 for (
int col = 1; col <= nCols; ++col) {
711 for (
int row = 1; row <= nRows; ++row) {
713 const int pixelId = (col-1)*nRows + row;
719 for (
int i = 0; i < 6; ++i) {
721 double theta1 = 30*
deg + 60*
deg*i;
722 double theta2 = 30*
deg + 60*
deg*(i+1);
724 Point p1_in(cos(theta1) * r_in,
727 Point p2_in(cos(theta2) * r_in,
731 Point p1_out(cos(theta1) * r_out,
734 Point p2_out(cos(theta2) * r_out,
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);
773 objs->AddLast(p_pos);
777 ostringstream pxl_txt;
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);
786 objs->AddLast(p_pos);
791 TPolyLine3D *l_in =
new TPolyLine3D(1);
792 l_in->SetLineColor(2);
798 TPolyLine3D *l_out =
new TPolyLine3D(1);
799 l_out->SetLineColor(1);
800 l_out->SetLineStyle(2);
805 objs->AddLast(l_out);
807 TPolyLine3D *l_corner =
new TPolyLine3D(1);
808 l_corner->SetLineColor(1);
809 l_corner->SetLineStyle(2);
814 objs->AddLast(l_corner);
818 TLine *l_in =
new TLine(p1_in.GetX(
fTelCS), p1_in.GetY(
fTelCS),
820 l_in->SetLineColor(2);
824 l_out->SetLineColor(1);
825 l_out->SetLineStyle(2);
830 objs->AddLast(l_out);
843 double length = 2.*
m;
845 for (
int i = 0; i < 2; ++i) {
848 double y2 = 30.*
cm + dx;
854 TPolyLine3D *up =
new TPolyLine3D(4);
855 TPolyLine3D *down =
new TPolyLine3D(4);
858 down->SetLineColor(1);
859 down->SetLineWidth(2);
862 for (
int iy = 0; iy < 2; ++iy) {
872 for (
int iz = 0; iz < (do3D ? 2 : 1); ++iz) {
884 TPolyLine3D *l =
new TPolyLine3D(1);
930 double theta = 16.*
deg;
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)
double GetSigmaNormal() const
Variable to model the Mercedes surface imperfection.
utl::CoordinateSystemPtr fTelCS
HexagonDirection Hexagon(double x, double y, double r)
std::vector< utl::Photon > PhotonList
Base class for all exceptions used in the auger offline code.
int Reflection(const utl::Photon &photonIn, const Vector &normal, utl::Photon &photonOut)
double GetEta() const
Camera angular pixel spacing.
double GetCosTheta(const CoordinateSystemPtr &coordinateSystem) const
cos of zenith (theta) angle
#define INFO(message)
Macro for logging informational messages.
double GetWeight() const
weight assigned to the photon
double GetMercedesHeight() const
Height of the Mercedes.
void CalculateCameraSupportCoordinateSystem()
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
int Sphere(const Point &origin, const double radius, const utl::Photon &photonIn, IntersectionList &intersection)
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
utl::CoordinateSystemPtr GetTelescopeCoordinateSystem() const
double GetX(const CoordinateSystemPtr &coordinateSystem) const
Wraps the random number engine used to generate distributions.
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
unsigned int GetLastRow() const
RTResult TraceShadow(const utl::Photon &photonIn, const bool doSupport=true)
std::vector< PhotonNormalPair > IntersectionList
TObjArray * Draw(const bool do3D=true)
const utl::Vector & GetDirection() const
int Refraction(const double n12, const utl::Photon &photonIn, const Vector &normal, PhotonList &photonsOut)
const utl::CoordinateSystemPtr & GetPixelCoordinateSystem() const
double GetMercedesBase() const
Base of the Mercedes.
double GetY(const CoordinateSystemPtr &coordinateSystem) const
Detector description interface for Telescope-related data.
int TraceSurf(const utl::Photon &photonIn, utl::Photon &photonOut, utl::Vector &normal)
utl::CoordinateSystemPtr fCameraSupportCoordinateSystem
utl::Point GetPosition() const
const fdet::Telescope & fTel
unsigned int GetLastColumn() const
void SetMercedesParameter(double height, double width)
int ConstructPlane(const int id, utl::Vector &n, utl::Point &p, const utl::CoordinateSystemPtr &pxlCS)
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
double GetRadiusFocal() const
Radius of focal surface of the camera.
#define ERROR(message)
Macro for logging error messages.
static int GetDebugLevel()
unsigned int GetFirstRow() const
unsigned int GetId() const
const utl::Point & GetPosition() const