10 #include "StIOMaker.h"
11 #include "StTreeMaker/StTreeMaker.h"
22 const char IOFMTS[] =
"root xdf mdc2 daq mudst dat ";
23 const char *IOCLAS[] = {0
32 const char *IONAME[] = {0,
45 const
char *ioFile,const
char *treeName)
48 Build(0,ioFile,treeName);
51 StIOMaker::StIOMaker(
const char *name,
const char *iomode,
52 StFileI *fileSet,
const char *treeName )
55 Build( fileSet,0,treeName);
64 SetTreeName(treeName);
fCase=0;
66 if (fIOMode[0]==
'r') {
68 if (ioFile && ioFile[0]) {
70 fFileSet->AddFile(ioFile);
79 StIOMaker::~StIOMaker()
82 if (fFileSet)
delete fFileSet; fFileSet= 0;
85 void StIOMaker::Rewind()
88 if (fFileSet) fFileSet->Rewind();
92 Int_t StIOMaker::Init()
98 void StIOMaker::SetFile(
const char *file)
100 if (!file || !file[0])
return;
101 StIOInterFace::SetFile(file);
103 if (fIOMode[0]!=
'r')
return;
110 fFileSet->AddFile(file);
113 Int_t StIOMaker::Skip()
116 if (!
fSkip)
return 0;
121 if (!
fSkip)
return 0;
129 Int_t StIOMaker::Open(
const char *)
131 if (fIOMode[0]==0)
return 0;
132 if (fIOMode[0]==
'r') { Skip();
return OpenRead();}
136 Int_t StIOMaker::OpenRead()
141 if (!fFileSet)
return kStEOF;
143 if (fFileSet->GetNextBundle())
return kStEOF;
147 if(GetDebug()) (
void) printf(
"<StIOMaker::Open() file %s\n",(
const char*)
fNextFile);
148 TString fmt = fFileSet->GetFormat(0);
149 TString bra = fFileSet->GetCompName(0);
151 const char *cc = strstr(IOFMTS,(
const char*)fmt);
153 fCase = (cc-IOFMTS)/6+1;
160 StIOInterFace::SetFile(
fNextFile.Data());
166 Int_t StIOMaker::OpenWrite()
172 if(GetDebug()) (
void) printf(
"<StIOMaker::Open() file %s\n",(
const char*)
fNextFile);
186 if (fIOMode[0]==
'r') {
193 <<
" EventId: " << GetEventNumber() << endm;
197 if (iret !=
kStEOF)
return iret;
199 iret = Open();
if (iret)
return iret;
207 Int_t StIOMaker::MakeRead(){
211 StUKey uk = fFileSet->GetNextEvent();
212 if (uk.EOK())
return kStEOF;
217 Int_t StIOMaker::MakeRead(
const StUKey &uk){
224 Int_t StIOMaker::MakeWrite()
234 for(
int i=0;i<n;i++) {
240 delete fFileSet; fFileSet=0;
244 void StIOMaker::Close(Option_t *)
248 NotifyEm(
"CloseFile",
fFile.Data());
258 void StIOMaker::NotifyMe(
const char *about,
const void *info)
260 if (strcmp(
"CloseFile",about)==0) { Close();
return;}
261 if (strcmp(
"OpenFile" ,about)==0) {
fNextFile =((
char*)info);
return;}
271 const char *className = IOCLAS[
fCase];
272 (void) printf(
"<StIOMaker::Load() trying to GetClass(%s) case %d\n",className,
fCase);
273 klass = gROOT->GetClass(className);
275 if (! klass || klass->Size()==0) {
280 gSystem->Load(
"RTS");
281 gSystem->Load(
"StDaqLib");
284 gSystem->Load(
"StTrgDatFileReader");
286 if (
fCase==kStMuDst){
288 gSystem->Load(
"St_Tables");
289 gSystem->Load(
"StEmcUtil");
290 gSystem->Load(
"StStrangeMuDstMaker");
291 gSystem->Load(
"StMuDSTMaker");
293 if (! Loaded) gSystem->Load(className);
294 klass = gROOT->GetClass(className);
297 (void) printf(
"<StIOMaker::Load() className %s was not loaded\n",
305 assert(Mk->InheritsFrom(StIOInterFace::Class()));
314 Mk->SetDebug(GetDebug());
316 if (brs) brs->
Shunt(Mk);
317 int iret = Mk->Init();
318 return (iret) ? 0 : Mk;
Int_t fCase
for debug only
StIOInterFace * fCurrMk
next file from file set
Int_t fNIO
Main file name name.
TString fTreeName
r=read,w=write,u=update
virtual void Clear(Option_t *opt)
User defined functions.
virtual void SetIOMode(Option_t *iomode="w")
number of transactions
virtual void Clear(Option_t *option="")
User defined functions.
void Build(StFileI *fileSet, const char *ioFile, const char *treeName)
Int_t fSkip
case 1=root,2=xdf,3=mdc2,4=daq
virtual const char * GetName() const
special overload
virtual Int_t GetRunNumber() const
Returns the current RunNumber.
TString fNextFile
Chain of files.
Int_t fNumEvent
for debug only
virtual void Shunt(TDataSet *newParent=0)
virtual Int_t GetIventNumber() const
Returns the current event number.
Int_t fMaxEvent
Pointers to TreeMaker,xdfin_Maker,St_io_Maker,StDAQMaker.
StIOInterFace * fFmtMk[9]
Pointer to Current Maker.
virtual TDataSet * Find(const char *path) const