//______________________________________________________________________________ void HighlightFragment() { // TODO templates: what and how highlighing if (!gPad || !gr) return; // not correct TVirtualPad *ph = (TVirtualPad *)gPad->FindObject("ph"); if (!ph) { ph = new TPad("ph", "ph", 0.0, 0.2, 1.0, 1.0); ph->SetFillColor(kBlue-10); ph->Draw(); } Int_t ih = gr->GetHighlightPoint(); if (ih == -1) return; TRsnFragment *frag = group->FragmentAt(ih); if (!frag) return; TVirtualPad *save = gPad; ph->cd(); TObject *element = frag->FindElement(tagname); if (!element) ph->Clear(); else element->Draw(); save->cd(); }
//_______________________________________________________________________________________ static void SetBackround(Color_t color, TVirtualPad *pad=0) { TVirtualPad *thisPad = pad; if (!thisPad) thisPad = qPad(); if (thisPad) { thisPad->SetFillColor(color); thisPad->Modified(); thisPad->Update(); } }
/** * * * @param o * @param useWeights * @param correct * * @ingroup pwglf_forward_scripts_tests */ void TestPoisson(Double_t o=.3, bool useWeights=false, bool correct=true) { const char* load = "$ALICE_PHYSICS/PWGLF/FORWARD/analysis2/scripts/LoadLibs.C"; if (!gROOT->GetClass("AliAODForwardMult")) { gROOT->Macro(load); gROOT->GetInterpreter()->UnloadFile(gSystem->ExpandPathName(load)); } // --- Parameters of this script ----------------------------------- Int_t nBin = 5; // Our detector matrix size Int_t nMax = TMath::Max(Int_t(nBin * nBin * o + .5)+nBin/2,nBin); Int_t nEv = 10000; // Number of events Double_t mp = o; // The 'hit' probability TH2D* base = new TH2D("base", "Basic histogram", nBin,-.5, nBin-.5, nBin, -.5, nBin-.5); base->SetXTitle("#eta"); base->SetYTitle("#varphi"); base->SetDirectory(0); base->SetOption("colz"); Int_t tN1=nMax; Double_t tMin1; Double_t tMax1; Int_t tN2=nMax*10; Double_t tMin2; Double_t tMax2=nMax; MakeIntegerAxis(tN1, tMin1, tMax1); MakeIntegerAxis(tN2, tMin2, tMax2); TH2D* corr = new TH2D("comp", "Comparison", tN1, tMin1, tMax1, tN2, tMin2, tMax2); corr->SetXTitle("Input"); corr->SetYTitle("Poisson"); corr->SetDirectory(0); corr->SetOption("colz"); corr->SetStats(0); TLine* lcorr = new TLine(0, 0, tMax2, tMax2); Int_t mm = TMath::Max(Int_t(nBin * o + .5),nBin/2); tN2=mm*10; tMax2 = mm; MakeIntegerAxis(tN2, tMin2, tMax2); Info("", "Making mean w/nbins=%d,range=[%f,%f]", tN2, tMin2, tMax2); TH2D* mean = new TH2D("mean", "Mean comparison", tN2, tMin2, tMax2, tN2, tMin2, tMax2); mean->SetXTitle("Input"); mean->SetYTitle("Poisson"); mean->SetDirectory(0); mean->SetOption("colz"); mean->SetStats(0); TLine* lmean = new TLine(tMin2, tMin2, tMax2, tMax2); TH1D* dist = new TH1D("dist", "Distribution of hits", tN1, tMin1, tMax1); dist->SetXTitle("s"); dist->SetYTitle("P(s)"); dist->SetFillColor(kRed+1); dist->SetFillStyle(3001); dist->SetDirectory(0); TH1D* diff = new TH1D("diff", "P-T", 100, -25, 25); diff->SetXTitle("Difference"); diff->SetFillColor(kRed+1); diff->SetFillStyle(3001); diff->SetYTitle("Prob"); AliPoissonCalculator* c = new AliPoissonCalculator("ignored"); c->Init(nBin ,nBin); for (Int_t i = 0; i < nEv; i++) { c->Reset(base); base->Reset(); for (Int_t iEta = 0; iEta < nBin; iEta++) { for (Int_t iPhi = 0; iPhi < nBin; iPhi++) { // Throw a die Int_t m = gRandom->Poisson(mp); dist->Fill(m); // Fill into our base histogram base->Fill(iEta, iPhi, m); // Fill into poisson calculator c->Fill(iEta, iPhi, m > 0, (useWeights ? m : 1)); } } // Calculate the result TH2D* res = c->Result(correct); // Now loop and compare Double_t mBase = 0; Double_t mPois = 0; for (Int_t iEta = 0; iEta < nBin; iEta++) { for (Int_t iPhi = 0; iPhi < nBin; iPhi++) { Double_t p = res->GetBinContent(iEta, iPhi); Double_t t = base->GetBinContent(iEta, iPhi); mBase += t; mPois += p; corr->Fill(t, p); diff->Fill(p-t); } } Int_t nn = nBin * nBin; mean->Fill(mBase / nn, mPois / nn); } TCanvas* cc = new TCanvas("c", "c", 900, 900); cc->SetFillColor(0); cc->SetFillStyle(0); cc->SetBorderMode(0); cc->SetRightMargin(0.02); cc->SetTopMargin(0.02); cc->Divide(2,2); TVirtualPad* pp = cc->cd(1); pp->SetFillColor(0); pp->SetFillStyle(0); pp->SetBorderMode(0); pp->SetRightMargin(0.15); pp->SetTopMargin(0.02); pp->SetLogz(); pp->SetGridx(); pp->SetGridy(); corr->Draw(); lcorr->Draw(); pp = cc->cd(2); pp->SetFillColor(0); pp->SetFillStyle(0); pp->SetBorderMode(0); pp->SetRightMargin(0.02); pp->SetTopMargin(0.02); #if 0 c->GetMean()->Draw(); #elif 1 pp->SetLogy(); diff->Draw(); #elif 1 c->GetOccupancy()->Draw(); #else pp->SetLogy(); dist->SetStats(0); dist->Scale(1. / dist->Integral()); dist->Draw(); TH1D* m1 = c->GetMean(); m1->Scale(1. / m1->Integral()); m1->Draw("same"); Double_t eI; Double_t ii = 100 * dist->Integral(2, 0); TLatex* ll = new TLatex(.97, .85, Form("Input #bar{m}: %5.3f", mp)); ll->SetNDC(); ll->SetTextFont(132); ll->SetTextAlign(31); ll->Draw(); ll->DrawLatex(.97, .75, Form("Result #bar{m}: %5.3f", dist->GetMean())); ll->DrawLatex(.97, .65, Form("Occupancy: #int_{1}^{#infty}P(s)ds = %6.2f%%", ii)); #endif pp = cc->cd(3); pp->SetFillColor(0); pp->SetFillStyle(0); pp->SetBorderMode(0); pp->SetRightMargin(0.15); pp->SetTopMargin(0.02); pp->SetGridx(); pp->SetGridy(); c->GetCorrection()->Draw(); pp = cc->cd(4); pp->SetFillColor(0); pp->SetFillStyle(0); pp->SetBorderMode(0); pp->SetRightMargin(0.15); pp->SetTopMargin(0.02); pp->SetLogz(); pp->SetGridx(); pp->SetGridy(); mean->Draw(); lmean->Draw(); cc->cd(); }
/** * Draw the Poisson estimate of the occupancy * * @param filename Input file name * @param folder Input folder name in file * * @deprecated Use QATrender instead * @ingroup pwglf_forward_scripts_qa */ void DrawOccupancy(const char* filename="forward.root", const char* folder="ForwardResults") { gStyle->SetPalette(1); gStyle->SetOptFit(0); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); gStyle->SetTitleW(.4); gStyle->SetTitleH(.1); gStyle->SetTitleX(.4); // gStyle->SetTitleY(.1); gStyle->SetTitleColor(0); gStyle->SetTitleStyle(0); gStyle->SetTitleBorderSize(0); TFile* file = TFile::Open(filename, "READ"); if (!file) { Error("DrawOccupancy", "failed to open %s", filename); return; } TList* forward = static_cast<TList*>(file->Get(folder)); if (!forward) { Error("DrawOccupancy", "List %s not found in %s", folder, filename); return; } TList* dc = static_cast<TList*>(forward->FindObject("fmdDensityCalculator")); if (!dc) { Error("DrawOccupancy", "List fmdDensityCalculator not found in Forward"); return; } TCanvas* c = new TCanvas("occupancy", "Mean Occupancy", 900, 700); c->SetFillColor(0); c->SetBorderSize(0); c->SetBorderMode(0); c->SetHighLightColor(0); c->SetBottomMargin(.15); c->SetTopMargin(.02); c->SetRightMargin(.02); c->SetLeftMargin(.15); c->Divide(3, 2, 0, 0); Double_t corrs[5]; c->cd(1); corrs[0] = DrawRingOccupancy(dc, 1, 'I'); c->cd(2); corrs[1] = DrawRingOccupancy(dc, 2, 'I'); c->cd(5); corrs[2] = DrawRingOccupancy(dc, 2, 'O'); c->cd(3); corrs[3] = DrawRingOccupancy(dc, 3, 'I'); c->cd(6); corrs[4] = DrawRingOccupancy(dc, 3, 'O'); TVirtualPad* p = c->cd(4); p->SetTopMargin(0.05); p->SetRightMargin(0.10); p->SetLeftMargin(0.15); p->SetBottomMargin(0.15); p->SetFillColor(0); TH1D* hc = new TH1D("occ", "Mean occupancy", 5, .5, 5.5); hc->SetFillColor(kRed+1); hc->SetFillStyle(3001); hc->SetMinimum(0.0); hc->GetXaxis()->SetBinLabel(1,"FMD1i"); hc->SetBinContent(1,corrs[0]); hc->GetXaxis()->SetBinLabel(2,"FMD2i"); hc->SetBinContent(2,corrs[1]); hc->GetXaxis()->SetBinLabel(3,"FMD2o"); hc->SetBinContent(3,corrs[2]); hc->GetXaxis()->SetBinLabel(4,"FMD3i"); hc->SetBinContent(4,corrs[3]); hc->GetXaxis()->SetBinLabel(5,"FMD3o"); hc->SetBinContent(5,corrs[4]); hc->GetXaxis()->SetLabelSize(0.08); hc->GetYaxis()->SetTitle("#bar{occupancy}"); hc->SetMarkerSize(1.5); hc->Draw("text hist"); hc->SetMaximum(hc->GetMaximum()*1.5); // TH2D* highCuts = static_cast<TH2D*>(dc->FindObject("highCuts")); // if (highCuts) highCuts->Draw("colz"); c->cd(); c->SaveAs("occupancy.png"); }