diff --git a/DDCore/include/DD4hep/Shapes.h b/DDCore/include/DD4hep/Shapes.h index 5d5751aa6d4c0b430aa00a7aed042af49f54ecdd..9983299ee7b226947d724e9d55130808a6ea0bd7 100644 --- a/DDCore/include/DD4hep/Shapes.h +++ b/DDCore/include/DD4hep/Shapes.h @@ -827,7 +827,7 @@ namespace dd4hep { double b() const { return access()->GetB(); } }; - /// Class describing a elliptical tube shape + /// Class describing a twisted tube shape /** * This is actually no TGeo shape. This implementation is a placeholder * for the Geant4 implementation G4TwistedTube. diff --git a/DDCore/src/plugins/Compact2Objects.cpp b/DDCore/src/plugins/Compact2Objects.cpp index 9229a9570dc2591fb050c41b988692cca6a8dd5f..65102cba6934f824b73fc9d496b191aa3d688663 100644 --- a/DDCore/src/plugins/Compact2Objects.cpp +++ b/DDCore/src/plugins/Compact2Objects.cpp @@ -65,7 +65,7 @@ namespace dd4hep { class Plugin; class Compact; class Includes; - class GdmlFile; + class IncludeFile; class Property; class XMLFile; class JsonFile; @@ -97,7 +97,7 @@ namespace dd4hep { #endif template <> void Converter<DetElement>::operator()(xml_h element) const; template <> void Converter<STD_Conditions>::operator()(xml_h element) const; - template <> void Converter<GdmlFile>::operator()(xml_h element) const; + template <> void Converter<IncludeFile>::operator()(xml_h element) const; template <> void Converter<JsonFile>::operator()(xml_h element) const; template <> void Converter<XMLFile>::operator()(xml_h element) const; template <> void Converter<Header>::operator()(xml_h element) const; @@ -1314,7 +1314,7 @@ template <> void Converter<DetElement>::operator()(xml_h element) const { } /// Read material entries from a seperate file in one of the include sections of the geometry -template <> void Converter<GdmlFile>::operator()(xml_h element) const { +template <> void Converter<IncludeFile>::operator()(xml_h element) const { xml::DocumentHolder doc(xml::DocumentHandler().load(element, element.attr_value(_U(ref)))); xml_h root = doc.root(); if ( s_debug.includes ) { @@ -1443,7 +1443,10 @@ template <> void Converter<DetElementInclude>::operator()(xml_h element) const { Converter<JsonFile>(this->description)(element); } else if ( type == "gdml" ) { - Converter<GdmlFile>(this->description)(element); + Converter<IncludeFile>(this->description)(element); + } + else if ( type == "include" ) { + Converter<IncludeFile>(this->description)(element); } else if ( type == "xml-extended" ) { Converter<XMLFile>(this->description)(element); @@ -1506,10 +1509,11 @@ template <> void Converter<Compact>::operator()(xml_h element) const { printout(INFO,"Compact","+++ degree: %8.3g Units:%8.3g",xml::_toDouble(_Unicode(degree)),dd4hep::degree); } - xml_coll_t(compact, _U(define)).for_each(_U(include), Converter<DetElementInclude>(description)); - xml_coll_t(compact, _U(define)).for_each(_U(constant), Converter<Constant>(description)); - xml_coll_t(compact, _U(std_conditions)).for_each(Converter<STD_Conditions>(description)); - xml_coll_t(compact, _U(includes)).for_each(_U(gdmlFile), Converter<GdmlFile>(description)); + xml_coll_t(compact, _U(define)).for_each(_U(include), Converter<DetElementInclude>(description)); + xml_coll_t(compact, _U(define)).for_each(_U(constant), Converter<Constant>(description)); + xml_coll_t(compact, _U(std_conditions)).for_each( Converter<STD_Conditions>(description)); + xml_coll_t(compact, _U(includes)).for_each(_U(gdmlFile), Converter<IncludeFile>(description)); + xml_coll_t(compact, _U(includes)).for_each(_U(file), Converter<IncludeFile>(description)); if (element.hasChild(_U(info))) (Converter<Header>(description))(xml_h(compact.child(_U(info)))); diff --git a/DDCore/src/plugins/ShapePlugins.cpp b/DDCore/src/plugins/ShapePlugins.cpp index fe5564822410a3d000410349c708ac57a121e98e..9234479049ebb0cecf74bbb26557c62a86a9dead 100644 --- a/DDCore/src/plugins/ShapePlugins.cpp +++ b/DDCore/src/plugins/ShapePlugins.cpp @@ -76,16 +76,30 @@ static Handle<TObject> create_Polycone(Detector&, xml_h element) { DECLARE_XML_SHAPE(Polycone__shape_constructor,create_Polycone) static Handle<TObject> create_ConeSegment(Detector&, xml_h element) { + Solid solid; xml_dim_t e(element); - Solid solid = ConeSegment(e.dz(),e.rmin1(0.0),e.rmax1(),e.rmin2(0.0),e.rmax2(),e.phi1(0.0),e.phi2(2*M_PI)); + xml_attr_t aphi = element.attr_nothrow(_U(phi1)); + xml_attr_t bphi = element.attr_nothrow(_U(phi2)); + if ( aphi || bphi ) { + double phi1 = e.phi1(0.0); + double phi2 = e.phi2(2*M_PI) - phi1; + /// Old naming: angles from [phi1,phi2] + solid = ConeSegment(e.dz(),e.rmin1(0.0),e.rmax1(),e.rmin2(0.0),e.rmax2(),phi1,phi2); + } + else { + double start_phi = e.startphi(0.0); + double delta_phi = e.deltaphi(2*M_PI); + /// New naming: angles from [startphi,startphi+deltaphi] + solid = ConeSegment(e.dz(),e.rmin1(0.0),e.rmax1(),e.rmin2(0.0),e.rmax2(),start_phi,delta_phi); + } if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); return solid; } DECLARE_XML_SHAPE(ConeSegment__shape_constructor,create_ConeSegment) static Handle<TObject> create_Tube(Detector&, xml_h element) { - xml_dim_t e(element); Solid solid; + xml_dim_t e(element); xml_attr_t aphi = element.attr_nothrow(_U(phi1)); if ( aphi ) { double phi1 = e.phi1(); @@ -263,7 +277,7 @@ static Handle<TObject> create_Sphere(Detector&, xml_h element) { else if ( e.hasAttr(_U(deltatheta)) ) endtheta = starttheta + e.deltatheta(); - Solid solid = Sphere(e.rmin(), e.rmax(), starttheta, endtheta, startphi, endphi); + Solid solid = Sphere(e.rmin(0e0), e.rmax(), starttheta, endtheta, startphi, endphi); if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); return solid; } diff --git a/doc/usermanuals/DD4hep/chapters/basics.tex b/doc/usermanuals/DD4hep/chapters/basics.tex index b3bac76604c23b923fd647604550c4cca9739712..08e201cab399abda5a5fafa7d1b820acfc59008c 100644 --- a/doc/usermanuals/DD4hep/chapters/basics.tex +++ b/doc/usermanuals/DD4hep/chapters/basics.tex @@ -435,22 +435,28 @@ The root tag of the \texttt{XML} tree is {\texttt{lccdd}}. This name is fixed. I \item {\textbf{The \texttt{<includes>} section}} allows to include GDML sub-trees containing material descriptions. These files are processed {\textit{before}} the detector constructors are called: \begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{xml} <includes> - <gdmlFile ref="elements.xml"/> - <gdmlFile ref="materials.xml"/> + <file ref="elements.xml"/> + <file ref="materials.xml"/> ... </includes> \end{minted} +For historic reasons the tag {\textbf{\texttt{<gdmlFile>}}} is supported but deprecated in parallel +with the new tag {\textbf{\texttt{<file>}}}. -\item {\textbf{The \texttt{<define>} section}} contains all variable definitions defined by the client to simplify the definition of subdetectors. These name-value pairs are fed to the expression evaluator and must evaluate to a number. String constants are not allowed. These variables can be combined to formulas e.g. to automatically re-dimension subdetectors if boundaries are changed: + +\item {\textbf{The \texttt{<define>} section}} contains all variable definitions defined by the client to simplify the definition of subdetectors. These name-value pairs are fed to the expression evaluator and must evaluate by default to a number. The data type + {\texttt{number}} is assumed by default (see example below). +These {\texttt{number}} variables can be combined to formulas e.g. to automatically re-dimension subdetectors if boundaries are changed: \begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{xml} <define> - <constant name="world_side" value="30000"/> + <constant name="world_side" value="30000" type="number"/> <constant name="world_x" value="world_side"/> <constant name="world_y" value="world_side"/> <constant name="world_z" value="world_side"/> .... </define> \end{minted} +The other allowed data type is {\texttt{string}}. {\texttt{string}} values are stored in the raw format in the {\texttt{Detector}} object instance and can be retrieved by name. The values are as well added to the evalutation dictionary in order to resolve e.g. environment pathes. \item {\textbf{The \texttt{<materials>} sub-tree}} contains additional materials, which are not contained in the default materials tables. The snippet below shows an example to extend the table of known materials. For more details please see section~\ref{sec:compact-material-description}. \begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{xml} @@ -596,7 +602,7 @@ description of the material's finish.}. Materials are not constructed by any cli \section{Shapes} \label{dd4hep-basic-shapes} -Shapes are abstract objects with a bounding surface and fixed dimensions. There are primitive, atomic shapes and complex boolean shapes as shown in Figure~\ref{fig:dd4hep-solids}. TGeo and similarly Geant4 offer a whole palette of primitive shapes, which can be used to construct more complex shapes: +Shapes are abstract objects with a bounding surface and fixed dimensions. There are primitive, atomic shapes and complex boolean shapes as shown in Figure~\ref{fig:dd4hep-solids}. The shapes have accessors for the most basic quantities to allow intrinsic access to the geometrical properties. Not all properties offered by TGeo are exposed. Other properties of the corresponding TGeo object can be accessed using the operloaded \texttt{operator->()} of the handle object. TGeo and similarly Geant4 offer a whole palette of primitive shapes, which can be used to construct more complex shapes: \begin{itemize} \item \texttt{Box} shape represented by the \texttt{TGeoBBox} class. To create a new box object call one of the following constructors: \begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} @@ -604,20 +610,82 @@ Shapes are abstract objects with a bounding surface and fixed dimensions. There Box(double x, double y, double z); /// Constructor to be used when creating an anonymous new box object template<typename X, typename Y, typename Z> Box(const X& x, const Y& y, const Z& z); + +/// 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; \end{minted} \item \texttt{Sphere} shape represented by the \texttt{TGeoSphere} class. To create a new sphere object call one of the following constructors: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} +/// Constructor to create a new anonymous object with attribute initialization +Sphere(double rmin, double rmax, + double startTheta= 0.0, double endTheta = M_PI, + double startPhi = 0.0, double endPhi = 2. * M_PI); +/// Constructor to create a new identified object with attribute initialization +Sphere(const std::string& nam, double rmin, double rmax, + double startTheta= 0.0, double endTheta = M_PI, + double startPhi = 0.0, double endPhi = 2. * M_PI); + +/// Accessor: start-phi value +double startPhi() const; +/// Accessor: end-phi value +double endPhi() const; +/// Accessor: start-theta value +double startTheta() const; +/// Accessor: end-theta value +double endTheta() const; +/// Accessor: r-min value +double rMin() const; +/// Accessor: r-max value +double rMax() const; +\end{minted} + \item \texttt{Cone} shape represented by the \texttt{TGeoCone} class. To create a new cone object call one of the following constructors: \begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} /// Constructor to create a new anonymous object with attribute initialization Cone(double z,double rmin1,double rmax1,double rmin2,double 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); + +/// Accessor: delta-z value +double dZ() const; +/// Accessor: r-min-1 value +double rMin1() const; +/// Accessor: r-min-2 value +double rMin2() const; +/// Accessor: r-max-1 value +double rMax1() const; +/// Accessor: r-max-2 value +double rMax2() const; \end{minted} + \item \texttt{ConeSegment} shape represented by the \texttt{TGeoConeSeg} class. To create a new cone segment object call one of the following constructors: \begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} /// Constructor to create a new ConeSegment ConeSegment(double dz, double rmin1, double rmax1, double rmin2, double rmax2, double phi1=0.0, double phi2=2.0*M_PI); +/// Constructor to create a new named ConeSegment object +ConeSegment(const std::string& nam, double dz, double rmin1, double rmax1, + double rmin2, double rmax2, double startPhi = 0.0, double endPhi = 2.0 * M_PI); + +/// Accessor: start-phi value +double startPhi() const; +/// Accessor: end-phi value +double endPhi() const; +/// Accessor: delta-z value +double dZ() const; +/// Accessor: r-min-1 value +double rMin1() const; +/// Accessor: r-min-2 value +double rMin2() const; +/// Accessor: r-max-1 value +double rMax1() const; +/// Accessor: r-max-2 value +double rMax2() const; \end{minted} + \item \texttt{Polycone} shape represented by the \texttt{TGeoPcon} class. To create a new polycone object call one of the following constructors: \begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} /// Constructor to create a new polycone object @@ -631,7 +699,25 @@ Polycone(double start, double delta, const std::vector<double>& rmin, const std::vector<double>& rmax, const std::vector<double>& z); + +/// Accessor: start-phi value +double startPhi() const; +/// Accessor: delta-phi value +double deltaPhi() const; +/// Accessor: z value +double z(int which) const; +/// Accessor: r-min value +double rMin(int which) const; +/// Accessor: r-max value +double rMax(int which) const; +/// Accessor: vector of z-values for Z-planes value +std::vector<double> zPlaneZ() const; +/// Accessor: vector of rMin-values for Z-planes value +std::vector<double> zPlaneRmin() const; +/// Accessor: vector of rMax-values for Z-planes value +std::vector<double> zPlaneRmax() const; \end{minted} + \item \texttt{TubeSegment} shape represented by the \tgeo{TGeoTubeSeg}{\texttt TGeoTubeSeg} class. To create a new tube segment object call one of the following constructors: \begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} Tube(double rmin, double rmax, double z, double deltaPhi=2*M_PI) @@ -643,12 +729,87 @@ Tube(const RMIN& rmin, const RMAX& rmax, const Z& z, const DELTAPHI& deltaPhi) template<typename RMIN, typename RMAX, typename Z, typename STARTPHI, typename DELTAPHI> Tube(const std::string& name, const RMIN& rmin, const RMAX& rmax, const Z& z, const STARTPHI& startPhi, const DELTAPHI& deltaPhi) + +/// Accessor: start-phi value +double startPhi() const; +/// Accessor: end-phi value +double endPhi() const; +/// Accessor: delta-z value +double dZ() const; +/// Accessor: r-min value +double rMin() const; +/// Accessor: r-max value +double rMax() const; +\end{minted} + +\item \texttt{CutTube} shape represented by the \tgeo{TGeoCtub}{\texttt TGeoCtub} class. +To create a new cut tube segment object call one of the following constructors: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} +/// Constructor to create a new cut-tube object with attribute initialization +CutTube(double rmin, double rmax, double dz, double startPhi, double endPhi, + double lx, double ly, double lz, double tx, double ty, double tz); +/// Constructor to create a new identifiable cut-tube object with attribute initialization +CutTube(const std::string& name, + double rmin, double rmax, double dz, double startPhi, double endPhi, + double lx, double ly, double lz, double tx, double ty, double tz); + +/// Accessor: start-phi value +double startPhi() const; +/// Accessor: end-phi value +double endPhi() const; +/// Accessor: delta-z value +double dZ() const; +/// Accessor: r-min value +double rMin() const; +/// Accessor: r-max value +double rMax() const; +/// Accessor: lower normal vector of cut plane +std::vector<double> lowNormal() const; +/// Accessor: upper normal vector of cut plane +std::vector<double> highNormal() const; +\end{minted} + +\item \texttt{EllipticalTube} shape represented by the \tgeo{TGeoEltu}{\texttt TGeoEltu} class. +To create a new elliptical tube segment object call one of the following constructors: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} +/// Constructor to create a new anonymous tube object with attribute initialization +EllipticalTube(double a, double b, double dz); +/// Constructor to create a new identified tube object with attribute initialization +EllipticalTube(const std::string& nam, double a, double b, double dz); + +/// Accessor: delta-z value +double dZ() const; +/// Accessor: a value (semi axis along x) +double a() const; +/// Accessor: b value (semi axis along y) +double b() const; \end{minted} -\item \texttt{Trapezoid} shape represented by the \texttt{TGeoTrd} class. To create a new trapezoid object call one of the following constructors: + +\item \texttt{Trapezoid} shape represented by the \texttt{TGeoTrd2} class. To create a new trapezoid object call one of the following constructors: \begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} /// 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> +Trd2(X1 x1, X2 x2, Y1 y1, Y2 y2, Z z); +/// Constructor to create a new identified object with attribute initialization +Trd2(const std::string& nam, double x1, double x2, double y1, double y2, double z); +/// Constructor to create a new identified object with attribute initialization +template <typename X1,typename X2,typename Y1,typename Y2,typename Z> +Trd2(const std::string& nam, X1 x1, X2 x2, Y1 y1, Y2 y2, Z z); + +/// Accessor: delta-x1 value +double dX1() const; +/// Accessor: delta-x2 value +double dX2() const; +/// Accessor: delta-y1 value +double dY1() const; +/// Accessor: delta-y2 value +double dY2() const; +/// Accessor: delta-z value +double dZ() const; \end{minted} + \item \texttt{Trap} shape represented by the \tgeo{TGeoTrap}{\texttt TGeoTrap} class. To create a new trap object call one of the following constructors: \begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} /// Constructor to create a new anonymous object with attribute initialization @@ -657,17 +818,81 @@ Trap(double z,double theta,double phi, 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); + +/// Accessor: phi value +double phi() const; +/// Accessor: theta value +double theta() const; +/// Angle between centers of x edges and y axis at low z +double alpha1() const; +/// Angle between centers of x edges and y axis at low z +double alpha2() const; +/// Half length in x at low z and y low edge +double bottomLow1() const; +/// Half length in x at high z and y low edge +double bottomLow2() const; +/// Half length in x at low z and y high edge +double topLow1() const; +/// Half length in x at high z and y high edge +double topLow2() const; +/// Half length in y at low z +double high1() const; +/// Half length in y at high z +double high2() const; +/// Half length in dZ +double dZ() const; \end{minted} + \item \texttt{Torus} shape represented by the \tgeo{TGeoTorus}{\texttt TGeoTorus} class. To create a new torus object call one of the following constructors: \begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} /// 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); + +/// Accessor: start-phi value +double startPhi() const; +/// Accessor: delta-phi value +double deltaPhi() const; + +/// Accessor: r value (torus axial radius) +double r() const; +/// Accessor: r-min value (inner radius) +double rMin() const; +/// Accessor: r-max value (outer radius) +double rMax() const; \end{minted} + \item \texttt{Paraboloid} shape represented by the \tgeo{TGeoParaboloid}{\texttt TGeoParaboloid} class. To create a new paraboloid object call one of the following constructors: \begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} /// Constructor to create a new anonymous object with attribute initialization Paraboloid(double r_low, double r_high, double delta_z); + +/// Accessor: delta-z value +double dZ() const; +/// Accessor: r-min value +double rLow() const; +/// Accessor: r-max value +double rHigh() const; +\end{minted} + +\item \texttt{Hyperboloid} shape represented by the \tgeo{TGeoHype}{\texttt TGeoHype} class. To create a new hyperboloid object call one of the following constructors: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} +/// Constructor to create a new anonymous object with attribute initialization +Hyperboloid(double rin, double stin, double rout, double stout, double dz); +/// Constructor to create a new identified object with attribute initialization +Hyperboloid(const std::string& nam, double rin, double stin, double rout, double stout, double dz); + +/// Accessor: delta-z value +double dZ() const; +/// Accessor: r-min value +double rMin() const; +/// Accessor: r-max value +double rMax() const; +/// Stereo angle for inner surface +double stereoInner() const; +/// Stereo angle for outer surface +double stereoOuter() const; \end{minted} + \item \texttt{PolyhedraRegular} shape represented by the \texttt{TGeoPgon} class. To create a new polyhedron object call one of the following constructors: \begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} /// Constructor to create a new object. Phi(start)=0, deltaPhi=2PI, Z-planes at +-zlen/2 @@ -676,7 +901,122 @@ PolyhedraRegular(int nsides, double rmin, double rmax, double zlen); PolyhedraRegular(int nsides, double rmin, double rmax, double zplanes[2]); /// Constructor to create a new object with phi_start, deltaPhi=2PI, Z-planes at +-zlen/2 PolyhedraRegular(int nsides, double phi_start, double rmin, double rmax, double zlen); + +/// Accessor: Number of edges +int numEdges() const; +/// Accessor: start-phi value +double startPhi() const; +/// Accessor: delta-phi value +double deltaPhi() const; + +/// Accessor: r-min value +double z(int which) const; +/// Accessor: r-min value +double rMin(int which) const; +/// Accessor: r-max value +double rMax(int which) const; + +/// Accessor: vector of z-values for Z-planes value +std::vector<double> zPlaneZ() const; +/// Accessor: vector of rMin-values for Z-planes value +std::vector<double> zPlaneRmin() const; +/// Accessor: vector of rMax-values for Z-planes value +std::vector<double> zPlaneRmax() const; +\end{minted} + +\item \texttt{Polyhedra} shape represented by the \texttt{TGeoPgon} class. To create a new generic polyhedron object call one of the following constructors: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} +/// Constructor to create a new object. Phi(start), deltaPhi, Z-planes at specified positions +Polyhedra(int nsides, double start, double delta, const std::vector<double>& z, const std::vector<double>& r); +/// Constructor to create a new object. Phi(start), deltaPhi, Z-planes at specified positions +Polyhedra(int nsides, double start, double delta, + const std::vector<double>& z, const std::vector<double>& rmin, const std::vector<double>& rmax) + +/// Accessor: Number of edges +int numEdges() const; +/// Accessor: start-phi value +double startPhi() const; +/// Accessor: delta-phi value +double deltaPhi() const; + +/// Accessor: z value +double z(int which) const; +/// Accessor: r-min value +double rMin(int which) const; +/// Accessor: r-max value +double rMax(int which) const; + +/// Accessor: vector of z-values for Z-planes value +std::vector<double> zPlaneZ() const; +/// Accessor: vector of rMin-values for Z-planes value +std::vector<double> zPlaneRmin() const; +/// Accessor: vector of rMax-values for Z-planes value +std::vector<double> zPlaneRmax() const; +\end{minted} + +\item \texttt{ExtrudedPolygon} shape represented by the \texttt{TGeoXtru} class. To create a new extruded polygon object call one of the following constructors: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} +/// Constructor to create a new object. +ExtrudedPolygon(const std::vector<double> & pt_x, const std::vector<double> & pt_y, + const std::vector<double> & sec_z, const std::vector<double> & sec_x, const std::vector<double> & sec_y, + const std::vector<double> & zscale); +/// Constructor to create a new identified object. +ExtrudedPolygon(const std::string& nam, + const std::vector<double> & pt_x, const std::vector<double> & pt_y, + const std::vector<double> & sec_z, const std::vector<double> & sec_x, const std::vector<double> & sec_y, + const std::vector<double> & zscale); + +/// Access vector of x parameters of the various vetrices +std::vector<double> x() const; +/// Access vector of x parameters of the various vetrices +std::vector<double> y() const; +/// Access vector of z-values of the z plane parameters +std::vector<double> z() const; +/// Access vector of x-offsets of the z plane parameters +std::vector<double> zx() const; +/// Access vector of y-offsets of the z plane parameters +std::vector<double> zy() const; +/// Access vector of z-scale parameters +std::vector<double> zscale() const; +\end{minted} + +\item \texttt{EightPointSolid} shape represented by the \texttt{TGeoArb8} class. To create a generic solid defined by eight vertices call one of the following constructors: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} +/// Constructor to create a new anonymous object with attribute initialization +EightPointSolid(double dz, const double* vertices); +/// Constructor to create a new identified object with attribute initialization +EightPointSolid(const std::string& nam, double dz, const double* vertices); + +/// Accessor: delta-z value +double dZ() const; +/// Accessor: all vertices as STL vector +std::vector<double> vertices() const; +/// Accessor: single vertex +std::pair<double, double> vertex(int which) const; +\end{minted} + +\item \texttt{TessellatedSolid} shape represented by the \texttt{TGeoTessellated} class. To create a generic solid defined by eight vertices call one of the following constructors: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} +/// Constructor to create a new anonymous object with attribute initialization +TessellatedSolid(int num_facets); +/// Constructor to create a new identified object with attribute initialization +TessellatedSolid(const std::vector<Vertex_t>& vertices); +/// Constructor to create a new anonymous object with attribute initialization +TessellatedSolid(const std::string& nam, int num_facets); +/// Constructor to create a new identified object with attribute initialization +TessellatedSolid(const std::string& nam, const std::vector<Vertex_t>& vertices); + +/// Add new facet to the shape +bool addFacet(const Vertex_t& pt0, const Vertex_t& pt1, const Vertex_t& pt2) const; +/// Add new facet to the shape +bool addFacet(const Vertex_t& pt0, const Vertex_t& pt1, const Vertex_t& pt2, const Vertex_t& pt3) const; +/// Add new facet to the shape. Call only if the tessellated shape was constructed with vertices +bool addFacet(const int pt0, const int pt1, const int pt2) const; +/// Add new facet to the shape. Call only if the tessellated shape was constructed with vertices +bool addFacet(const int pt0, const int pt1, const int pt2, const int pt3) const; \end{minted} +Tesselated shapes play an essential role to support reading Computer Aided Design files in DD4hep. Such support is implemented in the DD4hep subpackage \texttt{DDCAD}. + \end{itemize} Besides the primitive shapes three types of boolean shapes (described in TGeo by the \texttt{TGeoCompositeShape} class) are supported: @@ -710,6 +1050,7 @@ All three boolean shapes have constructors as shown here for the \texttt{UnionSo /// Constructor to create a new object. Placement by a generic transformation within the mother UnionSolid(const Solid& shape1, const Solid& shape2, const Transform3D& pos); \end{minted} +\newpage \subsection{Shape factories} Sometimes it is useful to create shapes in an ``abstract'' way e.g. to define areas in the detector. To create such shapes a factory method was implemented, which allows to create a valid shape handle given a valid \texttt{XML} element providing the required attributes. The factory methods are invoked using from \texttt{XML} elements of the following form: @@ -733,6 +1074,40 @@ The required arguments for the various shapes are then: \end{minted} fulfilling a constructor of the type: \texttt{Box(dim.dx(), dim.dy(), dim.dz())}. +\item For a Sphere the following constructor must be fulfilled: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} + Sphere(e.rmin(0), e.rmax(), e.starttheta(0), e.endtheta(), e.startphi(0), e.endphi()); +\end{minted} +The corrsponding XML snippet looks like this: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} + <some_element type="Sphere" rmin="value" rmax="value" starttheta="value" endtheta="value" startphi="value" endphi="value"/> +\end{minted} +where the above default values for the \texttt{XML} attributes \texttt{rmin=0}, \texttt{starttheta=0}, \texttt{endtheta=$\pi$}, +\texttt{startphi=0}, \texttt{endphi=$2\times\pi$}. + +\item For a Cone the following constructor must be fulfilled: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} + double rmi1 = e.rmin1(0), rma1 = e.rmax1(); + Cone(e.z(0), rmi1, rma1, e.rmin2(rmi1), e.rmax2(rma1)); +\end{minted} +The corrsponding XML snippet looks like this: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} + <some_element type="Cone" z="value" rmin1="value" rmax1="value" rmin2="value" rmax2="value"/> +\end{minted} +where the above default values for the \texttt{XML} attributes \texttt{rmin1=0}, \texttt{rmin2=rmin1}, \texttt{rmax2=rmax1}. + +\item For a ConeSegment the following constructor must be fulfilled: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} +ConeSegment(e.dz(), e.rmin1(0), e.rmax1(), e.rmin2(), e.rmax2(), e.startphi(), e.deltaphi()) +\end{minted} +where the above default values for the \texttt{XML} attributes \texttt{rmin1=0}, \texttt{rmin2=0}, +\texttt{rmax2=rmax1}, \texttt{startphi=0} and \texttt{deltaphi=$2\times\pi$} +are used if not explicitly stated in the \texttt{XML} element \texttt{e}. +The corrsponding XML snippet looks like this: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} + <some_element type="ConeSegment" rmin1="value" rmax="value" rmin2="value" rmax2="value" dz="value" startphi="value" deltaphi="value"/> +\end{minted} + \item For a Polycone: \vspace{-0.2cm} \begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{xml} @@ -743,52 +1118,165 @@ fulfilling a constructor of the type: \texttt{Box(dim.dx(), dim.dy(), dim.dz())} <zplane z="z-value" rmin="rmin-value" rmax="rmax-value"/> </some_element> \end{minted} +where the above default values for the \texttt{XML} attributes \texttt{startphi=0} and +\texttt{deltaphi=$2\times\pi$} and for each of the the z-planes \texttt{rmin=0} +are used if not explicitly stated in the \texttt{XML} element \texttt{e}. -\item For a ConeSegment the following constructor must be fulfilled: +\item For a Tube the constructor is: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} +Tube(e.rmin(0.0), e.rmax(), e.dz(), e.startphi(), e.deltaphi()) +\end{minted} +The corrsponding XML snippet looks like this: \begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} -ConeSegment(e.rmin(0.0), e.rmax(), e.z(0.0), e.startphi(0.0), e.deltaphi(2*M_PI))} + <some_element type="Tube" rmin="value" rmax="value" dz="value" startphi="value" deltaphi="value"/> \end{minted} -where the above default values for the \texttt{XML} attributes \texttt{rmin}, \texttt{z}, \texttt{startphi} and \texttt{deltaphi} are used if not explicitly stated in the \texttt{XML} element \texttt{e}. +where the defaults are \texttt{rmin=0}, \texttt{startphi=0} and \texttt{deltaphi=$2\times\pi$}. -\item For a Tube the constructor is: +\item For a CutTube the constructor is: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} +CutTube(e.rmin(0.0), e.rmax(), e.dz(), e.phi1(), e.phi2(), e.lx(), e.ly(), e.lz(), e.tx(), e.ty(), e.tz()) +\end{minted} +The corrsponding XML snippet looks like this: \begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} -Tube(e.rmin(0.0), e.rmax(), e.z(0.0), e.startphi(0.0), e.deltaphi(2*M_PI)) + <some_element type="CutTube" rmin="value" rmax="value" dz="value" phi1="value" phi2="value" + lx="value" ly="value" lz="value" tx="value" ty="value" tz="value"/> \end{minted} +where the defaults are \texttt{rmin=0}. -\item For a Cone the constructor is: +\item For a EllipticalTube the constructor is: \begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} -double rmi1 = e.rmin1(0.0), rma1 = e.rmax1(); -Cone(e.z(0.0), rmi1, rma1, e.rmin2(rmi1), e.rmax2(rma1)) +EllipticalTube(e.a(),e.b(),e.dz()); +\end{minted} +The corrsponding XML snippet looks like this: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} + <some_element type="EllipticalTube" dz="value" a="value" b="value"/> \end{minted} \item For a Trap the constructor is: if \texttt{dz} is specified: \begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} Trap(e.dz(), e.dy(), e.dx(),_toDouble(_Unicode(pLTX))) \end{minted} -Otherwise: +Alternatively, if the tag \texttt{dz} is not present: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} +Trap(e.z(0.0), e.theta(), e.phi(0), e.y1(), e.x1(), e.x2(), e.alpha1(), e.y2(), e.x3(), e.x4(), e.alpha2()) +\end{minted} +The corrsponding XML snippet looks like this: \begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} -Trap(e.z(0.0), e.theta(), e.phi(0), e.y1(), e.x1(), e.x2(), e.alpha(), e.y2(), e.x3(), e.x4(), e.alpha2()) + <some_element type="Trap" z="value" theta="value" phi="value" + y1="value" x1="value" x2="value" alpha1="value" + y2="value" x3="value" x4="value" alpha2="value"/> \end{minted} +Defaults are: \texttt{theta=0}, \texttt{phi=0}, \texttt{alpha1=0}, \texttt{alpha2=0} + \item For a Trapezoid the constructor is: \begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} -Trapezoid(e.x1(), e.x2(), e.y1(), e.y2(), e.z(0.0)) +Trapezoid(e.x1(), e.x2(), e.y(), e.z(0)) +\end{minted} +The corrsponding XML snippet looks like this: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} + <some_element type="Trapezoid" x1="value" x2="value" y="value" z="value"/> +\end{minted} +The Trapezoid is also aliased to Trd2. + +\item For a simplified Trapezoid, the Trd1 the constructor is: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} +Trd1(e.x1(), e.x2(), e.y1(), e.y2(), e.z(0)); +\end{minted} +The corrsponding XML snippet looks like this: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} + <some_element type="Trd1" x1="value" x2="value" y1="value" y2="value" z="value"/> \end{minted} + \item For a Torus the constructor is: \begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} -Torus(e.r(), e.rmin(), e.rmax(), e.phi(M_PI), e.deltaphi(2.*M_PI)) +Torus(e.r(), e.rmin(), e.rmax(), e.startphi(), e.deltaphi()) +\end{minted} +The corrsponding XML snippet looks like this: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} + <some_element type="Torus" r="value" rmin="value" rmax="value" startphi="value" deltaphi="value"/> \end{minted} +Defaults are: \texttt{rmin=0}, \texttt{startphi=$\pi$}, \texttt{deltaphi=$2\times\pi$}. + \item For a Sphere the constructor is: \begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} -Sphere(e.rmin(), e.rmax(), e.deltatheta(M_PI), e.phi(0e0),e.deltaphi(2.*M_PI)) +Sphere(e.rmin(), e.rmax(), e.starttheta(), e.deltatheta(), e.startphi(), e.deltaphi()) +\end{minted} +The corrsponding XML snippet looks like this: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} + <some_element type="Sphere" rmin="value" rmax="value" + starttheta="value" deltatheta="value" startphi="value" deltaphi="value"/> \end{minted} +Defaults are: \texttt{rmin=0}, \texttt{starttheta=0}, \texttt{deltatheta=$\pi$}, +\texttt{startphi=0}, \texttt{deltaphi=$2\times\pi$}. + \item For a Paraboloid the constructor is: \begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} -Paraboloid(e.rmin(0.0), e.rmax(), e.dz()) +Paraboloid(e.rmin(0), e.rmax(), e.dz()) +\end{minted} +The corrsponding XML snippet looks like this: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} + <some_element type="Paraboloid" rmin="value" rmax="value" dz="value"/> +\end{minted} +Defaults are: \texttt{rmin=0}. + +\item For a Hyperboloid the constructor is: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} +Hyperboloid(e.rmin(0), e.inner_stereo(), e.rmax(), e.outer_stereo, e.dz()) +\end{minted} +The corrsponding XML snippet looks like this: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} + <some_element type="Hyperboloid" rmin="value" inner_stereo="value" rmax="value" outer_stereo=="value" dz="value"/> \end{minted} + \item For a PolyhedraRegular the constructor is: \begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} PolyhedraRegular(e.numsides(), e.rmin(), e.rmax(), e.dz()) \end{minted} +The corrsponding XML snippet looks like this: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} + <some_element type="PolyhedraRegular" numsides="value" rmin="value" rmax="value" dz="value"/> +\end{minted} + +\item For a generic Polyhedra the constructor is: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} +PolyhedraRegular(e.numsides(), e.rmin(), e.startphi(), e.deltaphi(), vector<z>, vector<rmin>, vector<rmax>); +\end{minted} +The corrsponding XML snippet looks like this: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} + <some_element type="Polyhedra" numsides="value" startphi="value" deltaphi="value"> + <plane z="z-value" rmin="rmin-value" rmax="rmax-value"/> + <plane z="z-value" rmin="rmin-value" rmax="rmax-value"/> + ... + <some_element/> +\end{minted} + +\item For a generic eight point solid the constructor is: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} +EightPointSolid(e.dz(), vertices); +\end{minted} +The corrsponding XML snippet looks like this: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} + <some_element type="EightPointSolid" dz="value"> + <vertex x="x-value" y="y-value"/> + <vertex x="x-value" y="y-value"/> + ...exactly 8 vertices in total... + <some_element/> +\end{minted} + +\item For a boolean shape the xml snippet is nested and contains 2 shape descriptions: +\begin{minted}[frame=single,framesep=3pt,breaklines=true,tabsize=2,linenos,fontsize=\small]{c++} + <some_element type="BooleanShape" operation="value"> + <shape ....description of left hand shape/> + <shape ....description of right hand shape/> + + <transformation ...generic transformation description.../> + <!-- OR --> + <position x="value" y="value" z="value"/> + <rotation x="value" y="value" z="value"/> + <some_element/> +\end{minted} +valid operations are \texttt{subtraction}, \texttt{union} and \texttt{intersection}. + \end{itemize} \section{Volumes and Placements}