9 #include <FairLogger.h>
11 #include <TGenericClassInfo.h>
13 #include <TGeoManager.h>
15 #include <TGeoPhysicalNode.h>
16 #include <TGeoVolume.h>
17 #include <TObjArray.h>
19 #include <TVirtualMC.h>
29 , fIsSimulation(kFALSE)
31 , fCurrentVolume(nullptr)
32 , fVolumeShape(nullptr)
34 , fGlobalMatrix(nullptr)
55 LOG(debug4) << gMC->CurrentVolPath();
57 gMC->CurrentVolOffID(1, copyNr);
59 LOG(debug4) << gGeoManager->GetPath();
61 TGeoNode* node = gGeoManager->GetMother();
63 copyNr = node->GetNumber();
65 LOG(debug4) <<
"CopyNr: " << copyNr;
70 if ((copyNr / 100000000) > 0)
73 layerId = ((copyNr / 1000) % 100) - 1;
74 moduleId = (copyNr % 1000) - 1;
75 LOG(debug4) <<
"2014 ";
79 layerId = ((copyNr / 100) % 100) - 1;
80 moduleId = (copyNr % 100) - 1;
81 LOG(debug4) <<
"2013 ";
84 LOG(debug4) << copyNr / 100000000 <<
" copy " << copyNr <<
" layerID "
85 << layerId <<
" moduleId " << moduleId;
168 LOG(fatal) <<
"This method is not supported in simulation mode";
170 gGeoManager->cd(path.Data());
174 Double_t local[3] = {0., 0., 0.};
175 gGeoManager->LocalToMaster(local,
fGlobal);
178 const char* moduleName = gGeoManager->GetMother()->GetName();
180 string(1, *(moduleName + 6)).c_str());
183 TGeoNode* layernode = gGeoManager->GetMother(2);
184 Int_t layercopyNr = layernode->GetNumber();
186 fStation = ((layercopyNr / 10000) % 10);
188 fLayer = ((layercopyNr / 100) % 10);
191 TGeoNode* modulenode = gGeoManager->GetMother();
193 Int_t modulecopyNr = modulenode->GetNumber();
195 if ((modulecopyNr / 100000000) > 0)
199 ((modulecopyNr / 1000000) % 100);
200 fRotation = ((modulecopyNr / 100000) % 10);
205 fRotation = ((modulecopyNr / 10000) % 10);
225 std::map<Int_t, TGeoPhysicalNode*> moduleMap;
227 TGeoNode* topNode = gGeoManager->GetTopNode();
228 TObjArray* nodes = topNode->GetNodes();
229 for (Int_t iNode = 0; iNode < nodes->GetEntriesFast(); iNode++) {
230 TGeoNode* node =
static_cast<TGeoNode*
>(nodes->At(iNode));
231 if (!TString(node->GetName()).Contains(
"trd", TString::kIgnoreCase))
233 TGeoNode* station = node;
235 TObjArray* layers = station->GetNodes();
236 for (Int_t iLayer = 0; iLayer < layers->GetEntriesFast(); iLayer++) {
237 TGeoNode* layer =
static_cast<TGeoNode*
>(layers->At(iLayer));
238 if (!TString(layer->GetName()).Contains(
"layer", TString::kIgnoreCase))
241 TObjArray* modules = layer->GetNodes();
242 for (Int_t iModule = 0; iModule < modules->GetEntriesFast(); iModule++) {
243 TGeoNode* module =
static_cast<TGeoNode*
>(modules->At(iModule));
244 TObjArray* parts = module->GetNodes();
245 for (Int_t iPart = 0; iPart < parts->GetEntriesFast(); iPart++) {
246 TGeoNode* part =
static_cast<TGeoNode*
>(parts->At(iPart));
247 if (!TString(part->GetName()).Contains(
"gas", TString::kIgnoreCase))
254 TString path = TString(
"/") + topNode->GetName() +
"/"
255 + station->GetName() +
"/" + layer->GetName() +
"/"
256 + module->GetName() +
"/" + part->GetName();
258 LOG(debug) <<
"Adding detector with path " << path;
260 TGeoPhysicalNode* pNode =
new TGeoPhysicalNode(path.Data());
262 moduleMap[address] = pNode;