ATLAS Offline Software
Loading...
Searching...
No Matches
GDMLDetectorTool.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 "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 declareProperty("GeoDetectorName",m_geoDetectorName, "Name of the detector in GeoModel, if different from G4.");
22 declareProperty("GDMLFileName",m_GDMLFileName,"Name of the GDML file to be used as input.");
23
24}
25
27{
28 ATH_MSG_DEBUG( name() << " GDMLDetectorTool::initialize(): Starting" );
29
30 if(m_detectorName.empty())
31 {
32 m_detectorName = this->name();
33 // re-initialize m_detectorName in order to take the real detector name rather than the path to it
34 size_t ipos=m_detectorName.value().find_last_of('.');
35 size_t length=m_detectorName.value().size();
36 if (ipos<length)
37 {
38 ATH_MSG_DEBUG( "m_detectorName: " << m_detectorName.value() << " needs to be reset.");
39 m_detectorName=m_detectorName.value().substr(ipos+1,length-ipos-1);
40 ATH_MSG_DEBUG( "m_detectorName default value reset to " << m_detectorName.value());
41 }
42 }
43 ATH_MSG_DEBUG( name() << "GDMLDetectorTool::initialize() : Detector name = " << m_detectorName.value()<<" File name: "<<m_GDMLFileName );
44 if(m_geoDetectorName.empty())
45 {
47 }
48 if(m_GDMLFileName.empty())
49 {
50 m_GDMLFileName = m_detectorName.value()+".gdml";
51 }
52 ATH_MSG_DEBUG( name() << "GDMLDetectorTool::initialize() : Geo Detector name = " << m_geoDetectorName<<" File name: "<<m_GDMLFileName );
53
54 ATH_MSG_DEBUG( name() << " GDMLDetectorTool::initialize(): Finished" );
55 return StatusCode::SUCCESS;
56}
57
58
60{
61 ATH_MSG_VERBOSE( name() << " GDMLDetectorTool::BuildGeometry(): Starting" );
62
63 G4GDMLParser parser;
64 parser.Read(m_GDMLFileName.c_str(),false);
65 m_envelope.theEnvelope=parser.GetWorldVolume()->GetLogicalVolume();
66
67 ATH_MSG_VERBOSE( name() << " GDMLDetectorTool::BuildGeometry(): Finished" );
68}
69
74
76{
77 ATH_MSG_VERBOSE( name() << " GDMLDetectorTool::SetInitialTransformation(): Starting" );
78 if (!m_envelope.theRotation)
79 {
80 ATH_MSG_VERBOSE( name() << " GDMLDetectorTool::SetInitialTransformation(): Creating new G4RotationMatrix" );
81 m_envelope.theRotation=new G4RotationMatrix;
82 }
83 *(m_envelope.theRotation)=m_topTransform.getRotation().inverse();
84 m_envelope.thePosition=m_topTransform.getTranslation();
85 ATH_MSG_VERBOSE( name() << " GDMLDetectorTool::SetInitialTransformation(): Finished" );
86}
#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
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
std::string m_GDMLFileName
virtual StatusCode initialize() override final
Athena method.
std::string m_geoDetectorName