void gen(Int_t nev = 1, const char* genConfig = "$ALICE_ROOT/MUON/macros/genTestConfig.C") { // Load libraries // gSystem->SetIncludePath("-I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_ROOT"); gSystem->Load("liblhapdf"); // Parton density functions gSystem->Load("libEGPythia6"); // TGenerator interface gSystem->Load("libpythia6"); // Pythia gSystem->Load("libAliPythia6"); // ALICE specific implementations AliPDG::AddParticlesToPdgDataBase(); TDatabasePDG::Instance(); // Run loader 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 rl->MakeStack(); AliStack* stack = rl->Stack(); // Header AliHeader* header = rl->GetHeader(); // Create and Initialize Generator gROOT->LoadMacro(genConfig); AliGenerator* gener = genConfig(); // Go to galice.root rl->CdGAFile(); // Forbid some decays. Do it after gener->Init(0, because // the initialization of the generator includes reading of the decay table. // ... // // Event Loop // TStopwatch timer; timer.Start(); for (Int_t iev = 0; iev < nev; iev++) { cout <<"Event number "<< iev << endl; // Initialize event header->Reset(0,iev); rl->SetEventNumber(iev); stack->Reset(); rl->MakeTree("K"); // Generate event stack->Reset(); stack->ConnectTree(rl->TreeK()); gener->Generate(); cout << "Number of particles " << stack->GetNprimary() << endl; // Finish event header->SetNprimary(stack->GetNprimary()); header->SetNtrack(stack->GetNtrack()); // I/O stack->FinishEvent(); header->SetStack(stack); rl->TreeE()->Fill(); rl->WriteKinematics("OVERWRITE"); } // event loop timer.Stop(); timer.Print(); // Termination // Generator gener->FinishRun(); // Write file rl->WriteHeader("OVERWRITE"); gener->Write(); rl->Write(); }
void fastGen(Tune_t tune = kPyTuneCDFA , Float_t energy, Int_t nev = 1, TString process) { // Add all particles to the PDG database AliPDG::AddParticlesToPdgDataBase(); // set the random seed TDatime date; UInt_t seed = date.Get()+gSystem->GetPid(); gRandom->SetSeed(seed); cout<<"Seed for random number generation= "<<seed<<endl; // 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 rl->MakeStack(); AliStack* stack = rl->Stack(); // Header AliHeader* header = rl->GetHeader(); // // Create and Initialize Generator AliGenerator *gener = CreateGenerator(tune,energy); gener->Init(); // if nsd switch off single diffraction if ( process == "NSD"){ if(tune != kPhojet) { AliPythia::Instance()-> SetMSUB(92,0); // single diffraction AB-->XB AliPythia::Instance()-> SetMSUB(93,0); // single diffraction AB-->AX } else { cout << "NSD not yet implemented in the phojet case" << endl; exit(1); } } gener->SetStack(stack); // // Event Loop // Int_t iev; for (iev = 0; iev < nev; iev++) { if(!(iev%500)) printf("\n \n Event number %d \n \n", iev); // Initialize event header->Reset(0,iev); rl->SetEventNumber(iev); stack->Reset(); rl->MakeTree("K"); // stack->ConnectTree(); // Generate event gener->Generate(); // Analysis // Int_t npart = stack->GetNprimary(); // printf("Analyse %d Particles\n", npart); // for (Int_t part=0; part<npart; part++) { // TParticle *MPart = stack->Particle(part); // Int_t mpart = MPart->GetPdgCode(); // printf("Particle %d\n", mpart); // } // Finish event header->SetNprimary(stack->GetNprimary()); header->SetNtrack(stack->GetNtrack()); // I/O // stack->FinishEvent(); header->SetStack(stack); rl->TreeE()->Fill(); rl->WriteKinematics("OVERWRITE"); } // event loop // // Termination // Generator gener->FinishRun(); // Write file rl->WriteHeader("OVERWRITE"); gener->Write(); rl->Write(); }