2 #include <TGeoManager.h>
4 #include <TGDMLWrite.h>
11 TFile *
file =
new TFile(
"detector_geometry.root",
"READ");
12 gGeoManager = (TGeoManager*) file->Get(
"default");
17 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,22,00)
18 gGeoManager->LockDefaultUnits(
false);
19 gGeoManager->SetDefaultUnits(TGeoManager::kRootUnits);
22 TGDMLWrite *writer =
new TGDMLWrite;
23 writer->SetG4Compatibility(
true);
24 writer->WriteGDMLfile ( gGeoManager,
"athena_all.gdml",
"vg");
26 vector<string> outnames;
28 TGeoNodeMatrix*
m = (TGeoNodeMatrix*) gGeoManager->GetListOfNodes()->At(0);
29 for (
int i = 0; i<m->GetNdaughters() ; ++i ){
30 TGeoNode*
n = (TGeoNode*) m->GetNodes()->At(i);
31 string outname = outbase+n->GetName()+
".gdml";
32 if ( subsys !=
"all" && n->GetName()!=subsys )
continue;
33 writer->WriteGDMLfile ( gGeoManager, n, outname.c_str(),
"vg");
34 outnames.push_back(outname);
38 for (
auto fname : outnames ){
39 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,22,00)
40 gGeoManager->LockDefaultUnits(
false);
41 gGeoManager->SetDefaultUnits(TGeoManager::kRootUnits);
43 gGeoManager->Import(fname.c_str());
45 TGeoMedium *Air = gGeoManager->GetMedium(
"Air");
47 TGeoElementTable *table = gGeoManager->GetElementTable();
48 TGeoMixture *air =
new TGeoMixture(
"air",4, 0.00120479);
49 air->AddElement(table->GetElement(6),0.00012);
50 air->AddElement(table->GetElement(7),0.754);
51 air->AddElement(table->GetElement(8),0.234);
52 air->AddElement(table->GetElement(18),0.012827);
53 Air =
new TGeoMedium(
"Air",0, air);
56 TGeoVolume *top = gGeoManager->MakeBox(
"world_volume", Air, 3000., 3000., 10000.);
57 top->AddNode( gGeoManager->GetTopVolume(), 1 );
58 gGeoManager->SetTopVolume(top);
59 gGeoManager->Export(fname.c_str(),
"vg");