84 TFile* oldFile = gFile;
85 TDirectory* oldDir = gDirectory;
87 TFile* geoFile = new TFile(fgeoName);
90 TIter keyIter(geoFile->GetListOfKeys());
91 Bool_t foundVolume = kFALSE;
92 Bool_t foundMatrix = kFALSE;
93 std::string volumeName = "";
94 TGeoMatrix* transformation = nullptr;
96 while ( (key = (TKey*)keyIter() ) ) {
98 if ( key->ReadObj()->InheritsFrom("TGeoVolume") ) {
100 LOG(fatal) << GetName() << ": More than one TGeoVolume in file! "
101 << volumeName << " " << key->GetName();
103 } //? already found a volume
104 volumeName = key->GetName();
107 } //? key inherits from TGeoVolume
109 if ( key->ReadObj()->InheritsFrom("TGeoMatrix") ) {
111 LOG(fatal) << GetName() << ": More than one TGeoMatrix in file! ";
113 } //? already found a matrix
114 transformation = dynamic_cast<TGeoMatrix*>(key->ReadObj());
117 } //? key inherits from TGeoMatrix
121 if ( ! foundVolume ) LOG(fatal) << GetName() << ": No TGeoVolume in file " << fgeoName;
122 if ( ! foundMatrix ) LOG(fatal) << GetName() << ": No TGeoMatrix in file " << fgeoName;
124 // --- Import PSD volume
125 TGeoVolume* psdVolume = TGeoVolume::Import(fgeoName, volumeName.c_str());
127 // Add PSD to the geometry
128 gGeoManager->GetTopVolume()->AddNode(psdVolume, 0, transformation);
129 if (air::Logger::Logging(fair::Severity::debug)) {
131 transformation->Print();
134 // Register all sensitive volumes
135 for (Int_t i=0; i<psdVolume->GetNdaughters(); ++i)
136 RegisterSensitiveVolumes(psdVolume->GetNode(i));
137// RegisterSensitiveVolumes(psdVolume->GetNode(0));
139 LOG(debug) << GetName() << ": " << fNbOfSensitiveVol
140 << " sensitive volumes";
149 LOG(info) <<
"Importing PSD geometry from ROOT file " << fgeoName.Data();
223 TObjArray* daughters = node->GetVolume()->GetNodes();
224 for (Int_t iDaughter = 0; iDaughter < daughters->GetEntriesFast(); iDaughter++) {
225 TGeoNode* daughter =
dynamic_cast<TGeoNode*
>(daughters->At(iDaughter));
228 TGeoVolume* daughterVolume = daughter->GetVolume();
229 if (
CheckIfSensitive(daughterVolume->GetName())) { AddSensitiveVolume(daughterVolume); }