ATLAS Offline Software
DeadMaterialTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //class header
6 #include "DeadMaterialTool.h"
7 
8 //Athena headers
10 #include "GeoModelKernel/GeoMaterial.h"
12 
13 // Geant4 headers
14 #include "G4Box.hh"
15 #include "G4LogicalVolume.hh"
16 #include "G4Material.hh"
17 #include "G4PVPlacement.hh"
18 
19 // CLHEP headers
20 #include "CLHEP/Units/SystemOfUnits.h"
21 
22 DeadMaterialTool::DeadMaterialTool(const std::string& type, const std::string& name, const IInterface* parent)
24  m_zLength(0),
25  m_yLength(0),
26  m_xLength(0)
27 {
28  ATH_MSG_DEBUG( "DeadMaterialTool constructor for " << name );
29  declareProperty("ZLength", m_zLength, "");
30  declareProperty("YLength", m_yLength, "");
31  declareProperty("XLength", m_xLength, "");
32 }
33 
35 {
36 
37 }
38 
40 {
41  ATH_MSG_VERBOSE( name() << " DeadMaterialTool::BuildGeometry(): Starting" );
42 
43  const double dzdeadmaterial = (m_zLength)/2. *CLHEP::mm;
44  const double dydeadmaterial = (m_yLength)/2. *CLHEP::mm;
45  const double dxdeadmaterial = (m_xLength)/2. *CLHEP::mm;
46 
47  ATH_MSG_DEBUG ( "DeadMaterial geometry " << dzdeadmaterial << " " << dydeadmaterial << " " << dxdeadmaterial );
48 
49  G4Box *wall = new G4Box("DeadMaterial",dxdeadmaterial,dydeadmaterial,dzdeadmaterial);
50 
51  // Get the materials
52  StoredMaterialManager* materialManager = nullptr;
53  if (StatusCode::SUCCESS != detStore()->retrieve(materialManager, std::string("MATERIALS")))
54  {
55  //FIXME should probably at least print an ERROR here...
56  return;
57  }
58  const GeoMaterial *geoAir = materialManager->getMaterial("tile::Air");
59  const GeoMaterial *geoIron = materialManager->getMaterial("std::Iron");
60  Geo2G4MaterialFactory theMaterialFactory;
61  G4Material *airMaterial=theMaterialFactory.Build(geoAir);
62  G4Material *ironMaterial=theMaterialFactory.Build(geoIron);
63 
64  G4LogicalVolume *wallV = new G4LogicalVolume(wall,airMaterial,"DeadMaterial");
65 
66  // ------- Create iron bar and place it inside the mother box --------
67  const double IronWidth = 5./2. *CLHEP::mm;
68  for (int j=0; j<2; j++)
69  {
70  // X Iron plates
71  G4Box *ironLayerX = new G4Box("IronLayerX",IronWidth,dydeadmaterial,dzdeadmaterial);
72  G4LogicalVolume *ironLayerXV = new G4LogicalVolume(ironLayerX,ironMaterial,"DMIronLayerX");
73 
74  double xLayer=0.0, zLayer=0.0;
75  if(j==0) xLayer = -dxdeadmaterial+IronWidth;
76  if(j==1) xLayer = dxdeadmaterial-IronWidth;
77  G4PVPlacement *ironLayerXVPhys __attribute__((unused)) =
78  new G4PVPlacement (0,
79  G4ThreeVector(xLayer,0,0),
80  ironLayerXV,
81  "DMIronLayerX",
82  wallV,
83  false,
84  j+1);
85 
86  // Z Iron plates
87  const double IronWidthX = 140./2. *CLHEP::mm;
88  G4Box *ironLayerZ = new G4Box("IronLayerZ",IronWidthX,dydeadmaterial,IronWidth);
89  G4LogicalVolume *ironLayerZV = new G4LogicalVolume(ironLayerZ,ironMaterial,"DMIronLayerZ");
90  if(j==0) zLayer = -dzdeadmaterial+IronWidth;
91  if(j==1) zLayer = dzdeadmaterial-IronWidth;
92  G4PVPlacement *ironLayerZVPhys __attribute__((unused)) =
93  new G4PVPlacement (0,
94  G4ThreeVector(0,0,zLayer),
95  ironLayerZV,
96  "DMIronLayerZ",
97  wallV,
98  false,
99  j+1);
100  }
101 
102  // FINAL STEP
103  m_envelope.theEnvelope=wallV;
104  ATH_MSG_VERBOSE( name() << " DeadMaterialTool::BuildGeometry(): Finished" );
105 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
Envelope::theEnvelope
G4LogicalVolume * theEnvelope
Definition: IDetectorGeometryTool.h:20
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
DeadMaterialTool::m_yLength
double m_yLength
Definition: DeadMaterialTool.h:31
DeadMaterialTool::~DeadMaterialTool
~DeadMaterialTool()
Definition: DeadMaterialTool.cxx:34
DeadMaterialTool::m_xLength
double m_xLength
Definition: DeadMaterialTool.h:32
Geo2G4MaterialFactory.h
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
DeadMaterialTool.h
DeadMaterialTool::DeadMaterialTool
DeadMaterialTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: DeadMaterialTool.cxx:22
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
DeadMaterialTool::BuildGeometry
virtual void BuildGeometry() override final
virtual methods being implemented here
Definition: DeadMaterialTool.cxx:39
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
StoredMaterialManager.h
DetectorGeometryBase::m_envelope
Envelope m_envelope
Definition: DetectorGeometryBase.h:70
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
unused
void unused(Args &&...)
Definition: VP1ExpertSettings.cxx:39
__attribute__
__attribute__((always_inline)) inline uint16_t TileCalibDrawerBase
Definition: TileCalibDrawerBase.h:190
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DetectorGeometryBase
Definition: DetectorGeometryBase.h:26
StoredMaterialManager::getMaterial
virtual const GeoMaterial * getMaterial(const std::string &name)=0
StoredMaterialManager
This class holds one or more material managers and makes them storeable, under StoreGate.
Definition: StoredMaterialManager.h:28
DeadMaterialTool::m_zLength
double m_zLength
Definition: DeadMaterialTool.h:30
Geo2G4MaterialFactory
Definition: Geo2G4MaterialFactory.h:15
Geo2G4MaterialFactory::Build
G4Material * Build(const GeoMaterial *)
Definition: Geo2G4MaterialFactory.cxx:29