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(); }
Bool_t CheckESD(const char* gAliceFileName = "galice.root", const char* esdFileName = "AliESDs.root") { // check the content of the ESD // check values Int_t checkNGenLow = 1; Double_t checkEffLow = 0.5; Double_t checkEffSigma = 3; Double_t checkFakeHigh = 0.5; Double_t checkFakeSigma = 3; Double_t checkResPtInvHigh = 5; Double_t checkResPtInvSigma = 3; Double_t checkResPhiHigh = 10; Double_t checkResPhiSigma = 3; Double_t checkResThetaHigh = 10; Double_t checkResThetaSigma = 3; Double_t checkPIDEffLow = 0.5; Double_t checkPIDEffSigma = 3; Double_t checkResTOFHigh = 500; Double_t checkResTOFSigma = 3; Double_t checkPHOSNLow = 5; Double_t checkPHOSEnergyLow = 0.3; Double_t checkPHOSEnergyHigh = 1.0; Double_t checkEMCALNLow = 50; Double_t checkEMCALEnergyLow = 0.05; Double_t checkEMCALEnergyHigh = 1.0; Double_t checkMUONNLow = 1; Double_t checkMUONPtLow = 0.5; Double_t checkMUONPtHigh = 10.; Double_t cutPtV0 = 0.3; Double_t checkV0EffLow = 0.02; Double_t checkV0EffSigma = 3; Double_t cutPtCascade = 0.5; Double_t checkCascadeEffLow = 0.01; Double_t checkCascadeEffSigma = 3; // open run loader and load gAlice, kinematics and header AliRunLoader* runLoader = AliRunLoader::Open(gAliceFileName); if (!runLoader) { Error("CheckESD", "getting run loader from file %s failed", gAliceFileName); return kFALSE; } runLoader->LoadgAlice(); gAlice = runLoader->GetAliRun(); if (!gAlice) { Error("CheckESD", "no galice object found"); return kFALSE; } runLoader->LoadKinematics(); runLoader->LoadHeader(); // open the ESD file TFile* esdFile = TFile::Open(esdFileName); if (!esdFile || !esdFile->IsOpen()) { Error("CheckESD", "opening ESD file %s failed", esdFileName); return kFALSE; } AliESDEvent * esd = new AliESDEvent; TTree* tree = (TTree*) esdFile->Get("esdTree"); if (!tree) { Error("CheckESD", "no ESD tree found"); return kFALSE; } esd->ReadFromTree(tree); // efficiency and resolution histograms Int_t nBinsPt = 15; Float_t minPt = 0.1; Float_t maxPt = 3.1; TH1F* hGen = CreateHisto("hGen", "generated tracks", nBinsPt, minPt, maxPt, "p_{t} [GeV/c]", "N"); TH1F* hRec = CreateHisto("hRec", "reconstructed tracks", nBinsPt, minPt, maxPt, "p_{t} [GeV/c]", "N"); Int_t nGen = 0; Int_t nRec = 0; Int_t nFake = 0; TH1F* hResPtInv = CreateHisto("hResPtInv", "", 100, -10, 10, "(p_{t,rec}^{-1}-p_{t,sim}^{-1}) / p_{t,sim}^{-1} [%]", "N"); TH1F* hResPhi = CreateHisto("hResPhi", "", 100, -20, 20, "#phi_{rec}-#phi_{sim} [mrad]", "N"); TH1F* hResTheta = CreateHisto("hResTheta", "", 100, -20, 20, "#theta_{rec}-#theta_{sim} [mrad]", "N"); // PID Int_t partCode[AliPID::kSPECIES] = {kElectron, kMuonMinus, kPiPlus, kKPlus, kProton}; const char* partName[AliPID::kSPECIES+1] = {"electron", "muon", "pion", "kaon", "proton", "other"}; Double_t partFrac[AliPID::kSPECIES] = {0.01, 0.01, 0.85, 0.10, 0.05}; Int_t identified[AliPID::kSPECIES+1][AliPID::kSPECIES]; for (Int_t iGen = 0; iGen < AliPID::kSPECIES+1; iGen++) { for (Int_t iRec = 0; iRec < AliPID::kSPECIES; iRec++) { identified[iGen][iRec] = 0; } } Int_t nIdentified = 0; // dE/dx and TOF TH2F* hDEdxRight = new TH2F("hDEdxRight", "", 300, 0, 3, 100, 0, 400); hDEdxRight->SetStats(kFALSE); hDEdxRight->GetXaxis()->SetTitle("p [GeV/c]"); hDEdxRight->GetYaxis()->SetTitle("dE/dx_{TPC}"); hDEdxRight->SetMarkerStyle(kFullCircle); hDEdxRight->SetMarkerSize(0.4); TH2F* hDEdxWrong = new TH2F("hDEdxWrong", "", 300, 0, 3, 100, 0, 400); hDEdxWrong->SetStats(kFALSE); hDEdxWrong->GetXaxis()->SetTitle("p [GeV/c]"); hDEdxWrong->GetYaxis()->SetTitle("dE/dx_{TPC}"); hDEdxWrong->SetMarkerStyle(kFullCircle); hDEdxWrong->SetMarkerSize(0.4); hDEdxWrong->SetMarkerColor(kRed); TH1F* hResTOFRight = CreateHisto("hResTOFRight", "", 100, -1000, 1000, "t_{TOF}-t_{track} [ps]", "N"); TH1F* hResTOFWrong = CreateHisto("hResTOFWrong", "", 100, -1000, 1000, "t_{TOF}-t_{track} [ps]", "N"); hResTOFWrong->SetLineColor(kRed); // calorimeters TH1F* hEPHOS = CreateHisto("hEPHOS", "PHOS", 100, 0, 50, "E [GeV]", "N"); TH1F* hEEMCAL = CreateHisto("hEEMCAL", "EMCAL", 100, 0, 50, "E [GeV]", "N"); // muons TH1F* hPtMUON = CreateHisto("hPtMUON", "MUON", 100, 0, 20, "p_{t} [GeV/c]", "N"); // V0s and cascades TH1F* hMassK0 = CreateHisto("hMassK0", "K^{0}", 100, 0.4, 0.6, "M(#pi^{+}#pi^{-}) [GeV/c^{2}]", "N"); TH1F* hMassLambda = CreateHisto("hMassLambda", "#Lambda", 100, 1.0, 1.2, "M(p#pi^{-}) [GeV/c^{2}]", "N"); TH1F* hMassLambdaBar = CreateHisto("hMassLambdaBar", "#bar{#Lambda}", 100, 1.0, 1.2, "M(#bar{p}#pi^{+}) [GeV/c^{2}]", "N"); Int_t nGenV0s = 0; Int_t nRecV0s = 0; TH1F* hMassXi = CreateHisto("hMassXi", "#Xi", 100, 1.2, 1.5, "M(#Lambda#pi) [GeV/c^{2}]", "N"); TH1F* hMassOmega = CreateHisto("hMassOmega", "#Omega", 100, 1.5, 1.8, "M(#LambdaK) [GeV/c^{2}]", "N"); Int_t nGenCascades = 0; Int_t nRecCascades = 0; // loop over events for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) { runLoader->GetEvent(iEvent); // select simulated primary particles, V0s and cascades AliStack* stack = runLoader->Stack(); Int_t nParticles = stack->GetNtrack(); TArrayF vertex(3); runLoader->GetHeader()->GenEventHeader()->PrimaryVertex(vertex); TObjArray selParticles; TObjArray selV0s; TObjArray selCascades; for (Int_t iParticle = 0; iParticle < nParticles; iParticle++) { TParticle* particle = stack->Particle(iParticle); if (!particle) continue; if (particle->Pt() < 0.001) continue; if (TMath::Abs(particle->Eta()) > 0.9) continue; TVector3 dVertex(particle->Vx() - vertex[0], particle->Vy() - vertex[1], particle->Vz() - vertex[2]); if (dVertex.Mag() > 0.0001) continue; switch (TMath::Abs(particle->GetPdgCode())) { case kElectron: case kMuonMinus: case kPiPlus: case kKPlus: case kProton: { if (particle->Pt() > minPt) { selParticles.Add(particle); nGen++; hGen->Fill(particle->Pt()); } break; } case kK0Short: case kLambda0: { if (particle->Pt() > cutPtV0) { nGenV0s++; selV0s.Add(particle); } break; } case kXiMinus: case kOmegaMinus: { if (particle->Pt() > cutPtCascade) { nGenCascades++; selCascades.Add(particle); } break; } default: break; } } // get the event summary data tree->GetEvent(iEvent); if (!esd) { Error("CheckESD", "no ESD object found for event %d", iEvent); return kFALSE; } // loop over tracks for (Int_t iTrack = 0; iTrack < esd->GetNumberOfTracks(); iTrack++) { AliESDtrack* track = esd->GetTrack(iTrack); // select tracks of selected particles Int_t label = TMath::Abs(track->GetLabel()); if (label > stack->GetNtrack()) continue; // background TParticle* particle = stack->Particle(label); if (!selParticles.Contains(particle)) continue; if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) continue; if (track->GetConstrainedChi2() > 1e9) continue; selParticles.Remove(particle); // don't count multiple tracks nRec++; hRec->Fill(particle->Pt()); if (track->GetLabel() < 0) nFake++; // resolutions hResPtInv->Fill(100. * (TMath::Abs(track->GetSigned1Pt()) - 1./particle->Pt()) * particle->Pt()); hResPhi->Fill(1000. * (track->Phi() - particle->Phi())); hResTheta->Fill(1000. * (track->Theta() - particle->Theta())); // PID if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) continue; Int_t iGen = 5; for (Int_t i = 0; i < AliPID::kSPECIES; i++) { if (TMath::Abs(particle->GetPdgCode()) == partCode[i]) iGen = i; } Double_t probability[AliPID::kSPECIES]; track->GetESDpid(probability); Double_t pMax = 0; Int_t iRec = 0; for (Int_t i = 0; i < AliPID::kSPECIES; i++) { probability[i] *= partFrac[i]; if (probability[i] > pMax) { pMax = probability[i]; iRec = i; } } identified[iGen][iRec]++; if (iGen == iRec) nIdentified++; // dE/dx and TOF Double_t time[AliPID::kSPECIES]; track->GetIntegratedTimes(time); if (iGen == iRec) { hDEdxRight->Fill(particle->P(), track->GetTPCsignal()); if ((track->GetStatus() & AliESDtrack::kTOFpid) != 0) { hResTOFRight->Fill(track->GetTOFsignal() - time[iRec]); } } else { hDEdxWrong->Fill(particle->P(), track->GetTPCsignal()); if ((track->GetStatus() & AliESDtrack::kTOFpid) != 0) { hResTOFWrong->Fill(track->GetTOFsignal() - time[iRec]); } } } // loop over muon tracks { for (Int_t iTrack = 0; iTrack < esd->GetNumberOfMuonTracks(); iTrack++) { AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack); Double_t ptInv = TMath::Abs(muonTrack->GetInverseBendingMomentum()); if (ptInv > 0.001) { hPtMUON->Fill(1./ptInv); } } } // loop over V0s for (Int_t iV0 = 0; iV0 < esd->GetNumberOfV0s(); iV0++) { AliESDv0* v0 = esd->GetV0(iV0); if (v0->GetOnFlyStatus()) continue; v0->ChangeMassHypothesis(kK0Short); hMassK0->Fill(v0->GetEffMass()); v0->ChangeMassHypothesis(kLambda0); hMassLambda->Fill(v0->GetEffMass()); v0->ChangeMassHypothesis(kLambda0Bar); hMassLambdaBar->Fill(v0->GetEffMass()); Int_t negLabel = TMath::Abs(esd->GetTrack(v0->GetNindex())->GetLabel()); if (negLabel > stack->GetNtrack()) continue; // background Int_t negMother = stack->Particle(negLabel)->GetMother(0); if (negMother < 0) continue; Int_t posLabel = TMath::Abs(esd->GetTrack(v0->GetPindex())->GetLabel()); if (posLabel > stack->GetNtrack()) continue; // background Int_t posMother = stack->Particle(posLabel)->GetMother(0); if (negMother != posMother) continue; TParticle* particle = stack->Particle(negMother); if (!selV0s.Contains(particle)) continue; selV0s.Remove(particle); nRecV0s++; } // loop over Cascades for (Int_t iCascade = 0; iCascade < esd->GetNumberOfCascades(); iCascade++) { AliESDcascade* cascade = esd->GetCascade(iCascade); Double_t v0q; cascade->ChangeMassHypothesis(v0q,kXiMinus); hMassXi->Fill(cascade->GetEffMassXi()); cascade->ChangeMassHypothesis(v0q,kOmegaMinus); hMassOmega->Fill(cascade->GetEffMassXi()); Int_t negLabel = TMath::Abs(esd->GetTrack(cascade->GetNindex()) ->GetLabel()); if (negLabel > stack->GetNtrack()) continue; // background Int_t negMother = stack->Particle(negLabel)->GetMother(0); if (negMother < 0) continue; Int_t posLabel = TMath::Abs(esd->GetTrack(cascade->GetPindex()) ->GetLabel()); if (posLabel > stack->GetNtrack()) continue; // background Int_t posMother = stack->Particle(posLabel)->GetMother(0); if (negMother != posMother) continue; Int_t v0Mother = stack->Particle(negMother)->GetMother(0); if (v0Mother < 0) continue; Int_t bacLabel = TMath::Abs(esd->GetTrack(cascade->GetBindex()) ->GetLabel()); if (bacLabel > stack->GetNtrack()) continue; // background Int_t bacMother = stack->Particle(bacLabel)->GetMother(0); if (v0Mother != bacMother) continue; TParticle* particle = stack->Particle(v0Mother); if (!selCascades.Contains(particle)) continue; selCascades.Remove(particle); nRecCascades++; } // loop over the clusters { for (Int_t iCluster=0; iCluster<esd->GetNumberOfCaloClusters(); iCluster++) { AliESDCaloCluster * clust = esd->GetCaloCluster(iCluster); if (clust->IsPHOS()) hEPHOS->Fill(clust->E()); if (clust->IsEMCAL()) hEEMCAL->Fill(clust->E()); } } } // perform checks if (nGen < checkNGenLow) { Warning("CheckESD", "low number of generated particles: %d", Int_t(nGen)); } TH1F* hEff = CreateEffHisto(hGen, hRec); Info("CheckESD", "%d out of %d tracks reconstructed including %d " "fake tracks", nRec, nGen, nFake); if (nGen > 0) { // efficiency Double_t eff = nRec*1./nGen; Double_t effError = TMath::Sqrt(eff*(1.-eff) / nGen); Double_t fake = nFake*1./nGen; Double_t fakeError = TMath::Sqrt(fake*(1.-fake) / nGen); Info("CheckESD", "eff = (%.1f +- %.1f) %% fake = (%.1f +- %.1f) %%", 100.*eff, 100.*effError, 100.*fake, 100.*fakeError); if (eff < checkEffLow - checkEffSigma*effError) { Warning("CheckESD", "low efficiency: (%.1f +- %.1f) %%", 100.*eff, 100.*effError); } if (fake > checkFakeHigh + checkFakeSigma*fakeError) { Warning("CheckESD", "high fake: (%.1f +- %.1f) %%", 100.*fake, 100.*fakeError); } // resolutions Double_t res, resError; if (FitHisto(hResPtInv, res, resError)) { Info("CheckESD", "relative inverse pt resolution = (%.1f +- %.1f) %%", res, resError); if (res > checkResPtInvHigh + checkResPtInvSigma*resError) { Warning("CheckESD", "bad pt resolution: (%.1f +- %.1f) %%", res, resError); } } if (FitHisto(hResPhi, res, resError)) { Info("CheckESD", "phi resolution = (%.1f +- %.1f) mrad", res, resError); if (res > checkResPhiHigh + checkResPhiSigma*resError) { Warning("CheckESD", "bad phi resolution: (%.1f +- %.1f) mrad", res, resError); } } if (FitHisto(hResTheta, res, resError)) { Info("CheckESD", "theta resolution = (%.1f +- %.1f) mrad", res, resError); if (res > checkResThetaHigh + checkResThetaSigma*resError) { Warning("CheckESD", "bad theta resolution: (%.1f +- %.1f) mrad", res, resError); } } // PID if (nRec > 0) { Double_t eff = nIdentified*1./nRec; Double_t effError = TMath::Sqrt(eff*(1.-eff) / nRec); Info("CheckESD", "PID eff = (%.1f +- %.1f) %%", 100.*eff, 100.*effError); if (eff < checkPIDEffLow - checkPIDEffSigma*effError) { Warning("CheckESD", "low PID efficiency: (%.1f +- %.1f) %%", 100.*eff, 100.*effError); } } printf("%9s:", "gen\\rec"); for (Int_t iRec = 0; iRec < AliPID::kSPECIES; iRec++) { printf("%9s", partName[iRec]); } printf("\n"); for (Int_t iGen = 0; iGen < AliPID::kSPECIES+1; iGen++) { printf("%9s:", partName[iGen]); for (Int_t iRec = 0; iRec < AliPID::kSPECIES; iRec++) { printf("%9d", identified[iGen][iRec]); } printf("\n"); } if (FitHisto(hResTOFRight, res, resError)) { Info("CheckESD", "TOF resolution = (%.1f +- %.1f) ps", res, resError); if (res > checkResTOFHigh + checkResTOFSigma*resError) { Warning("CheckESD", "bad TOF resolution: (%.1f +- %.1f) ps", res, resError); } } // calorimeters if (hEPHOS->Integral() < checkPHOSNLow) { Warning("CheckESD", "low number of PHOS particles: %d", Int_t(hEPHOS->Integral())); } else { Double_t mean = hEPHOS->GetMean(); if (mean < checkPHOSEnergyLow) { Warning("CheckESD", "low mean PHOS energy: %.1f GeV", mean); } else if (mean > checkPHOSEnergyHigh) { Warning("CheckESD", "high mean PHOS energy: %.1f GeV", mean); } } if (hEEMCAL->Integral() < checkEMCALNLow) { Warning("CheckESD", "low number of EMCAL particles: %d", Int_t(hEEMCAL->Integral())); } else { Double_t mean = hEEMCAL->GetMean(); if (mean < checkEMCALEnergyLow) { Warning("CheckESD", "low mean EMCAL energy: %.1f GeV", mean); } else if (mean > checkEMCALEnergyHigh) { Warning("CheckESD", "high mean EMCAL energy: %.1f GeV", mean); } } // muons if (hPtMUON->Integral() < checkMUONNLow) { Warning("CheckESD", "low number of MUON particles: %d", Int_t(hPtMUON->Integral())); } else { Double_t mean = hPtMUON->GetMean(); if (mean < checkMUONPtLow) { Warning("CheckESD", "low mean MUON pt: %.1f GeV/c", mean); } else if (mean > checkMUONPtHigh) { Warning("CheckESD", "high mean MUON pt: %.1f GeV/c", mean); } } // V0s if (nGenV0s > 0) { Double_t eff = nRecV0s*1./nGenV0s; Double_t effError = TMath::Sqrt(eff*(1.-eff) / nGenV0s); if (effError == 0) effError = checkV0EffLow / TMath::Sqrt(1.*nGenV0s); Info("CheckESD", "V0 eff = (%.1f +- %.1f) %%", 100.*eff, 100.*effError); if (eff < checkV0EffLow - checkV0EffSigma*effError) { Warning("CheckESD", "low V0 efficiency: (%.1f +- %.1f) %%", 100.*eff, 100.*effError); } } // Cascades if (nGenCascades > 0) { Double_t eff = nRecCascades*1./nGenCascades; Double_t effError = TMath::Sqrt(eff*(1.-eff) / nGenCascades); if (effError == 0) effError = checkV0EffLow / TMath::Sqrt(1.*nGenCascades); Info("CheckESD", "Cascade eff = (%.1f +- %.1f) %%", 100.*eff, 100.*effError); if (eff < checkCascadeEffLow - checkCascadeEffSigma*effError) { Warning("CheckESD", "low Cascade efficiency: (%.1f +- %.1f) %%", 100.*eff, 100.*effError); } } } // draw the histograms if not in batch mode if (!gROOT->IsBatch()) { new TCanvas; hEff->DrawCopy(); new TCanvas; hResPtInv->DrawCopy("E"); new TCanvas; hResPhi->DrawCopy("E"); new TCanvas; hResTheta->DrawCopy("E"); new TCanvas; hDEdxRight->DrawCopy(); hDEdxWrong->DrawCopy("SAME"); new TCanvas; hResTOFRight->DrawCopy("E"); hResTOFWrong->DrawCopy("SAME"); new TCanvas; hEPHOS->DrawCopy("E"); new TCanvas; hEEMCAL->DrawCopy("E"); new TCanvas; hPtMUON->DrawCopy("E"); new TCanvas; hMassK0->DrawCopy("E"); new TCanvas; hMassLambda->DrawCopy("E"); new TCanvas; hMassLambdaBar->DrawCopy("E"); new TCanvas; hMassXi->DrawCopy("E"); new TCanvas; hMassOmega->DrawCopy("E"); } // write the output histograms to a file TFile* outputFile = TFile::Open("check.root", "recreate"); if (!outputFile || !outputFile->IsOpen()) { Error("CheckESD", "opening output file check.root failed"); return kFALSE; } hEff->Write(); hResPtInv->Write(); hResPhi->Write(); hResTheta->Write(); hDEdxRight->Write(); hDEdxWrong->Write(); hResTOFRight->Write(); hResTOFWrong->Write(); hEPHOS->Write(); hEEMCAL->Write(); hPtMUON->Write(); hMassK0->Write(); hMassLambda->Write(); hMassLambdaBar->Write(); hMassXi->Write(); hMassOmega->Write(); outputFile->Close(); delete outputFile; // clean up delete hGen; delete hRec; delete hEff; delete hResPtInv; delete hResPhi; delete hResTheta; delete hDEdxRight; delete hDEdxWrong; delete hResTOFRight; delete hResTOFWrong; delete hEPHOS; delete hEEMCAL; delete hPtMUON; delete hMassK0; delete hMassLambda; delete hMassLambdaBar; delete hMassXi; delete hMassOmega; delete esd; esdFile->Close(); delete esdFile; runLoader->UnloadHeader(); runLoader->UnloadKinematics(); delete runLoader; // result of check Info("CheckESD", "check of ESD was successfull"); return kTRUE; }
void runSimulation(int seed, int nevents, const char* config, const char* embedwith, int runnumber) { // Uncoment following lines to run simulation with local residual mis-alignment // (generated via MUONGenerateGeometryData.C macro) // AliCDBManager* man = AliCDBManager::Instance(); // man->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); // man->SetSpecificStorage("MUON/Align/Data","local://$ALICE_ROOT/OCDB/MUON/ResMisAlignCDB"); AliSimulation MuonSim(config); if ( strlen(embedwith) > 0 ) { // setups specific to embedding gAlice->SetConfigFunction("Config(\"\", \"param\", \"AliMUONDigitStoreV2S\",kTRUE);"); // get the run number from real data AliRunLoader* runLoader = AliRunLoader::Open(embedwith,"titi"); if (runLoader == 0x0) { cerr << Form("Cannot open file %s",embedwith) << endl; return; } runLoader->LoadHeader(); if ( ! runLoader->GetHeader() ) { cerr << "Cannot load header." << endl; return; } else { Int_t runNumber = runLoader->GetHeader()->GetRun(); MuonSim.SetRunNumber(runNumber); cout << Form("***** RUN NUMBER SET TO %09d ACCORDING TO %s ",runNumber,embedwith) << endl; } runLoader->UnloadHeader(); delete runLoader; cout << "***** EMBEDDING MODE : USING RAW OCDB" << endl; AliCDBManager::Instance()->SetDefaultStorage("raw://"); AliCDBManager::Instance()->SetSpecificStorage("local://$ALICE_ROOT/OCDB","MUON/Align/Data"); } else if ( runnumber > 0 ) { // simulation with anchor run cout << "***** ANCHOR RUN MODE : USING RAW OCDB AS MUCH AS POSSIBLE" << endl; cout << "***** AND TAKING VERTEX FROM OCDB IF AVAILABLE" << endl; // Last parameter of Config.C indicates we're doing realistic simulations, so we NEED // the ITS in the geometry gAlice->SetConfigFunction("Config(\"\", \"param\", \"AliMUONDigitStoreV2S\",kFALSE,kTRUE);"); AliCDBManager::Instance()->SetDefaultStorage("raw://"); // use something like : "alien://folder=/alice/data/2011/OCDB?cacheFold=/Users/laurent/OCDBcache" instead of "raw://" // if getting slow/problematic accesses to OCDB... AliCDBManager::Instance()->SetSpecificStorage("MUON/Align/Data","alien://folder=/alice/cern.ch/user/j/jcastill/LHC10hMisAlignCDB"); MuonSim.SetRunNumber(runnumber); MuonSim.UseVertexFromCDB(); } else { gAlice->SetConfigFunction("Config(\"\", \"param\", \"AliMUONDigitStoreV2S\",kFALSE);"); } MuonSim.SetSeed(seed); MuonSim.SetTriggerConfig("MUON"); MuonSim.SetWriteRawData("MUON ","raw.root",kTRUE); MuonSim.SetMakeSDigits("MUON"); MuonSim.SetMakeDigits("MUON ITS"); // ITS needed to propagate the simulated vertex MuonSim.SetMakeDigitsFromHits("ITS"); // ITS needed to propagate the simulated vertex MuonSim.SetRunHLT("libAliHLTMUON.so chains=dHLT-sim"); MuonSim.SetRunQA("MUON:ALL"); if ( strlen(embedwith) > 0 ) { MuonSim.MergeWith(embedwith); } MuonSim.Run(nevents); //gObjectTable->Print(); }
int main(int argc, char* argv[]) { TApplication theApp(srcName.Data(), &argc, argv); //============================================================================= for (int i=0; i<argc; i++) cout << i << ", " << argv[i] << endl; //============================================================================= if (argc<5) return -1; TString sPath = argv[1]; if (sPath.IsNull()) return -1; TString sFile = argv[2]; if (sFile.IsNull()) return -1; TString sJetR = argv[3]; if (sJetR.IsNull()) return -1; TString sSjeR = argv[4]; if (sSjeR.IsNull()) return -1; //============================================================================= sPath.ReplaceAll("#", "/"); //============================================================================= double dJetR = -1.; if (sJetR=="JetR02") dJetR = 0.2; if (sJetR=="JetR03") dJetR = 0.3; if (sJetR=="JetR04") dJetR = 0.4; if (sJetR=="JetR05") dJetR = 0.5; if (dJetR<0.) return -1; cout << "Jet R = " << dJetR << endl; //============================================================================= double dSjeR = -1.; if (sSjeR=="SjeR01") dSjeR = 0.1; if (sSjeR=="SjeR02") dSjeR = 0.2; if (sSjeR=="SjeR03") dSjeR = 0.3; if (sSjeR=="SjeR04") dSjeR = 0.4; if (dSjeR<0.) return -1; cout << "Sub-jet R = " << dSjeR << endl; //============================================================================= const double dJetsPtMin = 0.001; const double dCutEtaMax = 1.6; const double dJetEtaMax = 1.; const double dJetAreaRef = TMath::Pi() * dJetR * dJetR; fastjet::GhostedAreaSpec areaSpc(dCutEtaMax); fastjet::JetDefinition jetsDef(fastjet::antikt_algorithm, dJetR, fastjet::BIpt_scheme, fastjet::Best); //fastjet::AreaDefinition areaDef(fastjet::active_area,areaSpc); fastjet::AreaDefinition areaDef(fastjet::active_area_explicit_ghosts,areaSpc); //fastjet::JetDefinition bkgsDef(fastjet::kt_algorithm, 0.2, fastjet::BIpt_scheme, fastjet::Best); //fastjet::AreaDefinition aBkgDef(fastjet::active_area_explicit_ghosts, areaSpc); fastjet::Selector selectJet = fastjet::SelectorAbsEtaMax(dJetEtaMax); //fastjet::Selector selectRho = fastjet::SelectorAbsEtaMax(dCutEtaMax-0.2); //fastjet::Selector selecHard = fastjet::SelectorNHardest(2); //fastjet::Selector selectBkg = selectRho * (!(selecHard)); //fastjet::JetMedianBackgroundEstimator bkgsEstimator(selectBkg, bkgsDef, aBkgDef); //fastjet::Subtractor bkgSubtractor(&bkgsEstimator); fastjet::JetDefinition subjDef(fastjet::antikt_algorithm, dSjeR, fastjet::BIpt_scheme, fastjet::Best); //============================================================================= std::vector<fastjet::PseudoJet> fjInput; //============================================================================= TList *list = new TList(); TH1D *hPtHat = new TH1D("hPtHat", "", 1000, 0., 1000.); TH1D *hJet = new TH1D("hJet", "", 1000, 0., 1000.); hJet->Sumw2(); list->Add(hJet); TH2D *hJetNsj = new TH2D("hJetNsj", "", 1000, 0., 1000., 101, -0.5, 100.5); hJetNsj->Sumw2(); list->Add(hJetNsj); TH2D *hJetIsj = new TH2D("hJetIsj", "", 1000, 0., 1000., 1000, 0., 1000.); hJetIsj->Sumw2(); list->Add(hJetIsj); TH2D *hJet1sj = new TH2D("hJet1sj", "", 1000, 0., 1000., 1000, 0., 1000.); hJet1sj->Sumw2(); list->Add(hJet1sj); TH2D *hJet2sj = new TH2D("hJet2sj", "", 1000, 0., 1000., 1000, 0., 1000.); hJet2sj->Sumw2(); list->Add(hJet2sj); TH2D *hJetDsj = new TH2D("hJetDsj", "", 1000, 0., 1000., 1000, 0., 1000.); hJetDsj->Sumw2(); list->Add(hJetDsj); TH2D *hJetIsz = new TH2D("hJetIsz", "", 1000, 0., 1000., 120, 0., 1.2); hJetIsz->Sumw2(); list->Add(hJetIsz); TH2D *hJet1sz = new TH2D("hJet1sz", "", 1000, 0., 1000., 120, 0., 1.2); hJet1sz->Sumw2(); list->Add(hJet1sz); TH2D *hJet2sz = new TH2D("hJet2sz", "", 1000, 0., 1000., 120, 0., 1.2); hJet2sz->Sumw2(); list->Add(hJet2sz); TH2D *hJetDsz = new TH2D("hJetDsz", "", 1000, 0., 1000., 120, 0., 1.2); hJetDsz->Sumw2(); list->Add(hJetDsz); //============================================================================= AliRunLoader *rl = AliRunLoader::Open(Form("%s/galice.root",sPath.Data())); if (!rl) return -1; if (rl->LoadHeader()) return -1; if (rl->LoadKinematics("READ")) return -1; //============================================================================= for (Int_t iEvent=0; iEvent<rl->GetNumberOfEvents(); iEvent++) { fjInput.resize(0); if (rl->GetEvent(iEvent)) continue; //============================================================================= AliStack *pStack = rl->Stack(); if (!pStack) continue; AliHeader *pHeader = rl->GetHeader(); if (!pHeader) continue; //============================================================================= AliGenPythiaEventHeader *pHeadPy = (AliGenPythiaEventHeader*)pHeader->GenEventHeader(); if (!pHeadPy) continue; hPtHat->Fill(pHeadPy->GetPtHard()); //============================================================================= for (Int_t i=0; i<pStack->GetNtrack(); i++) if (pStack->IsPhysicalPrimary(i)) { TParticle *pTrk = pStack->Particle(i); if (!pTrk) continue; if (TMath::Abs(pTrk->Eta())>dCutEtaMax) { pTrk = 0; continue; } // TParticlePDG *pPDG = pTrk->GetPDG(); if (!pPDG) { pTrk = 0; continue; } fjInput.push_back(fastjet::PseudoJet(pTrk->Px(), pTrk->Py(), pTrk->Pz(), pTrk->P())); // pPDG = 0; pTrk = 0; } //============================================================================= fastjet::ClusterSequenceArea clustSeq(fjInput, jetsDef, areaDef); std::vector<fastjet::PseudoJet> includJets = clustSeq.inclusive_jets(dJetsPtMin); // std::vector<fastjet::PseudoJet> subtedJets = bkgSubtractor(includJets); std::vector<fastjet::PseudoJet> selectJets = selectJet(includJets); // std::vector<fastjet::PseudoJet> sortedJets = fastjet::sorted_by_pt(selectJets); for (int j=0; j<selectJets.size(); j++) { double dJet = selectJets[j].pt(); hJet->Fill(dJet); //============================================================================= fastjet::Filter trimmer(subjDef, fastjet::SelectorPtFractionMin(0.)); fastjet::PseudoJet trimmdJet = trimmer(selectJets[j]); std::vector<fastjet::PseudoJet> trimmdSj = trimmdJet.pieces(); double nIsj = 0.; double d1sj = -1.; int k1sj = -1; double d2sj = -1.; int k2sj = -1; for (int i=0; i<trimmdSj.size(); i++) { double dIsj = trimmdSj[i].pt(); if (dIsj<0.001) continue; hJetIsj->Fill(dJet, dIsj); hJetIsz->Fill(dJet, dIsj/dJet); if (dIsj>d1sj) { d2sj = d1sj; k2sj = k1sj; d1sj = dIsj; k1sj = i; } else if (dIsj>d2sj) { d2sj = dIsj; k2sj = i; } nIsj += 1.; } hJetNsj->Fill(dJet, nIsj); if (d1sj>0.) { hJet1sj->Fill(dJet, d1sj); hJet1sz->Fill(dJet, d1sj/dJet); } if (d2sj>0.) { hJet2sj->Fill(dJet, d2sj); hJet2sz->Fill(dJet, d2sj/dJet); } if ((d1sj>0.) && (d2sj>0.)) { double dsj = d1sj - d2sj; double dsz = dsj / dJet; hJetDsj->Fill(dJet, dsj); hJetDsz->Fill(dJet, dsz); } } //============================================================================= pStack = 0; pHeadPy = 0; pHeader = 0; } //============================================================================= rl->UnloadgAlice(); rl->UnloadHeader(); rl->UnloadKinematics(); rl->RemoveEventFolder(); //============================================================================= TFile *file = TFile::Open(Form("%s/pyxsec_hists.root",sPath.Data()), "READ"); TList *lXsc = (TList*)file->Get("cFilterList"); file->Close(); TH1D *hWeightSum = (TH1D*)lXsc->FindObject("h1Trials"); hWeightSum->SetName("hWeightSum"); TProfile *hSigmaGen = (TProfile*)lXsc->FindObject("h1Xsec"); hSigmaGen->SetName("hSigmaGen"); //============================================================================= file = TFile::Open(Form("%s.root",sFile.Data()), "NEW"); hPtHat->Write(); hWeightSum->Write(); hSigmaGen->Write(); list->Write(); file->Close(); //============================================================================= cout << "DONE" << endl; //============================================================================= return 0; }
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(); }
Int_t RunHLTITS(Int_t nev=1,Int_t run=0) { // gSystem->Load("libAliHLTITS"); TStopwatch timer; timer.Start(); if (gAlice) { delete gAlice->GetRunLoader(); delete gAlice; gAlice=0; } AliRunLoader *rl = AliRunLoader::Open("galice.root"); if (rl == 0x0) { cerr<<"Can not open session"<<endl; return 1; } Int_t retval = rl->LoadgAlice(); if (retval) { cerr<<"AliESDtest.C : LoadgAlice returned error"<<endl; delete rl; return 1; } retval = rl->LoadHeader(); if (retval) { cerr<<"AliESDtest.C : LoadHeader returned error"<<endl; delete rl; return 2; } gAlice=rl->GetAliRun(); AliTracker::SetFieldMap(gAlice->Field()); AliITSLoader* itsl = (AliITSLoader*)rl->GetLoader("ITSLoader"); if (itsl == 0x0) { cerr<<"AliESDtest.C : Can not get the ITS loader"<<endl; return 3; } itsl->LoadRecPoints("read"); AliITS *dITS = (AliITS*)gAlice->GetDetector("ITS"); if (!dITS) { cerr<<"AliESDtest.C : Can not find the ITS detector !"<<endl; return 4; } // AliITSgeom *geom = dITS->GetITSgeom(); AliITSgeom *geom = new AliITSgeom(); geom->ReadNewFile("$ALICE_ROOT/ITS/ITSgeometry_vPPRasymmFMD.det"); //An instance of the HLT ITS tracker AliHLTITStracker itsTracker(geom); TFile *ef=TFile::Open("AliESDs.root"); if (!ef || !ef->IsOpen()) {cerr<<"Can't AliESDs.root !\n"; return 1;} AliESD* event = new AliESD; TTree* tree = (TTree*) ef->Get("esdTree"); if (!tree) {cerr<<"no ESD tree found\n"; return 1;}; tree->SetBranchAddress("ESD", &event); TFile *itsf=TFile::Open("AliESDits.root","RECREATE"); if ((!itsf)||(!itsf->IsOpen())) { cerr<<"Can't AliESDits.root !\n"; return 1; } Int_t rc=0; if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents(); //The loop over events for (Int_t i=0; i<nev; i++) { cerr<<"\n\nProcessing event number : "<<i<<endl; tree->GetEvent(i); rl->GetEvent(i); TArrayF v(3); rl->GetHeader()->GenEventHeader()->PrimaryVertex(v); Double_t vtx[3]={v[0],v[1],v[2]}; Double_t cvtx[3]={0.005,0.005,0.010}; cout<<"MC vertex position: "<<v[2]<<endl; AliHLTITSVertexerZ vertexer("null"); AliESDVertex* vertex = NULL; TStopwatch timer2; timer2.Start(); TTree* treeClusters = itsl->TreeR(); // vertex = vertexer.FindVertexForCurrentEvent(i); // AliESDVertex *vertex = vertexer.FindVertexForCurrentEvent(geom,treeClusters); vertex = new AliESDVertex(vtx,cvtx); timer2.Stop(); timer2.Print(); if(!vertex){ cerr<<"Vertex not found"<<endl; vertex = new AliESDVertex(vtx,cvtx); } else { vertex->SetTruePos(vtx); // store also the vertex from MC } event->SetVertex(vertex); Double_t vtxPos[3]; Double_t vtxErr[3]; vertex->GetXYZ(vtxPos); vertex->GetSigmaXYZ(vtxErr); itsTracker.SetVertex(vtxPos,vtxErr); TTree *itsTree=itsl->TreeR(); if (!itsTree) { cerr<<"Can't get the ITS cluster tree !\n"; return 4; } itsTracker.LoadClusters(itsTree); rc+=itsTracker.Clusters2Tracks(event); // rc+=itsTracker.PropagateBack(event); itsTracker.UnloadClusters(); if (rc==0) { TTree* tree = new TTree("esdTree", "Tree with ESD objects"); tree->Branch("ESD", "AliESD", &event); tree->Fill(); itsf->cd(); tree->Write(); } if (rc) { cerr<<"Something bad happened...\n"; } } delete event; itsf->Close(); ef->Close(); // delete rl; timer.Stop(); timer.Print(); return rc; }