]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliGenerator.cxx
AliHMPIDDigitN no longer needed
[u/mrichter/AliRoot.git] / STEER / AliGenerator.cxx
index 1e6da896623dfe49e19a6c9b849c498287a6d2bf..8bae37d8181072f91b0ffeaa7048b1951b6b30d3 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/* $Header$ */
+/* $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">
 //                                                               //
 ///////////////////////////////////////////////////////////////////
 #include <TGenerator.h>
+#include <TMCProcess.h>
 
+#include "AliLog.h"
 #include "AliCollisionGeometry.h"
 #include "AliConfig.h"
 #include "AliGenerator.h"
 #include "AliRun.h"
 #include "AliStack.h"
+#include "AliMC.h"
+#include "AliVertexGenerator.h"
 
 ClassImp(AliGenerator)
 
-TGenerator* AliGenerator::fgMCEvGen=0;
 
 //_______________________________________________________________________
 AliGenerator::AliGenerator():
+  TNamed(),
+  AliRndm(),
+  fMCEvGen(0),
   fThetaMin(0),
   fThetaMax(0),
   fPhiMin(0),
@@ -65,23 +71,25 @@ AliGenerator::AliGenerator():
   fChildWeight(0),
   fAnalog(0),
   fVertexSmear(kNoSmear),
-  fVertexSource(kExternal),
+  fVertexSource(kInternal),
   fCutVertexZ(0),
+  fPileUpTimeWindow(-1.),
   fTrackIt(0),
+  fVertexGenerator(0),
   fOrigin(3),
   fOsigma(3),
   fVertex(3),
-  fEventVertex(0),
   fStack(0),
+  fContainer(0),
   fCollisionGeometry(0)
 {
   //
   // Default constructor
   //
     if (gAlice) {
-       if (gAlice->GetDebug()>0)
-           printf("\n AliGenerator Default Constructor\n\n");
-       gAlice->SetGenerator(this);
+       AliDebug(1, "AliGenerator Default Constructor");
+       AliMC * mc = gAlice->GetMCApp();
+       if (mc) mc->SetGenerator(this);
     }
 
     SetThetaRange(); ResetBit(kThetaRange);
@@ -104,6 +112,9 @@ AliGenerator::AliGenerator():
 
 //_______________________________________________________________________
 AliGenerator::AliGenerator(Int_t npart):
+  TNamed(),
+  AliRndm(),
+  fMCEvGen(0),
   fThetaMin(0),
   fThetaMax(0),
   fPhiMin(0),
@@ -121,23 +132,25 @@ AliGenerator::AliGenerator(Int_t npart):
   fChildWeight(0),
   fAnalog(0),
   fVertexSmear(kNoSmear),
-  fVertexSource(kExternal),
+  fVertexSource(kInternal),
   fCutVertexZ(0),
+  fPileUpTimeWindow(-1.),
   fTrackIt(0),
+  fVertexGenerator(0),
   fOrigin(3),
   fOsigma(3),
   fVertex(3),
-  fEventVertex(0),
   fStack(0),
+  fContainer(0),
   fCollisionGeometry(0)
 {
   //
   // Standard constructor
   //
     if (gAlice) {
-       if (gAlice->GetDebug()>0)
-           printf("\n AliGenerator Constructor initializing number of particles \n\n");
-       gAlice->SetGenerator(this);
+        AliDebug(1, "AliGenerator Constructor initializing number of particles");
+       AliMC * mc = gAlice->GetMCApp();
+       if (mc) mc->SetGenerator(this);
     }
     
     SetThetaRange(); ResetBit(kThetaRange);
@@ -164,6 +177,7 @@ AliGenerator::AliGenerator(Int_t npart):
 AliGenerator::AliGenerator(const AliGenerator &gen): 
   TNamed(gen),
   AliRndm(gen),
+  fMCEvGen(0),
   fThetaMin(0),
   fThetaMax(0),
   fPhiMin(0),
@@ -181,14 +195,17 @@ AliGenerator::AliGenerator(const AliGenerator &gen):
   fChildWeight(0),
   fAnalog(0),
   fVertexSmear(kNoSmear),
-  fVertexSource(kExternal),
+  fVertexSource(kInternal),
   fCutVertexZ(0),
+  fPileUpTimeWindow(-1.),
   fTrackIt(0),
+  fVertexGenerator(0),
   fOrigin(3),
   fOsigma(3),
   fVertex(3),
-  fEventVertex(0),
-  fStack(0)
+  fStack(0),
+  fContainer(0),
+  fCollisionGeometry(0)
 {
   //
   // Copy constructor
@@ -207,12 +224,12 @@ AliGenerator & AliGenerator::operator=(const AliGenerator &gen)
 }
 
 //_______________________________________________________________________
-void AliGenerator::Copy(AliGenerator &/* gen */) const
+void AliGenerator::Copy(TObject &/* gen */) const
 {
   //
   // Copy *this onto gen
   //
-  Fatal("Copy","Not implemented!\n");
+  AliFatal("Not implemented!");
 }
 
 //_______________________________________________________________________
