CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions
DDLogicalPart Class Reference

A DDLogicalPart aggregates information concerning material, solid and sensitveness ... More...

#include <DDLogicalPart.h>

Inheritance diagram for DDLogicalPart:
DDBase< DDName, std::unique_ptr< DDI::LogicalPart > >

Public Member Functions

void addSpecifics (const std::pair< const DDPartSelection *, const DDsvalues_type * > &)
 don't use, internal only /todo make it private More...
 
const std::vector< std::pair
< const DDPartSelection
*, const DDsvalues_type * > > & 
attachedSpecifics (void) const
 
DDEnums::Category category (void) const
 Returns the categorization of the DDLogicalPart (sensitive detector element, cable, ...) More...
 
 DDLogicalPart (void)
 The default constructor provides an uninitialzed reference object. More...
 
 DDLogicalPart (const DDName &name)
 Creates a reference object referring to the appropriate XML specification. More...
 
 DDLogicalPart (const DDName &name, const DDMaterial &material, const DDSolid &solid, DDEnums::Category cat=DDEnums::unspecified)
 Registers (creates) a reference object representing a LogicalPart. More...
 
bool hasDDValue (const DDValue &) const
 
const DDMaterialmaterial (void) const
 Returns a reference object of the material this LogicalPart is made of. More...
 
DDsvalues_type mergedSpecifics (void) const
 returns the merged-specifics, i.e. the last specified specifics of this logical-part More...
 
void removeSpecifics (const std::pair< DDPartSelection *, DDsvalues_type * > &)
 
const DDSolidsolid (void) const
 Returns a reference object of the solid being the shape of this LogicalPart. More...
 
std::vector< const
DDsvalues_type * > 
specifics (void) const
 returns the specific-data attached to the LogicalPart only (not to a DDExpandedNode) More...
 
- Public Member Functions inherited from DDBase< DDName, std::unique_ptr< DDI::LogicalPart > >
void create (const DDName &name, std::unique_ptr< DDI::LogicalPart >vals)
 
void create (const DDName &name)
 
 DDBase ()
 
const DDNameddname () const
 
def_type isDefined () const
 
bool isValid () const
 true, if the wrapped pointer is valid More...
 
const DDNamename () const
 
 operator bool () const
 
bool operator< (const DDBase &b) const
 
bool operator== (const DDBase &b) const
 
bool operator> (const DDBase &b) const
 
const DDI::rep_traits< DDName,
std::unique_ptr
< DDI::LogicalPart >
>::reference 
rep () const
 
DDI::rep_traits< DDName,
std::unique_ptr
< DDI::LogicalPart >
>::reference 
rep ()
 
std::string toString () const
 
const DDI::rep_traits< DDName,
std::unique_ptr
< DDI::LogicalPart >
>::reference 
val () const
 
const DDI::rep_traits< DDName,
std::unique_ptr
< DDI::LogicalPart >
>::reference 
val ()
 
virtual ~DDBase ()
 

Additional Inherited Members

- Public Types inherited from DDBase< DDName, std::unique_ptr< DDI::LogicalPart > >
using def_type = std::pair< const DDName *, bool >
 
using StoreT = DDI::Singleton< DDI::Store< DDName, std::unique_ptr< DDI::LogicalPart > > >
 
- Static Public Member Functions inherited from DDBase< DDName, std::unique_ptr< DDI::LogicalPart > >
static auto begin ()
 
static auto end ()
 

Detailed Description

A DDLogicalPart aggregates information concerning material, solid and sensitveness ...

... of a unpositioned volume. DDLogicalPart provides thus an interface to its XML representation <LogicalPart ... </LogicalPart>.

An object of this class is a reference-object and thus lightweighted. It can be copied by value without having a large overhead. Assigning to the reference-object invalidates the object which was referred to before. Assigning also effects all other instances of this class which were created using the same value of DDName. In fact, the value of DDName identifies a LogicalPart uniquely.

