CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
DDMapper< KeyType, ValueType > Class Template Reference

#include <DDMapper.h>

Public Types

typedef std::pair< KeyType, ValueType > Pair
 usefull typedef More...
 
typedef std::vector< PairVector
 usefull typedef More...
 

Public Member Functions

Vector all (const std::string &name) const
 get all std::mapped instances which have a specific 'name' More...
 
Vector all (const std::string &name, const double &value) const
 get all std::mapped instances which have a specific 'name' with value 'value' More...
 
Vector all (const std::string &name, const std::string &value) const
 get all std::mapped instances which have a specific 'name' with value 'value' More...
 
void insert (const KeyType &, const ValueType &)
 insert a new key-value-pair More...
 
unsigned int noSpecifics (const KeyType &key, const std::string &name) const
 fetch a key given a value More...
 
unsigned int toDouble (const std::string &name, const KeyType &key, double &value, unsigned int pos=0) const
 returns the number specific parameters named 'name' and the corrsponding double More...
 
unsigned int toDouble (const std::string &name, const ValueType &key, double &value, unsigned int pos=0) const
 
unsigned int toString (const std::string &name, const KeyType &key, std::string &value, unsigned int pos=0) const
 same as toDouble but for std::string-valued values of named parameters More...
 
unsigned int toString (const std::string &name, const ValueType &key, std::string &value, unsigned int pos=0) const
 same as toDouble but for std::string-valued values of named parameters More...
 
bool value (const KeyType &key, ValueType &result)
 removes a key-value pair More...
 

Private Attributes

std::map< KeyType, ValueType > keyToValue_
 
std::multimap< ValueType, KeyType > valueToKey_
 

Detailed Description

template<class KeyType, class ValueType>
class DDMapper< KeyType, ValueType >

Definition at line 13 of file DDMapper.h.

Member Typedef Documentation

◆ Pair

template<class KeyType, class ValueType>
typedef std::pair<KeyType, ValueType> DDMapper< KeyType, ValueType >::Pair

usefull typedef

Definition at line 16 of file DDMapper.h.

◆ Vector

template<class KeyType, class ValueType>
typedef std::vector<Pair> DDMapper< KeyType, ValueType >::Vector

usefull typedef

Definition at line 19 of file DDMapper.h.

Member Function Documentation

◆ all() [1/3]

template<class K , class V >
std::vector< std::pair< K, V > > DDMapper< K, V >::all ( const std::string &  name) const

get all std::mapped instances which have a specific 'name'

Definition at line 263 of file DDMapper.h.

263  {
264  std::vector<std::pair<K, V> > result;
265  typedef std::vector<const DDsvalues_type *> sv_type;
266  typename std::map<V, K>::const_iterator it = valueToKey_.begin();
267  typename std::map<V, K>::const_iterator ed = valueToKey_.end();
268 
269  // loop over all registered ValueTypes
270  for (; it != ed; ++it) {
271  sv_type sv = it->first.specifics();
272  //std::cout << "now at: " << it->first.name() << std::endl;
273  sv_type::const_iterator svIt = sv.begin();
274  sv_type::const_iterator svEd = sv.end();
275  DDValue v(name);
276  for (; svIt != svEd; ++svIt) {
277  if (DDfetch(*svIt, v)) {
278  result.emplace_back(std::make_pair(it->second, it->first));
279  break;
280  }
281  }
282  }
283  return result;
284 }

◆ all() [2/3]

template<class K , class V >
std::vector< std::pair< K, V > > DDMapper< K, V >::all ( const std::string &  name,
const double &  value 
) const

get all std::mapped instances which have a specific 'name' with value 'value'

Definition at line 231 of file DDMapper.h.

231  {
232  std::vector<std::pair<K, V> > result;
233  typedef std::vector<const DDsvalues_type *> sv_type;
234  typename std::map<V, K>::const_iterator it = valueToKey_.begin();
235  typename std::map<V, K>::const_iterator ed = valueToKey_.end();
236 
237  // loop over all registered ValueTypes
238  for (; it != ed; ++it) {
239  sv_type sv = it->first.specifics();
240  //std::cout << "now at: " << it->first.name() << std::endl;
241  sv_type::const_iterator svIt = sv.begin();
242  sv_type::const_iterator svEd = sv.end();
243  DDValue v(name);
244  for (; svIt != svEd; ++svIt) {
245  if (DDfetch(*svIt, v)) {
246  //std::cout << "found: ";
247  const std::vector<double> &s = v.doubles();
248  if (!s.empty()) {
249  //std::cout << s[0];
250  if (s[0] == value) {
251  result.emplace_back(std::make_pair(it->second, it->first));
252  break;
253  }
254  }
255  //std::cout << std::endl;
256  }
257  }
258  }
259  return result;
260 }

