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