Current Restriction: Only the name part of DDName identifies the LogicalPart.

General properties of reference objects:

Three kind of reference objects can be distinguished:

An unititialized reference object is somehow comparable to an anonymous structure. The default constructor (no arguments) is used to create it. No DDName was specified. It's not very useful unless you assign an initialized or defined reference object.

An initialized reference object is a reference object which was created first using only the constructor taking a single DDName as an argument. It's comparable to a variable declaration with default initialization (like std::vector < int > v). The default object is registered using the DDName as index in some from the user hidden registry. After an initialized reference object has been created it can be used (copied, assigned to, beeing assigned to, ..) like a built in type like int. As soon as an defined reference object with the same DDName is create, all already existing initialized reference object become defined reference object immidiately (some kind of one-definition-rule).

A defined reference object is a reference object which was created using a constructor taking DDName and additional arguments or using appropriate factory functions (e.g. DDbox) returning a defined reference object. As soon as one defined reference object A1 is created with a unique DDName N1, every reference object A2 created by the constructor which only take DDName N2 as an argument and N2 == N1, is also a defined reference object referring to the same object than A1. Hence A1 == A2 is true. Further any previously created initialized reference objects having the same DDName also become references to the newly created defined reference object A1.

To find out whether an instance of a reference object is defined or not, operator bool can be used, i.e.

DDLogicalPart(DDName("CMS","cms.xml")) cms;
if (cms) {
// cms is a defined reference object
}
else {
// cms is a (default) initialized reference object
}

Definition at line 93 of file DDLogicalPart.h.

Constructor & Destructor Documentation

DDLogicalPart::DDLogicalPart ( void  )
inline

The default constructor provides an uninitialzed reference object.

Definition at line 96 of file DDLogicalPart.h.

DDLogicalPart::DDLogicalPart ( const DDName name)

Creates a reference object referring to the appropriate XML specification.

In order to use an uninitialized reference object one has to assign to it an initialized object of the same class.

Example:

DDLogicalPart world; // uninitialized (anonymous) reference object
world = DDLogicalPart(DDName("CMS","cms.xml"));
// now world refers to an initialized object, which in turn is not
// necessarily defined yet.

One has to distinguish two cases:

The object which should be referred to has already been defined ...
... using the constructor:
const DDSolid, bool sens)
This will be the case for example after XML has been parsed. The XML parser calls the constructor described below and thus registers a new object using DDName to identify it uniquely. The using this constructor one fetches the reference object. Assigning to this reference object invalidates the object being refered before (and redirects all reference objects using the same value of their DDName already in use to the newly assigned reference object).
The object which should be referred to has not yet been defined
In this case this constructor registeres a valid object. But this object is not yet defined (i.e. no material nor a solid has been attached to it). Nevertheless the reference object can be used (copied ...) everywhere. If, at a later stage, a defined reference object with the same DDName is created, all already existing reference objects become references to this newly created reference object (one definition rule).

Example:

... // code for DDMaterial (material) definition and DDSolid (solid) defintion goes here
DDName detName("Detector","logparts"); // define a unique name
DDLogicalPart detDeclaration(detName); // detName-corresponding object not defined yet!
std::vector<DDLogicalPart> vec;
vec.emplace_back(det); // use reference object in a std::vector
// now define ad detName-corresponding object (it will be internally registered)
DDLogicalPart detDefinition(detName, material, solid, false);
// now also vec[0] automatically becomes a reference to detDefinition!
// both got

Definition at line 90 of file DDLogicalPart.cc.

References DDBase< DDName, std::unique_ptr< DDI::LogicalPart > >::create(), and DD_NC().

91  create(name);
92  DD_NC(name);
93 }
Definition: DDBase.h:10
void DD_NC(const DDName &)
void create(const DDName &name, std::unique_ptr< DDI::LogicalPart >vals)
Definition: DDBase.h:96
DDLogicalPart::DDLogicalPart ( const DDName ddname,
const DDMaterial material,
const DDSolid solid,
DDEnums::Category  cat = DDEnums::unspecified 
)