◆ all() [3/3]

template<class K , class V >
std::vector< std::pair< K, V > > DDMapper< K, V >::all ( const std::string &  name,
const std::string &  value 
) const

get all std::mapped instances which have a specific 'name' with value 'value'

Definition at line 199 of file DDMapper.h.

199  {
200  std::vector<std::pair<K, V> > result;
201  typedef std::vector<const DDsvalues_type *> sv_type;
202  typename std::map<V, K>::const_iterator it = valueToKey_.begin();
203  typename std::map<V, K>::const_iterator ed = valueToKey_.end();
204 
205  // loop over all registered ValueTypes
206  for (; it != ed; ++it) {
207  sv_type sv = it->first.specifics();
208  //std::cout << "now at: " << it->first.name() << std::endl;
209  sv_type::const_iterator svIt = sv.begin();
210  sv_type::const_iterator svEd = sv.end();
211  DDValue v(name);
212  for (; svIt != svEd; ++svIt) {
213  if (DDfetch(*svIt, v)) {
214  //std::cout << "found: ";
215  const std::vector<std::string> &s = v.strings();
216  if (!s.empty()) {
217  //std::cout << s[0];
218  if (s[0] == value) {
219  result.emplace_back(std::make_pair(it->second, it->first));
220  break;
221  }
222  }
223  //std::cout << std::endl;
224  }
225  }
226  }
227  return result;
228 }

Referenced by DDG4ProductionCuts::initialize().

◆ insert()

template<class K, class V>
void DDMapper< K, V >::insert ( const K &  key,
const V &  value 
)

insert a new key-value-pair

any existing entry will be overridden

Definition at line 74 of file DDMapper.h.

74  {
76  valueToKey_.insert(std::make_pair(value, key));
77  // valueToKey_[value] = key;
78 }

Referenced by BeautifulSoup.PageElement::append(), DDG4Builder::BuildGeometry(), and DDG4Builder::convertLV().

◆ noSpecifics()

template<class K, class V >
unsigned int DDMapper< K, V >::noSpecifics ( const K &  key,
const std::string &  name 
) const

fetch a key given a value

the number of specific parameters which are named 'name'

Definition at line 92 of file DDMapper.h.

92  {
93  typedef std::vector<const DDsvalues_type *> sv_type;
94  unsigned int result = 0;
95  typename std::map<K, V>::const_iterator it = keyToValue_.find(key);
96  if (it != keyToValue_.end()) {
97  sv_type sv = it->second.specifics();
98  sv_type::const_iterator it = sv.begin();
99  DDValue v(name);
100  for (; it != sv.end(); ++it) {
101  if (DDfetch(*it, v)) {
102  result += v.size();
103  }
104  }
105  }
106  return result;
107 }

◆ toDouble() [1/2]

template<class K, class V >
unsigned int DDMapper< K, V >::toDouble ( const std::string &  name,
const K &  key,
double &  value,
unsigned int  pos = 0 
) const

returns the number specific parameters named 'name' and the corrsponding double

of the DDLogicalPart which corresponds to the given KeyType key. The returned value is assigned to the 'value'-reference

  • if no parameters exist, 0 is returned and value is left unchanged
  • if more than one parameter with the given name exists, the first is returned by default, alternatively 'pos' can be used to address another value (note: pos=0 -> first value)

Definition at line 111 of file DDMapper.h.

111  {
112  typedef std::vector<const DDsvalues_type *> sv_type;
113  unsigned int result = 0;
114  typename std::map<K, V>::const_iterator it = keyToValue_.find(key);
115  if (it != keyToValue_.end()) {
116  sv_type sv = it->second.specifics();
117  sv_type::const_iterator svIt = sv.begin();
118  sv_type::const_iterator svEd = sv.end();
119  DDValue v(name);
120  for (; svIt != svEd; ++svIt) {
121  if (DDfetch(*svIt, v)) {
122  result = v.size();
123  value = v.doubles()[pos];
124  break;
125  }
126  }
127  }
128  return result;
129 }

