7 #include <FairLogger.h>
8 #include <FairRootManager.h>
9 #include <FairRunAna.h>
10 #include <FairRuntimeDb.h>
15 #include <TGeoManager.h>
17 #include <TObjArray.h>
24 : FairTask(
"TofCreateDigiPar")
74 LOG(info) <<
" * CbmTofCreateDigiPar:: SetParContainers() ";
77 FairRunAna* ana = FairRunAna::Instance();
78 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
82 LOG(info) <<
" * CbmTofCreateDigiPar:: fDigiPar " <<
fDigiPar;
89 LOG(info) <<
" * CbmTofCreateDigiPar * :: ReInit() ";
92 FairRunAna* ana = FairRunAna::Instance();
93 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
108 LOG(info) <<
" * CbmTofCreateDigiPar * :: Init() ";
110 FairRootManager* ioman = FairRootManager::Instance();
111 if (!ioman) LOG(fatal) <<
"No FairRootManager found";
114 if (
k14a == geoVersion) {
115 LOG(info) <<
"Will now create digitization parameters for root geometry.";
118 if (
k12b == geoVersion) {
119 LOG(info) <<
"Will now create digitization parameters for root geometry.";
122 if (
k07a == geoVersion) {
123 LOG(info) <<
"Will now create digitization parameters for ascii geometry.";
128 std::map<Int_t, TGeoNode*> nodemap;
132 gGeoManager->FindNode(
134 TGeoNode* tGeoNode = gGeoManager->GetCurrentNode();
135 nodemap.insert(std::pair<Int_t, TGeoNode*>(iAddr, tGeoNode));
137 "Digipar for %d, addr 0x%08x: Node=%p", iCell, iAddr, tGeoNode);
146 LOG(info) <<
" * CbmTofCreateDigiPar * :: FinishTask() ";
148 FairRunAna* ana = FairRunAna::Instance();
149 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
178 std::vector<CbmTofCell*> cellVector;
181 TString TopNode = gGeoManager->GetTopNode()->GetName();
182 LOG(debug2) << TopNode;
185 TObjArray* detSystems = gGeoManager->GetTopNode()->GetNodes();
186 for (Int_t iSys = 0; iSys < detSystems->GetEntriesFast(); ++iSys) {
187 TGeoNode* node = (TGeoNode*) detSystems->At(iSys);
188 LOG(debug2) << node->GetName();
193 if (TString(node->GetName()).Contains(
"tof")) {
194 TString TofNode = node->GetName();
195 LOG(info) <<
"Found keeping node " << TofNode;
196 if (TString(((node->GetNodes())->At(0))->GetName()).Contains(
"Stand")) {
197 LOG(info) <<
" Found Tof Stand "
198 << ((node->GetNodes())->At(0))->GetName();
199 node = (TGeoNode*) (node->GetNodes())->At(0);
200 TofNode = TofNode +
"/" + node->GetName();
201 LOG(info) <<
"Modified keeping node " << TofNode;
203 TGeoNode* keep = node;
204 TObjArray* keeping = keep->GetNodes();
206 LOG(info) <<
"Building Tof Digi Par database ... ";
209 for (Int_t ikeep = 0; ikeep < keeping->GetEntriesFast(); ikeep++) {
210 TGeoNode* keepvol = (TGeoNode*) keeping->At(ikeep);
211 TString KeepNode = keepvol->GetName();
212 TObjArray* modarray = keepvol->GetNodes();
215 for (Int_t imodule = 0; imodule < modarray->GetEntriesFast();
217 TGeoNode* module = (TGeoNode*) modarray->At(imodule);
218 TString ModuleNode = module->GetName();
219 TObjArray* cellarray = module->GetNodes();
222 for (Int_t icell = 0; icell < cellarray->GetEntriesFast(); icell++) {
223 TGeoNode* cell = (TGeoNode*) cellarray->At(icell);
224 TString CellNode = cell->GetName();
225 TObjArray* gaparray = cell->GetNodes();
229 for (Int_t igap = 0; igap < gaparray->GetEntriesFast(); igap++) {
230 TGeoNode* gap = (TGeoNode*) gaparray->At(igap);
231 TString GapNode = gap->GetName();
233 if (GapNode.Contains(
"gap")) {
238 TString FullPath =
"/" + TopNode +
"/" + TofNode +
"/"
239 + KeepNode +
"/" + ModuleNode +
"/"
240 + CellNode +
"/" + GapNode;
241 LOG(debug2) <<
"Path: " << FullPath;
255 cellVector.push_back(tofCell);
256 fCellMap.insert(std::pair<Int_t, std::vector<CbmTofCell*>>(
299 std::vector<CbmTofCell*> cellVector;
303 TString TopNode = gGeoManager->GetTopNode()->GetName();
304 LOG(debug2) <<
"TopNode: " << TopNode;
307 TObjArray* detSystems = gGeoManager->GetTopNode()->GetNodes();
308 for (Int_t iSys = 0; iSys < detSystems->GetEntriesFast(); ++iSys) {
309 TGeoNode* node = (TGeoNode*) detSystems->At(iSys);
310 LOG(debug2) <<
"Det system: " << node->GetName();
315 if (TString(node->GetName()).Contains(
"tof")) {
316 TString TofNode = node->GetName();
317 LOG(info) <<
"Found tof keeping volume: " << TofNode;
319 if (TString(((node->GetNodes())->At(0))->GetName()).Contains(
"Stand")) {
320 LOG(info) <<
" Found Tof Stand "
321 << ((node->GetNodes())->At(0))->GetName();
322 node = (TGeoNode*) (node->GetNodes())->At(0);
323 TofNode = TofNode +
"/" + node->GetName();
324 LOG(info) <<
"Modified tof keeping node " << TofNode;
327 TGeoNode* keep = node;
328 TObjArray* modarray = keep->GetNodes();
330 if (
nullptr == modarray) {
331 LOG(WARNING) <<
" No modules found in geometry ";
335 for (Int_t imodule = 0; imodule < modarray->GetEntriesFast(); imodule++) {
336 TGeoNode* module = (TGeoNode*) modarray->At(imodule);
337 TString ModuleNode = module->GetName();
338 TObjArray* modpartarray = module->GetNodes();
341 for (Int_t imodpart = 0; imodpart < modpartarray->GetEntriesFast();
343 TGeoNode* modpart = (TGeoNode*) modpartarray->At(imodpart);
344 TString ModPartNode = modpart->GetName();
346 if (ModPartNode.Contains(
"gas_box")) {
347 TObjArray* counterarray = modpart->GetNodes();
350 for (Int_t icounter = 0; icounter < counterarray->GetEntriesFast();
352 TGeoNode*
counter = (TGeoNode*) counterarray->At(icounter);
353 TString CounterNode =
counter->GetName();
354 if (!CounterNode.Contains(
"counter"))
continue;
355 TObjArray* gaparray =
counter->GetNodes();
356 if (
nullptr == gaparray)
357 LOG(error) <<
" no gaps for counter " << CounterNode;
359 for (Int_t igap = 0; igap < gaparray->GetEntriesFast(); igap++) {
360 TGeoNode* gap = (TGeoNode*) gaparray->At(igap);
361 TString GapNode = gap->GetName();
362 if (GapNode.Contains(
"Gap")) {
363 TObjArray* cellarray = gap->GetNodes();
366 for (Int_t icell = 0; icell < cellarray->GetEntriesFast();
368 TGeoNode* cell = (TGeoNode*) cellarray->At(icell);
369 TString CellNode = cell->GetName();
374 TString FullPath =
"/" + TopNode +
"/" + TofNode +
"/"
375 + +ModuleNode +
"/" + ModPartNode +
"/"
376 + CounterNode +
"/" + GapNode +
"/"
378 LOG(debug2) <<
"Path: " << FullPath;
394 cellVector.push_back(tofCell);
396 std::pair<Int_t, std::vector<CbmTofCell*>>(
fCellID,
439 LOG(debug2) <<
"FCI: " << FullPath.Data();
440 LOG(debug2) <<
"FCI: X: " <<
fX;
441 LOG(debug2) <<
" Y: " <<
fY;
442 LOG(debug2) <<
" Z: " <<
fZ;
443 LOG(debug2) <<
" SizeX: " <<
fSizex;
444 LOG(debug2) <<
" SizeY: " <<
fSizey;
445 LOG(debug2) << Form(
" DetID: 0x%08x",
fDetID);
446 LOG(debug2) <<
" Region: " <<
fRegion;
447 LOG(debug2) <<
" Module: " <<
fCounter;
448 LOG(debug2) <<
" Gap: " <<
fGap;
449 LOG(debug2) <<
" Cell: " <<
fCell;
460 LOG(debug2) <<
"FCI: Cell ID: " << Form(
"0x%08x",
fCellID) <<
" detId "
461 << Form(
"0x%08x",
fDetID);
485 Int_t Nrcells = (Int_t)
fCellMap.size();
486 LOG(debug) <<
"FillDigiPar:: Nr. of tof cells: " << Nrcells;
489 LOG(fatal) <<
"Tof Digi Parameter container not available ";
492 TArrayI* CellId =
new TArrayI(Nrcells);
493 TArrayD* CellX =
new TArrayD(Nrcells);
494 TArrayD* CellY =
new TArrayD(Nrcells);
495 TArrayD* CellZ =
new TArrayD(Nrcells);
496 TArrayD* CellDx =
new TArrayD(Nrcells);
497 TArrayD* CellDy =
new TArrayD(Nrcells);
502 std::map<Int_t, CbmTofCell*> singleCellMap;
510 std::vector<CbmTofCell*> vcell =
fCellMapIt->second;
513 std::vector<CbmTofCell*>::iterator vcellIt;
523 for (vcellIt = vcell.begin(); vcellIt != vcell.end(); ++vcellIt) {
524 tofcell = (*vcellIt);
527 LOG(info) <<
"id, cellId: " <<
id <<
" , " << cellId <<
"\n";
528 LOG(info) <<
"id and CellId differ";
530 x += tofcell->
GetX();
531 y += tofcell->
GetY();
532 z += tofcell->
GetZ();
537 CellX->AddAt(
x / vcell.size(), iDigi);
538 CellY->AddAt(
y / vcell.size(), iDigi);
539 CellZ->AddAt(z / vcell.size(), iDigi);
540 CellDx->AddAt(sizex / vcell.size(), iDigi);
541 CellDy->AddAt(sizey / vcell.size(), iDigi);
548 sizex / vcell.size(),
549 sizey / vcell.size());
550 singleCellMap.insert(std::pair<Int_t, CbmTofCell*>(cellId, singlecell));
560 LOG(info) <<
"FillDigiPar " << iDigi <<
", cellId = " << cellId <<
", t "
562 <<
fCell <<
" " <<
x / vcell.size() * 10 <<
" "
563 <<
y / vcell.size() * 10 <<
" " << z / vcell.size() * 10
564 <<
" " << sizex / vcell.size() * 10 <<
" "
565 << sizey / vcell.size() * 10;