source: trunk/MagicSoft/Mars/mtemp/mpisa/classes/mispointing/MSourceDirections.cc@ 5138

Last change on this file since 5138 was 5120, checked in by stamerra, 20 years ago
*** empty log message ***
File size: 5.2 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 TTree *tree = dynamic_cast<TTree*>(file.Get("RunHeaders"));
110 tree->SetBranchAddress("MMcConfigRunHeader.", &config);
111 if (tree->GetBranch("MGeomCam.")) tree->SetBranchAddress("MGeomCam.", &geom);
112 tree->GetEntry(0);
113
114 fAstro.SetMirrors(*config->GetMirrors());
115 fAstro.SetGeom(*geom);
116 fAstro.SetObservatory(magic1);
117
118
119 // make the starlist available already in the preprocessing
120 fStars->GetList()->Delete();
121 fAstro.SetTime(*fTimeCurr);
122 fAstro.SetGuiActive();
123 fAstro.FillStarList(fStars->GetList());
124 //*fLog << inf << "in preprocessing " << GetName() << " found "
125 // << fStars->GetList()->GetSize()
126 // << " directions inside the chosen FOV." << endl;
127
128
129 return kTRUE;
130}
131
132Int_t MSourceDirections::AddDirection(Float_t ra, Float_t dec, Float_t mag, TString name)
133{
134 *fLog << "MSourceDirections::AddDirection; add the direction : ra, dec, mag, name = "
135 << ra << ", " << dec << ", " << mag << ", " << name << endl;
136
137 Int_t rc = fAstro.AddObject(ra,dec,1,name);
138// if (rc) {
139// MStarPos *starpos = new MStarPos;
140// starpos->SetName(name);
141// fStars->GetList()->Add(starpos);
142// }
143 return rc;
144}
145
146Int_t MSourceDirections::Process()
147{
148 //First delete the previous directions in the list
149 fStars->GetList()->Delete();
150
151 fAstro.SetTime(*fTimeCurr);
152 fAstro.SetGuiActive();
153 fAstro.FillStarList(fStars->GetList());
154
155 MStarPos* starpos;
156 TIter Next(fStars->GetList());
157 while ((starpos=(MStarPos*)Next())) {
158 //starpos->SetCalcValues(40,40,starpos->GetXExp(),starpos->GetYExp(),
159 // 0.,0.,0., 0.,0.,0.);
160 //starpos->SetFitValues (40,40,starpos->GetXExp(),starpos->GetYExp(),
161 // 0.,0.,0., 0.,0.,0., 0., -1);
162 }
163
164 if (fStars->GetList()->GetSize() == 0) {
165 *fLog << err << GetName() << "No directions inside the chosen FOV." << endl;
166 }
167 else {
168 *fLog << inf << GetName() << " found " << fStars->GetList()->GetSize()
169 << " directions inside the chosen FOV." << endl;
170 }
171 return kTRUE;
172}
173
174Int_t MSourceDirections::PostProcess()
175{
176 return kTRUE;
177}
178
179
180
181
182
183
184
185
186
187
188
189
190
Note: See TracBrowser for help on using the repository browser.