CbmRoot
CbmTrdParSetGeo.cxx
Go to the documentation of this file.
1 #include "CbmTrdParSetGeo.h"
2 
3 #include "CbmTrdGeoHandler.h" // for CbmTrdGeoHandler
4 #include "CbmTrdParModGeo.h" // for CbmTrdParModGeo
5 
6 #include <FairLogger.h> // for LOG, Logger
7 
8 #include <TGenericClassInfo.h> // for TGenericClassInfo
9 #include <TGeoManager.h> // for TGeoManager, gGeoManager
10 #include <TGeoNode.h> // for TGeoNode
11 #include <TObjArray.h> // for TObjArray
12 #include <TString.h> // for operator+, TString, Form, TString::kI...
13 
14 #include <map> // for map, map<>::const_iterator, operator!=
15 #include <stdio.h> // for printf
16 #include <utility> // for pair
17 
18 //________________________________________________________________________________________
20  const char* title,
21  const char* context)
22  : CbmTrdParSet(name, title, context) {
23  LOG(debug) << "Constructor of CbmTrdParSetGeo";
24  Init();
25  LOG(debug) << "Constructor of CbmTrdParSetGeo --- finished";
26 }
27 
28 //________________________________________________________________________________________
30 
31 //________________________________________________________________________________________
33  CbmTrdGeoHandler geo;
34  TGeoNode* topNode = gGeoManager->GetTopNode();
35  TObjArray* nodes = topNode->GetNodes();
36  if (!nodes) {
37  LOG(fatal) << "CbmTrdParSetGeo::Init: nodes is null!";
38  return kFALSE;
39  }
40 
41  for (Int_t iNode = 0; iNode < nodes->GetEntriesFast(); iNode++) {
42  TGeoNode* node = static_cast<TGeoNode*>(nodes->At(iNode));
43  if (!TString(node->GetName()).Contains("trd", TString::kIgnoreCase))
44  continue; // trd_vXXy top node, e.g. trd_v13a, trd_v14b
45  TGeoNode* station = node;
46 
47  TObjArray* layers = station->GetNodes();
48  for (Int_t iLayer = 0; iLayer < layers->GetEntriesFast(); iLayer++) {
49  TGeoNode* layer = static_cast<TGeoNode*>(layers->At(iLayer));
50  if (!TString(layer->GetName()).Contains("layer", TString::kIgnoreCase))
51  continue; // only layers
52 
53  TObjArray* modules = layer->GetNodes();
54  for (Int_t iModule = 0; iModule < modules->GetEntriesFast(); iModule++) {
55  TGeoNode* module = static_cast<TGeoNode*>(modules->At(iModule));
56  TObjArray* parts = module->GetNodes();
57  for (Int_t iPart = 0; iPart < parts->GetEntriesFast(); iPart++) {
58  TGeoNode* part = static_cast<TGeoNode*>(parts->At(iPart));
59  if (!TString(part->GetName()).Contains("gas", TString::kIgnoreCase))
60  continue; // only active gas volume
61 
62  // Put together the full path to the interesting volume, which
63  // is needed to navigate with the geomanager to this volume.
64  // Extract the geometry information (size, global position)
65  // from this volume.
66  TString path = TString("/") + topNode->GetName() + "/"
67  + station->GetName() + "/" + layer->GetName() + "/"
68  + module->GetName() + "/" + part->GetName();
69 
70  LOG(debug) << "Adding detector with path " << path.Data();
71  // Generate a physical node which has all needed information
72  gGeoManager->cd(path.Data());
73  Int_t address = geo.GetModuleAddress();
74  fModuleMap[address] =
75  new CbmTrdParModGeo(Form("TRD_%d", address), path.Data());
76  }
77  }
78  }
79  }
80  return true;
81 }
82 
83 //________________________________________________________________________________________
84 void CbmTrdParSetGeo::Print(Option_t*) const {
85  std::map<Int_t, CbmTrdParMod*>::const_iterator imod = fModuleMap.begin();
86  CbmTrdParModGeo* mod(nullptr);
87  while (imod != fModuleMap.end()) {
88  mod = (CbmTrdParModGeo*) imod->second;
89  printf("Module %4d [%p]:\n", imod->first, (void*) mod);
90  printf(" %s[%s]\n", mod->GetName(), mod->GetPath());
91  Double_t xyz[3];
92  mod->GetXYZ(xyz);
93  printf(" X[%.2f] Y[%.2f] Z[%.2f] DX[%.2f] DY[%.2f] DZ[%.2f]\n",
94  xyz[0],
95  xyz[1],
96  xyz[2],
97  mod->GetDX(),
98  mod->GetDY(),
99  mod->GetDZ());
100  imod++;
101  }
102 }
103 
104 // //________________________________________________________________________________________
105 // void CbmTrdParSetGeo::putParams(FairParamList* l)
106 // {
107 // if (!l) return;
108 // TObjArray *snodes(nullptr), *pnodes(nullptr);
109 // //for()
110 // l->addObject("FairGeoNodes Sensitive List", snodes);
111 // l->addObject("FairGeoNodes Passive List", pnodes);
112 // }
113 //
114 // //________________________________________________________________________________________
115 // Bool_t CbmTrdParSetGeo::getParams(FairParamList* l)
116 // {
117 // if (!l) return kFALSE;
118 // TObjArray *snodes(nullptr), *pnodes(nullptr);
119 // if (!l->fillObject("FairGeoNodes Sensitive List", snodes)) return kFALSE;
120 // if (!l->fillObject("FairGeoNodes Passive List", pnodes)) return kFALSE;
121 //
122 // //CbmTrdParModGeo *geo(nullptr);
123 // for (Int_t i=0; i < snodes->GetEntriesFast(); i++){
124 // // fModPar[moduleId[i]] = new CbmTrdParModGeo(GetName());
125 // // fModPar
126 //
127 // ((FairGeoNode*)(*snodes)[i])->print();
128 // }
129 // return kTRUE;
130 // }
131 
CbmTrdParSet::fModuleMap
std::map< Int_t, CbmTrdParMod * > fModuleMap
Definition: CbmTrdParSet.h:43
CbmTrdGeoHandler::GetModuleAddress
Int_t GetModuleAddress()
Return module address calculated based on the current node in the TGeoManager.
Definition: CbmTrdGeoHandler.cxx:49
CbmTrdParSetGeo.h
CbmTrdParModGeo::GetDX
virtual Double_t GetDX() const
Definition: CbmTrdParModGeo.cxx:19
CbmTrdParSetGeo::Init
Bool_t Init()
Fill map with full geometrical description for each detector to be distributed to all processing modu...
Definition: CbmTrdParSetGeo.cxx:32
CbmTrdParModGeo.h
CbmTrdGeoHandler
Definition: CbmTrdGeoHandler.h:29
CbmTrdParSet
Definition: CbmTrdParSet.h:19
CbmTrdParModGeo::GetPath
const Char_t * GetPath() const
Definition: CbmTrdParModGeo.h:20
CbmTrdParModGeo
Definition of geometry for one TRD module.
Definition: CbmTrdParModGeo.h:12
CbmTrdGeoHandler.h
Helper class to extract information from the GeoManager.
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmTrdParSetGeo
Definition: CbmTrdParSetGeo.h:9
CbmTrdParModGeo::GetDY
virtual Double_t GetDY() const
Definition: CbmTrdParModGeo.cxx:24
CbmTrdParModGeo::GetDZ
virtual Double_t GetDZ() const
Definition: CbmTrdParModGeo.cxx:29
CbmTrdParSetGeo::~CbmTrdParSetGeo
virtual ~CbmTrdParSetGeo(void)
Definition: CbmTrdParSetGeo.cxx:29
CbmTrdParModGeo::GetXYZ
virtual void GetXYZ(Double_t xyz[3]) const
Definition: CbmTrdParModGeo.cxx:40
CbmTrdParSetGeo::CbmTrdParSetGeo
CbmTrdParSetGeo(const char *name="CbmTrdParSetGeo", const char *title="Trd Geometry Parameters", const char *context="TestDefaultContext")
Definition: CbmTrdParSetGeo.cxx:19
CbmTrdParSetGeo::Print
virtual void Print(Option_t *opt="") const
Definition: CbmTrdParSetGeo.cxx:84