source: trunk/Mars/mgeom/MGeomMirror.cc@ 13414

Last change on this file since 13414 was 8907, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 5.7 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Oscar Blanch 11/2002 <mailto:blanch@ifae.es>
19!
20! Copyright: MAGIC Software Development, 2000-2002
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MGeomMirror
28//
29// This is the base class of the Mirror geometry.
30//
31/////////////////////////////////////////////////////////////////////////////
32#include "MGeomMirror.h"
33
34#include <TMath.h>
35#include <TRotation.h>
36
37#include "MLog.h"
38#include "MLogManip.h"
39
40ClassImp(MGeomMirror);
41
42using namespace std;
43
44// --------------------------------------------------------------------------
45//
46// Initializes a Mirror geometry with 0 values, except for fMirrorID.
47//
48MGeomMirror::MGeomMirror(Int_t mir, const char *name, const char *title)
49 : fReflector(0)
50{
51 fName = name ? name : "MGeomMirror";
52 fTitle = title ? title : "Storage container for a mirror geometry";
53
54 fMirrorId=mir; // the Mirror Id
55
56 fFocalDist=0.; // focal distance of that mirror [cm]
57 fSX=0.; // curvilinear coordinate of mirror's center in X[cm]
58 fSY=0.; // curvilinear coordinate of mirror's center in X[cm]
59 fX=0.; // x coordinate of the center of the mirror [cm]
60 fY=0.; // y coordinate of the center of the mirror [cm]
61 fZ=0.; // z coordinate of the center of the mirror [cm]
62 fThetaN=0.; // polar theta angle of the direction
63 // where the mirror points to
64 fPhiN=0.; // polar phi angle of the direction
65 // where the mirror points to
66 fXN=0.; // xn coordinate of the normal vector
67 // in the center
68 fYN=0.; // yn coordinate of the normal vector
69 // in the center
70 fZN=0.; // zn coordinate of the normal vector
71 // in the center
72 // Note: fXN^2*fYN^2*fZN^2 = 1
73 fDeviationX=0.; // deviation in x [cm]
74 fDeviationY=0.; // deviation in y [cm]
75 // of the spot of a single mirror on the camera plane
76
77}
78
79// --------------------------------------------------------------------------
80//
81// DESCRIPTION MISSING: Please contact Oscar
82//
83void MGeomMirror::SetMirrorContent(Int_t mir, Float_t focal, Float_t curv_x,
84 Float_t curv_y, Float_t lin_x, Float_t lin_y,
85 Float_t lin_z, Float_t theta, Float_t phi,
86 Float_t x_n, Float_t y_n, Float_t z_n){
87 fMirrorId=mir; // the Mirror Id
88
89 fFocalDist=focal; // focal distance of that mirror [cm]
90 fSX=curv_x; // curvilinear coordinate of mirror's center in X[cm]
91 fSY=curv_y; // curvilinear coordinate of mirror's center in X[cm]
92 fX=lin_x; // x coordinate of the center of the mirror [cm]
93 fY=lin_y; // y coordinate of the center of the mirror [cm]
94 fZ=lin_z; // z coordinate of the center of the mirror [cm]
95 fThetaN=theta; // polar theta angle of the direction
96 // where the mirror points to
97 fPhiN=phi; // polar phi angle of the direction
98 // where the mirror points to
99 fXN=x_n; // xn coordinate of the normal vector
100 // in the center
101 fYN=y_n; // yn coordinate of the normal vector
102 // in the center
103 fZN=z_n; // zn coordinate of the normal vector
104 // in the center
105 // Note: fXN^2*fYN^2*fZN^2 = 1
106}
107
108void MGeomMirror::SetMirrorDeviations(Float_t dev_x, Float_t dev_y)
109{
110 fDeviationX=dev_x; // deviation in x [cm]
111 fDeviationY=dev_y; // deviation in y [cm]
112 // of the spot of a single mirror on the camera plane
113}
114
115// --------------------------------------------------------------------------
116//
117// Setting function to store the mirror reflectivity (ref) at different
118// wavelength (wav).
119//
120void MGeomMirror::SetReflectivity(const TArrayF &wav, const TArrayF &ref)
121{
122 if (fWavelength.GetSize()!=wav.GetSize() ||
123 fReflectivity.GetSize()!=ref.GetSize())
124 {
125 *fLog << err << dbginf << " fWavelength or fQE do not have ";
126 *fLog << "size of setting arrays" << endl;
127 return;
128 }
129
130 fWavelength = wav;
131 fReflectivity = ref;
132}
133
134TVector3 MGeomMirror::GetReflection(const TVector3 &star, Double_t dist)
135{
136 if (!fReflector)
137 {
138 fReflector = new TRotation; // unit matrix
139 fReflector->Rotate(TMath::Pi(), GetMirrorNorm());
140 }
141
142 // Reflect star on the mirror (done by a rotation
143 // around the normal vector of the mirror center
144 TVector3 light(star);
145 light *= *fReflector;
146
147 if (dist<0)
148 return light;
149
150 // calculate distance to the camera (stretch vector such, that
151 // its Z component is the distance between the camera and
152 // the mirror
153 const TVector3 &pos = GetMirrorCenter();
154 const Double_t d = (dist - pos.Z()) / light.Z();
155
156 return light*d + pos;
157}
Note: See TracBrowser for help on using the repository browser.