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  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  ((AGDD2GeoModelBuilder*)(m_theBuilder))->SetMotherVolume((GeoPhysVol*)ppv);
151  }
152 
153 }
154 
155 #if 0
156 void AGDDController::PrintVolumeHierarchy(const std::string& name, int ilevel)
157 {
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;
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 
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 
191 {
192  return m_xs;
193 }
194 
195 
197 {
198  return m_vs;
199 }
200 
201 
203 {
204  return m_cs;
205 }
206 
207 
209 {
210  return m_ss;
211 }
212 
213 
215 {
216  return m_ds;
217 }
218 
219 
221 {
222  return m_ps;
223 }
224 
225 
227 {
228  return m_ms;
229 }
230 
231 
233 {
234  return m_prs;
235 }
236 
237 
239 {
240  return m_as;
241 }
242 
243 
245 {
246  return m_eval;
247 }
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:396
GeoModelExperiment
Definition: GeoModelExperiment.h:32
AGDDController::GetMaterialStore
AGDDMaterialStore & GetMaterialStore()
Definition: AGDDController.cxx:226
AGDDController::GetVolumeStore
AGDDVolumeStore & GetVolumeStore()
Definition: AGDDController.cxx:196
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:125
AliasStore.h
AGDDVolumeStore::GetVolume
AGDDVolume * GetVolume(std::string)
Definition: AGDDVolumeStore.cxx:25
AGDDController::GetHandlerStore
XMLHandlerStore & GetHandlerStore()
Definition: AGDDController.cxx:190
lumiFormat.i
int i
Definition: lumiFormat.py:85
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:176
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:244
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:228
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:214
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:202
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:232
StoreGateSvc.h
AGDDController::GetAliasStore
AliasStore & GetAliasStore()
Definition: AGDDController.cxx:238
AGDDController::GetSectionStore
AGDDSectionStore & GetSectionStore()
Definition: AGDDController.cxx:208
AGDDController::AddSection
void AddSection(const std::string &section)
Definition: AGDDController.cxx:65
AGDDController::GetPositionerStore
AGDDPositionerStore & GetPositionerStore()
Definition: AGDDController.cxx:220