CMS 3D CMS Logo

LumiDetails.cc
Go to the documentation of this file.
3 
4 #include <cassert>
5 #include <iomanip>
6 #include <ostream>
7 
8 std::vector<std::string> const LumiDetails::m_algoNames = {
9  // If in the future additional algorithm names are added,
10  // it is important that they be added at the end of the list.
11  // The Algos enum in LumiDetails.h also would need to be
12  // updated to keep the list of names in sync.
13  {"OCC1"},
14  {"OCC2"},
15  {"ET"},
16  {"PLT"}};
17 
18 static std::vector<std::string> const s_dipalgoNames = {{"DIP"}};
19 
21  : m_lumiVersion("-1"),
22  m_algoToFirstIndex(kMaxNumAlgos + 1, 0),
23  m_allValues(),
24  m_allErrors(),
25  m_allQualities(),
26  m_beam1Intensities(),
27  m_beam2Intensities() {}
28 
30  : m_lumiVersion(lumiVersion),
31  m_algoToFirstIndex(kMaxNumAlgos + 1, 0),
32  m_allValues(),
33  m_allErrors(),
34  m_allQualities(),
35  m_beam1Intensities(),
36  m_beam2Intensities() {}
37 
39 
41 
43 
44 bool LumiDetails::isValid() const { return !m_allValues.empty(); }
45 
47  std::vector<float> const& values,
48  std::vector<float> const& errors,
49  std::vector<short> const& qualities) {
50  checkAlgo(algo);
51  if (values.size() != errors.size() || values.size() != qualities.size() ||
53  throw edm::Exception(edm::errors::LogicError) << "Illegal input values passed to LumiDetails::fill.\n"
54  << "The current implementation of LumiDetails only allows filling\n"
55  << "vectors for each algorithm once and the input vectors must\n"
56  << "all be the same size.\n";
57  }
58  m_allValues.insert(m_allValues.begin() + m_algoToFirstIndex[algo], values.begin(), values.end());
59  m_allErrors.insert(m_allErrors.begin() + m_algoToFirstIndex[algo], errors.begin(), errors.end());
60  m_allQualities.insert(m_allQualities.begin() + m_algoToFirstIndex[algo], qualities.begin(), qualities.end());
61  for (unsigned i = algo + 1U; i <= kMaxNumAlgos; ++i) {
62  m_algoToFirstIndex[i] += values.size();
63  }
64 }
65 
66 void LumiDetails::fillBeamIntensities(std::vector<float> const& beam1Intensities,
67  std::vector<float> const& beam2Intensities) {
68  m_beam1Intensities = beam1Intensities;
69  m_beam2Intensities = beam2Intensities;
70 }
71 
72 float LumiDetails::lumiValue(AlgoType algo, unsigned int bx) const {
75 }
76 
77 float LumiDetails::lumiError(AlgoType algo, unsigned int bx) const {
80 }
81 
82 short LumiDetails::lumiQuality(AlgoType algo, unsigned int bx) const {
85 }
86 
87 float LumiDetails::lumiBeam1Intensity(unsigned int bx) const { return m_beam1Intensities.at(bx); }
88 
89 float LumiDetails::lumiBeam2Intensity(unsigned int bx) const { return m_beam2Intensities.at(bx); }
90 
92  checkAlgo(algo);
94  m_allValues.begin() + m_algoToFirstIndex[algo + 1U]);
95 }
96 
98  checkAlgo(algo);
100  m_allErrors.begin() + m_algoToFirstIndex[algo + 1U]);
101 }
102 
104  checkAlgo(algo);
106  m_allQualities.begin() + m_algoToFirstIndex[algo + 1U]);
107 }
108 
109 std::vector<float> const& LumiDetails::lumiBeam1Intensities() const { return m_beam1Intensities; }
110 
111 std::vector<float> const& LumiDetails::lumiBeam2Intensities() const { return m_beam2Intensities; }
112 
113 std::vector<std::string> const& LumiDetails::algoNames() {
114  assert(m_algoNames.size() == kMaxNumAlgos);
115  return m_algoNames;
116 }
117 
118 std::vector<std::string> const& LumiDetails::dipalgoNames() { return s_dipalgoNames; }
119 bool LumiDetails::isProductEqual(LumiDetails const& lumiDetails) const {
120  if (m_lumiVersion == lumiDetails.m_lumiVersion && m_algoToFirstIndex == lumiDetails.m_algoToFirstIndex &&
121  m_allValues == lumiDetails.m_allValues && m_allErrors == lumiDetails.m_allErrors &&
122  m_allQualities == lumiDetails.m_allQualities && m_beam1Intensities == lumiDetails.m_beam1Intensities &&
123  m_beam2Intensities == lumiDetails.m_beam2Intensities) {
124  return true;
125  }
126  return false;
127 }
128 
130  if (algo >= kMaxNumAlgos) {
132  << "Algorithm type argument out of range in a call to a function in LumiDetails\n";
133  }
134 }
135 
136 void LumiDetails::checkAlgoAndBX(AlgoType algo, unsigned int bx) const {
137  checkAlgo(algo);
140  << "Branch crossing argument out of range in call to a function in LumiDetails\n";
141  }
142 }
143 
144 std::ostream& operator<<(std::ostream& s, LumiDetails const& lumiDetails) {
145  s << "\nDumping LumiDetails\n";
146  s << std::setw(12) << "lumi version " << lumiDetails.lumiVersion() << "\n";
147  std::vector<std::string>::const_iterator algo;
148  std::vector<std::string>::const_iterator algoEnd;
149  if (lumiDetails.lumiVersion() != std::string("DIP")) {
150  algo = lumiDetails.algoNames().begin();
151  algoEnd = lumiDetails.algoNames().end();
152  } else {
153  algo = lumiDetails.dipalgoNames().begin();
154  algoEnd = lumiDetails.dipalgoNames().end();
155  }
157 
158  for (; algo != algoEnd; ++algo, ++i) {
159  std::vector<float>::const_iterator value = lumiDetails.lumiValuesForAlgo(i).first;
160  std::vector<float>::const_iterator valueEnd = lumiDetails.lumiValuesForAlgo(i).second;
161  std::vector<float>::const_iterator error = lumiDetails.lumiErrorsForAlgo(i).first;
162  std::vector<short>::const_iterator quality = lumiDetails.lumiQualitiesForAlgo(i).first;
163 
164  s << "algorithm: " << *algo << "\n";
165  s << std::setw(12) << "value" << std::setw(12) << "error" << std::setw(12) << "quality"
166  << "\n";
167 
168  for (; value != valueEnd; ++value, ++error, ++quality) {
169  s << std::setw(12) << *value << std::setw(12) << *error << std::setw(12) << *quality << "\n";
170  }
171  s << "\n";
172  }
173  s << "beam 1 intensities:\n";
174  std::vector<float> const& beam1Intensities = lumiDetails.lumiBeam1Intensities();
175  for (std::vector<float>::const_iterator intensity = beam1Intensities.begin(), iEnd = beam1Intensities.end();
176  intensity != iEnd;
177  ++intensity) {
178  s << *intensity << "\n";
179  }
180  s << "\nbeam 2 intensities:\n";
181  std::vector<float> const& beam2Intensities = lumiDetails.lumiBeam2Intensities();
182  for (std::vector<float>::const_iterator intensity = beam2Intensities.begin(), iEnd = beam2Intensities.end();
183  intensity != iEnd;
184  ++intensity) {
185  s << *intensity << "\n";
186  }
187  s << "\n";
188  return s;
189 }
LumiDetails::checkAlgo
void checkAlgo(AlgoType algo) const
Definition: LumiDetails.cc:129
mps_fire.i
i
Definition: mps_fire.py:428
LumiDetails::m_allErrors
std::vector< float > m_allErrors
Definition: LumiDetails.h:85
edm::errors::LogicError
Definition: EDMException.h:37
s_dipalgoNames
static const std::vector< std::string > s_dipalgoNames
Definition: LumiDetails.cc:18
LumiDetails::LumiDetails
LumiDetails()
Definition: LumiDetails.cc:20
LumiDetails::QualityRange
std::pair< std::vector< short >::const_iterator, std::vector< short >::const_iterator > QualityRange
Definition: LumiDetails.h:30
LumiDetails::m_lumiVersion
std::string m_lumiVersion
Definition: LumiDetails.h:74
LumiDetails::algoNames
static std::vector< std::string > const & algoNames()
Definition: LumiDetails.cc:113
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
cms::cuda::assert
assert(be >=bs)
LumiDetails::setLumiVersion
void setLumiVersion(std::string const &lumiVersion)
Definition: LumiDetails.cc:40
LumiDetails
Definition: LumiDetails.h:20
LumiDetails::m_algoNames
static const std::vector< std::string > m_algoNames
Definition: LumiDetails.h:72
relativeConstraints.error
error
Definition: relativeConstraints.py:53
quality
const uint32_t *__restrict__ Quality * quality
Definition: CAHitNtupletGeneratorKernelsImpl.h:109
LumiDetails::fill
void fill(AlgoType algo, std::vector< float > const &values, std::vector< float > const &errors, std::vector< short > const &qualities)
Definition: LumiDetails.cc:46
EDMException.h
cmsdt::algo
algo
Definition: constants.h:165
LumiDetails::ValueRange
std::pair< std::vector< float >::const_iterator, std::vector< float >::const_iterator > ValueRange
Definition: LumiDetails.h:28
alignCSCRings.s
s
Definition: alignCSCRings.py:92
LumiDetails::isValid
bool isValid() const
Definition: LumiDetails.cc:44
operator<<
std::ostream & operator<<(std::ostream &s, LumiDetails const &lumiDetails)
Definition: LumiDetails.cc:144
errors
Definition: errors.py:1
LumiDetails::m_allValues
std::vector< float > m_allValues
Definition: LumiDetails.h:84
LumiDetails::lumiError
float lumiError(AlgoType algo, unsigned int bx) const
Definition: LumiDetails.cc:77
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
LumiDetails::lumiValuesForAlgo
ValueRange lumiValuesForAlgo(AlgoType algo) const
Definition: LumiDetails.cc:91
LumiDetails::lumiValue
float lumiValue(AlgoType algo, unsigned int bx) const
Definition: LumiDetails.cc:72
LumiDetails::checkAlgoAndBX
void checkAlgoAndBX(AlgoType algo, unsigned int bx) const
Definition: LumiDetails.cc:136
LumiDetails::m_algoToFirstIndex
std::vector< unsigned int > m_algoToFirstIndex
Definition: LumiDetails.h:83
LumiDetails::ErrorRange
std::pair< std::vector< float >::const_iterator, std::vector< float >::const_iterator > ErrorRange
Definition: LumiDetails.h:29
LumiDetails::m_beam2Intensities
std::vector< float > m_beam2Intensities
Definition: LumiDetails.h:88
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
LumiDetails::dipalgoNames
static std::vector< std::string > const & dipalgoNames()
Definition: LumiDetails.cc:118
LumiDetails::~LumiDetails
~LumiDetails()
Definition: LumiDetails.cc:38
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LumiDetails::kMaxNumAlgos
Definition: LumiDetails.h:26
LumiDetails::lumiBeam1Intensity
float lumiBeam1Intensity(unsigned int bx) const
Definition: LumiDetails.cc:87
LumiDetails::lumiBeam2Intensities
std::vector< float > const & lumiBeam2Intensities() const
Definition: LumiDetails.cc:111
LumiDetails.h
value
Definition: value.py:1
LumiDetails::lumiQuality
short lumiQuality(AlgoType algo, unsigned int bx) const
Definition: LumiDetails.cc:82
LumiDetails::m_allQualities
std::vector< short > m_allQualities
Definition: LumiDetails.h:86
LumiDetails::m_beam1Intensities
std::vector< float > m_beam1Intensities
Definition: LumiDetails.h:87
LumiDetails::lumiVersion
std::string const & lumiVersion() const
Definition: LumiDetails.cc:42
relativeConstraints.value
value
Definition: relativeConstraints.py:53
LumiDetails::lumiErrorsForAlgo
ErrorRange lumiErrorsForAlgo(AlgoType algo) const
Definition: LumiDetails.cc:97
Exception
Definition: hltDiff.cc:245
LumiDetails::lumiBeam1Intensities
std::vector< float > const & lumiBeam1Intensities() const
Definition: LumiDetails.cc:109
LumiDetails::lumiQualitiesForAlgo
QualityRange lumiQualitiesForAlgo(AlgoType algo) const
Definition: LumiDetails.cc:103
LumiDetails::lumiBeam2Intensity
float lumiBeam2Intensity(unsigned int bx) const
Definition: LumiDetails.cc:89
LumiDetails::AlgoType
unsigned int AlgoType
Definition: LumiDetails.h:27
LumiDetails::fillBeamIntensities
void fillBeamIntensities(std::vector< float > const &beam1Intensities, std::vector< float > const &beam2Intensities)
Definition: LumiDetails.cc:66
LumiDetails::isProductEqual
bool isProductEqual(LumiDetails const &lumiDetails) const
Definition: LumiDetails.cc:119