CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Public Attributes | Private Types | Static Private Member Functions | Private Attributes | Friends
DDValue Class Reference

#include <DDValue.h>

Public Member Functions

 DDValue (void)
 create a unnamed emtpy value. One can assing a named DDValue to it. More...
 
 DDValue (const std::string &)
 create a named empty value More...
 
 DDValue (const char *)
 create a named empty value More...
 
 DDValue (const std::string &, const std::vector< DDValuePair > &)
 creates a named DDValue initialized with a std::vector of values More...
 
 DDValue (const std::string &, double)
 creates a single double valued named DDValue. The corresponding std::string-value is an empty std::string More...
 
 DDValue (const std::string &, const std::string &, double)
 
 DDValue (const std::string &name, const std::string &val)
 
 DDValue (unsigned int)
 
const std::vector< double > & doubles () const
 a reference to the double-valued values stored in the given instance of DDValue More...
 
unsigned int id (void) const
 returns the ID of the DDValue More...
 
void init (const std::string &)
 
bool isEvaluated (void) const
 true, if values are numerical evaluated; else false. More...
 
const std::string & name (void) const
 the name of the DDValue More...
 
 operator unsigned int (void) const
 converts a DDValue object into its ID More...
 
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)) More...
 
bool operator== (const DDValue &v) const
 Two DDValues are equal only if their id() is equal AND their values are equal. More...
 
DDValuePair operator[] (unsigned int i) const
 
void setEvalState (bool newState)
 set to true, if the double-values (method DDValue::doubles()) make sense More...
 
unsigned int size () const
 the size of the stored value-pairs (std::string,double) More...
 
const std::vector< std::string > & strings () const
 a reference to the std::string-valued values stored in the given instance of DDValue More...
 
 ~DDValue (void)
 

Static Public Member Functions

static void clear (void)
 

Public Attributes

vecpair_typevecPair_
 

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
 

Detailed Description

A DDValue std::maps a std::vector of DDValuePair (std::string,double) to a name. 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 25 of file DDValue.h.

Member Typedef Documentation

typedef std::pair<bool, std::pair<std::vector<std::string>, std::vector<double> > > DDValue::vecpair_type
private

Definition at line 101 of file DDValue.h.

Constructor & Destructor Documentation

DDValue::DDValue ( void  )
inline

create a unnamed emtpy value. One can assing a named DDValue to it.

Definition at line 31 of file DDValue.h.

31 : id_(0), vecPair_(0) { }
unsigned int id_
Definition: DDValue.h:106
vecpair_type * vecPair_
Definition: DDValue.h:109
DDValue::DDValue ( const std::string &  name)

create a named empty value

Definition at line 24 of file DDValue.cc.

References init().

25  : id_( 0 ),
26  vecPair_( 0 )
27 {
28  init( name );
29 }
const std::string & name(void) const
the name of the DDValue
Definition: DDValue.h:64
unsigned int id_
Definition: DDValue.h:106
void init(const std::string &)
Definition: DDValue.cc:7
vecpair_type * vecPair_
Definition: DDValue.h:109
DDValue::DDValue ( const char *  name)

create a named empty value

Definition at line 31 of file DDValue.cc.

References init().

32  : id_( 0 ),
33  vecPair_( 0 )
34 {
35  init( name );
36 }
const std::string & name(void) const
the name of the DDValue
Definition: DDValue.h:64
unsigned int id_
Definition: DDValue.h:106
void init(const std::string &)
Definition: DDValue.cc:7
vecpair_type * vecPair_
Definition: DDValue.h:109
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 38 of file DDValue.cc.

References init(), mem(), and vecPair_.

39  : id_( 0 )
40 {
41  init( name );
42 
43  std::vector<DDValuePair>::const_iterator it = v.begin();
44  std::vector<std::string> svec;
45  std::vector<double> dvec;
46  vecPair_ = new vecpair_type( false, std::make_pair( svec, dvec ));
47  mem( vecPair_ );
48  for(; it != v.end(); ++it )
49  {
50  vecPair_->second.first.push_back( it->first );
51  vecPair_->second.second.push_back( it->second );
52  }
53 }
const std::string & name(void) const
the name of the DDValue
Definition: DDValue.h:64
static std::vector< boost::shared_ptr< vecpair_type > > & mem(vecpair_type *)
Definition: DDValue.cc:126
std::pair< bool, std::pair< std::vector< std::string >, std::vector< double > > > vecpair_type
Definition: DDValue.h:101
unsigned int id_
Definition: DDValue.h:106
void init(const std::string &)
Definition: DDValue.cc:7
mathSSE::Vec4< T > v
vecpair_type * vecPair_
Definition: DDValue.h:109
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 56 of file DDValue.cc.

