CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
62  computeRunRates(s);
63 }
64 
67 
68  const L1TriggerScalers* t1 = &s1;
69  const L1TriggerScalers* t2 = &s2;
70 
71  // Choose the later sample to be t2
72  if (t1->orbitNumber() > t2->orbitNumber()) {
73  t1 = &s2;
74  t2 = &s1;
75  }
76 
77  computeRunRates(*t2);
78  computeRates(*t1, *t2);
79 }
80 
82 
84  double deltaOrbit = (double)t2.orbitNumber() - (double)t1.orbitNumber();
85  if (deltaOrbit > 0) {
86  // Convert orbits into crossings and time in seconds
87  double deltaBC = deltaOrbit * N_BX;
88  double deltaBCActive = deltaOrbit * N_BX_ACTIVE;
89  deltaT_ = deltaBC * BX_SPACING;
90  deltaTActive_ = deltaBCActive * BX_SPACING;
91 
92  triggerNumberRate_ = ((double)t2.triggerNumber() - (double)t1.triggerNumber()) / deltaT_;
93  eventNumberRate_ = ((double)t2.eventNumber() - (double)t1.eventNumber()) / deltaT_;
95  ((double)t2.finalTriggersDistributed() - (double)t1.finalTriggersDistributed()) / deltaT_;
97  randomTriggersRate_ = ((double)t2.randomTriggers() - (double)t1.randomTriggers()) / deltaT_;
99  totalTestTriggersRate_ = ((double)t2.totalTestTriggers() - (double)t1.totalTestTriggers()) / deltaT_;
100  orbitNumberRate_ = ((double)t2.orbitNumber() - (double)t1.orbitNumber()) / deltaT_;
101  numberResetsRate_ = ((double)t2.numberResets() - (double)t1.numberResets()) / deltaT_;
102 
103  deadTimePercent_ = 100.0 * ((double)t2.deadTime() - (double)t1.deadTime()) / deltaBC;
104  deadTimeActivePercent_ = 100.0 * ((double)t2.deadTimeActive() - (double)t1.deadTimeActive()) / deltaBCActive;
106  100.0 * ((double)t2.deadTimeActiveCalibration() - (double)t1.deadTimeActiveCalibration()) / deltaBCActive;
108  100.0 * ((double)t2.deadTimeActivePrivate() - (double)t1.deadTimeActivePrivate()) / deltaBCActive;
110  100.0 * ((double)t2.deadTimeActivePartition() - (double)t1.deadTimeActivePartition()) / deltaBCActive;
112  100.0 * ((double)t2.deadTimeActiveThrottle() - (double)t1.deadTimeActiveThrottle()) / deltaBCActive;
114  100.0 * ((double)t2.deadTimeActiveTimeSlot() - (double)t1.deadTimeActiveTimeSlot()) / deltaBCActive;
116  100.0 * ((double)t2.finalTriggersInvalidBC() - (double)t1.finalTriggersInvalidBC()) / deltaBC;
117  lostFinalTriggersPercent_ = 100.0 * ((double)t2.lostFinalTriggers() - (double)t1.lostFinalTriggers()) / deltaBC;
119  100.0 * ((double)t2.lostFinalTriggersActive() - (double)t1.lostFinalTriggersActive()) / deltaBCActive;
120 
121  int length1 = t1.triggers().size();
122  int length2 = t2.triggers().size();
123  int minLength;
124  (length1 >= length2) ? minLength = length2 : minLength = length1;
125  std::vector<unsigned int> triggers1 = t1.triggers();
126  std::vector<unsigned int> triggers2 = t2.triggers();
127  for (int i = 0; i < minLength; i++) {
128  double rate = ((double)triggers2[i] - (double)triggers1[i]) / deltaT_;
129  triggersRate_.push_back(rate);
130  }
131 
132  length1 = t1.testTriggers().size();
133  length2 = t2.testTriggers().size();
134  (length1 >= length2) ? minLength = length2 : minLength = length1;
135  std::vector<unsigned int> testTriggers1 = t1.testTriggers();
136  std::vector<unsigned int> testTriggers2 = t2.testTriggers();
137  for (int i = 0; i < minLength; i++) {
138  double rate = ((double)testTriggers2[i] - (double)testTriggers1[i]) / deltaT_;
139  testTriggersRate_.push_back(rate);
140  }
141  }
142 }
143 
145  version_ = t.version();
146 
147  collectionTimeSummary_.set_tv_sec(static_cast<long>(t.collectionTimeSummary().tv_sec));
149 
150  collectionTimeDetails_.set_tv_sec(static_cast<long>(t.collectionTimeDetails().tv_sec));
152 
153  double deltaOrbit = (double)t.orbitNumber();
154  if (deltaOrbit > 0) {
155  // Convert orbits into crossings and time in seconds
156  double deltaBC = deltaOrbit * N_BX;
157  double deltaBCActive = deltaOrbit * N_BX_ACTIVE;
158  deltaTRun_ = deltaBC * BX_SPACING;
159  deltaTRunActive_ = deltaBCActive * BX_SPACING;
160 
170 
171  deadTimeRunPercent_ = 100.0 * (double)t.deadTime() / deltaBC;
172  deadTimeActiveRunPercent_ = 100.0 * (double)t.deadTimeActive() / deltaBCActive;
173  deadTimeActiveCalibrationRunPercent_ = 100.0 * (double)t.deadTimeActiveCalibration() / deltaBCActive;
174  deadTimeActivePrivateRunPercent_ = 100.0 * (double)t.deadTimeActivePrivate() / deltaBCActive;
175  deadTimeActivePartitionRunPercent_ = 100.0 * (double)t.deadTimeActivePartition() / deltaBCActive;
176  deadTimeActiveThrottleRunPercent_ = 100.0 * (double)t.deadTimeActiveThrottle() / deltaBCActive;
177  deadTimeActiveTimeSlotRunPercent_ = 100.0 * (double)t.deadTimeActiveTimeSlot() / deltaBCActive;
178  finalTriggersInvalidBCRunPercent_ = 100.0 * (double)t.finalTriggersInvalidBC() / deltaBC;
179  lostFinalTriggersRunPercent_ = 100.0 * (double)t.lostFinalTriggers() / deltaBC;
180  lostFinalTriggersActiveRunPercent_ = 100.0 * (double)t.lostFinalTriggersActive() / deltaBCActive;
181 
182  int length = t.triggers().size();
183  for (int i = 0; i < length; i++) {
184  double rate = ((double)t.triggers()[i]) / deltaTRun_;
185  triggersRunRate_.push_back(rate);
186  }
187  }
188 }
189 
191 std::ostream& operator<<(std::ostream& s, const L1TriggerRates& c) {
192  s << "L1TriggerRates Version: " << c.version() << " Differential Rates in Hz, DeltaT: " << c.deltaT() << " sec"
193  << std::endl;
194  char line[128];
195 
196  sprintf(line, " TriggerNumber: %e EventNumber: %e", c.triggerNumberRate(), c.eventNumberRate());
197  s << line << std::endl;
198 
199  sprintf(line,
200  " TriggersDistributed: %e TriggersGenerated: %e",
203  s << line << std::endl;
204 
205  sprintf(line,
206  " RandomTriggers: %e CalibrationTriggers: %e",
207  c.randomTriggersRate(),
209  s << line << std::endl;
210 
211  sprintf(
212  line, " TotalTestTriggers: %e OrbitNumber: %e", c.totalTestTriggersRate(), c.orbitNumberRate());
213  s << line << std::endl;
214 
215  sprintf(
216  line, " NumberResets: %e DeadTime: %3.3f%%", c.numberResetsRate(), c.deadTimePercent());
217  s << line << std::endl;
218 
219  sprintf(line,
220  " DeadTimeActive: %3.3f%% DeadTimeActiveCalibration: %3.3f%%",
223  s << line << std::endl;
224 
225  sprintf(line,
226  " LostTriggers: %3.3f%% DeadTimeActivePartition: %3.3f%%",
229  s << line << std::endl;
230 
231  sprintf(line,
232  " LostTriggersActive: %3.3f%% DeadTimeActiveThrottle: %3.3f%%",
235  s << line << std::endl;
236 
237  sprintf(line,
238  " TriggersInvalidBC: %3.3f%% DeadTimeActivePrivate: %3.3f%%",
241  s << line << std::endl;
242 
243  sprintf(line,
244  " DeadTimeActiveTimeSlot: %3.3f%%",
246  s << line << std::endl;
247 
248  std::vector<double> triggersRate = c.triggersRate();
249  int length = triggersRate.size() / 4;
250  for (int i = 0; i < length; i++) {
251  sprintf(line,
252  " %3.3d:%e %3.3d:%e %3.3d:%e %3.3d:%e",
253  i,
254  triggersRate[i],
255  (i + length),
256  triggersRate[i + length],
257  (i + (length * 2)),
258  triggersRate[i + (length * 2)],
259  (i + (length * 3)),
260  triggersRate[i + (length * 3)]);
261  s << line << std::endl;
262  }
263 
264  std::vector<double> testTriggersRate = c.testTriggersRate();
265  length = testTriggersRate.size() / 4;
266  for (int i = 0; i < length; i++) {
267  sprintf(line,
268  " %3.3d:%e %3.3d:%e %3.3d:%e %3.3d:%e",
269  i,
270  testTriggersRate[i],
271  (i + length),
272  testTriggersRate[i + length],
273  (i + (length * 2)),
274  testTriggersRate[i + (length * 2)],
275  (i + (length * 3)),
276  testTriggersRate[i + (length * 3)]);
277  s << line << std::endl;
278  }
279 
280  // Run Average rates
281 
282  s << "L1TriggerRates Version: " << c.version() << " Run Average Rates in Hz, DeltaT: " << c.deltaTRun() << " sec"
283  << std::endl;
284 
285  sprintf(
286  line, " TriggerNumber: %e EventNumber: %e", c.triggerNumberRunRate(), c.eventNumberRunRate());
287  s << line << std::endl;
288 
289  sprintf(line,
290  " TriggersDistributed: %e TriggersGenerated: %e",
293  s << line << std::endl;
294 
295  sprintf(line,
296  " RandomTriggers: %e CalibrationTriggers: %e",
299  s << line << std::endl;
300 
301  sprintf(line,
302  " TotalTestTriggers: %e OrbitNumber: %e",
304  c.orbitNumberRunRate());
305  s << line << std::endl;
306 
307  sprintf(line,
308  " NumberResets: %e DeadTime: %3.3f%%",
310  c.deadTimeRunPercent());
311  s << line << std::endl;
312 
313  sprintf(line,
314  " DeadTimeActive: %3.3f%% DeadTimeActiveCalibration: %3.3f%%",
317  s << line << std::endl;
318 
319  sprintf(line,
320  " LostTriggers: %3.3f%% DeadTimeActivePartition: %3.3f%%",
323  s << line << std::endl;
324 
325  sprintf(line,
326  " LostTriggersActive: %3.3f%% DeadTimeActiveThrottle: %3.3f%%",
329  s << line << std::endl;
330 
331  sprintf(line,
332  " FinalTriggersInvalidBC: %3.3f%% DeadTimeActivePrivate: %3.3f%%",
335  s << line << std::endl;
336 
337  sprintf(line, " DeadTimeActiveTimeSlot: %3.3f%%", c.deadTimeActiveTimeSlotRunPercent());
338  s << line << std::endl;
339 
340  std::vector<double> triggersRunRate = c.triggersRunRate();
341  length = triggersRunRate.size() / 4;
342  for (int i = 0; i < length; i++) {
343  sprintf(line,
344  " %3.3d:%e %3.3d:%e %3.3d:%e %3.3d:%e",
345  i,
346  triggersRunRate[i],
347  (i + length),
348  triggersRunRate[i + length],
349  (i + (length * 2)),
350  triggersRunRate[i + (length * 2)],
351  (i + (length * 3)),
352  triggersRunRate[i + (length * 3)]);
353  s << line << std::endl;
354  }
355 
356  return s;
357 }
double numberResetsRate() const
double totalTestTriggersRunRate() const
double lostFinalTriggersActivePercent() const
double deadTimeActivePrivateRunPercent_
double lostFinalTriggersActiveRunPercent_
double deadTimeActiveCalibrationPercent_
double finalTriggersGeneratedRate_
const edm::EventSetup & c
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:19
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_
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
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
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:18
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_