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