Changeset 8169
- Timestamp:
- 10/27/06 14:36:33 (18 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r8168 r8169 23 23 * datacenter/macros/buildsequenceentries.C: 24 24 - included a fix for 0000-00-00 times in the run-database 25 26 * datacenter/macros/plotdb.C: 27 - implemented a possibility to show average values with RMS 25 28 26 29 -
trunk/MagicSoft/Mars/datacenter/macros/plotdb.C
r8132 r8169 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: plotdb.C,v 1.2 8 2006-10-19 13:57:14tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: plotdb.C,v 1.29 2006-10-27 13:36:18 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 69 69 #include <TFrame.h> 70 70 #include <TStyle.h> 71 #include <TGraph.h>72 71 #include <TCanvas.h> 73 72 #include <TSQLRow.h> 74 73 #include <TSQLResult.h> 74 #include <TGraphErrors.h> 75 75 76 76 #include "MTime.h" … … 82 82 class MPlot : public MParContainer 83 83 { 84 public: 85 enum GroupBy_t 86 { 87 kNone, 88 kGroupByDay, 89 kGroupByWeek, 90 kGroupByMonth, 91 kGroupByYear 92 }; 84 93 private: 85 94 MSQLServer &fServer; … … 87 96 MDataSet *fDataSet; 88 97 89 TString fRequestFrom; 90 TString fRequestTo; 91 Int_t fRequestPeriod; 92 93 Float_t fPlotMin; 94 Float_t fPlotMax; 95 96 Float_t fHistMin; 97 Float_t fHistMax; 98 99 TString fDescription; 100 TString fNameTab; 98 TString fRequestFrom; 99 TString fRequestTo; 100 Int_t fRequestPeriod; 101 102 Float_t fPlotMin; 103 Float_t fPlotMax; 104 105 Float_t fHistMin; 106 Float_t fHistMax; 107 108 TString fDescription; 109 TString fNameTab; 110 111 TString fCondition; 112 GroupBy_t fGroupBy; 101 113 102 114 void PlotTable(TSQLResult &res, TString name, Float_t fmin, Float_t fmax, Float_t resolution) … … 106 118 TSQLRow *row; 107 119 108 TGraph gt;120 TGraph > = res.GetFieldCount()>4 ? *new TGraphErrors : *new TGraph; 109 121 gt.SetNameTitle(name, Form("%s vs Time", name.Data())); 110 122 gt.SetMarkerStyle(kFullDotMedium); … … 135 147 const char *val = (*row)[2]; 136 148 const char *snum = (*row)[3]; 149 const char *verr = res.GetFieldCount()>4 ? (*row)[5] : 0; 137 150 if (!date || !val || !zd || !snum) 138 151 continue; … … 171 184 gt.SetPoint(gt.GetN(), t.GetAxisTime(), value); 172 185 gz.SetPoint(gz.GetN(), zenith, value); 186 187 if (verr) 188 static_cast<TGraphErrors&>(gt).SetPointError(gt.GetN()-1, 0, atof(verr)); 173 189 } 174 190 … … 299 315 public: 300 316 MPlot(MSQLServer &server) : fServer(server), fDataSet(NULL), 301 fRequestPeriod(-1), fPlotMin(0), fPlotMax(-1), fHistMin(0), fHistMax(-1) 317 fRequestPeriod(-1), fPlotMin(0), fPlotMax(-1), fHistMin(0), fHistMax(-1), fGroupBy(kNone) 302 318 { 303 319 } … … 317 333 fDataSet = new MDataSet(filename); 318 334 } 319 void SetPlotRange(Float_t min, Float_t max, Int_t n=5) 320 { fPlotMin = min; fPlotMax = max; } 321 void SetHistRange(Float_t min, Float_t max) 322 { fHistMin = min; fHistMax = max; } 323 void SetRequestRange(const char *from="", const char *to="") 324 { fRequestFrom = from; fRequestTo = to; } 325 void SetRequestPeriod(Int_t n=-1) 326 { fRequestPeriod = n; } 335 void SetPlotRange(Float_t min, Float_t max, Int_t n=5) { fPlotMin = min; fPlotMax = max; } 336 void SetHistRange(Float_t min, Float_t max) { fHistMin = min; fHistMax = max; } 337 void SetRequestRange(const char *from="", const char *to="") { fRequestFrom = from; fRequestTo = to; } 338 void SetRequestPeriod(Int_t n=-1) { fRequestPeriod = n; } 327 339 void SetDescription(const char *d, const char *t=0) { fDescription = d; fNameTab = t; } 340 void SetCondition(const char *cond="") { fCondition = cond; } 341 void SetGroupBy(GroupBy_t b=kGroupByWeek) { fGroupBy=b; } 328 342 329 343 Bool_t Plot(const char *value, Float_t min=0, Float_t max=-1, Float_t resolution=0) … … 341 355 342 356 TString query; 343 query = Form("select %s, %s, %s, Sequences.fSequenceFirst ", valued.Data(), named2.Data(), valuev.Data()); 357 if (fGroupBy==kNone) 358 query = Form("select %s, %s, %s, Sequences.fSequenceFirst ", valued.Data(), named2.Data(), valuev.Data()); 359 else 360 query = Form("select %s, AVG(%s), AVG(%s), Sequences.fSequenceFirst, STD(%s), STD(%s) ", valued.Data(), named2.Data(), valuev.Data(), named2.Data(), valuev.Data()); 361 362 switch (fGroupBy) 363 { 364 case kNone: 365 break; 366 case kGroupByDay: 367 query += Form(", date_format(adddate(%s,Interval 12 hour), '%%Y-%%m-%%d') as %s ", named.Data(), valued.Data()); 368 break; 369 case kGroupByWeek: 370 query += Form(", date_format(adddate(%s,Interval 12 hour), '%%x%%v') as %s ", named.Data(), valued.Data()); 371 break; 372 case kGroupByMonth: 373 query += Form(", date_format(adddate(%s,Interval 12 hour), '%%Y-%%m') as %s ", named.Data(), valued.Data()); 374 break; 375 case kGroupByYear: 376 query += Form(", date_format(adddate(%s,Interval 12 hour), '%%Y') as %s ", named.Data(), valued.Data()); 377 break; 378 } 379 344 380 query += Form("from %s left join %s ", tabled.Data(), tablev.Data()); 345 query += Form("on %s.%s=%s.%s ", 381 query += Form("on %s.%s=%s.%s ", tabled.Data(), join.Data(), tablev.Data(), join.Data()); 346 382 347 383 const Bool_t interval = !fRequestFrom.IsNull() && !fRequestTo.IsNull(); 348 384 349 if (!fDataSet && !interval && table d=="Star")385 if (!fDataSet && !interval && tablev=="Star") 350 386 { 351 387 if (!query.Contains("Star.fSequenceFirst")) 352 388 query += "left join Star on Sequences.fSequenceFirst=Star.fSequenceFirst "; 353 query += "where Star.fEffOnTime>300 "; 389 // This is from a plot PSF/MuonNumber 390 query += "where Star.fMuonNumber>300 "; 354 391 } 355 392 … … 359 396 query += Form("fRunStart between '%s' and '%s' ", 360 397 fRequestFrom.Data(), fRequestTo.Data()); 398 } 399 400 if (fGroupBy!=kNone) 401 { 402 query += Form(" GROUP BY %s ", valued.Data()); 403 //query += Form(" HAVING COUNT(%s)=(COUNT(*)+1)/2 ", valuev.Data()); 361 404 } 362 405 … … 383 426 void plotall(MPlot &plot) 384 427 { 428 //plot.SetGroupBy(MPlot::kGroupByWeek); 429 385 430 //inner camera 386 431 //from calib*.root
Note:
See TracChangeset
for help on using the changeset viewer.