ATLAS Offline Software
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 
16 GDMLDetectorTool::GDMLDetectorTool(const std::string& type, const std::string& name, const IInterface* parent)
17  : DetectorGeometryBase(type,name,parent),m_GDMLFileName(""),m_blGetTopTransform(true),m_geoDetectorName("")
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 
71 {
72  return m_blGetTopTransform;
73 }
74 
76 {
77  ATH_MSG_VERBOSE( name() << " GDMLDetectorTool::SetInitialTransformation(): Starting" );
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 }
GDMLDetectorTool::initialize
virtual StatusCode initialize() override final
Athena method.
Definition: GDMLDetectorTool.cxx:26
python.CaloScaleNoiseConfig.parser
parser
Definition: CaloScaleNoiseConfig.py:75
GDMLDetectorTool::m_topTransform
G4Transform3D m_topTransform
Definition: GDMLDetectorTool.h:47
Envelope::theEnvelope
G4LogicalVolume * theEnvelope
Definition: IDetectorGeometryTool.h:20
GDMLDetectorTool::m_blGetTopTransform
bool m_blGetTopTransform
Definition: GDMLDetectorTool.h:46
GDMLDetectorTool.h
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
GDMLDetectorTool::BuildGeometry
virtual void BuildGeometry() override final
virtual methods being implemented here
Definition: GDMLDetectorTool.cxx:59
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
test_pyathena.parent
parent
Definition: test_pyathena.py:15
GDMLDetectorTool::GDMLDetectorTool
GDMLDetectorTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: GDMLDetectorTool.cxx:16
GDMLDetectorTool::m_geoDetectorName
std::string m_geoDetectorName
Definition: GDMLDetectorTool.h:48
DetectorGeometryBase.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
DetectorGeometryBase::m_envelope
Envelope m_envelope
Definition: DetectorGeometryBase.h:70
DetectorGeometryBase::m_detectorName
Gaudi::Property< std::string > m_detectorName
Definition: DetectorGeometryBase.h:71
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
GDMLDetectorTool::m_GDMLFileName
std::string m_GDMLFileName
Definition: GDMLDetectorTool.h:44
DetectorGeometryBase
Definition: DetectorGeometryBase.h:26
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
Envelope::theRotation
G4RotationMatrix * theRotation
Definition: IDetectorGeometryTool.h:22
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
GDMLDetectorTool::SetInitialTransformation
void SetInitialTransformation()
Definition: GDMLDetectorTool.cxx:75
GDMLDetectorTool::IsTopTransform
bool IsTopTransform()
Definition: GDMLDetectorTool.cxx:70