--- /dev/null
+function cce_distribution = build_cce_distribution(selected_matrix, x_coord, y_coord, delta_x, delta_y, X, Y)
+a = 1/20;
+c = 0.9;
+
+if selected_matrix == "quadratic"
+ cce_distribution = 0.5*exp(-1/10*sqrt((X-x_coord).^2 + (Y-y_coord).^2) );
+elseif selected_matrix == "Mi29a0"
+ cce_distribution = c*exp(-a*sqrt((X-x_coord).^2 + (Y-y_coord).^2) );
+# cce_distribution(sqrt((X-x_coord).^2 + (Y-y_coord).^2) < 2) = 1; % CCE of the diode
+
+# cce_distribution = 1./(exp(1/10*(sqrt((X-x_coord).^2 + (Y-y_coord).^2)-15) ) + 1); % Fermi-Dirac CCE
+
+ # cce_distribution = c*exp(-1/200*((X-x_coord).^2 + (Y-y_coord).^2) );
+ # cce_distribution = sqrt((X-x_coord).^2 + (Y-y_coord).^2);
+elseif (selected_matrix == "Mi29a1")
+ cce_distribution = c*exp(-a*sqrt((X-x_coord).^2 + (Y-y_coord).^2) ) + c*exp(-a*sqrt((X-(x_coord-delta_x/2)).^2 + (Y-y_coord).^2) );
+elseif (selected_matrix == "Mi29a2")
+ cce_distribution = c*exp(-a*sqrt((X-x_coord).^2 + (Y-y_coord).^2) ) + c*exp(-a*sqrt((X-(x_coord-delta_x/2)).^2 + (Y-y_coord).^2) );
+elseif (selected_matrix == "Mi29a3")
+ cce_distribution = c*exp(-a*sqrt((X-x_coord).^2 + (Y-y_coord).^2) ) + c*exp(-a*sqrt((X-(x_coord-delta_x/2)).^2 + (Y-y_coord).^2) );
+elseif (selected_matrix == "Mi29a4")
+ cce_distribution = c*exp(-a*sqrt((X-x_coord).^2 + (Y-y_coord).^2) ) + c*exp(-a*sqrt((X-(x_coord-delta_x/2)).^2 + (Y-(y_coord+delta_y/2)).^2) );
+elseif (selected_matrix == "Mi29a5")
+ cce_distribution = c*exp(-a*sqrt((X-x_coord).^2 + (Y-y_coord).^2) ) ...
+ + c*exp(-a*sqrt((X-x_coord).^2 + (Y-(y_coord+delta_y/2)).^2) ) ...
+ + c*exp(-a*sqrt((X-(x_coord-delta_x/2)).^2 + (Y-y_coord).^2)) ...
+ + c*exp(-a*sqrt((X-(x_coord-delta_x/2)).^2 + (Y-(y_coord+delta_y/2)).^2) );
+end
\ No newline at end of file
--- /dev/null
+%% main script
+
+% selected_matrix = "Mi29a0";
+selected_matrix = "quadratic";
+granularity = 500;
+numPixel = 6; % number of pixels in one row and one column
+
+if selected_matrix == "quadratic"
+ delta_x = 32;
+ delta_y = 32;
+ staggered_factor = 0;
+elseif selected_matrix == "Mi29a0"
+ delta_x = 64;
+ delta_y = 16;
+ staggered_factor = 1/2;
+elseif selected_matrix == "Mi29a1"
+ delta_x = 64;
+ delta_y = 16;
+ staggered_factor = 1/4;
+elseif selected_matrix == "Mi29a2"
+ delta_x = 64;
+ delta_y = 32;
+ staggered_factor = 0;
+elseif selected_matrix == "Mi29a3"
+ delta_x = 64;
+ delta_y = 32;
+ staggered_factor = 1/4;
+elseif selected_matrix == "Mi29a4"
+ delta_x = 64;
+ delta_y = 64;
+ staggered_factor = 0;
+elseif selected_matrix == "Mi29a5"
+ delta_x = 64;
+ delta_y = 64;
+ staggered_factor = 0;
+end
+
+[X, Y] = meshgrid( linspace(0, (numPixel-1)*delta_x, granularity), linspace(0, (numPixel-1)*delta_y, granularity));
+pixelCCE = zeros(granularity, granularity, numPixel, numPixel); %% second 2 arguments: x and y coordinate of the pixel; first 2 arguments: matrix with CCE entries
+
+% create CCE matrix for each pixel
+for i = 1:numPixel
+ for j = 1:numPixel
+ x_coord = (j-1)*delta_x + mod(i+1,2)*delta_x*staggered_factor; % every second row is shifted by delta_x/2 to the right
+ y_coord = (i-1)*delta_y;
+
+ pixelCCE(:, :, j, i) = build_cce_distribution(selected_matrix, x_coord, y_coord, delta_x, delta_y, X, Y);
+ end
+end
+
+
+maxCCE = zeros(size(pixelCCE(:,:,1,1)));
+sumCCE = zeros(size(pixelCCE(:,:,1,1)));
+for i = 1:numPixel
+ for j = 1:numPixel
+ maxCCE = max(maxCCE, pixelCCE(:, :, j, i));
+ sumCCE = sumCCE + pixelCCE(:, :, j, i);
+ end
+end
+
+
+combined_CCE = maxCCE./sumCCE;
+# selection = (X>delta_x*floor(numPixel/2)) & (X<delta_x*(floor(numPixel/2)+1)) & (Y>delta_y*floor(numPixel/2)) & (Y<delta_y*(floor(numPixel/2)+1));
+start_element = round(granularity/numPixel*floor(numPixel/2-1/2));
+end_element = round(granularity/numPixel*floor(numPixel/2+1/2));
+combined_CCE_central_pixel = combined_CCE(start_element:end_element, start_element:end_element);
+X_selection = X(start_element:end_element, start_element:end_element);
+Y_selection = Y(start_element:end_element, start_element:end_element);
+
+% plot single pixel CCE
+figure;
+imagesc(X,Y,pixelCCE(:, :, 3, 3));
+set(gca,'YDir','normal');
+axis equal;
+colorbar;
+
+% plot matrix CCE
+figure;
+pcolor(X,Y,combined_CCE);
+# imagesc(X,Y,combined_CCE);
+caxis([0, 1]);
+axis equal;
+shading flat;
+colorbar;
+
+% plot central pixel CCE
+figure;
+imagesc(X_selection,Y_selection,combined_CCE_central_pixel);
+set(gca,'YDir','normal');
+caxis([0, 1]);
+axis equal;
+shading flat;
+colorbar;
+
+% histogran for whole matrix
+figure;
+hist(combined_CCE(:), 50);
+axis([0, 1]);
+
+% histogran for central pixel
+figure;
+hist(combined_CCE_central_pixel(:), 50);
+axis([0, 1]);
+
29134 1/22/2014 -30 -21.5 50000 5 Sr90 80 3.00E+12 1.55 y
29135 -70 50000 5 Sr90 64 3.00E+12 1.57
29136 -70 50000 5 Sr90 80 3.00E+12 1.55
+
+
+
+29137 20 50000 1 none 64 0.00E+00 3.20 The noise of the unirradiated chip seems to be corrupted. Therefore we make this measurement again.
+29138 20 50000 1 none 80 0.00E+00 3.12
+29139 2/13/2014 -20 -17.5 50000 1 none 64 0.00E+00 3.19 y
+29140 2/13/2014 -20 -18.0 50000 1 none 80 0.00E+00 3.12 y
+29141 -70 50000 1 none 64 0.00E+00 3.18
+29142 -70 50000 1 none 80 0.00E+00 3.10
+
+29143 20 50000 6 none 64 1.00E+13 1.54
+29144 20 50000 6 none 80 1.00E+13 1.53
+29145 -20 50000 6 none 64 1.00E+13 1.54
+29146 -20 50000 6 none 80 1.00E+13 1.53
+29147 -70 50000 6 none 64 1.00E+13 1.54
+29148 -70 50000 6 none 80 1.00E+13 1.53
+
+29149 2/13/2014 -20 1000 1 none 64 0.00E+00 3.20 y
+29150 2/13/2014 -20 1000 6 none 64 1.00E+13 1.54 y
+29151 2/13/2014 -20 1000 6 none 64 1.00E+13 1.54 y
+29152 2/13/2014 -20 1000 6 none 64 1.00E+13 1.54 y