//*-- AUTHOR : Denis Bertini
//*-- Last modified : 15/12/98 by Ilse Koenig

//_HADES_CLASS_DESCRIPTION 
/////////////////////////////////////////////////////////////
//HTofinoParHadAsciiFileIo
//
//  Class for Tofino parameter input/output from/into Asci file
//
/////////////////////////////////////////////////////////////
using namespace std;
#include "htofinoparhadasciifileio.h"
#include "hades.h"
#include "hspectrometer.h"
#include "htofinodetector.h"
#include "htofinocalpar.h"
#include "htofinoshowermap.h"
#include <iostream> 
#include <iomanip>

ClassImp(HTofinoParHadAsciiFileIo)

HTofinoParHadAsciiFileIo::HTofinoParHadAsciiFileIo(HParHadAsciiFileIo* f) 
                            : HDetParHadAsciiFileIo(f) {
  fName="HTofinoParIo";
}


Bool_t HTofinoParHadAsciiFileIo::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

  const Text_t* name = ((TNamed*)pPar)->GetName();
  printf("Tofino par file io init - %s\n", name);
  if (pFile) {
    if (strcmp(name,"TofinoCalPar")==0) 
                                return read((HTofinoCalPar*)pPar,set);
    if (strcmp(name,"TofinoShowerMap")==0) 
                                return read((HTofinoShowerMap*)pPar,set);
  }
  cerr<<"Initialization of "<<name<<" not possible from ASCII file!"<<endl;
  return kFALSE;
}


Int_t HTofinoParHadAsciiFileIo::write(HParSet* pPar) {
  const  Text_t* name = ((TNamed*)pPar)->GetName();
  if (pFile) {
    if (strcmp(name,"TofinoCalPar")==0) 
                                return writeFile((HTofinoCalPar*)pPar);
    if (strcmp(name,"TofinoShowerMap")==0) 
                                return writeFile((HTofinoShowerMap*)pPar);
  }

  cerr<<name<<" Could not be written to ASCII file"<<endl;
  return kFALSE;
}


Bool_t HTofinoParHadAsciiFileIo::write(HDetector* p) {
  return kTRUE;  // not implemented!
}

Bool_t HTofinoParHadAsciiFileIo::read(HTofinoCalPar* pPar, Int_t* set) {
  printf("Reading TofinoCalPar container\n");
  Int_t ret;

  pPar->setStatic();
  ret = pPar->initAscii(pFile);

  return ret;
}

Bool_t HTofinoParHadAsciiFileIo::read(HTofinoShowerMap* pPar, Int_t* set) {
  printf("Reading TofinoShowerMap container\n");
  Int_t ret;

  pPar->setStatic();
  ret = pPar->initAscii(pFile);

  return ret;
}

Bool_t HTofinoParHadAsciiFileIo::writeFile(HTofinoCalPar* pPar) {
  printf("Writing TofinoCalPar container\n");
  
  pPar->writeAscii(pFile);      
  
  return kTRUE;
}   

Bool_t HTofinoParHadAsciiFileIo::writeFile(HTofinoShowerMap* pPar) {
  printf("Writing TofinoShowerMap container\n");

  pPar->writeAscii(pFile);

  return kTRUE;
}


Last change: Sat May 22 13:16:49 2010
Last generated: 2010-05-22 13:16

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.