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 {
37 }
38 
40 {
42 }
43 
45  int runNumber)
46 {
48  computeRates(s,runNumber);
49 }
50 
52  Level1TriggerScalers const& s2)
53 {
55 }
56 
58  Level1TriggerScalers const& s2,
59  int runNumber)
60 {
62  computeRates(s1,s2,runNumber);
63 }
64 
66 
67 
70 
72  int run)
73 {
74  version_ = t.version();
75 
76  collectionTime_.set_tv_sec(static_cast<long>(t.collectionTime().tv_sec));
78 
81 
82  collectionTimeLumiSeg_.set_tv_sec(static_cast<long>(t.collectionTimeLumiSeg().tv_sec));
84 
93 
98 
112 
113  const std::vector<unsigned int> gtAlgoCounts = t.gtAlgoCounts();
114  for ( std::vector<unsigned int>::const_iterator counts = gtAlgoCounts.begin();
115  counts != gtAlgoCounts.end(); ++counts)
116  {
117  gtAlgoCountsRate_.push_back(Level1TriggerScalers::rateLS(*counts,run));
118  }
119 
120  const std::vector<unsigned int> gtTechCounts = t.gtTechCounts();
121  for ( std::vector<unsigned int>::const_iterator counts = gtTechCounts.begin();
122  counts != gtTechCounts.end(); ++counts)
123  {
124  gtTechCountsRate_.push_back(Level1TriggerScalers::rateLS(*counts,run));
125  }
126 
127  deltaNS_ = 0ULL;
128  deltaT_ = 0.0;
129 }
130 
132  Level1TriggerScalers const& t2)
133 {
135 }
136 
138  Level1TriggerScalers const& t2,
139  int run)
140 {
141  computeRates(t1,run);
142 
143  unsigned long long zeit1 =
144  ( (unsigned long long)t1.collectionTime().tv_sec * 1000000000ULL)|
145  ( (unsigned long long)t1.collectionTime().tv_nsec );
146  unsigned long long zeit2 =
147  ( (unsigned long long)t2.collectionTime().tv_sec * 1000000000ULL)|
148  ( (unsigned long long)t2.collectionTime().tv_nsec );
149 
150  deltaT_ = 0.0;
151  deltaNS_ = 0ULL;
152  if ( zeit2 > zeit1 )
153  {
154  deltaNS_ = zeit2 - zeit1;
155  deltaT_ = ((double)deltaNS_) / 1.0E9;
156  gtTriggersRate_ =
157  ((double)(t2.gtTriggers()-t1.gtTriggers()))/deltaT_;
158  gtEventsRate_ =
159  ((double)(t2.gtEvents()-t1.gtEvents()))/deltaT_;
160  }
161 }
162 
163 
165 std::ostream& operator<<(std::ostream& s, const Level1TriggerRates& c)
166 {
167  constexpr size_t kLineBufferSize = 164;
168  char line[kLineBufferSize];
169  char zeitHeaven[128];
170  struct tm * horaHeaven;
171 
172  s << "Level1TriggerRates Version: " << c.version()
173  << " Rates in Hz, DeltaT: ";
174 
175  if ( c.deltaNS() > 0 )
176  {
177  s << c.deltaT() << " sec" << std::endl;
178  }
179  else
180  {
181  s << "n/a" << std::endl;
182  }
183 
184  struct timespec secondsToHeaven = c.collectionTime();
185  horaHeaven = gmtime(&secondsToHeaven.tv_sec);
186  strftime(zeitHeaven, sizeof(zeitHeaven), "%Y.%m.%d %H:%M:%S", horaHeaven);
187  snprintf(line, kLineBufferSize, " CollectionTime: %s.%9.9d" ,
188  zeitHeaven, (int)secondsToHeaven.tv_nsec);
189  s << line << std::endl;
190 
191  snprintf(line, kLineBufferSize,
192  " GtTriggersRate: %22.3f Hz",
193  c.gtTriggersRate());
194  s << line << std::endl;
195 
196  snprintf(line, kLineBufferSize,
197  " GtEventsRate: %22.3f Hz",
198  c.gtEventsRate());
199  s << line << std::endl;
200 
201  secondsToHeaven = c.collectionTimeLumiSeg();
202  horaHeaven = gmtime(&secondsToHeaven.tv_sec);
203  strftime(zeitHeaven, sizeof(zeitHeaven), "%Y.%m.%d %H:%M:%S", horaHeaven);
204  snprintf(line, kLineBufferSize, " CollectionTimeLumiSeg: %s.%9.9d" ,
205  zeitHeaven, (int)secondsToHeaven.tv_nsec);
206  s << line << std::endl;
207 
208  snprintf(line, kLineBufferSize,
209  " TriggersPhysicsGeneratedFDLRate: %22.3f Hz",
211  s << line << std::endl;
212 
213  snprintf(line, kLineBufferSize,
214  " TriggersPhysicsLostRate: %22.3f Hz",
216  s << line << std::endl;
217 
218  snprintf(line, kLineBufferSize,
219  " TriggersPhysicsLostBeamActiveRate: %22.3f Hz",
221  s << line << std::endl;
222 
223  snprintf(line, kLineBufferSize,
224  " TriggersPhysicsLostBeamInactiveRate: %22.3f Hz",
226  s << line << std::endl;
227 
228  snprintf(line, kLineBufferSize,
229  " L1AsPhysicsRate: %22.3f Hz",
230  c.l1AsPhysicsRate());
231  s << line << std::endl;
232 
233  snprintf(line, kLineBufferSize,
234  " L1AsRandomRate: %22.3f Hz",
235  c.l1AsRandomRate());
236  s << line << std::endl;
237 
238  snprintf(line, kLineBufferSize,
239  " L1AsTestRate: %22.3f Hz",
240  c.l1AsTestRate());
241  s << line << std::endl;
242 
243  snprintf(line, kLineBufferSize,
244  " L1AsCalibrationRate: %22.3f Hz",
245  c.l1AsCalibrationRate());
246  s << line << std::endl;
247 
248  snprintf(line, kLineBufferSize,
249  " DeadtimePercent: %22.3f %%",
250  c.deadtimePercent());
251  s << line << std::endl;
252 
253  snprintf(line, kLineBufferSize,
254  " DeadtimeBeamActivePercent: %22.3f %%",
256  s << line << std::endl;
257 
258  snprintf(line, kLineBufferSize,
259  " DeadtimeBeamActiveTriggerRulesPercent: %22.3f %%",
261  s << line << std::endl;
262 
263  snprintf(line, kLineBufferSize,
264  " DeadtimeBeamActiveCalibrationPercent: %22.3f %%",
266  s << line << std::endl;
267 
268  snprintf(line, kLineBufferSize,
269  " DeadtimeBeamActivePrivateOrbitPercent: %22.3f %%",
271  s << line << std::endl;
272 
273  snprintf(line, kLineBufferSize,
274  " DeadtimeBeamActivePartitionControllerPercent:%22.3f %%",
276  s << line << std::endl;
277 
278  snprintf(line, kLineBufferSize,
279  " DeadtimeBeamActiveTimeSlotPercent: %22.3f %%",
281  s << line << std::endl;
282 
283  s << "Physics GtAlgoCountsRate, Hz" << std::endl;
284  const std::vector<double> gtAlgoCountsRate = c.gtAlgoCountsRate();
285  int length = gtAlgoCountsRate.size() / 4;
286  for ( int i=0; i<length; i++)
287  {
288  snprintf(line, kLineBufferSize,
289  " %3.3d: %12.3f %3.3d: %12.3f %3.3d: %12.3f %3.3d: %12.3f",
290  i, gtAlgoCountsRate[i],
291  (i+length), gtAlgoCountsRate[i+length],
292  (i+(length*2)), gtAlgoCountsRate[i+(length*2)],
293  (i+(length*3)), gtAlgoCountsRate[i+(length*3)]);
294  s << line << std::endl;
295  }
296 
297  s << "Test GtTechCountsRate, Hz" << std::endl;
298  const std::vector<double> gtTechCountsRate = c.gtTechCountsRate();
299  length = gtTechCountsRate.size() / 4;
300  for ( int i=0; i<length; i++)
301  {
302  snprintf(line, kLineBufferSize,
303  " %3.3d: %12.3f %3.3d: %12.3f %3.3d: %12.3f %3.3d: %12.3f",
304  i, gtTechCountsRate[i],
305  (i+length), gtTechCountsRate[i+length],
306  (i+(length*2)), gtTechCountsRate[i+(length*2)],
307  (i+(length*3)), gtTechCountsRate[i+(length*3)]);
308  s << line << std::endl;
309  }
310  return s;
311 }
double deadtimeBeamActiveTimeSlotPercent_
double l1AsTestRate() const
static double rateLS(unsigned long long counts)
unsigned long long gtEvents() const
unsigned long long deadtimeBeamActive() const
unsigned long long deadtimeBeamActivePrivateOrbit() const
unsigned long long triggersPhysicsGeneratedFDL() const
double deadtimeBeamActivePartitionControllerPercent() const
double triggersPhysicsGeneratedFDLRate() const
void set_tv_nsec(long value)
Definition: TimeSpec.h:27
unsigned long long l1AsRandom() const
unsigned long long deltaNS_
std::vector< unsigned int > gtTechCounts() const
unsigned long long triggersPhysicsLost() const
unsigned long long triggersPhysicsLostBeamActive() const
double l1AsRandomRate() const
#define constexpr
double triggersPhysicsLostBeamActiveRate() const
unsigned long long l1AsCalibration() const
double gtTriggersRate() const
std::ostream & operator<<(std::ostream &s, const Level1TriggerRates &c)
Pretty-print operator for Level1TriggerRates.
std::vector< double > gtAlgoCountsRate() const
double triggersPhysicsLostBeamInactiveRate_
double triggersPhysicsLostBeamActiveRate_
double deadtimeBeamActiveCalibrationPercent_
int version() const
get the data
std::vector< double > gtAlgoCountsRate_
double triggersPhysicsLostBeamInactiveRate() const
double deadtimeBeamActivePercent() const
std::vector< unsigned int > gtAlgoCounts() const
double deadtimeBeamActiveTriggerRulesPercent_
double deadtimeBeamActiveTriggerRulesPercent() const
double deadtimeBeamActivePrivateOrbitPercent() const
unsigned long long l1AsPhysics() const
static double percentLSActive(unsigned long long counts)
unsigned long long deadtimeBeamActiveTriggerRules() const
unsigned long long deltaNS() const
timespec collectionTimeLumiSeg()
unsigned long long l1AsTest() const
double deadtimeBeamActiveTimeSlotPercent() const
double gtEventsRate() const
unsigned long long deadtime() const
unsigned long long gtTriggers() const
static double percentLS(unsigned long long counts)
float gtTriggersRate() const
void computeRates(Level1TriggerScalers const &t1)
std::vector< double > gtTechCountsRate_
struct timespec collectionTimeLumiSeg() const
unsigned long long deadtimeBeamActiveTimeSlot() const
double triggersPhysicsGeneratedFDLRate_
double deadtimeBeamActivePrivateOrbitPercent_
unsigned long long deadtimeBeamActiveCalibration() const
double deadtimePercent() const
double triggersPhysicsLostRate() const
double deadtimeBeamActiveCalibrationPercent() const
unsigned long long triggersPhysicsLostBeamInactive() const
void set_tv_sec(long value)
Definition: TimeSpec.h:26
std::vector< double > gtTechCountsRate() const
unsigned long long deadtimeBeamActivePartitionController() const
double l1AsCalibrationRate() const
double deadtimeBeamActivePartitionControllerPercent_
double l1AsPhysicsRate() const
struct timespec collectionTime() const
double deltaT() const