ATLAS Offline Software
Loading...
Searching...
No Matches
MuonWallTool Class Referencefinal

Tool for building the MuonWall detector. More...

#include "MuonWall/MuonWallTool.h"

Inheritance diagram for MuonWallTool:
Collaboration diagram for MuonWallTool:

Public Member Functions

 MuonWallTool (const std::string &type, const std::string &name, const IInterface *parent)
 ~MuonWallTool ()=default
virtual void BuildGeometry () override final
 Override DetectorGeometryBase::BuildGeometry method.
StatusCode initialize () override
 Athena method.
virtual void Build () override
 purely virtual methods being implemented here
virtual void PositionInParent () override
virtual void SetRotationAndOffset ()
virtual void BuildSubDetectors () override
virtual void SetEnvelope () override
virtual void ResetEnvelope () override
virtual void SetAsWorld () override
std::string GetDetectorName () const override
void SetDetectorName (const std::string &) override
void SetParent (IDetectorGeometryTool *) override
EnvelopeGetEnvelope () override final
G4VPhysicalVolume * GetWorldVolume () override final

Protected Attributes

ToolHandleArray< IDetectorGeometryToolm_subDetTools {this, "SubDetectors", {}, "Tool handle array of all subdetector tools"}
ServiceHandle< IG4GeometryNotifierSvcm_notifierSvc {this, "GeometryNotifierSvc", "G4GeometryNotifierSvc", "Detector name (same as the Tool name if not set"}
IDetectorGeometryToolm_theParent {}
Envelope m_envelope
Gaudi::Property< std::string > m_detectorName {this, "DetectorName", "", "Detector name (same as the Tool name if not set"}
bool m_isWorld {false}
Gaudi::Property< double > m_rotateX {this, "RotateX" , 0.0, "Rotation around the X-axis"}
Gaudi::Property< double > m_rotateY {this, "RotateY" , 0.0, "Rotation around the Y-axis"}
Gaudi::Property< double > m_rotateZ {this, "RotateZ" , 0.0, "Rotation around the Z-axis"}
Gaudi::Property< double > m_offsetX {this, "OffsetX" , 0.0, "Offset in the X-direction"}
Gaudi::Property< double > m_offsetY {this, "OffsetY" , 0.0, "Offset in the Y-direction"}
Gaudi::Property< double > m_offsetZ {this, "OffsetZ" , 0.0, "Offset in the Z-direction"}

Private Attributes

Gaudi::Property< double > m_zLength {this, "ZLength", 0.}
Gaudi::Property< double > m_yLength {this, "YLength", 0.}
Gaudi::Property< double > m_xLength {this, "XLength", 0.}
Gaudi::Property< bool > m_backWall {this, "backWall", true}
Gaudi::Property< bool > m_sideWall {this, "sideWall", false}

Detailed Description

Tool for building the MuonWall detector.

Definition at line 19 of file MuonWallTool.h.

Constructor & Destructor Documentation

◆ MuonWallTool()

MuonWallTool::MuonWallTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 34 of file MuonWallTool.cxx.

35 : DetectorGeometryBase(type,name,parent)
36{
37}
DetectorGeometryBase(const std::string &type, const std::string &name, const IInterface *parent)

◆ ~MuonWallTool()

MuonWallTool::~MuonWallTool ( )
default

Member Function Documentation

◆ Build()

void DetectorGeometryBase::Build ( )
overridevirtualinherited

purely virtual methods being implemented here

Definition at line 53 of file DetectorGeometryBase.cxx.

