ATLAS Offline Software
AGDDController.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
11 #include "AGDDKernel/AGDDVolume.h"
13 #include "AGDDKernel/AliasStore.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 
32 {
33  if (m_theParser) delete m_theParser;
34  if (m_theBuilder) delete m_theBuilder;
35 }
36 
38  : m_theBuilder(0),m_locked(false),m_disableSections(false),
39  m_printLevel(0)
40 {
43 }
44 
46 {
48 }
50 {
51  m_theParser=b;
52 }
54 {
55  return m_theBuilder;
56 }
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 
76 {
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 
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;
89  }
90 }
91 
93 {
94  for (unsigned int i=0;i<m_volumesToBuild.size();i++)
96 }
97 
99 {
100  BuildVolumes();
101  BuildSections();
102 }
103 
105 {
107 }
108 
109 void AGDDController::ParseString(const std::string& s)
110 {
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 {
124  return true;
125  }
126 }
127 
128 void AGDDController::UseGeoModelDetector ATLAS_NOT_THREAD_SAFE (const std::string& name)
129 {
130  StoreGateSvc* pDetStore=0;
131  ISvcLocator* svcLocator = Gaudi::svcLocator();
132  StatusCode sc=svcLocator->service("DetectorStore",pDetStore);
133  if (sc.isFailure())
134  {
135  std::cout<<"AGDDController could not get at the detector store!"<<std::endl;
136  }
137  const GeoModelExperiment* theExpt = nullptr;
138  sc=pDetStore->retrieve( theExpt,"ATLAS");
139  if (sc.isFailure())
140  {
141  std::cout<<"AGDDController could not get GeoModelExperiment!"<<std::endl;
142  }
143  else
144  {
145  const GeoVDetectorManager *theManager=theExpt->getManager(name);
146  if (theManager->getNumTreeTops()>1) std::cout<<"AGDDController: more than one treetop!!!"<<std::endl;
147  PVConstLink pv=theManager->getTreeTop(0);
148  GeoVPhysVol* ppv=const_cast<GeoVPhysVol*>(&(*pv));
149  ((AGDD2GeoModelBuilder*)(m_theBuilder))->SetMotherVolume((GeoPhysVol*)ppv);
150  }
151 
152 }
153 
154 #if 0
155 void AGDDController::PrintVolumeHierarchy(const std::string& name, int ilevel)
156 {
158  int currentLevel=ilevel+1;
159  for (int i=0;i<ilevel;i++) std::cout<<" ";
160  std::cout<<"| "<<name<<std::endl;
161  if (!vol->NrOfDaughter()) return;
162  std::vector<std::string> nameVec;
164  for (int i=0;i<vol->NrOfDaughter();i++)
165  {
166  std::string nameV=vol->GetDaughter(i)->GetVolume()->GetName();
167  it=find(nameVec.begin(),nameVec.end(),nameV);
168  if (it!=nameVec.end()) continue;
169  nameVec.push_back(nameV);
170  PrintVolumeHierarchy(nameV,currentLevel);
171  }
172 }
173 #endif
174 
176 {
177  delete m_theParser;
178  m_theParser=0;
179 
180  m_filesToParse.clear();
181  m_sectionsToBuild.clear();
182  m_volumesToBuild.clear();
183  m_structuresToBuild.clear();
184 
185  m_ss.Clean();
186  m_vs.Clean();
187 }
188 
190 {
191  return m_xs;
192 }
193 
194 
196 {
197  return m_vs;
198 }
199 
200 
202 {
203  return m_cs;
204 }
205 
206 
208 {
209  return m_ss;
210 }
211 
212 
214 {
215  return m_ds;
216 }
217 
218 
220 {
221  return m_ps;
222 }
223 
224 
226 {
227  return m_ms;
228 }
229 
230 
232 {
233  return m_prs;
234 }
235 
236 
238 {
239  return m_as;
240 }
241 
242 
244 {
245  return m_eval;
246 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
AGDDController.h
AGDDController::AGDDController
AGDDController()
Definition: AGDDController.cxx:37
AGDDPositioner.h
AGDDBuilder::BuildFromSection
virtual void BuildFromSection(const std::string &)=0
AliasStore
Definition: AliasStore.h:11
IAGDDParser.h
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
rootconvert.fName
string fName
Definition: rootconvert.py:5
AGDDBuilder.h
XercesParser.h
AGDDController::m_ds
AGDDDetectorStore m_ds
Definition: AGDDController.h:90
AGDDVolumeStore
Definition: AGDDVolumeStore.h:15
skel.it
it
Definition: skel.GENtoEVGEN.py:423
GeoModelExperiment
Definition: GeoModelExperiment.h:32
AGDDController::GetMaterialStore
AGDDMaterialStore & GetMaterialStore()
Definition: AGDDController.cxx:225
AGDDController::GetVolumeStore
AGDDVolumeStore & GetVolumeStore()
Definition: AGDDController.cxx:195
XMLHandlerStore
Definition: XMLHandlerStore.h:20
XercesParser
Definition: XercesParser.h:18
AGDDVolume::NrOfDaughter
int NrOfDaughter() const
Definition: AGDDVolume.h:29
AGDDController::m_ps
AGDDPositionerStore m_ps
Definition: AGDDController.h:91
IAGDDParser
Definition: IAGDDParser.h:15
AGDDController::BuildAll
void BuildAll()
Definition: AGDDController.cxx:98
ATLAS_NOT_THREAD_SAFE
void AGDDController::UseGeoModelDetector ATLAS_NOT_THREAD_SAFE(const std::string &name)
Definition: AGDDController.cxx:128
AGDDMaterialStore.h
AGDDController::m_volumesToBuild
std::vector< std::string > m_volumesToBuild
Definition: AGDDController.h:79
AGDDController::m_theParser
IAGDDParser * m_theParser
Definition: AGDDController.h:74
AGDDParameterStore.h
AGDDController::m_sectionsToBuild
std::vector< std::string > m_sectionsToBuild
Definition: AGDDController.h:78
AGDDController::m_vs
AGDDVolumeStore m_vs
Definition: AGDDController.h:87
AGDDController::BuildVolumes
void BuildVolumes()
Definition: AGDDController.cxx:92
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
AGDDBuilder::BuildFromVolume
virtual void BuildFromVolume(const std::string &)=0
AGDDController::ParseString
void ParseString(const std::string &)
Definition: AGDDController.cxx:109
AGDDVolumeStore::Clean
void Clean()
Definition: AGDDVolumeStore.cxx:36
StoreGateSvc::retrieve
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
AGDDController::m_ms
AGDDMaterialStore m_ms
Definition: AGDDController.h:92
GeoModelExperiment.h
IAGDDParser::WriteToFile
virtual bool WriteToFile(const std::string &)=0
AGDDSectionStore
Definition: AGDDSectionStore.h:15
AGDDBuilder
Definition: AGDDBuilder.h:31
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
AliasStore.h
AGDDVolumeStore::GetVolume
AGDDVolume * GetVolume(std::string)
Definition: AGDDVolumeStore.cxx:25
AGDDController::GetHandlerStore
XMLHandlerStore & GetHandlerStore()
Definition: AGDDController.cxx:189
lumiFormat.i
int i
Definition: lumiFormat.py:92
AGDDController::m_xs
XMLHandlerStore m_xs
Definition: AGDDController.h:94
AGDDController::BuildSections
void BuildSections()
Definition: AGDDController.cxx:83
AGDDController::Clean
void Clean()
Definition: AGDDController.cxx:175
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AGDDController::m_prs
AGDDParameterStore m_prs
Definition: AGDDController.h:93
AGDDColorStore
Definition: AGDDColorStore.h:15
AGDDSectionStore::Clean
void Clean()
Definition: AGDDSectionStore.cxx:41
AGDDController::Evaluator
AGDD::ExpressionEvaluator & Evaluator()
Definition: AGDDController.cxx:243
AGDDController::m_ss
AGDDSectionStore m_ss
Definition: AGDDController.h:88
AGDDController::ParseFiles
void ParseFiles()
Definition: AGDDController.cxx:75
AGDD2GeoModelBuilder
Definition: AGDD2GeoModelBuilder.h:42
GeoModelExperiment::getManager
const GeoVDetectorManager * getManager(const std::string &name) const
Definition: GeoModelExperiment.cxx:52
AGDDController::m_filesToParse
std::vector< std::string > m_filesToParse
Definition: AGDDController.h:77
AGDDController::m_eval
AGDD::ExpressionEvaluator m_eval
Definition: AGDDController.h:96
AGDDMaterialStore
Definition: AGDDMaterialStore.h:23
AGDDController::AddVolume
void AddVolume(const std::string &volume)
Definition: AGDDController.cxx:69
IAGDDParser::ParseStringAndNavigate
virtual bool ParseStringAndNavigate(AGDDController &c, const std::string &)=0
AGDDController::m_as
AliasStore m_as
Definition: AGDDController.h:95
AGDDSectionStore::PrintAllSections
void PrintAllSections() const
Definition: AGDDSectionStore.cxx:32
AGDDController::AddFile
void AddFile(const std::string &fName)
Definition: AGDDController.cxx:61
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
AGDDVolume::GetDaughter
AGDDPositioner * GetDaughter(int i)
Definition: AGDDVolume.h:28
AGDDController::WriteAGDDtoDBFile
bool WriteAGDDtoDBFile(const std::string &)
Definition: AGDDController.cxx:115
AGDDPositionerStore
Definition: AGDDPositionerStore.h:14
AGDDDetectorStore
Definition: AGDDDetectorStore.h:18
AGDDController::GetDetectorStore
AGDDDetectorStore & GetDetectorStore()
Definition: AGDDController.cxx:213
AGDDController::~AGDDController
~AGDDController()
Definition: AGDDController.cxx:31
AGDDController::PrintSections
void PrintSections() const
Definition: AGDDController.cxx:104
AGDD2GeoModelBuilder.h
AGDDController::m_cs
AGDDColorStore m_cs
Definition: AGDDController.h:89
AGDDController::m_structuresToBuild
std::vector< std::string > m_structuresToBuild
Definition: AGDDController.h:80
AGDDController::m_theBuilder
AGDDBuilder * m_theBuilder
Definition: AGDDController.h:75
AGDDController::m_printLevel
int m_printLevel
Definition: AGDDController.h:85
AGDDController::SetParser
void SetParser(IAGDDParser *b)
Definition: AGDDController.cxx:49
AGDDController::GetBuilder
AGDDBuilder * GetBuilder()
Definition: AGDDController.cxx:53
AGDDController::SetBuilder
void SetBuilder(AGDDBuilder *b)
Definition: AGDDController.cxx:45
python.changerun.pv
pv
Definition: changerun.py:81
AGDDVolume::GetName
const std::string & GetName() const
Definition: AGDDVolume.h:23
AGDDParameterStore
Definition: AGDDParameterStore.h:14
AGDDVolume
Definition: AGDDVolume.h:16
AGDDVolume.h
AGDDController::GetParser
IAGDDParser * GetParser()
Definition: AGDDController.cxx:57
AGDD::ExpressionEvaluator
Definition: ExpressionEvaluator.h:21
section
void section(const std::string &sec)
Definition: TestTriggerMenuAccess.cxx:22
AGDDController::GetColorStore
AGDDColorStore & GetColorStore()
Definition: AGDDController.cxx:201
IAGDDParser::ParseFileAndNavigate
virtual bool ParseFileAndNavigate(AGDDController &c, const std::string &)=0
IGeoModelSvc.h
AGDDPositioner::GetVolume
AGDDVolume * GetVolume()
Definition: AGDDPositioner.cxx:29
AGDDController::GetParameterStore
AGDDParameterStore & GetParameterStore()
Definition: AGDDController.cxx:231
StoreGateSvc.h
AGDDController::GetAliasStore
AliasStore & GetAliasStore()
Definition: AGDDController.cxx:237
AGDDController::GetSectionStore
AGDDSectionStore & GetSectionStore()
Definition: AGDDController.cxx:207
AGDDController::AddSection
void AddSection(const std::string &section)
Definition: AGDDController.cxx:65
AGDDController::GetPositionerStore
AGDDPositionerStore & GetPositionerStore()
Definition: AGDDController.cxx:219