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

Last change on this file since 4 was 4, checked in by zhangj, 11 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
40
41CM_PrevSP = CM_OrigSP;
42CM_PrevSP = CM_PrevSP - CM_OrigSP; %To make "0"
43
44for i = 1:numSP
45    CM_NextSP = CM_QuantaSP*arMultSP(i);
46    %Relative bump:
47    if(stepsp(CM_Family, CM_NextSP - CM_PrevSP, CM_DeviceList))
48        return;
49    end
50    pause(sleepTimeAfterBump_s);
51    CM_PrevSP = CM_NextSP;
52   
53    %Decorating filename core with bump information
54    fileNameCoreBump = strcat(fileNameCore, '_bump');
55    fileNameCoreBump = strcat(fileNameCoreBump, bumpPlane);
56        fileNameCoreBump = strcat(fileNameCoreBump, '_');
57    pairPos = arMultSP(i)*bumpValues{1};
58        fileNameCoreBump = strcat(fileNameCoreBump, idAuxNum2FileNameStr(pairPos(1)));
59    if(pairPos(2) ~= pairPos(1))
60        fileNameCoreBump = strcat(fileNameCoreBump, '_');
61        fileNameCoreBump = strcat(fileNameCoreBump, idAuxNum2FileNameStr(pairPos(2)));
62    end
63   
64        [curFileNameStruct, ErrorFlag] = idMeasElecBeamVsUndParam(idName, undParams, undParamsBkg, freqBkgMeas, inclPerturbMeas, fileNameCoreBump, dispData);
65    if(ErrorFlag)
66        return;
67    end
68    resFileNamesBumpInf{i} = {pairPos, curFileNameStruct};
69end
70
71%Returning to the original state
72%stepsp(CM_Family, CM_OrigSP - CM_PrevSP, CM_DeviceList);
73setsp(CM_Family, CM_OrigSP_abs);
Note: See TracBrowser for help on using the repository browser.