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 |
|
---|
48 | ClassImp(MSrcPosFromModel);
|
---|
49 |
|
---|
50 | using namespace std;
|
---|
51 |
|
---|
52 | // --------------------------------------------------------------------------
|
---|
53 | //
|
---|
54 | // Initialize fY and fY with 0
|
---|
55 | //
|
---|
56 | MSrcPosFromModel::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 |
|
---|
65 | MSrcPosFromModel::~MSrcPosFromModel()
|
---|
66 | {
|
---|
67 | delete fPoint0401;
|
---|
68 | delete fPoint0405;
|
---|
69 | }
|
---|
70 |
|
---|
71 | // --------------------------------------------------------------------------
|
---|
72 | //
|
---|
73 | // Search and if necessary create MSrcPosCam in the parameter list
|
---|
74 | //
|
---|
75 | Int_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 | //
|
---|
123 | Int_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 | MVector3 sky;
|
---|
133 | sky.SetRaDec(fPointPos->GetRaRad(), fPointPos->GetDecRad());
|
---|
134 |
|
---|
135 | // Get current star position (off center)
|
---|
136 | MVector3 vl2 = MAstroSky2Local(*fTime, *fObservatory)*sky;
|
---|
137 | // Get corrected position camera center)
|
---|
138 | TVector3 vl1 = conv->Correct(vl2);
|
---|
139 |
|
---|
140 | // Calculate x,y of za2
|
---|
141 | TVector2 d = MAstro::GetDistOnPlain(vl1, vl2, fGeom->GetCameraDist()*1000);
|
---|
142 |
|
---|
143 | // Set Source position
|
---|
144 | fSrcPos->SetXY(d);
|
---|
145 |
|
---|
146 | return kTRUE;
|
---|
147 | }
|
---|