//*-- AUTHOR : Ilse Koenig //*-- Modified : 30/11/2000 by Ilse Koenig //_HADES_CLASS_DESCRIPTION ///////////////////////////////////////////////////////////// // HTofinoParRootFileIo // // Class for Tofino parameter input/output from/into ROOT file // // It is derived from the base class HDetParFileIo and // inherits from it basic functions e.g. write(...) // ///////////////////////////////////////////////////////////// using namespace std; #include "htofinoparrootfileio.h" #include "hparrootfileio.h" #include "htofinolookup.h" #include "htofinogeompar.h" #include #include ClassImp(HTofinoParRootFileIo) HTofinoParRootFileIo::HTofinoParRootFileIo(HParRootFile* f) : HDetParRootFileIo(f) { // constructor sets the name of the detector I/O "HTofinoParIo" fName="HTofinoParIo"; initModules=new TArrayI(6); } HTofinoParRootFileIo::~HTofinoParRootFileIo() { // destructor if (modulesFound) { delete modulesFound; modulesFound=0; } if (initModules) { delete initModules; initModules=0; } } Bool_t HTofinoParRootFileIo::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("Tofino"); const Text_t* name = ((TNamed*)pPar)->GetName(); printf("Tofino par file io init - %s\n", name); if (pFile) { // if (strncmp(name,"TofinoCalPar",strlen("TofinoCalPar"))==0) return read((HTofinoCalPar*)pPar,set); if (strcmp(name,"TofinoCalPar")==0) return HDetParRootFileIo::read(pPar); if (strcmp(name,"TofinoShowerMap")==0) return HDetParRootFileIo::read(pPar); if (strcmp(name,"TofinoLookup")==0) return read((HTofinoLookup*)pPar,set); if (strcmp(name,"TofinoGeomPar")==0) return HDetParRootFileIo::read((HTofinoGeomPar*)pPar,set); } Error("init(HParSet*,Int_t*)","initialization of %s not possible from ROOT file!",name); return kFALSE; } Bool_t HTofinoParRootFileIo::read(HTofinoLookup* pPar,Int_t* set) { // Reads and fills the container "TofinoLookup" needed by the unpacker. // Returns kFalse, when not initialized completely from this input Text_t* name=(Char_t*)pPar->GetName(); Int_t version=findInputVersion(name); if (version<=0) { printf("Container %s not found in RuntimeDB in the %d input\n",name,inputNumber); pPar->setInputVersion(-1,inputNumber); return kFALSE;} // not in ROOT file if (pPar->getInputVersion(inputNumber)==version && pPar->getInputVersion(inputNumber)!=-1) return kTRUE; // needs reinitialization HTofinoLookup* rTofino=(HTofinoLookup*)findContainer(name,version); initModules->Reset(); pPar->clear(); // no initialization from 2 inputs possible! Int_t crate, slot, sector, module, cell; Char_t dcType; for(Int_t t=0;tgetSize();t++) { HTofinoLookupDConv& rDC=(*rTofino)[t]; crate=rDC.getCrate(); slot=rDC.getSlot(); dcType=rDC.getType(); for(Int_t c=0;c=0 && set[sector]) { pPar->setAddress(crate,slot,dcType,c,sector,module,cell); initModules->AddAt(sector+1,sector); } } } pPar->setInputVersion(version,inputNumber); pPar->setChanged(); //printInfo("TofinoLookup: module(s) initialized from ROOT input"); printf("TofinoLookup: module(s) initialized from the %d ROOT input",inputNumber); delete rTofino; Bool_t allFound=kTRUE; for(Int_t i=0;iGetSize(); i++) { if (set[i] && !initModules->At(i)) allFound=kFALSE; } return allFound; }