1 | // ESAF : Euso Simulation and Analysis Framework |
---|
2 | // $Id: PipesOpticalAdaptor.cc 2136 2005-10-02 14:18:08Z thea $ |
---|
3 | // A.Thea created Nov, 8 2002 |
---|
4 | |
---|
5 | #include "PipesOpticalAdaptor.hh" |
---|
6 | #include "Photomultiplier.hh" |
---|
7 | |
---|
8 | using namespace sou; |
---|
9 | |
---|
10 | ClassImp(PipesOpticalAdaptor) |
---|
11 | |
---|
12 | int PipesOpticalAdaptor::_nrows = 0; |
---|
13 | int PipesOpticalAdaptor::_npads = 0; |
---|
14 | double PipesOpticalAdaptor::_pad_side=0.; |
---|
15 | double PipesOpticalAdaptor::_bottom_inner_strip = 0.; |
---|
16 | double PipesOpticalAdaptor::_bottom_pad_side = 0.; |
---|
17 | EVector PipesOpticalAdaptor::_corners[10][10][2]; |
---|
18 | |
---|
19 | //______________________________________________________________________________ |
---|
20 | PipesOpticalAdaptor::PipesOpticalAdaptor() { |
---|
21 | // |
---|
22 | // Constructor |
---|
23 | // |
---|
24 | |
---|
25 | if (_npads <= 0) |
---|
26 | SetPipesGeometry(); |
---|
27 | |
---|
28 | fReflectivity = Conf()->GetNum("PipesOpticalAdaptor.fCathode.reflectivity"); |
---|
29 | |
---|
30 | fSide=Conf()->GetNum("PipesOpticalAdaptor.fSide")*mm; |
---|
31 | fHeight=Conf()->GetNum("PipesOpticalAdaptor.fHeight")*mm; |
---|
32 | } |
---|
33 | |
---|
34 | //______________________________________________________________________________ |
---|
35 | PipesOpticalAdaptor::~PipesOpticalAdaptor() { |
---|
36 | // |
---|
37 | // Destructor |
---|
38 | // |
---|
39 | } |
---|
40 | |
---|
41 | //______________________________________________________________________________ |
---|
42 | void PipesOpticalAdaptor::SetPipesGeometry(){ |
---|
43 | |
---|
44 | if (_npads == 0) { |
---|
45 | _nrows= (int) Conf()->GetNum("PipesOpticalAdaptor.size"); |
---|
46 | _npads=_nrows*_nrows; |
---|
47 | _pad_side=fSide/(double)_nrows; |
---|
48 | _bottom_inner_strip=Conf()->GetNum("PipesOpticalAdaptor.bottom.inner.strip")*mm; |
---|
49 | _bottom_pad_side=Conf()->GetNum("PipesOpticalAdaptor.bottom.pad.side")*mm; |
---|
50 | |
---|
51 | EVector loc_par_X(1.,0.,0.); |
---|
52 | EVector loc_par_Y(0.,1.,0.); |
---|
53 | EVector loc_par_Z(0.,0.,1.); |
---|
54 | |
---|
55 | // computes the positon of the two corners |
---|
56 | EVector blu_corner= (fSide-(_bottom_pad_side*_nrows |
---|
57 | +_bottom_inner_strip*(_nrows-1)))*0.5 |
---|
58 | *(loc_par_X-loc_par_Y); |
---|
59 | #ifdef DEBUG |
---|
60 | cout << "prova " << (fSide-(_bottom_pad_side*_nrows+_bottom_inner_strip*(_nrows-1)))*0.5 << "\n" << |
---|
61 | "blu_corner= " << blu_corner << endl; |
---|
62 | #endif /* DEBUG */ |
---|
63 | for(int row=0; row < _nrows; row++) { |
---|
64 | for(int col=0; col < _nrows; col++) { |
---|
65 | |
---|
66 | _corners[row][col][0]=_pad_side*((col+1)*loc_par_X |
---|
67 | -row*loc_par_Y) |
---|
68 | +fHeight*loc_par_Z; |
---|
69 | |
---|
70 | _corners[row][col][1]=blu_corner |
---|
71 | +(_bottom_pad_side+_bottom_inner_strip)*col*loc_par_X |
---|
72 | -(_bottom_pad_side*(row+1)+_bottom_inner_strip*row)*loc_par_Y; |
---|
73 | |
---|
74 | #ifdef DEBUG |
---|
75 | if(row < 4 && col < 4){ |
---|
76 | cout << "_corner[" << row << "][" << col << "][1]=\n" << |
---|
77 | "X = " << _corners[row][col][1][X] << " mm\n" |
---|
78 | "Y = " << _corners[row][col][1][Y] << " mm\n" |
---|
79 | "Z = " << _corners[row][col][1][Z] << " mm\n" |
---|
80 | << endl; |
---|
81 | } |
---|
82 | #endif /* DEBUG */ |
---|
83 | |
---|
84 | } |
---|
85 | } |
---|
86 | |
---|
87 | } |
---|
88 | #ifdef DEBUG |
---|
89 | cout << "PipesOpticalAdaptor created\n" << |
---|
90 | " fSide=" << fSide << "\n" << |
---|
91 | " fHeight=" << fHeight << "\n" << |
---|
92 | " size=" << _nrows << "\n" << |
---|
93 | " inner strip="<< _bottom_inner_strip << "\n" << |
---|
94 | " bottom pad side=" << _bottom_pad_side << endl; |
---|
95 | #endif /* DEBUG */ |
---|
96 | |
---|
97 | } |
---|
98 | |
---|
99 | |
---|
100 | //______________________________________________________________________________ |
---|
101 | Photon *PipesOpticalAdaptor::Transport(Photon *p) const { |
---|
102 | |
---|
103 | EVector lpos=p->pos-fPos; |
---|
104 | lpos=goLocal(lpos); |
---|
105 | |
---|
106 | int hitFace = whichFace(p); |
---|
107 | int row, col; |
---|
108 | |
---|
109 | |
---|
110 | if (hitFace==TOP) { |
---|
111 | #ifdef DEBUG |
---|
112 | cout << "PipesOpticalAdaptorTransport: hitface = TOP\n" << |
---|
113 | "Hit coordinates (local): X=" << lpos[X] << " mm Y=" << lpos[Y] << " mm" << endl; |
---|
114 | #endif /* DEBUG */ |
---|
115 | row=0; |
---|
116 | for(col=0; col<_nrows;col++){ |
---|
117 | #ifdef DEBUG |
---|
118 | cout << "col: lpos[X]=" << lpos[X] << " bounds: " << _corners[row][col][0][X]-_pad_side << "<X <" << _corners[row][col][0][X] << endl; |
---|
119 | #endif /* DEBUG */ |
---|
120 | if (lpos[X] >= _corners[row][col][0][X]-_pad_side |
---|
121 | && lpos[X] < _corners[row][col][0][X]) break; |
---|
122 | } |
---|
123 | for(row=0; row<_nrows;row++){ |
---|
124 | #ifdef DEBUG |
---|
125 | cout << "row: lpos[Y]=" << lpos[Y] << " bounds: " << _corners[row][col][0][Y]-_pad_side << "<X <" << _corners[row][col][0][Y] << endl; |
---|
126 | #endif /* DEBUG */ |
---|
127 | if(lpos[Y] >= _corners[row][col][0][Y]-_pad_side |
---|
128 | && lpos[Y] < _corners[row][col][0][Y] |
---|
129 | ) break; |
---|
130 | } |
---|
131 | |
---|
132 | } else if (hitFace == BOTTOM) { |
---|
133 | #ifdef DEBUG |
---|
134 | cout << "PipesOpticalAdaptorTransport: hitface = BOTTOM" << endl; |
---|
135 | #endif /* DEBUG */ |
---|
136 | row=0; |
---|
137 | for(col=0; col<_nrows;col++) |
---|
138 | if (lpos[X] >= _corners[row][col][1][X] |
---|
139 | && lpos[X] < _corners[row][col][1][X]+_bottom_pad_side) break; |
---|
140 | for(row=0; row<_nrows;row++) |
---|
141 | if (lpos[Y] >= _corners[row][col][1][Y] |
---|
142 | && lpos[Y] < _corners[row][col][1][Y]-_bottom_pad_side) break; |
---|
143 | } else { |
---|
144 | cerr<<"warning: photon on OpticalAdaptor edge. Killed"<<endl; |
---|
145 | return 0; // wrong face |
---|
146 | } |
---|
147 | #ifdef DEBUG |
---|
148 | cout << " Pipe hit: row =" << row << " col =" << col << endl; |
---|
149 | #endif /* DEBUG */ |
---|
150 | |
---|
151 | if (row==_nrows || col==_nrows) { |
---|
152 | cerr<<"warning: photon on OpticalAdaptor edge. Killed"<<endl; |
---|
153 | return 0; // wrong face |
---|
154 | } |
---|
155 | |
---|
156 | EVector c1=goGlobal(_corners[row][col][0])+fPos; |
---|
157 | EVector c2=goGlobal(_corners[row][col][1])+fPos; |
---|
158 | #ifdef DEBUG |
---|
159 | cout << "Creating LightPipe"<< endl; |
---|
160 | cout << " pos=" << fPos << "\n" |
---|
161 | << " row=" << row << " col=" << col << "\n" |
---|
162 | << " corner[0]=" << _corners[row][col][0] << "\n" |
---|
163 | << " corner[1]=" << _corners[row][col][1] << "\n" |
---|
164 | << " c1=" << c1 << "\n" |
---|
165 | << " c2=" << c2 << "\n" |
---|
166 | << " pad side=" << _pad_side << "\n" |
---|
167 | << " bottom pad side=" << _bottom_pad_side << endl; |
---|
168 | |
---|
169 | #endif /* DEBUG */ |
---|
170 | LightPipe pipe(c1, c2, _pad_side, _pad_side, _bottom_pad_side, _bottom_pad_side, pmt); |
---|
171 | p=pipe.Transport(p); |
---|
172 | |
---|
173 | hitFace=whichFace(p); |
---|
174 | if (hitFace==TOP){ |
---|
175 | return p; |
---|
176 | } else if (hitFace==BOTTOM){ |
---|
177 | if (isReflectedByCathode()) { |
---|
178 | EVector ldir=goLocal(p->dir); |
---|
179 | ldir[Z] *= -1; |
---|
180 | p->dir=goGlobal(ldir); |
---|
181 | p->MChit=false; |
---|
182 | p->hit=false; |
---|
183 | return Transport(p); |
---|
184 | } |
---|
185 | |
---|
186 | // Add photon to PMT |
---|
187 | if(!pmt->Pmt()->Add(*p)) { |
---|
188 | #ifdef DEBUG |
---|
189 | cout<<"photon rejected by PMT"<<endl; |
---|
190 | #endif /* DEBUG */ |
---|
191 | } else { |
---|
192 | #ifdef DEBUG |
---|
193 | cout<<"photon accepted by PMT"<<endl; |
---|
194 | #endif /* DEBUG */ |
---|
195 | } |
---|
196 | |
---|
197 | return 0; |
---|
198 | |
---|
199 | } |
---|
200 | return 0; |
---|
201 | } |
---|
202 | |
---|
203 | |
---|