54{
55 ATH_MSG_VERBOSE( name() << "::Build() (Base class method): Starting. Number of registered volumes "<<G4LogicalVolumeStore::GetInstance()->size() );
56
58 ATH_MSG_VERBOSE( name() << "::Build() - Envelope set. Number of registered volumes "<<G4LogicalVolumeStore::GetInstance()->size() );
59
60 m_notifierSvc->SetCurrentDetectorName(m_detectorName.value());
62 ATH_MSG_VERBOSE( name() << "::Build() - Geometry built. Number of registered volumes "<<G4LogicalVolumeStore::GetInstance()->size() );
63
65 ATH_MSG_VERBOSE( name() << "::Build() - Volume moved around. Number of registered volumes "<<G4LogicalVolumeStore::GetInstance()->size() );
66
68 ATH_MSG_VERBOSE( name() << "::Build() - Connected with parent. Number of registered volumes "<<G4LogicalVolumeStore::GetInstance()->size() );
69
71 ATH_MSG_VERBOSE( name() << "::Build() (Base class method): Finished. Number of registered volumes "<<G4LogicalVolumeStore::GetInstance()->size() );
72 return;
73}
#define ATH_MSG_VERBOSE(x)
virtual void BuildGeometry() override
virtual void SetEnvelope() override
virtual void SetRotationAndOffset()
Gaudi::Property< std::string > m_detectorName
ServiceHandle< IG4GeometryNotifierSvc > m_notifierSvc
virtual void PositionInParent() override
virtual void BuildSubDetectors() override

◆ BuildGeometry()

void MuonWallTool::BuildGeometry ( )
finaloverridevirtual

Override DetectorGeometryBase::BuildGeometry method.

Reimplemented from DetectorGeometryBase.

Definition at line 39 of file MuonWallTool.cxx.

39 {
40
41 ATH_MSG_DEBUG( "Building Geometry back muon wall: "
42 << (m_backWall ? "true" : "false")
43 << " side muon wall: "
44 << (m_sideWall ? "true" : "false") );
45
46 // MuonWall description :
47
48 // Scintillator : 400*200*20, calculating half-size
49 const double zScintillator = m_zLength / 2.;
50 const double yScintillator = m_yLength / 2.;
51 const double xScintillator = m_xLength / 2.;
52 const double dzmuonwall = 750. * CLHEP::mm;
53 const double dymuonwall = 425. * CLHEP::mm;
54 const double dxmuonwall = xScintillator;
55
56 G4Box *wall = new G4Box("MuonWall", dxmuonwall, dymuonwall, dzmuonwall);
57
58 // Get the materials
59 StoredMaterialManager* materialManager = nullptr;
60 if (StatusCode::SUCCESS != detStore()->retrieve(materialManager, std::string("MATERIALS"))) {
61 ATH_MSG_ERROR( "Could not find Material Manager MATERIALS" );
62 return;
63 }
64
65 const GeoMaterial *geoAir = materialManager->getMaterial("tile::Air");
66 const GeoMaterial *geoScintillator = materialManager->getMaterial("tile::Scintillator");
67 Geo2G4MaterialFactory theMaterialFactory;
68 G4Material *airMaterial = theMaterialFactory.Build(geoAir);
69 G4Material *scintillatorMaterial = theMaterialFactory.Build(geoScintillator);
70
71 G4LogicalVolume *wallV = new G4LogicalVolume(wall, airMaterial, "MuonWall");
72
73 // ------- Create lead layers and place them inside the mother box --------
74 double zLayer, yLayer, xLayer = 0.;
75
76 if (m_backWall) {
77
78 const int nrOfLayers = 12;
79
80 for (int j = 0; j < nrOfLayers; j++) {
81
82 // Scintillator
83 G4Box *scintillatorLayer = new G4Box("ScintillatorLayer", xScintillator, yScintillator, zScintillator);
84
85 G4LogicalVolume *scintillatorLayerV = new G4LogicalVolume(scintillatorLayer, scintillatorMaterial,
86 "MuScintillatorLayer");
87
88 // scintillatorLayerV->GetLogicalVolume()->SetSensitiveDetector(muonwallSD);
89
90 if (j < 6) {
91 yLayer = yScintillator + 25. * CLHEP::mm;
92 zLayer = -450. * CLHEP::mm + (2 * j + 1) * zScintillator;
93 } else {
94 yLayer = -yScintillator + 25. * CLHEP::mm;
95 zLayer = -450. * CLHEP::mm + (2 * (j - 6) + 1) * zScintillator;
96 }
97
98 G4PVPlacement* scintillatorLayerVPhys __attribute__((unused)) =
99 new G4PVPlacement(0,
100 G4ThreeVector(xLayer,yLayer,zLayer),
101 scintillatorLayerV,
102 "MuScintillatorLayer",
103 wallV,
104 false,
105 j+1);
106 }
107 }
108
109 if (m_sideWall) {
110
111 // Scintillator : 500*100*20 instead of 400*200*20
112 const double yScintillator1 = yScintillator + 50. * CLHEP::mm;
113 const double zScintillator1 = zScintillator - 50. * CLHEP::mm;
114
115 const int nScintLayers = 3;
116
117 for (int j = 0; j < nScintLayers; j++) {
118
119 G4Box* scintillatorLayer = new G4Box("SideScintiLayer", xScintillator, yScintillator1, zScintillator1);
120
121 G4LogicalVolume* scintillatorLayerV = new G4LogicalVolume(scintillatorLayer, scintillatorMaterial,
122 "SideMuScintiLayer");
123
124 yLayer = -175. * CLHEP::mm;
125 zLayer = -750. * CLHEP::mm + (2 * j + 1) * zScintillator1;
126
127 G4PVPlacement* scintillatorLayerVPhys __attribute__((unused)) =
128 new G4PVPlacement(0,
129 G4ThreeVector(xLayer,yLayer,zLayer),
130 scintillatorLayerV,
131 "SideMuScintiLayer",
132 wallV,
133 false,
134 j+1);
135 }
136 }
137
138 // FINAL STEP
139 m_envelope.theEnvelope = wallV;
140}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
__attribute__((always_inline)) inline uint16_t TileCalibDrawerBase
void unused(Args &&...)
G4Material * Build(const GeoMaterial *)
Gaudi::Property< bool > m_backWall
Gaudi::Property< double > m_zLength
Gaudi::Property< double > m_yLength
Gaudi::Property< double > m_xLength
Gaudi::Property< bool > m_sideWall
virtual const GeoMaterial * getMaterial(const std::string &name)=0
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

