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 express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Thomas Bretz, 05/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2005
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MHPointing
|
---|
28 | //
|
---|
29 | // Display drive information
|
---|
30 | //
|
---|
31 | // Class Version 2:
|
---|
32 | // ----------------
|
---|
33 | //
|
---|
34 | // + TGraph fNumStarsCor; // Number of correlated stars identified by starguider
|
---|
35 | //
|
---|
36 | ////////////////////////////////////////////////////////////////////////////
|
---|
37 | #include "MHPointing.h"
|
---|
38 |
|
---|
39 | #include <TPad.h>
|
---|
40 | #include <TCanvas.h>
|
---|
41 | #include <TGaxis.h>
|
---|
42 |
|
---|
43 | #include "MLog.h"
|
---|
44 | #include "MLogManip.h"
|
---|
45 |
|
---|
46 | #include "MParList.h"
|
---|
47 |
|
---|
48 | #include "MTime.h"
|
---|
49 | #include "MAstro.h"
|
---|
50 |
|
---|
51 | #include "MReportDrive.h"
|
---|
52 | #include "MReportStarguider.h"
|
---|
53 |
|
---|
54 | ClassImp(MHPointing);
|
---|
55 |
|
---|
56 | using namespace std;
|
---|
57 |
|
---|
58 | void MHPointing::ResetGraph(TGraph &g) const
|
---|
59 | {
|
---|
60 | g.Set(1);
|
---|
61 | g.SetPoint(0, 0, 0); // Dummy Point
|
---|
62 | g.SetEditable(); // Used as flag: First point? yes/no
|
---|
63 | }
|
---|
64 |
|
---|
65 | void MHPointing::InitGraph(TGraph &g) const
|
---|
66 | {
|
---|
67 | ResetGraph(g);
|
---|
68 | g.SetMarkerStyle(kFullDotMedium);
|
---|
69 | }
|
---|
70 |
|
---|
71 | void MHPointing::AddPoint(TGraph &g, Double_t x, Double_t y) const
|
---|
72 | {
|
---|
73 | if (g.IsEditable())
|
---|
74 | {
|
---|
75 | g.RemovePoint(0);
|
---|
76 | g.SetEditable(kFALSE);
|
---|
77 | }
|
---|
78 |
|
---|
79 | g.SetPoint(g.GetN(), x, y);
|
---|
80 | }
|
---|
81 |
|
---|
82 | // --------------------------------------------------------------------------
|
---|
83 | //
|
---|
84 | // Setup histograms
|
---|
85 | //
|
---|
86 | MHPointing::MHPointing(const char *name, const char *title)
|
---|
87 | : /*fTime(0),*/ fReportCosy(0), fReportSG(0)
|
---|
88 | {
|
---|
89 | fName = name ? name : "MHPointing";
|
---|
90 | fTitle = title ? title : "Graphs for rate data";
|
---|
91 |
|
---|
92 | // Init Graphs
|
---|
93 | fDevTimeSG.SetNameTitle("DevSG", "Absolute deviation of drive (black) and starguider (blue)");
|
---|
94 | fDevTimeCosy.SetNameTitle("DevCosy", "Cosy deviation");
|
---|
95 | fBrightness.SetNameTitle("Brightness", "Arbitrary Sky Brightness (black), No. of stars identified by starguider (blue)");
|
---|
96 | fNumStars.SetNameTitle("NumStars", "Number of stars identified by starguider");
|
---|
97 | fNumStarsCor.SetNameTitle("NumStarsCor", "Number of stars correlated by starguider");
|
---|
98 | fDevZd.SetNameTitle("DevZd", "Starguider deviation Zd (blue), Az (black)");
|
---|
99 | fDevAz.SetNameTitle("DevAz", "Starguider Deviation Az");
|
---|
100 | fPosZd.SetNameTitle("PosZd", "Nominal position Zd");
|
---|
101 | //fPosAz.SetNameTitle("PosZd", "Position Az");
|
---|
102 |
|
---|
103 | InitGraph(fDevTimeSG);
|
---|
104 | InitGraph(fDevTimeCosy);
|
---|
105 | InitGraph(fBrightness);
|
---|
106 | InitGraph(fNumStars);
|
---|
107 | InitGraph(fNumStarsCor);
|
---|
108 | InitGraph(fDevZd);
|
---|
109 | InitGraph(fDevAz);
|
---|
110 | InitGraph(fPosZd);
|
---|
111 | //InitGraph(fPosAz);
|
---|
112 |
|
---|
113 | fDevTimeSG.SetMarkerColor(kBlue);
|
---|
114 | fDevZd.SetMarkerColor(kBlue);
|
---|
115 | fNumStars.SetMarkerColor(kBlue);
|
---|
116 | fNumStarsCor.SetMarkerColor(kMagenta);
|
---|
117 | //fPosAz.SetMarkerColor(kBlue);
|
---|
118 | }
|
---|
119 |
|
---|
120 | // --------------------------------------------------------------------------
|
---|
121 | //
|
---|
122 | // Setup the Binning for the histograms automatically if the correct
|
---|
123 | // instances of MBinning
|
---|
124 | //
|
---|
125 | Bool_t MHPointing::SetupFill(const MParList *plist)
|
---|
126 | {
|
---|
127 | //fTime = (MTime*)plist->FindObject("MTime");
|
---|
128 | //if (!fTime)
|
---|
129 | //{
|
---|
130 | // *fLog << warn << "MTime not found... abort." << endl;
|
---|
131 | // return kFALSE;
|
---|
132 | //}
|
---|
133 | fReportSG = (MReportStarguider*)plist->FindObject("MReportStarguider");
|
---|
134 | if (!fReportSG)
|
---|
135 | *fLog << warn << "MReportStarguider not found..." << endl;
|
---|
136 |
|
---|
137 | fReportCosy = (MReportDrive*)plist->FindObject("MReportDrive");
|
---|
138 | if (!fReportCosy)
|
---|
139 | *fLog << warn << "MReportDrive not found..." << endl;
|
---|
140 |
|
---|
141 | // Reset Graphs
|
---|
142 | ResetGraph(fDevTimeSG);
|
---|
143 | ResetGraph(fDevTimeCosy);
|
---|
144 |
|
---|
145 | return kTRUE;
|
---|
146 | }
|
---|
147 |
|
---|
148 | // --------------------------------------------------------------------------
|
---|
149 | //
|
---|
150 | // Fill the histograms with data from a MMuonCalibPar and
|
---|
151 | // MMuonSearchPar container.
|
---|
152 | //
|
---|
153 | Bool_t MHPointing::Fill(const MParContainer *par, const Stat_t w)
|
---|
154 | {
|
---|
155 | const MTime *t = dynamic_cast<const MTime*>(par);
|
---|
156 | if (!t)
|
---|
157 | {
|
---|
158 | *fLog << err <<"MHPointing::Fill - ERROR: MTime not given as argument... abort." << endl;
|
---|
159 | return kERROR;
|
---|
160 | }
|
---|
161 |
|
---|
162 | const Double_t tm = t->GetAxisTime();
|
---|
163 |
|
---|
164 | if (t->GetName()==(TString)"MTimeStarguider")
|
---|
165 | {
|
---|
166 | if (!fReportSG)
|
---|
167 | {
|
---|
168 | *fLog << err << "ERROR: fReportSG==NULL... abort." << endl;
|
---|
169 | return kFALSE;
|
---|
170 | }
|
---|
171 |
|
---|
172 | // Check for old files
|
---|
173 | if (fReportSG->GetSkyBrightness()>0)
|
---|
174 | {
|
---|
175 | AddPoint(fBrightness, tm, fReportSG->GetSkyBrightness());
|
---|
176 | AddPoint(fNumStars, tm, fReportSG->GetNumIdentifiedStars());
|
---|
177 | AddPoint(fNumStarsCor, tm, fReportSG->GetNumCorrelatedStars());
|
---|
178 | }
|
---|
179 |
|
---|
180 | const Bool_t zdok = TMath::Abs(fReportSG->GetDevZd())<30;
|
---|
181 | const Bool_t azok = TMath::Abs(fReportSG->GetDevAz())<90;
|
---|
182 |
|
---|
183 | const Double_t devzd = fReportSG->GetDevZd();
|
---|
184 | const Double_t devaz = fReportSG->GetDevAz();
|
---|
185 |
|
---|
186 | if (zdok && azok)
|
---|
187 | AddPoint(fDevTimeSG, tm, fReportSG->GetDevAbs());
|
---|
188 | if (zdok)
|
---|
189 | AddPoint(fDevZd, tm, devzd);
|
---|
190 | if (azok)
|
---|
191 | AddPoint(fDevAz, tm, devaz);
|
---|
192 | return kTRUE;
|
---|
193 | }
|
---|
194 |
|
---|
195 | if (fReportCosy && t->GetName()==(TString)"MTimeDrive")
|
---|
196 | {
|
---|
197 | if (!fReportCosy)
|
---|
198 | {
|
---|
199 | *fLog << err << "ERROR: fReportCosy==NULL... abort." << endl;
|
---|
200 | return kFALSE;
|
---|
201 | }
|
---|
202 |
|
---|
203 | AddPoint(fDevTimeCosy, tm, fReportCosy->GetAbsError()*60);
|
---|
204 | if (fPosZd.GetY()[fPosZd.GetN()-1] != fReportCosy->GetNominalZd())
|
---|
205 | AddPoint(fPosZd, tm, fReportCosy->GetNominalZd());
|
---|
206 | //if (fPosAz.GetY()[fPosAz.GetN()-1] != fReportCosy->GetNominalAz())
|
---|
207 | // AddPoint(fPosAz, tm, fReportCosy->GetNominalAz());
|
---|
208 | return kTRUE;
|
---|
209 | }
|
---|
210 |
|
---|
211 | return kTRUE;
|
---|
212 | }
|
---|
213 |
|
---|
214 | void MHPointing::DrawGraph(TGraph &g, const char *y) const
|
---|
215 | {
|
---|
216 | TH1 *h = g.GetHistogram();
|
---|
217 | if (h)
|
---|
218 | {
|
---|
219 | TAxis *axe = h->GetXaxis();
|
---|
220 | axe->SetLabelSize(0.033);
|
---|
221 | axe->SetTimeFormat("%H:%M %F1995-01-01 00:00:00 GMT");
|
---|
222 | axe->SetTimeDisplay(1);
|
---|
223 | axe->SetTitle("Time");
|
---|
224 | if (y)
|
---|
225 | h->SetYTitle(y);
|
---|
226 | }
|
---|
227 | }
|
---|
228 |
|
---|
229 | // --------------------------------------------------------------------------
|
---|
230 | //
|
---|
231 | // Update position of an axis on the right side of the histogram
|
---|
232 | //
|
---|
233 | void MHPointing::UpdateRightAxis(TGraph &g1, TGraph &g2) const
|
---|
234 | {
|
---|
235 | TH1 &h1 = *g1.GetHistogram();
|
---|
236 | TH1 &h2 = *g2.GetHistogram();
|
---|
237 |
|
---|
238 | const Double_t max = TMath::Max(h1.GetMaximum(), h2.GetMaximum());
|
---|
239 | if (max==0)
|
---|
240 | return;
|
---|
241 |
|
---|
242 | TGaxis *axis = (TGaxis*)gPad->FindObject("RightAxis");
|
---|
243 | if (!axis)
|
---|
244 | return;
|
---|
245 |
|
---|
246 | axis->SetX1(g1.GetXaxis()->GetXmax());
|
---|
247 | axis->SetX2(g1.GetXaxis()->GetXmax());
|
---|
248 | axis->SetY1(gPad->GetUymin());
|
---|
249 | axis->SetY2(gPad->GetUymax());
|
---|
250 | axis->SetWmax(max);
|
---|
251 | }
|
---|
252 |
|
---|
253 | // --------------------------------------------------------------------------
|
---|
254 | //
|
---|
255 | // Draw an axis on the right side of the histogram
|
---|
256 | //
|
---|
257 |
|
---|
258 | void MHPointing::DrawRightAxis(const char *title) const
|
---|
259 | {
|
---|
260 | TGaxis *axis = new TGaxis(gPad->GetUxmax(), gPad->GetUymin(),
|
---|
261 | gPad->GetUxmax(), gPad->GetUymax(),
|
---|
262 | 0, 1, 510, "+L");
|
---|
263 | axis->SetName("RightAxis");
|
---|
264 | axis->SetTitle(title);
|
---|
265 | axis->SetTitleOffset(0.9);
|
---|
266 | axis->SetTextColor(kBlue);
|
---|
267 | axis->SetBit(kCanDelete);
|
---|
268 | axis->Draw();
|
---|
269 | }
|
---|
270 |
|
---|
271 | // --------------------------------------------------------------------------
|
---|
272 | //
|
---|
273 | // This displays the TGraph like you expect it to be (eg. time on the axis)
|
---|
274 | // It should also make sure, that the displayed time always is UTC and
|
---|
275 | // not local time...
|
---|
276 | //
|
---|
277 | void MHPointing::Draw(Option_t *opt)
|
---|
278 | {
|
---|
279 | TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
|
---|
280 | pad->SetBorderMode(0);
|
---|
281 |
|
---|
282 | AppendPad();
|
---|
283 |
|
---|
284 | pad->Divide(2,2);
|
---|
285 |
|
---|
286 | pad->cd(1);
|
---|
287 | gPad->SetBorderMode(0);
|
---|
288 | gPad->SetGridx();
|
---|
289 | gPad->SetGridy();
|
---|
290 | fDevTimeSG.Draw("AP");
|
---|
291 | fDevTimeCosy.Draw("P");
|
---|
292 |
|
---|
293 | pad->cd(2);
|
---|
294 | gPad->SetBorderMode(0);
|
---|
295 | gPad->SetGridx();
|
---|
296 | gPad->SetGridy();
|
---|
297 | fBrightness.Draw("AP");
|
---|
298 | fNumStars.Draw("P");
|
---|
299 | fNumStarsCor.Draw("P");
|
---|
300 | DrawRightAxis("N");
|
---|
301 |
|
---|
302 | pad->cd(3);
|
---|
303 | gPad->SetBorderMode(0);
|
---|
304 | gPad->SetGridx();
|
---|
305 | gPad->SetGridy();
|
---|
306 | fDevZd.Draw("AP");
|
---|
307 | fDevAz.Draw("P");
|
---|
308 |
|
---|
309 | pad->cd(4);
|
---|
310 | gPad->SetBorderMode(0);
|
---|
311 | gPad->SetGridx();
|
---|
312 | gPad->SetGridy();
|
---|
313 | fPosZd.Draw("AP");
|
---|
314 | //fPosAz.Draw("P");
|
---|
315 | //DrawRightAxis("Az [\\circ]");
|
---|
316 | }
|
---|
317 |
|
---|
318 | void MHPointing::Paint(Option_t *o)
|
---|
319 | {
|
---|
320 | // If this is set to early the plot remains empty in root 5.12/00
|
---|
321 | if (fDevTimeSG.GetN()>0)
|
---|
322 | fDevTimeSG.SetMinimum(0);
|
---|
323 | if (fDevTimeCosy.GetN()>0)
|
---|
324 | fDevTimeCosy.SetMinimum(0);
|
---|
325 | if (fBrightness.GetN()>0)
|
---|
326 | fBrightness.SetMinimum(0);
|
---|
327 | if (fNumStars.GetN()>0)
|
---|
328 | fNumStars.SetMinimum(0);
|
---|
329 | if (fNumStarsCor.GetN()>0)
|
---|
330 | fNumStarsCor.SetMinimum(0);
|
---|
331 |
|
---|
332 | DrawGraph(fDevTimeSG, "\\Delta [arcmin]");
|
---|
333 | DrawGraph(fDevTimeCosy, "\\Delta [arcmin]");
|
---|
334 | DrawGraph(fBrightness, "Brightness [au]");
|
---|
335 | DrawGraph(fNumStars, "N");
|
---|
336 | DrawGraph(fDevZd, "\\Delta [arcmin]");
|
---|
337 | DrawGraph(fDevAz, "\\Delta [arcmin]");
|
---|
338 | DrawGraph(fPosZd, "Zd [\\circ]");
|
---|
339 | //DrawGraph(fPosAz, "Az [\\circ]");
|
---|
340 |
|
---|
341 | TVirtualPad *pad = gPad;
|
---|
342 |
|
---|
343 | pad->cd(2);
|
---|
344 | if (gPad)
|
---|
345 | {
|
---|
346 | fNumStars.GetHistogram()->GetYaxis()->SetTitleColor(kBlue);
|
---|
347 | UpdateRightAxis(fNumStars, fNumStarsCor);
|
---|
348 | }
|
---|
349 | /*
|
---|
350 | pad->cd(4);
|
---|
351 | if (gPad)
|
---|
352 | {
|
---|
353 | fPosAz.GetHistogram()->GetYaxis()->SetTitleColor(kBlue);
|
---|
354 | UpdateRightAxis(fPosAz);
|
---|
355 | }*/
|
---|
356 | }
|
---|