source: trunk/MagicSoft/Mars/mtemp/MSourceDirections.cc@ 6068

Last change on this file since 6068 was 4797, checked in by wittek, 20 years ago
*** empty log message ***
File size: 5.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 expressed
14! * or implied warranty.
15! *
16!
17! Author(s): Robert Wagner, 8/2004 <mailto:rwagner@mppmu.mpg.de>
18!
19! Copyright: MAGIC Software Development, 2000-2004
20!
21!
22\* ======================================================================== */
23
24/////////////////////////////////////////////////////////////////////////////
25//
26// MSourceDirections
27//
28/////////////////////////////////////////////////////////////////////////////
29#include "MSourceDirections.h"
30
31#include <TTimer.h>
32#include <TString.h>
33#include <TFile.h>
34#include <TTree.h>
35#include <TCanvas.h>
36#include <TH1F.h>
37#include <TF1.h>
38#include <TEllipse.h>
39
40
41#include "MObservatory.h"
42#include "MAstroCamera.h"
43#include "MMcConfigRunHeader.h"
44
45#include "MLog.h"
46#include "MLogManip.h"
47
48#include "MHCamera.h"
49
50#include "MGeomCam.h"
51#include "MGeomPix.h"
52#include "MCameraDC.h"
53#include "MTime.h"
54#include "MReportDrive.h"
55#include "MStarCam.h"
56#include "MStarPos.h"
57
58#include "MParList.h"
59#include "MTaskList.h"
60
61ClassImp(MSourceDirections);
62using namespace std;
63
64MSourceDirections::MSourceDirections(const char *name, const char *title):
65 fGeomCam(NULL), fTimeCurr(NULL), fDrive(NULL), fStars(NULL)
66{
67 fName = name ? name : "MSourceDirections";
68 fTitle = title ? title : "Convert Ra-Dec source positions into camera coordinates";
69 fGeometryFile="";
70}
71
72Int_t MSourceDirections::PreProcess(MParList *pList)
73{
74 fGeomCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
75 if (!fGeomCam) {
76 *fLog << err << AddSerialNumber("MGeomCam") << " not found ... aborting" << endl;
77 return kFALSE;
78 }
79
80 fTimeCurr = (MTime*)pList->FindObject(AddSerialNumber("MTimeCurrents"));
81 if (!fTimeCurr) {
82 *fLog << err << AddSerialNumber("MTimeCurrents") << " not found ... aborting" << endl;
83 return kFALSE;
84 }
85
86 fDrive = (MReportDrive*)pList->FindObject(AddSerialNumber("MReportDrive"));
87 if (!fDrive) {
88 *fLog << warn << AddSerialNumber("MReportDrive") << " not found ... aborting" << endl;
89 return kFALSE;
90 }
91
92
93 fStars = (MStarCam*)pList->FindCreateObj(AddSerialNumber("MStarCam"),"MSourceCam");
94 if (!fStars) {
95 *fLog << err << AddSerialNumber("MStarCam") << " with name '"
96 << "MSourceCam" << " cannot be created ... aborting" << endl;
97 return kFALSE;
98 }
99
100
101
102 MObservatory magic1;
103
104 MMcConfigRunHeader *config=0;
105 MGeomCam *geom=0;
106
107 TFile file(fGeometryFile);
108 TTree *tree = (TTree*)file.Get("RunHeaders");
109 tree->SetBranchAddress("MMcConfigRunHeader", &config);
110 if (tree->GetBranch("MGeomCam")) tree->SetBranchAddress("MGeomCam", &geom);
111 tree->GetEntry(0);
112
113 fAstro.SetMirrors(*config->GetMirrors());
114 fAstro.SetGeom(*geom);
115 fAstro.SetObservatory(magic1);
116
117
118 // make the starlist available already in the preprocessing
119 fStars->GetList()->Delete();
120 fAstro.SetTime(*fTimeCurr);
121 fAstro.SetGuiActive();
122 fAstro.FillStarList(fStars->GetList());
123 //*fLog << inf << "in preprocessing " << GetName() << " found "
124 // << fStars->GetList()->GetSize()
125 // << " directions inside the chosen FOV." << endl;
126
127
128 return kTRUE;
129}
130
131Int_t MSourceDirections::AddDirection(Float_t ra, Float_t dec, Float_t mag, TString name)
132{
133 *fLog << "MSourceDirections::AddDirection; add the direction : ra, dec, mag, name = "
134 << ra << ", " << dec << ", " << mag << ", " << name << endl;
135
136 Int_t rc = fAstro.AddObject(ra,dec,1,name);
137// if (rc) {
138// MStarPos *starpos = new MStarPos;
139// starpos->SetName(name);
140// fStars->GetList()->Add(starpos);
141// }
142 return rc;
143}
144
145Int_t MSourceDirections::Process()
146{
147 //First delete the previous directions in the list
148 fStars->GetList()->Delete();
149
150 fAstro.SetTime(*fTimeCurr);
151 fAstro.SetGuiActive();
152 fAstro.FillStarList(fStars->GetList());
153
154 MStarPos* starpos;
155 TIter Next(fStars->GetList());
156 while ((starpos=(MStarPos*)Next())) {
157 //starpos->SetCalcValues(40,40,starpos->GetXExp(),starpos->GetYExp(),
158 // 0.,0.,0., 0.,0.,0.);
159 //starpos->SetFitValues (40,40,starpos->GetXExp(),starpos->GetYExp(),
160 // 0.,0.,0., 0.,0.,0., 0., -1);
161 }
162
163 if (fStars->GetList()->GetSize() == 0) {
164 *fLog << err << GetName() << "No directions inside the chosen FOV." << endl;
165 } else {
166 //*fLog << inf << GetName() << " found " << fStars->GetList()->GetSize()
167 // << " directions inside the chosen FOV." << endl;
168 }
169 return kTRUE;
170}
171
172Int_t MSourceDirections::PostProcess()
173{
174 return kTRUE;
175}
176
177
178
179
180
181
182
183
184
185
186
187
188
Note: See TracBrowser for help on using the repository browser.