]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVGEN/AliGenExtFile.cxx
bugfix for correlated propagation of assymetric correlated uncertainty
[u/mrichter/AliRoot.git] / EVGEN / AliGenExtFile.cxx
index b2c5adc6012d264ea201c2a3d512cee31c30d255..17436d5fff8dfda86585ca09607e08bd62ef9bd2 100644 (file)
@@ -31,6 +31,7 @@
 
 #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";
@@ -80,7 +85,7 @@ void AliGenExtFile::Init()
     if (fReader) fReader->Init();
 }
 
-    
+//___________________________________________________________
 void AliGenExtFile::Generate()
 {
 // Generate particles
@@ -96,6 +101,22 @@ void AliGenExtFile::Generate()
   //
   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) {
@@ -192,6 +213,7 @@ void AliGenExtFile::Generate()
   CdEventFile();
 }
 
+//___________________________________________________________
 void AliGenExtFile::CdEventFile()
 {
 // CD back to the event file