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 |
|
---|
61 | ClassImp(MSourceDirections);
|
---|
62 | using namespace std;
|
---|
63 |
|
---|
64 | MSourceDirections::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 |
|
---|
72 | Int_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 |
|
---|
120 | Int_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 | // if (rc) {
|
---|
127 | // MStarPos *starpos = new MStarPos;
|
---|
128 | // starpos->SetName(name);
|
---|
129 | // fStars->GetList()->Add(starpos);
|
---|
130 | // }
|
---|
131 | return rc;
|
---|
132 | }
|
---|
133 |
|
---|
134 | Int_t MSourceDirections::Process()
|
---|
135 | {
|
---|
136 | //First delete the previous directions in the list
|
---|
137 | fStars->GetList()->Delete();
|
---|
138 |
|
---|
139 | fAstro.SetTime(*fTimeCurr);
|
---|
140 | fAstro.SetGuiActive();
|
---|
141 | fAstro.FillStarList(fStars->GetList());
|
---|
142 |
|
---|
143 | MStarPos* starpos;
|
---|
144 | TIter Next(fStars->GetList());
|
---|
145 | while ((starpos=(MStarPos*)Next())) {
|
---|
146 | //starpos->SetCalcValues(40,40,starpos->GetXExp(),starpos->GetYExp(),
|
---|
147 | // 0.,0.,0., 0.,0.,0.);
|
---|
148 | //starpos->SetFitValues (40,40,starpos->GetXExp(),starpos->GetYExp(),
|
---|
149 | // 0.,0.,0., 0.,0.,0., 0., -1);
|
---|
150 | }
|
---|
151 |
|
---|
152 | if (fStars->GetList()->GetSize() == 0) {
|
---|
153 | *fLog << err << GetName() << "No directions inside the chosen FOV." << endl;
|
---|
154 | } else {
|
---|
155 | *fLog << inf << GetName() << " found " << fStars->GetList()->GetSize()
|
---|
156 | << " directions inside the chosen FOV." << endl;
|
---|
157 | }
|
---|
158 | return kTRUE;
|
---|
159 | }
|
---|
160 |
|
---|
161 | Int_t MSourceDirections::PostProcess()
|
---|
162 | {
|
---|
163 | return kTRUE;
|
---|
164 | }
|
---|
165 |
|
---|