Registers (creates) a reference object representing a LogicalPart.

An object representing a logicalpart uniquely identified by its DDName name will be created. If reference objects of the same name already exist, they will refere to the newly created object. DDMaterial material and DDSolid solid are themselves reference objects to a material and solid specification. The need not be defined yet as long as they were constructed using unique DDName-objects.

This constructor is intended to be called by the XML parsing software, not by the DDD user. It decouples the input technologies (i.e. XML) and forms the transition to the runtime DDD representation. However, it could also be used for 'programming' a detector description.

Definition at line 107 of file DDLogicalPart.cc.

References DDBase< DDName, std::unique_ptr< DDI::LogicalPart > >::create(), and DD_NC().

112  create(ddname, std::make_unique<DDI::LogicalPart>(material, solid, cat));
113  DD_NC(ddname);
114 }
Definition: DDBase.h:10
def cat
Definition: eostools.py:401
void DD_NC(const DDName &)
void create(const DDName &name, std::unique_ptr< DDI::LogicalPart >vals)
Definition: DDBase.h:96

Member Function Documentation

void DDLogicalPart::addSpecifics ( const std::pair< const DDPartSelection *, const DDsvalues_type * > &  s)

don't use, internal only /todo make it private

Definition at line 188 of file DDLogicalPart.cc.

References DDBase< DDName, std::unique_ptr< DDI::LogicalPart > >::rep().

188  {
189  rep().addSpecifics(s);
190 }
const DDI::rep_traits< DDName, std::unique_ptr< DDI::LogicalPart > >::reference rep() const
Definition: DDBase.h:65
const std::vector< std::pair< const DDPartSelection *, const DDsvalues_type * > > & DDLogicalPart::attachedSpecifics ( void  ) const
DDEnums::Category DDLogicalPart::category ( void  ) const

Returns the categorization of the DDLogicalPart (sensitive detector element, cable, ...)

Definition at line 116 of file DDLogicalPart.cc.

References DDBase< DDName, std::unique_ptr< DDI::LogicalPart > >::rep().

Referenced by DDHtmlLpDetails::details().

116 { return rep().category(); }
const DDI::rep_traits< DDName, std::unique_ptr< DDI::LogicalPart > >::reference rep() const
Definition: DDBase.h:65
bool DDLogicalPart::hasDDValue ( const DDValue v) const

Definition at line 194 of file DDLogicalPart.cc.

References DDBase< DDName, std::unique_ptr< DDI::LogicalPart > >::rep().

Referenced by DDSpecificsHasNamedValueFilter::accept(), DDSpecificsMatchesValueFilter::accept(), and DDSpecificsFilter::accept_impl().

194 { return rep().hasDDValue(v); }
const DDI::rep_traits< DDName, std::unique_ptr< DDI::LogicalPart > >::reference rep() const
Definition: DDBase.h:65
const DDMaterial & DDLogicalPart::material ( void  ) const

Returns a reference object of the material this LogicalPart is made of.

Definition at line 118 of file DDLogicalPart.cc.

References DDBase< DDName, std::unique_ptr< DDI::LogicalPart > >::rep().

