1 | #include <algorithm>
|
---|
2 | #include <functional>
|
---|
3 |
|
---|
4 | Bool_t Contains(TArrayD **vec, Double_t t0, Double_t range=0)
|
---|
5 | {
|
---|
6 | TArrayD *arr0 = vec[0];
|
---|
7 | TArrayD *arr1 = vec[1];
|
---|
8 | TArrayD *arr2 = vec[2];
|
---|
9 |
|
---|
10 | for (int i=0; i<arr0->GetSize(); i++)
|
---|
11 | {
|
---|
12 | Double_t start = (*arr1)[i];
|
---|
13 | Double_t stop = (*arr2)[i];
|
---|
14 |
|
---|
15 | if (stop>start+305./24/3600)
|
---|
16 | stop = start+305./24/3600;
|
---|
17 |
|
---|
18 | if (t0>start-range && t0<stop+range)
|
---|
19 | //{
|
---|
20 | // if (fmod(t0, 1)>4./24 && fmod(t0,1)<4.1/24)
|
---|
21 | // cout << t0-start << " " <<t0 << " " << stop-t0 << " " << start-15779 << " " << stop-15779 << " " << (*arr0)[i] << endl;
|
---|
22 | return kTRUE;
|
---|
23 | //}
|
---|
24 | }
|
---|
25 |
|
---|
26 | return arr0->GetSize()==0;
|
---|
27 | }
|
---|
28 |
|
---|
29 | Int_t PlotThresholds(TArrayD **vec, TString fname)
|
---|
30 | {
|
---|
31 | fname += ".RATE_CONTROL_THRESHOLD.fits";
|
---|
32 |
|
---|
33 | fits file(fname.Data());
|
---|
34 | if (!file)
|
---|
35 | {
|
---|
36 | cerr << fname << ": " << gSystem->GetError() << endl;
|
---|
37 | return -2;
|
---|
38 | }
|
---|
39 |
|
---|
40 | //cout << fname << endl;
|
---|
41 |
|
---|
42 | Double_t time;
|
---|
43 | UShort_t th;
|
---|
44 |
|
---|
45 | if (!file.SetPtrAddress("Time", &time))
|
---|
46 | return -1;
|
---|
47 |
|
---|
48 | if (!file.SetPtrAddress("threshold", &th))
|
---|
49 | return -1;
|
---|
50 |
|
---|
51 | TGraph g;
|
---|
52 | g.SetName("Threshold");
|
---|
53 |
|
---|
54 | while (file.GetNextRow())
|
---|
55 | {
|
---|
56 | if (Contains(vec, time, 10./(24*3600)))
|
---|
57 | g.SetPoint(g.GetN(), time*24*3600, th);
|
---|
58 | }
|
---|
59 |
|
---|
60 | g.SetMinimum(281);
|
---|
61 | g.SetMarkerStyle(kFullDotMedium);
|
---|
62 | g.GetXaxis()->SetTimeDisplay(true);
|
---|
63 | g.GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00 GMT");
|
---|
64 | g.GetXaxis()->SetLabelSize(0.12);
|
---|
65 | g.GetYaxis()->SetLabelSize(0.1);
|
---|
66 | g.GetYaxis()->SetTitle("THRESHOLD");
|
---|
67 | g.GetYaxis()->SetTitleOffset(0.2);
|
---|
68 | g.GetYaxis()->SetTitleSize(0.1);
|
---|
69 | g.DrawClone("AP");
|
---|
70 |
|
---|
71 | return 0;
|
---|
72 | }
|
---|
73 |
|
---|
74 | #include <vector>
|
---|
75 | #include <pair>
|
---|
76 |
|
---|
77 | vector<pair<double, Nova::EquPosn>> vecp;
|
---|
78 |
|
---|
79 | Nova::EquPosn FindPointing(Double_t time)
|
---|
80 | {
|
---|
81 | for (int i=0; i<vecp.size(); i++)
|
---|
82 | if (time<vecp[i].first)
|
---|
83 | {
|
---|
84 | if (i==0)
|
---|
85 | return Nova::EquPosn();
|
---|
86 | else
|
---|
87 | return vecp[i-1].second;
|
---|
88 | }
|
---|
89 |
|
---|
90 | return vecp[vecp.size()-1].second;
|
---|
91 | }
|
---|
92 |
|
---|
93 | Float_t Prediction(Double_t time)
|
---|
94 | {
|
---|
95 | Double_t jd = time + 40587 + 2400000.5;
|
---|
96 |
|
---|
97 | // Get source position
|
---|
98 | Nova::EquPosn pos = FindPointing(time);
|
---|
99 |
|
---|
100 | return FACT::PredictI(jd, pos);
|
---|
101 | }
|
---|
102 |
|
---|
103 | Int_t ReadSources(TString fname)
|
---|
104 | {
|
---|
105 | fname += ".DRIVE_CONTROL_SOURCE_POSITION.fits";
|
---|
106 |
|
---|
107 | fits file(fname.Data());
|
---|
108 | if (!file)
|
---|
109 | {
|
---|
110 | cerr << fname << ": " << gSystem->GetError() << endl;
|
---|
111 | return -2;
|
---|
112 | }
|
---|
113 |
|
---|
114 | Double_t time, ra, dec;
|
---|
115 | if (!file.SetPtrAddress("Time", &time))
|
---|
116 | return -1;
|
---|
117 | if (!file.SetPtrAddress("Ra_cmd", &ra))
|
---|
118 | return -1;
|
---|
119 | if (!file.SetPtrAddress("Dec_cmd", &dec))
|
---|
120 | return -1;
|
---|
121 |
|
---|
122 | while (file.GetNextRow())
|
---|
123 | {
|
---|
124 | Nova::EquPosn p;
|
---|
125 | p.ra = ra*15;
|
---|
126 | p.dec = dec;
|
---|
127 |
|
---|
128 | vecp.push_back(make_pair(time, p));
|
---|
129 | }
|
---|
130 |
|
---|
131 | return 0;
|
---|
132 | }
|
---|
133 |
|
---|
134 | Int_t PlotCurrent(TArrayD **vec, TString fname)
|
---|
135 | {
|
---|
136 | Int_t rc = ReadSources(fname);
|
---|
137 | if (rc<0)
|
---|
138 | return rc;
|
---|
139 |
|
---|
140 | fname += ".FEEDBACK_CALIBRATED_CURRENTS.fits";
|
---|
141 |
|
---|
142 | fits file(fname.Data());
|
---|
143 | if (!file)
|
---|
144 | {
|
---|
145 | cerr << fname << ": " << gSystem->GetError() << endl;
|
---|
146 | return -2;
|
---|
147 | }
|
---|
148 |
|
---|
149 | //cout << fname << endl;
|
---|
150 |
|
---|
151 | Double_t time;
|
---|
152 | Float_t Imed;
|
---|
153 | Float_t Idev;
|
---|
154 | Float_t I[416];
|
---|
155 |
|
---|
156 | if (!file.SetPtrAddress("Time", &time))
|
---|
157 | return -1;
|
---|
158 |
|
---|
159 | if (!file.SetPtrAddress("I_med", &Imed))
|
---|
160 | return -1;
|
---|
161 |
|
---|
162 | if (!file.SetPtrAddress("I_dev", &Idev))
|
---|
163 | return -1;
|
---|
164 |
|
---|
165 | if (!file.SetPtrAddress("I", I))
|
---|
166 | return -1;
|
---|
167 |
|
---|
168 | TGraph g1;
|
---|
169 | TGraph g2;
|
---|
170 | TGraph g3;
|
---|
171 | TGraph g4;
|
---|
172 | TGraph g5;
|
---|
173 | g1.SetName("CurrentsMed");
|
---|
174 | g2.SetName("Prediction");
|
---|
175 | g3.SetName("CurrentsDev");
|
---|
176 | g4.SetName("CurrentsMax-4");
|
---|
177 | g5.SetName("CurrentsMax");
|
---|
178 |
|
---|
179 | while (file.GetNextRow())
|
---|
180 | if (Contains(vec, time))
|
---|
181 | {
|
---|
182 | // crazy pixels
|
---|
183 | I[66] = 0;
|
---|
184 | I[191] = 0;
|
---|
185 | I[193] = 0;
|
---|
186 |
|
---|
187 | sort(I, I+320);
|
---|
188 |
|
---|
189 | g1.SetPoint(g1.GetN(), time*24*3600, Imed);
|
---|
190 | g2.SetPoint(g2.GetN(), time*24*3600, Prediction(time));
|
---|
191 | g3.SetPoint(g3.GetN(), time*24*3600, Imed+Idev);
|
---|
192 | g4.SetPoint(g4.GetN(), time*24*3600, I[315]);
|
---|
193 | g5.SetPoint(g5.GetN(), time*24*3600, I[319]);
|
---|
194 | }
|
---|
195 |
|
---|
196 | g1.SetMinimum(0);
|
---|
197 | g1.SetMaximum(149);
|
---|
198 |
|
---|
199 | g1.SetMarkerStyle(kFullDotMedium);
|
---|
200 | g1.GetXaxis()->SetTimeDisplay(true);
|
---|
201 | g1.GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00 GMT");
|
---|
202 | g1.GetXaxis()->SetLabelSize(0.12);
|
---|
203 | g1.GetYaxis()->SetLabelSize(0.1);
|
---|
204 | g1.GetYaxis()->SetTitle("CURRENT");
|
---|
205 | g1.GetYaxis()->SetTitleOffset(0.2);
|
---|
206 | g1.GetYaxis()->SetTitleSize(0.1);
|
---|
207 | g1.DrawClone("AP");
|
---|
208 |
|
---|
209 | g5.SetMarkerColor(kGray);
|
---|
210 | g5.DrawClone("P");
|
---|
211 |
|
---|
212 | g4.SetMarkerColor(kGray+1);
|
---|
213 | g4.DrawClone("P");
|
---|
214 |
|
---|
215 | g3.SetMarkerColor(kGray+2);
|
---|
216 | g3.DrawClone("P");
|
---|
217 |
|
---|
218 | g2.SetMarkerColor(kBlue);
|
---|
219 | g2.SetMarkerStyle(kFullDotMedium);
|
---|
220 | g2.DrawClone("P");
|
---|
221 |
|
---|
222 | g1.DrawClone("P");
|
---|
223 |
|
---|
224 | return 0;
|
---|
225 | }
|
---|
226 |
|
---|
227 | Int_t PlotRate(TArrayD **vec, TString fname)
|
---|
228 | {
|
---|
229 | fname += ".FTM_CONTROL_TRIGGER_RATES.fits";
|
---|
230 |
|
---|
231 | fits file(fname.Data());
|
---|
232 | if (!file)
|
---|
233 | {
|
---|
234 | cerr << fname << ": " << gSystem->GetError() << endl;
|
---|
235 | return -2;
|
---|
236 | }
|
---|
237 |
|
---|
238 | //cout << fname << endl;
|
---|
239 |
|
---|
240 | Double_t time;
|
---|
241 | Float_t rate;
|
---|
242 | Float_t ontime, elapsed;
|
---|
243 |
|
---|
244 | if (!file.SetPtrAddress("Time", &time))
|
---|
245 | return -1;
|
---|
246 |
|
---|
247 | if (!file.SetPtrAddress("TriggerRate", &rate))
|
---|
248 | return -1;
|
---|
249 | if (!file.SetPtrAddress("OnTime", &ontime))
|
---|
250 | return -1;
|
---|
251 | if (!file.SetPtrAddress("ElapsedTime", &elapsed))
|
---|
252 | return -1;
|
---|
253 |
|
---|
254 | TGraph g1, g2;
|
---|
255 | g1.SetName("TriggerRate");
|
---|
256 | g2.SetName("RelOnTime");
|
---|
257 |
|
---|
258 | while (file.GetNextRow())
|
---|
259 | if (Contains(vec, time))
|
---|
260 | {
|
---|
261 | if (rate>=0)
|
---|
262 | {
|
---|
263 | g1.SetPoint(g1.GetN(), time*24*3600, rate);
|
---|
264 | g2.SetPoint(g2.GetN(), time*24*3600, ontime/elapsed);
|
---|
265 | }
|
---|
266 | }
|
---|
267 |
|
---|
268 | g1.SetMinimum(0);
|
---|
269 | g1.SetMaximum(269);
|
---|
270 | g1.SetMarkerStyle(kFullDotMedium);
|
---|
271 | g1.GetXaxis()->SetTimeDisplay(true);
|
---|
272 | g1.GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00 GMT");
|
---|
273 | g1.GetXaxis()->SetLabelSize(0.12);
|
---|
274 | g1.GetYaxis()->SetLabelSize(0.1);
|
---|
275 | g1.GetYaxis()->SetTitle("TRIGGER RATE");
|
---|
276 | g1.GetYaxis()->SetTitleOffset(0.2);
|
---|
277 | g1.GetYaxis()->SetTitleSize(0.1);
|
---|
278 | g1.DrawClone("AP");
|
---|
279 |
|
---|
280 | gROOT->SetSelectedPad(0);
|
---|
281 | gPad->GetCanvas()->cd(4);
|
---|
282 |
|
---|
283 | gPad->SetGrid();
|
---|
284 | gPad->SetTopMargin(0);
|
---|
285 | gPad->SetBottomMargin(0);
|
---|
286 | gPad->SetRightMargin(0.001);
|
---|
287 | gPad->SetLeftMargin(0.04);
|
---|
288 |
|
---|
289 | g2.SetMinimum(0);
|
---|
290 | g2.SetMaximum(1);
|
---|
291 | g2.SetMarkerStyle(kFullDotMedium);
|
---|
292 | g2.GetXaxis()->SetTimeDisplay(true);
|
---|
293 | g2.GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00 GMT");
|
---|
294 | g2.GetXaxis()->SetLabelSize(0.12);
|
---|
295 | g2.GetYaxis()->SetLabelSize(0.1);
|
---|
296 | g2.GetYaxis()->SetTitle("RELATIVE ON TIME");
|
---|
297 | g2.GetYaxis()->SetTitleOffset(0.2);
|
---|
298 | g2.GetYaxis()->SetTitleSize(0.1);
|
---|
299 | g2.DrawClone("AP");
|
---|
300 |
|
---|
301 | return 0;
|
---|
302 | }
|
---|
303 |
|
---|
304 | void PlotRateQC(UInt_t night, MSQLServer &serv)
|
---|
305 | {
|
---|
306 | TString query =
|
---|
307 | "LEFT JOIN AnalysisResultsRunLP USING(fNight, fRunID) "
|
---|
308 | "WHERE fRunTypeKey=1 AND NOT ISNULL (AnalysisResultsRunLP.fNumEvtsAfterCleaning) AND fNight=";
|
---|
309 | query += night;
|
---|
310 |
|
---|
311 | TTree *t = serv.GetTree("RunInfo", query);
|
---|
312 | if (!t)
|
---|
313 | return;
|
---|
314 |
|
---|
315 | int save = gErrorIgnoreLevel;
|
---|
316 | gErrorIgnoreLevel = kFatal;
|
---|
317 |
|
---|
318 | gROOT->SetSelectedPad(0);
|
---|
319 | gPad->GetCanvas()->cd(3);
|
---|
320 |
|
---|
321 | t->Draw("AnalysisResultsRunLP.fNumEvtsAfterCleaning/AnalysisResultsRunLP.fOnTimeAfterCuts:(RunInfo.fRunStart+RunInfo.fRunStop)/2+9131*24*3600", "", "same");
|
---|
322 | TGraph *g = (TGraph*)gPad->GetPrimitive("Graph");
|
---|
323 | if (g)
|
---|
324 | {
|
---|
325 | g->SetName("CleaningRate");
|
---|
326 | g->SetMarkerColor(kRed);
|
---|
327 | g->SetMarkerStyle(29);//kFullDotMedium);
|
---|
328 | }
|
---|
329 |
|
---|
330 | t->Draw("AnalysisResultsRunLP.fNumEvtsAfterQualCuts/AnalysisResultsRunLP.fOnTimeAfterCuts:(RunInfo.fRunStart+RunInfo.fRunStop)/2+9131*24*3600", "", "same");
|
---|
331 | g = (TGraph*)gPad->GetPrimitive("Graph");
|
---|
332 | if (g)
|
---|
333 | {
|
---|
334 | g->SetName("RateAfterQC");
|
---|
335 | g->SetMarkerColor(kBlue);
|
---|
336 | g->SetMarkerStyle(29);//kFullDotMedium);
|
---|
337 | }
|
---|
338 |
|
---|
339 | gErrorIgnoreLevel = save;
|
---|
340 | }
|
---|
341 |
|
---|
342 | Int_t PlotHumidity(TArrayD **vec, TString fname)
|
---|
343 | {
|
---|
344 | fname += ".FSC_CONTROL_HUMIDITY.fits";
|
---|
345 |
|
---|
346 | fits file(fname.Data());
|
---|
347 | if (!file)
|
---|
348 | {
|
---|
349 | cerr << fname << ": " << gSystem->GetError() << endl;
|
---|
350 | return -2;
|
---|
351 | }
|
---|
352 |
|
---|
353 | //cout << fname << endl;
|
---|
354 |
|
---|
355 | Double_t time;
|
---|
356 | Float_t H[4];
|
---|
357 |
|
---|
358 | if (!file.SetPtrAddress("Time", &time))
|
---|
359 | return -1;
|
---|
360 | if (!file.SetPtrAddress("H", H))
|
---|
361 | return -1;
|
---|
362 |
|
---|
363 | //const int marker_style = kFullDotMedium;
|
---|
364 | const int marker_style = kDot;
|
---|
365 |
|
---|
366 | TGraph g1;
|
---|
367 | TGraph g2;
|
---|
368 | TGraph g3;
|
---|
369 | TGraph g4;
|
---|
370 | //TGraph g5;
|
---|
371 | g1.SetName("H0");
|
---|
372 | g2.SetName("H1");
|
---|
373 | g3.SetName("H2");
|
---|
374 | g4.SetName("H3");
|
---|
375 | //g5.SetName("PFmini");
|
---|
376 |
|
---|
377 |
|
---|
378 | Double_t first_time, last_time;
|
---|
379 | bool found_first_time = false;
|
---|
380 | while (file.GetNextRow())
|
---|
381 | if (Contains(vec, time))
|
---|
382 | {
|
---|
383 | if (!found_first_time){
|
---|
384 | first_time = time*24*3600;
|
---|
385 | found_first_time = true;
|
---|
386 | }
|
---|
387 | g1.SetPoint(g1.GetN(), time*24*3600, H[0]);
|
---|
388 | g2.SetPoint(g2.GetN(), time*24*3600, H[1]);
|
---|
389 | g3.SetPoint(g3.GetN(), time*24*3600, H[2]);
|
---|
390 | g4.SetPoint(g4.GetN(), time*24*3600, H[3]);
|
---|
391 | //g5.SetPoint(g5.GetN(), time*24*3600, I[319]);
|
---|
392 | last_time = time*24*3600;
|
---|
393 | }
|
---|
394 |
|
---|
395 |
|
---|
396 | g1.SetMinimum(0);
|
---|
397 | g1.SetMaximum(100);
|
---|
398 | g1.SetMarkerColor(kAzure);
|
---|
399 | g1.SetMarkerStyle(marker_style);
|
---|
400 | g1.GetXaxis()->SetTimeDisplay(true);
|
---|
401 | g1.GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00 GMT");
|
---|
402 | g1.GetXaxis()->SetLabelSize(0.12);
|
---|
403 | g1.GetYaxis()->SetLabelSize(0.1);
|
---|
404 | g1.GetYaxis()->SetTitle("HUMITIDY");
|
---|
405 | g1.GetYaxis()->SetTitleOffset(0.2);
|
---|
406 | g1.GetYaxis()->SetTitleSize(0.1);
|
---|
407 | g1.DrawClone("AP");
|
---|
408 |
|
---|
409 | g2.SetMarkerColor(kAzure+1);
|
---|
410 | g2.SetMarkerStyle(marker_style);
|
---|
411 | g2.DrawClone("P");
|
---|
412 |
|
---|
413 | g3.SetMarkerColor(kAzure+3);
|
---|
414 | g3.SetMarkerStyle(marker_style);
|
---|
415 | g3.DrawClone("P");
|
---|
416 |
|
---|
417 | g4.SetMarkerColor(kAzure+6);
|
---|
418 | g4.SetMarkerStyle(marker_style);
|
---|
419 | g4.DrawClone("P");
|
---|
420 |
|
---|
421 | //g5.SetMarkerColor(kAzure+1);
|
---|
422 | //g5.SetMarkerStyle(kFullDotMedium);
|
---|
423 | //g5.DrawClone("P");
|
---|
424 |
|
---|
425 | g1.DrawClone("P");
|
---|
426 |
|
---|
427 | TLine l1(first_time-600, 40, last_time+600, 40);
|
---|
428 | l1.SetLineColor(kOrange);
|
---|
429 | l1.DrawClone();
|
---|
430 | TText t1(first_time-600, 41, "Note in logbook");
|
---|
431 | t1.SetTextSize(0.1);
|
---|
432 | t1.DrawClone();
|
---|
433 |
|
---|
434 |
|
---|
435 | TLine l2(first_time-600, 55, last_time+600, 55);
|
---|
436 | l2.SetLineColor(kRed);
|
---|
437 | l2.DrawClone();
|
---|
438 | TText t2(first_time-600, 56, "Mail to fact-online.");
|
---|
439 | t2.SetTextSize(0.1);
|
---|
440 | t2.DrawClone();
|
---|
441 |
|
---|
442 |
|
---|
443 | return 0;
|
---|
444 | }
|
---|
445 |
|
---|
446 | Int_t PlotHumidity2(TArrayD **vec, TString fname)
|
---|
447 | {
|
---|
448 | fname += ".PFMINI_CONTROL_DATA.fits";
|
---|
449 |
|
---|
450 | fits file(fname.Data());
|
---|
451 | if (!file)
|
---|
452 | {
|
---|
453 | cerr << fname << ": " << gSystem->GetError() << endl;
|
---|
454 | return -2;
|
---|
455 | }
|
---|
456 |
|
---|
457 | //cout << fname << endl;
|
---|
458 |
|
---|
459 | Double_t time;
|
---|
460 | Float_t H;
|
---|
461 |
|
---|
462 | if (!file.SetPtrAddress("Time", &time))
|
---|
463 | return -1;
|
---|
464 | if (!file.SetPtrAddress("Humidity", &H))
|
---|
465 | return -1;
|
---|
466 |
|
---|
467 | const int marker_style = kFullDotMedium;
|
---|
468 | //const int marker_style = kDot;
|
---|
469 |
|
---|
470 | TGraph g1;
|
---|
471 | g1.SetName("PFmini");
|
---|
472 |
|
---|
473 |
|
---|
474 | while (file.GetNextRow())
|
---|
475 | if (Contains(vec, time))
|
---|
476 | {
|
---|
477 | g1.SetPoint(g1.GetN(), time*24*3600, H);
|
---|
478 | }
|
---|
479 |
|
---|
480 | g1.SetMarkerStyle(marker_style);
|
---|
481 | g1.SetMarkerColor(kGreen);
|
---|
482 | g1.DrawClone("P");
|
---|
483 | return 0;
|
---|
484 | }
|
---|
485 |
|
---|
486 | Int_t PlotPointing(TArrayD **vec, TString fname)
|
---|
487 | {
|
---|
488 | fname += ".DRIVE_CONTROL_POINTING_POSITION.fits";
|
---|
489 |
|
---|
490 | fits file(fname.Data());
|
---|
491 | if (!file)
|
---|
492 | {
|
---|
493 | cerr << fname << ": " << gSystem->GetError() << endl;
|
---|
494 | return -2;
|
---|
495 | }
|
---|
496 |
|
---|
497 | //cout << fname << endl;
|
---|
498 |
|
---|
499 | Double_t time;
|
---|
500 | Double_t zd;
|
---|
501 |
|
---|
502 | if (!file.SetPtrAddress("Time", &time))
|
---|
503 | return -1;
|
---|
504 | if (!file.SetPtrAddress("Zd", &zd))
|
---|
505 | return -1;
|
---|
506 |
|
---|
507 | TGraph g;
|
---|
508 | g.SetName("Zd");
|
---|
509 |
|
---|
510 | while (file.GetNextRow())
|
---|
511 | if (Contains(vec, time))
|
---|
512 | g.SetPoint(g.GetN(), time*24*3600, 90-zd);
|
---|
513 |
|
---|
514 | g.SetMinimum(1);
|
---|
515 | g.SetMaximum(90);
|
---|
516 | g.SetMarkerStyle(kFullDotMedium);
|
---|
517 | g.GetXaxis()->SetTimeDisplay(true);
|
---|
518 | g.GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00 GMT");
|
---|
519 | g.GetXaxis()->SetLabelSize(0.12);
|
---|
520 | g.GetYaxis()->SetLabelSize(0.1);
|
---|
521 | g.GetYaxis()->SetTitle("ELEVATION");
|
---|
522 | g.GetYaxis()->SetTitleOffset(0.2);
|
---|
523 | g.GetYaxis()->SetTitleSize(0.1);
|
---|
524 | g.DrawClone("AP");
|
---|
525 |
|
---|
526 | return 0;
|
---|
527 | }
|
---|
528 |
|
---|
529 | Int_t PlotTemperature1(TArrayD **vec, TString fname)
|
---|
530 | {
|
---|
531 | fname += ".TEMPERATURE_DATA.fits";
|
---|
532 |
|
---|
533 | fits file(fname.Data());
|
---|
534 | if (!file)
|
---|
535 | {
|
---|
536 | cerr << fname << ": " << gSystem->GetError() << endl;
|
---|
537 | return -2;
|
---|
538 | }
|
---|
539 |
|
---|
540 | //cout << fname << endl;
|
---|
541 |
|
---|
542 | Double_t time;
|
---|
543 | Float_t temp;
|
---|
544 |
|
---|
545 | if (!file.SetPtrAddress("Time", &time))
|
---|
546 | return -1;
|
---|
547 | if (!file.SetPtrAddress("T", &temp))
|
---|
548 | return -1;
|
---|
549 |
|
---|
550 | TGraph g;
|
---|
551 | g.SetName("ContainerTemp");
|
---|
552 |
|
---|
553 | while (file.GetNextRow())
|
---|
554 | if (Contains(vec, time))
|
---|
555 | g.SetPoint(g.GetN(), time*24*3600, temp);
|
---|
556 |
|
---|
557 | g.SetMinimum(-5);
|
---|
558 | g.SetMaximum(49);
|
---|
559 | g.SetMarkerStyle(kFullDotMedium);
|
---|
560 | g.SetMarkerColor(kRed);
|
---|
561 | g.GetXaxis()->SetTimeDisplay(true);
|
---|
562 | g.GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00 GMT");
|
---|
563 | g.GetXaxis()->SetLabelSize(0.1);
|
---|
564 | g.GetYaxis()->SetLabelSize(0.1);
|
---|
565 | g.GetYaxis()->SetTitle("TEMPERATURE");
|
---|
566 | g.GetYaxis()->SetTitleOffset(0.2);
|
---|
567 | g.GetYaxis()->SetTitleSize(0.1);
|
---|
568 | g.DrawClone("AP");
|
---|
569 |
|
---|
570 | return 0;
|
---|
571 | }
|
---|
572 |
|
---|
573 | Int_t PlotTemperature2(TArrayD **vec, TString fname)
|
---|
574 | {
|
---|
575 | fname += ".MAGIC_WEATHER_DATA.fits";
|
---|
576 |
|
---|
577 | fits file(fname.Data());
|
---|
578 | if (!file)
|
---|
579 | {
|
---|
580 | cerr << fname << ": " << gSystem->GetError() << endl;
|
---|
581 | return -2;
|
---|
582 | }
|
---|
583 |
|
---|
584 | //cout << fname << endl;
|
---|
585 |
|
---|
586 | Double_t time;
|
---|
587 | Float_t temp;
|
---|
588 |
|
---|
589 | if (!file.SetPtrAddress("Time", &time))
|
---|
590 | return -1;
|
---|
591 | if (!file.SetPtrAddress("T", &temp))
|
---|
592 | return -1;
|
---|
593 |
|
---|
594 | TGraph g;
|
---|
595 | g.SetName("OutsideTemp");
|
---|
596 |
|
---|
597 | while (file.GetNextRow())
|
---|
598 | if (Contains(vec, time))
|
---|
599 | g.SetPoint(g.GetN(), time*24*3600, temp);
|
---|
600 |
|
---|
601 | g.SetMarkerStyle(kFullDotMedium);
|
---|
602 | g.SetMarkerColor(kBlue);
|
---|
603 | g.DrawClone("P");
|
---|
604 |
|
---|
605 | return 0;
|
---|
606 | }
|
---|
607 |
|
---|
608 | Int_t PlotTemperature3(TArrayD **vec, TString fname)
|
---|
609 | {
|
---|
610 | fname += ".FSC_CONTROL_TEMPERATURE.fits";
|
---|
611 |
|
---|
612 | fits file(fname.Data());
|
---|
613 | if (!file)
|
---|
614 | {
|
---|
615 | cerr << fname << ": " << gSystem->GetError() << endl;
|
---|
616 | return -2;
|
---|
617 | }
|
---|
618 |
|
---|
619 | //cout << fname << endl;
|
---|
620 |
|
---|
621 | Double_t time;
|
---|
622 | Float_t temp[31];
|
---|
623 |
|
---|
624 | if (!file.SetPtrAddress("Time", &time))
|
---|
625 | return -1;
|
---|
626 | if (!file.SetPtrAddress("T_sens", temp))
|
---|
627 | return -1;
|
---|
628 |
|
---|
629 | TGraph g, g1, g2;
|
---|
630 | g.SetName("SensorTempAvg");
|
---|
631 | g1.SetName("SensorTempMin");
|
---|
632 | g2.SetName("SensorTempMax");
|
---|
633 |
|
---|
634 | while (file.GetNextRow())
|
---|
635 | if (Contains(vec, time))
|
---|
636 | {
|
---|
637 | float min = 100;
|
---|
638 | float max = -100;
|
---|
639 | double avg = 0;
|
---|
640 | int num = 0;
|
---|
641 | for (int i=0; i<31; i++)
|
---|
642 | if (temp[i]!=0)
|
---|
643 | {
|
---|
644 | avg += temp[i];
|
---|
645 | num++;
|
---|
646 |
|
---|
647 | min = TMath::Min(min, temp[i]);
|
---|
648 | max = TMath::Max(max, temp[i]);
|
---|
649 | }
|
---|
650 |
|
---|
651 | g.SetPoint(g.GetN(), time*24*3600, avg/num);
|
---|
652 | g1.SetPoint(g1.GetN(), time*24*3600, min);
|
---|
653 | g2.SetPoint(g2.GetN(), time*24*3600, max);
|
---|
654 | }
|
---|
655 |
|
---|
656 | g.SetMarkerStyle(kFullDotMedium);
|
---|
657 | g.DrawClone("P");
|
---|
658 |
|
---|
659 | /*
|
---|
660 | g1.SetLineWidth(1);
|
---|
661 | g1.DrawClone("L");
|
---|
662 |
|
---|
663 | g2.SetLineWidth(1);
|
---|
664 | g2.DrawClone("L");
|
---|
665 | */
|
---|
666 | return 0;
|
---|
667 | }
|
---|
668 |
|
---|
669 | Int_t PlotTemperature4(TArrayD **vec, TString fname)
|
---|
670 | {
|
---|
671 | fname += ".FAD_CONTROL_TEMPERATURE.fits";
|
---|
672 |
|
---|
673 | fits file(fname.Data());
|
---|
674 | if (!file)
|
---|
675 | {
|
---|
676 | cerr << fname << ": " << gSystem->GetError() << endl;
|
---|
677 | return -2;
|
---|
678 | }
|
---|
679 |
|
---|
680 | //cout << fname << endl;
|
---|
681 |
|
---|
682 | Double_t time;
|
---|
683 | Float_t temp[160];
|
---|
684 |
|
---|
685 | if (!file.SetPtrAddress("Time", &time))
|
---|
686 | return -1;
|
---|
687 | // if (!file.SetPtrAddress("Data1", temp) &&
|
---|
688 | // !file.SetPtrAddress("temp", temp))
|
---|
689 | if (!file.SetPtrAddress("temp", temp))
|
---|
690 | return -1;
|
---|
691 |
|
---|
692 | Int_t num = file.GetN("temp")==0 ? file.GetN("Data1") : file.GetN("temp");
|
---|
693 | Int_t beg = num==82 ? 2 : 0;
|
---|
694 |
|
---|
695 | TGraphErrors g1;
|
---|
696 | TGraph g2,g3;
|
---|
697 |
|
---|
698 | g1.SetName("FadTempAvg");
|
---|
699 | g2.SetName("FadTempMin");
|
---|
700 | g3.SetName("FadTempMax");
|
---|
701 |
|
---|
702 | while (file.GetNextRow())
|
---|
703 | if (Contains(vec, time))
|
---|
704 | {
|
---|
705 | double avg = 0;
|
---|
706 | double rms = 0;
|
---|
707 | float min = 100;
|
---|
708 | float max = -100;
|
---|
709 | for (int i=beg; i<num; i++)
|
---|
710 | {
|
---|
711 | avg += temp[i];
|
---|
712 | rms += temp[i]*temp[i];
|
---|
713 |
|
---|
714 | min = TMath::Min(min, temp[i]);
|
---|
715 | max = TMath::Max(max, temp[i]);
|
---|
716 | }
|
---|
717 |
|
---|
718 | avg /= num-beg;
|
---|
719 | rms /= num-beg;
|
---|
720 |
|
---|
721 | g1.SetPoint(g1.GetN(), time*24*3600, avg);
|
---|
722 | g1.SetPointError(g1.GetN()-1, 0, sqrt(rms-avg*avg));
|
---|
723 |
|
---|
724 | g2.SetPoint(g2.GetN(), time*24*3600, min);
|
---|
725 | g3.SetPoint(g3.GetN(), time*24*3600, max);
|
---|
726 | }
|
---|
727 |
|
---|
728 | g1.SetLineColor(kGreen);
|
---|
729 | g1.DrawClone("[]");
|
---|
730 |
|
---|
731 | g2.SetLineColor(kGreen);
|
---|
732 | g2.SetLineWidth(1);
|
---|
733 | g2.DrawClone("L");
|
---|
734 |
|
---|
735 | g3.SetLineColor(kGreen);
|
---|
736 | g3.SetLineWidth(1);
|
---|
737 | g3.DrawClone("L");
|
---|
738 |
|
---|
739 | return 0;
|
---|
740 | }
|
---|
741 |
|
---|
742 | int quality(UInt_t y=0, UInt_t m=0, UInt_t d=0, const char *outpath="quality")
|
---|
743 | {
|
---|
744 | // To get correct dates in the histogram you have to add
|
---|
745 | // the MJDREF offset (should be 40587) and 9131.
|
---|
746 |
|
---|
747 | if (y==0)
|
---|
748 | {
|
---|
749 | UInt_t nt = MTime(MTime(-1).GetMjd()-1.5).GetNightAsInt();
|
---|
750 | y = nt/10000;
|
---|
751 | m = (nt/100)%100;
|
---|
752 | d = nt%100;
|
---|
753 |
|
---|
754 | cout << y << "/" << m << "/" << d << endl;
|
---|
755 | }
|
---|
756 |
|
---|
757 | TString fname=Form("/fact/aux/%04d/%02d/%02d/%04d%02d%02d", y, m, d, y, m, d);
|
---|
758 |
|
---|
759 | UInt_t night = MTime(y, m, d, 0).GetNightAsInt();
|
---|
760 |
|
---|
761 | MSQLMagic serv("sql.rc");
|
---|
762 | Bool_t con = serv.IsConnected();
|
---|
763 |
|
---|
764 | cout << "quality" << endl;
|
---|
765 | cout << "-------" << endl;
|
---|
766 | cout << endl;
|
---|
767 | if (con)
|
---|
768 | {
|
---|
769 | cout << "Connected to " << serv.GetName() << endl;
|
---|
770 | cout << endl;
|
---|
771 | }
|
---|
772 | cout << "Night: " << Form("%04d-%02d-%02d", y, m, d) << endl;
|
---|
773 | cout << endl;
|
---|
774 |
|
---|
775 | TArrayD run, beg, end;
|
---|
776 |
|
---|
777 | TArrayD *runs[3] = { &run, &beg, &end };
|
---|
778 |
|
---|
779 | if (con)
|
---|
780 | {
|
---|
781 | TString query;
|
---|
782 | query += "SELECT fRunID, fRunStart, fRunStop FROM RunInfo";
|
---|
783 | query += " WHERE fNight=";
|
---|
784 | query += night;
|
---|
785 | query += " AND fRunTypeKey=1 ORDER BY fRunStart";
|
---|
786 |
|
---|
787 | TSQLResult *res = serv.Query(query);
|
---|
788 | if (!res)
|
---|
789 | return 1;
|
---|
790 |
|
---|
791 | run.Set(res->GetRowCount());
|
---|
792 | beg.Set(res->GetRowCount());
|
---|
793 | end.Set(res->GetRowCount());
|
---|
794 |
|
---|
795 | Int_t n = 0;
|
---|
796 |
|
---|
797 | TSQLRow *row = 0;
|
---|
798 | while ((row=res->Next()))
|
---|
799 | {
|
---|
800 | run[n] = atoi((*row)[0]);
|
---|
801 | beg[n] = MTime((*row)[1]).GetMjd()-40587;
|
---|
802 | end[n] = MTime((*row)[2]).GetMjd()-40587;
|
---|
803 | n++;
|
---|
804 | delete row;
|
---|
805 | }
|
---|
806 |
|
---|
807 | delete res;
|
---|
808 |
|
---|
809 | if (n==0)
|
---|
810 | cout << "WARNING - No data runs in db, displaying all data." << endl;
|
---|
811 | else
|
---|
812 | cout << "Num: " << n << "\n" << endl;
|
---|
813 | }
|
---|
814 |
|
---|
815 | TCanvas *c = new TCanvas("quality", Form("Quality %04d/%02d/%02d", y, m, d), 1280, 1120);
|
---|
816 | c->Divide(1, 7, 1e-5, 1e-5);
|
---|
817 |
|
---|
818 | gROOT->SetSelectedPad(0);
|
---|
819 |
|
---|
820 | c->cd(1);
|
---|
821 | gPad->SetGrid();
|
---|
822 | gPad->SetTopMargin(0);
|
---|
823 | gPad->SetRightMargin(0.001);
|
---|
824 | gPad->SetLeftMargin(0.04);
|
---|
825 | gPad->SetBottomMargin(0);
|
---|
826 | cout << PlotThresholds(runs, fname) << endl;
|
---|
827 |
|
---|
828 | gROOT->SetSelectedPad(0);
|
---|
829 | c->cd(2);
|
---|
830 | gPad->SetGrid();
|
---|
831 | gPad->SetTopMargin(0);
|
---|
832 | gPad->SetRightMargin(0.001);
|
---|
833 | gPad->SetLeftMargin(0.04);
|
---|
834 | gPad->SetBottomMargin(0);
|
---|
835 | cout << PlotCurrent(runs, fname) << endl;
|
---|
836 |
|
---|
837 | gROOT->SetSelectedPad(0);
|
---|
838 | c->cd(3);
|
---|
839 | gPad->SetGrid();
|
---|
840 | gPad->SetTopMargin(0);
|
---|
841 | gPad->SetBottomMargin(0);
|
---|
842 | gPad->SetRightMargin(0.001);
|
---|
843 | gPad->SetLeftMargin(0.04);
|
---|
844 | cout << PlotRate(runs, fname) << endl;
|
---|
845 | cout << PlotRateQC(night, serv) << endl;
|
---|
846 |
|
---|
847 | gROOT->SetSelectedPad(0);
|
---|
848 | c->cd(5);
|
---|
849 | gPad->SetGrid();
|
---|
850 | gPad->SetTopMargin(0);
|
---|
851 | gPad->SetBottomMargin(0);
|
---|
852 | gPad->SetRightMargin(0.001);
|
---|
853 | gPad->SetLeftMargin(0.04);
|
---|
854 | cout << PlotPointing(runs, fname) << endl;
|
---|
855 |
|
---|
856 | gROOT->SetSelectedPad(0);
|
---|
857 | c->cd(6);
|
---|
858 | gPad->SetGrid();
|
---|
859 | gPad->SetTopMargin(0);
|
---|
860 | gPad->SetRightMargin(0.001);
|
---|
861 | gPad->SetLeftMargin(0.04);
|
---|
862 | cout << PlotTemperature1(runs, fname) << endl;
|
---|
863 | cout << PlotTemperature2(runs, fname) << endl;
|
---|
864 | cout << PlotTemperature3(runs, fname) << endl;
|
---|
865 | cout << PlotTemperature4(runs, fname) << endl;
|
---|
866 |
|
---|
867 | gROOT->SetSelectedPad(0);
|
---|
868 | c->cd(7);
|
---|
869 | gPad->SetGrid();
|
---|
870 | gPad->SetTopMargin(0);
|
---|
871 | gPad->SetRightMargin(0.001);
|
---|
872 | gPad->SetLeftMargin(0.04);
|
---|
873 | cout << PlotHumidity(runs, fname) << endl;
|
---|
874 | cout << PlotHumidity2(runs, fname) << endl;
|
---|
875 |
|
---|
876 | c->SaveAs(Form("%s/%04d%02d%02d.png", outpath, y, m, d));
|
---|
877 |
|
---|
878 | return 0;
|
---|
879 | }
|
---|