CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
DDsvalues.cc File Reference
#include "DetectorDescription/Core/interface/DDsvalues.h"
#include <iostream>

Go to the source code of this file.

Functions

bool DDfetch (const DDsvalues_type *p, DDValue &v)
 helper for retrieving DDValues from DDsvalues_type *. More...
 
unsigned int DDfetch (const std::vector< const DDsvalues_type * > &sp, DDValue &toFetch, std::vector< DDValue > &result)
 helper for retrieving DDValues from a std::vector of (DDsvalues_type *). More...
 
void merge (DDsvalues_type &target, DDsvalues_type const &sv, bool sortit)
 
std::ostream & operator<< (std::ostream &os, const DDsvalues_type &s)
 
std::ostream & operator<< (std::ostream &os, const std::vector< const DDsvalues_type * > &v)
 

Function Documentation

bool DDfetch ( const DDsvalues_type p,
DDValue v 
)

helper for retrieving DDValues from DDsvalues_type *.

Example:

std::vector<std::string> myFunction(const DDsvalues_type * svalptr, const std::string & name)
{
static std::vector<std::string> v; // empty std::vector, for zero result
DDValue val(name);
if (DDfetch(svalptr,val)) {
return val.std::strings();
} else {
return v;
}
}

Definition at line 102 of file DDsvalues.cc.

References spr::find(), and query::result.

Referenced by DDMapper< KeyType, ValueType >::all(), GEMGeometryParsFromDD::buildGeometry(), GEMGeometryBuilderFromDDD::buildGeometry(), RPCGeometryBuilderFromDDD::buildGeometry(), RPCGeometryParsFromDD::buildGeometry(), DTGeometryBuilderFromDDD::buildGeometry(), DTGeometryParsFromDD::buildGeometry(), dddGetStringRaw(), DDfetch(), HFShowerFibreBundle::getDDDArray(), HFShowerPMT::getDDDArray(), HFFibre::getDDDArray(), MaterialBudgetHcalHistos::getDDDArray(), ECalSD::getDDDArray(), HFShower::getDDDArray(), HFShowerParam::getDDDArray(), HCalSD::getDDDArray(), HcalNumberingFromDDD::getDDDArray(), HFShowerLibrary::getDDDArray(), DDG4Builder::getDouble(), MuonDDDNumbering::getInt(), DDG4Builder::getInt(), CaloTrkProcessing::getNames(), CaloTrkProcessing::getNumbers(), ExtractStringFromDDD::getString(), DDG4SensitiveConverter::getString(), ECalSD::getStringArray(), CocoaAnalyzer::myFetchDbl(), CocoaAnalyzer::myFetchString(), DDMapper< KeyType, ValueType >::noSpecifics(), DDMapper< KeyType, ValueType >::toDouble(), and DDMapper< KeyType, ValueType >::toString().

103 {
104  bool result = false;
105  DDsvalues_type::const_iterator it = find(*p, v);
106  if (it != p->end()) {
107  result = true;
108  v = it->second;
109  }
110  return result;
111 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
tuple result
Definition: query.py:137
unsigned int DDfetch ( const std::vector< const DDsvalues_type * > &  sp,
DDValue toFetch,
std::vector< DDValue > &  result 
)

helper for retrieving DDValues from a std::vector of (DDsvalues_type *).

Definition at line 114 of file DDsvalues.cc.

References prof2calltree::count, and DDfetch().

115 {
116  unsigned int count = 0;
117  std::vector<const DDsvalues_type *>::const_iterator it(sp.begin()), ed(sp.end());
118  for (; it != ed; ++it) {
119  if (DDfetch(*it, toFetch)) {
120  result.push_back(toFetch);
121  ++count;
122  }
123  }
124  return count;
125 }
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:102
tuple result
Definition: query.py:137
void merge ( DDsvalues_type target,
DDsvalues_type const &  sv,
bool  sortit 
)

Definition at line 21 of file DDsvalues.cc.

References counter, spr::find(), and python.multivaluedict::sort().

21  {
22  static Counter counter = {0,0,0,0,0};
23  if (target.empty()) {
24  ++counter.empty;
25  target = sv;
26  return;
27  }
28  DDsvalues_type::const_iterator sit = sv.begin();
29  DDsvalues_type::const_iterator sed = sv.end();
30  // fast merge
31  if (target.back()<sv.front()) {
32  ++counter.end;
33  target.insert(target.end(),sit,sed);
34  return;
35  }
36  if (sv.back()<target.front()) {
37  ++counter.begin;
38  target.insert(target.begin(),sit,sed);
39  return;
40  }
41  {
42  DDsvalues_type::iterator it = std::lower_bound(target.begin(),target.end(),sv.front());
43  if (it == std::lower_bound(target.begin(),target.end(),sv.back())) {
44  ++counter.middle;
45  target.insert(it,sit,sed);
46  return;
47  }
48  }
49  // it nevers arrives here...
50  ++counter.mixed;
51  target.reserve(target.size()+sv.size());
52  DDsvalues_type::const_iterator ted = target.end();
53  for (; sit != sed; ++sit) {
54  DDsvalues_type::const_iterator it = find(target.begin(),ted, (*sit).first);
55  if (it!=ted) const_cast<DDsvalues_Content_type&>(*it).second = (*sit).second;
56  else target.push_back(*sit);
57  }
58  if (sortit) std::sort(target.begin(),target.end());
59 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
unsigned int(* Counter)(align::ID, const TrackerTopology *)
Definition: Counters.h:27
static std::atomic< unsigned int > counter
DDsvalues_type::value_type DDsvalues_Content_type
Definition: DDsvalues.h:20
std::ostream& operator<< ( std::ostream &  os,
const DDsvalues_type s 
)

Definition at line 62 of file DDsvalues.cc.

63 {
64  DDsvalues_type::const_iterator it = s.begin();
65  for(; it != s.end(); ++it) {
66  os << it->second;
67  /*
68  os << DDValue(it->first).name() << " = ";
69  for (unsigned int i=0; i<it->second.size(); ++i) {
70  os << it->second[i] << ' ';
71  }
72  os << std::endl;
73  */
74  }
75  return os;
76 }
std::ostream& operator<< ( std::ostream &  os,
const std::vector< const DDsvalues_type * > &  v 
)

Definition at line 79 of file DDsvalues.cc.

References i, and findQualityFiles::v.

80 {
81  for (unsigned int i=0; i<v.size() ; ++i) {
82  os << *(v[i]); // << std::endl;
83  }
84 
85  return os;
86 }
int i
Definition: DBlmapReader.cc:9