Subversion Repositories f9daq

Rev

Rev 73 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 73 Rev 84
Line 3... Line 3...
3
 
3
 
4
#include "TROOT.h"
4
#include "TROOT.h"
5
#include "TVector3.h"
5
#include "TVector3.h"
6
#include "TMath.h"
6
#include "TMath.h"
7
#include "TPolyLine3D.h"
7
#include "TPolyLine3D.h"
8
#include "TRandom.h"
8
#include "TRandom2.h"
9
#include "TDatime.h"
9
#include "TDatime.h"
10
#include "TH1F.h"
10
#include "TH1F.h"
11
#include "TH2F.h"
11
#include "TH2F.h"
12
#include "TColor.h"
12
#include "TColor.h"
13
 
13
 
Line 38... Line 38...
38
{
38
{
39
public:
39
public:
40
  CRay() :
40
  CRay() :
41
    r(TVector3(0,0,0)),
41
    r(TVector3(0,0,0)),
42
    k(TVector3(1,0,0)),
42
    k(TVector3(1,0,0)),
43
    //p(TVector3(0,1,0)),
43
    p(TVector3(0,1,0)),
44
    p(TVector3(0,0,1)),
-
 
45
    color(kBlack)
44
    color(kBlack)
46
  {};
45
  {};
47
  CRay(TVector3 r0, TVector3 k0) :
46
  CRay(TVector3 r0, TVector3 k0) :
48
    r(r0),
47
    r(r0),
49
    k(k0.Unit()),
48
    k(k0.Unit()),
50
    //p(TVector3(0,1,0)),
49
    p(TVector3(0,1,0)),
51
    p(TVector3(0,0,1)),
50
    //p(TVector3(0,0,1)),
52
    color(kBlack)
51
    color(kBlack)
53
  {};
52
  {};
54
  CRay(double x0, double y0, double z0, double l0, double m0, double n0) :
53
  CRay(double x0, double y0, double z0, double l0, double m0, double n0) :
55
    r(TVector3(x0,y0,z0)),
54
    r(TVector3(x0,y0,z0)),
56
    k(TVector3(l0,m0,n0).Unit()),
55
    k(TVector3(l0,m0,n0).Unit()),
57
    //p(TVector3(0,1,0)),
56
    p(TVector3(0,1,0)),
58
    p(TVector3(0,0,1)),
57
    //p(TVector3(0,0,1)),
59
    color(kBlack)
58
    color(kBlack)
60
  {};
59
  {};
61
 
60
 
62
  void Set(TVector3 r0, TVector3 k0);
61
  void Set(TVector3 r0, TVector3 k0);
63
  //void Set(double x0, double y0, double z0, double l0, double m0, double n0);
62
  //void Set(double x0, double y0, double z0, double l0, double m0, double n0);
Line 65... Line 64...
65
  void setPolarization(TVector3 p0) {
64
  void setPolarization(TVector3 p0) {
66
    p = p0.Unit();
65
    p = p0.Unit();
67
    if (p.Dot(k)>1e-3) printf("*** ERROR in CRay: E has component || with k\n");
66
    if (p.Dot(k)>1e-3) printf("*** ERROR in CRay: E has component || with k\n");
68
  };
67
  };
69
 
68
 
70
  //inline CRay & operator = (const CRay &);
69
  inline CRay & operator = (const CRay &);
71
 
70
 
72
  TVector3 GetR() const {return r;};
71
  TVector3 GetR() const {return r;};
73
  TVector3 GetK() const {return k;};
72
  TVector3 GetK() const {return k;};
74
  TVector3 GetP() const {return p;};
73
  TVector3 GetP() const {return p;};
75
 
74
 
Line 101... Line 100...
101
 
100
 
102
public:
101
public:
103
  CPlane4();
102
  CPlane4();
104
  CPlane4(TVector3 r1, TVector3 r2, TVector3 r3, TVector3 r4);
103
  CPlane4(TVector3 r1, TVector3 r2, TVector3 r3, TVector3 r4);
105
  CPlane4(TVector3 *vr);
104
  CPlane4(TVector3 *vr);
-
 
105
  ~CPlane4() { };
106
  void Set(TVector3 r1, TVector3 r2, TVector3 r3, TVector3 r4);
106
  void Set(TVector3 r1, TVector3 r2, TVector3 r3, TVector3 r4);
107
  void Set(TVector3 *vr) {Set(vr[0], vr[1], vr[2], vr[3]);};
107
  void Set(TVector3 *vr) {Set(vr[0], vr[1], vr[2], vr[3]);};
108
  void FlipN(){n = -n;};
108
  void FlipN(){n = -n;};
109
 
109
 
110
  int GetIntersection(TVector3 *vec, CRay ray);
110
  int GetIntersection(TVector3 *vec, CRay ray);
Line 117... Line 117...
117
 
117
 
118
  void Print();
118
  void Print();
119
  void Draw(int color = 1, int width = 1);
119
  void Draw(int color = 1, int width = 1);
120
 
120
 
121
private:
121
private:
122
  TVector3 r[4], n;
122
  TVector3 r[4];
-
 
123
  TVector3 n;
123
  double A, B, C, D;
124
  double A, B, C, D;
124
  TVector3 edge[4]; // vektorji stranic
125
  TVector3 edge[4]; // vektorji stranic
125
  double angle_r[4]; // koti ob posameznem vogalu
126
  double angle_r[4]; // koti ob posameznem vogalu
126
};
127
};
127
//=================================================================================
128
//=================================================================================
Line 130... Line 131...
130
{
131
{
131
 
132
 
132
public:
133
public:
133
  CPlaneR(TVector3 c, TVector3 n0, double R0)
134
  CPlaneR(TVector3 c, TVector3 n0, double R0)
134
  {center = c; n = n0; _r = R0;};
135
  {center = c; n = n0; _r = R0;};
-
 
136
  CPlaneR(){ n=TVector3(0,0,0); center=TVector3(0,0,0); _r=0; };
-
 
137
  ~CPlaneR() {};
135
 
138
 
136
  void Set(TVector3 c, TVector3 n0, double R0)
139
  void Set(TVector3 c, TVector3 n0, double R0)
137
  {center = c; n = n0; _r = R0;};
140
  {center = c; n = n0; _r = R0;};
138
 
141
 
139
  int TestIntersection(TVector3 *vec, CRay in);
142
  int TestIntersection(TVector3 *vec, CRay in);
Line 161... Line 164...
161
public:
164
public:
162
  CSurface(int type0 = 0);
165
  CSurface(int type0 = 0);
163
  CSurface(int type0, TVector3 r1, TVector3 r2, TVector3 r3, TVector3 r4,
166
  CSurface(int type0, TVector3 r1, TVector3 r2, TVector3 r3, TVector3 r4,
164
      double n10, double n20, double reflectivity);
167
      double n10, double n20, double reflectivity);
165
  CSurface(int type0, TVector3 *vr,  double n10, double n20, double reflectivity);
168
  CSurface(int type0, TVector3 *vr,  double n10, double n20, double reflectivity);
-
 
169
  ~CSurface() {};
-
 
170
  CSurface& operator=(const CSurface& rhs) {
-
 
171
    type=rhs.type;
-
 
172
    n1=rhs.n1;
-
 
173
    n2=rhs.n2;
-
 
174
    n1_n2=rhs.n1_n2;
-
 
175
    reflection=rhs.reflection;
-
 
176
    cosTtotal=rhs.cosTtotal;
-
 
177
    fresnel=rhs.fresnel;
-
 
178
    return *this;
-
 
179
  }
166
 
180
 
167
  void SetV(TVector3 *vr){CPlane4::Set(vr);};
181
  void SetV(TVector3 *vr){CPlane4::Set(vr);};
168
  void SetType(int type0){type = type0;};
182
  void SetType(int type0){type = type0;};
169
  void SetIndex(double n10, double n20);
183
  void SetIndex(double n10, double n20);
170
  void SetReflection(double reflectivity){reflection = reflectivity;};
184
  void SetReflection(double reflectivity){reflection = reflectivity;};
Line 173... Line 187...
173
  void Set(int type0, TVector3 *vr, double n10, double n20, double reflectivity)
187
  void Set(int type0, TVector3 *vr, double n10, double n20, double reflectivity)
174
  {type = type0; CPlane4::Set(vr); SetIndex(n10, n20); reflection = reflectivity;};
188
  {type = type0; CPlane4::Set(vr); SetIndex(n10, n20); reflection = reflectivity;};
175
  void Set(int type0, TVector3 r1, TVector3 r2, TVector3 r3, TVector3 r4, double n10, double n20, double reflectivity)
189
  void Set(int type0, TVector3 r1, TVector3 r2, TVector3 r3, TVector3 r4, double n10, double n20, double reflectivity)
176
  {type = type0; CPlane4::Set(r1, r2, r3, r4); SetIndex(n10, n20); reflection = reflectivity;};
190
  {type = type0; CPlane4::Set(r1, r2, r3, r4); SetIndex(n10, n20); reflection = reflectivity;};
177
 
191
 
178
  int PropagateRay(CRay in, CRay *out, TVector3 *intersection);
192
  int PropagateRay(CRay in, CRay& out, TVector3 *intersection);
179
 
193
 
180
  double N1_N2(int sign) { return ((sign > 0) ? n1/n2 : n2/n1);};
194
  double N1_N2(int sign) { return ((sign > 0) ? n1/n2 : n2/n1);};
181
 
195
 
182
  void Print(){printf("Type = %d\n", type); CPlane4::Print();};
196
  void Print(){printf("Type = %d\n", type); CPlane4::Print();};
183
 
197
 
184
private:
198
private:
185
  int type; //0 = dummy; 1 = refractor; 2 = reflector; 3 = total reflection
199
  int type; //0 = dummy; 1 = refractor; 2 = reflector; 3 = total reflection
186
  double n1, n2, n1_n2; //index of refraction, n1 @ +normal, n2 @ -normal
200
  double n1, n2, n1_n2; //index of refraction, n1 @ +normal, n2 @ -normal
187
  double reflection; // odbojnost stranic
201
  double reflection; // odbojnost stranic
188
  TRandom rand; // za racunanje verjetnosti odboja od zrcala
202
  TRandom2 rand; // za racunanje verjetnosti odboja od zrcala
189
  double cosTtotal; //cosinus mejnega kota totalnega odboja za dana n1 in n2
203
  double cosTtotal; //cosinus mejnega kota totalnega odboja za dana n1 in n2
190
 
204
 
191
  int fresnel; // ali naj uposteva Fresnelove enacbe
205
  int fresnel; // ali naj uposteva Fresnelove enacbe
192
};
206
};
193
 
