//*-- AUTHOR : Ilse Koenig //*-- Created : 16/11/2015 //*-- Modified : RafaƂ Lalik //_HADES_CLASS_DESCRIPTION ///////////////////////////////////////////////////////////// // // HStsDetector // // The detector class of the Forward Detector // ///////////////////////////////////////////////////////////// #include "hstsdetector.h" #include "hades.h" #include "hcategory.h" #include "hdetpario.h" #include "hevent.h" #include "hgeantmaxtrk.h" #include "hlinearcategory.h" #include "hmatrixcategory.h" #include "hparasciifileio.h" #include "hpario.h" #include "hparrootfileio.h" #include "hstsparasciifileio.h" #include "hstsparrootfileio.h" #include "stsdef.h" #include ClassImp(HStsDetector); // Sts detector class HStsDetector::HStsDetector() : HDetector("Sts", "The Sts detector") { // constructor fName = "Sts"; maxModules = STS_MAX_MODULES; maxSectors = STS_MAX_LAYERS; maxComponents = STS_MAX_COMP; modules = new TArrayI(maxSectors * maxModules); } HStsDetector::~HStsDetector() { delete modules; modules = 0; } void HStsDetector::activateParIo(HParIo *io) { // activates the input/output class for the Sts parameters if (strcmp(io->IsA()->GetName(), "HParOraIo") == 0) { io->setDetParIo("HStsParIo"); return; } if (strcmp(io->IsA()->GetName(), "HParRootFileIo") == 0) { HStsParRootFileIo *p = new HStsParRootFileIo(((HParRootFileIo *)io)->getParRootFile()); io->setDetParIo(p); } if (strcmp(io->IsA()->GetName(), "HParAsciiFileIo") == 0) { HStsParAsciiFileIo *p = new HStsParAsciiFileIo(((HParAsciiFileIo *)io)->getFile()); io->setDetParIo(p); } } Bool_t HStsDetector::write(HParIo *output) { // writes the Sts setup to output HDetParIo *out = output->getDetParIo("HStsParIo"); if (out) return out->write(this); return kFALSE; } HCategory *HStsDetector::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 Sts RPC HCategory * HStsDetector::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 *HStsDetector::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 *HStsDetector::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 *HStsDetector::buildLinearCategory(const Text_t *className, Int_t size) { if (size > 0) { HLinearCategory *category = new HLinearCategory(className, size); return category; } return 0; } HCategory *HStsDetector::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 Int_t maxModInSetup = getMaxModInSetup(); if (maxModInSetup == 0) return 0; switch (cat) { case catStsRaw: pcat = buildMatrixCategory("HStsRaw", STS_MAX_MODULES, STS_MAX_LAYERS, STS_MAX_CELLS, STS_MAX_UDCONF); break; case catStsCal: if (simulation) pcat = buildMatrixCategory("HStsCalSim", STS_MAX_MODULES, STS_MAX_LAYERS, STS_MAX_CELLS, STS_MAX_UDCONF); else pcat = buildMatrixCategory("HStsCal", STS_MAX_MODULES, STS_MAX_LAYERS, STS_MAX_CELLS, STS_MAX_UDCONF); break; default: return nullptr; } if (pcat) gHades->getCurrentEvent()->addCategory(cat, pcat, "Sts"); return pcat; } Int_t HStsDetector::getMaxModInSetup() { Int_t maxMod = -1; for (Int_t i = 0; i < maxModules; i++) { if (modules->At(i)) maxMod = (i > maxMod) ? i : maxMod; } ++maxMod; return maxMod; }