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 | ////////////////////////////////////////////////////////////////////////////
|
---|
32 | #include "MHPointing.h"
|
---|
33 |
|
---|
34 | #include <TPad.h>
|
---|
35 | #include <TCanvas.h>
|
---|
36 | #include <TGaxis.h>
|
---|
37 |
|
---|
38 | #include "MLog.h"
|
---|
39 | #include "MLogManip.h"
|
---|
40 |
|
---|
41 | #include "MParList.h"
|
---|
42 |
|
---|
43 | #include "MTime.h"
|
---|
44 |
|
---|
45 | #include "MReportDrive.h"
|
---|
46 | #include "MReportStarguider.h"
|
---|
47 |
|
---|
48 | ClassImp(MHPointing);
|
---|
49 |
|
---|
50 | using namespace std;
|
---|
51 |
|
---|
52 | void MHPointing::ResetGraph(TGraph &g) const
|
---|
53 | {
|
---|
54 | g.Set(1);
|
---|
55 | g.SetPoint(0, 0, 0); // Dummy Point
|
---|
56 | g.SetEditable(); // Used as flag: First point? yes/no
|
---|
57 | }
|
---|
58 |
|
---|
59 | void MHPointing::InitGraph(TGraph &g) const
|
---|
60 | {
|
---|
61 | ResetGraph(g);
|
---|
62 | g.SetMarkerStyle(kFullDotMedium);
|
---|
63 | }
|
---|
64 |
|
---|
65 | void MHPointing::AddPoint(TGraph &g, Double_t x, Double_t y) const
|
---|
66 | {
|
---|
67 | if (g.IsEditable())
|
---|
68 | {
|
---|
69 | g.RemovePoint(0);
|
---|
70 | g.SetEditable(kFALSE);
|
---|
71 | }
|
---|
72 |
|
---|
73 | g.SetPoint(g.GetN(), x, y);
|
---|
74 | }
|
---|
75 |
|
---|
76 | // --------------------------------------------------------------------------
|
---|
77 | //
|
---|
78 | // Setup histograms
|
---|
79 | //
|
---|
80 | MHPointing::MHPointing(const char *name, const char *title)
|
---|
81 | : /*fTime(0),*/ fReportCosy(0), fReportSG(0)
|
---|
82 | {
|
---|
83 | fName = name ? name : "MHPointing";
|
---|
84 | fTitle = title ? title : "Graphs for rate data";
|
---|
85 |
|
---|
86 | // Init Graphs
|
---|
87 | fDevTimeSG.SetNameTitle("DevSG", "Drive (black) and starguider (blue) deviation");
|
---|
88 | fDevTimeCosy.SetNameTitle("DevCosy", "Cosy deviation");
|
---|
89 | fBrightness.SetNameTitle("Brigtness", "Arbitrary Sky Brightness");
|
---|
90 | fNumStars.SetNameTitle("NumStars", "Number of stars identified by starguider");
|
---|
91 | fDevZd.SetNameTitle("DevZd", "Starguider Deviation Zd (blue), Az(black)");
|
---|
92 | fDevAz.SetNameTitle("DevAz", "Starguider Deviation Az");
|
---|
93 |
|
---|
94 | InitGraph(fDevTimeSG);
|
---|
95 | InitGraph(fDevTimeCosy);
|
---|
96 | InitGraph(fBrightness);
|
---|
97 | InitGraph(fNumStars);
|
---|
98 | InitGraph(fDevZd);
|
---|
99 | InitGraph(fDevAz);
|
---|
100 |
|
---|
101 | fDevTimeSG.SetMinimum(0);
|
---|
102 | fDevTimeCosy.SetMinimum(0);
|
---|
103 | fBrightness.SetMinimum(0);
|
---|
104 | fNumStars.SetMinimum(0);
|
---|
105 |
|
---|
106 | fDevTimeSG.SetMarkerColor(kBlue);
|
---|
107 | fDevZd.SetMarkerColor(kBlue);
|
---|
108 | }
|
---|
109 |
|
---|
110 | // --------------------------------------------------------------------------
|
---|
111 | //
|
---|
112 | // Setup the Binning for the histograms automatically if the correct
|
---|
113 | // instances of MBinning
|
---|
114 | //
|
---|
115 | Bool_t MHPointing::SetupFill(const MParList *plist)
|
---|
116 | {
|
---|
117 | //fTime = (MTime*)plist->FindObject("MTime");
|
---|
118 | //if (!fTime)
|
---|
119 | //{
|
---|
120 | // *fLog << warn << "MTime not found... abort." << endl;
|
---|
121 | // return kFALSE;
|
---|
122 | //}
|
---|
123 | fReportSG = (MReportStarguider*)plist->FindObject("MReportStarguider");
|
---|
124 | if (!fReportSG)
|
---|
125 | {
|
---|
126 | *fLog << warn << "MReportStarguider not found... abort." << endl;
|
---|
127 | return kFALSE;
|
---|
128 | }
|
---|
129 | fReportCosy = (MReportDrive*)plist->FindObject("MReportDrive");
|
---|
130 | if (!fReportCosy)
|
---|
131 | {
|
---|
132 | *fLog << warn << "MReportDrive not found... abort." << endl;
|
---|
133 | return kFALSE;
|
---|
134 | }
|
---|
135 |
|
---|
136 | // Reset Graphs
|
---|
137 | ResetGraph(fDevTimeSG);
|
---|
138 | ResetGraph(fDevTimeCosy);
|
---|
139 |
|
---|
140 | return kTRUE;
|
---|
141 | }
|
---|
142 |
|
---|
143 | // --------------------------------------------------------------------------
|
---|
144 | //
|
---|
145 | // Fill the histograms with data from a MMuonCalibPar and
|
---|
146 | // MMuonSearchPar container.
|
---|
147 | //
|
---|
148 | Bool_t MHPointing::Fill(const MParContainer *par, const Stat_t w)
|
---|
149 | {
|
---|
150 | const MTime *t = dynamic_cast<const MTime*>(par);
|
---|
151 | if (!t)
|
---|
152 | {
|
---|
153 | *fLog << err <<"MHPointing::Fill - ERROR: MTime not given as argument... abort." << endl;
|
---|
154 | return kERROR;
|
---|
155 | }
|
---|
156 |
|
---|
157 | const Double_t tm = t->GetAxisTime();
|
---|
158 |
|
---|
159 | if (t->GetName()==(TString)"MTimeStarguider")
|
---|
160 | {
|
---|
161 | AddPoint(fDevTimeSG, tm, fReportSG->GetDevAbs());
|
---|
162 | AddPoint(fBrightness, tm, fReportSG->GetSkyBrightness());
|
---|
163 | AddPoint(fNumStars, tm, fReportSG->GetNumIdentifiedStars());
|
---|
164 | AddPoint(fDevZd, tm, fReportSG->GetDevZd());
|
---|
165 | AddPoint(fDevAz, tm, fReportSG->GetDevAz());
|
---|
166 | return kTRUE;
|
---|
167 | }
|
---|
168 |
|
---|
169 | if (t->GetName()==(TString)"MTimeDrive")
|
---|
170 | {
|
---|
171 | AddPoint(fDevTimeCosy, tm, fReportCosy->GetAbsError()*60);
|
---|
172 | return kTRUE;
|
---|
173 | }
|
---|
174 |
|
---|
175 | return kTRUE;
|
---|
176 | }
|
---|
177 |
|
---|
178 | void MHPointing::DrawGraph(TGraph &g, const char *y) const
|
---|
179 | {
|
---|
180 | TH1 *h = g.GetHistogram();
|
---|
181 | if (h)
|
---|
182 | {
|
---|
183 | TAxis *axe = h->GetXaxis();
|
---|
184 | axe->SetLabelSize(0.033);
|
---|
185 | axe->SetTimeFormat("%H:%M:%S %F1995-01-01 00:00:00 GMT");
|
---|
186 | axe->SetTimeDisplay(1);
|
---|
187 | axe->SetTitle("Time");
|
---|
188 | if (y)
|
---|
189 | h->SetYTitle(y);
|
---|
190 | }
|
---|
191 | }
|
---|
192 | /*
|
---|
193 | // --------------------------------------------------------------------------
|
---|
194 | //
|
---|
195 | // Update position of an axis on the right side of the histogram
|
---|
196 | //
|
---|
197 | void MHPointing::UpdateRightAxis(TGraph &g) const
|
---|
198 | {
|
---|
199 | TH1 &h = *g.GetHistogram();
|
---|
200 |
|
---|
201 | const Double_t max = h.GetMaximum();
|
---|
202 | if (max==0)
|
---|
203 | return;
|
---|
204 |
|
---|
205 | TGaxis *axis = (TGaxis*)gPad->FindObject("RightAxis");
|
---|
206 | if (!axis)
|
---|
207 | return;
|
---|
208 |
|
---|
209 | axis->SetX1(g.GetXaxis()->GetXmax());
|
---|
210 | axis->SetX2(g.GetXaxis()->GetXmax());
|
---|
211 | axis->SetY1(gPad->GetUymin());
|
---|
212 | axis->SetY2(gPad->GetUymax());
|
---|
213 | axis->SetWmax(max);
|
---|
214 | }
|
---|
215 |
|
---|
216 | // --------------------------------------------------------------------------
|
---|
217 | //
|
---|
218 | // Draw an axis on the right side of the histogram
|
---|
219 | //
|
---|
220 |
|
---|
221 | void MHPointing::DrawRightAxis(const char *title) const
|
---|
222 | {
|
---|
223 | TGaxis *axis = new TGaxis(gPad->GetUxmax(), gPad->GetUymin(),
|
---|
224 | gPad->GetUxmax(), gPad->GetUymax(),
|
---|
225 | 0, 1, 510, "+L");
|
---|
226 | axis->SetName("RightAxis");
|
---|
227 | axis->SetTitle(title);
|
---|
228 | axis->SetTitleOffset(0.9);
|
---|
229 | axis->SetTextColor(kRed);
|
---|
230 | axis->SetBit(kCanDelete);
|
---|
231 | axis->Draw();
|
---|
232 | }
|
---|
233 | */
|
---|
234 | // --------------------------------------------------------------------------
|
---|
235 | //
|
---|
236 | // This displays the TGraph like you expect it to be (eg. time on the axis)
|
---|
237 | // It should also make sure, that the displayed time always is UTC and
|
---|
238 | // not local time...
|
---|
239 | //
|
---|
240 | void MHPointing::Draw(Option_t *opt)
|
---|
241 | {
|
---|
242 | TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
|
---|
243 | pad->SetBorderMode(0);
|
---|
244 |
|
---|
245 | AppendPad();
|
---|
246 |
|
---|
247 | pad->Divide(2,2);
|
---|
248 |
|
---|
249 | pad->cd(1);
|
---|
250 | gPad->SetBorderMode(0);
|
---|
251 | gPad->SetGridx();
|
---|
252 | gPad->SetGridy();
|
---|
253 | fDevTimeSG.Draw("AP");
|
---|
254 | fDevTimeCosy.Draw("P");
|
---|
255 |
|
---|
256 | pad->cd(2);
|
---|
257 | gPad->SetBorderMode(0);
|
---|
258 | gPad->SetGridx();
|
---|
259 | gPad->SetGridy();
|
---|
260 | fBrightness.Draw("AP");
|
---|
261 |
|
---|
262 | pad->cd(3);
|
---|
263 | gPad->SetBorderMode(0);
|
---|
264 | gPad->SetGridx();
|
---|
265 | gPad->SetGridy();
|
---|
266 | fDevZd.Draw("AP");
|
---|
267 | fDevAz.Draw("P");
|
---|
268 |
|
---|
269 | pad->cd(4);
|
---|
270 | gPad->SetBorderMode(0);
|
---|
271 | gPad->SetGridx();
|
---|
272 | gPad->SetGridy();
|
---|
273 | fNumStars.Draw("AP");
|
---|
274 | }
|
---|
275 |
|
---|
276 | void MHPointing::Paint(Option_t *o)
|
---|
277 | {
|
---|
278 | DrawGraph(fDevTimeSG, "\\Delta [arcmin]");
|
---|
279 | DrawGraph(fDevTimeCosy, "\\Delta [arcmin]");
|
---|
280 | DrawGraph(fBrightness, "Brightness [au]");
|
---|
281 | DrawGraph(fNumStars, "N");
|
---|
282 | DrawGraph(fDevZd, "\\Delta [arcmin]");
|
---|
283 | DrawGraph(fDevAz, "\\Delta [arcmin]");
|
---|
284 | /*
|
---|
285 | gPad->cd(1);
|
---|
286 |
|
---|
287 | if (gPad)
|
---|
288 | {
|
---|
289 | fHumidity.GetHistogram()->GetYaxis()->SetTitleColor(kBlue);
|
---|
290 | UpdateRightAxis(fTemperature);
|
---|
291 | }*/
|
---|
292 | }
|
---|