Adding Domenico Colella as responsible for SPD part in TRI pp
[u/mrichter/AliRoot.git] / FASTSIM / fastGen.C
index 35b1bb9..a86332e 100644 (file)
@@ -2,21 +2,28 @@ AliGenerator*  CreateGenerator();
 
 void fastGen(Int_t nev = 1, char* filename = "galice.root")
 {
-//
-//                        Construction
-//
-//  Output file
-    TFile*  file         = new TFile(filename, "recreate");
+//  Load libraries
+  gSystem->Load("liblhapdf");
+  gSystem->Load("libpythia6");
+  gSystem->Load("libEGPythia6");
+  gSystem->Load("libAliPythia6");
+
+//  Runloader
+    
+    AliRunLoader* rl = AliRunLoader::Open("galice.root","FASTRUN","recreate");
+    
+    rl->SetCompressionLevel(2);
+    rl->SetNumberOfEventsPerFile(nev);
+    rl->LoadKinematics("RECREATE");
+    rl->MakeTree("E");
+    gAlice->SetRunLoader(rl);
+
 //  Create stack
-    AliStack* stack      = new AliStack(10000);
-    stack->MakeTree(0, filename);
-
-//  Create Header
-    AliHeader* header    = new AliHeader();
-//  Create Header Tree
-    TTree* treeE         = new TTree("TE","Headers");
-    treeE->Branch("Header", "AliHeader", &header, 4000, 0);
-    treeE->Write();
+    rl->MakeStack();
+    AliStack* stack      = rl->Stack();
+//  Header
+    AliHeader* header = rl->GetHeader();
 //
 //  Create and Initialize Generator
     AliGenerator *gener = CreateGenerator();
@@ -34,8 +41,11 @@ void fastGen(Int_t nev = 1, char* filename = "galice.root")
        
 //  Initialize event
        header->Reset(0,iev);
-       stack->BeginEvent(iev);
-
+       rl->SetEventNumber(iev);
+       stack->Reset();
+       rl->MakeTree("K");
+//     stack->ConnectTree();
+    
 //  Generate event
        gener->Generate();
 //  Analysis
@@ -52,25 +62,21 @@ void fastGen(Int_t nev = 1, char* filename = "galice.root")
        header->SetNtrack(stack->GetNtrack());  
 //      I/O
 //     
-//     stack->FinishEvent();
-//     header->SetStack(stack);
-//     treeE->Fill();
-//     Reset stack
+       stack->FinishEvent();
+       header->SetStack(stack);
+       rl->TreeE()->Fill();
+       rl->WriteKinematics("OVERWRITE");
 
-       stack->Reset();
     } // event loop
 //
 //                         Termination
 //  Generator
     gener->FinishRun();
-//  Header
-    treeE->Write(0,TObject::kOverwrite);
-    delete treeE;   treeE = 0;
-//  Stack
-    stack->FinishRun();
 //  Write file
+    rl->WriteHeader("OVERWRITE");
     gener->Write();
-    file->Write();
+    rl->Write();
+    
 }
 
 
@@ -82,13 +88,13 @@ AliGenerator*  CreateGenerator()
 //   vertex position and smearing 
     gener->SetVertexSmear(kPerEvent);
 //   structure function
-    gener->SetStrucFunc(kGRVHO);
+    gener->SetStrucFunc(kCTEQ6);
 //   charm, beauty, charm_unforced, beauty_unforced, jpsi, jpsi_chi, mb
     gener->SetProcess(kPyJets);
 //   Centre of mass energy 
-    gener->SetEnergyCMS(14000.);
+    gener->SetEnergyCMS(5500.);
 //   Pt transfer of the hard scattering
-    gener->SetPtHard(5.,5.1);
+    gener->SetPtHard(50.,50.2);
 //   Initialize generator    
     return gener;
 }