]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVGEN/AliGenBox.cxx
Indexing bug fixed.
[u/mrichter/AliRoot.git] / EVGEN / AliGenBox.cxx
index 9946aba58999eae10a5535501fb1ba4d31472f16..5869d034441d56608529b2ec843d05da36b44480 100644 (file)
 // kinematic range (flat distribution)
 // Note that for a given theta pt and p are not independent 
 // Range for only one variable (pt or p) should be given.
-//
 // Comments and suggestions: andreas.morsch@cern.ch
-//
-//Begin_Html
-/*
-<img src="picts/AliGeneratorClass.gif">
-</pre>
-<br clear=left>
-<font size=+2 color=red>
-<p>The responsible person for this module is
-<a href="mailto:andreas.morsch@cern.ch">Andreas Morsch</a>.
-</font>
-<pre>
-*/
-//End_Html
-//                                                               //
-///////////////////////////////////////////////////////////////////
+
 
 #include "TPDGCode.h"
 
 #include "AliConst.h"
 #include "AliGenBox.h"
 #include "AliRun.h"
+#include "AliGenEventHeader.h"
 
 ClassImp(AliGenBox)
 
 //_____________________________________________________________________________
 AliGenBox::AliGenBox()
-    :AliGenerator()
+    :AliGenerator(), 
+     fIpart(0),
+     fEtaMin(0),
+     fEtaMax(0)
 {
   //
   // Default constructor
   //
-  fIpart=0;
 }
 
 //_____________________________________________________________________________
 AliGenBox::AliGenBox(Int_t npart)
-  :AliGenerator(npart)
+    :AliGenerator(npart),
+     fIpart(kProton),
+     fEtaMin(0),
+     fEtaMax(0)
 {
   //
   // Standard constructor
   //
   fName  = "Box";
   fTitle = "Box particle generator";
-  // Generate Proton by default
-  fIpart=kProton;
 }
 
 //_____________________________________________________________________________
@@ -94,7 +83,15 @@ void AliGenBox::Generate()
 
     for(i=0;i<fNpart;i++) {
        Rndm(random,3);
-       theta=fThetaMin+random[0]*(fThetaMax-fThetaMin);
+       
+       if (TestBit(kThetaRange)) {
+           theta = fThetaMin+random[0]*(fThetaMax-fThetaMin);
+       } else {
+           Float_t eta = fEtaMin+random[0]*(fEtaMax-fEtaMin);
+           theta = 2. * TMath::ATan(TMath::Exp(-eta));
+       }
+           
+           
        if(TestBit(kMomentumRange)) {
            pmom=fPMin+random[1]*(fPMax-fPMin);
            pt=pmom*TMath::Sin(theta);
@@ -103,6 +100,7 @@ void AliGenBox::Generate()
            pt=fPtMin+random[1]*(fPtMax-fPtMin);
            pmom=pt/TMath::Sin(theta);
        }
+
        phi=fPhiMin+random[2]*(fPhiMax-fPhiMin);
        p[0] = pt*TMath::Cos(phi);
        p[1] = pt*TMath::Sin(phi);
@@ -115,7 +113,18 @@ void AliGenBox::Generate()
                    TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
            }
        }
-       SetTrack(fTrackIt,-1,fIpart,p,origin,polar,0,kPPrimary,nt);
+       PushTrack(fTrackIt,-1,fIpart,p,origin,polar,0,kPPrimary,nt);
+    }
+
+    AliGenEventHeader* header = new AliGenEventHeader("BOX");
+    header->SetPrimaryVertex(fVertex);
+    header->SetNProduced(fNpart);
+    
+ // Passes header either to the container or to gAlice
+    if (fContainer) {
+       fContainer->AddHeader(header);
+    } else {
+       gAlice->SetGenEventHeader(header);      
     }
 }