CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
BeamCurrentInfo.cc
Go to the documentation of this file.
3 
4 #include <iomanip>
5 #include <ostream>
6 #include <iostream>
7 
8 const float BeamCurrentInfo::scaleFactor = 1e10;
9 
11  unpackData();
12  return beam1IntensitiesUnpacked_.at(bx);
13 }
14 
15 const std::vector<float>& BeamCurrentInfo::getBeam1Intensities() const {
16  unpackData();
18 
19 }
20 
22  unpackData();
23  return beam2IntensitiesUnpacked_.at(bx); }
24 
25 const std::vector<float>& BeamCurrentInfo::getBeam2Intensities() const {
26  unpackData();
28 }
29 
33 }
34 
35 void BeamCurrentInfo::fillBeamIntensities(const std::vector<float>& beam1Intensities,
36  const std::vector<float>& beam2Intensities) {
37  beam1IntensitiesUnpacked_.assign(beam1Intensities.begin(), beam1Intensities.end());
38  beam2IntensitiesUnpacked_.assign(beam2Intensities.begin(), beam2Intensities.end());
39  unpackedReady_ = true;
40  packData();
41 }
42 
43 void BeamCurrentInfo::fill(const std::vector<float>& beam1Intensities,
44  const std::vector<float>& beam2Intensities) {
45  fillBeamIntensities(beam1Intensities, beam2Intensities);
46 }
47 
48 // Convert unpacked data to packed data (when it is filled).
52 
53  for (unsigned int i=0; i<beam1IntensitiesUnpacked_.size(); i++) {
55  }
56  for (unsigned int i=0; i<beam2IntensitiesUnpacked_.size(); i++) {
58  }
59 
60  // Re-unpack the data so that it matches the packed data.
61  unpackedReady_ = false;
62  unpackData();
63 }
64 
65 // Convert packed data to unpacked data when accessors are called.
66 void BeamCurrentInfo::unpackData(void) const {
67  if (unpackedReady_) return;
68 
71 
72  for (unsigned int i=0; i<beam1IntensitiesPacked_.size(); i++) {
74  }
75  for (unsigned int i=0; i<beam2IntensitiesPacked_.size(); i++) {
77  }
78  unpackedReady_ = true;
79 }
80 
81 
82 std::ostream& operator<<(std::ostream& s, const BeamCurrentInfo& beamInfo) {
83  s << std::endl << "Dumping BeamCurrentInfo..." << std::endl;
84  s << " beam1Intensities = ";
85  const std::vector<float>& b1int = beamInfo.getBeam1Intensities();
86  const std::vector<uint16_t>& b1intPacked = beamInfo.getBeam1IntensitiesPacked();
87  for (unsigned int i=0; i<10 && i<b1int.size(); ++i) {
88  s << b1int.at(i) << " ";
89  }
90  s << "..." << std::endl << " (packed: ";
91  for (unsigned int i=0; i<10 && i<b1intPacked.size(); ++i) {
92  s << b1intPacked.at(i) << " ";
93  }
94  s << "...)" << std::endl;
95  s << " beam2Intensities = ";
96  const std::vector<float>& b2int = beamInfo.getBeam2Intensities();
97  for (unsigned int i=0; i<10 && i<b2int.size(); ++i) {
98  s << b2int.at(i) << " ";
99  }
100  s << " ..." << std::endl;
101 
102  return s;
103 }
const std::vector< float > & getBeam1Intensities() const
int i
Definition: DBlmapReader.cc:9
static const float scaleFactor
float getBeam1IntensityBX(int bx) const
std::vector< float > beam2IntensitiesUnpacked_
std::vector< float > beam1IntensitiesUnpacked_
void fillBeamIntensities(const std::vector< float > &beam1Intensities, const std::vector< float > &beam2Intensities)
bool isProductEqual(BeamCurrentInfo const &next) const
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
static float float16to32(uint16_t h)
Definition: libminifloat.h:10
static uint16_t float32to16(float x)
Definition: libminifloat.h:15
float getBeam2IntensityBX(int bx) const
void unpackData(void) const
const std::vector< uint16_t > & getBeam1IntensitiesPacked() const
void fill(const std::vector< float > &beam1Intensities, const std::vector< float > &beam2Intensities)
std::vector< uint16_t > beam1IntensitiesPacked_
const std::vector< float > & getBeam2Intensities() const
std::vector< uint16_t > beam2IntensitiesPacked_
void packData(void)