Flushing the buffer for debug purposes (R. Preghenella)
[u/mrichter/AliRoot.git] / FASTSIM / fastGenEMCocktail.C
1 void fastGenEMCocktail(Int_t nev = 1, char* filename = "galice.root")
2 {
3 // load libraries
4
5         gSystem->Load("liblhapdf");      // Parton density functions
6         gSystem->Load("libpythia6");     // Pythia
7         gSystem->Load("libEG");
8         gSystem->Load("libEGPythia6");
9         gSystem->Load("libAliPythia6");  // ALICE specific implementations
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
30         AliGenEMCocktail *gener = new AliGenEMCocktail();
31
32         //=======================================================================
33         // Set External decayer
34         TVirtualMCDecayer *decayer = new AliDecayerPythia();
35
36         gener->SetNPart(1000);               // source multiplicity per event
37         gener->SetPtRange(0.,20.);
38         gener->SetYRange(-1.,1.);
39         gener->SetPhiRange(0., 360.);
40         gener->SetOrigin(0.,0.,0.); 
41         gener->SetSigma(0.,0.,0.);
42         gener->SetVertexSmear(kPerEvent);
43         gener->SetTrackingFlag(0);
44         gener->SelectMotherParticles(62591);
45         gener->SetPtParamPi0(0);
46         gener->SetPtParamEta(3);
47         gener->SetPtParamOmega(3);
48         gener->SetPtParamPhi(0);
49         gener->SetCollisionSystem(2);                   //pp 7 TeV
50         gener->SetCentrality(0);                                // kpp
51
52         gener->SetDecayMode(kGammaEM);                  // select cocktail:
53                                                                                         // kElectronEM   => single electron
54                                                                                         // kDiElectronEM => electron-positron
55                                                                                         // kGammaEM      => single photon
56         gener->SetDecayer(decayer);
57         gener->SetWeightingMode(kNonAnalog);    // select weighting:
58                                                                                         // kNonAnalog => weight ~ dN/dp_T
59                                                                                         // kAnalog    => weight ~ 1
60         gener->CreateCocktail();
61         gener->Init();
62         gener->SetStack(stack);
63
64         //
65         //                        Event Loop
66         //
67         Int_t iev;
68                 
69         for (iev = 0; iev < nev; iev++) {
70
71                 printf("\n \n Event number %d \n \n", iev);
72                 
73                 // Initialize event
74                 header->Reset(0,iev);
75                 rl->SetEventNumber(iev);
76                 stack->Reset();
77                 rl->MakeTree("K");
78                 //  stack->ConnectTree();
79                 
80                 // Generate event
81                 gener->Generate();
82                 // Analysis
83                 Int_t npart = stack->GetNprimary();
84                 printf("Analyse %d Particles\n", npart);
85                 for (Int_t part=0; part<npart; part++) {
86                 TParticle *MPart = stack->Particle(part);
87                 Int_t mpart  = MPart->GetPdgCode();
88                 //      printf("Particle %d\n", mpart);
89                 }
90                 
91                 // Finish event
92                 header->SetNprimary(stack->GetNprimary());
93                 header->SetNtrack(stack->GetNtrack());  
94
95                 // I/O
96                 //      
97                 stack->FinishEvent();
98                 header->SetStack(stack);
99                 rl->TreeE()->Fill();
100                 rl->WriteKinematics("OVERWRITE");
101
102         } // event loop
103
104         //
105         //                         Termination
106         // Generator
107         gener->FinishRun();
108         // Write file
109         rl->WriteHeader("OVERWRITE");
110         gener->Write();
111         rl->Write();
112 }
113
114
115
116
117
118
119
120
121
122
123
124