CMS 3D CMS Logo

L1TriggerRates.cc
Go to the documentation of this file.
1 /*
2  * File: DataFormats/Scalers/src/L1TriggerRates.cc (W.Badgett)
3  */
4 
7 
8 #include <iostream>
9 #include <cstdio>
10 
12  version_(0),
13  collectionTimeSummary_(0,0),
14  deltaT_(0),
15  deltaTActive_(0),
16  triggerNumberRate_(0.0),
17  eventNumberRate_(0.0),
18  finalTriggersDistributedRate_(0.0),
19  finalTriggersGeneratedRate_(0.0),
20  randomTriggersRate_(0.0),
21  calibrationTriggersRate_(0.0),
22  totalTestTriggersRate_(0.0),
23  orbitNumberRate_(0.0),
24  numberResetsRate_(0.0),
25  deadTimePercent_(0.0),
26  deadTimeActivePercent_(0.0),
27  deadTimeActiveCalibrationPercent_(0.0),
28  deadTimeActivePrivatePercent_(0.0),
29  deadTimeActivePartitionPercent_(0.0),
30  deadTimeActiveThrottlePercent_(0.0),
31  deadTimeActiveTimeSlotPercent_(0.0),
32  finalTriggersInvalidBCPercent_(0.0),
33  lostFinalTriggersPercent_(0.0),
34  lostFinalTriggersActivePercent_(0.0),
35  triggersRate_(L1TriggerScalers::nL1Triggers),
36  testTriggersRate_(L1TriggerScalers::nL1TestTriggers),
37  triggerNumberRunRate_(0.0),
38  eventNumberRunRate_(0.0),
39  finalTriggersDistributedRunRate_(0.0),
40  finalTriggersGeneratedRunRate_(0.0),
41  randomTriggersRunRate_(0.0),
42  calibrationTriggersRunRate_(0.0),
43  totalTestTriggersRunRate_(0.0),
44  orbitNumberRunRate_(0.0),
45  numberResetsRunRate_(0.0),
46  deadTimeRunPercent_(0.0),
47  deadTimeActiveRunPercent_(0.0),
48  deadTimeActiveCalibrationRunPercent_(0.0),
49  deadTimeActivePrivateRunPercent_(0.0),
50  deadTimeActivePartitionRunPercent_(0.0),
51  deadTimeActiveThrottleRunPercent_(0.0),
52  deadTimeActiveTimeSlotRunPercent_(0.0),
53  finalTriggersInvalidBCRunPercent_(0.0),
54  lostFinalTriggersRunPercent_(0.0),
55  lostFinalTriggersActiveRunPercent_(0.0),
56  collectionTimeDetails_(0,0),
57  triggersRunRate_(L1TriggerScalers::nL1Triggers),
58  testTriggersRunRate_(L1TriggerScalers::nL1TestTriggers)
59 {
60 }
61 
63 {
65  computeRunRates(s);
66 }
67 
69  L1TriggerScalers const& s2)
70 {
72 
73  const L1TriggerScalers *t1 = &s1;
74  const L1TriggerScalers *t2 = &s2;
75 
76  // Choose the later sample to be t2
77  if ( t1->orbitNumber() > t2->orbitNumber())
78  {
79  t1 = &s2;
80  t2 = &s1;
81  }
82 
83  computeRunRates(*t2);
84  computeRates(*t1,*t2);
85 }
86 
88 
89 
91  L1TriggerScalers const& t2)
92 {
93  double deltaOrbit = (double)t2.orbitNumber() - (double)t1.orbitNumber();
94  if ( deltaOrbit > 0 )
95  {
96  // Convert orbits into crossings and time in seconds
97  double deltaBC = deltaOrbit * N_BX;
98  double deltaBCActive = deltaOrbit * N_BX_ACTIVE;
99  deltaT_ = deltaBC * BX_SPACING;
100  deltaTActive_ = deltaBCActive * BX_SPACING;
101 
102  triggerNumberRate_ = ((double)t2.triggerNumber()
103  - (double)t1.triggerNumber()) / deltaT_;
104  eventNumberRate_ = ((double)t2.eventNumber()
105  - (double)t1.eventNumber()) / deltaT_;
107  - (double)t1.finalTriggersDistributed()) / deltaT_;
109  - (double)t1.finalTriggersGenerated()) / deltaT_;
110  randomTriggersRate_ = ((double)t2.randomTriggers()
111  - (double)t1.randomTriggers()) / deltaT_;
113  - (double)t1.calibrationTriggers()) / deltaT_;
115  - (double)t1.totalTestTriggers()) / deltaT_;
116  orbitNumberRate_ = ((double)t2.orbitNumber()
117  - (double)t1.orbitNumber()) / deltaT_;
118  numberResetsRate_ = ((double)t2.numberResets()
119  - (double)t1.numberResets()) / deltaT_;
120 
121  deadTimePercent_ = 100.0 * ((double)t2.deadTime()
122  - (double)t1.deadTime()) / deltaBC;
123  deadTimeActivePercent_ = 100.0 * ((double)t2.deadTimeActive()
124  - (double)t1.deadTimeActive()) / deltaBCActive;
126  - (double)t1.deadTimeActiveCalibration()) / deltaBCActive;
128  - (double)t1.deadTimeActivePrivate()) / deltaBCActive;
130  - (double)t1.deadTimeActivePartition()) / deltaBCActive;
132  - (double)t1.deadTimeActiveThrottle()) / deltaBCActive;
134  - (double)t1.deadTimeActiveTimeSlot()) / deltaBCActive;
136  - (double)t1.finalTriggersInvalidBC()) / deltaBC;
137  lostFinalTriggersPercent_ = 100.0 * ((double)t2.lostFinalTriggers()
138  - (double)t1.lostFinalTriggers()) / deltaBC;
140  - (double)t1.lostFinalTriggersActive()) / deltaBCActive;
141 
142  int length1 = t1.triggers().size();
143  int length2 = t2.triggers().size();
144  int minLength;
145  ( length1 >= length2 ) ? minLength = length2 : minLength=length1;
146  std::vector<unsigned int> triggers1 = t1.triggers();
147  std::vector<unsigned int> triggers2 = t2.triggers();
148  for ( int i=0; i<minLength; i++)
149  {
150  double rate = ((double)triggers2[i] -
151  (double)triggers1[i] ) / deltaT_;
152  triggersRate_.push_back(rate);
153  }
154 
155 
156  length1 = t1.testTriggers().size();
157  length2 = t2.testTriggers().size();
158  ( length1 >= length2 ) ? minLength = length2 : minLength=length1;
159  std::vector<unsigned int> testTriggers1 = t1.testTriggers();
160  std::vector<unsigned int> testTriggers2 = t2.testTriggers();
161  for ( int i=0; i<minLength; i++)
162  {
163  double rate = ((double)testTriggers2[i] -
164  (double)testTriggers1[i] ) / deltaT_;
165  testTriggersRate_.push_back(rate);
166  }
167  }
168 }
169 
171 {
172  version_ = t.version();
173 
174  collectionTimeSummary_.set_tv_sec(static_cast<long>(t.collectionTimeSummary().tv_sec));
176 
177  collectionTimeDetails_.set_tv_sec(static_cast<long>(t.collectionTimeDetails().tv_sec));
179 
180  double deltaOrbit = (double)t.orbitNumber();
181  if ( deltaOrbit > 0 )
182  {
183  // Convert orbits into crossings and time in seconds
184  double deltaBC = deltaOrbit * N_BX;
185  double deltaBCActive = deltaOrbit * N_BX_ACTIVE;
186  deltaTRun_ = deltaBC * BX_SPACING;
187  deltaTRunActive_ = deltaBCActive * BX_SPACING;
188 
192  / deltaTRun_;
199 
200  deadTimeRunPercent_ = 100.0 * (double)t.deadTime() / deltaBC;
201  deadTimeActiveRunPercent_ = 100.0 * (double)t.deadTimeActive() / deltaBCActive;
202  deadTimeActiveCalibrationRunPercent_ = 100.0 * (double)t.deadTimeActiveCalibration() / deltaBCActive;
203  deadTimeActivePrivateRunPercent_ = 100.0 * (double)t.deadTimeActivePrivate() / deltaBCActive;
204  deadTimeActivePartitionRunPercent_ = 100.0 * (double)t.deadTimeActivePartition() / deltaBCActive;
205  deadTimeActiveThrottleRunPercent_ = 100.0 * (double)t.deadTimeActiveThrottle() / deltaBCActive;
206  deadTimeActiveTimeSlotRunPercent_ = 100.0 * (double)t.deadTimeActiveTimeSlot() / deltaBCActive;
207  finalTriggersInvalidBCRunPercent_ = 100.0 * (double)t.finalTriggersInvalidBC() / deltaBC;
208  lostFinalTriggersRunPercent_ = 100.0 * (double)t.lostFinalTriggers() / deltaBC;
209  lostFinalTriggersActiveRunPercent_ = 100.0 * (double)t.lostFinalTriggersActive() / deltaBCActive;
210 
211  int length = t.triggers().size();
212  for ( int i=0; i<length; i++)
213  {
214  double rate = ((double)t.triggers()[i]) / deltaTRun_;
215  triggersRunRate_.push_back(rate);
216  }
217  }
218 }
219 
220 
222 std::ostream& operator<<(std::ostream& s, const L1TriggerRates& c)
223 {
224  s << "L1TriggerRates Version: " << c.version()
225  << " Differential Rates in Hz, DeltaT: " <<
226  c.deltaT() << " sec" << std::endl;
227  char line[128];
228 
229  sprintf(line,
230  " TriggerNumber: %e EventNumber: %e",
232  s << line << std::endl;
233 
234  sprintf(line,
235  " TriggersDistributed: %e TriggersGenerated: %e",
237  s << line << std::endl;
238 
239  sprintf(line,
240  " RandomTriggers: %e CalibrationTriggers: %e",
242  s << line << std::endl;
243 
244  sprintf(line,
245  " TotalTestTriggers: %e OrbitNumber: %e",
247  s << line << std::endl;
248 
249  sprintf(line,
250  " NumberResets: %e DeadTime: %3.3f%%",
252  s << line << std::endl;
253 
254  sprintf(line,
255  " DeadTimeActive: %3.3f%% DeadTimeActiveCalibration: %3.3f%%",
258  s << line << std::endl;
259 
260  sprintf(line,
261  " LostTriggers: %3.3f%% DeadTimeActivePartition: %3.3f%%",
264  s << line << std::endl;
265 
266  sprintf(line,
267  " LostTriggersActive: %3.3f%% DeadTimeActiveThrottle: %3.3f%%",
270  s << line << std::endl;
271 
272  sprintf(line,
273  " TriggersInvalidBC: %3.3f%% DeadTimeActivePrivate: %3.3f%%",
276  s << line << std::endl;
277 
278  sprintf(line,
279  " DeadTimeActiveTimeSlot: %3.3f%%",
281  s << line << std::endl;
282 
283  std::vector<double> triggersRate = c.triggersRate();
284  int length = triggersRate.size() / 4;
285  for ( int i=0; i<length; i++)
286  {
287  sprintf(line," %3.3d:%e %3.3d:%e %3.3d:%e %3.3d:%e",
288  i, triggersRate[i],
289  (i+length), triggersRate[i+length],
290  (i+(length*2)), triggersRate[i+(length*2)],
291  (i+(length*3)), triggersRate[i+(length*3)]);
292  s << line << std::endl;
293  }
294 
295  std::vector<double> testTriggersRate = c.testTriggersRate();
296  length = testTriggersRate.size() / 4;
297  for ( int i=0; i<length; i++)
298  {
299  sprintf(line," %3.3d:%e %3.3d:%e %3.3d:%e %3.3d:%e",
300  i, testTriggersRate[i],
301  (i+length), testTriggersRate[i+length],
302  (i+(length*2)), testTriggersRate[i+(length*2)],
303  (i+(length*3)), testTriggersRate[i+(length*3)]);
304  s << line << std::endl;
305  }
306 
307 
308  // Run Average rates
309 
310  s << "L1TriggerRates Version: " << c.version()
311  << " Run Average Rates in Hz, DeltaT: " <<
312  c.deltaTRun() << " sec" << std::endl;
313 
314  sprintf(line,
315  " TriggerNumber: %e EventNumber: %e",
317  s << line << std::endl;
318 
319  sprintf(line,
320  " TriggersDistributed: %e TriggersGenerated: %e",
323  s << line << std::endl;
324 
325  sprintf(line,
326  " RandomTriggers: %e CalibrationTriggers: %e",
328  s << line << std::endl;
329 
330  sprintf(line,
331  " TotalTestTriggers: %e OrbitNumber: %e",
333  s << line << std::endl;
334 
335  sprintf(line,
336  " NumberResets: %e DeadTime: %3.3f%%",
338  s << line << std::endl;
339 
340  sprintf(line,
341  " DeadTimeActive: %3.3f%% DeadTimeActiveCalibration: %3.3f%%",
344  s << line << std::endl;
345 
346  sprintf(line,
347  " LostTriggers: %3.3f%% DeadTimeActivePartition: %3.3f%%",
350  s << line << std::endl;
351 
352  sprintf(line,
353  " LostTriggersActive: %3.3f%% DeadTimeActiveThrottle: %3.3f%%",
356  s << line << std::endl;
357 
358  sprintf(line,
359  " FinalTriggersInvalidBC: %3.3f%% DeadTimeActivePrivate: %3.3f%%",
362  s << line << std::endl;
363 
364  sprintf(line,
365  " DeadTimeActiveTimeSlot: %3.3f%%",
367  s << line << std::endl;
368 
369  std::vector<double> triggersRunRate = c.triggersRunRate();
370  length = triggersRunRate.size() / 4;
371  for ( int i=0; i<length; i++)
372  {
373  sprintf(line," %3.3d:%e %3.3d:%e %3.3d:%e %3.3d:%e",
374  i, triggersRunRate[i],
375  (i+length), triggersRunRate[i+length],
376  (i+(length*2)), triggersRunRate[i+(length*2)],
377  (i+(length*3)), triggersRunRate[i+(length*3)]);
378  s << line << std::endl;
379  }
380 
381  return s;
382 }
double numberResetsRate() const
double totalTestTriggersRunRate() const
double lostFinalTriggersActivePercent() const
double deadTimeActivePrivateRunPercent_
double lostFinalTriggersActiveRunPercent_
double deadTimeActiveCalibrationPercent_
double finalTriggersGeneratedRate_
unsigned long long deadTimeActivePartition() const
unsigned long long lostFinalTriggers() const
double finalTriggersInvalidBCRunPercent() const
std::vector< double > triggersRate_
unsigned int eventNumber() const
double orbitNumberRunRate_
void set_tv_nsec(long value)
Definition: TimeSpec.h:27
double finalTriggersInvalidBCPercent_
timespec collectionTimeSummary() const
double lostFinalTriggersRunPercent() const
double lostFinalTriggersActiveRunPercent() const
unsigned int numberResets() const
double deltaTRun() const
double deadTimeActiveThrottleRunPercent_
double eventNumberRunRate() const
double numberResetsRate_
double numberResetsRunRate_
double finalTriggersDistributedRunRate_
std::ostream & operator<<(std::ostream &s, const L1TriggerRates &c)
Pretty-print operator for L1TriggerRates.
double finalTriggersGeneratedRunRate() const
double deadTimeActiveRunPercent_
double finalTriggersGeneratedRate() const
double randomTriggersRate_
double deadTimeActivePartitionRunPercent() const
double deadTimeActiveTimeSlotPercent() const
double deadTimeActivePercent() const
double randomTriggersRunRate_
double deadTimePercent_
unsigned int totalTestTriggers() const
TimeSpec collectionTimeSummary_
int version() const
get the data
unsigned int triggerNumber() const
double deadTimeRunPercent() const
double finalTriggersDistributedRunRate() const
double deadTimePercent() const
double deadTimeActiveCalibrationRunPercent() const
unsigned long long deadTimeActiveThrottle() const
double triggerNumberRate_
double eventNumberRate() const
double deadTimeActivePartitionPercent() const
unsigned int randomTriggers() const
double finalTriggersDistributedRate() const
unsigned long long deadTimeActive() const
unsigned long long lostFinalTriggersActive() const
std::vector< unsigned int > testTriggers() const
unsigned long long deadTimeActiveCalibration() const
double calibrationTriggersRunRate() const
double numberResetsRunRate() const
double deadTimeActiveThrottlePercent() const
double deadTimeRunPercent_
double eventNumberRate_
double deltaT() const
timespec collectionTimeDetails() const
unsigned long long deadTime() const
double lostFinalTriggersActivePercent_
unsigned int finalTriggersDistributed() const
unsigned int finalTriggersGenerated() const
double deadTimeActivePartitionRunPercent_
double triggerNumberRate() const
double finalTriggersInvalidBCRunPercent_
double deadTimeActiveTimeSlotRunPercent() const
double deadTimeActivePercent_
double finalTriggersInvalidBCPercent() const
double deadTimeActiveThrottlePercent_
double randomTriggersRunRate() const
double calibrationTriggersRate() const
double deadTimeActiveTimeSlotPercent_
double orbitNumberRate() const
double totalTestTriggersRunRate_
double deadTimeActivePartitionPercent_
double calibrationTriggersRate_
double deadTimeActiveTimeSlotRunPercent_
std::vector< double > testTriggersRate_
virtual ~L1TriggerRates()
void computeRunRates(L1TriggerScalers const &t)
double lostFinalTriggersPercent_
double deadTimeActiveCalibrationRunPercent_
double triggerNumberRunRate() const
double totalTestTriggersRate() const
std::vector< double > triggersRunRate() const
double deadTimeActiveCalibrationPercent() const
void computeRates(L1TriggerScalers const &t1, L1TriggerScalers const &t2)
double triggerNumberRunRate_
double finalTriggersGeneratedRunRate_
std::vector< double > testTriggersRate() const
unsigned long long deadTimeActiveTimeSlot() const
double deadTimeActiveRunPercent() const
unsigned int orbitNumber() const
double calibrationTriggersRunRate_
double randomTriggersRate() const
double rate(double x)
Definition: Constants.cc:3
double deadTimeActiveThrottleRunPercent() const
double deadTimeActivePrivatePercent_
double deltaTRunActive_
double lostFinalTriggersPercent() const
std::vector< unsigned int > triggers() const
unsigned int calibrationTriggers() const
TimeSpec collectionTimeDetails_
double deadTimeActivePrivateRunPercent() const
int version() const
double eventNumberRunRate_
void set_tv_sec(long value)
Definition: TimeSpec.h:26
std::vector< double > triggersRunRate_
double deadTimeActivePrivatePercent() const
double orbitNumberRunRate() const
double orbitNumberRate_
unsigned int finalTriggersInvalidBC() const
double totalTestTriggersRate_
unsigned long long deadTimeActivePrivate() const
double lostFinalTriggersRunPercent_
std::vector< double > triggersRate() const
#define BX_SPACING
double finalTriggersDistributedRate_