CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HDQMSummary.cc
Go to the documentation of this file.
3 
4 #include <algorithm>
5 
6 HDQMSummary::HDQMSummary(std::vector<std::string>& userDBContent)
7 {
8  userDBContent_ = userDBContent;
9  runNr_ = 0;
10  timeValue_ = 0;
11 }
12 
13 
15 {
17  runNr_ = input.getTimeValue();
18  timeValue_ = input.getRunNr();
19  v_sum_.clear();
20  indexes_.clear();
21  v_sum_.insert(v_sum_.end(),input.v_sum_.begin(),input.v_sum_.end());
22  indexes_.insert(indexes_.end(),input.indexes_.begin(),input.indexes_.end());
23 }
24 
25 
26 bool HDQMSummary::put(const uint32_t& DetId, InputVector &input, std::vector<std::string>& userContent )
27 {
28  Registry::iterator p = std::lower_bound(indexes_.begin(),indexes_.end(),DetId,HDQMSummary::StrictWeakOrdering());
29 
30  if(p==indexes_.end() || p->detid!=DetId){
31  //First request for the given DetID
32  //Create entries for all the declared userDBContent
33  //and fill for the provided userContent
34 
35  DetRegistry detregistry;
36  detregistry.detid = DetId;
37  detregistry.ibegin = v_sum_.size();
38  indexes_.insert(p,detregistry);
39  InputVector tmp(userDBContent_.size(),-9999);
40 
41  for(size_t i=0;i<userContent.size();++i)
42  tmp[getPosition(userContent[i])]=input[i];
43 
44  v_sum_.insert(v_sum_.end(),tmp.begin(),tmp.end());
45  } else {
46 
47  if (p->detid==DetId){
48  //I should already find the entries
49  //fill for the provided userContent
50 
51  for(size_t i=0;i<userContent.size();++i)
52  v_sum_[p->ibegin+getPosition(userContent[i])]=input[i];
53  }
54  }
55 
56  return true;
57 }
58 
59 
60 const HDQMSummary::Range HDQMSummary::getRange(const uint32_t& DetId) const
61 {
62 
63  RegistryIterator p = std::lower_bound(indexes_.begin(),indexes_.end(),DetId,HDQMSummary::StrictWeakOrdering());
64  if (p==indexes_.end()|| p->detid!=DetId) {
65  return HDQMSummary::Range(v_sum_.end(),v_sum_.end()); std::cout << "not in range " << std::endl;}
66  else
67  return HDQMSummary::Range(v_sum_.begin()+p->ibegin,v_sum_.begin()+p->ibegin+userDBContent_.size());
68 }
69 
70 
71 std::vector<uint32_t> HDQMSummary::getDetIds() const
72 {
73  // returns vector of DetIds in map
74  std::vector<uint32_t> DetIds_;
77  for (HDQMSummary::RegistryIterator p=begin; p != end; ++p) {
78  DetIds_.push_back(p->detid);
79  }
80  return DetIds_;
81 }
82 
83 
84 
85 const short HDQMSummary::getPosition(std::string elementName) const
86 {
87  // returns position of elementName in UserDBContent_
88 
89  std::vector<std::string>::const_iterator it = find(userDBContent_.begin(),userDBContent_.end(),elementName);
90  short pos = -1;
91  if (it != userDBContent_.end()) pos = it - userDBContent_.begin();
92  else edm::LogError("HDQMSummary") << "attempting to retrieve non existing historic DB object : "<< elementName <<std::endl;
93  return pos;
94 }
95 
96 
97 
98 void HDQMSummary::setObj(const uint32_t& detID, std::string elementName, float value)
99 {
100  // modifies value of info "elementName" for the given detID
101  // requires that an entry has be defined beforehand for detId in DB
102  RegistryIterator p = std::lower_bound(indexes_.begin(),indexes_.end(),detID,HDQMSummary::StrictWeakOrdering());
103  if (p==indexes_.end()|| p->detid!=detID)
104  {
105  throw cms::Exception("")
106  <<"not allowed to modify "<< elementName << " in historic DB - SummaryObj needs to be available first !";
107  }
108 
109  const HDQMSummary::Range range = getRange(detID);
110 
111  std::vector<float>::const_iterator it = range.first+getPosition(elementName);
112  std::vector<float>::difference_type pos = -1;
113  if (it != v_sum_.end()){
114  pos = it - v_sum_.begin();
115  v_sum_.at(pos) = value; }
116 }
117 
118 
119 std::vector<float> HDQMSummary::getSummaryObj(uint32_t& detID, const std::vector<std::string>& _list) const
120 {
121  std::vector<std::string> list = _list;
122  std::vector<float> SummaryObj;
123  const HDQMSummary::Range range = getRange(detID);
124  if (range.first != range.second ) {
125  for (unsigned int i=0; i<list.size(); i++){
126  const short pos=getPosition(list.at(i));
127 
128  if (pos!=-1)
129  SummaryObj.push_back(*((range.first)+pos));
130  else
131  SummaryObj.push_back(-999.);
132  }
133  }
134  else
135  for (unsigned int i=0; i<list.size(); i++) SummaryObj.push_back(-99.); // no summary obj has ever been inserted for this detid, most likely all related histos were not available in DQM
136 
137  return SummaryObj;
138 }
139 
140 std::vector<float> HDQMSummary::getSummaryObj(uint32_t& detID) const
141 {
142  std::vector<float> SummaryObj;
143  const HDQMSummary::Range range = getRange(detID);
144  if (range.first != range.second ) {
145  for (unsigned int i=0; i<userDBContent_.size(); i++) SummaryObj.push_back(*((range.first)+i));}
146  else {
147  for (unsigned int i=0; i<userDBContent_.size(); i++) SummaryObj.push_back(-99.);}
148  return SummaryObj;
149 }
150 
151 
152 
153 std::vector<float> HDQMSummary::getSummaryObj() const
154 {
155  return v_sum_;
156 }
157 
158 
159 std::vector<float> HDQMSummary::getSummaryObj(std::string elementName) const
160 {
161  std::vector<float> vSumElement;
162  std::vector<uint32_t> DetIds_ = getDetIds();
163  const short pos = getPosition(elementName);
164 
165  if (pos !=-1)
166  {
167  for (unsigned int i=0; i<DetIds_.size(); i++){
168  const HDQMSummary::Range range = getRange(DetIds_.at(i));
169  if (range.first != range.second ) {
170  vSumElement.push_back(*((range.first)+pos));}
171  else { vSumElement.push_back(-99.);}
172  }
173  }
174 
175  return vSumElement;
176 }
177 
178 
180 {
181  std::cout << "Nr. of detector elements in HDQMSummary object is " << indexes_.size()
182  << " RunNr= " << runNr_
183  << " timeValue= " << timeValue_
184  << std::endl;
185 }
186 
int i
Definition: DBlmapReader.cc:9
std::pair< ContainerIterator, ContainerIterator > Range
Definition: HDQMSummary.h:59
unsigned long long getTimeValue() const
Definition: HDQMSummary.h:115
bool put(const uint32_t &detID, InputVector &input, std::vector< std::string > &userContent)
Definition: HDQMSummary.cc:26
std::vector< float > v_sum_
Definition: HDQMSummary.h:128
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
void setObj(const uint32_t &detID, std::string elementName, float value)
Definition: HDQMSummary.cc:98
static std::string const input
Definition: EdmProvDump.cc:44
unsigned long long timeValue_
Definition: HDQMSummary.h:132
std::vector< float > InputVector
Definition: HDQMSummary.h:62
void print()
Definition: HDQMSummary.cc:179
Registry::const_iterator RegistryIterator
Definition: HDQMSummary.h:61
std::vector< DetRegistry > indexes_
Definition: HDQMSummary.h:129
#define end
Definition: vmac.h:37
int getRunNr() const
Definition: HDQMSummary.h:117
std::vector< std::string > userDBContent_
Definition: HDQMSummary.h:127
Definition: DetId.h:18
std::vector< float > getSummaryObj() const
Definition: HDQMSummary.cc:153
const short getPosition(std::string elementName) const
Definition: HDQMSummary.cc:85
const Range getRange(const uint32_t &detID) const
Definition: HDQMSummary.cc:60
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
std::vector< uint32_t > getDetIds() const
Definition: HDQMSummary.cc:71
#define begin
Definition: vmac.h:30
tuple cout
Definition: gather_cfg.py:145
std::vector< std::string > getUserDBContent() const
Definition: HDQMSummary.h:116
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