//*-- AUTHOR : Ilse Koenig //*-- Created : 16/11/2015 //*-- Modified : RafaƂ Lalik //_HADES_CLASS_DESCRIPTION ///////////////////////////////////////////////////////////// // // HFRpcDetector // // The detector class of the Forward Detector // ///////////////////////////////////////////////////////////// #include "hfrpcdetector.h" #include "frpcdef.h" #include "hades.h" #include "hcategory.h" #include "hdetpario.h" #include "hevent.h" #include "hfrpcparasciifileio.h" #include "hfrpcparrootfileio.h" #include "hgeantmaxtrk.h" #include "hlinearcategory.h" #include "hmatrixcategory.h" #include "hparasciifileio.h" #include "hpario.h" #include "hparrootfileio.h" #include ClassImp(HFRpcDetector); // FRpc detector class HFRpcDetector::HFRpcDetector() : HDetector("FRpc", "The FRpc detector") { // constructor maxModules = FRPC_MAX_MODULES; maxSectors = FRPC_MAX_SECTORS; maxComponents = FRPC_MAX_CELLS; // needed for geometry parameter container modules = new TArrayI(maxSectors * maxModules); } HFRpcDetector::~HFRpcDetector() { delete modules; modules = 0; } void HFRpcDetector::activateParIo(HParIo *io) { // activates the input/output class for the FRpc parameters if (strcmp(io->IsA()->GetName(), "HParOraIo") == 0) { io->setDetParIo("HFRpcParIo"); return; } if (strcmp(io->IsA()->GetName(), "HParRootFileIo") == 0) { HFRpcParRootFileIo *p = new HFRpcParRootFileIo(((HParRootFileIo *)io)->getParRootFile()); io->setDetParIo(p); } if (strcmp(io->IsA()->GetName(), "HParAsciiFileIo") == 0) { HFRpcParAsciiFileIo *p = new HFRpcParAsciiFileIo(((HParAsciiFileIo *)io)->getFile()); io->setDetParIo(p); } } Bool_t HFRpcDetector::write(HParIo *output) { // writes the FRpc setup to output HDetParIo *out = output->getDetParIo("HFRpcParIo"); if (out) return out->write(this); return kFALSE; } HCategory *HFRpcDetector::buildMatrixCategory(const Text_t *className, Int_t maxMod, Int_t maxCell, Float_t fillRate) { Int_t *sizes = new Int_t[2]; // 2 levels Module - Cell sizes[0] = maxMod; sizes[1] = maxCell; HMatrixCategory *category = new HMatrixCategory(className, 2, sizes, fillRate); delete[] sizes; return category; } // Needed for FRpc RPC HCategory * HFRpcDetector::buildMatrixCategory(const Text_t *className, Int_t maxMod, Int_t maxLay, Int_t maxCell, Float_t fillRate) { Int_t *sizes = new Int_t[3]; // 3 levels Module - Layer - Cell sizes[0] = maxMod; sizes[1] = maxLay; sizes[2] = maxCell; HMatrixCategory *category = new HMatrixCategory(className, 3, sizes, fillRate); delete[] sizes; return category; } HCategory *HFRpcDetector::buildMatrixCategory(const Text_t *className, Int_t maxMod, Int_t maxDbLay, Int_t nLays, Int_t maxCell, Float_t fillRate) { Int_t *sizes = new Int_t[4]; // 4 levels Module - DoubleLayer - Layer - Cell(straw tube) sizes[0] = maxMod; sizes[1] = maxDbLay; sizes[2] = nLays; sizes[3] = maxCell; HMatrixCategory *category = new HMatrixCategory(className, 4, sizes, fillRate); delete[] sizes; return category; } HCategory *HFRpcDetector::buildMatrixCategory(const Text_t *className, Int_t maxMod, Int_t maxDbLay, Int_t nLays, Int_t maxCell, Int_t maxSubCell, Float_t fillRate) { Int_t *sizes = new Int_t[5]; // 4 levels Module - DoubleLayer - Layer - Cell(straw tube) sizes[0] = maxMod; sizes[1] = maxDbLay; sizes[2] = nLays; sizes[3] = maxCell; sizes[4] = maxSubCell; HMatrixCategory *category = new HMatrixCategory(className, 5, sizes, fillRate); delete[] sizes; return category; } HCategory *HFRpcDetector::buildLinearCategory(const Text_t *className, Int_t size) { if (size > 0) { HLinearCategory *category = new HLinearCategory(className, size); return category; } return 0; } HCategory *HFRpcDetector::buildCategory(Cat_t cat, Bool_t simulation) { // gets the category if existing // builts and adds if not existing // returns the pointer to the category or zero HCategory *pcat; pcat = gHades->getCurrentEvent()->getCategory(cat); if (pcat) return (pcat); // already existing switch (cat) { case catFRpcRaw: pcat = buildMatrixCategory("HFRpcRaw", FRPC_MAX_SECTORS, FRPC_MAX_COLUMNS, FRPC_MAX_STRIPS); break; case catFRpcCal: if (simulation) pcat = buildMatrixCategory("HFRpcCalSim", FRPC_MAX_SECTORS, FRPC_MAX_STRIPS); else pcat = buildMatrixCategory("HFRpcCal", FRPC_MAX_SECTORS, FRPC_MAX_STRIPS); break; case catFRpcClus: pcat = buildLinearCategory("HFRpcCluster", 64); break; case catFRpcHit: pcat = buildLinearCategory("HFRpcHit", 64); break; default: return nullptr; } if (pcat) gHades->getCurrentEvent()->addCategory(cat, pcat, "FRpc"); return pcat; } Int_t HFRpcDetector::getMaxSecInSetup() { Int_t maxSec = -1; for (Int_t i = 0; i < maxSectors; i++) { if (modules->At(i)) maxSec = (i > maxSec) ? i : maxSec; } ++maxSec; return maxSec; }