1 | // ESAF : Euso Simulation and Analysis Framework |
---|
2 | // class FastFocalPlane |
---|
3 | // $Id: FastFocalPlane.cc 2849 2010-11-11 11:59:41Z biktem $ |
---|
4 | // |
---|
5 | |
---|
6 | #include <math.h> |
---|
7 | #include "FastFocalPlane.hh" |
---|
8 | #include "ElectronicsFactory.hh" |
---|
9 | #include "EusoElectronics.hh" |
---|
10 | #include "MacroCell.hh" |
---|
11 | #include "Photomultiplier.hh" |
---|
12 | #include "PmtGeometry.hh" |
---|
13 | #include "Config.hh" |
---|
14 | #include "IdealFocalSurface.hh" |
---|
15 | #include "EConst.hh" |
---|
16 | |
---|
17 | ClassImp(FastFocalPlane) |
---|
18 | using namespace EConst; |
---|
19 | |
---|
20 | //______________________________________________________________________________ |
---|
21 | FastFocalPlane::FastFocalPlane() { |
---|
22 | // |
---|
23 | // Constructor |
---|
24 | // |
---|
25 | } |
---|
26 | |
---|
27 | //______________________________________________________________________________ |
---|
28 | FastFocalPlane::~FastFocalPlane() { |
---|
29 | // |
---|
30 | // Destructor |
---|
31 | // |
---|
32 | } |
---|
33 | |
---|
34 | //______________________________________________________________________________ |
---|
35 | Photon *FastFocalPlane::Transport(Photon *p) const { |
---|
36 | // |
---|
37 | // Transport the photon through the optics |
---|
38 | // |
---|
39 | |
---|
40 | if (!fElectronics) |
---|
41 | FatalError("No electronics defined."); |
---|
42 | // photon position relative to local coordinate system |
---|
43 | p->pos -= fPos; |
---|
44 | MacroCellGeometry *g; |
---|
45 | Photon *pOld = p; |
---|
46 | |
---|
47 | for(Int_t i=0; i<fElectronics->NumCell(); i++) { |
---|
48 | g=fElectronics->Cell(i)->Geometry(); |
---|
49 | if ( ( g->IsHit( *p ) ) > kTolerance ){ |
---|
50 | p = HitMC( p, g ); |
---|
51 | |
---|
52 | // photon can be either dead |
---|
53 | if (!p) { |
---|
54 | pOld->pos += fPos; |
---|
55 | return 0; |
---|
56 | } |
---|
57 | // or can have reached successfully a macrocell |
---|
58 | if ( p->MChit) { |
---|
59 | p->pos += fPos; |
---|
60 | return p; |
---|
61 | } |
---|
62 | } |
---|
63 | } |
---|
64 | |
---|
65 | if(p && !p->MChit) { |
---|
66 | if(p->dir[Z] > 0) { |
---|
67 | // photon going up |
---|
68 | p->pos += fPos; |
---|
69 | Double_t DL = CylinderIntersection( p ); |
---|
70 | |
---|
71 | if ( DL < kTolerance ) { |
---|
72 | p->history = kWalls; |
---|
73 | return 0; |
---|
74 | } |
---|
75 | |
---|
76 | p->pos+=DL*p->dir.Unit(); |
---|
77 | p->time+=DL/Clight(); |
---|
78 | p->history = kWalls; |
---|
79 | return 0; |
---|
80 | } else { |
---|
81 | // reflected photon |
---|
82 | EVector dummy=p->dir*((p->pos[Z]-Bottom())/fabs(p->dir[Z])); |
---|
83 | p->pos+=dummy; |
---|
84 | p->time+=dummy.Mag()/Clight(); |
---|
85 | p->pos[Z]=Bottom(); |
---|
86 | p->pos += fPos; |
---|
87 | return p; |
---|
88 | } |
---|
89 | } |
---|
90 | |
---|
91 | return 0; |
---|
92 | } |
---|
93 | |
---|
94 | //#define DEBUG |
---|
95 | //______________________________________________________________________________ |
---|
96 | Photon* FastFocalPlane::HitMC(Photon *p, MacroCellGeometry *g) const { |
---|
97 | Photomultiplier *HitPMT = g->FindHitPmt( *p ); |
---|
98 | if (!HitPMT){ |
---|
99 | |
---|
100 | return p; |
---|
101 | } |
---|
102 | p->MChit=true; |
---|
103 | |
---|
104 | Double_t DL = HitPMT->Geometry()->GetOA()->IsHit(*p); |
---|
105 | |
---|
106 | p->pos+=p->dir.Unit()*DL; |
---|
107 | p->time+=DL/Clight(); |
---|
108 | p->hit=true; |
---|
109 | #ifdef DEBUG |
---|
110 | cout<<"-------- MACROCELL HIT ---------"<<endl; |
---|
111 | //cout<<"Hit MacroCell "<<i<<endl; |
---|
112 | |
---|
113 | cout<<"relposition = "<<p->pos - g->GetCenter()<<endl; |
---|
114 | cout<<"position = "<<p->pos<<endl; |
---|
115 | cout<<"g->GetNormal() = "<<g->GetNormal()<<endl; |
---|
116 | cout<<"direction = "<<p->dir<<endl; |
---|
117 | if(HitPMT) { |
---|
118 | cout<<"Hit PMT "<<endl; |
---|
119 | cout<<"Hit PMT "<<HitPMT->Id()<<endl; |
---|
120 | cout <<"Hit PMT position "<<HitPMT->Geometry()->Position()<<endl; |
---|
121 | cout <<"Hit PMT distance "<< DL <<endl; |
---|
122 | } else { |
---|
123 | cout<<"missed PMT"<<endl; |
---|
124 | } |
---|
125 | |
---|
126 | cout<<"hit ifs "<<p->hitIfs<<" "<<p->posOnIfs<<endl; |
---|
127 | cout<<"pos "<<Position()<<endl; |
---|
128 | #endif /* DEBUG */ |
---|
129 | //p->posOnIfs=p->pos; |
---|
130 | p=HitPMT->Geometry()->GetOA()->Transport(p); |
---|
131 | |
---|
132 | // when we get here there are two possibility: |
---|
133 | // p==0 if the photon is not reflected by the cathode |
---|
134 | // p!=0 if the photon is reflected back |
---|
135 | if(p){ |
---|
136 | #ifdef DEBUG |
---|
137 | cerr<<"FastFocalPlane: photon reflected back by the chatode"<<endl; |
---|
138 | #endif /* DEBUG */ |
---|
139 | p=Transport(p); |
---|
140 | } |
---|
141 | return p; |
---|
142 | } |
---|