FairRoot/PandaRoot
Public Member Functions | List of all members
PndSttParAsciiFileIo Class Reference

#include <PndSttParAsciiFileIo.h>

Inheritance diagram for PndSttParAsciiFileIo:

Public Member Functions

 PndSttParAsciiFileIo (std::fstream *)
 
 ~PndSttParAsciiFileIo ()
 
Bool_t init (FairParSet *)
 
Int_t write (FairParSet *)
 
template<class T >
Bool_t read (T *, Int_t *, Bool_t needsClear=kFALSE)
 
template<class T >
Int_t writeFile2 (T *)
 

Detailed Description

Definition at line 12 of file PndSttParAsciiFileIo.h.

Constructor & Destructor Documentation

PndSttParAsciiFileIo::PndSttParAsciiFileIo ( std::fstream *  f)

Definition at line 23 of file PndParAsciiFileIo.cxx.

23  : FairDetParAsciiFileIo(f)
24 {
25  // constructor calls the base class constructor
26  fName="PndSttParIo";
27 }
TFile * f
Definition: bump_analys.C:12
PndSttParAsciiFileIo::~PndSttParAsciiFileIo ( )
inline

Definition at line 15 of file PndSttParAsciiFileIo.h.

15 {}

Member Function Documentation

Bool_t PndSttParAsciiFileIo::init ( FairParSet *  pPar)

Definition at line 29 of file PndParAsciiFileIo.cxx.

References name, and read().

30 {
31  // calls the appropriate read function for the container
32  const Text_t* name=pPar->GetName();
33  cout << "-I- Ascii Io init() " << pPar->GetName() << endl;
34 
35  if (pFile)
36  {
37  if (!strcmp(name,"PndSttDigiPar")) return read((PndSttDigiPar*)pPar,0,kTRUE);
38  cerr<<"initialization of "<<name<<" not possible from file!"<<endl;
39  return kFALSE;
40  }
41  cerr<<"no input file open"<<endl;
42  return kFALSE;
43 }
TString name
Bool_t read(T *, Int_t *, Bool_t needsClear=kFALSE)
template<class T >
Bool_t PndSttParAsciiFileIo::read ( T pPar,
Int_t *  set,
Bool_t  needsClear = kFALSE 
)

Definition at line 60 of file PndParAsciiFileIo.cxx.

References Bool_t, name, and printf().

Referenced by init().

62 {
63  // template function for all parameter containers
64  // searches the container in the file, reads the data line by line and
65  // called the member function readline(...) of the container class
66  // cout << "-I- Read Ascii IO " << endl;
67  // return kTRUE;
68 
69  const Text_t* name=pPar->GetName();
70  if (!findContainer(name)) return kFALSE;
71  if (needsClear) pPar->clear();
72  const Int_t maxbuf=155;
73  Text_t buf[maxbuf];
74  while (!pFile->eof()) {
75  pFile->getline(buf, maxbuf);
76  if (buf[0]=='#') break;
77  if (buf[0]!='/' && buf[0]!='\0')
78  // printf("-I- CbmStsParAsciiFileIo container name: %s",
79  // pPar->GetName());
80  pPar->readline(buf,set,pFile);
81  }
82  pPar->setInputVersion(1,inputNumber);
83  pPar->setChanged();
84  Bool_t allFound=kTRUE;
85  // if (allFound) printf("%s initialized from Ascii file\n",name);
86  printf("%s initialized from Ascii file\n",name);
87 
88  return allFound;
89 }
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
TString name
Int_t PndSttParAsciiFileIo::write ( FairParSet *  pPar)

Definition at line 45 of file PndParAsciiFileIo.cxx.

References name, and writeFile2().

46 {
47  // calls the appropriate write function for the container
48  if (pFile)
49  {
50  const Text_t* name=pPar->GetName();
51  if (!strcmp(name,"PndSttDigiPar")) return writeFile2((PndSttDigiPar*)pPar);
52  //problem with container name
53  cerr<<name<<" could not be written to Ascii file"<<endl;
54  return -1;
55  }
56  cerr<<"no output file open"<<endl;
57  return -1;
58 }
TString name
template<class T >
Int_t PndSttParAsciiFileIo::writeFile2 ( T pPar)

Definition at line 92 of file PndParAsciiFileIo.cxx.

Referenced by write().

92  {
93  // template function for all parameter containers with 2 levels
94  // writes the header, loops over the container and calls its member
95  // function writeline(...)
96  pPar->putAsciiHeader(fHeader);
97  writeHeader(pPar->GetName());
98  Text_t buf[155];
99  return 1;
100 }

The documentation for this class was generated from the following files: