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

Last change on this file since 3077 was 2841, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 8.8 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("ccdata.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 h0.SetName("Mjd");
96 h1.SetName("Zd");
97 h2.SetName("Az");
98 h3.SetName("State");
99
100 MH3 h4("MReportDrive.GetAbsError*60");
101 h4.SetName("DeltaH");
102
103 MH3 h5("MReportDrive.fNominalZd","MReportDrive.GetAbsError*60");
104 h5.SetName("DeltaHvsZd");
105
106 MBinning bins("BinningDeltaH");
107 bins.SetEdges(18, 0, 3.6);
108
109 MBinning bins2("BinningDeltaHvsZdX");
110 MBinning bins3("BinningDeltaHvsZdY");
111 bins2.SetEdges(90, 0, 90);
112 bins3.SetEdges(18, 0, 3.6);
113
114 plist.AddToList(&bins);
115 plist.AddToList(&bins2);
116 plist.AddToList(&bins3);
117
118 MFillH fill0(&h0, "MTimeDrive");
119 MFillH fill1(&h1, "MTimeDrive");
120 MFillH fill2(&h2, "MTimeDrive");
121 MFillH fill3(&h3, "MTimeDrive");
122 MFillH fill4(&h4);
123 MFillH fill5(&h5);
124
125 fill0.SetBit(MFillH::kDoNotDisplay);
126 fill1.SetBit(MFillH::kDoNotDisplay);
127 fill2.SetBit(MFillH::kDoNotDisplay);
128 fill3.SetBit(MFillH::kDoNotDisplay);
129 fill4.SetBit(MFillH::kDoNotDisplay);
130 fill5.SetBit(MFillH::kDoNotDisplay);
131
132 // -----------------------------------------------
133
134 //
135 // Setup Task list
136 //
137 tlist.AddToList(&read);
138 tlist.AddToList(&fill3);
139 tlist.AddToList(&tracking);
140 tlist.AddToList(&fill0);
141 tlist.AddToList(&fill1);
142 tlist.AddToList(&fill2);
143 tlist.AddToList(&fill4);
144 tlist.AddToList(&fill5);
145
146 gStyle->SetOptStat(0);
147
148 //
149 // Create and setup the eventloop
150 //
151 MEvtLoop evtloop;
152 evtloop.SetParList(&plist);
153
154 //
155 // Execute your analysis
156 //
157 evtloop.SetDisplay(d);
158 if (!evtloop.Eventloop())
159 return;
160
161 tlist.PrintStatistics();
162
163 TGraph *g1 = h1.GetGraph();
164 TGraph *g2 = h2.GetGraph();
165
166 TCanvas &c = d->AddTab("Sky");
167
168 c->cd();
169
170 TPad *p = new TPad("", "",0,0.05,0.6,0.95);
171 p->Draw();
172 p->cd();
173
174 gPad->SetTheta(-90);
175 gPad->SetPhi(90);
176 gPad->SetBorderMode(0);
177 gStyle->SetOptStat(0);
178
179 TH2F h("pol", "Telescope Tracking Positions on the Sky", 16, 0, 1, 9, 0, 1);
180 h.DrawClone("surf1pol");
181
182 gPad->Modified();
183 gPad->Update();
184
185 TView *view = gPad->GetView();
186 if (!view)
187 {
188 cout << "No View!" << endl;
189 return;
190 }
191
192 //TGraph gr;
193
194 Double_t *zd=g1->GetY();
195 Double_t *az=g2->GetY();
196
197 Double_t old[2] = {0,0};
198
199 for (int i=0; i<g1->GetN(); i++)
200 {
201 az[i] += 180;
202 az[i] *= TMath::Pi()/180;
203
204 Double_t x[3] = { zd[i]*cos(az[i])/90, zd[i]*sin(az[i])/90, 0};
205 Double_t y[3];
206
207 view->WCtoNDC(x, y);
208
209 if (old[0]!=0 && old[1]!=1)
210 {
211 TLine *l = new TLine(y[0], y[1], old[0], old[1]);
212 l->SetLineColor(kBlue);
213 l->Draw();
214 }
215
216 TMarker *m = new TMarker(y[0], y[1], kFullDotMedium);
217 m->SetMarkerColor(i==g1->GetN()-1 ? kGreen : kRed);
218 m->Draw();
219
220 old[0] = y[0];
221 old[1] = y[1];
222 }
223
224 c.cd();
225/*
226 p = new TPad("", "", 0.6, 0.66, 1, 1);
227 p->Draw();
228 p->cd();
229
230 MHVsTime *hvt=h0.DrawClone("nonew");
231 hvt->GetGraph()->SetMarkerStyle(kFullDotSmall);
232 hvt->GetGraph()->GetHistogram()->SetXTitle("Time");
233 hvt->GetGraph()->GetHistogram()->SetYTitle("");
234 hvt->GetGraph()->GetHistogram()->SetTitle("MJD vs. Time");
235 hvt->GetGraph()->GetHistogram()->SetStats(0);
236
237 c.cd();
238*/
239 p = new TPad("", "", 0.6, 0, 1, 0.29);
240 p->Draw();
241 p->cd();
242
243 gStyle->SetOptStat(1110);
244 gStyle->SetStatFormat(".2g");
245
246 MH3 *mh3 = (MH3*)h4.DrawClone("nonew");
247
248 mh3->GetHist()->SetXTitle("\\Delta [arcmin]");
249 mh3->GetHist()->SetYTitle("");
250 mh3->GetHist()->SetTitle("Control deviation of the motors");
251 mh3->GetHist()->SetStats(1);
252
253 TLine ln;
254 ln.SetLineColor(kGreen);
255 ln.DrawLine(0.5*360*60/16384., 0, 0.5*360*60/16384., h4.GetHist()->GetMaximum());
256 ln.SetLineColor(kYellow);
257 ln.DrawLine(1.0*360*60/16384., 0, 1.0*360*60/16384., h4.GetHist()->GetMaximum());
258 ln.SetLineColor(kRed);
259 ln.DrawLine(2.0*360*60/16384., 0, 2.0*360*60/16384., h4.GetHist()->GetMaximum());
260
261 c.cd();
262
263 p = new TPad("", "", 0.6, 0.29, 1, 0.42);
264 p->Draw();
265 p->cd();
266
267 hvt = (MHVsTime*)h3.DrawClone("nonew");
268 hvt->GetGraph()->SetMarkerStyle(kFullDotSmall);
269
270 TH1 *hist = hvt->GetGraph()->GetHistogram();
271 TAxis *axey = hist->GetYaxis();
272 TAxis *axex = hist->GetXaxis();
273
274 hist->SetXTitle("Time");
275 hist->SetYTitle("");
276 hist->SetTitle("");//Drive Status vs. Time");
277 hist->SetStats(0);
278 hist->SetMinimum(-0.5);
279 hist->SetMaximum(4.5);
280 axey->Set(5, -0.5, 4.5);
281 axey->SetBinLabel(axey->FindFixBin(0), "Error");
282 axey->SetBinLabel(axey->FindFixBin(1), "Stopped");
283 axey->SetBinLabel(axey->FindFixBin(3), "Moving");
284 axey->SetBinLabel(axey->FindFixBin(4), "Tracking");
285 axey->SetLabelSize(0.15);
286 axex->SetLabelSize(0.08);
287 axex->SetTitleSize(0.09);
288 axex->SetTitleOffset(0.45);
289
290 c.cd();
291
292 p = new TPad("", "", 0.6, 0.71, 1, 1);
293 p->Draw();
294 p->cd();
295
296 gStyle->SetOptStat(1110);
297 gStyle->SetStatFormat(".2g");
298
299 mh3 = (MH3*)h5.DrawClone("nonew");
300
301 mh3->GetHist()->SetXTitle("Zd [\\circ]");
302 mh3->GetHist()->SetYTitle("\\Delta [arcmin]");
303 mh3->GetHist()->SetTitle("Control deviation of the motors");
304 mh3->GetHist()->SetStats(1);
305 mh3->GetHist()->Draw("box");
306
307 c.cd();
308
309 p = new TPad("", "", 0.6, 0.42, 1, 0.71);
310 p->Draw();
311 p->cd();
312
313 gPad->SetBorderMode(0);
314
315 hvt = (MHVsTime*)h1.DrawClone("nonew");
316
317 hvt->GetGraph()->SetMarkerStyle(kFullDotSmall);
318 if (hvt->GetGraph()->GetN())
319 {
320 hvt->GetGraph()->GetHistogram()->SetXTitle("Time");
321 hvt->GetGraph()->GetHistogram()->SetYTitle("Zd [\\circ]");
322 hvt->GetGraph()->GetHistogram()->SetTitle("Zd vs. Time");
323 hvt->GetGraph()->GetHistogram()->SetStats(0);
324 }
325
326 /*
327 TCanvas &c = d->AddTab("Sky3");
328
329 c.cd();
330
331 p = new TPad("", "", 0, 0, 1, 1);
332 p->Draw();
333 p->cd();
334
335 hvt = (MHVsTime*)h1.DrawClone("nonew");
336 hvt->GetGraph()->SetMarkerStyle(kFullDotSmall);
337 hvt->GetGraph()->GetHistogram()->SetXTitle("Time");
338 hvt->GetGraph()->GetHistogram()->SetYTitle("Zd [\\circ]");
339 hvt->GetGraph()->GetHistogram()->SetTitle("Zd vs. Time");
340 hvt->GetGraph()->GetHistogram()->SetStats(0);
341
342 */
343
344 //d.SaveAsPS(2, "rep_files/CC_2003_11_27_22_31_59-new.ps");
345 //d.SaveAsRoot(2, "~/dev/Mars/rep_files/CC_2003_11_27_22_31_59-new.root");
346
347}
Note: See TracBrowser for help on using the repository browser.