Changeset 32 in MML for trunk


Ignore:
Timestamp:
Apr 9, 2014, 6:01:33 PM (10 years ago)
Author:
zhangj
Message:

To display the orbits but not 6D coordinates at the BPMs of the transfer line.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/machine/THOMX/readme

    r31 r32  
    7070----
    717109/04/2014
     72(1)
    7273    Test the machine mode in TLinit.m & thomxinit.m
    7374
    7475This is a very important command!!!!!!!!!!!
     76
     77
     78(2) Need to set the crunch & roll parameters of BPMs in the future...
     79
    7580-----
  • trunk/mml/at/getpvmodel.m

    r31 r32  
    6767% Jianfeng Zhang @ LAL, 09/04/2014
    6868%  Get the correct orbits at the position of BPMs in the transfer line.
    69 %
     69%  Maybe there is a potential bug for the multi-turn pass of the transfer line???
    7070%%
    7171
     
    260260
    261261submachinetype = getfamilydata('SubMachine');
    262 if(any(strcmpi(Family,{'BPMx','BPMz','BPMx'}))&&...
     262if(any(strcmpi(Family,{'BPMx','BPMz','BPMy'}))&&...
    263263        any(strcmpi(submachinetype,{'TL','Transport'})))
    264264
     
    999999            %AM = AM + 1e-3*randn(length(AM),1);
    10001000
     1001           
     1002           
     1003            %
     1004            % Modified by Jianfeng Zhang @ LAL, 09/04/2014
     1005            % to get the correct orbit of the BPMs at the transfer line
     1006            % using the functions: getam('BPMx/z') & getx/y.
     1007            %
     1008            % Need to set the corrector crunch & roll values of the BPMs
     1009            % in the future...
     1010            %
     1011            % get the horizontal orbit at the horizontal BPM
     1012           if(any(strcmpi(Family,{'BPMx'}))&&...
     1013            any(strcmpi(submachinetype,{'TL','Transport'})))
     1014                       % Roll and Crunch are corrected here (BPM gain errors are corrected in real2raw/raw2real)
     1015               
     1016                       % Only corrector for gain/roll errors is using a ML family
     1017                       % Roll and Crunch are corrected here (BPM gain errors are corrected in real2raw/raw2real)
     1018
     1019                        [ATIndexList, isort] = sort(ATIndexList);
     1020                   
     1021                    NDevices = length(ATIndexList);
     1022                    for i = 1:NDevices,
     1023                        if isfield(THERING{ATIndexList(i)}, 'GCR')
     1024                            GCR(i,:) = THERING{ATIndexList(i)}.GCR;
     1025                        else
     1026                            if GCRFlag
     1027                                if i == 1
     1028                                    Crunch = getcrunch(Family, Field, DeviceList);
     1029                                    Roll = getroll(Family, Field, DeviceList);
     1030                                end
     1031                                m = gcr2loco(1, 1, Crunch(i), Roll(i));
     1032                                GCR(i,:) = [1 1 Crunch(i) Roll(i)];
     1033                            else % Laurent
     1034                                GCR(i,:) = [1 1 0 0];
     1035                            end
     1036                        end
     1037                    end
     1038
     1039                    x = AM(:,:,1); %meters
     1040                    y = AM(:,:,3); %meters
     1041                   
     1042                   
     1043                    if NoiseFlag
     1044                        x = x + randncut(size(x))*BPMsigma;
     1045                        y = y + randncut(size(y))*BPMsigma;
     1046                    end
     1047
     1048                    AM = ((x - GCR(:,3) .* y) .* cos(GCR(:,4)) + (y + GCR(:,3) .* x) .* sin(GCR(:,4))) ./ sqrt(1-GCR(:,3).^2);
     1049
     1050                    % Same as:
     1051                    %Crunch = GCR(:,3);
     1052                    %Roll = GCR(:,4);
     1053                    %a = ( Crunch .* sin(Roll) + cos(Roll)) ./ sqrt(1 - Crunch.^2);
     1054                    %b = (-Crunch .* cos(Roll) + sin(Roll)) ./ sqrt(1 - Crunch.^2);
     1055                    %AM = a .* x + b .* y;
     1056%                 else
     1057%                     AM = Orbit(1,:)';
     1058%               
     1059           
     1060    AM(isort,:) = AM;
     1061
     1062           end
     1063           
     1064           
     1065       
     1066                   
     1067       % get the vertical orbit at the bpms of the transfer line
     1068if(any(strcmpi(Family,{'BPMz','BPMy'}))&&...
     1069        any(strcmpi(submachinetype,{'TL','Transport'})))
     1070              %  if isfamily(Family, Field)
     1071                    % Only corrector for gain/roll errors is using a ML family
     1072                    % Roll and Crunch are corrected here (BPM gain errors are corrected in real2raw/raw2real)
     1073                 
     1074                    [ATIndexList, isort] = sort(ATIndexList);
     1075                   
     1076                    for i = 1:length(ATIndexList)
     1077                        if isfield(THERING{ATIndexList(i)}, 'GCR')
     1078                            GCR(i,:) = THERING{ATIndexList(i)}.GCR;
     1079                        else
     1080                            if GCRFlag
     1081                                GCR(i,:) = [1 1 0 0];  % [Gx Gy Crunch Roll]
     1082                                if i == 1
     1083                                    Crunch = getcrunch(Family, Field, DeviceList); %Laurent
     1084                                    Roll = getroll(Family, Field, DeviceList); % Laurent
     1085                                end
     1086                                m = gcr2loco(1, 1, Crunch(i), Roll(i));
     1087                                GCR(i,:) = [1 1 Crunch(i) Roll(i)];
     1088                            else % Laurent
     1089                                GCR(i,:) = [1 1 0 0];
     1090                            end
     1091                        end
     1092                    end
     1093
     1094                    x = AM(:,:,1);
     1095                    y = AM(:,:,3);
     1096                   
     1097                    if NoiseFlag
     1098                        x = x + randn(size(x))*1e-7;
     1099                        y = y + randn(size(y))*1e-7;
     1100                    end
     1101
     1102
     1103                    AM = ((y - GCR(:,3) .* x) .* cos(GCR(:,4)) - (x + GCR(:,3) .* y) .* sin(GCR(:,4))) ./ sqrt(1-GCR(:,3).^2);
     1104
     1105                    % Same as:
     1106                    %Crunch = GCR(:,3);
     1107                    %Roll = GCR(:,4);
     1108                    %c = (-Crunch .* cos(Roll) - sin(Roll)) ./ sqrt(1 - Crunch.^2);
     1109                    %d = (-Crunch .* sin(Roll) + cos(Roll)) ./ sqrt(1 - Crunch.^2);
     1110                    %AM = c .* x + d .* y;
     1111%                 else
     1112%                     AM = Orbit(3,:)';
     1113%                 end
     1114%             elseif strcmpi(AT.ATType, 'ClosedOrbit')
     1115%                     AM = Orbit';
     1116%             end
     1117
     1118     
     1119
     1120
     1121             AM(isort,:) = AM;
     1122
     1123end       
     1124           
     1125           
     1126           
     1127           
    10011128        elseif strcmpi(AT.ATType, 'Septum')
    10021129
Note: See TracChangeset for help on using the changeset viewer.