source: trunk/Mars/datacenter/macros/plotdb.C@ 10503

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