]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliGenerator.cxx
Removing warnings (icc)
[u/mrichter/AliRoot.git] / STEER / AliGenerator.cxx
index 3be5217074924128b184f6c32e8524b6003361ec..507a2849cd4166fc0142123067734563c66aba91 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.11  2001/01/26 19:58:48  hristov
-Major upgrade of AliRoot code
-
-Revision 1.10  2000/12/21 15:30:18  fca
-Correcting coding convention violations
-
-Revision 1.9  2000/10/04 10:08:01  fca
-Correction of minor typing mistakes
-
-Revision 1.8  2000/10/02 21:28:14  fca
-Removal of useless dependecies via forward declarations
-
-Revision 1.7  2000/07/12 08:56:25  fca
-Coding convention correction and warning removal
-
-Revision 1.6  2000/07/11 18:24:59  fca
-Coding convention corrections + few minor bug fixes
-
-Revision 1.5  2000/06/08 13:34:50  fca
-Better control of momentum range in GenBox
-
-Revision 1.4  1999/09/29 09:24:29  fca
-Introduction of the Copyright and cvs Log
+/* $Id$ */
 
-*/
-
-///////////////////////////////////////////////////////////////////
-//                                                               //
-//    Generate the final state of the interaction as the input   //
-//    to the MonteCarlo                                          //
-//
+//-----------------------------------------------------------------
+//    Generate the final state of the interaction as the input
+//    to the MonteCarlo
+//    Author: A.Morsch
+//-----------------------------------------------------------------
 //Begin_Html
 /*
 <img src="picts/AliGeneratorClass.gif">
@@ -60,25 +34,57 @@ Introduction of the Copyright and cvs Log
 //End_Html
 //                                                               //
 ///////////////////////////////////////////////////////////////////
+#include <TGenerator.h>
 
+#include "AliCollisionGeometry.h"
+#include "AliConfig.h"
 #include "AliGenerator.h"
-#include "TGenerator.h"
 #include "AliRun.h"
+#include "AliStack.h"
+#include "AliMC.h"
 
 ClassImp(AliGenerator)
 
-TGenerator* AliGenerator::fgMCEvGen=0;
 
-//____________________________________________________________
-AliGenerator::AliGenerator()
+//_______________________________________________________________________
+AliGenerator::AliGenerator():
+  fMCEvGen(0),
+  fThetaMin(0),
+  fThetaMax(0),
+  fPhiMin(0),
+  fPhiMax(0),
+  fPMin(0),
+  fPMax(0),
+  fPtMin(0),
+  fPtMax(0),
+  fYMin(0),
+  fYMax(0),
+  fVMin(3),
+  fVMax(3),
+  fNpart(0),
+  fParentWeight(0),
+  fChildWeight(0),
+  fAnalog(0),
+  fVertexSmear(kNoSmear),
+  fVertexSource(kInternal),
+  fCutVertexZ(0),
+  fTrackIt(0),
+  fOrigin(3),
+  fOsigma(3),
+  fVertex(3),
+  fStack(0),
+  fCollisionGeometry(0)
 {
   //
   // Default constructor
   //
-    if (gAlice->GetDebug()>0)
-        printf("\n AliGenerator Default Constructor\n\n");
-    
-    gAlice->SetGenerator(this);
+    if (gAlice) {
+       if (gAlice->GetDebug()>0)
+           printf("\n AliGenerator Default Constructor\n\n");
+       AliMC * mc = gAlice->GetMCApp();
+       if (mc) mc->SetGenerator(this);
+    }
+
     SetThetaRange(); ResetBit(kThetaRange);
     SetPhiRange(); ResetBit(kPhiRange);
     SetMomentumRange(); ResetBit(kMomentumRange);
@@ -86,56 +92,105 @@ AliGenerator::AliGenerator()
     SetYRange(); ResetBit(kYRange);
     SetNumberParticles();
     SetTrackingFlag();
+    SetCutVertexZ();
 
-    fOrigin.Set(3);
-    fOsigma.Set(3);
-    fVertex.Set(3);
 
     fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
     fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
     fVertex[0]=fVertex[1]=fVertex[2]=0;
 
-    fVMin.Set(3);
     fVMin[0]=fVMin[1]=fVMin[2]=0;
-    fVMax.Set(3);
     fVMax[0]=fVMax[1]=fVMax[2]=10000;
 }
 
-//____________________________________________________________
-AliGenerator::AliGenerator(Int_t npart)
-    : TNamed(" "," ")
+//_______________________________________________________________________
+AliGenerator::AliGenerator(Int_t npart):
+  fMCEvGen(0),
+  fThetaMin(0),
+  fThetaMax(0),
+  fPhiMin(0),
+  fPhiMax(0),
+  fPMin(0),
+  fPMax(0),
+  fPtMin(0),
+  fPtMax(0),
+  fYMin(0),
+  fYMax(0),
+  fVMin(3),
+  fVMax(3),
+  fNpart(0),
+  fParentWeight(0),
+  fChildWeight(0),
+  fAnalog(0),
+  fVertexSmear(kNoSmear),
+  fVertexSource(kInternal),
+  fCutVertexZ(0),
+  fTrackIt(0),
+  fOrigin(3),
+  fOsigma(3),
+  fVertex(3),
+  fStack(0),
+  fCollisionGeometry(0)
 {
   //
   // Standard constructor
   //
-    if (gAlice->GetDebug()>0)
-        printf("\n AliGenerator Constructor initializing number of particles \n\n");
-    gAlice->SetGenerator(this);
+    if (gAlice) {
+       if (gAlice->GetDebug()>0)
+           printf("\n AliGenerator Constructor initializing number of particles \n\n");
+       AliMC * mc = gAlice->GetMCApp();
+       if (mc) mc->SetGenerator(this);
+    }
+    
     SetThetaRange(); ResetBit(kThetaRange);
     SetPhiRange(); ResetBit(kPhiRange);
     SetMomentumRange(); ResetBit(kMomentumRange);
     SetPtRange(); ResetBit(kPtRange);
     SetYRange(); ResetBit(kYRange);
     SetTrackingFlag();
-
-    fOrigin.Set(3);
-    fOsigma.Set(3);
-    fVertex.Set(3);
+    SetCutVertexZ();
 
     fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
     fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
     fVertex[0]=fVertex[1]=fVertex[2]=0;
 
-    fVMin.Set(3);
     fVMin[0]=fVMin[1]=fVMin[2]=0;
-    fVMax.Set(3);
     fVMax[0]=fVMax[1]=fVMax[2]=10000;
 
     SetNumberParticles(npart);
+
+    AliConfig::Instance()->Add(this);
 }
 
-//____________________________________________________________
-AliGenerator::AliGenerator(const AliGenerator &gen) : TNamed(" "," ")
+//_______________________________________________________________________
+AliGenerator::AliGenerator(const AliGenerator &gen): 
+  TNamed(gen),
+  AliRndm(gen),
+  fMCEvGen(0),
+  fThetaMin(0),
+  fThetaMax(0),
+  fPhiMin(0),
+  fPhiMax(0),
+  fPMin(0),
+  fPMax(0),
+  fPtMin(0),
+  fPtMax(0),
+  fYMin(0),
+  fYMax(0),
+  fVMin(3),
+  fVMax(3),
+  fNpart(0),
+  fParentWeight(0),
+  fChildWeight(0),
+  fAnalog(0),
+  fVertexSmear(kNoSmear),
+  fVertexSource(kInternal),
+  fCutVertexZ(0),
+  fTrackIt(0),
+  fOrigin(3),
+  fOsigma(3),
+  fVertex(3),
+  fStack(0)
 {
   //
   // Copy constructor
@@ -143,7 +198,7 @@ AliGenerator::AliGenerator(const AliGenerator &gen) : TNamed(" "," ")
   gen.Copy(*this);
 }
 
-//____________________________________________________________
+//_______________________________________________________________________
 AliGenerator & AliGenerator::operator=(const AliGenerator &gen)
 {
   //
@@ -153,8 +208,8 @@ AliGenerator & AliGenerator::operator=(const AliGenerator &gen)
   return (*this);
 }
 
-//____________________________________________________________
-void AliGenerator::Copy(AliGenerator &/* gen */) const
+//_______________________________________________________________________
+void AliGenerator::Copy(TObject &/* gen */) const
 {
   //
   // Copy *this onto gen
@@ -162,7 +217,7 @@ void AliGenerator::Copy(AliGenerator &/* gen */) const
   Fatal("Copy","Not implemented!\n");
 }
 
