]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVGEN/AliGenHalo.cxx
Driver macro for calculating Et em corrections
[u/mrichter/AliRoot.git] / EVGEN / AliGenHalo.cxx
index 1789853515ea15785ce80e3854a8428f9b14939a..d7d55249a2f7a1ef7c4c11858fe3f10397069c18 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "AliGenHalo.h"
 #include "AliRun.h"
+#include "AliLog.h"
 
 ClassImp(AliGenHalo)
 
@@ -124,6 +125,7 @@ void AliGenHalo::Init()
        printf("\n File %s opened for reading, %p ! \n ",  fFileName.Data(), (void*)fFile);
     } else {
        printf("\n Opening of file %s failed,  %p ! \n ",  fFileName.Data(), (void*)fFile);
+       return;
     }
 
     if (fNskip > 0) {
@@ -156,8 +158,14 @@ void AliGenHalo::Init()
        Fatal("Init()", "No gas pressure file for given run period !");
     }
 
-
-    FILE* file = fopen(name, "r");
+    
+    FILE* file = 0;
+    if (name) file = fopen(name, "r");
+    if (!file) {
+       AliError("No gas pressure file");
+       return;
+    }
+    
     Float_t z;
     Int_t i;
     Float_t p[5];    
@@ -240,6 +248,7 @@ void AliGenHalo::Init()
     sum1/=250.;
     sum2/=250.;
     printf("\n %f %f \n \n", sum1, sum2);
+    delete file;
 }
 
 //____________________________________________________________
@@ -267,8 +276,8 @@ void AliGenHalo::Generate()
       mass = TDatabasePDG::Instance()->GetParticle(fPdg)->Mass();
       p0  = TMath::Sqrt(fEkin * fEkin + 2. * mass * fEkin);
       txy = TMath::Sqrt(fDX * fDX + fDY * fDY);
-      if (txy == 1.) {
-         tz = 0;
+      if (txy > 1.) {
+         tz = 0.;
       } else {
          tz = - TMath::Sqrt(1. - txy);
       }
@@ -381,3 +390,24 @@ void AliGenHalo::SkipEvents()
       }
     } 
 }
+void AliGenHalo::CountEvents()
+{
+    // Count total number of events
+    Int_t nev = 0;
+    Int_t oldID = -1;
+    Int_t nc = 1;
+    while (nc != -1)
+    {
+       nc = ReadNextParticle();
+       if (oldID != fLossID) {
+           oldID = fLossID;
+           nev++;
+           printf("Number of events %10d %10d \n", nev, oldID);
+       }
+    }
+
+
+    rewind(fFile);
+}
+
+