void createGlauberTree(Int_t nEvents, const char *outFileName) { AliPDG::AddParticlesToPdgDataBase(); TDatabasePDG::Instance(); // Run loader TFolder *folder = new TFolder("myfolder","myfolder"); AliRunLoader* rl = new AliRunLoader(folder); rl->MakeHeader(); rl->MakeStack(); AliStack* stack = rl->Stack(); //AliHeader* rheader = rl->GetHeader(); AliGenHijing *genHi = new AliGenHijing(-1); genHi->SetStack(stack); genHi->SetEnergyCMS(2760); genHi->SetReferenceFrame("CMS"); genHi->SetProjectile("A", 208, 82); genHi->SetTarget ("A", 208, 82); genHi->SetPtHardMin (2.3); genHi->SetImpactParameterRange(0.,30); genHi->SetJetQuenching(0); // enable jet quenching genHi->SetShadowing(1); // enable shadowing genHi->SetDecaysOff(1); // neutral pion and heavy particle decays switched off genHi->Init(); MyHeader *myheader = new MyHeader; MyResponse *myresp = new MyResponse; TFile *outFile = TFile::Open(outFileName, "RECREATE"); outFile->SetCompressionLevel(5); TDirectory::TContext context(outFile); TTree *tree = new TTree("glaubertree", "Glauber tree"); tree->Branch("header",&myheader, 32*1024, 99); tree->Branch("response",&myresp, 32*1024, 99); TNtuple *ntuple = new TNtuple("gnt", "Glauber ntuple", "npart:ncoll:b"); Double_t etas[] = {-10,-5,-4,-3,-2,-1,0,1,2,3,4,5,10}; TH1D *hNEta = new TH1D("hNeta","",12,etas); TH1D *hEtEta = new TH1D("hEteta","",12,etas); // create events and fill them for (Int_t iEvent = 0; iEvent < nEvents; ++iEvent) { cout << "Event " << iEvent+1 << "/" << nEvents << endl;; stack->Reset(); hNEta->Reset(); hEtEta->Reset(); genHi->Generate(); AliStack *s = genHi->GetStack(); const TObjArray *parts = s->Particles(); Int_t nents = parts->GetEntries(); for (Int_t i = 0; i<nents; ++i) { TParticle *p = (TParticle*)parts->At(i); //p->Print(); TParticlePDG *pdg = p->GetPDG(1); Int_t c = (Int_t)(TMath::Abs(pdg->Charge())); if (c!=0) { hNEta->Fill(p->Eta()); hEtEta->Fill(p->Eta(),p->Pt()); } } AliGenHijingEventHeader *h = (AliGenHijingEventHeader*)genHi->CollisionGeometry(); myheader->fNATT = nents; myheader->fEATT = h->TotalEnergy(); myheader->fJATT = h->HardScatters(); myheader->fNT = h->TargetParticipants(); myheader->fNP = h->ProjectileParticipants(); myheader->fN00 = h->NwNw(); myheader->fN01 = h->NwN(); myheader->fN10 = h->NNw(); myheader->fN11 = h->NN(); myheader->fBB = h->ImpactParameter(); myheader->fRP = h->ReactionPlaneAngle(); myheader->fPSn = h->ProjSpectatorsn(); myheader->fPSp = h->ProjSpectatorsp(); myheader->fTSn = h->TargSpectatorsn(); myheader->fTSp = h->TargSpectatorsn(); myresp->fEtch0p = hEtEta->GetBinContent(hEtEta->FindBin(0.5)); myresp->fEtch1p = hEtEta->GetBinContent(hEtEta->FindBin(1.5)); myresp->fEtch2p = hEtEta->GetBinContent(hEtEta->FindBin(2.5)); myresp->fEtch3p = hEtEta->GetBinContent(hEtEta->FindBin(3.5)); myresp->fEtch4p = hEtEta->GetBinContent(hEtEta->FindBin(4.5)); myresp->fEtch5p = hEtEta->GetBinContent(hEtEta->FindBin(5.5)); myresp->fEtchrp = hEtEta->GetBinContent(hEtEta->FindBin(10.5)); myresp->fEtch0n = hEtEta->GetBinContent(hEtEta->FindBin(-0.5)); myresp->fEtch1n = hEtEta->GetBinContent(hEtEta->FindBin(-1.5)); myresp->fEtch2n = hEtEta->GetBinContent(hEtEta->FindBin(-2.5)); myresp->fEtch3n = hEtEta->GetBinContent(hEtEta->FindBin(-3.5)); myresp->fEtch4n = hEtEta->GetBinContent(hEtEta->FindBin(-4.5)); myresp->fEtch5n = hEtEta->GetBinContent(hEtEta->FindBin(-5.5)); myresp->fEtchrn = hEtEta->GetBinContent(hEtEta->FindBin(-10.5)); myresp->fNch0p = hNEta->GetBinContent(hNEta->FindBin(0.5)); myresp->fNch1p = hNEta->GetBinContent(hNEta->FindBin(1.5)); myresp->fNch2p = hNEta->GetBinContent(hNEta->FindBin(2.5)); myresp->fNch3p = hNEta->GetBinContent(hNEta->FindBin(3.5)); myresp->fNch4p = hNEta->GetBinContent(hNEta->FindBin(4.5)); myresp->fNch5p = hNEta->GetBinContent(hNEta->FindBin(5.5)); myresp->fNchrp = hNEta->GetBinContent(hNEta->FindBin(10.5)); myresp->fNch0n = hNEta->GetBinContent(hNEta->FindBin(-0.5)); myresp->fNch1n = hNEta->GetBinContent(hNEta->FindBin(-1.5)); myresp->fNch2n = hNEta->GetBinContent(hNEta->FindBin(-2.5)); myresp->fNch3n = hNEta->GetBinContent(hNEta->FindBin(-3.5)); myresp->fNch4n = hNEta->GetBinContent(hNEta->FindBin(-4.5)); myresp->fNch5n = hNEta->GetBinContent(hNEta->FindBin(-5.5)); myresp->fNchrn = hNEta->GetBinContent(hNEta->FindBin(-10.5)); tree->Fill(); if (ntuple) { Int_t np = h->TargetParticipants() + h->ProjectileParticipants(); Int_t nc = h->NwNw() + h->NwN() + h->NNw() + h->NN(); Double_t b = h->ImpactParameter(); ntuple->Fill(np,nc,b); } } // end of event loop tree->Write(); ntuple->Write(); outFile->Close(); }
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(); }