#include <DetectorDescription/Core/interface/DDMapper.h>
Public Types | |
typedef std::pair< KeyType, ValueType > | Pair |
usefull typedef | |
typedef std::vector< Pair > | Vector |
usefull typedef | |
Public Member Functions | |
Vector | all (const std::string &name) const |
get all std::mapped instances which have a specific 'name' | |
Vector | all (const std::string &name, const double &value) const |
get all std::mapped instances which have a specific 'name' with value 'value' | |
Vector | all (const std::string &name, const std::string &value) const |
get all std::mapped instances which have a specific 'name' with value 'value' | |
void | insert (const KeyType &, const ValueType &) |
insert a new key-value-pair | |
unsigned int | noSpecifics (const KeyType &key, const std::string &name) const |
fetch a key given a value | |
unsigned int | toDouble (const std::string &name, const ValueType &key, double &value, unsigned int pos=0) const |
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 | |
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 | |
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 | |
bool | value (const KeyType &key, ValueType &result) |
removes a key-value pair | |
Private Attributes | |
std::map< KeyType, ValueType > | keyToValue_ |
std::multimap< ValueType, KeyType > | valueToKey_ |
Definition at line 13 of file DDMapper.h.
std::vector< std::pair< K, V > > DDMapper< K, V >::all | ( | const std::string & | name | ) | const [inline] |
get all std::mapped instances which have a specific 'name'
Definition at line 276 of file DDMapper.h.
References DDfetch(), it, HLT_VtxMuL3::result, sv, v, and DDMapper< KeyType, ValueType >::valueToKey_.
00277 { 00278 std::vector<std::pair<K,V> > result; 00279 typedef std::vector<const DDsvalues_type *> sv_type; 00280 typename std::map<V,K>::const_iterator it = valueToKey_.begin(); 00281 typename std::map<V,K>::const_iterator ed = valueToKey_.end(); 00282 00283 // loop over all registered ValueTypes 00284 for (; it != ed; ++it) { 00285 sv_type sv = it->first.specifics(); 00286 //std::cout << "now at: " << it->first.name() << std::endl; 00287 sv_type::const_iterator svIt = sv.begin(); 00288 sv_type::const_iterator svEd = sv.end(); 00289 DDValue v(name); 00290 for (; svIt != svEd; ++svIt) { 00291 if (DDfetch(*svIt,v)) { 00292 result.push_back(std::make_pair(it->second,it->first)); 00293 break; 00294 } 00295 } 00296 } 00297 return result; 00298 }
std::vector< std::pair< K, V > > DDMapper< K, V >::all | ( | const std::string & | name, | |
const double & | value | |||
) | const [inline] |
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(), it, HLT_VtxMuL3::result, s, sv, v, and DDMapper< KeyType, ValueType >::valueToKey_.
00243 { 00244 std::vector<std::pair<K,V> > result; 00245 typedef std::vector<const DDsvalues_type *> sv_type; 00246 typename std::map<V,K>::const_iterator it = valueToKey_.begin(); 00247 typename std::map<V,K>::const_iterator ed = valueToKey_.end(); 00248 00249 // loop over all registered ValueTypes 00250 for (; it != ed; ++it) { 00251 sv_type sv = it->first.specifics(); 00252 //std::cout << "now at: " << it->first.name() << std::endl; 00253 sv_type::const_iterator svIt = sv.begin(); 00254 sv_type::const_iterator svEd = sv.end(); 00255 DDValue v(name); 00256 for (; svIt != svEd; ++svIt) { 00257 if (DDfetch(*svIt,v)) { 00258 //std::cout << "found: "; 00259 const std::vector<double> & s = v.doubles(); 00260 if (s.size()) { 00261 //std::cout << s[0]; 00262 if (s[0]==value) { 00263 result.push_back(std::make_pair(it->second,it->first)); 00264 break; 00265 } 00266 } 00267 //std::cout << std::endl; 00268 } 00269 } 00270 } 00271 return result; 00272 }
std::vector< std::pair< K, V > > DDMapper< K, V >::all | ( | const std::string & | name, | |
const std::string & | value | |||
) | const [inline] |
get all std::mapped instances which have a specific 'name' with value 'value'
Definition at line 208 of file DDMapper.h.
References DDfetch(), it, HLT_VtxMuL3::result, s, DDValue::strings(), sv, v, and DDMapper< KeyType, ValueType >::valueToKey_.
Referenced by DDG4ProductionCuts::initialize().
00209 { 00210 std::vector<std::pair<K,V> > result; 00211 typedef std::vector<const DDsvalues_type *> sv_type; 00212 typename std::map<V,K>::const_iterator it = valueToKey_.begin(); 00213 typename std::map<V,K>::const_iterator ed = valueToKey_.end(); 00214 00215 // loop over all registered ValueTypes 00216 for (; it != ed; ++it) { 00217 sv_type sv = it->first.specifics(); 00218 //std::cout << "now at: " << it->first.name() << std::endl; 00219 sv_type::const_iterator svIt = sv.begin(); 00220 sv_type::const_iterator svEd = sv.end(); 00221 DDValue v(name); 00222 for (; svIt != svEd; ++svIt) { 00223 if (DDfetch(*svIt,v)) { 00224 //std::cout << "found: "; 00225 const std::vector<std::string> & s = v.strings(); 00226 if (s.size()) { 00227 //std::cout << s[0]; 00228 if (s[0]==value) { 00229 result.push_back(std::make_pair(it->second,it->first)); 00230 break; 00231 } 00232 } 00233 //std::cout << std::endl; 00234 } 00235 } 00236 } 00237 return result; 00238 }
void DDMapper< K, V >::insert | ( | const K & | key, | |
const V & | value | |||
) | [inline] |
insert a new key-value-pair
any existing entry will be overridden
Definition at line 77 of file DDMapper.h.
References DDMapper< KeyType, ValueType >::keyToValue_, and DDMapper< KeyType, ValueType >::valueToKey_.
Referenced by DDG4Builder::BuildGeometry(), and DDG4Builder::convertLV().
00078 { 00079 keyToValue_[key] = value; 00080 valueToKey_.insert(std::make_pair(value,key)); 00081 // valueToKey_[value] = key; 00082 }
unsigned int DDMapper< K, V >::noSpecifics | ( | const K & | key, | |
const std::string & | name | |||
) | const [inline] |
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(), it, DDMapper< KeyType, ValueType >::keyToValue_, HLT_VtxMuL3::result, DDValue::size(), sv, and v.
00099 { 00100 typedef std::vector<const DDsvalues_type *> sv_type; 00101 unsigned int result = 0; 00102 typename std::map<K,V>::const_iterator it = keyToValue_.find(key); 00103 if (it != keyToValue_.end()) { 00104 sv_type sv = it->second.specifics(); 00105 sv_type::const_iterator it = sv.begin(); 00106 DDValue v(name); 00107 for (; it != sv.end(); ++it) { 00108 if (DDfetch(*it, v)) { 00109 result += v.size(); 00110 } 00111 } 00112 } 00113 return result; 00114 }
unsigned int DDMapper< K, V >::toDouble | ( | const std::string & | name, | |
const V & | key, | |||
double & | value, | |||
unsigned int | pos = 0 | |||
) | const [inline] |
Definition at line 142 of file DDMapper.h.
References DDfetch(), DDValue::doubles(), HLT_VtxMuL3::result, DDValue::size(), sv, and v.
00143 { 00144 typedef std::vector<const DDsvalues_type *> sv_type; 00145 unsigned int result=0; 00146 sv_type sv = val.specifics(); 00147 sv_type::const_iterator svIt = sv.begin(); 00148 sv_type::const_iterator svEd = sv.end(); 00149 DDValue v(name); 00150 for (; svIt != svEd; ++svIt) { 00151 if (DDfetch(*svIt,v)) { 00152 result = v.size(); 00153 value = v.doubles()[pos]; 00154 break; 00155 } 00156 } 00157 return result; 00158 }
unsigned int DDMapper< K, V >::toDouble | ( | const std::string & | name, | |
const K & | key, | |||
double & | value, | |||
unsigned int | pos = 0 | |||
) | const [inline] |
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
Definition at line 119 of file DDMapper.h.
References DDfetch(), DDValue::doubles(), it, DDMapper< KeyType, ValueType >::keyToValue_, HLT_VtxMuL3::result, DDValue::size(), sv, and v.
Referenced by DDG4ProductionCuts::setProdCuts().
00120 { 00121 typedef std::vector<const DDsvalues_type *> sv_type; 00122 unsigned int result=0; 00123 typename std::map<K,V>::const_iterator it = keyToValue_.find(key); 00124 if (it != keyToValue_.end()) { 00125 sv_type sv = it->second.specifics(); 00126 sv_type::const_iterator svIt = sv.begin(); 00127 sv_type::const_iterator svEd = sv.end(); 00128 DDValue v(name); 00129 for (; svIt != svEd; ++svIt) { 00130 if (DDfetch(*svIt,v)) { 00131 result = v.size(); 00132 value = v.doubles()[pos]; 00133 break; 00134 } 00135 } 00136 } 00137 return result; 00138 }
unsigned int DDMapper< K, V >::toString | ( | const std::string & | name, | |
const V & | key, | |||
std::string & | value, | |||
unsigned int | pos = 0 | |||
) | const [inline] |
same as toDouble but for std::string-valued values of named parameters
Definition at line 162 of file DDMapper.h.
References DDfetch(), HLT_VtxMuL3::result, DDValue::size(), DDValue::strings(), sv, and v.
00163 { 00164 typedef std::vector<const DDsvalues_type *> sv_type; 00165 unsigned int result=0; 00166 sv_type sv = val.specifics(); 00167 sv_type::const_iterator svIt = sv.begin(); 00168 sv_type::const_iterator svEd = sv.end(); 00169 DDValue v(name); 00170 for (; svIt != svEd; ++svIt) { 00171 if (DDfetch(*svIt,v)) { 00172 result = v.size(); 00173 value = v.strings()[pos]; 00174 break; 00175 } 00176 } 00177 return result; 00178 }
unsigned int DDMapper< K, V >::toString | ( | const std::string & | name, | |
const K & | key, | |||
std::string & | value, | |||
unsigned int | pos = 0 | |||
) | const [inline] |
same as toDouble but for std::string-valued values of named parameters
Definition at line 182 of file DDMapper.h.
References DDfetch(), it, DDMapper< KeyType, ValueType >::keyToValue_, HLT_VtxMuL3::result, DDValue::size(), DDValue::strings(), sv, and v.
Referenced by DDG4ProductionCuts::initialize(), and DDG4ProductionCuts::setProdCuts().
00183 { 00184 typedef std::vector<const DDsvalues_type *> sv_type; 00185 unsigned int result=0; 00186 typename std::map<K,V>::const_iterator it = keyToValue_.find(key); 00187 if (it != keyToValue_.end()) { 00188 sv_type sv = it->second.specifics(); 00189 sv_type::const_iterator svIt = sv.begin(); 00190 sv_type::const_iterator svEd = sv.end(); 00191 DDValue v(name); 00192 //std::cout << "DDValue=" << name << std::endl; 00193 for (; svIt != svEd; ++svIt) { 00194 //std::cout << "looping..." << **svIt << std::endl; 00195 if (DDfetch(*svIt,v)) { 00196 result = v.size(); 00197 //std::cout << "found!" << std::endl; 00198 value = v.strings()[pos]; 00199 break; 00200 } 00201 } 00202 } 00203 return result; 00204 }
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 it, DDMapper< KeyType, ValueType >::keyToValue_, and HLT_VtxMuL3::result.
00087 { 00088 bool result = false; 00089 typename std::map<K,V>::const_iterator it = keyToValue_.find(key); 00090 if (it != keyToValue_.end()) { 00091 value = it->second; 00092 result = true; 00093 } 00094 return result; 00095 }
std::map<KeyType, ValueType> DDMapper< KeyType, ValueType >::keyToValue_ [private] |
Definition at line 71 of file DDMapper.h.
Referenced by DDMapper< KeyType, ValueType >::insert(), DDMapper< KeyType, ValueType >::noSpecifics(), DDMapper< KeyType, ValueType >::toDouble(), DDMapper< KeyType, ValueType >::toString(), and DDMapper< KeyType, ValueType >::value().
std::multimap<ValueType, KeyType> DDMapper< KeyType, ValueType >::valueToKey_ [private] |
Definition at line 72 of file DDMapper.h.
Referenced by DDMapper< KeyType, ValueType >::all(), and DDMapper< KeyType, ValueType >::insert().