0001 function rerr=setBpmOffsetOnDipoleRef(rerr)
0002
0003
0004
0005
0006 inddip=findcells(rerr,'BendingAngle');
0007 indbpm=findcells(rerr,'Class','Monitor');
0008
0009 [X,Y,~,T,~,~,bpmerr]=GetExistingErrors(rerr,inddip);
0010
0011 indbpm=[indbpm(end) indbpm indbpm(1)];
0012
0013 sposBPM=findspos(rerr,indbpm);
0014 sposDip=findspos(rerr,inddip);
0015
0016 offx=interp1(sposDip,X,sposBPM);offx(isnan(offx))=0;
0017 offy=interp1(sposDip,Y,sposBPM);offy(isnan(offy))=0;
0018 offr=interp1(sposDip,T,sposBPM);offr(isnan(offr))=0;
0019
0020 rerr=setcellstruct(rerr,'Offset',indbpm(2:end-1),bpmerr.offsetx-offx(2:end-1),1,1);
0021 rerr=setcellstruct(rerr,'Offset',indbpm(2:end-1),bpmerr.offsetx-offy(2:end-1),1,2);
0022 rerr=setcellstruct(rerr,'Rotation',indbpm(2:end-1),bpmerr.rotation-offr(2:end-1)*0,1,1);
0023
0024 disp('BPMs on dipole positions curve');
0025
0026 return
0027