Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:17:46

0001 #include <TGeoManager.h>
0002 #include <TGeoVolume.h>
0003 #include <TGeoElement.h>
0004 #include <TGeoMedium.h>
0005 #include <TSystem.h>
0006 #include <TGDMLWrite.h>
0007 #include <TGeoSystemOfUnits.h>
0008 #include <TGeant4SystemOfUnits.h>
0009 
0010 
0011 int TestGDML()   {
0012   TGeoManager::LockDefaultUnits(false);
0013 
0014   //TGeoManager::SetDefaultUnits(TGeoManager::kRootUnits);
0015   //double unit_of_density = (TGeoUnit::g/TGeoUnit::cm3);
0016   //double gramm_per_mole  =  (TGeoUnit::g/TGeoUnit::mole);
0017   TGeoManager::SetDefaultUnits(TGeoManager::kG4Units);
0018   //double unit_of_density = (TGeant4Unit::g/TGeant4Unit::cm3);
0019   //double gramm_per_mole  =  (TGeant4Unit::g/TGeant4Unit::mole);
0020   
0021   TGeoManager::LockDefaultUnits(true);
0022   TGeoManager* mgr = new TGeoManager();
0023   TGeoElement* e = new TGeoElement("H","Hydro",1,3.0);
0024   e->Print();
0025 
0026   TGeoBBox*     world_shape = new TGeoBBox("WorldBox",100,100,100);
0027   TGeoMaterial* world_mat   = mgr->GetMaterial("Hydrogen-1");
0028   if ( !world_mat ) world_mat = new TGeoMaterial("Hydrogen-1", e, 1.0);
0029   world_mat->Print();
0030   TGeoMedium* world_med = new TGeoMedium(world_mat->GetName(), 1, world_mat);
0031   TGeoVolume* world_vol = new TGeoVolume("World", world_shape, world_med);
0032 
0033   TGeoBBox*     inner_shape = new TGeoBBox("InnerBox", 50, 50, 50);
0034   TGeoMaterial* inner_mat   = mgr->GetMaterial("Hydrogen-2");
0035   if ( !inner_mat ) inner_mat = new TGeoMaterial("Hydrogen-2", e, 5.0);
0036   inner_mat->Print();
0037   TGeoMedium* inner_med = new TGeoMedium(inner_mat->GetName(), 1, inner_mat);
0038   TGeoVolume* inner_vol = new TGeoVolume("Inner", inner_shape, inner_med);
0039 
0040   world_vol->AddNode(inner_vol, 1);
0041   mgr->SetTopVolume(world_vol);
0042   TGDMLWrite wr;
0043   wr.WriteGDMLfile(mgr, "Test.gdml");
0044   //world_vol->Draw("ogl");
0045   gSystem->Exit(0);
0046   return 0;
0047 }