CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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));
72  lumiFill_ = lumi->LumiFill;
73  lumiRun_ = lumi->LumiRun;
75  liveLumiRun_ = lumi->LiveLumiRun;
76  instantLumi_ = lumi->InstantLumi;
79  lumiETFill_ = lumi->LumiETFill;
80  lumiETRun_ = lumi->LumiETRun;
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  }
97  startOrbit_ = lumi->startOrbit;
98  numOrbits_ = lumi->numOrbits;
99 
100  if (version_ >= 7) {
101  struct ScalersEventRecordRaw_v6 const* raw6 = (struct ScalersEventRecordRaw_v6 const*)rawData;
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(),
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 }
unsigned char InstantETLumiQlty
Definition: ScalersRaw.h:136
unsigned int collectionTime_sec
Definition: ScalersRaw.h:117
float pileup_
Definition: LumiScalers.h:135
std::vector< unsigned char > instantOccLumiQlty_
Definition: LumiScalers.h:128
std::vector< float > lumiOccFill() const
Definition: LumiScalers.h:68
const edm::EventSetup & c
unsigned int trigType() const
Definition: LumiScalers.h:42
unsigned char instantETLumiQlty() const
Definition: LumiScalers.h:66
unsigned char instantLumiQlty_
Definition: LumiScalers.h:111
float LiveLumiOccFill[ScalersRaw::N_LUMI_OCC_v1]
Definition: ScalersRaw.h:140
unsigned int sectionNumber() const
Definition: LumiScalers.h:77
unsigned int bunchNumber() const
Definition: LumiScalers.h:45
float LumiOccRun[ScalersRaw::N_LUMI_OCC_v1]
Definition: ScalersRaw.h:139
virtual ~LumiScalers()
Definition: LumiScalers.cc:121
int version() const
Definition: LumiScalers.h:47
std::vector< float > liveLumiOccRun_
Definition: LumiScalers.h:125
void set_tv_nsec(long value)
Definition: TimeSpec.h:19
std::vector< float > liveLumiOccFill_
Definition: LumiScalers.h:124
float lumiETRun_
Definition: LumiScalers.h:114
unsigned char instantETLumiQlty_
Definition: LumiScalers.h:120
float liveLumiETRun_
Definition: LumiScalers.h:116
std::vector< float > instantOccLumi_
Definition: LumiScalers.h:126
float liveLumiFill_
Definition: LumiScalers.h:107
unsigned long long header
Definition: ScalersRaw.h:182
float normalization() const
Definition: LumiScalers.h:49
float pileupRMS() const
Definition: LumiScalers.h:82
float instantETLumi() const
Definition: LumiScalers.h:64
std::vector< float > instantOccLumiErr() const
Definition: LumiScalers.h:73
unsigned long long spare[ScalersRaw::N_SPARE_v5]
Definition: ScalersRaw.h:252
float spare_
Definition: LumiScalers.h:138
std::vector< float > lumiOccRun_
Definition: LumiScalers.h:123
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
float bunchLumi() const
Definition: LumiScalers.h:83
float pileup() const
Definition: LumiScalers.h:81
float liveLumiETFill_
Definition: LumiScalers.h:115
float DeadtimeNormalization
Definition: ScalersRaw.h:119
float LumiOccFill[ScalersRaw::N_LUMI_OCC_v1]
Definition: ScalersRaw.h:138
float liveLumiRun_
Definition: LumiScalers.h:108
std::vector< float > lumiNoise_
Definition: LumiScalers.h:129
float instantLumi() const
Definition: LumiScalers.h:56
unsigned int numOrbits
Definition: ScalersRaw.h:149
float instantLumiErr_
Definition: LumiScalers.h:110
unsigned char InstantOccLumiQlty[ScalersRaw::N_LUMI_OCC_v1]
Definition: ScalersRaw.h:144
float deadTimeNormalization_
Definition: LumiScalers.h:103
float lumiETFill_
Definition: LumiScalers.h:113
float lumiNoise[ScalersRaw::N_LUMI_OCC_v1]
Definition: ScalersRaw.h:145
float pileupRMS_
Definition: LumiScalers.h:136
float lumiFill_
Definition: LumiScalers.h:105
float liveLumiETRun() const
Definition: LumiScalers.h:63
float normalization_
Definition: LumiScalers.h:102
float liveLumiRun() const
Definition: LumiScalers.h:55
float instantETLumiErr_
Definition: LumiScalers.h:118
unsigned int numOrbits() const
Definition: LumiScalers.h:79
float lumiFill() const
Definition: LumiScalers.h:52
unsigned int collectionTime_nsec
Definition: ScalersRaw.h:118
timespec collectionTime() const
Definition: LumiScalers.h:48
unsigned int sectionNumber_
Definition: LumiScalers.h:131
float bunchLumi_
Definition: LumiScalers.h:137
float instantETLumiErr() const
Definition: LumiScalers.h:65
float instantETLumi_
Definition: LumiScalers.h:117
std::vector< float > lumiOccRun() const
Definition: LumiScalers.h:69
list lumi
Definition: dqmdumpme.py:53
float InstantOccLumiErr[ScalersRaw::N_LUMI_OCC_v1]
Definition: ScalersRaw.h:143
unsigned int startOrbit
Definition: ScalersRaw.h:148
std::vector< float > lumiNoise() const
Definition: LumiScalers.h:75
std::vector< float > instantOccLumiErr_
Definition: LumiScalers.h:127
std::vector< unsigned char > instantOccLumiQlty() const
Definition: LumiScalers.h:74
float liveLumiETFill() const
Definition: LumiScalers.h:62
float LiveLumiOccRun[ScalersRaw::N_LUMI_OCC_v1]
Definition: ScalersRaw.h:141
std::vector< float > lumiOccFill_
Definition: LumiScalers.h:122
float lumiRun() const
Definition: LumiScalers.h:53
float lumiRun_
Definition: LumiScalers.h:106
unsigned int eventID() const
Definition: LumiScalers.h:43
float spare() const
Definition: LumiScalers.h:84
unsigned char instantLumiQlty() const
Definition: LumiScalers.h:58
float instantLumi_
Definition: LumiScalers.h:109
float liveLumiFill() const
Definition: LumiScalers.h:54
unsigned int startOrbit() const
Definition: LumiScalers.h:78
float instantLumiErr() const
Definition: LumiScalers.h:57
unsigned int sourceID() const
Definition: LumiScalers.h:44
std::vector< float > instantOccLumi() const
Definition: LumiScalers.h:72
unsigned char InstantLumiQlty
Definition: ScalersRaw.h:128
unsigned int bunchNumber_
Definition: LumiScalers.h:96
TimeSpec collectionTime_
Definition: LumiScalers.h:100
unsigned int startOrbit_
Definition: LumiScalers.h:132
std::vector< float > liveLumiOccRun() const
Definition: LumiScalers.h:71
void set_tv_sec(long value)
Definition: TimeSpec.h:18
float InstantOccLumi[ScalersRaw::N_LUMI_OCC_v1]
Definition: ScalersRaw.h:142
struct LumiScalersRaw_v1 lumi
Definition: ScalersRaw.h:204
unsigned int sourceID_
Definition: LumiScalers.h:95
float InstantETLumiErr
Definition: ScalersRaw.h:135
unsigned int eventID_
Definition: LumiScalers.h:94
unsigned int numOrbits_
Definition: LumiScalers.h:133
unsigned int trigType_
Definition: LumiScalers.h:93
struct LumiScalersRaw_v1 lumi
Definition: ScalersRaw.h:185
unsigned int sectionNumber
Definition: ScalersRaw.h:147
float deadTimeNormalization() const
Definition: LumiScalers.h:50
std::vector< float > liveLumiOccFill() const
Definition: LumiScalers.h:70