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 }
L1TriggerScalers::~L1TriggerScalers
virtual ~L1TriggerScalers()
Definition: L1TriggerScalers.cc:96
ScalersEventRecordRaw_v1::version
int version
Definition: ScalersRaw.h:183
TriggerScalersRaw_v1::LOST_FINORA
unsigned long long LOST_FINORA
Definition: ScalersRaw.h:64
L1TriggerScalers::totalTestTriggers_
unsigned int totalTestTriggers_
Definition: L1TriggerScalers.h:110
TriggerScalersRaw_v1::NR_OF_RESETS
unsigned int NR_OF_RESETS
Definition: ScalersRaw.h:70
mps_fire.i
i
Definition: mps_fire.py:428
TriggerScalersRaw_v1::ORBIT_NUMBER
unsigned int ORBIT_NUMBER
Definition: ScalersRaw.h:47
TriggerScalersRaw_v1::TEST_TRIGGER
unsigned int TEST_TRIGGER
Definition: ScalersRaw.h:58
TriggerScalersRaw_v1::collectionTimeSummary_nsec
unsigned int collectionTimeSummary_nsec
Definition: ScalersRaw.h:52
L1TriggerScalers::collectionTimeDetails_
TimeSpec collectionTimeDetails_
Definition: L1TriggerScalers.h:124
L1TriggerScalers::luminositySection_
unsigned int luminositySection_
Definition: L1TriggerScalers.h:101
TriggerScalersRaw_v1::DEADTIMEA
unsigned long long DEADTIMEA
Definition: ScalersRaw.h:63
L1TriggerScalers::finalTriggersInvalidBC_
unsigned int finalTriggersInvalidBC_
Definition: L1TriggerScalers.h:112
l1tstage2_dqm_sourceclient-live_cfg.rawData
rawData
Definition: l1tstage2_dqm_sourceclient-live_cfg.py:162
TriggerScalersRaw_v1::PTCSTATUS_DEADTIMEA
unsigned long long PTCSTATUS_DEADTIMEA
Definition: ScalersRaw.h:66
TriggerScalersRaw_v1::TRIGGER_NR
unsigned int TRIGGER_NR
Definition: ScalersRaw.h:53
L1TriggerScalers::deadTime_
unsigned long long deadTime_
Definition: L1TriggerScalers.h:113
TimeSpec::set_tv_nsec
void set_tv_nsec(long value)
Definition: TimeSpec.h:19
L1TriggerScalers::deadTimeActiveCalibration_
unsigned long long deadTimeActiveCalibration_
Definition: L1TriggerScalers.h:120
L1TriggerScalers::triggerNumber_
unsigned int triggerNumber_
Definition: L1TriggerScalers.h:105
TriggerScalersRaw_v1::EVENT_NR
unsigned int EVENT_NR
Definition: ScalersRaw.h:54
L1TriggerScalers::sourceID_
unsigned int sourceID_
Definition: L1TriggerScalers.h:96
L1TriggerScalers::deadTimeActiveThrottle_
unsigned long long deadTimeActiveThrottle_
Definition: L1TriggerScalers.h:119
ScalersRaw.h
L1TriggerScalers::lostFinalTriggers_
unsigned long long lostFinalTriggers_
Definition: L1TriggerScalers.h:114
watchdog.const
const
Definition: watchdog.py:83
ScalersEventRecordRaw_v1::header
unsigned long long header
Definition: ScalersRaw.h:182
operator<<
std::ostream & operator<<(std::ostream &s, L1TriggerScalers const &c)
Pretty-print operator for L1TriggerScalers.
Definition: L1TriggerScalers.cc:99
L1TriggerScalers::L1TriggerScalers
L1TriggerScalers()
Definition: L1TriggerScalers.cc:12
alignCSCRings.s
s
Definition: alignCSCRings.py:92
L1TriggerScalers::collectionTimeSummary_
TimeSpec collectionTimeSummary_
Definition: L1TriggerScalers.h:104
L1TriggerScalers::bunchNumber_
unsigned int bunchNumber_
Definition: L1TriggerScalers.h:97
TimeSpec::set_tv_sec
void set_tv_sec(long value)
Definition: TimeSpec.h:18
TriggerScalersRaw_v1::LOST_FINOR
unsigned long long LOST_FINOR
Definition: ScalersRaw.h:62
L1TriggerScalers::lostFinalTriggersActive_
unsigned long long lostFinalTriggersActive_
Definition: L1TriggerScalers.h:116
ScalersEventRecordRaw_v1
Definition: ScalersRaw.h:181
L1TriggerScalers::finalTriggersGenerated_
unsigned int finalTriggersGenerated_
Definition: L1TriggerScalers.h:111
L1TriggerScalers.h
TriggerScalersRaw_v1::collectionTimeSpecial_nsec
unsigned int collectionTimeSpecial_nsec
Definition: ScalersRaw.h:46
ScalersRaw::N_L1_TRIGGERS_v1
Definition: ScalersRaw.h:30
L1TriggerScalers::calibrationTriggers_
unsigned int calibrationTriggers_
Definition: L1TriggerScalers.h:108
TriggerScalersRaw_v1::collectionTimeSummary_sec
unsigned int collectionTimeSummary_sec
Definition: ScalersRaw.h:51
L1TriggerScalers::randomTriggers_
unsigned int randomTriggers_
Definition: L1TriggerScalers.h:109
L1TriggerScalers::collectionTimeSpecial_
TimeSpec collectionTimeSpecial_
Definition: L1TriggerScalers.h:99
TriggerScalersRaw_v1::collectionTimeDetails_sec
unsigned int collectionTimeDetails_sec
Definition: ScalersRaw.h:72
L1TriggerScalers::bunchCrossingErrors_
unsigned short bunchCrossingErrors_
Definition: L1TriggerScalers.h:102
L1TriggerScalers::triggers_
std::vector< unsigned int > triggers_
Definition: L1TriggerScalers.h:125
L1TriggerScalers::deadTimeActive_
unsigned long long deadTimeActive_
Definition: L1TriggerScalers.h:115
ScalersRaw::N_L1_TEST_TRIGGERS_v1
Definition: ScalersRaw.h:31
L1TriggerScalers::deadTimeActivePrivate_
unsigned long long deadTimeActivePrivate_
Definition: L1TriggerScalers.h:117
createfilelist.int
int
Definition: createfilelist.py:10
TriggerScalersRaw_v1::CAL_TRIGGER
unsigned int CAL_TRIGGER
Definition: ScalersRaw.h:56
L1TriggerScalers::eventID_
unsigned int eventID_
Definition: L1TriggerScalers.h:95
ScalersEventRecordRaw_v1::trig
struct TriggerScalersRaw_v1 trig
Definition: ScalersRaw.h:184
L1TriggerScalers::deadTimeActivePartition_
unsigned long long deadTimeActivePartition_
Definition: L1TriggerScalers.h:118
TriggerScalersRaw_v1::THROTTLE_DEADTIMEA
unsigned long long THROTTLE_DEADTIMEA
Definition: ScalersRaw.h:67
TriggerScalersRaw_v1::FINOR_DISTRIBUTED
unsigned int FINOR_DISTRIBUTED
Definition: ScalersRaw.h:55
TriggerScalersRaw_v1::LUMINOSITY_SEGMENT
unsigned int LUMINOSITY_SEGMENT
Definition: ScalersRaw.h:48
L1TriggerScalers::version_
int version_
Definition: L1TriggerScalers.h:92
TriggerScalersRaw_v1::DEADTIME
unsigned long long DEADTIME
Definition: ScalersRaw.h:61
TriggerScalersRaw_v1::ALGO_RATE
unsigned int ALGO_RATE[ScalersRaw::N_L1_TRIGGERS_v1]
Definition: ScalersRaw.h:74
TriggerScalersRaw_v1::CALIBRATION_DEADTIMEA
unsigned long long CALIBRATION_DEADTIMEA
Definition: ScalersRaw.h:68
TriggerScalersRaw_v1::collectionTimeSpecial_sec
unsigned int collectionTimeSpecial_sec
Definition: ScalersRaw.h:45
TriggerScalersRaw_v1::TIMESLOT_DEADTIMEA
unsigned long long TIMESLOT_DEADTIMEA
Definition: ScalersRaw.h:69
TriggerScalersRaw_v1::FINOR_GENERATED
unsigned int FINOR_GENERATED
Definition: ScalersRaw.h:59
L1TriggerScalers::finalTriggersDistributed_
unsigned int finalTriggersDistributed_
Definition: L1TriggerScalers.h:107
L1TriggerScalers::eventNumber_
unsigned int eventNumber_
Definition: L1TriggerScalers.h:106
TriggerScalersRaw_v1::TEST_RATE
unsigned int TEST_RATE[ScalersRaw::N_L1_TEST_TRIGGERS_v1]
Definition: ScalersRaw.h:75
L1TriggerScalers::trigType_
unsigned int trigType_
Definition: L1TriggerScalers.h:94
TriggerScalersRaw_v1::FINOR_IN_INVALID_BC
unsigned int FINOR_IN_INVALID_BC
Definition: ScalersRaw.h:60
TriggerScalersRaw_v1::RANDOM_TRIGGER
unsigned int RANDOM_TRIGGER
Definition: ScalersRaw.h:57
TriggerScalersRaw_v1::collectionTimeDetails_nsec
unsigned int collectionTimeDetails_nsec
Definition: ScalersRaw.h:73
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
L1TriggerScalers::numberResets_
unsigned int numberResets_
Definition: L1TriggerScalers.h:122
TriggerScalersRaw_v1::PRIV_DEADTIMEA
unsigned long long PRIV_DEADTIMEA
Definition: ScalersRaw.h:65
L1TriggerScalers::deadTimeActiveTimeSlot_
unsigned long long deadTimeActiveTimeSlot_
Definition: L1TriggerScalers.h:121
mps_splice.line
line
Definition: mps_splice.py:76
L1TriggerScalers::orbitNumber_
unsigned int orbitNumber_
Definition: L1TriggerScalers.h:100
L1TriggerScalers
Definition: L1TriggerScalers.h:28
TriggerScalersRaw_v1::BC_ERRORS
unsigned short BC_ERRORS
Definition: ScalersRaw.h:49
L1TriggerScalers::testTriggers_
std::vector< unsigned int > testTriggers_
Definition: L1TriggerScalers.h:126