CMS 3D CMS Logo

DDsvalues.cc
Go to the documentation of this file.
2 
3 #include <iostream>
4 
5 void merge(DDsvalues_type &target, DDsvalues_type const &sv, bool sortit /* =true */) {
6  if (target.empty()) {
7  target = sv;
8  return;
9  }
10  DDsvalues_type::const_iterator sit = sv.begin();
11  DDsvalues_type::const_iterator sed = sv.end();
12  // fast merge
13  if (target.back() < sv.front()) {
14  target.insert(target.end(), sit, sed);
15  return;
16  }
17  if (sv.back() < target.front()) {
18  target.insert(target.begin(), sit, sed);
19  return;
20  }
21  {
22  DDsvalues_type::iterator it = std::lower_bound(target.begin(), target.end(), sv.front());
23  if (it == std::lower_bound(target.begin(), target.end(), sv.back())) {
24  target.insert(it, sit, sed);
25  return;
26  }
27  }
28  // it nevers arrives here...
29  target.reserve(target.size() + sv.size());
30  DDsvalues_type::const_iterator ted = target.end();
31  for (; sit != sed; ++sit) {
32  DDsvalues_type::const_iterator it = find(target.begin(), ted, (*sit).first);
33  if (it != ted)
34  const_cast<DDsvalues_Content_type &>(*it).second = (*sit).second;
35  else
36  target.emplace_back(*sit);
37  }
38  if (sortit)
39  std::sort(target.begin(), target.end());
40 }
41 
42 std::ostream &operator<<(std::ostream &os, const DDsvalues_type &s) {
43  DDsvalues_type::const_iterator it = s.begin();
44  for (; it != s.end(); ++it) {
45  os << it->second;
46  /*
47  os << DDValue(it->first).name() << " = ";
48  for (unsigned int i=0; i<it->second.size(); ++i) {
49  os << it->second[i] << ' ';
50  }
51  os << std::endl;
52  */
53  }
54  return os;
55 }
56 
57 std::ostream &operator<<(std::ostream &os, const std::vector<const DDsvalues_type *> &v) {
58  for (const auto &i : v) {
59  os << *i; // << std::endl;
60  }
61 
62  return os;
63 }
64 
79 bool DDfetch(const DDsvalues_type *p, DDValue &v) {
80  bool result = false;
81  DDsvalues_type::const_iterator it = find(*p, v);
82  if (it != p->end()) {
83  result = true;
84  v = it->second;
85  }
86  return result;
87 }
88 
89 unsigned int DDfetch(const std::vector<const DDsvalues_type *> &sp, DDValue &toFetch, std::vector<DDValue> &result) {
90  unsigned int count = 0;
91  for (const auto &it : sp) {
92  if (DDfetch(it, toFetch)) {
93  result.emplace_back(toFetch);
94  ++count;
95  }
96  }
97  return count;
98 }
mps_fire.i
i
Definition: mps_fire.py:428
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
findQualityFiles.v
v
Definition: findQualityFiles.py:179
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
alignCSCRings.s
s
Definition: alignCSCRings.py:92
pfDeepBoostedJetPreprocessParams_cfi.sv
sv
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:352
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
operator<<
std::ostream & operator<<(std::ostream &os, const DDsvalues_type &s)
Definition: DDsvalues.cc:42
merge
void merge(DDsvalues_type &target, DDsvalues_type const &sv, bool sortit)
Definition: DDsvalues.cc:5
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:15
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
DDValue
Definition: DDValue.h:21
DDsvalues.h
filterCSVwithJSON.target
target
Definition: filterCSVwithJSON.py:32
mps_fire.result
result
Definition: mps_fire.py:311
DDfetch
bool DDfetch(const DDsvalues_type *p, DDValue &v)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:79
DDsvalues_type
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
Definition: DDsvalues.h:12