source: trunk/MagicSoft/Mars/datacenter/macros/plotdb.C@ 9186

Last change on this file since 9186 was 9179, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 29.5 KB
Line 
1/* ======================================================================== *\
2! $Name: not supported by cvs2svn $:$Id: plotdb.C,v 1.53 2008-11-27 19:01:32 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, 05/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
21! Author(s): Daniela Dorner, 05/2005 <mailto:dorner@astro.uni-wuerzburg.de>
22!
23! Copyright: MAGIC Software Development, 2000-2008
24!
25!
26\* ======================================================================== */
27
28/////////////////////////////////////////////////////////////////////////////
29//
30// plotdb.C
31// ========
32//
33// This macro is used to read quality parameters from the DB and plot them.
34//
35// The parameters are from the following files:
36// calib*.root:mean conversion factor, mean arrival time, rms arrival time
37// (each parameter for inner and outer camera)
38// signal*.root: mean pedestal rms (for inner and outer camera)
39// star*.root: PSF, # of Muons, Effective OnTime, Muon rate,
40// Ratio MC/Data(MuonSize) and mean number of islands
41//
42// In the DB these values are stored in the tables Calibration and Star.
43//
44// Usage:
45// .x plotdb.C --> all values in the DB are plotted
46// You can chose are certain period:
47// .x plotdb.C(25) --> all values from period 25 are plotted
48// or a time period from a certain date to a certain date
49// .x plotdb.C("2004-11-14 00:00:00", "2005-02-28 00:00:00")
50// --> all values from 14.11.2004 0h to 28.2.2005 0h are plotted
51// or all data, but with dataset data highlighted
52// .x plotdb.C("dataset.txt")
53// --> the sequences defined in dataset.txt are highlighted (blue:on, red:off)
54// --> You can also add a dataset-name as last argument to one of the
55// calls above
56//
57// Make sure, that database and password are corretly set in a resource
58// file called sql.rc and the resource file is found.
59//
60/////////////////////////////////////////////////////////////////////////////
61#include <iostream>
62#include <iomanip>
63
64#include <TH1.h>
65#include <TPad.h>
66#include <TLine.h>
67#include <TText.h>
68#include <TFrame.h>
69#include <TStyle.h>
70#include <TCanvas.h>
71#include <TPRegexp.h>
72#include <TSQLRow.h>
73#include <TSQLResult.h>
74#include <TGraphErrors.h>
75
76#include "MTime.h"
77#include "MAstro.h"
78#include "MDataSet.h"
79#include "MSQLMagic.h"
80#include "MStatusDisplay.h"
81
82class MPlot : public MParContainer
83{
84public:
85 // Possible constants to group-by (average) over a certain period
86 enum GroupBy_t
87 {
88 kNone,
89 kGroupByPrimary,
90 kGroupByHour,
91 kGroupByDay,
92 kGroupByNight,
93 kGroupByWeek,
94 kGroupByMonth,
95 kGroupBySeason,
96 kGroupByYear
97 };
98
99private:
100 MSQLMagic &fServer; // Reference to the sql-server class
101
102 MDataSet *fDataSet; // A possible dtaset to highlite single points
103
104 TString fPrimaryDate; // The name of the data we plot
105 TString fPrimaryNumber; // The corresponding name for the key number
106 TString fSecondary; // The value versus which the second plot is made
107
108 TString fRequestFrom; // Start of a requested date range
109 TString fRequestTo; // End of a requested date range
110 Int_t fRequestPeriod; // A possible requested period
111
112 Float_t fPlotMin;
113 Float_t fPlotMax;
114
115 Float_t fHistMin;
116 Float_t fHistMax;
117
118 TString fDescription; // The description (title) of the plot
119 TString fNameTab; // The name of the tab in the display
120
121 TString fCondition; // An additional condition added to the query
122 GroupBy_t fGroupBy; // A possible Group-By flag
123
124 // --------------------------------------------------------------------------
125 //
126 // Function to plot the result of the query
127 //
128 void PlotTable(TSQLResult &res, TString name, Float_t fmin, Float_t fmax, Float_t resolution)
129 {
130 // Enable all otions in the statistics box
131 gStyle->SetOptStat(111111);
132
133 // Create TGraph objects
134 TGraph &gt = res.GetFieldCount()>4 ? *new TGraphErrors : *new TGraph;
135 gt.SetNameTitle(Form("%s_time", res.GetFieldName(2)), Form("%s vs %s", res.GetFieldName(2), res.GetFieldName(0)));
136 gt.SetMarkerStyle(kFullDotMedium);
137
138 TGraph gz;
139 gz.SetNameTitle(res.GetFieldName(2), Form("%s vs %s", res.GetFieldName(2), res.GetFieldName(1)));
140 gz.SetMarkerStyle(kFullDotMedium);
141
142 TGraph gt0, gt1;
143 gt0.SetMarkerColor(kRed);
144 gt1.SetMarkerColor(kBlue);
145 gt0.SetMarkerStyle(kFullDotLarge);
146 gt1.SetMarkerStyle(kFullDotLarge);
147
148 TGraph gz0, gz1;
149 gz0.SetMarkerColor(kRed);
150 gz1.SetMarkerColor(kBlue);
151 gz0.SetMarkerStyle(kFullDotLarge);
152 gz1.SetMarkerStyle(kFullDotLarge);
153
154 Int_t first = -1;
155 Int_t last = -1;
156
157 // Loop over the data
158 TSQLRow *row = 0;
159 while ((row=res.Next()))
160 {
161 Int_t pos=0;
162 // Get all fields of this row
163 const char *date = (*row)[pos++];
164 const char *zd = (*row)[pos++];
165 const char *val = (*row)[pos++];
166 const char *zderr = fGroupBy!=kNone ? (*row)[pos++] : 0;
167 const char *verr = fGroupBy!=kNone ? (*row)[pos++] : 0;
168 const char *snum = fDataSet ? (*row)[pos++] : 0;
169
170 delete row;
171
172 if (!date || !val || !zd)
173 continue;
174
175 // check if date is valid
176 MTime t(date);
177 if (!t.SetSqlDateTime(date))
178 continue;
179
180 // check if it belongs to the requested MAGIC period
181 if (fRequestPeriod>0 && MAstro::GetMagicPeriod(t.GetMjd())!=fRequestPeriod)
182 continue;
183
184 // Get axis range
185 if (first<0)
186 first = TMath::Nint(TMath::Floor(t.GetMjd()));
187 last = TMath::Nint(TMath::Ceil(t.GetMjd()));
188
189 // Convert a possible key number into a integer
190 UInt_t seq = snum ? atoi(snum) : 0;
191
192 // convert primary and secondary value into floats
193 Float_t value = atof(val);
194 Float_t zenith = atof(zd);
195
196 // If a datset is given add the point to the special TGraphs
197 // used for highliting these dates
198 if (fDataSet)
199 {
200 if (fDataSet->HasOnSequence(seq))
201 {
202 gt1.SetPoint(gt1.GetN(), t.GetAxisTime(), value);
203 gz1.SetPoint(gz1.GetN(), zenith, value);
204 }
205
206 if (fDataSet->HasOffSequence(seq))
207 {
208 gt0.SetPoint(gt0.GetN(), t.GetAxisTime(), value);
209 gz0.SetPoint(gz0.GetN(), zenith, value);
210 }
211 }
212
213 // Add Data to TGraph
214 gt.SetPoint(gt.GetN(), t.GetAxisTime(), value);
215 gz.SetPoint(gz.GetN(), zenith, value);
216
217 // Set error-bar, if one
218 if (verr)
219 static_cast<TGraphErrors&>(gt).SetPointError(gt.GetN()-1, 0, atof(verr));
220 }
221
222 // If this is done earlier the plots remain empty since root 5.12/00
223 if (fmax>fmin)
224 {
225 gt.SetMinimum(fmin);
226 gt.SetMaximum(fmax);
227 gz.SetMinimum(fmin);
228 gz.SetMaximum(fmax);
229 }
230
231 gROOT->SetSelectedPad(0);
232
233 TString cname = fNameTab.IsNull() ? name(name.First('.')+2, name.Length()) : fNameTab;
234 TString ctitle = fDescription.IsNull() ? name.Data() : fDescription.Data();
235 if (ctitle.First(';')>0)
236 ctitle.Remove(ctitle.First(';'), ctitle.Length());
237
238 // Create a TCanvas or open a new tab
239 TCanvas &c = fDisplay ? fDisplay->AddTab(cname, ctitle) : *new TCanvas(cname, ctitle);
240 // Set fillcolor, remove border and divide pad
241 c.SetFillColor(kWhite);
242 c.SetFrameBorderMode(0);
243 c.SetBorderMode(0);
244 c.Divide(1,2);
245
246 // Output mean and rms to console
247 cerr << setprecision(4) << setw(10) << cname << ": ";
248 if (gt.GetN()==0)
249 {
250 cerr << " <empty>" << endl;
251 return;
252 }
253 cerr << setw(8) << gt.GetMean(2) << "+-" << setw(8) << gt.GetRMS(2) << " ";
254 if (gt0.GetN()>0 || gt1.GetN()>0)
255 {
256 cerr << setw(8) << gt1.GetMean(2) << "+-" << setw(8) << gt1.GetRMS(2) << " ";
257 cerr << setw(8) << gt0.GetMean(2) << "+-" << setw(8) << gt0.GetRMS(2);
258 }
259 cerr << endl;
260
261 // format axis
262 TH1 *h = gt.GetHistogram();
263
264 const Double_t min = fHistMin>fHistMax ? h->GetMinimum()-resolution/2 : fHistMin;
265 const Double_t max = fHistMin>fHistMax ? h->GetMaximum()+resolution/2 : fHistMax;
266
267 // Create histogram
268 const Int_t n = resolution>0 ? TMath::Nint((max-min)/resolution) : 50;
269
270 TH1F hist("Hist", Form("Distribution of %s", fDescription.IsNull() ? name.Data() : fDescription.Data()), n, min, max);
271 hist.SetDirectory(0);
272
273 // Fill data into histogra,
274 for (int i=0; i<gt.GetN(); i++)
275 hist.Fill(gt.GetY()[i]);
276
277 // Format histogram
278 if (fDescription.IsNull())
279 hist.SetXTitle(name);
280 hist.SetYTitle("Counts");
281
282 TVirtualPad *pad = gPad;
283
284 // draw contants of pad 2 (counting starts at 0)
285 pad->cd(2);
286 gPad->SetBorderMode(0);
287 gPad->SetFrameBorderMode(0);
288 gPad->SetGridy();
289
290 gPad->SetLeftMargin(0.06);
291 gPad->SetRightMargin(0.06);
292 gPad->SetBottomMargin(0.08);
293
294 h->SetXTitle("Time");
295 h->SetYTitle(hist.GetXaxis()->GetTitle());
296 h->GetXaxis()->SetTimeDisplay(1);
297 h->GetYaxis()->SetTitleOffset(0.8);
298 h->GetXaxis()->SetTitleOffset(1.0);
299 h->GetXaxis()->SetLabelOffset(0.01);
300
301 // draw TGraph
302 gROOT->SetSelectedPad(0);
303 gt.DrawClone("AP");
304 if (gt0.GetN()>0)
305 gt0.DrawClone("P");
306 if (gt1.GetN()>0)
307 gt1.DrawClone("P");
308
309 // Add lines and text showing the MAGIC periods
310 TLine l;
311 TText t;
312 Int_t num=0;
313 l.SetLineStyle(kDotted);
314 l.SetLineColor(kBlue);
315 t.SetTextColor(kBlue);
316 l.SetLineWidth(1);
317 t.SetTextSize(h->GetXaxis()->GetLabelSize());
318 t.SetTextAlign(21);
319 Int_t p0 = MAstro::GetMagicPeriod(first);
320 for (Int_t p = first; p<last; p++)
321 {
322 Int_t p1 = MAstro::GetMagicPeriod(p);
323 if (p1!=p0)
324 {
325 l.DrawLine(MTime(p).GetAxisTime(), h->GetMinimum(), MTime(p).GetAxisTime(), h->GetMaximum());
326 t.DrawText(MTime(p+15).GetAxisTime(), h->GetMaximum(), Form("%d", p1));
327 num++;
328 }
329 p0 = p1;
330 }
331 if (num<4)
332 gPad->SetGridx();
333
334 // Go back to first (upper) pad, format it and divide it again
335 pad->cd(1);
336 gPad->SetBorderMode(0);
337 gPad->SetFrameBorderMode(0);
338 gPad->Divide(2,1);
339
340 TVirtualPad *pad2 = gPad;
341
342 // format left pad
343 pad2->cd(1);
344 gPad->SetBorderMode(0);
345 gPad->SetFrameBorderMode(0);
346 gPad->SetGridx();
347 gPad->SetGridy();
348
349 // plot histogram
350 hist.DrawCopy("");
351
352 // format right pad
353 pad2->cd(2);
354 gPad->SetBorderMode(0);
355 gPad->SetFrameBorderMode(0);
356 gPad->SetGridy();
357
358 // draw graph
359 gROOT->SetSelectedPad(0);
360 gz.GetXaxis()->SetTitle(res.GetFieldName(1));
361 gz.GetYaxis()->SetTitle(hist.GetXaxis()->GetTitle());
362 gz.DrawClone("AP");
363
364 if (gz0.GetN()>0)
365 gz0.DrawClone("P");
366 if (gz1.GetN()>0)
367 gz1.DrawClone("P");
368 }
369
370public:
371 MPlot(MSQLMagic &server) : fServer(server), fDataSet(NULL),
372 fRequestPeriod(-1), fPlotMin(0), fPlotMax(-1), fHistMin(0), fHistMax(-1), fGroupBy(kNone)
373 {
374 }
375 ~MPlot()
376 {
377 if (fDataSet)
378 delete fDataSet;
379 }
380 void SetDataSet(const TString filename)
381 {
382 if (fDataSet)
383 {
384 delete fDataSet;
385 fDataSet = NULL;
386 }
387
388 fPrimaryNumber="";
389
390 if (filename.IsNull())
391 return;
392
393 fDataSet = new MDataSet(filename);
394 fPrimaryNumber="Sequences.fSequenceFirst";
395 }
396 void SetPlotRange(Float_t min, Float_t max/*, Int_t n=5*/) { fPlotMin = min; fPlotMax = max; }
397 void SetHistRange(Float_t min, Float_t max) { fHistMin = min; fHistMax = max; }
398 void SetRequestRange(const char *from="", const char *to="") { fRequestFrom = from; fRequestTo = to; }
399 void SetRequestPeriod(Int_t n=-1) { fRequestPeriod = n; }
400 void SetCondition(const char *cond="") { fCondition = cond; }
401 void SetDescription(const char *d, const char *t=0) { fDescription = d; fNameTab = t; }
402 void SetTabName(const char *t) { fNameTab = t; }
403 void SetGroupBy(GroupBy_t b=kGroupByWeek) { fGroupBy=b; }
404 void SetPrimaryDate(const char *ts) { fPrimaryDate=ts; }
405 void SetPrimaryNumber(const char *ts) { }
406 void SetSecondary(const char *ts) { fSecondary=ts; }
407
408 MStatusDisplay *GetDisplay() { return fDisplay; }
409 MSQLMagic &GetServer() { return fServer; }
410
411 Bool_t Plot(const char *value, Float_t min=0, Float_t max=-1, Float_t resolution=0)
412 {
413 TString named = fPrimaryDate;
414 TString named2 = fSecondary;
415 TString namev = value;
416
417 TString tablev = namev(0, namev.First('.'));
418 TString valuev = namev(namev.First('.')+1, namev.Length());
419
420 TString tabled = named(0, named.First('.'));
421 TString valued = named(named.First('.')+1, named.Length());
422
423 TString query="SELECT ";
424 switch (fGroupBy)
425 {
426 case kNone:
427 case kGroupByPrimary:
428 query += Form("%s AS %s", valued.Data(), valued.Data()+1);
429 break;
430 case kGroupByHour:
431 query += Form("DATE_FORMAT(%s, '%%Y-%%m-%%d %%H:30:00') AS %s ", fPrimaryDate.Data(), valued.Data()+1);
432 break;
433 case kGroupByNight:
434 query += Form("DATE_FORMAT(ADDDATE(%s,Interval 12 hour), '%%Y-%%m-%%d 00:00:00') AS %s ", fPrimaryDate.Data(), valued.Data()+1);
435 break;
436 case kGroupByDay:
437 query += Form("DATE_FORMAT(%s, '%%Y-%%m-%%d 00:00:00') AS %s ", fPrimaryDate.Data(), valued.Data()+1);
438 break;
439 case kGroupByWeek:
440 query += Form("DATE_FORMAT(ADDDATE(%s,Interval 12 hour), '%%x%%v') AS %s ", fPrimaryDate.Data(), valued.Data()+1);
441 break;
442 case kGroupByMonth:
443 query += Form("DATE_FORMAT(ADDDATE(%s,Interval 12 hour), '%%Y-%%m-15 00:00:00') AS %s ", fPrimaryDate.Data(), valued.Data()+1);
444 break;
445 case kGroupBySeason:
446 //query += Form("DATE_FORMAT(ADDDATE(%s,Interval 12 hour), '%%Y-%%m-15 00:00:00') AS %s ", fPrimaryDate.Data(), valued.Data()+1);
447 break;
448 case kGroupByYear:
449 query += Form("DATE_FORMAT(ADDDATE(%s,Interval 12 hour), '%%Y-08-15 00:00:00') AS %s ", fPrimaryDate.Data(), valued.Data()+1);
450 break;
451 }
452
453 if (fGroupBy==kNone)
454 {
455 query += ", ";
456 query += fSecondary;
457 query += ", ";
458 query += value;
459 }
460 else
461 {
462 TString v(value);
463 TPRegexp regexp(" +[aA][sS] +[a-zA-Z0-9]+ *$");
464
465 TString as = v(regexp);
466 Ssiz_t p = v.Index(as);
467
468 v.Prepend("(");
469 v.Insert(p<=0?v.Length():p+1, ")");
470
471 query += ", AVG(";
472 query += fSecondary;
473 query += "), AVG(";
474 query += v;
475 query += "), STD(";
476 query += fSecondary;
477 query += "), STD(";
478 query += v;
479 query += ")";
480 }
481
482 if (fDataSet)
483 {
484 query += ", ";
485 query += fPrimaryNumber;
486 }
487
488 query += Form(" FROM %s ", tabled.Data());
489
490 const Bool_t interval = !fRequestFrom.IsNull() && !fRequestTo.IsNull();
491
492 TString where(fCondition);
493 if (interval)
494 {
495 if (!where.IsNull())
496 where += " AND ";
497 where += Form("%s BETWEEN '%s' AND '%s' ",
498 fPrimaryDate.Data(), fRequestFrom.Data(), fRequestTo.Data());
499 }
500
501 // ------------------------------
502
503 query += fServer.GetJoins(tabled, query+" "+where);
504
505 if (!where.IsNull())
506 {
507 query += "WHERE ";
508 query += where;
509 query += " ";
510 }
511
512 if (fGroupBy!=kNone)
513 {
514 query += Form("GROUP BY %s ", valued.Data()+1);
515 //query += Form(" HAVING COUNT(%s)=(COUNT(*)+1)/2 ", valuev.Data());
516 }
517 query += Form("ORDER BY %s ", valued.Data()+1);
518
519 // ------------------------------
520 TSQLResult *res = fServer.Query(query);
521 if (!res)
522 {
523 cout << "ERROR - Query failed: " << query << endl;
524 return kFALSE;
525 }
526
527 if (max>min)
528 PlotTable(*res, namev, min, max, resolution);
529 else
530 PlotTable(*res, namev, fPlotMin, fPlotMax, resolution);
531
532
533 delete res;
534 return kTRUE;
535 }
536// ClassDef(MPlot, 0)
537};
538
539//ClassImp(MPlot);
540
541void plotalldb(MPlot &plot)
542{
543 //plot.SetGroupBy(MPlot::kGroupByMonth);
544 //plot.SetDataSet("dataset.txt");
545
546 plot.SetPrimaryDate("Sequences.fRunStart");
547 plot.SetSecondary("(Sequences.fZenithDistanceMin+Sequences.fZenithDistanceMax)/2 as '<Zd>'");
548
549 //inner camera
550 //from calib*.root
551 plot.SetDescription("Median number of calibration phe in inner pixels;C [phe]", "CalPheI");
552 plot.Plot("Calibration.fMedNumPheInner", 0, 200, 1);
553 plot.SetDescription("Relative rms of calibration charge inner pixels;\\sigma_C [%]", "CalRmsI");
554 plot.Plot("Calibration.fRelChargeRmsInner", 0, 0.5, 0.01);
555 plot.SetDescription("Conversion Factor inner Camera;C_{I} [phe/fadc cnts]", "ConvI");
556 plot.Plot("Calibration.fConvFactorInner", 0, 0.7, 0.002);
557 plot.SetDescription("Mean Arrival Time inner Camera;T_{I} [sl]", "ArrTmI");
558 plot.Plot("Calibration.fArrTimeMeanInner", 0, 40.0, 0.1);
559 plot.SetDescription("RMS Arrival Time inner Camera;\\sigma_{T,I} [sl]", "RmsArrTmI");
560 plot.Plot("Calibration.fArrTimeRmsInner", 0, 4.5, 0.01);
561 plot.SetDescription("Number of unsuitable pixels inner Camera;N_{I}", "UnsuitI");
562 plot.Plot("Calibration.fUnsuitableInner", 0, 75, 1);
563 plot.SetDescription("Number of unsuitable pixels >50%;N", "Unsuit50");
564 plot.Plot("Calibration.fUnsuitable50", 0, 75, 1);
565 plot.SetDescription("Number of unsuitable pixels >1%;N", "Unsuit01");
566 plot.Plot("Calibration.fUnsuitable01", 0, 200, 5);
567
568 //from signal*.root
569 plot.SetDescription("Mean Pedestal RMS inner Camera;\\sigma_{P,I} [phe]", "PedRmsI");
570 plot.Plot("Calibration.fMeanPedRmsInner", 0, 3.5, 0.05);
571 plot.SetDescription("Mean Signal inner Camera;S_{I} [phe]", "SignalI");
572 plot.Plot("Calibration.fMeanSignalInner", 0, 7.0, 0.05);
573
574 plot.SetDescription("Mean PulsePosCheck (maximum slice) inner camera;T [sl]", "ChkPos");
575 plot.Plot("Calibration.fPulsePosCheckMean", 1, 50.0, 0.1);
576 plot.SetDescription("Rms PulsePosCheck (maximum slice) inner camera;T [sl]", "ChkRms");
577 plot.Plot("Calibration.fPulsePosCheckRms", 0, 12.0, 0.1);
578 plot.SetDescription("Mean calibrated PulsePos (as extracted);T [ns]", "PulPos");
579 plot.Plot("Calibration.fPulsePosMean", 1, 40.0, 0.1);
580 plot.SetDescription("Rms calibrated PulsePos (as extracted);T [ns]", "PulRms");
581 plot.Plot("Calibration.fPulsePosRms", 0, 3.0, 0.02);
582
583 plot.SetDescription("Ratio of accepted calibration events in cal-run;f [%]", "RatioCal");
584 plot.Plot("Calibration.fRatioCalEvents", 0, 105, 5);
585
586 plot.SetDescription("Average rate of events with lvl1 trigger;R [Hz]", "RateTrig");
587 plot.Plot("Calibration.fRateTrigEvts", 0, 500, 5);
588 plot.SetDescription("Average rate of events with only Sum trigger;R [Hz]", "RateSum");
589 plot.Plot("Calibration.fRateSumEvts", 0, 1500, 5);
590 //plot.SetDescription("Ratio of only Sum to Lvl1 triggers;R [Hz]", "RateRatio");
591 //plot.Plot("100*Calibration.fRateSumEvts/Calibration.fRateTrigEvts", 0, 500, 1);
592 plot.SetDescription("Average rate of events with calibration trigger;R [Hz]", "RateCal");
593 plot.Plot("Calibration.fRateCalEvts", 0, 75, 1);
594 plot.SetDescription("Average rate of events with pedestal trigger;R [Hz]", "RatePed");
595 plot.Plot("Calibration.fRatePedEvts", 0, 50, 1);
596 plot.SetDescription("Average rate of events with ped+cosmics trigger;R [Hz]", "RatePT");
597 plot.Plot("Calibration.fRatePedTrigEvts", 0, 4.0, 0.1);
598 plot.SetDescription("Average rate of events without trigger pattern;R [Hz]", "Rate0");
599 plot.Plot("Calibration.fRateNullEvts", 0, 3.5, 0.1);
600 plot.SetDescription("Average rate of unknown trigger pattern;R [Hz]", "RateUnknown");
601 plot.Plot("Calibration.fRateUnknownEvts", 0, 3.5, 0.1);
602
603 plot.SetDescription("Hi-/Lo-Gain offset;", "PulOff");
604 plot.Plot("Calibration.fPulsePosOffMed", -0.33, 0.5, 0.01);
605 plot.SetDescription("Hi-/Lo-Gain ratio;", "HiLoRatio");
606 plot.Plot("Calibration.fHiLoGainRatioMed", 10, 15, 0.05);
607
608 //plot.SetDescription("Pulse Variance;", "PulVar");
609 //plot.Plot("Calibration.fPulsePosVar", 0, 0.03, 0.001);
610
611 //from star*.root
612 //muon
613 plot.SetCondition("Star.fMuonNumber>300");
614 plot.SetDescription("Point Spred Function;PSF [mm]");
615 plot.Plot("Star.fPSF", 0, 30, 0.5);
616 plot.SetDescription("Muon Calibration Ratio Data/MC;r [1]", "MuonCal");
617 plot.Plot("Star.fRatio", 0, 200, 0.5);
618 plot.SetDescription("Muon Rate after Muon Cuts;R [Hz]");
619 plot.Plot("Star.fMuonRate", 0, 2.0, 0.05);
620 plot.SetCondition();
621
622 //quality
623 plot.SetDescription("Datarate [Hz]", "Rate");
624 plot.Plot("Star.fDataRate", 0, 600, 10);
625 plot.SetDescription("Camera Inhomogeneity;\\sigma [%]", "Inhom");
626 plot.Plot("Star.fInhomogeneity", 0, 100, 1);
627 plot.SetDescription("Camera Spark Rate;R [Hz]", "Sparks");
628 plot.Plot("Star.fSparkRate", 0.075, 2.425, 0.05);
629 plot.SetDescription("Relative effective on time;T_{eff}/T_{obs} [ratio]", "RelTime");
630 plot.Plot("Star.fEffOnTime/Sequences.fRunTime", 0.006, 1.506, 0.01);
631 //imgpar
632 plot.SetDescription("Mean Number of Islands after cleaning;N [#]", "NumIsl");
633 plot.Plot("Star.fMeanNumberIslands", 0.5, 4.5, 0.01);
634 //weather
635 plot.SetCondition("");
636 plot.SetDescription("Average Temperature [\\circ C];T [\\circ C]", "Temp");
637 plot.Plot("Star.fAvgTemperature", -5, 25, 1);
638 plot.SetDescription("Average Cloudiness [%]", "AvgClouds");
639 plot.Plot("Star.fAvgCloudiness", 0, 100, 1);
640 plot.SetDescription("RMS Cloudiness [%]", "RmsClouds");
641 plot.Plot("Star.fRmsCloudiness", 0, 30, 1);
642 plot.SetDescription("Sky Temperature [K]", "SkyTemp");
643 plot.Plot("Star.fAvgTempSky", 180, 280, 1);
644 plot.SetDescription("Maximum Humidity [%]", "MaxHum");
645 plot.Plot("Star.fMaxHumidity", 0, 100, 1);
646 plot.SetDescription("Average Humidity [%]", "AvgHum");
647 plot.Plot("Star.fAvgHumidity", 0, 100, 1);
648 plot.SetDescription("Average Wind Speed [km/h];v [km/h]", "Wind");
649 plot.Plot("Star.fAvgWindSpeed", 0, 50, 1);
650
651 //currents
652 plot.SetSecondary("Calibration.fMeanPedRmsInner as '<PedRMS_{I}>'");
653 plot.SetDescription("Minimum average DC current [nA];<I_{min}> [nA]", "MinDC");
654 plot.Plot("Star.fMinCurrents", 0, 25, 0.1);
655 plot.SetDescription("Median average DC current [nA];<I_{med}> [nA]", "MedDC");
656 plot.Plot("Star.fMedCurrents", 0, 25, 0.1);
657 plot.SetDescription("Maximum average DC current [nA];<I_{max}> [nA]", "MaxDC");
658 plot.Plot("Star.fMaxCurrents", 0, 25, 0.1);
659 plot.SetSecondary("(Sequences.fZenithDistanceMin+Sequences.fZenithDistanceMax)/2 as '<Zd>'");
660
661 //muon
662 //plot.SetDescription("Number of Muons after Muon Cuts;N [#]");
663 //plot.Plot("Star.fMuonNumber", 0, 10000, 100);
664
665 // starguider
666 plot.SetDescription("Median No. Stars recognized by the starguider;N_{0}", "StarsMed");
667 plot.Plot("Star.fNumStarsMed", 0, 100, 1);
668 plot.SetDescription("RMS No. Stars recognized by the starguider;\\sigma_{N_{0}}", "StarsRMS");
669 plot.Plot("Star.fNumStarsRMS", 0, 25, 1);
670 plot.SetDescription("Median No. Stars correlated by the starguider;N", "CorMed");
671 plot.Plot("Star.fNumStarsCorMed", 0, 100, 1);
672 plot.SetDescription("RMS No. Stars correlated by the starguider;\\sigma_{N}", "CorRMS");
673 plot.Plot("Star.fNumStarsCorRMS", 0, 25, 1);
674 plot.SetDescription("Relative number of correlated stars;N/N_{0} [%]", "StarsRel");
675 plot.Plot("Star.fNumStarsCorMed/Star.fNumStarsMed*100", 0, 100, 10);
676 plot.SetDescription("Median skbrightess measured by the starguider;B [au]", "BrightMed");
677 plot.Plot("Star.fBrightnessMed", 0, 111, 1);
678 plot.SetDescription("RMS skybrightess measured by the starguider;\\sigma_{B} [au]", "BrightRMS");
679 plot.Plot("Star.fBrightnessRMS", 0, 64, 1);
680
681 //outer camera
682 //from calib*.root
683 plot.SetDescription("Median number of calibration phe in outer pixels;C [phe]", "CalPheO");
684 plot.Plot("Calibration.fMedNumPheOuter", 0, 200, 1);
685 plot.SetDescription("Relative rms of calibration charge outer pixels;\\sigma_C [%]", "CalRmsO");
686 plot.Plot("Calibration.fRelChargeRmsOuter", 0, 0.5, 0.01);
687 plot.SetDescription("Conversion Factor outer Camera;C_{O} [phe/fadc cnts]", "ConvO");
688 plot.Plot("Calibration.fConvFactorOuter", 0, 3.0, 0.01);
689 plot.SetDescription("Mean Arrival Time outer Camera;T_{O} [sl]", "ArrTmO");
690 plot.Plot("Calibration.fArrTimeMeanOuter", 0, 45, 0.1);
691 plot.SetDescription("RMS Arrival Time outer Camera;\\sigma_{T,O} [sl]", "RmsArrTmO");
692 plot.Plot("Calibration.fArrTimeRmsOuter", 0, 4.5, 0.01);
693 plot.SetDescription("Number of unsuitable pixels outer Camera;N_{O}", "UnsuitO");
694 plot.Plot("Calibration.fUnsuitableOuter", 0, 25, 1);
695 //from signal*.root
696 plot.SetDescription("Mean Pedestal RMS outer Camera;\\sigma_{P,O} [phe]", "PedRmsO");
697 plot.Plot("Calibration.fMeanPedRmsOuter", 0, 4.0, 0.05);
698 plot.SetDescription("Mean Signal outer Camera;S_{O} [phe]", "SignalO");
699 plot.Plot("Calibration.fMeanSignalOuter", 0, 4.0, 0.05);
700}
701
702int plotdb(TString from, TString to, const char *dataset=0)
703{
704 MSQLMagic serv("sql.rc");
705 if (!serv.IsConnected())
706 {
707 cout << "ERROR - Connection to database failed." << endl;
708 return 0;
709 }
710
711 cout << "plotdb" << endl;
712 cout << "------" << endl;
713 cout << endl;
714 cout << "Connected to " << serv.GetName() << endl;
715 cout << endl;
716
717 MStatusDisplay *d = new MStatusDisplay;
718 d->SetWindowName(serv.GetName());
719 d->SetTitle(serv.GetName());
720
721 MPlot plot(serv);
722 plot.SetDataSet(dataset);
723 plot.SetDisplay(d);
724 plot.SetRequestRange(from, to);
725 plotalldb(plot);
726 d->SaveAsRoot("plotdb.root");
727 //d->SaveAsPS("plotdb.ps");
728
729 return 1;
730}
731
732int plotdb(const char *ds, TString path)
733{
734 MSQLMagic serv("sql.rc");
735 if (!serv.IsConnected())
736 {
737 cout << "ERROR - Connection to database failed." << endl;
738 return 0;
739 }
740
741 cout << "plotdb" << endl;
742 cout << "------" << endl;
743 cout << endl;
744 cout << "Connected to " << serv.GetName() << endl;
745 cout << endl;
746
747 MStatusDisplay *d = new MStatusDisplay;
748 d->SetWindowName(serv.GetName());
749 d->SetTitle(serv.GetName());
750
751 MPlot plot(serv);
752 plot.SetDataSet(ds);
753 plot.SetDisplay(d);
754 plot.SetRequestRange("", "");
755 plotalldb(plot);
756 d->SaveAsRoot(path+"plotdb.root");
757// d->SaveAsPS("plotdb.ps");
758
759 return 1;
760}
761
762int plotdb(TString path)
763{
764 MSQLMagic serv("sql.rc");
765 if (!serv.IsConnected())
766 {
767 cout << "ERROR - Connection to database failed." << endl;
768 return 0;
769 }
770
771 cout << "plotdb" << endl;
772 cout << "------" << endl;
773 cout << endl;
774 cout << "Connected to " << serv.GetName() << endl;
775 cout << endl;
776
777 MStatusDisplay *d = new MStatusDisplay;
778 d->SetWindowName(serv.GetName());
779 d->SetTitle(serv.GetName());
780
781 MPlot plot(serv);
782// plot.SetDataSet(ds);
783 plot.SetDisplay(d);
784 plot.SetRequestRange("", "");
785 plotalldb(plot);
786 d->SaveAsRoot(path+"plotdb.root");
787// d->SaveAsPS("plotdb.ps");
788
789 return 1;
790}
791
792int plotdb(Int_t period, const char *dataset="")
793{
794 MSQLMagic serv("sql.rc");
795 if (!serv.IsConnected())
796 {
797 cout << "ERROR - Connection to database failed." << endl;
798 return 0;
799 }
800
801 cout << "plotdb" << endl;
802 cout << "------" << endl;
803 cout << endl;
804 cout << "Connected to " << serv.GetName() << endl;
805 cout << endl;
806
807 MStatusDisplay *d = new MStatusDisplay;
808 d->SetWindowName(serv.GetName());
809 d->SetTitle(serv.GetName());
810
811 MPlot plot(serv);
812 plot.SetDataSet(dataset);
813 plot.SetDisplay(d);
814 plot.SetRequestPeriod(period);
815 plotalldb(plot);
816 d->SaveAsRoot("plotdb.root");
817 //d->SaveAsPS("plotdb.ps");
818
819 return 1;
820}
821
822int plotdb()
823{
824 return plotdb("", "", "");
825}
Note: See TracBrowser for help on using the repository browser.