References init(), mem(), setEvalState(), and vecPair_.

57  : id_( 0 )
58 {
59  init( name );
60 
61  std::vector<std::string> svec( 1, "" );
62  std::vector<double> dvec( 1, val );
63 
64  vecPair_ = new vecpair_type( false, std::make_pair( svec, dvec ));
65  setEvalState( true );
66  mem( vecPair_ );
67 }
const std::string & name(void) const
the name of the DDValue
Definition: DDValue.h:64
static std::vector< boost::shared_ptr< vecpair_type > > & mem(vecpair_type *)
Definition: DDValue.cc:126
std::pair< bool, std::pair< std::vector< std::string >, std::vector< double > > > vecpair_type
Definition: DDValue.h:101
void setEvalState(bool newState)
set to true, if the double-values (method DDValue::doubles()) make sense
Definition: DDValue.cc:192
unsigned int id_
Definition: DDValue.h:106
void init(const std::string &)
Definition: DDValue.cc:7
vecpair_type * vecPair_
Definition: DDValue.h:109
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 69 of file DDValue.cc.

References init(), mem(), setEvalState(), and vecPair_.

70  : id_( 0 )
71 {
72  init( name );
73 
74  std::vector<std::string> svec( 1, sval );
75  std::vector<double> dvec( 1, dval );
76  vecPair_ = new vecpair_type( false, std::make_pair( svec, dvec ));
77  setEvalState( true );
78  mem( vecPair_ );
79 }
const std::string & name(void) const
the name of the DDValue
Definition: DDValue.h:64
static std::vector< boost::shared_ptr< vecpair_type > > & mem(vecpair_type *)
Definition: DDValue.cc:126
std::pair< bool, std::pair< std::vector< std::string >, std::vector< double > > > vecpair_type
Definition: DDValue.h:101
void setEvalState(bool newState)
set to true, if the double-values (method DDValue::doubles()) make sense
Definition: DDValue.cc:192
unsigned int id_
Definition: DDValue.h:106
void init(const std::string &)
Definition: DDValue.cc:7
vecpair_type * vecPair_
Definition: DDValue.h:109
DDValue::DDValue ( const std::string &  name,
const std::string &  val 
)
explicit

creates a single std::string-valued named DDValue

Definition at line 81 of file DDValue.cc.

References init(), mem(), setEvalState(), and vecPair_.

82  : id_( 0 )
83 {
84  init( name );
85 
86  std::vector<std::string> svec( 1, sval );
87  std::vector<double> dvec( 1, 0 );
88  vecPair_ = new vecpair_type( false, std::make_pair( svec, dvec ));
89  setEvalState( false );
90  mem( vecPair_ );
91 }
const std::string & name(void) const
the name of the DDValue
Definition: DDValue.h:64
static std::vector< boost::shared_ptr< vecpair_type > > & mem(vecpair_type *)
Definition: DDValue.cc:126
std::pair< bool, std::pair< std::vector< std::string >, std::vector< double > > > vecpair_type
Definition: DDValue.h:101
void setEvalState(bool newState)
set to true, if the double-values (method DDValue::doubles()) make sense
Definition: DDValue.cc:192
unsigned int id_
Definition: DDValue.h:106
void init(const std::string &)
Definition: DDValue.cc:7
vecpair_type * vecPair_
Definition: DDValue.h:109
DDValue::DDValue ( unsigned int  i)
explicit

Definition at line 93 of file DDValue.cc.

References i, id_, names(), and size().

94  : id_( 0 ),
95  vecPair_( 0 )
96 {
97  if( names().size() - 1 <= i )
98  id_ = i;
99 }
static std::vector< std::string > & names()
Definition: DDValue.cc:119
int i
Definition: DBlmapReader.cc:9
unsigned int id_
Definition: DDValue.h:106
unsigned int size() const
the size of the stored value-pairs (std::string,double)
Definition: DDValue.h:78
vecpair_type * vecPair_
Definition: DDValue.h:109
DDValue::~DDValue ( void  )

Definition at line 101 of file DDValue.cc.

102 {}

Member Function Documentation

void DDValue::clear ( void  )
static
const std::vector< double > & DDValue::doubles ( void  ) const

