0001 function [DelHCM, DelVCM, DelQF, DelQD] = ffdeltasp(Sector, Gap, LongitudinalGap, GeV)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 HCMelem = dev2elem('HCM', family2dev('HCM'));
0029 VCMelem = dev2elem('VCM', family2dev('VCM'));
0030
0031
0032 if nargin < 1
0033 Sector = [];
0034 end
0035 if isempty(Sector)
0036 Sector = family2dev('ID');
0037 end
0038 if nargin < 2
0039 Gap = [];
0040 end
0041 if isempty(Gap)
0042 Gap = getsp('ID', Sector);
0043 end
0044 if nargin < 3
0045 LongitudinalGap = [];
0046 end
0047 if isempty(LongitudinalGap)
0048 LongitudinalGap = getepu(Sector);
0049 end
0050 if nargin < 4
0051 GeV = [];
0052 end
0053 if isempty(GeV)
0054 GeV = getenergy('Production');
0055 end
0056
0057
0058 if size(Sector,2) == 1
0059 Sector = elem2dev('ID', Sector);
0060 end
0061 if size(Sector,1) ~= size(Gap,1)
0062 error('Rows of Sector & Gap must equal.');
0063 end
0064 if any(size(Gap) ~= size(LongitudinalGap))
0065 error('Sector and LongitudinalGap must be the same size');
0066 end
0067
0068
0069
0070
0071 HCMDeviceList = family2dev('HCM');
0072 VCMDeviceList = family2dev('VCM');
0073 DelHCM = zeros(size(HCMDeviceList,1), size(Gap,2));
0074 DelVCM = zeros(size(VCMDeviceList,1), size(Gap,2));
0075 HCM = zeros( 4, size(Gap,2));
0076 VCM = zeros( 4, size(Gap,2));
0077
0078
0079 for i = 1:size(Sector,1);
0080 if any(Sector(i,1) == [4 6 11])
0081 if Sector(i,2) == 1
0082 HCMlist1 = [
0083 Sector(i,1)-1 8;
0084 Sector(i,1)-1 10;
0085 Sector(i,1)-1 2;
0086 Sector(i,1) 7];
0087
0088 VCMlist1 = [
0089 Sector(i,1)-1 8;
0090 Sector(i,1)-1 10;
0091 Sector(i,1)-1 2;
0092 Sector(i,1) 7];
0093 else
0094 HCMlist1 = [
0095 Sector(i,1)-1 10;
0096 Sector(i,1) 1;
0097 Sector(i,1)-1 2;
0098 Sector(i,1) 7];
0099
0100 VCMlist1 = [
0101 Sector(i,1)-1 10;
0102 Sector(i,1) 1;
0103 Sector(i,1)-1 2;
0104 Sector(i,1) 7];
0105 end
0106 else
0107 HCMlist1 = [
0108 Sector(i,1)-1 8;
0109 Sector(i,1) 1;
0110 Sector(i,1)-1 2;
0111 Sector(i,1) 7];
0112
0113 VCMlist1 = [
0114 Sector(i,1)-1 8;
0115 Sector(i,1) 1;
0116 Sector(i,1)-1 2;
0117 Sector(i,1) 7];
0118 end
0119
0120 iHCM = findrowindex(HCMlist1, HCMDeviceList);
0121 iVCM = findrowindex(VCMlist1, VCMDeviceList);
0122
0123
0124
0125 [tableHCM, tableVCM, tableQ] = fftable(Sector(i,1), GeV);
0126 if (Sector(i) == 4) | (Sector(i) == 11)
0127 [GapsLongitudinal, Gaps, HCMtable1, HCMtable2, VCMtable1, VCMtable2] = fftableepu(Sector(i,1), GeV);
0128
0129 end
0130
0131 for j = 1:size(Gap,2)
0132
0133 tmpgap = Gap(i,j);
0134 if tmpgap >= tableHCM(1,1)
0135 tmpgap = tableHCM(1,1);
0136 end
0137 if tmpgap <= tableHCM(size(tableHCM,1),1)
0138 tmpgap = tableHCM(size(tableHCM,1),1);
0139 end
0140
0141 HCM(1:2,j) = [
0142 interp1(tableHCM(:,1), tableHCM(:,2), tmpgap);
0143 interp1(tableHCM(:,1), tableHCM(:,3), tmpgap)];
0144
0145 VCM(1:2,j) = [
0146 interp1(tableVCM(:,1), tableVCM(:,2), tmpgap);
0147 interp1(tableVCM(:,1), tableVCM(:,3), tmpgap)];
0148
0149
0150
0151 if (Sector(i) == 4) | (Sector(i) == 11)
0152
0153 tmpgap = Gap(i,j);
0154 if tmpgap >= Gaps(1)
0155 tmpgap = Gaps(1);
0156 end
0157 if tmpgap <= Gaps(end)
0158 tmpgap = Gaps(end);
0159 end
0160
0161 tmpLongitudinalGap = LongitudinalGap(i,j);
0162 if tmpLongitudinalGap < GapsLongitudinal(1)
0163 tmpLongitudinalGap = GapsLongitudinal(1);
0164 end
0165 if tmpLongitudinalGap > GapsLongitudinal(end)
0166 tmpLongitudinalGap = GapsLongitudinal(end);
0167 end
0168
0169 hcm1 = interp2(GapsLongitudinal, Gaps, HCMtable1, tmpLongitudinalGap, tmpgap);
0170 hcm2 = interp2(GapsLongitudinal, Gaps, HCMtable2, tmpLongitudinalGap, tmpgap);
0171 vcm1 = interp2(GapsLongitudinal, Gaps, VCMtable1, tmpLongitudinalGap, tmpgap);
0172 vcm2 = interp2(GapsLongitudinal, Gaps, VCMtable2, tmpLongitudinalGap, tmpgap);
0173
0174 HCM(:,j) = HCM(:,j) + [hcm1;hcm2;0;0];
0175 VCM(:,j) = VCM(:,j) + [vcm1;vcm2;0;0];
0176 end
0177
0178 DelHCM(iHCM,j) = DelHCM(iHCM,j) + HCM(:,j);
0179 DelVCM(iVCM,j) = DelVCM(iVCM,j) + VCM(:,j);
0180 end
0181 end
0182
0183
0184
0185
0186 if nargout >= 3
0187 [DelQF, DelQD] = ffdeltaquad(Sector, Gap, GeV);
0188 end
0189
0190
0191
0192
0193