CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 <stdint.h>
31 
33  public:
34  static const float scaleFactor; // factor to scale data by when packing/unpacking
35 
42  unpackedReady_ = true;
43  }
44 
46  BeamCurrentInfo(const std::vector<float>& beam1Intensities,
47  const std::vector<float>& beam2Intensities) {
48  beam1IntensitiesUnpacked_.assign(beam1Intensities.begin(), beam1Intensities.end());
49  beam2IntensitiesUnpacked_.assign(beam2Intensities.begin(), beam2Intensities.end());
50  unpackedReady_ = true;
51  packData();
52  }
53 
56 
57  // Beam intensities by bunch, or all
58  float getBeam1IntensityBX(int bx) const;
59  const std::vector<float>& getBeam1Intensities() const;
60  float getBeam2IntensityBX(int bx) const;
61  const std::vector<float>& getBeam2Intensities() const;
62 
63  // Get packed intensities. Only use this if you really know that this is what you want!
64  const std::vector<uint16_t>& getBeam1IntensitiesPacked() const { return beam1IntensitiesPacked_; }
65  const std::vector<uint16_t>& getBeam2IntensitiesPacked() const { return beam2IntensitiesPacked_; }
66 
67  bool isProductEqual(BeamCurrentInfo const& next) const;
68 
69  //
70  //setters
71  //
72 
73  // fill beam intensities
74  void fillBeamIntensities(const std::vector<float>& beam1Intensities,
75  const std::vector<float>& beam2Intensities);
76  // synonym for above
77  void fill(const std::vector<float>& beam1Intensities,
78  const std::vector<float>& beam2Intensities);
79 
80  private:
81  std::vector<uint16_t> beam1IntensitiesPacked_;
82  std::vector<uint16_t> beam2IntensitiesPacked_;
83  mutable std::vector<float> beam1IntensitiesUnpacked_;
84  mutable std::vector<float> beam2IntensitiesUnpacked_;
85  void packData(void);
86  void unpackData(void) const;
87  mutable bool unpackedReady_;
88 };
89 
90 std::ostream& operator<<(std::ostream& s, const BeamCurrentInfo& beamInfo);
91 
92 #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:9
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
float getBeam2IntensityBX(int bx) const
BeamCurrentInfo(const std::vector< float > &beam1Intensities, const std::vector< float > &beam2Intensities)
constructor with fill
void unpackData(void) const
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_
void packData(void)