source: MML/trunk/machine/SOLEIL/StorageRing/insertions/idMeasElecBeamVsUndParamVsBump.m @ 4

Last change on this file since 4 was 4, checked in by zhangj, 10 years ago

Initial import--MML version from SOLEIL@2013

File size: 2.7 KB
Line 
1function [resFileNamesBumpInf, ErrorFlag] = idMeasElecBeamVsUndParamVsBump(idName, undParams, undParamsBkg, freqBkgMeas, inclPerturbMeas, fileNameCore, dispData, bumpPlane, bumpValues, CM_IncrementList)
2%Measure e-beam COD at different undulator parameters (gap, phase or currents in main coils)
3%at different orbit bumps in the straight section where the ID is located,
4%assuming that there is no bump in the beginning
5%bumpPlane: 'H' or 'V'
6%bumpValues: {[x1 x2],[k1,k2,k3,...}}
7%   [x1 x2] indicates direction/quanta of e-beam displacement (should be small enaugh to ensure correct bump directly from setorbitbump);
8%   the actual bumps will be then k1*[x1 x2], k2*[x1 x2], k3*[x1 x2], ...
9%CM_IncrementList: e.g. [-2 -1 1 2] - will go directly to setorbitbump
10
11sleepTimeAfterBump_s = 20; %To steer
12resFileNamesBumpInf = {};
13BPM_Family = 'BPMx';
14CM_Family = 'HCOR';
15if(strcmp(bumpPlane, 'V') || strcmp(bumpPlane, 'Z') || strcmp(bumpPlane, 'Y'))
16    BPM_Family = 'BPMz';
17    CM_Family = 'VCOR';
18end
19
20undParStruct = idGetGeomParamForUndSOLEIL(idName);
21BPM_DeviceList = undParStruct.indRelBPMs;
22
23[CM_DeviceList, CM_QuantaSP, ErrorFlag] = idGetCorCurForOrbitBump(BPM_Family, BPM_DeviceList, bumpValues{1}, CM_Family, CM_IncrementList);
24if(ErrorFlag)
25    return;
26end
27
28arMultSP = bumpValues{2};
29numSP = length(arMultSP);
30
31%[CM_OrigSP, tout, DataTime, ErrorFlag] = getam(CM_Family, CM_DeviceList);
32%if(ErrorFlag)
33%    return;
34%end
35
36%Save correctors at the beginning (print to )
37CM_OrigSP = getsp(CM_Family, CM_DeviceList);
38CM_OrigSP_abs = getsp(CM_Family);
39
40CM_PrevSP = CM_OrigSP;
41CM_PrevSP = CM_PrevSP - CM_OrigSP; %To make "0"
42
43for i = 1:numSP
44    CM_NextSP = CM_QuantaSP*arMultSP(i);
45    %Relative bump:
46    if(stepsp(CM_Family, CM_NextSP - CM_PrevSP, CM_DeviceList))
47        return;
48    end
49    pause(sleepTimeAfterBump_s);
50    CM_PrevSP = CM_NextSP;
51
52    %Decorating filename core with bump information
53    fileNameCoreBump = strcat(fileNameCore, '_bump');
54    fileNameCoreBump = strcat(fileNameCoreBump, bumpPlane);
55        fileNameCoreBump = strcat(fileNameCoreBump, '_');
56    pairPos = arMultSP(i)*bumpValues{1};
57        fileNameCoreBump = strcat(fileNameCoreBump, idAuxNum2FileNameStr(pairPos(1)));
58    if(pairPos(2) ~= pairPos(1))
59        fileNameCoreBump = strcat(fileNameCoreBump, '_');
60        fileNameCoreBump = strcat(fileNameCoreBump, idAuxNum2FileNameStr(pairPos(2)));
61    end
62
63        [curFileNameStruct, ErrorFlag] = idMeasElecBeamVsUndParam(idName, undParams, undParamsBkg, freqBkgMeas, inclPerturbMeas, fileNameCoreBump, dispData);
64    if(ErrorFlag)
65        return;
66    end
67    resFileNamesBumpInf{i} = {pairPos, curFileNameStruct};
68end
69
70%Returning to the original state
71%stepsp(CM_Family, CM_OrigSP - CM_PrevSP, CM_DeviceList);
72setsp(CM_Family, CM_OrigSP_abs);
Note: See TracBrowser for help on using the repository browser.