Referenced by ListIds::analyze(), OutputMagneticFieldDDToDDL::beginRun(), OutputDDToDDL::beginRun(), HcalTB06BeamParametersFromDD::build(), HcalSimParametersFromDD::build(), EcalSimParametersFromDD::build(), DDG4Builder::convertLV(), DDCheckLP(), DDHtmlLpDetails::details(), DDCoreToDDXMLOutput::logicalPart(), DDDividedConsRho::makeDDLogicalPart(), DDDividedTubsRho::makeDDLogicalPart(), DDDividedBoxX::makeDDLogicalPart(), DDDividedTrdX::makeDDLogicalPart(), DDDividedPolyconeRho::makeDDLogicalPart(), DDDividedPolyhedraRho::makeDDLogicalPart(), DDDividedBoxY::makeDDLogicalPart(), DDDividedConsPhi::makeDDLogicalPart(), DDDividedTubsPhi::makeDDLogicalPart(), DDDividedPolyhedraPhi::makeDDLogicalPart(), DDDividedTrdY::makeDDLogicalPart(), DDDividedPolyconePhi::makeDDLogicalPart(), DDDividedTubsZ::makeDDLogicalPart(), DDDividedConsZ::makeDDLogicalPart(), DDDividedBoxZ::makeDDLogicalPart(), DDDividedPolyhedraZ::makeDDLogicalPart(), DDDividedTrdZ::makeDDLogicalPart(), DDDividedPolyconeZ::makeDDLogicalPart(), DDFilteredView::material(), cms::DDFilteredView::materialName(), output(), and MagGeoBuilderFromDDD::volumeHandle::volumeHandle().

118 { return rep().material(); }
const DDI::rep_traits< DDName, std::unique_ptr< DDI::LogicalPart > >::reference rep() const
Definition: DDBase.h:65
DDsvalues_type DDLogicalPart::mergedSpecifics ( void  ) const

returns the merged-specifics, i.e. the last specified specifics of this logical-part

Definition at line 181 of file DDLogicalPart.cc.

References DDBase< DDName, std::unique_ptr< DDI::LogicalPart > >::rep(), and mps_fire::result.

181  {
183  rep().mergedSpecificsV(result);
184  return result;
185 }
const DDI::rep_traits< DDName, std::unique_ptr< DDI::LogicalPart > >::reference rep() const
Definition: DDBase.h:65
tuple result
Definition: mps_fire.py:311
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
Definition: DDsvalues.h:12
void DDLogicalPart::removeSpecifics ( const std::pair< DDPartSelection *, DDsvalues_type * > &  s)

Definition at line 192 of file DDLogicalPart.cc.

References DDBase< DDName, std::unique_ptr< DDI::LogicalPart > >::rep().

192 { rep().removeSpecifics(s); }
const DDI::rep_traits< DDName, std::unique_ptr< DDI::LogicalPart > >::reference rep() const
Definition: DDBase.h:65
const DDSolid & DDLogicalPart::solid ( void  ) const

Returns a reference object of the solid being the shape of this LogicalPart.

Definition at line 120 of file DDLogicalPart.cc.

References DDBase< DDName, std::unique_ptr< DDI::LogicalPart > >::rep().

