18 #include <TGeoManager.h>
20 #include <TGeoVolume.h>
21 #include <TVirtualMC.h>
27 , fIsSimulation(kFALSE)
28 , fLastUsedDetectorID(0)
30 , fCurrentVolume(nullptr)
31 , fVolumeShape(nullptr)
33 , fGlobalMatrix(nullptr)
40 fIsSimulation = isSimulation;
47 TString path = ConstructFullPathFromDetID(detID);
49 gGeoManager->LocalToMaster(local, global);
52 TString FairTutorialDet4GeoHandler::ConstructFullPathFromDetID(Int_t detID)
54 TString volStr =
"/cave_1/tutorial4_0/tut4_det_";
55 TString volPath = volStr;
62 if (fGeoPathHash != volName.Hash()) {
84 Int_t uid = gGeoManager->GetUID(name);
86 printf(
"VolId: Volume %s not found\n", name);
95 return TVirtualMC::GetMC()->VolId(name);
100 std::string volname(name);
101 while (!volname.empty() && volname.back() ==
' ') {
111 return TVirtualMC::GetMC()->CurrentVolID(copy);
116 if (gGeoManager->IsOutside()) {
119 TGeoNode* node = gGeoManager->GetCurrentNode();
120 copy = node->GetNumber();
121 Int_t
id = node->GetVolume()->GetNumber();
129 return TVirtualMC::GetMC()->CurrentVolOffID(off, copy);
135 if (off < 0 || off > gGeoManager->GetLevel()) {
141 TGeoNode* node = gGeoManager->GetMother(off);
145 copy = node->GetNumber();
146 return node->GetVolume()->GetNumber();
153 return TVirtualMC::GetMC()->CurrentVolName();
158 if (gGeoManager->IsOutside()) {
159 return gGeoManager->GetTopVolume()->GetName();
161 return gGeoManager->GetCurrentVolume()->GetName();
168 return TVirtualMC::GetMC()->CurrentVolOffName(off);
175 if (off < 0 || off > gGeoManager->GetLevel()) {
181 TGeoNode* node = gGeoManager->GetMother(off);
185 return node->GetVolume()->GetName();
192 LOG(fatal) <<
"This methode is not supported in simulation mode";
194 gGeoManager->cd(volName.Data());
195 fGeoPathHash = volName.Hash();
196 fCurrentVolume = gGeoManager->GetCurrentVolume();
197 fVolumeShape =
static_cast<TGeoBBox*
>(fCurrentVolume->GetShape());
198 Double_t local[3] = {0., 0., 0.};
199 gGeoManager->LocalToMaster(local, fGlobal);
200 LOG(debug2) <<
"Pos: " << fGlobal[0] <<
" , " << fGlobal[1] <<
" , " << fGlobal[2];
Int_t CurrentVolID(Int_t ©) const
FairTutorialDet4GeoHandler()
Int_t GetUniqueDetectorId()
ClassImp(FairEventBuilder)
Int_t VolIdGeo(const char *name) const
const char * CurrentVolOffName(Int_t off) const
Int_t VolId(const Text_t *name) const
void NavigateTo(TString volName)
const char * CurrentVolName() const
Int_t Init(Bool_t isSimulation=kFALSE)
void LocalToGlobal(Double_t *local, Double_t *global, Int_t detID)
Int_t CurrentVolOffID(Int_t off, Int_t ©) const