X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=EVGEN%2FAliGenHalo.cxx;h=d7d55249a2f7a1ef7c4c11858fe3f10397069c18;hb=9694d7f2817b7733f89029b205ce1215e023ad1c;hp=1789853515ea15785ce80e3854a8428f9b14939a;hpb=c321951cfac60908e3fbab1b42b128cb09ded1a7;p=u%2Fmrichter%2FAliRoot.git diff --git a/EVGEN/AliGenHalo.cxx b/EVGEN/AliGenHalo.cxx index 1789853515e..d7d55249a2f 100644 --- a/EVGEN/AliGenHalo.cxx +++ b/EVGEN/AliGenHalo.cxx @@ -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); +} + +