25 #include "GeoModelDBManager/GMDBManager.h"
26 #include "GeoModelKernel/GeoBox.h"
27 #include "GeoModelKernel/GeoVDetectorManager.h"
28 #include "GeoModelKernel/GeoVolumeCursor.h"
29 #include "GeoModelWrite/WriteGeoModel.h"
40 #include "GeoModelKernel/Units.h"
41 #define UNITS GeoModelKernelUnits // so we can use, e.g., 'UNITS::cm'
47 #define gr UNITS::gram
48 #define mole UNITS::mole
49 #define cm3 UNITS::cm3
52 GeoElement* Nitrogen =
53 new GeoElement(
"Nitrogen",
"N", 7.0, 14.0067 *
gr /
mole);
54 GeoElement* Oxygen =
new GeoElement(
"Oxygen",
"O", 8.0, 15.9995 *
gr /
mole);
55 GeoElement* Argon =
new GeoElement(
"Argon",
"Ar", 18.0, 39.948 *
gr /
mole);
56 GeoElement* Hydrogen =
57 new GeoElement(
"Hydrogen",
"H", 1.0, 1.00797 *
gr /
mole);
60 double densityOfAir = 0.001214 *
gr /
cm3;
61 GeoMaterial* air =
new GeoMaterial(
"Air", densityOfAir);
62 air->add(Nitrogen, 0.7494);
63 air->add(Oxygen, 0.2369);
64 air->add(Argon, 0.0129);
65 air->add(Hydrogen, 0.0008);
71 const GeoBox* worldBox =
73 const GeoLogVol* worldLog =
new GeoLogVol(
"WorldLog", worldBox, air);
74 GeoPhysVol* world =
new GeoPhysVol(worldLog);
86 ATH_MSG_INFO(
"===================================================");
88 ATH_MSG_INFO(
"===================================================");
103 "This is the Geometry TAG we are dumping: " << geoDbTag->atlasVersion());
112 std::set<std::string> managersList{};
115 managersList.insert(blub.begin(), blub.end());
118 ATH_MSG_INFO(
"List of the GeoModel Detector Managers that are being dumped: ");
119 for (
auto const& man : managersList) {
122 unsigned int nTreetops =
manager->getNumTreeTops();
123 std::cout <<
"\t" << man <<
" [contains " << nTreetops <<
" treetops]"
125 for (
unsigned int i = 0;
i < nTreetops; ++
i) {
126 PVConstLink treetop(
manager->getTreeTop(
i));
128 const GeoVPhysVol* vol = treetop;
130 std::string volName = vol->getLogVol()->getName();
131 std::cout <<
"\t\t treetop: " << volName << std::endl;
138 std::set<std::string> user_managersList{};
146 for (
auto& userDet : user_managersList) {
147 if (!managersList.count(userDet)) {
149 "This Detector Manager you requested to dump is not in the list of "
150 "DetectorManagers for the geometry tag you are using: "
152 throw GaudiException(
153 "The Detector Manager you requested to dump is not in the list of "
155 "DumpGeo", StatusCode::FAILURE);
159 if (!(managersList.empty())) {
160 for (
auto const&
mm : managersList) {
165 std::string detManName =
manager->getName();
169 unsigned int nTreetops =
manager->getNumTreeTops();
172 if ((nTreetops > 0) && user_managersList.count(detManName)) {
174 for (
unsigned int i = 0;
i < nTreetops; ++
i) {
176 PVConstLink treetop(
manager->getTreeTop(
i));
179 const GeoVPhysVol* vol = treetop;
183 GeoTransform* volXf =
new GeoTransform(vol->getDefX());
186 std::string volName = vol->getLogVol()->getName();
191 volTop->add(
new GeoNameTag(detManName));
194 volTop->add(
const_cast<GeoVPhysVol*
>(vol));
197 ATH_MSG_INFO(
"You enabled the option 'showTreetopContent', so we now print the content of the first layers of child volumes of the Treetops...");
199 GeoVolumeCursor av(treetop);
200 while (!av.atEnd()) {
202 if(1==v1)
ATH_MSG_INFO(
"first level of child volumes:");
204 ATH_MSG_INFO(
"\t\t- child's n. sub-nodes: " << av.getVolume()->getNChildNodes());
205 ATH_MSG_INFO(
"\t\t- child's n. sub-volumes: " << av.getVolume()->getNChildVols());
209 GeoVolumeCursor av2(av.getVolume());
210 while (!av2.atEnd()) {
213 ATH_MSG_INFO(
"\t\t\t- child's logvol's name: " << av2.getVolume()->getLogVol()->getName());
216 GeoVolumeCursor av3(av2.getVolume());
217 while (!av3.atEnd()) {
219 if(1==v3)
ATH_MSG_INFO(
"third level of child volumes:");
220 ATH_MSG_INFO(
"\t\t\t\t- child's logvol's name: " << av3.getVolume()->getLogVol()->getName());
239 "Looping over top volumes in the GeoModel tree (children of the "
240 "'World' volume)...");
241 GeoVolumeCursor av(world);
242 while (!av.atEnd()) {
243 std::string volname = av.getName();
251 ATH_MSG_FATAL(
"The name of the output SQLite file is not set!");
252 throw GaudiException(
"The name of the output SQLite file is not set!",
253 "DumpGeo", StatusCode::FAILURE);
261 if (
db.checkIsDBOpen())
265 throw GaudiException(
266 "The GeoModel SQLite .db file could not be opened successfully.",
267 "DumpGeo", StatusCode::FAILURE);
273 GeoModelIO::WriteGeoModel dumpGeoModelGraph(
db);
276 volTop->exec(&dumpGeoModelGraph);
278 world->exec(&dumpGeoModelGraph);
282 dumpGeoModelGraph.saveToDB();
288 "Test - list of all the GeoMaterial nodes in the persistified "
290 db.printAllMaterials();
292 "Test - list of all the GeoElement nodes in the persistified "
294 db.printAllElements();
298 return StatusCode::SUCCESS;