Skip to content

Commit 7c247fd

Browse files
authored
Adding GeneratorSpectator: generator for spectator protons (#9)
* Adding a test macro for GeneratorSpectators * Set pmax in def. constructor to avoid infinite loop in generation + small fixes
1 parent bc0582c commit 7c247fd

File tree

4 files changed

+78
-13
lines changed

4 files changed

+78
-13
lines changed

GeneratorSlowNucleons/GeneratorSlowNucleons.cxx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ ClassImp(GeneratorSlowNucleons)
3232

3333
GeneratorSlowNucleons::GeneratorSlowNucleons()
3434
: TGenerator("GeneratorParam", "GeneratorParam"), fCMS(0.), fMomentum(0.),
35-
fBeta(0.), fPmax(0.), fCharge(0), fProtonDirection(1.), fTemperatureG(0.),
35+
fBeta(0.), fPmax(10.), fCharge(0), fProtonDirection(1.), fTemperatureG(0.),
3636
fBetaSourceG(0.), fTemperatureB(0.), fBetaSourceB(0.), fNgp(0), fNgn(0),
3737
fNbp(0), fNbn(0), fDebug(0), fDebugHist1(0), fDebugHist2(0),
3838
fThetaDistribution(), fCosThetaGrayHist(), fCosTheta(),
@@ -247,10 +247,9 @@ void GeneratorSlowNucleons::GenerateSlow(Int_t charge, Double_t T,
247247
Three-momentum [GeV/c] is given back in q[3]
248248
*/
249249

250-
// printf("Generating slow nuc. with: charge %d. temp. %1.4f, beta %f
251-
// \n",charge,T,beta);
250+
//printf("Generating slow nuc. with: charge %d. temp. %1.4f, beta %f \n",charge,T,beta);
252251

253-
Double_t m, pmax, p, f, phi;
252+
Double_t m=0, pmax=0, p=0, f=0, phi=0;
254253
TDatabasePDG *pdg = TDatabasePDG::Instance();
255254
const Double_t kMassProton = pdg->GetParticle(kProton)->Mass();
256255
const Double_t kMassNeutron = pdg->GetParticle(kNeutron)->Mass();
@@ -315,8 +314,7 @@ void GeneratorSlowNucleons::GenerateSlow(Int_t charge, Double_t T,
315314

316315
Double_t GeneratorSlowNucleons::Maxwell(Double_t m, Double_t p, Double_t T) {
317316
/* Relativistic Maxwell-distribution */
318-
Double_t ekin;
319-
ekin = TMath::Sqrt(p * p + m * m) - m;
317+
Double_t ekin = TMath::Sqrt(p * p + m * m) - m;
320318
return (p * p * exp(-ekin / T));
321319
}
322320

GeneratorSlowNucleons/GeneratorSlowNucleons.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ class GeneratorSlowNucleons : public TGenerator {
4343
// {AliGenerator::SetTarget(s, a, z);}
4444
virtual void SetProtonDirection(Float_t dir = 1.);
4545
virtual void SetCharge(Int_t c = 1) { fCharge = c; }
46-
virtual void SetTemperature(Double_t t1 = 0.04, Double_t t2 = 0.004) {
46+
virtual void SetTemperature(Float_t t1 = 0.04, Float_t t2 = 0.004) {
4747
fTemperatureG = t1;
4848
fTemperatureB = t2;
4949
}
50-
virtual void SetBetaSource(Double_t b1 = 0.05, Double_t b2 = 0.) {
50+
virtual void SetBetaSource(Float_t b1 = 0.05, Float_t b2 = 0.) {
5151
fBetaSourceG = b1;
5252
fBetaSourceB = b2;
5353
}

GeneratorSlowNucleons/test.C

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,24 @@ void test()
22
{
33
GeneratorSlowNucleons* slow = new GeneratorSlowNucleons();
44
slow->SetSlowNucleonModel(new SlowNucleonModelExp());
5-
slow->SetNcoll(7);
65
slow->SetNominalCmsEnergy(13000);
76
slow->SetTarget();
7+
slow->SetTemperature();
8+
slow->SetBetaSource();
9+
slow->SetProtonDirection();
10+
slow->SetDebug();
11+
slow->SetPmax();
812
slow->Init();
13+
14+
slow->SetNcoll(7);
915
slow->GenerateEvent();
10-
16+
1117
auto particles = new TClonesArray("TParticle", 10);
1218
auto n = slow->ImportParticles(particles, "all");
1319
printf("Number of generated particles %5d \n", n);
14-
20+
1521
for (Int_t i = 0; i < n; i++) {
1622
auto p = *(TParticle*) (particles->At(i));
17-
printf("%5d %5d %5d %5d %5d\n", i, p.GetPdgCode(), p.GetFirstMother(), p.GetFirstDaughter(), p.GetLastDaughter());
18-
23+
printf(" PDG:%d pt=%1.2f GeV pz=%1.2f GeV\n", p.GetPdgCode(), p.Pt(), p.Pz());
1924
}
2025
}

GeneratorSpectators/test.C

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#if !defined(__CINT__) || defined(__MAKECINT__)
2+
3+
#include <TClonesArray.h>
4+
#include <TDatabasePDG.h>
5+
#include <TLorentzVector.h>
6+
#include <TMath.h>
7+
#include <TPDGCode.h>
8+
#include <TParticle.h>
9+
#include <TParticlePDG.h>
10+
#include <TRandom.h>
11+
#include <TH1F.h>
12+
#include <TCanvas.h>
13+
#include "GeneratorSpectators.h"
14+
15+
#endif
16+
17+
void test(int nev=1)
18+
{
19+
GeneratorSpectators* spgen = new GeneratorSpectators();
20+
spgen->SetParticle(2112); //Neutrons
21+
spgen->SetMomentum(2510.);
22+
spgen->SetDirection(0, 0., 0., -1.);
23+
spgen->SetFermi();
24+
spgen->SetDivergence(0.000032); //beam divergence in murad
25+
spgen->SetCrossing(0.000060, 2);//beam crossing angle in murad
26+
27+
spgen->Init();
28+
29+
double upper=4000.;
30+
if(spgen->GetZDirection()<0.) upper = -4000.;
31+
TH1F *hpz = new TH1F("hpz", "Spectators p_{z}", 200, 0., upper);
32+
TH1F *hpt = new TH1F("hpt", "Spectators p_{t}", 100, 0., 2.);
33+
34+
for (Int_t iev = 0; iev < nev; iev++) {
35+
spgen->GenerateEvent();
36+
37+
//printf(" \t Importing generated particles \n");
38+
auto particles = new TClonesArray("TParticle", 10);
39+
auto npart = spgen->ImportParticles(particles, "all");
40+
//printf(" - Number of generated particles %5d \n", npart);
41+
42+
for (Int_t i = 0; i < npart; i++) {
43+
auto p = *(TParticle*) (particles->At(i));
44+
//printf("(%d) PDG:%5d pt=%1.2f GeV pz=%1.2f GeV\n", iev, p.GetPdgCode(), p.Pt(), p.Pz());
45+
hpt->Fill(p.Pt());
46+
hpz->Fill(p.Pz());
47+
}
48+
}
49+
50+
TCanvas *c = new TCanvas("c","Momentum",0,0,1200,600);
51+
c->Divide(2,1);
52+
c->cd(1);
53+
hpt->SetLineColor(kAzure+10);
54+
hpt->SetLineWidth(2);
55+
hpt->Draw("e");
56+
hpt->GetXaxis()->SetTitle("p_{T} (GeV/c)");
57+
c->cd(2);
58+
hpz->SetLineColor(kPink);
59+
hpz->SetLineWidth(2);
60+
hpz->Draw("e");
61+
hpz->GetXaxis()->SetTitle("p_{Z} (GeV/c)");
62+
}

0 commit comments

Comments
 (0)