a reference to the double-valued values stored in the given instance of DDValue

Definition at line 134 of file DDValue.cc.

References edm::hlt::Exception, id_, python.rootplot.argparse::message, names(), and vecPair_.

Referenced by DDMapper< KeyType, ValueType >::all(), RPCGeometryBuilderFromDDD::buildGeometry(), RPCGeometryParsFromDD::buildGeometry(), HFShowerPMT::getDDDArray(), HFShowerFibreBundle::getDDDArray(), HFFibre::getDDDArray(), MaterialBudgetHcalHistos::getDDDArray(), ECalSD::getDDDArray(), HFShower::getDDDArray(), HFShowerParam::getDDDArray(), HCalSD::getDDDArray(), HcalNumberingFromDDD::getDDDArray(), HFShowerLibrary::getDDDArray(), MuonDDDNumbering::getInt(), DDG4Builder::getInt(), CaloTrkProcessing::getNumbers(), CocoaAnalyzer::myFetchDbl(), DDMapper< KeyType, ValueType >::toDouble(), and MagGeoBuilderFromDDD::volumeHandle::volumeHandle().

135 {
136  if( vecPair_->first )
137  {
138  return vecPair_->second.second;
139  }
140  else
141  {
142  std::string message = "DDValue " + names()[id_] + " is not numerically evaluated! Use DDValue::std::strings()!";
143  edm::LogError("DDValue") << message << std::endl;
144  throw cms::Exception("DDException") << message;
145  }
146 }
static std::vector< std::string > & names()
Definition: DDValue.cc:119
unsigned int id_
Definition: DDValue.h:106
vecpair_type * vecPair_
Definition: DDValue.h:109
unsigned int DDValue::id ( void  ) const
inline

returns the ID of the DDValue

Definition at line 58 of file DDValue.h.

References id_.

Referenced by DDI::LogicalPart::hasDDValue(), operator<(), and operator==().

58 { return id_; }
unsigned int id_
Definition: DDValue.h:106
std::map< std::string, unsigned int > & DDValue::indexer ( void  )
staticprivate

Definition at line 112 of file DDValue.cc.

Referenced by init().

113 {
114  static std::map<std::string,unsigned int> indexer_;
115  return indexer_;
116 }
void DDValue::init ( const std::string &  name)

Definition at line 7 of file DDValue.cc.

References id_, indexer(), names(), query::result, and groupFilesInBlocks::temp.

Referenced by DDValue().

8 {
9  unsigned int temp = indexer().size()+1;
10  typedef std::map<std::string,unsigned int>::iterator itT;
11  std::pair<itT,bool> result = indexer().insert( std::make_pair( name, temp ));
12 
13  if( result.second )
14  {
15  id_ = temp;
16  names().push_back( name );
17  }
18  else
19  {
20  id_ = result.first->second;
21  }
22 }
const std::string & name(void) const
the name of the DDValue
Definition: DDValue.h:64
static std::vector< std::string > & names()
Definition: DDValue.cc:119
static std::map< std::string, unsigned int > & indexer()
Definition: DDValue.cc:112
unsigned int id_
Definition: DDValue.h:106
tuple result
Definition: query.py:137
bool DDValue::isEvaluated ( void  ) 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 198 of file DDValue.cc.

References vecPair_.

Referenced by operator<<(), DDCoreToDDXMLOutput::specpar(), DDStreamer::specs_write(), and DDI::Specific::stream().

199 {
200  return vecPair_->first;
201 }
vecpair_type * vecPair_
Definition: DDValue.h:109
std::vector< boost::shared_ptr< DDValue::vecpair_type > > & DDValue::mem ( DDValue::vecpair_type vp)
staticprivate

Definition at line 126 of file DDValue.cc.

Referenced by clear(), and DDValue().

127 {
128  static std::vector<boost::shared_ptr<vecpair_type> > memory_;
129  memory_.push_back( boost::shared_ptr<vecpair_type>( vp ));
130  return memory_;
131 }
const std::string& DDValue::name ( void  ) const
inline

the name of the DDValue

Definition at line 64 of file DDValue.h.

References id_, and names().

Referenced by DDI::LogicalPart::addSpecifics(), operator<<(), DDCoreToDDXMLOutput::specpar(), DDStreamer::specs_write(), DDI::Specific::stream(), and Vispa.Views.PropertyView.Property::valueChanged().

