source: tags/Mars-V2.1/datacenter/macros/plotdb.C

Last change on this file was 8965, checked in by tbretz, 17 years ago
*** empty log message ***
File size: 27.1 KB
Line 
1/* ======================================================================== *\
2! $Name: not supported by cvs2svn $:$Id: plotdb.C,v 1.45 2008-06-16 14:58:26 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 <TEnv.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 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(name, Form("%s vs Time", name.Data()));
136 gt.SetMarkerStyle(kFullDotMedium);
137
138 TGraph gz;
139 gz.SetNameTitle(name, Form("%s vs <Zd>", name.Data()));
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 // Get all fields of this row
162 const char *date = (*row)[0];
163 const char *zd = (*row)[1];
164 const char *val = (*row)[2];
165 const char *snum = res.GetFieldCount()>3 ? (*row)[3] : 0;
166 const char *verr = res.GetFieldCount()>4 ? (*row)[5] : 0;
167
168 delete row;
169
170 if (!date || !val || !zd)
171 continue;
172
173 // check if date is valid
174 MTime t(date);
175 if (!t.SetSqlDateTime(date))
176 continue;
177
178 // check if it belongs to the requested MAGIC period
179 if (fRequestPeriod>0 && MAstro::GetMagicPeriod(t.GetMjd())!=fRequestPeriod)
180 continue;
181
182 // Get axis range
183 if (first<0)
184 first = TMath::Nint(TMath::Floor(t.GetMjd()));
185 last = TMath::Nint(TMath::Ceil(t.GetMjd()));
186
187 // Convert a possible key number into a integer
188 UInt_t seq = snum ? atoi(snum) : 0;
189
190 // convert primary and secondary value into floats
191 Float_t value = atof(val);
192 Float_t zenith = atof(zd);
193
194 // If a datset is given add the point to the special TGraphs
195 // used for highliting these dates
196 if (fDataSet)
197 {
198 if (fDataSet->HasOnSequence(seq))
199 {
200 gt1.SetPoint(gt1.GetN(), t.GetAxisTime(), value);
201 gz1.SetPoint(gz1.GetN(), zenith, value);
202 }
203
204 if (fDataSet->HasOffSequence(seq))
205 {
206 gt0.SetPoint(gt0.GetN(), t.GetAxisTime(), value);
207 gz0.SetPoint(gz0.GetN(), zenith, value);
208 }
209 }
210
211 // Add Data to TGraph
212 gt.SetPoint(gt.GetN(), t.GetAxisTime(), value);
213 gz.SetPoint(gz.GetN(), zenith, value);
214
215 // Set error-bar, if one
216 if (verr)
217 static_cast<TGraphErrors&>(gt).SetPointError(gt.GetN()-1, 0, atof(verr));
218 }
219
220 // If this is done earlier the plots remain empty since root 5.12/00
221 if (fmax>fmin)
222 {
223 gt.SetMinimum(fmin);
224 gt.SetMaximum(fmax);
225 gz.SetMinimum(fmin);
226 gz.SetMaximum(fmax);
227 }
228
229 gROOT->SetSelectedPad(0);
230
231 TString cname = fNameTab.IsNull() ? name(name.First('.')+2, name.Length()) : fNameTab;
232 TString ctitle = fDescription.IsNull() ? name.Data() : fDescription.Data();
233 if (ctitle.First(';')>0)
234 ctitle.Remove(ctitle.First(';'), ctitle.Length());
235
236 // Create a TCanvas or open a new tab
237 TCanvas &c = fDisplay ? fDisplay->AddTab(cname, ctitle) : *new TCanvas(cname, ctitle);
238 // Set fillcolor, remove border and divide pad
239 c.SetFillColor(kWhite);
240 c.SetFrameBorderMode(0);
241 c.SetBorderMode(0);
242 c.Divide(1,2);
243
244 // Output mean and rms to console
245 cerr << setprecision(4) << setw(10) << cname << ": ";
246 if (gt.GetN()==0)
247 {
248 cerr << " <empty>" << endl;
249 return;
250 }
251 cerr << setw(8) << gt.GetMean(2) << "+-" << setw(8) << gt.GetRMS(2) << " ";
252 if (gt0.GetN()>0 || gt1.GetN()>0)
253 {
254 cerr << setw(8) << gt1.GetMean(2) << "+-" << setw(8) << gt1.GetRMS(2) << " ";
255 cerr << setw(8) << gt0.GetMean(2) << "+-" << setw(8) << gt0.GetRMS(2);
256 }
257 cerr << endl;
258
259 TVirtualPad *pad = gPad;
260
261 // draw contants of pad 2 (counting starts at 0)
262 pad->cd(2);
263 gPad->SetBorderMode(0);
264 gPad->SetFrameBorderMode(0);
265 gPad->SetGridy();
266
267 gPad->SetLeftMargin(0.06);
268 gPad->SetRightMargin(0.06);
269 gPad->SetBottomMargin(0.08);
270
271 // format axis
272 TH1 *h = gt.GetHistogram();
273
274 h->SetXTitle("Time");
275 h->SetYTitle(name);
276 h->GetXaxis()->SetTimeDisplay(1);
277 h->GetYaxis()->SetTitleOffset(0.8);
278 h->GetXaxis()->SetTitleOffset(1.0);
279 h->GetXaxis()->SetLabelOffset(0.01);
280
281 // draw TGraph
282 gROOT->SetSelectedPad(0);
283 gt.DrawClone("AP");
284 if (gt0.GetN()>0)
285 gt0.DrawClone("P");
286 if (gt1.GetN()>0)
287 gt1.DrawClone("P");
288
289 // Add lines and text showing the MAGIC periods
290 TLine l;
291 TText t;
292 Int_t num=0;
293 l.SetLineStyle(kDotted);
294 l.SetLineColor(kBlue);
295 t.SetTextColor(kBlue);
296 l.SetLineWidth(1);
297 t.SetTextSize(h->GetXaxis()->GetLabelSize());
298 t.SetTextAlign(21);
299 Int_t p0 = MAstro::GetMagicPeriod(first);
300 for (Int_t p = first; p<last; p++)
301 {
302 Int_t p1 = MAstro::GetMagicPeriod(p);
303 if (p1!=p0)
304 {
305 l.DrawLine(MTime(p).GetAxisTime(), h->GetMinimum(), MTime(p).GetAxisTime(), h->GetMaximum());
306 t.DrawText(MTime(p+15).GetAxisTime(), h->GetMaximum(), Form("%d", p1));
307 num++;
308 }
309 p0 = p1;
310 }
311 if (num<4)
312 gPad->SetGridx();
313
314 const Double_t min = fHistMin>fHistMax ? h->GetMinimum()-resolution/2 : fHistMin;
315 const Double_t max = fHistMin>fHistMax ? h->GetMaximum()+resolution/2 : fHistMax;
316
317 // Use this to save the pad with the time development to a file
318 //gPad->SaveAs(Form("plotdb-%s.eps", title.Data()));
319
320 // Go back to first (upper) pad, format it and divide it again
321 pad->cd(1);
322 gPad->SetBorderMode(0);
323 gPad->SetFrameBorderMode(0);
324 gPad->Divide(2,1);
325
326 TVirtualPad *pad2 = gPad;
327
328 // format left pad
329 pad2->cd(1);
330 gPad->SetBorderMode(0);
331 gPad->SetFrameBorderMode(0);
332 gPad->SetGridx();
333 gPad->SetGridy();
334
335 // Create histogram
336 const Int_t n = resolution>0 ? TMath::Nint((max-min)/resolution) : 50;
337
338 TH1F hist("Hist", Form("Distribution of %s", fDescription.IsNull() ? name.Data() : fDescription.Data()), n, min, max);
339 hist.SetDirectory(0);
340
341 // Fill data into histogra,
342 for (int i=0; i<gt.GetN(); i++)
343 hist.Fill(gt.GetY()[i]);
344
345 // Format histogram
346 if (fDescription.IsNull())
347 hist.SetXTitle(name);
348 hist.SetYTitle("Counts");
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 // format graph
360 TH1 *h2 = gz.GetHistogram();
361
362 h2->SetXTitle("Zd");
363 h2->SetYTitle(name);
364
365 // draw graph
366 gROOT->SetSelectedPad(0);
367 gz.DrawClone("AP");
368
369 if (gz0.GetN()>0)
370 gz0.DrawClone("P");
371 if (gz1.GetN()>0)
372 gz1.DrawClone("P");
373 }
374
375public:
376 MPlot(MSQLMagic &server) : fServer(server), fDataSet(NULL),
377 fRequestPeriod(-1), fPlotMin(0), fPlotMax(-1), fHistMin(0), fHistMax(-1), fGroupBy(kNone)
378 {
379 }
380 ~MPlot()
381 {
382 if (fDataSet)
383 delete fDataSet;
384 }
385 void SetDataSet(const TString filename)
386 {
387 if (fDataSet)
388 {
389 delete fDataSet;
390 fDataSet = NULL;
391 }
392 if (!filename.IsNull())
393 fDataSet = new MDataSet(filename);
394 }
395 void SetPlotRange(Float_t min, Float_t max, Int_t n=5) { fPlotMin = min; fPlotMax = max; }
396 void SetHistRange(Float_t min, Float_t max) { fHistMin = min; fHistMax = max; }
397 void SetRequestRange(const char *from="", const char *to="") { fRequestFrom = from; fRequestTo = to; }
398 void SetRequestPeriod(Int_t n=-1) { fRequestPeriod = n; }
399 void SetCondition(const char *cond="") { fCondition = cond; }
400 void SetDescription(const char *d, const char *t=0) { fDescription = d; fNameTab = t; }
401 void SetGroupBy(GroupBy_t b=kGroupByWeek) { fGroupBy=b; }
402 void SetPrimaryDate(const char *ts) { fPrimaryDate=ts; }
403 void SetPrimaryNumber(const char *ts) { fPrimaryNumber=ts; }
404 void SetSecondary(const char *ts) { fSecondary=ts; }
405
406 Bool_t Plot(const char *value, Float_t min=0, Float_t max=-1, Float_t resolution=0)
407 {
408 TString named = fPrimaryDate;
409 TString named2 = fSecondary;
410 TString namev = value;
411
412 TString tablev = namev(0, namev.First('.'));
413 TString valuev = namev(namev.First('.')+1, namev.Length());
414
415 TString tabled = named(0, named.First('.'));
416 TString valued = named(named.First('.')+1, named.Length());
417
418 TString query="SELECT ";
419 switch (fGroupBy)
420 {
421 case kNone:
422 case kGroupByPrimary:
423 query += Form("%s AS %s", valued.Data(), valued.Data()+1);
424 break;
425 case kGroupByHour:
426 query += Form("DATE_FORMAT(%s, '%%Y-%%m-%%d %%H:30:00') AS %s ", fPrimaryDate.Data(), valued.Data()+1);
427 break;
428 case kGroupByNight:
429 query += Form("DATE_FORMAT(ADDDATE(%s,Interval 12 hour), '%%Y-%%m-%%d 00:00:00') AS %s ", fPrimaryDate.Data(), valued.Data()+1);
430 break;
431 case kGroupByWeek:
432 query += Form("DATE_FORMAT(ADDDATE(%s,Interval 12 hour), '%%x%%v') AS %s ", fPrimaryDate.Data(), valued.Data()+1);
433 break;
434 case kGroupByMonth:
435 query += Form("DATE_FORMAT(ADDDATE(%s,Interval 12 hour), '%%Y-%%m-15 00:00:00') AS %s ", fPrimaryDate.Data(), valued.Data()+1);
436 break;
437 case kGroupBySeason:
438 //query += Form("DATE_FORMAT(ADDDATE(%s,Interval 12 hour), '%%Y-%%m-15 00:00:00') AS %s ", fPrimaryDate.Data(), valued.Data()+1);
439 break;
440 case kGroupByYear:
441 query += Form("DATE_FORMAT(ADDDATE(%s,Interval 12 hour), '%%Y-08-15 00:00:00') AS %s ", fPrimaryDate.Data(), valued.Data()+1);
442 break;
443 }
444
445 if (fGroupBy==kNone)
446 {
447 query += ", ";
448 query += fSecondary;
449 query += ", ";
450 query += value;
451 query += ", ";
452 query += fPrimaryNumber;
453 query += " ";
454 }
455 else
456 {
457 query += ", AVG(";
458 query += fSecondary;
459 query += "), AVG(";
460 query += value;
461 query += "), ";
462 query += fPrimaryNumber;
463 query += ", STD(";
464 query += fSecondary;
465 query += "), STD(";
466 query += value;
467 query += ") ";
468 }
469
470 query += Form("FROM %s ", tabled.Data());
471
472 const Bool_t interval = !fRequestFrom.IsNull() && !fRequestTo.IsNull();
473
474 TString where(fCondition);
475 if (!fDataSet && !interval && tablev=="Star")
476 {
477 if (!where.IsNull())
478 where += " AND ";
479 where += "Star.fMuonNumber>300 ";
480 }
481
482 if (interval)
483 {
484 if (!where.IsNull())
485 where += " AND ";
486 where += Form("%s BETWEEN '%s' AND '%s' ",
487 fPrimaryDate.Data(), fRequestFrom.Data(), fRequestTo.Data());
488 }
489
490 // ------------------------------
491
492 query += fServer.GetJoins(tabled, query+" "+where);
493
494 if (!where.IsNull())
495 {
496 query += "WHERE ";
497 query += where;
498 }
499
500 if (fGroupBy!=kNone)
501 {
502 query += Form("GROUP BY %s ", valued.Data()+1);
503 //query += Form(" HAVING COUNT(%s)=(COUNT(*)+1)/2 ", valuev.Data());
504 }
505 query += Form("ORDER BY %s ", valued.Data()+1);
506
507
508 // ------------------------------
509
510 TSQLResult *res = fServer.Query(query);
511 if (!res)
512 {
513 cout << "ERROR - Query failed: " << query << endl;
514 return kFALSE;
515 }
516
517 if (max>min)
518 PlotTable(*res, namev, min, max, resolution);
519 else
520 PlotTable(*res, namev, fPlotMin, fPlotMax, resolution);
521
522
523 delete res;
524 return kTRUE;
525 }
526};
527
528void plotall(MPlot &plot)
529{
530 //plot.SetGroupBy(MPlot::kGroupByNight);
531
532 plot.SetPrimaryDate("Sequences.fRunStart");
533 plot.SetPrimaryNumber("Sequences.fSequenceFirst");
534 plot.SetSecondary("(Sequences.fZenithDistanceMin+Sequences.fZenithDistanceMax)/2");
535
536 //inner camera
537 //from calib*.root
538 plot.SetDescription("Conversion Factor inner Camera;C_{I} [phe/fadc cnts]", "ConvI");
539 plot.Plot("Calibration.fConvFactorInner", 0, 0.7, 0.002);
540 plot.SetDescription("Mean Arrival Time inner Camera;T_{I} [sl]", "ArrTmI");
541 plot.Plot("Calibration.fArrTimeMeanInner", 0, 40.0, 0.1);
542 plot.SetDescription("RMS Arrival Time inner Camera;\\sigma_{T,I} [sl]", "RmsArrTmI");
543 plot.Plot("Calibration.fArrTimeRmsInner", 0, 4.5, 0.01);
544 plot.SetDescription("Number of unsuitable pixels inner Camera;N{I}", "UnsuitI");
545 plot.Plot("Calibration.fUnsuitableInner", 0, 75, 1);
546 plot.SetDescription("Number of unsuitable pixels >50%;N", "Unsuit50");
547 plot.Plot("Calibration.fUnsuitable50", 0, 75, 1);
548 plot.SetDescription("Number of unsuitable pixels >1%;N", "Unsuit01");
549 plot.Plot("Calibration.fUnsuitable01", 0, 200, 5);
550
551 //from signal*.root
552 plot.SetDescription("Mean Pedestal RMS inner Camera;\\sigma_{P,I} [phe]", "PedRmsI");
553 plot.Plot("Calibration.fMeanPedRmsInner", 0, 3.5, 0.05);
554 plot.SetDescription("Mean Signal inner Camera;S_{I} [phe]", "SignalI");
555 plot.Plot("Calibration.fMeanSignalInner", 0, 7.0, 0.05);
556
557 plot.SetDescription("Mean PulsePosCheck (maximum slice) inner camera;T [sl]", "ChkPos");
558 plot.Plot("Calibration.fPulsePosCheckMean", 1, 50.0, 0.1);
559 plot.SetDescription("Rms PulsePosCheck (maximum slice) inner camera;T [sl]", "ChkRms");
560 plot.Plot("Calibration.fPulsePosCheckRms", 0, 12.0, 0.1);
561 plot.SetDescription("Mean calibrated PulsePos (as extracted);T [ns]", "PulPos");
562 plot.Plot("Calibration.fPulsePosMean", 1, 40.0, 0.1);
563 plot.SetDescription("Rms calibrated PulsePos (as extracted);T [ns]", "PulRms");
564 plot.Plot("Calibration.fPulsePosRms", 0, 3.0, 0.02);
565
566 plot.SetDescription("Ratio of accepted calibration events in cal-run;f [%]", "RatioCal");
567 plot.Plot("Calibration.fRatioCalEvents", 0, 105, 5);
568
569 plot.SetDescription("Average rate of events with lvl1 trigger;R [Hz]", "RateTrig");
570 plot.Plot("Calibration.fRateTrigEvts", 0, 500, 5);
571 plot.SetDescription("Average rate of events with only Sum trigger;R [Hz]", "RateSum");
572 plot.Plot("Calibration.fRateSumEvts", 0, 1500, 5);
573 //plot.SetDescription("Ratio of only Sum to Lvl1 triggers;R [Hz]", "RateRatio");
574 //plot.Plot("100*Calibration.fRateSumEvts/Calibration.fRateTrigEvts", 0, 500, 1);
575 plot.SetDescription("Average rate of events with calibration trigger;R [Hz]", "RateCal");
576 plot.Plot("Calibration.fRateCalEvts", 0, 75, 1);
577 plot.SetDescription("Average rate of events with pedestal trigger;R [Hz]", "RatePed");
578 plot.Plot("Calibration.fRatePedEvts", 0, 50, 1);
579 plot.SetDescription("Average rate of events with ped+cosmics trigger;R [Hz]", "RatePT");
580 plot.Plot("Calibration.fRatePedTrigEvts", 0, 3.5, 0.1);
581 plot.SetDescription("Average rate of events without trigger pattern;R [Hz]", "Rate0");
582 plot.Plot("Calibration.fRateNullEvts", 0, 3.5, 0.1);
583 plot.SetDescription("Average rate of unknown trigger pattern;R [Hz]", "RateUnknown");
584 plot.Plot("Calibration.fRateUnknownEvts", 0, 3.5, 0.1);
585
586 plot.SetDescription("Hi-/Lo-Gain offset;", "PulOff");
587 plot.Plot("Calibration.fPulsePosOffMed", -0.33, 0.5, 0.01);
588 plot.SetDescription("Hi-/Lo-Gain ratio;", "HiLoRatio");
589 plot.Plot("Calibration.fHiLoGainRatioMed", 10, 15, 0.05);
590
591 //plot.SetDescription("Pulse Variance;", "PulVar");
592 //plot.Plot("Calibration.fPulsePosVar", 0, 0.03, 0.001);
593
594 //from star*.root
595 //muon
596 plot.SetDescription("Point Spred Function;PSF [mm]");
597 plot.Plot("Star.fPSF", 0, 30, 0.5);
598 plot.SetDescription("Muon Calibration Ratio Data/MC;r [1]", "MuonCal");
599 plot.Plot("Star.fRatio", 0, 200, 0.5);
600 plot.SetDescription("Muon Rate after Muon Cuts;R [Hz]");
601 plot.Plot("Star.fMuonRate", 0, 2.0, 0.05);
602 //quality
603 plot.SetDescription("Datarate [Hz]", "Rate");
604 plot.Plot("Star.fDataRate", 0, 600, 10);
605 plot.SetDescription("Camera Inhomogeneity;\\sigma [%]", "Inhom");
606 plot.Plot("Star.fInhomogeneity", 0, 100, 1);
607 plot.SetDescription("Camera Spark Rate;R [Hz]", "Sparks");
608 plot.Plot("Star.fSparkRate", 0.075, 2.425, 0.05);
609 plot.SetDescription("Relative effective on time;T_{eff}/T_{obs} [ratio]", "RelTime");
610 plot.Plot("Star.fEffOnTime/Sequences.fRunTime", 0.006, 1.506, 0.01);
611 //imgpar
612 plot.SetDescription("Mean Number of Islands after cleaning;N [#]", "NumIsl");
613 plot.Plot("Star.fMeanNumberIslands", 0.5, 4.5, 0.01);
614 //weather
615 plot.SetDescription("Average Temperature [\\circ C];T [\\circ C]", "Temp");
616 plot.Plot("Star.fAvgTemperature", -5, 25, 1);
617 plot.SetDescription("Average Cloudiness [%]", "AvgClouds");
618 plot.Plot("Star.fAvgCloudiness", 0, 100, 1);
619 plot.SetDescription("RMS Cloudiness [%]", "RmsClouds");
620 plot.Plot("Star.fRmsCloudiness", 0, 30, 1);
621 plot.SetDescription("Sky Temperature [K]", "SkyTemp");
622 plot.Plot("Star.fAvgTempSky", 180, 280, 1);
623 plot.SetDescription("Maximum Humidity [%]", "MaxHum");
624 plot.Plot("Star.fMaxHumidity", 0, 100, 1);
625 plot.SetDescription("Average Humidity [%]", "AvgHum");
626 plot.Plot("Star.fAvgHumidity", 0, 100, 1);
627 plot.SetDescription("Average Wind Speed [km/h];v [km/h]", "Wind");
628 plot.Plot("Star.fAvgWindSpeed", 0, 50, 1);
629
630 //muon
631 //plot.SetDescription("Number of Muons after Muon Cuts;N [#]");
632 //plot.Plot("Star.fMuonNumber", 0, 10000, 100);
633
634 // starguider
635 plot.SetDescription("Median No. Stars recognized by the starguider;N_{0}", "StarsMed");
636 plot.Plot("Star.fNumStarsMed", 0, 100, 1);
637 plot.SetDescription("RMS No. Stars recognized by the starguider;\\sigma_{N_{0}}", "StarsRMS");
638 plot.Plot("Star.fNumStarsRMS", 0, 25, 1);
639 plot.SetDescription("Median No. Stars correlated by the starguider;N", "CorMed");
640 plot.Plot("Star.fNumStarsCorMed", 0, 100, 1);
641 plot.SetDescription("RMS No. Stars correlated by the starguider;\\sigma_{N}", "CorRMS");
642 plot.Plot("Star.fNumStarsCorRMS", 0, 25, 1);
643 plot.SetDescription("Relative number of correlated stars;N/N_{0} [%]", "StarsRel");
644 plot.Plot("Star.fNumStarsCorMed/Star.fNumStarsMed*100", 0, 100, 10);
645 plot.SetDescription("Median skbrightess measured by the starguider;B [au]", "BrightMed");
646 plot.Plot("Star.fBrightnessMed", 0, 111, 1);
647 plot.SetDescription("RMS skybrightess measured by the starguider;\\sigma_{B} [au]", "BrightRMS");
648 plot.Plot("Star.fBrightnessRMS", 0, 64, 1);
649
650 //outer camera
651 //from calib*.root
652 plot.SetDescription("Conversion Factor outer Camera;C_{O} [phe/fadc cnts]", "ConvO");
653 plot.Plot("Calibration.fConvFactorOuter", 0, 3.0, 0.01);
654 plot.SetDescription("Mean Arrival Time outer Camera;T_{O} [sl]", "ArrTmO");
655 plot.Plot("Calibration.fArrTimeMeanOuter", 0, 45, 0.1);
656 plot.SetDescription("RMS Arrival Time outer Camera;\\sigma_{T,O} [sl]", "RmsArrTmO");
657 plot.Plot("Calibration.fArrTimeRmsOuter", 0, 4.5, 0.01);
658 plot.SetDescription("Number of unsuitable pixels outer Camera;N{O}", "UnsuitO");
659 plot.Plot("Calibration.fUnsuitableOuter", 0, 25, 1);
660 //from signal*.root
661 plot.SetDescription("Mean Pedestal RMS outer Camera;\\sigma_{P,O} [phe]", "PedRmsO");
662 plot.Plot("Calibration.fMeanPedRmsOuter", 0, 4.0, 0.05);
663 plot.SetDescription("Mean Signal outer Camera;S_{O} [phe]", "SignalO");
664 plot.Plot("Calibration.fMeanSignalOuter", 0, 4.0, 0.05);
665}
666
667int plotdb(TString from, TString to, const char *dataset=0)
668{
669 TEnv env("sql.rc");
670
671 MSQLMagic serv(env);
672 if (!serv.IsConnected())
673 {
674 cout << "ERROR - Connection to database failed." << endl;
675 return 0;
676 }
677
678 cout << "plotdb" << endl;
679 cout << "------" << endl;
680 cout << endl;
681 cout << "Connected to " << serv.GetName() << endl;
682 cout << endl;
683
684 MStatusDisplay *d = new MStatusDisplay;
685 d->SetWindowName(serv.GetName());
686 d->SetTitle(serv.GetName());
687
688 MPlot plot(serv);
689 plot.SetDataSet(dataset);
690 plot.SetDisplay(d);
691 plot.SetRequestRange(from, to);
692 plotall(plot);
693 d->SaveAsRoot("plotdb.root");
694 d->SaveAsPS("plotdb.ps");
695
696 return 1;
697}
698
699int plotdb(const char *ds)
700{
701 TEnv env("sql.rc");
702
703 MSQLMagic serv(env);
704 if (!serv.IsConnected())
705 {
706 cout << "ERROR - Connection to database failed." << endl;
707 return 0;
708 }
709
710 cout << "plotdb" << endl;
711 cout << "------" << endl;
712 cout << endl;
713 cout << "Connected to " << serv.GetName() << endl;
714 cout << endl;
715
716 MStatusDisplay *d = new MStatusDisplay;
717 d->SetWindowName(serv.GetName());
718 d->SetTitle(serv.GetName());
719
720 MPlot plot(serv);
721 plot.SetDataSet(ds);
722 plot.SetDisplay(d);
723 plot.SetRequestRange("", "");
724 plotall(plot);
725 d->SaveAsRoot("plotdb.root");
726 d->SaveAsPS("plotdb.ps");
727
728 return 1;
729}
730
731int plotdb(Int_t period, const char *dataset="")
732{
733 TEnv env("sql.rc");
734
735 MSQLMagic serv(env);
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(dataset);
754 plot.SetDisplay(d);
755 plot.SetRequestPeriod(period);
756 plotall(plot);
757 d->SaveAsRoot("plotdb.root");
758 d->SaveAsPS("plotdb.ps");
759
760 return 1;
761}
762
763int plotdb()
764{
765 return plotdb("", "");
766}
Note: See TracBrowser for help on using the repository browser.