ATLAS Offline Software
GeoDetectorTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Base class
7 #include "GeoDetectorTool.h"
8 #include "Geo2G4Builder.h"
9 #include "VolumeBuilder.h"
10 
11 #include "G4NistManager.hh"
12 #include "G4LogicalVolume.hh"
13 #include "G4PVPlacement.hh"
14 #include "G4GDMLParser.hh"
15 
16 // Geant4 includes used in functions
17 
18 GeoDetectorTool::GeoDetectorTool(const std::string& type, const std::string& name, const IInterface* parent)
19  : DetectorGeometryBase(type,name,parent),m_blParamOn(false),m_blGetTopTransform(true),m_geoDetectorName("")
20 {
21  m_topTransform.setIdentity();
22  ATH_MSG_DEBUG( "GeoDetectorTool constructor for " << name );
23  declareProperty("GeoDetectorName",m_geoDetectorName, "Name of the detector in GeoModel, if different from G4.");
24  declareProperty("GDMLFileOut",m_dumpGDMLFile,"File name where the GDML description for the detector will be dumped.");
25 
26 }
27 
29 {
30  ATH_MSG_VERBOSE( name() << " GeoDetectorTool::initialize(): Starting" );
31  if(m_detectorName.empty())
32  {
33  m_detectorName = this->name();
34  // re-initialize m_detectorName in order to take the real detector name rather than the path to it
35  size_t ipos=m_detectorName.value().find_last_of('.');
36  size_t length=m_detectorName.value().size();
37  if (ipos<length)
38  {
39  ATH_MSG_VERBOSE( "m_detectorName: " << m_detectorName.value() << " needs to be reset.");
40  m_detectorName = m_detectorName.value().substr(ipos+1,length-ipos-1);
41  ATH_MSG_VERBOSE( "m_detectorName default value reset to " << m_detectorName.value());
42  }
43  }
44  ATH_MSG_DEBUG( name() << "GeoDetectorTool::initialize() : Detector name = " << m_detectorName.value() );
45  if(m_geoDetectorName.empty())
46  {
48  }
49  ATH_MSG_DEBUG( name() << "GeoDetectorTool::initialize() : Geo Detector name = " << m_geoDetectorName );
50 
51  ATH_CHECK(m_geo2G4Svc.retrieve());
52  m_builderName = m_geo2G4Svc->GetDefaultBuilder()->GetKey();
53  m_blGetTopTransform = m_geo2G4Svc->UseTopTransforms();
54  ATH_MSG_VERBOSE( name() << " GeoDetectorTool::initialize(): Finished" );
55  return StatusCode::SUCCESS;
56 }
57 
58 
60 {
61  ATH_MSG_VERBOSE( name() << " GeoDetectorTool::BuildGeometry(): Starting" );
62  G4LogicalVolume* temp = this->Convert();
64 
65  if (this->IsTopTransform())
66  {
68  }
69  ATH_MSG_VERBOSE( name() << " GeoDetectorTool::BuildGeometry(): Finished" );
70 }
71 
73 {
74  ATH_MSG_DEBUG( name() << " GeoDetectorTool::PositionInParent(): Starting" );
75 
77  if (!m_dumpGDMLFile.empty()) {
78  G4GDMLParser parser;
80  }
81 }
82 
83 G4LogicalVolume* GeoDetectorTool::Convert()
84 {
85  ATH_MSG_VERBOSE( name() << " GeoDetectorTool::Convert(): Starting" );
86  ATH_MSG_DEBUG( name() << " GeoDetectorTool::Convert(): GeoDetectorName:builderName = "<<m_geoDetectorName<<":"<<m_builderName);
89  b->SetParam(m_blParamOn);
90  G4LogicalVolume *temp=Builder.BuildTree();
91  if(this->IsTopTransform())
92  {
94  }
95 
96  ATH_MSG_VERBOSE( name() << " GeoDetectorTool::Convert(): Finished" );
97  return temp;
98 }
99 
101 {
102  return m_blGetTopTransform;
103 }
104 
106 {
107  ATH_MSG_VERBOSE( name() << " GeoDetectorTool::SetInitialTransformation(): Starting" );
108  if (!m_envelope.theRotation)
109  {
110  ATH_MSG_VERBOSE( name() << " GeoDetectorTool::SetInitialTransformation(): Creating new G4RotationMatrix" );
111  m_envelope.theRotation=new G4RotationMatrix;
112  }
113  *(m_envelope.theRotation)=m_topTransform.getRotation().inverse();
114  m_envelope.thePosition=m_topTransform.getTranslation();
115  ATH_MSG_VERBOSE( name() << " GeoDetectorTool::SetInitialTransformation(): Finished" );
116 }
python.CaloScaleNoiseConfig.parser
parser
Definition: CaloScaleNoiseConfig.py:75
Envelope::thePositionedVolume
G4VPhysicalVolume * thePositionedVolume
Definition: IDetectorGeometryTool.h:21
GeoDetectorTool::m_dumpGDMLFile
std::string m_dumpGDMLFile
Definition: GeoDetectorTool.h:50
Envelope::theEnvelope
G4LogicalVolume * theEnvelope
Definition: IDetectorGeometryTool.h:20
VolumeBuilder
Definition: Simulation/G4Utilities/Geo2G4/src/VolumeBuilder.h:20
GeoDetectorTool::BuildGeometry
virtual void BuildGeometry() override final
virtual methods being implemented here
Definition: GeoDetectorTool.cxx:59
Geo2G4Builder
Main builder to create/position all volumes described in a GeoModel Tree.
Definition: Geo2G4Builder.h:33
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
GeoDetectorTool.h
GeoDetectorTool::IsTopTransform
bool IsTopTransform()
Definition: GeoDetectorTool.cxx:100
Geo2G4Builder::GetDetectorTransform
HepGeom::Transform3D GetDetectorTransform()
Definition: Geo2G4Builder.h:51
GeoDetectorTool::GeoDetectorTool
GeoDetectorTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: GeoDetectorTool.cxx:18
GeoDetectorTool::m_topTransform
G4Transform3D m_topTransform
Definition: GeoDetectorTool.h:53
GeoDetectorTool::m_builderName
std::string m_builderName
Definition: GeoDetectorTool.h:49
Envelope::thePosition
G4ThreeVector thePosition
Definition: IDetectorGeometryTool.h:23
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Geo2G4Builder::BuildTree
G4LogicalVolume * BuildTree()
Definition: Geo2G4Builder.cxx:84
test_pyathena.parent
parent
Definition: test_pyathena.py:15
GeoDetectorTool::m_geoDetectorName
std::string m_geoDetectorName
Definition: GeoDetectorTool.h:54
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
GeoDetectorTool::initialize
virtual StatusCode initialize() override final
Athena method.
Definition: GeoDetectorTool.cxx:28
Geo2G4Builder.h
DetectorGeometryBase.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
GeoDetectorTool::Convert
G4LogicalVolume * Convert()
Definition: GeoDetectorTool.cxx:83
GeoDetectorTool::SetInitialTransformation
void SetInitialTransformation()
Definition: GeoDetectorTool.cxx:105
DetectorGeometryBase::m_envelope
Envelope m_envelope
Definition: DetectorGeometryBase.h:70
DetectorGeometryBase::PositionInParent
virtual void PositionInParent() override
Definition: DetectorGeometryBase.cxx:120
DetectorGeometryBase::m_detectorName
Gaudi::Property< std::string > m_detectorName
Definition: DetectorGeometryBase.h:71
VolumeBuilder.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DetectorGeometryBase
Definition: DetectorGeometryBase.h:26
GeoDetectorTool::m_blParamOn
bool m_blParamOn
Definition: GeoDetectorTool.h:51
Geo2G4Builder::GetVolumeBuilder
VolumeBuilder * GetVolumeBuilder(std::string)
Definition: Geo2G4Builder.cxx:167
Envelope::theRotation
G4RotationMatrix * theRotation
Definition: IDetectorGeometryTool.h:22
GeoDetectorTool::m_blGetTopTransform
bool m_blGetTopTransform
Definition: GeoDetectorTool.h:52
GeoDetectorTool::PositionInParent
virtual void PositionInParent() override final
Definition: GeoDetectorTool.cxx:72
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
GeoDetectorTool::m_geo2G4Svc
ServiceHandle< IGeo2G4Svc > m_geo2G4Svc
Definition: GeoDetectorTool.h:58