-//____________________________________________________________
+//_______________________________________________________________________
 AliGenerator::~AliGenerator()
 {
   //
@@ -170,9 +225,13 @@ AliGenerator::~AliGenerator()
   //
   fOrigin.Set(0);
   fOsigma.Set(0);
-  delete fgMCEvGen;
+  if (fMCEvGen) {
+    delete fMCEvGen;
+    fMCEvGen=0;
+  }
 }
 
+//_______________________________________________________________________
 void AliGenerator::Init()
 {   
   //
@@ -242,7 +301,8 @@ void AliGenerator::SetPhiRange(Float_t phimin, Float_t phimax)
   // Set the Phi range for the generated particles
   //
   fPhiMin = TMath::Pi()*phimin/180;
-  fPhiMax = TMath::Pi()*phimax/180; SetBit(kPhiRange);
+  fPhiMax = TMath::Pi()*phimax/180;
+  SetBit(kPhiRange);
 }
 
 //_______________________________________________________________________
@@ -276,7 +336,8 @@ void AliGenerator::SetThetaRange(Float_t thetamin, Float_t thetamax)
   // Set the theta range for the generated particles
   //
   fThetaMin = TMath::Pi()*thetamin/180;
-  fThetaMax = TMath::Pi()*thetamax/180; SetBit(kThetaRange);
+  fThetaMax = TMath::Pi()*thetamax/180;
+  SetBit(kThetaRange);
 }
 
 void AliGenerator::Vertex()
