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, std::vector<std::string> list) const
120 {
121  std::vector<float> SummaryObj;
122  const HDQMSummary::Range range = getRange(detID);
123  if (range.first != range.second ) {
124  for (unsigned int i=0; i<list.size(); i++){
125  const short pos=getPosition(list.at(i));
126 
127  if (pos!=-1)
128  SummaryObj.push_back(*((range.first)+pos));
129  else
130  SummaryObj.push_back(-999.);
131  }
132  }
133  else
134  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
135 
136  return SummaryObj;
137 }
138 
139 std::vector<float> HDQMSummary::getSummaryObj(uint32_t& detID) const
140 {
141  std::vector<float> SummaryObj;
142  const HDQMSummary::Range range = getRange(detID);
143  if (range.first != range.second ) {
144  for (unsigned int i=0; i<userDBContent_.size(); i++) SummaryObj.push_back(*((range.first)+i));}
145  else {
146  for (unsigned int i=0; i<userDBContent_.size(); i++) SummaryObj.push_back(-99.);}
147  return SummaryObj;
148 }
149 
150 
151 
152 std::vector<float> HDQMSummary::getSummaryObj() const
153 {
154  return v_sum_;
155 }
156 
157 
158 std::vector<float> HDQMSummary::getSummaryObj(std::string elementName) const
159 {
160  std::vector<float> vSumElement;
161  std::vector<uint32_t> DetIds_ = getDetIds();
162  const short pos = getPosition(elementName);
163 
164  if (pos !=-1)
165  {
166  for (unsigned int i=0; i<DetIds_.size(); i++){
167  const HDQMSummary::Range range = getRange(DetIds_.at(i));
168  if (range.first != range.second ) {
169  vSumElement.push_back(*((range.first)+pos));}
170  else { vSumElement.push_back(-99.);}
171  }
172  }
173 
174  return vSumElement;
175 }
176 
177 
179 {
180  std::cout << "Nr. of detector elements in HDQMSummary object is " << indexes_.size()
181  << " RunNr= " << runNr_
182  << " timeValue= " << timeValue_
183  << std::endl;
184 }
185 
int i
Definition: DBlmapReader.cc:9
std::pair< ContainerIterator, ContainerIterator > Range
Definition: HDQMSummary.h:55
unsigned long long getTimeValue() const
Definition: HDQMSummary.h:111
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:124
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
unsigned long long timeValue_
Definition: HDQMSummary.h:128
std::vector< float > InputVector
Definition: HDQMSummary.h:58
void print()
Definition: HDQMSummary.cc:178
Registry::const_iterator RegistryIterator
Definition: HDQMSummary.h:57
std::vector< DetRegistry > indexes_
Definition: HDQMSummary.h:125
#define end
Definition: vmac.h:38
int getRunNr() const
Definition: HDQMSummary.h:113
std::vector< std::string > userDBContent_
Definition: HDQMSummary.h:123
Definition: DetId.h:20
std::vector< float > getSummaryObj() const
Definition: HDQMSummary.cc:152
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:31
tuple cout
Definition: gather_cfg.py:121
std::vector< std::string > getUserDBContent() const
Definition: HDQMSummary.h:112
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