11 #include "openFile.tpl"
27 if ( (
side ==
beam2) && (
ip == 1) ) {
return 26658.88320;}
28 if ( (
side ==
beam2) && (
ip == 5) ) {
return 13329.593967;}
30 if ( (
side ==
beam1) && (
ip == 5) ) {
return 13329.289233;}
38 if ( (
side ==
beam2) && (
ip == 1) ) {
return 13329.28923;}
39 if ( (
side ==
beam2) && (
ip == 5) ) {
return 13329.59397;}
40 if ( (
side ==
beam1) && (
ip == 1) ) {
return 13329.59397;}
41 if ( (
side ==
beam1) && (
ip == 5) ) {
return 13329.28923;}
48 if ( (
side ==
beam2) && (
ip == 5) ) {
return 13329.593967;}
50 if ( (
side ==
beam1) && (
ip == 5) ) {
return 13329.289233;}
75 const int& IP = cData.
IP;
76 const double& apermb = cData.
apermb;
77 const double& brho = cData.
brho;
84 std::ifstream& myMags = *magfile;
89 while (myMags.peek() ==
'@' || myMags.peek() ==
'*' || myMags.peek() ==
'$')
91 myMags.ignore(1000,
'\n');
100 double endpos=0, maglength=0, K0L=0, K1L=0, K2L=0, K3L=0, HKICK=0, VKICK=0;
101 float BETX=0,ALFX=0,MUX=0,DX=0,DPX=0,
X=0,PX=0,BETY=0,ALFY=0,MUY=0,DY=0,DPY=0,
Y=0,PY=0,A1=0,A2=0,A3=0,A4=0;
103 std::string magname,magsort, basicmag ;
105 std::string aperture;
109 myMags>>magname>>magsort>>endpos>>maglength>>K0L>>K1L>>K2L>>K3L>>HKICK>>VKICK
110 >>BETX>>ALFX>>MUX>>DX>>DPX>>
X>>PX>>BETY>>ALFY>>MUY>>DY>>DPY>>
Y>>PY
111 >>aperture>>A1>>A2>>A3>>A4;
113 else if( magver==2 or magver==3 )
115 myMags>>magname>>magsort>>basicmag>>endpos>>maglength>>HKICK>>VKICK>>K0L
116 >>K1L>>K2L>>K3L>>
X>>
Y>>PX>>PY>>BETX>>BETY>>ALFX>>ALFY
117 >>MUX>>MUY>>DX>>DY>>DPX>>DPY>>aperture>>A1>>A2>>A3>>A4;
126 if(std::fabs(K0L)==0.000188) K0L=K0L*188.175/188.0 ;
127 if(std::fabs(K0L)==0.001129) K0L=K0L*1129.049/1129. ;
128 if(std::fabs(K1L)==0.055577) K0L=K0L*55576.561/55577. ;
129 if(std::fabs(K1L)==0.047986) K0L=K0L*47986.041/47986. ;
130 if(std::fabs(VKICK)==0.00020) VKICK=VKICK*20.171/20. ;
131 if(std::fabs(VKICK)==0.00019) VKICK=VKICK*19.17/19. ;
134 double dist = centreIP - endpos + 0.5*maglength ;
136 float adist=std::fabs(dist) ;
141 if ( magver == 1 or magver == 2 )
145 if( dist > 0. ) {
continue;}
146 if( adist > absZMagMax ) {
break;}
150 if( adist > absZMagMax ) {
continue;}
151 if ( dist <= 0. ) {
break;}
154 else if( magver == 3 )
156 if( dist > 0. ) {
continue;}
157 if( adist > absZMagMax ) {
break;}
161 double magstrength = 0;
168 magstrength = -magstrength;
176 assert(maglength > 0.);
177 magstrength = std::fabs(brho*magstrength/maglength);
182 magstrength = -HKICK;
193 double mmagcen = -dist;
204 int mmagapertype = 0;
206 if(aperture ==
"\"NONE\"")
210 else if(aperture ==
"\"CIRCLE\"" && A1 == 0.)
214 else if(aperture ==
"\"CIRCLE\"" && A1 > 0.)
218 else if(aperture ==
"\"RECTELLIPSE\"")
222 else if(aperture ==
"\"OCTAGON\"")
228 std::stringstream sstr;
229 sstr<<
" Unknown magnet aperture type "<<aperture<<
'\n' ;
230 throw std::runtime_error(sstr.str().c_str());
247 int pos = magname.find(
"MB.");
250 A3=apermb; A4=apermb;
276 magnets.push_back(mptr);
278 std::sort(magnets.begin(), magnets.end(), absZGreater< Magnet::ConstPtr_t >);