207
 
Line 299... Line 313...
299
  TVector3 _gap;
313
  TVector3 _gap;
300
 
314
 
301
  int _fresnel;
315
  int _fresnel;
302
 
316
 
303
  int _guideOn;
317
  int _guideOn;
304
  double offsetY;
318
  double offsetY;
305
  double offsetZ;
319
  double offsetZ;
306
 
320
 
307
  int _plateOn;
321
  int _plateOn;
308
  double _plateWidth;
322
  double _plateWidth;
309
 
323
 
310
  int _glassOn;
324
  int _glassOn;
311
  double _glassD;
325
  double _glassD;
312
  bool _coupling;
326
  bool _coupling;
313
 
327
 
314
};
328
};
Line 316... Line 330...
316
class Guide
330
class Guide
317
{
331
{
318
public:
332
public:
319
  Guide(TVector3 center0, DetectorParameters& parameters);
333
  Guide(TVector3 center0, DetectorParameters& parameters);
320
  ~Guide() {
334
  ~Guide() {
321
    for (int jk=0; jk<6; jk++) delete s_side[jk];
335
    //for (int jk=0; jk<6; jk++) delete s_side[jk];
322
    delete grease;
336
    //delete [] s_side;
323
    delete noCoupling;
-
 
324
    delete hfate;
337
    //delete hfate;
325
    delete hnodb_all;
338
    //delete hnodb_all;
326
    delete hnodb_exit;
339
    //delete hnodb_exit;
327
    delete hin;
340
    //delete hin;
328
    delete hout;
341
    //delete hout;
329
  }
342
  }
330
 
343
 
331
  Fate PropagateRay(CRay in, CRay *out, int *n_points, TVector3 *points);
344
  Fate PropagateRay(CRay in, CRay& out, int *n_points, TVector3 *points);
332
 
345
 
333
  double getD() { return _d; }
346
  double getD() { return _d; }
334
  double getN1() { return _n1; };
347
  double getN1() { return _n1; };
335
  double getN2() { return _n2; };
348
  double getN2() { return _n2; };
336
  double getN3() { return _n3; };
349
  double getN3() { return _n3; };
337
  TH1F* GetHFate() const {return hfate;};
350
  TH1F* GetHFate() {return &hfate;};
338
  TH1F* GetHNOdb_all() const {return hnodb_all;};
351
  TH1F* GetHNOdb_all() {return &hnodb_all;};
339
  TH1F* GetHNOdb_exit() const {return hnodb_exit;};
352
  TH1F* GetHNOdb_exit() {return &hnodb_exit;};
340
  TH2F* GetHIn() const {return hin;};
353
  TH2F* GetHIn() {return &hin;};
341
  TH2F* GetHOut() const {return hout;};
354
  TH2F* GetHOut() {return &hout;};
342
  int GetExitHits() {return (int)hfate->GetBinContent(5);};
355
  int GetExitHits() {return (int)hfate.GetBinContent(5);};
343
  int GetEnteranceHits() {return (int)hfate->GetBinContent(6);};
356
  int GetEnteranceHits() {return (int)hfate.GetBinContent(6);};
344
  void GetVFate(int *out);
357
  void GetVFate(int *out);
345
  int GetMAXODB() const {return MAX_REFLECTIONS;};
358
  int GetMAXODB() const {return MAX_REFLECTIONS;};
346
 
359
 
347
  void Draw(int color = 1, int width = 1);
360
  void Draw(int color = 1, int width = 1);
348
  void DrawSkel(int color = 1, int width = 1);
361
  void DrawSkel(int color = 1, int width = 1);
Line 353... Line 366...
353
  double _n1, _n2, _n3; // refractive index: n1 above entry surface, n2 inside, n3 after exit
366
  double _n1, _n2, _n3; // refractive index: n1 above entry surface, n2 inside, n3 after exit
354
  double _r;
367
  double _r;
355
  double _absorption;
368
  double _absorption;
356
  double _A;
369
  double _A;
357
  bool _badCoupling;
370
  bool _badCoupling;
358
  TRandom rand; // for material absorption
371
  TRandom2 rand; // for material absorption
359
  CSurface *s_side[6];
372
  CSurface s_side[6];
360
  CPlaneR* grease;
373
  CPlaneR grease;
361
  CSurface* noCoupling;
374
  CSurface noCoupling;
-
 
375
  TVector3 center;
362
  TVector3 center, vodnik_edge[8];
376
  TVector3 vodnik_edge[8];
363
 
377
 
-
 
378
  TH1F hfate;
-
 
379
  TH1F hnodb_all;
364
  TH1F *hfate, *hnodb_all, *hnodb_exit;
380
  TH1F hnodb_exit;
-
 
381
  TH2F hin;
365
  TH2F *hin, *hout;
382
  TH2F hout;
366
};
383
};
367
 
