CbmRoot
CbmLitDetectorSetup.cxx
Go to the documentation of this file.
1 
6 #include "CbmLitDetectorSetup.h"
7 
8 #include "TGeoManager.h"
9 #include "TGeoNode.h"
10 #include "TObjArray.h"
11 //#include "CbmSetup.h"
12 
13 #include <cassert>
14 #include <iostream>
15 
16 using std::cout;
17 
19  : fIsElectronSetup(false), fIsMuonSetup(false), fDet() {}
20 
22 
23 void CbmLitDetectorSetup::SetDet(ECbmModuleId detId, bool isDet) {
24  fDet[detId] = isDet;
25 }
26 
28  assert(fDet.count(detId) != 0);
29  return fDet.find(detId)->second;
30 }
31 
32 bool CbmLitDetectorSetup::CheckDetectorPresence(const std::string& name) const {
33  assert(gGeoManager != NULL);
34 
35  TObjArray* nodes = gGeoManager->GetTopNode()->GetNodes();
36  for (Int_t iNode = 0; iNode < nodes->GetEntriesFast(); iNode++) {
37  TGeoNode* node = (TGeoNode*) nodes->At(iNode);
38  if (TString(node->GetName()).Contains(name.c_str())) { return true; }
39  }
40 
41  if (name == "mvd") {
42  TGeoNode* node1 = gGeoManager->GetTopVolume()->FindNode("pipevac1_0");
43  if (node1) {
44  if (node1->GetVolume()->FindNode("mvdstation01_0")) { return true; }
45  } else {
46  TObjArray* nodes = gGeoManager->GetTopNode()->GetNodes();
47  for (Int_t iNode = 0; iNode < nodes->GetEntriesFast(); iNode++) {
48  TGeoNode* node = (TGeoNode*) nodes->At(iNode);
49  TString nodeName = node->GetName();
50  nodeName.ToLower();
51  if (nodeName.Contains("pipe")) {
52  TObjArray* nodes2 = node->GetNodes();
53  for (Int_t iiNode = 0; iiNode < nodes2->GetEntriesFast(); iiNode++) {
54  TGeoNode* node2 = (TGeoNode*) nodes2->At(iiNode);
55  TString nodeName2 = node2->GetName();
56  nodeName2.ToLower();
57  if (nodeName2.Contains("pipevac1")) {
58  // check if there is a mvd in the pipevac
59  // if there are no nodes return immediately
60  TObjArray* nodes3 = node2->GetNodes();
61  if (!nodes3) return false;
62  for (Int_t iiiNode = 0; iiiNode < nodes3->GetEntriesFast();
63  iiiNode++) {
64  TGeoNode* node3 = (TGeoNode*) nodes3->At(iiiNode);
65  TString nodeName3 = node3->GetName();
66  nodeName3.ToLower();
67  if (nodeName3.Contains("mvd")) { return true; }
68  }
69  }
70  }
71  }
72  }
73  }
74  }
75 
76  return false;
77 }
78 
89  /*fIsElectronSetup = !CbmSetup::Instance()->IsActive(kMuch);
90  fIsMuonSetup = CbmSetup::Instance()->IsActive(kMuch);
91  fDet[ECbmModuleId::kMvd] = CbmSetup::Instance()->IsActive(kMvd);
92  fDet[ECbmModuleId::kSts] = CbmSetup::Instance()->IsActive(kSts);
93  fDet[ECbmModuleId::kRich] = CbmSetup::Instance()->IsActive(kRich);
94  fDet[ECbmModuleId::kTrd] = CbmSetup::Instance()->IsActive(kTrd);
95  fDet[ECbmModuleId::kMuch] = CbmSetup::Instance()->IsActive(kMuch);
96  fDet[ECbmModuleId::kTof] = CbmSetup::Instance()->IsActive(kTof);*/
97 }
98 
100  string str = "LitDetectorSetup: ";
101  if (fIsMuonSetup) str += "Muon setup; ";
102  if (fIsElectronSetup) str += "Electron setup; ";
103  str += "detectors in geometry: ";
104  if (fDet.find(ECbmModuleId::kMvd)->second) str += "MVD ";
105  if (fDet.find(ECbmModuleId::kSts)->second) str += "STS ";
106  if (fDet.find(ECbmModuleId::kRich)->second) str += "RICH ";
107  if (fDet.find(ECbmModuleId::kMuch)->second) str += "MUCH ";
108  if (fDet.find(ECbmModuleId::kTrd)->second) str += "TRD ";
109  if (fDet.find(ECbmModuleId::kTof)->second) str += "TOF ";
110  return str;
111 }
CbmLitDetectorSetup::CheckDetectorPresence
bool CheckDetectorPresence(const std::string &name) const
Check detector presence using TGeoManager.
Definition: CbmLitDetectorSetup.cxx:32
ECbmModuleId::kMvd
@ kMvd
Micro-Vertex Detector.
ECbmModuleId
ECbmModuleId
Definition: CbmDefs.h:33
ECbmModuleId::kTof
@ kTof
Time-of-flight Detector.
CbmLitDetectorSetup::fIsMuonSetup
bool fIsMuonSetup
Definition: CbmLitDetectorSetup.h:94
CbmLitDetectorSetup::fIsElectronSetup
bool fIsElectronSetup
Definition: CbmLitDetectorSetup.h:93
CbmLitDetectorSetup::GetDet
bool GetDet(ECbmModuleId detId) const
Return detector presence in setup.
Definition: CbmLitDetectorSetup.cxx:27
ECbmModuleId::kRich
@ kRich
Ring-Imaging Cherenkov Detector.
CbmLitDetectorSetup::CbmLitDetectorSetup
CbmLitDetectorSetup()
Constructor.
Definition: CbmLitDetectorSetup.cxx:18
ECbmModuleId::kTrd
@ kTrd
Transition Radiation Detector.
CbmLitDetectorSetup::fDet
map< ECbmModuleId, bool > fDet
Definition: CbmLitDetectorSetup.h:95
ECbmModuleId::kMuch
@ kMuch
Muon detection system.
CbmLitDetectorSetup::ToString
string ToString() const
Return string representation of class.
Definition: CbmLitDetectorSetup.cxx:99
ECbmModuleId::kSts
@ kSts
Silicon Tracking System.
CbmLitDetectorSetup::SetDet
void SetDet(ECbmModuleId detId, bool isDet)
Set detector presence manually.
Definition: CbmLitDetectorSetup.cxx:23
CbmLitDetectorSetup.h
Helper class to access detector presence.
CbmLitDetectorSetup::~CbmLitDetectorSetup
virtual ~CbmLitDetectorSetup()
Destructor.
Definition: CbmLitDetectorSetup.cxx:21
CbmLitDetectorSetup::DetermineSetup
void DetermineSetup()
Determines detector presence using TGeoManager.
Definition: CbmLitDetectorSetup.cxx:79