]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Possibility to skip the first n events in a file.
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 27 Jan 2010 10:14:59 +0000 (10:14 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 27 Jan 2010 10:14:59 +0000 (10:14 +0000)
EVGEN/AliGenHalo.cxx
EVGEN/AliGenHalo.h

index db799a4271b793b835285f222ab50e0c51e9ab0f..1789853515ea15785ce80e3854a8428f9b14939a 100644 (file)
@@ -125,6 +125,11 @@ void AliGenHalo::Init()
     } else {
        printf("\n Opening of file %s failed,  %p ! \n ",  fFileName.Data(), (void*)fFile);
     }
+
+    if (fNskip > 0) {
+      // Skip the first fNskip events
+      SkipEvents();
+    }
 //
 //
 //
@@ -252,24 +257,22 @@ void AliGenHalo::Generate()
   static Bool_t first = kTRUE;
   static Int_t  oldID = -1;
 //
-  if (first) {
-      ReadNextParticle();
-      first = kFALSE;
-      oldID = fLossID;
-  }
-  
-  
+
+  if (first && (fNskip == 0)) ReadNextParticle();
+  first = kFALSE;
+  oldID = fLossID;
   
   while(1) {
       // Push particle to stack
       mass = TDatabasePDG::Instance()->GetParticle(fPdg)->Mass();
-      p0  = TMath::Sqrt(fEkin * fEkin + 2.* mass * fEkin);
+      p0  = TMath::Sqrt(fEkin * fEkin + 2. * mass * fEkin);
       txy = TMath::Sqrt(fDX * fDX + fDY * fDY);
       if (txy == 1.) {
          tz = 0;
       } else {
          tz = - TMath::Sqrt(1. - txy);
       }
       p[0] =  p0 * fDX;
       p[1] =  p0 * fDY;
       p[2] =  p0 * tz;
@@ -279,7 +282,7 @@ void AliGenHalo::Generate()
       origin[2] = 1950.;
 
       PushTrack(fTrackIt , -1, fPdg , p, origin, polar, fTS - 1950./2.9979e10, kPNoProcess, nt, fWS);
-
+      
       Int_t nc = ReadNextParticle();
       
       if (fLossID != oldID || nc == 0) {
@@ -361,3 +364,20 @@ Int_t AliGenHalo::ReadNextParticle()
     fTS    *= 1.e-9;
     return (ncols);
 }
+
+void AliGenHalo::SkipEvents()
+{
+  //
+  // Skip the first fNskip events
+  Int_t skip = fNskip;
+  Int_t oldID = -1;
+
+  while (skip >= 0)
+    {
+      ReadNextParticle();
+      if (oldID != fLossID) {
+       oldID = fLossID;
+       skip--;
+      }
+    } 
+}
index b71e396a5cb0bc63cbf4efb44e4d9880fe5cdb30..72fbf3bcc2429e812bc850d8ac1d92a3067965c9 100644 (file)
@@ -32,6 +32,7 @@ public:
     virtual void SetTimePerEvent(Float_t t = 1.e-4) {fTimePerEvent = t;}
     virtual void Draw(Option_t * opt="");
  private:
+    virtual void  SkipEvents();
     virtual Int_t ReadNextParticle();
  protected:
     FILE*    fFile;                       // ! Pointer to file