1 % bottom up calcualtion
of TPC rate using MC approach
2 % Author - Jin Huang <jhuang@bnl.gov>
46 dNdeta = 2 * 180 * 2; % Pre-CDR table 3.3 with effective factor x2 and two signs x2
47 bitPerHit =3*5*10 * 1.4; % Pre-CDR table 3.3 with effective factor
58 CollisionBCO =poissrnd((full_rate - trig_rate)/BCO ,TimeSpanBCO, 1)' +
TriggerBCO;
66 zBCO = repmat(linspace(maxZ, 0, PerTriggerBCO),nRing,1);
68 MinEtaRingBCO = atanh( (zBCO - 10) ./ sqrt((zBCO - 10).^2 + RRing.^2) );
69 % MinEtaRingBCO = atanh( (zBCO - 0) ./ sqrt((zBCO - 0).^2 + RRing.^2) );
70 dEtaRingBCO = atanh( (zBCO + maxZ/double(PerTriggerBCO) ) ./ sqrt((zBCO + maxZ/double(PerTriggerBCO) ).^2 + RRing.^2) ) - atanh( zBCO ./ sqrt(zBCO.^2 + RRing.^2) );
71 dataBitRingBCO = bitPerHit .* dNdeta .* dEtaRingBCO; % Pre-CDR table 3.3 with effective factor
73 TriggerMask = double(MinEtaRingBCO < TargetEta);
74 dataBitRingBCOAfterMask = dataBitRingBCO.*TriggerMask;
82 imagesc(zBCO(1,:), RRing(:,1), dataBitRingBCO);
86 plot([10 maxZ+10], [0 tan(acos(tanh(TargetEta))) * maxZ],'k--
');
88 set(gca,'YDir
','normal
');
89 set(gca,'YLim
',[0,80]);
90 set(gca,'XLim
',[0,110])
97 c.Label.String = 'FEE
data (bit) per MB collision per |
z|-
R bin (integrated over
z-
sign and azimuth)
';
98 c.Label.FontSize = 14;
100 title(sprintf('FEE
data (bit) per MB collision per |
z|-
R bin, total = %.1
f Mbit
', sum(sum(dataBitRingBCO))/1e6),'FontSize',16);
106 imagesc(zBCO(1,:), RRing(:,1), dataBitRingBCOAfterMask);
109 plot([10 maxZ+10], [0 tan(acos(tanh(TargetEta))) * maxZ],'k--
');
111 set(gca,'YDir
','normal
');
112 set(gca,'YLim
',[0,80]);
113 set(gca,'XLim
',[0,110])
120 c.Label.String = 'FEE
data (bit) per MB collision per |
z|-
R bin (integrated over
z-
sign and azimuth)
';
121 c.Label.FontSize = 14;
123 title(sprintf('FEE
data (bit) after DAM acceptance filtering, total = %.1
f Mbit
', sum(sum(dataBitRingBCOAfterMask))/1e6),'FontSize',16);
128 SaveCavas('TPCRateLayered
',gcf);
133 DataBCO = conv2(CollisionBCO,dataBitRingBCO);
134 TriggerAcceptBCO = conv2(TriggerBCO,TriggerMask);
135 ThrottleAcceptBCO = double(TriggerAcceptBCO>0);
137 PlotDataBCO = DataBCO(:,1:DataPlotRangeBCO);
138 PlotThrottleDataBCO = DataBCO(:,1:DataPlotRangeBCO).*ThrottleAcceptBCO(:,1:DataPlotRangeBCO);
140 TotalDataRate = sum(sum(DataBCO))/TimeSpan;
141 TriggerDataRate = sum(sum(DataBCO.*TriggerAcceptBCO))/TimeSpan;
142 ThrottleDataRate = sum(sum(DataBCO.*ThrottleAcceptBCO))/TimeSpan;
144 %% Event stream display
151 imagesc( DataBCO(:,1:DataPlotRangeBCO) );
154 set(gca,'YDir
','normal
');
155 set(gca,'YLim
',[-4,nRing+1]);
159 c.Label.String = 'FEE
data (bit)
';
160 c.Label.FontSize = 14;
161 title(sprintf('FEE
data input to DAM. Rate = %.0f Gbps @ %.0f kHz Collision, %.0f kHz Trigger %.0f
us Drift
',...
162 sum(sum(DataBCO))/TimeSpan/1e9,full_rate/1e3,trig_rate/1e3,trigger_window*1e6),'FontSize',16);
164 for i = 1:DataPlotRangeBCO
166 if (TriggerBCO(i) >0)
168 plot([i i], [-3 nRing],'r--
','LineWidth
',2);
169 plot([i,i+PerTriggerBCO], [-3 -3], 'r-
', 'LineWidth
', 2)
170 plot([i,i+PerTriggerBCO], [-1 -1], 'k-
', 'LineWidth
', 2)
172 elseif (CollisionBCO(i) >0)
174 plot([i i], [-1 nRing],'k--
','LineWidth
',2);
175 plot([i,i+PerTriggerBCO], [-1 -1], 'k-
', 'LineWidth
', 2)
185 imagesc( PlotThrottleDataBCO );
188 set(gca,'YDir
','normal
');
189 set(gca,'YLim
',[-4,nRing+1]);
193 c.Label.String = 'FEE
data equavelent (bit)
';
194 c.Label.FontSize = 14;
196 ThrottleDataRate * DAMCompressionFactor/1e9 ,...
197 TriggerDataRate * DAMCompressionFactor/1e9...
200 for i = 1:DataPlotRangeBCO
202 if (TriggerBCO(i) >0)
204 plot([i i], [-3 nRing],'r--
','LineWidth
',2);
205 plot([i,i+PerTriggerBCO], [-3 -3], 'r-
', 'LineWidth
', 2)
206 plot([i,i+PerTriggerBCO], [-1 -1], 'k-
', 'LineWidth
', 2)
208 elseif (CollisionBCO(i) >0)
210 plot([i i], [-1 nRing],'k--
','LineWidth
',2);
211 plot([i,i+PerTriggerBCO], [-1 -1], 'k-
', 'LineWidth
', 2)
217 SaveCavas(SaveName,gcf);
220 %% Event stream display - 1D
227 bar( PlotDataBCO(nRing,:) ,1);
230 set(gca,'YDir
','normal
');
231 set(gca, 'XLim
',[0 DataPlotRangeBCO]);
232 ylim = get(gca,'YLim
');
237 % c.Label.String = 'FEE
data (bit)
';
238 % c.Label.FontSize = 14;
239 title(sprintf('FEE
data input to DAM. Rate = %.0f Gbps @ %.0f kHz Collision, %.0f kHz Trigger %.0f
us Drift
',...
240 sum(sum(DataBCO))/TimeSpan/1e9,full_rate/1e3,trig_rate/1e3,trigger_window*1e6),'FontSize',16);
242 for i = 1:DataPlotRangeBCO
244 if (TriggerBCO(i) >0)
246 plot([i i], [-.15 1].*y_max,'r--
','LineWidth
',1);
247 plot([i,i+PerTriggerBCO], [-.15 -.15].*y_max, 'r-
', 'LineWidth
', 1)
248 plot([i,i+PerTriggerBCO], [-.1 -.1].*y_max, 'k-
', 'LineWidth
', 1)
250 elseif (CollisionBCO(i) >0)
252 plot([i i], [-.1 1].*y_max,'k--
','LineWidth
',1);
253 plot([i,i+PerTriggerBCO], [-.1 -.1].*y_max, 'k-
', 'LineWidth
', 1)
263 bar( PlotThrottleDataBCO(nRing,:), 1 );
266 set(gca,'YDir
','normal
');
267 set(gca, 'XLim
',[0 DataPlotRangeBCO]);
268 % set(gca,'YLim
',[-4,nRing+1]);
272 % c.Label.String = 'FEE
data equavelent (bit)
';
273 % c.Label.FontSize = 14;
275 ThrottleDataRate * DAMCompressionFactor/1e9 ,...
276 TriggerDataRate * DAMCompressionFactor/1e9...
279 for i = 1:DataPlotRangeBCO
281 if (TriggerBCO(i) >0)
283 plot([i i], [-.15 1].*y_max,'r--
','LineWidth
',1);
284 plot([i,i+PerTriggerBCO], [-.15 -.15].*y_max, 'r-
', 'LineWidth
', 1)
285 plot([i,i+PerTriggerBCO], [-.1 -.1].*y_max, 'k-
', 'LineWidth
', 1)
287 elseif (CollisionBCO(i) >0)
289 plot([i i], [-.1 1].*y_max,'k--
','LineWidth
',1);
290 plot([i,i+PerTriggerBCO], [-.1 -.1].*y_max, 'k-
', 'LineWidth
', 1)
297 SaveCavas(SaveName,gcf);
301 DataRadialLayerRate = sum(DataBCO, 2) / TimeSpan;
305 FEEDataRate = [sum( DataRadialLayerRate(1:8))/5;
306 sum( DataRadialLayerRate((8+1):(8+16)))/8;
307 sum( DataRadialLayerRate((8+1+16):(8+16+16)))/12]...
308 /12/2;%12 sectors and two sides
311 FEEDataRate = [sum( DataRadialLayerRate(1:16))/6;
312 sum( DataRadialLayerRate((16+1):(16+16)))/8;
313 sum( DataRadialLayerRate((16+1+16):(16+16+16)))/12]...
314 /12/2;%12 sectors and two sides
321 %% FEE Data Rate Plot
327 bar( FEEDataRate/1e9 );
330 set(gca,'YDir
','normal
');
331 % set(gca, 'XLim
',[0 DataPlotRangeBCO]);
332 ylim = get(gca,'YLim
');
335 xlabel('Module Number
','FontSize',16);
337 % c.Label.String = 'FEE
data (bit)
';
338 % c.Label.FontSize = 14;
339 title(sprintf('FEE
data input to DAM. Total = %.0f Gbps @ %.0f kHz Collision, %.0f kHz Trigger %.0f
us Drift
',...
340 sum(sum(DataBCO))/TimeSpan/1e9,full_rate/1e3,trig_rate/1e3,trigger_window*1e6),'FontSize',12);
342 SaveCavas(SaveName,gcf);
344 %% Collision pile up histogram
346 nPileUpTrig = zeros( sum(TriggerBCO(PerTriggerBCO+1:(TimeSpanBCO-PerTriggerBCO))) ,1) ;
347 nPileUpRnd = zeros( TimeSpanBCO - 2*PerTriggerBCO ,1) ;
350 for i = PerTriggerBCO+1:(TimeSpanBCO-PerTriggerBCO)
354 nPileUpTrig(iTrig) = sum( CollisionBCO((i-PerTriggerBCO):(i+PerTriggerBCO)) );
359 nPileUpRnd(i- PerTriggerBCO + 1) = sum( CollisionBCO((i-PerTriggerBCO):(i+PerTriggerBCO)) );
370 hist(nPileUpTrig,0:20);
372 set(gca,'XLim
',[-1,11]);
374 ylabel('Count per bin
','FontSize',14);
375 title(sprintf('Collision trigger: <# collision
in TPC window> = %.2f @ %.0f kHz Collision, %.0f
us Drift
',...
376 mean(nPileUpTrig),...
377 full_rate/1e3,trigger_window*1e6),'FontSize',16);
381 hist(nPileUpRnd,0:20);
383 set(gca,'XLim
',[-1,11]);
385 ylabel('Count per bin
','FontSize',14);
386 title(sprintf('Random trigger: <# collision
in TPC window> = %.2f @ %.0f kHz Collision, %.0f
us Drift
',...
388 full_rate/1e3,trigger_window*1e6),'FontSize',16);
390 SaveCavas(SaveName,gcf);
394 % fprintf('Throttled
event / total = %.3f; Throttled
data / total = %.3f; Triggered
event / total = %.3f; Triggered
data / total = = %.3f\n
',...
395 % n_recorded/n, recorded_data/n, n_triggered./n, triggered_data/n);
396 fprintf('------------\
n');
399 full_rate/1e3,trig_rate/1e3, trigger_window*1e6, TimeSpan );
401 fprintf('per
event effective track = %.0f , per
event FEE
data = %.0f bits, total FEE
data rate = %.0f Gbps \
n',...
402 mean(sum(dEtaRingBCO,2)*180*2), sum(sum(dataBitRingBCO)), sum(sum(DataBCO))/TimeSpan/1e9 );
404 fprintf('Trigger
rate*drift window = %.2f;Full
rate*drift window= %.2f;Trigger
rate/full
rate = %.2f (
input)/%.2f(MC); \n
',...
405 trig_rate*trigger_window,full_rate*trigger_window,trig_rate/full_rate, sum(TriggerBCO)/sum(CollisionBCO) );
407 fprintf('throttled
data / total = %.3f; Triggered
data / total = %.3f; throttled/trigger = %.3f; Triggered
data/Per
event data = %.3f \n
',...
408 ThrottleDataRate/TotalDataRate,...
409 TriggerDataRate/TotalDataRate,...
410 ThrottleDataRate/TriggerDataRate,...
411 sum(sum(DataBCO.*TriggerAcceptBCO)) ./ (sum(sum(dataBitRingBCOAfterMask)).*sum(TriggerBCO))...
413 % sum(sum(DataBCO.*TriggerAcceptBCO)) ./ (sum(sum(dataBitRingBCOAfterMask)).*sum(CollisionBCO))...
415 fprintf('throttled data
rate = %.0f Gbps; Triggered data rate = %.0f Gbps\n
',...
416 ThrottleDataRate * DAMCompressionFactor/1e9 ,...
417 TriggerDataRate * DAMCompressionFactor/1e9);
418 fprintf('------------\
n');
420 %
fprintf(
'throttled event / total = %.3f; Triggered event / total = = %.3f; throttled/trigger = %.3f\n',...