source: tags/Mars-V0.9/mpointing/MPointingPosCalc.cc

Last change on this file was 5583, checked in by MAGIC, 20 years ago
*** empty log message ***
File size: 4.5 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 "MPointingPosCalc.h"
49
50#include "MLog.h"
51#include "MLogManip.h"
52
53#include "MParList.h"
54
55#include "MPointingPos.h"
56#include "MRawRunHeader.h"
57#include "MReportDrive.h"
58#include "MMcEvt.hxx"
59
60ClassImp(MPointingPosCalc);
61
62using namespace std;
63
64// --------------------------------------------------------------------------
65//
66// Search for MRawRunHeader. Get the run type from there. Depending on
67// the run type search either for MMcEvt or MReportDrive.
68//
69Bool_t MPointingPosCalc::ReInit(MParList *plist)
70{
71 MRawRunHeader *run = (MRawRunHeader*)plist->FindObject("MRawRunHeader");
72 if (!run)
73 {
74 *fLog << err << "MRawRunHeader not found... aborting." << endl;
75 return kFALSE;
76 }
77
78 fRunType = run->GetRunType();
79
80 switch (fRunType)
81 {
82 case MRawRunHeader::kRTData:
83 fReport = (MReportDrive*)plist->FindObject("MReportDrive");
84 if (!fReport)
85 {
86 *fLog << err << "MReportDrive not found... aborting." << endl;
87 return kFALSE;
88 }
89 return kTRUE;
90
91 case MRawRunHeader::kRTMonteCarlo:
92 fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
93 if (!fMcEvt)
94 {
95 *fLog << err << "MMcEvt not found... aborting." << endl;
96 return kFALSE;
97 }
98 return kTRUE;
99
100 case MRawRunHeader::kRTPedestal:
101 *fLog << err << "Cannot work in a pedestal Run!... aborting." << endl;
102 return kFALSE;
103
104 case MRawRunHeader::kRTCalibration:
105 *fLog << err << "Cannot work in a calibration Run!... aborting." << endl;
106 return kFALSE;
107
108 default:
109 *fLog << err << "Run Type " << fRunType << " unknown!... aborting." << endl;
110 return kFALSE;
111 }
112
113 return kTRUE;
114}
115
116// --------------------------------------------------------------------------
117//
118// Search for 'MPointingPos'. Create if not found.
119//
120Int_t MPointingPosCalc::PreProcess(MParList *plist)
121{
122 fPosition = (MPointingPos*)plist->FindCreateObj("MPointingPos");
123 return fPosition ? kTRUE : kFALSE;
124}
125
126// --------------------------------------------------------------------------
127//
128// See class description.
129//
130Int_t MPointingPosCalc::Process()
131{
132 if (!fReport && fRunType == MRawRunHeader::kRTData)
133 {
134 *fLog << warn << "WARNING - MPointingPosCalc::Process was called BEFORE the first" << endl;
135 *fLog << " data event was read (means ReInit was executed!" << endl;
136 return kTRUE;
137 }
138
139 switch (fRunType)
140 {
141 case MRawRunHeader::kRTData:
142 fPosition->SetLocalPosition(fReport->GetNominalZd(), fReport->GetNominalAz());
143 fPosition->SetSkyPosition(fReport->GetRa(), fReport->GetDec());
144 return kTRUE;
145
146 case MRawRunHeader::kRTMonteCarlo:
147 fPosition->SetLocalPosition(fMcEvt->GetTelescopeTheta()*TMath::RadToDeg(), fMcEvt->GetTelescopePhi()*TMath::RadToDeg());
148 return kTRUE;
149 }
150 return kTRUE;
151}
Note: See TracBrowser for help on using the repository browser.