source: trunk/MagicSoft/Mars/macros/pointing.C@ 3916

Last change on this file since 3916 was 3909, checked in by Daniela Dorner, 21 years ago
*** empty log message ***
File size: 11.0 KB
Line 
1/*
2 class MGraph : public TGraph
3{
4public:
5 MGraph() : TGraph() {}
6 MGraph(Int_t n) : TGraph(n) {}
7 MGraph(Int_t n, const Int_t *x, const Int_t *y) : TGraph(n, x, y) {}
8 MGraph(Int_t n, const Float_t *x, const Float_t *y) : TGraph(n, x, y) {}
9 MGraph(Int_t n, const Double_t *x, const Double_t *y) : TGraph(n, x, y) {}
10 MGraph(const TVector &vx, const TVector &vy) : TGraph(vx, vy) {}
11 MGraph(const TVectorD &vx, const TVectorD &vy) : TGraph(vx, vy) {}
12 MGraph(const TH1 *h) : TGraph(h) {}
13 MGraph(const TF1 *f, Option_t *option="") : TGraph(f, option) {}
14 MGraph(const char *filename, const char *format="%lg %lg", Option_t *option="") : TGraph(filename, format, option) {}
15
16 void Paint(Option_t *o="")
17 {
18 if (!strstr(option,"POL") && !strstr(option,"pol"))
19 {
20 TGraph::Paint(o);
21 return;
22 }
23
24 //gPad->Range(-1.15, -1, 1.15, 1);
25
26 //gPad->Modified();
27 //gPad->Update();
28
29 TView *view = gPad->GetView();
30 if (!view)
31 {
32 cout << "No View!" << endl;
33 return;
34 }
35
36 TGraph gr;
37
38 Double_t *zd=g1->GetY();
39 Double_t *az=g2->GetY();
40
41 TMarker m;
42 m.SetMarkerStyle(kFullDotMedium);
43 m.SetMarkerColor(kRed);
44
45 for (int i=0; i<fN; i++)
46 {
47 const Double_t x = fX[i]/90;
48 const Double_t y = (fY[i]/180+1)*TMath::Pi();
49
50 Double_t r0[3] = { y*cos(x), y*sin(x), 0};
51 Double_t r1[3];
52
53 //gr.SetPoint(gr.GetN(), r0[0], r0[1]);
54
55 view->WCtoNDC(x, y);
56
57 m->PaintMarker(r1[0], r1[1]);
58 }
59 }
60};*/
61
62void pointing()
63{
64 MStatusDisplay *d = new MStatusDisplay;
65 d->SetLogStream(&gLog, kTRUE);
66
67 //
68 // Create a empty Parameter List and an empty Task List
69 // The tasklist is identified in the eventloop by its name
70 //
71 MParList plist;
72
73 MTaskList tlist;
74 plist.AddToList(&tlist);
75
76 //
77 // Now setup the tasks and tasklist:
78 // ---------------------------------
79 //
80
81 // First Task: Read file with image parameters
82 // (created with the star.C macro)
83 MReadReports read;
84 read.AddTree("Drive");
85 read.AddFile("data/2004_01_26_report.root");
86 read.AddToBranchList("MReportDrive.*");
87
88 MContinue tracking("MReportDrive.fState<3.5");
89
90 // Create a task which fills one histogram with the data
91 //MHVsTime h0("MReportDrive.fMjd");
92 MHVsTime h1("MReportDrive.fNominalZd");
93 MHVsTime h2("MReportDrive.fNominalAz");
94 MHVsTime h3("MReportDrive.fState");
95 MHVsTime h7("MReportDrive.GetAbsError*60");
96 //h0.SetName("Mjd");
97 h1.SetName("Zd");
98 h2.SetName("Az");
99 h3.SetName("State");
100 h7.SetName("ControlDeviation");
101
102 MH3 h4("MReportDrive.GetAbsError*60");
103 h4.SetName("DeltaH");
104
105 MH3 h5("MReportDrive.fNominalZd","MReportDrive.GetAbsError*60");
106 h5.SetName("DeltaHvsZd");
107
108 MBinning bins("BinningDeltaH");
109 bins.SetEdges(18, 0, 3.6);
110
111 MBinning bins2("BinningDeltaHvsZdX");
112 MBinning bins3("BinningDeltaHvsZdY");
113 bins2.SetEdges(90, 0, 90);
114 bins3.SetEdges(18, 0, 3.6);
115
116 plist.AddToList(&bins);
117 plist.AddToList(&bins2);
118 plist.AddToList(&bins3);
119
120 //MFillH fill0(&h0, "MTimeDrive");
121 MFillH fill1(&h1, "MTimeDrive");
122 MFillH fill2(&h2, "MTimeDrive");
123 MFillH fill3(&h3, "MTimeDrive");
124 MFillH fill7(&h7, "MTimeDrive");
125 MFillH fill4(&h4);
126 MFillH fill5(&h5);
127
128 //fill0.SetBit(MFillH::kDoNotDisplay);
129 fill1.SetBit(MFillH::kDoNotDisplay);
130 fill2.SetBit(MFillH::kDoNotDisplay);
131 fill3.SetBit(MFillH::kDoNotDisplay);
132 fill4.SetBit(MFillH::kDoNotDisplay);
133 fill5.SetBit(MFillH::kDoNotDisplay);
134 fill7.SetBit(MFillH::kDoNotDisplay);
135
136 // -----------------------------------------------
137
138 //
139 // Setup Task list
140 //
141 tlist.AddToList(&read);
142 tlist.AddToList(&fill3);
143 tlist.AddToList(&tracking);
144 //tlist.AddToList(&fill0);
145 tlist.AddToList(&fill1);
146 tlist.AddToList(&fill2);
147 tlist.AddToList(&fill4);
148 tlist.AddToList(&fill5);
149 tlist.AddToList(&fill7);
150
151 gStyle->SetOptStat(0);
152
153 //
154 // Create and setup the eventloop
155 //
156 MEvtLoop evtloop;
157 evtloop.SetParList(&plist);
158
159 //
160 // Execute your analysis
161 //
162 evtloop.SetDisplay(d);
163 if (!evtloop.Eventloop())
164 return;
165
166 tlist.PrintStatistics();
167
168
169 TGraph *g1 = h1.GetGraph();
170 TGraph *g2 = h2.GetGraph();
171
172 TCanvas &c = d->AddTab("Sky");
173 c.cd();
174
175 //Skyplot
176 TPad *p = new TPad("", "",0,0.32,0.5,1);
177 p->Draw();
178 p->cd();
179
180 gPad->SetTheta(-90);
181 gPad->SetPhi(90);
182 gPad->SetBorderMode(0);
183 gStyle->SetOptStat(0);
184
185 TH2F h("pol", "Telescope Tracking Positions on the Sky", 16, 0, 1, 9, 0, 1);
186 h.DrawClone("surf1pol");
187
188 gPad->Modified();
189 gPad->Update();
190
191 TView *view = gPad->GetView();
192 if (!view)
193 {
194 cout << "No View!" << endl;
195 return;
196 }
197
198 Double_t *zd=g1->GetY();
199 Double_t *az=g2->GetY();
200
201 Double_t old[2] = {0,0};
202
203 for (int i=0; i<g1->GetN(); i++)
204 {
205 az[i] += 180;
206 az[i] *= TMath::Pi()/180;
207
208 Double_t x[3] = { zd[i]*cos(az[i])/90, zd[i]*sin(az[i])/90, 0};
209 Double_t y[3];
210
211 view->WCtoNDC(x, y);
212
213 if (old[0]!=0 && old[1]!=1)
214 {
215 TLine *l = new TLine(y[0], y[1], old[0], old[1]);
216 l->SetLineColor(kBlue);
217 l->Draw();
218 }
219
220 TMarker *m = new TMarker(y[0], y[1], kFullDotMedium);
221 m->SetMarkerColor(i==g1->GetN()-1 ? kGreen : kRed);
222 m->Draw();
223
224 old[0] = y[0];
225 old[1] = y[1];
226 }
227
228 c.cd();
229
230
231/*
232 //MJD
233 p = new TPad("", "", 0.6, 0.66, 1, 1);
234 p->Draw();
235 p->cd();
236
237 MHVsTime *hvt=h0.DrawClone("nonew");
238 hvt->GetGraph()->SetMarkerStyle(kFullDotSmall);
239 hvt->GetGraph()->GetHistogram()->SetXTitle("Time");
240 hvt->GetGraph()->GetHistogram()->SetYTitle("");
241 hvt->GetGraph()->GetHistogram()->SetTitle("MJD vs. Time");
242 hvt->GetGraph()->GetHistogram()->SetStats(0);
243
244 c.cd();
245*/
246
247
248 //Histogram of Control Deviation
249 p = new TPad("", "", 0, 0, 0.5, 0.32);
250 p->Draw();
251 p->cd();
252
253 gPad->SetBorderMode(0);
254 //number of entries, mean, rms and number of overflows in the statusbox
255 gStyle->SetOptStat("emro");
256 //gStyle->SetStatFormat(".2g");
257
258 MH3 *mh3 = (MH3*)h4.DrawClone("nonew");
259
260 TAxis *axey = mh3->GetHist()->GetYaxis();
261 TAxis *axex = mh3->GetHist()->GetXaxis();
262 axey->SetLabelSize(0.05);
263 axex->SetLabelSize(0.05);
264 axex->SetTitleSize(0.05);
265 axex->SetTitleOffset(0.85);
266
267 mh3->GetHist()->SetXTitle("\\Delta [arcmin]");
268 mh3->GetHist()->SetYTitle("");
269 mh3->GetHist()->SetTitle("Control deviation of the motors");
270 mh3->GetHist()->SetStats(1);
271
272 //insert lines for 0.5, 1 and 2 SE
273 TLine ln;
274 ln.SetLineColor(kGreen);
275 ln.DrawLine(0.5*360*60/16384., 0, 0.5*360*60/16384., h4.GetHist()->GetMaximum());
276 ln.SetLineColor(kYellow);
277 ln.DrawLine(1.0*360*60/16384., 0, 1.0*360*60/16384., h4.GetHist()->GetMaximum());
278 ln.SetLineColor(kRed);
279 ln.DrawLine(2.0*360*60/16384., 0, 2.0*360*60/16384., h4.GetHist()->GetMaximum());
280
281 c.cd();
282
283
284 //Status of the Drive System vs Time
285 p = new TPad("", "", 0.5, 0.86, 1, 1);
286 p->Draw();
287 p->cd();
288 gPad->SetBorderMode(0);
289 p->SetGridx();
290
291 hvt = (MHVsTime*)h3.DrawClone("nonew");
292 hvt->GetGraph()->SetMarkerStyle(kFullDotSmall);
293
294 TH1 *hist = hvt->GetGraph()->GetHistogram();
295 TAxis *axey = hist->GetYaxis();
296 TAxis *axex = hist->GetXaxis();
297
298 hist->SetXTitle("Time");
299 hist->SetYTitle("");
300 hist->SetTitle("");//Drive Status vs. Time");
301 hist->SetStats(0);
302 hist->SetMinimum(-0.5);
303 hist->SetMaximum(4.5);
304 axey->Set(5, -0.5, 4.5);
305 axey->SetBinLabel(axey->FindFixBin(0), "Error");
306 axey->SetBinLabel(axey->FindFixBin(1), "Stopped");
307 axey->SetBinLabel(axey->FindFixBin(3), "Moving");
308 axey->SetBinLabel(axey->FindFixBin(4), "Tracking");
309 axey->SetLabelSize(0.15);
310 axex->SetLabelSize(0.08);
311 axex->SetTitleSize(0.09);
312 axex->SetTitleOffset(0.45);
313
314 c.cd();
315
316
317 //Zd vs Time
318 p = new TPad("", "", 0.5, 0.59, 1, 0.86);
319 p->Draw();
320 p->cd();
321 gPad->SetBorderMode(0);
322 p->SetGridx();
323
324 hvt = (MHVsTime*)h1.DrawClone("nonew");
325 hvt->GetGraph()->SetMarkerStyle(kFullDotSmall);
326
327 TH1 *hist = hvt->GetGraph()->GetHistogram();
328 if (hvt->GetGraph()->GetN())
329 {
330 hist->SetXTitle("Time");
331 hist->SetYTitle("Zd [\\circ]");
332 hist->SetTitle("Zd vs. Time");
333 hist->SetStats(0);
334 }
335
336 TAxis *axey = hist->GetYaxis();
337 TAxis *axex = hist->GetXaxis();
338 axey->SetLabelSize(0.05);
339 axey->SetTitleSize(0.06);
340 axey->SetTitleOffset(0.6);
341 axex->SetLabelSize(0.05);
342 axex->SetTitleSize(0.06);
343 axex->SetTitleOffset(0.85);
344
345 c.cd();
346
347
348 //Controll Deviation vs Time
349 p = new TPad("", "", 0.5, 0.32, 1, 0.59);
350 p->Draw();
351 p->cd();
352 gPad->SetBorderMode(0);
353 p->SetGridx();
354
355 hvt = (MHVsTime*)h7.DrawClone("nonew L");
356 TH1 *hist = hvt->GetGraph()->GetHistogram();
357 hist->SetAxisRange(-0.5, 10.5, "Y");
358 hist->SetXTitle("Time");
359 hist->SetYTitle("\\Delta [arcmin]");
360 hist->SetTitle("Control Deviation vs. Time");
361
362 TAxis *axey = hist->GetYaxis();
363 TAxis *axex = hist->GetXaxis();
364 axey->SetLabelSize(0.05);
365 axey->SetTitleSize(0.06);
366 axey->SetTitleOffset(0.5);
367 axex->SetLabelSize(0.05);
368 axex->SetTitleSize(0.06);
369 axex->SetTitleOffset(0.8);
370
371 //insert lines for 0.5, 1 and 2 SE
372 TLine ln;
373 ln.SetLineColor(kGreen);
374 ln.DrawLine(hist->GetXaxis()->GetXmin(), 0.5*360*60/16384., hist->GetXaxis()->GetXmax(), 0.5*360*60/16384.);
375 ln.SetLineColor(kYellow);
376 ln.DrawLine(hist->GetXaxis()->GetXmin(), 1.0*360*60/16384., hist->GetXaxis()->GetXmax(), 1.0*360*60/16384.);
377 ln.SetLineColor(kRed);
378 ln.DrawLine(hist->GetXaxis()->GetXmin(), 2.0*360*60/16384., hist->GetXaxis()->GetXmax(), 2.0*360*60/16384.);
379
380 c.cd();
381
382
383 //Controll Deviation vs Zd
384 p = new TPad("", "", 0.5, 0, 1, 0.32);
385 p->Draw();
386 p->cd();
387
388 gPad->SetBorderMode(0);
389 gStyle->SetOptStat(1110);
390 gStyle->SetStatFormat(".2g");
391
392 mh3 = (MH3*)h5.DrawClone("nonew");
393
394 TAxis *axey = mh3->GetHist()->GetYaxis();
395 TAxis *axex = mh3->GetHist()->GetXaxis();
396 axey->SetLabelSize(0.05);
397 axey->SetTitleSize(0.05);
398 axey->SetTitleOffset(0.7);
399 axex->SetLabelSize(0.05);
400 axex->SetTitleSize(0.05);
401 axex->SetTitleOffset(0.85);
402
403 mh3->GetHist()->SetYTitle("Zd [\\circ]");
404 mh3->GetHist()->SetXTitle("\\Delta [arcmin]");
405 mh3->GetHist()->SetTitle("Control deviation of the motors");
406 mh3->GetHist()->SetStats(1);
407 mh3->GetHist()->Draw("box");
408
409 //insert lines for 0.5, 1 and 2 SE
410 TLine ln;
411 ln.SetLineColor(kGreen);
412 ln.DrawLine(0, 0.5*360*60/16384., 90, 0.5*360*60/16384.);
413 ln.SetLineColor(kYellow);
414 ln.DrawLine(0, 1.0*360*60/16384., 90, 1.0*360*60/16384.);
415 ln.SetLineColor(kRed);
416 ln.DrawLine(0, 2.0*360*60/16384., 90, 2.0*360*60/16384.);
417
418
419 //d.SaveAsPS(2, "rep_files/CC_2003_11_27_22_31_59-new.ps");
420 //d.SaveAsRoot(2, "~/dev/Mars/rep_files/CC_2003_11_27_22_31_59-new.root");
421
422}
Note: See TracBrowser for help on using the repository browser.