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

Last change on this file since 9096 was 9067, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 28.2 KB
Line 
1/* ======================================================================== *\
2! $Name: not supported by cvs2svn $:$Id: plotdb.C,v 1.51 2008-08-01 13:41: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, 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 += v;
473 query += ", AVG(";
474 query += fSecondary;
475 query += "), STD";
476 query += v;
477 query += ", STD(";
478 query += fSecondary;
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
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::kGroupByNight);
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, 4.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", 0, 200, 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, 2.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.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 //muon
652 //plot.SetDescription("Number of Muons after Muon Cuts;N [#]");
653 //plot.Plot("Star.fMuonNumber", 0, 10000, 100);
654
655 // starguider
656 plot.SetDescription("Median No. Stars recognized by the starguider;N_{0}", "StarsMed");
657 plot.Plot("Star.fNumStarsMed", 0, 100, 1);
658 plot.SetDescription("RMS No. Stars recognized by the starguider;\\sigma_{N_{0}}", "StarsRMS");
659 plot.Plot("Star.fNumStarsRMS", 0, 25, 1);
660 plot.SetDescription("Median No. Stars correlated by the starguider;N", "CorMed");
661 plot.Plot("Star.fNumStarsCorMed", 0, 100, 1);
662 plot.SetDescription("RMS No. Stars correlated by the starguider;\\sigma_{N}", "CorRMS");
663 plot.Plot("Star.fNumStarsCorRMS", 0, 25, 1);
664 plot.SetDescription("Relative number of correlated stars;N/N_{0} [%]", "StarsRel");
665 plot.Plot("Star.fNumStarsCorMed/Star.fNumStarsMed*100", 0, 100, 10);
666 plot.SetDescription("Median skbrightess measured by the starguider;B [au]", "BrightMed");
667 plot.Plot("Star.fBrightnessMed", 0, 111, 1);
668 plot.SetDescription("RMS skybrightess measured by the starguider;\\sigma_{B} [au]", "BrightRMS");
669 plot.Plot("Star.fBrightnessRMS", 0, 64, 1);
670
671 //outer camera
672 //from calib*.root
673 plot.SetDescription("Median number of calibration phe in outer pixels;C [phe]", "CalPheO");
674 plot.Plot("Calibration.fMedNumPheOuter", 0, 200, 1);
675 plot.SetDescription("Relative rms of calibration charge outer pixels;\\sigma_C [%]", "CalRmsO");
676 plot.Plot("Calibration.fRelChargeRmsOuter", 0, 0.5, 0.01);
677 plot.SetDescription("Conversion Factor outer Camera;C_{O} [phe/fadc cnts]", "ConvO");
678 plot.Plot("Calibration.fConvFactorOuter", 0, 3.0, 0.01);
679 plot.SetDescription("Mean Arrival Time outer Camera;T_{O} [sl]", "ArrTmO");
680 plot.Plot("Calibration.fArrTimeMeanOuter", 0, 45, 0.1);
681 plot.SetDescription("RMS Arrival Time outer Camera;\\sigma_{T,O} [sl]", "RmsArrTmO");
682 plot.Plot("Calibration.fArrTimeRmsOuter", 0, 4.5, 0.01);
683 plot.SetDescription("Number of unsuitable pixels outer Camera;N_{O}", "UnsuitO");
684 plot.Plot("Calibration.fUnsuitableOuter", 0, 25, 1);
685 //from signal*.root
686 plot.SetDescription("Mean Pedestal RMS outer Camera;\\sigma_{P,O} [phe]", "PedRmsO");
687 plot.Plot("Calibration.fMeanPedRmsOuter", 0, 4.0, 0.05);
688 plot.SetDescription("Mean Signal outer Camera;S_{O} [phe]", "SignalO");
689 plot.Plot("Calibration.fMeanSignalOuter", 0, 4.0, 0.05);
690}
691
692int plotdb(TString from, TString to, const char *dataset=0)
693{
694 MSQLMagic serv("sql.rc");
695 if (!serv.IsConnected())
696 {
697 cout << "ERROR - Connection to database failed." << endl;
698 return 0;
699 }
700
701 cout << "plotdb" << endl;
702 cout << "------" << endl;
703 cout << endl;
704 cout << "Connected to " << serv.GetName() << endl;
705 cout << endl;
706
707 MStatusDisplay *d = new MStatusDisplay;
708 d->SetWindowName(serv.GetName());
709 d->SetTitle(serv.GetName());
710
711 MPlot plot(serv);
712 plot.SetDataSet(dataset);
713 plot.SetDisplay(d);
714 plot.SetRequestRange(from, to);
715 plotalldb(plot);
716 d->SaveAsRoot("plotdb.root");
717 d->SaveAsPS("plotdb.ps");
718
719 return 1;
720}
721
722int plotdb(const char *ds)
723{
724 MSQLMagic serv("sql.rc");
725 if (!serv.IsConnected())
726 {
727 cout << "ERROR - Connection to database failed." << endl;
728 return 0;
729 }
730
731 cout << "plotdb" << endl;
732 cout << "------" << endl;
733 cout << endl;
734 cout << "Connected to " << serv.GetName() << endl;
735 cout << endl;
736
737 MStatusDisplay *d = new MStatusDisplay;
738 d->SetWindowName(serv.GetName());
739 d->SetTitle(serv.GetName());
740
741 MPlot plot(serv);
742 plot.SetDataSet(ds);
743 plot.SetDisplay(d);
744 plot.SetRequestRange("", "");
745 plotalldb(plot);
746 d->SaveAsRoot("plotdb.root");
747 d->SaveAsPS("plotdb.ps");
748
749 return 1;
750}
751
752int plotdb(Int_t period, const char *dataset="")
753{
754 MSQLMagic serv("sql.rc");
755 if (!serv.IsConnected())
756 {
757 cout << "ERROR - Connection to database failed." << endl;
758 return 0;
759 }
760
761 cout << "plotdb" << endl;
762 cout << "------" << endl;
763 cout << endl;
764 cout << "Connected to " << serv.GetName() << endl;
765 cout << endl;
766
767 MStatusDisplay *d = new MStatusDisplay;
768 d->SetWindowName(serv.GetName());
769 d->SetTitle(serv.GetName());
770
771 MPlot plot(serv);
772 plot.SetDataSet(dataset);
773 plot.SetDisplay(d);
774 plot.SetRequestPeriod(period);
775 plotalldb(plot);
776 d->SaveAsRoot("plotdb.root");
777 d->SaveAsPS("plotdb.ps");
778
779 return 1;
780}
781
782int plotdb()
783{
784 return plotdb("", "");
785}
Note: See TracBrowser for help on using the repository browser.