ATLAS Offline Software
Loading...
Searching...
No Matches
GeoDetectorTool.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 "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
18GeoDetectorTool::GeoDetectorTool(const std::string& type, const std::string& name, const IInterface* parent)
19 : DetectorGeometryBase(type,name,parent)
20{
21 m_topTransform.setIdentity();
22 ATH_MSG_DEBUG( "GeoDetectorTool constructor for " << name );
23}
24
26{
27 ATH_MSG_VERBOSE( name() << " GeoDetectorTool::initialize(): Starting" );
28 if(m_detectorName.empty())
29 {
30 m_detectorName = this->name();
31 // re-initialize m_detectorName in order to take the real detector name rather than the path to it
32 size_t ipos=m_detectorName.value().find_last_of('.');
33 size_t length=m_detectorName.value().size();
34 if (ipos<length)
35 {
36 ATH_MSG_VERBOSE( "m_detectorName: " << m_detectorName.value() << " needs to be reset.");
37 m_detectorName = m_detectorName.value().substr(ipos+1,length-ipos-1);
38 ATH_MSG_VERBOSE( "m_detectorName default value reset to " << m_detectorName.value());
39 }
40 }
41 ATH_MSG_DEBUG( name() << "GeoDetectorTool::initialize() : Detector name = " << m_detectorName.value() );
42 if(m_geoDetectorName.empty())
43 {
45 }
46 ATH_MSG_DEBUG( name() << "GeoDetectorTool::initialize() : Geo Detector name = " << m_geoDetectorName );
47
48 ATH_CHECK(m_geo2G4Svc.retrieve());
49 m_builderName = m_geo2G4Svc->GetDefaultBuilder()->GetKey();
50 m_blGetTopTransform = m_geo2G4Svc->UseTopTransforms();
51 ATH_MSG_VERBOSE( name() << " GeoDetectorTool::initialize(): Finished" );
52 return StatusCode::SUCCESS;
53}
54
55
57{
58 ATH_MSG_VERBOSE( name() << " GeoDetectorTool::BuildGeometry(): Starting" );
59 G4LogicalVolume* temp = this->Convert();
60 m_envelope.theEnvelope=temp;
61
62 if (this->IsTopTransform())
63 {
65 }
66 ATH_MSG_VERBOSE( name() << " GeoDetectorTool::BuildGeometry(): Finished" );
67}
68
70{
71 ATH_MSG_DEBUG( name() << " GeoDetectorTool::PositionInParent(): Starting" );
72
74 if (!m_dumpGDMLFile.empty()) {
75 G4GDMLParser parser;
76 parser.Write(m_dumpGDMLFile.value(),m_envelope.thePositionedVolume);
77 }
78}
79
80G4LogicalVolume* GeoDetectorTool::Convert()
81{
82 ATH_MSG_VERBOSE( name() << " GeoDetectorTool::Convert(): Starting" );
83 ATH_MSG_DEBUG( name() << " GeoDetectorTool::Convert(): GeoDetectorName:builderName = "<<m_geoDetectorName<<":"<<m_builderName);
86 b->SetParam(m_blParamOn);
87 G4LogicalVolume *temp=Builder.BuildTree();
88 if(this->IsTopTransform())
89 {
91 }
92
93 ATH_MSG_VERBOSE( name() << " GeoDetectorTool::Convert(): Finished" );
94 return temp;
95}
96
101
103{
104 ATH_MSG_VERBOSE( name() << " GeoDetectorTool::SetInitialTransformation(): Starting" );
105 if (!m_envelope.theRotation)
106 {
107 ATH_MSG_VERBOSE( name() << " GeoDetectorTool::SetInitialTransformation(): Creating new G4RotationMatrix" );
108 m_envelope.theRotation=new G4RotationMatrix;
109 }
110 *(m_envelope.theRotation)=m_topTransform.getRotation().inverse();
111 m_envelope.thePosition=m_topTransform.getTranslation();
112 ATH_MSG_VERBOSE( name() << " GeoDetectorTool::SetInitialTransformation(): Finished" );
113}
#define ATH_CHECK
Evaluate an expression and check for errors.
#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
virtual void PositionInParent() override
Main builder to create/position all volumes described in a GeoModel Tree.
VolumeBuilder * GetVolumeBuilder(std::string)
G4LogicalVolume * BuildTree()
HepGeom::Transform3D GetDetectorTransform()
G4Transform3D m_topTransform
G4LogicalVolume * Convert()
GeoDetectorTool(const std::string &type, const std::string &name, const IInterface *parent)
std::string m_builderName
ServiceHandle< IGeo2G4Svc > m_geo2G4Svc
virtual void BuildGeometry() override final
virtual methods being implemented here
virtual StatusCode initialize() override final
Athena method.
Gaudi::Property< std::string > m_geoDetectorName
virtual void PositionInParent() override final
Gaudi::Property< std::string > m_dumpGDMLFile