ATLAS Offline Software
Loading...
Searching...
No Matches
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
6
18#include "GeoModelKernel/GeoVDetectorManager.h"
19#include "GeoModelKernel/GeoPhysVol.h"
20#include "GeoModelKernel/GeoVPhysVol.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
36
44
61void AGDDController::AddFile(const std::string& fName)
62{
63 m_filesToParse.push_back(fName);
64}
65void AGDDController::AddSection(const std::string& section)
66{
67 m_sectionsToBuild.push_back(section);
68}
69void 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;
88 m_theBuilder->BuildFromSection(m_sectionsToBuild[i]);
89 }
90}
91
93{
94 for (unsigned int i=0;i<m_volumesToBuild.size();i++)
95 m_theBuilder->BuildFromVolume(m_volumesToBuild[i]);
96}
97
103
105{
106 m_ss.PrintAllSections();
107}
108
109void AGDDController::ParseString(const std::string& s)
110{
112 m_theParser->ParseStringAndNavigate(*this, s);
113}
114
115bool 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
128void 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
156void 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
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
194
195
200
201
206
207
212
213
218
219
224
225
230
231
236
237
242
243
static Double_t sc
void section(const std::string &sec)
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
AGDDParameterStore & GetParameterStore()
AGDDBuilder * m_theBuilder
AGDDParameterStore m_prs
XMLHandlerStore m_xs
IAGDDParser * m_theParser
XMLHandlerStore & GetHandlerStore()
AGDDVolumeStore & GetVolumeStore()
void AddFile(const std::string &fName)
IAGDDParser * GetParser()
AGDDColorStore & GetColorStore()
AGDDMaterialStore m_ms
std::vector< std::string > m_filesToParse
AGDDDetectorStore m_ds
std::vector< std::string > m_volumesToBuild
AGDDPositionerStore m_ps
bool WriteAGDDtoDBFile(const std::string &)
AGDDDetectorStore & GetDetectorStore()
void PrintSections() const
AGDD::ExpressionEvaluator & Evaluator()
void AddSection(const std::string &section)
AGDDSectionStore m_ss
std::vector< std::string > m_sectionsToBuild
AGDDPositionerStore & GetPositionerStore()
AGDD::ExpressionEvaluator m_eval
void ParseString(const std::string &)
AGDDColorStore m_cs
void SetBuilder(AGDDBuilder *b)
std::vector< std::string > m_structuresToBuild
AGDDSectionStore & GetSectionStore()
AliasStore & GetAliasStore()
void SetParser(IAGDDParser *b)
void AddVolume(const std::string &volume)
AGDDVolumeStore m_vs
AliasStore m_as
AGDDMaterialStore & GetMaterialStore()
AGDDBuilder * GetBuilder()
AGDDVolume * GetVolume()
AGDDPositioner * GetDaughter(int i)
Definition AGDDVolume.h:28
int NrOfDaughter() const
Definition AGDDVolume.h:29
const std::string & GetName() const
Definition AGDDVolume.h:23
const GeoVDetectorManager * getManager(const std::string &name) const
The Athena Transient Store API.
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138