Referenced by PrintGeomSummary::addSolid(), PrintGeomSolids::analyze(), OutputMagneticFieldDDToDDL::beginRun(), OutputDDToDDL::beginRun(), HcalTB02ParametersFromDD::build(), EcalSimParametersFromDD::build(), CSCGeometryParsFromDD::build(), GEMGeometryParsFromDD::buildChamber(), ME0GeometryBuilder::buildChamber(), GEMGeometryBuilder::buildChamber(), GEMGeometryParsFromDD::buildEtaPartition(), ME0GeometryBuilder::buildEtaPartition(), GEMGeometryBuilder::buildEtaPartition(), RPCGeometryBuilder::buildGeometry(), RPCGeometryParsFromDD::buildGeometry(), ME0GeometryBuilder::buildGeometry(), ME0GeometryBuilder::buildLayer(), GEMGeometryParsFromDD::buildSuperChamber(), GEMGeometryBuilder::buildSuperChamber(), DDDividedPolyhedraRho::checkParametersValidity(), DDDividedPolyconeRho::checkParametersValidity(), DDDividedTrdX::checkParametersValidity(), DDDividedTrdY::checkParametersValidity(), DDDividedPolyhedraPhi::checkParametersValidity(), DDDividedTrdZ::checkParametersValidity(), DDDividedPolyconeZ::checkParametersValidity(), DDDividedPolyhedraZ::checkParametersValidity(), DDG4Builder::convertLV(), DDCheckLP(), DDCompareLP(), DDDividedBoxX::DDDividedBoxX(), DDDividedBoxY::DDDividedBoxY(), DDDividedBoxZ::DDDividedBoxZ(), DDDividedConsPhi::DDDividedConsPhi(), DDDividedConsRho::DDDividedConsRho(), DDDividedConsZ::DDDividedConsZ(), DDDividedPolyconePhi::DDDividedPolyconePhi(), DDDividedPolyconeRho::DDDividedPolyconeRho(), DDDividedPolyconeZ::DDDividedPolyconeZ(), DDDividedPolyhedraPhi::DDDividedPolyhedraPhi(), DDDividedPolyhedraRho::DDDividedPolyhedraRho(), DDDividedPolyhedraZ::DDDividedPolyhedraZ(), DDDividedTrdX::DDDividedTrdX(), DDDividedTrdY::DDDividedTrdY(), DDDividedTrdZ::DDDividedTrdZ(), DDDividedTubsPhi::DDDividedTubsPhi(), DDDividedTubsRho::DDDividedTubsRho(), DDDividedTubsZ::DDDividedTubsZ(), HGCalSimHitValidation::defineGeometry(), DDHtmlLpDetails::details(), DTGeometryBuilderFromDDD::extractParameters(), DTGeometryParsFromDD::extractParameters(), ME0GeometryParsFromDD::getDimension(), DDDividedBoxX::getMaxParameter(), DDDividedTubsRho::getMaxParameter(), DDDividedConsRho::getMaxParameter(), DDDividedPolyconeRho::getMaxParameter(), DDDividedPolyhedraRho::getMaxParameter(), DDDividedTrdX::getMaxParameter(), DDDividedTubsPhi::getMaxParameter(), DDDividedConsPhi::getMaxParameter(), DDDividedBoxY::getMaxParameter(), DDDividedPolyconePhi::getMaxParameter(), DDDividedPolyhedraPhi::getMaxParameter(), DDDividedTrdY::getMaxParameter(), DDDividedBoxZ::getMaxParameter(), DDDividedTubsZ::getMaxParameter(), DDDividedConsZ::getMaxParameter(), DDDividedTrdZ::getMaxParameter(), DDDividedPolyconeZ::getMaxParameter(), DDDividedPolyhedraZ::getMaxParameter(), DreamSD::initMap(), HcalGeomParameters::loadGeometry(), HGCalGeomParameters::loadGeometryHexagon(), HGCalGeomParameters::loadGeometryHexagon8(), HGCalGeomParameters::loadGeometryHexagonModule(), DDCoreToDDXMLOutput::logicalPart(), DDDividedTubsRho::makeDDLogicalPart(), DDDividedBoxX::makeDDLogicalPart(), DDDividedConsRho::makeDDLogicalPart(), DDDividedPolyconeRho::makeDDLogicalPart(), DDDividedPolyhedraRho::makeDDLogicalPart(), DDDividedTrdX::makeDDLogicalPart(), DDDividedTubsPhi::makeDDLogicalPart(), DDDividedConsPhi::makeDDLogicalPart(), DDDividedBoxY::makeDDLogicalPart(), DDDividedTrdY::makeDDLogicalPart(), DDDividedPolyhedraPhi::makeDDLogicalPart(), DDDividedPolyconePhi::makeDDLogicalPart(), DDDividedTubsZ::makeDDLogicalPart(), DDDividedBoxZ::makeDDLogicalPart(), DDDividedConsZ::makeDDLogicalPart(), DDDividedPolyhedraZ::makeDDLogicalPart(), DDDividedPolyconeZ::makeDDLogicalPart(), DDDividedTrdZ::makeDDLogicalPart(), DDDividedBoxX::makeDDTranslation(), DDDividedTrdX::makeDDTranslation(), DDDividedBoxY::makeDDTranslation(), DDDividedTrdY::makeDDTranslation(), DDDividedBoxZ::makeDDTranslation(), DDDividedConsZ::makeDDTranslation(), DDDividedTubsZ::makeDDTranslation(), DDDividedPolyhedraZ::makeDDTranslation(), DDDividedTrdZ::makeDDTranslation(), DDDividedPolyconeZ::makeDDTranslation(), DDLDivision::makeDivider(), EcalTBHodoscopeGeometryLoaderFromDDD::makeGeometry(), output(), DDFilteredView::parameters(), cms::DDSolid::parameters(), DDLDivision::processElement(), DDFilteredView::shape(), DDI::Division::stream(), and MagGeoBuilderFromDDD::volumeHandle::volumeHandle().

