source: trunk/MagicSoft/Mars/mpointing/MSrcPosFromModel.cc@ 9620

Last change on this file since 9620 was 5921, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 4.0 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 8/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2004
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26//
27// MSrcPosFromModel
28//
29//
30//////////////////////////////////////////////////////////////////////////////
31#include "MSrcPosFromModel.h"
32
33#include "MParList.h"
34
35#include "MLog.h"
36#include "MLogManip.h"
37
38#include "MRawRunHeader.h"
39#include "MPointing.h"
40#include "MSrcPosCam.h"
41#include "MAstro.h"
42#include "MAstroCatalog.h" // MVector3
43#include "MAstroSky2Local.h"
44#include "MPointingPos.h"
45#include "MGeomCam.h"
46#include "MReportDrive.h"
47
48ClassImp(MSrcPosFromModel);
49
50using namespace std;
51
52// --------------------------------------------------------------------------
53//
54// Initialize fY and fY with 0
55//
56MSrcPosFromModel::MSrcPosFromModel(const char *name, const char *title)
57{
58 fName = name ? name : "MSrcPosFromModel";
59 fTitle = title ? title : "";
60
61 fPoint0401 = new MPointing("bending-fit.txt");
62 fPoint0405 = new MPointing("bending0405.txt");
63}
64
65MSrcPosFromModel::~MSrcPosFromModel()
66{
67 delete fPoint0401;
68 delete fPoint0405;
69}
70
71// --------------------------------------------------------------------------
72//
73// Search and if necessary create MSrcPosCam in the parameter list
74//
75Int_t MSrcPosFromModel::PreProcess(MParList *pList)
76{
77 fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
78 if (!fGeom)
79 {
80 *fLog << err << "MGeomCam not found... aborting." << endl;
81 return kFALSE;
82 }
83
84 fPointPos = (MPointingPos*)pList->FindObject("MPointingPos");
85 if (!fPointPos)
86 {
87 *fLog << err << "MPointPos not found... aborting." << endl;
88 return kFALSE;
89 }
90
91 fRun = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
92 if (!fRun)
93 {
94 *fLog << err << "MRawRunHeader not found... aborting." << endl;
95 return kFALSE;
96 }
97
98 fObservatory = (MObservatory*)pList->FindObject("MObservatory");
99 if (!fObservatory)
100 {
101 *fLog << err << "MObservatory not found... aborting." << endl;
102 return kFALSE;
103 }
104
105 fTime = (MTime*)pList->FindObject("MTime");
106 if (!fTime)
107 {
108 *fLog << err << "MTime not found... aborting." << endl;
109 return kFALSE;
110 }
111
112 fSrcPos = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam");
113 if (!fSrcPos)
114 return kFALSE;
115
116 return kTRUE;
117}
118
119// --------------------------------------------------------------------------
120//
121// Derotate fX/fY by the current rotation angle, set MSrcPosCam
122//
123Int_t MSrcPosFromModel::Process()
124{
125 MPointing *conv = 0;
126
127 if (!conv && fRun->GetRunNumber()<26237)
128 conv = fPoint0401;
129 if (!conv && fRun->GetRunNumber()<31684)
130 conv = fPoint0405;
131
132 TVector2 d;
133
134 if (conv)
135 {
136 MVector3 sky;
137 sky.SetRaDec(fPointPos->GetRaRad(), fPointPos->GetDecRad());
138
139 // Get current star position (off center)
140 MVector3 vl2 = MAstroSky2Local(*fTime, *fObservatory)*sky;
141 // Get corrected position camera center)
142 TVector3 vl1 = conv->Correct(vl2);
143
144 // Calculate x,y of za2
145 d = MAstro::GetDistOnPlain(vl1, vl2, fGeom->GetCameraDist()*1000);
146 }
147
148 // Set Source position
149 fSrcPos->SetXY(d);
150
151 return kTRUE;
152}
Note: See TracBrowser for help on using the repository browser.