Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TPCRateData.m
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TPCRateData.m
1 close all
2 
3 clear all
4 
5 %%
6 
7 % n = 1000;
8 % full_rate = 100e3;
9 % trig_rate = 15e3;
10 % trigger_window = 18e-6;
11 
12 % n = 10000000;
13 n = 100000;
14 % n = 500000;
15 full_rate = 100e3;
16 % full_rate = 50e3;
17 trig_rate = 15e3;
18 % trigger_window = 13e-6;
19 trigger_window = 17.5e-6;
20 % trigger_window = 35e-6;
21 BCO = 10e6;
22 
23 
24 % Active region readout only
25 % 0.69
26 
27 trigger_window_in_BCO = int64(trigger_window * BCO);
29  exprnd(1/full_rate,n,1);
30 
31 DataLoadBCO = zeros(int64(n/full_rate*BCO*1.1), 1);
32 TriggerLoadBCO = zeros(int64(n/full_rate*BCO*1.1), 1);
33 
34 trig_event = binornd(1,trig_rate./full_rate, n, 1);
35 
36 DataRateBeforeTriggerPerkHz = (1/100e3)* 966. *.5*.6;
37 
38 
39 %%
40 
43 
47 
48 for i = 1:n
49 
50  start_time_bin = int64(current_time*BCO)+1;
51  % add data
52  DataLoadBCO(start_time_bin:(start_time_bin+trigger_window_in_BCO)) =...
53  DataLoadBCO(start_time_bin:(start_time_bin+trigger_window_in_BCO)) + 1;
54 
55  % trigger
56  if (trig_event(i) == 1)
58 
59  TriggerLoadBCO(start_time_bin:(start_time_bin+trigger_window_in_BCO)) =...
60  TriggerLoadBCO(start_time_bin:(start_time_bin+trigger_window_in_BCO)) + 1;
61 
63 
64  end
65 
66  % time elaps
67  current_time = current_time + event_time_gap(i);
68 
69 end
70 
71 %%
72 
73 % fprintf('Throttled event / total = %.3f; Throttled data / total = %.3f; Triggered event / total = %.3f; Triggered data / total = = %.3f\n',...
75 fprintf('------------\n');
76 
77 fprintf('full_rate = %.0f kHz; trig_rate= %.0f kHz; trigger_window= %.1f us; \n',...
78  full_rate/1e3,trig_rate/1e3, trigger_window*1e6 );
79 fprintf('Trigger rate*drift window = %.2f;Full rate*drift window= %.2f;Trigger rate/full rate= %.2f; \n',...
81 
82 fprintf('throttled data / total = %.3f; Triggered data / total = %.3f; throttled/trigger = %.3f \n',...
83  sum((TriggerLoadBCO >0) .* DataLoadBCO)/ sum(DataLoadBCO), sum(TriggerLoadBCO .* DataLoadBCO)/ sum(DataLoadBCO), ...
84  sum((TriggerLoadBCO >0) .* DataLoadBCO/ sum(TriggerLoadBCO .* DataLoadBCO)));
85 
86 fprintf('throttled data rate = %.0f Gbps; Triggered data rate = %.0f \n',...
87  sum((TriggerLoadBCO >0) .* DataLoadBCO)/ sum(DataLoadBCO) *full_rate*DataRateBeforeTriggerPerkHz ,...
88  sum(TriggerLoadBCO .* DataLoadBCO)/ sum(DataLoadBCO)*full_rate*DataRateBeforeTriggerPerkHz);
89 fprintf('------------\n');
90 
91 % fprintf('throttled event / total = %.3f; Triggered event / total = = %.3f; throttled/trigger = %.3f\n',...
93 
94 
95 %%
96 
97 
98 % recorded_data = 0;
99 % triggered_data = 0;
100 %
101 % n_recorded = 0;
102 % n_triggered = 0;
105 %
106 % for i = 1:n
107 %
108 % % trigger
109 % if (trig_event(i) == 1)
111 % end
112 %
113 % % readout
114 % if (current_trigger_window>0)
115 % % n_recorded = n_recorded + 1;
116 % % n_triggered = n_triggered + 1;
117 %
119 %
122 % elseif (recorded_window>=0)
125 % else
128 % end
129 %
131 %
134 % elseif (recorded_window>=0)
137 % else
140 % end
142 %
144 %
145 % % time elaps
148 %
149 % end
150 
151