◆ BuildSubDetectors()

void DetectorGeometryBase::BuildSubDetectors ( )
overridevirtualinherited

Definition at line 155 of file DetectorGeometryBase.cxx.

156{
157 ATH_MSG_VERBOSE( name() << "::BuildSubDetectors() (Base class method): Starting");
158 for (auto& subDetTool: m_subDetTools)
159 {
160 ATH_MSG_VERBOSE(name() << "::BuildSubDetectors() (Base class method): Positioning "<<subDetTool->GetDetectorName()<<" within "<<m_detectorName.value());
161 subDetTool->SetParent(this);
162 subDetTool->Build();
163 }
164 ATH_MSG_VERBOSE( name() << "::BuildSubDetectors() (Base class method): Finished");
165}
ToolHandleArray< IDetectorGeometryTool > m_subDetTools

◆ GetDetectorName()

std::string DetectorGeometryBase::GetDetectorName ( ) const
overrideinherited

Definition at line 180 of file DetectorGeometryBase.cxx.

181{
182 return m_detectorName.value();
183}

◆ GetEnvelope()

Envelope & DetectorGeometryBase::GetEnvelope ( )
finaloverrideinherited

Definition at line 195 of file DetectorGeometryBase.cxx.

196{
197 return m_envelope;
198}

◆ GetWorldVolume()

G4VPhysicalVolume * DetectorGeometryBase::GetWorldVolume ( )
finaloverrideinherited

Definition at line 200 of file DetectorGeometryBase.cxx.