64 { return names()[id_]; }
static std::vector< std::string > & names()
Definition: DDValue.cc:119
unsigned int id_
Definition: DDValue.h:106
std::vector< std::string > & DDValue::names ( void  )
staticprivate

Definition at line 119 of file DDValue.cc.

Referenced by DDValue(), doubles(), init(), name(), and operator[]().

120 {
121  static std::vector<std::string> names_( 1 );
122  return names_;
123 }
DDValue::operator unsigned int ( void  ) const
inline

converts a DDValue object into its ID

Definition at line 61 of file DDValue.h.

References id_.

61 { return id_; }
unsigned int id_
Definition: DDValue.h:106
bool DDValue::operator< ( const DDValue v) 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))

Definition at line 222 of file DDValue.cc.

References id(), query::result, and vecPair_.

223 {
224  bool result( false );
225  if( id() < v.id())
226  {
227  result = true;
228  }
229  else
230  {
231  if( id() == v.id())
232  {
233  assert( vecPair_ );
234  assert( v.vecPair_ );
235  if( vecPair_->first && v.vecPair_->first ) { // numerical values
236  result = ( vecPair_->second.second < v.vecPair_->second.second );
237  }
238  else { // std::string values
239  result = ( vecPair_->second.first < v.vecPair_->second.first );
240  }
241  }
242  }
243  return result;
244 }
unsigned int id(void) const
returns the ID of the DDValue
Definition: DDValue.h:58
tuple result
Definition: query.py:137
vecpair_type * vecPair_
Definition: DDValue.h:109
bool DDValue::operator== ( const DDValue v) const

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 204 of file DDValue.cc.

References id(), query::result, and vecPair_.

205 {
206  bool result( false );
207  if( id() == v.id())
208  {
209  assert( vecPair_ );
210  assert( v.vecPair_ );
211  if( vecPair_->first ) { // numerical values
212  result = ( vecPair_->second.second == v.vecPair_->second.second );
213  }
214  else { // std::string values
215  result = ( vecPair_->second.first == v.vecPair_->second.first );
216  }
217  }
218  return result;
219 }
unsigned int id(void) const
returns the ID of the DDValue
Definition: DDValue.h:58
tuple result
Definition: query.py:137
vecpair_type * vecPair_
Definition: DDValue.h:109
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 177 of file DDValue.cc.

References edm::hlt::Exception, id_, python.rootplot.argparse::message, names(), and vecPair_.

178 {
179  if( vecPair_->first )
180  {
181  return DDValuePair( vecPair_->second.first[i], vecPair_->second.second[i] );
182  }
183  else
184  {
185  std::string message = "DDValue " + names()[id_] + " is not numerically evaluated! Use DDValue::std::strings()!";
186  edm::LogError( "DDValue" ) << message;
187  throw cms::Exception("DDException") << message;
188  }
189 }
static std::vector< std::string > & names()
Definition: DDValue.cc:119
int i
Definition: DBlmapReader.cc:9
unsigned int id_
Definition: DDValue.h:106
vecpair_type * vecPair_
Definition: DDValue.h:109
void DDValue::setEvalState ( bool  newState)

set to true, if the double-values (method DDValue::doubles()) make sense

Definition at line 192 of file DDValue.cc.

References vecPair_.

Referenced by DDValue(), DDLSpecPar::processElement(), and DDStreamer::specs_read().

193 {
194  vecPair_->first = newState;
195 }
vecpair_type * vecPair_
Definition: DDValue.h:109
unsigned int DDValue::size ( void  ) const
inline

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<<(), DDCoreToDDXMLOutput::specpar(), DDStreamer::specs_write(), DDI::Specific::stream(), DDMapper< KeyType, ValueType >::toDouble(), and DDMapper< KeyType, ValueType >::toString().

78  {
79  return vecPair_ ? vecPair_->second.first.size() : 0 ;
80  }
vecpair_type * vecPair_
Definition: DDValue.h:109
const std::vector<std::string>& DDValue::strings ( ) const
inline

Friends And Related Function Documentation

friend class DDLSpecPar
friend

Definition at line 28 of file DDValue.h.

friend class DDSpecifics
friend

Definition at line 27 of file DDValue.h.

Member Data Documentation

unsigned int DDValue::id_
private

Definition at line 106 of file DDValue.h.

Referenced by DDValue(), doubles(), id(), init(), name(), operator unsigned int(), and operator[]().

vecpair_type* DDValue::vecPair_