1 | /*****************************************************************
|
---|
2 |
|
---|
3 | fresnellens_psf.C - Example how to use MFresnelLens directly
|
---|
4 |
|
---|
5 | To run the macro from the command line (assuming you are in a directory
|
---|
6 | Mars/build where you have built your Mars environment) you have to do
|
---|
7 |
|
---|
8 | root ../hawc/fresnellens_psf.C
|
---|
9 |
|
---|
10 | or from within root
|
---|
11 |
|
---|
12 | [0] .x ../hawc/fresnellens_psf.C
|
---|
13 |
|
---|
14 | ******************************************************************/
|
---|
15 | void fresnellens_psf()
|
---|
16 | {
|
---|
17 | // ------------------- setup lens -----------------------
|
---|
18 |
|
---|
19 | const double D = 54.92; // [cm] Diameter of the refractive surface
|
---|
20 | const double F = 50.21; // [cm] Nominal focal length of the lens
|
---|
21 | const double H = 0.25; // [cm] Thickness of lens
|
---|
22 | const double Z = F; // [cm] camera position w.r.t. lens exit (see also MGeomCamFAMOUS!)
|
---|
23 |
|
---|
24 | const double R = D/2; // [cm] radius of lens
|
---|
25 | //const double w = 0.01; // [cm] Width of a single groove
|
---|
26 | //const double w = 1; // [cm] Width of a single groove
|
---|
27 | //const double H = 1.5; // [cm] Thickness of lens
|
---|
28 |
|
---|
29 | const double Rcam = 1.5*4.5; // [cm] radius of camera
|
---|
30 |
|
---|
31 | const double lambda = 546; // [nm] Wavelength for simulated rays
|
---|
32 |
|
---|
33 | double psf = 0; // Do not change! It might have unpredicted side effectes
|
---|
34 |
|
---|
35 | double angle = 6; // [cm] angle of incidence of simulates rays
|
---|
36 |
|
---|
37 | MFresnelLens lens;
|
---|
38 | lens.SetPSF(psf);
|
---|
39 | //lens.DefineLens(F, D, w, H, lambda);
|
---|
40 | //lens.EnableSlopeAbsorption();
|
---|
41 | //lens.EnableDraftAbsorption();
|
---|
42 | //lens.DisableBottomReflection();
|
---|
43 | //lens.DisableMultiEntry();
|
---|
44 | //lens.DisableFresnelReflection();
|
---|
45 | lens.ReadTransmission("resmc/hawcseye/transmission-pmma-3mm.txt", 0.3, true);
|
---|
46 |
|
---|
47 | // ------------------- setup histograms -----------------
|
---|
48 |
|
---|
49 | unsigned int NN = 1000;
|
---|
50 |
|
---|
51 | TH2F h_out("OUT", "Photon Distribution (out)", NN*4/3, -R*4/3, R*4/3, NN, -R, R);
|
---|
52 | TH2F h_psf("PSF", "Point Spread Function", 2000*4/3, -R*4/3, R*4/3, 2000, -R, R);
|
---|
53 | TH2F h_cam("CAM", "Point Spread Function", 4*37*4/3, -14*4/3, 14*4/3, 4*37, -14, 14);
|
---|
54 |
|
---|
55 | TH1F h_rc("RET", "Return code", 8, 0.5, 8.5);
|
---|
56 |
|
---|
57 | // ------------------ Run simulation ---------------------
|
---|
58 |
|
---|
59 | int cnt = 0; // counter for photons hitting the camera
|
---|
60 |
|
---|
61 | int Nrays = 100000;
|
---|
62 | for (int i=0; i<Nrays; i++)
|
---|
63 | {
|
---|
64 | // ---------------------------------------------------------------
|
---|
65 | Double_t X, Y;
|
---|
66 | gRandom->Circle(X, Y, R*sqrt(gRandom->Uniform(0, 1)));
|
---|
67 |
|
---|
68 | TVector3 pos(X, Y, 0);
|
---|
69 |
|
---|
70 | // ---------------------------------------------------------------
|
---|
71 |
|
---|
72 | TVector3 dir;
|
---|
73 | dir.SetMagThetaPhi(1, (180-angle)*TMath::DegToRad(), TMath::Pi()/2);
|
---|
74 |
|
---|
75 | double v = 1./(TMath::C()*100/1e9); // cm/ns
|
---|
76 |
|
---|
77 | // ---------------------------------------------------------------
|
---|
78 |
|
---|
79 | MQuaternion pp(pos, 0);
|
---|
80 | MQuaternion uu(dir, v);
|
---|
81 |
|
---|
82 | // ---------------------------------------------------------------
|
---|
83 |
|
---|
84 | int ret = lens.ExecuteOptics(pp, uu, lambda);
|
---|
85 |
|
---|
86 | // Skip photons which will not hit the focal plane within r<R
|
---|
87 | if (ret<0)
|
---|
88 | {
|
---|
89 | h_rc.Fill((-ret)%10); // Keep reason for loss
|
---|
90 | continue;
|
---|
91 | }
|
---|
92 |
|
---|
93 | // Keep exit position on bottom surface
|
---|
94 | h_out.Fill(pp.X(), pp.Y());
|
---|
95 |
|
---|
96 | // Propagate to th focal plane
|
---|
97 | pp.PropagateZ(uu, Z);
|
---|
98 |
|
---|
99 | // Keep position in focal plane
|
---|
100 | h_psf.Fill(pp.X(), pp.Y());
|
---|
101 | h_cam.Fill(pp.X(), pp.Y());
|
---|
102 |
|
---|
103 | if (pp.R()<Rcam)
|
---|
104 | cnt++;
|
---|
105 | }
|
---|
106 |
|
---|
107 | // ------------------ Display result ---------------------
|
---|
108 |
|
---|
109 | TEllipse circ;
|
---|
110 | circ.SetLineWidth(2);
|
---|
111 | circ.SetFillStyle(0);
|
---|
112 |
|
---|
113 | TMarker m;
|
---|
114 | m.SetMarkerStyle(kFullDotMedium);
|
---|
115 |
|
---|
116 | TCanvas *c = new TCanvas;
|
---|
117 | c->Divide(2,2);
|
---|
118 | c->cd(1);
|
---|
119 | h_cam.DrawCopy("colz");
|
---|
120 | circ.DrawEllipse(0, 0, 4.5*1.5, 4.5*1.5, 0, 360, 0);
|
---|
121 | m.DrawMarker(0, angle*F/TMath::RadToDeg());
|
---|
122 | c->cd(2);
|
---|
123 | h_out.DrawCopy("colz");
|
---|
124 | c->cd(3);
|
---|
125 | h_psf.DrawCopy("colz");
|
---|
126 | circ.DrawEllipse(0, 0, 4.5*1.5, 4.5*1.5, 0, 360, 0);
|
---|
127 | m.DrawMarker(0, angle*F/TMath::RadToDeg());
|
---|
128 | c->cd(4);
|
---|
129 | h_rc.DrawCopy();
|
---|
130 |
|
---|
131 | // Photons inside the camera
|
---|
132 | cout << "Efficiency = " << double(cnt)/Nrays << " (N=" << cnt << ")" << endl;
|
---|
133 | }
|
---|