Faster reweighting method implemented.
[u/mrichter/AliRoot.git] / FASTSIM / fastGen.C
1 AliGenerator*  CreateGenerator();
2
3 void fastGen(Int_t nev = 1, char* filename = "galice.root")
4 {
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
15 //  Create stack
16     rl->MakeStack();
17     AliStack* stack      = rl->Stack();
18  
19 //  Header
20     AliHeader* header = rl->GetHeader();
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);
38         rl->SetEventNumber(iev);
39         stack->Reset();
40         rl->MakeTree("K");
41 //      stack->ConnectTree();
42     
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 //      
59         stack->FinishEvent();
60         header->SetStack(stack);
61         rl->TreeE()->Fill();
62         rl->WriteKinematics("OVERWRITE");
63
64     } // event loop
65 //
66 //                         Termination
67 //  Generator
68     gener->FinishRun();
69 //  Stack
70     stack->FinishRun();
71 //  Write file
72     rl->WriteHeader("OVERWRITE");
73     gener->Write();
74     rl->Write();
75     
76 }
77
78
79 AliGenerator*  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 
91     gener->SetEnergyCMS(5500.);
92 //   Pt transfer of the hard scattering
93     gener->SetPtHard(50.,50.2);
94 //   Initialize generator    
95     return gener;
96 }
97
98
99
100
101
102
103
104
105
106
107
108