384
 
368
 
385
 
369
 
386
 
370
class Plate
387
class Plate
371
{
388
{
372
public:
389
public:
373
  Plate(DetectorParameters& parameters);
390
  Plate(DetectorParameters& parameters);
374
  ~Plate() {
391
  ~Plate() { };
375
    for (int jk=0; jk<6; jk++) delete sides[jk]; // the same, needs solution
-
 
376
  };
-
 
377
 
392
 
378
  void draw(int color, int width);
393
  void draw(int color, int width);
379
  void drawSkel(int color, int width);
394
  void drawSkel(int color, int width);
380
  Fate propagateRay(CRay, CRay*, int*, TVector3*);
395
  Fate propagateRay(CRay, CRay&, int*, TVector3*);
381
 
396
 
382
private:
397
private:
383
  TVector3 plate_edge[8];
398
  TVector3 plate_edge[8];
384
  CSurface *sides[6];
399
  CSurface sides[6];
385
};
400
};
386
 
401
 
387
 
402
 
388
class CDetector
403
class CDetector
389
{
404
{
390
public:
405
public:
391
  CDetector(TVector3 center0, DetectorParameters& parameters);
406
  CDetector(TVector3 center0, DetectorParameters& parameters);
392
  ~CDetector() {
407
  ~CDetector() {
393
    delete glass;
408
    //delete glass;
394
    delete glass_circle;
409
    //delete glass_circle;
395
    delete hglass;
410
    //delete hglass;
396
    delete active;
411
    //delete active;
397
    delete hactive;
412
    //delete hactive;
398
    delete hlaser;
413
    //delete hlaser;
399
    delete detector;
414
    //delete detector;
400
    delete hdetector;
415
    //delete hdetector;
401
    delete guide;
416
    //delete guide;
402
    delete plate;
417
    //delete plate;
403
    delete histoPlate;
418
    //delete histoPlate;
404
    //delete window;
419
    //delete window;
405
    //delete window_circle;
420
    //delete window_circle;
406
    //delete hwindow;
421
    //delete hwindow;
407
  }
422
  }
408
 
423
 
Line 435... Line 450...
435
  //void SetGuideOn(int b)
450
  //void SetGuideOn(int b)
436
  //{guide_on = b;};
451
  //{guide_on = b;};
437
 
452
 
438
  //void Init();
453
  //void Init();
439
 
454
 
440
  int Propagate(CRay, CRay*, int);
455
  int Propagate(CRay, CRay&, int);
441
 
456
 
442
  Guide* GetLG() const {return guide;};
457
  Guide* GetLG() {return &guide;};
443
  //TH2F* GetHWindow() const {return hwindow;};
458
  //TH2F* GetHWindow() const {return hwindow;};
444
  TH2F* GetHGlass() const {return hglass;};
459
  TH2F* GetHGlass() {return &hglass;};
445
  TH2F* GetHActive() const {return hactive;};
460
  TH2F* GetHActive() {return &hactive;};
446
  TH2F* GetHLaser() const {return hlaser;};
461
  TH2F* GetHLaser() {return &hlaser;};
447
  TH2F* GetHDetector() const {return hdetector;};
462
  TH2F* GetHDetector() {return &hdetector;};
448
  TH2F* GetHPlate() const {return histoPlate;};
463
  TH2F* GetHPlate() {return &histoPlate;};
-
 
464
  TH2F* GetGenerated() {return &generated;};
449
 
465
 
450
  //double GetSiPM() const {return SiPM;};
466
  //double GetSiPM() const {return SiPM;};
451
  //double GetM() const {return M;};
467
  //double GetM() const {return M;};
452
  //double GetD() const {return d;};
468
  //double GetD() const {return d;};
453
  //double GetR() const {return R;};
469
  //double GetR() const {return R;};
Line 456... Line 472...
456
  //double getGlassWidth() {return glass_d;};
472
  //double getGlassWidth() {return glass_d;};
457
  //double GetWindowR() {return window_R;};
473
  //double GetWindowR() {return window_R;};
458
  //double GetWindowD() {return window_d;};
474
  //double GetWindowD() {return window_d;};
459
 
475
 
460
  void Draw(int width = 2);
476
  void Draw(int width = 2);
461
 
477
 
462
private:
478
private:
463
  Fate fate;
479
  Fate fate;
464
  TVector3 center;
480
  TVector3 center;
465
 
481
 
466
  //int type_in, type_side, type_out;
482
  //int type_in, type_side, type_out;
467
  //double SiPM, M, d, n1, n2, n3, R;
483
  //double SiPM, M, d, n1, n2, n3, R;
468
  //double detectorActive;
484
  //double detectorActive;
469
 
485
 
470
 
486
 
471
  int glass_on;
487
  int glass_on;
472
  double glass_d;
488
  double glass_d;
473
  CSurface *glass;
489
  CSurface glass;
474
  CPlaneR *glass_circle;
490
  CPlaneR glass_circle;
475
  TH2F *hglass;
491
  TH2F hglass;
476
 
492
 
477
  //double x_gap, y_gap, z_gap;
493
  //double x_gap, y_gap, z_gap;
478
  CPlane4* active;
494
  CPlane4 active;
479
  CPlaneR* grease;
495
  CPlaneR grease;
480
  TH2F *hactive, *hlaser;
496
  TH2F hactive;
-
 
497
  TH2F hlaser;
481
 
498
 
482
  CPlane4 *detector;
499
  CPlane4 detector;
483
  TH2F *hdetector;
500
  TH2F hdetector;
484
 
501
 
485
  int col_in, col_lg, col_out, col_rgla;
502
  int col_in, col_lg, col_out, col_rgla;
486
  int col_LG, col_glass, col_active;
503
  int col_LG, col_glass, col_active;
487
 
504
 
488
  //int fresnel, absorption;
505
  //int fresnel, absorption;
489
  //double A;
506
  //double A;
490
 
507
 
491
  int guide_on;
508
  int guide_on;
492
 
509
 
493
  //double window_R, window_d;
510
  //double window_R, window_d;
494
  //CSurface *window;
511
  //CSurface *window;
495
  //CPlaneR *window_circle;
512
  //CPlaneR *window_circle;
496
  //TH2F *hwindow;
513
  //TH2F *hwindow;
497
 
514
 
498
  Guide *guide;
515
  Guide guide;
499
  Plate *plate;
516
  Plate plate;
500
 
517
 
501
  double _plateWidth;
518
  double _plateWidth;
502
  int _plateOn;
519
  int _plateOn;
503
 
520
 
504
  TH2F *histoPlate;
521
  TH2F histoPlate;
505
 
522
 
506
  double offsetY;
523
  double offsetY;
507
  double offsetZ;
524
  double offsetZ;
-
 
525
 
-
 
526
  TH2F generated;
508
};
527
};
509
 
528
 
510
 
529
 
511
 
530
 
512
#endif
531
#endif