//*-- AUTHOR : Denis Bertini //*-- Created : 21/06/2005 /////////////////////////////////////////////////////////////// // PndMvdParAsciiFileIo // // Class for PndMvd parameter input/output from/into Ascii file // /////////////////////////////////////////////////////////////// #include "PndMvdParAsciiFileIo.h" #include "PndMvdPixelDigiPar.h" #include "PndMvdStripDigiPar.h" ClassImp(PndMvdParAsciiFileIo) PndMvdParAsciiFileIo::PndMvdParAsciiFileIo(fstream* f) : CbmDetParAsciiFileIo(f) { // constructor calls the base class constructor fName="PndMvdParIo"; } Bool_t PndMvdParAsciiFileIo::init(CbmParSet* pPar) { // calls the appropriate read function for the container const Text_t* name=pPar->GetName(); std::cout << "-I- Ascii Io init() " << pPar->GetName() << std::endl; if (pFile) { if (!strcmp(name,"PndMvdPixelDigiPar")) return read((PndMvdPixelDigiPar*)pPar,0,kTRUE); if (!strcmp(name,"PndMvdStripDigiPar")) return read((PndMvdStripDigiPar*)pPar,0,kTRUE); cerr<<"initialization of "<GetName(); if (!strcmp(name,"PndMvdPixelDigiPar")) return writeFile2((PndMvdPixelDigiPar*)pPar); if (!strcmp(name,"PndMvdStripDigiPar")) return writeFile2((PndMvdStripDigiPar*)pPar); //problem with container name cerr< Bool_t PndMvdParAsciiFileIo::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 // std::cout << "-I- Read Ascii IO " << std::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- PndMvdParAsciiFileIo 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 PndMvdParAsciiFileIo::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]; /* Int_t n0 = (*pPar).getSize(); for(Int_t i0=0; i0writeline(buf,i0,i1)) pFile->write(buf,strlen(buf)); } } pPar->setChanged(kFALSE); pFile->write(sepLine,strlen(sepLine)); */ return 1; }