Subversion Repositories f9daq

Rev

Rev 54 | Rev 72 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 54 Rev 70
Line 7... Line 7...
7
 
7
 
8
//extern int show_3d;
8
//extern int show_3d;
9
//extern int show_data;
9
//extern int show_data;
10
 
10
 
11
// Set the simulation parameters
11
// Set the simulation parameters
12
void Show3D(int b) {show_3d = b;}
12
void showVisual(int b) {show_3d = b;}
13
void ShowData(int b) {show_data = b;}
13
void showData(int b) {show_data = b;}
14
 
14
 
15
// Set the initial detector parameters (a, b, d, activeDetector, n1, n2, n3, gap)
15
// Set the initial detector parameters (a, b, d, activeDetector, n1, n2, n3, gap)
16
DetectorParameters parameters(3.0, 5.0, 3.0, 3.0, 1, 1.53, 1.52, TVector3(0.3, 0, 0));
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();
17
 
19
 
18
//void SetLGType(int in = 1, int side = 1, int out = 0)
20
//void SetLGType(int in = 1, int side = 1, int out = 0)
19
        //{detector->SetLGType(in, side, out);}
21
        //{detector->SetLGType(in, side, out);}
20
 
22
 
21
void SetLG(double SiPM0 = 3.0, double b0 = 5.0, double d0 = 3.0, double n10 = 1.0, double n20 = 1.53, double n30 = 1.52)
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)
22
        { parameters.setGuide(SiPM0, b0, d0, n10, n20, n30); }
24
        { parameters.setGuide(SiPM0, b0, d0);
-
 
25
          parameters.setIndices(n1, n2, n3); }
23
       
26
       
24
void SetGap(double x_gap0 = 0.3, double y_gap0 = 0.0, double z_gap0 = 0.0)
27
void setGap(double x_gap0 = 0.3, double y_gap0 = 0.0, double z_gap0 = 0.0)
25
  { parameters.setGap(x_gap0, y_gap0, z_gap0); }
28
  { parameters.setGap(x_gap0, y_gap0, z_gap0); }
26
 
29
 
27
void SetGlass(double glassOn, double glassD)
30
void setGlass(double glassOn, double glassD)
28
  { parameters.setGlass(glassOn, glassD); };
31
  { parameters.setGlass(glassOn, glassD); };
29
 
32
 
30
void SetPlate(int plateOn = 1, double plateWidth = 1)
33
void setPlate(int plateOn = 1, double plateWidth = 1)
31
  { parameters.setPlate(plateOn, plateWidth); }
34
  { parameters.setPlate(plateOn, plateWidth); }
32
 
35
 
33
void SetFresnel(int fresnel = 1) { parameters.setFresnel(fresnel); }
36
void setFresnel(int fresnel = 1) { parameters.setFresnel(fresnel); }
-
 
37
 
-
 
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);}
34
 
43
 
