]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVGEN/AliGenSlowNucleons.cxx
Updates to RAW package. Used during the Computing DC.
[u/mrichter/AliRoot.git] / EVGEN / AliGenSlowNucleons.cxx
index 115230eb5bc4431086d6ad96ac0c6fbd798d270b..0c5d7a82f70b094fe9c07405ea22b7e714cadd0a 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.2  2003/03/25 09:55:24  morsch
-Numbers of slow nucleons either from model or user set.
+/* $Id$ */
 
-Revision 1.1  2003/03/24 16:49:23  morsch
-Slow nucleon generator and model.
-
-*/
-
-/*
-  Generator for slow nucluons in pA interactions. 
-  Source is modelled by a relativistic Maxwell distributions.
-  Original code by  Ferenc Sikler  <sikler@rmki.kfki.hu>
- */
+//
+//  Generator for slow nucleons in pA interactions. 
+//  Source is modelled by a relativistic Maxwell distributions.
+//  This class cooparates with AliCollisionGeometry if used inside AliGenCocktail.
+//  In this case the number of slow nucleons is determined from the number of wounded nuclei
+//  using a realisation of AliSlowNucleonModel.
+//  Original code by  Ferenc Sikler  <sikler@rmki.kfki.hu>
+// 
 
 #include <TDatabasePDG.h>
 #include <TPDGCode.h>
 #include <TH2F.h>
+#include <TCanvas.h>
 
 #include "AliCollisionGeometry.h"
 #include "AliGenSlowNucleons.h"
@@ -63,6 +59,13 @@ AliGenSlowNucleons::AliGenSlowNucleons(Int_t npart)
     fDebug = 0;
 }
 
+AliGenSlowNucleons::AliGenSlowNucleons(const AliGenSlowNucleons & sn):
+    AliGenerator(sn)
+{
+// Copy constructor
+    sn.Copy(*this);
+}
+
 //____________________________________________________________
 AliGenSlowNucleons::~AliGenSlowNucleons()
 {
@@ -70,6 +73,10 @@ AliGenSlowNucleons::~AliGenSlowNucleons()
     delete  fSlowNucleonModel;
 }
 
+void AliGenSlowNucleons::SetProtonDirection(Float_t dir) {
+// Set direction of the proton to change between pA (1) and Ap (-1)
+  fProtonDirection = dir / TMath::Abs(dir);
+}
 
 void AliGenSlowNucleons::Init()
 {
@@ -80,14 +87,22 @@ void AliGenSlowNucleons::Init()
     fMomentum = fCMS/2. * fZTarget / fATarget;
     fBeta     = fMomentum / TMath::Sqrt(kMass * kMass + fMomentum * fMomentum);
     if (fDebug) {
-       fDebugHist = new TH2F("DebugHist", "N_heavy vs nu", 50, 0., 50., 50, 0., 50.);
+       fDebugHist1 = new TH2F("DebugHist1", "nu vs N_slow", 100, 0., 100., 20, 0., 20.);
+       fDebugHist2 = new TH2F("DebugHist2", "b  vs N_slow", 100, 0., 100., 15, 0., 15.);
     }
 }
 
 void AliGenSlowNucleons::FinishRun()
 {
+// End of run action
+// Show histogram for debugging if requested.
     if (fDebug) {
-       fDebugHist->Draw();
+       TCanvas *c = new TCanvas("c","Canvas 1",400,10,600,700);
+       c->Divide(2,1);
+       c->cd(1);
+       fDebugHist1->Draw();
+       c->cd(2);
+       fDebugHist2->Draw();
     }
 }
 
@@ -110,7 +125,8 @@ void AliGenSlowNucleons::Generate()
        fSlowNucleonModel->GetNumberOfSlowNucleons(fCollisionGeometry, fNgp, fNgn, fNbp, fNbn);
        if (fDebug) {
            printf("Nucleons %d %d %d %d \n", fNgp, fNgn, fNbp, fNbn);
-           fDebugHist->Fill(Float_t(fNgp + fNgn + fNbp + fNbn), fCollisionGeometry->NwN(), 1.);
+           fDebugHist1->Fill(Float_t(fNgp + fNgn + fNbp + fNbn), fCollisionGeometry->NwN(), 1.);
+           fDebugHist2->Fill(Float_t(fNgp + fNgn + fNbp + fNbn), b, 1.);
            printf("AliGenSlowNucleons: Impact parameter from Collision Geometry %f %d %d %d %d\n", 
                   b, nn, nwn, nnw, nwnw);
        }
