diff --git a/DDCore/include/DD4hep/CartesianGridXY.h b/DDCore/include/DD4hep/CartesianGridXY.h index 34b2b59b9efce185e017b1a92fbca4d82a270e97..c29e507b9f0922727da80e7cb03256a8b9ba590f 100644 --- a/DDCore/include/DD4hep/CartesianGridXY.h +++ b/DDCore/include/DD4hep/CartesianGridXY.h @@ -28,27 +28,48 @@ namespace DD4hep { // Forward declarations class Segmentation; - + + /// We need some abbreviation to make the code more readable. + typedef Handle<SegmentationWrapper<DDSegmentation::CartesianGridXY> > CartesianGridXYHandle; + /// Implementation class for the grid XY segmentation. /** - * \author M.Frank - * \version 1.0 - * \ingroup DD4HEP_GEOMETRY + * Concrete user handle to serve specific needs of client code + * which requires access to the base functionality not served + * by the super-class Segmentation. + * + * Note: + * We only check the validity of the underlying handle. + * If for whatever reason the implementation object is not valid + * This is not checked. + * In principle this CANNOT happen unless some brain-dead has + * fiddled with the handled object directly..... + * + * Note: + * The handle base corrsponding to this object in for + * conveniance reasons instantiated in DD4hep/src/Segmentations.cpp. + * + * \author M.Frank + * \version 1.0 + * \ingroup DD4HEP_GEOMETRY */ - class CartesianGridXY : public Handle<DDSegmentation::CartesianGridXY> { + class CartesianGridXY : public CartesianGridXYHandle { public: /// Defintiion of the basic handled object - typedef DDSegmentation::CartesianGridXY Object; + typedef CartesianGridXYHandle::Implementation Object; public: /// Default constructor - CartesianGridXY() : Handle<Object>() {} - /// Copy constructor from handle - CartesianGridXY(const Handle<Object>& e) : Handle<Object>(e) {} + CartesianGridXY() = default; /// Copy constructor CartesianGridXY(const CartesianGridXY& e) = default; /// Copy Constructor from segmentation base object - CartesianGridXY(const Segmentation& e); + CartesianGridXY(const Segmentation& e) : Handle<Object>(e) { } + /// Copy constructor from handle + CartesianGridXY(const Handle<Object>& e) : Handle<Object>(e) { } + /// Copy constructor from other equivalent handle + template <typename Q> + CartesianGridXY(const Handle<Q>& e) : Handle<Object>(e) { } /// Assignment operator CartesianGridXY& operator=(const CartesianGridXY& seg) = default; /// Equality operator diff --git a/DDCore/include/DD4hep/CartesianGridXYZ.h b/DDCore/include/DD4hep/CartesianGridXYZ.h index 3fa4f54bafe40b02de78732884ae084daafe5299..1d53c9e466140e9ae4eacf2e0a61c2fb93703e8e 100644 --- a/DDCore/include/DD4hep/CartesianGridXYZ.h +++ b/DDCore/include/DD4hep/CartesianGridXYZ.h @@ -28,34 +28,53 @@ namespace DD4hep { // Forward declarations class Segmentation; - + + /// We need some abbreviation to make the code more readable. + typedef Handle<SegmentationWrapper<DDSegmentation::CartesianGridXYZ> > CartesianGridXYZHandle; + /// Implementation class for the grid XYZ segmentation. /** - * \author M.Frank - * \version 1.0 - * \ingroup DD4HEP_GEOMETRY + * Concrete user handle to serve specific needs of client code + * which requires access to the base functionality not served + * by the super-class Segmentation. + * + * Note: + * We only check the validity of the underlying handle. + * If for whatever reason the implementation object is not valid + * This is not checked. + * In principle this CANNOT happen unless some brain-dead has + * fiddled with the handled object directly..... + * + * Note: + * The handle base corrsponding to this object in for + * conveniance reasons instantiated in DD4hep/src/Segmentations.cpp. + * + * \author M.Frank + * \version 1.0 + * \ingroup DD4HEP_GEOMETRY */ - class CartesianGridXYZ : public Handle<DDSegmentation::CartesianGridXYZ> { + class CartesianGridXYZ : public CartesianGridXYZHandle { public: /// Defintiion of the basic handled object - typedef DDSegmentation::CartesianGridXYZ Object; + typedef CartesianGridXYZHandle::Implementation Object; public: /// Default constructor - CartesianGridXYZ() : Handle<Object>() {} - /// Copy constructor from handle - CartesianGridXYZ(const Handle<Object>& e) : Handle<Object>(e) {} + CartesianGridXYZ() = default; /// Copy constructor CartesianGridXYZ(const CartesianGridXYZ& e) = default; /// Copy Constructor from segmentation base object - CartesianGridXYZ(const Segmentation& e); + CartesianGridXYZ(const Segmentation& e) : Handle<Object>(e) {} + /// Copy constructor from handle + CartesianGridXYZ(const Handle<Object>& e) : Handle<Object>(e) {} + /// Copy constructor from other polymorph/equivalent handle + template <typename Q> + CartesianGridXYZ(const Handle<Q>& e) : Handle<Object>(e) {} /// Assignment operator CartesianGridXYZ& operator=(const CartesianGridXYZ& seg) = default; /// Equality operator - bool operator==(const CartesianGridXYZ& seg) const { - return m_element == seg.m_element; - } - + bool operator==(const CartesianGridXYZ& seg) const + { return m_element == seg.m_element; } /// determine the position based on the cell ID Position position(const CellID& cellID) const; /// determine the cell ID based on the position diff --git a/DDCore/include/DD4hep/CartesianGridXZ.h b/DDCore/include/DD4hep/CartesianGridXZ.h index 294b3113d1158f0a72b3696f2abf76c1ac2d2057..e86f5828e1da9c039e49c26613417190f718470c 100644 --- a/DDCore/include/DD4hep/CartesianGridXZ.h +++ b/DDCore/include/DD4hep/CartesianGridXZ.h @@ -29,32 +29,52 @@ namespace DD4hep { // Forward declarations class Segmentation; + /// We need some abbreviation to make the code more readable. + typedef Handle<SegmentationWrapper<DDSegmentation::CartesianGridXZ> > CartesianGridXZHandle; + /// Implementation class for the grid XZ segmentation. /** - * \author M.Frank - * \version 1.0 - * \ingroup DD4HEP_GEOMETRY + * Concrete user handle to serve specific needs of client code + * which requires access to the base functionality not served + * by the super-class Segmentation. + * + * Note: + * We only check the validity of the underlying handle. + * If for whatever reason the implementation object is not valid + * This is not checked. + * In principle this CANNOT happen unless some brain-dead has + * fiddled with the handled object directly..... + * + * Note: + * The handle base corrsponding to this object in for + * conveniance reasons instantiated in DD4hep/src/Segmentations.cpp. + * + * \author M.Frank + * \version 1.0 + * \ingroup DD4HEP_GEOMETRY */ - class CartesianGridXZ : public Handle<DDSegmentation::CartesianGridXZ> { + class CartesianGridXZ : public CartesianGridXZHandle { public: /// Defintiion of the basic handled object - typedef DDSegmentation::CartesianGridXZ Object; + typedef CartesianGridXZHandle::Implementation Object; public: /// Default constructor - CartesianGridXZ() : Handle<Object>() {} - /// Copy constructor from handle - CartesianGridXZ(const Handle<Object>& e) : Handle<Object>(e) {} + CartesianGridXZ() = default; /// Copy constructor CartesianGridXZ(const CartesianGridXZ& e) = default; /// Copy Constructor from segmentation base object - CartesianGridXZ(const Segmentation& e); + CartesianGridXZ(const Segmentation& e) : Handle<Object>(e) {} + /// Copy constructor from handle + CartesianGridXZ(const Handle<Object>& e) : Handle<Object>(e) {} + /// Copy constructor from other polymorph/equivalent handle + template <typename Q> + CartesianGridXZ(const Handle<Q>& e) : Handle<Object>(e) {} /// Assignment operator CartesianGridXZ& operator=(const CartesianGridXZ& seg) = default; /// Equality operator - bool operator==(const CartesianGridXZ& seg) const { - return m_element == seg.m_element; - } + bool operator==(const CartesianGridXZ& seg) const + { return m_element == seg.m_element; } /// determine the position based on the cell ID Position position(const CellID& cellID) const; diff --git a/DDCore/include/DD4hep/CartesianGridYZ.h b/DDCore/include/DD4hep/CartesianGridYZ.h index ecd7a97ab3f37e388c2900dacbdbfd3f676fbf54..04f46915e4a8b8484d225b3f8d8267eff2ba3698 100644 --- a/DDCore/include/DD4hep/CartesianGridYZ.h +++ b/DDCore/include/DD4hep/CartesianGridYZ.h @@ -29,33 +29,52 @@ namespace DD4hep { // Forward declarations class Segmentation; - /// Implementation class for the grid YZ segmentation. + /// We need some abbreviation to make the code more readable. + typedef Handle<SegmentationWrapper<DDSegmentation::CartesianGridYZ> > CartesianGridYZHandle; + + /// Implementation class for the grid YZ segmentation. /** - * \author M.Frank - * \version 1.0 - * \ingroup DD4HEP_GEOMETRY + * Concrete user handle to serve specific needs of client code + * which requires access to the base functionality not served + * by the super-class Segmentation. + * + * Note: + * We only check the validity of the underlying handle. + * If for whatever reason the implementation object is not valid + * This is not checked. + * In principle this CANNOT happen unless some brain-dead has + * fiddled with the handled object directly..... + * + * Note: + * The handle base corrsponding to this object in for + * conveniance reasons instantiated in DD4hep/src/Segmentations.cpp. + * + * \author M.Frank + * \version 1.0 + * \ingroup DD4HEP_GEOMETRY */ - class CartesianGridYZ : public Handle<DDSegmentation::CartesianGridYZ> { + class CartesianGridYZ : public CartesianGridYZHandle { public: /// Defintiion of the basic handled object - typedef DDSegmentation::CartesianGridYZ Object; + typedef CartesianGridYZHandle::Implementation Object; public: /// Default constructor - CartesianGridYZ() : Handle<Object>() {} - /// Copy constructor from handle - CartesianGridYZ(const Handle<Object>& e) : Handle<Object>(e) {} + CartesianGridYZ() = default; /// Copy constructor CartesianGridYZ(const CartesianGridYZ& e) = default; /// Copy Constructor from segmentation base object - CartesianGridYZ(const Segmentation& e); + CartesianGridYZ(const Segmentation& e) : Handle<Object>(e) {} + /// Copy constructor from handle + CartesianGridYZ(const Handle<Object>& e) : Handle<Object>(e) {} + /// Copy constructor from other polymorph/equivalent handle + template <typename Q> + CartesianGridYZ(const Handle<Q>& e) : Handle<Object>(e) { } /// Assignment operator CartesianGridYZ& operator=(const CartesianGridYZ& seg) = default; /// Equality operator - bool operator==(const CartesianGridYZ& seg) const { - return m_element == seg.m_element; - } - + bool operator==(const CartesianGridYZ& seg) const + { return m_element == seg.m_element; } /// determine the position based on the cell ID Position position(const CellID& cellID) const; /// determine the cell ID based on the position diff --git a/DDCore/include/DD4hep/Conditions.h b/DDCore/include/DD4hep/Conditions.h index d8782507b3ff2434b1403ab212fde5f876aca2e0..1f9ce3e55b5a8de47ad105556542deabb2c1ffe9 100644 --- a/DDCore/include/DD4hep/Conditions.h +++ b/DDCore/include/DD4hep/Conditions.h @@ -114,9 +114,9 @@ namespace DD4hep { }; /// Default constructor - Condition(); + Condition() = default; /// Copy constructor - Condition(const Condition& c); + Condition(const Condition& c) = default; /// Initializing constructor Condition(Object* p); /// Constructor to be used when reading the already parsed object @@ -124,7 +124,7 @@ namespace DD4hep { /// Initializing constructor for a pure, undecorated conditions object Condition(const std::string& name, const std::string& type); /// Assignment operator - Condition& operator=(const Condition& c); + Condition& operator=(const Condition& c) = default; /// Output method std::string str(int with_data=WITH_IOV|WITH_ADDRESS|WITH_DATATYPE) const; @@ -183,15 +183,6 @@ namespace DD4hep { inline Condition::Condition(Condition::Object* p) : Handle<Condition::Object>(p) { } - /// Copy constructor - inline Condition::Condition(const Condition& c) : Handle<Condition::Object>(c) { - } - - /// Default constructor - inline Condition::Condition() : Handle<Condition::Object>() { - } - - /// Container class for condition handles aggregated by a detector element /** * Note: The conditions container is owner by the detector element @@ -213,10 +204,9 @@ namespace DD4hep { public: /// Default constructor - Container(); - + Container() = default; /// Constructor to be used when reading the already parsed object - template <typename Q> Container(const Container& c) : Handle<Object>(c) {} + Container(const Container& c) = default; /// Constructor to be used when reading the already parsed object template <typename Q> Container(const Handle<Q>& e) : Handle<Object>(e) {} @@ -237,11 +227,6 @@ namespace DD4hep { Condition get(key_type condition_key, const UserPool& iov); }; - /// Default constructor - inline Container::Container() : Handle<Object>() { - } - - /// Key definition to optimize ans simplyfy the access to conditions entities /** * \author M.Frank diff --git a/DDCore/include/DD4hep/Detector.h b/DDCore/include/DD4hep/Detector.h index b83945a541119704c70b78fc19256ccb6c70cbc0..b718484c1eae5d4bea1a02ab323a84adce0f8e8a 100644 --- a/DDCore/include/DD4hep/Detector.h +++ b/DDCore/include/DD4hep/Detector.h @@ -69,39 +69,25 @@ namespace DD4hep { public: /// Default constructor - SensitiveDetector() - : RefObject() { - } + SensitiveDetector() : RefObject() { } /// Constructor to copy handled object - SensitiveDetector(Object* obj_pointer) - : RefObject(obj_pointer) { - } + SensitiveDetector(Object* obj_pointer) : RefObject(obj_pointer) { } /// Copy from named handle - SensitiveDetector(const RefObject& sd) - : RefObject(sd) { - } + SensitiveDetector(const RefObject& sd) : RefObject(sd) { } /// Copy from handle - SensitiveDetector(const SensitiveDetector& sd) - : RefObject(sd) { - } + SensitiveDetector(const SensitiveDetector& sd) = default; /// Templated constructor for handle conversions - template <typename Q> - SensitiveDetector(const Handle<Q>& e) - : RefObject(e) { - } + template <typename Q> SensitiveDetector(const Handle<Q>& e) : RefObject(e) { } /// Constructor for a new sensitive detector element SensitiveDetector(const std::string& name, const std::string& type = "sensitive"); /// Assignment operator - SensitiveDetector& operator=(const SensitiveDetector& sd) { - m_element = sd.m_element; - return *this; - } + SensitiveDetector& operator=(const SensitiveDetector& sd) = default; /// Access the type of the sensitive detector std::string type() const; @@ -251,7 +237,7 @@ namespace DD4hep { template <typename Q> DetElement(const Handle<Q>& e) : RefObject(e) {} /// Constructor to copy handle - DetElement(const DetElement& e) : RefObject(e) { } + DetElement(const DetElement& e) = default; #ifdef __MAKECINT__ /// Constructor to copy handle @@ -284,10 +270,7 @@ namespace DD4hep { } /// Assignment operator - DetElement& operator=(const DetElement& e) { - m_element = e.m_element; - return *this; - } + DetElement& operator=(const DetElement& e) = default; /// Clone (Deep copy) the DetElement structure with a new name DetElement clone(const std::string& new_name) const; diff --git a/DDCore/include/DD4hep/Fields.h b/DDCore/include/DD4hep/Fields.h index da485721564e77750702912219e7e85083dfa2f8..6caeb5524d82815ea77b585a108f691c136588d9 100644 --- a/DDCore/include/DD4hep/Fields.h +++ b/DDCore/include/DD4hep/Fields.h @@ -73,25 +73,17 @@ namespace DD4hep { }; /// Default constructor - CartesianField() - : Ref_t() { - } + CartesianField() = default; /// Constructor to be used when reading the already parsed DOM tree - CartesianField(const CartesianField& e) - : Ref_t(e) { - } + CartesianField(const CartesianField& e) = default; /// Constructor to be used when reading the already parsed DOM tree - template <typename Q> CartesianField(const Handle<Q>& e) - : Ref_t(e) { + template <typename Q> CartesianField(const Handle<Q>& e) : Ref_t(e) { } /// Assignment operator - CartesianField& operator=(const CartesianField& f) { - m_element = f.m_element; - return *this; - } + CartesianField& operator=(const CartesianField& f) = default; /// Access the field type int fieldType() const { @@ -166,15 +158,10 @@ namespace DD4hep { }; /// Default constructor - OverlayedField() - : Ref_t() { - } + OverlayedField() = default; /// Constructor to be used when reading the already parsed DOM tree - template <typename Q> - OverlayedField(const Handle<Q>& e) - : Ref_t(e) { - } + template <typename Q> OverlayedField(const Handle<Q>& e) : Ref_t(e) { } /// Object constructor OverlayedField(const std::string& name); diff --git a/DDCore/include/DD4hep/Handle.h b/DDCore/include/DD4hep/Handle.h index 67f86716b79ae2511a6253b6adeb25c68a68f206..4dde5bd305e79686bef6b2838c440c520bc763bc 100644 --- a/DDCore/include/DD4hep/Handle.h +++ b/DDCore/include/DD4hep/Handle.h @@ -96,32 +96,19 @@ namespace DD4hep { /// Single and only data member: Reference to the actual element. T* m_element; /// Defaulot constructor - Handle() - : m_element(0) { - } + Handle() : m_element(0) { } /// Initializing constructor from pointer - Handle(T* e) - : m_element(e) { - } + Handle(T* e) : m_element(e) { } /// Copy constructor - Handle(const Handle<T>& e) - : m_element(e.m_element) { - } + Handle(const Handle<T>& e) = default; /// Initializing constructor from unrelated pointer with type checking - template <typename Q> Handle(Q* e) - : m_element((T*) e) { - verifyObject(); - } + template <typename Q> Handle(Q* e) : m_element((T*)e) + { verifyObject(); } /// Initializing constructor from unrelated handle with type checking - template <typename Q> Handle(const Handle<Q>& e) - : m_element((T*) e.m_element) { - verifyObject(); - } + template <typename Q> Handle(const Handle<Q>& e) : m_element((T*)e.m_element) + { verifyObject(); } /// Assignment operator - Handle<T>& operator=(const Handle<T>& e) { - m_element = e.m_element; - return *this; - } + Handle<T>& operator=(const Handle<T>& e) = default; /// Boolean operator == used for RB tree insertions bool operator==(const Handle<T>& e) const { return m_element == e.m_element; diff --git a/DDCore/include/DD4hep/IDDescriptor.h b/DDCore/include/DD4hep/IDDescriptor.h index f98ad930479787d343eaceb6ae09dbdcb963bbb0..6fd8fd8d9e8378d430a4cd6366d2172b79167a55 100644 --- a/DDCore/include/DD4hep/IDDescriptor.h +++ b/DDCore/include/DD4hep/IDDescriptor.h @@ -53,13 +53,9 @@ namespace DD4hep { public: /// Default constructor - IDDescriptor() - : Handle<Object>() { - } + IDDescriptor() = default; /// Constructor to be used when reading the already parsed object - template <typename Q> IDDescriptor(const Handle<Q>& e) - : Handle<Object>(e) { - } + template <typename Q> IDDescriptor(const Handle<Q>& e) : Handle<Object>(e) { } /// Initializing constructor IDDescriptor(const std::string& description); // the string description of all fields diff --git a/DDCore/include/DD4hep/PolarGridRPhi.h b/DDCore/include/DD4hep/PolarGridRPhi.h index be0cb19b208d97491dfc2e7db6c44e078c9f3bf5..45a438cea48a650607686435132b49b7e1e6fd14 100644 --- a/DDCore/include/DD4hep/PolarGridRPhi.h +++ b/DDCore/include/DD4hep/PolarGridRPhi.h @@ -29,33 +29,51 @@ namespace DD4hep { // Forward declarations class Segmentation; + /// We need some abbreviation to make the code more readable. + typedef Handle<SegmentationWrapper<DDSegmentation::PolarGridRPhi> > PolarGridRPhiHandle; + /// Implementation class for the grid XZ segmentation. /** - * \author M.Frank - * \version 1.0 - * \ingroup DD4HEP_GEOMETRY + * Concrete user handle to serve specific needs of client code + * which requires access to the base functionality not served + * by the super-class Segmentation. + * + * Note: + * We only check the validity of the underlying handle. + * If for whatever reason the implementation object is not valid + * This is not checked. + * In principle this CANNOT happen unless some brain-dead has + * fiddled with the handled object directly..... + * + * Note: + * The handle base corrsponding to this object in for + * conveniance reasons instantiated in DD4hep/src/Segmentations.cpp. + * + * \author M.Frank + * \version 1.0 + * \ingroup DD4HEP_GEOMETRY */ - class PolarGridRPhi : public Handle<DDSegmentation::PolarGridRPhi> { + class PolarGridRPhi : public PolarGridRPhiHandle { public: /// Defintiion of the basic handled object - typedef DDSegmentation::PolarGridRPhi Object; + typedef PolarGridRPhiHandle::Implementation Object; public: /// Default constructor - PolarGridRPhi() : Handle<Object>() {} - /// Copy constructor from handle - PolarGridRPhi(const Handle<Object>& e) : Handle<Object>(e) {} - /// Copy Constructor from segmentation base object - PolarGridRPhi(const Segmentation& e); + PolarGridRPhi() = default; /// Copy constructor PolarGridRPhi(const PolarGridRPhi& e) = default; + /// Copy Constructor from segmentation base object + PolarGridRPhi(const Segmentation& e) : Handle<Object>(e) {} + /// Copy constructor from handle + PolarGridRPhi(const Handle<Object>& e) : Handle<Object>(e) {} + /// Copy constructor from other polymorph/equivalent handle + template <typename Q> PolarGridRPhi(const Handle<Q>& e) : Handle<Object>(e) {} /// Assignment operator PolarGridRPhi& operator=(const PolarGridRPhi& seg) = default; /// Equality operator - bool operator==(const PolarGridRPhi& seg) const { - return m_element == seg.m_element; - } - + bool operator==(const PolarGridRPhi& seg) const + { return m_element == seg.m_element; } /// determine the position based on the cell ID Position position(const CellID& cellID) const; /// determine the cell ID based on the position diff --git a/DDCore/include/DD4hep/PolarGridRPhi2.h b/DDCore/include/DD4hep/PolarGridRPhi2.h new file mode 100644 index 0000000000000000000000000000000000000000..fa18d8e19d9d6c9889a72e23c9c6719160a744f4 --- /dev/null +++ b/DDCore/include/DD4hep/PolarGridRPhi2.h @@ -0,0 +1,111 @@ +// AIDA Detector description implementation for LCD +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// \author Markus Frank +// \date 2016-10-18 +// \version 1.0 +// +//========================================================================== +#ifndef DD4HEP_DDCORE_POLARGRIDRPHI2_H +#define DD4HEP_DDCORE_POLARGRIDRPHI2_H 1 + +// Framework include files +#include "DD4hep/Objects.h" + +/// Namespace for the AIDA detector description toolkit +namespace DD4hep { + + /// Namespace for base segmentations + namespace DDSegmentation { class PolarGridRPhi2; } + + /// Namespace for the geometry part of the AIDA detector description toolkit + namespace Geometry { + + // Forward declarations + class Segmentation; + + /// We need some abbreviation to make the code more readable. + typedef Handle<SegmentationWrapper<DDSegmentation::PolarGridRPhi2> > PolarGridRPhi2Handle; + + /// Implementation class for the grid XZ segmentation. + /** + * Concrete user handle to serve specific needs of client code + * which requires access to the base functionality not served + * by the super-class Segmentation. + * + * Note: + * We only check the validity of the underlying handle. + * If for whatever reason the implementation object is not valid + * This is not checked. + * In principle this CANNOT happen unless some brain-dead has + * fiddled with the handled object directly..... + * + * Note: + * The handle base corrsponding to this object in for + * conveniance reasons instantiated in DD4hep/src/Segmentations.cpp. + * + * \author M.Frank + * \version 1.0 + * \ingroup DD4HEP_GEOMETRY + */ + class PolarGridRPhi2 : public PolarGridRPhi2Handle { + public: + /// Defintiion of the basic handled object + typedef PolarGridRPhi2Handle::Implementation Object; + + public: + /// Default constructor + PolarGridRPhi2() = default; + /// Copy constructor + PolarGridRPhi2(const PolarGridRPhi2& e) = default; + /// Copy Constructor from segmentation base object + PolarGridRPhi2(const Segmentation& e) : Handle<Object>(e) {} + /// Copy constructor from handle + PolarGridRPhi2(const Handle<Object>& e) : Handle<Object>(e) {} + /// Copy constructor from other polymorph/equivalent handle + template <typename Q> PolarGridRPhi2(const Handle<Q>& e) : Handle<Object>(e) {} + /// Assignment operator + PolarGridRPhi2& operator=(const PolarGridRPhi2& seg) = default; + /// Equality operator + bool operator==(const PolarGridRPhi2& seg) const + { return m_element == seg.m_element; } + /// determine the position based on the cell ID + Position position(const CellID& cellID) const; + /// determine the cell ID based on the position + CellID cellID(const Position& local, const Position& global, const VolumeID& volID) const; + /// access the grid size in R + double gridSizeR() const; + /// access the grid size in Phi + double gridSizePhi() const; + /// access the coordinate offset in R + double offsetR() const; + /// access the coordinate offset in Phi + double offsetPhi() const; + /// access the grid size in R + std::vector<double> gridRValues() const; + /// access the grid size in Phi + std::vector<double> gridPhiValues() const; + /// access the field name used for R + const std::string& fieldNameR() const; + /// access the field name used for Phi + const std::string& fieldNamePhi() const; + /** \brief Returns a vector<double> of the cellDimensions of the given cell ID + in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi + + Returns a vector of the cellDimensions of the given cell ID + \param cellID is ignored as all cells have the same dimension + \return std::vector<double> size 2: + -# size in x + -# size in z + */ + std::vector<double> cellDimensions(const CellID& cellID) const; + }; + + } /* End namespace Geometry */ +} /* End namespace DD4hep */ +#endif // DD4HEP_DDCORE_POLARGRIDRPHI2_H diff --git a/DDCore/include/DD4hep/Readout.h b/DDCore/include/DD4hep/Readout.h index d51eb9a1c737d6f2842542912bbdee9cce723253..376de3da338c412a241ca7522871f143faa216d8 100644 --- a/DDCore/include/DD4hep/Readout.h +++ b/DDCore/include/DD4hep/Readout.h @@ -31,7 +31,6 @@ namespace DD4hep { namespace Geometry { // Forward declarations - class DetElement; class ReadoutObject; class HitCollection; @@ -52,36 +51,24 @@ namespace DD4hep { typedef HitCollection Collection; public: /// Default constructor - Readout() - : Handle<Object>() { - } + Readout() = default; /// Copy Constructor from object - Readout(const Readout& e) - : Handle<Object>(e) { - } + Readout(const Readout& e) = default; #ifndef __CINT__ /// Copy Constructor from handle - Readout(const Handle<ReadoutObject>& e) - : Handle<Object>(e) { - } + Readout(const Handle<ReadoutObject>& e) : Handle<Object>(e) { } #endif /// Constructor to be used when reading the already parsed object - template <typename Q> Readout(const Handle<Q>& e) - : Handle<Object>(e) { - } + template <typename Q> Readout(const Handle<Q>& e) : Handle<Object>(e) { } /// Initializing constructor Readout(const std::string& name); /// Assignment operator - Readout& operator=(const Readout& ro) { - if ( &ro == this ) return *this; - m_element = ro.m_element; - return *this; - } + Readout& operator=(const Readout& ro) = default; /// Access explicit names of hit collections if present std::vector<std::string> collectionNames() const; #ifndef __CINT__ /// Access hit collections if present - std::vector<const HitCollection*> collections() const; + std::vector<const Collection*> collections() const; #endif /// Access number of hit collections size_t numCollections() const; diff --git a/DDCore/include/DD4hep/Segmentations.h b/DDCore/include/DD4hep/Segmentations.h index 0ae355c389cf4ebecbeb61476c9bb4723365fd8a..11012e377a8000c5a0b1e977fe0319d1f9c77ef2 100644 --- a/DDCore/include/DD4hep/Segmentations.h +++ b/DDCore/include/DD4hep/Segmentations.h @@ -17,9 +17,7 @@ // Framework include files #include "DD4hep/Objects.h" #include "DD4hep/Handle.h" -#include "DD4hep/IDDescriptor.h" #include "DDSegmentation/Segmentation.h" -#include "DDSegmentation/SegmentationFactory.h" // C/C++ include files #include <cmath> @@ -37,15 +35,18 @@ namespace DD4hep { /// Implementation class supporting generic Segmentation of sensitive detectors /** - * \author M.Frank - * \version 1.0 - * \ingroup DD4HEP_GEOMETRY + * The SegmentationObject wraps the functionality of the DDSegmentation base class. + * + * \author M.Frank + * \version 1.0 + * \ingroup DD4HEP_GEOMETRY */ - class SegmentationObject /* : public DDSegmentation::Segmentation */ { + class SegmentationObject { public: typedef DDSegmentation::Segmentation BaseSegmentation; - typedef DDSegmentation::Parameters Parameters; - typedef DDSegmentation::Parameter Parameter; + typedef DDSegmentation::Parameters Parameters; + typedef DDSegmentation::Parameter Parameter; + public: /// Standard constructor SegmentationObject(BaseSegmentation* s = 0); @@ -62,11 +63,11 @@ namespace DD4hep { /// Access the description of the segmentation const std::string& description() const; /// Access the underlying decoder - BitField64* decoder(); + BitField64* decoder() const; /// Set the underlying decoder - void setDecoder(BitField64* decoder); + void setDecoder(BitField64* decoder) const; /// Access to parameter by name - Parameter parameter(const std::string& parameterName) const; + Parameter parameter(const std::string& parameterName) const; /// Access to all parameters Parameters parameters() const; /// Set all parameters from an existing set of parameters @@ -102,30 +103,26 @@ namespace DD4hep { * \version 1.0 * \ingroup DD4HEP_GEOMETRY */ - template <typename IMP> class SegmentationImplementation : public SegmentationObject { + template <typename IMP> class SegmentationWrapper : public SegmentationObject { public: /// DDSegmentation aggregate - IMP implementation; + IMP* implementation; public: /// Standard constructor - SegmentationImplementation(DDSegmentation::BitField64* decoder); + SegmentationWrapper(DDSegmentation::BitField64* decoder); /// Default destructor - virtual ~SegmentationImplementation(); + virtual ~SegmentationWrapper(); }; /// Standard constructor template <typename IMP> inline - SegmentationImplementation<IMP>::SegmentationImplementation(DDSegmentation::BitField64* decode) - : SegmentationObject(0), implementation(decode) + SegmentationWrapper<IMP>::SegmentationWrapper(DDSegmentation::BitField64* decode) + : SegmentationObject(implementation=new IMP(decode)) { - this->segmentation = &implementation; } /// Default destructor - template <typename IMP> inline - SegmentationImplementation<IMP>::~SegmentationImplementation() - { - this->segmentation = 0; // Prevent deletion! We have the object aggregated! + template <typename IMP> inline SegmentationWrapper<IMP>::~SegmentationWrapper() { } /// Handle class supporting generic Segmentation of sensitive detectors @@ -146,36 +143,32 @@ namespace DD4hep { /// Initializing constructor creating a new object of the given DDSegmentation type Segmentation(const std::string& type, const std::string& name, BitField64* decoder); /// Default constructor - Segmentation() : Handle<Object>() { } + Segmentation() : Handle<Object>() { } /// Copy Constructor from object - Segmentation(const Segmentation& e) : Handle<Object>(e) { } + Segmentation(const Segmentation& e) : Handle<Object>(e) { } #ifndef __CINT__ /// Copy Constructor from handle Segmentation(const Handle<Object>& e) : Handle<Object>(e) { } #endif /// Constructor to be used when reading the already parsed object - template <typename Q> Segmentation(const Handle<Q>& e) - : Handle<Implementation>(e) { - } + template <typename Q> + Segmentation(const Handle<Q>& e) : Handle<Object>(e) { } /// Assignment operator - Segmentation& operator=(const Segmentation& seg) { - if ( &seg == this ) return *this; - m_element = seg.m_element; - return *this; - } + Segmentation& operator=(const Segmentation& seg) = default; /// Access flag for hit positioning bool useForHitPosition() const; /// Accessor: Segmentation type std::string type() const; - /// Access segmentation object - BaseSegmentation* segmentation() const; /// Access to the parameters Parameters parameters() const; + /// Access the underlying decoder + BitField64* decoder() const; + /// Set the underlying decoder + void setDecoder(BitField64* decoder) const; /// determine the local position based on the cell ID Position position(const long64& cellID) const; /// determine the cell ID based on the local position long64 cellID(const Position& localPosition, const Position& globalPosition, const long64& volumeID) const; - /// Access the concrete underlying segmentation implementation from DDSegmentation template <typename T> static T* get(const Object* object); }; diff --git a/DDCore/include/DD4hep/Shapes.h b/DDCore/include/DD4hep/Shapes.h index 4fb0af492f5f7628efb3898cb833f61eefe014a2..0e0f14aed63edbe77f070549acd875059bcbef58 100644 --- a/DDCore/include/DD4hep/Shapes.h +++ b/DDCore/include/DD4hep/Shapes.h @@ -77,38 +77,25 @@ namespace DD4hep { public: /// Default constructor for uninitialized object - Solid_type() - : Handle<T>() { - } - + Solid_type() = default; + /// Constructor to be used when passing an already created object + Solid_type(const Solid_type& e) = default; /// Direct assignment using the implementation pointer - Solid_type(T* p) - : Handle<T>(p) { - } - + Solid_type(T* p) : Handle<T>(p) { } /// Constructor to be used when passing an already created object - Solid_type(const Handle<T>& e) - : Handle<T>(e) { - } - + Solid_type(const Handle<T>& e) : Handle<T>(e) { } /// Constructor to be used when passing an already created object: need to check pointers - template <typename Q> Solid_type(const Handle<Q>& e) - : Handle<T>(e) { - } - + template <typename Q> Solid_type(const Handle<Q>& e) : Handle<T>(e) { } /// Access to shape name const char* name() const; - /// Auto conversion to underlying ROOT object operator T*() const { return this->m_element; } - /// Overloaded operator -> to access underlying object T* operator->() const { return this->m_element; } - /// Conversion to string for pretty print std::string toString(int precision=2) const { return toStringSolid(this->m_element,precision); @@ -132,36 +119,29 @@ namespace DD4hep { void make(double x_val, double y_val, double z_val); public: + /// Default constructor + Box() = default; + /// Constructor to be used when passing an already created object + Box(const Box& e) = default; /// Constructor to be used with an existing object - template <typename Q> Box(const Q* p) - : Solid_type<TGeoBBox>(p) { - } - + template <typename Q> Box(const Q* p) : Solid_type<TGeoBBox>(p) { } /// Constructor to be used with an existing object - template <typename Q> Box(const Handle<Q>& e) - : Solid_type<TGeoBBox>(e) { - } - + template <typename Q> Box(const Handle<Q>& e) : Solid_type<TGeoBBox>(e) { } /// Constructor to create an anonymous new box object (retrieves name from volume) Box(double x_val, double y_val, double z_val) { make(x_val, y_val, z_val); } - /// Constructor to create an anonymous new box object (retrieves name from volume) template <typename X, typename Y, typename Z> Box(const X& x_val, const Y& y_val, const Z& z_val) { make(_toDouble(x_val), _toDouble(y_val), _toDouble(z_val)); } - /// Set the box dimensions Box& setDimensions(double x_val, double y_val, double z_val); - /// Access half "length" of the box double x() const; - /// Access half "width" of the box double y() const; - /// Access half "depth" of the box double z() const; }; @@ -182,16 +162,14 @@ namespace DD4hep { void make(const double* const point, const double* const normal); public: + /// Default constructor + HalfSpace() = default; + /// Constructor to be used when passing an already created object + HalfSpace(const HalfSpace& e) = default; /// Constructor to be used with an existing object - template <typename Q> HalfSpace(const Q* p) - : Solid_type<TGeoHalfSpace>(p) { - } - + template <typename Q> HalfSpace(const Q* p) : Solid_type<TGeoHalfSpace>(p) { } /// Constructor to be used with an existing object - template <typename Q> HalfSpace(const Handle<Q>& e) - : Solid_type<TGeoHalfSpace>(e) { - } - + template <typename Q> HalfSpace(const Handle<Q>& e) : Solid_type<TGeoHalfSpace>(e) { } /// Constructor to create an new halfspace object from a point on a plane and the plane normal HalfSpace(const double* const point, const double* const normal) { make(point,normal); @@ -218,16 +196,14 @@ namespace DD4hep { */ class Polycone: public Solid_type<TGeoPcon> { public: + /// Default constructor + Polycone() = default; + /// Constructor to be used when passing an already created object + Polycone(const Polycone& e) = default; /// Constructor to be used with an existing object - template <typename Q> Polycone(const Q* p) - : Solid_type<TGeoPcon>(p) { - } - + template <typename Q> Polycone(const Q* p) : Solid_type<TGeoPcon>(p) { } /// Constructor to be used when reading the already parsed polycone object - template <typename Q> Polycone(const Handle<Q>& e) - : Solid_type<TGeoPcon>(e) { - } - + template <typename Q> Polycone(const Handle<Q>& e) : Solid_type<TGeoPcon>(e) { } /// Constructor to create a new polycone object Polycone(double start, double delta); @@ -253,39 +229,29 @@ namespace DD4hep { */ class ConeSegment: public Solid_type<TGeoConeSeg> { public: + /// Default constructor + ConeSegment() = default; + /// Constructor to be used when passing an already created object + ConeSegment(const ConeSegment& e) = default; /// Constructor to be used with an existing object - template <typename Q> ConeSegment(const Q* p) - : Solid_type<TGeoConeSeg>(p) { - } - + template <typename Q> ConeSegment(const Q* p) : Solid_type<TGeoConeSeg>(p) { } /// Constructor to be used when reading the already parsed ConeSegment object - template <typename Q> ConeSegment(const Handle<Q>& e) - : Solid_type<TGeoConeSeg>(e) { - } - + template <typename Q> ConeSegment(const Handle<Q>& e) : Solid_type<TGeoConeSeg>(e) { } /// Constructor to create a new ConeSegment object - ConeSegment(double dz, double rmin1, double rmax1, double rmin2, double rmax2, double phi1 = 0.0, - double phi2 = 2.0 * M_PI); + ConeSegment(double dz, double rmin1, double rmax1, double rmin2, double rmax2, double phi1 = 0.0, double phi2 = 2.0 * M_PI); /// Set the cone segment dimensions - ConeSegment& setDimensions(double dz, double rmin1, double rmax1, double rmin2, double rmax2, double phi1 = 0.0, - double phi2 = 2.0 * M_PI); + ConeSegment& setDimensions(double dz, double rmin1, double rmax1, + double rmin2, double rmax2, double phi1 = 0.0, double phi2 = 2.0 * M_PI); }; /// Intermediate class to overcome drawing probles with the TGeoTubeSeg class MyConeSeg: public TGeoConeSeg { public: - MyConeSeg() - : TGeoConeSeg() { - } - virtual ~MyConeSeg() { - } - double GetRmin() const { - return GetRmin1(); - } - double GetRmax() const { - return GetRmax1(); - } + MyConeSeg() : TGeoConeSeg() { } + virtual ~MyConeSeg() { } + double GetRmin() const { return GetRmin1(); } + double GetRmax() const { return GetRmax1(); } }; /// Class describing a tube shape of a section of a tube @@ -306,46 +272,33 @@ namespace DD4hep { void make(const std::string& nam, double rmin, double rmax, double z, double startPhi, double deltaPhi); public: + /// Default constructor + Tube() = default; + /// Constructor to be used when passing an already created object + Tube(const Tube& e) = default; /// Constructor to be used with an existing object - template <typename Q> Tube(const Q* p) : Solid_type<MyConeSeg>(p) { - } - + template <typename Q> Tube(const Q* p) : Solid_type<MyConeSeg>(p) { } /// Constructor to assign an object - template <typename Q> Tube(const Handle<Q>& e) - : Solid_type<MyConeSeg>(e) { - } - + template <typename Q> Tube(const Handle<Q>& e) : Solid_type<MyConeSeg>(e) { } /// Constructor to create a new anonymous tube object with attribute initialization - Tube(double rmin, double rmax, double z) { - make("", rmin, rmax, z, 0, 2*M_PI); - } - + Tube(double rmin, double rmax, double z) + { make("", rmin, rmax, z, 0, 2*M_PI); } /// Constructor to create a new anonymous tube object with attribute initialization - Tube(double rmin, double rmax, double z, double deltaPhi) { - make("", rmin, rmax, z, 0, deltaPhi); - } - + Tube(double rmin, double rmax, double z, double deltaPhi) + { make("", rmin, rmax, z, 0, deltaPhi); } /// Constructor to create a new anonymous tube object with attribute initialization - Tube(double rmin, double rmax, double z, double startPhi, double deltaPhi) { - make("", rmin, rmax, z, startPhi, deltaPhi); - } - + Tube(double rmin, double rmax, double z, double startPhi, double deltaPhi) + { make("", rmin, rmax, z, startPhi, deltaPhi); } /// Legacy: Constructor to create a new identifiable tube object with attribute initialization - Tube(const std::string& nam, double rmin, double rmax, double z) { - make(nam, rmin, rmax, z, 0, 2*M_PI); - } - + Tube(const std::string& nam, double rmin, double rmax, double z) + { make(nam, rmin, rmax, z, 0, 2*M_PI); } /// Legacy: Constructor to create a new identifiable tube object with attribute initialization - Tube(const std::string& nam, double rmin, double rmax, double z, double deltaPhi) { - make(nam, rmin, rmax, z, 0, deltaPhi); - } - + Tube(const std::string& nam, double rmin, double rmax, double z, double deltaPhi) + { make(nam, rmin, rmax, z, 0, deltaPhi); } /// Constructor to create a new anonymous tube object with attribute initialization template <typename RMIN, typename RMAX, typename Z, typename DELTAPHI> - Tube(const RMIN& rmin, const RMAX& rmax, const Z& z, const DELTAPHI& deltaPhi) { - make("", _toDouble(rmin), _toDouble(rmax), _toDouble(z), 0, _toDouble(deltaPhi)); - } - + Tube(const RMIN& rmin, const RMAX& rmax, const Z& z, const DELTAPHI& deltaPhi) + { make("", _toDouble(rmin), _toDouble(rmax), _toDouble(z), 0, _toDouble(deltaPhi)); } /// Set the tube dimensions Tube& setDimensions(double rmin, double rmax, double z, double startPhi=0.0, double deltaPhi=2*M_PI); }; @@ -368,21 +321,20 @@ namespace DD4hep { void make(double a, double b, double dz); public: + /// Default constructor + EllipticalTube() = default; + /// Constructor to be used when passing an already created object + EllipticalTube(const EllipticalTube& e) = default; /// Constructor to be used with an existing object template <typename Q> EllipticalTube(const Q* p) : Solid_type<TGeoEltu>(p) { } - /// Constructor to assign an object template <typename Q> EllipticalTube(const Handle<Q>& e) : Solid_type<TGeoEltu>(e) { } - /// Constructor to create a new anonymous tube object with attribute initialization EllipticalTube(double a, double b, double dz) { make(a, b, dz); } - /// Constructor to create a new anonymous tube object with attribute initialization template <typename A, typename B, typename DZ> - EllipticalTube(const A& a, const B& b, const DZ& dz) { - make(_toDouble(a), _toDouble(b), _toDouble(dz)); - } - + EllipticalTube(const A& a, const B& b, const DZ& dz) + { make(_toDouble(a), _toDouble(b), _toDouble(dz)); } /// Set the tube dimensions EllipticalTube& setDimensions(double a, double b, double dz); }; @@ -400,28 +352,21 @@ namespace DD4hep { protected: /// Internal helper method to support object construction void make(double z, double rmin1, double rmax1, double rmin2, double rmax2); - public: + /// Default constructor + Cone() = default; + /// Constructor to be used when passing an already created object + Cone(const Cone& e) = default; /// Constructor to be used with an existing object - template <typename Q> Cone(const Q* p) - : Solid_type<TGeoCone>(p) { - } - + template <typename Q> Cone(const Q* p) : Solid_type<TGeoCone>(p) { } /// Constructor to be used when passing an already created object - template <typename Q> Cone(const Handle<Q>& e) - : Solid_type<TGeoCone>(e) { - } - + template <typename Q> Cone(const Handle<Q>& e) : Solid_type<TGeoCone>(e) { } /// Constructor to create a new anonymous object with attribute initialization - Cone(double z, double rmin1, double rmax1, double rmin2, double rmax2) { - make(z, rmin1, rmax1, rmin2, rmax2); - } - + Cone(double z, double rmin1, double rmax1, double rmin2, double rmax2) + { make(z, rmin1, rmax1, rmin2, rmax2); } template <typename Z, typename RMIN1, typename RMAX1, typename RMIN2, typename RMAX2> - Cone(const Z& z, const RMIN1& rmin1, const RMAX1& rmax1, const RMIN2& rmin2, const RMAX2& rmax2) { - make(_toDouble(z), _toDouble(rmin1), _toDouble(rmax1), _toDouble(rmin2), _toDouble(rmax2)); - } - + Cone(const Z& z, const RMIN1& rmin1, const RMAX1& rmax1, const RMIN2& rmin2, const RMAX2& rmax2) + { make(_toDouble(z), _toDouble(rmin1), _toDouble(rmax1), _toDouble(rmin2), _toDouble(rmax2)); } /// Set the box dimensions Cone& setDimensions(double z, double rmin1, double rmax1, double rmin2, double rmax2); }; @@ -439,33 +384,24 @@ namespace DD4hep { private: /// Internal helper method to support object construction void make(double pz, double py, double px, double pLTX); - public: - /// Constructor to be used with an existing object - template <typename Q> Trap(const Q* p) - : Solid_type<TGeoTrap>(p) { - } - + /// Default constructor + Trap() = default; /// Constructor to be used when passing an already created object - Trap(const Trap& e) - : Solid_type<TGeoTrap>(e) { - } + Trap(const Trap& e) = default; + /// Constructor to be used with an existing object + template <typename Q> Trap(const Q* p) : Solid_type<TGeoTrap>(p) { } /// Constructor to be used when passing an already created object - template <typename Q> Trap(const Handle<Q>& e) - : Solid_type<TGeoTrap>(e) { - } - + template <typename Q> Trap(const Handle<Q>& e) : Solid_type<TGeoTrap>(e) { } /// Constructor to create a new anonymous object with attribute initialization - Trap(double z, double theta, double phi, double y1, double x1, double x2, double alpha1, double y2, double x3, double x4, - double alpha2); - + Trap(double z, double theta, double phi, + double y1, double x1, double x2, double alpha1, + double y2, double x3, double x4, double alpha2); /// Constructor to create a new anonymous object for right angular wedge from STEP (Se G4 manual for details) Trap(double pz, double py, double px, double pLTX) { make(pz,py,px,pLTX); } - /// Constructor to create a new anonymous object with attribute initialization template <typename PZ,typename PY,typename PX,typename PLTX> Trap(PZ pz, PY py, PX px, PLTX pLTX) { make(_toDouble(pz),_toDouble(py),_toDouble(px),_toDouble(pLTX)); } - /// Set the trap dimensions Trap& setDimensions(double z, double theta, double phi, double y1, double x1, double x2, double alpha1, @@ -488,25 +424,20 @@ namespace DD4hep { void make(double x1, double x2, double y1, double y2, double z); public: - /// Constructor to be used with an existing object - template <typename Q> Trapezoid(const Q* p) : Solid_type<TGeoTrd2>(p) { } - + /// Default constructor + Trapezoid() = default; /// Constructor to be used when passing an already created object - Trapezoid(const Trapezoid& e) : Solid_type<TGeoTrd2>(e) { } - + Trapezoid(const Trapezoid& e) = default; + /// Constructor to be used with an existing object + template <typename Q> Trapezoid(const Q* p) : Solid_type<TGeoTrd2>(p) { } /// Constructor to be used when passing an already created object - template <typename Q> Trapezoid(const Handle<Q>& e) - : Solid_type<TGeoTrd2>(e) { - } - + template <typename Q> Trapezoid(const Handle<Q>& e) : Solid_type<TGeoTrd2>(e) { } /// Constructor to create a new anonymous object with attribute initialization Trapezoid(double x1, double x2, double y1, double y2, double z); - /// Constructor to create a new anonymous object with attribute initialization template <typename X1,typename X2,typename Y1,typename Y2,typename Z> Trapezoid(X1 x1, X2 x2, Y1 y1, Y2 y2, Z z) { make(_toDouble(x1),_toDouble(x2),_toDouble(y1),_toDouble(y2),_toDouble(z)); } - /// Set the Trapezoid dimensions Trapezoid& setDimensions(double x1, double x2, double y1, double y2, double z); }; @@ -525,30 +456,21 @@ namespace DD4hep { /// Internal helper method to support object construction void make(double r, double rmin, double rmax, double phi, double delta_phi); public: - /// Constructor to be used with an existing object - template <typename Q> Torus(const Q* p) - : Solid_type<TGeoTorus>(p) { - } - + /// Default constructor + Torus() = default; /// Constructor to be used when passing an already created object - Torus(const Torus& e) - : Solid_type<TGeoTorus>(e) { - } - + Torus(const Torus& e) = default; + /// Constructor to be used with an existing object + template <typename Q> Torus(const Q* p) : Solid_type<TGeoTorus>(p) { } /// Constructor to be used when passing an already created object - template <typename Q> Torus(const Handle<Q>& e) - : Solid_type<TGeoTorus>(e) { - } - + template <typename Q> Torus(const Handle<Q>& e) : Solid_type<TGeoTorus>(e) { } /// Constructor to create a new anonymous object with attribute initialization template<typename R, typename RMIN, typename RMAX, typename PHI, typename DELTA_PHI> Torus(R r, RMIN rmin, RMAX rmax, PHI phi=M_PI, DELTA_PHI delta_phi = 2.*M_PI) { make(_toDouble(r),_toDouble(rmin),_toDouble(rmax),_toDouble(phi),_toDouble(delta_phi)); } - /// Constructor to create a new anonymous object with attribute initialization Torus(double r, double rmin, double rmax, double phi=M_PI, double delta_phi = 2.*M_PI) { make(r,rmin,rmax,phi,delta_phi); } - /// Set the Torus dimensions Torus& setDimensions(double r, double rmin, double rmax, double phi, double delta_phi); }; @@ -565,24 +487,16 @@ namespace DD4hep { */ class Sphere: public Solid_type<TGeoSphere> { public: - /// Constructor to be used with an existing object - template <typename Q> Sphere(const Q* p) - : Solid_type<TGeoSphere>(p) { - } - + /// Default constructor + Sphere() = default; /// Constructor to be used when passing an already created object - Sphere(const Sphere& e) - : Solid_type<TGeoSphere>(e) { - } - + Sphere(const Sphere& e) = default; + /// Constructor to be used with an existing object + template <typename Q> Sphere(const Q* p) : Solid_type<TGeoSphere>(p) { } /// Constructor to be used when passing an already created object - template <typename Q> Sphere(const Handle<Q>& e) - : Solid_type<TGeoSphere>(e) { - } - + template <typename Q> Sphere(const Handle<Q>& e) : Solid_type<TGeoSphere>(e) { } /// Constructor to create a new anonymous object with attribute initialization Sphere(double rmin, double rmax, double theta = 0., double delta_theta = M_PI, double phi = 0.0, double delta_phi = 2. * M_PI); - /// Set the Sphere dimensions Sphere& setDimensions(double rmin, double rmax, double theta, double delta_theta, double phi, double delta_phi); }; @@ -599,24 +513,16 @@ namespace DD4hep { */ class Paraboloid: public Solid_type<TGeoParaboloid> { public: - /// Constructor to be used with an existing object - template <typename Q> Paraboloid(const Q* p) - : Solid_type<TGeoParaboloid>(p) { - } - + /// Default constructor + Paraboloid() = default; /// Constructor to be used when passing an already created object - Paraboloid(const Paraboloid& e) - : Solid_type<TGeoParaboloid>(e) { - } - + Paraboloid(const Paraboloid& e) = default; + /// Constructor to be used with an existing object + template <typename Q> Paraboloid(const Q* p) : Solid_type<TGeoParaboloid>(p) { } /// Constructor to be used when passing an already created object - template <typename Q> Paraboloid(const Handle<Q>& e) - : Solid_type<TGeoParaboloid>(e) { - } - + template <typename Q> Paraboloid(const Handle<Q>& e) : Solid_type<TGeoParaboloid>(e) { } /// Constructor to create a new anonymous object with attribute initialization Paraboloid(double r_low, double r_high, double delta_z); - /// Set the Paraboloid dimensions Paraboloid& setDimensions(double r_low, double r_high, double delta_z); }; @@ -633,18 +539,16 @@ namespace DD4hep { */ class Hyperboloid: public Solid_type<TGeoHype> { public: + /// Default constructor + Hyperboloid() = default; + /// Constructor to be used when passing an already created object + Hyperboloid(const Hyperboloid& e) = default; /// Constructor to be used with an existing object template <typename Q> Hyperboloid(const Q* p) : Solid_type<TGeoHype>(p) { } - - /// Constructor to be used when passing an already created object - Hyperboloid(const Hyperboloid& e) : Solid_type<TGeoHype>(e) { } - /// Constructor to be used when passing an already created object template <typename Q> Hyperboloid(const Handle<Q>& e) : Solid_type<TGeoHype>(e) { } - /// Constructor to create a new anonymous object with attribute initialization Hyperboloid(double rin, double stin, double rout, double stout, double dz); - /// Set the Hyperboloid dimensions Hyperboloid& setDimensions(double rin, double stin, double rout, double stout, double dz); }; @@ -663,22 +567,14 @@ namespace DD4hep { /// Helper function to create the polyhedron void _create(int nsides, double rmin, double rmax, double zpos, double zneg, double start, double delta); public: - /// Constructor to be used with an existing object - template <typename Q> PolyhedraRegular(const Q* p) - : Solid_type<TGeoPgon>(p) { - } - + /// Default constructor + PolyhedraRegular() = default; /// Constructor to be used when passing an already created object - PolyhedraRegular(const PolyhedraRegular& e) - : Solid_type<TGeoPgon>(e) { - } - + PolyhedraRegular(const PolyhedraRegular& e) = default; + /// Constructor to be used with an existing object + template <typename Q> PolyhedraRegular(const Q* p) : Solid_type<TGeoPgon>(p) { } /// Constructor to be used when passing an already created object - template <typename Q> - PolyhedraRegular(const Handle<Q>& e) - : Solid_type<TGeoPgon>(e) { - } - + template <typename Q> PolyhedraRegular(const Handle<Q>& e) : Solid_type<TGeoPgon>(e) { } /// Constructor to create a new object. Phi(start)=0, deltaPhi=2PI, Z-planes at -zlen/2 and +zlen/2 PolyhedraRegular(int nsides, double rmin, double rmax, double zlen); /// Constructor to create a new object. Phi(start)=0, deltaPhi=2PI, Z-planes a zplanes[0] and zplanes[1] @@ -700,23 +596,15 @@ namespace DD4hep { private: /// Internal helper method to support object construction void make(double dz, const double* vtx); - public: - /// Constructor to be used with an existing object - template <typename Q> EightPointSolid(const Q* p) - : Solid_type<TGeoArb8>(p) { - } - + /// Default constructor + EightPointSolid() = default; /// Constructor to be used when passing an already created object - EightPointSolid(const EightPointSolid& e) - : Solid_type<TGeoArb8>(e) { - } - + EightPointSolid(const EightPointSolid& e) = default; + /// Constructor to be used with an existing object + template <typename Q> EightPointSolid(const Q* p) : Solid_type<TGeoArb8>(p) { } /// Constructor to be used when passing an already created object - template <typename Q> EightPointSolid(const Handle<Q>& e) - : Solid_type<TGeoArb8>(e) { - } - + template <typename Q> EightPointSolid(const Handle<Q>& e) : Solid_type<TGeoArb8>(e) {} /// Constructor to create a new anonymous object with attribute initialization EightPointSolid(double dz, const double* vertices) { make(dz,vertices); } }; @@ -732,17 +620,15 @@ namespace DD4hep { */ class BooleanSolid: public Solid_type<TGeoCompositeShape> { protected: + /// Default constructor + BooleanSolid() = default; /// Constructor to be used when passing an already created object - BooleanSolid() - : Solid_type<TGeoCompositeShape>() { - } - + BooleanSolid(const BooleanSolid& b) = default; + public: /// Constructor to be used when passing an already created object template <typename Q> - BooleanSolid(const Handle<Q>& e) - : Solid_type<TGeoCompositeShape>(e) { - } + BooleanSolid(const Handle<Q>& e) : Solid_type<TGeoCompositeShape>(e) { } }; /// Class describing boolean subtraction solid @@ -758,17 +644,11 @@ namespace DD4hep { class SubtractionSolid: public BooleanSolid { public: /// Default constructor - SubtractionSolid() - : BooleanSolid() { - } + SubtractionSolid() = default; /// Constructor to be used when passing an already created object - SubtractionSolid(const SubtractionSolid& e) - : BooleanSolid(e) { - } + SubtractionSolid(const SubtractionSolid& e) = default; /// Constructor to be used when passing an already created object - template <typename Q> SubtractionSolid(const Handle<Q>& e) - : BooleanSolid(e) { - } + template <typename Q> SubtractionSolid(const Handle<Q>& e) : BooleanSolid(e) { } /// Constructor to create a new object. Position is identity, Rotation is identity-rotation! SubtractionSolid(const Solid& shape1, const Solid& shape2); /// Constructor to create a new object. Placement by position, Rotation is identity-rotation! @@ -794,17 +674,11 @@ namespace DD4hep { class UnionSolid: public BooleanSolid { public: /// Default constructor - UnionSolid() - : BooleanSolid() { - } + UnionSolid() = default; /// Constructor to be used when passing an already created object - UnionSolid(const UnionSolid& e) - : BooleanSolid(e) { - } + UnionSolid(const UnionSolid& e) = default; /// Constructor to be used when passing an already created object - template <typename Q> UnionSolid(const Handle<Q>& e) - : BooleanSolid(e) { - } + template <typename Q> UnionSolid(const Handle<Q>& e) : BooleanSolid(e) { } /// Constructor to create a new object. Position is identity, Rotation is identity-rotation! UnionSolid(const Solid& shape1, const Solid& shape2); /// Constructor to create a new object. Placement by position, Rotation is identity-rotation! @@ -830,17 +704,11 @@ namespace DD4hep { class IntersectionSolid: public BooleanSolid { public: /// Default constructor - IntersectionSolid() - : BooleanSolid() { - } + IntersectionSolid() = default; /// Constructor to be used when passing an already created object - IntersectionSolid(const IntersectionSolid& e) - : BooleanSolid(e) { - } + IntersectionSolid(const IntersectionSolid& e) = default; /// Constructor to be used when passing an already created object - template <typename Q> IntersectionSolid(const Handle<Q>& e) - : BooleanSolid(e) { - } + template <typename Q> IntersectionSolid(const Handle<Q>& e) : BooleanSolid(e) { } /// Constructor to create a new object. Position is identity, Rotation is identity-rotation! IntersectionSolid(const Solid& shape1, const Solid& shape2); /// Constructor to create a new object. Placement by position, Rotation is identity-rotation! diff --git a/DDCore/include/DD4hep/WaferGridXY.h b/DDCore/include/DD4hep/WaferGridXY.h new file mode 100644 index 0000000000000000000000000000000000000000..e189a52338ce29e23c20b473aa9cf64ed2414f6b --- /dev/null +++ b/DDCore/include/DD4hep/WaferGridXY.h @@ -0,0 +1,111 @@ +// AIDA Detector description implementation for LCD +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// \author Markus Frank +// \date 2016-10-18 +// \version 1.0 +// +//========================================================================== +#ifndef DD4HEP_DDCORE_WAFERGRIDZY_H +#define DD4HEP_DDCORE_WAFERGRIDZY_H 1 + +// Framework include files +#include "DD4hep/Objects.h" + +/// Namespace for the AIDA detector description toolkit +namespace DD4hep { + + /// Namespace for base segmentations + namespace DDSegmentation { class WaferGridXY; } + + /// Namespace for the geometry part of the AIDA detector description toolkit + namespace Geometry { + + // Forward declarations + class Segmentation; + + /// We need some abbreviation to make the code more readable. + typedef Handle<SegmentationWrapper<DDSegmentation::WaferGridXY> > WaferGridXYHandle; + + /// Implementation class for the grid XZ segmentation. + /** + * Concrete user handle to serve specific needs of client code + * which requires access to the base functionality not served + * by the super-class Segmentation. + * + * Note: + * We only check the validity of the underlying handle. + * If for whatever reason the implementation object is not valid + * This is not checked. + * In principle this CANNOT happen unless some brain-dead has + * fiddled with the handled object directly..... + * + * Note: + * The handle base corrsponding to this object in for + * conveniance reasons instantiated in DD4hep/src/Segmentations.cpp. + * + * \author M.Frank + * \version 1.0 + * \ingroup DD4HEP_GEOMETRY + */ + class WaferGridXY : public WaferGridXYHandle { + public: + /// Defintiion of the basic handled object + typedef WaferGridXYHandle::Implementation Object; + + public: + /// Default constructor + WaferGridXY() = default; + /// Copy constructor + WaferGridXY(const WaferGridXY& e) = default; + /// Copy Constructor from segmentation base object + WaferGridXY(const Segmentation& e) : Handle<Object>(e) {} + /// Copy constructor from handle + WaferGridXY(const Handle<Object>& e) : Handle<Object>(e) {} + /// Copy constructor from other polymorph/equivalent handle + template <typename Q> WaferGridXY(const Handle<Q>& e) : Handle<Object>(e) {} + /// Assignment operator + WaferGridXY& operator=(const WaferGridXY& seg) = default; + /// Equality operator + bool operator==(const WaferGridXY& seg) const + { return m_element == seg.m_element; } + /// determine the position based on the cell ID + Position position(const CellID& cellID) const; + /// determine the cell ID based on the position + CellID cellID(const Position& local, const Position& global, const VolumeID& volID) const; + /// access the grid size in X + double gridSizeX() const; + /// access the grid size in Y + double gridSizeY() const; + /// access the coordinate offset in X + double offsetX() const; + /// access the coordinate offset in Y + double offsetY() const; + /// access the coordinate waferOffset for inGroup in X + double waferOffsetX(int inGroup, int inWafer) const; + /// access the coordinate waferOffset for inGroup in Y + double waferOffsetY(int inGroup, int inWafer) const; + /// access the field name used for X + const std::string& fieldNameX() const; + /// access the field name used for Y + const std::string& fieldNameY() const; + /** \brief Returns a vector<double> of the cellDimensions of the given cell ID + in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi + + Returns a vector of the cellDimensions of the given cell ID + \param cellID is ignored as all cells have the same dimension + \return std::vector<double> size 2: + -# size in x + -# size in z + */ + std::vector<double> cellDimensions(const CellID& cellID) const; + }; + + } /* End namespace Geometry */ +} /* End namespace DD4hep */ +#endif // DD4HEP_DDCORE_WAFERGRIDZY_H diff --git a/DDCore/include/DD4hep/objects/ObjectsInterna.h b/DDCore/include/DD4hep/objects/ObjectsInterna.h index d75eb9c60ade1eaa2ffe2034a926a22b4f239ad1..f106e98386821fb3ff139d0b8b349fdbdb360f15 100644 --- a/DDCore/include/DD4hep/objects/ObjectsInterna.h +++ b/DDCore/include/DD4hep/objects/ObjectsInterna.h @@ -18,6 +18,7 @@ // Framework include files #include "DD4hep/Volumes.h" #include "DD4hep/NamedObject.h" +#include "DD4hep/IDDescriptor.h" #include "DD4hep/Segmentations.h" #include "DDSegmentation/BitField64.h" @@ -150,7 +151,7 @@ namespace DD4hep { /// Range values of the key is not empty. long key_min, key_max; /// Default constructor - HitCollection() {} + HitCollection() : key_min(~0x0), key_max(~0x0) {} /// Copy constructor HitCollection(const HitCollection& c); /// Initializing constructor diff --git a/DDCore/src/CartesianGridXY.cpp b/DDCore/src/CartesianGridXY.cpp index 0222d229ed86dc1a8a9936b6758e9635a827f390..b72996f098e1f00d52298110fa1608535c2e9dde 100644 --- a/DDCore/src/CartesianGridXY.cpp +++ b/DDCore/src/CartesianGridXY.cpp @@ -21,15 +21,9 @@ using namespace std; using namespace DD4hep::Geometry; -/// Copy Constructor from segmentation base object -CartesianGridXY::CartesianGridXY(const Segmentation& e) : Handle<Object>() -{ - m_element = Segmentation::get<Object>(e.ptr()); -} - /// determine the position based on the cell ID Position CartesianGridXY::position(const CellID& id) const { - return Position(access()->position(id)); + return Position(access()->implementation->position(id)); } /// determine the cell ID based on the position @@ -37,37 +31,37 @@ DD4hep::CellID CartesianGridXY::cellID(const Position& local, const Position& global, const VolumeID& volID) const { - return access()->cellID(local, global, volID); + return access()->implementation->cellID(local, global, volID); } /// access the grid size in X double CartesianGridXY::gridSizeX() const { - return access()->gridSizeX(); + return access()->implementation->gridSizeX(); } /// access the grid size in Y double CartesianGridXY::gridSizeY() const { - return access()->gridSizeY(); + return access()->implementation->gridSizeY(); } /// access the coordinate offset in X double CartesianGridXY::offsetX() const { - return access()->offsetX(); + return access()->implementation->offsetX(); } /// access the coordinate offset in Y double CartesianGridXY::offsetY() const { - return access()->offsetY(); + return access()->implementation->offsetY(); } /// access the field name used for X const string& CartesianGridXY::fieldNameX() const { - return access()->fieldNameX(); + return access()->implementation->fieldNameX(); } /// access the field name used for Y const string& CartesianGridXY::fieldNameY() const { - return access()->fieldNameY(); + return access()->implementation->fieldNameY(); } /** \brief Returns a vector<double> of the cellDimensions of the given cell ID @@ -80,5 +74,5 @@ const string& CartesianGridXY::fieldNameY() const { -# size in y */ vector<double> CartesianGridXY::cellDimensions(const CellID& id) const { - return access()->cellDimensions(id); + return access()->implementation->cellDimensions(id); } diff --git a/DDCore/src/CartesianGridXYZ.cpp b/DDCore/src/CartesianGridXYZ.cpp index a9bcf1bc366797883fdcfbfc225047414febce63..396864c41aaddd34336e7ff0568e16fe96231b69 100644 --- a/DDCore/src/CartesianGridXYZ.cpp +++ b/DDCore/src/CartesianGridXYZ.cpp @@ -21,15 +21,9 @@ using namespace std; using namespace DD4hep::Geometry; -/// Copy Constructor from segmentation base object -CartesianGridXYZ::CartesianGridXYZ(const Segmentation& e) : Handle<Object>() -{ - m_element = Segmentation::get<Object>(e.ptr()); -} - /// determine the position based on the cell ID Position CartesianGridXYZ::position(const CellID& id) const { - return Position(access()->position(id)); + return Position(access()->implementation->position(id)); } /// determine the cell ID based on the position @@ -37,52 +31,52 @@ DD4hep::CellID CartesianGridXYZ::cellID(const Position& local, const Position& global, const VolumeID& volID) const { - return access()->cellID(local, global, volID); + return access()->implementation->cellID(local, global, volID); } /// access the grid size in X double CartesianGridXYZ::gridSizeX() const { - return access()->gridSizeX(); + return access()->implementation->gridSizeX(); } /// access the grid size in Y double CartesianGridXYZ::gridSizeY() const { - return access()->gridSizeY(); + return access()->implementation->gridSizeY(); } /// access the grid size in Z double CartesianGridXYZ::gridSizeZ() const { - return access()->gridSizeZ(); + return access()->implementation->gridSizeZ(); } /// access the coordinate offset in X double CartesianGridXYZ::offsetX() const { - return access()->offsetX(); + return access()->implementation->offsetX(); } /// access the coordinate offset in Y double CartesianGridXYZ::offsetY() const { - return access()->offsetY(); + return access()->implementation->offsetY(); } /// access the coordinate offset in Z double CartesianGridXYZ::offsetZ() const { - return access()->offsetZ(); + return access()->implementation->offsetZ(); } /// access the field name used for X const string& CartesianGridXYZ::fieldNameX() const { - return access()->fieldNameX(); + return access()->implementation->fieldNameX(); } /// access the field name used for Y const string& CartesianGridXYZ::fieldNameY() const { - return access()->fieldNameY(); + return access()->implementation->fieldNameY(); } /// access the field name used for Z const string& CartesianGridXYZ::fieldNameZ() const { - return access()->fieldNameZ(); + return access()->implementation->fieldNameZ(); } /** \brief Returns a vector<double> of the cellDimensions of the given cell ID @@ -96,5 +90,5 @@ const string& CartesianGridXYZ::fieldNameZ() const { -# size in z */ vector<double> CartesianGridXYZ::cellDimensions(const CellID& id) const { - return access()->cellDimensions(id); + return access()->implementation->cellDimensions(id); } diff --git a/DDCore/src/CartesianGridXZ.cpp b/DDCore/src/CartesianGridXZ.cpp index c2f6aedac5151f153484ebda791f8c7ce1940947..0d4ee904efdd54d2c3dee38d194c61948060690a 100644 --- a/DDCore/src/CartesianGridXZ.cpp +++ b/DDCore/src/CartesianGridXZ.cpp @@ -21,15 +21,9 @@ using namespace std; using namespace DD4hep::Geometry; -/// Copy Constructor from segmentation base object -CartesianGridXZ::CartesianGridXZ(const Segmentation& e) : Handle<Object>() -{ - m_element = Segmentation::get<Object>(e.ptr()); -} - /// determine the position based on the cell ID Position CartesianGridXZ::position(const CellID& id) const { - return Position(access()->position(id)); + return Position(access()->implementation->position(id)); } /// determine the cell ID based on the position @@ -37,37 +31,37 @@ DD4hep::CellID CartesianGridXZ::cellID(const Position& local, const Position& global, const VolumeID& volID) const { - return access()->cellID(local, global, volID); + return access()->implementation->cellID(local, global, volID); } /// access the grid size in X double CartesianGridXZ::gridSizeX() const { - return access()->gridSizeX(); + return access()->implementation->gridSizeX(); } /// access the grid size in Z double CartesianGridXZ::gridSizeZ() const { - return access()->gridSizeZ(); + return access()->implementation->gridSizeZ(); } /// access the coordinate offset in X double CartesianGridXZ::offsetX() const { - return access()->offsetX(); + return access()->implementation->offsetX(); } /// access the coordinate offset in Z double CartesianGridXZ::offsetZ() const { - return access()->offsetZ(); + return access()->implementation->offsetZ(); } /// access the field name used for X const string& CartesianGridXZ::fieldNameX() const { - return access()->fieldNameX(); + return access()->implementation->fieldNameX(); } /// access the field name used for Z const string& CartesianGridXZ::fieldNameZ() const { - return access()->fieldNameZ(); + return access()->implementation->fieldNameZ(); } /** \brief Returns a vector<double> of the cellDimensions of the given cell ID @@ -80,5 +74,5 @@ const string& CartesianGridXZ::fieldNameZ() const { -# size in z */ vector<double> CartesianGridXZ::cellDimensions(const CellID& id) const { - return access()->cellDimensions(id); + return access()->implementation->cellDimensions(id); } diff --git a/DDCore/src/CartesianGridYZ.cpp b/DDCore/src/CartesianGridYZ.cpp index ed5660ddd2da47b6a94f68dc335bff42f8103b30..2b1176e10e40a917944e3c7e6d0878c4d1b9af50 100644 --- a/DDCore/src/CartesianGridYZ.cpp +++ b/DDCore/src/CartesianGridYZ.cpp @@ -21,15 +21,9 @@ using namespace std; using namespace DD4hep::Geometry; -/// Copy Constructor from segmentation base object -CartesianGridYZ::CartesianGridYZ(const Segmentation& e) : Handle<Object>() -{ - m_element = Segmentation::get<Object>(e.ptr()); -} - /// determine the position based on the cell ID Position CartesianGridYZ::position(const CellID& id) const { - return Position(access()->position(id)); + return Position(access()->implementation->position(id)); } /// determine the cell ID based on the position @@ -37,37 +31,37 @@ DD4hep::CellID CartesianGridYZ::cellID(const Position& local, const Position& global, const VolumeID& volID) const { - return access()->cellID(local, global, volID); + return access()->implementation->cellID(local, global, volID); } /// access the grid size in Y double CartesianGridYZ::gridSizeY() const { - return access()->gridSizeY(); + return access()->implementation->gridSizeY(); } /// access the grid size in Z double CartesianGridYZ::gridSizeZ() const { - return access()->gridSizeZ(); + return access()->implementation->gridSizeZ(); } /// access the coordinate offset in Y double CartesianGridYZ::offsetY() const { - return access()->offsetY(); + return access()->implementation->offsetY(); } /// access the coordinate offset in Z double CartesianGridYZ::offsetZ() const { - return access()->offsetZ(); + return access()->implementation->offsetZ(); } /// access the field name used for Y const string& CartesianGridYZ::fieldNameY() const { - return access()->fieldNameY(); + return access()->implementation->fieldNameY(); } /// access the field name used for Z const string& CartesianGridYZ::fieldNameZ() const { - return access()->fieldNameZ(); + return access()->implementation->fieldNameZ(); } /** \brief Returns a vector<double> of the cellDimensions of the given cell ID @@ -80,5 +74,5 @@ const string& CartesianGridYZ::fieldNameZ() const { -# size in z */ vector<double> CartesianGridYZ::cellDimensions(const CellID& id) const { - return access()->cellDimensions(id); + return access()->implementation->cellDimensions(id); } diff --git a/DDCore/src/Conditions.cpp b/DDCore/src/Conditions.cpp index 243bcb3611f0be384cd368895e54f4ce75e99787..4916db716f331861d08c742f0dce0b419a39bb5f 100644 --- a/DDCore/src/Conditions.cpp +++ b/DDCore/src/Conditions.cpp @@ -58,12 +58,6 @@ Condition::Condition(const string& nam,const string& typ) : Handle<Object>() { o->hash = ConditionKey::hashCode(nam); } -/// Assignment operator -Condition& Condition::operator=(const Condition& c) { - if ( this != &c ) this->m_element = c.m_element; - return *this; -} - /// Output method string Condition::str(int flags) const { stringstream output; diff --git a/DDCore/src/PolarGridRPhi.cpp b/DDCore/src/PolarGridRPhi.cpp index bbd1dd0b44ccc4accb7f3dd5ea75615f129a3724..56498a0c667712543eae09ffb7d733fba5f49d16 100644 --- a/DDCore/src/PolarGridRPhi.cpp +++ b/DDCore/src/PolarGridRPhi.cpp @@ -21,15 +21,9 @@ using namespace std; using namespace DD4hep::Geometry; -/// Copy Constructor from segmentation base object -PolarGridRPhi::PolarGridRPhi(const Segmentation& e) : Handle<Object>() -{ - m_element = Segmentation::get<Object>(e.ptr()); -} - /// determine the position based on the cell ID Position PolarGridRPhi::position(const CellID& id) const { - return Position(access()->position(id)); + return Position(access()->implementation->position(id)); } /// determine the cell ID based on the position @@ -37,37 +31,37 @@ DD4hep::CellID PolarGridRPhi::cellID(const Position& local, const Position& global, const VolumeID& volID) const { - return access()->cellID(local, global, volID); + return access()->implementation->cellID(local, global, volID); } /// access the grid size in R double PolarGridRPhi::gridSizeR() const { - return access()->gridSizeR(); + return access()->implementation->gridSizeR(); } /// access the grid size in Phi double PolarGridRPhi::gridSizePhi() const { - return access()->gridSizePhi(); + return access()->implementation->gridSizePhi(); } /// access the coordinate offset in R double PolarGridRPhi::offsetR() const { - return access()->offsetR(); + return access()->implementation->offsetR(); } /// access the coordinate offset in Phi double PolarGridRPhi::offsetPhi() const { - return access()->offsetPhi(); + return access()->implementation->offsetPhi(); } /// access the field name used for R const string& PolarGridRPhi::fieldNameR() const { - return access()->fieldNameR(); + return access()->implementation->fieldNameR(); } /// access the field name used for Phi const string& PolarGridRPhi::fieldNamePhi() const { - return access()->fieldNamePhi(); + return access()->implementation->fieldNamePhi(); } /** \brief Returns a vector<double> of the cellDimensions of the given cell ID @@ -80,5 +74,5 @@ const string& PolarGridRPhi::fieldNamePhi() const { -# size in z */ vector<double> PolarGridRPhi::cellDimensions(const CellID& id) const { - return access()->cellDimensions(id); + return access()->implementation->cellDimensions(id); } diff --git a/DDCore/src/PolarGridRPhi2.cpp b/DDCore/src/PolarGridRPhi2.cpp new file mode 100644 index 0000000000000000000000000000000000000000..839f739c3bc3798929d871fe8cd2ba01bf4aa379 --- /dev/null +++ b/DDCore/src/PolarGridRPhi2.cpp @@ -0,0 +1,78 @@ +//========================================================================== +// AIDA Detector description implementation for LCD +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// Author : M.Frank +// +//========================================================================== + +// Framework include files +#include "DD4hep/Segmentations.h" +#include "DD4hep/PolarGridRPhi2.h" +#include "DDSegmentation/PolarGridRPhi2.h" + +// C/C++ include files + +using namespace std; +using namespace DD4hep::Geometry; + +/// determine the position based on the cell ID +Position PolarGridRPhi2::position(const CellID& id) const { + return Position(access()->implementation->position(id)); +} + +/// determine the cell ID based on the position +DD4hep::CellID PolarGridRPhi2::cellID(const Position& local, + const Position& global, + const VolumeID& volID) const +{ + return access()->implementation->cellID(local, global, volID); +} + +/// access the grid size in R +vector<double> PolarGridRPhi2::gridRValues() const { + return access()->implementation->gridRValues(); +} + +/// access the grid size in Phi +vector<double> PolarGridRPhi2::gridPhiValues() const { + return access()->implementation->gridPhiValues(); +} + +/// access the coordinate offset in R +double PolarGridRPhi2::offsetR() const { + return access()->implementation->offsetR(); +} + +/// access the coordinate offset in Phi +double PolarGridRPhi2::offsetPhi() const { + return access()->implementation->offsetPhi(); +} + +/// access the field name used for R +const string& PolarGridRPhi2::fieldNameR() const { + return access()->implementation->fieldNameR(); +} + +/// access the field name used for Phi +const string& PolarGridRPhi2::fieldNamePhi() const { + return access()->implementation->fieldNamePhi(); +} + +/** \brief Returns a vector<double> of the cellDimensions of the given cell ID + in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi + + Returns a vector of the cellDimensions of the given cell ID + \param cellID is ignored as all cells have the same dimension + \return vector<double> size 2: + -# size in x + -# size in z +*/ +vector<double> PolarGridRPhi2::cellDimensions(const CellID& id) const { + return access()->implementation->cellDimensions(id); +} diff --git a/DDCore/src/Readout.cpp b/DDCore/src/Readout.cpp index 48b7b3cc35f28140d35d9e4d886dea7d1bac34d0..8297bae803acff15f102523ea4b7adf228947a91 100644 --- a/DDCore/src/Readout.cpp +++ b/DDCore/src/Readout.cpp @@ -91,13 +91,13 @@ vector<const HitCollection*> Readout::collections() const { /// Assign IDDescription to readout structure void Readout::setIDDescriptor(const Ref_t& new_descriptor) const { - if ( isValid() ) { // Remember: segmentation is NOT owned by readout structure! + if ( isValid() ) { // The ID descriptor is NOT owned by the readout! if (new_descriptor.isValid()) { // Do NOT delete! data<Object>()->id = new_descriptor; Segmentation seg = data<Object>()->segmentation; - IDDescriptor id = new_descriptor; - if (seg.isValid()) { - seg.segmentation()->setDecoder(id.decoder()); + IDDescriptor id = new_descriptor; + if ( seg.isValid() ) { + seg.setDecoder(id.decoder()); } return; } @@ -115,10 +115,10 @@ void Readout::setSegmentation(const Segmentation& seg) const { if ( isValid() ) { Object& ro = object<Object>(); Segmentation::Implementation* e = ro.segmentation.ptr(); - if (e) { // Remember: segmentation is owned by readout structure! - delete e; // Need to delete the segmentation object - } - if (seg.isValid()) { + if ( e && e != seg.ptr() ) { // Remember: + delete e; // The segmentation is owned by the readout! + } // Need to delete the segmentation object + if ( seg.isValid() ) { ro.segmentation = seg; return; } diff --git a/DDCore/src/Segmentations.cpp b/DDCore/src/Segmentations.cpp index d6f9aa67d1160af6d1da151c3680e534688b5417..bbe28a2234f754a0ff36625dc61bc6837824a4ee 100644 --- a/DDCore/src/Segmentations.cpp +++ b/DDCore/src/Segmentations.cpp @@ -75,12 +75,12 @@ const string& SegmentationObject::description() const { } /// Access the underlying decoder -BitField64* SegmentationObject::decoder() { +BitField64* SegmentationObject::decoder() const { return segmentation->decoder(); } /// Set the underlying decoder -void SegmentationObject::setDecoder(BitField64* ptr_decoder) { +void SegmentationObject::setDecoder(BitField64* ptr_decoder) const { segmentation->setDecoder(ptr_decoder); } @@ -122,7 +122,7 @@ void SegmentationObject::neighbours(const CellID& cell, std::set<CellID>& nb) co } /// Constructor to used when creating a new object -Segmentation::Segmentation(const string& typ, const string& nam, BitField64* dec) : Handle<Implementation>() +Segmentation::Segmentation(const string& typ, const string& nam, BitField64* dec) : Handle<Object>() { string type = "segmentation_constructor__"+typ; SegmentationObject* obj = PluginService::Create<SegmentationObject*>(type, dec); @@ -131,14 +131,7 @@ Segmentation::Segmentation(const string& typ, const string& nam, BitField64* dec if ( !nam.empty() ) obj->setName(nam); return; } -#if 0 - BaseSegmentation* s = DDSegmentation::SegmentationFactory::instance()->create(typ); - if (s != 0) { - assign(new Object(s), nam, ""); - if ( !nam.empty() ) s->setName(nam); - return; - } -#endif + // This is fatal and cannot be recovered. We need to throw an exception here. except("Segmentation","FAILED to create segmentation: %s. [Missing factory]",typ.c_str()); } @@ -157,18 +150,28 @@ Parameters Segmentation::parameters() const { } /// Access segmentation object -DDSegmentation::Segmentation* Segmentation::segmentation() const { - return data<Object>()->segmentation; -} +//DDSegmentation::Segmentation* Segmentation::segmentation() const { +// return data<Object>()->segmentation; +//} /// determine the local position based on the cell ID Position Segmentation::position(const long64& cell) const { - return Position(segmentation()->position(cell)); + return Position(data<Object>()->segmentation->position(cell)); } /// determine the cell ID based on the local position long64 Segmentation::cellID(const Position& localPosition, const Position& globalPosition, const long64& volID) const { - return segmentation()->cellID(localPosition, globalPosition, volID); + return data<Object>()->segmentation->cellID(localPosition, globalPosition, volID); +} + +/// Access the underlying decoder +BitField64* Segmentation::decoder() const { + return data<Object>()->segmentation->decoder(); +} + +/// Set the underlying decoder +void Segmentation::setDecoder(BitField64* decode) const { + data<Object>()->segmentation->setDecoder(decode); } /// Namespace for the AIDA detector description toolkit @@ -195,7 +198,7 @@ namespace DD4hep { } /* End namespace DD4hep */ #define IMPLEMENT_SEGMENTATION_HANDLE(X) \ - DD4HEP_INSTANTIATE_HANDLE_UNNAMED(DDSegmentation::X); \ + DD4HEP_INSTANTIATE_HANDLE_UNNAMED(SegmentationWrapper<DDSegmentation::X>); \ namespace DD4hep { namespace Geometry { \ template DDSegmentation::X* \ Segmentation::get<DDSegmentation::X>(const Object* obj); }} diff --git a/DDCore/src/WaferGridXY.cpp b/DDCore/src/WaferGridXY.cpp new file mode 100644 index 0000000000000000000000000000000000000000..45aaa4c4d3e2c8b9d3057eafe17531dd9f4751c0 --- /dev/null +++ b/DDCore/src/WaferGridXY.cpp @@ -0,0 +1,87 @@ +//========================================================================== +// AIDA Detector description implementation for LCD +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// Author : M.Frank +// +//========================================================================== + +// Framework include files +#include "DD4hep/Segmentations.h" +#include "DD4hep/WaferGridXY.h" +#include "DDSegmentation/WaferGridXY.h" + +// C/C++ include files + +using namespace std; +using namespace DD4hep::Geometry; + +/// determine the position based on the cell ID +Position WaferGridXY::position(const CellID& id) const { + return Position(access()->implementation->position(id)); +} + +/// determine the cell ID based on the position +DD4hep::CellID WaferGridXY::cellID(const Position& local, + const Position& global, + const VolumeID& volID) const +{ + return access()->implementation->cellID(local, global, volID); +} + +/// access the grid size in X +double WaferGridXY::gridSizeX() const { + return access()->implementation->gridSizeX(); +} + +/// access the grid size in Y +double WaferGridXY::gridSizeY() const { + return access()->implementation->gridSizeY(); +} + +/// access the coordinate offset in X +double WaferGridXY::offsetX() const { + return access()->implementation->offsetX(); +} + +/// access the coordinate offset in Y +double WaferGridXY::offsetY() const { + return access()->implementation->offsetY(); +} +/// access the coordinate waferOffset for inGroup in X +double WaferGridXY::waferOffsetX(int inGroup, int inWafer) const { + return access()->implementation->waferOffsetX(inGroup,inWafer); +} + +/// access the coordinate waferOffset for inGroup in Y +double WaferGridXY::waferOffsetY(int inGroup, int inWafer) const { + return access()->implementation->waferOffsetY(inGroup,inWafer); +} + +/// access the field name used for X +const string& WaferGridXY::fieldNameX() const { + return access()->implementation->fieldNameX(); +} + +/// access the field name used for Y +const string& WaferGridXY::fieldNameY() const { + return access()->implementation->fieldNameY(); +} + +/** \brief Returns a vector<double> of the cellDimensions of the given cell ID + in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi + + Returns a vector of the cellDimensions of the given cell ID + \param cellID is ignored as all cells have the same dimension + \return vector<double> size 2: + -# size in x + -# size in y +*/ +vector<double> WaferGridXY::cellDimensions(const CellID& id) const { + return access()->implementation->cellDimensions(id); +} diff --git a/DDCore/src/plugins/Compact2Objects.cpp b/DDCore/src/plugins/Compact2Objects.cpp index 9fd9848d3e575d8e6cd931bb54676cee44e34f98..636aa9ad35f1db28f6843ffd28128706220b7d93 100644 --- a/DDCore/src/plugins/Compact2Objects.cpp +++ b/DDCore/src/plugins/Compact2Objects.cpp @@ -635,21 +635,27 @@ template <> void Converter<Readout>::operator()(xml_h e) const { Readout ro(name); printout(DEBUG, "Compact", "++ Converting readout structure: %s.",ro.name()); + if (id) { // <id>system:6,barrel:3,module:4,layer:8,slice:5,x:32:-16,y:-16</id> opt.second = IDDescriptor(id.text()); opt.second->SetName(ro.name()); - ro.setIDDescriptor(opt.second); lcdd.addIDSpecification(opt.second); } if (seg) { // Segmentation is not mandatory! - Converter<Segmentation> converter(lcdd,param,&opt); - converter(seg); - if ( opt.first.isValid() ) { - opt.first->setName(name); - ro.setSegmentation(opt.first); - } + Converter<Segmentation>(lcdd,param,&opt)(seg); + opt.first->setName(name); + } + /// The next 2 if-clauses are a bit tricky, because they are not commutativ. + /// The segmentation MUST be set first - THEN the ID descriptor, since it will + /// update the segmentation. + if ( opt.first.isValid() ) { + ro.setSegmentation(opt.first); } + if ( opt.second.isValid() ) { + ro.setIDDescriptor(opt.second); + } + for(xml_coll_t colls(e,_U(hits_collections)); colls; ++colls) { string hits_key; if ( colls.hasAttr(_U(key)) ) hits_key = colls.attr<string>(_U(key)); diff --git a/DDCore/src/plugins/LCDDSegmentations.cpp b/DDCore/src/plugins/LCDDSegmentations.cpp index 43d701195e38e5e7c9946fe4890f86849eab4314..d1453698715c4b2c2fe99d5e5fca4c50e8f14c60 100644 --- a/DDCore/src/plugins/LCDDSegmentations.cpp +++ b/DDCore/src/plugins/LCDDSegmentations.cpp @@ -21,50 +21,55 @@ using namespace DD4hep::DDSegmentation; #include "DDSegmentation/CartesianGridXY.h" static SegmentationObject* create_CartesianGridXY(BitField64* decoder) -{ return new SegmentationImplementation<CartesianGridXY>(decoder); } +{ return new SegmentationWrapper<CartesianGridXY>(decoder); } DECLARE_SEGMENTATION(CartesianGridXY,create_CartesianGridXY) #include "DDSegmentation/CartesianGridXZ.h" static SegmentationObject* create_CartesianGridXZ(BitField64* decoder) -{ return new SegmentationImplementation<CartesianGridXZ>(decoder); } +{ return new SegmentationWrapper<CartesianGridXZ>(decoder); } DECLARE_SEGMENTATION(CartesianGridXZ,create_CartesianGridXZ) #include "DDSegmentation/CartesianGridYZ.h" static SegmentationObject* create_CartesianGridYZ(BitField64* decoder) -{ return new SegmentationImplementation<CartesianGridYZ>(decoder); } +{ return new SegmentationWrapper<CartesianGridYZ>(decoder); } DECLARE_SEGMENTATION(CartesianGridYZ,create_CartesianGridYZ) #include "DDSegmentation/CartesianGridXYZ.h" static SegmentationObject* create_CartesianGridXYZ(BitField64* decoder) -{ return new SegmentationImplementation<CartesianGridXYZ>(decoder); } +{ return new SegmentationWrapper<CartesianGridXYZ>(decoder); } DECLARE_SEGMENTATION(CartesianGridXYZ,create_CartesianGridXYZ) #include "DDSegmentation/TiledLayerGridXY.h" static SegmentationObject* create_TiledLayerGridXY(BitField64* decoder) -{ return new SegmentationImplementation<TiledLayerGridXY>(decoder); } +{ return new SegmentationWrapper<TiledLayerGridXY>(decoder); } DECLARE_SEGMENTATION(TiledLayerGridXY,create_TiledLayerGridXY) #include "DDSegmentation/MegatileLayerGridXY.h" static SegmentationObject* create_MegatileLayerGridXY(BitField64* decoder) -{ return new SegmentationImplementation<MegatileLayerGridXY>(decoder); } +{ return new SegmentationWrapper<MegatileLayerGridXY>(decoder); } DECLARE_SEGMENTATION(MegatileLayerGridXY,create_MegatileLayerGridXY) #include "DDSegmentation/WaferGridXY.h" static SegmentationObject* create_WaferGridXY(BitField64* decoder) -{ return new SegmentationImplementation<WaferGridXY>(decoder); } +{ return new SegmentationWrapper<WaferGridXY>(decoder); } DECLARE_SEGMENTATION(WaferGridXY,create_WaferGridXY) #include "DDSegmentation/PolarGridRPhi.h" static SegmentationObject* create_PolarGridRPhi(BitField64* decoder) -{ return new SegmentationImplementation<PolarGridRPhi>(decoder); } +{ return new SegmentationWrapper<PolarGridRPhi>(decoder); } DECLARE_SEGMENTATION(PolarGridRPhi,create_PolarGridRPhi) #include "DDSegmentation/PolarGridRPhi2.h" static SegmentationObject* create_PolarGridRPhi2(BitField64* decoder) -{ return new SegmentationImplementation<PolarGridRPhi2>(decoder); } +{ return new SegmentationWrapper<PolarGridRPhi2>(decoder); } DECLARE_SEGMENTATION(PolarGridRPhi2,create_PolarGridRPhi2) #include "DDSegmentation/ProjectiveCylinder.h" static SegmentationObject* create_ProjectiveCylinder(BitField64* decoder) -{ return new SegmentationImplementation<ProjectiveCylinder>(decoder); } +{ return new SegmentationWrapper<ProjectiveCylinder>(decoder); } DECLARE_SEGMENTATION(ProjectiveCylinder,create_ProjectiveCylinder) + +#include "DDSegmentation/MultiSegmentation.h" +static SegmentationObject* create_MultiSegmentation(BitField64* decoder) +{ return new SegmentationWrapper<MultiSegmentation>(decoder); } +DECLARE_SEGMENTATION(MultiSegmentation,create_MultiSegmentation) diff --git a/DDSegmentation/include/DDSegmentation/Segmentation.h b/DDSegmentation/include/DDSegmentation/Segmentation.h index db21677e75aa9dccd31a089e14a6ed234ba33994..89323900fe02fb947283d2388ad144d274177e50 100644 --- a/DDSegmentation/include/DDSegmentation/Segmentation.h +++ b/DDSegmentation/include/DDSegmentation/Segmentation.h @@ -102,7 +102,7 @@ public: return _description; } /// Access the underlying decoder - virtual BitField64* decoder() { + virtual BitField64* decoder() const { return _decoder; } /// Set the underlying decoder diff --git a/DDSegmentation/include/DDSegmentation/WaferGridXY.h b/DDSegmentation/include/DDSegmentation/WaferGridXY.h index 042ff2476f11e60f6cd4020a9e609b254072c802..68a7767ad584504ba3c73382f8645b4593ffb62f 100644 --- a/DDSegmentation/include/DDSegmentation/WaferGridXY.h +++ b/DDSegmentation/include/DDSegmentation/WaferGridXY.h @@ -14,121 +14,121 @@ #define MAX_WAFERS 100 namespace DD4hep { -namespace DDSegmentation { + namespace DDSegmentation { -class WaferGridXY: public CartesianGrid { -public: - /// Default constructor passing the encoding string - WaferGridXY(const std::string& cellEncoding = ""); - /// Default constructor used by derived classes passing an existing decoder - WaferGridXY(BitField64* decoder); - /// destructor - virtual ~WaferGridXY(); + class WaferGridXY: public CartesianGrid { + public: + /// Default constructor passing the encoding string + WaferGridXY(const std::string& cellEncoding = ""); + /// Default constructor used by derived classes passing an existing decoder + WaferGridXY(BitField64* decoder); + /// destructor + virtual ~WaferGridXY(); - /// determine the position based on the cell ID - virtual Vector3D position(const CellID& cellID) const; - /// determine the cell ID based on the position - virtual CellID cellID(const Vector3D& localPosition, const Vector3D& globalPosition, const VolumeID& volumeID) const; - /// access the grid size in X - double gridSizeX() const { - return _gridSizeX; - } - /// access the grid size in Y - double gridSizeY() const { - return _gridSizeY; - } - /// access the coordinate offset in X - double offsetX() const { - return _offsetX; - } - /// access the coordinate offset in Y - double offsetY() const { - return _offsetY; - } - /// access the coordinate waferOffset for inGroup in X - double waferOffsetX(int inGroup, int inWafer) const { - return _waferOffsetX[inGroup][inWafer]; - } - /// access the coordinate waferOffset for inGroup in Y - double waferOffsetY(int inGroup, int inWafer) const { - return _waferOffsetY[inGroup][inWafer]; - } + /// determine the position based on the cell ID + virtual Vector3D position(const CellID& cellID) const; + /// determine the cell ID based on the position + virtual CellID cellID(const Vector3D& localPosition, const Vector3D& globalPosition, const VolumeID& volumeID) const; + /// access the grid size in X + double gridSizeX() const { + return _gridSizeX; + } + /// access the grid size in Y + double gridSizeY() const { + return _gridSizeY; + } + /// access the coordinate offset in X + double offsetX() const { + return _offsetX; + } + /// access the coordinate offset in Y + double offsetY() const { + return _offsetY; + } + /// access the coordinate waferOffset for inGroup in X + double waferOffsetX(int inGroup, int inWafer) const { + return _waferOffsetX[inGroup][inWafer]; + } + /// access the coordinate waferOffset for inGroup in Y + double waferOffsetY(int inGroup, int inWafer) const { + return _waferOffsetY[inGroup][inWafer]; + } - /// access the field name used for X - const std::string& fieldNameX() const { - return _xId; - } - /// access the field name used for Y - const std::string& fieldNameY() const { - return _yId; - } - /// set the grid size in X - void setGridSizeX(double cellSize) { - _gridSizeX = cellSize; - } - /// set the grid size in Y - void setGridSizeY(double cellSize) { - _gridSizeY = cellSize; - } - /// set the coordinate offset in X - void setOffsetX(double offset) { - _offsetX = offset; - } - /// set the coordinate offset in Y - void setOffsetY(double offset) { - _offsetY = offset; - } - /// set the coordinate waferOffset for inlayer in X - void setWaferOffsetX(int inGroup,int inWafer, double offset) { - _waferOffsetX[inGroup][inWafer] = offset; - } - /// set the coordinate waferOffset for inGroup in Y - void setWaferOffsetY(int inGroup,int inWafer, double offset) { - _waferOffsetY[inGroup][inWafer] = offset; - } + /// access the field name used for X + const std::string& fieldNameX() const { + return _xId; + } + /// access the field name used for Y + const std::string& fieldNameY() const { + return _yId; + } + /// set the grid size in X + void setGridSizeX(double cellSize) { + _gridSizeX = cellSize; + } + /// set the grid size in Y + void setGridSizeY(double cellSize) { + _gridSizeY = cellSize; + } + /// set the coordinate offset in X + void setOffsetX(double offset) { + _offsetX = offset; + } + /// set the coordinate offset in Y + void setOffsetY(double offset) { + _offsetY = offset; + } + /// set the coordinate waferOffset for inlayer in X + void setWaferOffsetX(int inGroup,int inWafer, double offset) { + _waferOffsetX[inGroup][inWafer] = offset; + } + /// set the coordinate waferOffset for inGroup in Y + void setWaferOffsetY(int inGroup,int inWafer, double offset) { + _waferOffsetY[inGroup][inWafer] = offset; + } - /// set the field name used for X - void setFieldNameX(const std::string& fieldName) { - _xId = fieldName; - } - /// set the field name used for Y - void setFieldNameY(const std::string& fieldName) { - _yId = fieldName; - } - /** \brief Returns a vector<double> of the cellDimensions of the given cell ID - in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi + /// set the field name used for X + void setFieldNameX(const std::string& fieldName) { + _xId = fieldName; + } + /// set the field name used for Y + void setFieldNameY(const std::string& fieldName) { + _yId = fieldName; + } + /** \brief Returns a vector<double> of the cellDimensions of the given cell ID + in natural order of dimensions, e.g., dx/dy/dz, or dr/r*dPhi - Returns a vector of the cellDimensions of the given cell ID - \param cellID is ignored as all cells have the same dimension - \return std::vector<double> size 2: - -# size in x - -# size in y - */ - virtual std::vector<double> cellDimensions(const CellID& cellID) const; + Returns a vector of the cellDimensions of the given cell ID + \param cellID is ignored as all cells have the same dimension + \return std::vector<double> size 2: + -# size in x + -# size in y + */ + virtual std::vector<double> cellDimensions(const CellID& cellID) const; -protected: - /// the grid size in X - double _gridSizeX; - /// the coordinate offset in X - double _offsetX; - /// the grid size in Y - double _gridSizeY; - /// the coordinate offset in Y - double _offsetY; - /// list of wafer x offset for each group - double _waferOffsetX[MAX_GROUPS][MAX_WAFERS]; - /// list of wafer y offset for each group - double _waferOffsetY[MAX_GROUPS][MAX_WAFERS]; - /// the field name used for X - std::string _xId; - /// the field name used for Y - std::string _yId; - /// encoding field used for the Magic Wafer group - std::string _identifierMGWaferGroup; - /// encoding field used for the wafer - std::string _identifierWafer; -}; + protected: + /// the grid size in X + double _gridSizeX; + /// the coordinate offset in X + double _offsetX; + /// the grid size in Y + double _gridSizeY; + /// the coordinate offset in Y + double _offsetY; + /// list of wafer x offset for each group + double _waferOffsetX[MAX_GROUPS][MAX_WAFERS]; + /// list of wafer y offset for each group + double _waferOffsetY[MAX_GROUPS][MAX_WAFERS]; + /// the field name used for X + std::string _xId; + /// the field name used for Y + std::string _yId; + /// encoding field used for the Magic Wafer group + std::string _identifierMGWaferGroup; + /// encoding field used for the wafer + std::string _identifierWafer; + }; -} /* namespace DDSegmentation */ + } /* namespace DDSegmentation */ } /* namespace DD4hep */ #endif /* DDSegmentation_WAFERGRIDXY_H_ */ diff --git a/DDSegmentation/src/CartesianGrid.cpp b/DDSegmentation/src/CartesianGrid.cpp index 8774fa8d64c341bf81d3c6a4231dd9358e4366d5..b213e7640934e8c179af1e7a7fe224e316c70336 100644 --- a/DDSegmentation/src/CartesianGrid.cpp +++ b/DDSegmentation/src/CartesianGrid.cpp @@ -16,7 +16,7 @@ namespace DD4hep { } /// Default constructor used by derived classes passing an existing decoder - CartesianGrid::CartesianGrid(BitField64* decoder) : Segmentation(decoder) { + CartesianGrid::CartesianGrid(BitField64* decode) : Segmentation(decode) { } /// Destructor diff --git a/DDSegmentation/src/CartesianGridXY.cpp b/DDSegmentation/src/CartesianGridXY.cpp index b474cc13e672635f6fb18c2841a31d1b79daa431..876fc99340a8bac44ad72eeb553e66585e2cde2a 100644 --- a/DDSegmentation/src/CartesianGridXY.cpp +++ b/DDSegmentation/src/CartesianGridXY.cpp @@ -27,8 +27,8 @@ CartesianGridXY::CartesianGridXY(const std::string& cellEncoding) : } /// Default constructor used by derived classes passing an existing decoder -CartesianGridXY::CartesianGridXY(BitField64* decoder) : - CartesianGrid(decoder) +CartesianGridXY::CartesianGridXY(BitField64* decode) : + CartesianGrid(decode) { // define type and description _type = "CartesianGridXY"; diff --git a/DDSegmentation/src/CartesianGridXYZ.cpp b/DDSegmentation/src/CartesianGridXYZ.cpp index 9937b7216b82735b85bdc41d94e2c4ca872f3eb3..d7b82bb01705a256d1b47805d2d2aaa2a8073c26 100644 --- a/DDSegmentation/src/CartesianGridXYZ.cpp +++ b/DDSegmentation/src/CartesianGridXYZ.cpp @@ -24,8 +24,8 @@ CartesianGridXYZ::CartesianGridXYZ(const std::string& cellEncoding) : } /// Default constructor used by derived classes passing an existing decoder -CartesianGridXYZ::CartesianGridXYZ(BitField64* decoder) : - CartesianGridXY(decoder) { +CartesianGridXYZ::CartesianGridXYZ(BitField64* decode) : + CartesianGridXY(decode) { // define type and description _type = "CartesianGridXYZ"; _description = "Cartesian segmentation in the local coordinates"; diff --git a/DDSegmentation/src/CartesianGridXZ.cpp b/DDSegmentation/src/CartesianGridXZ.cpp index 07f88b0a16e6f42f5b26456416d253100a405181..6ed4359f5e0adf1c2784ad888e207d35d0257156 100644 --- a/DDSegmentation/src/CartesianGridXZ.cpp +++ b/DDSegmentation/src/CartesianGridXZ.cpp @@ -30,8 +30,8 @@ CartesianGridXZ::CartesianGridXZ(const std::string& cellEncoding) : } /// Default constructor used by derived classes passing an existing decoder -CartesianGridXZ::CartesianGridXZ(BitField64* decoder) : - CartesianGrid(decoder) { +CartesianGridXZ::CartesianGridXZ(BitField64* decode) : + CartesianGrid(decode) { // define type and description _type = "CartesianGridXZ"; _description = "Cartesian segmentation in the local XZ-plane"; diff --git a/DDSegmentation/src/CartesianGridYZ.cpp b/DDSegmentation/src/CartesianGridYZ.cpp index 3498e871184c196e252822818927a9797442b5c5..d5075a01ec061428c83a5db24a3dac59044182e3 100644 --- a/DDSegmentation/src/CartesianGridYZ.cpp +++ b/DDSegmentation/src/CartesianGridYZ.cpp @@ -29,8 +29,8 @@ CartesianGridYZ::CartesianGridYZ(const std::string& cellEncoding) : /// Default constructor used by derived classes passing an existing decoder -CartesianGridYZ::CartesianGridYZ(BitField64* decoder) : - CartesianGrid(decoder) { +CartesianGridYZ::CartesianGridYZ(BitField64* decode) : CartesianGrid(decode) +{ // define type and description _type = "CartesianGridYZ"; _description = "Cartesian segmentation in the local YZ-plane"; diff --git a/DDSegmentation/src/CylindricalSegmentation.cpp b/DDSegmentation/src/CylindricalSegmentation.cpp index dbb4b1b4ca388196cb8deccbcae953269049b91f..b02374600c32d8add5b4f8436cd552cc7cd01194 100644 --- a/DDSegmentation/src/CylindricalSegmentation.cpp +++ b/DDSegmentation/src/CylindricalSegmentation.cpp @@ -8,22 +8,22 @@ #include "DDSegmentation/CylindricalSegmentation.h" namespace DD4hep { -namespace DDSegmentation { + namespace DDSegmentation { -/// default constructor using an encoding string -CylindricalSegmentation::CylindricalSegmentation(const std::string& cellEncoding) : - Segmentation(cellEncoding) { -} + /// default constructor using an encoding string + CylindricalSegmentation::CylindricalSegmentation(const std::string& cellEncoding) : + Segmentation(cellEncoding) { + } -/// Default constructor used by derived classes passing an existing decoder -CylindricalSegmentation::CylindricalSegmentation(BitField64* decoder) : - Segmentation(decoder) { -} + /// Default constructor used by derived classes passing an existing decoder + CylindricalSegmentation::CylindricalSegmentation(BitField64* decode) : + Segmentation(decode) { + } -/// destructor -CylindricalSegmentation::~CylindricalSegmentation() { + /// destructor + CylindricalSegmentation::~CylindricalSegmentation() { -} + } -} /* namespace DDSegmentation */ + } /* namespace DDSegmentation */ } /* namespace DD4hep */ diff --git a/DDSegmentation/src/MegatileLayerGridXY.cpp b/DDSegmentation/src/MegatileLayerGridXY.cpp index bf4093a4048610502d5d42c759944d881afd7640..93b77bd2cba828dd70b9faa7c8cd6477fe4975bb 100644 --- a/DDSegmentation/src/MegatileLayerGridXY.cpp +++ b/DDSegmentation/src/MegatileLayerGridXY.cpp @@ -57,8 +57,8 @@ namespace DD4hep { } /// default constructor using an encoding string - MegatileLayerGridXY::MegatileLayerGridXY(BitField64* decoder) : - CartesianGrid(decoder) { + MegatileLayerGridXY::MegatileLayerGridXY(BitField64* decode) : + CartesianGrid(decode) { // define type and description _type = "MegatileLayerGridXY"; // _description = "Cartesian segmentation in the local XY-plane for both Normal wafer and Magic wafer(depending on the layer dimensions)"; diff --git a/DDSegmentation/src/MultiSegmentation.cpp b/DDSegmentation/src/MultiSegmentation.cpp index 17ab760c0c1b2d46bcaeca56e5175e5156b25654..8f25865221cde823644fd1ea34cfc798aefd3ffc 100644 --- a/DDSegmentation/src/MultiSegmentation.cpp +++ b/DDSegmentation/src/MultiSegmentation.cpp @@ -26,8 +26,8 @@ namespace DD4hep { } /// Default constructor used by derived classes passing an existing decoder - MultiSegmentation::MultiSegmentation(BitField64* decoder) - : Segmentation(decoder), m_discriminator(0), m_debug(0) + MultiSegmentation::MultiSegmentation(BitField64* decode) + : Segmentation(decode), m_discriminator(0), m_debug(0) { // define type and description _type = "MultiSegmentation"; diff --git a/DDSegmentation/src/PolarGrid.cpp b/DDSegmentation/src/PolarGrid.cpp index 88099ec3e87f588f2f4fe50eb2845f14f91fe27f..f39b9b535d9953f4316fbdb42b252efba9a27fcb 100644 --- a/DDSegmentation/src/PolarGrid.cpp +++ b/DDSegmentation/src/PolarGrid.cpp @@ -15,7 +15,7 @@ namespace DD4hep { Segmentation(cellEncoding) { } /// Default constructor used by derived classes passing an existing decoder - PolarGrid::PolarGrid(BitField64* decoder) : Segmentation(decoder) { + PolarGrid::PolarGrid(BitField64* decode) : Segmentation(decode) { } /// Destructor diff --git a/DDSegmentation/src/PolarGridRPhi.cpp b/DDSegmentation/src/PolarGridRPhi.cpp index a44569455ecb7137774098287af09472f53f2722..2a1f217c729f120915049bd9f231ba51dafacb8a 100644 --- a/DDSegmentation/src/PolarGridRPhi.cpp +++ b/DDSegmentation/src/PolarGridRPhi.cpp @@ -28,8 +28,7 @@ PolarGridRPhi::PolarGridRPhi(const std::string& cellEncoding) : /// Default constructor used by derived classes passing an existing decoder -PolarGridRPhi::PolarGridRPhi(BitField64* decoder) : - PolarGrid(decoder) { +PolarGridRPhi::PolarGridRPhi(BitField64* decode) : PolarGrid(decode) { // define type and description _type = "PolarGridRPhi"; _description = "Polar RPhi segmentation in the local XY-plane"; diff --git a/DDSegmentation/src/PolarGridRPhi2.cpp b/DDSegmentation/src/PolarGridRPhi2.cpp index 98c76fe5333c25a8fedca0e9fe05a00798659ede..ab47c30973b49262dec82cecb4881f9ea60fff85 100644 --- a/DDSegmentation/src/PolarGridRPhi2.cpp +++ b/DDSegmentation/src/PolarGridRPhi2.cpp @@ -27,8 +27,8 @@ PolarGridRPhi2::PolarGridRPhi2(const std::string& cellEncoding) : } /// Default constructor used by derived classes passing an existing decoder -PolarGridRPhi2::PolarGridRPhi2(BitField64* decoder) : - PolarGrid(decoder) { +PolarGridRPhi2::PolarGridRPhi2(BitField64* decode) : + PolarGrid(decode) { // define type and description _type = "PolarGridRPhi2"; _description = "Polar RPhi segmentation in the local XY-plane"; diff --git a/DDSegmentation/src/ProjectiveCylinder.cpp b/DDSegmentation/src/ProjectiveCylinder.cpp index 6e5e6179679b1ba668af6295bd65841a73936848..17dfde93ea759121921661eb3cb020a45c8d8607 100644 --- a/DDSegmentation/src/ProjectiveCylinder.cpp +++ b/DDSegmentation/src/ProjectiveCylinder.cpp @@ -35,8 +35,7 @@ ProjectiveCylinder::ProjectiveCylinder(const std::string& cellEncoding) : /// Default constructor used by derived classes passing an existing decoder -ProjectiveCylinder::ProjectiveCylinder(BitField64* decoder) : - CylindricalSegmentation(decoder) { +ProjectiveCylinder::ProjectiveCylinder(BitField64* decode) : CylindricalSegmentation(decode) { // define type and description _type = "ProjectiveCylinder"; _description = "Projective segmentation in the global coordinates"; diff --git a/DDSegmentation/src/Segmentation.cpp b/DDSegmentation/src/Segmentation.cpp index ad97ea88f40bb71cee95655af460e719f75613b5..ad8b2fd05f03c21f3f4454635107fa49bb29a97f 100644 --- a/DDSegmentation/src/Segmentation.cpp +++ b/DDSegmentation/src/Segmentation.cpp @@ -91,10 +91,10 @@ namespace DD4hep { /// Set the underlying decoder void Segmentation::setDecoder(BitField64* newDecoder) { - if ( _decoder == newDecoder ) return; //self assignment - if (_ownsDecoder) { + if ( _decoder == newDecoder ) + return; //self assignment + else if (_ownsDecoder) delete _decoder; - } _decoder = newDecoder; _ownsDecoder = false; } diff --git a/DDSegmentation/src/TiledLayerGridXY.cpp b/DDSegmentation/src/TiledLayerGridXY.cpp index 58afea8a4d268cd001f6c8e755d82200bea17b7c..bd539e056cb32af705db00061a9b42184a834743 100644 --- a/DDSegmentation/src/TiledLayerGridXY.cpp +++ b/DDSegmentation/src/TiledLayerGridXY.cpp @@ -40,8 +40,7 @@ TiledLayerGridXY::TiledLayerGridXY(const std::string& cellEncoding) : } /// Default constructor used by derived classes passing an existing decoder -TiledLayerGridXY::TiledLayerGridXY(BitField64* decoder) : - CartesianGrid(decoder) { +TiledLayerGridXY::TiledLayerGridXY(BitField64* decode) : CartesianGrid(decode) { // define type and description _type = "TiledLayerGridXY"; _description = "Cartesian segmentation in the local XY-plane using optimal tiling depending on the layer dimensions"; diff --git a/DDSegmentation/src/TiledLayerSegmentation.cpp b/DDSegmentation/src/TiledLayerSegmentation.cpp index 0a35ac6a5b1c0a452b89fe4975b2df57b1a4bdb0..d330fb52bd5705107778edd51c6fa88a3c7b6a84 100644 --- a/DDSegmentation/src/TiledLayerSegmentation.cpp +++ b/DDSegmentation/src/TiledLayerSegmentation.cpp @@ -42,8 +42,7 @@ TiledLayerSegmentation::TiledLayerSegmentation(const std::string& cellEncoding) } /// Default constructor used by derived classes passing an existing decoder -TiledLayerSegmentation::TiledLayerSegmentation(BitField64* decoder) : - Segmentation(decoder) { +TiledLayerSegmentation::TiledLayerSegmentation(BitField64* decode) : Segmentation(decode) { _type = "TiledLayerSegmentation"; _description = "Cartesian segmentation using optimal tiling depending on the layer dimensions"; diff --git a/DDSegmentation/src/WaferGridXY.cpp b/DDSegmentation/src/WaferGridXY.cpp index c55d2b0d360883f8a832d041e09e2fa138abc871..c381e170d324338271bba8c9f2953849af81b800 100644 --- a/DDSegmentation/src/WaferGridXY.cpp +++ b/DDSegmentation/src/WaferGridXY.cpp @@ -31,8 +31,7 @@ WaferGridXY::WaferGridXY(const std::string& cellEncoding) : } /// Default constructor used by derived classes passing an existing decoder -WaferGridXY::WaferGridXY(BitField64* decoder) : - CartesianGrid(decoder) { +WaferGridXY::WaferGridXY(BitField64* decode) : CartesianGrid(decode) { // define type and description _type = "WaferGridXY"; _description = "Cartesian segmentation in the local XY-plane for both Normal wafer and Magic wafer(depending on the layer dimensions)";