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

Last change on this file since 4698 was 4697, checked in by rwagner, 20 years ago
*** empty log message ***
File size: 4.4 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 fStars = (MStarCam*)pList->FindCreateObj(AddSerialNumber("MStarCam"),"MSourceCam");
93 if (!fStars) {
94 *fLog << err << AddSerialNumber("MStarCam") << " cannot be created ... aborting" << endl;
95 return kFALSE;
96 }
97
98 MObservatory magic1;
99
100 MMcConfigRunHeader *config=0;
101 MGeomCam *geom=0;
102
103 TFile file(fGeometryFile);
104 TTree *tree = (TTree*)file.Get("RunHeaders");
105 tree->SetBranchAddress("MMcConfigRunHeader", &config);
106 if (tree->GetBranch("MGeomCam")) tree->SetBranchAddress("MGeomCam", &geom);
107 tree->GetEntry(0);
108
109 fAstro.SetMirrors(*config->GetMirrors());
110 fAstro.SetGeom(*geom);
111 fAstro.SetObservatory(magic1);
112
113 return kTRUE;
114}
115
116Int_t MSourceDirections::AddDirection(Float_t ra, Float_t dec, Float_t mag, TString name)
117{
118 Int_t rc = fAstro.AddObject(ra,dec,1,name);
119 if (rc) {
120 MStarPos *starpos = new MStarPos;
121 starpos->SetName(name);
122 fStars->GetList()->Add(starpos);
123 }
124 return rc;
125}
126
127Int_t MSourceDirections::Process()
128{
129 //Fist delete the previous directions in the list
130 fStars->GetList()->Delete();
131
132 fAstro.SetTime(*fTimeCurr);
133 fAstro.SetGuiActive();
134 fAstro.FillStarList(fStars->GetList());
135
136 MStarPos* starpos;
137 TIter Next(fStars->GetList());
138 while ((starpos=(MStarPos*)Next())) {
139 starpos->SetCalcValues(40,40,starpos->GetXExp(),starpos->GetYExp(),0.,0.);
140 starpos->SetFitValues (40,40,starpos->GetXExp(),starpos->GetYExp(),0.,0.,0.,1);
141 }
142
143 if (fStars->GetList()->GetSize() == 0) {
144 *fLog << err << GetName() << "No directions inside the chosen FOV." << endl;
145 } else {
146 *fLog << inf << GetName() << " found " << fStars->GetList()->GetSize()
147 << " directions inside the chosen FOV." << endl;
148 }
149 return kTRUE;
150}
151
152Int_t MSourceDirections::PostProcess()
153{
154 return kTRUE;
155}
Note: See TracBrowser for help on using the repository browser.