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