@@ -134,7 +150,7 @@ void AliGenSlowNucleons::Generate()
     kf = kProton;    
     for(i = 0; i < fNgp; i++) {
        GenerateSlow(fCharge, fTemperatureG, fBetaSourceG, p);
-       SetTrack(fTrackIt, -1, kf, p, origin, polar,
+       PushTrack(fTrackIt, -1, kf, p, origin, polar,
                 0., kPNoProcess, nt, 1.);
        KeepTrack(nt);
     }
@@ -145,7 +161,7 @@ void AliGenSlowNucleons::Generate()
     kf = kNeutron;    
     for(i = 0; i < fNgn; i++) {
        GenerateSlow(fCharge, fTemperatureG, fBetaSourceG, p);
-       SetTrack(fTrackIt, -1, kf, p, origin, polar,
+       PushTrack(fTrackIt, -1, kf, p, origin, polar,
                 0., kPNoProcess, nt, 1.);
        KeepTrack(nt);
     }
@@ -156,7 +172,7 @@ void AliGenSlowNucleons::Generate()
     kf = kProton;    
     for(i = 0; i < fNbp; i++) {
        GenerateSlow(fCharge, fTemperatureB, fBetaSourceB, p);
-       SetTrack(fTrackIt, -1, kf, p, origin, polar,
+       PushTrack(fTrackIt, -1, kf, p, origin, polar,
                 0., kPNoProcess, nt, 1.);
        KeepTrack(nt);
     }
@@ -167,7 +183,7 @@ void AliGenSlowNucleons::Generate()
     kf = kNeutron;    
     for(i = 0; i < fNbn; i++) {
        GenerateSlow(fCharge, fTemperatureB, fBetaSourceB, p);
-       SetTrack(fTrackIt, -1, kf, p, origin, polar,
+       PushTrack(fTrackIt, -1, kf, p, origin, polar,
                 0., kPNoProcess, nt, 1.);
        KeepTrack(nt);
     }
@@ -177,15 +193,15 @@ void AliGenSlowNucleons::Generate()
 
 
 void AliGenSlowNucleons::GenerateSlow(Int_t charge, Double_t T, Double_t beta, Float_t* q)
+
+{
 /* 
    Emit a slow nucleon with "temperature" T [GeV], 
    from a source moving with velocity beta         
    Three-momentum [GeV/c] is given back in q[3]    
 */
 
-{
  Double_t m, pmax, p, f, theta, phi;
  TDatabasePDG * pdg = TDatabasePDG::Instance();
  const Double_t kMassProton  = pdg->GetParticle(kProton) ->Mass();
  const Double_t kMassNeutron = pdg->GetParticle(kNeutron)->Mass();
@@ -224,6 +240,7 @@ void AliGenSlowNucleons::GenerateSlow(Int_t charge, Double_t T, Double_t beta, F
 
  /* Transform to laboratory system */
  Lorentz(m, fBeta, q);
+ q[2] *= fProtonDirection; 
 }
 
 Double_t AliGenSlowNucleons::Maxwell(Double_t m, Double_t p, Double_t T)
@@ -244,6 +261,22 @@ void AliGenSlowNucleons::Lorentz(Double_t m, Double_t beta, Float_t* q)
     q[2] = gamma * (q[2] + beta*energy);
 }
 
+         
+AliGenSlowNucleons& AliGenSlowNucleons::operator=(const  AliGenSlowNucleons& rhs)
+{
+// Assignment operator
+    rhs.Copy(*this);
+    return *this;
+}
+
+void AliGenSlowNucleons::Copy(TObject&) const
+{
+    //
+    // Copy 
+    //
+    Fatal("Copy","Not implemented!\n");
+}
+