test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Typedefs | Functions
DDsvalues.h File Reference
#include <ostream>
#include <map>
#include <vector>
#include <algorithm>
#include "DetectorDescription/Core/interface/DDValue.h"

Go to the source code of this file.

Typedefs

typedef DDsvalues_type::value_type DDsvalues_Content_type
 
typedef std::vector< std::pair
< unsigned int, DDValue > > 
DDsvalues_type
 std::maps an index to a DDValue. The index corresponds to the index assigned to the name of the std::mapped DDValue. More...
 

Functions

bool DDfetch (const DDsvalues_type *, DDValue &)
 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...
 
DDsvalues_type::const_iterator find (DDsvalues_type::const_iterator begin, DDsvalues_type::const_iterator end, unsigned int id)
 
DDsvalues_type::const_iterator find (DDsvalues_type const &sv, unsigned int id)
 
void merge (DDsvalues_type &target, DDsvalues_type const &sv, bool sortit=true)
 
bool operator< (const DDsvalues_Content_type &lh, const DDsvalues_Content_type &rh)
 
std::ostream & operator<< (std::ostream &, const DDsvalues_type &)
 
std::ostream & operator<< (std::ostream &, const std::vector< const DDsvalues_type * > &)
 

Typedef Documentation

typedef DDsvalues_type::value_type DDsvalues_Content_type

Definition at line 20 of file DDsvalues.h.

typedef std::vector< std::pair<unsigned int, DDValue> > DDsvalues_type

std::maps an index to a DDValue. The index corresponds to the index assigned to the name of the std::mapped DDValue.

Definition at line 19 of file DDsvalues.h.

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
DDsvalues_type::const_iterator find ( DDsvalues_type::const_iterator  begin,
DDsvalues_type::const_iterator  end,
unsigned int  id 
)
inline

Definition at line 30 of file DDsvalues.h.

References end, and findQualityFiles::v.

30  {
31  static const DDValue dummy;
32  DDsvalues_Content_type v(id,dummy);
33  DDsvalues_type::const_iterator it = std::lower_bound(begin,end,v);
34  if (it!=end && (*it).first==id) return it;
35  return end;
36 }
#define end
Definition: vmac.h:37
#define begin
Definition: vmac.h:30
DDsvalues_type::value_type DDsvalues_Content_type
Definition: DDsvalues.h:20
DDsvalues_type::const_iterator find ( DDsvalues_type const &  sv,
unsigned int  id 
)
inline

Definition at line 38 of file DDsvalues.h.

References spr::find().

38  {
39  return find(sv.begin(),sv.end(),id);
40 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
void merge ( DDsvalues_type target,
DDsvalues_type const &  sv,
bool  sortit = true 
)

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
bool operator< ( const DDsvalues_Content_type lh,
const DDsvalues_Content_type rh 
)
inline

Definition at line 26 of file DDsvalues.h.

26  {
27  return lh.first < rh.first;
28 }
bool int lh
Definition: SIMDVec.h:19
std::ostream& operator<< ( std::ostream &  ,
const DDsvalues_type  
)

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 &  ,
const std::vector< const DDsvalues_type * > &   
)

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