#include <Riostream.h>
+#include "AliLog.h"
#include "AliGenExtFile.h"
#include "AliRunLoader.h"
#include "AliHeader.h"
#include <TTree.h>
+using std::cout;
+using std::endl;
ClassImp(AliGenExtFile)
AliGenExtFile::AliGenExtFile()
:AliGenMC(),
fFileName(0),
- fReader(0)
+ fReader(0),
+ fStartEvent(0)
{
// Constructor
//
// Read all particles
- fNpart =- 1;
+ fNpart = -1;
}
AliGenExtFile::AliGenExtFile(Int_t npart)
:AliGenMC(npart),
fFileName(0),
- fReader(0)
+ fReader(0),
+ fStartEvent(0)
{
// Constructor
fName = "ExtFile";
if (fReader) fReader->Init();
}
-
+//___________________________________________________________
void AliGenExtFile::Generate()
{
// Generate particles
//
if (fVertexSmear == kPerEvent) Vertex();
+ // Fast forward up to start Event
+ for (Int_t ie=0; ie<fStartEvent; ++ie ) {
+ Int_t nTracks = fReader->NextEvent();
+ if (nTracks == 0) {
+ // printf("\n No more events !!! !\n");
+ Warning("AliGenExtFile::Generate","\nNo more events in external file!!!\nLast event may be empty or incomplete.\n");
+ return;
+ }
+ for (Int_t i=0; i<nTracks; ++i) {
+ if (NULL == fReader->NextParticle())
+ AliFatal("Error while skipping tracks");
+ }
+ cout << "Skipping event " << ie << endl;
+ }
+ fStartEvent = 0; // do not skip events the second time
+
while(1) {
Int_t nTracks = fReader->NextEvent();
if (nTracks == 0) {
CdEventFile();
}
+//___________________________________________________________
void AliGenExtFile::CdEventFile()
{
// CD back to the event file