@@ -286,12 +347,14 @@ void AliGenerator::Vertex()
   //
     if (fVertexSource == kInternal) {
        VertexInternal();
-    } else {
+    } else if (fVertexSource == kContainer) {
+       ;
+    } else if (fVertexSource == kExternal) {
        VertexExternal();
     }
 }
 
-
+//_______________________________________________________________________
 void AliGenerator::VertexExternal()
 {
     // Dummy !!!!!!
@@ -302,18 +365,96 @@ void AliGenerator::VertexExternal()
     fVertex[0]=fVertex[1]=fVertex[2]=0;  
 }
 
+//_______________________________________________________________________
 void AliGenerator::VertexInternal()
 {
     // 
     // Obtain calculated vertex 
     // Default is gaussian smearing
     Float_t random[6];
-    Rndm(random,6);
-    for (Int_t j = 0; j<3 ; j++) {
-       fVertex[j]=
-           fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
-           TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
+    Float_t dv[3];
+    Int_t j;
+    dv[2] = 1.e10;
+    if (!TestBit(kVertexRange)) {
+       while(TMath::Abs(dv[2]) > fCutVertexZ*fOsigma[2]) {
+           Rndm(random,6);
+           for (j=0; j < 3; j++) {
+               dv[j] = fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
+                   TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
+           }
+       }
+       for (j=0; j < 3; j++) fVertex[j] = fOrigin[j] + dv[j];
+    } else {
+       Rndm(random,3);
+       for (j=0; j < 3; j++)
+           fVertex[j] =  fVMin[j] + random[j] * (fVMax[j] - fVMin[j]);
     }
 }
 
+//_______________________________________________________________________
+void  AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
+                               Float_t *pmom, Float_t *vpos, Float_t *polar,
+                               Float_t tof, TMCProcess mech, Int_t &ntr,
+                               Float_t weight, Int_t is)
+{
+  //
+  // Loads one track on the stack
+  //
+
+  if (fStack)
+    fStack->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
+                     mech, ntr, weight, is);
+  else 
+    gAlice->GetMCApp()->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
+                     mech, ntr, weight, is);
+}
+
+//_______________________________________________________________________
+void  AliGenerator::PushTrack(Int_t done, Int_t parent, Int_t pdg,
+                      Double_t px, Double_t py, Double_t pz, Double_t e,
+                      Double_t vx, Double_t vy, Double_t vz, Double_t tof,
+                      Double_t polx, Double_t poly, Double_t polz,
+                      TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
+{
+  //
+  // Loads one track on the stack
+  //
+  
+  if (fStack)
+     fStack->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
+                      polx, poly, polz, mech, ntr, weight, is);
+  else 
+     gAlice->GetMCApp()->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
+                        polx, poly, polz, mech, ntr, weight, is);
+}
+
+
+//_______________________________________________________________________
+void AliGenerator:: KeepTrack(Int_t itrack)
+{
+  //
+  // Declare a track permanent on the stack
+  //
+  if (fStack)
+     fStack->KeepTrack(itrack);
+  else 
+     gAlice->GetMCApp()->KeepTrack(itrack);
+   
+}
 
+//_______________________________________________________________________
+void AliGenerator:: SetHighWaterMark(Int_t nt)
+{
+  //
+  // Internal function to set the maximum index used in the stack
+  //
+  if (fStack)
+     fStack->SetHighWaterMark(nt);
+  else 
+     gAlice->GetMCApp()->SetHighWaterMark(nt);
+   
+}
+void AliGenerator::FinishRun()
+{
+    ;
+}