[17] | 1 | function [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 | |
---|
| 11 | sleepTimeAfterBump_s = 20; %To steer |
---|
| 12 | resFileNamesBumpInf = {}; |
---|
| 13 | BPM_Family = 'BPMx'; |
---|
| 14 | CM_Family = 'HCOR'; |
---|
| 15 | if(strcmp(bumpPlane, 'V') || strcmp(bumpPlane, 'Z') || strcmp(bumpPlane, 'Y')) |
---|
| 16 | BPM_Family = 'BPMz'; |
---|
| 17 | CM_Family = 'VCOR'; |
---|
| 18 | end |
---|
| 19 | |
---|
| 20 | undParStruct = idGetGeomParamForUndSOLEIL(idName); |
---|
| 21 | BPM_DeviceList = undParStruct.indRelBPMs; |
---|
| 22 | |
---|
| 23 | [CM_DeviceList, CM_QuantaSP, ErrorFlag] = idGetCorCurForOrbitBump(BPM_Family, BPM_DeviceList, bumpValues{1}, CM_Family, CM_IncrementList); |
---|
| 24 | if(ErrorFlag) |
---|
| 25 | return; |
---|
| 26 | end |
---|
| 27 | |
---|
| 28 | arMultSP = bumpValues{2}; |
---|
| 29 | numSP = 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 ) |
---|
| 37 | CM_OrigSP = getsp(CM_Family, CM_DeviceList); |
---|
| 38 | CM_OrigSP_abs = getsp(CM_Family); |
---|
| 39 | |
---|
| 40 | CM_PrevSP = CM_OrigSP; |
---|
| 41 | CM_PrevSP = CM_PrevSP - CM_OrigSP; %To make "0" |
---|
| 42 | |
---|
| 43 | for 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}; |
---|
| 68 | end |
---|
| 69 | |
---|
| 70 | %Returning to the original state |
---|
| 71 | %stepsp(CM_Family, CM_OrigSP - CM_PrevSP, CM_DeviceList); |
---|
| 72 | setsp(CM_Family, CM_OrigSP_abs); |
---|