ATLAS Offline Software
Loading...
Searching...
No Matches
GDMLDetectorTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Base class
7#include "GDMLDetectorTool.h"
8
9#include "G4GDMLParser.hh"
10#include "G4NistManager.hh"
11#include "G4LogicalVolume.hh"
12#include "G4PVPlacement.hh"
13
14// Geant4 includes used in functions
15
16GDMLDetectorTool::GDMLDetectorTool(const std::string& type, const std::string& name, const IInterface* parent)
18{
19 m_topTransform.setIdentity();
20 ATH_MSG_DEBUG( "GDMLDetectorTool constructor for " << name );
21}
22
24{
25 ATH_MSG_DEBUG( name() << " GDMLDetectorTool::initialize(): Starting" );
26
27 if(m_detectorName.empty())
28 {
29 m_detectorName = this->name();
30 // re-initialize m_detectorName in order to take the real detector name rather than the path to it
31 size_t ipos=m_detectorName.value().find_last_of('.');
32 size_t length=m_detectorName.value().size();
33 if (ipos<length)
34 {
35 ATH_MSG_DEBUG( "m_detectorName: " << m_detectorName.value() << " needs to be reset.");
36 m_detectorName=m_detectorName.value().substr(ipos+1,length-ipos-1);
37 ATH_MSG_DEBUG( "m_detectorName default value reset to " << m_detectorName.value());
38 }
39 }
40 ATH_MSG_DEBUG( name() << "GDMLDetectorTool::initialize() : Detector name = " << m_detectorName.value()<<" File name: "<<m_GDMLFileName );
41 if(m_geoDetectorName.empty())
42 {
44 }
45 if(m_GDMLFileName.empty())
46 {
47 m_GDMLFileName = m_detectorName.value()+".gdml";
48 }
49 ATH_MSG_DEBUG( name() << "GDMLDetectorTool::initialize() : Geo Detector name = " << m_geoDetectorName<<" File name: "<<m_GDMLFileName );
50
51 ATH_MSG_DEBUG( name() << " GDMLDetectorTool::initialize(): Finished" );
52 return StatusCode::SUCCESS;
53}
54
55
57{
58 ATH_MSG_VERBOSE( name() << " GDMLDetectorTool::BuildGeometry(): Starting" );
59
60 G4GDMLParser parser;
61 parser.Read(m_GDMLFileName.value().c_str(),false);
62 m_envelope.theEnvelope=parser.GetWorldVolume()->GetLogicalVolume();
63
64 ATH_MSG_VERBOSE( name() << " GDMLDetectorTool::BuildGeometry(): Finished" );
65}
66
71
73{
74 ATH_MSG_VERBOSE( name() << " GDMLDetectorTool::SetInitialTransformation(): Starting" );
75 if (!m_envelope.theRotation)
76 {
77 ATH_MSG_VERBOSE( name() << " GDMLDetectorTool::SetInitialTransformation(): Creating new G4RotationMatrix" );
78 m_envelope.theRotation=new G4RotationMatrix;
79 }
80 *(m_envelope.theRotation)=m_topTransform.getRotation().inverse();
81 m_envelope.thePosition=m_topTransform.getTranslation();
82 ATH_MSG_VERBOSE( name() << " GDMLDetectorTool::SetInitialTransformation(): Finished" );
83}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
double length(const pvec &v)
DetectorGeometryBase(const std::string &type, const std::string &name, const IInterface *parent)
Gaudi::Property< std::string > m_detectorName
Gaudi::Property< std::string > m_GDMLFileName
G4Transform3D m_topTransform
GDMLDetectorTool(const std::string &type, const std::string &name, const IInterface *parent)
virtual void BuildGeometry() override final
virtual methods being implemented here
Gaudi::Property< std::string > m_geoDetectorName
virtual StatusCode initialize() override final
Athena method.