Home > lattice > Converters > AT2G4BL > ATtoG4BL.m

ATtoG4BL

PURPOSE ^

function [outtext]=ATtoG4BL(P_0,particle,folder)

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 function [outtext]=ATtoG4BL(P_0,particle,folder)
 tansform AT structure into G4BL input file.
 
 Simone Maria Liuzzo PhD@ESRF 11-oct-2012

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % function [outtext]=ATtoG4BL(P_0,particle,folder)
0002 % tansform AT structure into G4BL input file.
0003 %
0004 % Simone Maria Liuzzo PhD@ESRF 11-oct-2012
0005 
0006 %load ../../../routines/OptimizationsN4/StartVal0.mat
0007 %load ../../../routines/OptimizedipolesV173/bendoptStartV173.mat
0008 %arc=LOW_EMIT_RING;
0009 %arc=mergedoublesDipole(arc,'BPI5');
0010 %arc=mergedoublesDipole(arc,'BPI6');
0011 %E0=arc{1}.('Energy');
0012 %multbend=2;
0013 %nameG4bllat='G4blnewlat';
0014 % arc=LOW_EMIT_RING;
0015 % E0=6.039*1e9;
0016 
0017   load ../../../LATTICES/perfmach78.mat
0018   arc=THERING;%(1:51);
0019   multbend=0;
0020   nameG4bllat='ESRFlat';
0021 
0022  sector=1;
0023 % E0=6.039*1e9;
0024 
0025 format longe
0026 
0027 StepLength=10; % [mm] default is 10mm
0028 
0029 Nevents=1; % e+ events and e- events.
0030 disp(['writing G4BL file to simulate: ' num2str(Nevents) ' e-'])
0031 det=0;
0032 SR=0;
0033 RINGFLAG=1;
0034 fringON=0;
0035 
0036 TotLength=findspos(arc,length(arc)+1); %[mm]
0037 
0038 beamstart=0;
0039 
0040 % beams shapes
0041 
0042 % diversi da zero muore!!! sestupoli??? KL? BRHO?
0043 sX=1*1e-3; %[mm]
0044 sY=1*1e-3; %[mm]
0045 sXp=0*1e-6; %[rad]
0046 sYp=0*1e-6; %[rad]
0047 
0048 killval=1;
0049 
0050 
0051 P_0=sqrt((E0/1e9)^2-(0.511/1e6)^2); % transform in momentum
0052 particle='e-';
0053 
0054 sxt=1;
0055 quadH=-1;  % e- want - sign
0056 
0057 Brho=3.3356409519815205*P_0; % positron and opposite rotation
0058 
0059 
0060 bigmondo=[...
0061     ...'box mondo height=10000 width=3000000 length=3000000 material=Vacuum \n'...
0062     ];
0063 
0064 ShynRadstarter=[
0065     '#### no net displacement beam generator for radiation.\n'...
0066     'genericbend B1  fieldLength=2 fieldWidth=300  fieldHeight=300  ironLength=2 ironWidth=330  ironHeight=330  fringe=0   By=0.1 ironColor=0.5,.0,.0 kill=1 \n'...
0067     'genericbend B2  fieldLength=1 fieldWidth=300  fieldHeight=300  ironLength=1 ironWidth=330  ironHeight=330  fringe=0   By=-0.1 ironColor=1,.0,.0 kill=1 \n'...
0068     'genericbend B3  fieldLength=1 fieldWidth=300  fieldHeight=300  ironLength=1 ironWidth=330  ironHeight=330  fringe=0   By=-0.1 ironColor=0.5,.0,.0 kill=1 \n'...
0069     'genericbend B4  fieldLength=1 fieldWidth=300  fieldHeight=300  ironLength=1 ironWidth=330  ironHeight=330  fringe=0   By=0.1 ironColor=1,.0,.0 kill=1\n'...
0070     '\n'...
0071     'place B1 z=0\n'...
0072     'place B2 z=1.5\n'...
0073     'place B3 z=2.5\n'...
0074     'place B4 z=3.5\n'...
0075     ];
0076 
0077 % beam parameters
0078 posbeam=[ ' beam gaussian particle=' particle ...
0079     ' beamZ=' num2str(beamstart) ...
0080     ' beamX=' num2str(+0*1.532845188e-07,15) ...
0081     ' beamXp=' num2str(+0*1.683548689e-07,15) ...
0082     ' rotation=Y' num2str(0*180)... rotate to head back
0083     '  nEvents=' num2str(Nevents) ' '... % nEvents=10
0084     '    sigmaX=' num2str(sX,15) ...
0085     ' sigmaY=' num2str(sY,15)...
0086     ' sigmaXp=' num2str(sXp,15)...
0087     ' sigmaYp=' num2str(sYp,15) ' '...
0088     '    meanMomentum=' num2str(P_0*1000,15) ' sigmaP=0'...
0089     ' meanT=0 sigmaT=0 \n'...
0090     'trackcolor reference=1,1,1 \n'...
0091     ShynRadstarter...
0092     ];
0093 
0094 head=['physics QGSP synchrotronRadiation=' num2str(SR) '\n'...
0095     'start x=0 y=0 z=' num2str(beamstart) ' radiusCut=0.001 ring=' num2str(RINGFLAG) '\n'...
0096     'reference particle=' particle ' referenceMomentum=' num2str(P_0*1000,15) ' noEloss=1'...
0097     ' beamXp=0 beamYp=0 '...
0098     ' tuneMomentum=' num2str(P_0,15) '\n'...
0099     'box BeamVis width=200.0 height=200.0 length=0.1 material=Vacuum color=1,0,0 kill=1 \n'...
0100     'trace nTrace=' num2str(2*Nevents) ' oneNTuple=1 format=root \n'...ascii
0101     ' param eventTimeLimit=60*8\n'... %  8 minutes maximum time for one simulation
0102     ' trackcuts keep=e+,e-,gamma maxTime=1000000*10\n' ... %ns --> 4micros
0103     ];
0104 % x damping time= 0.26700741E-01 => 15% =~ 40ms = 40*10^6 ns
0105 
0106 
0107 defQ= ['virtualdetector Det radius=10.0 length=' num2str(2*StepLength)...
0108     ' color=0,.2,.0 referenceParticle=1 format=rootExtended\n'];
0109 defS='';
0110 defB='';
0111 ord=1;
0112 plac={};
0113 defined={};
0114 d=1;
0115 
0116 
0117 quadr=unique([findcells(arc,'Class','Quadrupole') findcells(arc,'BetaCode','QP') ]);
0118 sextu=unique([findcells(arc,'Class','Sextupole') findcells(arc,'BetaCode','SX') ]);
0119 dipol=unique([findcells(arc,'Class','Dipole') findcells(arc,'BetaCode','DI') ]);
0120 octup=unique([findcells(arc,'Class','Octupole') findcells(arc,'BetaCode','OC') ]);
0121 
0122 for i=1:length(quadr)
0123     %genericquad QDpi fieldLength=280 apertureRadius=101.5 ironRadius=381 \
0124     %    ironLength=250 ironColor=0.6,.0,.6 kill=' num2str(killval) ' gradient=$KQDpi
0125     %
0126     S=findspos(arc,quadr(i))+arc{quadr(i)}.('Length')/2;
0127     N=arc{quadr(i)}.('FamName');
0128     L=arc{quadr(i)}.('Length');
0129     K=arc{quadr(i)}.('PolynomB')(2);
0130     
0131     if sum(strcmp(N,defined))==0;
0132         inrad=60; % quarupole size
0133         outrad=70;
0134         
0135         
0136         defQ=[ defQ ...
0137             ' genericquad ' N ' '...
0138             ' fieldLength=' num2str(L*1000,15) ... % mm
0139             ' apertureRadius=' num2str(inrad,15) ' '...
0140             ' ironRadius=' num2str(outrad,15) ' '...
0141             ' ironLength=' num2str(L*1000,15) ' '...
0142             ' ironColor=0/255,191/255,255/255 kill=' num2str(killval) ' '...
0143             ' fringe=' num2str(0*fringON) ...
0144             ' gradient=' num2str(quadH*K*Brho,15) ' '...  K
0145             ' maxStep=' num2str(StepLength/2)  ...
0146             '\n']; %#ok<*AGROW>
0147         
0148         % add to already defined
0149         defined{d}=N;
0150         d=d+1;
0151     end
0152     
0153     if (ord/2-floor(ord/2))==(det-1) % set 0 to place a detector in every quadrupole.
0154         plac{ord}=['place ' N ' parent=  z=' num2str(S*1000,15)...
0155             ' coordinates=centerline'...
0156             '\n'...
0157             'place ' 'Det' ...
0158             ' rename=DET# '...
0159             ' parent=  z=' num2str((S)*1000)...
0160             ' coordinates=centerline '...
0161             '\n']; %#ok<*SAGROW>
0162     else
0163         plac{ord}=['place ' N ' parent=  z=' num2str(S*1000,15)...
0164             ' coordinates=centerline'...
0165             '\n']; %#ok<*SAGROW>
0166     end
0167     
0168     ord=ord+1;
0169 end
0170 
0171 for i=1:length(sextu)
0172     %multipole SF1 fieldLength=150 apertureRadius=101.5 ironRadius=381 \
0173     %    ironLength=140 ironColor=0,.6,.6 kill=' num2str(killval) ' sextupole=$KSF1
0174     S=findspos(arc,sextu(i))+arc{sextu(i)}.('Length')/2;
0175     N=arc{sextu(i)}.('FamName');
0176     L=arc{sextu(i)}.('Length');
0177     %Ord=arc{sextu(i)}.('MaxOrder');
0178     K=2*arc{sextu(i)}.('PolynomB')(3);
0179     
0180     if sum(strcmp(N,defined))==0;
0181         inrad=60;
0182         outrad=70;
0183         
0184         
0185         defS=[ defS ...
0186             ' multipole ' N ' '...
0187             ' fieldLength=' num2str(L*1000-1e6,15) ... % mm
0188             ' apertureRadius=' num2str(inrad,15) ' '...
0189             ' ironRadius=' num2str(outrad,15) ' '...
0190             ' ironLength=' num2str(L*1000,15) ' '...
0191             ' ironColor=173/255,255/255,47/255 kill=' num2str(killval) ' '...
0192             ' fringe=' num2str(0*fringON) ...
0193             ' maxStep=' num2str(StepLength/2)  ...
0194             ' sextupole=' num2str(sxt*K*Brho,15) ' '... K2
0195             '\n'];
0196         % add to already defined
0197         defined{d}=N;
0198         d=d+1;
0199     end
0200     
0201     
0202     plac{ord}=['place ' N ' parent=  z=' num2str(S*1000,15)...
0203         ' coordinates=centerline '...
0204         '\n']; %#ok<*SAGROW>
0205     ord=ord+1;
0206     
0207 end
0208 
0209 totA=0;
0210 for i=1:length(dipol)
0211     
0212     %genericbend BHer fieldWidth=1660 fieldHeight=200 fieldLength=5400 \
0213     %    ironColor=1,0,0 ironWidth=1828 ironHeight=1320 ironLength=5000 \
0214     % kill=' num2str(killval) ' By=0.2778157677856496
0215     %tune B1 z0=100 z1=3000 initial=-0.6500 step=0.01 expr=Px1/Pz1 \
0216     %tolerance=0.000001
0217     %genericbend B fieldWidth=500 fieldHeight=500 fieldLength=500 \
0218     %ironWidth=800 ironHeight=800 ironLength=500 \
0219     %fieldMaterial=Vacuum place B z=2000 rename=B1 rotation=Y15 By=B1
0220     
0221     S=findspos(arc,dipol(i))+arc{dipol(i)}.('Length')/2;
0222     N=arc{dipol(i)}.('FamName');
0223     L=arc{dipol(i)}.('Length');
0224     %Ord=arc{sextu(i)}.('MaxOrder');
0225     A=arc{dipol(i)}.('BendingAngle');
0226     K=quadH*arc{dipol(i)}.('PolynomB')(2);
0227 
0228     tmpmultibend=multbend;
0229     if K==0
0230         multbend=0;
0231     end
0232     
0233     if multbend==0
0234         split=1;
0235     else
0236         split=1; %make 'split' parts of a single magnet
0237     end
0238     L=L/split;
0239     A=A/split;
0240     K=K/split;
0241     totA=totA+A;
0242     
0243     if sum(strcmp(N,defined))==0 % if not defined, define.
0244         Fw=240*1.0;
0245         Fh=70;
0246         Iw=10+Fw;
0247         Ih=30+Fh;
0248         
0249         defB=[ defB ...
0250             '\n param B' num2str(i) N '=' num2str(-Brho*A/L,15) '\n'...
0251             ];
0252         if multbend==0
0253             if sector==0
0254                 defB=[ defB ...
0255                     'genericbend ' N ' '...
0256                     ' fieldLength=' num2str(L*1000/split,15) ... % mm
0257                     ' fieldWidth=' num2str(Fw,15) ' '...
0258                     ' fieldHeight=' num2str(Fh,15) ' '...
0259                     ' ironLength=' num2str(L*1*1000/split,15) ... % mm
0260                     ' ironWidth=' num2str(Iw,15) ' '...
0261                     ' ironHeight=' num2str(Ih,15) ' '...' fringe=' num2str(fringON) ...
0262                     ' maxStep=' num2str(StepLength)  ...
0263                     ' By=' num2str(Brho*A/L,15)...' fieldColor=0.5,.1,.0 '...' By=$B' num2str(i) A ...
0264                     ' ironColor=1,.0,.0 kill=' num2str(killval) ' '...
0265                     '\n'...
0266                     ];
0267                 
0268             elseif sector==1
0269                 
0270                 defB=[ defB ...
0271                     'idealsectorbend ' N ' '...
0272                     ' fieldCenterRadius=' num2str((L/A)*1000,15) ' '...
0273                     ' fieldOuterRadius=' num2str((L/A)*1000+250,15) ' '...
0274                     ' fieldInnerRadius=' num2str((L/A)*1000-250,15) ' '...
0275                     ' fieldHeight=' num2str(Fh,15) ' '...
0276                     ' ironOuterRadius=' num2str((L/A)*1000+270,15) ... % mm
0277                     ' ironInnerRadius=' num2str((L/A)*1000-270,15) ' '...
0278                     ' ironHeight=' num2str(Ih,15) ' '...
0279                     ' maxStep=' num2str(StepLength)  ...' fringe=' num2str(fringON) ...
0280                     ' angle=' num2str(A*180/pi,15)...' fieldColor=0.5,.1,.0 '...' By=$B' num2str(i) A ...
0281                     ' By=' num2str(Brho*A/L,15)...
0282                     ' ironColor=1,.0,.0 kill=' num2str(killval) ' '...
0283                     '\n'...
0284                     ];
0285             end
0286             
0287         elseif multbend==1
0288              % multipole bend-quadrupole
0289             inrad=60;
0290             outrad=70;
0291             
0292             L=L * (2*sin(A/2))/A;  % Length of sector arc to length of rectangular element
0293             
0294             % define 1 slice
0295             defB=[ defB ...
0296                 'multipole ' N ' '...
0297                 ' fieldLength=' num2str(L*1000,15) ... % mm
0298                 ' ironLength=' num2str(L*1000,15) ... % mm
0299                 ' ironRadius=' num2str(outrad,15) ... % mm
0300                 ' apertureRadius=' num2str(inrad,15) ' '...
0301                 ' fringe=' num2str(0*fringON) ...
0302                 ' maxStep=' num2str(StepLength,15)  ...
0303                 ' dipole=' num2str(Brho*A/L,15)...' fieldColor=0.5,.1,.0 '...' By=$B' num2str(i) A ...
0304                 ' quadrupole=' num2str(Brho*K,15)...
0305                 ' ironColor=1,.0,.0 kill=' num2str(killval) ' '...
0306                 '\n'...
0307                 ];
0308             
0309             % add to already defined
0310             defined{d}=N;
0311             d=d+1;
0312                 
0313         elseif multbend==2
0314              % misalignaed quadrupole
0315             inrad=450;
0316             outrad=500;
0317             
0318             L=L * (2*sin(A/2))/A;  % Length of sector arc to length of rectangular element
0319             % L=L * 0.99;
0320             % define 1 slice
0321             defB=[ defB ...
0322                 ' genericquad ' N ' '...
0323                 ' fieldLength=' num2str(L*1000,15) ... % mm
0324                 ' apertureRadius=' num2str(inrad,15) ' '...
0325                 ' ironRadius=' num2str(outrad,15) ' '...
0326                 ' ironLength=' num2str(L*1000,15) ' '...
0327                 ' ironColor=0/255,191/255,255/255 kill=' num2str(killval) ' '...
0328                 ' fringe=' num2str(0*fringON) ...
0329                 ' gradient=' num2str(K*Brho,15) ' '...  K
0330                 ' maxStep=' num2str(StepLength/2)  ...
0331                 ' ironColor=1,.0,.0 kill=' num2str(killval) ' '...
0332                 '\n'...
0333                 ];
0334             
0335             % add to already defined
0336             defined{d}=N;
0337             d=d+1;
0338         
0339         end
0340     end
0341     
0342     disp(totA)
0343     
0344     dipposstr=[];
0345     
0346     for spl=1:split
0347         S=findspos(arc,dipol(i))+(L*(spl-1/2));
0348         if multbend==1
0349             
0350             dipposstr=[ dipposstr ' \n'...
0351                 'place ' N ' parent=  z=0+' num2str(0) '+0+' num2str(S*1000,15) ...
0352                 ' x=' num2str(0*L/2*tan(A/2)*1000,15) ''... % move in by a sagitta amount
0353                 ' coordinates=centerline'...' \n'...
0354                 ' rotation=Y' num2str(0*A*180/pi/2,15)...' rename=' N ' \n'...
0355                 ...' By=B' num2str(i) N ...
0356                 '\n' ...
0357                 ' corner C' num2str(i) ' z=0+' num2str(0) '+0+' num2str((S)*1000,15) ...-L/2
0358                 ' rotation=Y' num2str(A*180/pi,15)  ' radiusCut=100 radius='  num2str((L/A)*1000,15) '\n'...'#corner' ' parent=  z=' num2str((B{2}(i)+B{4}(i)/2)*1000,15) ... ' rotation=Y' num2str(B{3}(i)*180/pi/2,15) ' \n'...
0359                 '\n'
0360                 ...' cornerarc' ' z=0+' num2str(0) '+0+' num2str((S)*1000,15) ...-L/2
0361                 ...' angle=' num2str(A*180/pi,15)  ' centerRadius='  num2str((L/A)*1000,15) '\n'...'#corner' ' parent=  z=' num2str((B{2}(i)+B{4}(i)/2)*1000,15) ... ' rotation=Y' num2str(B{3}(i)*180/pi/2,15) ' \n'...
0362                 ...'\n'...
0363                 ]; %#ok<*SAGROW>
0364         elseif multbend==2
0365             
0366             dipposstr=[ dipposstr ' \n'...
0367                 'place ' N ' parent=  z=0+' num2str(0) '+0+' num2str(S*1000,15) ...
0368                 ' x=' num2str(-A/(K*L)*1000,15) ''... % move in by a sagitta amount
0369                 ' coordinates=centerline'...' \n'...
0370                 ' rotation=Y' num2str(A*180/pi/2,15)...' rename=' N ' \n'...
0371                 ...' By=B' num2str(i) N ...
0372                 '\n' ...
0373                 ...' corner C' num2str(i) ' z=0+' num2str(0) '+0+' num2str((S)*1000,15) ...-L/2
0374                 ...' rotation=Y' num2str(A*180/pi,15)  ' radiusCut=100 radius='  num2str((L/A)*1000,15) '\n'...'#corner' ' parent=  z=' num2str((B{2}(i)+B{4}(i)/2)*1000,15) ... ' rotation=Y' num2str(B{3}(i)*180/pi/2,15) ' \n'...
0375                 ...'\n'
0376                 ' cornerarc' ' z=0+' num2str(0) '+0+' num2str((S)*1000,15) ...-L/2
0377                 ' angle=' num2str(A*180/pi,15)  ' centerRadius='  num2str((L/A)*1000,15) '\n'...'#corner' ' parent=  z=' num2str((B{2}(i)+B{4}(i)/2)*1000,15) ... ' rotation=Y' num2str(B{3}(i)*180/pi/2,15) ' \n'...
0378                 '\n'...
0379                 ]; %#ok<*SAGROW>
0380             
0381         elseif multbend==0
0382             if sector==0
0383                 % %  rectangular
0384                 dipposstr=[ dipposstr ' \n'...
0385                     'place ' N ' parent=  z=0+' num2str(0) '+0+' num2str(S*1000,15) ...
0386                     ' x=' num2str(L/2*tan(A/2)*1000,15) ''... % move in by a sagitta amount
0387                     ' coordinates=centerline'...' \n'...
0388                     ' rotation=Y' num2str(A*180/pi/2,15)...' rename=' N ' \n'...
0389                     ...' By=B' num2str(i) N ...
0390                     '\n' ...
0391                     ' cornerarc' ' z=0+' num2str(0) '+0+' num2str((S-L/2)*1000,15) ...
0392                     ' angle=' num2str(A*180/pi,15)  ' centerRadius='  num2str((L/A)*1000,15) '\n'...'#corner' ' parent=  z=' num2str((B{2}(i)+B{4}(i)/2)*1000,15) ... ' rotation=Y' num2str(B{3}(i)*180/pi/2,15) ' \n'...
0393                     '\n'...
0394                     ]; %#ok<*SAGROW>
0395                 
0396             elseif sector==1
0397                 % % sector
0398                 S=findspos(arc,dipol(i))+(L*(spl-1));
0399                 
0400                 
0401                 dipposstr=[ dipposstr ' \n'...
0402                     'place ' N ' parent=  z=0+' num2str(0) '+0+' num2str(S*1000,15) ...
0403                     ' x=' num2str(0*L/2*tan(A/2)*1000,15) ''... % move in by a sagitta amount
0404                     ' coordinates=centerline'...' \n'...
0405                     ' rotation=Y' num2str(0*(A*180/pi)/2,15)...' rename=' N ' \n'...
0406                     ...' By=B' num2str(i) N ...
0407                     '\n' ...
0408                     ' cornerarc' ' z=0+' num2str(0) '+0+' num2str((S)*1000,15) ... z value is the front face of the magnet
0409                     ' angle=' num2str(A*180/pi,15)  ' centerRadius='  num2str((L/A)*1000,15) '\n'...'#corner' ' parent=  z=' num2str((B{2}(i)+B{4}(i)/2)*1000,15) ... ' rotation=Y' num2str(B{3}(i)*180/pi/2,15) ' \n'...
0410                     '\n'...
0411                     ]; %#ok<*SAGROW>
0412             end
0413         end
0414     end
0415     plac{ord}=dipposstr;
0416     ord=ord+1;
0417     multbend=tmpmultibend;
0418 
0419 end
0420 
0421 TotLength
0422 
0423 RF_on=0;
0424 % plac RFC
0425 %length[m]        voltage[MV]                lag          freq[MHz]             harmon
0426 %0.501777                0.6           0.424389        476.0054439               1998
0427 RF=['pillbox RFC maxGradient=' num2str(RF_on*0.6/0.501777,15) ...
0428     ' color=0.5,0.5,0 frequency=0.4760054439 innerLength=501.777 '...
0429     ' phaseAcc=0.424389 wallThick=100 innerRadius=1000\n'];
0430 RF1pos=0*1000;
0431 plac{ord}=['  # place RFC z=' num2str(RF1pos) '\n'];
0432 
0433 ippos=0;
0434 Dumppos=beamstart-1;
0435 
0436 positions=[findspos(arc,quadr)'; findspos(arc,sextu)'; findspos(arc,dipol)'; (RF1pos-TotLength)/1000; (beamstart-TotLength)/1000;(TotLength/2)/1000;TotLength*2];
0437 
0438 posString=[];
0439 for i=1:length(positions)-1
0440     posString=[posString num2str(positions(i)*1000) ','];
0441 end
0442 posString=[posString num2str(positions(i)*1000)];
0443 
0444 twissH=['profile ' ...
0445     'zloop=' num2str(beamstart*0) ':' num2str(TotLength*3) ':1000 '...
0446     ...' z=' posString ...
0447     ' file=twissLER particle=' particle ...
0448     ' coordinates=centerline\n']; %   ' coordinates=reference\n'];
0449 
0450 %twissH=['profile zloop=' num2str(beamstart*0) ':' num2str(beamstart+TotLength*2.5) ':1000 file=twissHER particle=' particle ...
0451 %      ' coordinates=centerline\n']; %   ' coordinates=reference\n'];
0452 
0453 dump=['tubs DUMP innerRadius=0.01 outerRadius=300 length=10 kill=1 material=Cu color=0.2,0.2,0\n '...
0454     ];
0455 
0456 plac{ord+1}=['# place ip parent=  z=' num2str(ippos,15) ' \n' ];
0457 plac{ord+2}=[...
0458     posbeam 'place BeamVis z=' num2str(beamstart,15) ' y=101 \n'
0459     ];
0460 plac{ord+3}=['# place DUMP parent=  z=' num2str(Dumppos,15) ' \n'];
0461 
0462 %%%%%%                             RF1         RF2                   beam
0463 [s,ind]=sort([findspos(arc,quadr)'; findspos(arc,sextu)'; findspos(arc,dipol)'; RF1pos/1000;beamstart/1000;Dumppos/1000;TotLength/1000]); % in m
0464 
0465 
0466 R=[head defQ defS defB RF dump];
0467 RPlace=[plac{ind}];
0468 
0469 
0470 outtext=char([...
0471     bigmondo ...
0472     ... definitions
0473     R ...  RING
0474     RPlace ...  Place RING magnets
0475     ' particlecolor e-=0,0,1 e+=1,0,0 \n'...  electron is blue and positron is red.
0476     ...'g4ui when=4 ''/vis/open OGL''\n'...
0477     'g4ui when=4 ''/vis/viewer/set/viewpointThetaPhi 90 90''\n'...
0478     'g4ui when=4 ''/vis/viewer/set/style wireframe''\n'...
0479     'g4ui when=4 ''/run/beamOn ' num2str(Nevents*2) ' ''\n'...
0480     ... 'g4ui when=4 ''vis/ogl/printEPS''\n'...
0481     ]);
0482 % lattice 'g4ui when=4 ''/vis/viewer/set/style wireframe''\n'...    'g4ui ''/run/beamOn 20''\n'...
0483 out=fopen(nameG4bllat,'w+');
0484 fprintf(out,outtext);
0485 
0486 fclose('all');
0487 % clear defQ
0488 % clear defS
0489 % clear defB
0490 % clear plac ind ord
0491 % clear defined
0492 disp('--- DONE ---')

Generated on Thu 24-Aug-2017 18:47:33 by m2html © 2005