void compareWeights(const char* fileName, const std::string plotTitle, const std::string plotType, const std::string plot, const std::string xlabel, const float xMin, const float xMax) { gStyle->SetOptStat(0); gROOT->ForceStyle(); THStack* histStack = new THStack("histStack", plotTitle.c_str()); TLegend* legend = new TLegend(.55 ,.55 ,.885 ,.875); legend->SetFillColor(kWhite); std::vector<std::string> weightNames = {"unit wgt = 0.000001"}; //{"f_{T1} = 5e-12 ", "f_{T1} = 4e-12 ", //"f_{T1} = 1.5e-12 ", "Standard Model"}; std::vector<int> colors = {kRed-7, kAzure-3, kGreen-6, kBlack, kBlue-4}; TFile signal_file(fileName); TCanvas* canvas = new TCanvas("canvas","Weight Comparison",150,10,990,660); canvas->cd(); int numBins = 13; float rebinPoint = 0; double variableBins[numBins+1]; for (int i = 0; i <= numBins; i++) { if (i < 10) rebinPoint += 75.; else if (i < 11) rebinPoint += 150.; else rebinPoint += 200; variableBins[i] = rebinPoint; } std::string bg_path = "/nfs_scratch/kdlong/wpz_zg_qcdbkgd/Events/run_01/"; bg_path += fileName; addBackground(histStack, bg_path, plotType, plot, legend, "WZ EWK + QCD", variableBins, numBins); for (unsigned int i = 0; i < weightNames.size(); i++) { std::string path = weightNames[i] + "/" + plotType + "/" + plot; TH1F* hist = static_cast<TH1F*>(signal_file.GetObjectChecked(path.c_str(), "TH1F")); //hist->SetFillColor(colors[i]); hist->SetLineColor(colors[i]); hist->SetLineWidth(2); TH1* histRebin = hist->Rebin(numBins, "histRebin", variableBins); histRebin->Sumw2(); histStack->Add(histRebin, "hist E1"); std::string legendName = "WZ EWK (" + weightNames[i] + ")"; legend->AddEntry(hist, legendName.c_str(), "l"); } histStack->Draw("nostack"); histStack->GetXaxis()->SetTitle(xlabel.c_str()); histStack->GetYaxis()->SetTitle("Events"); //histStack->GetXaxis()->SetRangeUser(xMin, xMax); //histStack->SetMaximum(125); histStack->DrawClone("nostack"); legend->DrawClone("same"); canvas->Update(); canvas->Print("WZTMassComp_zg_bg_cuts.pdf"); }
void plot_bgnd(int ch=4) { vector<fileInfo> files; files.push_back(fileInfo("u#bar{u}", TFile::Open(Form("Histo_ch%d_uubar.root" ,ch)), kRed)); files.push_back(fileInfo("d#bar{d}", TFile::Open(Form("Histo_ch%d_ddbar.root" ,ch)), kGreen)); files.push_back(fileInfo("s#bar{s}", TFile::Open(Form("Histo_ch%d_ssbar.root" ,ch)), kBlue)); files.push_back(fileInfo("c#bar{c}", TFile::Open(Form("Histo_ch%d_ccbar.root" ,ch)), kOrange)); // files.push_back(fileInfo("mixed", TFile::Open(Form("Histo_ch%d_mixed.root" ,ch)), kViolet)); // files.push_back(fileInfo("charged", TFile::Open(Form("Histo_ch%d_charged.root",ch)), kGray)); gStyle->SetPadTopMargin(0.10); gStyle->SetOptStat(0); gStyle->SetTitleSize(.5,"XYZ"); TLatex* tt=new TLatex(); tt->SetTextSize(0.05); vector<plotInfo> plotInfos; getWhatToPlot(ch, plotInfos); if (plotAllDistributions) { TLine* tl=new TLine(); tl->SetLineWidth(2); tl->SetLineColor(kRed+2); int nHisto=plotInfos.size(); int nX=3, nY=1; float sizeX=900,sizeY=300; const int nCanvas(nHisto/(nX*nY)+1); TLegend* tleg=new TLegend(0.8,0.6,0.96,0.89); tleg->SetFillStyle(0); TCanvas* c0[nCanvas]; int iCan=0; c0[iCan]=new TCanvas(Form("c0%d",iCan),"Before Cuts",sizeX,sizeY); c0[iCan]->Divide(nX,nY); int i=0; for (vector<plotInfo>::const_iterator h=plotInfos.begin(); h!=plotInfos.end(); ++h) { THStack hs; TString xTitle; for (vector<fileInfo>::const_iterator f=files.begin(); f!=files.end(); ++f) { c0[iCan]->cd(i+1); (f->file)->cd("AllCandidates"); TH1* htmp=(TH1F*)gDirectory->Get(h->name); float ymin=0; if (h->log) { gPad->SetLogy(); ymin=10; } if (htmp) { htmp->GetXaxis()->SetTitleOffset(.7); htmp->GetXaxis()->SetTitleSize(0.08); htmp->SetFillColor(f->color); htmp->SetMinimum(ymin); hs.Add(htmp); xTitle=htmp->GetXaxis()->GetTitle(); if (i==0) { tleg->AddEntry(htmp,f->name,"f"); } } } hs.DrawClone(); tt->SetTextAlign(32); tt->DrawLatexNDC(0.95,.03,xTitle); tl->DrawLine(h->cutLow,ymin,h->cutLow,htmp->GetMaximum()*1.05); tl->DrawLine(h->cutHigh,ymin,h->cutHigh,htmp->GetMaximum()*1.05); if (i==0) tleg->Draw(); ++i; // Check if I need a new canvas if (i>nX*nY) { channel(ch,c0[iCan]); c0[iCan]->Print(Form("Ch%d_all_distr%d_bgnd.pdf",ch,iCan)); c0[iCan]->Print(Form("Ch%d_all_distr%d_bgnd.png",ch,iCan)); iCan++; c0[iCan]=new TCanvas(Form("c0%d",iCan),"Before Cuts",sizeX,sizeY); c0[iCan]->Divide(nX,nY); tleg->Clear(); i=0; } } channel(ch,c0[iCan]); c0[iCan]->Print(Form("Ch%d_all_distr%d_bgnd.pdf",ch,iCan)); c0[iCan]->Print(Form("Ch%d_all_distr%d_bgnd.png",ch,iCan)); } if(plotGoldDistributions) { TLine* tl=new TLine(); tl->SetLineWidth(2); tl->SetLineColor(kRed+2); TCanvas* c1=new TCanvas("c1","Before Cuts",900,600); c1->Divide(3,2); TLegend* tleg=new TLegend(0.8,0.6,0.96,0.89); tleg->SetFillStyle(0); int i=0; for (vector<plotInfo>::const_iterator h=plotInfos.begin(); h!=plotInfos.end(); ++h) { if (!h->gold) continue; THStack hs; TString xTitle; for (vector<fileInfo>::const_iterator f=files.begin(); f!=files.end(); ++f) { c1->cd(i+1); (f->file)->cd("AllCandidates"); TH1* htmp=(TH1F*)gDirectory->Get(h->name); float ymin=0; if (h->log) { gPad->SetLogy(); ymin=10; } if (htmp) { htmp->SetFillColor(f->color); htmp->GetXaxis()->SetTitleOffset(.7); htmp->GetXaxis()->SetTitleOffset(.7); htmp->GetXaxis()->SetTitleSize(0.08); xTitle=htmp->GetXaxis()->GetTitle(); hs.Add(htmp); if (i==0) { cout << "Adding " << f->name << endl; tleg->AddEntry(htmp,f->name,"f"); } } } hs.DrawClone(); tt->SetTextAlign(32); tt->DrawLatexNDC(0.95,.03,xTitle); tl->DrawLine(h->cutLow,ymin,h->cutLow,htmp->GetMaximum()*1.05); tl->DrawLine(h->cutHigh,ymin,h->cutHigh,htmp->GetMaximum()*1.05); if (i==0) tleg->Draw(); ++i; } channel(ch,c1); c1->Print(Form("Ch%d_distr_bgnd.pdf",ch)); c1->Print(Form("Ch%d_distr_bgnd.png",ch)); } }
void Interpolate(const TString& trigger="INEL") { if (gSystem->Getenv("FWD")) fwd = gSystem->Getenv("FWD"); else fwd = gSystem->ExpandPathName("$ALICE_PHYSICS/PWGLF/FORWARD/analysis2"); gROOT->SetMacroPath(Form("%s/dndeta:%s", gROOT->GetMacroPath(),fwd)); if (!gROOT->GetClass("Drawer")) gROOT->LoadMacro("Drawer.C+"); TH1* h0900 = GetOne( 900, trigger); TH1* h2760 = GetOne(2760, trigger); TH1* h7000 = GetOne(7000, trigger); TH1* h8000 = GetOne(8000, trigger); Info("","900: %p 2760: %p 7000: %p 8000: %p", h0900, h2760, h7000, h8000); Double_t e8000 = (trigger.EqualTo("INEL") ? 0.852 : 0.93); h8000->Scale(e8000); TFile* out = TFile::Open("trends.root", "RECREATE"); THStack* sOrig = new THStack("orig", Form("pp - %s", trigger.Data())); sOrig->Add(h8000); sOrig->Add(h7000); sOrig->Add(h2760); sOrig->Add(h0900); TCanvas* cOrig = new TCanvas("cOrig", "Original", 1200, 1200); cOrig->SetTopMargin(0.01); cOrig->SetRightMargin(0.01); sOrig->Draw("nostack"); sOrig->GetHistogram()->SetYTitle("1/#it{N} d#it{N}_{ch}/d#it{#eta}"); sOrig->GetHistogram()->SetXTitle("#it{#eta}"); sOrig->DrawClone("nostack"); sOrig->Write(); TLegend* l = cOrig->BuildLegend(.35, .2, .55, .6, "#sqrt{s}"); l->SetFillColor(0); l->SetFillStyle(0); l->SetBorderSize(0); cOrig->Modified(); cOrig->Update(); cOrig->cd(); cOrig->Write(); Info("", "Wrote original"); TCanvas* cG = new TCanvas("cG", "one", 1200, 1200); cG->SetTopMargin(0.01); cG->SetRightMargin(0.01); Info("","Creating tuple"); TNtuple* tuple = new TNtuple("tuple", "Tuple", "eta:deta:" "v0900:e0900:v2760:e2760:" "v7000:e7000:v8000:e8000"); TMultiGraph* mg = new TMultiGraph; Int_t n = h0900->GetNbinsX(); Info("","Loop over bins %d", n); for (Int_t i = 1; i <= n; i++) { Info("", "Getting one bin %d,%p,%p,%p,%p,%p,%p", i, h0900,h2760,h7000,h8000,mg,tuple); OneBin(i, h0900, h2760, h7000, h8000, mg, tuple); } mg->Draw("alp"); cG->Modified(); cG->Update(); cG->cd(); TPrincipal* p =tuple->Principal("v0900:v2760:v7000:v8000","eta<0", "npdhc"); }