source: trunk/MagicSoft/Mars/macros/tutorials/mirrordelay.C@ 8560

Last change on this file since 8560 was 8337, checked in by tbretz, 18 years ago
*** empty log message ***
File size: 3.4 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Thomas Bretz, 2/2007 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2007
21!
22!
23\* ======================================================================== */
24
25void mirrordelay()
26{
27 TF1 fpar("Parab", "x*x/(4*[0])");
28 TF1 fsph("Sphere", "-sqrt(4*[0]*[0] - x*x) + 2*[0]");
29
30 Double_t F = 4.92; // Fokallaenge = 1/4a
31 Double_t D = 4.5; // Mirror Diameter
32 Double_t x = 1.85; // incident point for photon
33
34 fsph.SetRange(-D*0.55, D*0.55);
35 fpar.SetRange(-D*0.55, D*0.55);
36
37 fpar.SetParameter(0, F);
38 fsph.SetParameter(0, F);
39
40 fpar.SetMaximum(F*1.05);
41
42 TCanvas *c = new TCanvas;
43 c->SetBorderMode(0);
44 c->SetFrameBorderMode(0);
45 c->SetFillColor(kWhite);
46
47 TF1 *f = (TF1*)fpar.DrawClone();
48 fsph.DrawClone("same");
49
50 f->GetXaxis()->SetTitle("x [m]");
51 f->GetYaxis()->SetTitle("y [m]");
52 f->GetXaxis()->CenterTitle();
53
54 TArrow l;
55 l.SetLineColor(kBlue);
56 l.DrawArrow(-x, F*1.05, -x, fsph.Eval(-x), 0.02);
57 l.DrawArrow( x, F*1.05, x, fsph.Eval( x), 0.02);
58 l.SetLineColor(kRed);
59 l.DrawArrow(-x, fsph.Eval(-x), -x, fpar.Eval(-x), 0.02);
60 l.DrawArrow( x, fsph.Eval(-x), x, fpar.Eval( x), 0.02);
61 l.DrawArrow(-x, fpar.Eval(-x), 0, F, 0.02);
62 l.DrawArrow(-x, fsph.Eval(-x), 0, F, 0.02);
63 l.DrawArrow( x, fpar.Eval( x), 0, F, 0.02);
64 l.DrawArrow( x, fsph.Eval( x), 0, F, 0.02);
65
66 TMarker m;
67 m.SetMarkerStyle(kStar);
68 m.DrawMarker(0, F);
69
70 // Plot run-time different versus distance
71
72 c = new TCanvas;
73 c->SetBorderMode(0);
74 c->SetFrameBorderMode(0);
75 c->SetFillColor(kWhite);
76 c->SetGridx();
77 c->SetGridy();
78
79 TLegend leg(0.40, 0.6, 0.60, 0.85);//, "NDC");
80
81 for (int i=-2; i<3; i++)
82 {
83 // Make sure to set the parameters BEFORE reusing the function!
84 fsph.SetParameter(0, F+i*0.10*F);
85 fpar.SetParameter(0, F+i*0.10*F);
86
87 TF1 fdel1("Diff1", "Sphere-Parab");
88 TF1 fdel2("Diff2", "TMath::Hypot(x-0, Parab-[0])-TMath::Hypot(x-0, Sphere-[0])");
89 fdel2.SetParameter(0, F+i*0.10*F);
90
91 TF1 fdel("Diff", "(Diff1+Diff2)/3e8*1e9");
92 fdel.SetRange(-D*0.55, D*0.55);
93 fdel.SetLineWidth(2);
94 fdel.SetParameter(0, F+i*0.10*F);
95
96 fdel.SetLineColor(kBlack+(abs(i)==2?3:abs(i)));
97 if (i<0)
98 fdel.SetLineStyle(2);
99 if (i==0)
100 fdel.SetLineStyle(kSolid);
101 if (i>0)
102 fdel.SetLineStyle(7);
103
104 f = (TF1*)fdel.DrawClone(i==-2?"":"same");
105
106 f->GetXaxis()->SetTitle("x [m]");
107 f->GetYaxis()->SetTitle("Delay \\Delta t [ns]");
108 f->GetXaxis()->CenterTitle();
109
110 leg.AddEntry(f, Form("F=%.1fm", F+i*0.10*F));
111 }
112
113 leg.DrawClone();
114}
Note: See TracBrowser for help on using the repository browser.