source: trunk/MagicSoft/Mars/mgeom/MGeomMirror.cc@ 7116

Last change on this file since 7116 was 3710, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 5.6 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 <TRotation.h>
35
36#include "MLog.h"
37#include "MLogManip.h"
38
39ClassImp(MGeomMirror);
40
41using namespace std;
42
43// --------------------------------------------------------------------------
44//
45// Initializes a Mirror geometry with 0 values, except for fMirrorID.
46//
47MGeomMirror::MGeomMirror(Int_t mir, const char *name, const char *title)
48 : fReflector(0)
49{
50 fName = name ? name : "MGeomMirror";
51 fTitle = title ? title : "Storage container for a mirror geometry";
52
53 fMirrorId=mir; // the Mirror Id
54
55 fFocalDist=0.; // focal distance of that mirror [cm]
56 fSX=0.; // curvilinear coordinate of mirror's center in X[cm]
57 fSY=0.; // curvilinear coordinate of mirror's center in X[cm]
58 fX=0.; // x coordinate of the center of the mirror [cm]
59 fY=0.; // y coordinate of the center of the mirror [cm]
60 fZ=0.; // z coordinate of the center of the mirror [cm]
61 fThetaN=0.; // polar theta angle of the direction
62 // where the mirror points to
63 fPhiN=0.; // polar phi angle of the direction
64 // where the mirror points to
65 fXN=0.; // xn coordinate of the normal vector
66 // in the center
67 fYN=0.; // yn coordinate of the normal vector
68 // in the center
69 fZN=0.; // zn coordinate of the normal vector
70 // in the center
71 // Note: fXN^2*fYN^2*fZN^2 = 1
72 fDeviationX=0.; // deviation in x [cm]
73 fDeviationY=0.; // deviation in y [cm]
74 // of the spot of a single mirror on the camera plane
75
76}
77
78// --------------------------------------------------------------------------
79//
80// DESCRIPTION MISSING: Please contact Oscar
81//
82void MGeomMirror::SetMirrorContent(Int_t mir, Float_t focal, Float_t curv_x,
83 Float_t curv_y, Float_t lin_x, Float_t lin_y,
84 Float_t lin_z, Float_t theta, Float_t phi,
85 Float_t x_n, Float_t y_n, Float_t z_n){
86 fMirrorId=mir; // the Mirror Id
87
88 fFocalDist=focal; // focal distance of that mirror [cm]
89 fSX=curv_x; // curvilinear coordinate of mirror's center in X[cm]
90 fSY=curv_y; // curvilinear coordinate of mirror's center in X[cm]
91 fX=lin_x; // x coordinate of the center of the mirror [cm]
92 fY=lin_y; // y coordinate of the center of the mirror [cm]
93 fZ=lin_z; // z coordinate of the center of the mirror [cm]
94 fThetaN=theta; // polar theta angle of the direction
95 // where the mirror points to
96 fPhiN=phi; // polar phi angle of the direction
97 // where the mirror points to
98 fXN=x_n; // xn coordinate of the normal vector
99 // in the center
100 fYN=y_n; // yn coordinate of the normal vector
101 // in the center
102 fZN=z_n; // zn coordinate of the normal vector
103 // in the center
104 // Note: fXN^2*fYN^2*fZN^2 = 1
105}
106
107void MGeomMirror::SetMirrorDeviations(Float_t dev_x, Float_t dev_y)
108{
109 fDeviationX=dev_x; // deviation in x [cm]
110 fDeviationY=dev_y; // deviation in y [cm]
111 // of the spot of a single mirror on the camera plane
112}
113
114// --------------------------------------------------------------------------
115//
116// Setting function to store the mirror reflectivity (ref) at different
117// wavelength (wav).
118//
119void MGeomMirror::SetReflectivity(const TArrayF &wav, const TArrayF &ref)
120{
121 if (fWavelength.GetSize()!=wav.GetSize() ||
122 fReflectivity.GetSize()!=ref.GetSize())
123 {
124 *fLog << err << dbginf << " fWavelength or fQE do not have ";
125 *fLog << "size of setting arrays" << endl;
126 return;
127 }
128
129 fWavelength = wav;
130 fReflectivity = ref;
131}
132
133TVector3 MGeomMirror::GetReflection(const TVector3 &star, Double_t dist)
134{
135 if (!fReflector)
136 {
137 fReflector = new TRotation; // unit matrix
138 fReflector->Rotate(TMath::Pi(), GetMirrorNorm());
139 }
140
141 // Reflect star on the mirror (done by a rotation
142 // around the normal vector of the mirror center
143 TVector3 light(star);
144 light *= *fReflector;
145
146 if (dist<0)
147 return light;
148
149 // calculate distance to the camera (stretch vector such, that
150 // its Z component is the distance between the camera and
151 // the mirror
152 const TVector3 &pos = GetMirrorCenter();
153 const Double_t d = (dist - pos.Z()) / light.Z();
154
155 return light*d + pos;
156}
Note: See TracBrowser for help on using the repository browser.