1#include "include/MdcCosGeom.h"
12 m_fwconf(fwireconf), m_falign(falign)
18 for(icell=0; icell<
CELLNMAX; icell++){
19 m_wiretable[ilay][icell] = -1;
23 for(
int i=0; i<12; i++){
43 for(ipream=0; ipream<100; ipream++){
44 m_fan[ilay][ipream] = -999;
48 cout <<
"INFO: MdcCosGeom created." << endl;
61 cout <<
"INFO: MdcCosGeom has been destructed." << endl;
65 m_rot = rot *
PI / 180.0;
67 cout <<
"ERROR: Intialize wire failed !!!" << endl;
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,
125 ifstream fin( m_fwconf.c_str() );
126 if( ! fin.is_open() ){
127 cout <<
"ERROR: can not open file " << m_fwconf << endl;
132 fin >> strtmp >> radius >> ncell >> twist
133 >> offset >> length >> first;
138 if( fabs(twist) > 0.1 ){
142 aglstart = (
PI / ncell) * first + (offset *
PI / 180.0);
143 if( aglstart < -0.000001 ){
144 aglstart += 2.0 *
PI / ncell;
149 }
else if( twist > 0.1 ){
155 slant = atan(
sin(
PI * twist / ncell)
156 * radius * 2.0 / length );
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 );
166 if( ilay <
INNERNMAX ) m_player[ilay] -> setFgInner(
true );
167 else m_player[ilay] -> setFgInner(
false );
172 }
else if( ilay < 10 ){
174 }
else if( ilay < 12 ){
176 }
else if( ilay < 14 ){
178 }
else if( ilay < 16 ){
180 }
else if( ilay < 18 ){
182 }
else if( ilay < 20 ){
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;
201 m_player[ilay] -> setAlignParId(iPar);
203 for(icell=0; icell<ncell; icell++){
204 m_wiretable[ilay][icell] = iwire;
205 angleforwini = (double)icell * 2.0 *
PI / ncell + aglstart;
208 angleforw = angleforwini + m_alignPar[iEle+m_iRZf];
211 xf = radius *
cos( angleforw );
212 yf = radius *
sin( angleforw );
215 xf += m_alignPar[iEle+m_iTXf];
216 yf += m_alignPar[iEle+m_iTYf];
217 zf += m_alignPar[iEle+m_iTZf];
220 angleback = angleforwini + twist * 2.0 *
PI / ncell;
221 angleback += m_alignPar[iEle+m_iRZb];
224 xb = radius *
cos( angleback );
225 yb = radius *
sin( angleback );
228 xb += m_alignPar[iEle+m_iTXb];
229 yb += m_alignPar[iEle+m_iTYb];
230 zb += m_alignPar[iEle+m_iTZb];
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);
240 m_pwire[iwire] -> setLayerPtr(m_player[ilay]);
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 );
249 iFan = m_fan[ilay][ampid];
251 m_pwire[iwire] -> setFanId(
abs(iFan) );
252 if(iFan > 0) m_pwire[iwire] -> setEndId( 1 );
253 else m_pwire[iwire] -> setEndId( -1 );
255 m_pwire[iwire] -> setWireLabel( wirelabel );
256 m_pwire[iwire] -> setWireTag( wiretag );
258 m_pwire[iwire] -> setXf( xf );
259 m_pwire[iwire] -> setYf( yf );
260 m_pwire[iwire] -> setZf( zf );
262 m_pwire[iwire] -> setXb( xb );
263 m_pwire[iwire] -> setYb( yb );
264 m_pwire[iwire] -> setZb( zb );
266 if( angleforw < 0 ) angleforw += 2.0 *
PI;
267 m_pwire[iwire] -> setPhiForward( angleforw );
269 m_pwire[iwire] ->
setTension( tension[ilay] );
275 cout <<
"INFO: Number of wires: " << iwire << endl;
282bool MdcCosGeom::initAlign(){
283 ifstream falign( m_falign.c_str() );
284 if( ! falign.is_open() ){
285 cout <<
"ERROR: can not open alignment data file "
290 cout <<
"INFO: Alignment data file is " << m_falign << endl;
294 getline(falign, str);
297 falign >> str >> m_alignPar[i+m_iTXf] >> m_alignPar[i+m_iTYf]
298 >> m_alignPar[i+m_iTZf] >> m_alignPar[i+m_iRXf]
299 >> m_alignPar[i+m_iRYf] >> m_alignPar[i+m_iRZf];
302 m_alignPar[i+m_iRXf] *= 0.001;
303 m_alignPar[i+m_iRYf] *= 0.001;
304 m_alignPar[i+m_iRZf] *= 0.001;
308 falign >> str >> m_alignPar[i+m_iTXb] >> m_alignPar[i+m_iTYb]
309 >> m_alignPar[i+m_iTZb] >> m_alignPar[i+m_iRXb]
310 >> m_alignPar[i+m_iRYb] >> m_alignPar[i+m_iRZb];
313 m_alignPar[i+m_iRXb] *= 0.001;
314 m_alignPar[i+m_iRYb] *= 0.001;
315 m_alignPar[i+m_iRZb] *= 0.001;
335 sprintf(fname,
"pream/east%d.dat", i+1);
338 sprintf(fname,
"pream/west%d.dat", i+1);
345 m_fan[lay-1][ipream-1] = (i+1) * iEnd;
359 ofstream fout( fchk.c_str() );
360 for(
int iwire=0; iwire<6796; iwire++){
361 fout << setw(4) << iwire;
362 fout << setw(6) <<
getWire(iwire) -> getWireId();
363 fout << setw(4) <<
getWire(iwire) -> getLayerId();
364 fout << setw(5) <<
getWire(iwire) -> getCellId();
365 fout << setw(15) <<
getWire(iwire) -> getXb();
366 fout << setw(15) <<
getWire(iwire) -> getYb();
367 fout << setw(7) <<
getWire(iwire) -> getZb();
368 fout << setw(15) <<
getWire(iwire) -> getXf();
369 fout << setw(15) <<
getWire(iwire) -> getYf();
370 fout << setw(7) <<
getWire(iwire) -> getZf();
375 cout << fchk <<
" has been created for check." << endl;
380 assert( icell <
getLayer(ilay)->getNcell() );
382 int iwire = m_wiretable[ilay][icell];
384 return m_pwire[iwire];
388 for(
int i=0; i<96; i++){
389 alignPar[i] = m_alignPar[i];
392 for(
int k=0; k<8; k++){
393 alignPar[k+m_iRXf] *= 1000.0;
394 alignPar[k+m_iRYf] *= 1000.0;
395 alignPar[k+m_iRZf] *= 1000.0;
double sin(const BesAngle a)
double cos(const BesAngle a)
bool initialize(double rot)
void check(std::string fchk) const
MdcCosGeom(std::string fwireconf, std::string fAlign)
const void getAlignPar(double alignPar[]) const
const MdcCosLayer * getLayer(int ilay) const
const MdcCosWire * getWire(int iwire) const
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)