source: trunk/MagicSoft/Mars/mpointing/MSrcPosCorrect.cc@ 7814

Last change on this file since 7814 was 7388, checked in by tbretz, 19 years ago
*** empty log message ***
File size: 6.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 6/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2005
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26//
27// MSrcPosCorrect
28//
29// For more details see Process()
30//
31//////////////////////////////////////////////////////////////////////////////
32#include "MSrcPosCorrect.h"
33
34#include <TVector2.h>
35
36#include "MParList.h"
37
38#include "MLog.h"
39#include "MLogManip.h"
40
41#include "MGeomCam.h"
42#include "MSrcPosCam.h"
43#include "MRawRunHeader.h"
44#include "MReportStarguider.h"
45
46ClassImp(MSrcPosCorrect);
47
48using namespace std;
49
50// --------------------------------------------------------------------------
51//
52MSrcPosCorrect::MSrcPosCorrect(const char *name, const char *title)
53 : fSrcPosCam(NULL), fSrcPosAnti(NULL), fAxis(NULL), fGeom(NULL)
54 , fDx(-14.24) , fDy(-9.495)
55
56{
57 fName = name ? name : "MSrcPosCorrect";
58 fTitle = title ? title : "Calculates the source position in the camera";
59}
60
61// --------------------------------------------------------------------------
62//
63// Search and if necessary create MSrcPosCam in the parameter list. Search
64// MSourcePos. If not found, do nothing else, and skip the task. If MSrcPosCam
65// did not exist before and has been created here, it will contain as source
66// position the camera center (0,0).
67// In the case that MSourcePos is found, go ahead in searching the rest of
68// necessary containers. The source position will be calculated for each
69// event in Process.
70//
71Int_t MSrcPosCorrect::PreProcess(MParList *pList)
72{
73 fSrcPosCam = (MSrcPosCam*)pList->FindObject("MSrcPosCam");
74 if (!fSrcPosCam)
75 {
76 *fLog << err << "MSrcPosCam not found... aborting." << endl;
77 return kFALSE;
78 }
79
80 fSrcPosAnti = (MSrcPosCam*)pList->FindObject("MSrcPosAnti", "MSrcPosCam");
81
82 fAxis = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", "OpticalAxis");
83 if (!fAxis)
84 return kFALSE;
85
86 return kTRUE;
87}
88
89// --------------------------------------------------------------------------
90//
91// Checking for file type. If the file type is Monte Carlo the
92// source position is arbitrarily determined from the MC headers.
93//
94Bool_t MSrcPosCorrect::ReInit(MParList *plist)
95{
96 MRawRunHeader *run = (MRawRunHeader*)plist->FindObject("MRawRunHeader");
97 if (!run)
98 {
99 *fLog << err << "MRawRunHeader not found... aborting." << endl;
100 return kFALSE;
101 }
102
103 fRunType = run->GetRunType();
104 fRunNumber = run->GetRunNumber();
105
106 if (fRunNumber<56161 && fRunNumber>53832)
107 {
108 *fLog << inf << "Run Number " << fRunNumber << " between 53832 and 56161." << endl;
109 *fLog << "A misfocussing correction (" << fDx << "mm/" << fDy << "mm) will be applied." << endl;
110 }
111
112 return kTRUE;
113}
114
115// --------------------------------------------------------------------------
116//
117// Performs source position correction in the camera.
118// Due to missfocussing a shift of
119// dx=0.048deg and dy=0.034deg
120// or
121// dx=14.24mm and dy=9.495mm
122// is added between run 53832 (excl) and 56161 (excl)
123//
124// See also: Runbook
125//
126// 2005-05-23 03:33:51:
127// We start again to make tests on AMC with Roque lamp and PinDiode Tests.
128// At park position, we do a Laser initial isation and a Laser adjustment.
129// We discovered that the procedure we used yester day for Roque Lamp
130// light source was producing a very non-uniform light
131// We did some studies to produce an uniformly illuminated li ght from
132// the Roque Lamp Then we moved the telescope to the Roque Lamp position
133// and did a Laser adjust for the Roque position. We put the telescope to
134// the same shaftencoder values as were used in August to adjust the
135// mirrors
136// ( 29691 for SE-Az and SE-Zd1 1301 and SE-Zd2 9912 ( sometimes
137// oscillating to 9913 ) ) When we looked at the image of the spot on the
138// camer a, we saw a clear offset from the centre. Then we calculated this
139// offset and put the correct numbers in the AMC code. Then we redid the
140// laser adjustment and fou nd the spot to be nicely centred. Our
141// calculations showed that the offset was 0.048 deg in X direction and
142// 0.032 deg in Y direction.
143// Good night
144//
145// Believing the Database the following data is affected:
146// 1ES1426+428 Off1ES1426-1
147// 1ES1959+650 Off1ES1959-1
148// 2E-1415+2557 Off2E1415-1
149// Arp-220 OffArp-220-1
150// GC-W1 OffHB1553-1
151// HB89-1553+11 OffM87-1
152// M87 OffW-Comae-1
153// W-Comae
154//
155Int_t MSrcPosCorrect::Process()
156{
157 if (fRunType==MRawRunHeader::kRTMonteCarlo)
158 return kTRUE;
159
160 TVector2 d;
161 if (fRunNumber<56161 && fRunNumber>53832)
162 {
163 // dx=-0.048deg, dy=0.034deg, d=0.059deg
164 static const TVector2 dxy(fDx, fDy);
165
166 d -= dxy;
167 }
168
169 fAxis->SetXY(d);
170 fSrcPosCam->Add(d);
171 if (fSrcPosAnti)
172 {
173 d *= -1; // Anti-Source position should always be symetric
174 fSrcPosAnti->Add(d);
175 }
176
177 return kTRUE;
178}
179
180Int_t MSrcPosCorrect::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
181{
182 Bool_t rc = kFALSE;
183 if (IsEnvDefined(env, prefix, "Dx", print))
184 {
185 fDx = GetEnvValue(env, prefix, "Dx", fDx);
186 rc = kTRUE;
187 }
188 if (IsEnvDefined(env, prefix, "Dy", print))
189 {
190 fDy = GetEnvValue(env, prefix, "Dy", fDy);
191 rc = kTRUE;
192 }
193
194 return rc;
195}
Note: See TracBrowser for help on using the repository browser.