5 #include "TGeoManager.h" 7 #include "FairLogger.h" 10 TGeoNode* ERNDSetup::fNDnode = NULL;
12 ERNDSetup::ERNDSetup(){
14 if ( ! gGeoManager ) {
15 std::cerr <<
"ERNDSetup: cannot initialise without TGeoManager!"<< std::endl;
18 TGeoNode* cave = gGeoManager->GetCurrentNode();
20 for (Int_t iNode = 0; iNode < cave->GetNdaughters(); iNode++) {
21 TString name = cave->GetDaughter(iNode)->GetName();
22 if ( name.Contains(
"ND", TString::kIgnoreCase) ) {
23 fNDnode = cave->GetDaughter(iNode);
29 if (fInstance == NULL)
35 void ERNDSetup::ReadGeoParamsFromParContainer() {
39 LOG(FATAL) <<
"ERNDSetup: cannot initialise without TGeoManager!"<< FairLogger::endl;
41 TGeoNode* cave = gGeoManager->GetCurrentNode();
42 for (Int_t iNode = 0; iNode < cave->GetNdaughters(); iNode++) {
43 TString detectorName = cave->GetDaughter(iNode)->GetName();
44 if (!detectorName.Contains(
"ND", TString::kIgnoreCase))
46 const auto* nd = cave->GetDaughter(iNode);
47 if (nd->GetNdaughters() != 1)
48 LOG(FATAL) <<
"Wrong ND geometry structure" << FairLogger::endl;
49 const auto* airBox = nd->GetDaughter(0);
50 for (Int_t iStilben = 0; iStilben < airBox->GetNdaughters(); iStilben++) {
51 const auto* node = airBox->GetDaughter(iStilben);
52 const auto* translation = node->GetMatrix()->GetTranslation();
53 fChannel2Node[node->GetNumber()] = node;
59 void ERNDSetup::PMTPos(TVector3 pos, TVector3& pmtPos){
61 TGeoNode* stilben = gGeoManager->FindNode(pos.X(), pos.Y(), pos.Z());
63 TGeoMatrix* stilbenMatrix = stilben->GetMatrix();
64 pmtPos.SetXYZ(stilbenMatrix->GetTranslation()[0],
65 stilbenMatrix->GetTranslation()[1],
66 stilbenMatrix->GetTranslation()[2]);
69 TVector3 ERNDSetup::Pos(Int_t channel) {
70 if (fChannel2Node.find(channel) == fChannel2Node.end()) {
71 LOG(FATAL) <<
"ERNDSetup: Node for channel " << channel <<
" not found in geometry." 74 const auto* translation = fChannel2Node[channel]->GetMatrix()->GetTranslation();
75 return TVector3(translation[0], translation[1], translation[2]);