0001 function atclass = atguessclass(elem, varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 useclass=any(strcmpi(varargin,'UseClass'));
0012
0013 if isfield(elem,'BendingAngle')
0014 atclass='Bend';
0015 elseif isfield(elem,'Frequency')
0016 atclass='RFCavity';
0017 elseif isfield(elem,'KickAngle')
0018 atclass='Corrector';
0019 elseif isfield(elem,'Periodicity')
0020 atclass='RingParam';
0021 elseif isfield(elem,'Limits')
0022 atclass='Aperture';
0023 elseif isfield(elem,'PolynomB')
0024 if useclass && isfield(elem,'Class')
0025 atclass=elem.Class;
0026 elseif isfield(elem,'Length') && elem.Length~=0
0027 loworder=find(abs(elem.PolynomB(2:end))~=0,1);
0028 if isempty(loworder)
0029 atclass='Drift';
0030 elseif loworder==1
0031 atclass='Quadrupole';
0032 elseif loworder==2
0033 atclass='Sextupole';
0034 else
0035 atclass='Multipole';
0036 end
0037 else
0038 atclass='ThinMultipole';
0039 end
0040 elseif isfield(elem,'Lmatp')
0041 atclass='QuantDiff';
0042 elseif isfield(elem,'M66')
0043 if isfield(elem,'Tijk')
0044 atclass='MatrixTijkPass';
0045 else
0046 atclass='Matrix66';
0047 end
0048 elseif isfield(elem,'Length') && elem.Length~=0
0049 atclass='Drift';
0050 else
0051 if useclass && isfield(elem,'Class')
0052 atclass=elem.Class;
0053 else
0054 atclass='Marker';
0055 end
0056 end
0057
0058 end