//*-- AUTHOR : Denis Bertini //*-- Created : 21/06/2005 /////////////////////////////////////////////////////////////// // CbmStsParAsciiFileIo // // Class for Stt parameter input/output from/into Ascii file // /////////////////////////////////////////////////////////////// #include "PndSttParAsciiFileIo.h" #include "PndSttDigiPar.h" #include using std::cout; using std::cerr; using std::endl; ClassImp(PndSttParAsciiFileIo) PndSttParAsciiFileIo::PndSttParAsciiFileIo(fstream* f) : FairDetParAsciiFileIo(f) { // constructor calls the base class constructor fName="PndSttParIo"; } Bool_t PndSttParAsciiFileIo::init(FairParSet* pPar) { // calls the appropriate read function for the container const Text_t* name=pPar->GetName(); cout << "-I- Ascii Io init() " << pPar->GetName() << endl; if (pFile) { if (!strcmp(name,"PndSttDigiPar")) return read((PndSttDigiPar*)pPar,0,kTRUE); cerr<<"initialization of "<GetName(); if (!strcmp(name,"PndSttDigiPar")) return writeFile2((PndSttDigiPar*)pPar); //problem with container name cerr< Bool_t PndSttParAsciiFileIo::read(T* pPar, Int_t* set, Bool_t needsClear) { // template function for all parameter containers // searches the container in the file, reads the data line by line and // called the member function readline(...) of the container class // cout << "-I- Read Ascii IO " << endl; // return kTRUE; const Text_t* name=pPar->GetName(); if (!findContainer(name)) return kFALSE; if (needsClear) pPar->clear(); const Int_t maxbuf=155; Text_t buf[maxbuf]; while (!pFile->eof()) { pFile->getline(buf, maxbuf); if (buf[0]=='#') break; if (buf[0]!='/' && buf[0]!='\0') // printf("-I- CbmStsParAsciiFileIo container name: %s", // pPar->GetName()); pPar->readline(buf,set,pFile); } pPar->setInputVersion(1,inputNumber); pPar->setChanged(); Bool_t allFound=kTRUE; // if (allFound) printf("%s initialized from Ascii file\n",name); printf("%s initialized from Ascii file\n",name); return allFound; } template Int_t PndSttParAsciiFileIo::writeFile2(T* pPar) { // template function for all parameter containers with 2 levels // writes the header, loops over the container and calls its member // function writeline(...) pPar->putAsciiHeader(fHeader); writeHeader(pPar->GetName()); Text_t buf[155]; return 1; }