35
int save_ary = 0;
44
int save_ary = 0;
36
//------------------------------------------------------------------------------------------
45
//------------------------------------------------------------------------------------------
37
void Help()
46
void Help()
38
{
47
{
Line 105... Line 114...
105
 
114
 
106
TVector3 p_pol0(0.0, 0.0, 1.0);
115
TVector3 p_pol0(0.0, 0.0, 1.0);
107
void SetPol(double x, double y, double z)
116
void SetPol(double x, double y, double z)
108
{p_pol0.SetXYZ(x,y,z);}
117
{p_pol0.SetXYZ(x,y,z);}
109
 
118
 
-
 
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)
110
void PolTest(double theta = 0.0)
124
void PolTest(double theta = 0.0)
111
{
125
{
112
  int p_type = 1;
126
  int p_type = 1;
113
  double p_n1 = 1.5;
127
  double p_n1 = parameters.getN1();
114
  double p_n2 = 1.0;
128
  double p_n2 = parameters.getN2();
115
        theta = 3.141593*theta/180.0; if(theta < 1e-6) theta = 1e-6;
129
        theta = 3.141593*theta/180.0; if(theta < 1e-6) theta = 1e-6;
116
        TVector3 p_pol;
130
        TVector3 p_pol;
117
       
131
       
118
        Init();
132
        Init();
119
       
133
       
Line 128... Line 142...
128
#define SURF_REFLE 2
142
#define SURF_REFLE 2
129
#define SURF_TOTAL 3
143
#define SURF_TOTAL 3
130
#define SURF_IMPER 4
144
#define SURF_IMPER 4
131
        */
145
        */
132
        CSurface *surf = new CSurface(p_type, vodnik_edge, p_n1, p_n2, 0.96); //surf->FlipN();
146
        CSurface *surf = new CSurface(p_type, vodnik_edge, p_n1, p_n2, 0.96); //surf->FlipN();
133
        surf->SetFresnel(0);
147
        surf->SetFresnel(1);
134
        surf->Draw();
148
        surf->Draw();
135
       
149
       
136
        CRay *ray = new CRay(cx, 0.0, 0.0, TMath::Cos(theta), 0.0, TMath::Sin(theta));
150
        CRay *ray = new CRay(cx, 0.0, 0.0, TMath::Cos(theta), 0.0, TMath::Sin(theta));
137
        ray->SetColor(1);
151
        ray->SetColor(kBlack);
138
        //p_pol = rotatey(p_pol0, -theta);
152
        //p_pol = rotatey(p_pol0, -theta);
139
        p_pol = p_pol0; p_pol.RotateY(-theta);
153
        p_pol = p_pol0; p_pol.RotateY(-theta);
140
        //printf("p_pol = "); printv(p_pol);
154
        //printf("p_pol = "); printv(p_pol);
141
        ray->SetPolarization(p_pol);
155
        ray->SetPolarization(p_pol);
142
       
156
       
143
        ray->DrawS(cx, -5.0);
157
        ray->DrawS(cx, -5.0);
144
       
158
       
145
        CRay *out = new CRay; out->SetColor(2);
159
        CRay *out = new CRay; out->SetColor(kRed);
146
        TVector3 *inters = new TVector3;
160
        TVector3 *inters = new TVector3;
147
        int fate = surf->PropagateRay(*ray, out, inters);
161
        surf->PropagateRay(*ray, out, inters);
148
        if(fate == 1) out->DrawS(cx, 5.0);
162
        //if(fate == 1) out->DrawS(cx, 5.0);
-
 
163
  out->DrawS(cx, 5.0);
149
       
164
 
-
 
165
        CRay *incidentPolarization = new CRay;
150
        CRay *pp = new CRay; pp->SetColor(3);
166
        incidentPolarization->SetColor(kGreen);
151
        pp->Set(ray->GetR(), p_pol);
167
        incidentPolarization->Set(ray->GetR(), p_pol);
152
        pp->DrawS(cx, 2.0);
168
        incidentPolarization->DrawS(cx, 1.0);
153
       
169
       
-
 
170
        CRay *surfaceNormal = new CRay;
154
        CRay *pn = new CRay; pn->SetColor(4);
171
        surfaceNormal->SetColor(kBlue);
155
        pn->Set(ray->GetR(), surf->GetN());
172
        surfaceNormal->Set(ray->GetR(), surf->GetN());
156
        pn->DrawS(cx, 3.0);
173
        surfaceNormal->DrawS(cx, 1.0);
157
}
174
}
158
 
175
 
159
void ptt()
176
void ptt()
160
{
177
{
161
        for(double th = 0.0; th < 91.0; th += 5.0) {
178
        for(double th = 0.0; th < 91.0; th += 5.0) {
Line 190... Line 207...
190
// Propagate NN rays genarated under the same angle theta, phi with random spacing and statistics
207
// Propagate NN rays genarated under the same angle theta, phi with random spacing and statistics
191
void LGR(int NN = 1e4, double theta = 0.0, double phi = 0.0)
208
void LGR(int NN = 1e4, double theta = 0.0, double phi = 0.0)
192
{
209
{
193
  CDetector *detector = new CDetector(TVector3(-2,0,0), parameters);
210
  CDetector *detector = new CDetector(TVector3(-2,0,0), parameters);
194
        Init();
211
        Init();
195
        double izkoristek = RandYZ(detector, parameters, NN, theta, phi);
212
        double izkoristek = RandYZ(detector, parameters, NN, theta, phi, 30);
196
        //printf("izkoristek = %.3lf\n", izkoristek);
213
        //printf("izkoristek = %.3lf\n", izkoristek);
197
        PrintGuideHead(); PrintGuideStat(izkoristek);
214
        PrintGuideHead(); PrintGuideStat(izkoristek);
198
        DrawData(detector, parameters, theta, izkoristek);
215
        DrawData(detector, parameters, theta, izkoristek);
199
}
216
}
200
//------------------------------------------------------------------------------------------
217
//------------------------------------------------------------------------------------------
Line 202... Line 219...
202
void LGI(int NN = 1e4, double theta = 30.0, int nnrays = 30, int showr = 0)
219
void LGI(int NN = 1e4, double theta = 30.0, int nnrays = 30, int showr = 0)
203
{
220
{
204
  Init();
221
  Init();
205
  CDetector *detector = new CDetector(CENTER, parameters);
222
  CDetector *detector = new CDetector(CENTER, parameters);
206
  //CDetector detector = new CDetector();
223
  //CDetector detector = new CDetector();
207
        double izkoristek = RandIso(detector, parameters, NN, theta, nnrays, showr);
224
        double izkoristek = RandIso(detector, parameters, NN, 0.0, theta, nnrays, showr);
208
        //printf("izkoristek = %.3lf\n", izkoristek);
225
        //printf("izkoristek = %.3lf\n", izkoristek);
-
 
226
        PrintGuideHead();
209
        PrintGuideHead(); PrintGuideStat(izkoristek);
227
        PrintGuideStat(izkoristek);
210
        DrawData(detector, parameters, theta, izkoristek);
228
        DrawData(detector, parameters, theta, izkoristek);
211
        //TCanvas *canvasDetector = new TCanvas("canvasDetector","canvasDetector",500,500);
229
        //TCanvas *canvasDetector = new TCanvas("canvasDetector","canvasDetector",500,500);
212
        //canvasDetector->cd();
230
        //canvasDetector->cd();
213
        //detector->Draw();
231
        //detector->Draw();
214
}
232
}
215
 
233
 
-
 
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
}
216
       
248
       
217
       
249
       
218
//------------------------------------------------------------------------------------------
250
//------------------------------------------------------------------------------------------
219
void LGI_gap(int NN = 1e4, double min = 0.0, double max = 2.0, const int steps = 10, double theta = 30.0)
251
void LGI_gap(int NN = 1e4, double min = 0.0, double max = 2.0, const int steps = 10, double theta = 30.0)
220
{
252
{
221
int tmp3d = show_3d, tmpdata = show_data;
253
int tmp3d = show_3d, tmpdata = show_data;
222
double step[steps], acc[steps];
254
double step[steps], acc[steps];
223
 
255
 
224
        show_3d = 0; show_data = 0;
256
        show_3d = 0; show_data = 0;
225
       
257
       
226
        //printf(" x_gap | acceptance \n");
258
        //printf(" x_gap | acceptance \n");
227
        PrintGuideHead();
259
        PrintGuideHead();
228
        for(int i=0; i<=steps; i++) {
260
        for(int i=0; i<=steps; i++) {
229
                step[i] = min + i*(max - min)/(double)steps;
261
                step[i] = min + i*(max - min)/(double)steps;
230
                parameters.setGap(step[i], 0.0, 0.0);
262
                parameters.setGap(step[i], 0.0, 0.0);
231
                CDetector *detector = new CDetector(CENTER, parameters);
263
                CDetector *detector = new CDetector(CENTER, parameters);
232
                Init();
264
                Init();
233
                acc[i] = RandIso(detector, parameters, NN, theta);
265
                acc[i] = RandIso(detector, parameters, NN, 0, theta);
234
                //printf("%6.2lf |%6.1lf\n", step[i], acc[i]*100.0);
266
                //printf("%6.2lf |%6.1lf\n", step[i], acc[i]*100.0);
235
                PrintGuideStat(acc[i]);
267
                PrintGuideStat(acc[i]);
236
        }
268
        }
237
       
269
       
238
        //char sbuff[256];
270
        //char sbuff[256];
239
        //sprintf(sbuff, "SiPM = %.1lf, M = %.1lf, d = %.1lf | gap(y,z) = (%.1lf, %.1lf) | #theta = %.1lf",
271
        //sprintf(sbuff, "SiPM = %.1lf, M = %.1lf, d = %.1lf | gap(y,z) = (%.1lf, %.1lf) | #theta = %.1lf",
240
                //      detector->GetSiPM(), detector->GetM(), detector->GetD(), 
272
                //      detector->GetSiPM(), detector->GetM(), detector->GetD(), 
241
                //      (detector->GetVGap()).y(), (detector->GetVGap()).z(), theta);
273
                //      (detector->GetVGap()).y(), (detector->GetVGap()).z(), theta);
242
       
274
       
243
        DrawAcc(steps+1, step, acc, (char*)"; x_gap;Acceptance", min, max);
275
        DrawAcc(steps+1, step, acc, (char*)"; x_gap;Acceptance", min, max);
244
       
276
       
245
        show_3d = tmp3d; show_data = tmpdata;
277
        show_3d = tmp3d; show_data = tmpdata;
246
}
278
}
247
//------------------------------------------------------------------------------------------
279
//------------------------------------------------------------------------------------------
-
 
280
 
-
 
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
 
248
 
311
 
249
//------------------------------------------------------------------------------------------
312
//------------------------------------------------------------------------------------------
250
void LGR_th(int NN = 1e4, double min = 0.0, double max = 30.0, const int steps = 15, double phi = 5.0)
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)
251
{
315
{
252
int tmp3d = show_3d, tmpdata = show_data;
316
  //int tmp3d = show_3d, tmpdata = show_data;
253
double step[steps], acc[steps];
317
  double step[steps], acc[steps];
254
 
318
 
255
        show_3d = 0; show_data = 0;
319
        //show_3d = 0; show_data = 0;
256
       
320
       
257
        //printf(" theta | acceptance \n");
321
        //printf(" theta | acceptance \n");
258
        PrintGuideHead();
322
        PrintGuideHead();
259
        for(int i=0; i<=steps; i++) {
323
        for(int i=0; i<=steps; i++) {
260
                Init();
324
                Init();
261
                step[i] = min + i*(max - min)/(double)steps;
325
                step[i] = min + i*(max - min)/(double)steps;
262
                CDetector *detector = new CDetector(TVector3(-2,0,0), parameters);
326
                CDetector *detector = new CDetector(TVector3(-2,0,0), parameters);
263
                acc[i] = RandYZ(detector, parameters, NN, step[i], phi);
327
                //acc[i] = RandYZ(detector, parameters, NN, step[i], phi, 30);
-
 
328
                acc[i] = RandIso(detector, parameters, NN, 0, step[i], 30, show_3d);
264
                //printf("%6.1lf |%6.1lf\n", step[i], acc[i]*100.0);
329
                //printf("%6.1lf |%6.1lf\n", step[i], acc[i]*100.0);
265
                PrintGuideStat(acc[i]);
330
                PrintGuideStat(acc[i]);
266
                //delete detector;
331
                delete detector;
267
        }
332
        }
268
       
333
       
269
        //char sbuff[256];
334
        //char sbuff[256];
270
        //sprintf(sbuff, "SiPM = %.1lf, M = %.1lf, d = %.1lf | gap = (%.1lf, %.1lf, %.1lf)",
335
        //sprintf(sbuff, "SiPM = %.1lf, M = %.1lf, d = %.1lf | gap = (%.1lf, %.1lf, %.1lf)",
271
                //      detector->GetSiPM(), detector->GetM(), detector->GetD(), 
336
                //      detector->GetSiPM(), detector->GetM(), detector->GetD(), 
272
                //      (detector->GetVGap()).x(), (detector->GetVGap()).y(), (detector->GetVGap()).z());
337
                //      (detector->GetVGap()).x(), (detector->GetVGap()).y(), (detector->GetVGap()).z());
273
       
338
       
274
        DrawAcc(steps+1, step, acc, (char*)"; #theta [deg];Acceptance", min, max);
339
        DrawAcc(steps+1, step, acc, (char*)"; #theta [deg];Acceptance", min, max);
275
       
340
       
276
        show_3d = tmp3d; show_data = tmpdata;
341
        //show_3d = tmp3d; show_data = tmpdata;
277
}
342
}
278
//------------------------------------------------------------------------------------------
343
//------------------------------------------------------------------------------------------
-
 
344
 
-
 
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
}
279
 
374
 
280
// a vs. d
375
// a vs. d
281
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)
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)
282
{
377
{
283
  int tmp3d = show_3d;
-
 
284
        int tmpdata = show_data;
-
 
285
        //char sbuff[256];
378
        //char sbuff[256];
286
 
379
 
287
        show_3d = 0; // don't show simulations 
380
        //show_3d = 0; // don't show simulations 
288
        show_data = 1;
381
        //show_data = 1;
289
       
382
       
290
        //double d  = detector->GetD();
383
        //double d  = detector->GetD();
291
        const double b = parameters.getB(); // upper side of LG
384
        const double b = parameters.getB(); // upper side of LG
292
        //const double SiPM = 3.0; // the length of the detector itself
385
        //const double SiPM = 3.0; // the length of the detector itself
293
        //double reflectivity = detector->guide->getR();
386
        //double reflectivity = detector->guide->getR();
294
       
387
       
295
        TH2F *hAcceptance = new TH2F("hAcceptance","Acceptance",steps-1,minD,maxD,steps-1,min,max);
388
        TH2F *hAcceptance = new TH2F("hAcceptance","Acceptance",steps-1,minD,maxD,steps-1,min,max);
296
       
389
       
297
        // Use the Fresnel eq. instead of fixed reflectivity 96%
390
        // Use the Fresnel eq. instead of fixed reflectivity 96%
298
        //detector->SetFresnel(1);
391
        //detector->SetFresnel(1);
299
       
392
       
300
        printf("   d |   a  | Acceptance\n");
393
        //printf("   d |   a  | Acceptance\n");
-
 
394
        getParameters();
-
 
395
        printf("Wait, this takes a while ");
301
        for(int i=0; i<steps; i++) {
396
        for(int i=0; i<steps; i++) {
302
                const double d = hAcceptance->GetXaxis()->GetBinCenter(i);
397
                const double d = hAcceptance->GetXaxis()->GetBinCenter(i);
303
                for(int j=0; j<steps; j++) {
398
                for(int j=0; j<steps; j++) {
-
 
399
                  Init();
304
                  const double a = hAcceptance->GetYaxis()->GetBinCenter(j);
400
                  const double a = hAcceptance->GetYaxis()->GetBinCenter(j);
305
                  const double M = b/a;
401
                  //const double M = b/a;
306
      parameters.setGuide(a, M, d);
402
      parameters.setGuide(a, b, d);
307
                  CDetector *detector = new CDetector(CENTER, parameters);
403
                  CDetector *detector = new CDetector(CENTER, parameters);
308
                  //detector->guide->setLG(y, M, x);
404
                  //detector->guide->setLG(y, M, x);
309
                  //Init(); exclude simulation
405
                  //Init(); exclude simulation
310
                  double acceptance = RandIso(detector, parameters, NN, theta, 0, 0);
406
                  double acceptance = RandIso(detector, parameters, NN, 0, theta, 30, show_3d);
311
                  //double acceptance = Grid(NN, theta);
407
                  //double acceptance = Grid(NN, theta);
312
                  //double acceptance = -1.0;
408
                  //double acceptance = -1.0;
313
                  hAcceptance->Fill(d, a, acceptance);
409
                  hAcceptance->Fill(d, a, acceptance);
314
                  //printf("%.2lf | %.2lf | ", x,y);
410
                  //printf("%.2lf | %.2lf | ", d, a);
315
                  //PrintGuideStat(izkoristek);
411
                  //PrintGuideStat(acceptance);
316
                  delete detector; //works fine, 50x50 grid takes ~4MB of RAM
412
                  delete detector; //works fine, 50x50 grid takes ~4MB of RAM
317
                  }
413
                  }
-
 
414
                printf(".");
318
        }
415
        }
-
 
416
        printf("\n");
319
       
417
       
320
 
418
 
321
       
419
       
322
        TCanvas *cp = new TCanvas("Acceptance", "Acceptance", 0, 0, 640, 480);
420
        TCanvas *cp = new TCanvas("Acceptance", "Acceptance", 0, 0, 1200, 1200);
-
 
421
        cp->cd();
323
        TVirtualPad *pacc = cp->cd(0);
422
        //TVirtualPad *pacc = cp->cd(0);
324
       
423
       
-
 
424
        /*
325
        pacc->SetRightMargin(0.10);
425
        pacc->SetRightMargin(0.10);
326
        pacc->SetLeftMargin(0.10);
426
        pacc->SetLeftMargin(0.10);
327
        pacc->SetTopMargin(0.10);
427
        pacc->SetTopMargin(0.10);
-
 
428
        pacc->SetBottomMargin(0.10);
-
 
429
        */
328
       
430
       
329
        TFile *file = new TFile("acceptance.root","RECREATE");
431
        TFile *file = new TFile("acceptance.root","RECREATE");
330
        hAcceptance->Write();
432
        hAcceptance->Write();
331
        file->Close();
433
        file->Close();
332
        //delete file;
434
        //delete file;
Line 334... Line 436...
334
        //hAcceptance->SetContour(100);
436
        //hAcceptance->SetContour(100);
335
        //gStyle->SetPalette(1,0);
437
        //gStyle->SetPalette(1,0);
336
        hAcceptance->SetTitle(";d [mm];a [mm]");
438
        hAcceptance->SetTitle(";d [mm];a [mm]");
337
        hAcceptance->GetXaxis()->SetRangeUser(minD,maxD);
439
        hAcceptance->GetXaxis()->SetRangeUser(minD,maxD);
338
        hAcceptance->Draw("COLZ");
440
        hAcceptance->Draw("COLZ");
-
 
441
        char filename[128];
-
 
442
        sprintf(filename,"LGI_ad%d.C", steps);
-
 
443
        cp->SaveAs(filename);
339
       
444
       
340
        show_3d = tmp3d; show_data = tmpdata;
-
 
341
}
445
}
342
 
