CMS 3D CMS Logo

SiStripSummary.cc
Go to the documentation of this file.
3 
4 #include <algorithm>
5 
6 SiStripSummary::SiStripSummary(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 SiStripSummary::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,SiStripSummary::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 bool SiStripSummary::put(sistripsummary::TrackerRegion region, InputVector &input, std::vector<std::string>& userContent ) {
61 
62  uint32_t fakeDet = region;
63  return put(fakeDet, input, userContent);
64 }
65 
66 
68 {
69 
70  RegistryIterator p = std::lower_bound(indexes_.begin(),indexes_.end(),DetId,SiStripSummary::StrictWeakOrdering());
71  if (p==indexes_.end()|| p->detid!=DetId) {
72  return SiStripSummary::Range(v_sum_.end(),v_sum_.end()); std::cout << "not in range " << std::endl;}
73  else
74  return SiStripSummary::Range(v_sum_.begin()+p->ibegin,v_sum_.begin()+p->ibegin+userDBContent_.size());
75 }
76 
77 
78 std::vector<uint32_t> SiStripSummary::getDetIds() const
79 {
80  // returns vector of DetIds in map
81  std::vector<uint32_t> DetIds_;
84  for (SiStripSummary::RegistryIterator p=begin; p != end; ++p) {
85  DetIds_.push_back(p->detid);
86  }
87  return DetIds_;
88 }
89 
90 
91 
92 const short SiStripSummary::getPosition(std::string elementName) const
93 {
94  // returns position of elementName in UserDBContent_
95 
96  std::vector<std::string>::const_iterator it = find(userDBContent_.begin(),userDBContent_.end(),elementName);
97  short pos = -1;
98  if (it != userDBContent_.end()) pos = it - userDBContent_.begin();
99  else edm::LogError("SiStripSummary") << "attempting to retrieve non existing historic DB object : "<< elementName <<std::endl;
100  return pos;
101 }
102 
103 
104 
105 void SiStripSummary::setObj(const uint32_t& detID, std::string elementName, float value)
106 {
107  // modifies value of info "elementName" for the given detID
108  // requires that an entry has be defined beforehand for detId in DB
109  RegistryIterator p = std::lower_bound(indexes_.begin(),indexes_.end(),detID,SiStripSummary::StrictWeakOrdering());
110  if (p==indexes_.end()|| p->detid!=detID)
111  {
112  throw cms::Exception("")
113  <<"not allowed to modify "<< elementName << " in historic DB - SummaryObj needs to be available first !";
114  }
115 
116  const SiStripSummary::Range range = getRange(detID);
117 
118  std::vector<float>::const_iterator it = range.first+getPosition(elementName);
119  std::vector<float>::difference_type pos = -1;
120  if (it != v_sum_.end()){
121  pos = it - v_sum_.begin();
122  v_sum_.at(pos) = value; }
123 }
124 
125 
126 std::vector<float> SiStripSummary::getSummaryObj(uint32_t& detID, const std::vector<std::string>& list) const
127 {
128  std::vector<float> SummaryObj;
129  const SiStripSummary::Range range = getRange(detID);
130  if (range.first != range.second ) {
131  for (unsigned int i=0; i<list.size(); i++){
132  const short pos=getPosition(list.at(i));
133 
134  if (pos!=-1)
135  SummaryObj.push_back(*((range.first)+pos));
136  else
137  SummaryObj.push_back(-999.);
138  }
139  }
140  else
141  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
142 
143  return SummaryObj;
144 }
145 
146 std::vector<float> SiStripSummary::getSummaryObj(sistripsummary::TrackerRegion region, const std::vector<std::string>& list) const
147 {
148 
149  uint32_t fakeDet = region;
150  return getSummaryObj(fakeDet,list);
151 }
152 
153 std::vector<float> SiStripSummary::getSummaryObj(uint32_t& detID) const
154 {
155  std::vector<float> SummaryObj;
156  const SiStripSummary::Range range = getRange(detID);
157  if (range.first != range.second ) {
158  for (unsigned int i=0; i<userDBContent_.size(); i++) SummaryObj.push_back(*((range.first)+i));}
159  else {
160  for (unsigned int i=0; i<userDBContent_.size(); i++) SummaryObj.push_back(-99.);}
161  return SummaryObj;
162 }
163 
164 
165 
166 std::vector<float> SiStripSummary::getSummaryObj() const
167 {
168  return v_sum_;
169 }
170 
171 
172 std::vector<float> SiStripSummary::getSummaryObj(std::string elementName) const
173 {
174  std::vector<float> vSumElement;
175  std::vector<uint32_t> DetIds_ = getDetIds();
176  const short pos = getPosition(elementName);
177 
178  if (pos !=-1)
179  {
180  for (unsigned int i=0; i<DetIds_.size(); i++){
181  const SiStripSummary::Range range = getRange(DetIds_.at(i));
182  if (range.first != range.second ) {
183  vSumElement.push_back(*((range.first)+pos));}
184  else { vSumElement.push_back(-99.);}
185  }
186  }
187 
188  return vSumElement;
189 }
190 
191 
193 {
194  std::cout << "Nr. of detector elements in SiStripSummary object is " << indexes_.size()
195  << " RunNr= " << runNr_
196  << " timeValue= " << timeValue_
197  << std::endl;
198 }
199 
std::vector< uint32_t > getDetIds() const
unsigned long long getTimeValue() const
const Range getRange(const uint32_t &detID) const
std::vector< DetRegistry > indexes_
Registry::const_iterator RegistryIterator
std::pair< ContainerIterator, ContainerIterator > Range
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
static std::string const input
Definition: EdmProvDump.cc:45
std::vector< float > v_sum_
void setObj(const uint32_t &detID, std::string elementName, float value)
unsigned long long timeValue_
#define end
Definition: vmac.h:39
std::vector< float > InputVector
Definition: value.py:1
Definition: DetId.h:18
bool put(const uint32_t &detID, InputVector &input, std::vector< std::string > &userContent)
std::vector< std::string > getUserDBContent() const
int getRunNr() const
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
#define begin
Definition: vmac.h:32
std::vector< float > getSummaryObj() const
std::vector< std::string > userDBContent_
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
const short getPosition(std::string elementName) const