test
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  return beam1IntensitiesUnpacked_.at(bx);
12 }
13 
14 const std::vector<float>& BeamCurrentInfo::getBeam1Intensities() const {
16 
17 }
18 
20  return beam2IntensitiesUnpacked_.at(bx); }
21 
22 const std::vector<float>& BeamCurrentInfo::getBeam2Intensities() const {
24 }
25 
29 }
30 
31 void BeamCurrentInfo::fillBeamIntensities(const std::vector<float>& beam1Intensities,
32  const std::vector<float>& beam2Intensities) {
33  beam1IntensitiesUnpacked_.assign(beam1Intensities.begin(), beam1Intensities.end());
34  beam2IntensitiesUnpacked_.assign(beam2Intensities.begin(), beam2Intensities.end());
35  packData();
36 }
37 
38 void BeamCurrentInfo::fill(const std::vector<float>& beam1Intensities,
39  const std::vector<float>& beam2Intensities) {
40  fillBeamIntensities(beam1Intensities, beam2Intensities);
41 }
42 
43 // Convert unpacked data to packed data (when it is filled).
47 
48  for (unsigned int i=0; i<beam1IntensitiesUnpacked_.size(); i++) {
50  }
51  for (unsigned int i=0; i<beam2IntensitiesUnpacked_.size(); i++) {
53  }
54 
55  // Re-unpack the data so that it matches the packed data.
56  unpackData();
57 }
58 
59 // Convert packed data to unpacked data when reading back data
60 void BeamCurrentInfo::unpackData(const std::vector<uint16_t>& packed, std::vector<float>& unpacked ) {
61  unpacked.resize(packed.size());
62 
63  for (unsigned int i=0; i<packed.size(); i++) {
64  unpacked[i] = MiniFloatConverter::float16to32(packed[i])*scaleFactor;
65  }
66 }
67 
69 
72 }
73 
74 
75 std::ostream& operator<<(std::ostream& s, const BeamCurrentInfo& beamInfo) {
76  s << std::endl << "Dumping BeamCurrentInfo..." << std::endl;
77  s << " beam1Intensities = ";
78  const std::vector<float>& b1int = beamInfo.getBeam1Intensities();
79  const std::vector<uint16_t>& b1intPacked = beamInfo.getBeam1IntensitiesPacked();
80  for (unsigned int i=0; i<10 && i<b1int.size(); ++i) {
81  s << b1int[i] << " ";
82  }
83  s << "..." << std::endl << " (packed: ";
84  for (unsigned int i=0; i<10 && i<b1intPacked.size(); ++i) {
85  s << b1intPacked[i] << " ";
86  }
87  s << "...)" << std::endl;
88  s << " beam2Intensities = ";
89  const std::vector<float>& b2int = beamInfo.getBeam2Intensities();
90  for (unsigned int i=0; i<10 && i<b2int.size(); ++i) {
91  s << b2int[i] << " ";
92  }
93  s << " ..." << std::endl;
94 
95  return s;
96 }
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:188
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
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_