#include <DetectorDescription/Core/interface/DDValue.h>
Public Member Functions | |
DDValue (unsigned int) | |
DDValue (const std::string &name, const std::string &val) | |
creates a single std::string-valued named DDValue | |
DDValue (const std::string &, const std::string &, double) | |
creates a single std::string & numerical-valued named DDValue. | |
DDValue (const std::string &, double) | |
creates a single double valued named DDValue. The corresponding std::string-value is an empty std::string | |
DDValue (const std::string &, const std::vector< DDValuePair > &) | |
creates a named DDValue initialized with a std::vector of values | |
DDValue (const std::string &) | |
create a named empty value | |
DDValue () | |
create a unnamed emtpy value. One can assing a named DDValue to it. | |
const std::vector< double > & | doubles () const |
a reference to the double-valued values stored in the given instance of DDValue | |
unsigned int | id () const |
returns the ID of the DDValue | |
bool | isEvaluated () const |
true, if values are numerical evaluated; else false. | |
const std::string & | name () const |
the name of the DDValue | |
operator unsigned int () const | |
converts a DDValue object into its ID | |
bool | operator< (const DDValue &) const |
A DDValue a is smaller than a DDValue b if (a.id()<b.id()) OR (a.id()==b.id() and value(a)<value(b)). | |
bool | operator== (const DDValue &) const |
Two DDValues are equal only if their id() is equal AND their values are equal. | |
DDValuePair | operator[] (unsigned int i) const |
access to the values stored in DDValue by an index. | |
void | setEvalState (bool newState) |
set to true, if the double-values (method DDValue::doubles()) make sense | |
unsigned int | size () const |
the size of the stored value-pairs (std::string,double) | |
const std::vector< std::string > & | strings () const |
a reference to the std::string-valued values stored in the given instance of DDValue | |
~DDValue () | |
Static Public Member Functions | |
static void | clear () |
Public Attributes | |
vecpair_type * | vecPair_ |
Private Types | |
typedef std::pair< bool, std::pair< std::vector < std::string >, std::vector < double > > > | vecpair_type |
Static Private Member Functions | |
static std::map< std::string, unsigned int > & | indexer () |
static std::vector < boost::shared_ptr < vecpair_type > > & | mem (vecpair_type *) |
static std::vector< std::string > & | names () |
Private Attributes | |
unsigned int | id_ |
Friends | |
class | DDLSpecPar |
class | DDSpecifics |
Names of DDValues are stored transiently. Furthermore, an ID is assigned std::mapping to the name. If a particular DDValue is not used anymore, use DDValue::clear() to free the internally allocated memory. Use DDValue::setEvalState(true) to indicate whether the double numbers stored in the DDValuePair make sense, otherwise an exception will be thrown when trying to get access to these values via DDValue::doubles() or DDValue::operator[].
Definition at line 26 of file DDValue.h.
typedef std::pair<bool, std::pair<std::vector<std::string>, std::vector<double> > > DDValue::vecpair_type [private] |
DDValue::DDValue | ( | ) | [inline] |
DDValue::DDValue | ( | const std::string & | name | ) |
create a named empty value
Definition at line 13 of file DDValue.cc.
References id_, indexer(), names(), HLT_VtxMuL3::result, and pyDBSRunClass::temp.
00014 : id_(0) 00015 { 00016 unsigned int temp = indexer().size()+1; 00017 typedef std::map<std::string,unsigned int>::iterator itT; 00018 std::pair<itT,bool> result = indexer().insert(std::make_pair(name,temp)); 00019 00020 if (result.second) { 00021 id_ = temp; 00022 names().push_back(name); 00023 } 00024 else { 00025 id_ = result.first->second; 00026 } 00027 }
DDValue::DDValue | ( | const std::string & | name, | |
const std::vector< DDValuePair > & | v | |||
) | [explicit] |
creates a named DDValue initialized with a std::vector of values
Definition at line 29 of file DDValue.cc.
References id_, indexer(), it, mem(), names(), HLT_VtxMuL3::result, pyDBSRunClass::temp, and vecPair_.
00030 : id_(0) 00031 { 00032 unsigned int temp = indexer().size()+1; 00033 typedef std::map<std::string,unsigned int>::iterator itT; 00034 std::pair<itT,bool> result = indexer().insert(std::make_pair(name,temp)); 00035 00036 if (result.second) { 00037 id_ = temp; 00038 names().push_back(name); 00039 } 00040 else { 00041 id_ = result.first->second; 00042 } 00043 00044 std::vector<DDValuePair>::const_iterator it = v.begin(); 00045 std::vector<std::string> svec; 00046 std::vector<double> dvec; 00047 vecPair_ = new vecpair_type(false,std::make_pair(svec,dvec)); 00048 mem(vecPair_); 00049 for (; it != v.end(); ++it) { 00050 vecPair_->second.first.push_back(it->first); 00051 vecPair_->second.second.push_back(it->second); 00052 } 00053 00054 //valPairs_ = new std::vector<DDValuePair>(v); 00055 }
DDValue::DDValue | ( | const std::string & | name, | |
double | val | |||
) | [explicit] |
creates a single double valued named DDValue. The corresponding std::string-value is an empty std::string
Definition at line 58 of file DDValue.cc.
References id_, indexer(), mem(), names(), HLT_VtxMuL3::result, setEvalState(), pyDBSRunClass::temp, and vecPair_.
00059 : id_(0) 00060 { 00061 unsigned int temp = indexer().size()+1; 00062 typedef std::map<std::string,unsigned int>::iterator itT; 00063 std::pair<itT,bool> result = indexer().insert(std::make_pair(name,temp)); 00064 00065 if (result.second) { 00066 id_ = temp; 00067 names().push_back(name); 00068 } 00069 else { 00070 id_ = result.first->second; 00071 } 00072 std::vector<std::string> svec(1,""); 00073 std::vector<double> dvec(1,val); 00074 00075 vecPair_ = new vecpair_type(false,std::make_pair(svec,dvec)); 00076 setEvalState(true); 00077 mem(vecPair_); 00078 00079 //DDValuePair vp(val); 00080 //valPairs_ = new std::vector<DDValuePair>(1,vp); 00081 }
DDValue::DDValue | ( | const std::string & | name, | |
const std::string & | sval, | |||
double | dval | |||
) | [explicit] |
creates a single std::string & numerical-valued named DDValue.
Definition at line 84 of file DDValue.cc.
References id_, indexer(), mem(), names(), HLT_VtxMuL3::result, setEvalState(), pyDBSRunClass::temp, and vecPair_.
00085 : id_(0) 00086 { 00087 unsigned int temp = indexer().size()+1; 00088 typedef std::map<std::string,unsigned int>::iterator itT; 00089 std::pair<itT,bool> result = indexer().insert(std::make_pair(name,temp)); 00090 00091 if (result.second) { 00092 id_ = temp; 00093 names().push_back(name); 00094 } 00095 else { 00096 id_ = result.first->second; 00097 } 00098 00099 std::vector<std::string> svec(1,sval); 00100 std::vector<double> dvec(1,dval); 00101 vecPair_ = new vecpair_type(false,std::make_pair(svec,dvec)); 00102 setEvalState(true); 00103 mem(vecPair_); 00104 //DDValuePair vp(sval,dval); 00105 //valPairs_ = new std::vector<DDValuePair>(1,vp); 00106 }
DDValue::DDValue | ( | const std::string & | name, | |
const std::string & | val | |||
) | [explicit] |
creates a single std::string-valued named DDValue
Definition at line 109 of file DDValue.cc.
References id_, indexer(), mem(), names(), HLT_VtxMuL3::result, setEvalState(), pyDBSRunClass::temp, and vecPair_.
00110 : id_(0) 00111 { 00112 unsigned int temp = indexer().size()+1; 00113 typedef std::map<std::string,unsigned int>::iterator itT; 00114 std::pair<itT,bool> result = indexer().insert(std::make_pair(name,temp)); 00115 00116 if (result.second) { 00117 id_ = temp; 00118 names().push_back(name); 00119 } 00120 else { 00121 id_ = result.first->second; 00122 } 00123 00124 std::vector<std::string> svec(1,sval); 00125 std::vector<double> dvec(1,0); 00126 vecPair_ = new vecpair_type(false,std::make_pair(svec,dvec)); 00127 setEvalState(false); 00128 mem(vecPair_); 00129 //DDValuePair vp(sval,dval); 00130 //valPairs_ = new std::vector<DDValuePair>(1,vp); 00131 }
DDValue::DDValue | ( | unsigned int | i | ) | [explicit] |
DDValue::~DDValue | ( | ) |
Definition at line 142 of file DDValue.cc.
00143 { 00144 //DCOUT('C' , "Deleting DDValue.name()=" << name() ); 00145 // delete vecPair_; 00146 }
Definition at line 149 of file DDValue.cc.
Referenced by DDCompactView::clear().
00150 { 00151 std::vector<boost::shared_ptr<vecpair_type> > & v = mem(0); 00152 //NOT sure about removing this... I think it is ok because of shared_ptr... 00153 // std::vector<boost::shared_ptr<vecpair_type> >::iterator it = v.begin(); 00154 // for (; it != v.end(); ++ it) { 00155 // delete *it; 00156 // } 00157 v.clear(); 00158 //delete vecPair_; 00159 //vecPair_=0; 00160 }
const std::vector< double > & DDValue::doubles | ( | ) | const |
a reference to the double-valued values stored in the given instance of DDValue
Definition at line 180 of file DDValue.cc.
References lat::endl(), id_, names(), and vecPair_.
Referenced by DDMapper< KeyType, ValueType >::all(), RPCGeometryBuilderFromDDD::buildGeometry(), MaterialBudgetHcalHistos::getDDDArray(), HFShowerLibrary::getDDDArray(), HCalSD::getDDDArray(), HFFibre::getDDDArray(), HFShowerPMT::getDDDArray(), HcalNumberingFromDDD::getDDDArray(), HFShowerParam::getDDDArray(), DDG4Builder::getInt(), MuonDDDNumbering::getInt(), CaloTrkProcessing::getNumbers(), CocoaAnalyzer::myFetchDbl(), sfd_compare(), sfd_compare_nm(), DDMapper< KeyType, ValueType >::toDouble(), and MagGeoBuilderFromDDD::volumeHandle::volumeHandle().
00181 { 00182 if (vecPair_->first) { 00183 return vecPair_->second.second; 00184 } 00185 else { 00186 std::string message = "DDValue " + names()[id_] + " is not numerically evaluated! Use DDValue::std::strings()!"; 00187 edm::LogError("DDValue") << message << std::endl; 00188 throw DDException(message); 00189 } 00190 }
returns the ID of the DDValue
Definition at line 58 of file DDValue.h.
References id_.
Referenced by DDI::LogicalPart::hasDDValue(), operator<(), operator==(), sfd_compare(), sfd_compare_nm(), sfs_compare(), and sfs_compare_nm().
00058 { return id_; }
std::map< std::string, unsigned int > & DDValue::indexer | ( | ) | [static, private] |
bool DDValue::isEvaluated | ( | ) | const |
true, if values are numerical evaluated; else false.
in case of a 'true' return value, the method DDValue::doubles() and the operator DDValue::operator[] can be used
Definition at line 230 of file DDValue.cc.
References vecPair_.
Referenced by operator<<(), DDDToPersFactory::specpar(), DDStreamer::specs_write(), and DDI::Specific::stream().
00231 { 00232 return vecPair_->first; 00233 }
std::vector< boost::shared_ptr< DDValue::vecpair_type > > & DDValue::mem | ( | DDValue::vecpair_type * | vp | ) | [static, private] |
Definition at line 173 of file DDValue.cc.
Referenced by clear(), and DDValue().
00174 { 00175 static std::vector<boost::shared_ptr<vecpair_type> > memory_; 00176 memory_.push_back( boost::shared_ptr<vecpair_type>(vp) ); 00177 return memory_; 00178 }
const std::string& DDValue::name | ( | ) | const [inline] |
the name of the DDValue
Definition at line 64 of file DDValue.h.
Referenced by operator<<(), sfd_compare(), sfd_compare_nm(), DDDToPersFactory::specpar(), DDStreamer::specs_write(), and DDI::Specific::stream().
std::vector< std::string > & DDValue::names | ( | ) | [static, private] |
Definition at line 168 of file DDValue.cc.
Referenced by DDValue(), doubles(), name(), and operator[]().
DDValue::operator unsigned int | ( | ) | const [inline] |
A DDValue a is smaller than a DDValue b if (a.id()<b.id()) OR (a.id()==b.id() and value(a)<value(b)).
Definition at line 253 of file DDValue.cc.
References id(), HLT_VtxMuL3::result, and vecPair_.
00254 { 00255 bool result(false); 00256 if (id()<v.id()) { 00257 result = true; 00258 } 00259 else { 00260 if (id()==v.id()) { 00261 assert(vecPair_); 00262 assert(v.vecPair_); 00263 if (vecPair_->first) { // numerical values 00264 result = (vecPair_->second.second < v.vecPair_->second.second); 00265 } 00266 else { // std::string values 00267 result = (vecPair_->second.first < v.vecPair_->second.first); 00268 } 00269 } 00270 } 00271 return result; 00272 }
Two DDValues are equal only if their id() is equal AND their values are equal.
If the DDValue::isEvalued() == true, the numerical representation is taken for comparison, else the std::string representation
Definition at line 236 of file DDValue.cc.
References id(), HLT_VtxMuL3::result, and vecPair_.
00237 { 00238 bool result(false); 00239 if (id()==v.id()) { 00240 assert(vecPair_); 00241 assert(v.vecPair_); 00242 if (vecPair_->first) { // numerical values 00243 result = (vecPair_->second.second == v.vecPair_->second.second); 00244 } 00245 else { // std::string values 00246 result = (vecPair_->second.first == v.vecPair_->second.first); 00247 } 00248 } 00249 return result; 00250 }
DDValuePair DDValue::operator[] | ( | unsigned int | i | ) | const |
access to the values stored in DDValue by an index.
Note, that the index is not checked for bounds excess!
Definition at line 211 of file DDValue.cc.
References id_, names(), and vecPair_.
00212 { 00213 if (vecPair_->first) { 00214 return DDValuePair(vecPair_->second.first[i], vecPair_->second.second[i]); 00215 } 00216 else { 00217 std::string message = "DDValue " + names()[id_] + " is not numerically evaluated! Use DDValue::std::strings()!"; 00218 edm::LogError("DDValue") << message; 00219 throw DDException(message); 00220 } 00221 }
set to true, if the double-values (method DDValue::doubles()) make sense
Definition at line 224 of file DDValue.cc.
References vecPair_.
Referenced by DDValue(), DDLSpecPar::processElement(), DDPersToDDDFactory::specPar(), and DDStreamer::specs_read().
00225 { 00226 vecPair_->first = newState; 00227 }
the size of the stored value-pairs (std::string,double)
Definition at line 78 of file DDValue.h.
References vecPair_.
Referenced by DDValue(), DDMapper< KeyType, ValueType >::noSpecifics(), operator<<(), DDDToPersFactory::specpar(), DDStreamer::specs_write(), DDI::Specific::stream(), DDMapper< KeyType, ValueType >::toDouble(), and DDMapper< KeyType, ValueType >::toString().
const std::vector<std::string>& DDValue::strings | ( | ) | const [inline] |
a reference to the std::string-valued values stored in the given instance of DDValue
Definition at line 71 of file DDValue.h.
References vecPair_.
Referenced by DDMapper< KeyType, ValueType >::all(), DTGeometryBuilderFromDDD::buildGeometry(), dddGetStringRaw(), DDG4Builder::getDouble(), getDouble(), CaloTrkProcessing::getNames(), getString(), DDG4SensitiveConverter::getString(), ExtractStringFromDDD::getString(), CocoaAnalyzer::myFetchString(), operator<<(), sfs_compare(), sfs_compare_nm(), DDDToPersFactory::specpar(), DDStreamer::specs_write(), DDI::Specific::stream(), DDMapper< KeyType, ValueType >::toString(), and MagGeoBuilderFromDDD::volumeHandle::volumeHandle().
00071 { return vecPair_->second.first; }
friend class DDLSpecPar [friend] |
friend class DDSpecifics [friend] |
unsigned int DDValue::id_ [private] |
Definition at line 110 of file DDValue.h.
Referenced by DDValue(), doubles(), id(), name(), operator unsigned int(), and operator[]().
Definition at line 114 of file DDValue.h.
Referenced by DDValue(), doubles(), isEvaluated(), operator<(), operator==(), operator[](), setEvalState(), size(), and strings().