Referenced by DDG4ProductionCuts::setProdCuts().

◆ toDouble() [2/2]

template<class K , class V>
unsigned int DDMapper< K, V >::toDouble ( const std::string &  name,
const V &  key,
double &  value,
unsigned int  pos = 0 
) const

Definition at line 132 of file DDMapper.h.

132  {
133  typedef std::vector<const DDsvalues_type *> sv_type;
134  unsigned int result = 0;
135  sv_type sv = val.specifics();
136  sv_type::const_iterator svIt = sv.begin();
137  sv_type::const_iterator svEd = sv.end();
138  DDValue v(name);
139  for (; svIt != svEd; ++svIt) {
140  if (DDfetch(*svIt, v)) {
141  result = v.size();
142  value = v.doubles()[pos];
143  break;
144  }
145  }
146  return result;
147 }

◆ toString() [1/2]

template<class K, class V >
unsigned int DDMapper< K, V >::toString ( const std::string &  name,
const K &  key,
std::string &  value,
unsigned int  pos = 0 
) const

same as toDouble but for std::string-valued values of named parameters

Definition at line 172 of file DDMapper.h.

175  {
176  typedef std::vector<const DDsvalues_type *> sv_type;
177  unsigned int result = 0;
178  typename std::map<K, V>::const_iterator it = keyToValue_.find(key);
179  if (it != keyToValue_.end()) {
180  sv_type sv = it->second.specifics();
181  sv_type::const_iterator svIt = sv.begin();
182  sv_type::const_iterator svEd = sv.end();
183  DDValue v(name);
184  //std::cout << "DDValue=" << name << std::endl;
185  for (; svIt != svEd; ++svIt) {
186  //std::cout << "looping..." << **svIt << std::endl;
187  if (DDfetch(*svIt, v)) {
188  result = v.size();
189  //std::cout << "found!" << std::endl;
190  value = v.strings()[pos];
191  break;
192  }
193  }
194  }
195  return result;
196 }

Referenced by DDG4ProductionCuts::initialize().

◆ toString() [2/2]

template<class K, class V>
unsigned int DDMapper< K, V >::toString ( const std::string &  name,
const V &  key,
std::string &  value,
unsigned int  pos = 0 
) const

same as toDouble but for std::string-valued values of named parameters

Definition at line 150 of file DDMapper.h.

153  {
154  typedef std::vector<const DDsvalues_type *> sv_type;
155  unsigned int result = 0;
156  sv_type sv = val.specifics();
157  sv_type::const_iterator svIt = sv.begin();
158  sv_type::const_iterator svEd = sv.end();
159  DDValue v(name);
160  for (; svIt != svEd; ++svIt) {
161  if (DDfetch(*svIt, v)) {
162  result = v.size();
163  value = v.strings()[pos];
164  break;
165  }
166  }
167  return result;
168 }

◆ value()

template<class K, class V>
bool DDMapper< K, V >::value ( const K &  key,
V &  result 
)

Member Data Documentation

◆ keyToValue_

template<class KeyType, class ValueType>
std::map<KeyType, ValueType> DDMapper< KeyType, ValueType >::keyToValue_
private

Definition at line 69 of file DDMapper.h.

◆ valueToKey_

template<class KeyType, class ValueType>
std::multimap<ValueType, KeyType> DDMapper< KeyType, ValueType >::valueToKey_
private

Definition at line 70 of file DDMapper.h.

DDMapper::value
bool value(const KeyType &key, ValueType &result)
removes a key-value pair
Definition: DDMapper.h:81
pos
Definition: PixelAliasList.h:18
findQualityFiles.v
v
Definition: findQualityFiles.py:179
alignCSCRings.s
s
Definition: alignCSCRings.py:92
pfDeepBoostedJetPreprocessParams_cfi.sv
sv
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:226
DDfetch
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:79
DDMapper::keyToValue_
std::map< KeyType, ValueType > keyToValue_
Definition: DDMapper.h:69
DDMapper::valueToKey_
std::multimap< ValueType, KeyType > valueToKey_
Definition: DDMapper.h:70
value
Definition: value.py:1
heppy_batch.val
val
Definition: heppy_batch.py:351
DDValue
Definition: DDValue.h:21
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
mps_fire.result
result
Definition: mps_fire.py:303
crabWrapper.key
key
Definition: crabWrapper.py:19