Changeset 20003
- Timestamp:
- 11/13/20 16:55:21 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/hawc/quality.C
r19921 r20003 9 9 #include "TText.h" 10 10 #include "TLine.h" 11 #include "TStyle.h" 11 12 12 13 #include "fits.h" … … 19 20 #endif 20 21 21 Bool_t Contains(TArrayD **vec, Double_t t0, Double_t range=0) 22 { 23 TArrayD *arr0 = vec[0]; 24 TArrayD *arr1 = vec[1]; 25 TArrayD *arr2 = vec[2]; 26 27 for (int i=0; i<arr0->GetSize(); i++) 28 { 29 Double_t start = (*arr1)[i]; 30 Double_t stop = (*arr2)[i]; 22 #include <numeric> 23 24 Bool_t Contains(vector<double> *vec, Double_t t0, Double_t range=0) 25 { 26 auto &arr0 = vec[0]; 27 auto &arr1 = vec[1]; 28 auto &arr2 = vec[2]; 29 30 for (size_t i=0; i<arr0.size(); i++) 31 { 32 Double_t start = arr1[i]; 33 Double_t stop = arr2[i]; 31 34 32 35 if (stop>start+305./24/3600) … … 34 37 35 38 if (t0>start-range && t0<stop+range) 36 //{37 //if (fmod(t0, 1)>4./24 && fmod(t0,1)<4.1/24)38 //cout << t0-start << " " <<t0 << " " << stop-t0 << " " << start-15779 << " " << stop-15779 << " " << (*arr0)[i] << endl;39 { 40 //if (fmod(t0, 1)>4./24 && fmod(t0,1)<4.1/24) 41 // cout << t0-start << " " <<t0 << " " << stop-t0 << " " << start-15779 << " " << stop-15779 << " " << (*arr0)[i] << endl; 39 42 return kTRUE; 40 //} 41 } 42 43 return arr0->GetSize()==0; 44 } 45 46 Int_t PlotThresholds(double start, TArrayD **vec, TString fname) 43 } 44 } 45 46 return arr0.empty(); 47 } 48 49 Int_t ReadRuns(vector<double> *vec, TString fname) 50 { 51 fname += ".FAD_CONTROL_RUNS.fits"; 52 53 fits file(fname.Data()); 54 if (!file) 55 { 56 cerr << fname << ": " << gSystem->GetError() << endl; 57 return -2; 58 } 59 60 //cout << fname << endl; 61 62 Double_t time; 63 uint32_t qos, stats[2]; 64 65 if (!file.SetPtrAddress("Time", &time)) 66 return -1; 67 if (!file.SetPtrAddress("QoS", &qos)) 68 return -1; 69 if (!file.SetPtrAddress("stats", stats)) 70 return -1; 71 72 int32_t run = -1; 73 double start=0; 74 75 while (file.GetNextRow()) 76 { 77 switch (qos) 78 { 79 case 1: 80 start = time; 81 run = stats[0]; 82 break; 83 case 0: 84 if (uint32_t(run)==stats[1] && stats[0]==stats[1]) 85 { 86 vec[0].push_back(run); 87 vec[1].push_back(start); 88 vec[2].push_back(time); 89 //cout << setw(3) << ": " << MTime(start) << " -- " << MTime(time) << endl; 90 } 91 run = -1; 92 break; 93 } 94 } 95 96 return 0; 97 } 98 99 100 Int_t PlotThresholds(double start, vector<double> *vec, TString fname) 47 101 { 48 102 fname += ".FTU_CONTROL_DAC.fits"; … … 103 157 } 104 158 105 Int_t PlotCurrent(double start, TArrayD **vec, TString fname)159 Int_t PlotCurrent(double start, vector<double> *vec, TString fname) 106 160 { 107 161 fname += ".BIAS_CONTROL_AVERAGE_DATA.fits"; … … 121 175 Float_t Tpsu[2]; 122 176 Float_t Vavg[64]; 177 Float_t Uavg[64]; 123 178 124 179 if (!file.SetPtrAddress("Time", &time)) … … 136 191 if (!file.SetPtrAddress("Vavg", Vavg)) 137 192 return -1; 193 194 bool has_uset = true; 195 try 196 { 197 has_uset = file.SetPtrAddress("Uavg", Uavg); 198 } 199 catch (const exception&) 200 { 201 } 138 202 139 203 TGraph g1; … … 141 205 TGraph g3; 142 206 TGraph g4; 207 TGraph g5; 143 208 g1.SetName("CurrentAvg"); 144 209 g2.SetName("TemperatureAvg"); 145 210 g3.SetName("TempPSUavg"); 146 211 g4.SetName("VoltageAvg"); 212 g5.SetName("UsetAvg"); 147 213 148 214 while (file.GetNextRow()) … … 152 218 sort(Tavg, Tavg+64); 153 219 sort(Vavg, Vavg+64); 220 if (has_uset) 221 sort(Uavg, Uavg+64); 154 222 155 223 g1.SetPoint(g1.GetN(), time*24*3600, Iavg[31]); … … 157 225 g3.SetPoint(g3.GetN(), time*24*3600, (Tpsu[0]+Tpsu[1])/2); 158 226 g4.SetPoint(g4.GetN(), time*24*3600, Vavg[31]); 227 if (has_uset) 228 g5.SetPoint(g5.GetN(), time*24*3600, Uavg[31]); 159 229 } 160 230 … … 176 246 frame1.GetXaxis()->SetLabelSize(0.12); 177 247 frame1.GetYaxis()->SetLabelSize(0.1); 178 frame1.GetYaxis()->SetTitle("CURRENT ");248 frame1.GetYaxis()->SetTitle("CURRENT [#mu A]"); 179 249 frame1.GetYaxis()->CenterTitle(); 180 250 frame1.GetYaxis()->SetTitleOffset(0.2); … … 203 273 frame4.GetXaxis()->SetLabelSize(0.12); 204 274 frame4.GetYaxis()->SetLabelSize(0.1); 205 frame4.GetYaxis()->SetTitle(" VOLTAGE");275 frame4.GetYaxis()->SetTitle("BIAS VOLTAGE [V]"); 206 276 frame4.GetYaxis()->CenterTitle(); 207 277 frame4.GetYaxis()->SetTitleOffset(0.2); … … 209 279 frame4.DrawCopy(); 210 280 281 if (has_uset) 282 { 283 g5.SetMarkerColor(kBlue); 284 g5.SetMarkerStyle(kFullDotMedium); 285 g5.DrawClone("P"); 286 } 287 211 288 g4.SetMarkerStyle(kFullDotMedium); 212 289 g4.DrawClone("P"); 213 290 214 291 215 216 292 gROOT->SetSelectedPad(0); 217 293 gPad->GetCanvas()->cd(6); … … 224 300 TH1C frame2("Temperature_frame", "", 1000, (start+0.45)*24*3600, (start+1.025)*24*3600); 225 301 frame2.SetMinimum(0); 226 frame2.SetMaximum( 40);302 frame2.SetMaximum(65); 227 303 frame2.SetStats(kFALSE); 228 304 frame2.GetXaxis()->SetTimeDisplay(true); … … 230 306 frame2.GetXaxis()->SetLabelSize(0.12); 231 307 frame2.GetYaxis()->SetLabelSize(0.1); 232 frame2.GetYaxis()->SetTitle("TEMPERATURE ");308 frame2.GetYaxis()->SetTitle("TEMPERATURE [#circ C]"); 233 309 frame2.GetYaxis()->CenterTitle(); 234 310 frame2.GetYaxis()->SetTitleOffset(0.2); … … 239 315 g2.DrawClone("P"); 240 316 241 g3.SetMarkerColor(k Blue);317 g3.SetMarkerColor(kRed); 242 318 g3.SetMarkerStyle(kFullDotMedium); 243 319 g3.DrawClone("P"); … … 246 322 } 247 323 248 Int_t Plot Rate(double start, TArrayD **vec, TString fname)249 { 250 fname += ".F TM_CONTROL_DATA.fits";324 Int_t PlotDrsTemp(double /*start*/, vector<double> *vec, TString fname) 325 { 326 fname += ".FAD_CONTROL_TEMPERATURE.fits"; 251 327 252 328 fits file(fname.Data()); … … 260 336 261 337 Double_t time; 262 uint32_t trg_counter; 263 uint32_t dead_time, run_time; 264 265 if (!file.SetPtrAddress("Time", &time)) 266 return -1; 267 268 if (!file.SetPtrAddress("trg_counter", &trg_counter)) 269 return -1; 270 if (!file.SetPtrAddress("dead_time", &dead_time)) 271 return -1; 272 if (!file.SetPtrAddress("run_time", &run_time)) 338 uint16_t cnt; 339 Float_t temp[160]; 340 341 if (!file.SetPtrAddress("Time", &time)) 342 return -1; 343 344 if (!file.SetPtrAddress("cnt", &cnt)) 345 return -1; 346 347 if (!file.SetPtrAddress("temp", temp)) 273 348 return -1; 274 349 275 350 TGraph g1, g2; 276 g1.SetName("TriggerRate"); 277 g2.SetName("RelOnTime"); 278 279 uint32_t prev = 0; 351 g1.SetName("TempDRS1"); 352 g2.SetName("TempDRS2"); 280 353 281 354 while (file.GetNextRow()) 282 355 if (Contains(vec, time)) 283 356 { 284 g1.SetPoint(g1.GetN(), time*24*3600, 1e8*(trg_counter-prev)/(run_time-dead_time)); 285 g2.SetPoint(g2.GetN(), time*24*3600, 1.-float(dead_time)/run_time); 286 prev = trg_counter; 357 g1.SetPoint(g1.GetN(), time*24*3600, accumulate(temp, temp+4, 0.)/4); 358 g2.SetPoint(g2.GetN(), time*24*3600, accumulate(temp+4, temp+8, 0.)/4); 287 359 } 288 360 289 361 290 362 gROOT->SetSelectedPad(0); 363 gPad->GetCanvas()->cd(6); 364 365 g1.SetMarkerColor(kBlue); 366 g1.SetMarkerStyle(kFullDotMedium); 367 g1.DrawClone("P"); 368 369 g2.SetMarkerColor(kBlue); 370 g2.SetMarkerStyle(kFullDotMedium); 371 g2.DrawClone("P"); 372 373 return 0; 374 } 375 376 Int_t PlotPatchRate(double /*start*/, vector<double> *vec, TString fname) 377 { 378 fname += ".FTU_CONTROL_DATA.fits"; 379 380 fits file(fname.Data()); 381 if (!file) 382 { 383 cerr << fname << ": " << gSystem->GetError() << endl; 384 return -2; 385 } 386 387 //cout << fname << endl; 388 389 Double_t time; 390 uint32_t qos; 391 uint32_t counter_ch[8]; 392 float dt_sec; 393 394 if (!file.SetPtrAddress("QoS", &qos)) 395 return -1; 396 if (!file.SetPtrAddress("Time", &time)) 397 return -1; 398 399 if (!file.SetPtrAddress("counter_ch", counter_ch)) 400 return -1; 401 if (!file.SetPtrAddress("dt_sec", &dt_sec)) 402 return -1; 403 404 TGraph g1, g2; 405 g1.SetName("MinPatchRate"); 406 g2.SetName("MaxPatchRate"); 407 408 while (file.GetNextRow()) 409 if (Contains(vec, time)) 410 { 411 if (qos==0) // Only automatic reports 412 continue; 413 414 sort(counter_ch, counter_ch+8); 415 416 g1.SetPoint(g1.GetN(), time*24*3600, counter_ch[1]/dt_sec); 417 g2.SetPoint(g2.GetN(), time*24*3600, counter_ch[7]/dt_sec); 418 } 419 420 421 gROOT->SetSelectedPad(0); 291 422 gPad->GetCanvas()->cd(3); 423 /* 292 424 gPad->SetGrid(); 293 425 gPad->SetTopMargin(0); … … 305 437 frame1.GetYaxis()->SetLabelSize(0.1); 306 438 frame1.GetYaxis()->SetTitle("TRIGGER RATE"); 439 frame1.GetYaxis()->CenterTitle(); 440 frame1.GetYaxis()->SetTitleOffset(0.2); 441 frame1.GetYaxis()->SetTitleSize(0.1); 442 frame1.DrawCopy();*/ 443 444 g1.SetMarkerColor(kGreen); 445 g1.SetMarkerStyle(kFullDotMedium); 446 g1.DrawClone("P"); 447 448 g2.SetMarkerColor(kRed); 449 g2.SetMarkerStyle(kFullDotMedium); 450 g2.DrawClone("P"); 451 452 return 0; 453 } 454 455 Int_t PlotCameraRate(double start, vector<double> *vec, TString fname) 456 { 457 fname += ".FTM_CONTROL_DATA.fits"; 458 459 fits file(fname.Data()); 460 if (!file) 461 { 462 cerr << fname << ": " << gSystem->GetError() << endl; 463 return -2; 464 } 465 466 //cout << fname << endl; 467 468 Double_t time; 469 uint32_t trg_counter; 470 uint32_t dead_time, run_time; 471 float temp; 472 473 if (!file.SetPtrAddress("Time", &time)) 474 return -1; 475 476 if (!file.SetPtrAddress("trg_counter", &trg_counter)) 477 return -1; 478 if (!file.SetPtrAddress("dead_time", &dead_time)) 479 return -1; 480 if (!file.SetPtrAddress("run_time", &run_time)) 481 return -1; 482 if (!file.SetPtrAddress("temp", &temp)) 483 return -1; 484 485 TGraph g1, g2, g3; 486 g1.SetName("TriggerRate"); 487 g2.SetName("RelOnTime"); 488 g3.SetName("TempFTM"); 489 490 491 uint32_t prev = 0; 492 493 while (file.GetNextRow()) 494 if (Contains(vec, time)) 495 { 496 g1.SetPoint(g1.GetN(), time*24*3600, 1e8*(trg_counter-prev)/(run_time-dead_time)); 497 g2.SetPoint(g2.GetN(), time*24*3600, 1.-float(dead_time)/run_time); 498 g3.SetPoint(g2.GetN(), time*24*3600, temp); 499 prev = trg_counter; 500 } 501 502 503 gROOT->SetSelectedPad(0); 504 gPad->GetCanvas()->cd(3); 505 gPad->SetGrid(); 506 gPad->SetTopMargin(0); 507 gPad->SetBottomMargin(0); 508 gPad->SetRightMargin(0.001); 509 gPad->SetLeftMargin(0.04); 510 511 TH1C frame1("Rate_frame", "", 1000, (start+0.45)*24*3600, (start+1.025)*24*3600); 512 frame1.SetMinimum(0); 513 frame1.SetMaximum(90); 514 frame1.SetStats(kFALSE); 515 frame1.GetXaxis()->SetTimeDisplay(true); 516 frame1.GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00 GMT"); 517 frame1.GetXaxis()->SetLabelSize(0.12); 518 frame1.GetYaxis()->SetLabelSize(0.1); 519 frame1.GetYaxis()->SetTitle("TRIGGER RATE [Hz]"); 307 520 frame1.GetYaxis()->CenterTitle(); 308 521 frame1.GetYaxis()->SetTitleOffset(0.2); … … 340 553 g2.DrawClone("P"); 341 554 555 gROOT->SetSelectedPad(0); 556 gPad->GetCanvas()->cd(6); 557 558 g3.SetMarkerColor(kGreen); 559 g3.SetMarkerStyle(kFullDotMedium); 560 g3.DrawClone("P"); 561 342 562 return 0; 343 563 } 344 564 345 int quality(const char *basepath , UInt_t y=0, UInt_t m=0, UInt_t d=0, const char *outpath=0)565 int quality(const char *basepath="/data/aux", UInt_t y=0, UInt_t m=0, UInt_t d=0, const char *outpath=0, const bool all=true) 346 566 { 347 567 // To get correct dates in the histogram you have to add … … 366 586 cout << endl; 367 587 368 double start = MTime(y, m, d).GetMjd()-40587;369 370 TArrayD run, beg, end;371 372 TArrayD *runs[3] = { &run, &beg, &end };588 const double start = MTime(y, m, d).GetMjd()-40587; 589 590 vector<double> runs[3]; // { &run, &beg, &end }; 591 if (!all) 592 ReadRuns(runs, fname); 373 593 374 594 //check if the sqm was already installed on the telescope … … 378 598 PlotThresholds(start, runs, fname); 379 599 PlotCurrent(start, runs, fname); 380 PlotRate(start, runs, fname); 600 PlotDrsTemp(start, runs, fname); 601 PlotCameraRate(start, runs, fname); 602 PlotPatchRate(start, runs, fname); 381 603 382 604 gROOT->SetSelectedPad(0); … … 392 614 frame1.SetStats(kFALSE); 393 615 frame1.GetXaxis()->SetTimeDisplay(true); 394 frame1.GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 17:00:00 GMT");616 frame1.GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00");// 18:00:00 GMT); 395 617 frame1.GetXaxis()->SetLabelSize(0.2); 396 618 frame1.GetXaxis()->SetTitleSize(0.2); … … 400 622 401 623 if (outpath) 402 c->SaveAs( outpath);624 c->SaveAs(Form("%s/quality-%04d%02d%02d.pdf", outpath, y, m, d)); 403 625 404 626 return 0; 405 627 } 628 629 int quality(UInt_t y, UInt_t m, UInt_t d, const char *outpath=0, const bool all=true) 630 { 631 return quality("/data/aux", y, m, d, outpath, all); 632 }
Note:
See TracChangeset
for help on using the changeset viewer.