Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Proto3ShowerCalibFit.m File Reference

Go to the source code of this file.

Functions

 fprintf ('processing%s\n', filename)
 
 disp (size(data))
 
 fprintf ('processing%s-%.0f GeV @%d\n', filename, energy(j), N_Runs)
 
 DataSet (N_Runs).FileID
 
end end DrawDataSet (DataSet, InitConst, 'Inputs')
 
 SaveCanvas ([DataFolder 'EnergyCalibFIt'], gcf)
 
 figure ('name',['DrawDataSet_EnergyFraction'],'PaperPositionMode','auto',... 'position',[100, 0, 1800, 1000])
 
 imagesc (0:7, 0:7, MeanFraction)
 
colorbar set (gca,'YDir','normal') title(sprintf('%s
 
colorbar DataSet (i).FileID
 
 xlabel ('Column ID')
 
 ylabel ('Row ID')
 
 subplot (1, 3, 1)
 
 title (sprintf('Sum all data'))
 
 subplot (1, 3, 2)
 
 hist (reshape(MeanFraction, size(MeanFraction, 1)*size(MeanFraction, 2), 1), 100)
 
 title ('fraction of shower energy carried by each tower')
 
 xlabel ('MeanFraction')
 
 subplot (1, 3, 3)
 
 imagesc (0:7, 0:7, reshape(low_tower_IDs, 8, 8))
 
 title (sprintf('Low hit towers'))
 
 data_selection (InitConst_RunScale, 10)
 
 disp (object_function(InitConst_RunScale))
 
 disp (object_function(InitConst_RunScale, 2))
 
 disp (object_function(InitConst_RunScale, 1))
 
 data_selection (x, 8)
 
 disp (object_function(x))
 
 data_selection (x, 4)
 
 data_selection (x, 2)
 
 plot (calib_const)
 
 title (sprintf('Calibration constant'))
 
 xlabel ('Col *8+Row')
 
 ylabel ('Calibration New/Old')
 
 imagesc (0:7, 0:7, reshape(calib_const, 8, 8))
 
 plot (E_scale,'x')
 
 title (sprintf('Energy scale constant, mean=%.2f', mean(E_scale)))
 
 xlabel ('Run ID')
 
 ylabel ('Energy scale New/Old')
 
 set (gca,'YLim',[0.5, 1.5]) grid on SaveCanvas([DataFolder 'EnergyCalibFIt']
 
 figure ('name',['CalibConstVSModuleDensity'],'PaperPositionMode','auto',...% 'position',[100, 0, 1300, 1000])
 
 subplot (2, 2, 1)
 
 imagesc (0:7, 0:7, ModuleDensity)
 
 subplot (2, 2, 2)
 
 title (sprintf('Calibration constant, New/Old'))
 
 subplot (2, 2, 3)
 
 plot (calib_const(IDs), dens, 'o')
 
 title (sprintf('THP 3x3, Calibration adjustment VS density'))
 
 xlabel ('Calibration constant, New/Old')
 
 ylabel ('Module Density')
 
 subplot (2, 2, 4)
 
 title (sprintf('All calibrated modules, Calibration adjustment VS density'))
 
 DrawDataSet (DataSet, calib_const,'Optimized')
 
 dlmwrite (filename,[total_E calib_total_E])
 
end save ([DataFolder 'fit.mat'])
 
 save ('goodfit.mat')
 
 reshape (calib_const_row, 1, 64)
 
 fprintf (fileID,'%d-%d\n',)
 
 fprintf (fileID,'%d\t%d\t%f\n', A)
 
 fclose (fileID)
 

Variables

clear all close all global Ndata = 64
 
global DataSet =struct('FileID',{},'E',{},'DE',{},'data',{}, 'accept',{})
 
global low_tower_IDs =reshape( MeanFraction<0.01, 1, Ndata)
 
 DataFolder = 'E:/tmp/Transfer Buffer/ShowerCalib/'
 
 FileID = {'Rot45','THP','UIUC18','UpTilt5', 'ShowerDepth'}
 
 FileList = FileID
 
 sim_const = 3/100
 
 sim_stat = 12/100
 
 InitConst = [ones(1, 64) ]
 
 zero_sup = -1000
 
zero suppression disabled for i
 
end N_Runs = size(RunList, 2)
 
 data = textread(filename)
 
 energys = data(:,1)
 
 energy = unique(energys)
 
for j
 
 total_E = sum( DataSet(N_Runs).data* InitConst', 2)
 
 SumFraction = []
 
 Fraction = DataSet(i).data ./ total_E
 
 MeanFraction = mean(Fraction, 1)
 
colorbar E = %.1f GeV'
 
return InitConst_RunScale = [InitConst ones(1, N_Runs)]
 
 x = InitConst_RunScale
 
 options = optimset('Display','iter','TolX',1, 'MaxFunEvals', 100000,'MaxIter',40000,'PlotFcns',@optimplotfval )
 
 calib_const = x(1:Ndata)
 
 E_scale = x((Ndata+1):(Ndata + N_Runs))
 
colorbar New Old
 
 gcf
 
 ModuleDensity
 
 calib_const_col = reshape(calib_const_col,1,64)
 
 calib_const_row = reshape(calib_const_row,1,64)
 
 IDs = ~low_tower_IDs
 
 dens = reshape(ModuleDensity,1, 8* 8)
 
 calib_total_E = sum( DataSet(i).data* calib_const', 2)
 
 A = [reshape(calib_const_col,1,64)
 
 fileID = fopen([DataFolder 'ShowerCalibFit_CablibConst.dat'],'w')
 

Function Documentation

data_selection ( InitConst_RunScale  ,
10   
)
data_selection ( x  ,
 
)
data_selection ( x  ,
 
)
data_selection ( x  ,
 
)
DataSet ( N_Runs  )
colorbar DataSet ( i  )
disp ( size(data )
disp ( object_function(InitConst_RunScale )
disp ( object_function(InitConst_RunScale, 2)  )
disp ( object_function(InitConst_RunScale, 1)  )
disp ( object_function(x )
dlmwrite ( filename  )
end end DrawDataSet ( DataSet  ,
InitConst  ,
'Inputs'   
)
DrawDataSet ( DataSet  ,
calib_const  ,
'Optimized'   
)
fclose ( fileID  )
figure ( 'name ,
'PaperPositionMode ,
'auto ,
... 'position  
)
figure ( 'name ,
'PaperPositionMode ,
'auto ,
...% 'position  
)
fprintf ( 'processing%s\n ,
filename   
)
fprintf ( 'processing%s-%.0f GeV @%d\n'  ,
filename  ,
energy(j ,
N_Runs   
)
fprintf ( fileID  ,
'%d-%d\n  
)
fprintf ( fileID  ,
'%d\t%d\t%f\n ,
A   
)
hist ( reshape(MeanFraction, size(MeanFraction, 1)*size(MeanFraction, 2), 1)  ,
100   
)
imagesc ( 0:7  ,
0:7  ,
MeanFraction   
)
imagesc ( 0:7  ,
0:7  ,
reshape(low_tower_IDs, 8, 8)   
)
imagesc ( 0:7  ,
0:7  ,
reshape(calib_const, 8, 8)   
)
imagesc ( 0:7  ,
0:7  ,
ModuleDensity   
)
plot ( calib_const  )
plot ( E_scale  ,
'x  
)
plot ( calib_const(IDs ,
dens  ,
'o'   
)
reshape ( calib_const_row  ,
,
64   
)
end save ( )
save ( 'goodfit.mat'  )
SaveCanvas ( gcf  )
colorbar set ( gca  ,
'YDir'  ,
'normal'   
)
set ( gca  ,
'YLim'   
)
subplot ( ,
,
 
)
subplot ( ,
,
 
)
subplot ( ,
,
 
)
subplot ( ,
,
 
)
subplot ( ,
,
 
)
subplot ( ,
,
 
)
subplot ( ,
,
 
)
title ( sprintf('Sum all data')  )
title ( 'fraction of shower energy carried by each tower )
title ( sprintf('Low hit towers')  )
title ( sprintf('Calibration constant')  )
title ( sprintf('Energy scale constant, mean=%.2f', mean(E_scale))  )
title ( sprintf('Calibration constant, New/Old')  )
title ( sprintf('THP 3x3, Calibration adjustment VS density')  )
title ( sprintf('All calibrated modules, Calibration adjustment VS density')  )
xlabel ( 'Column ID'  )
xlabel ( 'MeanFraction )
xlabel ( 'Col *8+Row'  )
xlabel ( 'Run ID'  )
xlabel ( 'Calibration  constant,
New/Old  
)
ylabel ( 'Row ID'  )
ylabel ( 'Calibration New/Old )
ylabel ( 'Energy scale New/Old )
ylabel ( 'Module Density'  )

Variable Documentation

Definition at line 334 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 334 of file Proto3ShowerCalibFit.m

calib_const = x(1:Ndata)

Definition at line 197 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 197 of file Proto3ShowerCalibFit.m

calib_const_col = reshape(calib_const_col,1,64)

Definition at line 279 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 279 of file Proto3ShowerCalibFit.m

calib_const_row = reshape(calib_const_row,1,64)

Definition at line 280 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 280 of file Proto3ShowerCalibFit.m

calib_total_E = sum( DataSet(i).data* calib_const', 2)

Definition at line 322 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 322 of file Proto3ShowerCalibFit.m

data = textread(filename)

Definition at line 46 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 46 of file Proto3ShowerCalibFit.m

DataFolder = 'E:/tmp/Transfer Buffer/ShowerCalib/'

Definition at line 11 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 11 of file Proto3ShowerCalibFit.m

Readin global DataSet DataSet =struct('FileID',{},'E',{},'DE',{},'data',{}, 'accept',{})

Definition at line 6 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 6 of file Proto3ShowerCalibFit.m

dens = reshape(ModuleDensity,1, 8* 8)

Definition at line 284 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 284 of file Proto3ShowerCalibFit.m

colorbar E = %.1f GeV'

Definition at line 103 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 103 of file Proto3ShowerCalibFit.m

E_scale = x((Ndata+1):(Ndata + N_Runs))

Definition at line 198 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 198 of file Proto3ShowerCalibFit.m

energy = unique(energys)

Definition at line 50 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 50 of file Proto3ShowerCalibFit.m

energys = data(:,1)

Definition at line 49 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 49 of file Proto3ShowerCalibFit.m

FileID = {'Rot45','THP','UIUC18','UpTilt5', 'ShowerDepth'}

Definition at line 13 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 13 of file Proto3ShowerCalibFit.m

fileID = fopen([DataFolder 'ShowerCalibFit_CablibConst.dat'],'w')

Definition at line 336 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 336 of file Proto3ShowerCalibFit.m

Definition at line 15 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 15 of file Proto3ShowerCalibFit.m

Fraction = DataSet(i).data ./ total_E

Definition at line 93 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 93 of file Proto3ShowerCalibFit.m

gcf

Definition at line 233 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 233 of file Proto3ShowerCalibFit.m

Referenced by ActsExamples::DigitizationAlgorithm::DigitizationAlgorithm().

Save out for i
Initial value:
= 1:size(FileList,2)
FileList{i} = [DataFolder FileList{i} '.lst_EMCalCalib.root.dat']

Definition at line 26 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 26 of file Proto3ShowerCalibFit.m

IDs = ~low_tower_IDs

Definition at line 281 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 281 of file Proto3ShowerCalibFit.m

InitConst = [ones(1, 64) ]

Definition at line 20 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 20 of file Proto3ShowerCalibFit.m

InitConst_RunScale = [InitConst ones(1, N_Runs)]

Definition at line 151 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 151 of file Proto3ShowerCalibFit.m

for j
Initial value:
=1:size(energy, 1)

Definition at line 55 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 55 of file Proto3ShowerCalibFit.m

low_tower_IDs =reshape( MeanFraction<0.01, 1, Ndata)

Definition at line 7 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 7 of file Proto3ShowerCalibFit.m

MeanFraction = mean(Fraction, 1)

Definition at line 94 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 94 of file Proto3ShowerCalibFit.m

ModuleDensity
Initial value:
=[
% 10.19 8.47 8.96 9.77
% 9.74 9.96 10.00 9.87
% 9.25 9.83 9.32 10.10
% 9.59 9.39 10.06 9.62
% 9.48 9.5 9.34 9.33
% 9.43 9.34 9.39 9.55
% 9.21 9.55 9.3 9.3
% 9.5 9.6 9.3 9.24
% ]

Definition at line 239 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 239 of file Proto3ShowerCalibFit.m

N_Runs = size(RunList, 2)

Definition at line 34 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 34 of file Proto3ShowerCalibFit.m

Ndata = 64

Definition at line 5 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 5 of file Proto3ShowerCalibFit.m

colorbar New Old

Definition at line 218 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 218 of file Proto3ShowerCalibFit.m

options = optimset('Display','iter','TolX',1, 'MaxFunEvals', 100000,'MaxIter',40000,'PlotFcns',@optimplotfval )

Definition at line 165 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 165 of file Proto3ShowerCalibFit.m

sim_const = 3/100

Definition at line 17 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 17 of file Proto3ShowerCalibFit.m

sim_stat = 12/100

Definition at line 18 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 18 of file Proto3ShowerCalibFit.m

SumFraction = []

Definition at line 88 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 88 of file Proto3ShowerCalibFit.m

total_E = sum( DataSet(N_Runs).data* InitConst', 2)

Definition at line 67 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 67 of file Proto3ShowerCalibFit.m

Definition at line 163 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 163 of file Proto3ShowerCalibFit.m

zero_sup = -1000

Definition at line 22 of file Proto3ShowerCalibFit.m.

View newest version in sPHENIX GitHub at line 22 of file Proto3ShowerCalibFit.m