446
 
343
//------------------------------------------------------------------------------------------
447
//------------------------------------------------------------------------------------------
344
// collection efficiency vs length
448
// collection efficiency vs length
345
// a changes, b rests the same, d changes
449
// a changes, b rests the same, d changes
Line 362... Line 466...
362
       
466
       
363
        PrintGuideHead();
467
        PrintGuideHead();
364
        for(int i=0; i<=steps; i++) {
468
        for(int i=0; i<=steps; i++) {
365
                step[i] = min + i*(max - min)/(double)steps;           
469
                step[i] = min + i*(max - min)/(double)steps;           
366
                sipm_d = M0 - 2.0*step[i]*0.199819;//tan 11.3 deg
470
                sipm_d = M0 - 2.0*step[i]*0.199819;//tan 11.3 deg
367
                parameters.setGuide(sipm_d, M0/sipm_d, step[i]);
471
                parameters.setGuide(sipm_d, M0*sipm_d, step[i]);
368
                //printf("sipm = %lf, M = %lf, d = %lf\n", detector->GetSiPM(), detector->GetM(), step[i]);
472
                //printf("sipm = %lf, M = %lf, d = %lf\n", detector->GetSiPM(), detector->GetM(), step[i]);
369
                printf("%.1lf | %.2lf | ", step[i], sipm_d);
473
                printf("%.1lf | %.2lf | ", step[i], sipm_d);
370
                Init();
474
                Init();
371
                acc[i] = RandIso(detector, parameters, NN, theta);
475
                acc[i] = RandIso(detector, parameters, NN, 0, theta);
372
                PrintGuideStat(acc[i]);
476
                PrintGuideStat(acc[i]);
373
                sprintf(sbuff, "d%2d.gif", i);
477
                sprintf(sbuff, "d%2d.gif", i);
374
                //c3dview->SaveAs(sbuff);
478
                //c3dview->SaveAs(sbuff);
375
        }
479
        }
