test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 std::string &value) const
 get all std::mapped instances which have a specific 'name' with value 'value' 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
 get all std::mapped instances which have a specific 'name' 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

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

usefull typedef

Definition at line 17 of file DDMapper.h.

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

usefull typedef

Definition at line 20 of file DDMapper.h.

Member Function Documentation

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 208 of file DDMapper.h.

References DDfetch(), mps_fire::result, alignCSCRings::s, DDValue::strings(), and findQualityFiles::v.

Referenced by DDG4ProductionCuts::initialize().

209 {
210  std::vector<std::pair<K,V> > result;
211  typedef std::vector<const DDsvalues_type *> sv_type;
212  typename std::map<V,K>::const_iterator it = valueToKey_.begin();
213  typename std::map<V,K>::const_iterator ed = valueToKey_.end();
214 
215  // loop over all registered ValueTypes
216  for (; it != ed; ++it) {
217  sv_type sv = it->first.specifics();
218  //std::cout << "now at: " << it->first.name() << std::endl;
219  sv_type::const_iterator svIt = sv.begin();
220  sv_type::const_iterator svEd = sv.end();
221  DDValue v(name);
222  for (; svIt != svEd; ++svIt) {
223  if (DDfetch(*svIt,v)) {
224  //std::cout << "found: ";
225  const std::vector<std::string> & s = v.strings();
226  if (s.size()) {
227  //std::cout << s[0];
228  if (s[0]==value) {
229  result.push_back(std::make_pair(it->second,it->first));
230  break;
231  }
232  }
233  //std::cout << std::endl;
234  }
235  }
236  }
237  return result;
238 }
bool value(const KeyType &key, ValueType &result)
removes a key-value pair
Definition: DDMapper.h:86
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:80
tuple result
Definition: mps_fire.py:83
std::multimap< ValueType, KeyType > valueToKey_
Definition: DDMapper.h:72
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 242 of file DDMapper.h.

References DDfetch(), DDValue::doubles(), mps_fire::result, alignCSCRings::s, and findQualityFiles::v.

243 {
244  std::vector<std::pair<K,V> > result;
245  typedef std::vector<const DDsvalues_type *> sv_type;
246  typename std::map<V,K>::const_iterator it = valueToKey_.begin();
247  typename std::map<V,K>::const_iterator ed = valueToKey_.end();
248 
249  // loop over all registered ValueTypes
250  for (; it != ed; ++it) {
251  sv_type sv = it->first.specifics();
252  //std::cout << "now at: " << it->first.name() << std::endl;
253  sv_type::const_iterator svIt = sv.begin();
254  sv_type::const_iterator svEd = sv.end();
255  DDValue v(name);
256  for (; svIt != svEd; ++svIt) {
257  if (DDfetch(*svIt,v)) {
258  //std::cout << "found: ";
259  const std::vector<double> & s = v.doubles();
260  if (s.size()) {
261  //std::cout << s[0];
262  if (s[0]==value) {
263  result.push_back(std::make_pair(it->second,it->first));
264  break;
265  }
266  }
267  //std::cout << std::endl;
268  }
269  }
270  }
271  return result;
272 }
bool value(const KeyType &key, ValueType &result)
removes a key-value pair
Definition: DDMapper.h:86
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:80
tuple result
Definition: mps_fire.py:83
std::multimap< ValueType, KeyType > valueToKey_
Definition: DDMapper.h:72
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 276 of file DDMapper.h.

References DDfetch(), mps_fire::result, and findQualityFiles::v.

