//_____________________________________________________________________________ Bool_t ProofPythia::Process(Long64_t entry) { // Main event loop fPythia->GenerateEvent(); if (entry < 2) fPythia->EventListing(); fPythia->ImportParticles(fP, "All"); Int_t nTot = fPythia->GetN(); fPythia->ImportParticles(fP, "All"); Int_t np = fP->GetEntriesFast(); // Particle loop Int_t nCharged = 0; for (Int_t ip = 0; ip < np; ip++) { TParticle* part = (TParticle*) fP->At(ip); Int_t ist = part->GetStatusCode(); Int_t pdg = part->GetPdgCode(); if (ist != 1) continue; Float_t charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge(); if (charge == 0.) continue; nCharged++; Float_t eta = part->Eta(); Float_t pt = part->Pt(); if (pt > 0.) fPt->Fill(pt); if ((eta > -10) && (eta < 10)) fEta->Fill(eta); } fHist->Fill(nCharged); fTot->Fill(nTot); return kTRUE; }
void pythia8(Int_t nev = 100, Int_t ndeb = 1) { const char *p8dataenv = gSystem->Getenv("PYTHIA8DATA"); if (!p8dataenv) { const char *p8env = gSystem->Getenv("PYTHIA8"); if (!p8env) { Error("pythia8.C", "Environment variable PYTHIA8 must contain path to pythia directory!"); return; } TString p8d = p8env; p8d += "/xmldoc"; gSystem->Setenv("PYTHIA8DATA", p8d); } const char* path = gSystem->ExpandPathName("$PYTHIA8DATA"); if (gSystem->AccessPathName(path)) { Error("pythia8.C", "Environment variable PYTHIA8DATA must contain path to $PYTHIA8/xmldoc directory !"); return; } // Load libraries #ifndef G__WIN32 // Pythia8 is a static library on Windows if (gSystem->Getenv("PYTHIA8")) { gSystem->Load("$PYTHIA8/lib/libpythia8"); } else { gSystem->Load("libpythia8"); } #endif gSystem->Load("libEG"); gSystem->Load("libEGPythia8"); // Histograms TH1F* etaH = new TH1F("etaH", "Pseudorapidity", 120, -12., 12.); TH1F* ptH = new TH1F("ptH", "pt", 50, 0., 10.); // Array of particles TClonesArray* particles = new TClonesArray("TParticle", 1000); // Create pythia8 object TPythia8* pythia8 = new TPythia8(); // Configure pythia8->ReadString("HardQCD:all = on"); // Initialize pythia8->Initialize(2212 /* p */, 2212 /* p */, 14000. /* TeV */); // Event loop for (Int_t iev = 0; iev < nev; iev++) { pythia8->GenerateEvent(); if (iev < ndeb) pythia8->EventListing(); pythia8->ImportParticles(particles,"All"); Int_t np = particles->GetEntriesFast(); // Particle loop for (Int_t ip = 0; ip < np; ip++) { TParticle* part = (TParticle*) particles->At(ip); Int_t ist = part->GetStatusCode(); // Positive codes are final particles. if (ist <= 0) continue; Int_t pdg = part->GetPdgCode(); Float_t charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge(); if (charge == 0.) continue; Float_t eta = part->Eta(); Float_t pt = part->Pt(); etaH->Fill(eta); if (pt > 0.) ptH->Fill(pt, 1./(2. * pt)); } } pythia8->PrintStatistics(); TCanvas* c1 = new TCanvas("c1","Pythia8 test example",800,800); c1->Divide(1, 2); c1->cd(1); etaH->Scale(5./Float_t(nev)); etaH->Draw(); etaH->SetXTitle("#eta"); etaH->SetYTitle("dN/d#eta"); c1->cd(2); gPad->SetLogy(); ptH->Scale(5./Float_t(nev)); ptH->Draw(); ptH->SetXTitle("p_{t} [GeV/c]"); ptH->SetYTitle("dN/dp_{t}^{2} [GeV/c]^{-2}"); }
void pythia8_susy() { Int_t maxEvts = 100; // Maximo numero de eventos char* path = gSystem->ExpandPathName("$PYTHIA8DATA"); if (gSystem->AccessPathName(path)) { Warning("pythia8.C", "Environment variable PYTHIA8DATA must contain path to pythi8100/xmldoc directory !"); return; } // Load libraries gSystem->Load("$PYTHIA8/lib/libpythia8"); gSystem->Load("$PYTHIA8/lib/liblhapdfdummy"); gSystem->Load("libEG"); gSystem->Load("libEGPythia8"); //Definir archivo de salida TFile * outfile = new TFile("eventos_pythia8_SUSY.root","RECREATE"); // Array of particles TClonesArray* particles = new TClonesArray("TParticle", 5000); //Definir el TTree TTree*tree= new TTree("tree","Arbol con particulas segun Pythia8"); tree->Branch("particles",&particles); // Create pythia8 object TPythia8* pythia8 = new TPythia8(); //*Configurar: Aqui seleccione el proceso que quiere simular pythia8->ReadString("SUSY:all = on"); //Todos los procesos susy posibles //pythia8->ReadString("SUSY:qqbar2chi+-chi0 = on"); //Un proceso en especial //Importante: pasar a Pythia8 el nombre del archivo SLHA pythia8->ReadString("SLHA:file = SUSY_LM2_sftsht.slha"); //insertar aqui el nombre del archivo SLHA // Initialize pythia8->Initialize(2212 /* p */, 2212 /* p */, 7000. /* TeV */); int iev = 0; // Event loop while( iev < maxEvts ) { pythia8->GenerateEvent(); if (iev < 1) pythia8->EventListing(); pythia8->ImportParticles(particles,"All"); Int_t np = particles->GetEntriesFast(); // Particle loop for (Int_t ip = 0; ip < np; ip++) { TParticle* part = (TParticle*) particles->At(ip); Int_t ist = part->GetStatusCode(); Int_t pdg = part->GetPdgCode(); } tree->Fill(); ++iev; } pythia8->PrintStatistics(); outfile->Write(); outfile->Close(); }
//!PG main function int selector (TChain * tree, histos & plots, int if_signal) { plots.v_hardTAGPt = -99; plots.v_softTAGPt = -99; plots.v_TAGDProdEta = -99; plots.v_TAGDeta = -99; plots.v_TAGMinv = -99; plots.v_LepLep = -99; plots.v_hardLEPPt = -99; plots.v_softLEPPt = -99; plots.v_LEPDPhi = -99; plots.v_LEPDEta = -99; plots.v_LEPDR = -99; plots.v_LEPMinv = -99; plots.v_LEPProdCharge = -99; plots.v_hardLEPCharge = -99; plots.v_softLEPCharge = -99; plots.v_MET = -99; plots.v_ojets = -99 ; plots.v_ojetsCJV = -99 ; plots.v_ojetsRegionalCJV = -99 ; plots.v_ojetsZepp_01 = -99 ; plots.v_ojetsZepp_02 = -99 ; plots.v_ojetsZepp_03 = -99 ; plots.v_ojetsZepp_04 = -99 ; plots.v_ojetsZepp_05 = -99 ; plots.v_ojetsZepp_06 = -99 ; plots.v_ojetsZepp_07 = -99 ; plots.v_ojetsZepp_08 = -99 ; plots.v_ojetsZepp_09 = -99 ; plots.v_ojetsZepp_10 = -99 ; plots.v_ojetsZepp_11 = -99 ; plots.v_ojetsZepp_12 = -99 ; plots.v_ojetsZepp_13 = -99 ; plots.v_ojetsZepp_14 = -99 ; plots.v_decay_Channel_e = -99 ; plots.v_decay_Channel_mu = -99 ; plots.v_decay_Channel_tau = -99 ; TClonesArray * genParticles = new TClonesArray ("TParticle") ; tree->SetBranchAddress ("genParticles", &genParticles) ; // TClonesArray * tagJets = new TClonesArray ("TLorentzVector") ; // tree->SetBranchAddress ("tagJets", &tagJets) ; TClonesArray * otherJets_temp = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress (g_KindOfJet.c_str(), &otherJets_temp) ; // tree->SetBranchAddress ("otherJets", &otherJets_temp) ; TClonesArray * electrons = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress ("electrons", &electrons) ; TClonesArray * muons = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress ("muons", &muons) ; TClonesArray * MET = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress ("MET", &MET) ; TClonesArray * tracks = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress ("tracks", &tracks) ; TClonesArray * tagJets = new TClonesArray ("TLorentzVector") ; TClonesArray * otherJets = new TClonesArray ("TLorentzVector") ; int EleId[100]; float IsolEleSumPt_VBF[100]; int nEle; int EleCharge[30]; tree->SetBranchAddress ("nEle", &nEle) ; tree->SetBranchAddress ("EleId",EleId ) ; tree->SetBranchAddress ("IsolEleSumPt_VBF",IsolEleSumPt_VBF ) ; tree->SetBranchAddress ("EleCharge",EleCharge ) ; float IsolMuTr[100]; int nMu ; int MuCharge[30]; tree->SetBranchAddress ("nMu", &nMu) ; tree->SetBranchAddress ("IsolMuTr",IsolMuTr ) ; tree->SetBranchAddress ("MuCharge", MuCharge) ; int IdEvent; tree->SetBranchAddress ("IdEvent", &IdEvent) ; int nentries = (int) tree->GetEntries () ; plots.passedJetAndLepNumberSelections = 0; plots.analyzed = 0; plots.analyzed_ee = 0; plots.analyzed_mumu = 0; plots.analyzed_tautau = 0; plots.analyzed_emu = 0; plots.analyzed_etau = 0; plots.analyzed_mutau = 0; plots.passedJetAndLepNumberSelections_ee = 0; plots.passedJetAndLepNumberSelections_mumu = 0; plots.passedJetAndLepNumberSelections_tautau = 0; plots.passedJetAndLepNumberSelections_emu = 0; plots.passedJetAndLepNumberSelections_etau = 0; plots.passedJetAndLepNumberSelections_mutau = 0; //PG loop over the events for (int evt = 0 ; evt < nentries ; ++evt) { tree->GetEntry (evt) ; tagJets -> Clear () ; otherJets -> Clear () ; //---- check if signal ---- if (if_signal && (IdEvent!=123 && IdEvent!=124)) continue; plots.analyzed++; //!---- MC ---- if (IdEvent==123 || IdEvent==124) { //---- VBF event ---- plots.v_decay_Channel_e = 0; plots.v_decay_Channel_mu = 0; plots.v_decay_Channel_tau = 0; for (int iGen = 0; iGen < genParticles->GetEntries() ; ++iGen){ TParticle* myparticle = (TParticle*) genParticles->At(iGen); if (abs(myparticle->GetPdgCode()) == 24) { //---- W Int_t mother1 = 0; mother1 = myparticle->GetMother(0); if (mother1 == 25) { //---- mother is higgs ---- for (int iDaughter = 0; iDaughter<2; iDaughter++){ if (abs(myparticle->GetDaughter(iDaughter)) == 11) {//---- W -> e plots.v_decay_Channel_e++; } if (abs(myparticle->GetDaughter(iDaughter)) == 13) {//---- W -> mu plots.v_decay_Channel_mu++; } if (abs(myparticle->GetDaughter(iDaughter)) == 15) {//---- W -> tau plots.v_decay_Channel_tau++; } } } } } } if (plots.v_decay_Channel_e == 2) plots.analyzed_ee++; if (plots.v_decay_Channel_mu == 2) plots.analyzed_mumu++; if (plots.v_decay_Channel_tau == 2) plots.analyzed_tautau++; if (plots.v_decay_Channel_e == 1 && plots.v_decay_Channel_mu == 1) plots.analyzed_emu++; if (plots.v_decay_Channel_e == 1 && plots.v_decay_Channel_tau == 1) plots.analyzed_etau++; if (plots.v_decay_Channel_mu == 1 && plots.v_decay_Channel_tau == 1) plots.analyzed_mutau++; int cutId = 0 ; plots.increase (cutId++) ; //AM 0 -> total number of events // std::cerr << "--- preambolo leptoni " << std::endl; std::vector<lepton> leptons ; //PG pour electrons into leptons collection //PG --------------------------------------- //PG loop over electrons for (int iele = 0; iele < electrons->GetEntries () ; ++iele) { TLorentzVector * theEle = (TLorentzVector*) (electrons->At (iele)) ; lepton dummy (theEle, 0, iele) ; leptons.push_back (dummy) ; } //PG loop over electrons //PG loop over muons for (int imu = 0 ; imu < nMu ; ++imu) { TLorentzVector * theMu = (TLorentzVector*) (muons->At (imu)) ; lepton dummy (theMu, 1, imu) ; leptons.push_back (dummy) ; } //PG loop over muons //PG this check is not necessary //PG if (leptons.size () < 2) continue ; // std::cerr << "--- inizia leptoni " << std::endl; //PG 2 LEPTONS //PG --------- /* applied after the leptons choice: in this case it is possible to differentiate the selections depending on the position of each lepton in the pt-sorting. the algorithm searches the first two most energetic candidates which satisfy the ID selections required for the first and second lepton respectively. Then check for channel analysis according to "g_LepLep" 0 == ee 1 == mumu 2 == emu 3 == mue pt ordered */ sort (leptons.rbegin (), leptons.rend (), lessThan ()) ; lepton primoLEP ; lepton secondoLEP ; double first_lepton_charge = 0; double second_lepton_charge = 0; int lepton_counter = 0; int electron_counter = 0; int muon_counter = 0; //PG find the first lepton int ilep = 0 ; for ( ; ilep < leptons.size () ; ++ilep) { if (leptons.at (ilep).m_flav == 0) //PG electron { //PG iso check bool eleIso = (IsolEleSumPt_VBF[leptons.at (ilep).m_index] / leptons.at (ilep).m_kine->Pt () ) < g_IsoElectron ; // 0.2 per il momento if (g_ISO1[0] == 1 && eleIso != 1) continue; //PG eleID check int eleID = EleId[leptons.at (ilep).m_index] ; if (g_ID1 == 100 && (eleID/100) != 1) continue; else if (g_ID1 == 10 && ((eleID%100)/10) != 1) continue; else if (g_ID1 == 1 && (eleID%10) != 1) continue; first_lepton_charge = EleCharge[leptons.at (ilep).m_index]; } else //PG muon { //PG iso check bool muIso = (IsolMuTr[leptons.at (ilep).m_index] / leptons.at (ilep).m_kine->Pt () ) < g_IsoMuon ; if (g_ISO1[1] == 1 && muIso != 1) continue; first_lepton_charge = MuCharge[leptons.at (ilep).m_index]; } primoLEP = leptons[ilep] ; lepton_counter++; if (leptons.at (ilep).m_flav == 0) electron_counter++; else muon_counter++; break ; } //PG find the first lepton //PG find the second lepton bool flag_secondoLEP = false; for (++ilep ; ilep < leptons.size () ; ++ilep) { if (leptons.at (ilep).m_flav == 0) //PG electron { //PG iso check bool eleIso = (IsolEleSumPt_VBF[leptons.at (ilep).m_index] / leptons.at (ilep).m_kine->Pt () ) < g_IsoElectron ; // 0.2 per il momento if (g_ISO2[0] == 1 && eleIso != 1) continue; //PG eleID check int eleID = EleId[leptons.at (ilep).m_index] ; if (g_ID2 == 100 && (eleID/100) != 1) continue; else if (g_ID2 == 10 && ((eleID%100)/10) != 1) continue; else if (g_ID2 == 1 && (eleID%10) != 1) continue; second_lepton_charge = EleCharge[leptons.at (ilep).m_index]; } else //PG muon { //PG iso check bool muIso = (IsolMuTr[leptons.at (ilep).m_index] / leptons.at (ilep).m_kine->Pt () ) < g_IsoMuon ; if (g_ISO2[1] == 1 && muIso != 1) continue; second_lepton_charge = MuCharge[leptons.at (ilep).m_index]; } if (!flag_secondoLEP) { secondoLEP = leptons[ilep] ; flag_secondoLEP = true; } if (leptons.at (ilep).m_kine->Pt () > 0) { if (leptons.at (ilep).m_flav == 0) electron_counter++; else muon_counter++; lepton_counter++; } } //PG find the second lepton //---- AM 3 --- 2 leptons after Id if (primoLEP.m_flav == -1 || secondoLEP.m_flav == -1) continue ; //---- AM 4 check for the two most transverse-energetic leptons have the right flavours plots.v_numLep = lepton_counter; plots.v_numEle = electron_counter; plots.v_numMu = muon_counter; if (primoLEP.m_flav == 0 && secondoLEP.m_flav == 0) plots.v_LepLep = 0 ; if (primoLEP.m_flav == 1 && secondoLEP.m_flav == 1) plots.v_LepLep = 1 ; if (primoLEP.m_flav == 0 && secondoLEP.m_flav == 1) plots.v_LepLep = 2 ; if (primoLEP.m_flav == 1 && secondoLEP.m_flav == 0) plots.v_LepLep = 3 ; plots.v_hardLEPPt = primoLEP.m_kine->Pt () ; //---- AM 5 pt_min of the most energetic lepton plots.v_softLEPPt = secondoLEP.m_kine->Pt () ; //---- AM 6 pt_min of the least energetic lepton plots.v_LEPDPhi = deltaPhi (primoLEP.m_kine->Phi (), secondoLEP.m_kine->Phi ()) ; //---- AM 7 Delta_phi_min between leptons plots.v_LEPDEta = deltaEta (primoLEP.m_kine->Eta (), secondoLEP.m_kine->Eta ()) ; plots.v_LEPDR = deltaR (primoLEP.m_kine->Phi (),primoLEP.m_kine->Eta (), secondoLEP.m_kine->Phi (), secondoLEP.m_kine->Eta ()) ; TLorentzVector sumLEP = *(primoLEP.m_kine) + *(secondoLEP.m_kine) ; plots.v_LEPMinv = sumLEP.M () ; //---- AM 9 MInv_min of leptons plots.v_LEPProdCharge = first_lepton_charge * second_lepton_charge ; plots.v_hardLEPCharge = first_lepton_charge ; plots.v_softLEPCharge = second_lepton_charge ; //PG MET //PG --- // std::cerr << "--- finito " << std::endl; TLorentzVector* met = ((TLorentzVector*) (MET->At(0))) ; //correct for muons for (int i = 0 ; i < nMu ; i++) { TLorentzVector * mu_v = (TLorentzVector*) (muons->At (i)) ; if (mu_v->Pt () > 3) { met->SetPx (met->Px () - mu_v->Px ()) ; met->SetPy (met->Py () - mu_v->Py ()) ; } } plots.v_MET = met->Pt () ; //---- AM 11 Met_min ----------------> Met correction ? // if (((TLorentzVector*) (MET->At (0)))->Pt () < g_METMin) continue ; plots.increase (cutId++) ; //PG 10 //PG Ztautau vetos //PG ------------- //PG the two electrons should not be opposite to each other // // TVector2 primoLEPT (primoLEP.m_kine->X (), primoLEP.m_kine->Y ()) ; // TVector2 secondoLEPT (secondoLEP.m_kine->X (), secondoLEP.m_kine->Y ()) ; // TVector2 METT (met->X (), met->Y ()) ; // // double Sum = METT * primoLEPT + METT * secondoLEPT / (1 + primoLEPT * secondoLEPT) ; // double Dif = METT * primoLEPT - METT * secondoLEPT / (1 - primoLEPT * secondoLEPT) ; // // TVector2 METT1 = 0.5 * (Sum + Dif) * primoLEPT ; // TVector2 METT2 = 0.5 * (Sum - Dif) * secondoLEPT ; // // double ptNu1 = METT1.Mod () / cos (primoLEP.m_kine->Theta ()) ; // double ptNu2 = METT2.Mod () / cos (secondoLEP.m_kine->Theta ()) ; plots.m_tree_selections->Fill(); plots.passedJetAndLepNumberSelections++; if (plots.v_decay_Channel_e == 2) plots.passedJetAndLepNumberSelections_ee++; if (plots.v_decay_Channel_mu == 2) plots.passedJetAndLepNumberSelections_mumu++; if (plots.v_decay_Channel_tau == 2) plots.passedJetAndLepNumberSelections_tautau++; if (plots.v_decay_Channel_e == 1 && plots.v_decay_Channel_mu == 1) plots.passedJetAndLepNumberSelections_emu++; if (plots.v_decay_Channel_e == 1 && plots.v_decay_Channel_tau == 1) plots.passedJetAndLepNumberSelections_etau++; if (plots.v_decay_Channel_mu == 1 && plots.v_decay_Channel_tau == 1) plots.passedJetAndLepNumberSelections_mutau++; } //PG loop over the events plots.m_efficiency->Fill(); plots.m_efficiency->Write(); plots.m_tree_selections->Write(); delete otherJets_temp ; delete tagJets ; delete otherJets ; delete electrons ; delete muons ; delete MET ; delete tracks ; return 0; }
void plots() { gSystem->Load("libEVGEN"); // Needs to be! AliRunLoader* rl = AliRunLoader::Open("galice.root"); rl->LoadKinematics(); rl->LoadHeader(); // 4pi histograms TH1* hM = new TH1D("hM", "DIME #rho#rho;M_{4#pi} #(){GeV/#it{c}^{2}}", 100, 1.0, 3.0); TH1* hPt = new TH1D("hPt", "DIME #rho#rho;p_{T}#(){4#pi} #(){GeV/#it{c}}", 100, 0.0, 3.0); // pi+- histograms TH1* hPt1 = new TH1D("hPt1", "DIME #rho#rho;p_{T}#(){#pi^{#pm}} #(){Gev/#it{c}}", 100, 0.0, 3.0); AliStack* stack = NULL; TParticle* part = NULL; TLorentzVector v[4]; TLorentzVector vSum; // Loop over events for (Int_t i = 0; i < rl->GetNumberOfEvents(); ++i) { rl->GetEvent(i); stack = rl->Stack(); Int_t nPrimary = 0; // Loop over all particles for (Int_t j = 0; j < stack->GetNtrack(); ++j) { part = stack->Particle(j); // Get particle part->Print(); // Print contents if (abs(part->GetPdgCode()) == 211 // Is pi+ or pi- & part->GetStatusCode() == 1 // Is stable final state & stack->IsPhysicalPrimary(j)) { // Is from generator level part->Momentum(v[nPrimary]); // Set content of v ++nPrimary; } } if (nPrimary != 4) { printf("Error: nPrimary=%d != 4 \n", nPrimary); continue; } // 4-vector sum vSum = v[0] + v[1] + v[2] + v[3]; // Fill 4pi histograms hM->Fill(vSum.M()); hPt->Fill(vSum.Perp()); // Fill pi+- histograms for (Int_t k = 0; k < 4; ++k) { hPt1->Fill(v[k].Perp()); } printf("\n"); } // Save plots as pdf hM->Draw(); c1->SaveAs("plotM.pdf"); hPt->Draw(); c1->SaveAs("plotPt.pdf"); hPt1->Draw(); c1->SaveAs("plotPt1.pdf"); }
//________________________________________________________________________________ void StarMCHits::FinishEvent() { static const Double_t pEMax = 1 - 1.e-10; TDataSet *m_DataSet = StarMCHits::instance()->GetHitHolder(); if (! m_DataSet) return; St_g2t_event *g2t_event = new St_g2t_event("g2t_event",1); m_DataSet->Add(g2t_event); g2t_event_st event; memset (&event, 0, sizeof(g2t_event_st)); fEventNumber++; event.n_event = fEventNumber;//IHEAD(2) event.ge_rndm[0] = fSeed;//IHEAD(3) event.ge_rndm[1] = 0;//IHEAD(4) event.n_run = 1; event.n_track_eg_fs = StarVMCApplication::Instance()->GetStack()->GetNtrack(); event.n_track_prim = StarVMCApplication::Instance()->GetStack()->GetNprimary(); event.prim_vertex_p = 1; event.b_impact = 99; event.phi_impact = 0.5; g2t_event->AddAt(&event); Int_t NoVertex = 1; St_g2t_vertex *g2t_vertex = new St_g2t_vertex("g2t_vertex",NoVertex); m_DataSet->Add(g2t_vertex); g2t_vertex_st vertex; Int_t NTracks = StarVMCApplication::Instance()->GetStack()->GetNtrack(); St_g2t_track *g2t_track = new St_g2t_track ("g2t_track",NTracks); m_DataSet->Add(g2t_track); g2t_track_st track; StarMCParticle *particle = 0; Int_t iv = 0; TLorentzVector oldV(0,0,0,0); TLorentzVector newV(0,0,0,0); TLorentzVector devV(0,0,0,0); for (Int_t it = 0; it <NTracks; it++) { memset(&track, 0, sizeof(g2t_track_st)); particle = (StarMCParticle*) StarVMCApplication::Instance()->GetStack()->GetParticle(it); TParticle *part = (TParticle *) particle->GetParticle(); part->ProductionVertex(newV); devV = newV - oldV; if (iv == 0 || devV.Mag() > 1.e-7) { if (iv > 0) g2t_vertex->AddAt(&vertex); memset (&vertex, 0, sizeof(g2t_vertex_st)); iv++; vertex.id = iv ;// primary key vertex.event_p = 0 ;// pointer to event vertex.eg_label = 0 ;// generator label (0 if GEANT) vertex.eg_tof = 0 ;// vertex production time vertex.eg_proc = 0 ;// event generator mechanism memcpy(vertex.ge_volume," ",4); ;// GEANT volume name vertex.ge_medium = 0 ;// GEANT Medium vertex.ge_tof = 0 ;// GEANT vertex production time vertex.ge_proc = 0 ;// GEANT mechanism (0 if eg) vertex.ge_x[0] = newV.X() ;// GEANT vertex coordinate vertex.ge_x[1] = newV.Y() ; vertex.ge_x[2] = newV.Z() ; vertex.ge_tof = newV.T() ; vertex.n_parent = 0 ;// number of parent tracks vertex.parent_p = 0 ;// first parent track vertex.is_itrmd = 0 ;// flags intermediate vertex vertex.next_itrmd_p = 0 ;// next intermedate vertex vertex.next_prim_v_p= 0 ;// next primary vertex oldV = newV; } vertex.n_daughter++; track.id = it+1; track.eg_label = particle->GetIdGen(); track.eg_pid = part->GetPdgCode(); track.ge_pid = gMC->IdFromPDG(track.eg_pid); track.start_vertex_p = iv; track.p[0] = part->Px(); track.p[1] = part->Py(); track.p[2] = part->Pz(); track.ptot = part->P(); track.e = part->Energy(); track.charge = part->GetPDG()->Charge()/3; Double_t ratio = part->Pz()/part->Energy(); ratio = TMath::Min(1.-1e-10,TMath::Max(-1.+1e-10, ratio)); track.rapidity = TMath::ATanH(ratio); track.pt = part->Pt(); ratio = part->Pz()/part->P(); ratio = TMath::Min(pEMax,TMath::Max(-pEMax, ratio)); track.eta = TMath::ATanH(ratio); g2t_track->AddAt(&track); } g2t_vertex->AddAt(&vertex); }
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 ExtractOutputHistos(Bool_t onlyPrims=0,Bool_t onlyPion=0,Int_t plotFlag=0) { // gROOT->SetStyle("Plain"); gStyle->SetPalette(1); const Int_t nbins=20; Double_t ptmin=0.06;//04; Double_t ptmax=2.0;//GeV Double_t logxmin = TMath::Log10(ptmin); Double_t logxmax = TMath::Log10(ptmax); Double_t binwidth = (logxmax-logxmin)/(nbins+1); enum {nb=nbins+1}; Double_t xbins[nb]; xbins[0] = ptmin; for (Int_t i=1;i<=nbins;i++) { xbins[i] = ptmin + TMath::Power(10,logxmin+(i)*binwidth); // cout<<xbins[i]<<endl; } // TH1F *h = new TH1F("h","hist with log x axis",nbins,xbins); TH1F *hMultCount = new TH1F("mult","averaged multiplicity (charg. prim)",80,-4.,4.); hMultCount->GetXaxis()->SetTitle("eta"); hMultCount->GetYaxis()->SetTitle("N/d#eta"); TH1F *hAllMC = new TH1F("allMC","All Tracks MC primaries",nbins,xbins); TH1F *hAllFound = new TH1F("allFound","All Tracks found",nbins,xbins); TH1F *hImperfect = new TH1F("imperfect","Imperfect tracks",nbins,xbins); TH1F *hPerfect = new TH1F("perfect","Perfect tracks",nbins,xbins); TH1F *hEff = new TH1F("efficiency","Efficiency (Perfect tracks in \"ALL MC\")",nbins,xbins); TH1F *hFake = new TH1F("fake","Fake tracks (Inperfect tracks in \"ALL MC\")",nbins,xbins); TH1F *hPurity = new TH1F("purity","Purity (Perfect tracks in \"All Found\")",nbins,xbins); TH1F *hAnna = new TH1F("annaEff","AnnalisaEff ",nbins,xbins); TH1F *hNoMCTrack = new TH1F("noMCtrack","noMCtrack ",nbins,xbins); TH1F *hEta = new TH1F("","",50,-2,2); // TH1F *hEtaMC = new TH1F("","",50,-2,2); TH2D *h2Ddca = new TH2D("dca2D","DCAvsPt2D",nbins,xbins,50,-0.05,0.05); TH2D *h2Dpt = new TH2D("dPt2D","dPtdvsPt2D",nbins,xbins,50,-25,25); // open run loader and load gAlice, kinematics and header AliRunLoader* runLoader = AliRunLoader::Open("galice.root"); if (!runLoader) { Error("Check kine", "getting run loader from file %s failed", "galice.root"); return; } runLoader->LoadgAlice(); gAlice = runLoader->GetAliRun(); if (!gAlice) { Error("Check kine", "no galice object found"); return; } runLoader->LoadHeader(); runLoader->LoadKinematics(); TFile* esdFile = TFile::Open("AliESDs.root"); if (!esdFile || !esdFile->IsOpen()) { Error("CheckESD", "opening ESD file %s failed", "AliESDs.root"); return; } AliESDEvent *esd = new AliESDEvent(); TTree* tree = (TTree*) esdFile->Get("esdTree"); if (!tree) { Error("CheckESD", "no ESD tree found"); return; } esd->ReadFromTree(tree); Int_t nTrackTotalMC = 0; Int_t nTrackFound = 0; Int_t nTrackImperfect = 0; Int_t nTrackPerfect = 0; Int_t nNoMCTrack = 0; for(Int_t iEv =0; iEv<tree->GetEntries(); iEv++){ tree->GetEvent(iEv); runLoader->GetEvent(iEv); printf("+++ event %i (of %lld) +++++++++++++++++++++++ # ESDtracks: %d \n",iEv,tree->GetEntries()-1,esd->GetNumberOfTracks()); Int_t nESDtracks = esd->GetNumberOfTracks(); for (Int_t iTrack = 0; iTrack < nESDtracks; iTrack++) { AliESDtrack* track = esd->GetTrack(iTrack); if (!(iTrack%1000)) printf("event %i: ESD track count %d (of %d)\n",iEv,iTrack,nESDtracks); Int_t label = track->GetLabel(); Int_t idx[12]; // Int_t ncl = track->GetITSclusters(idx); if(label<0) { // cout<< " ESD track label " << label; // cout<<" ---> imperfect track (label "<<label<<"<0) !! -> track Pt: "<< track->Pt() << endl; } AliStack* stack = runLoader->Stack(); // nTrackTotalMC += stack->GetNprimary(); TParticle* particle = stack->Particle(TMath::Abs(label)); Double_t pt = track->Pt(); if(particle) { if (TMath::Abs(particle->Eta())>etaCut) continue; Double_t ptMC = particle->Pt(); // Efficiencies if (onlyPion && TMath::Abs(particle->GetPdgCode())!=211) continue; if ( (!onlyPrims) || stack->IsPhysicalPrimary(TMath::Abs(label))) { // cout<<" # clusters "<<ncl<<endl; nTrackFound++; hAllFound->Fill(ptMC); hEta->Fill(track->Eta()); if (label<0) { nTrackImperfect++; hImperfect->Fill(ptMC); } else { nTrackPerfect++; hPerfect->Fill(ptMC); } } // following only for "true tracks, pions if(particle->Pt() < 0.001)continue; if (TMath::Abs(particle->GetPdgCode())!=211) continue; if (label>0) { // Impact parameters for Pions only Double_t dca = track->GetD(0,0,0.5); h2Ddca->Fill(ptMC,dca); // Pt resolution for Pions only Double_t dPt = (pt-ptMC)/ptMC*100; h2Dpt->Fill(ptMC,dPt); } } else { nNoMCTrackFound++; hNoMCTrack->Fill(pt); cout<<" according MC particle not found"<<endl; } } //entries track esd }//entries tree runLoader->UnloadHeader(); runLoader->UnloadKinematics(); delete runLoader; // Count trackable MC tracks CountTrackableMCs(hAllMC, onlyPrims, onlyPion); // Count trackable MC tracks CountPrimaries(hMultCount); // Get Errors right hMultCount->Sumw2(); hAllMC->Sumw2(); hAllFound->Sumw2(); hPerfect->Sumw2(); hImperfect->Sumw2(); h2Dpt->Sumw2(); h2Ddca->Sumw2(); // -- Global efficienies nTrackTotalMC = hAllMC->GetEntries(); Double_t eff = ((Double_t)nTrackPerfect)/nTrackTotalMC; printf("-> Total number of events: %lld -> MCtracks %d -> nPerfect %d -> Eff: %3.2lf \n", tree->GetEntries(),nTrackTotalMC,nTrackPerfect,eff); Double_t purity = ((Double_t)nTrackPerfect)/nTrackFound; printf("-> Total number of events: %lld -> FoundTracks %d -> nPerfect %d -> Purity: %3.2lf \n", tree->GetEntries(),nTrackFound,nTrackPerfect,purity); // Efficiencies - and normalize to 100% TF1 f1("f1","100+x*0",0.,1.e3); hPurity->Divide(hPerfect,hAllFound,1,1,"b"); hPurity->Multiply(&f1); hPurity->SetMarkerColor(kGreen); hPurity->SetMarkerStyle(21); hPurity->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)"); hPurity->SetStats(0); hPurity->GetYaxis()->SetRangeUser(0,100); hPurity->SetTitle("Efficiency & Purity"); hEff->Divide(hPerfect,hAllMC,1,1,"b"); hEff->Multiply(&f1); hEff->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)"); hEff->SetMarkerColor(kBlue); hEff->SetMarkerStyle(21); hEff->SetStats(0); hFake->Divide(hImperfect,hAllMC,1,1,"b"); hFake->Multiply(&f1); hFake->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)"); hFake->SetMarkerColor(kRed); hFake->SetMarkerStyle(21); hFake->SetStats(0); hAnna->Divide(hAllFound,hAllMC,1,1,"b"); hAnna->Multiply(&f1); hAnna->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)"); hAnna->SetMarkerColor(kBlack); hAnna->SetMarkerStyle(21); hAnna->SetStats(0); TCanvas *c1 = new TCanvas("c1","NoMCTrackFound");//,200,10,900,900); TVirtualPad *pad = c1->cd(); pad->SetGridx(); pad->SetGridy(); hNoMCTrack->Draw(); TCanvas *c2 = new TCanvas("c2","Eff&Purity");//,200,10,900,900); TVirtualPad *pad = c2->cd(); pad->SetGridx(); pad->SetGridy(); // pad->SetLogx(); hPurity->Draw("E"); hEff->Draw("Same E"); hFake->Draw("Same E"); hAnna->Draw("Same E"); TLegend *leg = new TLegend(0.1,0.8,0.6,0.9);leg->SetFillColor(0); leg->AddEntry(hPurity,"Purity (\"Perfect tracks\" within \"Found Tracks\")","PE"); leg->AddEntry(hEff,"Efficiency (\"Perfect tracks\" within \"MC findable Tracks\")","PE"); leg->AddEntry(hFake,"Fake (\"Inperfect tracks\" within \"MC findable Tracks\")","PE"); leg->AddEntry(hAnna,"AnnaLisa - Efficiency (\"Found tracks\" within \"MC findable Tracks\")","PE"); leg->Draw(); if (plotFlag==1){ hAllMC->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)"); hAllMC->Draw(); // MC pt distribution hAllFound->SetLineColor(2); hAllFound->Draw("same"); // MC pt distribution } /* .L ~/ITSupgrade/BuildDetector/DetectorK.cxx+ // All NEW DetectorK its("ALICE","ITS"); its.MakeAliceAllNew(0); its.SetMaxRadiusOfSlowDetectors(0.01); its.SolveViaBilloir(0); TGraph *c = its.GetGraphRecoEfficiency(0,3,2); c->Draw("C"); // Current DetectorK its("ALICE","ITS"); its.MakeAliceCurrent(0,0); its.SetMaxRadiusOfSlowDetectors(0.01); its.SolveViaBilloir(0); TGraph *c = its.GetGraphRecoEfficiency(0,4,2); c->Draw("C"); */ TCanvas *c3 = new TCanvas("c3","impact");//,200,10,900,900); c3->Divide(2,1); c3->cd(1); // Impact parameter // Impact parameter resolution --------------- h2Ddca->Draw("colz"); h2Ddca->FitSlicesY() ; TH2D *dcaM = (TH2D*)gDirectory->Get("dca2D_1"); dcaM->Draw("same"); TH2D *dcaRMS = (TH2D*)gDirectory->Get("dca2D_2"); //dcaRMS->Draw(); TGraphErrors *d0 = new TGraphErrors(); for (Int_t ibin =1; ibin<=dcaRMS->GetXaxis()->GetNbins(); ibin++) { d0->SetPoint( ibin-1,dcaRMS->GetBinCenter(ibin),dcaRMS->GetBinContent(ibin)*1e4); // microns d0->SetPointError(ibin-1,0,dcaRMS->GetBinError(ibin)*1e4); // microns } d0->SetMarkerStyle(21); d0->SetMaximum(200); d0->SetMinimum(0); d0->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)"); d0->GetYaxis()->SetTitle("R-#phi Pointing Resolution (#mum)"); d0->SetName("dca"); d0->SetTitle("DCAvsPt"); c3->cd(1); h2Ddca->Draw("surf2"); c3->cd(2); d0->Draw("APE"); // PT RESOLUTION ------------ TCanvas *c4 = new TCanvas("c4","pt resolution");//,200,10,900,900); c4->Divide(2,1); c4->cd(1); // Impact parameter h2Dpt->Draw("colz"); h2Dpt->FitSlicesY() ; TH2D *dPtM = (TH2D*)gDirectory->Get("dPt2D_1"); dPtM->Draw("same"); TH2D *dPtRMS = (TH2D*)gDirectory->Get("dPt2D_2"); // dPtRMS->Draw(""); TGraphErrors *gPt = new TGraphErrors(); for (Int_t ibin =1; ibin<=dPtRMS->GetXaxis()->GetNbins(); ibin++) { gPt->SetPoint( ibin-1,dPtRMS->GetBinCenter(ibin),dPtRMS->GetBinContent(ibin)); gPt->SetPointError(ibin-1,0,dPtRMS->GetBinError(ibin)); } gPt->SetMarkerStyle(21); gPt->SetMaximum(20); gPt->SetMinimum(0); gPt->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)"); gPt->GetYaxis()->SetTitle("relative momentum resolution (%)"); gPt->SetName("dPt"); gPt->SetTitle("DPTvsPt"); c4->cd(1); h2Dpt->Draw("surf2"); c4->cd(2); gPt->Draw("APE"); // EXPORT -------- TFile f("histos.root","RECREATE"); hMultCount->Write(); hAllMC->Write(); hAllFound->Write(); hImperfect->Write(); hPerfect->Write(); hNoMCTrack->Write(); hPurity->Write(); hEff->Write(); hFake->Write(); hAnna->Write(); h2Ddca->Write(); d0->Write(); h2Dpt->Write(); gPt->Write(); f.Close(); return; }
void CountTrackableMCs(TH1F *hAllMC, Bool_t onlyPrims,Bool_t onlyPion) { gSystem->Load("libITSUpgradeBase"); gSystem->Load("libITSUpgradeSim"); // open run loader and load gAlice, kinematics and header AliRunLoader* runLoader = AliRunLoader::Open("galice.root"); if (!runLoader) { Error("Check kine", "getting run loader from file %s failed", "galice.root"); return; } runLoader->LoadHeader(); runLoader->LoadKinematics(); runLoader->LoadTrackRefs(); AliLoader *dl = runLoader->GetDetectorLoader("ITS"); //Trackf TTree *trackRefTree = 0x0; TClonesArray *trackRef = new TClonesArray("AliTrackReference",1000); // TH1F *hRef = new TH1F("","",100,0,100); TH1F *hR = new TH1F("","",100,0,100); if (hAllMC==0) hAllMC = new TH1F("","",100,0.1,2); Float_t ptmin = hAllMC->GetBinCenter(1)-hAllMC->GetBinWidth(1)/2; Float_t ptmax = hAllMC->GetBinCenter(hAllMC->GetNbinsX())+hAllMC->GetBinWidth(hAllMC->GetNbinsX())/2; // Int_t nAllMC = 0; // Detector geometry TArrayD rmin(0); TArrayD rmax(0); GetDetectorRadii(&rmin,&rmax); TArrayI nLaySigs(rmin.GetSize()); printf("Counting trackable MC tracks ...\n"); for(Int_t iEv =0; iEv<runLoader->GetNumberOfEvents(); iEv++){ Int_t nTrackableTracks = 0; runLoader->GetEvent(iEv); AliStack* stack = runLoader->Stack(); printf("+++ event %i (of %d) +++++++++++++++++++++++ # total MCtracks: %d \n",iEv,runLoader->GetNumberOfEvents()-1,stack->GetNtrack()); trackRefTree=runLoader->TreeTR(); TBranch *br = trackRefTree->GetBranch("TrackReferences"); if(!br) { printf("no TR branch available , exiting \n"); return; } br->SetAddress(&trackRef); // init the trackRef tree trackRefTree=runLoader->TreeTR(); trackRefTree->SetBranchAddress("TrackReferences",&trackRef); // Count trackable MC tracks for (Int_t iMC=0; iMC<stack->GetNtrack(); iMC++) { TParticle* particle = stack->Particle(iMC); if (TMath::Abs(particle->Eta())>etaCut) continue; if (onlyPrims && !stack->IsPhysicalPrimary(iMC)) continue; if (onlyPion && TMath::Abs(particle->GetPdgCode())!=211) continue; Bool_t isTrackable = 0; nLaySigs.Reset(0); trackRefTree->GetEntry(stack->TreeKEntry(iMC)); Int_t nref=trackRef->GetEntriesFast(); for(Int_t iref =0; iref<nref; iref++){ AliTrackReference *trR = (AliTrackReference*)trackRef->At(iref); if(!trR) continue; if(trR->DetectorId()!=AliTrackReference::kITS) continue; Float_t radPos = trR->R(); hR->Fill(radPos); for (Int_t il=0; il<rmin.GetSize();il++) { if (radPos>=rmin.At(il)-0.1 && radPos<=rmax.At(il)+0.1) { // cout<<" in Layer "<<il<<" "<<radPos; nLaySigs.AddAt(1.,il); // cout<<" "<<nLaySigs.At(il)<<endl; } } } if (nLaySigs.GetSum()>=3) { isTrackable =1; // cout<<nLaySigs.GetSum()<<endl; } if (isTrackable) { Double_t ptMC = particle->Pt(); // Double_t etaMC = particle->Eta(); // if (ptMC>ptmin&&ptMC<ptmax) {nTrackableTracks++;hAllMC->Fill(ptMC);} if (ptMC>ptmin) {nTrackableTracks++;hAllMC->Fill(ptMC);} } } // entries tracks MC printf(" -> trackable MC tracks: %d (%d)\n",nTrackableTracks,hAllMC->GetEntries()); }//entries Events hR->DrawCopy(); hAllMC->DrawCopy(); runLoader->UnloadHeader(); runLoader->UnloadKinematics(); delete runLoader; }
void Pythia8(const Int_t nEvents = 10) { gROOT->LoadMacro("TUtils.h"); if (LoadRootLibs()) return; if (LoadPythia8()) return; if (LoadThermalClass()) return; //============================================================================= TPythia8 *pythia8 = new TPythia8(); pythia8->ReadString("SoftQCD:all = on"); pythia8->ReadString("SoftQCD:singleDiffractive = on"); pythia8->ReadString("SoftQCD:doubleDiffractive = on"); pythia8->Initialize(2212, 2212, 14000.); //============================================================================= TGenThermalParticles *thermal = new TGenThermalParticles("Boltzmann"); thermal->SetMultiplicity(2000); thermal->SetMeanPt(0.7); thermal->SetPtRange(0.15, 200.); thermal->SetEtaRange(-0.8, 0.8); thermal->SetPhiRange(0., TMath::TwoPi()); //============================================================================= TClonesArray *particles = new TClonesArray("TParticle", 1000); for (Int_t iEvent=0; iEvent<nEvents; iEvent++) { pythia8->GenerateEvent(); if (iEvent==0) pythia8->EventListing(); pythia8->ImportParticles(particles, "Final"); Int_t nb = particles->GetEntriesFast(); cout << "iEvent = "<< iEvent << ", np before = " << nb; thermal->ImportParticles(particles, "Boltzmann"); Int_t na = particles->GetEntriesFast(); cout << ", np after = " << na << endl; TParticle *part = 0; for (Int_t i=0; i<na; i++) { part = (TParticle*)particles->At(i); if (!part) continue; Bool_t bThermalBkg = (part->GetStatusCode()==-1); if (!bThermalBkg) { Int_t kPDG = part->GetPdgCode(); Float_t dCharge = TDatabasePDG::Instance()->GetParticle(kPDG)->Charge(); } part = 0; } } //============================================================================= pythia8->PrintStatistics(); //============================================================================= return; }
void fastGen(Int_t nev = 1, char* filename = "gilc.root") { IlcPDG::AddParticlesToPdgDataBase(); TDatabasePDG::Instance(); // Run loader IlcRunLoader* rl = IlcRunLoader::Open("gilc.root","FASTRUN","recreate"); rl->SetCompressionLevel(2); rl->SetNumberOfEventsPerFile(nev); rl->LoadKinematics("RECREATE"); rl->MakeTree("E"); gIlc->SetRunLoader(rl); // Create stack rl->MakeStack(); IlcStack* stack = rl->Stack(); // Header IlcHeader* header = rl->GetHeader(); // Create and Initialize Generator // Example of charm generation taken from Config_PythiaHeavyFlavours.C IlcGenPythia *gener = new IlcGenPythia(-1); gener->SetEnergyCMS(14000.); gener->SetMomentumRange(0,999999); gener->SetPhiRange(0., 360.); gener->SetThetaRange(0.,180.); // gener->SetProcess(kPyCharmppMNR); // Correct Pt distribution, wrong mult gener->SetProcess(kPyMb); // Correct multiplicity, wrong Pt gener->SetStrucFunc(kCTEQ4L); gener->SetPtHard(2.1,-1.0); gener->SetFeedDownHigherFamily(kFALSE); gener->SetStack(stack); gener->Init(); // Go to gilc.root rl->CdGAFile(); // Forbid some decays. Do it after gener->Init(0, because // the initialization of the generator includes reading of the decay table. IlcPythia * py= IlcPythia::Instance(); py->SetMDME(737,1,0); //forbid D*+->D+ + pi0 py->SetMDME(738,1,0);//forbid D*+->D+ + gamma // Forbid all D0 decays except D0->K- pi+ for(Int_t d=747; d<=762; d++){ py->SetMDME(d,1,0); } // decay 763 is D0->K- pi+ for(Int_t d=764; d<=807; d++){ py->SetMDME(d,1,0); } // // 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 Int_t nprim = 0; Int_t ntrial = 0; Int_t ndstar = 0; //------------------------------------------------------------------------------------- while(!ndstar) { // Selection of events with D* stack->Reset(); stack->ConnectTree(rl->TreeK()); gener->Generate(); ntrial++; nprim = stack->GetNprimary(); for(Int_t ipart =0; ipart < nprim; ipart++){ TParticle * part = stack->Particle(ipart); if(part) { if (TMath::Abs(part->GetPdgCode())== 413) { TArrayI daughtersId; GetFinalDecayProducts(ipart,*stack,daughtersId); Bool_t kineOK = kTRUE; Double_t thetaMin = TMath::Pi()/4; Double_t thetaMax = 3*TMath::Pi()/4; for (Int_t id=1; id<=daughtersId[0]; id++) { TParticle * daughter = stack->Particle(daughtersId[id]); if (!daughter) { kineOK = kFALSE; break; } Double_t theta = daughter->Theta(); if (theta<thetaMin || theta>thetaMax) { kineOK = kFALSE; break; } } if (!kineOK) continue; part->Print(); ndstar++; } } } } cout << "Number of particles " << nprim << endl; cout << "Number of trials " << ntrial << 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 compClusHitsMod2(int nev=-1) { const int kSplit=0x1<<22; const int kSplCheck=0x1<<23; // gSystem->Load("libITSUpgradeBase"); gSystem->Load("libITSUpgradeSim"); gSystem->Load("libITSUpgradeRec"); gROOT->SetStyle("Plain"); AliCDBManager* man = AliCDBManager::Instance(); man->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); man->SetSpecificStorage("GRP/GRP/Data", Form("local://%s",gSystem->pwd())); man->SetSpecificStorage("ITS/Align/Data", Form("local://%s",gSystem->pwd())); man->SetSpecificStorage("ITS/Calib/RecoParam", Form("local://%s",gSystem->pwd())); man->SetRun(0); TH1F* hL0A = new TH1F("hL0A", "Layer 0, polar angle", 20, 0, TMath::PiOver2()); hL0A->SetDirectory(0); hL0A->GetXaxis()->SetTitle("#alpha"); TH1F* hL0B = new TH1F("hL0B", "Layer 0, azimuthal angle", 20, 0, TMath::PiOver2()); hL0B->SetDirectory(0); hL0B->GetXaxis()->SetTitle("#beta"); TH1F* hL1A = new TH1F("hL1A", "Layer 1, polar angle", 20, 0, TMath::PiOver2()); hL1A->SetDirectory(0); hL1A->GetXaxis()->SetTitle("#alpha"); TH1F* hL1B = new TH1F("hL1B", "Layer 1, azimuthal angle", 20, 0, TMath::PiOver2()); hL1B->SetDirectory(0); hL1B->GetXaxis()->SetTitle("#beta"); TH1F* hL2A = new TH1F("hL2A", "Layer 2, polar angle", 20, 0, TMath::PiOver2()); hL2A->SetDirectory(0); hL2A->GetXaxis()->SetTitle("#alpha"); TH1F* hL2B = new TH1F("hL2B", "Layer 2, azimuthal angle", 20, 0, TMath::PiOver2()); hL2B->SetDirectory(0); hL2B->GetXaxis()->SetTitle("#beta"); TH1F* hL3A = new TH1F("hL3A", "Layer 3, polar angle", 20, 0, TMath::PiOver2()); hL3A->SetDirectory(0); hL3A->GetXaxis()->SetTitle("#alpha"); TH1F* hL3B = new TH1F("hL3B", "Layer 3, azimuthal angle", 20, 0, TMath::PiOver2()); hL3B->SetDirectory(0); hL3B->GetXaxis()->SetTitle("#beta"); TH1F* hL4A = new TH1F("hL4A", "Layer 4, polar angle", 20, 0, TMath::PiOver2()); hL4A->SetDirectory(0); hL4A->GetXaxis()->SetTitle("#alpha"); TH1F* hL4B = new TH1F("hL4B", "Layer 4, azimuthal angle", 20, 0, TMath::PiOver2()); hL4B->SetDirectory(0); hL4B->GetXaxis()->SetTitle("#beta"); TH1F* hL5A = new TH1F("hL5A", "Layer 5, polar angle", 20, 0, TMath::PiOver2()); hL5A->SetDirectory(0); hL5A->GetXaxis()->SetTitle("#alpha"); TH1F* hL5B = new TH1F("hL5B", "Layer 5, azimuthal angle", 20, 0, TMath::PiOver2()); hL5B->SetDirectory(0); hL5B->GetXaxis()->SetTitle("#beta"); TH1F* hL6A = new TH1F("hL6A", "Layer 6, polar angle", 20, 0, TMath::PiOver2()); hL6A->SetDirectory(0); hL6A->GetXaxis()->SetTitle("#alpha"); TH1F* hL6B = new TH1F("hL6B", "Layer 6, azimuthal angle", 20, 0, TMath::PiOver2()); hL6B->SetDirectory(0); hL6B->GetXaxis()->SetTitle("#beta"); gAlice=NULL; AliRunLoader* runLoader = AliRunLoader::Open("galice.root"); runLoader->LoadgAlice(); gAlice = runLoader->GetAliRun(); runLoader->LoadHeader(); runLoader->LoadKinematics(); runLoader->LoadRecPoints(); runLoader->LoadSDigits(); runLoader->LoadHits(); AliLoader *dl = runLoader->GetDetectorLoader("ITS"); AliGeomManager::LoadGeometry("geometry.root"); TObjArray algITS; AliGeomManager::LoadAlignObjsFromCDBSingleDet("ITS",algITS); AliGeomManager::ApplyAlignObjsToGeom(algITS); // AliITSUGeomTGeo* gm = new AliITSUGeomTGeo(kTRUE); AliITSMFTClusterPix::SetGeom(gm); // AliITSURecoDet *its = new AliITSURecoDet(gm, "ITSinterface"); its->CreateClusterArrays(); // Double_t xg1,yg1,zg1=0.,xg0,yg0,zg0=0.,tg0; Double_t xExit,yExit,zExit,xEnt,yEnt,zEnt,tof1; // TTree *cluTree = 0x0; TTree *hitTree = 0x0; TClonesArray *hitList=new TClonesArray("AliITSMFTHit"); // Float_t xyzClGloF[3]; Double_t xyzClGlo[3],xyzClTr[3]; Int_t labels[3]; int nLab = 0; int nlr=its->GetNLayersActive(); int ntotev = (Int_t)runLoader->GetNumberOfEvents(); printf("N Events : %i \n",ntotev); if (nev>0) ntotev = TMath::Min(nev,ntotev); // // output tree TFile* flOut = TFile::Open("clInfo.root","recreate"); TTree* trOut = new TTree("clitsu","clitsu"); clSumm cSum; trOut->Branch("evID", &cSum.evID ,"evID/I"); trOut->Branch("volID",&cSum.volID,"volID/I"); trOut->Branch("lrID", &cSum.lrID ,"lrID/I"); trOut->Branch("clID", &cSum.clID ,"clID/I"); trOut->Branch("nPix", &cSum.nPix ,"nPix/I"); trOut->Branch("nX" , &cSum.nX ,"nX/I"); trOut->Branch("nZ" , &cSum.nZ ,"nZ/I"); trOut->Branch("q" , &cSum.q ,"q/I"); trOut->Branch("pt" , &cSum.pt ,"pt/F"); trOut->Branch("eta" ,&cSum.eta ,"eta/F"); trOut->Branch("phi" , &cSum.phi ,"phi/F"); trOut->Branch("xyz", cSum.xyz, "xyz[3]/F"); trOut->Branch("dX" , &cSum.dX ,"dX/F"); trOut->Branch("dY" , &cSum.dY ,"dY/F"); trOut->Branch("dZ" , &cSum.dZ ,"dZ/F"); trOut->Branch("split",&cSum.split,"split/O"); trOut->Branch("prim", &cSum.prim, "prim/O"); trOut->Branch("pdg", &cSum.pdg, "pdg/I"); trOut->Branch("ntr", &cSum.ntr, "ntr/I"); trOut->Branch("alpha", &cSum.alpha, "alpha/F"); trOut->Branch("beta", &cSum.beta, "beta/F"); trOut->Branch("nRowPatt", &cSum.nRowPatt, "nRowPatt/I"); trOut->Branch("nColPatt", &cSum.nColPatt, "nColPatt/I"); TopDatabase DB; for (Int_t iEvent = 0; iEvent < ntotev; iEvent++) { printf("\n Event %i \n",iEvent); runLoader->GetEvent(iEvent); AliStack *stack = runLoader->Stack(); cluTree=dl->TreeR(); hitTree=dl->TreeH(); hitTree->SetBranchAddress("ITS",&hitList); // // read clusters for (int ilr=nlr;ilr--;) { TBranch* br = cluTree->GetBranch(Form("ITSRecPoints%d",ilr)); if (!br) {printf("Did not find cluster branch for lr %d\n",ilr); exit(1);} br->SetAddress(its->GetLayerActive(ilr)->GetClustersAddress()); } cluTree->GetEntry(0); its->ProcessClusters(); // // read hits for(Int_t iEnt=0;iEnt<hitTree->GetEntries();iEnt++){//entries loop of the hits hitTree->GetEntry(iEnt); int nh = hitList->GetEntries(); for(Int_t iHit=0; iHit<nh;iHit++){ AliITSMFTHit *pHit = (AliITSMFTHit*)hitList->At(iHit); int mcID = pHit->GetTrack(); //printf("MCid: %d %d %d Ch %d\n",iEnt,iHit, mcID, pHit->GetChip()); TClonesArray* harr = arrMCTracks.GetEntriesFast()>mcID ? (TClonesArray*)arrMCTracks.At(mcID) : 0; if (!harr) { harr = new TClonesArray("AliITSMFTHit"); // 1st encounter of the MC track arrMCTracks.AddAtAndExpand(harr,mcID); } // new ( (*harr)[harr->GetEntriesFast()] ) AliITSMFTHit(*pHit); } } // return; // // compare clusters and hits // printf(" tree entries: %lld\n",cluTree->GetEntries()); // for (int ilr=0;ilr<nlr;ilr++) { AliITSURecoLayer* lr = its->GetLayerActive(ilr); TClonesArray* clr = lr->GetClusters(); int nClu = clr->GetEntries(); //printf("Layer %d : %d clusters\n",ilr,nClu); // for (int icl=0;icl<nClu;icl++) { AliITSMFTClusterPix *cl = (AliITSMFTClusterPix*)clr->At(icl); int modID = cl->GetVolumeId(); //------------ check if this is a split cluster int sInL = modID - gm->GetFirstChipIndex(ilr); if (!cl->TestBit(kSplCheck)) { cl->SetBit(kSplCheck); // check if there is no other cluster with same label on this module AliITSURecoSens* sens = lr->GetSensor(sInL); int nclSn = sens->GetNClusters(); int offs = sens->GetFirstClusterId(); // printf("To check for %d (mod:%d) N=%d from %d\n",icl,modID,nclSn,offs); for (int ics=0;ics<nclSn;ics++) { AliITSMFTClusterPix* clusT = (AliITSMFTClusterPix*)lr->GetCluster(offs+ics); // access to clusters if (clusT==cl) continue; for (int ilb0=0;ilb0<3;ilb0++) { int lb0 = cl->GetLabel(ilb0); if (lb0<=-1) break; for (int ilb1=0;ilb1<3;ilb1++) { int lb1 = clusT->GetLabel(ilb1); if (lb1<=-1) break; if (lb1==lb0) { cl->SetBit(kSplit); clusT->SetBit(kSplit); /* printf("Discard clusters of module %d:\n",modID); cl->Print(); clusT->Print(); */ break; } } } } } //------------ const AliITSMFTSegmentationPix* segm = gm->GetSegmentation(ilr); // cl->GetGlobalXYZ(xyzClGloF); int clsize = cl->GetNPix(); for (int i=3;i--;) xyzClGlo[i] = xyzClGloF[i]; const TGeoHMatrix* mat = gm->GetMatrixSens(modID); if (!mat) {printf("failed to get matrix for module %d\n",cl->GetVolumeId());} mat->MasterToLocal(xyzClGlo,xyzClTr); // int col,row; segm->LocalToDet(xyzClTr[0],xyzClTr[2],row,col); // effective col/row nLab = 0; for (int il=0;il<3;il++) { if (cl->GetLabel(il)>=0) labels[nLab++] = cl->GetLabel(il); else break; } // find hit info for (int il=0;il<nLab;il++) { TClonesArray* htArr = (TClonesArray*)arrMCTracks.At(labels[il]); //printf("check %d/%d LB %d %p\n",il,nLab,labels[il],htArr); if (!htArr) {printf("did not find MChits for label %d ",labels[il]); cl->Print(); continue;} // int nh = htArr->GetEntriesFast(); AliITSMFTHit *pHit=0; for (int ih=nh;ih--;) { AliITSMFTHit* tHit = (AliITSMFTHit*)htArr->At(ih); if (tHit->GetChip()!=modID) continue; pHit = tHit; break; } if (!pHit) { printf("did not find MChit for label %d on module %d ",il,modID); cl->Print(); htArr->Print(); continue; } // pHit->GetPositionG(xg1,yg1,zg1); pHit->GetPositionG0(xg0,yg0,zg0,tg0); // double txyzH[3],gxyzH[3] = { (xg1+xg0)/2, (yg1+yg0)/2, (zg1+zg0)/2 }; mat->MasterToLocal(gxyzH,txyzH); double rcl = TMath::Sqrt(xyzClTr[0]*xyzClTr[0]+xyzClTr[1]*xyzClTr[1]); double rht = TMath::Sqrt(txyzH[0]*txyzH[0]+txyzH[1]*txyzH[1]); // //Angles determination pHit->GetPositionL(xExit,yExit,zExit,gm); pHit->GetPositionL0(xEnt,yEnt,zEnt,tof1,gm); Double_t dirHit[3]={(xExit-xEnt),(yExit-yEnt),(zExit-zEnt)}; /*double PG[3] = {(double)pHit->GetPXG(), (double)pHit->GetPYG(), (double)pHit->GetPZG()}; //Momentum at hit-point in Global Frame double PL[3]; if (TMath::Abs(PG[0])<10e-7 && TMath::Abs(PG[1])<10e-7) { pHit->Dump(); int lb = pHit->GetTrack(); stack->Particle(lb)->Print(); continue; } mat->MasterToLocalVect(PG,PL); //Momentum in local Frame //printf(">> %e %e %e %e %e %e\n",PG[0],PL[0],PG[1],PL[1],PG[2],PL[2]);*/ Double_t alpha1 = TMath::ACos(TMath::Abs(dirHit[1])/TMath::Sqrt(dirHit[0]*dirHit[0]+dirHit[1]*dirHit[1]+dirHit[2]*dirHit[2])); //Polar Angle Float_t alpha2 = (Float_t) alpha1; //convert to float cSum.alpha = alpha2; Double_t beta1; beta1 = TMath::ATan2(dirHit[0],dirHit[2]); //Azimuthal angle, values from -Pi to Pi Float_t beta2 = (Float_t) beta1; cSum.beta = beta2; if(ilr==0){ hL0A->Fill(alpha2); hL0B->Fill(beta2); } if(ilr==1){ hL1A->Fill(alpha2); hL1B->Fill(beta2); } if(ilr==2){ hL2A->Fill(alpha2); hL2B->Fill(beta2); } if(ilr==3){ hL3A->Fill(alpha2); hL3B->Fill(beta2); } if(ilr==4){ hL4A->Fill(alpha2); hL4B->Fill(beta2); } if(ilr==5){ hL5A->Fill(alpha2); hL5B->Fill(beta2); } if(ilr==6){ hL6A->Fill(alpha2); hL6B->Fill(beta2); } GetHistoClSize(clsize,kDR,&histoArr)->Fill((rht-rcl)*1e4); if (cl->TestBit(kSplit)) { if (col%2) GetHistoClSize(clsize,kDTXoddSPL,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4); else GetHistoClSize(clsize,kDTXevenSPL,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4); GetHistoClSize(clsize,kDTZSPL,&histoArr)->Fill((txyzH[2]-xyzClTr[2])*1e4); GetHistoClSize(0,kNPixSPL,&histoArr)->Fill(clsize); } if (col%2) GetHistoClSize(clsize,kDTXodd,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4); else GetHistoClSize(clsize,kDTXeven,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4); GetHistoClSize(clsize,kDTZ,&histoArr)->Fill((txyzH[2]-xyzClTr[2])*1e4); GetHistoClSize(0,kNPixAll,&histoArr)->Fill(clsize); // cSum.evID = iEvent; cSum.volID = cl->GetVolumeId(); cSum.lrID = ilr; cSum.clID = icl; cSum.nPix = cl->GetNPix(); cSum.nX = cl->GetNx(); cSum.nZ = cl->GetNz(); cSum.q = cl->GetQ(); cSum.split = cl->TestBit(kSplit); cSum.dX = (txyzH[0]-xyzClTr[0])*1e4; cSum.dY = (txyzH[1]-xyzClTr[1])*1e4; cSum.dZ = (txyzH[2]-xyzClTr[2])*1e4; cSum.nRowPatt = cl-> GetPatternRowSpan(); cSum.nColPatt = cl-> GetPatternColSpan(); DB.AccountTopology(*cl, cSum.dX, cSum.dZ, cSum.alpha, cSum.beta); GetHistoClSize(clsize,kDR,&histoArr)->Fill((rht-rcl)*1e4); if (cl->TestBit(kSplit)) { if (col%2) GetHistoClSize(clsize,kDTXoddSPL,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4); else GetHistoClSize(clsize,kDTXevenSPL,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4); GetHistoClSize(clsize,kDTZSPL,&histoArr)->Fill((txyzH[2]-xyzClTr[2])*1e4); GetHistoClSize(0,kNPixSPL,&histoArr)->Fill(clsize); } if (col%2) GetHistoClSize(clsize,kDTXodd,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4); else GetHistoClSize(clsize,kDTXeven,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4); GetHistoClSize(clsize,kDTZ,&histoArr)->Fill((txyzH[2]-xyzClTr[2])*1e4); GetHistoClSize(0,kNPixAll,&histoArr)->Fill(clsize); // cSum.evID = iEvent; cSum.volID = cl->GetVolumeId(); cSum.lrID = ilr; cSum.clID = icl; cSum.nPix = cl->GetNPix(); cSum.nX = cl->GetNx(); cSum.nZ = cl->GetNz(); cSum.q = cl->GetQ(); cSum.split = cl->TestBit(kSplit); cSum.dX = (txyzH[0]-xyzClTr[0])*1e4; cSum.dY = (txyzH[1]-xyzClTr[1])*1e4; cSum.dZ = (txyzH[2]-xyzClTr[2])*1e4; cSum.nRowPatt = cl-> GetPatternRowSpan(); cSum.nColPatt = cl-> GetPatternColSpan(); int label = cl->GetLabel(0); TParticle* part = 0; if (label>=0 && (part=stack->Particle(label)) ) { cSum.pdg = part->GetPdgCode(); cSum.eta = part->Eta(); cSum.pt = part->Pt(); cSum.phi = part->Phi(); cSum.prim = stack->IsPhysicalPrimary(label); } cSum.ntr = 0; for (int ilb=0;ilb<3;ilb++) if (cl->GetLabel(ilb)>=0) cSum.ntr++; for (int i=0;i<3;i++) cSum.xyz[i] = xyzClGloF[i]; // trOut->Fill(); /* if (clsize==5) { printf("\nL%d(%c) Mod%d, Cl:%d | %+5.1f %+5.1f (%d/%d)|H:%e %e %e | C:%e %e %e\n",ilr,cl->TestBit(kSplit) ? 'S':'N', modID,icl,(txyzH[0]-xyzClTr[0])*1e4,(txyzH[2]-xyzClTr[2])*1e4, row,col, gxyzH[0],gxyzH[1],gxyzH[2],xyzClGlo[0],xyzClGlo[1],xyzClGlo[2]); cl->Print(); pHit->Print(); // double a0,b0,c0,a1,b1,c1,e0; pHit->GetPositionL0(a0,b0,c0,e0); pHit->GetPositionL(a1,b1,c1); float cloc[3]; cl->GetLocalXYZ(cloc); printf("LocH: %e %e %e | %e %e %e\n",a0,b0,c0,a1,b1,c1); printf("LocC: %e %e %e | %e %e %e\n",cloc[0],cloc[1],cloc[2],xyzClTr[0],xyzClTr[1],xyzClTr[2]); } */ // } } } // layerClus.Clear(); // arrMCTracks.Delete(); }//event loop // DB.EndAndSort(); DB.SetThresholdCumulative(0.95); cout << "Over threshold: : "<< DB.GetOverThr()<<endl; DB.Grouping(10,10); DB.PrintDB("Database1.txt"); flOut->cd(); trOut->Write(); delete trOut; flOut->Close(); flOut->Delete(); DrawReport("clinfo.ps",&histoArr); TFile* flDB = TFile::Open("TopologyDatabase.root", "recreate"); flDB->WriteObject(&DB,"DB","kSingleKey"); flDB->Close(); delete flDB; TCanvas* cnv123 = new TCanvas("cnv123","cnv123"); cnv123->Divide(1,2); cnv123->Print("anglesdistr.pdf["); cnv123->cd(1); hL0A->Draw(); cnv123->cd(2); hL0B->Draw(); cnv123->Print("anglesdistr.pdf"); cnv123->cd(1); hL1A->Draw(); cnv123->cd(2); hL1B->Draw(); cnv123->Print("anglesdistr.pdf"); cnv123->cd(1); hL2A->Draw(); cnv123->cd(2); hL2B->Draw(); cnv123->Print("anglesdistr.pdf"); cnv123->cd(1); hL3A->Draw(); cnv123->cd(2); hL3B->Draw(); cnv123->Print("anglesdistr.pdf"); cnv123->cd(1); hL4A->Draw(); cnv123->cd(2); hL4B->Draw(); cnv123->Print("anglesdistr.pdf"); cnv123->cd(1); hL5A->Draw(); cnv123->cd(2); hL5B->Draw(); cnv123->Print("anglesdistr.pdf"); cnv123->cd(1); hL6A->Draw(); cnv123->cd(2); hL6B->Draw(); cnv123->Print("anglesdistr.pdf"); cnv123->Print("anglesdistr.pdf]"); // }
void fastGenPA(Int_t nev = 1, char* filename = "gilc.root") { // Runloader IlcRunLoader* rl = IlcRunLoader::Open("gilc.root", "FASTRUN", "recreate"); rl->SetCompressionLevel(2); rl->SetNumberOfEventsPerFile(10000); rl->LoadKinematics("RECREATE"); rl->MakeTree("E"); gIlc->SetRunLoader(rl); // Create stack rl->MakeStack(); IlcStack* stack = rl->Stack(); // Header IlcHeader* header = rl->GetHeader(); // Create and Initialize Generator IlcGenerator *gener = CreateGenerator(); gener->Init(); gener->SetStack(stack); // // Event Loop // Int_t iev; for (iev = 0; iev < nev; iev++) { printf("\n \n Event number %d \n \n", iev); // Initialize event header->Reset(0,iev); rl->SetEventNumber(iev); stack->Reset(); rl->MakeTree("K"); // 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(); } // 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(); }