using namespace std;
#include "hwallparrootfileio.h"
#include "hparrootfileio.h"
#include "hades.h"
#include "hspectrometer.h"
#include "hwalldetector.h"
#include "hwalllookup.h"
#include "hwalltrb2lookup.h"
#include "hwallcalpar.h"
#include "hwallgeompar.h"
#include "hruntimedb.h"
#include <iostream>
#include <iomanip>
ClassImp(HWallParRootFileIo)
HWallParRootFileIo::HWallParRootFileIo(HParRootFile* f) : HDetParRootFileIo(f) {
fName="HWallParIo";
initModules=new TArrayI(1);
}
Bool_t HWallParRootFileIo::init(HParSet* pPar,Int_t* set) {
if (!isActiv) readModules("Wall");
const Text_t* name=pPar->GetName();
if (pFile) {
if (strcmp(name,"WallLookup")==0) return read((HWallLookup*)pPar,set);
if (strcmp(name,"WallCalPar")==0) return read((HWallCalPar*)pPar,set);
if (strcmp(name,"WallTrb2Lookup")==0)
return HDetParRootFileIo::read((HWallTrb2Lookup*)pPar);
if (strcmp(name,"WallGeomPar")==0)
return HDetParRootFileIo::read((HWallGeomPar*)pPar,set);
}
cerr<<"initialization of "<<name<<" not possible from ROOT file!"<<endl;
return kFALSE;
}
Bool_t HWallParRootFileIo::read(HWallLookup* pPar,Int_t* set) {
Text_t* name=(Char_t*)pPar->GetName();
Int_t version=findInputVersion(name);
if (version<=0) {
pPar->setInputVersion(-1,inputNumber);
return kFALSE;
}
if (pPar->getInputVersion(inputNumber)==version
&& pPar->getInputVersion(inputNumber)!=-1) return kTRUE;
HWallLookup* rWall=(HWallLookup*)findContainer(name,version);
pPar->clear();
Int_t cell;
Char_t modType;
Bool_t allFound=kFALSE;
for(Int_t c=0;c<rWall->getSize();c++) {
for(Int_t s=0;s<(*rWall)[c].getSize();s++) {
HWallLookupSlot& slot=(*rWall)[c][s];
modType=slot.getType();
for(Int_t i=0;i<slot.getSize();i++) {
cell=slot[i].getCell();
if (cell>=0) {
pPar->fill(c,s,modType,i,cell);
allFound=kTRUE;
}
}
}
}
if (allFound) {
pPar->setInputVersion(version,inputNumber);
pPar->setChanged();
cout<<"WallLookup: module(s) initialized from ROOT file\n";
}
return allFound;
}
Bool_t HWallParRootFileIo::read(HWallCalPar* pPar,Int_t* set) {
Text_t* name=(Char_t*)pPar->GetName();
Int_t version=findInputVersion(name);
if (version==-1) {
pPar->setInputVersion(-1,inputNumber);
return kFALSE;
}
if (pPar->getInputVersion(inputNumber)==version
&& pPar->getInputVersion(inputNumber)!=-1) return kTRUE;
pPar->clear();
HWallCalPar* r=(HWallCalPar*)findContainer(name,version);
Bool_t allFound=kTRUE;
HWallCalPar& rWall=*r;
HWallCalPar& pWall=*pPar;
Int_t pWallSize=pWall.getSize();
if (pWallSize && (rWall.getSize()==pWallSize)) {
for(Int_t c=0;c<pWallSize;c++) pWall[c].fill(rWall[c]);
} else allFound=kFALSE;
if (allFound) {
pPar->setInputVersion(version,inputNumber);
pPar->setChanged();
cout<<"WallCalPar initialized from ROOT file\n";
} else pPar->setInputVersion(-1,inputNumber);
delete r;
return allFound;
}
hwallparrootfileio.cc:100 hwallparrootfileio.cc:101 hwallparrootfileio.cc:102 hwallparrootfileio.cc:103 hwallparrootfileio.cc:104 hwallparrootfileio.cc:105 hwallparrootfileio.cc:106 hwallparrootfileio.cc:107 hwallparrootfileio.cc:108 hwallparrootfileio.cc:109 hwallparrootfileio.cc:110 hwallparrootfileio.cc:111 hwallparrootfileio.cc:112 hwallparrootfileio.cc:113 hwallparrootfileio.cc:114 hwallparrootfileio.cc:115 hwallparrootfileio.cc:116 hwallparrootfileio.cc:117 hwallparrootfileio.cc:118 hwallparrootfileio.cc:119 hwallparrootfileio.cc:120 hwallparrootfileio.cc:121 hwallparrootfileio.cc:122 hwallparrootfileio.cc:123 hwallparrootfileio.cc:124 hwallparrootfileio.cc:125 hwallparrootfileio.cc:126 hwallparrootfileio.cc:127 hwallparrootfileio.cc:128 hwallparrootfileio.cc:129 hwallparrootfileio.cc:130 hwallparrootfileio.cc:131 hwallparrootfileio.cc:132 hwallparrootfileio.cc:133 hwallparrootfileio.cc:134 hwallparrootfileio.cc:135 hwallparrootfileio.cc:136