376
       
480
       
377
       
481
       
378
        //sprintf(sbuff, "SiPM = %.1lf, M = %.1lf, d = %.1lf | gap(y,z) = (%.1lf, %.1lf) | #theta = %.1lf",
482
        //sprintf(sbuff, "SiPM = %.1lf, M = %.1lf, d = %.1lf | gap(y,z) = (%.1lf, %.1lf) | #theta = %.1lf",
379
                //      detector->GetSiPM(), detector->GetM(), detector->GetD(), 
483
                //      detector->GetSiPM(), detector->GetM(), detector->GetD(), 
380
                        //                                (detector->GetVGap()).y(), (detector->GetVGap()).z(), theta);
484
                        //                                (detector->GetVGap()).y(), (detector->GetVGap()).z(), theta);
381
       
485
       
382
        //DrawAcc(steps+1, step, acc, sbuff, (char*)"; d;Acceptance", min, max);
486
        //DrawAcc(steps+1, step, acc, sbuff, (char*)"; d;Acceptance", min, max);
383
       
487
       
384
        TCanvas *cp = new TCanvas("Acceptance", "Acceptance", 0, 0, 640, 480);
488
        TCanvas *cp = new TCanvas("Acceptance", "Acceptance", 0, 0, 640, 480);
385
        TVirtualPad *pacc = cp->cd(0);
