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

Last change on this file since 3569 was 3569, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 5.1 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//
49//////////////////////////////////////////////////////////////////////////////
50#include "MSrcPosCalc.h"
51
52#include "MParList.h"
53
54#include "MLog.h"
55#include "MLogManip.h"
56
57#include "MRawRunHeader.h"
58#include "MObservatory.h"
59#include "MSrcPosCam.h"
60#include "MAstroSky2Local.h"
61#include "MPointingPos.h"
62#include "MGeomCam.h"
63
64ClassImp(MSrcPosCalc);
65
66using namespace std;
67
68// --------------------------------------------------------------------------
69//
70// Initialize fY and fY with 0
71//
72MSrcPosCalc::MSrcPosCalc(const char *name, const char *title)
73 : fX(0), fY(0)
74{
75 fName = name ? name : "MSrcPosCalc";
76 fTitle = title ? title : "Derotates the source position in the camera";
77}
78
79// --------------------------------------------------------------------------
80//
81// Search and if necessary create MSrcPosCam in the parameter list
82//
83Int_t MSrcPosCalc::PreProcess(MParList *pList)
84{
85 fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
86 if (!fGeom)
87 {
88 *fLog << err << "MGeomCam not found... aborting." << endl;
89 return kFALSE;
90 }
91
92 fPointPos = (MPointingPos*)pList->FindObject("MPointingPos");
93 if (!fPointPos)
94 {
95 *fLog << err << "MPointPos not found... aborting." << endl;
96 return kFALSE;
97 }
98
99 fObservatory = (MObservatory*)pList->FindObject("MObservatory");
100 if (!fObservatory)
101 {
102 *fLog << err << "MObservatory not found... aborting." << endl;
103 return kFALSE;
104 }
105
106 fSrcPos = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam");
107 if (!fSrcPos)
108 return kFALSE;
109
110 return kTRUE;
111}
112
113// --------------------------------------------------------------------------
114//
115// Search the parameter list for MObservatory and MTime
116//
117Bool_t MSrcPosCalc::ReInit(MParList *pList)
118{
119 if (fX!=0 || fY!=0)
120 return kTRUE;
121
122 *fLog << warn << "fX==0 && fY==0: Using arbitrary source position!" << endl;
123
124 //
125 // This is a workaround for current crab misspointing - DO NOT USE!
126 // It will be removed soon!
127 //
128 const MRawRunHeader *h = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
129 if (!h)
130 {
131 *fLog << err << "MRawRunHeader not found... aborting." << endl;
132 return kFALSE;
133 }
134
135 const MTime &t = h->GetRunStart();
136
137 const Double_t rho = fPointPos->RotationAngle(*fObservatory, t);
138
139 // Calculate x, y of Zeta Tauri
140
141 Double_t tm = t.GetAxisTime();
142
143 Double_t x = 1.7267e6-6.03285e-3*tm; // [mm]
144 Double_t y = -189.823+974.908*exp(-52.3083*(tm*1e-5-2861.5)); // [mm]
145
146 const Double_t cs = TMath::Cos(rho-fDrho);
147 const Double_t sn = TMath::Sin(rho-fDrho);
148
149 const Double_t dx = fR*cs;
150 const Double_t dy = fR*sn;
151
152 fSrcPos->SetXY(x-dx, y-dy);
153
154 *fLog << dbg << t << " - Position: x=" << x-dx << "mm y=" << y-dy << "mm" << endl;
155
156 return kTRUE;
157}
158
159// --------------------------------------------------------------------------
160//
161// Derotate fX/fY by the current rotation angle, set MSrcPosCam
162//
163Int_t MSrcPosCalc::Process()
164{
165 if (fX==0 && fY==0)
166 return kTRUE;
167
168 // Define source position in the camera plain
169 TVector2 v(fX, fY);
170
171 *fLog << dbg << fPointPos << " " << fGeom << " " << fObservatory << " " << fSrcPos << endl;
172
173 // rotate the source position by the current rotation angle
174 const Double_t rho = fPointPos->RotationAngle(*fObservatory);
175 v.Rotate(-rho);
176
177 // Convert coordinates into camera plain (mm)
178 v *= 1./fGeom->GetConvMm2Deg();
179
180 // Set current source position
181 fSrcPos->SetXY(v);
182
183 return kTRUE;
184}
Note: See TracBrowser for help on using the repository browser.