/* $Id$ */
+#include <TROOT.h>
+#include <TFile.h>
+#include <TObjString.h>
+
+#include "AliLog.h"
+#include "AliLoader.h"
+#include "AliRun.h"
+#include "AliStream.h"
+
////////////////////////////////////////////////////////////////////////
//
// AliStream.cxx
// - open and close files
// - return serial event number of the next event in the stream
// and the TFile pointer for a proper file
+// Author: Jiri Chudoba (CERN), 2001
//
////////////////////////////////////////////////////////////////////////
-#include <Riostream.h>
-
-#include "TTree.h"
-#include "TROOT.h"
-
-#include "AliStream.h"
-#include "AliRun.h"
-
-#include "TObjString.h"
-#include "TArrayI.h"
-#include "TClonesArray.h"
-#include "TFile.h"
-#include "AliLoader.h"
-
ClassImp(AliStream)
AliStream::AliStream():
fFileNames(0x0),
fEventFolderName(0)
{
-// root requires default ctor, where no new objects can be created
-// do not use this ctor, it is supplied only for root needs
+ // root requires default ctor, where no new objects can be created
+ // do not use this ctor, it is supplied only for root needs
}
//_______________________________________________________________________
}
//_______________________________________________________________________
+AliStream::AliStream(const AliStream &as):
+ TNamed(as),
+ fLastEventSerialNr(-1),
+ fLastEventNr(0),
+ fCurrentFileIndex(-1),
+ fEvents(0),
+ fMode(0),
+ fFileNames(0x0),
+ fEventFolderName(" ")
+{
+ //
+ // Copy ctor
+ //
+ as.Copy(*this);
+}
+//_______________________________________________________________________
+
AliStream::~AliStream()
{
// default dtor
}
//_______________________________________________________________________
+void AliStream::Copy(TObject &) const
+{
+ //
+ // Copy function
+ //
+ AliFatal("Not implemented!");
+}
+//_______________________________________________________________________
+
void AliStream::AddFile(const char *fileName)
{
// stores the name of the file
AliRunLoader* currentloader = AliRunLoader::GetRunLoader(fEventFolderName);
if (currentloader == 0x0)
{
- Info("NextEventInStream",
+ AliDebug(1, Form(
"Can not get RL from folder named %s. Attempting to open next file",
- fEventFolderName.Data());
+ fEventFolderName.Data()));
Int_t res = OpenNextFile();
if ( res == 0) return kFALSE;
currentloader = AliRunLoader::GetRunLoader(fEventFolderName);
{
if (!OpenNextFile()) return kFALSE;
}
- Info("NextEventInStream","Trying to get event ",fLastEventSerialNr+1);
+ AliDebug(1, Form("Trying to get event %d",fLastEventSerialNr+1));
currentloader->GetEvent(++fLastEventSerialNr);
return kTRUE;
}
//_______________________________________________________________________
void AliStream::ChangeMode(Option_t* option)
-// set the mode to READ or UPDATE, reopen file with the new mode
-// only change from UPDATE to READ have sense in the current scheme,
-// other changes are possible but not usefull
{
+ // set the mode to READ or UPDATE, reopen file with the new mode
+ // only change from UPDATE to READ have sense in the current scheme,
+ // other changes are possible but not usefull
fMode = option;
AliRunLoader* currentloader = AliRunLoader::GetRunLoader(fEventFolderName);
Bool_t AliStream::OpenNextFile()
{
+ //
+ // Opens next file in the list
+ //
if (++fCurrentFileIndex > fFileNames->GetLast()) {
- cerr<<"No more files in the stream"<<endl;
+ AliInfo("No more files in the stream") ;
return kFALSE;
}
if (currentloader == 0x0)
{
// cannot open file specified on input. Do not skip it silently.
- cerr<<"Cannot open session "<<filename<<endl;
+ AliError("Cannot open session ");
return kFALSE;
}
Int_t res = currentloader->LoadHeader();
if (res)
{
- Error("OpenNextFile","Problems with loading header");
+ AliError("Problems with loading header");
return kFALSE;
}
fEvents = static_cast<Int_t>(currentloader->TreeE()->GetEntries());
Bool_t AliStream::ImportgAlice()
{
+ //
+ // Imports gAlice object from file
+ //
if (fFileNames->GetLast() < 0) return kFALSE;
AliRunLoader* currentloader = AliRunLoader::GetRunLoader(fEventFolderName);
}
//_______________________________________________________________________
-TString AliStream::GetFileName(const Int_t order) const
-// returns name of the order-th file
-// returns empty string if such file does not exist
-// first file in the input stream is 0
+TString AliStream::GetFileName(Int_t order) const
{
+ // returns name of the order-th file
+ // returns empty string if such file does not exist
+ // first file in the input stream is 0
TString fileName("");
if (order > fFileNames->GetLast()) return fileName;
TObjString *fileNameStored = dynamic_cast<TObjString*>(fFileNames->At(order));