ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
DetectorDescription
GeoModel
GeoModelExamples
src
ToyDetectorTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef BUILDVP1LIGHT
6
#include "
ToyDetectorTool.h
"
7
#include "
ToyDetectorFactory.h
"
8
#include "
GeoModelExamples/ToyDetectorManager.h
"
9
#include "
GeoModelUtilities/GeoModelExperiment.h
"
10
#include "GaudiKernel/IService.h"
11
#include "GaudiKernel/ISvcLocator.h"
12
#include "
StoreGate/StoreGateSvc.h
"
13
14
#include "GeoModelKernel/GeoDefinitions.h"
15
#include "GeoModelKernel/GeoVolumeCursor.h"
16
#include <string>
17
18
ToyDetectorTool::ToyDetectorTool
(
const
std::string&
type
,
const
std::string& name,
const
IInterface* parent )
19
:
GeoModelTool
(
type
, name, parent )
20
{
21
}
22
23
ToyDetectorTool::~ToyDetectorTool
()
24
{
25
delete
m_detector
;
26
}
27
28
StatusCode
ToyDetectorTool::create
()
29
{
30
ATH_MSG_INFO
(
"ToyDetectorTool::create() ..."
);
31
32
// Locate the top level experiment
33
GeoModelExperiment
* theExpt =
nullptr
;
34
ATH_CHECK
(detStore()->retrieve(theExpt,
"ATLAS"
));
35
36
ToyDetectorFactory
theToyFactory(detStore().operator->());
37
if
(
m_detector
==
nullptr
) {
38
// Build geometry
39
try
{
40
//
41
// This strange way of casting is to avoid an
42
// utterly brain damaged compiler warning.
43
//
44
GeoPhysVol *world=theExpt->
getPhysVol
();
45
theToyFactory.
create
(world);
46
printVolume
(world);
47
}
48
catch
(
const
std::bad_alloc&) {
49
ATH_MSG_FATAL
(
"Could not Toy Detector Geometry!"
);
50
return
StatusCode::FAILURE;
51
}
52
// Add detector manager to AtlasExperiment and also record it into DetStore
53
theExpt->
addManager
(theToyFactory.
getDetectorManager
());
54
if
(detStore()->record(theToyFactory.
getDetectorManager
(),theToyFactory.
getDetectorManager
()->getName()).isSuccess())
return
StatusCode::SUCCESS;
55
ATH_MSG_FATAL
(
"Failed to record Toy Detector Manager into Detector Store!"
);
56
}
57
else
{
58
ATH_MSG_FATAL
(
"Attempt to build Toy Detector Geometry one more time. The geometry can be built only once!"
);
59
}
60
return
StatusCode::FAILURE;
61
}
62
63
void
ToyDetectorTool::printVolume
(GeoPVConstLink volume,
int
level
/*= 0*/
)
64
{
65
GeoVolumeCursor cursor(volume);
66
while
(!cursor.atEnd()) {
67
GeoPVConstLink physChild = cursor.getVolume();
68
GeoTrf::Transform3D position = cursor.getTransform();
69
for
(
int
k{0};k<level;++k) std::cout <<
"... "
;
70
std::cout << cursor.getName() <<
" "
<< (cursor.getId()?std::to_string(cursor.getId().value()).c_str():
"N/A"
)
71
<<
" Transform:"
<<
"\n"
;
72
for
(
int
i{0};i<3;++i) {
73
for
(
int
j{0};j<4;++j) {
74
std::cout << position(i,j) <<
" "
;
75
}
76
std::cout <<
"\n"
;
77
}
78
printVolume
(physChild, level+1);
79
cursor.next();
80
}
81
}
82
83
#endif
// BUILDVP1LIGHT
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
GeoModelExperiment.h
StoreGateSvc.h
ToyDetectorFactory.h
ToyDetectorManager.h
ToyDetectorTool.h
GeoModelExperiment
Definition
GeoModelExperiment.h:32
GeoModelExperiment::getPhysVol
GeoPhysVol * getPhysVol()
Destructor.
Definition
GeoModelExperiment.cxx:21
GeoModelExperiment::addManager
void addManager(const GeoVDetectorManager *)
Definition
GeoModelExperiment.cxx:40
GeoModelTool
Definition
GeoModelTool.h:15
GeoModelTool::m_detector
GeoVDetectorManager * m_detector
Definition
GeoModelTool.h:28
ToyDetectorFactory
Definition
ToyDetectorFactory.h:10
ToyDetectorFactory::getDetectorManager
virtual const ToyDetectorManager * getDetectorManager() const
Definition
ToyDetectorFactory.cxx:179
ToyDetectorFactory::create
virtual void create(GeoPhysVol *world)
Definition
ToyDetectorFactory.cxx:61
ToyDetectorTool::create
virtual StatusCode create() override final
Definition
ToyDetectorTool.cxx:28
ToyDetectorTool::~ToyDetectorTool
virtual ~ToyDetectorTool() override final
Definition
ToyDetectorTool.cxx:23
ToyDetectorTool::ToyDetectorTool
ToyDetectorTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition
ToyDetectorTool.cxx:18
ToyDetectorTool::printVolume
void printVolume(GeoPVConstLink volime, int level=0)
Definition
ToyDetectorTool.cxx:63
type
Generated on
for ATLAS Offline Software by
1.17.0