CMS 3D CMS Logo

LumiScalers.cc
Go to the documentation of this file.
1 
2 /*
3  * File: DataFormats/Scalers/src/LumiScalers.cc (W.Badgett)
4  */
5 
8 #include <cstdio>
9 #include <ostream>
10 
12  : trigType_(0),
13  eventID_(0),
14  sourceID_(0),
15  bunchNumber_(0),
16  version_(0),
17  normalization_(0.0),
18  deadTimeNormalization_(0.0),
19  lumiFill_(0.0),
20  lumiRun_(0.0),
21  liveLumiFill_(0.0),
22  liveLumiRun_(0.0),
23  instantLumi_(0.0),
24  instantLumiErr_(0.0),
25  instantLumiQlty_(0),
26  lumiETFill_(0.0),
27  lumiETRun_(0.0),
28  liveLumiETFill_(0.0),
29  liveLumiETRun_(0.0),
30  instantETLumi_(0.0),
31  instantETLumiErr_(0.0),
32  instantETLumiQlty_(0),
33  lumiOccFill_(nOcc),
34  lumiOccRun_(nOcc),
35  liveLumiOccFill_(nOcc),
36  liveLumiOccRun_(nOcc),
37  instantOccLumi_(nOcc),
38  instantOccLumiErr_(nOcc),
39  instantOccLumiQlty_(nOcc),
40  lumiNoise_(nOcc),
41  sectionNumber_(0),
42  startOrbit_(0),
43  numOrbits_(0),
44  pileup_(0.0),
45  pileupRMS_(0.0),
46  bunchLumi_(0.0),
47  spare_(0.0) {}
48 
49 LumiScalers::LumiScalers(const unsigned char* rawData) {
50  LumiScalers();
51 
52  struct ScalersEventRecordRaw_v1 const* raw = reinterpret_cast<struct ScalersEventRecordRaw_v1 const*>(rawData);
53  trigType_ = (raw->header >> 56) & 0xFULL;
54  eventID_ = (raw->header >> 32) & 0x00FFFFFFULL;
55  sourceID_ = (raw->header >> 8) & 0x00000FFFULL;
56  bunchNumber_ = (raw->header >> 20) & 0xFFFULL;
57  version_ = raw->version;
58 
59  struct LumiScalersRaw_v1 const* lumi = nullptr;
60 
61  if (version_ >= 1) {
62  if (version_ <= 2) {
63  lumi = &(raw->lumi);
64  } else {
65  struct ScalersEventRecordRaw_v3 const* raw3 = reinterpret_cast<struct ScalersEventRecordRaw_v3 const*>(rawData);
66  lumi = &(raw3->lumi);
67  }
68  collectionTime_.set_tv_sec(static_cast<long>(lumi->collectionTime_sec));
69  collectionTime_.set_tv_nsec(lumi->collectionTime_nsec);
70  deadTimeNormalization_ = lumi->DeadtimeNormalization;
71  normalization_ = lumi->Normalization;
72  lumiFill_ = lumi->LumiFill;
73  lumiRun_ = lumi->LumiRun;
74  liveLumiFill_ = lumi->LiveLumiFill;
75  liveLumiRun_ = lumi->LiveLumiRun;
76  instantLumi_ = lumi->InstantLumi;
77  instantLumiErr_ = lumi->InstantLumiErr;
78  instantLumiQlty_ = lumi->InstantLumiQlty;
79  lumiETFill_ = lumi->LumiETFill;
80  lumiETRun_ = lumi->LumiETRun;
81  liveLumiETFill_ = lumi->LiveLumiETFill;
82  liveLumiETRun_ = lumi->LiveLumiETRun;
83  instantETLumi_ = lumi->InstantETLumi;
84  instantETLumiErr_ = lumi->InstantETLumiErr;
85  instantETLumiQlty_ = lumi->InstantETLumiQlty;
86  for (int i = 0; i < ScalersRaw::N_LUMI_OCC_v1; i++) {
87  lumiOccFill_.push_back(lumi->LumiOccFill[i]);
88  lumiOccRun_.push_back(lumi->LumiOccRun[i]);
89  liveLumiOccFill_.push_back(lumi->LiveLumiOccFill[i]);
90  liveLumiOccRun_.push_back(lumi->LiveLumiOccRun[i]);
91  instantOccLumi_.push_back(lumi->InstantOccLumi[i]);
92  instantOccLumiErr_.push_back(lumi->InstantOccLumiErr[i]);
93  instantOccLumiQlty_.push_back(lumi->InstantOccLumiQlty[i]);
94  lumiNoise_.push_back(lumi->lumiNoise[i]);
95  }
96  sectionNumber_ = lumi->sectionNumber;
97  startOrbit_ = lumi->startOrbit;
98  numOrbits_ = lumi->numOrbits;
99 
100  if (version_ >= 7) {
102  float const* fspare = reinterpret_cast<float const*>(raw6->spare);
105  if (version_ >= 8) {
108  } else {
109  bunchLumi_ = (float)0.0;
110  spare_ = (float)0.0;
111  }
112  } else {
113  pileup_ = (float)0.0;
114  pileupRMS_ = (float)0.0;
115  bunchLumi_ = (float)0.0;
116  spare_ = (float)0.0;
117  }
118  }
119 }
120 
122 
124 std::ostream& operator<<(std::ostream& s, const LumiScalers& c) {
125  char zeit[128];
126  constexpr size_t kLineBufferSize = 157;
127  char line[kLineBufferSize];
128  struct tm* hora;
129 
130  s << "LumiScalers Version: " << c.version() << " SourceID: " << c.sourceID() << std::endl;
131 
132  timespec ts = c.collectionTime();
133  hora = gmtime(&ts.tv_sec);
134  strftime(zeit, sizeof(zeit), "%Y.%m.%d %H:%M:%S", hora);
135  snprintf(line, kLineBufferSize, " CollectionTime: %s.%9.9d", zeit, (int)ts.tv_nsec);
136  s << line << std::endl;
137 
138  snprintf(line,
139  kLineBufferSize,
140  " TrigType: %d EventID: %d BunchNumber: %d",
141  c.trigType(),
142  c.eventID(),
143  c.bunchNumber());
144  s << line << std::endl;
145 
146  snprintf(line,
147  kLineBufferSize,
148  " SectionNumber: %10d StartOrbit: %10d NumOrbits: %10d",
149  c.sectionNumber(),
150  c.startOrbit(),
151  c.numOrbits());
152  s << line << std::endl;
153 
154  snprintf(line,
155  kLineBufferSize,
156  " Normalization: %e DeadTimeNormalization: %e",
157  c.normalization(),
158  c.deadTimeNormalization());
159  s << line << std::endl;
160 
161  // Integrated Luminosity
162 
163  snprintf(line, kLineBufferSize, " LumiFill: %e LumiRun: %e", c.lumiFill(), c.lumiRun());
164  s << line << std::endl;
165  snprintf(
166  line, kLineBufferSize, " LiveLumiFill: %e LiveLumiRun: %e", c.liveLumiFill(), c.liveLumiRun());
167  s << line << std::endl;
168 
169  snprintf(line, kLineBufferSize, " LumiETFill: %e LumiETRun: %e", c.lumiFill(), c.lumiRun());
170  s << line << std::endl;
171 
172  snprintf(
173  line, kLineBufferSize, " LiveLumiETFill: %e LiveLumETiRun: %e", c.liveLumiETFill(), c.liveLumiETRun());
174  s << line << std::endl;
175 
176  int length = c.instantOccLumi().size();
177  for (int i = 0; i < length; i++) {
178  snprintf(line,
179  kLineBufferSize,
180  " LumiOccFill[%d]: %e LumiOccRun[%d]: %e",
181  i,
182  c.lumiOccFill()[i],
183  i,
184  c.lumiOccRun()[i]);
185  s << line << std::endl;
186 
187  snprintf(line,
188  kLineBufferSize,
189  " LiveLumiOccFill[%d]: %e LiveLumiOccRun[%d]: %e",
190  i,
191  c.liveLumiOccFill()[i],
192  i,
193  c.liveLumiOccRun()[i]);
194  s << line << std::endl;
195  }
196 
197  // Instantaneous Luminosity
198 
199  snprintf(line,
200  kLineBufferSize,
201  " InstantLumi: %e Err: %e Qlty: %d",
202  c.instantLumi(),
203  c.instantLumiErr(),
204  c.instantLumiQlty());
205  s << line << std::endl;
206 
207  snprintf(line,
208  kLineBufferSize,
209  " InstantETLumi: %e Err: %e Qlty: %d",
210  c.instantETLumi(),
211  c.instantETLumiErr(),
212  c.instantETLumiQlty());
213  s << line << std::endl;
214 
215  for (int i = 0; i < length; i++) {
216  snprintf(line,
217  kLineBufferSize,
218  " InstantOccLumi[%d]: %e Err: %e Qlty: %d",
219  i,
220  c.instantOccLumi()[i],
221  c.instantOccLumiErr()[i],
222  c.instantOccLumiQlty()[i]);
223  s << line << std::endl;
224  snprintf(line, kLineBufferSize, " LumiNoise[%d]: %e", i, c.lumiNoise()[i]);
225  s << line << std::endl;
226  }
227 
228  snprintf(line, kLineBufferSize, " Pileup: %f PileupRMS: %f", c.pileup(), c.pileupRMS());
229  s << line << std::endl;
230 
231  snprintf(line, kLineBufferSize, " BunchLumi: %f Spare: %f", c.bunchLumi(), c.spare());
232  s << line << std::endl;
233 
234  return s;
235 }
ScalersEventRecordRaw_v1::version
int version
Definition: ScalersRaw.h:183
LumiScalers::lumiETRun_
float lumiETRun_
Definition: LumiScalers.h:114
LumiScalers.h
ScalersRaw::I_SPARE_BUNCHLUMI_v8
Definition: ScalersRaw.h:38
mps_fire.i
i
Definition: mps_fire.py:355
ScalersRaw::I_SPARE_PILEUPRMS_v7
Definition: ScalersRaw.h:37
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
LumiScalers::numOrbits_
unsigned int numOrbits_
Definition: LumiScalers.h:133
LumiScalers
Definition: LumiScalers.h:28
LumiScalers::startOrbit_
unsigned int startOrbit_
Definition: LumiScalers.h:132
l1tstage2_dqm_sourceclient-live_cfg.rawData
rawData
Definition: l1tstage2_dqm_sourceclient-live_cfg.py:156
ScalersRaw::N_LUMI_OCC_v1
Definition: ScalersRaw.h:32
LumiScalers::pileup_
float pileup_
Definition: LumiScalers.h:135
LumiScalers::trigType_
unsigned int trigType_
Definition: LumiScalers.h:93
TimeSpec::set_tv_nsec
void set_tv_nsec(long value)
Definition: TimeSpec.h:19
LumiScalersRaw_v1
Definition: ScalersRaw.h:116
ScalersEventRecordRaw_v6::spare
unsigned long long spare[ScalersRaw::N_SPARE_v5]
Definition: ScalersRaw.h:252
ScalersEventRecordRaw_v3
Definition: ScalersRaw.h:200
ScalersRaw.h
LumiScalers::instantLumiQlty_
unsigned char instantLumiQlty_
Definition: LumiScalers.h:111
LumiScalers::LumiScalers
LumiScalers()
Definition: LumiScalers.cc:11
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, const LumiScalers &c)
Pretty-print operator for LumiScalers.
Definition: LumiScalers.cc:124
LumiScalers::lumiETFill_
float lumiETFill_
Definition: LumiScalers.h:113
LumiScalers::sectionNumber_
unsigned int sectionNumber_
Definition: LumiScalers.h:131
LumiScalers::instantOccLumiQlty_
std::vector< unsigned char > instantOccLumiQlty_
Definition: LumiScalers.h:128
LumiScalers::pileupRMS_
float pileupRMS_
Definition: LumiScalers.h:136
LumiScalers::normalization_
float normalization_
Definition: LumiScalers.h:102
LumiScalers::liveLumiFill_
float liveLumiFill_
Definition: LumiScalers.h:107
alignCSCRings.s
s
Definition: alignCSCRings.py:92
LumiScalers::instantOccLumiErr_
std::vector< float > instantOccLumiErr_
Definition: LumiScalers.h:127
TimeSpec::set_tv_sec
void set_tv_sec(long value)
Definition: TimeSpec.h:18
ScalersEventRecordRaw_v1
Definition: ScalersRaw.h:181
LumiScalers::instantETLumiQlty_
unsigned char instantETLumiQlty_
Definition: LumiScalers.h:120
ScalersRaw::I_SPARE_SPARE_v8
Definition: ScalersRaw.h:39
LumiScalers::lumiOccRun_
std::vector< float > lumiOccRun_
Definition: LumiScalers.h:123
LumiScalers::version_
int version_
Definition: LumiScalers.h:98
LumiScalers::spare_
float spare_
Definition: LumiScalers.h:138
LumiScalers::instantOccLumi_
std::vector< float > instantOccLumi_
Definition: LumiScalers.h:126
LumiScalers::liveLumiETRun_
float liveLumiETRun_
Definition: LumiScalers.h:116
LumiScalers::instantLumi_
float instantLumi_
Definition: LumiScalers.h:109
ScalersEventRecordRaw_v6
Definition: ScalersRaw.h:239
LumiScalers::bunchNumber_
unsigned int bunchNumber_
Definition: LumiScalers.h:96
LumiScalers::liveLumiETFill_
float liveLumiETFill_
Definition: LumiScalers.h:115
LumiScalers::collectionTime_
TimeSpec collectionTime_
Definition: LumiScalers.h:100
LumiScalers::deadTimeNormalization_
float deadTimeNormalization_
Definition: LumiScalers.h:103
LumiScalers::liveLumiRun_
float liveLumiRun_
Definition: LumiScalers.h:108
LumiScalers::lumiFill_
float lumiFill_
Definition: LumiScalers.h:105
LumiScalers::lumiNoise_
std::vector< float > lumiNoise_
Definition: LumiScalers.h:129
ScalersEventRecordRaw_v3::lumi
struct LumiScalersRaw_v1 lumi
Definition: ScalersRaw.h:204
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
LumiScalers::eventID_
unsigned int eventID_
Definition: LumiScalers.h:94
LumiScalers::instantLumiErr_
float instantLumiErr_
Definition: LumiScalers.h:110
LumiScalers::instantETLumiErr_
float instantETLumiErr_
Definition: LumiScalers.h:118
LumiScalers::bunchLumi_
float bunchLumi_
Definition: LumiScalers.h:137
ScalersRaw::I_SPARE_PILEUP_v7
Definition: ScalersRaw.h:36
LumiScalers::instantETLumi_
float instantETLumi_
Definition: LumiScalers.h:117
LumiScalers::sourceID_
unsigned int sourceID_
Definition: LumiScalers.h:95
LumiScalers::lumiRun_
float lumiRun_
Definition: LumiScalers.h:106
LumiScalers::liveLumiOccFill_
std::vector< float > liveLumiOccFill_
Definition: LumiScalers.h:124
ScalersEventRecordRaw_v1::lumi
struct LumiScalersRaw_v1 lumi
Definition: ScalersRaw.h:185
mps_splice.line
line
Definition: mps_splice.py:76
lumi
Definition: LumiSectionData.h:20
LumiScalers::lumiOccFill_
std::vector< float > lumiOccFill_
Definition: LumiScalers.h:122
LumiScalers::~LumiScalers
virtual ~LumiScalers()
Definition: LumiScalers.cc:121
LumiScalers::liveLumiOccRun_
std::vector< float > liveLumiOccRun_
Definition: LumiScalers.h:125