201{
202 if (m_isWorld)
203 return m_envelope.thePositionedVolume;
204 else
205 {
206 ATH_MSG_ERROR("trying to get World from a DetectorTool which World is not!");
207 return 0;
208 }
209}

◆ initialize()

StatusCode DetectorGeometryBase::initialize ( )
overrideinherited

Athena method.

called at initialization time, being customized here

Definition at line 19 of file DetectorGeometryBase.cxx.

20{
21 ATH_MSG_VERBOSE( name() << "::initialize(): starting." );
22 if(m_detectorName.empty())
23 {
24 m_detectorName = this->name();
25 // re-initialize m_detectorName in order to take the real detector name rather than the path to it
26 size_t ipos=m_detectorName.value().find_last_of('.');
27 size_t length=m_detectorName.value().size();
28 if (ipos<length)
29 {
30 ATH_MSG_VERBOSE( "m_detectorName: " << m_detectorName.value() << " needs to be reset.");
31 m_detectorName=m_detectorName.value().substr(ipos+1,length-ipos-1);
32 ATH_MSG_VERBOSE( "m_detectorName default value reset to " << m_detectorName.value());
33 }
34 }
35 ATH_MSG_DEBUG( name() << "::initialize() (Base class method): Detector name = " << m_detectorName.value() );
36 CHECK(m_notifierSvc.retrieve());
37
38 // This fires initialize() for each of those tools
39 if (m_subDetTools.size())
40 {
41 ATH_MSG_DEBUG( name() << "::initialize(): Initializing list of " << m_subDetTools.size() << " detectors." );
42 CHECK( m_subDetTools.retrieve() );
43 }
44 else
45 {
46 ATH_MSG_DEBUG( name() << "::initialize(): no sub-detectors to initialize." );
47 }
48
49 ATH_MSG_VERBOSE( name() << "::initialize(): finished." );
50 return StatusCode::SUCCESS;
51}
#define CHECK(...)
Evaluate an expression and check for errors.
double length(const pvec &v)

◆ PositionInParent()

void DetectorGeometryBase::PositionInParent ( )
overridevirtualinherited

Reimplemented in GeoDetectorTool.

Definition at line 120 of file DetectorGeometryBase.cxx.

121{
122 ATH_MSG_VERBOSE( name() << "::PositionInParent() (Base class method)");
123 if (m_isWorld)
124 {
125 // check that the detector is built
126 if (m_envelope.IsBuilt())
127 {
128 G4VPhysicalVolume* physWorld= new G4PVPlacement(0,G4ThreeVector(),
129 m_envelope.theEnvelope,m_envelope.theEnvelope->GetName(),0,false,0,false);
130 m_envelope.thePositionedVolume=physWorld;
131 }
132 }
133 else
134 {
135 // check that there is a parent
136 if (!m_theParent)
137 {
138 ATH_MSG_ERROR("Parent not set for "<<m_detectorName.value()<<"!!!!!!!!!!");
139 }
140 else
141 {
142 if (m_theParent->GetEnvelope().IsBuilt())
143 {
144 // G4VPhysicalVolume *physVol = new G4PVPlacement(0,G4ThreeVector(),
145 // m_envelope.theEnvelope,m_envelope.theEnvelope->GetName(),m_theParent->GetEnvelope().theEnvelope,false,0,false);
146 // TODO: implement a possible rotation/displacement - something like this based on the old code?
147 G4VPhysicalVolume *physVol = new G4PVPlacement(m_envelope.theRotation,m_envelope.thePosition,
148 m_envelope.theEnvelope,m_envelope.theEnvelope->GetName(),m_theParent->GetEnvelope().theEnvelope,false,0);
149 m_envelope.thePositionedVolume=physVol;
150 }
151 }
152 }
153}
IDetectorGeometryTool * m_theParent

◆ ResetEnvelope()

void DetectorGeometryBase::ResetEnvelope ( )
overridevirtualinherited

