CMS 3D CMS Logo

LumiDetails.h
Go to the documentation of this file.
1 #ifndef DataFormats_Luminosity_LumiDetails_h
2 #define DataFormats_Luminosity_LumiDetails_h
3 
15 #include <utility>
16 #include <vector>
17 #include <string>
18 #include <iosfwd>
19 
20 class LumiDetails {
21 public:
22 
23  // If in the future additional algorithm names are added,
24  // it is important that they be added at the end of the list.
25  // The LumiDetails::algoNames function in LumiDetails.cc also
26  // would need to be updated to keep the list of names in sync.
27  enum Algos {
30  kET,
33  };
34  typedef unsigned int AlgoType;
35  typedef std::pair<std::vector<float>::const_iterator, std::vector<float>::const_iterator> ValueRange;
36  typedef std::pair<std::vector<float>::const_iterator, std::vector<float>::const_iterator> ErrorRange;
37  typedef std::pair<std::vector<short>::const_iterator, std::vector<short>::const_iterator> QualityRange;
38 
39  LumiDetails();
40  explicit LumiDetails(std::string const& lumiVersion);
41  ~LumiDetails();
42 
44  std::string const& lumiVersion() const;
45  bool isValid() const;
46 
47  // This will perform more efficiently if the calls to this
48  // are in the same order as the Algos enumeration. It will
49  // work properly even if they are not.
50  void fill(AlgoType algo,
51  std::vector<float> const& values,
52  std::vector<float> const& errors,
53  std::vector<short> const& qualities);
54 
55  void fillBeamIntensities(std::vector<float> const& beam1Intensities,
56  std::vector<float> const& beam2Intensities);
57 
58  float lumiValue(AlgoType algo, unsigned int bx) const;
59  float lumiError(AlgoType algo, unsigned int bx) const;
60  short lumiQuality(AlgoType algo, unsigned int bx) const;
61  float lumiBeam1Intensity(unsigned int bx) const;
62  float lumiBeam2Intensity(unsigned int bx) const;
63 
64  ValueRange lumiValuesForAlgo(AlgoType algo) const;
65  ErrorRange lumiErrorsForAlgo(AlgoType algo) const;
66  QualityRange lumiQualitiesForAlgo(AlgoType algo) const;
67  std::vector<float> const& lumiBeam1Intensities() const;
68  std::vector<float> const& lumiBeam2Intensities() const;
69 
70  bool isProductEqual(LumiDetails const& lumiDetails) const;
71 
72  static std::vector<std::string> const& algoNames();
73 
74  static std::vector<std::string> const& dipalgoNames();
75 
76 private:
77 
78  void checkAlgo(AlgoType algo) const;
79  void checkAlgoAndBX(AlgoType algo, unsigned int bx) const;
80 
81  static std::vector<std::string> const m_algoNames;
82 
84 
85  /* m_algoToFirstIndex is 'kMaxNumAlgos' long. Each algorithm's
86  numerical value from the enum Algos is used as the index into m_algoToFirstIndex
87  to find the first entry into the m_all* vectors containing data for that
88  algorithm. The entry beyond the last entry is found by using the numerical value + 1.
89  If the first and last index are the same then there is no information recorded for that
90  algorithm.
91  */
92  std::vector<unsigned int> m_algoToFirstIndex;
93  std::vector<float> m_allValues;
94  std::vector<float> m_allErrors;
95  std::vector<short> m_allQualities;
96  std::vector<float> m_beam1Intensities;
97  std::vector<float> m_beam2Intensities;
98 };
99 
100 std::ostream& operator<<(std::ostream & s, LumiDetails const& lumiDetails);
101 
102 #endif
float lumiBeam2Intensity(unsigned int bx) const
Definition: LumiDetails.cc:115
std::vector< float > const & lumiBeam2Intensities() const
Definition: LumiDetails.cc:146
std::pair< std::vector< float >::const_iterator, std::vector< float >::const_iterator > ValueRange
Definition: LumiDetails.h:35
ValueRange lumiValuesForAlgo(AlgoType algo) const
Definition: LumiDetails.cc:120
std::ostream & operator<<(std::ostream &s, LumiDetails const &lumiDetails)
Definition: LumiDetails.cc:192
bool isValid() const
Definition: LumiDetails.cc:57
void checkAlgoAndBX(AlgoType algo, unsigned int bx) const
Definition: LumiDetails.cc:184
std::vector< float > m_allErrors
Definition: LumiDetails.h:94
std::pair< std::vector< float >::const_iterator, std::vector< float >::const_iterator > ErrorRange
Definition: LumiDetails.h:36
std::vector< float > const & lumiBeam1Intensities() const
Definition: LumiDetails.cc:141
float lumiValue(AlgoType algo, unsigned int bx) const
Definition: LumiDetails.cc:92
std::vector< float > m_beam2Intensities
Definition: LumiDetails.h:97
float lumiBeam1Intensity(unsigned int bx) const
Definition: LumiDetails.cc:110
static std::vector< std::string > const m_algoNames
Definition: LumiDetails.h:81
short lumiQuality(AlgoType algo, unsigned int bx) const
Definition: LumiDetails.cc:104
void setLumiVersion(std::string const &lumiVersion)
Definition: LumiDetails.cc:47
std::string m_lumiVersion
Definition: LumiDetails.h:83
std::pair< std::vector< short >::const_iterator, std::vector< short >::const_iterator > QualityRange
Definition: LumiDetails.h:37
ErrorRange lumiErrorsForAlgo(AlgoType algo) const
Definition: LumiDetails.cc:127
void fill(AlgoType algo, std::vector< float > const &values, std::vector< float > const &errors, std::vector< short > const &qualities)
Definition: LumiDetails.cc:62
static std::vector< std::string > const & dipalgoNames()
Definition: LumiDetails.cc:157
std::vector< float > m_allValues
Definition: LumiDetails.h:93
static std::vector< std::string > const & algoNames()
Definition: LumiDetails.cc:151
unsigned int AlgoType
Definition: LumiDetails.h:34
void checkAlgo(AlgoType algo) const
Definition: LumiDetails.cc:176
std::vector< unsigned int > m_algoToFirstIndex
Definition: LumiDetails.h:92
QualityRange lumiQualitiesForAlgo(AlgoType algo) const
Definition: LumiDetails.cc:134
float lumiError(AlgoType algo, unsigned int bx) const
Definition: LumiDetails.cc:98
std::vector< short > m_allQualities
Definition: LumiDetails.h:95
void fillBeamIntensities(std::vector< float > const &beam1Intensities, std::vector< float > const &beam2Intensities)
Definition: LumiDetails.cc:85
Definition: errors.py:1
std::string const & lumiVersion() const
Definition: LumiDetails.cc:52
bool isProductEqual(LumiDetails const &lumiDetails) const
Definition: LumiDetails.cc:161
std::vector< float > m_beam1Intensities
Definition: LumiDetails.h:96