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
Subdetector.h
Go to the documentation of this file.
1 /*
2  * Subdetector.h
3  *
4  * Basic reconstruction interface for generic subdetectors
5  *
6  * Created on: Apr 3, 2014
7  * Author: Christian Grefe, CERN
8  */
9 
10 #ifndef SUBDETECTOR_H_
11 #define SUBDETECTOR_H_
12 
13 #include "DD4hep/Detector.h"
15 
16 namespace DD4hep {
17 namespace DDRec {
18 
19 class Subdetector: public virtual Geometry::DetElement {
20 public:
23  Geometry::DetElement(det) {
25  }
26 
28  virtual ~Subdetector() {
29  // does not own the extension!
30  }
31 
33  bool isBarrel() const {
34  return _subdetector->isBarrel();
35  }
36 
38  bool isEndcap() const {
39  return _subdetector->isEndcap();
40  }
41 
43  double getRMin() const {
44  return _subdetector->getRMin();
45  }
46 
48  double getRMax() const {
49  return _subdetector->getRMax();
50  }
51 
53  double getZMin() const {
54  return _subdetector->getZMin();
55  }
56 
58  double getZMax() const {
59  return _subdetector->getZMax();
60  }
61 
63  /* Describes the number of corners for a polygon.
64  * Returns 0 in case of a circular shape
65  */
66  int getNSides() const {
67  return _subdetector->getNSides();
68  }
69 
70 protected:
72 
73 private:
76  _subdetector = this->isValid() ? this->extension<SubdetectorExtension>() : 0;
77  if (not _subdetector) {
78  throw invalid_detector_element("Found no extension of type \"SubdetectorExtension\"", Geometry::DetElement(*this));
79  }
80  }
81 };
82 
83 } /* namespace DDRec */
84 } /* namespace DD4hep */
85 
86 #endif /* SUBDETECTOR_H_ */
SubdetectorExtension * _subdetector
Definition: Subdetector.h:71
bool isValid() const
Check the validity of the object held by the handle.
Definition: Handle.h:124
double getZMin() const
Access to the lower z extent.
Definition: Subdetector.h:53
virtual bool isEndcap() const =0
Is this an endcap detector.
bool isBarrel() const
Is this a barrel detector.
Definition: Subdetector.h:33
virtual double getZMin() const =0
Access to the lower z extent.
virtual double getZMax() const =0
Access to the upper z extent.
double getRMax() const
Access to the outer radius.
Definition: Subdetector.h:48
bool isEndcap() const
Is this an endcap detector.
Definition: Subdetector.h:38
virtual bool isBarrel() const =0
Is this a barrel detector.
virtual ~Subdetector()
Destructor.
Definition: Subdetector.h:28
double getRMin() const
Access to the inner radius.
Definition: Subdetector.h:43
Handle class describing a detector element.
Definition: Detector.h:172
void getSubdetectorExtension()
Helper method to retrieve the extension.
Definition: Subdetector.h:75
Subdetector(const Geometry::DetElement &det)
Default constructor.
Definition: Subdetector.h:22
int getNSides() const
Access to the number of sides.
Definition: Subdetector.h:66
double getZMax() const
Access to the upper z extent.
Definition: Subdetector.h:58
virtual int getNSides() const =0
Access to the number of sides.
virtual double getRMin() const =0
Access to the inner radius.
virtual double getRMax() const =0
Access to the outer radius.