ATLAS Offline Software
InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef InDetDD_ServiceVolume_H
6 #define InDetDD_ServiceVolume_H
7 
9 #include "GeoModelKernel/GeoShape.h"
10 #include "GeoModelKernel/GeoIntrusivePtr.h"
11 #include <cmath>
12 #include <mutex>
13 #include <string>
14 
15 class GeoMaterial;
16 class GeoShape;
17 
18 namespace InDetDD {
19 
20  // class to hold GeoShape pointer. This takes care of the GeoShape ref counting and
21  // avoids needing to write a copy constructor for ServiceVolume
22  using GeoShapeHolder = GeoIntrusivePtr<const GeoShape>;
23 
24  class ServiceVolume {
25 
26  public:
27  ServiceVolume();
29  void setRmin(double rmin) {m_rmin = rmin; resetGeoShape();}
30  void setRmax(double rmax) {m_rmax = rmax; resetGeoShape();}
31  void setRmin2(double rmin2) {m_rmin2 = rmin2; resetGeoShape();}
32  void setRmax2(double rmax2) {m_rmax2 = rmax2; resetGeoShape();}
33  void setZmin(double zmin) {m_zmin = zmin; resetGeoShape();}
34  void setZmax(double zmax) {m_zmax = zmax; resetGeoShape();}
35  //void setVolId(int num) {m_volId = num;}
36  void setZsymm(bool zsymm) {m_zsymm = zsymm;}
37  void setMaterial(const std::string & mat) {m_materialName = mat;}
38  void setMaterial(const GeoMaterial * mat) {m_material = mat;}
39  void setVolName(const std::string & name) {m_volName = name;}
40  void setShapeType(const std::string & shapeType) {m_shapeType = shapeType; setSplittable();}
45  void setNCopies(int num) {m_nCopies = num;}
46  void setRegion(const std::string & region) {m_region = region;}
47  void setLabel(const std::string & name, int volId);
48  void setLabel(const std::string & name) {m_label = name;}
49  void addLabel(const std::string & name) {m_label += name;}
50  //void setLength() {m_origLength = std::abs(m_zmax - m_zmin);}
52  void resetGeoShape() {if (!m_lockGeoShape) m_geoShape.reset();}
53  void reduceSize(double safety);
54  // Set a custom shape. A volume can be specified.
55  // This should be used when the shapes volume calculation is unreliable (eg boolean volumes)
56  // NB. rmin,rmax,zmin,zmax should still be set to determine z position and to determine which zone it belongs.
57  void setGeoShape(const GeoShape * geoShape, double volume=0);
58  void setEnvelopeNum(int num) { m_envNum=num; }
60  void setZShift(double shift) { m_zShift=shift; }
61 
62  double rmin() const {return m_rmin;}
63  double rmax() const {return m_rmax;}
64  double rmin2() const {return m_rmin2;}
65  double rmax2() const {return m_rmax2;}
66  double zmin() const {return m_zmin+m_safety;}
67  double zmax() const {return m_zmax-m_safety;}
68  //int volId() const {return m_volId;}
69  bool zsymm() const {return m_zsymm;}
70  const std::string & materialName() const {return m_materialName;}
71  const GeoMaterial * material() const {return m_material;}
72  const std::string & volName() const {return m_volName;}
73  const std::string & shapeType() const {return m_shapeType;}
74  double phiLoc() const {return m_phiLoc;}
75  double phiWidth() const {return m_phiWidth;}
76  bool needsRotation() const {return m_needsRotation;}
77  int sides() const {return m_sides;}
78  int nCopies() const {return m_nCopies;}
79  //double origLength() const {return m_origLength;}
80  const std::string & region() const {return m_region;}
81  std::string fullLabel() const;
82  double length() const {return std::abs(m_zmax - m_zmin) - 2*m_safety;}
83  double zposition() const {return 0.5 * (m_zmin + m_zmax);}
84  double rposition() const {return 0.5 * (m_rmin + m_rmax);}
85  //double fractionInRegion() const {return std::abs(m_zmax - m_zmin)/m_origLength;}
86  double volume() const;
87  double origVolume() const;
88  const GeoShape * getShape() const;
89  bool splittableInR() const {return m_splittableR;}
90  bool splittableInZ() const {return m_splittableZ;}
91  int envelopeNum() const {return m_envNum; }
92  int envelopeParent() const {return m_envParentNum; }
93  double zShift() const {return m_zShift; }
94 
95  // For debugging
96  void print() const;
97 
98  private:
99  void setSplittable();
100 
101  double m_rmin;
102  double m_rmax;
103  double m_rmin2;
104  double m_rmax2;
105  double m_zmin;
106  double m_zmax;
107  //int m_volId;
108  bool m_zsymm;
109  mutable GeoShapeHolder m_geoShape ATLAS_THREAD_SAFE; // Guarded by m_mutex
110  const GeoMaterial * m_material;
111  std::string m_materialName;
112  std::string m_volName;
113  std::string m_shapeType;
114  double m_phiLoc;
115  double m_phiWidth;
117  int m_sides;
119  //double m_origLength;
120  double m_origVolume;
121  mutable double m_volume ATLAS_THREAD_SAFE; // Guarded by m_mutex
122  double m_safety;
123  std::string m_region;
124  std::string m_label;
128 
129  int m_envNum;
131  double m_zShift;
132 
134  };
135 
136 } // End namespace
137 
138 
139 #endif
InDetDD::ServiceVolume::zmax
double zmax() const
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:67
InDetDD::ServiceVolume::needsRotation
bool needsRotation() const
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:76
InDetDD::ServiceVolume::setRmin2
void setRmin2(double rmin2)
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:31
InDetDD::ServiceVolume::print
void print() const
Definition: InDetGeoModelUtils/src/ServiceVolume.cxx:183
InDetDD::ServiceVolume::reduceSize
void reduceSize(double safety)
Definition: InDetGeoModelUtils/src/ServiceVolume.cxx:160
InDetDD::ServiceVolume::setEnvelopeNum
void setEnvelopeNum(int num)
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:58
InDetDD::ServiceVolume::m_zmin
double m_zmin
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:105
InDetDD::ServiceVolume::m_phiWidth
double m_phiWidth
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:115
InDetDD::ServiceVolume::volName
const std::string & volName() const
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:72
InDetDD::ServiceVolume::splittableInZ
bool splittableInZ() const
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:90
InDetDD::ServiceVolume::m_zsymm
bool m_zsymm
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:108
InDetDD::ServiceVolume::m_materialName
std::string m_materialName
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:111
InDetDD::ServiceVolume::m_sides
int m_sides
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:117
InDetDD::ServiceVolume::envelopeNum
int envelopeNum() const
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:91
InDetDD::ServiceVolume::setZmax
void setZmax(double zmax)
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:34
InDetDD::ServiceVolume::splittableInR
bool splittableInR() const
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:89
InDetDD::ServiceVolume::m_zmax
double m_zmax
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:106
InDetDD::ServiceVolume::setZShift
void setZShift(double shift)
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:60
InDetDD::ServiceVolume::setLabel
void setLabel(const std::string &name, int volId)
Definition: InDetGeoModelUtils/src/ServiceVolume.cxx:171
InDetDD::ServiceVolume::m_envNum
int m_envNum
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:129
InDetDD::ServiceVolume::setMaterial
void setMaterial(const std::string &mat)
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:37
InDetDD::ServiceVolume::rmax
double rmax() const
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:63
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
InDetDD::ServiceVolume::setOrigVolume
void setOrigVolume(double volume)
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:51
InDetDD::ServiceVolume::m_rmin2
double m_rmin2
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:103
mat
GeoMaterial * mat
Definition: LArDetectorConstructionTBEC.cxx:55
InDetDD::ServiceVolume::m_nCopies
int m_nCopies
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:118
InDetDD::ServiceVolume::setPhiWidth
void setPhiWidth(double phiWidth)
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:42
InDetDD::ServiceVolume::setLabel
void setLabel(const std::string &name)
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:48
InDetDD::ServiceVolume::resetGeoShape
void resetGeoShape()
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:52
InDetDD::ServiceVolume::m_splittableR
bool m_splittableR
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:126
InDetDD::ServiceVolume::m_envParentNum
int m_envParentNum
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:130
InDetDD::ServiceVolume::setZsymm
void setZsymm(bool zsymm)
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:36
InDetDD::ServiceVolume::m_mutex
std::mutex m_mutex
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:133
InDetDD::ServiceVolume::setPhiLoc
void setPhiLoc(double phiLoc)
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:41
InDetDD::ServiceVolume::m_rmin
double m_rmin
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:101
InDetDD::ServiceVolume::getShape
const GeoShape * getShape() const
Definition: InDetGeoModelUtils/src/ServiceVolume.cxx:194
InDetDD::ServiceVolume::setSides
void setSides(int sides)
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:44
InDetDD::ServiceVolume::length
double length() const
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:82
InDetDD::ServiceVolume::setRegion
void setRegion(const std::string &region)
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:46
InDetDD::ServiceVolume::rmax2
double rmax2() const
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:65
InDetDD::ServiceVolume::region
const std::string & region() const
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:80
InDetDD::ServiceVolume::m_zShift
double m_zShift
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:131
InDetDD::ServiceVolume::zShift
double zShift() const
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:93
InDetDD::ServiceVolume::material
const GeoMaterial * material() const
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:71
InDetDD::ServiceVolume::setMaterial
void setMaterial(const GeoMaterial *mat)
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:38
InDetDD::ServiceVolume::ServiceVolume
ServiceVolume()
Definition: InDetGeoModelUtils/src/ServiceVolume.cxx:96
InDetDD::ServiceVolume::m_origVolume
double m_origVolume
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:120
InDetDD::ServiceVolume::zsymm
bool zsymm() const
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:69
InDetDD::ServiceVolume::volume
double volume() const
Definition: InDetGeoModelUtils/src/ServiceVolume.cxx:324
InDetDD::ServiceVolume::m_splittableZ
bool m_splittableZ
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:127
InDetDD::ServiceVolume::m_shapeType
std::string m_shapeType
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:113
InDetDD::ServiceVolume::zposition
double zposition() const
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:83
InDetDD::ServiceVolume::setRmin
void setRmin(double rmin)
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:29
master.flag
bool flag
Definition: master.py:29
InDetDD::ServiceVolume::origVolume
double origVolume() const
Definition: InDetGeoModelUtils/src/ServiceVolume.cxx:349
InDetDD::ServiceVolume::m_safety
double m_safety
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:122
InDetDD::ServiceVolume::setParentEnvelope
void setParentEnvelope(int num)
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:59
InDetDD::ServiceVolume::m_rmax2
double m_rmax2
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:104
InDetDD::ServiceVolume::fullLabel
std::string fullLabel() const
Definition: InDetGeoModelUtils/src/ServiceVolume.cxx:176
InDetDD::ServiceVolume::setRmax2
void setRmax2(double rmax2)
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:32
InDetDD::ServiceVolume::setZmin
void setZmin(double zmin)
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:33
InDetDD::ServiceVolume::ATLAS_THREAD_SAFE
GeoShapeHolder m_geoShape ATLAS_THREAD_SAFE
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:109
InDetDD::GeoShapeHolder
GeoIntrusivePtr< const GeoShape > GeoShapeHolder
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:22
InDetDD::ServiceVolume::setGeoShape
void setGeoShape(const GeoShape *geoShape, double volume=0)
Definition: InDetGeoModelUtils/src/ServiceVolume.cxx:332
trigbs_pickEvents.num
num
Definition: trigbs_pickEvents.py:76
InDetDD::ServiceVolume::setNeedsRotation
void setNeedsRotation(bool flag)
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:43
InDetDD::ServiceVolume::m_lockGeoShape
bool m_lockGeoShape
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:125
InDetDD::ServiceVolume::rmin2
double rmin2() const
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:64
InDetDD::ServiceVolume::rposition
double rposition() const
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:84
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
InDetDD::ServiceVolume::m_material
const GeoMaterial * m_material
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:110
InDetDD::ServiceVolume::m_volName
std::string m_volName
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:112
InDetDD::ServiceVolume::ATLAS_THREAD_SAFE
double m_volume ATLAS_THREAD_SAFE
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:121
InDetDD::ServiceVolume::envelopeParent
int envelopeParent() const
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:92
InDetDD::ServiceVolume::setRmax
void setRmax(double rmax)
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:30
InDetDD::ServiceVolume::rmin
double rmin() const
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:62
InDetDD::ServiceVolume::setSplittable
void setSplittable()
Definition: InDetGeoModelUtils/src/ServiceVolume.cxx:356
InDetDD::ServiceVolume::addLabel
void addLabel(const std::string &name)
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:49
InDetDD
Message Stream Member.
Definition: FakeTrackBuilder.h:8
InDetDD::ServiceVolume::m_phiLoc
double m_phiLoc
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:114
InDetDD::ServiceVolume::m_needsRotation
bool m_needsRotation
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:116
InDetDD::ServiceVolume::setVolName
void setVolName(const std::string &name)
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:39
InDetDD::ServiceVolume::nCopies
int nCopies() const
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:78
InDetDD::ServiceVolume::setShapeType
void setShapeType(const std::string &shapeType)
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:40
InDetDD::ServiceVolume::m_rmax
double m_rmax
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:102
InDetDD::ServiceVolume::sides
int sides() const
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:77
InDetDD::ServiceVolume::setNCopies
void setNCopies(int num)
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:45
InDetDD::ServiceVolume::m_label
std::string m_label
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:124
InDetDD::ServiceVolume::m_region
std::string m_region
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:123
InDetDD::ServiceVolume
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:24
InDetDD::ServiceVolume::phiLoc
double phiLoc() const
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:74
InDetDD::ServiceVolume::phiWidth
double phiWidth() const
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:75
InDetDD::ServiceVolume::materialName
const std::string & materialName() const
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:70
checker_macros.h
Define macros for attributes used to control the static checker.
InDetDD::ServiceVolume::shapeType
const std::string & shapeType() const
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:73
InDetDD::ServiceVolume::zmin
double zmin() const
Definition: InDetGeoModelUtils/InDetGeoModelUtils/ServiceVolume.h:66