277 {
278  std::vector<std::pair<K,V> > result;
279  typedef std::vector<const DDsvalues_type *> sv_type;
280  typename std::map<V,K>::const_iterator it = valueToKey_.begin();
281  typename std::map<V,K>::const_iterator ed = valueToKey_.end();
282 
283  // loop over all registered ValueTypes
284  for (; it != ed; ++it) {
285  sv_type sv = it->first.specifics();
286  //std::cout << "now at: " << it->first.name() << std::endl;
287  sv_type::const_iterator svIt = sv.begin();
288  sv_type::const_iterator svEd = sv.end();
289  DDValue v(name);
290  for (; svIt != svEd; ++svIt) {
291  if (DDfetch(*svIt,v)) {
292  result.push_back(std::make_pair(it->second,it->first));
293  break;
294  }
295  }
296  }
297  return result;
298 }
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:80
tuple result
Definition: mps_fire.py:83
std::multimap< ValueType, KeyType > valueToKey_
Definition: DDMapper.h:72
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 77 of file DDMapper.h.

References relval_steps::key, and relativeConstraints::value.

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

78 {
80  valueToKey_.insert(std::make_pair(value,key));
81  // valueToKey_[value] = key;
82 }
bool value(const KeyType &key, ValueType &result)
removes a key-value pair
Definition: DDMapper.h:86
std::map< KeyType, ValueType > keyToValue_
Definition: DDMapper.h:71
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
std::multimap< ValueType, KeyType > valueToKey_
Definition: DDMapper.h:72
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 98 of file DDMapper.h.

References DDfetch(), mps_fire::result, DDValue::size(), and findQualityFiles::v.

99 {
100  typedef std::vector<const DDsvalues_type *> sv_type;
101  unsigned int result = 0;
102  typename std::map<K,V>::const_iterator it = keyToValue_.find(key);
103  if (it != keyToValue_.end()) {
104  sv_type sv = it->second.specifics();
105  sv_type::const_iterator it = sv.begin();
106  DDValue v(name);
107  for (; it != sv.end(); ++it) {
108  if (DDfetch(*it, v)) {
109  result += v.size();
110  }
111  }
112  }
113  return result;
114 }
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:80
tuple result
Definition: mps_fire.py:83
std::map< KeyType, ValueType > keyToValue_
Definition: DDMapper.h:71
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
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 119 of file DDMapper.h.

References DDfetch(), DDValue::doubles(), mps_fire::result, DDValue::size(), and findQualityFiles::v.

Referenced by DDG4ProductionCuts::setProdCuts().

120 {
121  typedef std::vector<const DDsvalues_type *> sv_type;
122  unsigned int result=0;
123  typename std::map<K,V>::const_iterator it = keyToValue_.find(key);
124  if (it != keyToValue_.end()) {
125  sv_type sv = it->second.specifics();
126  sv_type::const_iterator svIt = sv.begin();
127  sv_type::const_iterator svEd = sv.end();
128  DDValue v(name);
129  for (; svIt != svEd; ++svIt) {
130  if (DDfetch(*svIt,v)) {
131  result = v.size();
132  value = v.doubles()[pos];
133  break;
134  }
135  }
136  }
137  return result;
138 }
bool value(const KeyType &key, ValueType &result)
removes a key-value pair
Definition: DDMapper.h:86
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:80
tuple result
Definition: mps_fire.py:83
std::map< KeyType, ValueType > keyToValue_
Definition: DDMapper.h:71
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
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 142 of file DDMapper.h.

References DDfetch(), DDValue::doubles(), mps_fire::result, DDValue::size(), and findQualityFiles::v.

143 {
144  typedef std::vector<const DDsvalues_type *> sv_type;
145  unsigned int result=0;
146  sv_type sv = val.specifics();
147  sv_type::const_iterator svIt = sv.begin();
148  sv_type::const_iterator svEd = sv.end();
149  DDValue v(name);
150  for (; svIt != svEd; ++svIt) {
151  if (DDfetch(*svIt,v)) {
152  result = v.size();
153  value = v.doubles()[pos];
154  break;
155  }
156  }
157  return result;
158 }
bool value(const KeyType &key, ValueType &result)
removes a key-value pair
Definition: DDMapper.h:86
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:80
tuple result
Definition: mps_fire.py:83
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 182 of file DDMapper.h.

References DDfetch(), mps_fire::result, DDValue::size(), DDValue::strings(), and findQualityFiles::v.

