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

Last change on this file since 4706 was 4706, checked in by wittek, 20 years ago
*** empty log message ***
File size: 4.6 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 return kTRUE;
118}
119
120Int_t MSourceDirections::AddDirection(Float_t ra, Float_t dec, Float_t mag, TString name)
121{
122 *fLog << "MSourceDirections::AddDirection; add the direction : ra, dec, mag, name = "
123 << ra << ", " << dec << ", " << mag << ", " << name << endl;
124
125 Int_t rc = fAstro.AddObject(ra,dec,1,name);
126
127 return rc;
128}
129
130Int_t MSourceDirections::Process()
131{
132 //First delete the previous directions in the list
133 fStars->GetList()->Delete();
134
135 fAstro.SetTime(*fTimeCurr);
136 fAstro.SetGuiActive();
137 fAstro.FillStarList(fStars->GetList());
138
139 MStarPos* starpos;
140 TIter Next(fStars->GetList());
141 while ((starpos=(MStarPos*)Next())) {
142 //starpos->SetCalcValues(40,40,starpos->GetXExp(),starpos->GetYExp(),
143 // 0.,0.,0., 0.,0.,0.);
144 //starpos->SetFitValues (40,40,starpos->GetXExp(),starpos->GetYExp(),
145 // 0.,0.,0., 0.,0.,0., 0., -1);
146 }
147
148 if (fStars->GetList()->GetSize() == 0) {
149 *fLog << err << GetName() << "No directions inside the chosen FOV." << endl;
150 } else {
151 *fLog << inf << GetName() << " found " << fStars->GetList()->GetSize()
152 << " directions inside the chosen FOV." << endl;
153 }
154 return kTRUE;
155}
156
157Int_t MSourceDirections::PostProcess()
158{
159 return kTRUE;
160}
161
Note: See TracBrowser for help on using the repository browser.