CMS 3D CMS Logo

L1TriggerScalers.cc
Go to the documentation of this file.
1 
2 /*
3  * File: DataFormats/Scalers/src/L1TriggerScalers.cc (W.Badgett)
4  */
5 
8 
9 #include <iostream>
10 #include <cstdio>
11 
13  : version_(0),
14  collectionTimeSpecial_(0, 0),
15  orbitNumber_(0),
16  luminositySection_(0),
17  bunchCrossingErrors_(0),
18  collectionTimeSummary_(0, 0),
19  triggerNumber_(0),
20  eventNumber_(0),
21  finalTriggersDistributed_(0),
22  calibrationTriggers_(0),
23  randomTriggers_(0),
24  totalTestTriggers_(0),
25  finalTriggersGenerated_(0),
26  finalTriggersInvalidBC_(0),
27  deadTime_(0),
28  lostFinalTriggers_(0),
29  deadTimeActive_(0),
30  lostFinalTriggersActive_(0),
31  deadTimeActivePrivate_(0),
32  deadTimeActivePartition_(0),
33  deadTimeActiveThrottle_(0),
34  deadTimeActiveCalibration_(0),
35  deadTimeActiveTimeSlot_(0),
36  numberResets_(0),
37  collectionTimeDetails_(0, 0),
38  triggers_(nL1Triggers),
39  testTriggers_(nL1TestTriggers) {}
40 
43 
44  struct ScalersEventRecordRaw_v1 const* raw = reinterpret_cast<struct ScalersEventRecordRaw_v1 const*>(rawData);
45 
46  trigType_ = (raw->header >> 56) & 0xFULL;
47  eventID_ = (raw->header >> 32) & 0x00FFFFFFULL;
48  sourceID_ = (raw->header >> 8) & 0x00000FFFULL;
49  bunchNumber_ = (raw->header >> 20) & 0xFFFULL;
50 
51  version_ = raw->version;
52  if ((version_ == 1) || (version_ == 2)) {
58 
61 
63  eventNumber_ = raw->trig.EVENT_NR;
68 
71 
72  deadTime_ = raw->trig.DEADTIME;
82 
85 
86  for (int i = 0; i < ScalersRaw::N_L1_TRIGGERS_v1; i++) {
87  triggers_.push_back(raw->trig.ALGO_RATE[i]);
88  }
89 
90  for (int i = 0; i < ScalersRaw::N_L1_TEST_TRIGGERS_v1; i++) {
91  testTriggers_.push_back(raw->trig.TEST_RATE[i]);
92  }
93  }
94 }
95 
97 
99 std::ostream& operator<<(std::ostream& s, L1TriggerScalers const& c) {
100  s << "L1TriggerScalers Version:" << c.version() << " SourceID: " << c.sourceID() << std::endl;
101  constexpr size_t kLineBufferSize = 164;
102  char line[kLineBufferSize];
103  char zeitHeaven[128];
104  char zeitHell[128];
105  char zeitLimbo[128];
106  struct tm* horaHeaven;
107  struct tm* horaHell;
108  struct tm* horaLimbo;
109 
110  sprintf(line, " TrigType: %d EventID: %d BunchNumber: %d", c.trigType(), c.eventID(), c.bunchNumber());
111  s << line << std::endl;
112 
113  timespec secondsToHeaven = c.collectionTimeSummary();
114  horaHeaven = gmtime(&secondsToHeaven.tv_sec);
115  strftime(zeitHeaven, sizeof(zeitHeaven), "%Y.%m.%d %H:%M:%S", horaHeaven);
116  snprintf(line, kLineBufferSize, " CollectionTimeSummary: %s.%9.9d", zeitHeaven, (int)secondsToHeaven.tv_nsec);
117  s << line << std::endl;
118 
119  timespec secondsToHell = c.collectionTimeSpecial();
120  horaHell = gmtime(&secondsToHell.tv_sec);
121  strftime(zeitHell, sizeof(zeitHell), "%Y.%m.%d %H:%M:%S", horaHell);
122  snprintf(line, kLineBufferSize, " CollectionTimeSpecial: %s.%9.9d", zeitHell, (int)secondsToHell.tv_nsec);
123  s << line << std::endl;
124 
125  timespec secondsToLimbo = c.collectionTimeDetails();
126  horaLimbo = gmtime(&secondsToLimbo.tv_sec);
127  strftime(zeitLimbo, sizeof(zeitLimbo), "%Y.%m.%d %H:%M:%S", horaLimbo);
128  snprintf(line, kLineBufferSize, " CollectionTimeDetails: %s.%9.9d", zeitLimbo, (int)secondsToLimbo.tv_nsec);
129  s << line << std::endl;
130 
131  snprintf(line,
132  kLineBufferSize,
133  " LuminositySection: %15d BunchCrossingErrors: %15d",
134  c.luminositySection(),
135  c.bunchCrossingErrors());
136  s << line << std::endl;
137 
138  snprintf(line,
139  kLineBufferSize,
140  " TriggerNumber: %15d EventNumber: %15d",
141  c.triggerNumber(),
142  c.eventNumber());
143  s << line << std::endl;
144 
145  snprintf(line,
146  kLineBufferSize,
147  " TriggersDistributed: %10d TriggersGenerated: %15d",
148  c.finalTriggersDistributed(),
149  c.finalTriggersGenerated());
150  s << line << std::endl;
151 
152  snprintf(line,
153  kLineBufferSize,
154  " TriggersInvalidBC: %15d CalibrationTriggers: %15d",
155  c.finalTriggersInvalidBC(),
156  c.calibrationTriggers());
157  s << line << std::endl;
158 
159  snprintf(line,
160  kLineBufferSize,
161  " TestTriggers: %15d RandomTriggers: %15d",
162  c.totalTestTriggers(),
163  c.randomTriggers());
164  s << line << std::endl;
165 
166  snprintf(line,
167  kLineBufferSize,
168  " DeadTime: %15d DeadTimeActiveTimeSlot: %15ld",
169  c.numberResets(),
170  (long int)c.deadTime());
171  s << line << std::endl;
172 
173  snprintf(line,
174  kLineBufferSize,
175  " DeadTimeActive: %15ld DeadTimeActiveCalibration:%15ld",
176  (long int)c.deadTimeActive(),
177  (long int)c.deadTimeActiveCalibration());
178  s << line << std::endl;
179 
180  snprintf(line,
181  kLineBufferSize,
182  " LostTriggers: %15ld DeadTimeActivePartition: %15ld",
183  (long int)c.lostFinalTriggers(),
184  (long int)c.deadTimeActivePartition());
185  s << line << std::endl;
186 
187  snprintf(line,
188  kLineBufferSize,
189  " LostTriggersActive:%15ld DeadTimeActiveThrottle: %15ld",
190  (long int)c.lostFinalTriggersActive(),
191  (long int)c.deadTimeActiveThrottle());
192  s << line << std::endl;
193 
194  snprintf(line,
195  kLineBufferSize,
196  " NumberResets: %15d DeadTimeActivePrivate: %15ld",
197  c.numberResets(),
198  (long int)c.deadTimeActivePrivate());
199  s << line << std::endl;
200 
201  s << "Physics Triggers" << std::endl;
202  std::vector<unsigned int> triggers = c.triggers();
203  int length = triggers.size() / 4;
204  for (int i = 0; i < length; i++) {
205  snprintf(line,
206  kLineBufferSize,
207  " %3.3d: %10d %3.3d: %10d %3.3d: %10d %3.3d: %10d",
208  i,
209  triggers[i],
210  (i + length),
211  triggers[i + length],
212  (i + (length * 2)),
213  triggers[i + (length * 2)],
214  (i + (length * 3)),
215  triggers[i + (length * 3)]);
216  s << line << std::endl;
217  }
218 
219  s << "Test Triggers" << std::endl;
220  std::vector<unsigned int> testTriggers = c.testTriggers();
221  length = testTriggers.size() / 4;
222  for (int i = 0; i < length; i++) {
223  snprintf(line,
224  kLineBufferSize,
225  " %3.3d: %10d %3.3d: %10d %3.3d: %10d %3.3d: %10d",
226  i,
227  testTriggers[i],
228  (i + length),
229  testTriggers[i + length],
230  (i + (length * 2)),
231  testTriggers[i + (length * 2)],
232  (i + (length * 3)),
233  testTriggers[i + (length * 3)]);
234  s << line << std::endl;
235  }
236  return s;
237 }
unsigned int EVENT_NR
Definition: ScalersRaw.h:54
unsigned long long deadTimeActive_
unsigned long long deadTimeActivePrivate_
unsigned long long PRIV_DEADTIMEA
Definition: ScalersRaw.h:65
TimeSpec collectionTimeSpecial_
unsigned int eventID_
unsigned long long deadTimeActivePartition_
void set_tv_nsec(long value)
Definition: TimeSpec.h:19
unsigned long long header
Definition: ScalersRaw.h:182
unsigned int FINOR_GENERATED
Definition: ScalersRaw.h:59
unsigned int FINOR_IN_INVALID_BC
Definition: ScalersRaw.h:60
unsigned int trigType_
unsigned int LUMINOSITY_SEGMENT
Definition: ScalersRaw.h:48
unsigned int CAL_TRIGGER
Definition: ScalersRaw.h:56
unsigned int ALGO_RATE[ScalersRaw::N_L1_TRIGGERS_v1]
Definition: ScalersRaw.h:74
unsigned long long LOST_FINOR
Definition: ScalersRaw.h:62
struct TriggerScalersRaw_v1 trig
Definition: ScalersRaw.h:184
unsigned int finalTriggersDistributed_
unsigned int eventNumber_
unsigned int numberResets_
unsigned int orbitNumber_
unsigned long long DEADTIMEA
Definition: ScalersRaw.h:63
unsigned long long TIMESLOT_DEADTIMEA
Definition: ScalersRaw.h:69
virtual ~L1TriggerScalers()
unsigned long long deadTimeActiveTimeSlot_
unsigned int TRIGGER_NR
Definition: ScalersRaw.h:53
unsigned int totalTestTriggers_
std::vector< unsigned int > testTriggers_
unsigned long long LOST_FINORA
Definition: ScalersRaw.h:64
TimeSpec collectionTimeDetails_
unsigned int collectionTimeSummary_sec
Definition: ScalersRaw.h:51
unsigned int TEST_TRIGGER
Definition: ScalersRaw.h:58
unsigned short BC_ERRORS
Definition: ScalersRaw.h:49
unsigned int luminositySection_
unsigned int collectionTimeSpecial_sec
Definition: ScalersRaw.h:45
unsigned int ORBIT_NUMBER
Definition: ScalersRaw.h:47
unsigned long long THROTTLE_DEADTIMEA
Definition: ScalersRaw.h:67
unsigned long long deadTimeActiveCalibration_
std::ostream & operator<<(std::ostream &s, L1TriggerScalers const &c)
Pretty-print operator for L1TriggerScalers.
unsigned int triggerNumber_
unsigned int FINOR_DISTRIBUTED
Definition: ScalersRaw.h:55
unsigned int collectionTimeSpecial_nsec
Definition: ScalersRaw.h:46
unsigned long long deadTimeActiveThrottle_
unsigned int collectionTimeDetails_nsec
Definition: ScalersRaw.h:73
unsigned long long lostFinalTriggers_
unsigned int finalTriggersInvalidBC_
unsigned int NR_OF_RESETS
Definition: ScalersRaw.h:70
unsigned long long PTCSTATUS_DEADTIMEA
Definition: ScalersRaw.h:66
unsigned int collectionTimeDetails_sec
Definition: ScalersRaw.h:72
unsigned int RANDOM_TRIGGER
Definition: ScalersRaw.h:57
unsigned long long deadTime_
unsigned int sourceID_
unsigned int bunchNumber_
unsigned int TEST_RATE[ScalersRaw::N_L1_TEST_TRIGGERS_v1]
Definition: ScalersRaw.h:75
void set_tv_sec(long value)
Definition: TimeSpec.h:18
TimeSpec collectionTimeSummary_
unsigned int collectionTimeSummary_nsec
Definition: ScalersRaw.h:52
unsigned int calibrationTriggers_
unsigned long long lostFinalTriggersActive_
unsigned int randomTriggers_
unsigned long long DEADTIME
Definition: ScalersRaw.h:61
unsigned long long CALIBRATION_DEADTIMEA
Definition: ScalersRaw.h:68
unsigned int finalTriggersGenerated_
unsigned short bunchCrossingErrors_
std::vector< unsigned int > triggers_