CMS 3D CMS Logo

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
BeamCurrentInfo::getBeam2IntensityBX
float getBeam2IntensityBX(int bx) const
Definition: BeamCurrentInfo.cc:14
LumiConstants::numBX
static const unsigned int numBX
Definition: LumiConstants.h:8
BeamCurrentInfo::fillBeamIntensities
void fillBeamIntensities(const std::vector< float > &beam1Intensities, const std::vector< float > &beam2Intensities)
Definition: BeamCurrentInfo.cc:23
BeamCurrentInfo::getBeam2IntensitiesPacked
const std::vector< uint16_t > & getBeam2IntensitiesPacked() const
Definition: BeamCurrentInfo.h:62
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
LumiConstants.h
BeamCurrentInfo::BeamCurrentInfo
BeamCurrentInfo()
default constructor
Definition: BeamCurrentInfo.h:37
alignCSCRings.s
s
Definition: alignCSCRings.py:92
BeamCurrentInfo::getBeam1Intensities
const std::vector< float > & getBeam1Intensities() const
Definition: BeamCurrentInfo.cc:12
BeamCurrentInfo::~BeamCurrentInfo
~BeamCurrentInfo()
destructor
Definition: BeamCurrentInfo.h:52
BeamCurrentInfo::beam1IntensitiesUnpacked_
std::vector< float > beam1IntensitiesUnpacked_
Definition: BeamCurrentInfo.h:81
BeamCurrentInfo::BeamCurrentInfo
BeamCurrentInfo(const std::vector< float > &beam1Intensities, const std::vector< float > &beam2Intensities)
constructor with fill
Definition: BeamCurrentInfo.h:45
BeamCurrentInfo::getBeam1IntensitiesPacked
const std::vector< uint16_t > & getBeam1IntensitiesPacked() const
Definition: BeamCurrentInfo.h:61
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
BeamCurrentInfo::beam1IntensitiesPacked_
std::vector< uint16_t > beam1IntensitiesPacked_
Definition: BeamCurrentInfo.h:79
operator<<
std::ostream & operator<<(std::ostream &s, const BeamCurrentInfo &beamInfo)
Definition: BeamCurrentInfo.cc:64
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