CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 {
41 }
42 
43 L1TriggerScalers::L1TriggerScalers(const unsigned char * rawData)
44 {
46 
47  struct ScalersEventRecordRaw_v1 * raw
48  = (struct ScalersEventRecordRaw_v1 *)rawData;
49 
50  trigType_ = ( raw->header >> 56 ) & 0xFULL;
51  eventID_ = ( raw->header >> 32 ) & 0x00FFFFFFULL;
52  sourceID_ = ( raw->header >> 8 ) & 0x00000FFFULL;
53  bunchNumber_ = ( raw->header >> 20 ) & 0xFFFULL;
54 
55  version_ = raw->version;
56  if ( ( version_ == 1 ) || ( version_ == 2 ) )
57  {
58  collectionTimeSpecial_.set_tv_sec( static_cast<long>(
65 
66  collectionTimeSummary_.set_tv_sec( static_cast<long>(
70 
72  eventNumber_ = raw->trig.EVENT_NR;
77 
80 
81  deadTime_ = raw->trig.DEADTIME;
91 
92  collectionTimeDetails_.set_tv_sec( static_cast<long>(
96 
97  for ( int i=0; i<ScalersRaw::N_L1_TRIGGERS_v1; i++)
98  { triggers_.push_back( raw->trig.ALGO_RATE[i]);}
99 
100  for ( int i=0; i<ScalersRaw::N_L1_TEST_TRIGGERS_v1; i++)
101  { testTriggers_.push_back( raw->trig.TEST_RATE[i]);}
102  }
103 }
104 
106 
107 
109 std::ostream& operator<<(std::ostream& s,L1TriggerScalers const &c)
110 {
111  s << "L1TriggerScalers Version:" << c.version() <<
112  " SourceID: " << c.sourceID() << std::endl;
113  char line[128];
114  char zeitHeaven[128];
115  char zeitHell[128];
116  char zeitLimbo[128];
117  struct tm * horaHeaven;
118  struct tm * horaHell;
119  struct tm * horaLimbo;
120 
121  sprintf(line, " TrigType: %d EventID: %d BunchNumber: %d",
122  c.trigType(), c.eventID(), c.bunchNumber());
123  s << line << std::endl;
124 
125  timespec secondsToHeaven = c.collectionTimeSummary();
126  horaHeaven = gmtime(&secondsToHeaven.tv_sec);
127  strftime(zeitHeaven, sizeof(zeitHeaven), "%Y.%m.%d %H:%M:%S", horaHeaven);
128  sprintf(line, " CollectionTimeSummary: %s.%9.9d" ,
129  zeitHeaven, (int)secondsToHeaven.tv_nsec);
130  s << line << std::endl;
131 
132  timespec secondsToHell= c.collectionTimeSpecial();
133  horaHell = gmtime(&secondsToHell.tv_sec);
134  strftime(zeitHell, sizeof(zeitHell), "%Y.%m.%d %H:%M:%S", horaHell);
135  sprintf(line, " CollectionTimeSpecial: %s.%9.9d" ,
136  zeitHell, (int)secondsToHell.tv_nsec);
137  s << line << std::endl;
138 
139  timespec secondsToLimbo= c.collectionTimeDetails();
140  horaLimbo = gmtime(&secondsToLimbo.tv_sec);
141  strftime(zeitLimbo, sizeof(zeitLimbo), "%Y.%m.%d %H:%M:%S", horaLimbo);
142  sprintf(line, " CollectionTimeDetails: %s.%9.9d" ,
143  zeitLimbo, (int)secondsToLimbo.tv_nsec);
144  s << line << std::endl;
145 
146  sprintf(line,
147  " LuminositySection: %15d BunchCrossingErrors: %15d",
149  s << line << std::endl;
150 
151  sprintf(line,
152  " TriggerNumber: %15d EventNumber: %15d",
153  c.triggerNumber(), c.eventNumber());
154  s << line << std::endl;
155 
156  sprintf(line,
157  " TriggersDistributed: %10d TriggersGenerated: %15d",
160  s << line << std::endl;
161 
162  sprintf(line,
163  " TriggersInvalidBC: %15d CalibrationTriggers: %15d",
165  s << line << std::endl;
166 
167  sprintf(line,
168  " TestTriggers: %15d RandomTriggers: %15d",
170  s << line << std::endl;
171 
172  sprintf(line,
173  " DeadTime: %15d DeadTimeActiveTimeSlot: %15ld",
174  c.numberResets(), (long int)c.deadTime());
175  s << line << std::endl;
176 
177  sprintf(line,
178  " DeadTimeActive: %15ld DeadTimeActiveCalibration:%15ld",
179  (long int)c.deadTimeActive(),
180  (long int)c.deadTimeActiveCalibration());
181  s << line << std::endl;
182 
183  sprintf(line,
184  " LostTriggers: %15ld DeadTimeActivePartition: %15ld",
185  (long int)c.lostFinalTriggers(),
186  (long int)c.deadTimeActivePartition());
187  s << line << std::endl;
188 
189  sprintf(line,
190  " LostTriggersActive:%15ld DeadTimeActiveThrottle: %15ld",
191  (long int)c.lostFinalTriggersActive(),
192  (long int)c.deadTimeActiveThrottle());
193  s << line << std::endl;
194 
195  sprintf(line,
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  {
206  sprintf(line," %3.3d: %10d %3.3d: %10d %3.3d: %10d %3.3d: %10d",
207  i, triggers[i],
208  (i+length), triggers[i+length],
209  (i+(length*2)), triggers[i+(length*2)],
210  (i+(length*3)), triggers[i+(length*3)]);
211  s << line << std::endl;
212  }
213 
214  s << "Test Triggers" << std::endl;
215  std::vector<unsigned int> testTriggers = c.testTriggers();
216  length = testTriggers.size() / 4;
217  for ( int i=0; i<length; i++)
218  {
219  sprintf(line," %3.3d: %10d %3.3d: %10d %3.3d: %10d %3.3d: %10d",
220  i, testTriggers[i],
221  (i+length), testTriggers[i+length],
222  (i+(length*2)), testTriggers[i+(length*2)],
223  (i+(length*3)), testTriggers[i+(length*3)]);
224  s << line << std::endl;
225  }
226  return s;
227 }
unsigned int EVENT_NR
Definition: ScalersRaw.h:57
unsigned long long deadTimeActive_
int i
Definition: DBlmapReader.cc:9
unsigned long long deadTimeActivePrivate_
unsigned long long PRIV_DEADTIMEA
Definition: ScalersRaw.h:68
TimeSpec collectionTimeSpecial_
unsigned int eventID_
unsigned long long deadTimeActivePartition() const
unsigned long long deadTimeActivePartition_
unsigned long long lostFinalTriggers() const
unsigned int eventNumber() const
void set_tv_nsec(long value)
Definition: TimeSpec.h:27
timespec collectionTimeSpecial() const
timespec collectionTimeSummary() const
unsigned int numberResets() const
unsigned long long header
Definition: ScalersRaw.h:190
unsigned int FINOR_GENERATED
Definition: ScalersRaw.h:62
unsigned int FINOR_IN_INVALID_BC
Definition: ScalersRaw.h:63
unsigned int eventID() const
unsigned int totalTestTriggers() const
unsigned int trigType_
unsigned int LUMINOSITY_SEGMENT
Definition: ScalersRaw.h:51
unsigned int CAL_TRIGGER
Definition: ScalersRaw.h:59
unsigned int triggerNumber() const
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
unsigned int ALGO_RATE[ScalersRaw::N_L1_TRIGGERS_v1]
Definition: ScalersRaw.h:77
unsigned long long LOST_FINOR
Definition: ScalersRaw.h:65
struct TriggerScalersRaw_v1 trig
Definition: ScalersRaw.h:192
unsigned long long deadTimeActiveThrottle() const
unsigned int finalTriggersDistributed_
unsigned int eventNumber_
unsigned int numberResets_
unsigned int orbitNumber_
unsigned long long DEADTIMEA
Definition: ScalersRaw.h:66
unsigned int randomTriggers() const
unsigned long long deadTimeActive() const
unsigned long long lostFinalTriggersActive() const
std::vector< unsigned int > testTriggers() const
unsigned long long deadTimeActiveCalibration() const
unsigned long long TIMESLOT_DEADTIMEA
Definition: ScalersRaw.h:72
timespec collectionTimeDetails() const
virtual ~L1TriggerScalers()
unsigned long long deadTimeActiveTimeSlot_
unsigned int TRIGGER_NR
Definition: ScalersRaw.h:56
unsigned long long deadTime() const
unsigned int totalTestTriggers_
unsigned int sourceID() const
unsigned int finalTriggersDistributed() const
unsigned int finalTriggersGenerated() const
unsigned int bunchNumber() const
std::vector< unsigned int > testTriggers_
unsigned int luminositySection() const
unsigned long long LOST_FINORA
Definition: ScalersRaw.h:67
TimeSpec collectionTimeDetails_
unsigned int collectionTimeSummary_sec
Definition: ScalersRaw.h:54
unsigned int TEST_TRIGGER
Definition: ScalersRaw.h:61
unsigned short BC_ERRORS
Definition: ScalersRaw.h:52
unsigned int luminositySection_
unsigned int collectionTimeSpecial_sec
Definition: ScalersRaw.h:48
unsigned int ORBIT_NUMBER
Definition: ScalersRaw.h:50
unsigned long long THROTTLE_DEADTIMEA
Definition: ScalersRaw.h:70
unsigned long long deadTimeActiveCalibration_
unsigned int trigType() const
unsigned int triggerNumber_
unsigned int FINOR_DISTRIBUTED
Definition: ScalersRaw.h:58
unsigned int collectionTimeSpecial_nsec
Definition: ScalersRaw.h:49
unsigned int bunchCrossingErrors() const
unsigned long long deadTimeActiveThrottle_
unsigned int collectionTimeDetails_nsec
Definition: ScalersRaw.h:76
unsigned long long lostFinalTriggers_
unsigned int finalTriggersInvalidBC_
unsigned int NR_OF_RESETS
Definition: ScalersRaw.h:73
unsigned long long PTCSTATUS_DEADTIMEA
Definition: ScalersRaw.h:69
unsigned int collectionTimeDetails_sec
Definition: ScalersRaw.h:75
unsigned int RANDOM_TRIGGER
Definition: ScalersRaw.h:60
unsigned long long deadTime_
unsigned int sourceID_
unsigned int bunchNumber_
std::vector< unsigned int > triggers() const
unsigned int calibrationTriggers() const
unsigned int TEST_RATE[ScalersRaw::N_L1_TEST_TRIGGERS_v1]
Definition: ScalersRaw.h:78
int version() const
void set_tv_sec(long value)
Definition: TimeSpec.h:26
TimeSpec collectionTimeSummary_
unsigned int collectionTimeSummary_nsec
Definition: ScalersRaw.h:55
unsigned int calibrationTriggers_
unsigned int finalTriggersInvalidBC() const
unsigned long long lostFinalTriggersActive_
unsigned int randomTriggers_
unsigned long long deadTimeActivePrivate() const
unsigned long long DEADTIME
Definition: ScalersRaw.h:64
unsigned long long CALIBRATION_DEADTIMEA
Definition: ScalersRaw.h:71
unsigned int finalTriggersGenerated_
unsigned short bunchCrossingErrors_
std::vector< unsigned int > triggers_