1 | /* ======================================================================== *\
|
---|
2 | ! $Name: not supported by cvs2svn $:$Id: plotstat.C,v 1.6 2008-06-19 15:18:57 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 not ISNULL(fRawFileAvail)";
|
---|
325 |
|
---|
326 | // 1: All data
|
---|
327 | query[1] = "select SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart)))/3600 ";
|
---|
328 | query[1] += "from RunData where fRunTypeKEY=2";
|
---|
329 |
|
---|
330 | // 2: All data which is not excluded
|
---|
331 | query[2] = "select SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart)))/3600 ";
|
---|
332 | query[2] += "from RunData where fRunTypeKEY=2 and fExcludedFDAKEY=1";
|
---|
333 |
|
---|
334 | // 3: All sequences
|
---|
335 | query[3] = "select SUM(fRunTime)/3600 from Sequences";
|
---|
336 |
|
---|
337 | // 4: All sequences with callisto failed
|
---|
338 | query[4] = "select SUM(fRunTime)/3600 from Sequences left join SequenceProcessStatus on ";
|
---|
339 | query[4] += "Sequences.fSequenceFirst=SequenceProcessStatus.fSequenceFirst where ";
|
---|
340 | query[4] += "ISNULL(fCallisto) and not ISNULL(fFailedTime) and not ISNULL(fAllFilesAvail)";
|
---|
341 |
|
---|
342 | // 5: All sequences with callisto=OK
|
---|
343 | query[5] = "select SUM(fRunTime)/3600 from Sequences left join SequenceProcessStatus on ";
|
---|
344 | query[5] += "Sequences.fSequenceFirst=SequenceProcessStatus.fSequenceFirst where not ISNULL(fCallisto)";
|
---|
345 |
|
---|
346 | // 6: All sequences with star failed
|
---|
347 | query[6] = "select SUM(fRunTime)/3600 from Sequences left join SequenceProcessStatus on ";
|
---|
348 | query[6] += "Sequences.fSequenceFirst=SequenceProcessStatus.fSequenceFirst where ";
|
---|
349 | query[6] += "ISNULL(fStar) and not ISNULL(fFailedTime) and not ISNULL(fCallisto)";
|
---|
350 |
|
---|
351 | // 7: All sequences with star=OK
|
---|
352 | query[7] = "select SUM(fRunTime)/3600 from Sequences left join SequenceProcessStatus on ";
|
---|
353 | query[7] += "Sequences.fSequenceFirst=SequenceProcessStatus.fSequenceFirst where not ISNULL(fStar)";
|
---|
354 |
|
---|
355 | // 0: All data
|
---|
356 | // 1: All data which is not excluded
|
---|
357 | // 2: All data for which are files available
|
---|
358 | // 3: All sequences
|
---|
359 | // 4: All sequences with callisto=not done
|
---|
360 | // 5: All sequences with callisto not done and failed
|
---|
361 | // 6: All sequences with star=not done
|
---|
362 | // 7: All sequences with star not done and failed
|
---|
363 |
|
---|
364 | MTime now(-1);
|
---|
365 | MTime past;
|
---|
366 | past.Set(2004, 1, 1, 13, 1);
|
---|
367 |
|
---|
368 | if (first<0)
|
---|
369 | first=14;
|
---|
370 | if (last<0)
|
---|
371 | last=now.GetMagicPeriod();
|
---|
372 |
|
---|
373 | TH1F h[8];
|
---|
374 | TH2F h8;
|
---|
375 |
|
---|
376 | MBinning binsp(last-first+1, first-0.5, last+0.5);
|
---|
377 | MBinning binst(4*7, 0, 7);
|
---|
378 | for (int i=0; i<8; i++)
|
---|
379 | {
|
---|
380 | binsp.Apply(h[i]);
|
---|
381 | h[i].SetName(Form("H%d", i));
|
---|
382 | h[i].SetDirectory(0);
|
---|
383 | }
|
---|
384 |
|
---|
385 | MH::SetBinning(&h8, &binsp, &binst);
|
---|
386 | h8.SetNameTitle("ObsTime", "Distribution of observation time per exposure");
|
---|
387 | h8.SetXTitle("Observation Period");
|
---|
388 | h8.SetYTitle("Obs. time per exposure [h]");
|
---|
389 | h8.SetZTitle("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->SetYTitle("Counts");
|
---|
450 | p->SetDirectory(0);
|
---|
451 | p->SetBit(kCanDelete);
|
---|
452 | p->Draw();
|
---|
453 |
|
---|
454 | // --------------------------------------------
|
---|
455 |
|
---|
456 | TCanvas &c1 = d.AddTab("Hist");
|
---|
457 | c1.SetFillColor(kWhite);
|
---|
458 | c1.Divide(2,2);
|
---|
459 |
|
---|
460 | c1.cd(1);
|
---|
461 |
|
---|
462 | gPad->SetBorderMode(0);
|
---|
463 | gPad->SetFrameBorderMode(0);
|
---|
464 | gPad->SetFillColor(kWhite);
|
---|
465 | gPad->SetRightMargin(0.01);
|
---|
466 | gPad->SetTopMargin(0.02);
|
---|
467 | gPad->SetLeftMargin(0.09);
|
---|
468 | gPad->SetBottomMargin(0.12);
|
---|
469 | gPad->SetGridy();
|
---|
470 | gPad->SetPad(0, 0.5, 0.75, 1.0);
|
---|
471 |
|
---|
472 | h[1].SetBit(TH1::kNoStats);
|
---|
473 | // h[0].GetXaxis()->SetRangeUser(13.5, period+0.5);
|
---|
474 | h[1].GetXaxis()->CenterTitle();
|
---|
475 | h[1].GetXaxis()->SetTitleSize(0.06);
|
---|
476 | h[1].GetYaxis()->SetTitleSize(0.06);
|
---|
477 | h[1].GetYaxis()->SetTitleOffset(0.7);
|
---|
478 | h[1].GetXaxis()->SetLabelSize(0.06);
|
---|
479 | h[1].GetYaxis()->SetLabelSize(0.06);
|
---|
480 | h[1].GetXaxis()->SetNdivisions(550);
|
---|
481 | h[1].SetYTitle("Time [h]");
|
---|
482 | h[1].SetFillColor(kWhite);
|
---|
483 | h[1].SetLineColor(kBlack);
|
---|
484 | h[1].DrawCopy("");
|
---|
485 |
|
---|
486 | h[2].SetLineColor(kBlack);
|
---|
487 | h[2].SetFillColor(kBlack);
|
---|
488 | h[2].DrawCopy("Bsame");
|
---|
489 |
|
---|
490 | h[3].SetLineColor(kBlue);
|
---|
491 | h[3].SetFillColor(kBlue);
|
---|
492 | h[3].DrawCopy("Bsame");
|
---|
493 |
|
---|
494 | h[4].SetLineColor(kRed);
|
---|
495 | h[4].SetFillColor(kRed);
|
---|
496 | h[4].DrawCopy("Bsame");
|
---|
497 |
|
---|
498 | h[5].SetLineColor(kGreen);
|
---|
499 | h[5].SetFillColor(kGreen);
|
---|
500 | h[5].DrawCopy("Bsame");
|
---|
501 |
|
---|
502 | h[6].SetLineColor(kRed+100);
|
---|
503 | h[6].SetFillColor(kRed+100);
|
---|
504 | h[6].DrawCopy("Bsame");
|
---|
505 |
|
---|
506 | h[7].SetLineColor(kGreen+100);
|
---|
507 | h[7].SetFillColor(kGreen+100);
|
---|
508 | h[7].DrawCopy("Bsame");
|
---|
509 |
|
---|
510 | h[0].SetMarkerSize(0);
|
---|
511 | h[0].SetMarkerColor(15);
|
---|
512 | h[0].SetLineWidth(3);
|
---|
513 | h[0].SetLineColor(15);
|
---|
514 | h[0].DrawCopy("EPsame");
|
---|
515 |
|
---|
516 | gPad->Update();
|
---|
517 | DrawYears();
|
---|
518 |
|
---|
519 | c1.cd(4);
|
---|
520 |
|
---|
521 | gPad->SetBorderMode(0);
|
---|
522 | gPad->SetFrameBorderMode(0);
|
---|
523 | gPad->SetPad(0.75, 0, 1.0, 0.5);
|
---|
524 |
|
---|
525 | DrawCake(h);
|
---|
526 |
|
---|
527 | // --------------------------------------------
|
---|
528 |
|
---|
529 | TCanvas &cx = d.AddTab("All");
|
---|
530 | cx.SetBorderMode(0);
|
---|
531 | cx.SetFrameBorderMode(0);
|
---|
532 | cx.SetFillColor(kWhite);
|
---|
533 | cx.Divide(9,5);
|
---|
534 | cx.cd(1);
|
---|
535 | DrawLegend(h);
|
---|
536 |
|
---|
537 | for (int i=0; i<h[0].GetNbinsX(); i++)
|
---|
538 | {
|
---|
539 | const Int_t num = TMath::Nint(h[0].GetBinCenter(i+1));
|
---|
540 |
|
---|
541 | TCanvas &c = d.AddTab(Form("P%d", num));
|
---|
542 | c.SetBorderMode(0);
|
---|
543 | c.SetFrameBorderMode(0);
|
---|
544 | c.SetFillColor(kWhite);
|
---|
545 |
|
---|
546 | c.cd();
|
---|
547 |
|
---|
548 | TPad *pad1 = new TPad(Form("Pad%da", num), "", 0.05, 0, 0.55, 1);
|
---|
549 | pad1->SetBorderMode(0);
|
---|
550 | pad1->SetFrameBorderMode(0);
|
---|
551 | pad1->SetFillColor(kWhite);
|
---|
552 | pad1->SetBit(kCanDelete);
|
---|
553 | pad1->Draw();
|
---|
554 | pad1->cd();
|
---|
555 |
|
---|
556 | DrawCake(h, i+1, i+1);
|
---|
557 |
|
---|
558 | if (i<4*8)
|
---|
559 | {
|
---|
560 | cx.cd(i+2);
|
---|
561 | DrawCake(h, i+1, i+1);
|
---|
562 | }
|
---|
563 |
|
---|
564 | c.cd();
|
---|
565 |
|
---|
566 | TPad *pad2 = new TPad(Form("Pad%db", num), "", 0.6, 0.02, 1, 0.48);
|
---|
567 | pad2->SetBorderMode(0);
|
---|
568 | pad2->SetFrameBorderMode(0);
|
---|
569 | pad2->SetFillColor(kWhite);
|
---|
570 | pad2->SetBit(kCanDelete);
|
---|
571 | pad2->SetGridx();
|
---|
572 | pad2->SetGridy();
|
---|
573 | pad2->SetRightMargin(0.01);
|
---|
574 | pad2->Draw();
|
---|
575 | pad2->cd();
|
---|
576 |
|
---|
577 | TH1 * p = h8.ProjectionY(Form("Obs%d", num), i+1, i+1);
|
---|
578 |
|
---|
579 | p->Rebin(2);
|
---|
580 | p->SetBit(TH1::kNoStats);
|
---|
581 | p->SetTitle("");
|
---|
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 | }
|
---|