Definition at line 171 of file DetectorGeometryBase.cxx.

172{
173}

◆ SetAsWorld()

void DetectorGeometryBase::SetAsWorld ( )
overridevirtualinherited

Definition at line 185 of file DetectorGeometryBase.cxx.

186{
187 m_isWorld=true;
188}

◆ SetDetectorName()

void DetectorGeometryBase::SetDetectorName ( const std::string & s)
overrideinherited

Definition at line 175 of file DetectorGeometryBase.cxx.

◆ SetEnvelope()

void DetectorGeometryBase::SetEnvelope ( )
overridevirtualinherited

Definition at line 167 of file DetectorGeometryBase.cxx.

168{
169}

◆ SetParent()

void DetectorGeometryBase::SetParent ( IDetectorGeometryTool * p)
overrideinherited

◆ SetRotationAndOffset()

void DetectorGeometryBase::SetRotationAndOffset ( )
virtualinherited

Definition at line 80 of file DetectorGeometryBase.cxx.

81{
82 ATH_MSG_VERBOSE( name() << "::SetRotationAndOffset() (Base class method)");
83 // Firstly do the rotation
84 if (!m_envelope.theRotation)
85 {
86 // m_envelope.theRotation is null, so create an identity
87 // rotation first.
88 // FIXME probably a neater way to do this part.
89 m_envelope.theRotation=new G4RotationMatrix;
90 // add the extra rotations.
91 m_envelope.theRotation->rotateX(m_rotateX);
92 m_envelope.theRotation->rotateY(m_rotateY);
93 m_envelope.theRotation->rotateZ(m_rotateZ);
94 if (m_envelope.thePositionedVolume)
95 {
96 // Override the rotation for m_envelope.thePositionedVolume.
97 m_envelope.thePositionedVolume->SetRotation(m_envelope.theRotation);
98 }
99 }
100 else
101 {
102 // m_envelope.theRotation already exists, so just add the
103 // extra rotations.
104 m_envelope.theRotation->rotateX(m_rotateX);
105 m_envelope.theRotation->rotateY(m_rotateY);
106 m_envelope.theRotation->rotateZ(m_rotateZ);
107 }
108 // Secondly add the additional position offset to the existing
109 // m_envelope.thePosition vector.
110 m_envelope.thePosition+=G4ThreeVector(m_offsetX,m_offsetY,m_offsetZ);
111 if (m_envelope.thePositionedVolume)
112 {
113 // Override the translation for m_envelope.thePositionedVolume.
114 m_envelope.thePositionedVolume->SetTranslation(m_envelope.thePosition);
115 }
116
117 ATH_MSG_VERBOSE( name() << "::SetRotationAndOffset() (Base class method): Finished" );
118 return;
119}
Gaudi::Property< double > m_rotateY
Gaudi::Property< double > m_rotateX
Gaudi::Property< double > m_offsetX
Gaudi::Property< double > m_offsetY
Gaudi::Property< double > m_rotateZ
Gaudi::Property< double > m_offsetZ

Member Data Documentation

◆ m_backWall

Gaudi::Property<bool> MuonWallTool::m_backWall {this, "backWall", true}
private

Definition at line 32 of file MuonWallTool.h.

32{this, "backWall", true};

◆ m_detectorName

Gaudi::Property<std::string> DetectorGeometryBase::m_detectorName {this, "DetectorName", "", "Detector name (same as the Tool name if not set"}
protectedinherited

Definition at line 71 of file DetectorGeometryBase.h.

71{this, "DetectorName", "", "Detector name (same as the Tool name if not set"};

◆ m_envelope

Envelope DetectorGeometryBase::m_envelope
protectedinherited

Definition at line 70 of file DetectorGeometryBase.h.

◆ m_isWorld

bool DetectorGeometryBase::m_isWorld {false}
protectedinherited

Definition at line 72 of file DetectorGeometryBase.h.

72{false};