@@ -223,9 +240,9 @@ AliGenerator::~AliGenerator()
   //
   fOrigin.Set(0);
   fOsigma.Set(0);
-  if (fgMCEvGen) {
-    delete fgMCEvGen;
-    fgMCEvGen=0;
+  if (fMCEvGen) {
+    delete fMCEvGen;
+    fMCEvGen=0;
   }
 }
 
@@ -345,7 +362,9 @@ void AliGenerator::Vertex()
   //
     if (fVertexSource == kInternal) {
        VertexInternal();
-    } else {
+    } else if (fVertexSource == kContainer) {
+       ;
+    } else if (fVertexSource == kExternal) {
        VertexExternal();
     }
 }
@@ -353,12 +372,13 @@ void AliGenerator::Vertex()
 //_______________________________________________________________________
 void AliGenerator::VertexExternal()
 {
-    // Dummy !!!!!!
-    // Obtain vertex from external source 
     //
-    // Should be something like fVertex = gAlice->GetVertex()
-    
-    fVertex[0]=fVertex[1]=fVertex[2]=0;  
+    // Obtain vertex from external source (vertex generator)
+    //
+    TVector3 vertex = fVertexGenerator->GetVertex();
+    fVertex[0] = vertex.X();
+    fVertex[1] = vertex.Y();
+    fVertex[2] = vertex.Z();
 }
 
 //_______________________________________________________________________
@@ -368,16 +388,27 @@ 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::SetTrack(Int_t done, Int_t parent, Int_t pdg,
+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)
@@ -385,17 +416,17 @@ void  AliGenerator::SetTrack(Int_t done, Int_t parent, Int_t pdg,
   //
   // Loads one track on the stack
   //
-
+    
   if (fStack)
-    fStack->SetTrack(done, parent, pdg, pmom, vpos, polar, tof,
+    fStack->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
                      mech, ntr, weight, is);
   else 
-    gAlice->SetTrack(done, parent, pdg, pmom, vpos, polar, tof,
+    gAlice->GetMCApp()->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
                      mech, ntr, weight, is);
 }
 
 //_______________________________________________________________________
-void  AliGenerator::SetTrack(Int_t done, Int_t parent, Int_t pdg,
+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,
@@ -406,10 +437,10 @@ void  AliGenerator::SetTrack(Int_t done, Int_t parent, Int_t pdg,
   //
   
   if (fStack)
-     fStack->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
+     fStack->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
                       polx, poly, polz, mech, ntr, weight, is);
   else 
-     gAlice->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
+     gAlice->GetMCApp()->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
                         polx, poly, polz, mech, ntr, weight, is);
 }
 
@@ -423,7 +454,7 @@ void AliGenerator:: KeepTrack(Int_t itrack)
   if (fStack)
      fStack->KeepTrack(itrack);
   else 
-     gAlice->KeepTrack(itrack);
+     gAlice->GetMCApp()->KeepTrack(itrack);
    
 }
 
@@ -436,6 +467,10 @@ void AliGenerator:: SetHighWaterMark(Int_t nt)
   if (fStack)
      fStack->SetHighWaterMark(nt);
   else 
-     gAlice->SetHighWaterMark(nt);
+     gAlice->GetMCApp()->SetHighWaterMark(nt);
    
 }
+void AliGenerator::FinishRun()
+{
+    ;
+}