CMS 3D CMS Logo

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 
12 const std::vector<float>& BeamCurrentInfo::getBeam1Intensities() const { return beam1IntensitiesUnpacked_; }
13 
15 
16 const std::vector<float>& BeamCurrentInfo::getBeam2Intensities() const { return beam2IntensitiesUnpacked_; }
17 
19  return (beam1IntensitiesPacked_ == next.beam1IntensitiesPacked_ &&
20  beam2IntensitiesPacked_ == next.beam2IntensitiesPacked_);
21 }
22 
23 void BeamCurrentInfo::fillBeamIntensities(const std::vector<float>& beam1Intensities,
24  const std::vector<float>& beam2Intensities) {
25  beam1IntensitiesUnpacked_.assign(beam1Intensities.begin(), beam1Intensities.end());
26  beam2IntensitiesUnpacked_.assign(beam2Intensities.begin(), beam2Intensities.end());
27  packData();
28 }
29 
30 void BeamCurrentInfo::fill(const std::vector<float>& beam1Intensities, const std::vector<float>& beam2Intensities) {
31  fillBeamIntensities(beam1Intensities, beam2Intensities);
32 }
33 
34 // Convert unpacked data to packed data (when it is filled).
38 
39  for (unsigned int i = 0; i < beam1IntensitiesUnpacked_.size(); i++) {
41  }
42  for (unsigned int i = 0; i < beam2IntensitiesUnpacked_.size(); i++) {
44  }
45 
46  // Re-unpack the data so that it matches the packed data.
47  unpackData();
48 }
49 
50 // Convert packed data to unpacked data when reading back data
51 void BeamCurrentInfo::unpackData(const std::vector<uint16_t>& packed, std::vector<float>& unpacked) {
52  unpacked.resize(packed.size());
53 
54  for (unsigned int i = 0; i < packed.size(); i++) {
55  unpacked[i] = MiniFloatConverter::float16to32(packed[i]) * scaleFactor;
56  }
57 }
58 
62 }
63 
64 std::ostream& operator<<(std::ostream& s, const BeamCurrentInfo& beamInfo) {
65  s << std::endl << "Dumping BeamCurrentInfo..." << std::endl;
66  s << " beam1Intensities = ";
67  const std::vector<float>& b1int = beamInfo.getBeam1Intensities();
68  const std::vector<uint16_t>& b1intPacked = beamInfo.getBeam1IntensitiesPacked();
69  for (unsigned int i = 0; i < 10 && i < b1int.size(); ++i) {
70  s << b1int[i] << " ";
71  }
72  s << "..." << std::endl << " (packed: ";
73  for (unsigned int i = 0; i < 10 && i < b1intPacked.size(); ++i) {
74  s << b1intPacked[i] << " ";
75  }
76  s << "...)" << std::endl;
77  s << " beam2Intensities = ";
78  const std::vector<float>& b2int = beamInfo.getBeam2Intensities();
79  for (unsigned int i = 0; i < 10 && i < b2int.size(); ++i) {
80  s << b2int[i] << " ";
81  }
82  s << " ..." << std::endl;
83 
84  return s;
85 }
mps_fire.i
i
Definition: mps_fire.py:355
BeamCurrentInfo::getBeam2IntensityBX
float getBeam2IntensityBX(int bx) const
Definition: BeamCurrentInfo.cc:14
BeamCurrentInfo::fillBeamIntensities
void fillBeamIntensities(const std::vector< float > &beam1Intensities, const std::vector< float > &beam2Intensities)
Definition: BeamCurrentInfo.cc:23
BeamCurrentInfo::packData
void packData()
Definition: BeamCurrentInfo.cc:35
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
BeamCurrentInfo::scaleFactor
static const float scaleFactor
Definition: BeamCurrentInfo.h:34
BeamCurrentInfo.h
operator<<
std::ostream & operator<<(std::ostream &s, const BeamCurrentInfo &beamInfo)
Definition: BeamCurrentInfo.cc:64
alignCSCRings.s
s
Definition: alignCSCRings.py:92
libminifloat.h
BeamCurrentInfo::getBeam1Intensities
const std::vector< float > & getBeam1Intensities() const
Definition: BeamCurrentInfo.cc:12
BeamCurrentInfo::beam1IntensitiesUnpacked_
std::vector< float > beam1IntensitiesUnpacked_
Definition: BeamCurrentInfo.h:81
BeamCurrentInfo::getBeam1IntensitiesPacked
const std::vector< uint16_t > & getBeam1IntensitiesPacked() const
Definition: BeamCurrentInfo.h:61
MiniFloatConverter::float16to32
static float float16to32(uint16_t h)
Definition: libminifloat.h:12
BeamCurrentInfo::isProductEqual
bool isProductEqual(BeamCurrentInfo const &next) const
Definition: BeamCurrentInfo.cc:18
BeamCurrentInfo::unpackData
void unpackData()
Definition: BeamCurrentInfo.cc:59
BeamCurrentInfo::fill
void fill(const std::vector< float > &beam1Intensities, const std::vector< float > &beam2Intensities)
Definition: BeamCurrentInfo.cc:30
BeamCurrentInfo::beam2IntensitiesPacked_
std::vector< uint16_t > beam2IntensitiesPacked_
Definition: BeamCurrentInfo.h:80
BeamCurrentInfo::getBeam2Intensities
const std::vector< float > & getBeam2Intensities() const
Definition: BeamCurrentInfo.cc:16
BeamCurrentInfo::beam2IntensitiesUnpacked_
std::vector< float > beam2IntensitiesUnpacked_
Definition: BeamCurrentInfo.h:82
MiniFloatConverter::float32to16
static uint16_t float32to16(float x)
Definition: libminifloat.h:20
BeamCurrentInfo::beam1IntensitiesPacked_
std::vector< uint16_t > beam1IntensitiesPacked_
Definition: BeamCurrentInfo.h:79
BeamCurrentInfo
Definition: BeamCurrentInfo.h:32
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31
BeamCurrentInfo::getBeam1IntensityBX
float getBeam1IntensityBX(int bx) const
Definition: BeamCurrentInfo.cc:10