Referenced by DDG4ProductionCuts::initialize(), and DDG4ProductionCuts::setProdCuts().

183 {
184  typedef std::vector<const DDsvalues_type *> sv_type;
185  unsigned int result=0;
186  typename std::map<K,V>::const_iterator it = keyToValue_.find(key);
187  if (it != keyToValue_.end()) {
188  sv_type sv = it->second.specifics();
189  sv_type::const_iterator svIt = sv.begin();
190  sv_type::const_iterator svEd = sv.end();
191  DDValue v(name);
192  //std::cout << "DDValue=" << name << std::endl;
193  for (; svIt != svEd; ++svIt) {
194  //std::cout << "looping..." << **svIt << std::endl;
195  if (DDfetch(*svIt,v)) {
196  result = v.size();
197  //std::cout << "found!" << std::endl;
198  value = v.strings()[pos];
199  break;
200  }
201  }
202  }
203  return result;
204 }
bool value(const KeyType &key, ValueType &result)
removes a key-value pair
Definition: DDMapper.h:86
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:80
tuple result
Definition: mps_fire.py:83
std::map< KeyType, ValueType > keyToValue_
Definition: DDMapper.h:71
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
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 162 of file DDMapper.h.

References DDfetch(), mps_fire::result, DDValue::size(), DDValue::strings(), and findQualityFiles::v.

163 {
164  typedef std::vector<const DDsvalues_type *> sv_type;
165  unsigned int result=0;
166  sv_type sv = val.specifics();
167  sv_type::const_iterator svIt = sv.begin();
168  sv_type::const_iterator svEd = sv.end();
169  DDValue v(name);
170  for (; svIt != svEd; ++svIt) {
171  if (DDfetch(*svIt,v)) {
172  result = v.size();
173  value = v.strings()[pos];
174  break;
175  }
176  }
177  return result;
178 }
bool value(const KeyType &key, ValueType &result)
removes a key-value pair
Definition: DDMapper.h:86
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:80
tuple result
Definition: mps_fire.py:83
template<class K, class V>
bool DDMapper< K, V >::value ( const K &  key,
V &  result 
)

removes a key-value pair

non-existing keys are simply ignored removes a key-value pair non-existing values are simply ignored fetch a value given a key returns true, if sucessfull - value is assigned to result; else false

Definition at line 86 of file DDMapper.h.

References mps_fire::result.

Referenced by Types.int32::__nonzero__(), Types.uint32::__nonzero__(), Types.int64::__nonzero__(), Types.uint64::__nonzero__(), Types.double::__nonzero__(), Types.bool::__nonzero__(), Types.string::__nonzero__(), average.Average::average(), Vispa.Views.PropertyView.FileProperty::buttonClicked(), Types.string::configValue(), Types.FileInPath::configValue(), Mixins.UsingBlock::dumpPython(), Types.int32::insertInto(), Types.uint32::insertInto(), Types.int64::insertInto(), Types.uint64::insertInto(), Mixins.UsingBlock::insertInto(), Types.double::insertInto(), Types.bool::insertInto(), Types.string::insertInto(), Types.FileInPath::insertInto(), Types.vint32::insertInto(), Types.vuint32::insertInto(), Types.vint64::insertInto(), Types.vuint64::insertInto(), Types.vdouble::insertInto(), Types.vbool::insertInto(), Types.vstring::insertInto(), and Vispa.Views.PropertyView.FileProperty::labelDoubleClicked().

87 {
88  bool result = false;
89  typename std::map<K,V>::const_iterator it = keyToValue_.find(key);
90  if (it != keyToValue_.end()) {
91  value = it->second;
92  result = true;
93  }
94  return result;
95 }
bool value(const KeyType &key, ValueType &result)
removes a key-value pair
Definition: DDMapper.h:86
tuple result
Definition: mps_fire.py:83
std::map< KeyType, ValueType > keyToValue_
Definition: DDMapper.h:71
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.

Member Data Documentation

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

Definition at line 71 of file DDMapper.h.

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

Definition at line 72 of file DDMapper.h.