//_HADES_CLASS_DESCRIPTION //*-- AUTHOR : Ilse Koenig //*-- Created : 16/11/2015 ///////////////////////////////////////////////////////////////////////////////// // HStsParRootFileIo // // Class for parameter input/output from/into ROOT file for the Forward detector // // It is derived from the base class HDetParRootFileIo and // inherits from it basic functions e.g. write(...) // ///////////////////////////////////////////////////////////////////////////////// #include "hstsparrootfileio.h" #include "hades.h" #include "hspectrometer.h" #include "hstscalpar.h" #include "hstsdetector.h" #include "hstsgeompar.h" ClassImp(HStsParRootFileIo); HStsParRootFileIo::HStsParRootFileIo(HParRootFile *f) : HDetParRootFileIo(f) { // constructor sets the name of the detector I/O "HStsParIo" fName = "HStsParIo"; HDetector *det = gHades->getSetup()->getDetector("Sts"); Int_t n = det->getMaxModules() * det->getMaxSectors(); initModules = new TArrayI(n); } HStsParRootFileIo::~HStsParRootFileIo() { // destructor if (initModules) { delete initModules; initModules = 0; } } Bool_t HStsParRootFileIo::init(HParSet *pPar, Int_t *set) { // initializes a container called by name, but only the modules // defined in the array 'set' // calls the special read function for this container // If it is called the first time it reads the setup found in the file if (!isActiv) readModules("Sts"); const Text_t *name = pPar->GetName(); if (pFile) { if (0 == strncmp(name, "StsTrb3Lookup", strlen("StsTrb3Lookup"))) return HDetParRootFileIo::read(pPar); if (0 == strncmp(name, "StsGeomPar", strlen("StsGeomPar"))) return HDetParRootFileIo::read((HStsGeomPar *)pPar, set); if (0 == strncmp(name, "StsTrb3Calpar", strlen("StsTrb3Calpar"))) return HDetParRootFileIo::read(pPar); if (0 == strncmp(name, "StsCalPar", strlen("StsCalPar"))) return read((HStsCalPar *)pPar, set); } Error("init(HParSet*,Int_t*)", "Initialization of %s not possible from ROOT file", name); return kFALSE; } Bool_t HStsParRootFileIo::read(HStsCalPar *pPar, Int_t *set) { // reads and fills the container "StsCalPar" for calibration parameters Text_t *name = (Char_t *)pPar->GetName(); Int_t version = findInputVersion(name); if (version == -1) { pPar->setInputVersion(-1, inputNumber); return kFALSE; // not in ROOT file } if (pPar->getInputVersion(inputNumber) == version && pPar->getInputVersion(inputNumber) != -1) return kTRUE; // needs reinitialization HStsCalPar *r = (HStsCalPar *)findContainer(name, version); Bool_t allFound = kTRUE; initModules->Reset(); HStsCalPar &rSts = *r; HStsCalPar &pSts = *pPar; for (Int_t m = 0; m < pSts.getSize(); m++) { HStsCalParMod &rMod = rSts[m]; HStsCalParMod &pMod = pSts[m]; for (Int_t s = 0; s < pMod.getSize(); s++) { HStsCalParSec &rSec = rMod[s]; HStsCalParSec &pSec = pMod[s]; Int_t pos = m * STS_MAX_LAYERS + s; if (set[pos]) { Int_t pSecSize = pSec.getSize(); for (Int_t c = 0; c < pSecSize; c++){ HStsCalParCell& rcell = rSec[c]; HStsCalParCell& pcell = pSec[c]; for (Int_t k = 0; k < rcell.getSize() ; k++){ HStsCalParCellKind& rkind = rcell[k]; HStsCalParCellKind& pkind = pcell[k]; pkind.fill(rkind); } } set[pos] = 0; initModules->AddAt(pos + 1, pos); } else allFound = kFALSE; } } pPar->setInputVersion(version, inputNumber); pPar->setChanged(); printInfo("StsCalPar: module(s) initialized from Root file:\n "); delete r; return allFound; }