11 #include "TGeoManager.h" 14 #include "FairRootManager.h" 15 #include "FairRunAna.h" 17 #include "FairRuntimeDb.h" 18 #include "FairGeoLoader.h" 19 #include "FairGeoInterface.h" 20 #include "FairGeoMedia.h" 21 #include "FairGeoBuilder.h" 22 #include "FairLogger.h" 24 Int_t ERSetup::SetParContainers(){
26 FairRun* run = FairRun::Instance();
27 if ( ! run ) Fatal(
"SetParContainers",
"No analysis run");
28 FairRuntimeDb* rtdb = run->GetRuntimeDb();
29 if ( ! rtdb ) Fatal(
"SetParContainers",
"No runtime database");
33 fSubAssemblies[subAssembly->GetName()] = subAssembly;
36 void ERSetup::AddSubAssembly(
ERGeoSubAssembly* subAssembly,
const TVector3& position,
37 const TVector3& rotation) {
38 subAssembly->SetPosition(position);
39 subAssembly->SetRotation(rotation);
40 AddSubAssembly(subAssembly);
43 void ERSetup::ConstructGeometry(
void) {
45 LOG(FATAL) <<
"[ERSetup] gGeoManager has not inited.\n";
46 TGeoVolume* top =
new TGeoVolumeAssembly(
"TOP");
47 TGeoVolume* geoVol =
new TGeoVolumeAssembly(fGeoName);
49 for (
auto subAssemblyPair : fSubAssemblies) {
50 auto* subAssembly = subAssemblyPair.second;
51 subAssembly->ConstructGeometryVolume();
52 const TVector3* translation = subAssembly->GetPosition();
53 auto* rotation =
const_cast<TGeoRotation*
>(subAssembly->GetRotation());
54 auto* volume =
const_cast<TGeoVolume*
>(subAssembly->GetVolume());
55 geoVol->AddNode(volume, ++i,
56 new TGeoCombiTrans(translation->X() ,translation->Y(), translation->Z(),
59 top->AddNode(geoVol, 1,
new TGeoCombiTrans(0., 0., 0.,
new TGeoRotation()));
60 const TString geoPath = gSystem->Getenv(
"VMCWORKDIR");
61 const TString geoFileName = geoPath +
"/geometry/" + fGeoName +
".temp.root";
62 TFile* geoFile =
new TFile(geoFileName,
"RECREATE");
67 std::list<ERGeoComponent*> ERSetup::GetAllComponents() {
68 std::list<ERGeoComponent*> components;
69 for (
auto subAssemblyPair : fSubAssemblies) {
70 auto* subAssembly = subAssemblyPair.second;
71 auto& subComponents = subAssembly->GetComponents();
72 for (
auto subComponentPair : subComponents) {
73 components.push_back(subComponentPair.second);
80 const auto components = GetAllComponents();
81 const auto componentIt = std::find_if(
82 components.begin(), components.end(), [&path](
ERGeoComponent* component) {
83 return path.Contains(component->GetVolumeName());
85 return componentIt != components.end() ? *componentIt :
nullptr;