489
        TVirtualPad *pacc = cp->cd(0);
386
       
490
       
387
        pacc->SetRightMargin(0.05);
491
        pacc->SetRightMargin(0.05);
388
        pacc->SetLeftMargin(0.13);
492
        pacc->SetLeftMargin(0.13);
Line 416... Line 520...
416
        // Use Fresnel equations
520
        // Use Fresnel equations
417
        //detector->SetFresnel(1);
521
        //detector->SetFresnel(1);
418
       
522
       
419
        // Set glass (n=1.5) at the exit
523
        // Set glass (n=1.5) at the exit
420
        //detector->SetGlass(1,0);
524
        //detector->SetGlass(1,0);
421
       
525
       
422
        PrintGuideHead();
526
        PrintGuideHead();
423
        for(int i=0; i<=steps; i++) {
527
        for(int i=0; i<=steps; i++) {
424
                step[i] = min + i*(max - min)/(double)steps;
528
                step[i] = min + i*(max - min)/(double)steps;
-
 
529
                //parameters.setGuide(a, magnif, step[i]);
425
                parameters.setGuide(a, magnif, step[i]);
530
                parameters.setGuide(a, magnif, step[i]);
426
                CDetector *detector = new CDetector(CENTER, parameters);
531
                CDetector *detector = new CDetector(CENTER, parameters);
427
                //printf("sipm = %lf, M = %lf, d = %lf\n", detector->GetSiPM(), detector->GetM(), step[i]);
532
                //printf("sipm = %lf, M = %lf, d = %lf\n", detector->GetSiPM(), detector->GetM(), step[i]);
428
                printf("%.1lf | ", step[i]);
533
                printf("%.1lf | ", step[i]);
429
                Init();
534
                Init();
430
                acc[i] = RandIso(detector, parameters, NN, theta);
535
                acc[i] = RandIso(detector, parameters, NN, 0, theta);
431
                PrintGuideStat(acc[i]);
536
                PrintGuideStat(acc[i]);
432
                delete detector;
537
                delete detector;
433
        }
538
        }
