13 %
FileID = {
'Rot45',
'THP',
'UIUC18',
'UpTilt5',
'ShowerDepth'};
14 FileID = {
'Rot45',
'THP',
'UIUC18',
'UIUC21',
'Tilt0',
'ShowerDepth'};
28 FileList{
i} = [DataFolder FileList{i} '.lst_EMCalCalib.root.dat'];
38 DataSet =
struct(
'FileID',{},
'E',{},
'DE',{},
'data',{},
'accept',{});
69 DataSet(N_Runs).data = DataSet(N_Runs).data(total_E > DataSet(N_Runs).E/2, :);
70 DataSet(N_Runs).accept = ones(size(data, 1), 1);
77 DrawDataSet(DataSet, InitConst, 'Inputs
');
79 SaveCanvas([DataFolder 'EnergyCalibFIt
'],gcf);
92 total_E = ones(size(DataSet(i).data)) .*DataSet(i).E;
93 Fraction = DataSet(i).data ./ total_E;
94 MeanFraction = mean(Fraction, 1);
95 MeanFraction = reshape(MeanFraction, 8, 8);
97 SumFraction = [SumFraction; Fraction];
99 imagesc(0:7, 0:7, MeanFraction);
101 set(gca,'YDir
','normal
')
103 title(sprintf('%
s,
E = %.1
f GeV', DataSet(i).FileID, DataSet(i).E));
108 SaveCanvas([DataFolder 'EnergyCalibFIt
'],gcf);
116 MeanFraction = mean(SumFraction, 1);
117 MeanFraction = reshape(MeanFraction, 8, 8);
119 imagesc(0:7, 0:7, MeanFraction);
121 set(gca,'YDir
','normal
');
123 title(sprintf('Sum all
data'));
129 hist(reshape(MeanFraction,size(MeanFraction,1) * size(MeanFraction,2),1),100);
135 low_tower_IDs =reshape( MeanFraction<0.004, 1, Ndata);
137 imagesc(0:7, 0:7, reshape(low_tower_IDs, 8, 8));
139 set(gca,'YDir
','normal
');
141 title(sprintf('Low hit towers
'));
145 SaveCanvas([DataFolder 'EnergyCalibFIt
'],gcf);
150 InitConst_RunScale = [InitConst ones(1, N_Runs)];
151 % InitConst_RunScale = [InitConst ];
153 data_selection(InitConst_RunScale,10);
154 disp(object_function(InitConst_RunScale));
156 % disp(object_function(InitConst_RunScale, 2));
157 % disp(object_function(InitConst_RunScale, 1));
161 x = InitConst_RunScale;
163 options = optimset('Display
','iter
','TolX
',1, 'MaxFunEvals
', 100000,'MaxIter
',40000,'PlotFcns
',@optimplotfval );
166 disp(object_function(x));
168 x = fminsearch(@(x) object_function(x), x,...
172 options = optimset('Display
','iter
','TolX
',1, 'MaxFunEvals
', 100000,'MaxIter
',40000,'PlotFcns
',@optimplotfval );
175 disp(object_function(x));
177 x = fminsearch(@(x) object_function(x), x,...
182 options = optimset('Display
','iter
','TolX
',1, 'MaxFunEvals
', 100000,'MaxIter
',40000,'PlotFcns
',@optimplotfval );
185 disp(object_function(x));
187 x = fminsearch(@(x) object_function(x), x,...
195 calib_const = x(1:Ndata);
196 E_scale = x((Ndata+1):(Ndata + N_Runs));
206 title(sprintf('Calibration constant
'));
207 xlabel('Col * 8 + Row
');
208 ylabel('Calibration New /
Old');
212 imagesc(0:7, 0:7, reshape(calib_const, 8, 8));
214 set(gca,'YDir
','normal
')
216 title(sprintf('Calibration constant, New /
Old'));
224 title(sprintf('Energy scale constant,
mean = %.1
f', mean(E_scale)));
226 ylabel('Energy scale New /
Old');
229 SaveCanvas([DataFolder 'EnergyCalibFIt
'],gcf);
232 DrawDataSet(DataSet,calib_const,'Optimized
');
233 SaveCanvas([DataFolder 'EnergyCalibFIt
'],gcf);
238 % filename = sprintf('%
s/calirbated_%d_%.0
f.dat
',DataFolder, DataSet(i).FileID, DataSet(i).E );
241 % total_E = sum( DataSet(i).data*InitConst', 2) ;
244 % dlmwrite(filename,[total_E calib_total_E]);
247 save([DataFolder 'fit.mat
']);
248 % save('goodfit.mat
');
252 [calib_const_col, calib_const_row]= meshgrid(0:7,0:7);
254 A = [reshape(calib_const_col,1,64); reshape(calib_const_row,1,64); calib_const];
256 fileID = fopen([DataFolder 'ShowerCalibFit_CablibConst.dat
'],'w
');
257 % fprintf(fileID,'%d - %d \
n',);
259 fprintf(fileID,'%d\
t%d\
t%
f\
n',A);