CMS 3D CMS Logo

Level1TriggerRates.cc
Go to the documentation of this file.
1 /*
2  * File: DataFormats/Scalers/src/Level1TriggerRates.cc (W.Badgett)
3  */
4 
7 
8 #include <iostream>
9 #include <cstdio>
10 
12  : version_(0),
13  collectionTime_(0, 0),
14  deltaNS_(0),
15  deltaT_(0.0),
16  gtTriggersRate_(0.0),
17  gtEventsRate_(0.0),
18  collectionTimeLumiSeg_(0, 0),
19  triggersPhysicsGeneratedFDLRate_(0.0),
20  triggersPhysicsLostRate_(0.0),
21  triggersPhysicsLostBeamActiveRate_(0.0),
22  triggersPhysicsLostBeamInactiveRate_(0.0),
23  l1AsPhysicsRate_(0.0),
24  l1AsRandomRate_(0.0),
25  l1AsTestRate_(0.0),
26  l1AsCalibrationRate_(0.0),
27  deadtimePercent_(0.0),
28  deadtimeBeamActivePercent_(0.0),
29  deadtimeBeamActiveTriggerRulesPercent_(0.0),
30  deadtimeBeamActiveCalibrationPercent_(0.0),
31  deadtimeBeamActivePrivateOrbitPercent_(0.0),
32  deadtimeBeamActivePartitionControllerPercent_(0.0),
33  deadtimeBeamActiveTimeSlotPercent_(0.0),
34  gtAlgoCountsRate_(Level1TriggerScalers::nLevel1Triggers),
35  gtTechCountsRate_(Level1TriggerScalers::nLevel1TestTriggers) {}
36 
39 }
40 
44 }
45 
48 }
49 
53 }
54 
56 
59 }
60 
62  version_ = t.version();
63 
64  collectionTime_.set_tv_sec(static_cast<long>(t.collectionTime().tv_sec));
65  collectionTime_.set_tv_nsec(t.collectionTime().tv_nsec);
66 
67  gtTriggersRate_ = t.gtTriggersRate();
68  gtEventsRate_ = t.gtEventsRate();
69 
70  collectionTimeLumiSeg_.set_tv_sec(static_cast<long>(t.collectionTimeLumiSeg().tv_sec));
71  collectionTimeLumiSeg_.set_tv_nsec(t.collectionTimeLumiSeg().tv_nsec);
72 
73  triggersPhysicsGeneratedFDLRate_ = Level1TriggerScalers::rateLS(t.triggersPhysicsGeneratedFDL(), run);
75  triggersPhysicsLostBeamActiveRate_ = Level1TriggerScalers::rateLS(t.triggersPhysicsLostBeamActive(), run);
76  triggersPhysicsLostBeamInactiveRate_ = Level1TriggerScalers::rateLS(t.triggersPhysicsLostBeamInactive(), run);
77 
82 
86  Level1TriggerScalers::percentLSActive(t.deadtimeBeamActiveTriggerRules(), run);
89  Level1TriggerScalers::percentLSActive(t.deadtimeBeamActivePrivateOrbit(), run);
91  Level1TriggerScalers::percentLSActive(t.deadtimeBeamActivePartitionController(), run);
93 
94  const std::vector<unsigned int> gtAlgoCounts = t.gtAlgoCounts();
95  for (std::vector<unsigned int>::const_iterator counts = gtAlgoCounts.begin(); counts != gtAlgoCounts.end();
96  ++counts) {
98  }
99 
100  const std::vector<unsigned int> gtTechCounts = t.gtTechCounts();
101  for (std::vector<unsigned int>::const_iterator counts = gtTechCounts.begin(); counts != gtTechCounts.end();
102  ++counts) {
104  }
105 
106  deltaNS_ = 0ULL;
107  deltaT_ = 0.0;
108 }
109 
112 }
113 
115  computeRates(t1, run);
116 
117  unsigned long long zeit1 = ((unsigned long long)t1.collectionTime().tv_sec * 1000000000ULL) |
118  ((unsigned long long)t1.collectionTime().tv_nsec);
119  unsigned long long zeit2 = ((unsigned long long)t2.collectionTime().tv_sec * 1000000000ULL) |
120  ((unsigned long long)t2.collectionTime().tv_nsec);
121 
122  deltaT_ = 0.0;
123  deltaNS_ = 0ULL;
124  if (zeit2 > zeit1) {
125  deltaNS_ = zeit2 - zeit1;
126  deltaT_ = ((double)deltaNS_) / 1.0E9;
127  gtTriggersRate_ = ((double)(t2.gtTriggers() - t1.gtTriggers())) / deltaT_;
128  gtEventsRate_ = ((double)(t2.gtEvents() - t1.gtEvents())) / deltaT_;
129  }
130 }
131 
133 std::ostream& operator<<(std::ostream& s, const Level1TriggerRates& c) {
134  constexpr size_t kLineBufferSize = 164;
135  char line[kLineBufferSize];
136  char zeitHeaven[128];
137  struct tm* horaHeaven;
138 
139  s << "Level1TriggerRates Version: " << c.version() << " Rates in Hz, DeltaT: ";
140 
141  if (c.deltaNS() > 0) {
142  s << c.deltaT() << " sec" << std::endl;
143  } else {
144  s << "n/a" << std::endl;
145  }
146 
147  struct timespec secondsToHeaven = c.collectionTime();
148  horaHeaven = gmtime(&secondsToHeaven.tv_sec);
149  strftime(zeitHeaven, sizeof(zeitHeaven), "%Y.%m.%d %H:%M:%S", horaHeaven);
150  snprintf(line, kLineBufferSize, " CollectionTime: %s.%9.9d", zeitHeaven, (int)secondsToHeaven.tv_nsec);
151  s << line << std::endl;
152 
153  snprintf(line, kLineBufferSize, " GtTriggersRate: %22.3f Hz", c.gtTriggersRate());
154  s << line << std::endl;
155 
156  snprintf(line, kLineBufferSize, " GtEventsRate: %22.3f Hz", c.gtEventsRate());
157  s << line << std::endl;
158 
159  secondsToHeaven = c.collectionTimeLumiSeg();
160  horaHeaven = gmtime(&secondsToHeaven.tv_sec);
161  strftime(zeitHeaven, sizeof(zeitHeaven), "%Y.%m.%d %H:%M:%S", horaHeaven);
162  snprintf(line, kLineBufferSize, " CollectionTimeLumiSeg: %s.%9.9d", zeitHeaven, (int)secondsToHeaven.tv_nsec);
163  s << line << std::endl;
164 
165  snprintf(line,
166  kLineBufferSize,
167  " TriggersPhysicsGeneratedFDLRate: %22.3f Hz",
168  c.triggersPhysicsGeneratedFDLRate());
169  s << line << std::endl;
170 
171  snprintf(
172  line, kLineBufferSize, " TriggersPhysicsLostRate: %22.3f Hz", c.triggersPhysicsLostRate());
173  s << line << std::endl;
174 
175  snprintf(line,
176  kLineBufferSize,
177  " TriggersPhysicsLostBeamActiveRate: %22.3f Hz",
178  c.triggersPhysicsLostBeamActiveRate());
179  s << line << std::endl;
180 
181  snprintf(line,
182  kLineBufferSize,
183  " TriggersPhysicsLostBeamInactiveRate: %22.3f Hz",
184  c.triggersPhysicsLostBeamInactiveRate());
185  s << line << std::endl;
186 
187  snprintf(line, kLineBufferSize, " L1AsPhysicsRate: %22.3f Hz", c.l1AsPhysicsRate());
188  s << line << std::endl;
189 
190  snprintf(line, kLineBufferSize, " L1AsRandomRate: %22.3f Hz", c.l1AsRandomRate());
191  s << line << std::endl;
192 
193  snprintf(line, kLineBufferSize, " L1AsTestRate: %22.3f Hz", c.l1AsTestRate());
194  s << line << std::endl;
195 
196  snprintf(line, kLineBufferSize, " L1AsCalibrationRate: %22.3f Hz", c.l1AsCalibrationRate());
197  s << line << std::endl;
198 
199  snprintf(line, kLineBufferSize, " DeadtimePercent: %22.3f %%", c.deadtimePercent());
200  s << line << std::endl;
201 
202  snprintf(
203  line, kLineBufferSize, " DeadtimeBeamActivePercent: %22.3f %%", c.deadtimeBeamActivePercent());
204  s << line << std::endl;
205 
206  snprintf(line,
207  kLineBufferSize,
208  " DeadtimeBeamActiveTriggerRulesPercent: %22.3f %%",
209  c.deadtimeBeamActiveTriggerRulesPercent());
210  s << line << std::endl;
211 
212  snprintf(line,
213  kLineBufferSize,
214  " DeadtimeBeamActiveCalibrationPercent: %22.3f %%",
215  c.deadtimeBeamActiveCalibrationPercent());
216  s << line << std::endl;
217 
218  snprintf(line,
219  kLineBufferSize,
220  " DeadtimeBeamActivePrivateOrbitPercent: %22.3f %%",
221  c.deadtimeBeamActivePrivateOrbitPercent());
222  s << line << std::endl;
223 
224  snprintf(line,
225  kLineBufferSize,
226  " DeadtimeBeamActivePartitionControllerPercent:%22.3f %%",
227  c.deadtimeBeamActivePartitionControllerPercent());
228  s << line << std::endl;
229 
230  snprintf(line,
231  kLineBufferSize,
232  " DeadtimeBeamActiveTimeSlotPercent: %22.3f %%",
233  c.deadtimeBeamActiveTimeSlotPercent());
234  s << line << std::endl;
235 
236  s << "Physics GtAlgoCountsRate, Hz" << std::endl;
237  const std::vector<double> gtAlgoCountsRate = c.gtAlgoCountsRate();
238  int length = gtAlgoCountsRate.size() / 4;
239  for (int i = 0; i < length; i++) {
240  snprintf(line,
241  kLineBufferSize,
242  " %3.3d: %12.3f %3.3d: %12.3f %3.3d: %12.3f %3.3d: %12.3f",
243  i,
244  gtAlgoCountsRate[i],
245  (i + length),
246  gtAlgoCountsRate[i + length],
247  (i + (length * 2)),
248  gtAlgoCountsRate[i + (length * 2)],
249  (i + (length * 3)),
250  gtAlgoCountsRate[i + (length * 3)]);
251  s << line << std::endl;
252  }
253 
254  s << "Test GtTechCountsRate, Hz" << std::endl;
255  const std::vector<double> gtTechCountsRate = c.gtTechCountsRate();
256  length = gtTechCountsRate.size() / 4;
257  for (int i = 0; i < length; i++) {
258  snprintf(line,
259  kLineBufferSize,
260  " %3.3d: %12.3f %3.3d: %12.3f %3.3d: %12.3f %3.3d: %12.3f",
261  i,
262  gtTechCountsRate[i],
263  (i + length),
264  gtTechCountsRate[i + length],
265  (i + (length * 2)),
266  gtTechCountsRate[i + (length * 2)],
267  (i + (length * 3)),
268  gtTechCountsRate[i + (length * 3)]);
269  s << line << std::endl;
270  }
271  return s;
272 }
RandomServiceHelper.t2
t2
Definition: RandomServiceHelper.py:257
Level1TriggerRates::deadtimePercent_
double deadtimePercent_
Definition: Level1TriggerRates.h:130
mps_fire.i
i
Definition: mps_fire.py:355
Level1TriggerScalers::rateLS
static double rateLS(unsigned long long counts)
Definition: Level1TriggerScalers.cc:143
Level1TriggerRates::l1AsTestRate_
double l1AsTestRate_
Definition: Level1TriggerRates.h:128
Level1TriggerRates::collectionTime_
TimeSpec collectionTime_
Definition: Level1TriggerRates.h:115
Level1TriggerRates::gtEventsRate_
double gtEventsRate_
Definition: Level1TriggerRates.h:119
Level1TriggerRates::computeRates
void computeRates(Level1TriggerScalers const &t1)
Definition: Level1TriggerRates.cc:57
Level1TriggerRates::deltaT_
double deltaT_
Definition: Level1TriggerRates.h:117
TimeSpec::set_tv_nsec
void set_tv_nsec(long value)
Definition: TimeSpec.h:19
Level1TriggerRates::gtTriggersRate_
double gtTriggersRate_
Definition: Level1TriggerRates.h:118
indexGen.s2
s2
Definition: indexGen.py:107
Level1TriggerRates::deltaNS_
unsigned long long deltaNS_
Definition: Level1TriggerRates.h:116
Level1TriggerRates::version_
int version_
Definition: Level1TriggerRates.h:113
Level1TriggerRates::triggersPhysicsLostBeamInactiveRate_
double triggersPhysicsLostBeamInactiveRate_
Definition: Level1TriggerRates.h:125
Level1TriggerRates::Level1TriggerRates
Level1TriggerRates()
Definition: Level1TriggerRates.cc:11
convertSQLiteXML.runNumber
runNumber
Definition: convertSQLiteXML.py:91
Level1TriggerRates::l1AsCalibrationRate_
double l1AsCalibrationRate_
Definition: Level1TriggerRates.h:129
alignCSCRings.s
s
Definition: alignCSCRings.py:92
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
Level1TriggerRates::deadtimeBeamActivePartitionControllerPercent_
double deadtimeBeamActivePartitionControllerPercent_
Definition: Level1TriggerRates.h:135
Level1TriggerScalers.h
Level1TriggerRates
Definition: Level1TriggerRates.h:30
Level1TriggerRates::deadtimeBeamActivePercent_
double deadtimeBeamActivePercent_
Definition: Level1TriggerRates.h:131
TimeSpec::set_tv_sec
void set_tv_sec(long value)
Definition: TimeSpec.h:18
OrderedSet.t
t
Definition: OrderedSet.py:90
Level1TriggerRates::deadtimeBeamActiveCalibrationPercent_
double deadtimeBeamActiveCalibrationPercent_
Definition: Level1TriggerRates.h:133
operator<<
std::ostream & operator<<(std::ostream &s, const Level1TriggerRates &c)
Pretty-print operator for Level1TriggerRates.
Definition: Level1TriggerRates.cc:133
Level1TriggerRates::gtAlgoCountsRate_
std::vector< double > gtAlgoCountsRate_
Definition: Level1TriggerRates.h:138
Level1TriggerRates::deadtimeBeamActiveTimeSlotPercent_
double deadtimeBeamActiveTimeSlotPercent_
Definition: Level1TriggerRates.h:136
Level1TriggerRates::deadtimeBeamActiveTriggerRulesPercent_
double deadtimeBeamActiveTriggerRulesPercent_
Definition: Level1TriggerRates.h:132
Level1TriggerRates::~Level1TriggerRates
virtual ~Level1TriggerRates()
Definition: Level1TriggerRates.cc:55
Level1TriggerScalers::percentLSActive
static double percentLSActive(unsigned long long counts)
Definition: Level1TriggerScalers.cc:175
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
Level1TriggerScalers::firstShortLSRun
Definition: Level1TriggerScalers.h:28
Level1TriggerRates::triggersPhysicsLostRate_
double triggersPhysicsLostRate_
Definition: Level1TriggerRates.h:123
Level1TriggerScalers::percentLS
static double percentLS(unsigned long long counts)
Definition: Level1TriggerScalers.cc:160
writedatasetfile.run
run
Definition: writedatasetfile.py:27
Level1TriggerRates::gtTechCountsRate_
std::vector< double > gtTechCountsRate_
Definition: Level1TriggerRates.h:139
Level1TriggerScalers
Definition: Level1TriggerScalers.h:26
dqmiodumpmetadata.counts
counts
Definition: dqmiodumpmetadata.py:25
Level1TriggerRates.h
Level1TriggerRates::triggersPhysicsGeneratedFDLRate_
double triggersPhysicsGeneratedFDLRate_
Definition: Level1TriggerRates.h:122
Level1TriggerRates::l1AsPhysicsRate_
double l1AsPhysicsRate_
Definition: Level1TriggerRates.h:126
Level1TriggerRates::deadtimeBeamActivePrivateOrbitPercent_
double deadtimeBeamActivePrivateOrbitPercent_
Definition: Level1TriggerRates.h:134
Level1TriggerRates::l1AsRandomRate_
double l1AsRandomRate_
Definition: Level1TriggerRates.h:127
mps_splice.line
line
Definition: mps_splice.py:76
Level1TriggerRates::triggersPhysicsLostBeamActiveRate_
double triggersPhysicsLostBeamActiveRate_
Definition: Level1TriggerRates.h:124
Level1TriggerRates::collectionTimeLumiSeg_
TimeSpec collectionTimeLumiSeg_
Definition: Level1TriggerRates.h:121