Example for fast generation of kinematics with DPMJET.
[u/mrichter/AliRoot.git] / TDPMjet / fastGenDPMjet.C
1 AliGenerator*  CreateGenerator();
2
3 void fastGenDPMjet(Int_t nev = 1, char* filename = "galice.root")
4 {
5 //  Runloader
6
7     gSystem->Load("libdpmjet.so");
8     gSystem->Load("libTDPMjet.so");
9     
10     AliRunLoader* rl = AliRunLoader::Open("galice.root","FASTRUN","recreate");
11     
12     rl->SetCompressionLevel(2);
13     rl->SetNumberOfEventsPerFile(nev);
14     rl->LoadKinematics("RECREATE");
15     rl->MakeTree("E");
16     gAlice->SetRunLoader(rl);
17
18 //  Create stack
19     rl->MakeStack();
20     AliStack* stack      = rl->Stack();
21  
22 //  Header
23     AliHeader* header = rl->GetHeader();
24 //
25 //  Create and Initialize Generator
26     AliGenerator *gener = CreateGenerator();
27     gener->Init();
28     gener->SetStack(stack);
29     
30 //
31 //                        Event Loop
32 //
33     Int_t iev;
34      
35     for (iev = 0; iev < nev; iev++) {
36
37         printf("\n \n Event number %d \n \n", iev);
38         
39 //  Initialize event
40         header->Reset(0,iev);
41         rl->SetEventNumber(iev);
42         stack->Reset();
43         rl->MakeTree("K");
44 //      stack->ConnectTree();
45     
46 //  Generate event
47         gener->Generate();
48 //  Analysis
49         Int_t npart = stack->GetNprimary();
50         printf("Analyse %d Particles\n", npart);
51         for (Int_t part=0; part<npart; part++) {
52             TParticle *MPart = stack->Particle(part);
53             Int_t pdg  = MPart->GetPdgCode();
54             Int_t pis  = MPart->GetStatusCode();
55 //          printf("Particle %5d %5d\n", part, pdg, pis);
56         }
57         
58 //  Finish event
59         header->SetNprimary(stack->GetNprimary());
60         header->SetNtrack(stack->GetNtrack());  
61 //      I/O
62 //      
63         stack->FinishEvent();
64         header->SetStack(stack);
65         rl->TreeE()->Fill();
66         rl->WriteKinematics("OVERWRITE");
67
68     } // event loop
69 //
70 //                         Termination
71 //  Generator
72     gener->FinishRun();
73 //  Write file
74     rl->WriteHeader("OVERWRITE");
75     gener->Write();
76     rl->Write();
77     
78 }
79
80
81 AliGenerator*  CreateGenerator()
82
83     //  kDpmMb
84     //  kDpmMbNonDiffr
85     //  kDpmDiffr
86     //  kDpmSingleDiffr
87     //  kDpmDoubleDiffr
88     gener = new AliGenDPMjet(1);
89     gener->SetProcess(kDpmMb);
90     gener->SetEnergyCMS(14000.);
91     return gener;
92 }
93
94
95
96
97
98
99
100
101
102
103
104