1 | /* ======================================================================== *\
|
---|
2 | ! $Name: not supported by cvs2svn $:$Id: plotstat.C,v 1.5 2008-06-06 17:02:07 tbretz Exp $
|
---|
3 | ! --------------------------------------------------------------------------
|
---|
4 | !
|
---|
5 | ! *
|
---|
6 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
7 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
8 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
9 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
10 | ! *
|
---|
11 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
12 | ! * documentation for any purpose is hereby granted without fee,
|
---|
13 | ! * provided that the above copyright notice appear in all copies and
|
---|
14 | ! * that both that copyright notice and this permission notice appear
|
---|
15 | ! * in supporting documentation. It is provided "as is" without express
|
---|
16 | ! * or implied warranty.
|
---|
17 | ! *
|
---|
18 | !
|
---|
19 | !
|
---|
20 | ! Author(s): Thomas Bretz, 02/2006 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
21 | ! Author(s): Daniela Dorner, 02/2006 <mailto:dorner@astro.uni-wuerzburg.de>
|
---|
22 | !
|
---|
23 | ! Copyright: MAGIC Software Development, 2000-2008
|
---|
24 | !
|
---|
25 | !
|
---|
26 | \* ======================================================================== */
|
---|
27 |
|
---|
28 | /////////////////////////////////////////////////////////////////////////////
|
---|
29 | //
|
---|
30 | // plotstat.C
|
---|
31 | // ==========
|
---|
32 | //
|
---|
33 | // This macro is used to plot processing statistics from the db.
|
---|
34 | //
|
---|
35 | // Normally all period are processed. If you want to restric processing to
|
---|
36 | // less periods, use:
|
---|
37 | // > root plotstat.C+(20, -1)
|
---|
38 | // means that all periods since 20 are taken into account. The two numbers
|
---|
39 | // denote the first and last period taken into account, -1 means
|
---|
40 | // open start or open end.
|
---|
41 | //
|
---|
42 | // Make sure, that database and password are corretly set in a resource
|
---|
43 | // file called sql.rc and the resource file is found.
|
---|
44 | //
|
---|
45 | /////////////////////////////////////////////////////////////////////////////
|
---|
46 | #include <iostream>
|
---|
47 | #include <iomanip>
|
---|
48 |
|
---|
49 | #include <TH2.h>
|
---|
50 | #include <TEnv.h>
|
---|
51 | #include <TPad.h>
|
---|
52 | #include <TLine.h>
|
---|
53 | #include <TText.h>
|
---|
54 | #include <TCanvas.h>
|
---|
55 | #include <TLegend.h>
|
---|
56 | #include <TPaveText.h>
|
---|
57 | #include <TEllipse.h>
|
---|
58 | #include <TSQLRow.h>
|
---|
59 | #include <TSQLResult.h>
|
---|
60 |
|
---|
61 | #include "MH.h"
|
---|
62 | #include "MTime.h"
|
---|
63 | #include "MBinning.h"
|
---|
64 | #include "MSQLServer.h"
|
---|
65 | #include "MStatusDisplay.h"
|
---|
66 |
|
---|
67 | using namespace std;
|
---|
68 |
|
---|
69 | TString GetFullQuery(TString query, TString from="", TString to="")
|
---|
70 | {
|
---|
71 | if (from.IsNull())
|
---|
72 | return query;
|
---|
73 |
|
---|
74 | if (!query.Contains("where", TString::kIgnoreCase))
|
---|
75 | query += " where ";
|
---|
76 | else
|
---|
77 | query += " and ";
|
---|
78 |
|
---|
79 | query += " fRunStart>'";
|
---|
80 | query += from;
|
---|
81 | query += "' and fRunStart<'";
|
---|
82 | query += to;
|
---|
83 | query += "'";
|
---|
84 |
|
---|
85 | return query;
|
---|
86 | }
|
---|
87 |
|
---|
88 | Double_t GetTime(MSQLServer &serv, TString query, TString from="", TString to="")
|
---|
89 | {
|
---|
90 | query = GetFullQuery(query, from, to);
|
---|
91 |
|
---|
92 | TSQLResult *res = serv.Query(query);
|
---|
93 | if (!res)
|
---|
94 | {
|
---|
95 | cout << "ERROR - Query failed: " << query << endl;
|
---|
96 | return -1;
|
---|
97 | }
|
---|
98 |
|
---|
99 | TSQLRow *row=res->Next();
|
---|
100 | if (!row)
|
---|
101 | {
|
---|
102 | cout << "ERROR - Query " << query << " empty." << endl;
|
---|
103 | delete res;
|
---|
104 | return -1;
|
---|
105 | }
|
---|
106 |
|
---|
107 | const char *time = (*row)[0];
|
---|
108 |
|
---|
109 | const Double_t rc = time ? atof(time) : 0;
|
---|
110 |
|
---|
111 | delete res;
|
---|
112 | return rc<0 || rc>200 ? 0 : rc;
|
---|
113 | }
|
---|
114 |
|
---|
115 | TArrayD GetObsDist(MSQLServer &serv, TString from="", TString to="")
|
---|
116 | {
|
---|
117 | // 8: Sequenced RunTime per source and night
|
---|
118 | //query[8] = "select SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart)))/3600, ";
|
---|
119 | //query[8] += "DATE_FORMAT(ADDDATE(fRunStart,Interval 12 hour), '%Y-%m-%d') as Start,";
|
---|
120 | //query[8] += "from RunData where fRunTypeKEY=2 and fExcludedFDAKEY=1 group by Start, fSourceKEY";
|
---|
121 |
|
---|
122 | TString query;
|
---|
123 |
|
---|
124 | query = "SELECT SUM(fRunTime)/3600, ";
|
---|
125 | query += "DATE_FORMAT(ADDDATE(fRunStart, INTERVAL 12 hour), '%Y-%m-%d') AS Start ";
|
---|
126 | query += "FROM Sequences ";
|
---|
127 |
|
---|
128 | query = GetFullQuery(query, from, to);
|
---|
129 | query += " GROUP BY Start, fSourceKEY";
|
---|
130 |
|
---|
131 |
|
---|
132 | TSQLResult *res = serv.Query(query);
|
---|
133 | if (!res)
|
---|
134 | {
|
---|
135 | cout << "ERROR - Query failed: " << query << endl;
|
---|
136 | return -1;
|
---|
137 | }
|
---|
138 |
|
---|
139 | TSQLRow *row = 0;
|
---|
140 |
|
---|
141 | TArrayD arr;
|
---|
142 |
|
---|
143 | while ((row=res->Next()))
|
---|
144 | {
|
---|
145 | const char *time = (*row)[0];
|
---|
146 |
|
---|
147 | const Double_t rc = time ? atof(time) : 0;
|
---|
148 |
|
---|
149 | if (rc>0 && rc<200)
|
---|
150 | {
|
---|
151 | arr.Set(arr.GetSize()+1);
|
---|
152 | arr[arr.GetSize()-1] = rc;
|
---|
153 | }
|
---|
154 | }
|
---|
155 |
|
---|
156 | delete res;
|
---|
157 |
|
---|
158 | return arr;
|
---|
159 | }
|
---|
160 |
|
---|
161 | void DrawYears()
|
---|
162 | {
|
---|
163 | UInt_t year = 2004;
|
---|
164 | Int_t period = 0;
|
---|
165 |
|
---|
166 | MTime past, from, now(-1);
|
---|
167 | past.Set(2004, 1, 1, 13, 1);
|
---|
168 |
|
---|
169 | TLine l;
|
---|
170 | l.SetLineStyle(kDotted);
|
---|
171 | l.SetLineColor(kWhite);
|
---|
172 | while (past<now)
|
---|
173 | {
|
---|
174 | if (period!=past.GetMagicPeriod())
|
---|
175 | {
|
---|
176 | period = past.GetMagicPeriod();
|
---|
177 | from = past;
|
---|
178 | }
|
---|
179 |
|
---|
180 | if (past.Year()!=year)
|
---|
181 | {
|
---|
182 | Double_t dx = (past.GetMjd()-from.GetMjd())/28;
|
---|
183 | l.DrawLine(past.GetMagicPeriod()+dx, 0,
|
---|
184 | past.GetMagicPeriod()+dx, gPad->GetUymax());
|
---|
185 | year = past.Year();
|
---|
186 | }
|
---|
187 | past.SetMjd(past.GetMjd()+1);
|
---|
188 | }
|
---|
189 | }
|
---|
190 |
|
---|
191 | void DrawCake(TH1F *h, Int_t p0=-1, Int_t p1=9999)
|
---|
192 | {
|
---|
193 | gPad->Range(-1, -0.9, 1, 1.1);
|
---|
194 |
|
---|
195 | gPad->SetFillColor(kWhite);
|
---|
196 | gPad->SetBorderMode(0);
|
---|
197 | gPad->SetFrameBorderMode(0);
|
---|
198 |
|
---|
199 | const Double_t r1 = 0.8;
|
---|
200 | const Double_t r2 = 0.59;
|
---|
201 |
|
---|
202 | const Double_t tot0 = h[0].Integral(p0, p1);
|
---|
203 | const Double_t tot1 = h[1].Integral(p0, p1);
|
---|
204 | const Double_t tot2 = h[2].Integral(p0, p1);
|
---|
205 | const Double_t tot3 = h[3].Integral(p0, p1);
|
---|
206 | const Double_t tot4 = h[4].Integral(p0, p1);
|
---|
207 | const Double_t tot5 = h[5].Integral(p0, p1);
|
---|
208 | const Double_t tot6 = h[6].Integral(p0, p1);
|
---|
209 | const Double_t tot7 = h[7].Integral(p0, p1);
|
---|
210 |
|
---|
211 | TString title = Form("Total = %.1fh (excl=%.1fh)", tot1, tot1-tot2);
|
---|
212 |
|
---|
213 | if (p0>0 && p1<9000 && p0==p1)
|
---|
214 | title.Prepend(Form("P%d: ", TMath::Nint(h[0].GetBinCenter(p0))));
|
---|
215 |
|
---|
216 | TPaveText *pave = new TPaveText(-0.99, 0.92, 0.99, 1.09);
|
---|
217 | pave->SetBorderSize(1);
|
---|
218 | pave->AddText(title)->SetTextAlign(22);
|
---|
219 | pave->SetBit(kCanDelete);
|
---|
220 | pave->Draw();
|
---|
221 |
|
---|
222 | if (tot1<0.1)
|
---|
223 | return;
|
---|
224 |
|
---|
225 | TEllipse e;
|
---|
226 | e.SetFillColor(15);
|
---|
227 | //e.SetLineColor(15);
|
---|
228 | e.DrawEllipse(0, 0, r1*1.1, r2*1.1, 90, tot0/tot1*360+90, 0);
|
---|
229 |
|
---|
230 | // 0 : hollow
|
---|
231 | // 1001 : Solid
|
---|
232 | // 2001 : hatch style
|
---|
233 | // 3000+pattern_number (see below)
|
---|
234 | // 4000 :the window is transparent.
|
---|
235 | // 4000 to 4100 the window is 100% transparent to 100% opaque
|
---|
236 |
|
---|
237 | e.SetLineColor(10);//17);
|
---|
238 | e.SetFillColor(10);//17);
|
---|
239 | e.DrawEllipse(0, 0, r1, r2, 0, 360, 0);
|
---|
240 | e.SetLineColor(kBlack);
|
---|
241 |
|
---|
242 | e.SetFillColor(kBlack);
|
---|
243 | e.DrawEllipse(0, 0, r1, r2, 90, tot2/tot1*360+90, 0);
|
---|
244 | //e.SetLineColor(kBlue);
|
---|
245 | e.SetFillColor(kBlue);
|
---|
246 | e.DrawEllipse(0, 0, r1, r2, 90, tot3/tot1*360+90, 0);
|
---|
247 | //e.SetLineColor(kRed);
|
---|
248 | e.SetFillColor(kRed);
|
---|
249 | e.DrawEllipse(0, 0, r1, r2, 90, tot4/tot1*360+90, 0);
|
---|
250 | //e.SetLineColor(kGreen);
|
---|
251 | e.SetFillColor(kGreen);
|
---|
252 | e.DrawEllipse(0, 0, r1, r2, 90, tot5/tot1*360+90, 0);
|
---|
253 | //e.SetLineColor(kRed+100);
|
---|
254 | e.SetFillColor(kRed+100);
|
---|
255 | e.DrawEllipse(0, 0, r1, r2, 90, tot6/tot1*360+90, 0);
|
---|
256 | //e.SetLineColor(kGreen+100);
|
---|
257 | e.SetFillColor(kGreen+100);
|
---|
258 | e.DrawEllipse(0, 0, r1, r2, 90, tot7/tot1*360+90, 0);
|
---|
259 |
|
---|
260 | TText txt;
|
---|
261 | txt.SetTextSize(0.08);
|
---|
262 |
|
---|
263 | txt.SetTextAlign(32);
|
---|
264 |
|
---|
265 | txt.SetTextColor(kBlack);
|
---|
266 | txt.DrawText(0.99, 0.65, Form("%.1f%%", (tot2-tot3)/tot1*100));
|
---|
267 | txt.SetTextColor(kBlue);
|
---|
268 | txt.DrawText(0.99, -0.58, Form("%.1f%%", (tot3-tot4)/tot1*100));
|
---|
269 | txt.SetTextColor(kRed+100);
|
---|
270 | txt.DrawText(-0.35, -0.70, Form("%.1f%%", (tot6-tot7)/tot1*100));
|
---|
271 |
|
---|
272 | txt.SetTextAlign(12);
|
---|
273 |
|
---|
274 | txt.SetTextColor(kBlack);
|
---|
275 | txt.DrawText(0, 0.77, Form("%.1f%%", (tot1-tot2)/tot1*100));
|
---|
276 | txt.SetTextColor(15);
|
---|
277 | txt.DrawText(-0.99, 0.65, Form("%.1f%%", tot0/tot1*100));
|
---|
278 | txt.SetTextColor(kGreen+100);
|
---|
279 | txt.DrawText(-0.99, -0.58, Form("%.1f%%", tot7/tot1*100));
|
---|
280 | txt.SetTextColor(kRed);
|
---|
281 | txt.DrawText(0.35, -0.70, Form("%.1f%%", (tot4-tot5)/tot1*100));
|
---|
282 |
|
---|
283 | txt.SetTextAlign(22);
|
---|
284 |
|
---|
285 | txt.SetTextColor(kGreen);
|
---|
286 | txt.DrawText(0, -0.79, Form("%.1f%%", (tot5-tot6)/tot1*100));
|
---|
287 | }
|
---|
288 |
|
---|
289 | void DrawLegend(TH1F *h)
|
---|
290 | {
|
---|
291 | TLegend leg(0.01, 0.12, 0.99, 0.98, "Data Statistics");
|
---|
292 | leg.SetBorderSize(1);
|
---|
293 | leg.SetTextSize(0.1);
|
---|
294 |
|
---|
295 | TH1 *hc[8];
|
---|
296 |
|
---|
297 | for (int i=0; i<8; i++)
|
---|
298 | {
|
---|
299 | hc[i] = (TH1*)h[i].Clone();
|
---|
300 | hc[i]->SetBit(kCanDelete);
|
---|
301 | hc[i]->SetDirectory(0);
|
---|
302 | }
|
---|
303 |
|
---|
304 | leg.AddEntry(hc[0], "Files available", "L");
|
---|
305 | leg.AddEntry(hc[1], "Excluded data", "F");
|
---|
306 | leg.AddEntry(hc[2], "Not sequenced", "F");
|
---|
307 | leg.AddEntry(hc[3], "Callisto not done", "F");
|
---|
308 | leg.AddEntry(hc[4], "Callisto failed", "F");
|
---|
309 | leg.AddEntry(hc[5], "Star not done", "F");
|
---|
310 | leg.AddEntry(hc[6], "Star failed", "F");
|
---|
311 | leg.AddEntry(hc[7], "Star OK", "F");
|
---|
312 |
|
---|
313 | gROOT->SetSelectedPad(0);
|
---|
314 | leg.DrawClone()->SetBit(kCanDelete);;
|
---|
315 | }
|
---|
316 |
|
---|
317 | Bool_t plot(MStatusDisplay &d, MSQLServer &serv, Int_t first, Int_t last)
|
---|
318 | {
|
---|
319 | TString query[8];
|
---|
320 |
|
---|
321 | // 0: All data for which are files available
|
---|
322 | query[0] = "select SUM(TIME_TO_SEC(TIMEDIFF(fRunStop, fRunStart)))/3600 ";
|
---|
323 | query[0] += "from RunData left join RunProcessStatus on RunData.fRunNumber=RunProcessStatus.fRunNumber ";
|
---|
324 | query[0] += "where fRunTypeKey=2 and ";
|
---|
325 | query[0] += " not ISNULL(fRawFileAvail)";
|
---|
326 |
|
---|
327 | // 1: All data
|
---|
328 | query[1] = "select SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart)))/3600 ";
|
---|
329 | query[1] += "from RunData where fRunTypeKEY=2";
|
---|
330 |
|
---|
331 | // 2: All data which is not excluded
|
---|
332 | query[2] = "select SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart)))/3600 ";
|
---|
333 | query[2] += "from RunData where fRunTypeKEY=2 and fExcludedFDAKEY=1";
|
---|
334 |
|
---|
335 | // 3: All sequences
|
---|
336 | query[3] = "select SUM(fRunTime)/3600 from Sequences";
|
---|
337 |
|
---|
338 | // 4: All sequences with callisto failed
|
---|
339 | query[4] = "select SUM(fRunTime)/3600 from Sequences left join SequenceProcessStatus on ";
|
---|
340 | query[4] += "Sequences.fSequenceFirst=SequenceProcessStatus.fSequenceFirst where ";
|
---|
341 | query[4] += "ISNULL(fCallisto) and not ISNULL(fFailedTime) and not ISNULL(fAllFilesAvail)";
|
---|
342 |
|
---|
343 | // 5: All sequences with callisto=OK
|
---|
344 | query[5] = "select SUM(fRunTime)/3600 from Sequences left join SequenceProcessStatus on ";
|
---|
345 | query[5] += "Sequences.fSequenceFirst=SequenceProcessStatus.fSequenceFirst where not ISNULL(fCallisto)";
|
---|
346 |
|
---|
347 | // 6: All sequences with star failed
|
---|
348 | query[6] = "select SUM(fRunTime)/3600 from Sequences left join SequenceProcessStatus on ";
|
---|
349 | query[6] += "Sequences.fSequenceFirst=SequenceProcessStatus.fSequenceFirst where ";
|
---|
350 | query[6] += "ISNULL(fStar) and not ISNULL(fFailedTime) and not ISNULL(fCallisto)";
|
---|
351 |
|
---|
352 | // 7: All sequences with star=OK
|
---|
353 | query[7] = "select SUM(fRunTime)/3600 from Sequences left join SequenceProcessStatus on ";
|
---|
354 | query[7] += "Sequences.fSequenceFirst=SequenceProcessStatus.fSequenceFirst where not ISNULL(fStar)";
|
---|
355 |
|
---|
356 | // 0: All data
|
---|
357 | // 1: All data which is not excluded
|
---|
358 | // 2: All data for which are files available
|
---|
359 | // 3: All sequences
|
---|
360 | // 4: All sequences with callisto=not done
|
---|
361 | // 5: All sequences with callisto not done and failed
|
---|
362 | // 6: All sequences with star=not done
|
---|
363 | // 7: All sequences with star not done and failed
|
---|
364 |
|
---|
365 | MTime now(-1);
|
---|
366 | MTime past;
|
---|
367 | past.Set(2004, 1, 1, 13, 1);
|
---|
368 |
|
---|
369 | if (first<0)
|
---|
370 | first=14;
|
---|
371 | if (last<0)
|
---|
372 | last=now.GetMagicPeriod();
|
---|
373 |
|
---|
374 | TH1F h[8];
|
---|
375 | TH2F h8;
|
---|
376 |
|
---|
377 | MBinning binsp(last-first+1, first-0.5, last+0.5);
|
---|
378 | MBinning binst(4*7, 0, 7);
|
---|
379 | for (int i=0; i<8; i++)
|
---|
380 | {
|
---|
381 | binsp.Apply(h[i]);
|
---|
382 | h[i].SetName(Form("H%d", i));
|
---|
383 | h[i].SetDirectory(0);
|
---|
384 | }
|
---|
385 |
|
---|
386 | MH::SetBinning(&h8, &binsp, &binst);
|
---|
387 | h8.SetNameTitle("ObsTime", "Distribution of observation time per exposure");
|
---|
388 | h8.SetXTitle("Obs. time per exposure [h]");
|
---|
389 | h8.SetYTitle("Counts");
|
---|
390 | h8.SetDirectory(0);
|
---|
391 |
|
---|
392 | Int_t period = 0;
|
---|
393 | MTime from;
|
---|
394 |
|
---|
395 | while (1)
|
---|
396 | {
|
---|
397 | if (past.GetMagicPeriod()!=period)
|
---|
398 | {
|
---|
399 | period = past.GetMagicPeriod();
|
---|
400 |
|
---|
401 | if (period>first && period-1<=last)
|
---|
402 | {
|
---|
403 | TString a = from.GetSqlDateTime();
|
---|
404 | TString b = past.GetSqlDateTime();
|
---|
405 |
|
---|
406 | for (int i=0; i<8; i++)
|
---|
407 | h[i].Fill(period-1, GetTime(serv, query[i], a, b));
|
---|
408 |
|
---|
409 | TArrayD arr(GetObsDist(serv, a, b));
|
---|
410 |
|
---|
411 | for (int i=0; i<arr.GetSize(); i++)
|
---|
412 | h8.Fill(period-1, arr[i]);
|
---|
413 | }
|
---|
414 |
|
---|
415 | if (past>now)
|
---|
416 | break;
|
---|
417 |
|
---|
418 | from = past;
|
---|
419 |
|
---|
420 | }
|
---|
421 | past.SetMjd(past.GetMjd()+1);
|
---|
422 | }
|
---|
423 |
|
---|
424 | for (int i=0; i<h[0].GetNbinsX(); i++)
|
---|
425 | h[0].SetBinError(i+1, 0.001);
|
---|
426 |
|
---|
427 |
|
---|
428 | h[4].Add(&h[5]);
|
---|
429 | h[6].Add(&h[7]);
|
---|
430 |
|
---|
431 | // --------------------------------------------
|
---|
432 |
|
---|
433 | TCanvas &c0 = d.AddTab("ObsDist");
|
---|
434 | c0.SetFillColor(kWhite);
|
---|
435 |
|
---|
436 | gPad->SetBorderMode(0);
|
---|
437 | gPad->SetFrameBorderMode(0);
|
---|
438 | gPad->SetFillColor(kWhite);
|
---|
439 | gPad->SetRightMargin(0.01);
|
---|
440 | //gPad->SetTopMargin(0.02);
|
---|
441 | //gPad->SetLeftMargin(0.09);
|
---|
442 | //gPad->SetBottomMargin(0.12);
|
---|
443 | gPad->SetGridx();
|
---|
444 | gPad->SetGridy();
|
---|
445 | gPad->SetLogy();
|
---|
446 |
|
---|
447 | TH1 * p = h8.ProjectionY();
|
---|
448 |
|
---|
449 | p->SetDirectory(0);
|
---|
450 | p->SetBit(kCanDelete);
|
---|
451 | p->Draw();
|
---|
452 |
|
---|
453 | // --------------------------------------------
|
---|
454 |
|
---|
455 | TCanvas &c1 = d.AddTab("Hist");
|
---|
456 | c1.SetFillColor(kWhite);
|
---|
457 | c1.Divide(2,2);
|
---|
458 |
|
---|
459 | c1.cd(1);
|
---|
460 |
|
---|
461 | gPad->SetBorderMode(0);
|
---|
462 | gPad->SetFrameBorderMode(0);
|
---|
463 | gPad->SetFillColor(kWhite);
|
---|
464 | gPad->SetRightMargin(0.01);
|
---|
465 | gPad->SetTopMargin(0.02);
|
---|
466 | gPad->SetLeftMargin(0.09);
|
---|
467 | gPad->SetBottomMargin(0.12);
|
---|
468 | gPad->SetGridy();
|
---|
469 | gPad->SetPad(0, 0.5, 0.75, 1.0);
|
---|
470 |
|
---|
471 | h[1].SetBit(TH1::kNoStats);
|
---|
472 | // h[0].GetXaxis()->SetRangeUser(13.5, period+0.5);
|
---|
473 | h[1].GetXaxis()->CenterTitle();
|
---|
474 | h[1].GetXaxis()->SetTitleSize(0.06);
|
---|
475 | h[1].GetYaxis()->SetTitleSize(0.06);
|
---|
476 | h[1].GetYaxis()->SetTitleOffset(0.7);
|
---|
477 | h[1].GetXaxis()->SetLabelSize(0.06);
|
---|
478 | h[1].GetYaxis()->SetLabelSize(0.06);
|
---|
479 | h[1].GetXaxis()->SetNdivisions(550);
|
---|
480 | h[1].SetYTitle("Time [h]");
|
---|
481 | h[1].SetFillColor(kWhite);
|
---|
482 | h[1].SetLineColor(kBlack);
|
---|
483 | h[1].DrawCopy("");
|
---|
484 |
|
---|
485 | h[2].SetLineColor(kBlack);
|
---|
486 | h[2].SetFillColor(kBlack);
|
---|
487 | h[2].DrawCopy("Bsame");
|
---|
488 |
|
---|
489 | h[3].SetLineColor(kBlue);
|
---|
490 | h[3].SetFillColor(kBlue);
|
---|
491 | h[3].DrawCopy("Bsame");
|
---|
492 |
|
---|
493 | h[4].SetLineColor(kRed);
|
---|
494 | h[4].SetFillColor(kRed);
|
---|
495 | h[4].DrawCopy("Bsame");
|
---|
496 |
|
---|
497 | h[5].SetLineColor(kGreen);
|
---|
498 | h[5].SetFillColor(kGreen);
|
---|
499 | h[5].DrawCopy("Bsame");
|
---|
500 |
|
---|
501 | h[6].SetLineColor(kRed+100);
|
---|
502 | h[6].SetFillColor(kRed+100);
|
---|
503 | h[6].DrawCopy("Bsame");
|
---|
504 |
|
---|
505 | h[7].SetLineColor(kGreen+100);
|
---|
506 | h[7].SetFillColor(kGreen+100);
|
---|
507 | h[7].DrawCopy("Bsame");
|
---|
508 |
|
---|
509 | h[0].SetMarkerSize(0);
|
---|
510 | h[0].SetMarkerColor(15);
|
---|
511 | h[0].SetLineWidth(3);
|
---|
512 | h[0].SetLineColor(15);
|
---|
513 | h[0].DrawCopy("EPsame");
|
---|
514 |
|
---|
515 | gPad->Update();
|
---|
516 | DrawYears();
|
---|
517 |
|
---|
518 | c1.cd(4);
|
---|
519 |
|
---|
520 | gPad->SetBorderMode(0);
|
---|
521 | gPad->SetFrameBorderMode(0);
|
---|
522 | gPad->SetPad(0.75, 0, 1.0, 0.5);
|
---|
523 |
|
---|
524 | DrawCake(h);
|
---|
525 |
|
---|
526 | // --------------------------------------------
|
---|
527 |
|
---|
528 | TCanvas &cx = d.AddTab("All");
|
---|
529 | cx.SetBorderMode(0);
|
---|
530 | cx.SetFrameBorderMode(0);
|
---|
531 | cx.SetFillColor(kWhite);
|
---|
532 | cx.Divide(9,5);
|
---|
533 | cx.cd(1);
|
---|
534 | DrawLegend(h);
|
---|
535 |
|
---|
536 | for (int i=0; i<h[0].GetNbinsX(); i++)
|
---|
537 | {
|
---|
538 | const Int_t num = TMath::Nint(h[0].GetBinCenter(i+1));
|
---|
539 |
|
---|
540 | TCanvas &c = d.AddTab(Form("P%d", num));
|
---|
541 | c.SetBorderMode(0);
|
---|
542 | c.SetFrameBorderMode(0);
|
---|
543 | c.SetFillColor(kWhite);
|
---|
544 |
|
---|
545 | c.cd();
|
---|
546 |
|
---|
547 | TPad *pad1 = new TPad(Form("Pad%da", num), "", 0.05, 0, 0.55, 1);
|
---|
548 | pad1->SetBorderMode(0);
|
---|
549 | pad1->SetFrameBorderMode(0);
|
---|
550 | pad1->SetFillColor(kWhite);
|
---|
551 | pad1->SetBit(kCanDelete);
|
---|
552 | pad1->Draw();
|
---|
553 | pad1->cd();
|
---|
554 |
|
---|
555 | DrawCake(h, i+1, i+1);
|
---|
556 |
|
---|
557 | if (i<4*8)
|
---|
558 | {
|
---|
559 | cx.cd(i+2);
|
---|
560 | DrawCake(h, i+1, i+1);
|
---|
561 | }
|
---|
562 |
|
---|
563 | c.cd();
|
---|
564 |
|
---|
565 | TPad *pad2 = new TPad(Form("Pad%db", num), "", 0.6, 0.02, 1, 0.48);
|
---|
566 | pad2->SetBorderMode(0);
|
---|
567 | pad2->SetFrameBorderMode(0);
|
---|
568 | pad2->SetFillColor(kWhite);
|
---|
569 | pad2->SetBit(kCanDelete);
|
---|
570 | pad2->SetGridx();
|
---|
571 | pad2->SetGridy();
|
---|
572 | pad2->SetRightMargin(0.01);
|
---|
573 | pad2->Draw();
|
---|
574 | pad2->cd();
|
---|
575 |
|
---|
576 | TH1 * p = h8.ProjectionY(Form("Obs%d", num), i+1, i+1);
|
---|
577 |
|
---|
578 | p->Rebin(2);
|
---|
579 | p->SetBit(TH1::kNoStats);
|
---|
580 | p->SetTitle("");
|
---|
581 | p->SetXTitle("Obs. time per exposure [h]");
|
---|
582 | p->SetYTitle("Counts");
|
---|
583 | p->SetDirectory(0);
|
---|
584 | p->SetBit(kCanDelete);
|
---|
585 | p->Draw();
|
---|
586 |
|
---|
587 | /*
|
---|
588 | c.cd();
|
---|
589 |
|
---|
590 | TPaveText *pave = new TPaveText(0.6, 0.52, 0.98, 0.98);
|
---|
591 | pave->SetBorderSize(1);
|
---|
592 | pave->AddText(Form("Period: %d", num))->SetTextAlign(22);
|
---|
593 | pave->AddSeperator();
|
---|
594 | pave->AddText(Form("Start: %s", num));
|
---|
595 | pave->AddText(Form("End: %s", num));
|
---|
596 | pave->SetBit(kCanDelete);
|
---|
597 | pave->Draw();
|
---|
598 | */
|
---|
599 | }
|
---|
600 |
|
---|
601 | c1.cd(2);
|
---|
602 |
|
---|
603 | gPad->SetBorderMode(0);
|
---|
604 | gPad->SetFrameBorderMode(0);
|
---|
605 | gPad->SetRightMargin(0.01);
|
---|
606 | gPad->SetTopMargin(0.02);
|
---|
607 | gPad->SetLeftMargin(0.09);
|
---|
608 | gPad->SetBottomMargin(0.12);
|
---|
609 | gPad->SetPad(0, 0, 0.75, 0.5);
|
---|
610 | gPad->SetGridy();
|
---|
611 |
|
---|
612 | h[1].Scale(0.01);
|
---|
613 | h[0].Divide(&h[1]);
|
---|
614 | h[2].Divide(&h[1]);
|
---|
615 | h[3].Divide(&h[1]);
|
---|
616 | h[4].Divide(&h[1]);
|
---|
617 | h[5].Divide(&h[1]);
|
---|
618 | h[6].Divide(&h[1]);
|
---|
619 | h[7].Divide(&h[1]);
|
---|
620 | h[1].Divide(&h[1]);
|
---|
621 | h[1].Scale(100);
|
---|
622 |
|
---|
623 | for (int i=0; i<h[0].GetNbinsX(); i++)
|
---|
624 | h[0].SetBinError(i+1, 0.001);
|
---|
625 |
|
---|
626 | h[1].GetXaxis()->SetNdivisions(550);
|
---|
627 | h[1].SetYTitle("%");
|
---|
628 | h[1].SetXTitle("Period");
|
---|
629 | h[1].GetYaxis()->SetRangeUser(0, 100);
|
---|
630 |
|
---|
631 | h[1].DrawCopy();
|
---|
632 | h[2].DrawCopy("same");
|
---|
633 | h[3].DrawCopy("same");
|
---|
634 | h[4].DrawCopy("same");
|
---|
635 | h[5].DrawCopy("same");
|
---|
636 | h[6].DrawCopy("same");
|
---|
637 | h[7].DrawCopy("same");
|
---|
638 | h[0].DrawCopy("same");
|
---|
639 | /*
|
---|
640 | TLine l;
|
---|
641 | l.SetLineColor(kWhite);
|
---|
642 | l.SetLineWidth(1);
|
---|
643 | l.SetLineStyle(kDotted);
|
---|
644 | for (int i=10; i<95; i+=10)
|
---|
645 | l.DrawLine(13.5, i, period+0.5, i);
|
---|
646 | l.SetLineStyle(kSolid);
|
---|
647 | l.DrawLine(13.5, 50, period+0.5, 50);
|
---|
648 | */
|
---|
649 | gPad->Update();
|
---|
650 | DrawYears();
|
---|
651 |
|
---|
652 | c1.cd(3);
|
---|
653 |
|
---|
654 | gPad->SetBorderMode(0);
|
---|
655 | gPad->SetFrameBorderMode(0);
|
---|
656 | gPad->SetPad(0.75, 0.5, 1.0, 1.0);
|
---|
657 |
|
---|
658 | DrawLegend(h);
|
---|
659 |
|
---|
660 | return kTRUE;
|
---|
661 | }
|
---|
662 |
|
---|
663 | int plotstat(Int_t first=-1, Int_t last=-1)
|
---|
664 | {
|
---|
665 | TEnv env("sql.rc");
|
---|
666 |
|
---|
667 | MSQLServer serv(env);
|
---|
668 | if (!serv.IsConnected())
|
---|
669 | {
|
---|
670 | cout << "ERROR - Connection to database failed." << endl;
|
---|
671 | return 0;
|
---|
672 | }
|
---|
673 |
|
---|
674 | cout << "plotstat" << endl;
|
---|
675 | cout << "--------" << endl;
|
---|
676 | cout << endl;
|
---|
677 | cout << "Connected to " << serv.GetName() << endl;
|
---|
678 | cout << endl;
|
---|
679 |
|
---|
680 | MStatusDisplay *d = new MStatusDisplay;
|
---|
681 | d->SetWindowName(serv.GetName());
|
---|
682 | d->SetTitle(serv.GetName());
|
---|
683 |
|
---|
684 | plot(*d, serv, first, last);
|
---|
685 |
|
---|
686 | //d->SaveAsRoot("plotstat.root");
|
---|
687 | //d->SaveAsPS("plotstat.ps");
|
---|
688 |
|
---|
689 | return 1;
|
---|
690 | }
|
---|