Changeset 8996 for trunk/MagicSoft/Mars/datacenter/macros
- Timestamp:
- 07/05/08 20:01:55 (16 years ago)
- Location:
- trunk/MagicSoft/Mars/datacenter/macros
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/datacenter/macros/fillcamera.C
r8760 r8996 47 47 #include <iomanip> 48 48 49 #include <TEnv.h>50 49 #include <TRegexp.h> 51 50 #include <TObjectTable.h> … … 656 655 // "where MCRunData.fRunNumber=%d;", RunNum)); 657 656 TString query3(Form("SELECT fMCParticleName, fSpectrum FROM MCRunData " 658 "LEFT JOIN MCParticle ON MCRunData.fMCParticleKEY=MCParticle.fMCParticleKEY"659 "LEFT JOIN Spectrum ON Spectrum.fSpectrumKEY=MCRunData.fSpectrumKEY"657 "LEFT JOIN MCParticle USING (fMCParticleKEY) " 658 "LEFT JOIN Spectrum USING (fSpectrumKEY) " 660 659 "WHERE MCRunData.fRunNumber=%d;", RunNum)); 661 660 res = serv.Query(query3); … … 773 772 int fillcamera(TString fname, Bool_t dummy=kTRUE) 774 773 { 775 TEnv env("sql.rc"); 776 777 MSQLMagic serv(env); 774 MSQLMagic serv("sql.rc"); 778 775 if (!serv.IsConnected()) 779 776 { … … 797 794 int fillcamera(TString path="/magic/montecarlo/camera", Bool_t dummy=kTRUE) 798 795 { 799 TEnv env("mcsql.rc"); 800 801 MSQLMagic serv(env); 796 MSQLMagic serv("mcsql.rc"); 802 797 if (!serv.IsConnected()) 803 798 { -
trunk/MagicSoft/Mars/datacenter/macros/filldotrbk.C
r7460 r8996 64 64 #include <fstream> 65 65 66 #include <TEnv.h>67 66 #include <TRegexp.h> 68 67 … … 206 205 int filldotrbk(TString path="/data/MAGIC/Period017/ccdata", Bool_t dummy=kTRUE) 207 206 { 208 TEnv env("sql.rc"); 209 210 MSQLServer serv(env); 207 MSQLServer serv("sql.rc"); 211 208 if (!serv.IsConnected()) 212 209 { -
trunk/MagicSoft/Mars/datacenter/macros/filldotrun.C
r8993 r8996 79 79 #include <fstream> 80 80 81 #include <TEnv.h>82 81 #include <TMath.h> 83 82 #include <TRegexp.h> … … 148 147 { 149 148 cout << "First character is not an M." << endl; 149 cout << strng << endl; 150 strng.ReadLine(fin); 151 continue; 152 } 153 if (strng[1]!='1') 154 { 155 cout << "Only MAGIC 1 implemented so far." << endl; 150 156 cout << strng << endl; 151 157 strng.ReadLine(fin); … … 580 586 int filldotrun(const TString path="/data/MAGIC/Period018/ccdata", Bool_t dummy=kTRUE) 581 587 { 582 TEnv env("sql.rc"); 583 584 MSQLMagic serv(env); 588 MSQLMagic serv("sql.rc"); 585 589 if (!serv.IsConnected()) 586 590 { -
trunk/MagicSoft/Mars/datacenter/macros/fillganymed.C
r7777 r8996 55 55 #include <iomanip> 56 56 57 #include <TEnv.h>58 57 #include <TRegexp.h> 59 58 … … 218 217 int fillganymed(TString fname, Bool_t dummy=kTRUE) 219 218 { 220 TEnv env("sql.rc"); 221 222 MSQLServer serv(env); 219 MSQLServer serv("sql.rc"); 223 220 if (!serv.IsConnected()) 224 221 { -
trunk/MagicSoft/Mars/datacenter/macros/filloptical.C
r8404 r8996 46 46 #include <TVector3.h> 47 47 48 #include <TEnv.h>49 48 #include <TRegexp.h> 50 49 … … 274 273 int filloptical(TString path, Bool_t dummy=kTRUE) 275 274 { 276 TEnv env("sql.rc"); 277 278 MSQLMagic serv(env); 275 MSQLMagic serv("sql.rc"); 279 276 if (!serv.IsConnected()) 280 277 { -
trunk/MagicSoft/Mars/datacenter/macros/fillsources.C
r7518 r8996 36 36 #include <fstream> 37 37 38 #include <TEnv.h>39 40 #include <MSQLServer.h>41 38 #include <TSQLRow.h> 42 39 #include <TSQLResult.h> 40 41 #include "MSQLServer.h" 43 42 44 43 using namespace std; … … 67 66 int fillsources(TString catalog) 68 67 { 69 TEnv env("sql.rc"); 70 71 MSQLServer serv(env); 68 MSQLServer serv("sql.rc"); 72 69 if (!serv.IsConnected()) 73 70 { -
trunk/MagicSoft/Mars/datacenter/macros/fillstar.C
r8987 r8996 59 59 #include <iomanip> 60 60 61 #include <TEnv.h>62 61 #include <TRegexp.h> 63 62 … … 310 309 int fillstar(TString fname, Bool_t dummy=kTRUE) 311 310 { 312 TEnv env("sql.rc"); 313 314 MSQLMagic serv(env); 311 MSQLMagic serv("sql.rc"); 315 312 if (!serv.IsConnected()) 316 313 { -
trunk/MagicSoft/Mars/datacenter/macros/findcacofiles.C
r8482 r8996 57 57 #include <fstream> 58 58 59 #include <TEnv.h>60 59 #include <TSystem.h> 61 60 62 #include "MSQLMagic.h"63 61 #include <TSQLRow.h> 64 62 #include <TSQLResult.h> 63 64 #include "MSQLMagic.h" 65 65 66 66 using namespace std; … … 69 69 int findcacofiles() 70 70 { 71 TEnv env("sql.rc"); 72 73 MSQLMagic serv(env); 71 MSQLMagic serv("sql.rc"); 74 72 if (!serv.IsConnected()) 75 73 { … … 87 85 query+=" DATE_FORMAT(ADDDATE(if(fRunStart='0000-00-00 00:00:00', fRunStop, fRunStart), INTERVAL +13 HOUR), '%Y/%m/%d') "; 88 86 query+=" FROM RunProcessStatus "; 89 query+=" LEFT JOIN RunData ON RunData.fRunNumber=RunProcessStatus.fRunNumber";90 query+=" LEFT JOIN Source ON RunData.fSourceKEY=Source.fSourceKEY";87 query+=" LEFT JOIN RunData USING (fRunNumber) "; 88 query+=" LEFT JOIN Source USING (fSourceKEY) "; 91 89 query+=" WHERE IsNull(fCaCoFileFound) AND fExcludedFDAKEY=1 "; 92 90 query+=" AND RunProcessStatus.fRunNumber > 10000 AND NOT IsNull(fCCFileAvail)"; … … 115 113 116 114 query ="SELECT MAX(fCaCoFileFound) FROM RunProcessStatus "; 117 query+=" LEFT JOIN RunData ON RunData.fRunNumber=RunProcessStatus.fRunNumber";115 query+=" LEFT JOIN RunData USING (fRunNumber) "; 118 116 query+=Form("WHERE DATE_FORMAT(ADDDATE(fRunStart, INTERVAL +13 HOUR), '%%Y/%%m/%%d')='%s' ", 119 117 (*row)[1]); -
trunk/MagicSoft/Mars/datacenter/macros/getdolist.C
r7501 r8996 68 68 #include <TSystem.h> 69 69 70 #include <MSQLServer.h>71 70 #include <TSQLRow.h> 72 71 #include <TSQLResult.h> 73 72 73 #include "MSQLServer.h" 74 74 75 using namespace std; 75 76 … … 77 78 int getdolist(TString table, TString column, TString date, TString listpath) 78 79 { 79 TEnv env("sql.rc"); 80 81 MSQLServer serv(env); 80 MSQLServer serv("sql.rc"); 82 81 if (!serv.IsConnected()) 83 82 { -
trunk/MagicSoft/Mars/datacenter/macros/insertcacofile.C
r7460 r8996 57 57 #include <fstream> 58 58 59 #include <TEnv.h>60 59 #include <TSystem.h> 61 60 62 #include <MSQLServer.h>63 61 #include <TSQLRow.h> 64 62 #include <TSQLResult.h> 63 64 #include "MSQLServer.h" 65 65 66 66 using namespace std; … … 68 68 int insertcacofile(TString runnumber, TString newrunnumber) 69 69 { 70 TEnv env("sql.rc"); 71 72 MSQLServer serv(env); 70 MSQLServer serv("sql.rc"); 73 71 if (!serv.IsConnected()) 74 72 { -
trunk/MagicSoft/Mars/datacenter/macros/insertdataset.C
r8108 r8996 54 54 #include <iomanip> 55 55 56 #include <TEnv.h>57 58 56 #include "MSQLMagic.h" 59 57 … … 62 60 int insertdataset(TString number, TString source, TString wobble, TString comment, Bool_t dummy=kTRUE) 63 61 { 64 TEnv env("sql.rc"); 65 66 MSQLMagic serv(env); 62 MSQLMagic serv("sql.rc"); 67 63 if (!serv.IsConnected()) 68 64 { -
trunk/MagicSoft/Mars/datacenter/macros/plotoptical.C
r8752 r8996 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: plotoptical.C,v 1. 8 2007-10-07 21:11:01tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: plotoptical.C,v 1.9 2008-07-05 19:01:42 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 78 78 // 79 79 ///////////////////////////////////////////////////////////////////////////// 80 #include <iostream> 81 #include <iomanip> 82 83 #include <TH1.h> 84 #include <TEnv.h> 85 #include <TPad.h> 86 #include <TLine.h> 87 #include <TText.h> 88 #include <TFrame.h> 89 #include <TStyle.h> 90 #include <TCanvas.h> 91 #include <TPRegexp.h> 92 #include <TSQLRow.h> 93 #include <TSQLResult.h> 94 #include <TGraphErrors.h> 95 96 #include "MTime.h" 97 #include "MAstro.h" 98 #include "MDataSet.h" 99 #include "MSQLMagic.h" 100 #include "MStatusDisplay.h" 101 102 class MPlot : public MParContainer 103 { 104 public: 105 // Possible constants to group-by (average) over a certain period 106 enum GroupBy_t 107 { 108 kNone, 109 kGroupByPrimary, 110 kGroupByHour, 111 kGroupByNight, 112 kGroupByWeek, 113 kGroupByMonth, 114 kGroupBySeason, 115 kGroupByYear 116 }; 117 118 private: 119 MSQLMagic &fServer; // Reference to the sql-server class 120 121 MDataSet *fDataSet; // A possible dtaset to highlite single points 122 123 TString fPrimaryDate; // The name of the data we plot 124 TString fPrimaryNumber; // The corresponding name for the key number 125 TString fSecondary; // The value versus which the second plot is made 126 127 TString fRequestFrom; // Start of a requested date range 128 TString fRequestTo; // End of a requested date range 129 Int_t fRequestPeriod; // A possible requested period 130 131 Float_t fPlotMin; 132 Float_t fPlotMax; 133 134 Float_t fHistMin; 135 Float_t fHistMax; 136 137 TString fDescription; // The description (title) of the plot 138 TString fNameTab; // The name of the tab in the display 139 140 TString fCondition; // An additional condition added to the query 141 GroupBy_t fGroupBy; // A possible Group-By flag 142 143 // -------------------------------------------------------------------------- 144 // 145 // Function to plot the result of the query 146 // 147 void PlotTable(TSQLResult &res, TString name, Float_t fmin, Float_t fmax, Float_t resolution) 148 { 149 // Enable all otions in the statistics box 150 gStyle->SetOptStat(111111); 151 152 // Create TGraph objects 153 TGraph > = res.GetFieldCount()>4 ? *new TGraphErrors : *new TGraph; 154 gt.SetNameTitle(name, Form("%s vs Time", name.Data())); 155 gt.SetMarkerStyle(kFullDotMedium); 156 157 TGraph gz; 158 gz.SetNameTitle(name, Form("%s vs <Zd>", name.Data())); 159 gz.SetMarkerStyle(kFullDotMedium); 160 161 TGraph gt0, gt1; 162 gt0.SetMarkerColor(kRed); 163 gt1.SetMarkerColor(kBlue); 164 gt0.SetMarkerStyle(kFullDotLarge); 165 gt1.SetMarkerStyle(kFullDotLarge); 166 167 TGraph gz0, gz1; 168 gz0.SetMarkerColor(kRed); 169 gz1.SetMarkerColor(kBlue); 170 gz0.SetMarkerStyle(kFullDotLarge); 171 gz1.SetMarkerStyle(kFullDotLarge); 172 173 Int_t first = -1; 174 Int_t last = -1; 175 176 // Loop over the data 177 TSQLRow *row=0; 178 while ((row=res.Next())) 179 { 180 // Get all fields of this row 181 const char *date = (*row)[0]; 182 const char *zd = (*row)[1]; 183 const char *val = (*row)[2]; 184 const char *snum = res.GetFieldCount()>3 ? (*row)[3] : 0; 185 const char *verr = res.GetFieldCount()>4 ? (*row)[5] : 0; 186 187 delete row; 188 189 if (!date || !val || !zd) 190 continue; 191 192 // check if date is valid 193 MTime t(date); 194 if (!t.SetSqlDateTime(date)) 195 continue; 196 197 // check if it belongs to the requested MAGIC period 198 if (fRequestPeriod>0 && MAstro::GetMagicPeriod(t.GetMjd())!=fRequestPeriod) 199 continue; 200 201 // Get axis range 202 if (first<0) 203 first = TMath::Nint(TMath::Floor(t.GetMjd())); 204 last = TMath::Nint(TMath::Ceil(t.GetMjd())); 205 206 // Convert a possible key number into a integer 207 UInt_t seq = snum ? atoi(snum) : 0; 208 209 // convert primary and secondary value into floats 210 Float_t value = atof(val); 211 Float_t zenith = atof(zd); 212 213 // If a datset is given add the point to the special TGraphs 214 // used for highliting these dates 215 if (fDataSet) 216 { 217 if (fDataSet->HasOnSequence(seq)) 218 { 219 gt1.SetPoint(gt1.GetN(), t.GetAxisTime(), value); 220 gz1.SetPoint(gz1.GetN(), zenith, value); 221 } 222 223 if (fDataSet->HasOffSequence(seq)) 224 { 225 gt0.SetPoint(gt0.GetN(), t.GetAxisTime(), value); 226 gz0.SetPoint(gz0.GetN(), zenith, value); 227 } 228 } 229 230 // Add Data to TGraph 231 gt.SetPoint(gt.GetN(), t.GetAxisTime(), value); 232 gz.SetPoint(gz.GetN(), zenith, value); 233 234 // Set error-bar, if one 235 if (verr) 236 static_cast<TGraphErrors&>(gt).SetPointError(gt.GetN()-1, 0, atof(verr)); 237 } 238 239 // If this is done earlier the plots remain empty since root 5.12/00 240 if (fmax>fmin) 241 { 242 gt.SetMinimum(fmin); 243 gt.SetMaximum(fmax); 244 gz.SetMinimum(fmin); 245 gz.SetMaximum(fmax); 246 } 247 248 gROOT->SetSelectedPad(0); 249 250 // Create a TCanvas or open a new tab 251 TString title = fNameTab.IsNull() ? name(name.First('.')+2, name.Length()) : fNameTab; 252 TCanvas &c = fDisplay ? fDisplay->AddTab(title) : *new TCanvas; 253 // Set fillcolor, remove border and divide pad 254 c.SetFillColor(kWhite); 255 c.SetBorderMode(0); 256 c.Divide(1,2); 257 258 // Output mean and rms to console 259 cerr << setprecision(4) << setw(10) << title << ": "; 260 if (gt.GetN()==0) 261 { 262 cerr << " <empty>" << endl; 263 return; 264 } 265 cerr << setw(8) << gt.GetMean(2) << "+-" << setw(8) << gt.GetRMS(2) << " "; 266 if (gt0.GetN()>0 || gt1.GetN()>0) 267 { 268 cerr << setw(8) << gt1.GetMean(2) << "+-" << setw(8) << gt1.GetRMS(2) << " "; 269 cerr << setw(8) << gt0.GetMean(2) << "+-" << setw(8) << gt0.GetRMS(2); 270 } 271 cerr << endl; 272 273 TVirtualPad *pad = gPad; 274 275 // draw contants of pad 2 (counting starts at 0) 276 pad->cd(2); 277 gPad->SetBorderMode(0); 278 gPad->SetFrameBorderMode(0); 279 gPad->SetGridy(); 280 281 gPad->SetLeftMargin(0.06); 282 gPad->SetRightMargin(0.06); 283 gPad->SetBottomMargin(0.08); 284 285 // format axis 286 TH1 *h = gt.GetHistogram(); 287 288 h->SetXTitle("Time"); 289 h->SetYTitle(name); 290 h->GetXaxis()->SetTimeDisplay(1); 291 h->GetYaxis()->SetTitleOffset(0.8); 292 h->GetXaxis()->SetTitleOffset(1.0); 293 h->GetXaxis()->SetLabelOffset(0.01); 294 295 // draw TGraph 296 gt.DrawClone("AP"); 297 if (gt0.GetN()>0) 298 gt0.DrawClone("P"); 299 if (gt1.GetN()>0) 300 gt1.DrawClone("P"); 301 302 // Add lines and text showing the MAGIC periods 303 TLine l; 304 TText t; 305 Int_t num=0; 306 l.SetLineStyle(kDotted); 307 l.SetLineColor(kBlue); 308 t.SetTextColor(kBlue); 309 l.SetLineWidth(1); 310 t.SetTextSize(h->GetXaxis()->GetLabelSize()); 311 t.SetTextAlign(21); 312 Int_t p0 = MAstro::GetMagicPeriod(first); 313 for (Int_t p = first; p<last; p++) 314 { 315 Int_t p1 = MAstro::GetMagicPeriod(p); 316 if (p1!=p0) 317 { 318 l.DrawLine(MTime(p).GetAxisTime(), h->GetMinimum(), MTime(p).GetAxisTime(), h->GetMaximum()); 319 t.DrawText(MTime(p+15).GetAxisTime(), h->GetMaximum(), Form("%d", p1)); 320 num++; 321 } 322 p0 = p1; 323 } 324 if (num<4) 325 gPad->SetGridx(); 326 327 const Double_t min = fHistMin>fHistMax ? h->GetMinimum()-resolution/2 : fHistMin; 328 const Double_t max = fHistMin>fHistMax ? h->GetMaximum()+resolution/2 : fHistMax; 329 330 // Use this to save the pad with the time development to a file 331 //gPad->SaveAs(Form("plotdb-%s.eps", title.Data())); 332 333 // Go back to first (upper) pad, format it and divide it again 334 pad->cd(1); 335 gPad->SetBorderMode(0); 336 gPad->SetFrameBorderMode(0); 337 gPad->Divide(2,1); 338 339 TVirtualPad *pad2 = gPad; 340 341 // format left pad 342 pad2->cd(1); 343 gPad->SetBorderMode(0); 344 gPad->SetFrameBorderMode(0); 345 gPad->SetGridx(); 346 gPad->SetGridy(); 347 348 // Create histogram 349 const Int_t n = resolution>0 ? TMath::Nint((max-min)/resolution) : 50; 350 351 TH1F hist("Hist", Form("Distribution of %s", fDescription.IsNull() ? name.Data() : fDescription.Data()), n, min, max); 352 hist.SetDirectory(0); 353 354 // Fill data into histogra, 355 for (int i=0; i<gt.GetN(); i++) 356 hist.Fill(gt.GetY()[i]); 357 358 // Format histogram 359 if (fDescription.IsNull()) 360 hist.SetXTitle(name); 361 hist.SetYTitle("Counts"); 362 363 // plot histogram 364 hist.DrawCopy(""); 365 366 // format right pad 367 pad2->cd(2); 368 gPad->SetBorderMode(0); 369 gPad->SetFrameBorderMode(0); 370 gPad->SetGridy(); 371 372 // format graph 373 TH1 *h2 = gz.GetHistogram(); 374 375 h2->SetXTitle("Zd"); 376 h2->SetYTitle(name); 377 378 // draw graph 379 gz.DrawClone("AP"); 380 381 if (gz0.GetN()>0) 382 gz0.DrawClone("P"); 383 if (gz1.GetN()>0) 384 gz1.DrawClone("P"); 385 } 386 387 public: 388 MPlot(MSQLMagic &server) : fServer(server), fDataSet(NULL), 389 fRequestPeriod(-1), fPlotMin(0), fPlotMax(-1), fHistMin(0), fHistMax(-1), fGroupBy(kNone) 390 { 391 } 392 ~MPlot() 393 { 394 if (fDataSet) 395 delete fDataSet; 396 } 397 void SetDataSet(const TString filename) 398 { 399 if (fDataSet) 400 { 401 delete fDataSet; 402 fDataSet = NULL; 403 } 404 if (!filename.IsNull()) 405 fDataSet = new MDataSet(filename); 406 } 407 void SetPlotRange(Float_t min, Float_t max, Int_t n=5) { fPlotMin = min; fPlotMax = max; } 408 void SetHistRange(Float_t min, Float_t max) { fHistMin = min; fHistMax = max; } 409 void SetRequestRange(const char *from="", const char *to="") { fRequestFrom = from; fRequestTo = to; } 410 void SetRequestPeriod(Int_t n=-1) { fRequestPeriod = n; } 411 void SetCondition(const char *cond="") { fCondition = cond; } 412 void SetDescription(const char *d, const char *t=0) { fDescription = d; fNameTab = t; } 413 void SetGroupBy(GroupBy_t b=kGroupByWeek) { fGroupBy=b; } 414 void SetPrimaryDate(const char *ts) { fPrimaryDate=ts; } 415 void SetPrimaryNumber(const char *ts) { fPrimaryNumber=ts; } 416 void SetSecondary(const char *ts) { fSecondary=ts; } 417 418 Int_t QueryKeyOfSource(TString src) 419 { 420 return fServer.QueryKeyOfName("Object", src, kFALSE); 421 } 422 423 Bool_t Plot(const char *value, Float_t min=0, Float_t max=-1, Float_t resolution=0) 424 { 425 TString named = fPrimaryDate; 426 TString named2 = fSecondary; 427 TString namev = value; 428 429 TString tablev = namev(0, namev.First('.')); 430 TString valuev = namev(namev.First('.')+1, namev.Length()); 431 432 TString tabled = named(0, named.First('.')); 433 TString valued = named(named.First('.')+1, named.Length()); 434 435 TString query="SELECT "; 436 switch (fGroupBy) 437 { 438 case kNone: 439 case kGroupByPrimary: 440 query += Form("%s AS %s", valued.Data(), valued.Data()+1); 441 break; 442 case kGroupByHour: 443 query += Form("DATE_FORMAT(%s, '%%Y-%%m-%%d %%H:30:00') AS %s ", fPrimaryDate.Data(), valued.Data()+1); 444 break; 445 case kGroupByNight: 446 query += Form("DATE_FORMAT(ADDDATE(%s,Interval 12 hour), '%%Y-%%m-%%d 00:00:00') AS %s ", fPrimaryDate.Data(), valued.Data()+1); 447 break; 448 case kGroupByWeek: 449 query += Form("DATE_FORMAT(ADDDATE(%s,Interval 12 hour), '%%x%%v') AS %s ", fPrimaryDate.Data(), valued.Data()+1); 450 break; 451 case kGroupByMonth: 452 query += Form("DATE_FORMAT(ADDDATE(%s,Interval 12 hour), '%%Y-%%m-15 00:00:00') AS %s ", fPrimaryDate.Data(), valued.Data()+1); 453 break; 454 case kGroupBySeason: 455 //query += Form("DATE_FORMAT(ADDDATE(%s,Interval 12 hour), '%%Y-%%m-15 00:00:00') AS %s ", fPrimaryDate.Data(), valued.Data()+1); 456 break; 457 case kGroupByYear: 458 query += Form("DATE_FORMAT(ADDDATE(%s,Interval 12 hour), '%%Y-08-15 00:00:00') AS %s ", fPrimaryDate.Data(), valued.Data()+1); 459 break; 460 } 461 462 if (fGroupBy==kNone) 463 { 464 query += ", "; 465 query += fSecondary; 466 query += ", "; 467 query += value; 468 query += ", "; 469 query += fPrimaryNumber; 470 query += " "; 471 } 472 else 473 { 474 query += ", AVG("; 475 query += fSecondary; 476 query += "), AVG("; 477 query += value; 478 query += "), "; 479 query += fPrimaryNumber; 480 query += ", STD("; 481 query += fSecondary; 482 query += "), STD("; 483 query += value; 484 query += ") "; 485 } 486 487 query += Form("FROM %s ", tabled.Data()); 488 489 TString where(fCondition); 490 491 const Bool_t interval = !fRequestFrom.IsNull() && !fRequestTo.IsNull(); 492 if (interval) 493 { 494 if (!where.IsNull()) 495 where += " AND "; 496 where += Form("%s BETWEEN '%s' AND '%s' ", 497 fPrimaryDate.Data(), fRequestFrom.Data(), fRequestTo.Data()); 498 } 499 500 if (!where.IsNull()) 501 where += " AND "; 502 where += fCondition; 503 where += " "; 504 505 // ------------------------------ 506 507 query += fServer.GetJoins(tabled, query+" "+where); 508 509 if (!where.IsNull()) 510 { 511 query += "WHERE "; 512 query += where; 513 } 514 515 if (fGroupBy!=kNone) 516 { 517 query += Form("GROUP BY %s ", valued.Data()+1); 518 //query += Form(" HAVING COUNT(%s)=(COUNT(*)+1)/2 ", valuev.Data()); 519 } 520 query += Form("ORDER BY %s ", valued.Data()+1); 521 522 // ------------------------------ 523 524 TSQLResult *res = fServer.Query(query); 525 if (!res) 526 return kFALSE; 527 528 if (max>min) 529 PlotTable(*res, namev, min, max, resolution); 530 else 531 PlotTable(*res, namev, fPlotMin, fPlotMax, resolution); 532 533 delete res; 534 return kTRUE; 535 } 536 }; 537 538 void plotall(MPlot &plot, TString source) 80 #include "plotdb.C" 81 82 void plotalloptical(MPlot &plot, TString source) 539 83 { 540 84 // Setup here the values for timestamp and secondary (upper/right) plot … … 548 92 if (!source.IsNull()) 549 93 { 550 const Int_t key = plot. QueryKeyOfSource(source);94 const Int_t key = plot.GetServer().QueryKeyOfName("Object", source, kFALSE); 551 95 if (key<0) 552 96 return; 553 97 cond += Form(" AND Object.fObjectKEY=%d", key); 554 555 98 } 556 99 … … 625 168 int plotoptical(TString from, TString to, const char *source=0) 626 169 { 627 TEnv env("sql.rc"); 628 629 MSQLMagic serv(env); 170 MSQLMagic serv("sql.rc"); 630 171 if (!serv.IsConnected()) 631 172 { … … 648 189 plot.SetDisplay(d); 649 190 plot.SetRequestRange(from, to); 650 plotall (plot, source);191 plotalloptical(plot, source); 651 192 // Use this to create output plots automatically 652 193 // d->SaveAsRoot("plotoptical.root"); … … 658 199 int plotoptical(const char *source) 659 200 { 660 TEnv env("sql.rc"); 661 662 MSQLMagic serv(env); 201 MSQLMagic serv("sql.rc"); 663 202 if (!serv.IsConnected()) 664 203 { … … 681 220 plot.SetDisplay(d); 682 221 plot.SetRequestRange("", ""); 683 plotall (plot, source);222 plotalloptical(plot, source); 684 223 // Use this to create output plots automatically 685 224 // d->SaveAsRoot("plotoptical.root"); … … 691 230 int plotoptical(Int_t period, const char *source="") 692 231 { 693 TEnv env("sql.rc"); 694 695 MSQLMagic serv(env); 232 MSQLMagic serv("sql.rc"); 696 233 if (!serv.IsConnected()) 697 234 { … … 714 251 plot.SetDisplay(d); 715 252 plot.SetRequestPeriod(period); 716 plotall (plot, source);253 plotalloptical(plot, source); 717 254 718 255 // Use this to create output plots automatically -
trunk/MagicSoft/Mars/datacenter/macros/plotrundb.C
r8994 r8996 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: plotrundb.C,v 1. 5 2008-07-03 16:29:48tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: plotrundb.C,v 1.6 2008-07-05 19:01:42 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 111 111 int plotrundb(TString from, TString to, const char *dataset=0) 112 112 { 113 TEnv env("sql.rc"); 114 115 MSQLMagic serv(env); 113 MSQLMagic serv("sql.rc"); 116 114 if (!serv.IsConnected()) 117 115 { … … 143 141 int plotrundb(const char *ds) 144 142 { 145 TEnv env("sql.rc"); 146 147 MSQLMagic serv(env); 143 MSQLMagic serv("sql.rc"); 148 144 if (!serv.IsConnected()) 149 145 { … … 175 171 int plotrundb(Int_t period, const char *dataset="") 176 172 { 177 TEnv env("sql.rc"); 178 179 MSQLMagic serv(env); 173 MSQLMagic serv("sql.rc"); 180 174 if (!serv.IsConnected()) 181 175 { -
trunk/MagicSoft/Mars/datacenter/macros/plotstat.C
r8983 r8996 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: plotstat.C,v 1. 6 2008-06-19 15:18:57tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: plotstat.C,v 1.7 2008-07-05 19:01:42 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 48 48 49 49 #include <TH2.h> 50 #include <TEnv.h>51 50 #include <TPad.h> 52 51 #include <TLine.h> … … 663 662 int plotstat(Int_t first=-1, Int_t last=-1) 664 663 { 665 TEnv env("sql.rc"); 666 667 MSQLServer serv(env); 664 MSQLServer serv("sql.rc"); 668 665 if (!serv.IsConnected()) 669 666 { -
trunk/MagicSoft/Mars/datacenter/macros/resetallruns.C
r7460 r8996 49 49 #include <fstream> 50 50 51 #include <TEnv.h>52 53 #include <MSQLServer.h>54 51 #include <TSQLRow.h> 55 52 #include <TSQLResult.h> 53 54 #include "MSQLServer.h" 56 55 57 56 using namespace std; … … 60 59 int resetallruns(TString filename, TString column) 61 60 { 62 TEnv env("sql.rc"); 63 64 MSQLServer serv(env); 61 MSQLServer serv("sql.rc"); 65 62 if (!serv.IsConnected()) 66 63 { -
trunk/MagicSoft/Mars/datacenter/macros/setstatus.C
r7486 r8996 18 18 ! Author(s): Daniela Dorner, 01/2005 <mailto:dorner@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 620 ! Copyright: MAGIC Software Development, 2000-2008 21 21 ! 22 22 ! … … 50 50 // 51 51 ///////////////////////////////////////////////////////////////////////////// 52 53 52 #include <iostream> 54 53 #include <iomanip> … … 56 55 57 56 #include <TEnv.h> 58 59 #include <MTime.h>60 61 #include <MSQLServer.h>62 57 #include <TSQLRow.h> 63 58 #include <TSQLResult.h> 59 60 #include "MTime.h" 61 #include "MSQLServer.h" 64 62 65 63 using namespace std; -
trunk/MagicSoft/Mars/datacenter/macros/writedatasetfile.C
r8248 r8996 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: writedatasetfile.C,v 1. 2 2007-01-12 17:33:10 snruegamExp $2 ! $Name: not supported by cvs2svn $:$Id: writedatasetfile.C,v 1.3 2008-07-05 19:01:43 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 20 20 ! Author(s): Thomas Bretz, 11/2006 <mailto:tbretz@astro.uni-wuerzburg.de> 21 21 ! 22 ! Copyright: MAGIC Software Development, 2000-200 622 ! Copyright: MAGIC Software Development, 2000-2008 23 23 ! 24 24 ! … … 50 50 #include <TSQLResult.h> 51 51 52 #include <TEnv.h>53 52 #include <errno.h> 54 53 … … 91 90 //get sequence information from database 92 91 TString query0(Form("SELECT fSourceName, fComment, fDataSetName, fRunTime, fObservationModeKEY" 93 " FROM DataSets LEFT JOIN Source ON" 94 " Source.fSourceKEY=DataSets.fSourceKEY" 92 " FROM DataSets LEFT JOIN Source USING (fSourceKEY)" 95 93 " WHERE fDataSetNumber=%d", dsno)); 96 94 … … 167 165 int writedatasetfile(Int_t dsno, TString seqpath) 168 166 { 169 TEnv env("sql.rc"); 170 171 MSQLMagic serv(env); 167 MSQLMagic serv("sql.rc"); 172 168 if (!serv.IsConnected()) 173 169 {
Note:
See TracChangeset
for help on using the changeset viewer.