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