CMS 3D CMS Logo

LHCInfoPerFill.cc
Go to the documentation of this file.
3 #include <algorithm>
4 #include <iterator>
5 #include <vector>
6 #include <stdexcept>
7 
8 //helper function: returns the positions of the bits in the bitset that are set (i.e., have a value of 1).
9 static std::vector<unsigned short> bitsetToVector(std::bitset<LHCInfoPerFill::bunchSlots + 1> const& bs) {
10  std::vector<unsigned short> vec;
11  //reserve space only for the bits in the bitset that are set
12  vec.reserve(bs.count());
13  for (size_t i = 0; i < bs.size(); ++i) {
14  if (bs.test(i))
15  vec.push_back((unsigned short)i);
16  }
17  return vec;
18 }
19 
20 //helper function: returns the enum for fill types in string type
22  std::string s_fillType("UNKNOWN");
23  switch (fillType) {
25  s_fillType = std::string("UNKNOWN");
26  break;
28  s_fillType = std::string("PROTONS");
29  break;
31  s_fillType = std::string("IONS");
32  break;
34  s_fillType = std::string("COSMICS");
35  break;
37  s_fillType = std::string("GAP");
38  break;
39  default:
40  s_fillType = std::string("UNKNOWN");
41  }
42  return s_fillType;
43 }
44 
45 //helper function: returns the enum for particle types in string type
47  std::string s_particleType("NONE");
48  switch (particleType) {
50  s_particleType = std::string("NONE");
51  break;
53  s_particleType = std::string("PROTON");
54  break;
56  s_particleType = std::string("PB82");
57  break;
59  s_particleType = std::string("AR18");
60  break;
61  case LHCInfoPerFill::D:
62  s_particleType = std::string("D");
63  break;
65  s_particleType = std::string("XE54");
66  break;
67  default:
68  s_particleType = std::string("NONE");
69  }
70  return s_particleType;
71 }
72 
74  m_floatParams[LUMI_PER_B] = std::vector<float>();
75  m_floatParams[BEAM1_VC] = std::vector<float>();
76  m_floatParams[BEAM2_VC] = std::vector<float>();
77  m_floatParams[BEAM1_RF] = std::vector<float>();
78  m_floatParams[BEAM2_RF] = std::vector<float>();
79  m_stringParams[INJECTION_SCHEME].push_back(std::string("None"));
80 }
81 
84  ret->m_isData = m_isData;
85  if (!m_intParams[0].empty()) {
86  for (size_t i = 0; i < ISIZE; i++)
87  ret->m_intParams[i] = m_intParams[i];
88  for (size_t i = 0; i < DELIV_LUMI; i++)
89  ret->m_floatParams[i] = m_floatParams[i];
90  ret->m_floatParams[LUMI_PER_B] = m_floatParams[LUMI_PER_B];
91  for (size_t i = 0; i < TSIZE; i++)
92  ret->m_timeParams[i] = m_timeParams[i];
93  for (size_t i = 0; i < LHC_STATE; i++)
94  ret->m_stringParams[i] = m_stringParams[i];
95  ret->m_bunchConfiguration1 = m_bunchConfiguration1;
96  ret->m_bunchConfiguration2 = m_bunchConfiguration2;
97  }
98  return ret;
99 }
100 
101 //getters
103 
104 unsigned short const LHCInfoPerFill::bunchesInBeam1() const {
106 }
107 
108 unsigned short const LHCInfoPerFill::bunchesInBeam2() const {
110 }
111 
112 unsigned short const LHCInfoPerFill::collidingBunches() const {
114 }
115 
116 unsigned short const LHCInfoPerFill::targetBunches() const {
118 }
119 
122 }
123 
126 }
127 
130 }
131 
134 }
135 
138 }
139 
141 
143 
145 
147 
149 
151 
153 
155 
158 }
159 
160 std::vector<float> const& LHCInfoPerFill::lumiPerBX() const {
162 }
163 
165 
168 }
169 
172 }
173 
174 std::vector<float> const& LHCInfoPerFill::beam1VC() const { return LHCInfoPerFill::getParams(m_floatParams, BEAM1_VC); }
175 
176 std::vector<float> const& LHCInfoPerFill::beam2VC() const { return LHCInfoPerFill::getParams(m_floatParams, BEAM2_VC); }
177 
178 std::vector<float> const& LHCInfoPerFill::beam1RF() const { return LHCInfoPerFill::getParams(m_floatParams, BEAM1_RF); }
179 
180 std::vector<float> const& LHCInfoPerFill::beam2RF() const { return LHCInfoPerFill::getParams(m_floatParams, BEAM2_RF); }
181 
183 
185 
187 
189 
190 //returns a boolean, true if the injection scheme has a leading 25ns
191 //TODO: parse the circulating bunch configuration, instead of the string.
193  const std::string prefix("25ns");
194  return std::equal(prefix.begin(), prefix.end(), injectionScheme().begin());
195 }
196 
197 //returns a boolean, true if the bunch slot number is in the circulating bunch configuration
198 bool LHCInfoPerFill::isBunchInBeam1(size_t const& bunch) const {
199  if (bunch == 0)
200  throw std::out_of_range("0 not allowed"); //CMS starts counting bunch crossing from 1!
201  return m_bunchConfiguration1.test(bunch);
202 }
203 
204 bool LHCInfoPerFill::isBunchInBeam2(size_t const& bunch) const {
205  if (bunch == 0)
206  throw std::out_of_range("0 not allowed"); //CMS starts counting bunch crossing from 1!
207  return m_bunchConfiguration2.test(bunch);
208 }
209 
210 //member functions returning *by value* a vector with all filled bunch slots
211 std::vector<unsigned short> LHCInfoPerFill::bunchConfigurationForBeam1() const {
213 }
214 
215 std::vector<unsigned short> LHCInfoPerFill::bunchConfigurationForBeam2() const {
217 }
218 
219 void LHCInfoPerFill::setFillNumber(unsigned short lhcFill) {
220  LHCInfoPerFill::setOneParam(m_intParams, LHC_FILL, static_cast<unsigned int>(lhcFill));
221 }
222 
223 //setters
224 void LHCInfoPerFill::setBunchesInBeam1(unsigned short const& bunches) {
225  LHCInfoPerFill::setOneParam(m_intParams, BUNCHES_1, static_cast<unsigned int>(bunches));
226 }
227 
228 void LHCInfoPerFill::setBunchesInBeam2(unsigned short const& bunches) {
229  LHCInfoPerFill::setOneParam(m_intParams, BUNCHES_2, static_cast<unsigned int>(bunches));
230 }
231 
232 void LHCInfoPerFill::setCollidingBunches(unsigned short const& collidingBunches) {
234 }
235 
236 void LHCInfoPerFill::setTargetBunches(unsigned short const& targetBunches) {
238 }
239 
241  LHCInfoPerFill::setOneParam(m_intParams, FILL_TYPE, static_cast<unsigned int>(fillType));
242 }
243 
245  LHCInfoPerFill::setOneParam(m_intParams, PARTICLES_1, static_cast<unsigned int>(particleType));
246 }
247 
249  LHCInfoPerFill::setOneParam(m_intParams, PARTICLES_2, static_cast<unsigned int>(particleType));
250 }
251 
252 void LHCInfoPerFill::setIntensityForBeam1(float const& intensity) {
254 }
255 
256 void LHCInfoPerFill::setIntensityForBeam2(float const& intensity) {
258 }
259 
261 
264 }
265 
267 
270 }
271 
272 void LHCInfoPerFill::setInstLumiError(float const& instLumiError) {
274 }
275 
278 }
279 
282 }
283 
286 }
287 
288 void LHCInfoPerFill::setInjectionScheme(std::string const& injectionScheme) {
290 }
291 
292 void LHCInfoPerFill::setLumiPerBX(std::vector<float> const& lumiPerBX) {
294 }
295 
298 }
299 
302 }
303 
304 void LHCInfoPerFill::setCtppsStatus(std::string const& ctppsStatus) {
306 }
307 
308 void LHCInfoPerFill::setBeam1VC(std::vector<float> const& beam1VC) {
310 }
311 
312 void LHCInfoPerFill::setBeam2VC(std::vector<float> const& beam2VC) {
314 }
315 
316 void LHCInfoPerFill::setBeam1RF(std::vector<float> const& beam1RF) {
318 }
319 
320 void LHCInfoPerFill::setBeam2RF(std::vector<float> const& beam2RF) {
322 }
323 
324 //sets all values in one go
325 void LHCInfoPerFill::setInfo(unsigned short const& bunches1,
326  unsigned short const& bunches2,
327  unsigned short const& collidingBunches,
328  unsigned short const& targetBunches,
329  FillTypeId const& fillType,
330  ParticleTypeId const& particleType1,
331  ParticleTypeId const& particleType2,
332  float const& intensity1,
333  float const& intensity2,
334  float const& energy,
335  float const& delivLumi,
336  float const& recLumi,
337  float const& instLumi,
338  float const& instLumiError,
339  cond::Time_t const& createTime,
340  cond::Time_t const& beginTime,
341  cond::Time_t const& endTime,
342  std::string const& scheme,
343  std::vector<float> const& lumiPerBX,
344  std::string const& lhcState,
345  std::string const& lhcComment,
346  std::string const& ctppsStatus,
347  std::vector<float> const& beam1VC,
348  std::vector<float> const& beam2VC,
349  std::vector<float> const& beam1RF,
350  std::vector<float> const& beam2RF,
351  std::bitset<bunchSlots + 1> const& bunchConf1,
352  std::bitset<bunchSlots + 1> const& bunchConf2) {
353  this->setBunchesInBeam1(bunches1);
354  this->setBunchesInBeam2(bunches2);
355  this->setCollidingBunches(collidingBunches);
356  this->setTargetBunches(targetBunches);
357  this->setFillType(fillType);
358  this->setParticleTypeForBeam1(particleType1);
359  this->setParticleTypeForBeam2(particleType2);
360  this->setIntensityForBeam1(intensity1);
361  this->setIntensityForBeam2(intensity2);
362  this->setEnergy(energy);
363  this->setDelivLumi(delivLumi);
364  this->setRecLumi(recLumi);
365  this->setInstLumi(instLumi);
366  this->setInstLumiError(instLumiError);
367  this->setCreationTime(createTime);
368  this->setBeginTime(beginTime);
369  this->setEndTime(endTime);
370  this->setInjectionScheme(scheme);
371  this->setLumiPerBX(lumiPerBX);
372  this->setLhcState(lhcState);
373  this->setLhcComment(lhcComment);
374  this->setCtppsStatus(ctppsStatus);
375  this->setBeam1VC(beam1VC);
376  this->setBeam2VC(beam2VC);
377  this->setBeam1RF(beam1RF);
378  this->setBeam2RF(beam2RF);
379  this->setBunchBitsetForBeam1(bunchConf1);
380  this->setBunchBitsetForBeam2(bunchConf2);
381 }
382 
383 void LHCInfoPerFill::print(std::stringstream& ss) const {
384  ss << "LHC fill: " << this->fillNumber() << std::endl
385  << "Bunches in Beam 1: " << this->bunchesInBeam1() << std::endl
386  << "Bunches in Beam 2: " << this->bunchesInBeam2() << std::endl
387  << "Colliding bunches at IP5: " << this->collidingBunches() << std::endl
388  << "Target bunches at IP5: " << this->targetBunches() << std::endl
389  << "Fill type: " << fillTypeToString(static_cast<FillTypeId>(this->fillType())) << std::endl
390  << "Particle type for Beam 1: " << particleTypeToString(static_cast<ParticleTypeId>(this->particleTypeForBeam1()))
391  << std::endl
392  << "Particle type for Beam 2: " << particleTypeToString(static_cast<ParticleTypeId>(this->particleTypeForBeam2()))
393  << std::endl
394  << "Average Intensity for Beam 1 (number of charges): " << this->intensityForBeam1() << std::endl
395  << "Average Intensity for Beam 2 (number of charges): " << this->intensityForBeam2() << std::endl
396  << "Energy (GeV): " << this->energy() << std::endl
397  << "Delivered Luminosity (max): " << this->delivLumi() << std::endl
398  << "Recorded Luminosity (max): " << this->recLumi() << std::endl
399  << "Instantaneous Luminosity: " << this->instLumi() << std::endl
400  << "Instantaneous Luminosity Error: " << this->instLumiError() << std::endl
401  << "Creation time of the fill: "
402  << boost::posix_time::to_iso_extended_string(cond::time::to_boost(this->createTime())) << std::endl
403  << "Begin time of Stable Beam flag: "
404  << boost::posix_time::to_iso_extended_string(cond::time::to_boost(this->beginTime())) << std::endl
405  << "End time of the fill: " << boost::posix_time::to_iso_extended_string(cond::time::to_boost(this->endTime()))
406  << std::endl
407  << "Injection scheme as given by LPC: " << this->injectionScheme() << std::endl
408  << "LHC State: " << this->lhcState() << std::endl
409  << "LHC Comments: " << this->lhcComment() << std::endl
410  << "CTPPS Status: " << this->ctppsStatus() << std::endl;
411 
412  ss << "Luminosity per bunch (total " << this->lumiPerBX().size() << "): ";
413  std::copy(this->lumiPerBX().begin(), this->lumiPerBX().end(), std::ostream_iterator<float>(ss, ", "));
414  ss << std::endl;
415 
416  ss << "Beam 1 VC (total " << this->beam1VC().size() << "): ";
417  std::copy(this->beam1VC().begin(), this->beam1VC().end(), std::ostream_iterator<float>(ss, "\t"));
418  ss << std::endl;
419 
420  ss << "Beam 2 VC (total " << beam2VC().size() << "): ";
421  std::copy(beam2VC().begin(), beam2VC().end(), std::ostream_iterator<float>(ss, "\t"));
422  ss << std::endl;
423 
424  ss << "Beam 1 RF (total " << beam1RF().size() << "): ";
425  std::copy(beam1RF().begin(), beam1RF().end(), std::ostream_iterator<float>(ss, "\t"));
426  ss << std::endl;
427 
428  ss << "Beam 2 RF (total " << beam2RF().size() << "): ";
429  std::copy(beam2RF().begin(), beam2RF().end(), std::ostream_iterator<float>(ss, "\t"));
430  ss << std::endl;
431 
432  std::vector<unsigned short> bunchVector1 = this->bunchConfigurationForBeam1();
433  std::vector<unsigned short> bunchVector2 = this->bunchConfigurationForBeam2();
434  ss << "Bunches filled for Beam 1 (total " << bunchVector1.size() << "): ";
435  std::copy(bunchVector1.begin(), bunchVector1.end(), std::ostream_iterator<unsigned short>(ss, ", "));
436  ss << std::endl;
437  ss << "Bunches filled for Beam 2 (total " << bunchVector2.size() << "): ";
438  std::copy(bunchVector2.begin(), bunchVector2.end(), std::ostream_iterator<unsigned short>(ss, ", "));
439  ss << std::endl;
440 }
441 
442 //protected getters
443 std::bitset<LHCInfoPerFill::bunchSlots + 1> const& LHCInfoPerFill::bunchBitsetForBeam1() const {
444  return m_bunchConfiguration1;
445 }
446 
447 std::bitset<LHCInfoPerFill::bunchSlots + 1> const& LHCInfoPerFill::bunchBitsetForBeam2() const {
448  return m_bunchConfiguration2;
449 }
450 
451 //protected setters
452 void LHCInfoPerFill::setBunchBitsetForBeam1(std::bitset<LHCInfoPerFill::bunchSlots + 1> const& bunchConfiguration) {
453  m_bunchConfiguration1 = bunchConfiguration;
454 }
455 
456 void LHCInfoPerFill::setBunchBitsetForBeam2(std::bitset<LHCInfoPerFill::bunchSlots + 1> const& bunchConfiguration) {
457  m_bunchConfiguration2 = bunchConfiguration;
458 }
459 
460 std::ostream& operator<<(std::ostream& os, LHCInfoPerFill beamInfo) {
461  std::stringstream ss;
462  beamInfo.print(ss);
463  os << ss.str();
464  return os;
465 }
466 
467 bool LHCInfoPerFill::equals(const LHCInfoPerFill& rhs) const {
468  if (m_isData != rhs.m_isData)
469  return false;
470  if (m_intParams != rhs.m_intParams)
471  return false;
472  if (m_floatParams != rhs.m_floatParams)
473  return false;
474  if (m_timeParams != rhs.m_timeParams)
475  return false;
476  if (m_stringParams != rhs.m_stringParams)
477  return false;
479  return false;
481  return false;
482  return true;
483 }
484 
485 bool LHCInfoPerFill::empty() const { return m_intParams[0].empty(); }
float const intensityForBeam1() const
void setParticleTypeForBeam2(ParticleTypeId const &particleType)
void setInjectionScheme(std::string const &injectionScheme)
std::string const & injectionScheme() const
static void setOneParam(std::vector< std::vector< T > > &params, size_t index, const T &value)
void setBeginTime(cond::Time_t const &beginTime)
void setInstLumiError(float const &instLumiError)
ParticleTypeId const particleTypeForBeam2() const
std::vector< float > const & beam2VC() const
unsigned short const collidingBunches() const
void setLhcComment(std::string const &lhcComment)
std::ostream & operator<<(std::ostream &os, LHCInfoPerFill beamInfo)
void setDelivLumi(float const &delivLumi)
std::vector< std::vector< unsigned int > > m_intParams
for(int i=first, nt=offsets[nh];i< nt;i+=gridDim.x *blockDim.x)
ret
prodAgent to be discontinued
void setInfo(unsigned short const &bunches1, unsigned short const &bunches2, unsigned short const &collidingBunches, unsigned short const &targetBunches, FillTypeId const &fillType, ParticleTypeId const &particleType1, ParticleTypeId const &particleType2, float const &intensity1, float const &intensity2, float const &energy, float const &delivLumi, float const &recLumi, float const &instLumi, float const &instLumiError, cond::Time_t const &createTime, cond::Time_t const &beginTime, cond::Time_t const &endTime, std::string const &scheme, std::vector< float > const &lumiPerBX, std::string const &lhcState, std::string const &lhcComment, std::string const &ctppsStatus, std::vector< float > const &beam1VC, std::vector< float > const &beam2VC, std::vector< float > const &beam1RF, std::vector< float > const &beam2RF, std::bitset< bunchSlots+1 > const &bunchConf1, std::bitset< bunchSlots+1 > const &bunchConf2)
cond::Time_t const beginTime() const
std::vector< std::vector< std::string > > m_stringParams
static const T & getOneParam(const std::vector< std::vector< T > > &params, size_t index)
float const delivLumi() const
float const recLumi() const
unsigned short const bunchesInBeam1() const
static void setParams(std::vector< T > &params, size_t index, const T &value)
unsigned short const targetBunches() const
std::string const & lhcState() const
bool equal(const T &first, const T &second)
Definition: Equal.h:32
void setBunchesInBeam1(unsigned short const &bunches)
void setEndTime(cond::Time_t const &endTime)
ParticleTypeId const particleTypeForBeam1() const
static std::string fillTypeToString(LHCInfoPerFill::FillTypeId const &fillType)
LHCInfoPerFill * cloneFill() const
void setBunchesInBeam2(unsigned short const &bunches)
void setBeam1VC(std::vector< float > const &beam1VC)
std::vector< std::vector< unsigned long long > > m_timeParams
void setIntensityForBeam2(float const &intensity)
unsigned long long Time_t
Definition: Time.h:14
std::bitset< bunchSlots+1 > const & bunchBitsetForBeam2() const
std::string const & ctppsStatus() const
std::bitset< bunchSlots+1 > const & bunchBitsetForBeam1() const
void setTargetBunches(unsigned short const &targetBunches)
std::vector< float > const & lumiPerBX() const
void setRecLumi(float const &recLumi)
float const energy() const
std::bitset< bunchSlots+1 > m_bunchConfiguration2
void setLhcState(std::string const &lhcState)
float const intensityForBeam2() const
static std::vector< unsigned short > bitsetToVector(std::bitset< LHCInfoPerFill::bunchSlots+1 > const &bs)
std::vector< std::vector< float > > m_floatParams
void setFillNumber(unsigned short lhcFill)
cond::Time_t const createTime() const
unsigned short const bunchesInBeam2() const
void setIntensityForBeam1(float const &intensity)
void setCtppsStatus(std::string const &ctppsStatus)
std::vector< float > const & beam1RF() const
std::string const & lhcComment() const
void setParticleTypeForBeam1(ParticleTypeId const &particleType)
void setBeam2VC(std::vector< float > const &beam2VC)
void setBeam1RF(std::vector< float > const &beam1RF)
unsigned short const fillNumber() const
std::vector< unsigned short > bunchConfigurationForBeam2() const
std::bitset< bunchSlots+1 > m_bunchConfiguration1
float const instLumi() const
void setCollidingBunches(unsigned short const &collidingBunches)
void setBunchBitsetForBeam2(std::bitset< bunchSlots+1 > const &bunchConfiguration)
bool equals(const LHCInfoPerFill &rhs) const
bool empty() const
bool isBunchInBeam2(size_t const &bunch) const
std::vector< unsigned short > bunchConfigurationForBeam1() const
FillTypeId const fillType() const
static std::string particleTypeToString(LHCInfoPerFill::ParticleTypeId const &particleType)
std::vector< float > const & beam2RF() const
bool isBunchInBeam1(size_t const &bunch) const
void setBunchBitsetForBeam1(std::bitset< bunchSlots+1 > const &bunchConfiguration)
void setCreationTime(cond::Time_t const &createTime)
void setLumiPerBX(std::vector< float > const &lumiPerBX)
void print(std::stringstream &ss) const
static const T & getParams(const std::vector< T > &params, size_t index)
void setInstLumi(float const &instLumi)
std::vector< float > const & beam1VC() const
bool is25nsBunchSpacing() const
void setBeam2RF(std::vector< float > const &beam2RF)
float const instLumiError() const
void setEnergy(float const &energy)
static T & accessParams(std::vector< T > &params, size_t index)
void setFillType(FillTypeId const &fillType)
cond::Time_t const endTime() const
boost::posix_time::ptime to_boost(Time_t iValue)