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
IDDecoder.h
Go to the documentation of this file.
1 /*
2  * IDDecoder.h
3  *
4  * Created on: Dec 12, 2013
5  * Author: Christian Grefe, CERN
6  */
7 
8 #ifndef IDDECODER_H_
9 #define IDDECODER_H_
10 
11 #include "DD4hep/Readout.h"
12 #include "DD4hep/VolumeManager.h"
13 
15 
16 #include <set>
17 #include <string>
18 
19 class TGeoManager;
20 
21 namespace DD4hep {
22 namespace DDRec {
23 
26 
32 class IDDecoder {
33 public:
35  public:
37  Barrel=0,
41  };
42  BarrelEndcapFlag(unsigned int val) :
43  value(static_cast<BarrelEncapID>(val)) {}
44 
45  virtual ~BarrelEndcapFlag() {}
46 
47  bool isBarrel() const {
48  return value == Barrel;
49  }
50 
51  bool isEndcap() const {
52  return value == EndcapNorth || value == EndcapSouth;
53  }
54 
55  bool isEndcapSouth() const {
56  return value == EndcapSouth;
57  }
58 
59  bool isEndcapNorth() const {
60  return value == EndcapSouth;
61  }
62 
64  return value;
65  }
66 
67  protected:
69  };
70 
72  static IDDecoder& getInstance();
73 
75  virtual ~IDDecoder() {};
76 
78  CellID cellIDFromLocal(const Geometry::Position& local, const VolumeID volumeID) const;
79 
81  CellID cellID(const Geometry::Position& global) const;
82 
85 
88 
90  VolumeID volumeID(const CellID& cellID) const;
91 
93  VolumeID volumeID(const Geometry::Position& global) const;
94 
97 
100 
103 
106 
109 
112 
114  Geometry::Readout readout(const CellID& cellID) const;
115 
117  Geometry::Readout readout(const Geometry::Position& global) const;
118 
120  void neighbours(const CellID& cellID, std::set<CellID>& neighbours) const;
121 
123  bool areNeighbours(const CellID& cellID, const CellID& otherCellID) const;
124 
126  BarrelEndcapFlag barrelEndcapFlag(const CellID& cellID) const;
127 
129  long int layerIndex(const CellID& cellID) const;
130 
132  long int systemIndex(const CellID& cellID) const;
133 
134  static std::string barrelIdentifier() {
135  return std::string("barrel");
136  }
137 
138  static std::string layerIdentifier() {
139  return std::string("layer");
140  }
141 
142  static std::string systemIdentifier() {
143  return std::string("system");
144  }
145 
146 protected:
148  TGeoManager* _tgeoMgr;
149 
152 
155 
156 private:
158  IDDecoder();
159 
161  IDDecoder(const IDDecoder&);
162 
164  void operator=(const IDDecoder&);
165 };
166 
167 } /* namespace DDRec */
168 } /* namespace DD4hep */
169 #endif /* IDDECODER_H_ */
long long int CellID
Useful typedefs to differentiate cell IDs and volume IDs.
Definition: Primitives.h:32
IDDecoder()
Default constructor.
Definition: IDDecoder.cpp:33
static Geometry::DetElement getClosestDaughter(const Geometry::DetElement &det, const Geometry::Position &position)
Helper method to get the closest daughter DetElement to the position starting from the given DetEleme...
Definition: IDDecoder.cpp:238
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:135
static std::string systemIdentifier()
Definition: IDDecoder.h:142
Geometry::Position position(const CellID &cellID) const
Returns the global position from a given cell ID.
Definition: IDDecoder.cpp:78
void operator=(const IDDecoder &)
Disable assignment operator.
DDSegmentation::CellID CellID
Definition: IDDecoder.h:24
Geometry::DetElement detectorElement(const CellID &cellID) const
Returns the closest detector element in the hierarchy for a given cell ID.
Definition: IDDecoder.cpp:146
VolumeID volumeID(const CellID &cellID) const
Returns the volume ID of a given cell ID.
Definition: IDDecoder.cpp:102
BarrelEndcapFlag barrelEndcapFlag(const CellID &cellID) const
Access to the barrel-endcap flag.
Definition: IDDecoder.cpp:194
Geometry::Readout findReadout(const Geometry::DetElement &det) const
Helper method to find the corresponding Readout object to a DetElement.
Definition: IDDecoder.cpp:212
Geometry::Position localPosition(const CellID &cellID) const
Returns the local position from a given cell ID.
Definition: IDDecoder.cpp:94
virtual ~IDDecoder()
Destructor.
Definition: IDDecoder.h:75
Handle to the implementation of the readout structure of a subdetector.
Definition: Readout.h:46
Geometry::PlacedVolume placement(const CellID &cellID) const
Returns the placement for a given cell ID.
Definition: IDDecoder.cpp:118
CellID cellIDFromLocal(const Geometry::Position &local, const VolumeID volumeID) const
Returns the cell ID from the local position in the given volume ID.
Definition: IDDecoder.cpp:45
Geometry::Readout readout(const CellID &cellID) const
Access to the Readout object for a given cell ID.
Definition: IDDecoder.cpp:164
static std::string barrelIdentifier()
Definition: IDDecoder.h:134
static std::string layerIdentifier()
Definition: IDDecoder.h:138
long int systemIndex(const CellID &cellID) const
Access to the system index.
Definition: IDDecoder.cpp:206
TGeoManager * _tgeoMgr
Definition: IDDecoder.h:148
void neighbours(const CellID &cellID, std::set< CellID > &neighbours) const
Calculates the neighbours of the given cell ID and adds them to the list of neighbours.
Definition: IDDecoder.cpp:178
long int layerIndex(const CellID &cellID) const
Access to the layer index.
Definition: IDDecoder.cpp:200
ROOT::Math::XYZVector Position
Definition: Objects.h:75
Geometry::DetElement subDetector(const CellID &cellID) const
Returns the subdetector for a given cell ID.
Definition: IDDecoder.cpp:132
DDSegmentation::VolumeID VolumeID
Definition: IDDecoder.h:25
Handle class describing a detector element.
Definition: Detector.h:172
Class to support the retrieval of detector elements and volumes given a valid identifier.
Definition: VolumeManager.h:70
Geometry::VolumeManager _volumeManager
Definition: IDDecoder.h:147
bool areNeighbours(const CellID &cellID, const CellID &otherCellID) const
Checks if the given cell IDs are neighbours.
Definition: IDDecoder.cpp:186
long long int VolumeID
Definition: Primitives.h:35
static IDDecoder & getInstance()
Access to the global IDDecoder instance.
Definition: IDDecoder.cpp:27
CellID cellID(const Geometry::Position &global) const
Returns the global cell ID from a given global position.
Definition: IDDecoder.cpp:61