CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
BeamCurrentInfo.h
Go to the documentation of this file.
1 #ifndef DataFormats_Luminosity_BeamCurrentInfo_h
2 #define DataFormats_Luminosity_BeamCurrentInfo_h
3 
19 // To preserve space, this class stores information in uint16_t using
20 // libminifloat. The beamIntensitiesUnpacked variables contain the expanded
21 // float versions, and the beamIntensitiesPacked variables contain the
22 // 16-bit versions. The intensities are also divided by 1e10 during packing
23 // so that the values are near 1, to avoid running into the limits of
24 // this packing.
25 
26 #include <vector>
27 #include <iosfwd>
28 #include <string>
29 #include <cstdint>
31 
33 public:
34  static const float scaleFactor; // factor to scale data by when packing/unpacking
35 
42  }
43 
45  BeamCurrentInfo(const std::vector<float>& beam1Intensities, const std::vector<float>& beam2Intensities) {
46  beam1IntensitiesUnpacked_.assign(beam1Intensities.begin(), beam1Intensities.end());
47  beam2IntensitiesUnpacked_.assign(beam2Intensities.begin(), beam2Intensities.end());
48  packData();
49  }
50 
53 
54  // Beam intensities by bunch, or all
55  float getBeam1IntensityBX(int bx) const;
56  const std::vector<float>& getBeam1Intensities() const;
57  float getBeam2IntensityBX(int bx) const;
58  const std::vector<float>& getBeam2Intensities() const;
59 
60  // Get packed intensities. Only use this if you really know that this is what you want!
61  const std::vector<uint16_t>& getBeam1IntensitiesPacked() const { return beam1IntensitiesPacked_; }
62  const std::vector<uint16_t>& getBeam2IntensitiesPacked() const { return beam2IntensitiesPacked_; }
63 
64  bool isProductEqual(BeamCurrentInfo const& next) const;
65 
66  //
67  //setters
68  //
69 
70  // fill beam intensities
71  void fillBeamIntensities(const std::vector<float>& beam1Intensities, const std::vector<float>& beam2Intensities);
72  // synonym for above
73  void fill(const std::vector<float>& beam1Intensities, const std::vector<float>& beam2Intensities);
74 
75  // used by ROOT iorules
76  static void unpackData(const std::vector<uint16_t>& packed, std::vector<float>& unpacked);
77 
78 private:
79  std::vector<uint16_t> beam1IntensitiesPacked_;
80  std::vector<uint16_t> beam2IntensitiesPacked_;
81  std::vector<float> beam1IntensitiesUnpacked_;
82  std::vector<float> beam2IntensitiesUnpacked_;
83  void packData();
84  void unpackData();
85 };
86 
87 std::ostream& operator<<(std::ostream& s, const BeamCurrentInfo& beamInfo);
88 
89 #endif // DataFormats_Luminosity_BeamCurrentInfo_h
const std::vector< float > & getBeam1Intensities() const
~BeamCurrentInfo()
destructor
static const float scaleFactor
float getBeam1IntensityBX(int bx) const
std::vector< float > beam2IntensitiesUnpacked_
std::vector< float > beam1IntensitiesUnpacked_
static const unsigned int numBX
Definition: LumiConstants.h:8
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:167
float getBeam2IntensityBX(int bx) const
BeamCurrentInfo(const std::vector< float > &beam1Intensities, const std::vector< float > &beam2Intensities)
constructor with fill
const std::vector< uint16_t > & getBeam1IntensitiesPacked() const
BeamCurrentInfo()
default constructor
void fill(const std::vector< float > &beam1Intensities, const std::vector< float > &beam2Intensities)
std::vector< uint16_t > beam1IntensitiesPacked_
const std::vector< float > & getBeam2Intensities() const
const std::vector< uint16_t > & getBeam2IntensitiesPacked() const
std::vector< uint16_t > beam2IntensitiesPacked_