◆ m_notifierSvc

ServiceHandle<IG4GeometryNotifierSvc> DetectorGeometryBase::m_notifierSvc {this, "GeometryNotifierSvc", "G4GeometryNotifierSvc", "Detector name (same as the Tool name if not set"}
protectedinherited

Definition at line 66 of file DetectorGeometryBase.h.

66{this, "GeometryNotifierSvc", "G4GeometryNotifierSvc", "Detector name (same as the Tool name if not set"};

◆ m_offsetX

Gaudi::Property<double> DetectorGeometryBase::m_offsetX {this, "OffsetX" , 0.0, "Offset in the X-direction"}
protectedinherited

Definition at line 76 of file DetectorGeometryBase.h.

76{this, "OffsetX" , 0.0, "Offset in the X-direction"};

◆ m_offsetY

Gaudi::Property<double> DetectorGeometryBase::m_offsetY {this, "OffsetY" , 0.0, "Offset in the Y-direction"}
protectedinherited

Definition at line 77 of file DetectorGeometryBase.h.

77{this, "OffsetY" , 0.0, "Offset in the Y-direction"};

◆ m_offsetZ

Gaudi::Property<double> DetectorGeometryBase::m_offsetZ {this, "OffsetZ" , 0.0, "Offset in the Z-direction"}
protectedinherited

Definition at line 78 of file DetectorGeometryBase.h.

78{this, "OffsetZ" , 0.0, "Offset in the Z-direction"};

◆ m_rotateX

Gaudi::Property<double> DetectorGeometryBase::m_rotateX {this, "RotateX" , 0.0, "Rotation around the X-axis"}
protectedinherited

Definition at line 73 of file DetectorGeometryBase.h.

73{this, "RotateX" , 0.0, "Rotation around the X-axis"};

◆ m_rotateY

Gaudi::Property<double> DetectorGeometryBase::m_rotateY {this, "RotateY" , 0.0, "Rotation around the Y-axis"}
protectedinherited

Definition at line 74 of file DetectorGeometryBase.h.

74{this, "RotateY" , 0.0, "Rotation around the Y-axis"};

◆ m_rotateZ

Gaudi::Property<double> DetectorGeometryBase::m_rotateZ {this, "RotateZ" , 0.0, "Rotation around the Z-axis"}
protectedinherited

Definition at line 75 of file DetectorGeometryBase.h.

75{this, "RotateZ" , 0.0, "Rotation around the Z-axis"};

◆ m_sideWall

Gaudi::Property<bool> MuonWallTool::m_sideWall {this, "sideWall", false}
private

Definition at line 33 of file MuonWallTool.h.

33{this, "sideWall", false};

◆ m_subDetTools

ToolHandleArray<IDetectorGeometryTool> DetectorGeometryBase::m_subDetTools {this, "SubDetectors", {}, "Tool handle array of all subdetector tools"}
protectedinherited

Definition at line 64 of file DetectorGeometryBase.h.

64{this, "SubDetectors", {}, "Tool handle array of all subdetector tools"};

◆ m_theParent

IDetectorGeometryTool* DetectorGeometryBase::m_theParent {}
protectedinherited

Definition at line 68 of file DetectorGeometryBase.h.

68{};

◆ m_xLength

Gaudi::Property<double> MuonWallTool::m_xLength {this, "XLength", 0.}
private

Definition at line 31 of file MuonWallTool.h.

31{this, "XLength", 0.};

◆ m_yLength

Gaudi::Property<double> MuonWallTool::m_yLength {this, "YLength", 0.}
private

Definition at line 30 of file MuonWallTool.h.

30{this, "YLength", 0.};

◆ m_zLength

Gaudi::Property<double> MuonWallTool::m_zLength {this, "ZLength", 0.}
private

Definition at line 29 of file MuonWallTool.h.

29{this, "ZLength", 0.};

The documentation for this class was generated from the following files: