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