DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Objects.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation for LCD
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 #ifndef DD4HEP_GEOMETRY_OBJECTS_H
14 #define DD4HEP_GEOMETRY_OBJECTS_H
15 
16 // Framework include files
17 #include "DD4hep/Handle.h"
18 #include "DD4hep/NamedObject.h"
19 
20 // Forward declarations
21 class TMap;
22 class TGeoElement;
23 class TGeoMaterial;
24 class TGeoMedium;
25 class TGeoMatrix;
26 class TGeoRotation;
27 class TGeoTranslation;
28 class TGeoPhysicalNode;
29 class TGeoIdentity;
30 
31 #ifdef __GNUC__
32 #pragma GCC diagnostic push
33 #pragma GCC diagnostic ignored "-Wdeprecated" // Code that causes warning goes here
34 #endif
35 // ROOT include files
36 #include "TGeoPhysicalNode.h"
37 #include "Math/Vector3D.h"
38 #include "Math/Transform3D.h"
39 #include "Math/Translation3D.h"
40 #include "Math/RotationX.h"
41 #include "Math/RotationY.h"
42 #include "Math/RotationZ.h"
43 #include "Math/Rotation3D.h"
44 #include "Math/RotationZYX.h"
45 #include "Math/EulerAngles.h"
46 #include "Math/VectorUtil.h"
47 #ifdef __GNUC__
48 #pragma GCC diagnostic pop
49 #endif
50 
51 // C/C++ include files
52 #include <set>
53 #include <cmath>
54 #include <limits>
55 #include <vector>
56 
57 #define _USE_MATH_DEFINES
58 #ifndef M_PI
59 #define M_PI 3.14159265358979323846
60 #endif
61 
63 namespace DD4hep {
64 
66  namespace Geometry {
67 
68  // Forward declarations
69  class LCDD;
70  class IDDescriptor;
71  class VisAttrObject;
72  class HeaderObject;
73  class ConstantObject;
74  class RegionObject;
76 
77  typedef ROOT::Math::XYZVector Position;
78  template <class V> V RotateX(const V& v, double a) {
80  }
81  template <class V> V RotateY(const V& v, double a) {
83  }
84  template <class V> V RotateZ(const V& v, double a) {
86  }
87 
113 
115  TGeoIdentity* identityTransform();
116 
117 
119 
124  class Author: public Ref_t {
125  public:
130  : Ref_t() {
131  }
133  Author(const Author& e)
134  : Ref_t(e) {
135  }
137  template <typename Q>
139  : Ref_t(e) {
140  }
142  Author(LCDD& doc);
145  if ( this != & e ) {
146  m_element = e.m_element;
147  }
148  return *this;
149  }
151  std::string authorName() const;
153  void setAuthorName(const std::string& nam);
155  std::string authorEmail() const;
157  void setAuthorEmail(const std::string& addr);
158  };
159 
161 
168  class Header: public Handle<HeaderObject> {
169  public:
173  : Handle<HeaderObject>() {
174  }
176  Header(const Header& e)
177  : Handle<HeaderObject>(e) {
178  }
180  template <typename Q> Header(const Handle<Q>& e)
181  : Handle<HeaderObject>(e) {
182  }
184  Header(const std::string& author, const std::string& url);
187  if ( this != & e ) {
188  m_element = e.m_element;
189  }
190  return *this;
191  }
193  const std::string name() const;
195  void setName(const std::string& new_name);
197  const std::string title() const;
199  void setTitle(const std::string& new_title);
201  const std::string& author() const;
203  void setAuthor(const std::string& new_author);
205  const std::string& url() const;
207  void setUrl(const std::string& new_url);
209  const std::string& status() const;
211  void setStatus(const std::string& new_status);
213  const std::string& version() const;
215  void setVersion(const std::string& new_version);
217  const std::string& comment() const;
219  void setComment(const std::string& new_comment);
220  };
221 
223 
231  class Constant: public Handle<ConstantObject> {
232  public:
237  : Handle<ConstantObject> () {
238  }
241  : Handle<ConstantObject> (e) {
242  }
244  template <typename Q>
246  : Handle<ConstantObject> (e) {
247  }
249  Constant(const std::string& name);
251  Constant(const std::string& name, const std::string& val, const std::string& typ="number");
253  std::string dataType() const;
255  std::string toString() const;
256  };
257 
259 
267  class Atom: public Handle<TGeoElement> {
268  public:
270  typedef TGeoElement Object;
273  : Handle<Object>() {
274  }
275 #ifndef __CINT__
276  Atom(const Handle<Object>& e)
278  : Handle<Object>(e) {
279  }
280 #endif
281  template <typename Q>
283  Atom(const Handle<Q>& e)
284  : Handle<Object>(e) {
285  }
287  Atom(const std::string& name, const std::string& formula, int Z, int N, double density);
288  };
289 
291 
300  class Material: public Handle<TGeoMedium> {
301  public:
303  typedef TGeoMedium Object;
304 
307  : Handle<Object>() {
308  }
309 #ifndef __CINT__
310  Material(const Handle<Object>& e)
312  : Handle<Object>(e) {
313  }
314 #endif
315  template <typename Q>
318  : Handle<Object>(e) {
319  }
321  double Z() const ;
323  double A() const ;
325  double density() const ;
327  std::string toString() const;
329  double radLength() const;
331  double intLength() const;
332  };
333 
335 
341  class VisAttr: public Handle<VisAttrObject> {
342  public:
343  enum Style {
344  SOLID = 0x1, WIREFRAME = 0x2, DASHED = 0x2, LAST_STYLE
345  };
349  : Handle<Object>() {
350  }
352  VisAttr(const VisAttr& e)
353  : Handle<Object>(e) {
354  }
355 #ifndef __CINT__
356  VisAttr(const Handle<Object>& e)
358  : Handle<Object>(e) {
359  }
360 #endif
361  template <typename Q>
364  : Handle<Object>(e) {
365  }
367  VisAttr(const std::string& name);
369  VisAttr(const char* name);
371  VisAttr& operator=(const VisAttr& attr) {
372  m_element = attr.m_element;
373  return *this;
374  }
375 
377  bool showDaughters() const;
379  void setShowDaughters(bool value);
380 
382  bool visible() const;
384  void setVisible(bool value);
385 
387  int lineStyle() const;
389  void setLineStyle(int style);
390 
392  int drawingStyle() const;
394  void setDrawingStyle(int style);
395 
397  float alpha() const;
399  void setAlpha(float value);
400 
402  int color() const;
404  void setColor(float red, float green, float blue);
405 
407  bool rgb(float& red, float& green, float& blue) const;
408 
410  std::string toString() const;
411  };
412 
414 
420  class AlignmentEntry: public Handle<TGeoPhysicalNode> {
421  public:
424  template <typename Q>
426  : Base(h) {
427  }
429  AlignmentEntry(const std::string& path);
431  int align(const Position& pos, bool check = false, double overlap = 0.001);
433  int align(const RotationZYX& rot, bool check = false, double overlap = 0.001);
435  int align(const Position& pos, const RotationZYX& rot, bool check = false, double overlap = 0.001);
436  };
437 
439 
444  class Limit {
445  public:
446  std::string particles;
447  std::string name;
448  std::string unit;
449  std::string content;
450  double value;
453  : particles(), name(), unit(), content(), value(0.0) {
454  }
456  Limit(const Limit& c)
457  : particles(c.particles), name(c.name), unit(c.unit), content(c.content), value(c.value) {
458  }
460  Limit& operator=(const Limit& c);
462  bool operator==(const Limit& c) const;
464  bool operator<(const Limit& c) const;
466  std::string toString() const;
467  };
468 
470 
475  class LimitSet: public Handle<LimitSetObject> {
476  public:
480  : Handle<LimitSetObject>() {
481  }
484  : Handle<LimitSetObject>(e) {
485  }
486 #ifndef __CINT__
489  : Handle<LimitSetObject>(e) {
490  }
491 #endif
492  template <typename Q>
495  : Handle<LimitSetObject>(e) {
496  }
499  m_element = c.m_element;
500  return *this;
501  }
503  LimitSet(const std::string& name);
505  bool addLimit(const DD4hep::Geometry::Limit& limit);
507  const std::set<DD4hep::Geometry::Limit>& limits() const;
508  };
509 
511 
516  class Region: public Handle<RegionObject> {
517  public:
522  : Handle<Object>() {
523  }
525  Region(const Region& e)
526  : Handle<Object>(e) {
527  }
528 #ifndef __CINT__
531  : Handle<Object>(e) {
532  }
533 #endif
534  template <typename Q>
537  : Handle<Object>(e) {
538  }
540  Region(const std::string& name);
542  Region& operator=(const Region& c) {
543  m_element = c.m_element;
544  return *this;
545  }
546 
547  Region& setStoreSecondaries(bool value);
548  Region& setThreshold(double value);
549  Region& setCut(double value);
551  std::vector<std::string>& limits() const;
552 
554  double cut() const;
556  double threshold() const;
558  bool storeSecondaries() const;
559  };
560 
561  } /* End namespace Geometry */
562 } /* End namespace DD4hep */
563 
564 #include "Math/Vector4D.h"
565 #include "Math/Point3D.h"
566 
567 namespace ROOT {
568  namespace Math {
571  inline double operator *(const Position& l, const Position& r) {
572  return std::sqrt(l.X() * r.X() + l.Y() * r.Y() + l.Z() * r.Z());
573  }
575  inline double mean_length(const Position& p1, const Position& p2) {
576  return 0.5 * (p1.R() + p2.R()) / 2.0;
577  }
579  inline Position mean_direction(const Position& p1, const Position& p2) {
580  return 0.5 * (p1 + p2);
581  }
582 
583  // These operators are used for component properties.
584  // The implementation is in the parsers, but since the parsers
585  // do not have public include files, they are defined here.
586 
588  bool operator<(const XYZPoint& a, const XYZPoint& b);
590  bool operator<(const XYZVector& a, const XYZVector& b);
592  bool operator<(const PxPyPzEVector& a, const PxPyPzEVector& b);
593  }
594 }
595 
596 #endif /* DD4HEP_GEOMETRY_OBJECTS_H */
Handle< TGeoPhysicalNode > Base
Definition: Objects.h:422
Constant(const Constant &e)
Constructorto be used for assignment from a handle.
Definition: Objects.h:240
std::string toString() const
Conversion to a string representation.
Definition: Objects.cpp:414
Atom()
Default constructor.
Definition: Objects.h:272
Limit & operator=(const Limit &c)
Assignment operator.
Definition: Objects.cpp:386
double operator*(const Position &l, const Position &r)
Dot product of 3-vectors.
Definition: Objects.h:571
Constant()
Default constructor.
Definition: Objects.h:236
VisAttrObject Object
Definition: Objects.h:346
void setShowDaughters(bool value)
Set Flag to show/hide daughter elements.
Definition: Objects.cpp:272
const char * name() const
Access the object name (or "" if not supported by the object)
Definition: Handle.inl:36
Header(const Handle< Q > &e)
Constructor to be used when reading the already parsed DOM tree.
Definition: Objects.h:180
Handle class describing a material.
Definition: Objects.h:300
bool storeSecondaries() const
Access secondaries flag.
Definition: Objects.cpp:480
Handle class describing an element in the periodic table.
Definition: Objects.h:267
Region & operator=(const Region &c)
Assignment operator.
Definition: Objects.h:542
void setUrl(const std::string &new_url)
Accessor: set object url.
Definition: Objects.cpp:95
LimitSet(const Handle< Q > &e)
Constructor to be used when reading the already parsed DOM tree.
Definition: Objects.h:494
const std::set< DD4hep::Geometry::Limit > & limits() const
Accessor to limits container.
Definition: Objects.cpp:434
Author(const Handle< Q > &e)
Constructor to be used when assigning already valid handle.
Definition: Objects.h:138
double cut() const
Access cut value.
Definition: Objects.cpp:470
Constant(const Handle< Q > &e)
Constructor to be used when reading the already parsed DOM tree.
Definition: Objects.h:245
Concrete object implementation of the Region Handle.
NamedObject Object
Definition of the implementation type.
Definition: Objects.h:127
void setName(const std::string &new_name)
Accessor: set object name.
Definition: Objects.cpp:75
double intLength() const
Access the interaction length of the underlying material.
Definition: Objects.cpp:225
VisAttr()
Default constructor.
Definition: Objects.h:348
Region(const Region &e)
Copy Constructor.
Definition: Objects.h:525
Handle class describing the basic information about geometry objects as it is defined in LCDD...
Definition: Objects.h:168
std::string authorName() const
Access the auhor's name.
Definition: Objects.cpp:44
const std::string & version() const
Accessor to object version.
Definition: Objects.cpp:120
RegionObject Object
Implemeting class.
Definition: Objects.h:519
LimitSet(const LimitSet &e)
Copy constructor for handle.
Definition: Objects.h:483
const std::string & status() const
Accessor to object status.
Definition: Objects.cpp:110
LimitSet()
Constructor to be used when reading the already parsed DOM tree.
Definition: Objects.h:479
return e
Definition: Volumes.cpp:297
ROOT::Math::RotationY RotationY
Definition: Objects.h:102
Header & operator=(const Header &e)
Assignment operator.
Definition: Objects.h:186
Concrete object implementation for the Constant handle.
void setColor(float red, float green, float blue)
Set object color.
Definition: Objects.cpp:326
void setComment(const std::string &new_comment)
Accessor: set object comment.
Definition: Objects.cpp:135
Region & setThreshold(double value)
Definition: Objects.cpp:454
double mean_length(const Position &p1, const Position &p2)
Calculate the mean length of two vectors.
Definition: Objects.h:575
bool rgb(float &red, float &green, float &blue) const
Get RGB values of the color (if valid)
Definition: Objects.cpp:333
Region & setStoreSecondaries(bool value)
Definition: Objects.cpp:449
const std::string title() const
Accessor to object title.
Definition: Objects.cpp:80
std::string content
Definition: Objects.h:449
Implementation of a named object.
Definition: NamedObject.h:31
const std::string name() const
Accessor to object name.
Definition: Objects.cpp:70
HeaderObject Object
Definition: Objects.h:170
const std::string & url() const
Accessor to object url.
Definition: Objects.cpp:90
Header(const Header &e)
Constructorto be used for assignment from a handle.
Definition: Objects.h:176
std::vector< std::string > & limits() const
Access references to user limits.
Definition: Objects.cpp:465
ROOT::Math::RotationZYX RotationZYX
Definition: Objects.h:98
bool operator<(const XYZPoint &a, const XYZPoint &b)
Allow point insertion of a point in maps.
DD4hep::Geometry::Position Position
Definition: Objects.h:569
std::string particles
Definition: Objects.h:446
bool visible() const
Get visibility flag.
Definition: Objects.cpp:277
std::string toString() const
String representation of this object.
Definition: Objects.cpp:344
Deprecated: Handle class describing an alignment entry.
Definition: Objects.h:420
TGeoIdentity * identityTransform()
Access the TGeo identity transformation
V RotateZ(const V &v, double a)
Definition: Objects.h:84
void setTitle(const std::string &new_title)
Accessor: set object title.
Definition: Objects.cpp:85
std::string toString() const
String representation of this object.
Definition: Objects.cpp:237
Position mean_direction(const Position &p1, const Position &p2)
Calculate the mean direction of two vectors.
Definition: Objects.h:579
ROOT::Math::Rotation3D Rotation3D
Definition: Objects.h:106
double threshold() const
Access production threshold.
Definition: Objects.cpp:475
void setAuthorEmail(const std::string &addr)
Set the author's email address.
Definition: Objects.cpp:59
Limit()
Default constructor.
Definition: Objects.h:452
Limit(const Limit &c)
Copy constructor.
Definition: Objects.h:456
Region(const Handle< Q > &e)
Constructor to be used when assigning handle.
Definition: Objects.h:536
void setAuthorName(const std::string &nam)
Set the author's name.
Definition: Objects.cpp:49
double radLength() const
Access the radiation length of the underlying material.
Definition: Objects.cpp:213
void setAuthor(const std::string &new_author)
Accessor: set object author.
Definition: Objects.cpp:105
double A() const
atomic number of the underlying material
Definition: Objects.cpp:189
std::string name
Definition: Objects.h:447
VisAttr(const VisAttr &e)
Copy constructor for handle.
Definition: Objects.h:352
int lineStyle() const
Get line style.
Definition: Objects.cpp:287
const std::string & comment() const
Accessor to object comment.
Definition: Objects.cpp:130
ROOT::Math::XYZVector Position
Definition: Objects.h:75
Concrete object implementation for the Header handle.
Author(const Author &e)
Constructorto be used for assignment from a handle.
Definition: Objects.h:133
Material()
Default constructor.
Definition: Objects.h:306
TGeoMedium Object
Definition of the implementation type.
Definition: Objects.h:303
const std::string & author() const
Accessor to object author.
Definition: Objects.cpp:100
std::string unit
Definition: Objects.h:448
ROOT::Math::RotationZ RotationZ
Definition: Objects.h:100
Author()
Default constructor.
Definition: Objects.h:129
Atom(const Handle< Q > &e)
Constructor to be used when creating from a object handle.
Definition: Objects.h:283
Handle< NamedObject > Ref_t
Default Ref_t definition describing named objects.
Definition: Handle.h:176
Region & setCut(double value)
Definition: Objects.cpp:459
Handle class describing an author entity.
Definition: Objects.h:124
Small object describing a limit structure acting on a particle type.
Definition: Objects.h:444
double Z() const
proton number of the underlying material
Definition: Objects.cpp:178
void setVersion(const std::string &new_version)
Accessor: set object version.
Definition: Objects.cpp:125
std::string dataType() const
Access the constant.
Definition: Objects.cpp:150
Header()
Default constructor.
Definition: Objects.h:172
Handle class describing visualization attributes.
Definition: Objects.h:341
std::string authorEmail() const
Access the auhor's email address.
Definition: Objects.cpp:54
LimitSet & operator=(const LimitSet &c)
Assignment operator.
Definition: Objects.h:498
LimitSetObject Object
Definition: Objects.h:477
TGeoElement Object
Definition of the implementation type.
Definition: Objects.h:270
Handle: a templated class like a shared pointer, which allows specialized access to tgeometry objects...
Definition: Handle.h:87
ROOT::Math::Translation3D Translation3D
Definition: Objects.h:112
AlignmentEntry(const Handle< Q > &h)
Constructor to be used when reading the already parsed DOM tree.
Definition: Objects.h:425
View * v
Definition: MultiView.cpp:30
int drawingStyle() const
Get drawing style.
Definition: Objects.cpp:297
Material(const Handle< Q > &e)
Constructorto be used for assignment from object handle.
Definition: Objects.h:317
V RotateY(const V &v, double a)
Definition: Objects.h:81
Handle class describing a set of limits as they are used for simulation.
Definition: Objects.h:475
bool operator==(const Limit &c) const
Equality operator.
Definition: Objects.cpp:398
Handle class describing a region as used in simulation.
Definition: Objects.h:516
V RotateX(const V &v, double a)
Definition: Objects.h:78
double density() const
density of the underlying material
Definition: Objects.cpp:201
bool operator<(const Limit &c) const
operator less
Definition: Objects.cpp:403
The main interface to the DD4hep detector description package.
Definition: LCDD.h:82
void setDrawingStyle(int style)
Set drawing style.
Definition: Objects.cpp:302
ROOT::Math::EulerAngles EulerAngles
Definition: Objects.h:108
ConstantObject Object
Definition of the implementation type.
Definition: Objects.h:234
int color() const
Get object color.
Definition: Objects.cpp:321
Concrete object implementation of the LimitSet Handle.
Region()
Default constructor.
Definition: Objects.h:521
float alpha() const
Get alpha value.
Definition: Objects.cpp:307
T * m_element
Single and only data member: Reference to the actual element.
Definition: Handle.h:96
VisAttr & operator=(const VisAttr &attr)
Assignment operator.
Definition: Objects.h:371
std::string toString() const
String representation of this object.
Definition: Objects.cpp:158
VisAttr(const Handle< Q > &e)
Constructor to be used for assignment from object handle.
Definition: Objects.h:363
int align(const Position &pos, bool check=false, double overlap=0.001)
Align the PhysicalNode (translation only)
Definition: Objects.cpp:361
void setAlpha(float value)
Set alpha value.
Definition: Objects.cpp:314
ROOT::Math::Transform3D Transform3D
Definition: Objects.h:110
ROOT::Math::RotationX RotationX
Definition: Objects.h:104
void setVisible(bool value)
Set visibility flag.
Definition: Objects.cpp:282
Author & operator=(const Author &e)
Assignment operator.
Definition: Objects.h:144
bool addLimit(const DD4hep::Geometry::Limit &limit)
Add new limit. Returns true if the new limit was added, false if it already existed.
Definition: Objects.cpp:428
void setStatus(const std::string &new_status)
Accessor: set object status.
Definition: Objects.cpp:115
Handle class describing a constant (define) object in lcdd.
Definition: Objects.h:231
Geometry::IDDescriptor IDDescriptor
Concrete object implementation of the VisAttr Handle.
bool showDaughters() const
Get Flag to show/hide daughter elements.
Definition: Objects.cpp:267
void setLineStyle(int style)
Set line style.
Definition: Objects.cpp:292