73 {
74 int iwire = 0;
75 int ilay;
76 int icell;
77 int ampid;
78 int channel;
79 int iFan;
80
81 char wirelabel[100];
82 char wiretag[100];
83
84 int ncell;
86 double radius;
87 double twist;
89 double offset;
90 string strtmp;
91
92 double aglstart;
93 double angleforwini;
94 double angleforw;
95 double angleback;
96
97 int layertype;
98
99 double xf;
100 double yf;
101 double zf;
102 double xb;
103 double yb;
104 double zb;
105
106 double slant;
107
108 double tension[] = {15, 15, 15, 16, 16, 17, 17, 18, 14, 14,
109 19, 19, 24, 24, 31, 31, 37, 37, 45, 45,
110 46, 47, 47, 47, 47, 48, 48, 48, 48, 49,
111 49, 49, 49, 50, 50, 50, 51, 51, 51, 52,
112 52, 52, 52};
113
114 int iEle;
115 int iPar[12];
116
117 if( ! initAlign() ){
118 return false;
119 }
120
122 return false;
123 }
124
125 ifstream fin( m_fwconf.c_str() );
126 if( ! fin.is_open() ){
127 cout << "ERROR: can not open file " << m_fwconf << endl;
128 return false;
129 }
130
132 fin >> strtmp >> radius >> ncell >> twist
134
136 ncell /= 2;
137
138 if( fabs(twist) > 0.1 ){
139 offset = 0.0;
140 }
141
142 aglstart = (
PI / ncell) * first + (offset *
PI / 180.0);
143 if( aglstart < -0.000001 ){
144 aglstart += 2.0 *
PI / ncell;
145 }
146
147 if( twist < -0.1 ){
148 layertype = 1;
149 } else if( twist > 0.1 ){
150 layertype = 2;
151 } else{
152 layertype = 0;
153 }
154
155 slant = atan(
sin(
PI * twist / ncell)
156 * radius * 2.0 /
length );
157
159 m_player[ilay] -> setLayerType( layertype );
160 m_player[ilay] -> setNcell( ncell );
161 m_player[ilay] -> setLayerRad( radius );
162 m_player[ilay] -> setLength(
length );
163 m_player[ilay] -> setTwistCell( twist );
164 m_player[ilay] -> setSlant( slant );
165
166 if( ilay <
INNERNMAX ) m_player[ilay] -> setFgInner(
true );
167 else m_player[ilay] -> setFgInner( false );
168
169
170 if( ilay < 8 ){
171 iEle = 0;
172 } else if( ilay < 10 ){
173 iEle = 1;
174 } else if( ilay < 12 ){
175 iEle = 2;
176 } else if( ilay < 14 ){
177 iEle = 3;
178 } else if( ilay < 16 ){
179 iEle = 4;
180 } else if( ilay < 18 ){
181 iEle = 5;
182 } else if( ilay < 20 ){
183 iEle = 6;
184 } else{
185 iEle = 7;
186 }
187
188 iPar[0] = iEle + m_iTXf;
189 iPar[1] = iEle + m_iTXb;
190 iPar[2] = iEle + m_iTYf;
191 iPar[3] = iEle + m_iTYb;
192 iPar[4] = iEle + m_iTZf;
193 iPar[5] = iEle + m_iTZb;
194 iPar[6] = iEle + m_iRXf;
195 iPar[7] = iEle + m_iRXb;
196 iPar[8] = iEle + m_iRYf;
197 iPar[9] = iEle + m_iRYb;
198 iPar[10] = iEle + m_iRZf;
199 iPar[11] = iEle + m_iRZb;
200
201 m_player[ilay] -> setAlignParId(iPar);
202
203 for(icell=0; icell<ncell; icell++){
204 m_wiretable[ilay][icell] = iwire;
205 angleforwini = (double)icell * 2.0 *
PI / ncell + aglstart;
206
207
208 angleforw = angleforwini + m_alignPar[iEle+m_iRZf];
209 angleforw += m_rot;
210
211 xf = radius *
cos( angleforw );
212 yf = radius *
sin( angleforw );
214
215 xf += m_alignPar[iEle+m_iTXf];
216 yf += m_alignPar[iEle+m_iTYf];
217 zf += m_alignPar[iEle+m_iTZf];
218
219
220 angleback = angleforwini + twist * 2.0 *
PI / ncell;
221 angleback += m_alignPar[iEle+m_iRZb];
222 angleback += m_rot;
223
224 xb = radius *
cos( angleback );
225 yb = radius *
sin( angleback );
227
228 xb += m_alignPar[iEle+m_iTXb];
229 yb += m_alignPar[iEle+m_iTYb];
230 zb += m_alignPar[iEle+m_iTZb];
231
232 ampid = icell / 8;
233 channel = icell - 8 * ampid;
234 sprintf(wirelabel, "%02dS%02d-%d", ilay+1, ampid+1, channel+1);
235 sprintf(wiretag, "%02d_%02d_%04d_%02d",
236 ilay, icell, iwire, ampid+1);
237
239
240 m_pwire[iwire] -> setLayerPtr(m_player[ilay]);
241
242 m_pwire[iwire] -> setWireId( iwire );
243 m_pwire[iwire] -> setLayerId( ilay );
244 m_pwire[iwire] -> setCellId( icell );
245 m_pwire[iwire] -> setPreAmpId( ampid+1 );
246 m_pwire[iwire] -> setChannel( channel );
247
248
249 iFan = m_fan[ilay][ampid];
250
251 m_pwire[iwire] -> setFanId(
abs(iFan) );
252 if(iFan > 0) m_pwire[iwire] -> setEndId( 1 );
253 else m_pwire[iwire] -> setEndId( -1 );
254
255 m_pwire[iwire] -> setWireLabel( wirelabel );
256 m_pwire[iwire] -> setWireTag( wiretag );
257
258 m_pwire[iwire] -> setXf( xf );
259 m_pwire[iwire] -> setYf( yf );
260 m_pwire[iwire] -> setZf( zf );
261
262 m_pwire[iwire] -> setXb( xb );
263 m_pwire[iwire] -> setYb( yb );
264 m_pwire[iwire] -> setZb( zb );
265
266 if( angleforw < 0 ) angleforw += 2.0 *
PI;
267 m_pwire[iwire] -> setPhiForward( angleforw );
268
269 m_pwire[iwire] ->
setTension( tension[ilay] );
270
271 iwire++;
272 }
273 }
274 fin.close();
275 cout << "INFO: Number of wires: " << iwire << endl;
276 m_nWire = iwire;
278
279 return true;
280}
double sin(const BesAngle a)
double cos(const BesAngle a)
double abs(const EvtComplex &c)