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  }
43 
45  BeamCurrentInfo(const std::vector<float>& beam1Intensities,
46  const std::vector<float>& beam2Intensities) {
47  beam1IntensitiesUnpacked_.assign(beam1Intensities.begin(), beam1Intensities.end());
48  beam2IntensitiesUnpacked_.assign(beam2Intensities.begin(), beam2Intensities.end());
49  packData();
50  }
51 
54 
55  // Beam intensities by bunch, or all
56  float getBeam1IntensityBX(int bx) const;
57  const std::vector<float>& getBeam1Intensities() const;
58  float getBeam2IntensityBX(int bx) const;
59  const std::vector<float>& getBeam2Intensities() const;
60 
61  // Get packed intensities. Only use this if you really know that this is what you want!
62  const std::vector<uint16_t>& getBeam1IntensitiesPacked() const { return beam1IntensitiesPacked_; }
63  const std::vector<uint16_t>& getBeam2IntensitiesPacked() const { return beam2IntensitiesPacked_; }
64 
65  bool isProductEqual(BeamCurrentInfo const& next) const;
66 
67  //
68  //setters
69  //
70 
71  // fill beam intensities
72  void fillBeamIntensities(const std::vector<float>& beam1Intensities,
73  const std::vector<float>& beam2Intensities);
74  // synonym for above
75  void fill(const std::vector<float>& beam1Intensities,
76  const std::vector<float>& beam2Intensities);
77 
78 
79  // used by ROOT iorules
80  static void unpackData( const std::vector<uint16_t>& packed, std::vector<float>& unpacked);
81 
82  private:
83  std::vector<uint16_t> beam1IntensitiesPacked_;
84  std::vector<uint16_t> beam2IntensitiesPacked_;
85  std::vector<float> beam1IntensitiesUnpacked_;
86  std::vector<float> beam2IntensitiesUnpacked_;
87  void packData();
88  void unpackData();
89 };
90 
91 std::ostream& operator<<(std::ostream& s, const BeamCurrentInfo& beamInfo);
92 
93 #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:188
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_