Rev 54 | Rev 72 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
25 | f9daq | 1 | #include "include/guide.h" |
2 | #include "src/raySimulator.cpp" |
||
3 | |||
4 | #include "TFile.h" |
||
5 | #include "TPolyMarker3D.h" |
||
6 | #include "TCanvas.h" |
||
7 | |||
8 | //extern int show_3d; |
||
9 | //extern int show_data; |
||
10 | |||
11 | // Set the simulation parameters |
||
70 | f9daq | 12 | void showVisual(int b) {show_3d = b;} |
13 | void showData(int b) {show_data = b;} |
||
25 | f9daq | 14 | |
15 | // Set the initial detector parameters (a, b, d, activeDetector, n1, n2, n3, gap) |
||
70 | f9daq | 16 | DetectorParameters parameters(3.0, 5.0, 3.0, 3.0, 1, 1.53, 1.46, TVector3(0.3, 0, 0)); |
17 | // Print the detector parameters |
||
18 | void getParameters(); |
||
25 | f9daq | 19 | |
20 | //void SetLGType(int in = 1, int side = 1, int out = 0) |
||
21 | //{detector->SetLGType(in, side, out);} |
||
22 | |||
70 | f9daq | 23 | void setLG(double SiPM0 = 3.0, double b0 = 5.0, double d0 = 3.0, double n1 = 1.0, double n2 = 1.53, double n3 = 1.46) |
24 | { parameters.setGuide(SiPM0, b0, d0); |
||
25 | parameters.setIndices(n1, n2, n3); } |
||
25 | f9daq | 26 | |
70 | f9daq | 27 | void setGap(double x_gap0 = 0.3, double y_gap0 = 0.0, double z_gap0 = 0.0) |
25 | f9daq | 28 | { parameters.setGap(x_gap0, y_gap0, z_gap0); } |
29 | |||
70 | f9daq | 30 | void setGlass(double glassOn, double glassD) |
25 | f9daq | 31 | { parameters.setGlass(glassOn, glassD); }; |
32 | |||
70 | f9daq | 33 | void setPlate(int plateOn = 1, double plateWidth = 1) |
25 | f9daq | 34 | { parameters.setPlate(plateOn, plateWidth); } |
35 | |||
70 | f9daq | 36 | void setFresnel(int fresnel = 1) { parameters.setFresnel(fresnel); } |
25 | f9daq | 37 | |
70 | f9daq | 38 | // Refractive Indices |
39 | // n1 - around light guide - air |
||
40 | // n2 - light guide (plate) material - k9 glass |
||
41 | // n3 - the material at the exit - optical grease, epoxy, air, etc. |
||
42 | void setIndices(double n1, double n2, double n3) {parameters.setIndices(n1, n2, n3);} |
||
43 | |||
25 | f9daq | 44 | int save_ary = 0; |
45 | //------------------------------------------------------------------------------------------ |
||
46 | void Help() |
||
47 | { |
||
48 | printf("void SetCenter(x, y, z)\n"); |
||
49 | printf("void SetLGType(in, side, out)\n"); |
||
50 | printf("SURF_DUMMY 0, "); |
||
51 | printf("SURF_REFRA 1, "); |
||
52 | printf("SURF_REFLE 2, "); |
||
53 | printf("SURF_TOTAL 3, "); |
||
54 | printf("SURF_IMPER 4\n"); |
||
55 | printf("void SetLG(SiPM0, M0, d0, n10, n20, n30, R0)\n"); |
||
56 | printf("void SetR(R0)\n"); |
||
57 | printf("void SetGlass(glass_on0, glass_d0)\n"); |
||
58 | printf("void SetGap(x_gap0, y_gap0, z_gap0)\n"); |
||
59 | |||
60 | printf("LGG(NN, theta)\n"); |
||
61 | printf("LGR(NN, theta, phi)\n"); |
||
62 | printf("LGI(NN, theta)\n"); |
||
63 | |||
64 | printf("LGI_gap(NN, min, max, steps, theta)\n"); |
||
65 | printf("LGR_gap(NN, min, max, steps, theta, phi)\n"); |
||
66 | printf("LGR_th(NN, min, max, steps, phi)\n"); |
||
67 | printf("LGG_th(NN, min, max, steps)\n"); |
||
68 | |||
69 | printf("LGI_ad(NN, mina, maxa, mind, maxd, steps(memory dependent), theta)"); |
||
70 | } |
||
71 | //------------------------------------------------------------------------------------------ |
||
72 | int show_in_steps = 0; |
||
73 | void SetShowInSteps(int in = 1) |
||
74 | { |
||
75 | show_in_steps = in; |
||
76 | } |
||
77 | //------------------------------------------------------------------------------------------ |
||
78 | int gs_set = 0; |
||
79 | void SetGS() |
||
80 | { |
||
81 | const UInt_t Number = 2; |
||
82 | Double_t Red[Number] = { 1.00, 0.00}; |
||
83 | Double_t Green[Number] = { 1.00, 0.00}; |
||
84 | Double_t Blue[Number] = { 1.00, 0.00}; |
||
85 | Double_t Stops[Number] = { 0.00, 1.00}; |
||
86 | |||
87 | Int_t nb=50; |
||
88 | if(!gs_set) { |
||
89 | TColor::CreateGradientColorTable(Number,Stops,Red,Green,Blue,nb); |
||
90 | gs_set = 1; |
||
91 | } |
||
92 | } |
||
93 | //------------------------------------------------------------------------------------------ |
||
94 | void Draw1(CDetector *detector, int gs = 0, double range = 0.0) |
||
95 | { |
||
96 | if(gs) SetGS(); |
||
97 | TCanvas *cdata = new TCanvas("cdata", "2dscan", 350, 0, 500, 500); |
||
98 | gStyle->SetOptTitle(0); |
||
99 | gStyle->SetOptStat(0); |
||
100 | cdata->cd(0); |
||
101 | if(range > 0.1) { |
||
102 | ((detector->GetHLaser())->GetXaxis())->SetRangeUser(-range,range); |
||
103 | ((detector->GetHLaser())->GetYaxis())->SetRangeUser(-range,range); |
||
104 | } |
||
105 | (detector->GetHLaser())->SetTitle("Hits at LG entrance; x [mm]; y [mm]"); |
||
106 | (detector->GetHLaser())->Draw("COLZ"); |
||
107 | cdata->SaveAs("2dscan.gif"); |
||
108 | //gStyle->SetOptTitle(1); |
||
109 | //gStyle->SetOptStat(1); |
||
110 | } |
||
111 | |||
112 | //------------------------------------------------------------------------------------------ |
||
113 | |||
114 | |||
115 | TVector3 p_pol0(0.0, 0.0, 1.0); |
||
116 | void SetPol(double x, double y, double z) |
||
117 | {p_pol0.SetXYZ(x,y,z);} |
||
118 | |||
70 | f9daq | 119 | // Test function |
120 | // creates an optical boundary surface |
||
121 | // shows the propagation of light ray |
||
122 | // and polarization state of the incident ray (green) |
||
123 | // and surface normal (blue) |
||
25 | f9daq | 124 | void PolTest(double theta = 0.0) |
125 | { |
||
126 | int p_type = 1; |
||
70 | f9daq | 127 | double p_n1 = parameters.getN1(); |
128 | double p_n2 = parameters.getN2(); |
||
25 | f9daq | 129 | theta = 3.141593*theta/180.0; if(theta < 1e-6) theta = 1e-6; |
130 | TVector3 p_pol; |
||
131 | |||
132 | Init(); |
||
133 | |||
134 | double cx = 0.0; |
||
135 | TVector3 vodnik_edge[4]; |
||
136 | double t = 3.0; |
||
137 | vodnik_edge[0].SetXYZ(cx, t,-t); vodnik_edge[1].SetXYZ(cx, t, t); |
||
138 | vodnik_edge[2].SetXYZ(cx,-t, t); vodnik_edge[3].SetXYZ(cx,-t,-t); |
||
139 | /* |
||
140 | #define SURF_DUMMY 0 |
||
141 | #define SURF_REFRA 1 |
||
142 | #define SURF_REFLE 2 |
||
143 | #define SURF_TOTAL 3 |
||
144 | #define SURF_IMPER 4 |
||
145 | */ |
||
146 | CSurface *surf = new CSurface(p_type, vodnik_edge, p_n1, p_n2, 0.96); //surf->FlipN(); |
||
70 | f9daq | 147 | surf->SetFresnel(1); |
25 | f9daq | 148 | surf->Draw(); |
149 | |||
150 | CRay *ray = new CRay(cx, 0.0, 0.0, TMath::Cos(theta), 0.0, TMath::Sin(theta)); |
||
70 | f9daq | 151 | ray->SetColor(kBlack); |
25 | f9daq | 152 | //p_pol = rotatey(p_pol0, -theta); |
153 | p_pol = p_pol0; p_pol.RotateY(-theta); |
||
154 | //printf("p_pol = "); printv(p_pol); |
||
155 | ray->SetPolarization(p_pol); |
||
156 | |||
157 | ray->DrawS(cx, -5.0); |
||
158 | |||
70 | f9daq | 159 | CRay *out = new CRay; out->SetColor(kRed); |
25 | f9daq | 160 | TVector3 *inters = new TVector3; |
70 | f9daq | 161 | surf->PropagateRay(*ray, out, inters); |
162 | //if(fate == 1) out->DrawS(cx, 5.0); |
||
163 | out->DrawS(cx, 5.0); |
||
164 | |||
165 | CRay *incidentPolarization = new CRay; |
||
166 | incidentPolarization->SetColor(kGreen); |
||
167 | incidentPolarization->Set(ray->GetR(), p_pol); |
||
168 | incidentPolarization->DrawS(cx, 1.0); |
||
25 | f9daq | 169 | |
70 | f9daq | 170 | CRay *surfaceNormal = new CRay; |
171 | surfaceNormal->SetColor(kBlue); |
||
172 | surfaceNormal->Set(ray->GetR(), surf->GetN()); |
||
173 | surfaceNormal->DrawS(cx, 1.0); |
||
25 | f9daq | 174 | } |
175 | |||
176 | void ptt() |
||
177 | { |
||
178 | for(double th = 0.0; th < 91.0; th += 5.0) { |
||
179 | printf("%lf ", th); |
||
180 | PolTest(th); |
||
181 | } |
||
182 | } |
||
183 | //------------------------------------------------------------------------------------------ |
||
184 | // Propagate single ray and show the statistics |
||
185 | void LGS(double xh = 0.0, double yh = 0.0, double zh = 0.0, double theta = 0.0, double phi = 0.0) |
||
186 | { |
||
187 | CDetector *detector = new CDetector(CENTER, parameters); |
||
188 | Init(); |
||
189 | double izkoristek = Single(detector, parameters, TVector3(xh,yh,zh),theta, phi); |
||
190 | PrintGuideHead(); |
||
54 | f9daq | 191 | PrintGuideStat(izkoristek); |
25 | f9daq | 192 | DrawData(detector, parameters, theta, izkoristek); |
193 | } |
||
194 | //------------------------------------------------------------------------------------------ |
||
195 | // Propagate NN rays generated as grid and show the statistics |
||
196 | void LGG(int NN = 10, double theta = 0.0) |
||
197 | { |
||
198 | CDetector *detector = new CDetector(TVector3(-2,0,0), parameters); |
||
199 | Init(); |
||
200 | double izkoristek = Grid(detector, parameters, NN, theta); |
||
201 | //printf("izkoristek = %.3lf\n", izkoristek); |
||
202 | PrintGuideHead(); |
||
54 | f9daq | 203 | PrintGuideStat(izkoristek); |
25 | f9daq | 204 | DrawData(detector, parameters, theta, izkoristek); |
205 | } |
||
206 | //------------------------------------------------------------------------------------------ |
||
207 | // Propagate NN rays genarated under the same angle theta, phi with random spacing and statistics |
||
208 | void LGR(int NN = 1e4, double theta = 0.0, double phi = 0.0) |
||
209 | { |
||
210 | CDetector *detector = new CDetector(TVector3(-2,0,0), parameters); |
||
211 | Init(); |
||
70 | f9daq | 212 | double izkoristek = RandYZ(detector, parameters, NN, theta, phi, 30); |
25 | f9daq | 213 | //printf("izkoristek = %.3lf\n", izkoristek); |
54 | f9daq | 214 | PrintGuideHead(); PrintGuideStat(izkoristek); |
25 | f9daq | 215 | DrawData(detector, parameters, theta, izkoristek); |
216 | } |
||
217 | //------------------------------------------------------------------------------------------ |
||
218 | // Propagate NN rays isotropically generated in solid angle theta and show the statistics |
||
219 | void LGI(int NN = 1e4, double theta = 30.0, int nnrays = 30, int showr = 0) |
||
220 | { |
||
221 | Init(); |
||
222 | CDetector *detector = new CDetector(CENTER, parameters); |
||
223 | //CDetector detector = new CDetector(); |
||
70 | f9daq | 224 | double izkoristek = RandIso(detector, parameters, NN, 0.0, theta, nnrays, showr); |
25 | f9daq | 225 | //printf("izkoristek = %.3lf\n", izkoristek); |
70 | f9daq | 226 | PrintGuideHead(); |
227 | PrintGuideStat(izkoristek); |
||
25 | f9daq | 228 | DrawData(detector, parameters, theta, izkoristek); |
229 | //TCanvas *canvasDetector = new TCanvas("canvasDetector","canvasDetector",500,500); |
||
230 | //canvasDetector->cd(); |
||
231 | //detector->Draw(); |
||
232 | } |
||
233 | |||
70 | f9daq | 234 | void LGB(int NN = 1e4, double phiMin=-19.4, double phiMax=19.4, int nnrays = 30, int showr = 0) |
235 | { |
||
236 | Init(); |
||
237 | CDetector *detector = new CDetector(CENTER, parameters); |
||
238 | //CDetector detector = new CDetector(); |
||
239 | double izkoristek = beamtest(detector, parameters, NN, 18.5, phiMin, phiMax, nnrays, showr); |
||
240 | //printf("izkoristek = %.3lf\n", izkoristek); |
||
241 | PrintGuideHead(); |
||
242 | PrintGuideStat(izkoristek); |
||
243 | DrawData(detector, parameters, 18.5, izkoristek); |
||
244 | //TCanvas *canvasDetector = new TCanvas("canvasDetector","canvasDetector",500,500); |
||
245 | //canvasDetector->cd(); |
||
246 | //detector->Draw(); |
||
247 | } |
||
25 | f9daq | 248 | |
249 | |||
250 | //------------------------------------------------------------------------------------------ |
||
251 | void LGI_gap(int NN = 1e4, double min = 0.0, double max = 2.0, const int steps = 10, double theta = 30.0) |
||
252 | { |
||
253 | int tmp3d = show_3d, tmpdata = show_data; |
||
254 | double step[steps], acc[steps]; |
||
255 | |||
256 | show_3d = 0; show_data = 0; |
||
257 | |||
258 | //printf(" x_gap | acceptance \n"); |
||
259 | PrintGuideHead(); |
||
260 | for(int i=0; i<=steps; i++) { |
||
261 | step[i] = min + i*(max - min)/(double)steps; |
||
262 | parameters.setGap(step[i], 0.0, 0.0); |
||
263 | CDetector *detector = new CDetector(CENTER, parameters); |
||
264 | Init(); |
||
70 | f9daq | 265 | acc[i] = RandIso(detector, parameters, NN, 0, theta); |
25 | f9daq | 266 | //printf("%6.2lf |%6.1lf\n", step[i], acc[i]*100.0); |
54 | f9daq | 267 | PrintGuideStat(acc[i]); |
25 | f9daq | 268 | } |
269 | |||
270 | //char sbuff[256]; |
||
271 | //sprintf(sbuff, "SiPM = %.1lf, M = %.1lf, d = %.1lf | gap(y,z) = (%.1lf, %.1lf) | #theta = %.1lf", |
||
272 | // detector->GetSiPM(), detector->GetM(), detector->GetD(), |
||
273 | // (detector->GetVGap()).y(), (detector->GetVGap()).z(), theta); |
||
274 | |||
275 | DrawAcc(steps+1, step, acc, (char*)"; x_gap;Acceptance", min, max); |
||
276 | |||
277 | show_3d = tmp3d; show_data = tmpdata; |
||
278 | } |
||
279 | //------------------------------------------------------------------------------------------ |
||
280 | |||
70 | f9daq | 281 | void LGR_th(int NN = 1e4, double min = 0.0, double max = 30.0, const int steps = 15, double phi = 0) |
282 | { |
||
283 | //int tmp3d = show_3d, tmpdata = show_data; |
||
284 | double show_rays = 10; |
||
285 | double step[steps], acc[steps]; |
||
286 | |||
287 | //show_3d = 0; show_data = 0; |
||
288 | |||
289 | //printf(" theta | acceptance \n"); |
||
290 | PrintGuideHead(); |
||
291 | for(int i=0; i<=steps; i++) { |
||
292 | Init(); |
||
293 | step[i] = min + i*(max - min)/(double)steps; |
||
294 | CDetector *detector = new CDetector(TVector3(-2,0,0), parameters); |
||
295 | acc[i] = RandYZ(detector, parameters, NN, step[i], phi, show_rays); |
||
296 | //printf("%6.1lf |%6.1lf\n", step[i], acc[i]*100.0); |
||
297 | PrintGuideStat(acc[i]); |
||
298 | delete detector; |
||
299 | } |
||
300 | |||
301 | //char sbuff[256]; |
||
302 | //sprintf(sbuff, "SiPM = %.1lf, M = %.1lf, d = %.1lf | gap = (%.1lf, %.1lf, %.1lf)", |
||
303 | // detector->GetSiPM(), detector->GetM(), detector->GetD(), |
||
304 | // (detector->GetVGap()).x(), (detector->GetVGap()).y(), (detector->GetVGap()).z()); |
||
305 | |||
306 | DrawAcc(steps+1, step, acc, (char*)"; #theta [deg];Acceptance", min, max); |
||
307 | |||
308 | //show_3d = tmp3d; show_data = tmpdata; |
||
309 | } |
||
310 | |||
311 | |||
25 | f9daq | 312 | //------------------------------------------------------------------------------------------ |
70 | f9daq | 313 | //void LGR_th(int NN = 1e4, double min = 0.0, double max = 30.0, const int steps = 15, double phi = 0) |
314 | void LGI_th(int NN = 1e4, double min = 0.0, double max = 30.0, const int steps = 15) |
||
25 | f9daq | 315 | { |
70 | f9daq | 316 | //int tmp3d = show_3d, tmpdata = show_data; |
317 | double step[steps], acc[steps]; |
||
25 | f9daq | 318 | |
70 | f9daq | 319 | //show_3d = 0; show_data = 0; |
25 | f9daq | 320 | |
321 | //printf(" theta | acceptance \n"); |
||
322 | PrintGuideHead(); |
||
323 | for(int i=0; i<=steps; i++) { |
||
324 | Init(); |
||
325 | step[i] = min + i*(max - min)/(double)steps; |
||
326 | CDetector *detector = new CDetector(TVector3(-2,0,0), parameters); |
||
70 | f9daq | 327 | //acc[i] = RandYZ(detector, parameters, NN, step[i], phi, 30); |
328 | acc[i] = RandIso(detector, parameters, NN, 0, step[i], 30, show_3d); |
||
25 | f9daq | 329 | //printf("%6.1lf |%6.1lf\n", step[i], acc[i]*100.0); |
54 | f9daq | 330 | PrintGuideStat(acc[i]); |
70 | f9daq | 331 | delete detector; |
25 | f9daq | 332 | } |
333 | |||
334 | //char sbuff[256]; |
||
335 | //sprintf(sbuff, "SiPM = %.1lf, M = %.1lf, d = %.1lf | gap = (%.1lf, %.1lf, %.1lf)", |
||
336 | // detector->GetSiPM(), detector->GetM(), detector->GetD(), |
||
337 | // (detector->GetVGap()).x(), (detector->GetVGap()).y(), (detector->GetVGap()).z()); |
||
338 | |||
339 | DrawAcc(steps+1, step, acc, (char*)"; #theta [deg];Acceptance", min, max); |
||
340 | |||
70 | f9daq | 341 | //show_3d = tmp3d; show_data = tmpdata; |
25 | f9daq | 342 | } |
343 | //------------------------------------------------------------------------------------------ |
||
344 | |||
70 | f9daq | 345 | void LGR_phi(int NN = 1e4, double maxTheta = 10.0, double maxPhi = 10.0, int steps = 10) |
346 | { |
||
347 | int tmp3d = show_3d, tmpdata = show_data; |
||
348 | show_3d = 1; show_data = 0; |
||
349 | //PrintGuideHead(); |
||
350 | TH2F *hAcceptance = new TH2F("hAcceptance","Acceptance;#theta;#phi", steps, 0, maxTheta, steps, 0, maxPhi); |
||
351 | double min = 0.0; |
||
352 | printf("\nWait, this takes a while "); |
||
353 | for(int i=0; i<=steps; i++) { |
||
354 | double theta = min + i*(maxTheta - min) / (double)steps; |
||
355 | for (int j=0; j<=steps; j++) { |
||
356 | Init(); |
||
357 | double phi = min + j*(maxPhi - min) / (double)steps; |
||
358 | CDetector *detector = new CDetector(TVector3(-2,0,0), parameters); |
||
359 | double acc = RandYZ(detector, parameters, NN, theta, phi, 30); |
||
360 | //PrintGuideStat(acc); |
||
361 | hAcceptance->Fill(i, j, acc); |
||
362 | //printf("Acc: %f ", acc); |
||
363 | delete detector; |
||
364 | } |
||
365 | printf("."); |
||
366 | } |
||
367 | printf("\n"); |
||
368 | //DrawAcc(steps+1, step, acc, (char*)"; #theta [deg];Acceptance", min, max); |
||
369 | show_3d = tmp3d; show_data = tmpdata; |
||
370 | TCanvas *cp = new TCanvas("Acceptance", "Acceptance", 0, 0, 1000, 1000); |
||
371 | cp->cd(); |
||
372 | hAcceptance->Draw("COLZ"); |
||
373 | } |
||
374 | |||
25 | f9daq | 375 | // a vs. d |
376 | void LGI_ad(int NN = 1e4, double min = 2.5, double max = 3.5, double minD = 1, double maxD = 6, const int steps = 10, double theta = 30.0) |
||
377 | { |
||
378 | //char sbuff[256]; |
||
379 | |||
70 | f9daq | 380 | //show_3d = 0; // don't show simulations |
381 | //show_data = 1; |
||
25 | f9daq | 382 | |
383 | //double d = detector->GetD(); |
||
384 | const double b = parameters.getB(); // upper side of LG |
||
385 | //const double SiPM = 3.0; // the length of the detector itself |
||
386 | //double reflectivity = detector->guide->getR(); |
||
387 | |||
388 | TH2F *hAcceptance = new TH2F("hAcceptance","Acceptance",steps-1,minD,maxD,steps-1,min,max); |
||
389 | |||
390 | // Use the Fresnel eq. instead of fixed reflectivity 96% |
||
391 | //detector->SetFresnel(1); |
||
392 | |||
70 | f9daq | 393 | //printf(" d | a | Acceptance\n"); |
394 | getParameters(); |
||
395 | printf("Wait, this takes a while "); |
||
25 | f9daq | 396 | for(int i=0; i<steps; i++) { |
397 | const double d = hAcceptance->GetXaxis()->GetBinCenter(i); |
||
398 | for(int j=0; j<steps; j++) { |
||
70 | f9daq | 399 | Init(); |
25 | f9daq | 400 | const double a = hAcceptance->GetYaxis()->GetBinCenter(j); |
70 | f9daq | 401 | //const double M = b/a; |
402 | parameters.setGuide(a, b, d); |
||
25 | f9daq | 403 | CDetector *detector = new CDetector(CENTER, parameters); |
404 | //detector->guide->setLG(y, M, x); |
||
405 | //Init(); exclude simulation |
||
70 | f9daq | 406 | double acceptance = RandIso(detector, parameters, NN, 0, theta, 30, show_3d); |
25 | f9daq | 407 | //double acceptance = Grid(NN, theta); |
408 | //double acceptance = -1.0; |
||
409 | hAcceptance->Fill(d, a, acceptance); |
||
70 | f9daq | 410 | //printf("%.2lf | %.2lf | ", d, a); |
411 | //PrintGuideStat(acceptance); |
||
54 | f9daq | 412 | delete detector; //works fine, 50x50 grid takes ~4MB of RAM |
25 | f9daq | 413 | } |
70 | f9daq | 414 | printf("."); |
25 | f9daq | 415 | } |
70 | f9daq | 416 | printf("\n"); |
25 | f9daq | 417 | |
418 | |||
419 | |||
70 | f9daq | 420 | TCanvas *cp = new TCanvas("Acceptance", "Acceptance", 0, 0, 1200, 1200); |
421 | cp->cd(); |
||
422 | //TVirtualPad *pacc = cp->cd(0); |
||
25 | f9daq | 423 | |
70 | f9daq | 424 | /* |
25 | f9daq | 425 | pacc->SetRightMargin(0.10); |
426 | pacc->SetLeftMargin(0.10); |
||
427 | pacc->SetTopMargin(0.10); |
||
70 | f9daq | 428 | pacc->SetBottomMargin(0.10); |
429 | */ |
||
25 | f9daq | 430 | |
431 | TFile *file = new TFile("acceptance.root","RECREATE"); |
||
432 | hAcceptance->Write(); |
||
433 | file->Close(); |
||
54 | f9daq | 434 | //delete file; |
25 | f9daq | 435 | |
436 | //hAcceptance->SetContour(100); |
||
437 | //gStyle->SetPalette(1,0); |
||
438 | hAcceptance->SetTitle(";d [mm];a [mm]"); |
||
439 | hAcceptance->GetXaxis()->SetRangeUser(minD,maxD); |
||
440 | hAcceptance->Draw("COLZ"); |
||
70 | f9daq | 441 | char filename[128]; |
442 | sprintf(filename,"LGI_ad%d.C", steps); |
||
443 | cp->SaveAs(filename); |
||
25 | f9daq | 444 | |
445 | } |
||
446 | |||
447 | //------------------------------------------------------------------------------------------ |
||
448 | // collection efficiency vs length |
||
449 | // a changes, b rests the same, d changes |
||
450 | // still can't use this function, it has hardcoded tan 10 deg |
||
451 | // !very stupid! |
||
452 | // new 3D graph NEEDED |
||
453 | // d vs a vs acceptance |
||
454 | void LGI_d2(int NN = 1e4, double min = 0.5, double max = 3.0, const int steps = 25, double theta = 30.0) |
||
455 | { |
||
456 | TVector3 gapGuideSiPM(0.3, 0, 0); |
||
457 | CDetector *detector = new CDetector(TVector3(-2,0,0), parameters); |
||
458 | int tmp3d = show_3d, tmpdata = show_data; |
||
459 | double step[steps], acc[steps]; |
||
460 | double sipm_d, M0; |
||
461 | char sbuff[256]; |
||
462 | |||
463 | show_3d = 1; show_data = 1; |
||
464 | |||
465 | M0 = parameters.getM(); |
||
466 | |||
467 | PrintGuideHead(); |
||
468 | for(int i=0; i<=steps; i++) { |
||
469 | step[i] = min + i*(max - min)/(double)steps; |
||
470 | sipm_d = M0 - 2.0*step[i]*0.199819;//tan 11.3 deg |
||
70 | f9daq | 471 | parameters.setGuide(sipm_d, M0*sipm_d, step[i]); |
25 | f9daq | 472 | //printf("sipm = %lf, M = %lf, d = %lf\n", detector->GetSiPM(), detector->GetM(), step[i]); |
473 | printf("%.1lf | %.2lf | ", step[i], sipm_d); |
||
474 | Init(); |
||
70 | f9daq | 475 | acc[i] = RandIso(detector, parameters, NN, 0, theta); |
54 | f9daq | 476 | PrintGuideStat(acc[i]); |
25 | f9daq | 477 | sprintf(sbuff, "d%2d.gif", i); |
478 | //c3dview->SaveAs(sbuff); |
||
479 | } |
||
480 | |||
481 | |||
482 | //sprintf(sbuff, "SiPM = %.1lf, M = %.1lf, d = %.1lf | gap(y,z) = (%.1lf, %.1lf) | #theta = %.1lf", |
||
483 | // detector->GetSiPM(), detector->GetM(), detector->GetD(), |
||
484 | // (detector->GetVGap()).y(), (detector->GetVGap()).z(), theta); |
||
485 | |||
486 | //DrawAcc(steps+1, step, acc, sbuff, (char*)"; d;Acceptance", min, max); |
||
487 | |||
488 | TCanvas *cp = new TCanvas("Acceptance", "Acceptance", 0, 0, 640, 480); |
||
489 | TVirtualPad *pacc = cp->cd(0); |
||
490 | |||
491 | pacc->SetRightMargin(0.05); |
||
492 | pacc->SetLeftMargin(0.13); |
||
493 | pacc->SetTopMargin(0.08); |
||
494 | |||
495 | TGraph *gacceptance = new TGraph(steps+1, step, acc); |
||
496 | gacceptance->SetTitle("; d [mm];Collection efficiency"); |
||
497 | gacceptance->SetMarkerStyle(8); |
||
498 | gacceptance->SetLineColor(12); |
||
499 | gacceptance->SetLineWidth(1); |
||
500 | (gacceptance->GetXaxis())->SetRangeUser(min, max); |
||
501 | //(gacceptance->GetYaxis())->SetRangeUser(ymin, ymax); |
||
502 | |||
503 | gacceptance->Draw("ACP"); |
||
504 | |||
505 | |||
506 | show_3d = tmp3d; show_data = tmpdata; |
||
507 | } |
||
508 | //------------------------------------------------------------------------------------------ |
||
509 | // Acceptance vs. the length |
||
510 | // The magnification ratio M rests the same all the time |
||
511 | void LGI_d(int NN = 1e4, double min = 1, double max = 6.0, const int steps = 25, double theta = 30.0) |
||
512 | { |
||
513 | int tmp3d = show_3d, tmpdata = show_data; |
||
514 | double step[steps], acc[steps]; |
||
515 | const double a = parameters.getA(); |
||
516 | const double magnif = parameters.getM(); |
||
517 | |||
518 | //show_3d = show_in_steps; show_data = 1; |
||
519 | |||
520 | // Use Fresnel equations |
||
521 | //detector->SetFresnel(1); |
||
522 | |||
523 | // Set glass (n=1.5) at the exit |
||
524 | //detector->SetGlass(1,0); |
||
525 | |||
526 | PrintGuideHead(); |
||
527 | for(int i=0; i<=steps; i++) { |
||
528 | step[i] = min + i*(max - min)/(double)steps; |
||
70 | f9daq | 529 | //parameters.setGuide(a, magnif, step[i]); |
25 | f9daq | 530 | parameters.setGuide(a, magnif, step[i]); |
531 | CDetector *detector = new CDetector(CENTER, parameters); |
||
532 | //printf("sipm = %lf, M = %lf, d = %lf\n", detector->GetSiPM(), detector->GetM(), step[i]); |
||
533 | printf("%.1lf | ", step[i]); |
||
534 | Init(); |
||
70 | f9daq | 535 | acc[i] = RandIso(detector, parameters, NN, 0, theta); |
54 | f9daq | 536 | PrintGuideStat(acc[i]); |
25 | f9daq | 537 | delete detector; |
538 | } |
||
539 | |||
540 | //char sbuff[256]; |
||
541 | //sprintf(sbuff, "SiPM = %.1lf, M = %.1lf, d = %.1lf | gap(y,z) = (%.1lf, %.1lf) | #theta = %.1lf", |
||
542 | // detector->GetSiPM(), detector->GetM(), detector->GetD(), |
||
543 | // (detector->GetVGap()).y(), (detector->GetVGap()).z(), theta); |
||
544 | |||
545 | DrawAcc(steps+1, step, acc, (char*)"; d [mm];Acceptance", min, max); |
||
546 | |||
547 | show_3d = tmp3d; show_data = tmpdata; |
||
548 | } |
||
549 | //------------------------------------------------------------------------------------------ |
||
550 | // Magnification optimization. a and d are fixed, M and b change in steps |
||
551 | void LGI_M(int NN = 1e4, double min = 1.0, double max = 3.0, const int steps = 30, double theta = 30.0) |
||
552 | { |
||
553 | int tmp3d = show_3d, tmpdata = show_data; |
||
554 | double step[steps], acc[steps]; |
||
555 | |||
556 | const double a = parameters.getA(); |
||
557 | const double d = parameters.getD(); |
||
558 | |||
559 | show_3d = 0; show_data = 0; |
||
560 | |||
561 | PrintGuideHead(); |
||
562 | for(int i=0; i<=steps; i++) { |
||
563 | step[i] = min + i*(max - min)/(double)steps; |
||
70 | f9daq | 564 | //parameters.setGuide(a, step[i], d); |
565 | parameters.setGuide(a, a*step[i], d); |
||
25 | f9daq | 566 | CDetector *detector = new CDetector(CENTER, parameters); |
567 | Init(); |
||
70 | f9daq | 568 | acc[i] = RandIso(detector, parameters, NN, 0, theta); |
54 | f9daq | 569 | PrintGuideStat(acc[i]); |
25 | f9daq | 570 | } |
571 | |||
572 | //char sbuff[256]; |
||
573 | //sprintf(sbuff, "SiPM = %.1lf, M = %.1lf, d = %.1lf | gap(y,z) = (%.1lf, %.1lf) | #theta = %.1lf", |
||
574 | // detector->GetSiPM(), detector->GetM(), detector->GetD(), |
||
575 | // (detector->GetVGap()).y(), (detector->GetVGap()).z(), theta); |
||
576 | |||
577 | DrawAcc(steps+1, step, acc, (char*)"; M;Acceptance", min, max); |
||
578 | |||
579 | show_3d = tmp3d; show_data = tmpdata; |
||
580 | } |
||
70 | f9daq | 581 | |
25 | f9daq | 582 | //------------------------------------------------------------------------------------------ |
583 | |||
70 | f9daq | 584 | void getParameters() |
585 | { |
||
586 | printf("LIGHT GUIDE\n" |
||
587 | " b=%f mm, d=%f mm, a=%f mm\n", parameters.getB(), parameters.getD(), parameters.getA()); |
||
588 | printf("MATERIAL REFRACITVE INDICES\n" |
||
589 | " n1=%f, n2=%f, n3=%f\n", parameters.getN1(), parameters.getN2(), parameters.getN3()); |
||
590 | printf("PLATE\n" |
||
591 | " ON: %d, width=%f mm\nUSES FRESNEL EQUATIONS: %d\n", parameters.getPlateOn(), parameters.getPlateWidth(), parameters.getFresnel()); |
||
592 | return; |
||
593 | } |
||
594 |