11#include <FairRootManager.h>
12#include <FairRunAna.h>
13#include <FairRuntimeDb.h>
19#include <TGeoManager.h>
28 : FairTask(
"TofCreateDigiPar")
82 LOG(info) <<
" * CbmTofCreateDigiPar:: SetParContainers() ";
87 FairRuntimeDb* rtdb = FairRuntimeDb::instance();
91 LOG(info) <<
" * CbmTofCreateDigiPar:: fDigiPar " <<
fDigiPar;
99 LOG(info) <<
" * CbmTofCreateDigiPar * :: ReInit() ";
104 FairRuntimeDb* rtdb = FairRuntimeDb::instance();
120 LOG(info) <<
" * CbmTofCreateDigiPar * :: Init() ";
122 FairRootManager* ioman = FairRootManager::Instance();
123 if (!ioman) LOG(fatal) <<
"No FairRootManager found";
125 if (
k21a == geoVersion) {
126 LOG(info) <<
"Will now create digitization parameters for root geometry.";
129 if (
k14a == geoVersion) {
130 LOG(info) <<
"Will now create digitization parameters for root geometry.";
133 if (
k12b == geoVersion) {
134 LOG(info) <<
"Will now create digitization parameters for root geometry.";
137 if (
k07a == geoVersion) {
138 LOG(info) <<
"Will now create digitization parameters for ascii geometry.";
143 std::map<Int_t, TGeoNode*> nodemap;
147 gGeoManager->FindNode(fChannelInfo->
GetX(), fChannelInfo->
GetY(), fChannelInfo->
GetZ());
148 TGeoNode* tGeoNode = gGeoManager->GetCurrentNode();
149 nodemap.insert(std::pair<Int_t, TGeoNode*>(iAddr, tGeoNode));
150 LOG(debug2) << Form(
"Digipar for %d, addr 0x%08x: Node=%p, x %6.2f, y %6.2f, z %6.2f ", iCell, iAddr, tGeoNode,
151 fChannelInfo->
GetX(), fChannelInfo->
GetY(), fChannelInfo->
GetZ());
161 LOG(info) <<
" * CbmTofCreateDigiPar * :: FinishTask() ";
163 FairRunAna* ana = FairRunAna::Instance();
164 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
194 std::vector<CbmTofCell*> cellVector;
197 TString TopNode = gGeoManager->GetTopNode()->GetName();
198 LOG(debug2) << TopNode;
201 TObjArray* detSystems = gGeoManager->GetTopNode()->GetNodes();
202 for (Int_t iSys = 0; iSys < detSystems->GetEntriesFast(); ++iSys) {
203 TGeoNode* node = (TGeoNode*) detSystems->At(iSys);
204 LOG(debug2) << node->GetName();
209 if (TString(node->GetName()).Contains(
"tof")) {
210 TString TofNode = node->GetName();
211 LOG(info) <<
"Found keeping node " << TofNode;
212 if (TString(((node->GetNodes())->At(0))->GetName()).Contains(
"Stand")) {
213 LOG(info) <<
" Found Tof Stand " << ((node->GetNodes())->At(0))->GetName();
214 node = (TGeoNode*) (node->GetNodes())->At(0);
215 TofNode = TofNode +
"/" + node->GetName();
216 LOG(info) <<
"Modified keeping node " << TofNode;
218 TGeoNode* keep = node;
219 TObjArray* keeping = keep->GetNodes();
221 LOG(info) <<
"Building Tof Digi Par database ... ";
224 for (Int_t ikeep = 0; ikeep < keeping->GetEntriesFast(); ikeep++) {
225 TGeoNode* keepvol = (TGeoNode*) keeping->At(ikeep);
226 TString KeepNode = keepvol->GetName();
227 TObjArray* modarray = keepvol->GetNodes();
230 for (Int_t imodule = 0; imodule < modarray->GetEntriesFast(); imodule++) {
231 TGeoNode* module = (TGeoNode*) modarray->At(imodule);
232 TString ModuleNode =
module->GetName();
233 TObjArray* cellarray =
module->GetNodes();
236 for (Int_t icell = 0; icell < cellarray->GetEntriesFast(); icell++) {
237 TGeoNode* cell = (TGeoNode*) cellarray->At(icell);
238 TString CellNode = cell->GetName();
239 TObjArray* gaparray = cell->GetNodes();
243 for (Int_t igap = 0; igap < gaparray->GetEntriesFast(); igap++) {
244 TGeoNode* gap = (TGeoNode*) gaparray->At(igap);
245 TString GapNode = gap->GetName();
247 if (GapNode.Contains(
"gap")) {
253 "/" + TopNode +
"/" + TofNode +
"/" + KeepNode +
"/" + ModuleNode +
"/" + CellNode +
"/" + GapNode;
254 LOG(debug2) <<
"Path: " << FullPath;
268 cellVector.push_back(tofCell);
269 fCellMap.insert(std::pair<Int_t, std::vector<CbmTofCell*>>(
fCellID, cellVector));
314 std::vector<CbmTofCell*> cellVector;
318 TString TopNode = gGeoManager->GetTopNode()->GetName();
319 LOG(debug2) <<
"TopNode: " << TopNode;
322 TObjArray* detSystems = gGeoManager->GetTopNode()->GetNodes();
323 for (Int_t iSys = 0; iSys < detSystems->GetEntriesFast(); ++iSys) {
324 TGeoNode* node = (TGeoNode*) detSystems->At(iSys);
325 LOG(debug2) <<
"Det system: " << node->GetName();
330 if (TString(node->GetName()).Contains(
"tof")) {
331 TString TofNode = node->GetName();
332 LOG(info) <<
"Found tof keeping volume: " << TofNode;
334 if (TString(((node->GetNodes())->At(0))->GetName()).Contains(
"Stand")) {
335 LOG(info) <<
" Found Tof Stand " << ((node->GetNodes())->At(0))->GetName();
336 node = (TGeoNode*) (node->GetNodes())->At(0);
337 TofNode = TofNode +
"/" + node->GetName();
338 LOG(info) <<
"Modified tof keeping node " << TofNode;
341 TGeoNode* keep = node;
342 TObjArray* modarray = keep->GetNodes();
344 if (
nullptr == modarray) {
345 LOG(warning) <<
" No modules found in geometry ";
349 for (Int_t imodule = 0; imodule < modarray->GetEntriesFast(); imodule++) {
350 TGeoNode* module = (TGeoNode*) modarray->At(imodule);
351 TString ModuleNode =
module->GetName();
352 TObjArray* modpartarray =
module->GetNodes();
355 for (Int_t imodpart = 0; imodpart < modpartarray->GetEntriesFast(); imodpart++) {
356 TGeoNode* modpart = (TGeoNode*) modpartarray->At(imodpart);
357 TString ModPartNode = modpart->GetName();
359 if (ModPartNode.Contains(
"gas_box")) {
360 TObjArray* counterarray = modpart->GetNodes();
363 for (Int_t icounter = 0; icounter < counterarray->GetEntriesFast(); icounter++) {
364 TGeoNode*
counter = (TGeoNode*) counterarray->At(icounter);
365 TString CounterNode =
counter->GetName();
366 if (!CounterNode.Contains(
"counter"))
continue;
367 TObjArray* gaparray =
counter->GetNodes();
368 if (
nullptr == gaparray) LOG(error) <<
" no gaps for counter " << CounterNode;
370 for (Int_t igap = 0; igap < gaparray->GetEntriesFast(); igap++) {
371 TGeoNode* gap = (TGeoNode*) gaparray->At(igap);
372 TString GapNode = gap->GetName();
373 if (GapNode.Contains(
"Gap")) {
374 TObjArray* cellarray = gap->GetNodes();
377 for (Int_t icell = 0; icell < cellarray->GetEntriesFast(); icell++) {
378 TGeoNode* cell = (TGeoNode*) cellarray->At(icell);
379 TString CellNode = cell->GetName();
384 TString FullPath =
"/" + TopNode +
"/" + TofNode +
"/" + +ModuleNode +
"/" + ModPartNode +
"/"
385 + CounterNode +
"/" + GapNode +
"/" + CellNode;
386 LOG(debug2) <<
"Path: " << FullPath;
401 cellVector.push_back(tofCell);
402 fCellMap.insert(std::pair<Int_t, std::vector<CbmTofCell*>>(
fCellID, cellVector));
445 LOG(debug2) <<
"FCI: " << FullPath.Data();
446 LOG(debug2) <<
"FCI: X: " <<
fX <<
" Y: " <<
fY <<
" Z: " <<
fZ <<
" SizeX: " <<
fSizex <<
" SizeY: " <<
fSizey;
448 <<
" Gap: " <<
fGap <<
" Cell: " <<
fCell;
459 LOG(debug2) <<
"FCI: Cell ID: " << Form(
"0x%08x",
fCellID) <<
" detId " << Form(
"0x%08x",
fDetID);
481 Int_t Nrcells = (Int_t)
fCellMap.size();
482 LOG(debug) <<
"FillDigiPar:: Nr. of tof cells: " << Nrcells;
484 if (NULL ==
fDigiPar) LOG(fatal) <<
"Tof Digi Parameter container not available ";
487 TArrayI* CellId =
new TArrayI(Nrcells);
488 TArrayD* CellX =
new TArrayD(Nrcells);
489 TArrayD* CellY =
new TArrayD(Nrcells);
490 TArrayD* CellZ =
new TArrayD(Nrcells);
491 TArrayD* CellDx =
new TArrayD(Nrcells);
492 TArrayD* CellDy =
new TArrayD(Nrcells);
497 std::map<Int_t, CbmTofCell*> singleCellMap;
504 std::vector<CbmTofCell*> vcell =
fCellMapIt->second;
507 std::vector<CbmTofCell*>::iterator vcellIt;
517 for (vcellIt = vcell.begin(); vcellIt != vcell.end(); ++vcellIt) {
518 tofcell = (*vcellIt);
521 LOG(info) <<
"id, cellId: " <<
id <<
" , " << cellId <<
"\n";
522 LOG(info) <<
"id and CellId differ";
524 x += tofcell->
GetX();
525 y += tofcell->
GetY();
526 z += tofcell->
GetZ();
531 CellX->AddAt(
x / vcell.size(), iDigi);
532 CellY->AddAt(
y / vcell.size(), iDigi);
533 CellZ->AddAt(z / vcell.size(), iDigi);
534 CellDx->AddAt(sizex / vcell.size(), iDigi);
535 CellDy->AddAt(sizey / vcell.size(), iDigi);
538 singlecell =
new CbmTofCell(cellId,
x / vcell.size(),
y / vcell.size(), z / vcell.size(), sizex / vcell.size(),
539 sizey / vcell.size());
540 singleCellMap.insert(std::pair<Int_t, CbmTofCell*>(cellId, singlecell));
550 LOG(info) <<
"FillDigiPar " << iDigi <<
", cellId = " << cellId <<
", t " <<
fSMType <<
" m " <<
fSModule
551 <<
" c " <<
fCounter <<
" s " <<
fCell <<
" " <<
x / vcell.size() * 10 <<
" "
552 <<
y / vcell.size() * 10 <<
" " << z / vcell.size() * 10 <<
" " << sizex / vcell.size() * 10
553 <<
" " << sizey / vcell.size() * 10;
ClassImp(CbmConverterManager)
const constexpr Int_t fCounter(0)
Int_t GetDetectorId() const
Double_t GetSizey() const
Double_t GetSizex() const
virtual ~CbmTofCreateDigiPar()
std::map< Int_t, std::vector< CbmTofCell * > >::iterator fCellMapIt
virtual void SetParContainers()
virtual void Exec(Option_t *option)
void FillCellMapRootGeometry()
void FillCellInfoFromGeoHandler(TString FullPath)
CbmTofGeoHandler * fGeoHandler
pointer to digi parameters
void FillCellMapAsciiGeometry()
std::map< Int_t, std::vector< CbmTofCell * > > fCellMap
virtual void FinishTask()
virtual InitStatus ReInit()
virtual InitStatus Init()
CbmTofCell * GetCell(Int_t i)
void SetCellMap(std::map< Int_t, CbmTofCell * > map)
void SetCellDxArray(TArrayD array)
void SetNodeMap(std::map< Int_t, TGeoNode * > map)
void SetCellZArray(TArrayD array)
void SetCellDyArray(TArrayD array)
void SetCellYArray(TArrayD array)
void SetCellIdArray(TArrayI array)
void SetNrOfCells(Int_t i)
void SetCellXArray(TArrayD array)
Int_t GetCell(Int_t uniqueId)
Int_t Init(Bool_t isSimulation=kFALSE)
Float_t GetZ(TString volName)
Float_t GetX(TString volName)
Int_t GetSModule(Int_t uniqueId)
Int_t GetUniqueDetectorId()
Int_t GetCounter(Int_t uniqueId)
Int_t GetSMType(Int_t uniqueId)
Float_t GetSizeX(TString volName)
Float_t GetSizeY(TString volName)
Int_t GetRegion(Int_t uniqueId)
Int_t GetCellId(Int_t uniqueId)
Float_t GetY(TString volName)
Int_t GetGap(Int_t uniqueId)