]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - THbtp/AliGenHBTprocessor.cxx
Update master to aliroot
[u/mrichter/AliRoot.git] / THbtp / AliGenHBTprocessor.cxx
index fe8257a32896b32e74b962179fa3164c81182cd3..6c7b8bfef4d5089730b7df1091369dd8af785f53 100644 (file)
 
 #include "AliGenHBTprocessor.h"
 
-#include <string.h>
-
-#include <TROOT.h>
-#include <TError.h>
-#include <TFile.h>
-#include <TTree.h>
 #include <TParticle.h>
 #include "THBTprocessor.h"
 
-#include "AliRun.h"
 #include "AliStack.h"
+#include "AliMC.h"
+#include "AliRun.h"
 #include "AliGenCocktailAfterBurner.h"
+#include "AliLog.h"
 
 
 
 ClassImp(AliGenHBTprocessor)
 
 Int_t AliGenHBTprocessor::fgDebug = 0;
-static TRandom* sRandom;
+static TRandom* gAliRandom;//RNG to be used by the fortran code
 
 AliGenCocktailAfterBurner*  GetGenerator();
 /*******************************************************************/
-AliGenHBTprocessor::AliGenHBTprocessor(const AliGenHBTprocessor& in):
- fEventMerge(1)
-{
-//copy contructor
-  // AliGenHBTprocessor::AliGenHBTprocessor();
-}
 
