CMS 3D CMS Logo

HDQMSummary.cc
Go to the documentation of this file.
3 
4 #include <algorithm>
5 
6 HDQMSummary::HDQMSummary(std::vector<std::string>& userDBContent) {
7  userDBContent_ = userDBContent;
8  runNr_ = 0;
9  timeValue_ = 0;
10 }
11 
14  runNr_ = input.getTimeValue();
15  timeValue_ = input.getRunNr();
16  v_sum_.clear();
17  indexes_.clear();
18  v_sum_.insert(v_sum_.end(), input.v_sum_.begin(), input.v_sum_.end());
19  indexes_.insert(indexes_.end(), input.indexes_.begin(), input.indexes_.end());
20 }
21 
22 bool HDQMSummary::put(const uint32_t& DetId, InputVector& input, std::vector<std::string>& userContent) {
23  Registry::iterator p = std::lower_bound(indexes_.begin(), indexes_.end(), DetId, HDQMSummary::StrictWeakOrdering());
24 
25  if (p == indexes_.end() || p->detid != DetId) {
26  //First request for the given DetID
27  //Create entries for all the declared userDBContent
28  //and fill for the provided userContent
29 
30  DetRegistry detregistry;
31  detregistry.detid = DetId;
32  detregistry.ibegin = v_sum_.size();
33  indexes_.insert(p, detregistry);
34  InputVector tmp(userDBContent_.size(), -9999);
35 
36  for (size_t i = 0; i < userContent.size(); ++i)
37  tmp[getPosition(userContent[i])] = input[i];
38 
39  v_sum_.insert(v_sum_.end(), tmp.begin(), tmp.end());
40  } else {
41  if (p->detid == DetId) {
42  //I should already find the entries
43  //fill for the provided userContent
44 
45  for (size_t i = 0; i < userContent.size(); ++i)
46  v_sum_[p->ibegin + getPosition(userContent[i])] = input[i];
47  }
48  }
49 
50  return true;
51 }
52 
53 const HDQMSummary::Range HDQMSummary::getRange(const uint32_t& DetId) const {
54  RegistryIterator p = std::lower_bound(indexes_.begin(), indexes_.end(), DetId, HDQMSummary::StrictWeakOrdering());
55  if (p == indexes_.end() || p->detid != DetId) {
56  return HDQMSummary::Range(v_sum_.end(), v_sum_.end());
57  std::cout << "not in range " << std::endl;
58  } else
59  return HDQMSummary::Range(v_sum_.begin() + p->ibegin, v_sum_.begin() + p->ibegin + userDBContent_.size());
60 }
61 
62 std::vector<uint32_t> HDQMSummary::getDetIds() const {
63  // returns vector of DetIds in map
64  std::vector<uint32_t> DetIds_;
67  for (HDQMSummary::RegistryIterator p = begin; p != end; ++p) {
68  DetIds_.push_back(p->detid);
69  }
70  return DetIds_;
71 }
72 
73 const short HDQMSummary::getPosition(std::string elementName) const {
74  // returns position of elementName in UserDBContent_
75 
76  std::vector<std::string>::const_iterator it = find(userDBContent_.begin(), userDBContent_.end(), elementName);
77  short pos = -1;
78  if (it != userDBContent_.end())
79  pos = it - userDBContent_.begin();
80  else
81  edm::LogError("HDQMSummary") << "attempting to retrieve non existing historic DB object : " << elementName
82  << std::endl;
83  return pos;
84 }
85 
86 void HDQMSummary::setObj(const uint32_t& detID, std::string elementName, float value) {
87  // modifies value of info "elementName" for the given detID
88  // requires that an entry has be defined beforehand for detId in DB
89  RegistryIterator p = std::lower_bound(indexes_.begin(), indexes_.end(), detID, HDQMSummary::StrictWeakOrdering());
90  if (p == indexes_.end() || p->detid != detID) {
91  throw cms::Exception("") << "not allowed to modify " << elementName
92  << " in historic DB - SummaryObj needs to be available first !";
93  }
94 
95  const HDQMSummary::Range range = getRange(detID);
96 
97  std::vector<float>::const_iterator it = range.first + getPosition(elementName);
98  std::vector<float>::difference_type pos = -1;
99  if (it != v_sum_.end()) {
100  pos = it - v_sum_.begin();
101  v_sum_.at(pos) = value;
102  }
103 }
104 
105 std::vector<float> HDQMSummary::getSummaryObj(uint32_t& detID, const std::vector<std::string>& _list) const {
106  std::vector<std::string> list = _list;
107  std::vector<float> SummaryObj;
108  const HDQMSummary::Range range = getRange(detID);
109  if (range.first != range.second) {
110  for (unsigned int i = 0; i < list.size(); i++) {
111  const short pos = getPosition(list.at(i));
112 
113  if (pos != -1)
114  SummaryObj.push_back(*((range.first) + pos));
115  else
116  SummaryObj.push_back(-999.);
117  }
118  } else
119  for (unsigned int i = 0; i < list.size(); i++)
120  SummaryObj.push_back(
121  -99.); // no summary obj has ever been inserted for this detid, most likely all related histos were not available in DQM
122 
123  return SummaryObj;
124 }
125 
126 std::vector<float> HDQMSummary::getSummaryObj(uint32_t& detID) const {
127  std::vector<float> SummaryObj;
128  const HDQMSummary::Range range = getRange(detID);
129  if (range.first != range.second) {
130  for (unsigned int i = 0; i < userDBContent_.size(); i++)
131  SummaryObj.push_back(*((range.first) + i));
132  } else {
133  for (unsigned int i = 0; i < userDBContent_.size(); i++)
134  SummaryObj.push_back(-99.);
135  }
136  return SummaryObj;
137 }
138 
139 std::vector<float> HDQMSummary::getSummaryObj() const { return v_sum_; }
140 
141 std::vector<float> HDQMSummary::getSummaryObj(std::string elementName) const {
142  std::vector<float> vSumElement;
143  std::vector<uint32_t> DetIds_ = getDetIds();
144  const short pos = getPosition(elementName);
145 
146  if (pos != -1) {
147  for (unsigned int i = 0; i < DetIds_.size(); i++) {
148  const HDQMSummary::Range range = getRange(DetIds_.at(i));
149  if (range.first != range.second) {
150  vSumElement.push_back(*((range.first) + pos));
151  } else {
152  vSumElement.push_back(-99.);
153  }
154  }
155  }
156 
157  return vSumElement;
158 }
159 
161  std::cout << "Nr. of detector elements in HDQMSummary object is " << indexes_.size() << " RunNr= " << runNr_
162  << " timeValue= " << timeValue_ << std::endl;
163 }
std::pair< ContainerIterator, ContainerIterator > Range
Definition: HDQMSummary.h:56
unsigned long long getTimeValue() const
Definition: HDQMSummary.h:106
bool put(const uint32_t &detID, InputVector &input, std::vector< std::string > &userContent)
Definition: HDQMSummary.cc:22
std::vector< float > v_sum_
Definition: HDQMSummary.h:117
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
void setObj(const uint32_t &detID, std::string elementName, float value)
Definition: HDQMSummary.cc:86
static std::string const input
Definition: EdmProvDump.cc:48
unsigned long long timeValue_
Definition: HDQMSummary.h:121
std::vector< float > InputVector
Definition: HDQMSummary.h:59
void print()
Definition: HDQMSummary.cc:160
Registry::const_iterator RegistryIterator
Definition: HDQMSummary.h:58
std::vector< DetRegistry > indexes_
Definition: HDQMSummary.h:118
#define end
Definition: vmac.h:39
Definition: value.py:1
int getRunNr() const
Definition: HDQMSummary.h:108
std::vector< std::string > userDBContent_
Definition: HDQMSummary.h:116
Definition: DetId.h:17
std::vector< float > getSummaryObj() const
Definition: HDQMSummary.cc:139
const short getPosition(std::string elementName) const
Definition: HDQMSummary.cc:73
const Range getRange(const uint32_t &detID) const
Definition: HDQMSummary.cc:53
std::vector< uint32_t > getDetIds() const
Definition: HDQMSummary.cc:62
#define begin
Definition: vmac.h:32
tmp
align.sh
Definition: createJobs.py:716
std::vector< std::string > getUserDBContent() const
Definition: HDQMSummary.h:107
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run