20#include <TGeoManager.h>
22#include <TGeoVolume.h>
25#include <TVirtualMC.h>
33 , fIsSimulation(kFALSE)
35 , fUseNodeName(kFALSE)
36 , fLastUsedDetectorID(0)
37 , fDetectorInfoArray()
39 , fCurrentVolume(nullptr)
40 , fVolumeShape(nullptr)
42 , fGlobalMatrix(nullptr)
51 TString tVirtualMCName = gMC->GetName();
53 if (tVirtualMCName ==
"TGeant3TGeo") {
56 else if (tVirtualMCName ==
"TGeant4") {
59 else if (tVirtualMCName ==
"TFluka") {
89 if (
nullptr == gGeoManager) LOG(fatal) <<
"No GeoManager";
91 TObjArray* nodes = gGeoManager->GetTopNode()->GetNodes();
92 for (Int_t iNode = 0; iNode < nodes->GetEntriesFast(); iNode++) {
93 TGeoNode* node = (TGeoNode*) nodes->At(iNode);
94 LOG(info) <<
"Inspect node " << iNode <<
" " << node->GetName();
95 if (TString(node->GetName()).Contains(
"tof")) {
100 LOG(info) <<
"Found TOF geometry " << TString(node->GetName());
101 if (TString(node->GetName()).EqualTo(
"tof1_0")) {
102 LOG(info) <<
"Found TOF geometry v07a";
107 else if (TString(node->GetName()).EqualTo(
"tof_v12b_0")) {
108 LOG(info) <<
"Found TOF geometry v12b.";
113 else if (TString(node->GetName()).Contains(
"v13")) {
115 LOG(info) <<
"Found TOF geometry " << TString(node->GetName()) <<
", treat as Id 12b ";
120 else if ((TString(node->GetName()).Contains(
"v14")) || (TString(node->GetName()).Contains(
"v16a"))
121 || (TString(node->GetName()).Contains(
"v16c")) || (TString(node->GetName()).Contains(
"v16d"))
122 || (TString(node->GetName()).Contains(
"v16e")) || (TString(node->GetName()).Contains(
"v17a"))
123 || (TString(node->GetName()).Contains(
"v17c")) || (TString(node->GetName()).Contains(
"v19"))) {
124 LOG(info) <<
"CbmTofGeoHandler::CheckGeometryVersion: Found TOF geometry " << TString(node->GetName())
125 <<
", treat as Id 14a ";
130 if (TString(node->GetName()).Contains(
"v14a_n")) {
132 LOG(fatal) <<
"Using node names instead of volume names to extract "
134 <<
"in a MC simulation only works with GEANT3 VMC!";
141 else if ((TString(node->GetName()).Contains(
"v21")) || (TString(node->GetName()).Contains(
"v18"))
142 || (TString(node->GetName()).Contains(
"v20")) || (TString(node->GetName()).Contains(
"v22"))
143 || (TString(node->GetName()).Contains(
"v24"))) {
144 LOG(info) <<
"CbmTofGeoHandler::CheckGeometryVersion: Found TOF geometry " << TString(node->GetName())
145 <<
", treat as Id 21a ";
152 LOG(fatal) <<
"Found an unknown TOF geometry.";
158 LOG(fatal) <<
"No TOF geometry found!";
178 Int_t countertype = 0;
186 smtype = Volname[5] -
'0';
193 smtype = Volname[7] -
'0';
206 smtype = Volname[7] -
'0';
224 TString csmtype = Volname(7, Volname.Length());
225 smtype = csmtype.Atoi();
236 LOG(debug1) <<
"GetUniqueDetectorId: ";
241 TString cType = cTemp(8, 2);
242 countertype = cType.Atoi();
245 LOG(debug1) <<
" SMtype: " << smtype <<
" SModule: " << smodule <<
" CounterType: " << countertype
246 <<
" Counter: " <<
counter <<
" Gap: " << gap <<
" Cell: " << cell;
249 LOG(debug1) <<
" SMtype: " << smtype <<
" SModule: " << smodule <<
" Counter: " <<
counter <<
" Gap: " << gap
250 <<
" Cell: " << cell;
256 LOG(debug1) <<
" Unique ID: " << Form(
"0x%08x", result);
267 Int_t countertype = 0;
276 smtype = Volname[5] -
'0';
283 smtype = Volname[7] -
'0';
297 TString csmtype = Volname(7, Volname.Length());
298 smtype = csmtype.Atoi();
313 smtype = Volname[7] -
'0';
316 TString cType = cTemp(8, 2);
317 countertype = cType.Atoi();
329 LOG(debug1) <<
"GetUniqueCounterId: ";
333 LOG(debug1) <<
" SMtype: " << smtype <<
" SModule: " << smodule <<
" CounterType: " << countertype
334 <<
" Counter: " <<
counter <<
" Gap: " << gap <<
" Cell: " << cell;
337 LOG(debug1) <<
" SMtype: " << smtype <<
" SModule: " << smodule <<
" Counter: " <<
counter <<
" Gap: " << gap
338 <<
" Cell: " << cell;
345 LOG(debug1) <<
" Unique ID: " << Form(
"0x%08x", result);
416 Int_t uid = gGeoManager->GetUID(name);
418 LOG(info) <<
"VolId: Volume " << name <<
" not found";
427 return gMC->VolId(name);
433 Int_t len = strlen(name) - 1;
434 if (name[len] !=
' ') {
438 memcpy(sname, name, len);
447 return gMC->CurrentVolID(copy);
453 if (gGeoManager->IsOutside()) {
456 TGeoNode* node = gGeoManager->GetCurrentNode();
457 copy = node->GetNumber();
458 Int_t
id = node->GetVolume()->GetNumber();
467 return gMC->CurrentVolOffID(off, copy);
474 if (off < 0 || off > gGeoManager->GetLevel()) {
480 TGeoNode* node = gGeoManager->GetMother(off);
484 copy = node->GetNumber();
485 return node->GetVolume()->GetNumber();
493 return gMC->CurrentVolName();
499 if (gGeoManager->IsOutside())
return gGeoManager->GetTopVolume()->GetName();
500 return gGeoManager->GetCurrentVolume()->GetName();
508 return gMC->CurrentVolOffName(off);
516 if (off < 0 || off > gGeoManager->GetLevel())
return 0;
518 TGeoNode* node = gGeoManager->GetMother(off);
520 return node->GetVolume()->GetName();
530 if (gGeoManager->IsOutside())
return gGeoManager->GetTopNode()->GetName();
531 return gGeoManager->GetCurrentNode()->GetName();
541 if (off < 0 || off > gGeoManager->GetLevel())
return 0;
543 TGeoNode* node = gGeoManager->GetMother(off);
545 return node->GetName();
668 LOG(fatal) <<
"This methode is not supported in simulation mode";
671 gGeoManager->cd(volName.Data());
675 Double_t local[3] = {0., 0., 0.};
676 gGeoManager->LocalToMaster(local,
fGlobal);
ClassImp(CbmConverterManager)
@ kTof
Time-of-flight Detector.
virtual int32_t GetCellId(const int32_t detectorId)=0
virtual int32_t SetDetectorInfo(const CbmTofDetectorInfo detectorInfo)=0
virtual CbmTofDetectorInfo GetDetectorInfo(const int32_t detectorId)=0
Int_t VolIdGeo(const char *name) const
Int_t GetCell(Int_t uniqueId)
Int_t Init(Bool_t isSimulation=kFALSE)
void NavigateTo(TString volName)
Float_t GetZ(TString volName)
Float_t GetX(TString volName)
Int_t GetSModule(Int_t uniqueId)
Int_t GetUniqueDetectorId()
const char * CurrentVolOffName(Int_t off) const
Int_t VolId(const Text_t *name) const
Int_t CheckGeometryVersion()
Int_t GetCounter(Int_t uniqueId)
Int_t CurrentVolOffID(Int_t off, Int_t ©) const
Int_t GetSMType(Int_t uniqueId)
Float_t GetSizeX(TString volName)
void FillDetectorInfoArray(Int_t uniqueId)
const char * CurrentVolName() const
Float_t GetSizeY(TString volName)
Int_t GetRegion(Int_t uniqueId)
Float_t GetSizeZ(TString volName)
CbmTofDetectorId * fTofId
const char * CurrentNodeOffName(Int_t off) const
CbmTofDetectorInfo fDetectorInfoArray
Int_t GetUniqueCounterId()
const char * CurrentNodeName() const
Int_t CurrentVolID(Int_t ©) const
TGeoVolume * fCurrentVolume
Int_t GetDetSystemId(Int_t uniqueId)
Int_t GetCellId(Int_t uniqueId)
Float_t GetY(TString volName)
Int_t fLastUsedDetectorID
Int_t GetGap(Int_t uniqueId)