source: trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.cc@ 6048

Last change on this file since 6048 was 3666, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 5.3 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): Thomas Bretz 3/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2004
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26//
27// MSrcPosCalc
28//
29// Calculate the current source position in the camera from the (already
30// corrected) local pointing position of the telescope (MPointingPos) by
31// derotating the position (given in x and y coordinates in the camera
32// plane) at culmination time by the current rotation angle of the
33// starfield dtermined from MObservatory and MPointingPos
34//
35// The conversion factor between the camera plain (mm) and the
36// sky (deg) is taken from MGeomCam.
37//
38// Input Container:
39// MPointingPos
40// MObservatory
41// MGeomCam
42//
43// Output Container:
44// MSrcPosCam
45//
46// To be done:
47// - wobble mode missing
48// - a switch between using sky-coordinates and time or local-coordinates
49// from MPointingPos for determin the rotation angle
50// - the center of rotation need not to be the camera center
51//
52//////////////////////////////////////////////////////////////////////////////
53#include "MSrcPosCalc.h"
54
55#include "MParList.h"
56
57#include "MLog.h"
58#include "MLogManip.h"
59
60#include "MRawRunHeader.h"
61#include "MObservatory.h"
62#include "MSrcPosCam.h"
63#include "MAstroSky2Local.h"
64#include "MPointingPos.h"
65#include "MGeomCam.h"
66
67ClassImp(MSrcPosCalc);
68
69using namespace std;
70
71// --------------------------------------------------------------------------
72//
73// Initialize fY and fY with 0
74//
75MSrcPosCalc::MSrcPosCalc(const char *name, const char *title)
76 : fX(0), fY(0)
77{
78 fName = name ? name : "MSrcPosCalc";
79 fTitle = title ? title : "Derotates the source position in the camera";
80}
81
82// --------------------------------------------------------------------------
83//
84// Search and if necessary create MSrcPosCam in the parameter list
85//
86Int_t MSrcPosCalc::PreProcess(MParList *pList)
87{
88 fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
89 if (!fGeom)
90 {
91 *fLog << err << "MGeomCam not found... aborting." << endl;
92 return kFALSE;
93 }
94
95 fPointPos = (MPointingPos*)pList->FindObject("MPointingPos");
96 if (!fPointPos)
97 {
98 *fLog << err << "MPointPos not found... aborting." << endl;
99 return kFALSE;
100 }
101
102 fObservatory = (MObservatory*)pList->FindObject("MObservatory");
103 if (!fObservatory)
104 {
105 *fLog << err << "MObservatory not found... aborting." << endl;
106 return kFALSE;
107 }
108
109 fTime = (MTime*)pList->FindObject("MTime");
110 if (!fTime)
111 {
112 *fLog << err << "MTime not found... aborting." << endl;
113 return kFALSE;
114 }
115
116 fSrcPos = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam");
117 if (!fSrcPos)
118 return kFALSE;
119
120 return kTRUE;
121}
122
123// --------------------------------------------------------------------------
124//
125// Search the parameter list for MObservatory and MTime
126//
127Bool_t MSrcPosCalc::ReInit(MParList *pList)
128{
129 if (fX!=0 || fY!=0)
130 return kTRUE;
131
132 *fLog << warn << "fX==0 && fY==0: Using arbitrary source position!" << endl;
133
134 //
135 // This is a workaround for current crab misspointing - DO NOT USE!
136 // It will be removed soon!
137 //
138 const MRawRunHeader *h = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
139 if (!h)
140 {
141 *fLog << err << "MRawRunHeader not found... aborting." << endl;
142 return kFALSE;
143 }
144
145 const MTime &t = h->GetRunStart();
146
147 const Double_t rho = fPointPos->RotationAngle(*fObservatory, t);
148
149 // Calculate x, y of Zeta Tauri
150
151 Double_t tm = t.GetAxisTime();
152
153 Double_t x = 1.7267e6-6.03285e-3*tm; // [mm]
154 Double_t y = -189.823+974.908*exp(-52.3083*(tm*1e-5-2861.5)); // [mm]
155
156 const Double_t cs = TMath::Cos(rho-fDrho);
157 const Double_t sn = TMath::Sin(rho-fDrho);
158
159 const Double_t dx = fR*cs;
160 const Double_t dy = fR*sn;
161
162 fSrcPos->SetXY(x-dx, y-dy);
163
164 *fLog << dbg << t << " - Position: x=" << x-dx << "mm y=" << y-dy << "mm" << endl;
165
166 return kTRUE;
167}
168
169// --------------------------------------------------------------------------
170//
171// Derotate fX/fY by the current rotation angle, set MSrcPosCam
172//
173Int_t MSrcPosCalc::Process()
174{
175 if (fX==0 && fY==0)
176 return kTRUE;
177
178 // rotate the source position by the current rotation angle
179 const Double_t rho = fPointPos->RotationAngle(*fObservatory, *fTime);
180
181 // Define source position in the camera plain
182 TVector2 v(fX, fY);
183 v=v.Rotate(rho);
184
185 // Convert coordinates into camera plain (mm)
186 v *= 1./fGeom->GetConvMm2Deg();
187
188 // Set current source position
189 fSrcPos->SetXY(v);
190
191 return kTRUE;
192}
Note: See TracBrowser for help on using the repository browser.