-AliGenHBTprocessor::AliGenHBTprocessor() : AliGenerator(), fEventMerge(1)
+AliGenHBTprocessor::AliGenHBTprocessor(): 
+  AliGenerator(), 
+  fHBTprocessor(0x0),
+  fHbtPStatCodes(0x0),
+  fNPDGCodes(0),
+  fTrackRejectionFactor(0),
+  fReferenceControl(0),
+  fPrintFull(0),
+  fPrintSectorData(0),
+  fNPidTypes(0),
+  fNevents(0),
+  fSwitch1d(0),
+  fSwitch3d(0),
+  fSwitchType(0),
+  fSwitchCoherence(0),
+  fSwitchCoulomb(0),
+  fSwitchFermiBose(0),
+  fEventLineCounter(0),
+  fMaxit(0),
+  fIrand(0),
+  fLambda(0),
+  fR1d(0),
+  fRside(0),
+  fRout(0),
+  fRlong(0),
+  fRperp(0),
+  fRparallel(0),
+  fR0(0),
+  fQ0(0),
+  fDeltap(0),
+  fDelchi(0),
+  fNPtBins(0),
+  fNPhiBins(0),
+  fNEtaBins(0),
+  fN1dFine(0),
+  fN1dCoarse(0),
+  fN1dTotal(0),
+  fN3dFine(0),
+  fN3dCoarse(0),
+  fN3dTotal(0),
+  fN3dFineProject(0),
+  fNPxBins(0),
+  fNPyBins(0),
+  fNPzBins(0),
+  fNSectors(0),
+  fPtBinSize(0),
+  fPhiBinSize(0),
+  fEtaBinSize(0),
+  fEtaMin(0),
+  fEtaMax(0),
+  fBinsize1dFine(0),
+  fBinsize1dCoarse(0),
+  fQmid1d(0),
+  fQmax1d(0),
+  fBinsize3dFine(0),
+  fBinsize3dCoarse(0),
+  fQmid3d(0),
+  fQmax3d(0),
+  fPxMin(0),
+  fPxMax(0),
+  fDelpx(0),
+  fPyMin(0),
+  fPyMax(0),
+  fDelpy(0),
+  fPzMin(0),
+  fPzMax(0),
+  fDelpz(0),
+  fEventMerge(1),
+  fActiveStack(0)
 {
   //
   // Standard constructor
   // Sets default veues of all parameters
-  fHbtPStatCodes = 0x0;
-  fHBTprocessor = 0x0;
 
   SetName("AliGenHBTprocessor");
   SetTitle("AliGenHBTprocessor");
   
-  sRandom = fRandom;
+  gAliRandom = fRandom;
   fHBTprocessor = new THBTprocessor();
 
   fNPDGCodes = 0;
@@ -185,7 +241,10 @@ void AliGenHBTprocessor::InitStatusCodes()
  //creates and inits status codes array to zero
   AliGenCocktailAfterBurner *cab = GetGenerator();
 
-  if(!cab) Fatal("InitStatusCodes()","Can not find AliGenCocktailAfterBurner generator");
+  if(!cab) {
+    Fatal("InitStatusCodes()","Can not find AliGenCocktailAfterBurner generator");
+    return;
+  }
 
   Int_t nev = cab->GetNumberOfEvents();
 
@@ -209,7 +268,7 @@ void AliGenHBTprocessor::CleanStatusCodes()
   {
     for (Int_t i =0; i<GetGenerator()->GetNumberOfEvents(); i++)
       delete [] fHbtPStatCodes[i];  
-    delete fHbtPStatCodes;
+    delete [] fHbtPStatCodes;
     fHbtPStatCodes = 0;
   }
 
@@ -301,6 +360,7 @@ void AliGenHBTprocessor::Generate()
    if (cab == 0x0)
     {
       Fatal("Generate()","AliGenHBTprocessor needs AliGenCocktailAfterBurner to be main generator");
+      return;
     }
    if (cab->GetNumberOfEvents() <2)
     {
@@ -667,7 +727,7 @@ void AliGenHBTprocessor::SetPzRange(Float_t pzmin, Float_t pzmax)
    fPzMax =pzmax; 
    fHBTprocessor->SetPzRange(pzmin,pzmax);
  }
-void AliGenHBTprocessor::SetMomentumRange(Float_t pmin, Float_t pmax)
+void AliGenHBTprocessor::SetMomentumRange(Float_t /*pmin*/, Float_t /*pmax*/)
  {
  //default pmin=0, pmax=0
  //Do not use this method!
@@ -843,6 +903,7 @@ void AliGenHBTprocessor::SetNBins3DFineProjectMesh(Int_t n )
 /*******************************************************************/
 void AliGenHBTprocessor::SetPrintFull(Int_t flag)
 {
+//sets the print full flag
  fPrintFull = flag;
  fHBTprocessor->SetPrintFull(flag);
 }
@@ -852,7 +913,8 @@ void AliGenHBTprocessor::SetPrintFull(Int_t flag)
 
 Int_t  AliGenHBTprocessor::GetNumberOfEvents()
 {
-  AliGenerator* g = gAlice->Generator();
+//returns number of available events
+  AliGenerator* g = gAlice->GetMCApp()->Generator();
   AliGenCocktailAfterBurner* cab = (g)?dynamic_cast<AliGenCocktailAfterBurner*>(g):0x0;
   if (cab == 0x0)
    {
@@ -866,16 +928,16 @@ Int_t  AliGenHBTprocessor::GetNumberOfEvents()
 
 void AliGenHBTprocessor::SetActiveEventNumber(Int_t n)
 {
+//sets the active event
  fActiveStack =  n*fEventMerge;
- if (fgDebug)
-  Info("SetActiveEventNumber","Settimg active event %d passed %d",
-        fActiveStack,n);
+ AliDebug(1,Form("Settimg active event %d passed %d",fActiveStack,n));
 }
 /*******************************************************************/
 
 Int_t  AliGenHBTprocessor::GetNumberOfTracks()
 {
-  AliGenerator* g = gAlice->Generator();
+//returns number of tracks in active event
+  AliGenerator* g = gAlice->GetMCApp()->Generator();
   AliGenCocktailAfterBurner* cab = (g)?dynamic_cast<AliGenCocktailAfterBurner*>(g):0x0;
   if (cab == 0x0)
    {
@@ -887,9 +949,10 @@ Int_t  AliGenHBTprocessor::GetNumberOfTracks()
   { 
     if (i >= GetNumberOfEvents()) break; //protection not to overshoot nb of events
     AliStack* stack = cab->GetStack(i);
-    if (stack == 0x0)
+    if (stack == 0x0) {
      Error("GetNumberOfTracks","There is no stack %d",i);
-
+     continue;
+    }
     n+=stack->GetNprimary();
   }
  return n;
@@ -898,6 +961,7 @@ Int_t  AliGenHBTprocessor::GetNumberOfTracks()
 
 void AliGenHBTprocessor::SetNEventsToMerge(Int_t nev)
 {
+ //sets number of events to merge
  if (nev > 0 ) fEventMerge = nev;
 }
 /*******************************************************************/
@@ -905,8 +969,8 @@ void AliGenHBTprocessor::SetNEventsToMerge(Int_t nev)
 TParticle* AliGenHBTprocessor::GetTrack(Int_t n)
 { 
 //returns track that hbtp thinks is n in active event
-  if (fgDebug > 5) Info("GetTrack","n = %d",n);
-  AliGenerator* g = gAlice->Generator();
+  AliDebug(5,Form("n = %d",n));
+  AliGenerator* g = gAlice->GetMCApp()->Generator();
   AliGenCocktailAfterBurner* cab = (g)?dynamic_cast<AliGenCocktailAfterBurner*>(g):0x0;
   if (cab == 0x0)
    {
@@ -916,13 +980,13 @@ TParticle* AliGenHBTprocessor::GetTrack(Int_t n)
 
  Int_t ev, idx;
  GetTrackEventIndex(n,ev,idx);
if (fgDebug > 5) Info("GetTrack","Event = %d Particle = %d",ev,idx);
AliDebug(5,Form("Event = %d Particle = %d",ev,idx));
  if ( (ev<0) || (idx<0) )
   {
     Error("GetTrack","GetTrackEventIndex returned error");
     return 0x0;
   }
if (fgDebug > 5) Info("GetTrack","Number of Tracks in Event(%d) = %d",ev,cab->GetStack(ev)->GetNprimary());
AliDebug(5,Form("Number of Tracks in Event(%d) = %d",ev,cab->GetStack(ev)->GetNprimary()));
  return cab->GetStack(ev)->Particle(idx);//safe - in case stack does not exist 
 }
 /*******************************************************************/
@@ -930,7 +994,7 @@ TParticle* AliGenHBTprocessor::GetTrack(Int_t n)
 void AliGenHBTprocessor::GetTrackEventIndex(Int_t n, Int_t &evno, Int_t &index) const
 {
  //returns event(stack) number and particle index
-  AliGenerator* g = gAlice->Generator();
+  AliGenerator* g = gAlice->GetMCApp()->Generator();
   AliGenCocktailAfterBurner* cab = (g)?dynamic_cast<AliGenCocktailAfterBurner*>(g):0x0;
   if (cab == 0x0)
    {
@@ -950,7 +1014,7 @@ void AliGenHBTprocessor::GetTrackEventIndex(Int_t n, Int_t &evno, Int_t &index)
      }
 
     Int_t ntracks = stack->GetNprimary();
-    if (fgDebug > 10) Info("GetTrackEventIndex","Event %d has %d tracks. n = %d",i,ntracks,n);
+    AliDebug(10,Form("Event %d has %d tracks. n = %d",i,ntracks,n));
     
     if ( ntracks > n) 
      {
@@ -1097,7 +1161,7 @@ AliGenCocktailAfterBurner*  GetGenerator()
               "Running HBT Processor without gAlice... Exiting \n");
       return 0x0;//pro forma
     }
-   AliGenerator * gen = gAlice->Generator();
+   AliGenerator * gen = gAlice->GetMCApp()->Generator();
    
    if (!gen) 
     {
@@ -1166,15 +1230,15 @@ extern "C" void type_ofCall  alihbtp_initialize()
 
 extern "C" void type_ofCall alihbtp_getnumberevents(Int_t &nev)
  {
-  //passes number of events to the fortran 
-   if(AliGenHBTprocessor::fgDebug
-    ::Info("AliGenHBTprocessor.cxx: alihbtp_getnumberevents","(%d) ....",nev);
+   //passes number of events to the fortran 
+   if(AliGenHBTprocessor::GetDebug()
+    AliInfoGeneral("alihbtp_getnumberevents",Form("(%d) ....",nev));
 
    AliGenHBTprocessor* gen = GetAliGenHBTprocessor();//we dont check because it is done in function
    nev = gen->GetNumberOfEvents();
     
-   if(AliGenHBTprocessor::fgDebug>5) 
-    ::Info("AliGenHBTprocessor.cxx: alihbtp_getnumberevents","EXITED N Ev = %d",nev);
+   if(AliGenHBTprocessor::GetDebug()>5) 
+    AliInfoGeneral("alihbtp_getnumberevents",Form("EXITED N Ev = %d",nev));
  }
 
 /*******************************************************************/
@@ -1183,16 +1247,16 @@ extern "C" void type_ofCall  alihbtp_setactiveeventnumber(Int_t & nev)
  {
 //sets active event in generator (AliGenCocktailAfterBurner)
 
-   if(AliGenHBTprocessor::fgDebug>5) 
+   if(AliGenHBTprocessor::GetDebug()>5) 
     ::Info("AliGenHBTpocessor.cxx: alihbtp_setactiveeventnumber","(%d)",nev);
-   if(AliGenHBTprocessor::fgDebug>0)
+   if(AliGenHBTprocessor::GetDebug()>0)
     ::Info("AliGenHBTpocessor.cxx: alihbtp_setactiveeventnumber","Asked for event %d",nev-1);
     
    AliGenHBTprocessor* gen = GetAliGenHBTprocessor();//we dont check because it is done in function
    
    gen->SetActiveEventNumber(nev - 1); //fortran numerates events from 1 to N
    
-   if(AliGenHBTprocessor::fgDebug>5) 
+   if(AliGenHBTprocessor::GetDebug()>5) 
     ::Info("AliGenHBTpocessor.cxx: alihbtp_setactiveeventnumber","EXITED returned %d",nev);
  }
 /*******************************************************************/
@@ -1200,13 +1264,13 @@ extern "C" void type_ofCall  alihbtp_setactiveeventnumber(Int_t & nev)
 extern "C" void type_ofCall  alihbtp_getnumbertracks(Int_t &ntracks)
  {
 //passes number of particles in active event to the fortran  
-   if(AliGenHBTprocessor::fgDebug>5) 
+   if(AliGenHBTprocessor::GetDebug()>5) 
     ::Info("AliGenHBTpocessor.cxx: alihbtp_getnumbertracks","(%d)",ntracks);
 
    AliGenHBTprocessor* gen = GetAliGenHBTprocessor();//we dont check because it is done in function
 
    ntracks = gen->GetNumberOfTracks();
-   if(AliGenHBTprocessor::fgDebug>5)
+   if(AliGenHBTprocessor::GetDebug()>5)
     ::Info("AliGenHBTpocessor.cxx: alihbtp_getnumbertracks","EXITED Ntracks = %d",ntracks); 
  }
  
@@ -1223,7 +1287,7 @@ extern "C" void type_ofCall
 // px,py,pz - momenta
 // geantpid - type of the particle - Geant Particle ID
  
-   if(AliGenHBTprocessor::fgDebug>5)
+   if(AliGenHBTprocessor::GetDebug()>5)
     ::Info("AliGenHBTpocessor.cxx: alihbtp_puttrack","(%d)",n);
 
    AliGenHBTprocessor* gen = GetAliGenHBTprocessor();//we dont check because it is done in function
@@ -1242,12 +1306,12 @@ extern "C" void type_ofCall
               "SOMETHING IS GOING BAD:\n   GEANTPIDS ARE NOT THE SAME");
     }
    
-   if(AliGenHBTprocessor::fgDebug>0)
+   if(AliGenHBTprocessor::GetDebug()>0)
      if (px != track->Px()) 
        ::Info("AliGenHBTprocessor.cxx: alihbtp_puttrack",
               "Px diff. = %f", px - track->Px());
    
-   if(AliGenHBTprocessor::fgDebug>3)
+   if(AliGenHBTprocessor::GetDebug()>3)
      ::Info("AliGenHBTprocessor.cxx: alihbtp_puttrack",
             "track->GetPdgCode() --> %d",track->GetPdgCode());
    
@@ -1259,7 +1323,7 @@ extern "C" void type_ofCall
    
    gen->SetHbtPStatusCode(flag,n-1);
    
-   if(AliGenHBTprocessor::fgDebug>5) ::Info("AliGenHBTprocessor.cxx: alihbtp_puttrack","EXITED ");
+   if(AliGenHBTprocessor::GetDebug()>5) ::Info("AliGenHBTprocessor.cxx: alihbtp_puttrack","EXITED ");
  }
 
 /*******************************************************************/
@@ -1275,7 +1339,7 @@ extern "C" void type_ofCall
 // px,py,pz - momenta
 // geantpid - type of the particle - Geant Particle ID
  
-   if(AliGenHBTprocessor::fgDebug>5) ::Info("AliGenHBTprocessor.cxx: alihbtp_gettrack","(%d)",n);
+   if(AliGenHBTprocessor::GetDebug()>5) ::Info("AliGenHBTprocessor.cxx: alihbtp_gettrack","(%d)",n);
    AliGenHBTprocessor* g = GetAliGenHBTprocessor();
 
    TParticle * track = g->GetTrack(n-1);
@@ -1288,14 +1352,14 @@ extern "C" void type_ofCall
   
    geantpid = g->IdFromPDG( track->GetPdgCode() );
   
-   if(AliGenHBTprocessor::fgDebug>5) ::Info("AliGenHBTprocessor.cxx: alihbtp_gettrack","EXITED"); 
+   if(AliGenHBTprocessor::GetDebug()>5) ::Info("AliGenHBTprocessor.cxx: alihbtp_gettrack","EXITED"); 
  }
 
 /*******************************************************************/
 extern "C" Float_t type_ofCall hbtpran(Int_t &)
 {
 //interface to the random number generator
-  return sRandom->Rndm();
+  return gAliRandom->Rndm();
 }        
 
 /*******************************************************************/