ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
DetectorDescription
AGDD
AGDDControl
src
AGDDController.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
AGDDControl/AGDDController.h
"
6
7
#include "
AGDDKernel/AGDDBuilder.h
"
8
#include "
AGDDControl/IAGDDParser.h
"
9
#include "
AGDDControl/XercesParser.h
"
10
#include "
AGDDControl/AGDD2GeoModelBuilder.h
"
11
#include "
AGDDKernel/AGDDVolume.h
"
12
#include "
AGDDKernel/AGDDPositioner.h
"
13
#include "
AGDDKernel/AliasStore.h
"
14
#include "
AGDDModel/AGDDParameterStore.h
"
15
#include "
AGDDModel/AGDDMaterialStore.h
"
16
#include "
GeoModelInterfaces/IGeoModelSvc.h
"
17
#include "
GeoModelUtilities/GeoModelExperiment.h
"
18
#include "GeoModelKernel/GeoVDetectorManager.h"
19
#include "GeoModelKernel/GeoPhysVol.h"
20
#include "GeoModelKernel/GeoVPhysVol.h"
21
#include "
StoreGate/StoreGateSvc.h
"
22
23
#include <map>
24
#include <vector>
25
#include <string>
26
#include <fstream>
27
#include <ctime>
28
#include <TString.h>
// for Form
29
#include <iostream>
30
31
AGDDController::~AGDDController
()
32
{
33
if
(
m_theParser
)
delete
m_theParser
;
34
if
(
m_theBuilder
)
delete
m_theBuilder
;
35
}
36
37
AGDDController::AGDDController
()
38
:
m_theBuilder
(0),
m_locked
(false),
m_disableSections
(false),
39
m_printLevel
(0)
40
{
41
m_theParser
=
new
XercesParser
(
m_xs
);
42
m_theBuilder
=
new
AGDD2GeoModelBuilder
(
m_ds
,
m_vs
,
m_ss
,
m_as
,
m_ms
);
43
}
44
45
void
AGDDController::SetBuilder
(
AGDDBuilder
*b)
46
{
47
m_theBuilder
=b;
48
}
49
void
AGDDController::SetParser
(
IAGDDParser
*b)
50
{
51
m_theParser
=b;
52
}
53
AGDDBuilder
*
AGDDController::GetBuilder
()
54
{
55
return
m_theBuilder
;
56
}
57
IAGDDParser
*
AGDDController::GetParser
()
58
{
59
return
m_theParser
;
60
}
61
void
AGDDController::AddFile
(
const
std::string& fName)
62
{
63
m_filesToParse
.push_back(fName);
64
}
65
void
AGDDController::AddSection
(
const
std::string&
section
)
66
{
67
m_sectionsToBuild
.push_back(
section
);
68
}
69
void
AGDDController::AddVolume
(
const
std::string&
section
)
70
{
71
m_volumesToBuild
.push_back(
section
);
72
}
73
74
75
void
AGDDController::ParseFiles
()
76
{
77
if
(!
m_theParser
)
m_theParser
=
new
XercesParser
(
m_xs
);
78
for
(
unsigned
int
i=0;i<
m_filesToParse
.size();i++) {
79
if
(!
m_theParser
->ParseFileAndNavigate(*
this
,
m_filesToParse
[i]))
throw
std::runtime_error(Form(
"File: %s, Line: %d\nAGDDController::ParseFiles() - Could parse file %s."
, __FILE__, __LINE__,
m_filesToParse
[i].c_str()));
80
}
81
}
82
83
void
AGDDController::BuildSections
()
84
{
85
for
(
unsigned
int
i=0;i<
m_sectionsToBuild
.size();i++)
86
{
87
if
(
m_printLevel
) std::cout<<
" -----> now building section "
<<
m_sectionsToBuild
[i]<<std::endl;
88
m_theBuilder
->BuildFromSection(
m_sectionsToBuild
[i]);
89
}
90
}
91
92
void
AGDDController::BuildVolumes
()
93
{
94
for
(
unsigned
int
i=0;i<
m_volumesToBuild
.size();i++)
95
m_theBuilder
->BuildFromVolume(
m_volumesToBuild
[i]);
96
}
97
98
void
AGDDController::BuildAll
()
99
{
100
BuildVolumes
();
101
BuildSections
();
102
}
103
104
void
AGDDController::PrintSections
()
const
105
{
106
m_ss
.PrintAllSections();
107
}
108
109
void
AGDDController::ParseString
(
const
std::string& s)
110
{
111
if
(!
m_theParser
)
m_theParser
=
new
XercesParser
(
m_xs
);
112
m_theParser
->ParseStringAndNavigate(*
this
, s);
113
}
114
115
bool
AGDDController::WriteAGDDtoDBFile
(
const
std::string& s)
116
{
117
if
(!
m_theParser
)
118
{
119
std::cout<<
" -----> asking for a dump without defined parser makes no sense - crashing!"
<<std::endl;
120
return
false
;
121
}
122
else
{
123
m_theParser
->WriteToFile(s);
124
return
true
;
125
}
126
}
127
128
void
AGDDController::UseGeoModelDetector
ATLAS_NOT_THREAD_SAFE
(
const
std::string& name)
129
{
130
SmartIF<IService> svcDetStore = Gaudi::svcLocator()->service(
"DetectorStore"
);
131
StoreGateSvc
* pDetStore=
dynamic_cast<
StoreGateSvc
*
>
(svcDetStore.get());
132
if
(!pDetStore)
133
{
134
std::cout<<
"AGDDController could not get at the detector store!"
<<std::endl;
135
return
;
136
}
137
const
GeoModelExperiment
* theExpt =
nullptr
;
138
StatusCode
sc
=pDetStore->
retrieve
( theExpt,
"ATLAS"
);
139
if
(
sc
.isFailure())
140
{
141
std::cout<<
"AGDDController could not get GeoModelExperiment!"
<<std::endl;
142
return
;
143
}
144
else
145
{
146
const
GeoVDetectorManager *theManager=theExpt->
getManager
(name);
147
if
(theManager->getNumTreeTops()>1) std::cout<<
"AGDDController: more than one treetop!!!"
<<std::endl;
148
PVConstLink pv=theManager->getTreeTop(0);
149
GeoVPhysVol* ppv=
const_cast<
GeoVPhysVol*
>
(&(*pv));
150
static_cast<
AGDD2GeoModelBuilder
*
>
(m_theBuilder)->SetMotherVolume(
static_cast<
GeoPhysVol*
>
(ppv));
151
}
152
153
}
154
155
#if 0
156
void
AGDDController::PrintVolumeHierarchy(
const
std::string& name,
int
ilevel)
157
{
158
AGDDVolume *vol=
m_vs
.GetVolume(name);
159
int
currentLevel=ilevel+1;
160
for
(
int
i=0;
i
<ilevel;
i
++) std::cout<<
" "
;
161
std::cout<<
"| "
<<
name
<<std::endl;
162
if
(!vol->
NrOfDaughter
())
return
;
163
std::vector<std::string> nameVec;
164
std::vector<std::string>::iterator
it
;
165
for
(
int
i=0;
i
<vol->
NrOfDaughter
();
i
++)
166
{
167
std::string nameV=vol->
GetDaughter
(i)->
GetVolume
()->
GetName
();
168
it
=
find
(nameVec.begin(),nameVec.end(),nameV);
169
if
(it!=nameVec.end())
continue
;
170
nameVec.push_back(nameV);
171
PrintVolumeHierarchy(nameV,currentLevel);
172
}
173
}
174
#endif
175
176
void
AGDDController::Clean
()
177
{
178
delete
m_theParser
;
179
m_theParser
=0;
180
181
m_filesToParse
.clear();
182
m_sectionsToBuild
.clear();
183
m_volumesToBuild
.clear();
184
m_structuresToBuild
.clear();
185
186
m_ss
.Clean();
187
m_vs
.Clean();
188
}
189
190
XMLHandlerStore
&
AGDDController::GetHandlerStore
()
191
{
192
return
m_xs
;
193
}
194
195
196
AGDDVolumeStore
&
AGDDController::GetVolumeStore
()
197
{
198
return
m_vs
;
199
}
200
201
202
AGDDColorStore
&
AGDDController::GetColorStore
()
203
{
204
return
m_cs
;
205
}
206
207
208
AGDDSectionStore
&
AGDDController::GetSectionStore
()
209
{
210
return
m_ss
;
211
}
212
213
214
AGDDDetectorStore
&
AGDDController::GetDetectorStore
()
215
{
216
return
m_ds
;
217
}
218
219
220
AGDDPositionerStore
&
AGDDController::GetPositionerStore
()
221
{
222
return
m_ps
;
223
}
224
225
226
AGDDMaterialStore
&
AGDDController::GetMaterialStore
()
227
{
228
return
m_ms
;
229
}
230
231
232
AGDDParameterStore
&
AGDDController::GetParameterStore
()
233
{
234
return
m_prs
;
235
}
236
237
238
AliasStore
&
AGDDController::GetAliasStore
()
239
{
240
return
m_as
;
241
}
242
243
244
AGDD::ExpressionEvaluator
&
AGDDController::Evaluator
()
245
{
246
return
m_eval
;
247
}
AGDD2GeoModelBuilder.h
AGDDBuilder.h
AGDDController.h
AGDDMaterialStore.h
AGDDParameterStore.h
AGDDPositioner.h
AGDDVolume.h
AliasStore.h
GeoModelExperiment.h
IAGDDParser.h
IGeoModelSvc.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
StoreGateSvc.h
section
void section(const std::string &sec)
Definition
TestTriggerMenuAccess.cxx:22
XercesParser.h
ATLAS_NOT_THREAD_SAFE
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
Definition
checker_macros.h:212
AGDD2GeoModelBuilder
Definition
AGDD2GeoModelBuilder.h:42
AGDDBuilder
Definition
AGDDBuilder.h:31
AGDDColorStore
Definition
AGDDColorStore.h:15
AGDDController::GetParameterStore
AGDDParameterStore & GetParameterStore()
Definition
AGDDController.cxx:232
AGDDController::m_printLevel
int m_printLevel
Definition
AGDDController.h:85
AGDDController::m_theBuilder
AGDDBuilder * m_theBuilder
Definition
AGDDController.h:75
AGDDController::m_prs
AGDDParameterStore m_prs
Definition
AGDDController.h:93
AGDDController::m_locked
bool m_locked
Definition
AGDDController.h:82
AGDDController::m_xs
XMLHandlerStore m_xs
Definition
AGDDController.h:94
AGDDController::~AGDDController
~AGDDController()
Definition
AGDDController.cxx:31
AGDDController::Clean
void Clean()
Definition
AGDDController.cxx:176
AGDDController::m_theParser
IAGDDParser * m_theParser
Definition
AGDDController.h:74
AGDDController::AGDDController
AGDDController()
Definition
AGDDController.cxx:37
AGDDController::GetHandlerStore
XMLHandlerStore & GetHandlerStore()
Definition
AGDDController.cxx:190
AGDDController::GetVolumeStore
AGDDVolumeStore & GetVolumeStore()
Definition
AGDDController.cxx:196
AGDDController::BuildSections
void BuildSections()
Definition
AGDDController.cxx:83
AGDDController::AddFile
void AddFile(const std::string &fName)
Definition
AGDDController.cxx:61
AGDDController::GetParser
IAGDDParser * GetParser()
Definition
AGDDController.cxx:57
AGDDController::GetColorStore
AGDDColorStore & GetColorStore()
Definition
AGDDController.cxx:202
AGDDController::m_ms
AGDDMaterialStore m_ms
Definition
AGDDController.h:92
AGDDController::m_filesToParse
std::vector< std::string > m_filesToParse
Definition
AGDDController.h:77
AGDDController::m_ds
AGDDDetectorStore m_ds
Definition
AGDDController.h:90
AGDDController::m_volumesToBuild
std::vector< std::string > m_volumesToBuild
Definition
AGDDController.h:79
AGDDController::m_ps
AGDDPositionerStore m_ps
Definition
AGDDController.h:91
AGDDController::WriteAGDDtoDBFile
bool WriteAGDDtoDBFile(const std::string &)
Definition
AGDDController.cxx:115
AGDDController::GetDetectorStore
AGDDDetectorStore & GetDetectorStore()
Definition
AGDDController.cxx:214
AGDDController::PrintSections
void PrintSections() const
Definition
AGDDController.cxx:104
AGDDController::Evaluator
AGDD::ExpressionEvaluator & Evaluator()
Definition
AGDDController.cxx:244
AGDDController::AddSection
void AddSection(const std::string §ion)
Definition
AGDDController.cxx:65
AGDDController::m_ss
AGDDSectionStore m_ss
Definition
AGDDController.h:88
AGDDController::ParseFiles
void ParseFiles()
Definition
AGDDController.cxx:75
AGDDController::m_sectionsToBuild
std::vector< std::string > m_sectionsToBuild
Definition
AGDDController.h:78
AGDDController::GetPositionerStore
AGDDPositionerStore & GetPositionerStore()
Definition
AGDDController.cxx:220
AGDDController::m_eval
AGDD::ExpressionEvaluator m_eval
Definition
AGDDController.h:96
AGDDController::ParseString
void ParseString(const std::string &)
Definition
AGDDController.cxx:109
AGDDController::m_cs
AGDDColorStore m_cs
Definition
AGDDController.h:89
AGDDController::BuildVolumes
void BuildVolumes()
Definition
AGDDController.cxx:92
AGDDController::SetBuilder
void SetBuilder(AGDDBuilder *b)
Definition
AGDDController.cxx:45
AGDDController::m_structuresToBuild
std::vector< std::string > m_structuresToBuild
Definition
AGDDController.h:80
AGDDController::GetSectionStore
AGDDSectionStore & GetSectionStore()
Definition
AGDDController.cxx:208
AGDDController::BuildAll
void BuildAll()
Definition
AGDDController.cxx:98
AGDDController::GetAliasStore
AliasStore & GetAliasStore()
Definition
AGDDController.cxx:238
AGDDController::SetParser
void SetParser(IAGDDParser *b)
Definition
AGDDController.cxx:49
AGDDController::AddVolume
void AddVolume(const std::string &volume)
Definition
AGDDController.cxx:69
AGDDController::m_vs
AGDDVolumeStore m_vs
Definition
AGDDController.h:87
AGDDController::m_as
AliasStore m_as
Definition
AGDDController.h:95
AGDDController::GetMaterialStore
AGDDMaterialStore & GetMaterialStore()
Definition
AGDDController.cxx:226
AGDDController::m_disableSections
bool m_disableSections
Definition
AGDDController.h:83
AGDDController::GetBuilder
AGDDBuilder * GetBuilder()
Definition
AGDDController.cxx:53
AGDDDetectorStore
Definition
AGDDDetectorStore.h:18
AGDDMaterialStore
Definition
AGDDMaterialStore.h:23
AGDDParameterStore
Definition
AGDDParameterStore.h:14
AGDDPositionerStore
Definition
AGDDPositionerStore.h:14
AGDDPositioner::GetVolume
AGDDVolume * GetVolume()
Definition
AGDDPositioner.cxx:29
AGDDSectionStore
Definition
AGDDSectionStore.h:15
AGDDVolumeStore
Definition
AGDDVolumeStore.h:15
AGDDVolume::GetDaughter
AGDDPositioner * GetDaughter(int i)
Definition
AGDDVolume.h:28
AGDDVolume::NrOfDaughter
int NrOfDaughter() const
Definition
AGDDVolume.h:29
AGDDVolume::GetName
const std::string & GetName() const
Definition
AGDDVolume.h:23
AGDD::ExpressionEvaluator
Definition
ExpressionEvaluator.h:22
AliasStore
Definition
AliasStore.h:11
GeoModelExperiment
Definition
GeoModelExperiment.h:32
GeoModelExperiment::getManager
const GeoVDetectorManager * getManager(const std::string &name) const
Definition
GeoModelExperiment.cxx:52
IAGDDParser
Definition
IAGDDParser.h:15
StoreGateSvc
The Athena Transient Store API.
Definition
StoreGateSvc.h:120
StoreGateSvc::retrieve
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
XMLHandlerStore
Definition
XMLHandlerStore.h:20
XercesParser
Definition
XercesParser.h:19
find
std::string find(const std::string &s)
return a remapped string
Definition
hcg.cxx:140
extractSporadic.name
name
Definition
extractSporadic.py:101
lumiFormat.i
int i
Definition
lumiFormat.py:85
skel.it
it
Definition
skel.GENtoEVGEN.py:407
Generated on
for ATLAS Offline Software by
1.17.0