12 #include <FairLogger.h>
15 #include <TGeoManager.h>
17 #include <TGeoVolume.h>
18 #include <TObjArray.h>
20 #include <TVirtualMC.h>
28 , fIsSimulation(kFALSE)
30 , fUseNodeName(kFALSE)
31 , fLastUsedDetectorID(0)
32 , fDetectorInfoArray()
34 , fCurrentVolume(nullptr)
35 , fVolumeShape(nullptr)
37 , fGlobalMatrix(nullptr) {}
43 TString tVirtualMCName = gMC->GetName();
45 if (tVirtualMCName ==
"TGeant3TGeo") {
47 }
else if (tVirtualMCName ==
"TGeant4") {
49 }
else if (tVirtualMCName ==
"TFluka") {
74 if (
nullptr == gGeoManager) LOG(fatal) <<
"No GeoManager";
76 TObjArray* nodes = gGeoManager->GetTopNode()->GetNodes();
77 for (Int_t iNode = 0; iNode < nodes->GetEntriesFast(); iNode++) {
78 TGeoNode* node = (TGeoNode*) nodes->At(iNode);
79 LOG(info) <<
"Inspect node " << iNode <<
" " << node->GetName();
80 if (TString(node->GetName()).Contains(
"tof")) {
85 LOG(info) <<
"Found TOF geometry " << TString(node->GetName());
86 if (TString(node->GetName()).EqualTo(
"tof1_0")) {
87 LOG(info) <<
"Found TOF geometry v07a";
91 }
else if (TString(node->GetName()).EqualTo(
"tof_v12b_0")) {
92 LOG(info) <<
"Found TOF geometry v12b.";
96 }
else if (TString(node->GetName()).Contains(
"v13")) {
98 LOG(info) <<
"Found TOF geometry " << TString(node->GetName())
99 <<
", treat as Id 12b ";
103 }
else if ((TString(node->GetName()).Contains(
"v14"))
104 || (TString(node->GetName()).Contains(
"v16a"))
105 || (TString(node->GetName()).Contains(
"v16c"))
106 || (TString(node->GetName()).Contains(
"v16d"))
107 || (TString(node->GetName()).Contains(
"v16e"))
108 || (TString(node->GetName()).Contains(
"v17a"))
109 || (TString(node->GetName()).Contains(
"v17c"))
110 || (TString(node->GetName()).Contains(
"v18"))
111 || (TString(node->GetName()).Contains(
"v19"))
112 || (TString(node->GetName()).Contains(
"v20"))) {
114 <<
"CbmTofGeoHandler::CheckGeometryVersion: Found TOF geometry "
115 << TString(node->GetName()) <<
", treat as Id 14a ";
120 if (TString(node->GetName()).Contains(
"v14a_n")) {
122 LOG(fatal) <<
"Using node names instead of volume names to extract "
124 <<
"in a MC simulation only works with GEANT3 VMC!";
132 LOG(fatal) <<
"Found an unknown TOF geometry.";
138 LOG(fatal) <<
"No TOF geometry found!";
161 smtype = Volname[5] -
'0';
167 smtype = Volname[7] -
'0';
178 smtype = Volname[7] -
'0';
189 LOG(debug1) <<
"GeoHand: ";
193 LOG(debug1) <<
" SMtype: " << smtype;
194 LOG(debug1) <<
" SModule: " << smodule;
195 LOG(debug1) <<
" Counter: " <<
counter;
196 LOG(debug1) <<
" Gap: " << gap;
197 LOG(debug1) <<
" Cell: " << cell;
203 LOG(debug1) <<
" Unique ID: " << Form(
"0x%08x", result);
221 smtype = Volname[5] -
'0';
227 smtype = Volname[7] -
'0';
238 smtype = Volname[7] -
'0';
254 LOG(debug1) <<
"GeoHand: ";
258 LOG(debug1) <<
" SMtype: " << smtype;
259 LOG(debug1) <<
" SModule: " << smodule;
260 LOG(debug1) <<
" Counter: " <<
counter;
261 LOG(debug1) <<
" Gap: " << gap;
262 LOG(debug1) <<
" Cell: " << cell;
269 LOG(debug1) <<
" Unique ID: " << Form(
"0x%08x", result);
339 Int_t uid = gGeoManager->GetUID(name);
341 LOG(info) <<
"VolId: Volume " << name <<
" not found";
349 return gMC->VolId(name);
355 Int_t len = strlen(name) - 1;
356 if (name[len] !=
' ') {
return VolIdGeo(name); }
357 strncpy(sname, name, len);
365 return gMC->CurrentVolID(copy);
370 if (gGeoManager->IsOutside()) {
return 0; }
371 TGeoNode* node = gGeoManager->GetCurrentNode();
372 copy = node->GetNumber();
373 Int_t
id = node->GetVolume()->GetNumber();
381 return gMC->CurrentVolOffID(off, copy);
387 if (off < 0 || off > gGeoManager->GetLevel()) {
return 0; }
389 TGeoNode* node = gGeoManager->GetMother(off);
390 if (!node) {
return 0; }
391 copy = node->GetNumber();
392 return node->GetVolume()->GetNumber();
399 return gMC->CurrentVolName();
404 if (gGeoManager->IsOutside())
return gGeoManager->GetTopVolume()->GetName();
405 return gGeoManager->GetCurrentVolume()->GetName();
412 return gMC->CurrentVolOffName(off);
419 if (off < 0 || off > gGeoManager->GetLevel())
return 0;
421 TGeoNode* node = gGeoManager->GetMother(off);
423 return node->GetVolume()->GetName();
432 if (gGeoManager->IsOutside())
return gGeoManager->GetTopNode()->GetName();
433 return gGeoManager->GetCurrentNode()->GetName();
442 if (off < 0 || off > gGeoManager->GetLevel())
return 0;
444 TGeoNode* node = gGeoManager->GetMother(off);
446 return node->GetName();
532 LOG(fatal) <<
"This methode is not supported in simulation mode";
534 gGeoManager->cd(volName.Data());
538 Double_t local[3] = {0., 0., 0.};
539 gGeoManager->LocalToMaster(local,
fGlobal);
540 LOG(debug2) <<
"GeoNav: Pos: " <<
fGlobal[0] <<
" , " <<
fGlobal[1] <<
" , "