source: trunk/Mars/mtemp/mmpi/MPointingPosCalcWA.cc@ 14993

Last change on this file since 14993 was 5490, checked in by mazin, 20 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, 11/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2003
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MPointingPosCalc
28//
29// Currently:
30//
31// * MC files: Copy the simulated telescope position (Telescope Theta,
32// Telescope Phi in MMcEvt) to MPointingPosition
33//
34// * Real Data: Copy the nominal poiting position (Nominal Zd, Nominal Az
35// in MReportDrive) to MPointingPosition
36//
37// Future: Interpolate the pointing position for each event between two
38// consecutive drive reports.
39//
40// Input Container:
41// MRawRunHeader
42// [MMcEvt, MReportDrive]
43//
44// Output Container:
45// MPointingPosition
46//
47/////////////////////////////////////////////////////////////////////////////
48#include "MPointingPosCalcWA.h"
49
50#include "MLog.h"
51#include "MLogManip.h"
52
53#include "MParList.h"
54#include "MVector3.h"
55
56#include "MPointingPos.h"
57#include "MAstro.h"
58#include "MObservatory.h"
59#include "MAstroSky2Local.h"
60#include "MRawRunHeader.h"
61#include "MReportDrive.h"
62#include "MMcEvt.hxx"
63
64ClassImp(MPointingPosCalcWA);
65
66using namespace std;
67
68// --------------------------------------------------------------------------
69//
70// Search for MRawRunHeader. Get the run type from there. Depending on
71// the run type search either for MMcEvt or MReportDrive.
72//
73Bool_t MPointingPosCalcWA::ReInit(MParList *plist)
74{
75 fObs = (MObservatory*)plist->FindCreateObj("MObservatory");
76 if (!fObs)
77 {
78 *fLog << err << "MObservatory not found... aborting." << endl;
79 return kFALSE;
80 }
81
82 fRunHeader = (MRawRunHeader*)plist->FindObject("MRawRunHeader");
83 if (!fRunHeader)
84 {
85 *fLog << err << "MRawRunHeader not found... aborting." << endl;
86 return kFALSE;
87 }
88
89 fRunType = fRunHeader->GetRunType();
90
91 switch (fRunType)
92 {
93 case MRawRunHeader::kRTData:
94 fReport = (MReportDrive*)plist->FindObject("MReportDrive");
95 if (!fReport)
96 {
97 *fLog << err << "MReportDrive not found... will set Az and Zd to a fixed value." << endl;
98 return kTRUE;
99 }
100 return kTRUE;
101
102 case MRawRunHeader::kRTMonteCarlo:
103 fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
104 if (!fMcEvt)
105 {
106 *fLog << err << "MMcEvt not found... aborting." << endl;
107 return kFALSE;
108 }
109 return kTRUE;
110
111 case MRawRunHeader::kRTPedestal:
112 *fLog << err << "Cannot work in a pedestal Run!... aborting." << endl;
113 return kFALSE;
114
115 case MRawRunHeader::kRTCalibration:
116 *fLog << err << "Cannot work in a calibration Run!... aborting." << endl;
117 return kFALSE;
118
119 default:
120 *fLog << err << "Run Type " << fRunType << " unknown!... aborting." << endl;
121 return kFALSE;
122 }
123
124 return kTRUE;
125}
126
127// --------------------------------------------------------------------------
128//
129// Search for 'MPointingPos'. Create if not found.
130//
131Int_t MPointingPosCalcWA::PreProcess(MParList *plist)
132{
133 fPosition = (MPointingPos*)plist->FindCreateObj("MPointingPos");
134 return fPosition ? kTRUE : kFALSE;
135}
136
137// --------------------------------------------------------------------------
138//
139// See class description.
140//
141Int_t MPointingPosCalcWA::Process()
142{
143
144 const char plus = '+';
145 Char_t Rsgn;
146 UShort_t Rhour, Rmin, Rsec;
147 Double_t ra;
148
149 switch (fRunType)
150 {
151 case MRawRunHeader::kRTData:
152 if(!fReport)
153 {
154 MTime start = fRunHeader->GetRunStart();
155
156 MVector3 v;
157 v.SetRaDec(fRa,fDec);
158 v *= MAstroSky2Local(start,*fObs);
159 Double_t ZA = v.Theta()*180./acos(-1.);
160 Double_t Az = v.Phi()*180./acos(-1.);
161// cout << " Za = " << ZA << " v.Theta() " << v.Theta() << " Az " << Az << " v.Phi " << v.Phi() << endl;
162 fPosition->SetLocalPosition(ZA, Az);
163 MAstro::Rad2Hms(fRa, Rsgn, Rhour, Rmin, Rsec);
164 if (Rsgn==plus) ra = Rhour + Rmin/60. + Rsec/3600.;
165 else ra = - (Rhour + Rmin/60. + Rsec/3600.);
166 fPosition->SetSkyPosition(ra, TMath::RadToDeg()*fDec);
167 return kTRUE;
168 }
169 else
170 {
171 fPosition->SetLocalPosition(fReport->GetNominalZd(), fReport->GetNominalAz());
172 fPosition->SetSkyPosition(fReport->GetRa(), fReport->GetDec());
173 return kTRUE;
174 }
175
176 case MRawRunHeader::kRTMonteCarlo:
177 fPosition->SetLocalPosition(fMcEvt->GetTelescopeTheta()*TMath::RadToDeg(), fMcEvt->GetTelescopePhi()*TMath::RadToDeg());
178 return kTRUE;
179 }
180 return kTRUE;
181}
Note: See TracBrowser for help on using the repository browser.