void GLWidget::createTRPObject(void) { if (!pObj->GetX().Size()) return; if (isBuild) glDeleteLists(xList, 1); xList = glGenLists(1); glNewList (xList, GL_COMPILE); switch (pObj->GetType()) { case FE1D_2: draw1D(); break; case FE2D_3: case FE2D_6: case FE2D_4: draw2D(); break; case FE3D_4: case FE3D_10: case FE3D_8: draw3D(); break; default: break; } glEndList(); isBuild = true; }
//================================================ void DeltaZVsPt(const Int_t save = 0) { THnSparseF *hn = (THnSparseF*)f->Get(Form("mhTrkDzDy_%s",trigName[kTrigType])); TH2F *hTrkDzVsPt = (TH2F*)hn->Projection(1,0); c = draw2D(hTrkDzVsPt,Form("%s: #Deltaz of matched track-hit pairs",trigName[kTrigType])); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaZ_vs_pt_%s.pdf",run_type,trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaZ_vs_pt_%s.png",run_type,trigName[kTrigType])); } Double_t pt_cut = 1; hTrkDzVsPt->GetXaxis()->SetRangeUser(pt_cut+0.1,100); TH1F *hMthDz = (TH1F*)hTrkDzVsPt->ProjectionY(Form("hTrkDzVsPt_%s_proj",trigName[kTrigType])); hMthDz->SetTitle(Form("%s: #Deltaz of matched track-hit pairs (p_{T}>%1.1f GeV/c);#Deltaz (cm)",trigName[kTrigType],pt_cut)); TH1F *hClone = (TH1F*)hMthDz->Clone(Form("%s_clone",hMthDz->GetName())); c = draw1D(hClone,"",kFALSE,kFALSE); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaZ_%s.pdf",run_type,trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaZ_%s.png",run_type,trigName[kTrigType])); } Double_t range = 50; TF1 *func = new TF1("func","gaus(0)+gaus(3)",-1*range,range); func->SetParameters(10000,0,10,1000,0,40); c = FitDeltaZ(hMthDz,func,range,20.); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/FitDz_Pt%1.0f_%s.pdf",run_type,pt_cut,trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/FitDz_Pt%1.0f_%s.png",run_type,pt_cut,trigName[kTrigType])); } // pt dependence Double_t pt_cuts[5] = {1,2,3,5,20}; for(Int_t i=0; i<4; i++) { hTrkDzVsPt->GetXaxis()->SetRangeUser(pt_cuts[i]+0.1,pt_cuts[i+1]-0.1); TH1F *htmp = (TH1F*)hTrkDzVsPt->ProjectionY(Form("hTrkDz_pt%1.0f-%1.0f_%s",pt_cuts[i],pt_cuts[i+1],trigName[kTrigType])); htmp->SetTitle(Form("%s: #Deltaz of matched track-hit pairs (%1.0f < p_{T} < %1.0f GeV/c);#Deltaz (cm)",trigName[kTrigType],pt_cuts[i],pt_cuts[i+1])); TF1 *func = new TF1(Form("func_pt%1.0f-%1.0f",pt_cuts[i],pt_cuts[i+1]),"gaus(0)+gaus(3)",-1*range,range); if(i==0) func->SetParameters(100,0,100,1000,0,10); if(i==1) func->SetParameters(1000,0,15,1000,0,60); if(i==2) func->SetParameters(1000,0,15,1000,0,60); if(i==3) func->SetParameters(1000,0,60,1000,0,15); c = FitDeltaZ(htmp,func,range,20.); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/FitDz_Pt%1.0f_%1.0f_%s.pdf",run_type,pt_cuts[i],pt_cuts[i+1],trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/FitDz_Pt%1.0f_%1.0f_%s.png",run_type,pt_cuts[i],pt_cuts[i+1],trigName[kTrigType])); } } }
Stack* Stack::draw(){ if( can == NULL ) can = new TCanvas(("can_"+name).c_str(), name.c_str()); int N = vec.size(); int Ngraph = vecGraph.size(); if(N == 0 && Ngraph == 0) return this; bool plotLegend = checkIfDrawLegend(); if( N == 0 ) draw1D(); else if( vec[0] -> InheritsFrom("TH2") ) draw2D(); else draw1D(); if( _displayLegend && leg -> GetListOfPrimitives() -> GetSize() > 0 && plotLegend ) leg -> Draw("same"); if( labelSizeX != 0 ) frame -> GetXaxis() -> SetLabelSize( labelSizeX ); if( labelSizeY != 0 ) frame -> GetYaxis() -> SetLabelSize( labelSizeY ); frame -> GetXaxis() -> SetNdivisions(507,true); frame -> GetYaxis() -> SetNdivisions(507,true); frame -> GetXaxis() -> SetLabelSize(0.07); frame -> GetYaxis() -> SetLabelSize(0.07); if( titleX != "" ){ frame -> GetXaxis() -> SetTitleSize(0.08); // frame -> GetXaxis() -> SetTitleOffset(1.4); gPad -> SetBottomMargin(0.2); } if( titleY != "" ){ frame -> GetYaxis() -> SetTitleSize(0.08); gPad -> SetLeftMargin(0.2); } gPad -> SetGridx(); gPad -> SetGridy(); // gPad->RedrawAxis(); return this; }
//================================================ TCanvas *FitDeltaZ(TH1 *histo, TF1 *func, const Double_t range1 = 50., Double_t range2 = 20.) { histo->Fit(func,"R0"); histo->GetYaxis()->SetNdivisions(505); c = draw1D(histo); TF1 *func1 = new TF1("func1","gaus",-1*range1,range1); func1->SetParameters(func->GetParameter(3),func->GetParameter(4),func->GetParameter(5)); func->SetLineColor(2); func->Draw("sames"); func1->SetLineColor(4); func1->Draw("sames"); TPaveText *t1 = GetPaveText(0.2,0.3,0.65,0.78,0.04); t1->AddText(Form("#Deltaz ~ [-%1.0f,%1.0f]",range1,range1)); t1->AddText(Form("S/B ~ %1.1f:1",((func->Integral(-1*range1,range1))-(func1->Integral(-1*range1,range1)))/(func1->Integral(-1*range1,range1)))); t1->Draw(); t1 = GetPaveText(0.2,0.3,0.47,0.6,0.04); t1->AddText(Form("#Deltaz ~ [-%1.0f,%1.0f]",range2,range2)); t1->AddText(Form("S/B ~ %1.1f:1",((func->Integral(-1*range2,range2))-(func1->Integral(-1*range2,range2)))/(func1->Integral(-1*range2,range2)))); t1->Draw(); return c; }
//================================================ void Run14_AuAu200(const int saveHisto = 1) { // --------------------------------------------- // Jpsi efficiency TFile *feff = TFile::Open(Form("Rootfiles/Run14_AuAu200.EmbJpsiEff.pt%1.1f.pt%1.1f.root",run_type,pt1_cut,pt2_cut),"read"); const int nHistos = 6; const char *trkEffType[nHistos] = {"MC","Tpc","MtdMth","MuonPid","MtdTrig","TrigUnit"}; TH1F *hJpsiPt[nHistos][nCentBins_pt]; TH1F *hJpsiPtEff[nHistos][nCentBins_pt]; for(int i=0; i<nHistos; i++) { for(int k=0; k<nCentBins_pt; k++) { hJpsiPt[i][k] = (TH1F*)feff->Get(Form("hJpsiPt_%s_cent%s",trkEffType[i],cent_Title_pt[k])); int index = i-1; if(i==0) index = 0; hJpsiPtEff[i][k] = DivideTH1ForEff(hJpsiPt[i][k],hJpsiPt[index][k],Form("hJpsiPtEff_%s_cent%s",trkEffType[i],cent_Title_pt[k])); } } // --------------------------------------------- // Jpsi efficiency for uncertainty studies // TH1F *hJpsiEffVsPt[11]; hJpsiEffVsPt[0] = (TH1F*)feff->Get(Form("JpsiEffVsPt_cent%s_final",cent_Title_pt[0])); hJpsiEffVsPt[0]->SetName(Form("JpsiEffVsPt_cent%s_default",cent_Title_pt[0])); const TString sysName[10] = {"dcaUp","dcaDown","NHitsUp","NDedxUp", "dzUp","dzDown","dyUp","dyDown","nSigPiUp","nSigPiDown"}; TFile *fsys[2]; fsys[0] = TFile::Open(Form("Rootfiles/Run14_AuAu200.Sys.TpcTracking.root"),"read"); fsys[1] = TFile::Open(Form("Rootfiles/Run14_AuAu200.Sys.MuonPid.root"),"read"); TH1F *hJpsiTpcEffVsPt[2]; for(int i=0; i<2; i++) { hJpsiTpcEffVsPt[i] = (TH1F*)fsys[i]->Get(Form("Sysdefault_JpsiEffVsPtEmb_cent%s",cent_Title_pt[0])); hJpsiTpcEffVsPt[i]->SetName(Form("%s_%d",hJpsiTpcEffVsPt[i]->GetName(),i)); } c = draw1D(hJpsiEffVsPt[0]); for(int s=0; s<10; s++) { int index = 0; if(s>=4) index = 1; hJpsiEffVsPt[s+1] = (TH1F*)fsys[index]->Get(Form("Sys%s_JpsiEffVsPtEmb_cent%s",sysName[s].Data(),cent_Title_pt[0])); hJpsiEffVsPt[s+1]->SetName(Form("JpsiEffVsPt_cent%s_%s",cent_Title_pt[0],sysName[s].Data())); hJpsiEffVsPt[s+1]->Divide(hJpsiTpcEffVsPt[index]); hJpsiEffVsPt[s+1]->Multiply(hJpsiEffVsPt[0]); hJpsiEffVsPt[s+1]->SetMarkerStyle(21+s); hJpsiEffVsPt[s+1]->Draw("sames"); } // --------------------------------------------- // Fully corrected Jpsi invariant yield TFile *fxsec = TFile::Open("Rootfiles/Run14_AuAu200.JpsiXsec.pt1.5.pt1.3.root","read"); TH1F *hJpsiYieldVsPt[nCentBins_pt]; TH1F *hJpsiRaaVsPt[nCentBins_pt]; TF1 *funcJpsiYield[nCentBins_pt]; for(int i=0; i<nCentBins_pt; i++) { hJpsiYieldVsPt[i] = (TH1F*)fxsec->Get(Form("Jpsi_InvYieldVsPt_cent%s",cent_Title_pt[i])); hJpsiRaaVsPt[i] = (TH1F*)fxsec->Get(Form("Jpsi_RaaVsPt_cent%s",cent_Title_pt[i])); funcJpsiYield[i] = (TF1*)fxsec->Get(Form("func_JpsiYieldVsPt_cent%s",cent_Title_pt[i])); } if(saveHisto) { TFile *fout = TFile::Open("Rootfiles/Run14_AuAu200.AnaInfo.root","update"); for(int s=0; s<11; s++) { hJpsiEffVsPt[s]->Write("", TObject::kOverwrite); } for(int k=0; k<nCentBins_pt; k++) { for(int i=0; i<nHistos; i++) { if(i<4) hJpsiPt[i][k]->Write(Form("Emb_JpsiPt_%s_cent%s",trkEffType[i],cent_Title_pt[k]), TObject::kOverwrite); if(i>0 && i<4) hJpsiPtEff[i][k]->Write(Form("Emb_JpsiEffVsPt_%s_cent%s",trkEffType[i],cent_Title_pt[k]), TObject::kOverwrite); } } for(int i=0; i<nCentBins_pt; i++) { hJpsiYieldVsPt[i]->Write(Form("JpsiInvYieldVsPt_cent%s",cent_Title_pt[i]), TObject::kOverwrite); funcJpsiYield[i]->Write(Form("JpsiInvYieldVsPtFit_cent%s",cent_Title_pt[i]), TObject::kOverwrite); } } }
//================================================ void eventBinning(const Int_t save = 0) { TH1F *hVtxZ = (TH1F*)f->Get(Form("mhVertexZ_%s",trigName[kTrigType])); c = draw1D(hVtxZ,"",kFALSE,kFALSE); for(int i=0; i<19; i++) { double value = -100 + i*10 + 10; double height = hVtxZ->GetBinContent(hVtxZ->FindFixBin(value)); TLine *line = GetLine(value,0,value,height,2,1,1); line->Draw(); } if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sVertexZ_Binning.pdf",run_type,run_cfg_name.Data())); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sVertexZ_Binning.png",run_type,run_cfg_name.Data())); } TH1F *hgRefMultCorr = (TH1F*)f->Get(Form("mhgRefMultCorr_%s",trigName[kTrigType])); c = draw1D(hgRefMultCorr,"",kTRUE,kFALSE); //double bounds[9] = {472,401,283,193,126,77,44,23,11}; double bounds[16] = {11,16,23,32,44,59,77,99,126,157,193,235,283,338,401,472}; for(int i=0; i<16; i++) { double value = bounds[i]; double height = hgRefMultCorr->GetBinContent(hgRefMultCorr->FindFixBin(value)); TLine *line = GetLine(value,0,value,height,2,1,1); line->Draw(); } if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sgRefMult_Binning.pdf",run_type,run_cfg_name.Data())); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sgRefMult_Binning.png",run_type,run_cfg_name.Data())); } // centrality TH1F *hgRefMult = (TH1F*)f->Get(Form("mhgRefMult_%s",trigName[kTrigType])); hgRefMult->SetLineColor(2); c = draw1D(hgRefMult,"",kTRUE,kFALSE); hgRefMultCorr->Draw("sames HIST"); TLegend *leg = new TLegend(0.15,0.3,0.4,0.5); leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetTextSize(0.04); leg->AddEntry(hgRefMult,"Raw gRefMult","L"); leg->AddEntry(hgRefMultCorr,"Corrected gRefMult","L"); leg->Draw(); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sgRefMult.pdf",run_type,run_cfg_name.Data())); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sgRefMult.png",run_type,run_cfg_name.Data())); } TH1F *hCentrality = (TH1F*)f->Get(Form("mhCentrality_%s",trigName[kTrigType])); c = draw1D(hCentrality,"",kTRUE,kFALSE); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sCentrality.pdf",run_type,run_cfg_name.Data())); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sCentrality.png",run_type,run_cfg_name.Data())); } // event plane TH2F *hExcVsIncRawEP = (TH2F*)f->Get(Form("mhExcVsIncRawEP_%s",trigName[kTrigType])); c = draw2D(hExcVsIncRawEP); TH1F *hEventPlane = (TH1F*)f->Get(Form("mhEventPlane_%s",trigName[kTrigType])); c = draw1D(hEventPlane,"",kFALSE,kFALSE); }
//================================================ void subtraction(const Int_t save = 1) { Double_t pt1_cut = 1.0, pt2_cut = 1.0; //Double_t pt1_cut = 2.0, pt2_cut = 1.2; TFile *fdata = TFile::Open(Form("~/Work/STAR/analysis/output/jpsi.AuAu200.Run14.%s.root",run_config),"read"); const char *hName[3] = {"hJpsiInfo","hBkgLSPos","hBkgLSNeg"}; THnSparseF *hnInvMass[3]; TH1F *hInvMass[3]; for(Int_t j=0; j<3; j++) { hnInvMass[j] = (THnSparseF*)fdata->Get(Form("%s_%s",hName[j],trigName[kTrigType])); hnInvMass[j]->GetAxis(4)->SetRangeUser(pt1_cut+0.01,100); hnInvMass[j]->GetAxis(5)->SetRangeUser(pt2_cut+0.01,100); hInvMass[j] = (TH1F*)hnInvMass[j]->Projection(0); hInvMass[j]->SetName(Form("%s_%s_InvMass_WithCut",hName[j],trigName[kTrigType])); hInvMass[j]->Sumw2(); hnInvMass[j]->GetAxis(4)->SetRange(0,-1); hnInvMass[j]->GetAxis(5)->SetRange(0,-1); } hInvMass[1]->Add(hInvMass[2]); hInvMass[0]->SetMarkerStyle(20); hInvMass[0]->SetMarkerColor(2); hInvMass[0]->SetLineColor(2); hInvMass[0]->SetYTitle("Counts"); TH1F *hMixUS = (TH1F*)f->Get(Form("US_InvMass_pt1_%1.1f_pt2_%1.1f_%s",pt1_cut,pt2_cut,trigName[kTrigType])); TH1F *hMixLS = (TH1F*)f->Get(Form("LS_InvMass_pt1_%1.1f_pt2_%1.1f_%s",pt1_cut,pt2_cut,trigName[kTrigType])); Double_t scale = hInvMass[1]->Integral()/hMixLS->Integral(); hMixLS->Scale(scale); TList *list = new TList; TString legName[2] = {"Data: like sign","Mixed event: like sign"}; list->Add(hInvMass[1]); list->Add(hMixLS); c = sysCompare(list,Form("EventMixing_pt1_%1.1f_pt2_%1.1f",pt1_cut,pt2_cut),Form("Au+Au %s: invariant mass of dimuon pairs",trigName[kTrigType]),"(Mixed event)/Data",kFALSE,0,15,kFALSE,0.1,10,kTRUE,0,2,kTRUE,kTRUE,legName,kTRUE,"",0.5,0.7,0.7,0.85,kFALSE); if(save) c->SaveAs(Form("~/Work/STAR/analysis/Plots/ana_EventMixing/%s.Compare_LS_pt1_%1.1f_pt2_%1.1f.png",run_config,pt1_cut,pt2_cut)); c = draw1D(hInvMass[0],Form("Au+Au %s: invariant mass of di-muon pairs;M_{#mu#mu} (GeV/c^{2})",trigName[kTrigType]),kTRUE); hInvMass[1]->Draw("HIST sames"); hMixUS->SetLineColor(4); hMixUS->SetLineWidth(2); hMixUS->Scale(scale); hMixUS->Draw("sames HIST"); leg = new TLegend(0.45,0.65,0.55,0.88); leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetTextSize(0.04); leg->SetHeader(Form("p_{T,1} > %1.1f, p_{T,2} > %1.1f GeV/c",pt1_cut,pt2_cut)); leg->AddEntry(hInvMass[0],"Data: Unlike sign","PLE"); leg->AddEntry(hInvMass[1],"Data: Like sign (++)+(--)","L"); leg->AddEntry(hMixUS,"Mixed event: Like sign (++)+(--)","L"); leg->Draw(); if(save) c->SaveAs(Form("~/Work/STAR/analysis/Plots/ana_EventMixing/%s.Compare_US_pt1_%1.1f_pt2_%1.1f.png",run_config,pt1_cut,pt2_cut)); hInvMass[0]->GetXaxis()->SetRangeUser(2.5,3.5); hInvMass[0]->SetName(Form("%s_zoom",hInvMass[0]->GetName())); c = draw1D(hInvMass[0],Form("Au+Au %s: invariant mass of di-muon pairs;M_{#mu#mu} (GeV/c^{2})",trigName[kTrigType]),kFALSE); hInvMass[1]->Draw("HIST sames"); hMixUS->Draw("sames HIST"); leg = new TLegend(0.15,0.65,0.3,0.88); leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetTextSize(0.04); leg->SetHeader(Form("p_{T,1} > %1.1f, p_{T,2} > %1.1f GeV/c",pt1_cut,pt2_cut)); leg->AddEntry(hInvMass[0],"Data: Unlike sign","PLE"); leg->AddEntry(hInvMass[1],"Data: Like sign (++)+(--)","L"); leg->AddEntry(hMixUS,"Mixed event: Like sign (++)+(--)","L"); leg->Draw(); if(save) c->SaveAs(Form("~/Work/STAR/analysis/Plots/ana_EventMixing/%s.Compare_US_jpsi_pt1_%1.1f_pt2_%1.1f.png",run_config,pt1_cut,pt2_cut)); Double_t low_mass = 3.0, high_mass = 3.2; Int_t low_bin = hInvMass[0]->GetXaxis()->FindFixBin(low_mass); Int_t high_bin = hInvMass[0]->GetXaxis()->FindFixBin(high_mass); Double_t nBackground = hMixUS->Integral(low_bin,high_bin); Double_t nSignal = hInvMass[0]->Integral(low_bin,high_bin) - nBackground; TPaveText *signif = GetPaveText(0.15,0.45,0.12,0.25); signif->AddText(Form("[%1.1f,%1.1f] GeV/c^{2}",low_mass,high_mass)); signif->AddText(Form("S/B = %1.0f/%1.0f = %1.2e:1",nSignal,nBackground,nSignal/nBackground)); TH1F *hdiff_jpsi = (TH1F*)hInvMass[0]->Clone(Form("US-LS_jpsi")); hdiff_jpsi->Add(hMixUS,-1); hdiff_jpsi->GetXaxis()->SetRangeUser(3.05,3.15); c = draw1D(hdiff_jpsi,Form("Au+Au %s: invariant mass of di-muon pairs;M_{#mu#mu} (GeV/c^{2});US_{Data}-US_{mixing}",trigName[kTrigType]),kFALSE); gPad->SetGridy(); TPaveText *t1 = GetPaveText(0.2,0.4,0.8,0.85,0.04); t1->AddText(Form("p_{T,1} > %1.1f, p_{T,2} > %1.1f GeV/c",pt1_cut,pt2_cut)); t1->Draw(); if(save) c->SaveAs(Form("~/Work/STAR/analysis/Plots/ana_EventMixing/%s.Data-EventMixing_jpsi_pt1_%1.1f_pt2_%1.1f.png",run_config,pt1_cut,pt2_cut)); hdiff_jpsi->SetName(Form("%s_rebin4",hdiff_jpsi->GetName())); hdiff_jpsi->Rebin(4); hdiff_jpsi->GetXaxis()->SetRangeUser(2.5,3.5); c = draw1D(hdiff_jpsi,Form("Au+Au %s: invariant mass of di-muon pairs;M_{#mu#mu} (GeV/c^{2});US_{Data}-US_{mixing}",trigName[kTrigType]),kFALSE); gPad->SetGridy(); t1->Draw(); signif->Draw(); if(save) c->SaveAs(Form("~/Work/STAR/analysis/Plots/ana_EventMixing/%s.Data-EventMixing_jpsi_pt1_%1.1f_pt2_%1.1f_rebin4.png",run_config,pt1_cut,pt2_cut)); }
void ana_Run11_eff() { const int rebin = 1; TFile *f = TFile::Open("Rootfiles/Run11_eff.root","read"); // Run with weigth TH2F *hMcPtVsEta = (TH2F*)f->Get("mcJpsiPtY"); TH2F *hRcPtVsEta = (TH2F*)f->Get("hHt2JpsiPE"); draw2D(hMcPtVsEta); draw2D(hRcPtVsEta); hMcPtVsEta->GetXaxis()->SetRangeUser(-1+1e-6,1-1e-6); TH1F *hMcPt = (TH1F*)hMcPtVsEta->ProjectionY("hMcPt"); hMcPt->Rebin(rebin); hMcPt->SetMarkerStyle(20); draw1D(hMcPt,"",kTRUE); hRcPtVsEta->GetXaxis()->SetRangeUser(-1+1e-6,1-1e-6); TH1F *hRcPt = (TH1F*)hRcPtVsEta->ProjectionY("hRcPt"); hRcPt->Rebin(rebin); hRcPt->SetMarkerStyle(21); hRcPt->SetMarkerColor(2); hRcPt->SetLineColor(2); hRcPt->Draw("sames P"); TH1F *hRatio = (TH1F*)hRcPt->Clone("hRatio_fromRunning"); hRatio->Rebin(100); hMcPt->Rebin(100); hRatio->Divide(hMcPt); cEff = draw1D(hRatio,""); // Run without weight TH2F *hMcPtVsEtaNoWeight = (TH2F*)f->Get("mcJpsiPtY_Or"); draw2D(hMcPtVsEtaNoWeight); TH2F *hMcPtVsRcNoWeight = (TH2F*)f->Get("hJpsiRcvsMC_Cut1"); hMcPtVsRcNoWeight->RebinX(rebin); hMcPtVsRcNoWeight->RebinY(rebin); draw2D(hMcPtVsRcNoWeight); hMcPtVsEtaNoWeight->GetXaxis()->SetRangeUser(-1+1e-6,1-1e-6); TH1F *hMcPtNoWeight = (TH1F*)hMcPtVsEtaNoWeight->ProjectionY("hMcPtNoWeight"); hMcPtNoWeight->Rebin(rebin); hMcPtNoWeight->SetMarkerStyle(20); hMcPtNoWeight->SetMinimum(1); draw1D(hMcPtNoWeight,"",kTRUE); TH1F *hRcPtNoWeight = (TH1F*)hMcPtVsRcNoWeight->ProjectionX("hRcPtNoWeight"); hRcPtNoWeight->SetMarkerStyle(21); hRcPtNoWeight->SetMarkerColor(2); hRcPtNoWeight->SetLineColor(2); hRcPtNoWeight->Draw("sames P"); TH1F *hRatioNoWeight = (TH1F*)hRcPtNoWeight->Clone("hRatioNoWeight"); hRatioNoWeight->Divide(hMcPtNoWeight); cEff->cd(); hRatioNoWeight->SetMarkerColor(4); hRatioNoWeight->Draw("samesP"); // weight with input histogram TH1F *hMcPtWeight = (TH1F*)hMcPtNoWeight->Clone("hMcPtWeight"); TH2F *hMcPtVsRcWeight = (TH2F*)hMcPtVsRcNoWeight->Clone("hMcPtVsRcWeight"); for(int ibin=1; ibin<=hMcPtVsRcNoWeight->GetNbinsX(); ibin++) { double scale = hMcPt->GetBinContent(ibin); hMcPtWeight->SetBinContent(ibin,hMcPtWeight->GetBinContent(ibin)*scale); hMcPtWeight->SetBinError(ibin,hMcPtWeight->GetBinError(ibin)*scale); for(int jbin=1; jbin<=hMcPtVsRcNoWeight->GetNbinsY(); jbin++) { hMcPtVsRcWeight->SetBinContent(ibin,jbin,hMcPtVsRcWeight->GetBinContent(ibin,jbin)*scale); hMcPtVsRcWeight->SetBinError(ibin,jbin,hMcPtVsRcWeight->GetBinError(ibin,jbin)*scale); } } TH1F *hRcPtWeight = (TH1F*)hMcPtVsRcWeight->ProjectionY("hRcPtWeight"); hRcPtWeight->SetMarkerStyle(21); hRcPtWeight->SetMarkerColor(2); hRcPtWeight->SetLineColor(2); draw2D(hMcPtVsRcWeight); draw1D(hMcPtWeight,"",kTRUE); hRcPtWeight->Draw("sames P"); TH1F *hRatioWeight = (TH1F*)hRcPtWeight->Clone("hRatioWeight"); hRatioWeight->Divide(hMcPtWeight); cEff->cd(); hRatioWeight->SetMarkerColor(6); hRatioWeight->Draw("samesP"); TH1F *hCheck = (TH1F*)hRatioWeight->Clone("check"); hCheck->Divide(hRatio); draw1D(hCheck); // weight with fitted function TCanvas *c = new TCanvas("Fit","Fit",800,600); SetPadMargin(gPad,0.15,0.15); gPad->SetLogy(); TH1F *h = new TH1F("histogram",";;;",7,0,30); h->GetYaxis()->SetRangeUser(1e-7,100); h->Draw(); TFile *fdata = TFile::Open("Rootfiles/Spectrum_in_bin.root","read"); TGraphErrors *gr = (TGraphErrors*)fdata->Get("gall"); gr->SetMarkerColor(1); gr->SetLineColor(1); gr->GetXaxis()->SetRangeUser(0,30); gr->Draw("sames PE"); TF1 *func = new TF1("func",InvPt,0,30,4); func->SetParameters(0.4,-0.4796,4.229,-7.54); gr->Fit(func,"RL"); TH1F *hMcPtFunc = (TH1F*)hMcPtNoWeight->Clone("hMcPtFunc"); TH2F *hMcPtVsRcFunc = (TH2F*)hMcPtVsRcNoWeight->Clone("hMcPtVsRcFunc"); for(int ibin=1; ibin<=hMcPtVsRcFunc->GetNbinsX(); ibin++) { double scale = func->Eval(hMcPtFunc->GetBinCenter(ibin)); hMcPtFunc->SetBinContent(ibin,hMcPtFunc->GetBinContent(ibin)*scale); hMcPtFunc->SetBinError(ibin,hMcPtFunc->GetBinError(ibin)*scale); for(int jbin=1; jbin<=hMcPtVsRcNoWeight->GetNbinsY(); jbin++) { hMcPtVsRcFunc->SetBinContent(ibin,jbin,hMcPtVsRcFunc->GetBinContent(ibin,jbin)*scale); hMcPtVsRcFunc->SetBinError(ibin,jbin,hMcPtVsRcFunc->GetBinError(ibin,jbin)*scale); } } TH1F *hRcPtFunc = (TH1F*)hMcPtVsRcFunc->ProjectionY("hRcPtFunc"); hRcPtFunc->SetMarkerStyle(21); hRcPtFunc->SetMarkerColor(2); hRcPtFunc->SetLineColor(2); hMcPtVsRcFunc->GetZaxis()->SetRangeUser(1e-4,1e2); draw2D(hMcPtVsRcFunc); hMcPtFunc->GetYaxis()->SetRangeUser(1e-4,5e4); draw1D(hMcPtFunc,"",kTRUE); hRcPtFunc->Draw("sames P"); TH1F *hRatioFunc = (TH1F*)hRcPtFunc->Clone("hRatioFunc"); hRatioFunc->Rebin(100); hMcPtFunc->Rebin(100); hRatioFunc->Divide(hMcPtFunc); cEff->cd(); hRatioFunc->SetMarkerColor(5); hRatioFunc->Draw("samesP"); TH1F *hCheck2 = (TH1F*)hRatioFunc->Clone("check2"); hCheck2->Divide(hRatio); draw1D(hCheck2); }
void cosmic_Eff() { gStyle->SetOptStat(0); //TFile *f = TFile::Open("Output/cosmic.eff.root","read"); TFile *f = TFile::Open("Output/test.histos.root","read"); TH2F *hTrkPtVsBL[2]; hTrkPtVsBL[0] = (TH2F*)f->Get("nProBlvsPt"); hTrkPtVsBL[1] = (TH2F*)f->Get("nMatchBlvsPt2"); TH1F *hTrkPt[2][2]; for(Int_t i=0; i<2; i++) { //draw2D(hTrkPtVsBL[i]); hTrkPt[i][0] = (TH1F*)hTrkPtVsBL[i]->ProjectionX(Form("hTrkPt_%d_Bottom",i),9,23); hTrkPt[i][1] = (TH1F*)hTrkPtVsBL[i]->ProjectionX(Form("hTrkPt_%d_Top",i),1,7); for(Int_t j=0; j<2; j++) { hTrkPt[i][j]->Sumw2(); hTrkPt[i][j]->SetMarkerStyle(21); hTrkPt[i][j]->SetMarkerColor(color[i]); hTrkPt[i][j]->SetLineColor(color[i]); } hTrkPt[i][1]->Add((TH1F*)hTrkPtVsBL[i]->ProjectionX(Form("hTrkPt_%d_Top_2",i),24,30)); } const char *title[2] = {"bottom","top"}; for(Int_t j=0; j<2; j++) { c = draw1D(hTrkPt[0][j],Form("p_{T} of tracks matched to backlegs on %s;p_{T} (GeV/c);Counts",title[j])); hTrkPt[1][j]->Draw("samesP"); } TLegend *leg = new TLegend(0.25,0.15,0.45,0.3); leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetTextSize(0.04); TH1F *hTrkPtClone[2][2]; TGraphAsymmErrors *hEff[2]; for(Int_t j=0; j<2; j++) { hEff[j] = new TGraphAsymmErrors(); hEff[j]->SetName(Form("hEff_%s",title[j])); for(Int_t i=0; i<2; i++) { hTrkPtClone[i][j] = (TH1F*)hTrkPt[i][j]->Clone(Form("%s_clone",hTrkPt[i][j]->GetName())); } hEff[j]->Divide(hTrkPt[1][j],hTrkPt[0][j]); hTrkPtClone[1][j]->Divide(hTrkPtClone[0][j]); hTrkPtClone[1][j]->SetMarkerStyle(25-j*4); hTrkPtClone[1][j]->SetMarkerColor(color[j]); hTrkPtClone[1][j]->SetLineColor(color[j]); hTrkPtClone[1][j]->GetYaxis()->SetRangeUser(0,1.2); leg->AddEntry(hTrkPtClone[1][j],title[j],"PLE"); hEff[j]->SetMarkerStyle(25-j*4); hEff[j]->SetMarkerColor(color[j]); hEff[j]->SetLineColor(color[j]); hEff[j]->SetMaximum(1.1); } c = draw1D(hTrkPtClone[1][0]); hTrkPtClone[1][1]->Draw("sames"); leg->Draw(); //cout << hEff[j]->GetErrorYhigh(0) << endl; // drawGraph(hEff[0],"Track matching efficiency to MTD;p_{T} (GeV/c);Efficiency"); // hEff[1]->Draw("samesP"); // leg->Draw(); }