13 %
FileID = {
'Rot45',
'THP',
'UIUC18',
'UpTilt5',
'ShowerDepth'};
15 %
FileID = {
'ShowerCalib',
'ShowerCalib_tilted'};
18 FileID = {
'5thPositionScan_dst',
'6thPositionScan_dst'};
36 FileList{
i} = [DataFolder FileList{i} '.lst_EMCalCalib.root.dat'];
46 DataSet =
struct(
'FileID',{},
'E',{},
'DE',{},
'data',{},
'accept',{});
81 DataSet(N_Runs).data = DataSet(N_Runs).data(total_E > 1, :);
82 DataSet(N_Runs).accept = ones(size(data, 1), 1);
89 DrawDataSet(DataSet, InitConst, 'Inputs
');
91 SaveCanvas([DataFolder 'EnergyCalibFIt
'],gcf);
106 total_E = ones(size(DataSet(i).data)) .*DataSet(i).E;
107 Fraction = DataSet(i).data ./ total_E;
108 MeanFraction = mean(Fraction, 1);
109 MeanFraction = reshape(MeanFraction, 8, 8);
111 SumFraction = [SumFraction; Fraction];
113 imagesc(0:7, 0:7, MeanFraction);
115 set(gca,'YDir
','normal
')
117 title(sprintf('%
s,
E = %.1
f GeV', DataSet(i).FileID, DataSet(i).E));
123 SaveCanvas([DataFolder 'EnergyCalibFIt
'],gcf);
133 idx = col + (row - 1)*8;
137 histogram( DataSet(i).data(:,idx),[0.:.1:16]);
139 set(gca,'XLim
',[0,16])
141 title(sprintf('Row%d Col%d
', row-1, col-1));
153 MeanFraction = mean(SumFraction, 1);
154 MeanFraction = reshape(MeanFraction, 8, 8);
156 imagesc(0:7, 0:7, MeanFraction);
158 set(gca,'YDir
','normal
');
160 title(sprintf('Sum all
data'));
166 hist(reshape(MeanFraction,size(MeanFraction,1) * size(MeanFraction,2),1),100);
172 low_tower_IDs =reshape( MeanFraction<0.001, 1, Ndata);
173 % low_tower_IDs =reshape( MeanFraction<0.0001, 1, Ndata);
175 imagesc(0:7, 0:7, reshape(low_tower_IDs, 8, 8));
177 set(gca,'YDir
','normal
');
179 title(sprintf('Low hit towers
'));
183 SaveCanvas([DataFolder 'EnergyCalibFIt
'],gcf);
188 % InitConst_RunScale = [InitConst ones(1, N_Runs)];
189 InitConst_RunScale = [InitConst ];
190 % InitConst_RunScale = [InitConst ];
192 data_selection(InitConst_RunScale,10);
193 disp(object_function(InitConst_RunScale));
195 % disp(object_function(InitConst_RunScale, 2));
196 % disp(object_function(InitConst_RunScale, 1));
200 x = InitConst_RunScale;
202 options = optimset('Display
','iter
','TolX
',1, 'MaxFunEvals
', 100000,'MaxIter
',40000,'PlotFcns
',@optimplotfval );
205 disp(object_function(x));
207 x = fminsearch(@(x) object_function(x), x,...
211 options = optimset('Display
','iter
','TolX
',1, 'MaxFunEvals
', 100000,'MaxIter
',40000,'PlotFcns
',@optimplotfval );
214 disp(object_function(x));
216 x = fminsearch(@(x) object_function(x), x,...
221 options = optimset('Display
','iter
','TolX
',1, 'MaxFunEvals
', 100000,'MaxIter
',40000,'PlotFcns
',@optimplotfval );
224 disp(object_function(x));
226 x = fminsearch(@(x) object_function(x), x,...
234 calib_const = x(1:Ndata);
235 % E_scale = x((Ndata+1):(Ndata + N_Runs));
236 E_scale = ones(N_Runs);
245 title(sprintf('Calibration constant
'));
246 xlabel('Col * 8 + Row
');
247 ylabel('Calibration New /
Old');
251 imagesc(0:7, 0:7, reshape(calib_const, 8, 8));
253 set(gca,'YDir
','normal
')
255 title(sprintf('Calibration constant, New /
Old'));
263 title(sprintf('Energy scale constant,
mean = %.2
f', mean(E_scale)));
265 ylabel('Energy scale New /
Old');
266 set(gca,'YLim
',[0.5,1.5])
270 SaveCanvas([DataFolder 'EnergyCalibFIt
'],gcf);
277 % 10.19 8.47 8.96 9.77
278 % 9.74 9.96 10.00 9.87
279 % 9.25 9.83 9.32 10.10
280 % 9.59 9.39 10.06 9.62
282 % 9.43 9.34 9.39 9.55
287 % ModuleDensity = ModuleDensity(8:-1:1,:);
289 % ModuleDensity = [ModuleDensity(:,1) ModuleDensity(:,1) ModuleDensity(:,2) ModuleDensity(:,2) ModuleDensity(:,3) ModuleDensity(:,3) ModuleDensity(:,4) ModuleDensity(:,4)];
292 % imagesc(0:7, 0:7,ModuleDensity);
294 % set(gca,'YDir
','normal
')
296 % title(sprintf('Module Density (
g/
cm^3)
'));
297 % xlabel('Column ID
');
303 % imagesc(0:7, 0:7, reshape(calib_const, 8, 8));
305 % set(gca,'YDir
','normal
');
307 % title(sprintf('Calibration constant, New /
Old'));
308 % xlabel('Column ID
');
314 % [calib_const_col, calib_const_row]= meshgrid(0:7,0:7);
316 % calib_const_col = reshape(calib_const_col,1,64);
317 % calib_const_row = reshape(calib_const_row,1,64);
318 % % IDs = ~low_tower_IDs;
319 % IDs = (calib_const_col >=3 & calib_const_col<=5 & calib_const_row>=4 & calib_const_row<=6);
321 % dens = reshape(ModuleDensity,1, 8* 8);
324 % plot(calib_const(IDs),dens, 'o
');
325 % title(sprintf('THP 3x3, Calibration adjustment VS density
'));
326 % xlabel('Calibration constant, New /
Old');
327 % ylabel('Module Density
');
332 % IDs = ~low_tower_IDs;
333 % % IDs = (calib_const_col >=3 & calib_const_col<=5 & calib_const_row>=4 & calib_const_row<=6);
335 % dens = reshape(ModuleDensity,1, 8* 8);
338 % plot(calib_const(IDs),dens, 'o
');
339 % title(sprintf('All calibrated modules, Calibration adjustment VS density
'));
340 % xlabel('Calibration constant, New /
Old');
341 % ylabel('Module Density
');
343 % SaveCanvas([DataFolder 'EnergyCalibFIt
'],gcf);
349 DrawDataSet(DataSet,calib_const,'Optimized
');
350 SaveCanvas([DataFolder 'EnergyCalibFIt
'],gcf);
355 % filename = sprintf('%
s/calirbated_%d_%.0
f.dat
',DataFolder, DataSet(i).FileID, DataSet(i).E );
358 % total_E = sum( DataSet(i).data*InitConst', 2) ;
361 % dlmwrite(filename,[total_E calib_total_E]);
364 save([DataFolder 'fit.mat
']);
365 % save('goodfit.mat
');
369 [calib_const_col, calib_const_row]= meshgrid(0:7,0:7);
371 A = [reshape(calib_const_col,1,64); reshape(calib_const_row,1,64); calib_const];
374 fileID = fopen([DataFolder 'ShowerCalibFit_CablibConst.dat
'],'w
');
375 % fprintf(fileID,'%d - %d \
n',);
377 fprintf(fileID,'%d\
t%d\
t%
f\
n',A);
382 disp([DataFolder 'ShowerCalibFit_CablibConst.dat
'])
391 idx = col + (row - 1)*8;
395 histogram( DataSet(i).data(:,idx) * calib_const(idx),[0.:.1:16]);
397 set(gca,'XLim
',[0,16]);
399 title(sprintf('Row%d Col%d
', row-1, col-1));