434
       
539
       
435
        //char sbuff[256];
540
        //char sbuff[256];
436
        //sprintf(sbuff, "SiPM = %.1lf, M = %.1lf, d = %.1lf | gap(y,z) = (%.1lf, %.1lf) | #theta = %.1lf",
541
        //sprintf(sbuff, "SiPM = %.1lf, M = %.1lf, d = %.1lf | gap(y,z) = (%.1lf, %.1lf) | #theta = %.1lf",
437
                //      detector->GetSiPM(), detector->GetM(), detector->GetD(), 
542
                //      detector->GetSiPM(), detector->GetM(), detector->GetD(), 
438
                        //                                (detector->GetVGap()).y(), (detector->GetVGap()).z(), theta);
543
                        //                                (detector->GetVGap()).y(), (detector->GetVGap()).z(), theta);
439
       
544
       
440
        DrawAcc(steps+1, step, acc, (char*)"; d [mm];Acceptance", min, max);
545
        DrawAcc(steps+1, step, acc, (char*)"; d [mm];Acceptance", min, max);
441
       
546
       
442
        show_3d = tmp3d; show_data = tmpdata;
547
        show_3d = tmp3d; show_data = tmpdata;
443
}
548
}
444
//------------------------------------------------------------------------------------------
549
//------------------------------------------------------------------------------------------
445
// Magnification optimization. a and d are fixed, M and b change in steps
550
// Magnification optimization. a and d are fixed, M and b change in steps
446
void LGI_M(int NN = 1e4, double min = 1.0, double max = 3.0, const int steps = 30, double theta = 30.0)
551
void LGI_M(int NN = 1e4, double min = 1.0, double max = 3.0, const int steps = 30, double theta = 30.0)
447
{
552
{
448
        int tmp3d = show_3d, tmpdata = show_data;
553
        int tmp3d = show_3d, tmpdata = show_data;
449
        double step[steps], acc[steps];
554
        double step[steps], acc[steps];
450
       
555
       
451
        const double a = parameters.getA();
556
        const double a = parameters.getA();
452
        const double d = parameters.getD();
557
        const double d = parameters.getD();
453
 
558
 
454
        show_3d = 0; show_data = 0;
559
        show_3d = 0; show_data = 0;
455
       
560
       
456
        PrintGuideHead();
561
        PrintGuideHead();
457
        for(int i=0; i<=steps; i++) {
562
        for(int i=0; i<=steps; i++) {
458
                step[i] = min + i*(max - min)/(double)steps;
563
                step[i] = min + i*(max - min)/(double)steps;
-
 
564
                //parameters.setGuide(a, step[i], d);
459
                parameters.setGuide(a, step[i], d);
565
                parameters.setGuide(a, a*step[i], d);
460
                CDetector *detector = new CDetector(CENTER, parameters);
566
                CDetector *detector = new CDetector(CENTER, parameters);
461
                Init();
567
                Init();
462
                acc[i] = RandIso(detector, parameters, NN, theta);
568
                acc[i] = RandIso(detector, parameters, NN, 0, theta);
463
                PrintGuideStat(acc[i]);
569
                PrintGuideStat(acc[i]);
464
        }
570
        }
465
       
571
       
466
        //char sbuff[256];
572
        //char sbuff[256];
467
        //sprintf(sbuff, "SiPM = %.1lf, M = %.1lf, d = %.1lf | gap(y,z) = (%.1lf, %.1lf) | #theta = %.1lf",
573
        //sprintf(sbuff, "SiPM = %.1lf, M = %.1lf, d = %.1lf | gap(y,z) = (%.1lf, %.1lf) | #theta = %.1lf",
468
                //      detector->GetSiPM(), detector->GetM(), detector->GetD(), 
574
                //      detector->GetSiPM(), detector->GetM(), detector->GetD(), 
469
                        //                                (detector->GetVGap()).y(), (detector->GetVGap()).z(), theta);
575
                        //                                (detector->GetVGap()).y(), (detector->GetVGap()).z(), theta);
470
       
576
       
471
        DrawAcc(steps+1, step, acc, (char*)"; M;Acceptance", min, max);
577
        DrawAcc(steps+1, step, acc, (char*)"; M;Acceptance", min, max);
472
       
578
       
473
        show_3d = tmp3d; show_data = tmpdata;
579
        show_3d = tmp3d; show_data = tmpdata;
474
}
580
}
-
 
581
 
475
//------------------------------------------------------------------------------------------
582
//------------------------------------------------------------------------------------------
476
 
583
 
-
 
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