CbmRoot
Loading...
Searching...
No Matches
CbmTrdParSetGeo.cxx
Go to the documentation of this file.
1/* Copyright (C) 2018-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Alexandru Bercuci, Florian Uhlig [committer] */
4
5#include "CbmTrdParSetGeo.h"
6
7#include "CbmGeoHelper.h"
8#include "CbmTrdGeoHandler.h" // for CbmTrdGeoHandler
9#include "CbmTrdParModGeo.h" // for CbmTrdParModGeo
10
11#include <Logger.h> // for LOG, Logger
12
13#include <TGenericClassInfo.h> // for TGenericClassInfo
14#include <TGeoManager.h> // for TGeoManager, gGeoManager
15#include <TGeoNode.h> // for TGeoNode
16#include <TObjArray.h> // for TObjArray
17#include <TString.h> // for operator+, TString, Form, TString::kI...
18
19#include <cstdio> // for printf
20#include <map> // for map, map<>::const_iterator, operator!=
21#include <utility> // for pair
22
23//________________________________________________________________________________________
24CbmTrdParSetGeo::CbmTrdParSetGeo(const char* name, const char* title, const char* context)
25 : CbmTrdParSet(name, title, context)
26{
27 LOG(debug) << "Constructor of CbmTrdParSetGeo";
28 Init();
29 LOG(debug) << "Constructor of CbmTrdParSetGeo --- finished";
30}
31
32//________________________________________________________________________________________
34
35//________________________________________________________________________________________
37{
39 TGeoNode* topNode = gGeoManager->GetTopNode();
40 TObjArray* nodes = topNode->GetNodes();
41 if (!nodes) {
42 LOG(fatal) << "CbmTrdParSetGeo::Init: nodes is null!";
43 return false;
44 }
45 CbmTrdParModGeo* pGeo(nullptr);
46
47 auto vGasPaths = cbm::GeoHelper::CollectNodes("trd", std::regex{"gas"}, "", gGeoManager->GetTopNode());
48 for (const auto& path : vGasPaths) {
49 gGeoManager->cd(path.Data());
50 Int_t address = geo.GetModuleAddress();
51 pGeo = new CbmTrdParModGeo(Form("TRD_%d", address), path.Data());
52 pGeo->SetModuleId(address);
53 addParam(pGeo);
54 }
55 return true;
56}
57
58//________________________________________________________________________________________
60{
61 if (!GetNrOfModules()) {
62 LOG(error) << "CbmTrdParSetGeo::LoadAlignVolumes: No modules initialized. Nothing to do.";
63 return false;
64 }
65
66 for (auto mod : fModuleMap)
67 if (!((CbmTrdParModGeo*) mod.second)->SetNode()) return false;
68
69 return true;
70}
71
72//________________________________________________________________________________________
73void CbmTrdParSetGeo::Print(Option_t*) const
74{
75 std::map<Int_t, CbmTrdParMod*>::const_iterator imod = fModuleMap.begin();
76 CbmTrdParModGeo* mod(nullptr);
77 while (imod != fModuleMap.end()) {
78 mod = (CbmTrdParModGeo*) imod->second;
79 printf("Module %4d [%p]:\n", imod->first, (void*) mod);
80 printf(" %s[%s]\n", mod->GetName(), mod->GetPath());
81 Double_t xyz[3];
82 mod->GetXYZ(xyz);
83 printf(" X[%.2f] Y[%.2f] Z[%.2f] DX[%.2f] DY[%.2f] DZ[%.2f]\n", xyz[0], xyz[1], xyz[2], mod->GetDX(), mod->GetDY(),
84 mod->GetDZ());
85 imod++;
86 }
87}
88
89// //________________________________________________________________________________________
90// void CbmTrdParSetGeo::putParams(FairParamList* l)
91// {
92// if (!l) return;
93// TObjArray *snodes(nullptr), *pnodes(nullptr);
94// //for()
95// l->addObject("FairGeoNodes Sensitive List", snodes);
96// l->addObject("FairGeoNodes Passive List", pnodes);
97// }
98//
99// //________________________________________________________________________________________
100// Bool_t CbmTrdParSetGeo::getParams(FairParamList* l)
101// {
102// if (!l) return kFALSE;
103// TObjArray *snodes(nullptr), *pnodes(nullptr);
104// if (!l->fillObject("FairGeoNodes Sensitive List", snodes)) return kFALSE;
105// if (!l->fillObject("FairGeoNodes Passive List", pnodes)) return kFALSE;
106//
107// //CbmTrdParModGeo *geo(nullptr);
108// for (Int_t i=0; i < snodes->GetEntriesFast(); i++){
109// // fModPar[moduleId[i]] = new CbmTrdParModGeo(GetName());
110// // fModPar
111//
112// ((FairGeoNode*)(*snodes)[i])->print();
113// }
114// return kTRUE;
115// }
116
ClassImp(CbmConverterManager)
A multi-purpose class to access the geometrical information stored in a TGeoManager (source)
Helper class to extract information from the GeoManager.
int Int_t
Int_t GetModuleAddress()
Return module address calculated based on the current node in the TGeoManager.
Definition of geometry for one TRD module.
virtual void SetModuleId(int m)
bool LoadAlignVolumes()
Trigger loading alignment information for all nodes registered.
virtual void Print(Option_t *opt="") const
CbmTrdParSetGeo(const char *name="CbmTrdParSetGeo", const char *title="Trd Geometry Parameters", const char *context="TestDefaultContext")
virtual ~CbmTrdParSetGeo(void)
std::map< Int_t, CbmTrdParMod * > fModuleMap
CbmTrdParSet(const char *name="CbmTrdParSet", const char *title="TRD parameters", const char *context="Default")
virtual Int_t GetNrOfModules() const
virtual void addParam(CbmTrdParMod *mod)
static std::vector< TString > CollectNodes(const TString &detector, const std::regex &component, const TString &path, TGeoNode *pNode)
Collects paths of the components.