120 { return rep().solid(); }
const DDI::rep_traits< DDName, std::unique_ptr< DDI::LogicalPart > >::reference rep() const
Definition: DDBase.h:65
std::vector< const DDsvalues_type * > DDLogicalPart::specifics ( void  ) const

returns the specific-data attached to the LogicalPart only (not to a DDExpandedNode)

The method will only return specific data attached to a DDLogicalPart. If DDL-XML is used to define specific data, the path-attribute of <PartSelector> addressing only LogicalParts only consists of a "//" and the name of the LogicalPart (or a regexp for the name):

<SpecPar name="Color">
<PartSelector path="//BarrelDetector"/>
<PartSelector path="//ForwardSector1.*Cable."/>
<Parameter name="rgb" value="0.5"/>
<Parameter name="rgb" value="0.1+0.2"/>
<Parameter name="rgb" value="[colors:blue1]/>
<Parameter name="visible" value="true"/>
</SpecPar>

The above XML assigns specific data to a DDLogicalPart with name "BarrelDetector" and to all DDLogicalParts whose names match the regexp "ForwardSector1.*Cable.", e.g. "ForwardSector123abCable7" Two parameters are attached as specific data: "rgb" - a std::vector of three values, and "visible" - a std::vector of one value.

The method DDLogicalPart::specifics() now returns a std::vector<const DDsvalues_type *> V which correspond to these two values. Every entry in V comes from a different <SpecPar> tag. In our example above, V would have size 1, e.g. V.size() == 1.

A <Paramter> is std::mapped to DDValue. 'value' of <Parameter> is kept as a std::string and as a double. If the std::string does not evaluate correctly to double, 0 is the assigned.

Here's the code to retrieve the 'rgb' Parameter:

void someFunc(DDLogicalPart aLp) {
// want to know, whether the specific parameter 'Color' is attached to aLp
// each <SpecPar> for this LogicalPart will create one entry in the result_type std::vector
// each entry in the result_type std::vector contains all Paramters defined in one SpecPar-tag
// We assume now, that we have only one SpecPar ...
typedef std::vector<const DDsvalues_type *> result_type;
result_type result = aLp.specifics();
if (result.size()==1) {
DDValue val("Color");
bool foundIt=false;
foundIt = DDfetch(result[0],val) // DDfetch is a utility function to retrieve values from a DDsvalues_type*
if (foundIt) { // val contains the result
const std::vector<std::string> & strVec = val.std::string();
// strVec[0] == "0.5"
// strVec[1] == "0.1+0.2"
const std::vector<double> & dblVec = val.doubles();
// dblVec[0] == double value of Constant 'red' 0.5
...
// do something here ...
}
}

Definition at line 175 of file DDLogicalPart.cc.

References DDBase< DDName, std::unique_ptr< DDI::LogicalPart > >::rep(), and mps_fire::result.

Referenced by DDG4Builder::getDouble(), DDG4Builder::getInt(), MuonGeometryNumbering::getInt(), and DDG4SensitiveConverter::getString().

175  {
176  std::vector<const DDsvalues_type*> result;
177  rep().specificsV(result);
178  return result;
179 }
const DDI::rep_traits< DDName, std::unique_ptr< DDI::LogicalPart > >::reference rep() const
Definition: DDBase.h:65
tuple result
Definition: mps_fire.py:311