Made more robust
[u/mrichter/AliRoot.git] / FASTSIM / fastGen.C
CommitLineData
8bb5c9a6 1AliGenerator* CreateGenerator();
2
3void fastGen(Int_t nev = 1, char* filename = "galice.root")
4{
9c653bef 5// Runloader
6
7 AliRunLoader* rl = AliRunLoader::Open("galice.root","FASTRUN","recreate");
8
9 rl->SetCompressionLevel(2);
10 rl->SetNumberOfEventsPerFile(nev);
11 rl->LoadKinematics("RECREATE");
12 rl->MakeTree("E");
13 gAlice->SetRunLoader(rl);
14
8bb5c9a6 15// Create stack
9c653bef 16 rl->MakeStack();
17 AliStack* stack = rl->Stack();
18
19// Header
20 AliHeader* header = rl->GetHeader();
8bb5c9a6 21//
22// Create and Initialize Generator
23 AliGenerator *gener = CreateGenerator();
24 gener->Init();
25 gener->SetStack(stack);
26
27//
28// Event Loop
29//
30 Int_t iev;
31
32 for (iev = 0; iev < nev; iev++) {
33
34 printf("\n \n Event number %d \n \n", iev);
35
36// Initialize event
37 header->Reset(0,iev);
9c653bef 38 rl->SetEventNumber(iev);
db11648d 39 stack->Reset();
9c653bef 40 rl->MakeTree("K");
41// stack->ConnectTree();
42
8bb5c9a6 43// Generate event
44 gener->Generate();
45// Analysis
46 Int_t npart = stack->GetNprimary();
47 printf("Analyse %d Particles\n", npart);
48 for (Int_t part=0; part<npart; part++) {
49 TParticle *MPart = stack->Particle(part);
50 Int_t mpart = MPart->GetPdgCode();
51 printf("Particle %d\n", mpart);
52 }
53
54// Finish event
55 header->SetNprimary(stack->GetNprimary());
56 header->SetNtrack(stack->GetNtrack());
57// I/O
58//
db11648d 59 stack->FinishEvent();
60 header->SetStack(stack);
abf2927c 61 rl->TreeE()->Fill();
9c653bef 62 rl->WriteKinematics("OVERWRITE");
abf2927c 63
8bb5c9a6 64 } // event loop
65//
66// Termination
67// Generator
68 gener->FinishRun();
8bb5c9a6 69// Stack
70 stack->FinishRun();
71// Write file
9c653bef 72 rl->WriteHeader("OVERWRITE");
abf2927c 73 gener->Write();
74 rl->Write();
75
8bb5c9a6 76}
77
78
79AliGenerator* CreateGenerator()
80{
81 gener = new AliGenPythia(1);
82//
83//
84// vertex position and smearing
85 gener->SetVertexSmear(kPerEvent);
86// structure function
87 gener->SetStrucFunc(kGRVHO);
88// charm, beauty, charm_unforced, beauty_unforced, jpsi, jpsi_chi, mb
89 gener->SetProcess(kPyJets);
90// Centre of mass energy
db11648d 91 gener->SetEnergyCMS(5500.);
8bb5c9a6 92// Pt transfer of the hard scattering
db11648d 93 gener->SetPtHard(50.,50.2);
8bb5c9a6 94// Initialize generator
95 return gener;
96}
97
98
99
100
101
102
103
104
105
106
107
108