void Legend::SetOrientation(Orientation orientation, std::string const& title) { INFO0; if(!legend_.GetListOfPrimitives()) return; std::vector<std::string> entries; auto list = legend_.GetListOfPrimitives()->MakeIterator(); TLegendEntry* entry; while ((entry = static_cast<TLegendEntry*>(list->Next()))) entries.emplace_back(entry->GetLabel()); SetOrientation(orientation, entries, title); SetTitle(title); }
//____________________________________________________________________ TH1* One(TDirectory* newDir, TDirectory* oldDir, Double_t c1, Double_t c2) { TString name; name.Form("cent%03dd%02d_%03dd%02d", Int_t(c1), Int_t(c1*100)%100, Int_t(c2), Int_t(c2*100)%100); TDirectory* newSubDir = GetD(newDir, name); TDirectory* oldSubDir = GetD(oldDir, name); if (!newSubDir || !oldSubDir) return 0; Int_t newDim = 0; if (TString(newDir->GetName()).Contains("etaipz")) newDim = 3; else if (TString(newDir->GetName()).Contains("eta")) newDim = 2; else if (TString(newDir->GetName()).Contains("const")) newDim = 1; Int_t oldDim = 0; if (TString(oldDir->GetName()).Contains("etaipz")) oldDim = 3; else if (TString(oldDir->GetName()).Contains("eta")) oldDim = 2; else if (TString(oldDir->GetName()).Contains("const")) oldDim = 1; TDirectory* newSubSubDir = GetD(newSubDir, Form("results%dd",newDim)); TDirectory* oldSubSubDir = GetD(oldSubDir, Form("results%dd",oldDim)); if (!newSubSubDir || !oldSubSubDir) return 0; TH1* newRes = GetH1(newSubSubDir, "result"); TH1* oldRes = GetH1(oldSubSubDir, "result"); if (!newRes || !oldRes) return 0; TH1* ratio = static_cast<TH1*>(newRes->Clone(name)); ratio->SetDirectory(0); ratio->SetTitle(Form("%5.1f - %5.1f%%", c1, c2)); ratio->SetYTitle("New / Old"); ratio->Divide(oldRes); fMin = TMath::Min(fMin, ratio->GetMinimum()); fMax = TMath::Max(fMax, ratio->GetMaximum()); Printf("Calculated %s/%s", newDir->GetName(), oldDir->GetName()); if (!fLegend) return ratio; TLegendEntry* e = fLegend->AddEntry("", Form("%3.0f - %3.0f%%", c1, c2), "f"); e->SetFillStyle(1001); e->SetFillColor(ratio->GetMarkerColor()); return ratio; }
void makePlot_legend(TLegend* legend, const std::string& outputFilePath, const std::string& outputFileName) { TCanvas* canvas_legend = new TCanvas("canvas_legend", "canvas_legend", 900, 800); canvas_legend->SetFillColor(10); canvas_legend->SetBorderSize(2); canvas_legend->Draw(); canvas_legend->cd(); legend->SetX1NDC(0.30); legend->SetY1NDC(0.30); legend->SetX2NDC(0.80); legend->SetY2NDC(0.80); legend->SetTextSize(0.070); legend->SetMargin(0.20); TList* legend_primitives = legend->GetListOfPrimitives(); TIter legend_nextObj(legend_primitives); while ( TObject* obj = legend_nextObj() ) { std::string objName = ""; if ( dynamic_cast<TNamed*>(obj) ) objName = (dynamic_cast<TNamed*>(obj))->GetName(); //std::cout << "obj = " << obj << ": name = " << objName << ", type = " << obj->ClassName() << std::endl; TLegendEntry* legendEntry = dynamic_cast<TLegendEntry*>(obj); if ( legendEntry ) { TH1* histogram = dynamic_cast<TH1*>(legendEntry->GetObject()); if ( histogram ) { histogram->SetLineWidth(2*histogram->GetLineWidth()); histogram->SetMarkerSize(3); } } } legend->Draw(); canvas_legend->Update(); std::string outputFileName_full = Form("%s%s", outputFilePath.data(), outputFileName.data()); size_t idx = outputFileName_full.find_last_of('.'); std::string outputFileName_plot = std::string(outputFileName_full, 0, idx); canvas_legend->Print(std::string(outputFileName_plot).append(".pdf").data()); canvas_legend->Print(std::string(outputFileName_plot).append(".root").data()); delete canvas_legend; }
void PlotAlignmentValidation::modifySSHistAndLegend(THStack* hs, TLegend* legend) { // Add mean-y-values to the legend and scale the histograms. Double_t legendY = 0.80; if (hs->GetHists()->GetSize() > 3) legendY -= 0.01 * (hs->GetHists()->GetSize() - 3); if (legendY < 0.6) { std::cerr << "Warning: Huge legend!" << std::endl; legendY = 0.6; } legend->SetY1(legendY); // Loop over all profiles TProfile* prof = 0; TIter next(hs->GetHists()); Int_t index = 0; while ((prof = (TProfile*)next())) { //Scaling: from cm to um Double_t scale = 10000; prof->Scale(scale); Double_t stats[6] = {0}; prof->GetStats(stats); std::ostringstream legendtext; legendtext.precision(3); legendtext << fixed; // to always show 3 decimals legendtext << ": y mean = " << stats[4]/stats[0]*scale << " #mum"; TLegendEntry* entry = (TLegendEntry*)legend->GetListOfPrimitives()->At(index); if (entry == 0) cout << "PlotAlignmentValidation::PlotAlignmentValidation::modifySSLegend: Bad legend!" << endl; else entry->SetLabel((entry->GetLabel() + legendtext.str()).c_str()); index++; } }
/** * Create ratios to other data * * @param ib Bin number * @param res Result * @param alice ALICE result if any * @param cms CMS result if any * @param all Stack to add ratio to */ void Ratio2Stack(Int_t ib, TH1* res, TGraph* alice, TGraph* cms, THStack* all) { if (!all || !res || !(alice || cms)) return; Int_t off = 5*ib; TGraph* gs[] = { (alice ? alice : cms), (alice ? cms : 0), 0 }; TGraph** pg = gs; while (*pg) { TGraph* g = *pg; const char* n = (g == alice ? "ALICE" : "CMS"); TH1* r = static_cast<TH1*>(res->Clone(Form("ratio%s", n))); TString tit(r->GetTitle()); tit.ReplaceAll("Corrected", Form("Ratio to %s", n)); r->SetTitle(tit); r->SetMarkerColor(g->GetMarkerColor()); r->SetLineColor(g->GetLineColor()); TObject* tst = r->FindObject("legend"); if (tst) r->GetListOfFunctions()->Remove(tst); for (Int_t i = 1; i <= r->GetNbinsX(); i++) { Double_t c = r->GetBinContent(i); Double_t e = r->GetBinError(i); Double_t o = g->Eval(r->GetBinCenter(i)); if (o < 1e-12) { r->SetBinContent(i, 0); r->SetBinError(i, 0); continue; } r->SetBinContent(i, (c - o) / o + off); r->SetBinError(i, e / o); } all->Add(r); pg++; } TLegend* leg = StackLegend(all); if (!leg) return; TString txt = res->GetTitle(); txt.ReplaceAll("Corrected P(#it{N}_{ch}) in ", ""); if (ib == 0) txt.Append(" "); // (#times1)"); // else if (ib == 1) txt.Append(" (#times10)"); else txt.Append(Form(" (+%d)", off)); TObject* dummy = 0; TLegendEntry* e = leg->AddEntry(dummy, txt, "p"); e->SetMarkerStyle(res->GetMarkerStyle()); e->SetMarkerSize(res->GetMarkerSize()); e->SetMarkerColor(kBlack); e->SetFillColor(0); e->SetFillStyle(0); e->SetLineColor(kBlack); }
// A macro to print out a TLegend - can be considered a smarter TLegend::ls(). // If no TLegend pointer is passed, it loops over the TLegends drawn on current TPad. void PrintLegend(TLegend *leg=0) { if ( leg==0 ) { if (gROOT->GetListOfCanvases()->GetEntries()==0) return; TList *padprim = gPad->GetListOfPrimitives(); for (int i=0; i<padprim->GetEntries(); i++) { TObject *myobj = gROOT->FindObject(padprim->At(i)->GetName()); if ( myobj != 0 && myobj->InheritsFrom("TLegend") ) PrintLegend((TLegend*)myobj); } return; } TList *ents = leg->GetListOfPrimitives(); for (int i=0; i<ents->GetEntries(); i++) { TLegendEntry *le = (TLegendEntry*)ents->At(i); TString s( le->GetLabel() ); TObject *obj = le->GetObject(); if (!obj) continue; // if no object, this can be the title line, so skip TString color = "???"; if ( obj->InheritsFrom("TH1") ) color = gROOT->GetListOfColors()->At(((TH1*)obj)->GetLineColor())->GetName(); cout << "Item "; cout.width(2); cout.fill('0'); cout << i << " plotted in "; cout.width(7); cout.fill(' '); cout << color << " : " << s << endl; } //leg->ls(); }
fitYnSMassUnbinned(const char *filename = "YMassOS_186nb.txt", const char* plotOpt = "NEU", const int nbins = 40, const char* filenameB = "YMassSS_186nb.txt") { gROOT->ProcessLine(".L tdrstyle.C"); setTDRStyle(); gStyle->SetPadRightMargin(0.05); RooRealVar mass("mass","M(#mu^{+}#mu^{-})", 8.0, 12.0,"GeV/c^{2}"); // Read data set RooDataSet *data = RooDataSet::read(filename,RooArgSet(mass)); RooDataSet *dataB = RooDataSet::read(filenameB,RooArgSet(mass)); // Build p.d.f. //////////////////////////////////////////////// // Parameters // //////////////////////////////////////////////// // Signal p.d.f. parameters // Parameters for a Gaussian and a Crystal Ball Lineshape RooRealVar m0 ("m_{0}", "Bias", 9.46, 9.2, 9.7,"GeV/c^{2}"); RooRealVar sigma("#sigma","Width", 0.04,0.01,0.1,"GeV/c^{2}"); RooRealVar cut ("#alpha","Cut", 0.6,0.6,2.0); RooRealVar power("power","Power", 10.0, 0.5, 20.0); // Background p.d.f. parameters // Parameters for a polynomial lineshape RooRealVar c0("c_{0}", "c0", 0., -10, 10); RooRealVar c1("c_{1}", "c1", 0., -100, 0); RooRealVar c2("c_{2}", "c2", 0., -100, 100); // c0.setConstant(); // fraction of signal // RooRealVar frac("frac", "Signal Fraction", 0.1,0.,0.3.); RooRealVar nsig("N_{S}", "#signal events", 9000, 0.,10000.); RooRealVar nbkg("N_{B}", "#background events", 1000,2,10000.); //////////////////////////////////////////////// // P.D.F.s // //////////////////////////////////////////////// // Di-photon mass signal p.d.f. RooGaussian signal("signal", "A Gaussian Lineshape", mass, m0, sigma); // RooCBShape signal("signal", "A Crystal Ball Lineshape", mass, m0,sigma, cut, power); // Di-photon mass background p.d.f. RooPolynomial bg("bg", "Backgroung Distribution", mass, RooArgList(c0,c1)); // Di-photon mass model p.d.f. // RooAddPdf model("model", "Di-photon mass model", signal, bg, frac); RooAddPdf model("model", "Di-photon mass model", RooArgList(signal, bg), RooArgList(nsig, nbkg)); TStopwatch t ; t.Start() ; model->fitTo(*data,FitOptions("mh"),Optimize(0),Timer(1)); t.Print() ; c = new TCanvas("c","J/psi->mu mu Distributions", 0,0,800,600); // Plot the fit results RooPlot* plot = mass.frame(Range(8.0,12.0),Bins(nbins)); // Plot 1 dataB->plotOn(plot, MarkerColor(kRed)); data->plotOn(plot); model.plotOn(plot); //model.paramOn(plot, Format(plotOpt, AutoPrecision(1)), Parameters(RooArgSet(nsig, nbkg, m0, sigma))); model.paramOn(plot, Format(plotOpt, AutoPrecision(1)), Parameters(RooArgSet(m0, sigma))); /// model.plotOn(plot, Components("signal"), LineStyle(kDashed), LineColor(kRed)); model.plotOn(plot, Components("bg"), LineStyle(kDashed), LineColor(kRed)); plot->Draw(); TLatex * tex = new TLatex(0.2,0.8,"CMS preliminary"); tex->SetTextFont(42); tex->SetNDC(); tex->SetLineWidth(2); tex->Draw(); tex->DrawLatex(0.2, 0.725, "#sqrt{s} = 7 TeV"); tex->DrawLatex(0.2, 0.650, "L = 186 nb^{-1}"); float fsig_peak = NormalizedIntegral(signal, mass, m0.getVal() - 2.5*sigma.getVal(), m0.getVal() + 2.5*sigma.getVal() ); float fbkg_peak = NormalizedIntegral(bg, mass, m0.getVal() - 2.5*sigma.getVal(), m0.getVal() + 2.5*sigma.getVal() ); double nsigVal = fsig_peak * nsig.getVal(); double nsigErr = fsig_peak * nsig.getError(); double nsigErrRel = nsigErr / nsigVal; double nbkgVal = fbkg_peak * nbkg.getVal(); double nbkgErr = fbkg_peak * nbkg.getError(); double nbkgErrRel = nbkgErr / nbkgVal; cout << "nsig " << nsigVal << " +/- " << nsigErr << endl; cout << "S/B_{#pm2.5#sigma} " << nsigVal/nbkgVal << " +/- " << (nsigVal/nbkgVal)*sqrt(nsigErrRel*nsigErrRel + nbkgErrRel*nbkgErrRel) << endl; tex->DrawLatex(0.2, 0.5, Form("N_{S} = %.0f#pm%.0f", nsigVal, nsigErr) ); tex->DrawLatex(0.2, 0.425, Form("S/B_{#pm2.5#sigma} = %.1f", nsigVal/nbkgVal) ); tex->DrawLatex(0.2, 0.35, Form("#frac{S}{#sqrt{B}}_{#pm2.5#sigma} = %.1f", nsigVal/sqrt(nbkgVal))); leg = new TLegend(0.65,0.6,0.9,0.75); leg->SetFillColor(kWhite); leg->SetLineColor(kWhite); leg->SetShadowColor(kWhite); leg->SetTextFont(42); TLegendEntry * ldata = leg->AddEntry(data, "Opposite Sign"); TLegendEntry * ldataB = leg->AddEntry(dataB, "Same Sign"); ldata->SetMarkerStyle(20); ldataB->SetMarkerStyle(20); ldataB->SetMarkerColor(kRed); leg->Draw(); }
void runEffRej() { gROOT->LoadMacro("AtlasStyle.C"); gROOT->LoadMacro("AtlasUtils.C"); gROOT->LoadMacro("AtlasLabels.C"); TString input("effrej_su4"); TFile* r17 = new TFile(TString("input/btagval.su4.susy1049.root"),"READ"); TFile* r16 = new TFile(TString("input/btagval.su4.susy1004.root"),"READ"); TString prefix("btagwgt/"); bool doLogY = true; //bool doLogY = false; vector<TString> cuts; // cuts.push_back("2jet_metmeff0.25"); cuts.push_back("2jet_deltaphi0.4"); // cuts.push_back("2jet_deltaphi0.4cr"); // cuts.push_back("2jet_nbtag1"); // cuts.push_back("2jet_qcdcontrol"); // cuts.push_back("2jet_nbtag2"); // cuts.push_back("2jet_metphi"); // cuts.push_back("2jet_mct100"); // cuts.push_back("2jet_mct100cr"); // cuts.push_back("2jet_mct150"); // cuts.push_back("2jet_mct200"); // cuts.push_back("2jetX_metmeff0.25"); // cuts.push_back("2jetX_deltaphi0.4"); // cuts.push_back("2jetX_deltaphi0.4cr"); // cuts.push_back("2jetX_nbtag1"); // cuts.push_back("2jetX_qcdcontrol"); // cuts.push_back("2jetX_nbtag2"); // cuts.push_back("2jetX_metphi"); // cuts.push_back("2jetX_mct100"); // cuts.push_back("2jetX_mct100cr"); // cuts.push_back("2jetX_mct150"); // cuts.push_back("2jetX_mct200"); // cuts.push_back("3jet_metmeff0.25"); cuts.push_back("3jet_deltaphi0.4"); // cuts.push_back("3jet_nbtag1"); // cuts.push_back("3jet_ewcontrol"); // cuts.push_back("3jet_topcontrol"); // cuts.push_back("3jet_topcontrol_2"); /* cuts.push_back("3jet_meff500_qcdcontrol"); cuts.push_back("3jet_meff500_2_qcdcontrol"); cuts.push_back("3jet_meff700_qcdcontrol"); cuts.push_back("3jet_meff700_2_qcdcontrol"); cuts.push_back("3jet_meff900_qcdcontrol"); cuts.push_back("3jet_meff900_2_qcdcontrol"); */ /* cuts.push_back("3jet_meff500"); cuts.push_back("3jet_meff500_2"); cuts.push_back("3jet_meff700"); cuts.push_back("3jet_meff700_2"); cuts.push_back("3jet_meff900"); cuts.push_back("3jet_meff900_2"); */ vector<TString> plottype; plottype.push_back("jjfitNN0jfitNN"); plottype.push_back("jjfitNN1jfitNN"); plottype.push_back("jjfitNN2jfitNN"); plottype.push_back("jsv00sv0"); plottype.push_back("jsv01sv0"); plottype.push_back("jsv02sv0"); TString logstring = ""; if(doLogY) logstring = "_logy"; TCanvas* canvas = new TCanvas(); canvas->Print(TString::Format("output/%s_2jet%s.ps[",input.Data(),logstring.Data()),"Portrait"); canvas->Print(TString::Format("output/%s_2jetX%s.ps[",input.Data(),logstring.Data()),"Portrait"); canvas->Print(TString::Format("output/%s_3jet%s.ps[",input.Data(),logstring.Data()),"Portrait"); gStyle->SetPaperSize(100,20); vector<TString>::iterator cut = cuts.begin(); for(; cut!=cuts.end(); cut++) { vector<TString>::iterator type = plottype.begin(); for(; type!=plottype.end(); type++) { canvas->Clear(); canvas->SetLogy(doLogY); TString histo_l = TString::Format("%s%s_%s_l",prefix.Data(),cut->Data(),type->Data()); TString histo_c = TString::Format("%s%s_%s_c",prefix.Data(),cut->Data(),type->Data()); TString histo_b = TString::Format("%s%s_%s_b",prefix.Data(),cut->Data(),type->Data()); TH1F* R17_l = (TH1F*)r17->Get(histo_l); TH1F* R17_c = (TH1F*)r17->Get(histo_c); TH1F* R17_b = (TH1F*)r17->Get(histo_b); TH1F* R16_l = (TH1F*)r16->Get(histo_l); TH1F* R16_c = (TH1F*)r16->Get(histo_c); TH1F* R16_b = (TH1F*)r16->Get(histo_b); map<TString, float> op; //op, eff map<TString, float> r17op; //op, eff map<TString, float> newop; //oldop, newop //Find current efficiency operating points if(histo_b.Contains("sv0")) { op["5.85"] = R16_b->Integral(R16_b->FindBin(5.85),-1)/R16_b->Integral(0,-1); r17op["5.85"] = R17_b->Integral(R17_b->FindBin(5.85),-1)/R17_b->Integral(0,-1); for(int i = 0; i<100; i++) { float eff = R17_b->Integral(i,-1)/R17_b->Integral(0,-1); //cout << eff << " " << op["5.85"] << endl; if(eff>op["5.85"]) continue; else { //float slope = (R17_b->GetBinCenter(i)-R17_b->GetBinCenter(i-1))/(eff-R17_b->Integral(i-1,-1)/R17_b->Integral(0,-1)); //newop["5.85"] = R17_b->GetBinCenter(i-1)+slope*(op["5.85"]-R17_b->Integral(i-1,-1)/R17_b->Integral(0,-1)); newop["5.85"] = (R17_b->GetBinCenter(i-1)+R17_b->GetBinCenter(i))/2.; break; } } cout << "5.85: "<< op["5.85"] << ", " << newop["5.85"] << ": " << R17_b->Integral(R17_b->FindBin(newop["5.85"]),-1)/R17_b->Integral(0,-1) << endl; } else { op["2.00"] = R16_b->Integral(R16_b->FindBin(2.00),-1)/R16_b->Integral(0,-1); op["0.35"] = R16_b->Integral(R16_b->FindBin(0.35),-1)/R16_b->Integral(0,-1); op["-1.25"] = R16_b->Integral(R16_b->FindBin(-1.25),-1)/R16_b->Integral(0,-1); r17op["2.00"] = R17_b->Integral(R16_b->FindBin(2.00),-1)/R17_b->Integral(0,-1); r17op["0.35"] = R17_b->Integral(R16_b->FindBin(0.35),-1)/R17_b->Integral(0,-1); r17op["-1.25"] = R17_b->Integral(R16_b->FindBin(-1.25),-1)/R17_b->Integral(0,-1); for(int i = 0; i<100; i++) { float eff = R17_b->Integral(i,-1)/R17_b->Integral(0,-1); //cout << eff << " " << op["2.00"] << endl; if(eff>op["2.00"]) continue; else { //float slope = (R17_b->GetBinCenter(i)-R17_b->GetBinCenter(i-1))/(eff-R17_b->Integral(i-1,-1)/R17_b->Integral(0,-1)); //newop["2.00"] = R17_b->GetBinCenter(i-1)+slope*(op["2.00"]-R17_b->Integral(i-1,-1)/R17_b->Integral(0,-1)); newop["2.00"] = (R17_b->GetBinCenter(i-1)+R17_b->GetBinCenter(i))/2.; break; } } cout << "2.00: "<< op["2.00"] << ", " << newop["2.00"] << ": " << R17_b->Integral(R17_b->FindBin(newop["2.00"]),-1)/R17_b->Integral(0,-1) << endl; for(int i = 0; i<100; i++) { float eff = R17_b->Integral(i,-1)/R17_b->Integral(0,-1); //cout << eff << " " << op["0.35"] << endl; if(eff>op["0.35"]) continue; else { //float slope = (R17_b->GetBinCenter(i)-R17_b->GetBinCenter(i-1))/(eff-R17_b->Integral(i-1,-1)/R17_b->Integral(0,-1)); //newop["0.35"] = R17_b->GetBinCenter(i-1)+slope*(op["0.35"]-R17_b->Integral(i-1,-1)/R17_b->Integral(0,-1)); newop["0.35"] = (R17_b->GetBinCenter(i-1)+R17_b->GetBinCenter(i))/2.; break; } } cout << "0.35: "<< op["0.35"] << ", " << newop["0.35"] << ": " << R17_b->Integral(R17_b->FindBin(newop["0.35"]),-1)/R17_b->Integral(0,-1) << endl; for(int i = 0; i<100; i++) { float eff = R17_b->Integral(i,-1)/R17_b->Integral(0,-1); //cout << eff << " " << op["0.35"] << endl; if(eff>op["-1.25"]) continue; else { //float slope = (R17_b->GetBinCenter(i)-R17_b->GetBinCenter(i-1))/(eff-R17_b->Integral(i-1,-1)/R17_b->Integral(0,-1)); //newop["-1.25"] = R17_b->GetBinCenter(i-1)+slope*(op["-1.25"]-R17_b->Integral(i-1,-1)/R17_b->Integral(0,-1)); newop["-1.25"] = (R17_b->GetBinCenter(i-1)+R17_b->GetBinCenter(i))/2.; break; } } cout << "-1.25: "<< op["-1.25"] << ", " << newop["-1.25"] << ": " << R17_b->Integral(R17_b->FindBin(newop["-1.25"]),-1)/R17_b->Integral(0,-1) << endl; } R17_l->Rebin(5); R17_c->Rebin(5); R17_b->Rebin(5); R16_l->Rebin(5); R16_c->Rebin(5); R16_b->Rebin(5); TH2F* grid = new TH2F("grid","grid",2,0.,1.,2,1.,1000.); TString num; if(histo_b.Contains("2")) num = "3 tags"; else if(histo_b.Contains("1")) num = "2 tags"; else if(histo_b.Contains("0")) num = "1 tag"; grid->SetXTitle(TString("Efficiency ("+num+")")); grid->SetYTitle("l-jet Rejection"); //grid->Reset(); //grid->SetMinimum(0.); //grid->SetMaximum(1.); grid->Draw(); TGraph* r16graph = MakeEffRej(R16_l,R16_c,R16_b); TGraph* r17graph = MakeEffRej(R17_l,R17_c,R17_b); r16graph->SetMarkerColor(kBlack); r16graph->SetLineColor(kBlack); r16graph->Draw("elp same"); r17graph->SetMarkerColor(kRed); r17graph->SetLineColor(kRed); //r17graph->SetMarkerSize(); r17graph->Draw("elp same"); //stacked->SetATLASLabel("Preliminary"); //if(input.Contains("JetTauEtmiss")) stacked->SetLumi("95.6 pb^{-1}"); //else stacked->SetLumi("2.052 fb^{-1}"); TString label(TString("#splitline{"+input+"}{")); label.Append(*cut); label.Append("}"); TLatex n2; n2.SetNDC(); n2.SetTextFont(42); n2.SetTextColor(kBlack); n2.DrawLatex(0.20,0.25,label.Data()); float leg_ylower = 0.90-((float)(2+op.size()))*0.06; TLegend* legend = new TLegend(0.75,leg_ylower,0.95,0.95); legend->SetFillStyle(0); legend->SetBorderSize(0); TLegendEntry* entry = 0; entry = legend->AddEntry(r17graph,"Release 17","elp"); entry->SetTextAlign(12); entry->SetTextColor(1); entry = legend->AddEntry(r16graph,"Release 16","elp"); entry->SetTextAlign(12); entry->SetTextColor(1); map<TString, float>::iterator iter = op.begin(); int color = 3; for(; iter!=op.end(); iter++) { TLine* line = new TLine(iter->second,0.,iter->second,1000.); line->SetLineColor(color); line->Draw("same"); TH1F* histo = new TH1F(); histo->SetLineColor(color); entry = legend->AddEntry(histo,TString("Release 16, "+iter->first+ " ("+TString::Format("R17 %0.2f",newop[iter->first])+")"),"l"); entry->SetTextAlign(12); entry->SetTextColor(1); color++; } iter = r17op.begin(); for(; iter!=r17op.end(); iter++) { TLine* line = new TLine(iter->second,0.,iter->second,1000.); line->SetLineColor(color); line->Draw("same"); TH1F* histo = new TH1F(); histo->SetLineColor(color); entry = legend->AddEntry(histo,TString("Release 17, "+iter->first),"l"); entry->SetTextAlign(12); entry->SetTextColor(1); color++; } legend->Draw(); canvas->Update(); if(cut->Contains("2jet_")) canvas->Print(TString::Format("output/%s_2jet%s.ps",input.Data(),logstring.Data())); else if(cut->Contains("2jetX_")) canvas->Print(TString::Format("output/%s_2jetX%s.ps",input.Data(),logstring.Data())); else if(cut->Contains("3jet_")) canvas->Print(TString::Format("output/%s_3jet%s.ps",input.Data(),logstring.Data())); canvas->Print(TString::Format("output/%s_%s_%s%s.eps",input.Data(),cut->Data(),type->Data(),logstring.Data())); delete r16graph; delete r17graph; delete grid; } } canvas->Print(TString::Format("output/%s_2jet%s.ps]",input.Data(),logstring.Data()),"Portrait"); canvas->Print(TString::Format("output/%s_2jetX%s.ps]",input.Data(),logstring.Data()),"Portrait"); canvas->Print(TString::Format("output/%s_3jet%s.ps]",input.Data(),logstring.Data()),"Portrait"); }
void plot_BSM_MCFM(int SignalOnly=0){ gROOT->ProcessLine(".x tdrstyle.cc"); double mPOLE = 125.6; TString OUTPUT_NAME; OUTPUT_NAME = "HtoZZ4l_MCFM_125p6_BSMPlots"; if (SignalOnly==0) OUTPUT_NAME.Append(".root"); else OUTPUT_NAME.Append("_SignalOnly.root"); TString coutput_common = user_TemplateswithTrees_dir + "../BSMReweight_GenLevel/Plots/"; gSystem->Exec("mkdir -p " + coutput_common); TString coutput = coutput_common + OUTPUT_NAME; TFile* foutput = new TFile(coutput, "recreate"); foutput->cd(); float ZZMass = 0; float p0plus_VAJHU; float p0hplus_VAJHU; float p0minus_VAJHU; float p0_g1prime2_VAJHU; float p0_g1prime4_VAJHU; float pg1g2_VAJHU; float pg1g4_VAJHU; float pg1g1prime2_VAJHU; float pg1g1prime4_VAJHU; TChain* tc[2][3][4]; TH1F* hfill[4][9]; int nbinsx = 73; double xlimits[2]={ 160, 1620 }; if (SignalOnly==1){ xlimits[0]=100; nbinsx = 76; } for (int t=0; t<4; t++){ for (int ac=0; ac<9; ac++){ hfill[t][ac]= new TH1F(Form("hSum_BSI%i_Hypo%i", t, ac), "", nbinsx, xlimits[0], xlimits[1]); hfill[t][ac]->SetXTitle("m_{4l} (GeV)"); hfill[t][ac]->SetYTitle(Form("Events / %.0f GeV", (xlimits[1]-xlimits[0])/nbinsx)); } } double nCounted[2][3][9]={ { { 0 } } }; double nCountedScaled[2][3][9]={ { { 0 } } }; for (int erg_tev=7; erg_tev<9; erg_tev++){ for (int folder=0; folder<3; folder++){ TString comstring; comstring.Form("%iTeV", erg_tev); TString erg_dir; erg_dir.Form("LHC_%iTeV/", erg_tev); int EnergyIndex = 1; if (erg_tev == 7) EnergyIndex = 0; TString cinput_common = user_TemplateswithTrees_dir + "../BSMReweight_GenLevel/"; cinput_common.Append(+erg_dir); cinput_common += user_folder[folder] + "/"; cout << cinput_common << endl; for (int t=0; t<4; t++){ TString INPUT_NAME; INPUT_NAME = "HtoZZ4l_MCFM_125p6_BSMTrees_"; INPUT_NAME += sample_suffix[t] + ".root"; INPUT_NAME.Prepend(cinput_common); tc[EnergyIndex][folder][t] = new TChain("GenTree"); if (t!=3) tc[EnergyIndex][folder][t]->Add(INPUT_NAME); tc[EnergyIndex][folder][t]->SetBranchAddress("ZZMass", &ZZMass); tc[EnergyIndex][folder][t]->SetBranchAddress("p0plus_VAJHU", &p0plus_VAJHU); tc[EnergyIndex][folder][t]->SetBranchAddress("p0hplus_VAJHU", &p0hplus_VAJHU); tc[EnergyIndex][folder][t]->SetBranchAddress("p0minus_VAJHU", &p0minus_VAJHU); tc[EnergyIndex][folder][t]->SetBranchAddress("p0_g1prime2_VAJHU", &p0_g1prime2_VAJHU); tc[EnergyIndex][folder][t]->SetBranchAddress("p0_g1prime4_VAJHU", &p0_g1prime4_VAJHU); tc[EnergyIndex][folder][t]->SetBranchAddress("pg1g2_VAJHU", &pg1g2_VAJHU); tc[EnergyIndex][folder][t]->SetBranchAddress("pg1g4_VAJHU", &pg1g4_VAJHU); tc[EnergyIndex][folder][t]->SetBranchAddress("pg1g1prime2_VAJHU", &pg1g1prime2_VAJHU); tc[EnergyIndex][folder][t]->SetBranchAddress("pg1g1prime4_VAJHU", &pg1g1prime4_VAJHU); } double nsig_counted[9] ={ 0 }; for (int ev=0; ev<tc[EnergyIndex][folder][0]->GetEntries(); ev++){ tc[EnergyIndex][folder][0]->GetEntry(ev); if (fabs(ZZMass-mPOLE)<0.1){ nsig_counted[0] += p0plus_VAJHU; nsig_counted[1] += p0hplus_VAJHU; nsig_counted[2] += p0minus_VAJHU; nsig_counted[3] += p0_g1prime2_VAJHU; nsig_counted[4] += p0_g1prime4_VAJHU; nsig_counted[5] += (2.*(p0plus_VAJHU+p0hplus_VAJHU)-pg1g2_VAJHU); nsig_counted[6] += pg1g4_VAJHU; nsig_counted[7] += pg1g1prime2_VAJHU; nsig_counted[8] += pg1g1prime4_VAJHU; } } for (int ac=0; ac<9; ac++) nCounted[EnergyIndex][folder][ac] = nsig_counted[ac]; } } for (int erg_tev=7; erg_tev<9; erg_tev++){ for (int folder=0; folder<3; folder++){ int EnergyIndex = 1; if (erg_tev == 7) EnergyIndex = 0; double nsig_SM = nSM_ScaledPeak[EnergyIndex][folder]; double SMscale = nsig_SM/nCounted[EnergyIndex][folder][0]; double scale=1; for (int t=0; t<4; t++){ for (int ev=0; ev<tc[EnergyIndex][folder][t]->GetEntries(); ev++){ tc[EnergyIndex][folder][t]->GetEntry(ev); if (ZZMass<xlimits[0]) continue; if (ZZMass>=xlimits[1]) ZZMass=xlimits[1]*0.999; scale = SMscale; if (t==0 && ev==0) nCountedScaled[EnergyIndex][folder][0] = nCounted[EnergyIndex][folder][0]*scale; hfill[t][0]->Fill(ZZMass, p0plus_VAJHU*scale); scale = SMscale; if (t==0 && ev==0) nCountedScaled[EnergyIndex][folder][1] = nCounted[EnergyIndex][folder][1]*scale; hfill[t][1]->Fill(ZZMass, p0hplus_VAJHU*scale); scale = SMscale; if (t==0 && ev==0) nCountedScaled[EnergyIndex][folder][2] = nCounted[EnergyIndex][folder][2]*scale; hfill[t][2]->Fill(ZZMass, p0minus_VAJHU*scale); scale = SMscale; if (t==0 && ev==0) nCountedScaled[EnergyIndex][folder][3] = nCounted[EnergyIndex][folder][3]*scale; hfill[t][3]->Fill(ZZMass, p0_g1prime2_VAJHU*scale); scale = SMscale; if (t==0 && ev==0) nCountedScaled[EnergyIndex][folder][4] = nCounted[EnergyIndex][folder][4]*scale; hfill[t][4]->Fill(ZZMass, p0_g1prime4_VAJHU*scale); scale = SMscale; if (t>0){ hfill[t][5]->Fill(ZZMass, pg1g2_VAJHU*scale); } else{ scale *= (nCounted[0][2][0]+nCounted[1][2][0])/(nCounted[0][2][5]+nCounted[1][2][5]); hfill[t][5]->Fill(ZZMass, (2.*(p0plus_VAJHU+p0hplus_VAJHU)-pg1g2_VAJHU)*scale); } if (t==0 && ev==0) nCountedScaled[EnergyIndex][folder][5] = nCounted[EnergyIndex][folder][5]*scale; scale = SMscale; if (t==0) scale *= (nCounted[0][2][0]+nCounted[1][2][0])/(nCounted[0][2][6]+nCounted[1][2][6]); if (t==0 && ev==0) nCountedScaled[EnergyIndex][folder][6] = nCounted[EnergyIndex][folder][6]*scale; hfill[t][6]->Fill(ZZMass, pg1g4_VAJHU*scale); scale = SMscale; if (t==0) scale *= (nCounted[0][2][0]+nCounted[1][2][0])/(nCounted[0][2][7]+nCounted[1][2][7]); if (t==0 && ev==0) nCountedScaled[EnergyIndex][folder][7] = nCounted[EnergyIndex][folder][7]*scale; hfill[t][7]->Fill(ZZMass, pg1g1prime2_VAJHU*scale); scale = SMscale; // if (t==0) scale *= (nCounted[0][2][0]+nCounted[1][2][0])/(nCounted[0][2][8]+nCounted[1][2][8]); if (t==0 && ev==0) nCountedScaled[EnergyIndex][folder][8] = nCounted[EnergyIndex][folder][8]*scale; hfill[t][8]->Fill(ZZMass, pg1g1prime4_VAJHU*scale); } delete tc[EnergyIndex][folder][t]; } } } for (int ac=1; ac<9; ac++){ double nTotal[2]={ 0 }; for (int erg_tev=7; erg_tev<9; erg_tev++){ for (int folder=0; folder<3; folder++){ int EnergyIndex = 1; if (erg_tev == 7) EnergyIndex = 0; nTotal[0] += nCountedScaled[EnergyIndex][folder][0]; nTotal[1] += nCountedScaled[EnergyIndex][folder][ac]; } } if (ac!=8) hfill[0][ac]->Scale(nTotal[0]/nTotal[1]); else hfill[0][ac]->Scale(0.5); } double maxplot=0; for (int t=0; t<4; t++){ for (int ac=0; ac<9; ac++){ if (SignalOnly==0 && ac<5) maxplot = max(maxplot, hfill[t][ac]->GetMaximum()); else if (SignalOnly==1 && !(ac<5 && ac>0) && t==0) maxplot = max(maxplot, hfill[t][ac]->GetMaximum()); hfill[t][ac]->SetLineWidth(2); if (t==0 && ac>=5){ hfill[t][ac]->SetLineStyle(7); // hfill[t][ac]->Add(hfill[1][ac]); } if (t==1) hfill[t][ac]->SetLineStyle(3); if (t==3) hfill[t][ac]->SetLineStyle(9); hfill[t][ac]->GetXaxis()->SetLabelFont(42); hfill[t][ac]->GetXaxis()->SetLabelOffset(0.007); hfill[t][ac]->GetXaxis()->SetLabelSize(0.04); hfill[t][ac]->GetXaxis()->SetTitleSize(0.06); hfill[t][ac]->GetXaxis()->SetTitleOffset(0.9); hfill[t][ac]->GetXaxis()->SetTitleFont(42); hfill[t][ac]->GetYaxis()->SetNdivisions(505); hfill[t][ac]->GetYaxis()->SetLabelFont(42); hfill[t][ac]->GetYaxis()->SetLabelOffset(0.007); hfill[t][ac]->GetYaxis()->SetLabelSize(0.04); hfill[t][ac]->GetYaxis()->SetTitleSize(0.06); hfill[t][ac]->GetYaxis()->SetTitleOffset(1.1); hfill[t][ac]->GetYaxis()->SetTitleFont(42); } } TPaveText* pt = new TPaveText(0.15, 0.93, 0.85, 1, "brNDC"); pt->SetBorderSize(0); pt->SetFillStyle(0); pt->SetTextAlign(12); pt->SetTextFont(42); pt->SetTextSize(0.045); TText* text = pt->AddText(0.025, 0.45, "#font[61]{CMS}"); text->SetTextSize(0.044); text = pt->AddText(0.165, 0.42, "#font[52]{Simulation}"); text->SetTextSize(0.0315); TString cErgTev = "#font[42]{19.7 fb^{-1} (8 TeV) + 5.1 fb^{-1} (7 TeV)}"; text = pt->AddText(0.537, 0.45, cErgTev); text->SetTextSize(0.0315); float lxmin = 0.22; float lxwidth = 0.38; float lymax = 0.9; float lywidth = 0.3; float lxmax = lxmin + lxwidth; float lymin = lymax; if (SignalOnly==0) lymin -= lywidth*4./5.; else lymin -= lywidth; float lxmin2 = 0.22+0.39; float lymax2 = lymax; float lxmax2 = lxmin2 + lxwidth; float lymin2 = lymax2; if (SignalOnly==0) lymin2 -= lywidth*2./5.; else lymin2 -= lywidth*4./5.; if (SignalOnly==1){ float lxmin3 = lxmin2; float lymax3 = lymax2; float lxmax3 = lxmax2; float lymin3 = lymin2; lxmin2 = lxmin; lxmax2 = lxmax; lymin2 = lymin; lymax2 = lymax; lxmin = lxmin3; lxmax = lxmax3; lymin = lymin3; lymax = lymax3; } float pxmin = 0.756; float pymin = 0.76; float pxmax = 0.85; if (SignalOnly==1){ pymin -= 0.12; } float pymax = pymin+0.05; TPaveText* ptx = new TPaveText(pxmin, pymin, pxmax, pymax, "brNDC"); ptx->SetBorderSize(0); ptx->SetTextFont(42); ptx->SetTextSize(0.04); ptx->SetLineColor(1); ptx->SetLineStyle(1); ptx->SetLineWidth(1); ptx->SetFillColor(0); ptx->SetFillStyle(0); text = ptx->AddText(0.01, 0.01, "gg#rightarrow4l"); text->SetTextSize(0.04); TString canvasname = "cCanvas_MCFMBSM_GenLevel"; if (SignalOnly==1) canvasname.Append("_SignalOnly"); TCanvas* cc = new TCanvas(canvasname, "", 8, 30, 800, 800); cc->cd(); gStyle->SetOptStat(0); cc->SetFillColor(0); cc->SetBorderMode(0); cc->SetBorderSize(2); cc->SetTickx(1); cc->SetTicky(1); cc->SetLeftMargin(0.17); cc->SetRightMargin(0.05); cc->SetTopMargin(0.07); cc->SetBottomMargin(0.13); cc->SetFrameFillStyle(0); cc->SetFrameBorderMode(0); cc->SetFrameFillStyle(0); cc->SetFrameBorderMode(0); cc->SetLogy(); TLegend* ll; TLegend* ll2; ll = new TLegend(lxmin2, lymin2, lxmax2, lymax2); ll2 = new TLegend(lxmin, lymin, lxmax, lymax); ll->SetBorderSize(0); ll->SetTextFont(42); ll->SetTextSize(0.04); ll->SetLineColor(1); ll->SetLineStyle(1); ll->SetLineWidth(1); ll->SetFillColor(0); ll->SetFillStyle(0); ll2->SetBorderSize(0); ll2->SetTextFont(42); ll2->SetTextSize(0.04); ll2->SetLineColor(1); ll2->SetLineStyle(1); ll2->SetLineWidth(1); ll2->SetFillColor(0); ll2->SetFillStyle(0); TString strACtitle[9]={ "", "f_{a2}=1", "f_{a3}=1", "f_{#Lambda1}=1", "f_{#LambdaQ}=1", "f_{a2}=0.5, #phi_{#lower[-0.2]{a2}}=#pi", "f_{a3}=0.5", "f_{#Lambda1}=0.5", "f_{#LambdaQ}=0.5" }; int iDraw = 2 - 2*SignalOnly; if (SignalOnly==0) hfill[iDraw][0]->GetYaxis()->SetRangeUser(7e-3, maxplot*15.); else{ double histmin = 7e-3; if (hfill[iDraw][0]->GetMinimum()>0) histmin = hfill[iDraw][0]->GetMinimum(); hfill[iDraw][0]->GetYaxis()->SetRangeUser(histmin, maxplot*2000.); } hfill[iDraw][0]->GetXaxis()->SetRangeUser(xlimits[0], 800.); hfill[iDraw][0]->SetLineColor(kBlack); if (SignalOnly==0){ hfill[iDraw][0]->SetFillColor(kAzure-2); hfill[iDraw][0]->SetFillStyle(1001); } hfill[iDraw][0]->Draw("hist"); hfill[iDraw][1]->SetLineColor(kBlue); hfill[iDraw][1]->Draw("histsame"); hfill[iDraw][2]->SetLineColor(kRed); hfill[iDraw][2]->Draw("histsame"); hfill[iDraw][3]->SetLineColor(kViolet); hfill[iDraw][3]->Draw("histsame"); hfill[iDraw][4]->SetLineColor(kGreen+2); hfill[iDraw][4]->Draw("histsame"); if (SignalOnly==1){ hfill[iDraw][5]->SetLineColor(kBlue); hfill[iDraw][5]->Draw("histsame"); hfill[iDraw][6]->SetLineColor(kRed); hfill[iDraw][6]->Draw("histsame"); hfill[iDraw][7]->SetLineColor(kViolet); hfill[iDraw][7]->Draw("histsame"); hfill[iDraw][8]->SetLineColor(kGreen+2); hfill[iDraw][8]->Draw("histsame"); } if (SignalOnly==0){ hfill[1][0]->SetLineColor(kBlack); hfill[1][0]->SetLineStyle(3); hfill[1][0]->Draw("histsame"); } hfill[iDraw][0]->Draw("histsame"); TLegendEntry* legendtext; if (SignalOnly==0){ legendtext = ll->AddEntry(hfill[iDraw][0], "SM total", "f"); legendtext = ll->AddEntry(hfill[1][0], "SM bkg.", "f"); legendtext->SetFillStyle(1001); legendtext->SetFillColor(hfill[1][0]->GetFillColor()); } else{ legendtext = ll->AddEntry(hfill[iDraw][0], "SM signal", "f"); legendtext->SetFillStyle(3001); } if (SignalOnly==0){ legendtext = ll2->AddEntry(hfill[iDraw][4], Form("#Gamma_{H}=#Gamma^{SM}_{H}, %s", strACtitle[4].Data()), "f"); legendtext->SetFillStyle(3001); legendtext->SetFillColor(hfill[iDraw][4]->GetFillColor()); legendtext = ll2->AddEntry(hfill[iDraw][2], Form("#Gamma_{H}=#Gamma^{SM}_{H}, %s", strACtitle[2].Data()), "f"); legendtext->SetFillStyle(3001); legendtext->SetFillColor(hfill[iDraw][2]->GetFillColor()); legendtext = ll2->AddEntry(hfill[iDraw][1], Form("#Gamma_{H}=#Gamma^{SM}_{H}, %s", strACtitle[1].Data()), "f"); legendtext->SetFillStyle(3001); legendtext->SetFillColor(hfill[iDraw][1]->GetFillColor()); legendtext = ll2->AddEntry(hfill[iDraw][3], Form("#Gamma_{H}=#Gamma^{SM}_{H}, %s", strACtitle[3].Data()), "f"); legendtext->SetFillStyle(3001); legendtext->SetFillColor(hfill[iDraw][3]->GetFillColor()); } else{ legendtext = ll->AddEntry(hfill[iDraw][4], strACtitle[4].Data(), "f"); legendtext->SetFillStyle(3001); legendtext->SetFillColor(hfill[iDraw][4]->GetFillColor()); legendtext = ll->AddEntry(hfill[iDraw][2], strACtitle[2].Data(), "f"); legendtext->SetFillStyle(3001); legendtext->SetFillColor(hfill[iDraw][2]->GetFillColor()); legendtext = ll->AddEntry(hfill[iDraw][1], strACtitle[1].Data(), "f"); legendtext->SetFillStyle(3001); legendtext->SetFillColor(hfill[iDraw][1]->GetFillColor()); legendtext = ll->AddEntry(hfill[iDraw][3], strACtitle[3].Data(), "f"); legendtext->SetFillStyle(3001); legendtext->SetFillColor(hfill[iDraw][3]->GetFillColor()); } if (SignalOnly==1){ legendtext = ll2->AddEntry(hfill[iDraw][8], strACtitle[8].Data(), "f"); legendtext->SetFillStyle(3001); legendtext->SetFillColor(hfill[iDraw][8]->GetFillColor()); legendtext = ll2->AddEntry(hfill[iDraw][5], strACtitle[5].Data(), "f"); legendtext->SetFillStyle(3001); legendtext->SetFillColor(hfill[iDraw][5]->GetFillColor()); legendtext = ll2->AddEntry(hfill[iDraw][7], strACtitle[7].Data(), "f"); legendtext->SetFillStyle(3001); legendtext->SetFillColor(hfill[iDraw][7]->GetFillColor()); legendtext = ll2->AddEntry(hfill[iDraw][6], strACtitle[6].Data(), "f"); legendtext->SetFillStyle(3001); legendtext->SetFillColor(hfill[iDraw][6]->GetFillColor()); } ll->Draw("same"); ll2->Draw("same"); ptx->Draw(); pt->Draw(); cc->RedrawAxis(); cc->Update(); canvasname.Prepend(coutput_common); TString canvasname_pdf = canvasname; TString canvasname_eps = canvasname; TString canvasname_png = canvasname; TString canvasname_root = canvasname; TString canvasname_c = canvasname; canvasname_pdf.Append(".pdf"); canvasname_eps.Append(".eps"); canvasname_png.Append(".png"); canvasname_root.Append(".root"); canvasname_c.Append(".C"); cc->SaveAs(canvasname_pdf); cc->SaveAs(canvasname_eps); cc->SaveAs(canvasname_png); cc->SaveAs(canvasname_root); cc->SaveAs(canvasname_c); foutput->WriteTObject(cc); delete ll2; delete ll; cc->Close(); delete ptx; delete pt; for (int t=0; t<4; t++){ for (int ac=0; ac<5; ac++){ foutput->WriteTObject(hfill[t][ac]); delete hfill[t][ac]; } } foutput->Close(); }
void DrawTwoInPad(TVirtualPad* p, Int_t sub, TH1* h1, TH1* h2, Bool_t ratio, Bool_t logy=false, Bool_t legend=false) { TVirtualPad* pp = p->cd(sub); pp->SetRightMargin(0.02); pp->SetLeftMargin(0.10); TVirtualPad* ppp = pp; if (ratio) { pp->Divide(1,2,0,0); ppp = pp->cd(1); ppp->SetRightMargin(0.02); } if (logy) ppp->SetLogy(); TH1* hs[] = { h1, h2, 0 }; if (h1->GetMaximum() < h2->GetMaximum()) { hs[0] = h2; hs[1] = h1; } TH1** ph = hs; Double_t size = (ratio ? 0.1 : 0.05); Double_t off = (ratio ? 0.6 : 0.5); h1->SetFillStyle(3004); h2->SetFillStyle(3005); while (*ph) { TString opt("hist"); if (ph != hs) opt.Append(" same"); TH1* copy = (*ph)->DrawCopy(opt); copy->GetXaxis()->SetLabelSize(2*size); copy->GetYaxis()->SetLabelSize(size); copy->GetYaxis()->SetTitleSize(size); copy->GetYaxis()->SetTitleOffset(off); copy->SetYTitle(copy->GetTitle()); copy->SetTitle(""); copy->SetDirectory(0); ph++; } TString s1 = h1->GetYaxis()->GetTitle(); TString s2 = h2->GetYaxis()->GetTitle(); if (legend) { TLegend* l = new TLegend(0.6, 0.1, 0.9, 0.9); l->SetBorderSize(0); TLegendEntry* e = l->AddEntry("dummy", s1, "lf"); l->SetFillColor(kWhite); e->SetFillColor(kBlack); e->SetFillStyle(h1->GetFillStyle()); e = l->AddEntry("dummy", s2, "lf"); e->SetFillColor(kBlack); e->SetFillStyle(h2->GetFillStyle()); l->Draw(); } if (!ratio) return; ppp = pp->cd(2); ppp->SetRightMargin(0.02); TH1* r = static_cast<TH1*>(h1->Clone(Form("ratio%s", h1->GetName()))); r->SetDirectory(0); r->SetTitle(""); r->GetXaxis()->SetLabelSize(size); r->GetYaxis()->SetLabelSize(size); r->GetYaxis()->SetTitleSize(0.9*size); r->GetYaxis()->SetTitleOffset(0.9*off); r->SetMarkerStyle(20); r->SetMarkerColor(h1->GetFillColor()+1); r->SetFillStyle(3007); r->SetYTitle(Form("#frac{%s}{%s}", s1.Data(), s2.Data())); // r->Add(h2, -1); // r->Divide(h1); if (!r->IsA()->InheritsFrom(TProfile::Class())) { r->GetSumw2()->Set(0); // r->Sumw2(false); h2->GetSumw2()->Set(0); // h2->Sumw2(false); } r->Divide(h2); Printf("%s", r->GetName()); for (UShort_t bin = 1; bin <= r->GetNbinsX(); bin++) { Printf(" bin # %2d: Diff=%g+/-%g", bin, r->GetBinContent(bin), r->GetBinError(bin)); r->SetBinError(bin, 0); } r->GetSumw2()->Set(0); //r->Sumw2(false); r->SetMarkerSize(4); r->SetMaximum(r->GetMaximum()*1.2); r->SetMinimum(r->GetMinimum()*0.8); r->Draw("hist text30"); p->Modified(); p->Update(); p->cd(); }
TH1* GetCentK(TDirectory* top, Double_t c1, Double_t c2, Int_t s, TLegend* l) { TString dname; dname.Form("cent%06.2f_%06.2f", c1, c2); dname.ReplaceAll(".", "d"); TDirectory* d = top->GetDirectory(dname); if (!d) { Warning("GetCetnK", "Directory %s not found in %s", dname.Data(), top->GetName()); return; } TDirectory* det = d->GetDirectory("details"); if (!det) { Warning("GetCetnK", "Directory details not found in %s", d->GetName()); d->ls(); return; } TObject* o = det->Get("scalar"); if (!o) { Warning("GetCetnK", "Object scalar not found in %s", det->GetName()); return; } if (!o->IsA()->InheritsFrom(TH1::Class())) { Warning("GetCetnK", "Object %s is not a TH1, but a %s", o->GetName(), o->ClassName()); return; } TH1* h = static_cast<TH1*>(o->Clone()); Color_t col = cc[(s-1)%10]; h->SetLineColor(col); h->SetMarkerColor(col); h->SetFillColor(col); h->SetFillStyle(1001); // h->SetTitle(Form("%5.2f-%5.2f%% #times %d", c1, c2, s)); h->SetTitle(Form("%2.0f-%2.0f%% + %d", c1, c2, s-1)); TF1* f = new TF1("", "[0]",-2.2,2.2); f->SetParameter(0,s-1); f->SetLineColor(col); f->SetLineStyle(7); f->SetLineWidth(1); // h->Scale(s); h->Add(f); h->GetListOfFunctions()->Add(f); f->SetParameter(0,s); for (Int_t i = 1; i <= h->GetNbinsX(); i++) { if (TMath::Abs(h->GetBinCenter(i)) > 2) { h->SetBinContent(i,0); h->SetBinError(i,0); } } TLegendEntry* e = l->AddEntry(h, h->GetTitle(), "f"); e->SetFillColor(col); e->SetFillStyle(1001); e->SetLineColor(col); return h; }
/** * Add the bin histograms to our summary stacks * * @param bin Bin stack * @param i Current off-set in the stacks * @param measured All measured @f$ P(N_{ch})@f$ * @param truth All MC truth @f$ P(N_{ch})@f$ * @param accepted All MC accepted @f$ P(N_{ch})@f$ * @param unfolded All unfolded @f$ P(N_{ch})@f$ * @param corrected All corrected @f$ P(N_{ch})@f$ * @param result The result in this bin */ void Bin2Stack(const THStack* bin, Int_t i, THStack* measured, THStack* truth, THStack* accepted, THStack* unfolded, THStack* corrected, TH1*& result) { Int_t open, closed; Double_t factor; Float_t size; BinAttributes(i, open, closed, size, factor); TIter next(bin->GetHists()); TH1* h = 0; while ((h = static_cast<TH1*>(next()))) { THStack* tmp = 0; Int_t col = h->GetMarkerColor(); Int_t sty = 0; switch (col) { case kColorMeasured: tmp = measured; sty = closed; break; case kColorTruth: tmp = truth; sty = open; break; case kColorAccepted: tmp = accepted; sty = open; break; case kColorUnfolded: tmp = unfolded; sty = closed; break; case kColorCorrected: tmp = corrected; sty = closed; break; default: continue; } // Now clone, and add to the appropriate stack TH1* cln = static_cast<TH1*>(h->Clone(h->GetName())); cln->SetDirectory(0); cln->SetMarkerStyle(sty); cln->SetMarkerSize(size); cln->Scale(factor); // Scale by 10^i if (col == kColorCorrected) result = cln; // Make sure we do not get the old legend TObject* tst = cln->FindObject("legend"); if (tst) cln->GetListOfFunctions()->Remove(tst); tmp->Add(cln, next.GetOption()); } // Add entries to our stacks TString txt = bin->GetTitle(); if (i == 0) txt.Append(" (#times1)"); else if (i == 1) txt.Append(" (#times10)"); else txt.Append(Form(" (#times10^{%d})", i)); THStack* stacks[] = { measured, truth, accepted, unfolded, corrected, 0 }; THStack** pstack = stacks; while (*pstack) { TLegend* leg = StackLegend(*pstack); pstack++; if (!leg) continue; TObject* dummy = 0; TLegendEntry* e = leg->AddEntry(dummy, txt, "p"); e->SetMarkerStyle(closed); e->SetMarkerSize(1.2*size); e->SetMarkerColor(kBlack); e->SetFillColor(0); e->SetFillStyle(0); e->SetLineColor(kBlack); } }
void Overlay_NeutralEnergyDifferenceMean() { std::string canvasName = "canvas"; std::string canvasTitle = "Neutral energy mean"; int canvasX1 = 200; int canvasY1 = 52; int canvasX2 = 700; int canvasY2 = 650; int nPoints = 6; int nGraphs = 5; int neutralEnergy = 10; double zero [] = {0, 0, 0, 0, 0, 0, 0, 0}; double energies[] = {10, 20, 30, 40, 50}; double distances[] = {5, 10, 15, 20, 25, 30}; std::string graphXTitle = "Distance between showers [cm]"; std::string graphYTitle = "<E_{n,rec} - E_{n,meas}>"; double rangeUserXMin = 0; double rangeUserXMax = 35; double rangeUserYMin = -10; double rangeUserYMax = 10; TCanvas *pCanvas = new TCanvas(canvasName.c_str(), canvasTitle.c_str(), canvasX1, canvasY1, canvasX2, canvasY2); pCanvas->SetFillColor(0); pCanvas->SetBorderMode(0); pCanvas->SetBorderSize(2); pCanvas->SetTickx(1); pCanvas->SetTicky(1); pCanvas->SetLeftMargin(0.15); pCanvas->SetRightMargin(0.03); pCanvas->SetTopMargin(0.05); pCanvas->SetBottomMargin(0.14); pCanvas->SetFrameBorderMode(0); pCanvas->SetFrameBorderMode(0); TH1F *pH = new TH1F("pouette", "", rangeUserXMax-rangeUserXMin, rangeUserXMin, rangeUserXMax); pH->SetMinimum(rangeUserYMin); pH->SetMaximum(rangeUserYMax); pH->Draw(); gStyle->SetOptStat(0); pH->GetYaxis()->SetTitle(graphYTitle.c_str()); pH->GetXaxis()->SetTitle(graphXTitle.c_str()); pH->GetYaxis()->SetLabelFont(42); pH->GetYaxis()->SetTitleSize(0.05); pH->GetYaxis()->SetTitleOffset(1); pH->GetYaxis()->SetTitleFont(42); pH->GetYaxis()->SetLabelSize(0.045); TLegend *leg = new TLegend(0.3,0.55,0.8,0.8,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetLineColor(0); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetTextSize(0.03); int currentColor = 1; for(unsigned int e=0 ; e<nGraphs ; e++) { int energy = energies[e]; double *data = new double[nPoints]; double *dataError = zero;//new double[nPoints]; std::stringstream fileName; fileName << "data_neutralERecDifference_ArborPFA_Test\ Beam_" << energy << "Gev.txt"; readData(fileName.str(), data, nPoints); // fileName.str(""); // fileName << "fichier_data_error_energy_" << energy << "GeV.txt"; // readData(fileName.str(), dataError, nPoints); TGraphErrors *gre = 0; std::stringstream graphName; graphName << "Charged particle energy = " << energy << " GeV"; gre = new TGraphErrors(nPoints, distances, data, zero, dataError); gre->SetName(graphName.str().c_str()); gre->SetTitle(graphName.str().c_str()); gre->SetLineColor(currentColor); gre->SetMarkerColor(currentColor); gre->SetMarkerStyle(23); gre->SetMarkerSize(1.2); gre->Draw("lp same"); TLegendEntry *entry = 0; entry=leg->AddEntry(gre, graphName.str().c_str(), "lp"); entry->SetFillStyle(1001); entry->SetMarkerColor(currentColor); entry->SetMarkerStyle(23); entry->SetMarkerSize(1); currentColor++; } TPaveText *pt = new TPaveText(0.55, 0.2, 0.93, 0.3, "tbNDC"); pt->SetTextSize(0.05); pt->SetTextColor(kGray+2); pt->SetFillColor(0); pt->SetLineWidth(0); pt->SetBorderSize(0); pt->AddText("CALICE Preliminary"); pt->SetTextFont(62); pt->Draw(); leg->Draw(); pCanvas->Modified(); pCanvas->cd(); pCanvas->SetSelected(pCanvas); }
void makePlots_Combinations(short makePlots=0) { TString dirPlots("/home/rossin/Dropbox/TT/Work/figures_stubCleaning/"); TFile fIn ("/home/rossin/Dropbox/TT/Work/figures_stubCleaning/stubCleaning_Neutrino_PU140_sf1_nz4_pt3_5oo6_14k.root"); TString sLogic ("5oo6"); TString pName("Neutrino_PU140_sf1_nz4_pt3_5oo6_14k"); TString pTitle(" PU140 SF=1 Nz=4 Pt>3 GeV/c"); TFile fIn2("/home/rossin/Dropbox/TT/Work/figures_stubCleaning/stubCleaning_Neutrino_PU140_sf1_nz4_pt3_6oo6_14k.root"); TString sLogic2("6oo6"); //TString pName("Neutrino_PU140_sf1_nz4_pt3_6oo6_14k"); TString pTitle(" PU140 SF=1 Nz=4 Pt>3 GeV/c"); TFile fInOR("/home/rossin/Dropbox/TT/Work/figures_stubCleaning/stubCleaning_Neutrino_PU140_sf1_nz4_pt3_5oo6_14k_OverlapRemoved.root"); // TFile fIn("/home/rossin/Dropbox/TT/Work/figures_stubCleaning/stubCleaning_Neutrino_PU200_sf1_nz4_pt3_5oo6_4k.root"); TString sLogic("5oo6"); TString pName("Neutrino_PU200_sf1_nz4_pt3_5oo6_4k"); TString pTitle(" PU200 SF=1 Nz=4 Pt>3 GeV/c"); // TFile fInOR("/home/rossin/Dropbox/TT/Work/figures_stubCleaning/stubCleaning_Neutrino_PU200_sf1_nz4_pt3_5oo6_4k_OverlapRemoved.root"); // TFile fIn("/home/rossin/Dropbox/TT/Work/figures_stubCleaning/stubCleaning_Neutrino_PU250_sf1_nz4_pt3_5oo6_4k.root"); TString sLogic("5oo6"); TString pName("Neutrino_PU250_sf1_nz4_pt3_5oo6_4k"); TString pTitle(" PU250 SF=1 Nz=4 Pt>3 GeV/c"); // TFile fInOR("/home/rossin/Dropbox/TT/Work/figures_stubCleaning/stubCleaning_Neutrino_PU250_sf1_nz4_pt3_5oo6_4k_OverlapRemoved.root"); TH1* h1stubsInLayer [6][2]; TH1* h1stubsInLayerOR[6][2]; TH1* h1RoadPerEvent [2]; TH1* h1RoadPerEventOR[2]; TH1* h1CombPerRoad [2]; TH1* h1CombPerRoadOR [2]; TH1* h1CombPerEvent [2]; TH1* h1CombPerEventOR[2]; TH1* h1RoadPerEvent6oo6 [2]; TH1* h1CombPerRoad6oo6 [2]; TH1* h1CombPerEvent6oo6 [2]; TString sClean[2] = {TString(""), TString("_Cleaned")}; for (unsigned short iLay=0; iLay<6; ++iLay) { TList* tl = fIn.GetListOfKeys(); TIter next(tl); TObject *obj; char cc[20]; sprintf(cc,"_%d",iLay); TString hString("h1stubsInLayer__"+sLogic+TString(cc)); while ((obj=next())) { TString hName(obj->GetName()); if (hName==hString) { for (unsigned short iClean = 0; iClean < 2; ++iClean) { char cc2[100]; h1stubsInLayer [iLay][iClean] = (TH1*) fIn .Get(hName+sClean[iClean]); sprintf(cc2,"L%d - ",iLay+5); h1stubsInLayer [iLay][iClean]->SetTitle(TString(cc2)+sLogic+pTitle); h1stubsInLayerOR[iLay][iClean] = (TH1*) fInOR.Get(hName+sClean[iClean]); if (h1stubsInLayer [iLay][iClean]==0) { std::cout << "ERROR. " << hName+sClean[iClean] << " not loaded." << std::endl; return; } if (h1stubsInLayerOR[iLay][iClean]==0) { std::cout << "ERROR. " << hName+sClean[iClean] << " overlap removed not loaded." << std::endl; return; } } } } // std::cout << h1stubsInLayer [iLay][0] << "\t" << h1stubsInLayer [iLay][1] << "\t" << h1stubsInLayerOR[iLay][0] << "\t" << h1stubsInLayerOR[iLay][1] << std::endl; } for (unsigned short iClean = 0; iClean < 2; ++iClean) { TString hString("h1RoadPerEvent_"+sLogic); h1RoadPerEvent [iClean] = (TH1*) fIn .Get(hString+sClean[iClean]); h1RoadPerEventOR[iClean] = (TH1*) fInOR.Get(hString+sClean[iClean]); hString=TString("h1CombPerRoad_")+sLogic; h1CombPerRoad [iClean] = (TH1*) fIn .Get(hString+sClean[iClean]); h1CombPerRoadOR [iClean] = (TH1*) fInOR.Get(hString+sClean[iClean]); hString=TString("h1CombPerEvent_")+sLogic; h1CombPerEvent [iClean] = (TH1*) fIn .Get(hString+sClean[iClean]); h1CombPerEventOR [iClean] = (TH1*) fInOR.Get(hString+sClean[iClean]); hString=TString("h1RoadPerEvent_"+sLogic2); h1RoadPerEvent6oo6 [iClean] = (TH1*) fIn2 .Get(hString+sClean[iClean]); hString=TString("h1CombPerRoad_")+sLogic2; h1CombPerRoad6oo6 [iClean] = (TH1*) fIn2 .Get(hString+sClean[iClean]); hString=TString("h1CombPerEvent_")+sLogic2; h1CombPerEvent6oo6 [iClean] = (TH1*) fIn2 .Get(hString+sClean[iClean]); } TString cName("cStubsPerLayer_"+sLogic+pName); TString cTitle("StubsPerLayer "+sLogic+pTitle); TCanvas* cStubsPerLayer = new TCanvas(cName,cTitle,0,0,1400,900); cStubsPerLayer->Divide(3,2); for (unsigned short iLay=0; iLay<6; ++iLay) { char cc3[100]; cStubsPerLayer->cd(iLay+1); gPad->SetLogy(); h1stubsInLayer [iLay][0]->DrawCopy(); TLegend* tl = new TLegend(0.3,0.75,0.9,0.9); sprintf(cc3,"Mean # stubs: %3.2lf",h1stubsInLayer [iLay][0]->GetMean()); TLegendEntry* tle = tl->AddEntry(h1stubsInLayer [iLay][0],cc3,"l"); tle->SetLineColor(h1stubsInLayer [iLay][0]->GetLineColor()); tle->SetLineWidth(h1stubsInLayer [iLay][0]->GetLineWidth()); tl->Draw("L"); } if (makePlots) { cStubsPerLayer->SaveAs(dirPlots+cName+"__.pdf"); cStubsPerLayer->SaveAs(dirPlots+cName+"__.png"); } for (unsigned short iLay=0; iLay<6; ++iLay) { char cc3[100]; cStubsPerLayer->cd(iLay+1); gPad->SetLogy(); h1stubsInLayerOR[iLay][0]->SetLineColor(2); h1stubsInLayerOR[iLay][0]->DrawCopy("same"); TLegend* tl = new TLegend(0.25,0.75,0.9,0.9); sprintf(cc3,"Mean # stubs: %3.2lf",h1stubsInLayer [iLay][0]->GetMean()); TLegendEntry* tle = tl->AddEntry(h1stubsInLayer [iLay][0],cc3,"l"); tle->SetLineColor(h1stubsInLayer [iLay][0]->GetLineColor()); tle->SetLineWidth(h1stubsInLayer [iLay][0]->GetLineWidth()); sprintf(cc3,"Mean # stubs Overlap Removed: %3.2lf",h1stubsInLayerOR[iLay][0]->GetMean()); tle = tl->AddEntry(h1stubsInLayerOR[iLay][0],cc3,"l"); tle->SetLineColor(h1stubsInLayerOR[iLay][0]->GetLineColor()); tle->SetLineWidth(h1stubsInLayerOR[iLay][0]->GetLineWidth()); tl->Draw("L"); } if (makePlots) { cStubsPerLayer->SaveAs(dirPlots+cName+"_OR_.pdf"); cStubsPerLayer->SaveAs(dirPlots+cName+"_OR_.png"); } cName=TString("cStubsPerLayerDsClean_")+sLogic+pName; cTitle=TString("StubsPerLayer Ds clean ")+sLogic+pTitle; TCanvas* cStubsPerLayerDsClean = new TCanvas(cName,cTitle,0,0,1400,900); cStubsPerLayerDsClean->Divide(3,2); for (unsigned short iLay=0; iLay<6; ++iLay) { char cc3[100]; cStubsPerLayerDsClean->cd(iLay+1); gPad->SetLogy(); h1stubsInLayer [iLay][0]->DrawCopy(); h1stubsInLayer [iLay][1]->SetLineColor(8); h1stubsInLayer [iLay][1]->DrawCopy("same"); TLegend* tl = new TLegend(0.25,0.75,0.9,0.9); sprintf(cc3,"Mean # stubs: %3.2lf",h1stubsInLayer [iLay][0]->GetMean()); TLegendEntry* tle = tl->AddEntry(h1stubsInLayer [iLay][0],cc3,"l"); tle->SetLineColor(h1stubsInLayer [iLay][0]->GetLineColor()); tle->SetLineWidth(h1stubsInLayer [iLay][0]->GetLineWidth()); sprintf(cc3,"Mean # stubs #Deltas clean: %3.2lf",h1stubsInLayer [iLay][1]->GetMean()); tle = tl->AddEntry(h1stubsInLayer [iLay][1],cc3,"l"); tle->SetLineColor(h1stubsInLayer [iLay][1]->GetLineColor()); tle->SetLineWidth(h1stubsInLayer [iLay][1]->GetLineWidth()); tl->Draw("L"); } if (makePlots) { cStubsPerLayerDsClean->SaveAs(dirPlots+cName+"__.pdf"); cStubsPerLayerDsClean->SaveAs(dirPlots+cName+"__.png"); } cName=TString("cStubsPerLayerDsCleanOR_")+sLogic+pName; cTitle=TString("StubsPerLayer #Deltas clean Overlap Removed ")+sLogic+pTitle; TCanvas* cStubsPerLayerDsCleanOR = new TCanvas(cName,cTitle,0,0,1400,900); cStubsPerLayerDsCleanOR->Divide(3,2); for (unsigned short iLay=0; iLay<6; ++iLay) { char cc3[100]; cStubsPerLayerDsCleanOR->cd(iLay+1); gPad->SetLogy(); h1stubsInLayer [iLay][0]->DrawCopy(); h1stubsInLayerOR[iLay][0]->SetLineColor(2); h1stubsInLayerOR[iLay][0]->DrawCopy("same"); h1stubsInLayerOR[iLay][1]->SetLineColor(6); h1stubsInLayerOR[iLay][1]->DrawCopy("same"); TLegend* tl = new TLegend(0.25,0.70,0.9,0.9); sprintf(cc3,"Mean # stubs: %3.2lf",h1stubsInLayer [iLay][0]->GetMean()); TLegendEntry* tle = tl->AddEntry(h1stubsInLayer [iLay][0],cc3,"l"); tle->SetLineColor(h1stubsInLayer [iLay][0]->GetLineColor()); tle->SetLineWidth(h1stubsInLayer [iLay][0]->GetLineWidth()); sprintf(cc3,"Mean # stubs Ov. Rem.: %3.2lf",h1stubsInLayerOR[iLay][0]->GetMean()); tle = tl->AddEntry(h1stubsInLayerOR[iLay][0],cc3,"l"); tle->SetLineColor (h1stubsInLayerOR[iLay][0]->GetLineColor()); tle->SetLineWidth (h1stubsInLayerOR[iLay][0]->GetLineWidth()); sprintf(cc3,"Mean # stubs Ds clean Ov. Rem.: %3.2lf",h1stubsInLayerOR[iLay][1]->GetMean()); tle = tl->AddEntry(h1stubsInLayerOR[iLay][1],cc3,"l"); tle->SetLineColor (h1stubsInLayerOR[iLay][1]->GetLineColor()); tle->SetLineWidth (h1stubsInLayerOR[iLay][1]->GetLineWidth()); tl->Draw("L"); } if (makePlots) { cStubsPerLayerDsCleanOR->SaveAs(dirPlots+cName+"__.pdf"); cStubsPerLayerDsCleanOR->SaveAs(dirPlots+cName+"__.png"); } const short nQuant = 4; double percentiles [nQuant] = {0.90, 0.95, 0.99, 0.999}; double xpercentiles[6][nQuant]; cName=TString("cRoadPerEvent_")+sLogic+pName; cTitle=TString("Roads per Tower "+sLogic+pTitle); TCanvas* cRoadPerEvent = new TCanvas(cName,cTitle,0,0,1400,900); cRoadPerEvent->SetLogy(); h1RoadPerEvent [0]->SetTitle(cTitle); h1RoadPerEvent [0]->DrawCopy(); // h1RoadPerEvent6oo6[0]->SetLineColor(14); // h1RoadPerEvent6oo6[0]->DrawCopy("same"); char cc3[100]; h1RoadPerEvent [0]->GetQuantiles(nQuant,xpercentiles[0],percentiles); sprintf(cc3," #mu=%3.1lf, #Lambda_{%3.1lf}=%3.1lf",h1RoadPerEvent [0]->GetMean(),percentiles[3]*100,xpercentiles[0][3]); TLegend* tl = new TLegend(0.25,0.84,0.9,0.9); TLegendEntry* tle = tl->AddEntry(h1RoadPerEvent [0],cc3,"l"); tle->SetLineColor(h1RoadPerEvent [0]->GetLineColor()); tle->SetLineWidth(h1RoadPerEvent [0]->GetLineWidth()); // h1RoadPerEvent6oo6[0]->GetQuantiles(nQuant,xpercentiles[0],percentiles); // sprintf(cc3,"# roads/tower-6/6. #mu=%3.1lf, #Lambda_{%3.1lf}=%3.1lf",h1RoadPerEvent6oo6[0]->GetMean(),percentiles[3]*100,xpercentiles[0][3]); // tle = tl->AddEntry(h1RoadPerEvent6oo6[0],cc3,"l"); // tle->SetLineColor(h1RoadPerEvent6oo6[0]->GetLineColor()); // tle->SetLineWidth(h1RoadPerEvent6oo6[0]->GetLineWidth()); tl->Draw("L"); if (makePlots) { cRoadPerEvent->SaveAs(dirPlots+cName+"__.pdf"); cRoadPerEvent->SaveAs(dirPlots+cName+"__.png"); } cName=TString("cRoadPerEvent_OR_")+sLogic+pName; cTitle=TString("Roads per Tower "+sLogic+pTitle); TCanvas* cRoadPerEventOR = new TCanvas(cName,cTitle,0,0,1400,900); cRoadPerEventOR->SetLogy(); h1RoadPerEvent [0]->SetTitle(cTitle); h1RoadPerEvent [0]->DrawCopy(); h1RoadPerEvent [0]->GetQuantiles(nQuant,xpercentiles[0],percentiles); sprintf(cc3," #mu=%3.1lf, #Lambda_{%3.1lf}=%3.1lf",h1RoadPerEvent [0]->GetMean(),percentiles[3]*100,xpercentiles[0][3]); tl = new TLegend(0.25,0.8,0.9,0.9); tle = tl->AddEntry(h1RoadPerEvent [0],cc3,"l"); tle->SetLineColor(h1RoadPerEvent [0]->GetLineColor()); tle->SetLineWidth(h1RoadPerEvent [0]->GetLineWidth()); h1RoadPerEventOR[0]->SetLineColor(2); h1RoadPerEventOR[0]->DrawCopy("same"); h1RoadPerEventOR[0]->GetQuantiles(nQuant,xpercentiles[0],percentiles); sprintf(cc3,"Ov. Masked #mu=%3.1lf, #Lambda_{%3.1lf}=%3.1lf",h1RoadPerEventOR[0]->GetMean(),percentiles[3]*100,xpercentiles[0][3]); tle = tl->AddEntry(h1RoadPerEventOR[0],cc3,"l"); tle->SetLineColor(h1RoadPerEventOR[0]->GetLineColor()); tle->SetLineWidth(h1RoadPerEventOR[0]->GetLineWidth()); tl->Draw("L"); if (makePlots) { cRoadPerEventOR->SaveAs(dirPlots+cName+"__.pdf"); cRoadPerEventOR->SaveAs(dirPlots+cName+"__.png"); } cName=TString("cCombPerRoad_")+sLogic+pName; cTitle=TString("Combinations per Road "+sLogic+pTitle); TCanvas* cCombPerRoad = new TCanvas(cName,cTitle,0,0,1400,900); cCombPerRoad->SetLogy(); h1CombPerRoad [0]->SetTitle(cTitle); h1CombPerRoad [0]->DrawCopy(); h1CombPerRoad [0]->GetQuantiles(nQuant,xpercentiles[0],percentiles); sprintf(cc3,"# combinations/road. #mu=%3.1lf, #Lambda_{%3.1lf}=%3.1lf",h1CombPerRoad [0]->GetMean(),percentiles[3]*100,xpercentiles[0][3]); tl = new TLegend(0.25,0.75,0.9,0.9); tle = tl->AddEntry(h1CombPerRoad [0],cc3,"l"); tle->SetLineColor (h1CombPerRoad [0]->GetLineColor()); tle->SetLineWidth (h1CombPerRoad [0]->GetLineWidth()); tl->Draw("L"); if (makePlots) { cCombPerRoad->SaveAs(dirPlots+cName+"__.pdf"); cCombPerRoad->SaveAs(dirPlots+cName+"__.png"); } cName=TString("cCombPerRoad_OR_")+sLogic+pName; h1CombPerRoadOR[0]->SetLineColor(2); h1CombPerRoadOR[0]->DrawCopy("same"); h1CombPerRoadOR[0]->GetQuantiles(nQuant,xpercentiles[0],percentiles); sprintf(cc3,"# combinations/road. Ov. Masked. #mu=%3.1lf, #Lambda_{%3.1lf}=%3.1lf",h1CombPerRoadOR[0]->GetMean(),percentiles[3]*100,xpercentiles[0][3]); tle = tl->AddEntry(h1CombPerRoadOR[0],cc3,"l"); tle->SetLineColor (h1CombPerRoadOR[0]->GetLineColor()); tle->SetLineWidth (h1CombPerRoadOR[0]->GetLineWidth()); tl->Draw("L"); if (makePlots) { cCombPerRoad->SaveAs(dirPlots+cName+"__.pdf"); cCombPerRoad->SaveAs(dirPlots+cName+"__.png"); } cName=TString("cCombPerRoad_OR_DsClean_")+sLogic+pName; h1CombPerRoadOR[1]->SetLineColor(8); h1CombPerRoadOR[1]->DrawCopy("same"); h1CombPerRoadOR[1]->GetQuantiles(nQuant,xpercentiles[0],percentiles); sprintf(cc3,"# combinations/road. #Deltas clean Ov. Masked #mu=%3.1lf, #Lambda_{%3.1lf}=%3.1lf",h1CombPerRoadOR[1]->GetMean(),percentiles[3]*100,xpercentiles[0][3]); tle = tl->AddEntry(h1CombPerRoadOR[1],cc3,"l"); tle->SetLineColor (h1CombPerRoadOR[1]->GetLineColor()); tle->SetLineWidth (h1CombPerRoadOR[1]->GetLineWidth()); tl->Draw("L"); if (makePlots) { cCombPerRoad->SaveAs(dirPlots+cName+"__.pdf"); cCombPerRoad->SaveAs(dirPlots+cName+"__.png"); } cName=TString("cCombPerEvent_")+sLogic+pName; cTitle=TString("Combinations per Tower "+sLogic+pTitle); TCanvas* cCombPerEvent = new TCanvas(cName,cTitle,0,0,1400,900); cCombPerEvent->SetLogy(); h1CombPerEvent [0]->SetTitle(cTitle); h1CombPerEvent [0]->DrawCopy(); h1CombPerEvent [0]->GetQuantiles(nQuant,xpercentiles[0],percentiles); sprintf(cc3," #mu=%3.1lf, #Lambda_{%3.1lf}=%3.1lf",45.7,percentiles[3]*100,772.4); tl = new TLegend(0.25,0.75,0.9,0.9); tle = tl->AddEntry(h1CombPerEvent [0],cc3,"l"); tle->SetLineColor (h1CombPerEvent [0]->GetLineColor()); tle->SetLineWidth (h1CombPerEvent [0]->GetLineWidth()); tl->Draw("L"); if (makePlots) { cCombPerEvent->SaveAs(dirPlots+cName+"__.pdf"); cCombPerEvent->SaveAs(dirPlots+cName+"__.png"); } cName=TString("cCombPerEvent_OR_")+sLogic+pName; h1CombPerEventOR[0]->SetLineColor(2); h1CombPerEventOR[0]->DrawCopy("same"); h1CombPerEventOR[0]->GetQuantiles(nQuant,xpercentiles[0],percentiles); sprintf(cc3," Ov. Masked #mu=%3.1lf, #Lambda_{%3.1lf}=%3.1lf",h1CombPerEventOR[0]->GetMean(),percentiles[3]*100,467.4); tle = tl->AddEntry(h1CombPerEventOR[0],cc3,"l"); tle->SetLineColor (h1CombPerEventOR[0]->GetLineColor()); tle->SetLineWidth (h1CombPerEventOR[0]->GetLineWidth()); tl->Draw("L"); if (makePlots) { cCombPerEvent->SaveAs(dirPlots+cName+"__.pdf"); cCombPerEvent->SaveAs(dirPlots+cName+"__.png"); } cName=TString("cCombPerEvent_OR_DsClean_")+sLogic+pName; h1CombPerEventOR[1]->SetLineColor(8); // h1CombPerEventOR[1]->SetTitle(cTitle); // h1CombPerEventOR[1]->DrawCopy(); h1CombPerEvent [0]->DrawCopy(); h1CombPerEventOR[0]->DrawCopy("same"); h1CombPerEventOR[1]->DrawCopy("same"); h1CombPerEventOR[1]->GetQuantiles(nQuant,xpercentiles[0],percentiles); sprintf(cc3,"#Deltas clean Ov. Masked #mu=%3.1lf, #Lambda_{%3.1lf}=%3.1lf",h1CombPerEventOR[1]->GetMean(),percentiles[3]*100,xpercentiles[0][3]); tle = tl->AddEntry(h1CombPerEventOR[1],cc3,"l"); tle->SetLineColor (h1CombPerEventOR[1]->GetLineColor()); tle->SetLineWidth (h1CombPerEventOR[1]->GetLineWidth()); tl->Draw("L"); if (makePlots) { cCombPerEvent->SaveAs(dirPlots+cName+"__.pdf"); cCombPerEvent->SaveAs(dirPlots+cName+"__.png"); } TFile f1("/home/rossin/Dropbox/TT/Work/figures_stubOverlapRemoval/eff_LTF_SingleMuonTest_tt27_PU0_sf1_nz4_pt3_5oo6_95c_100k/efficiency1_10dedup_ppt_sf1_nz4.root"); TFile f2("/home/rossin/Dropbox/TT/Work/figures_stubOverlapRemoval/eff_LTF_SingleMuonTest_tt27_PU0_sf1_nz4_pt3_5oo6_95c_100k_removeOverlap/efficiency1_10dedup_ppt_sf1_nz4.root"); TCanvas* c1 = (TCanvas*) f1.Get("c1"); TList* list1 = c1->GetListOfPrimitives(); TIter next1(list1); TObject* obj1; TGraphAsymmErrors* eff_graph; while ((obj1 = next1())) { std::cout << obj1->GetName() << std::endl; if (obj1->GetName()==TString("eff_graph")) eff_graph = (TGraphAsymmErrors*) obj1; } // eff_graph->GetYaxis()->SetTitle("#varepsilon"); // eff_graph->SetMinimum(0.8); TCanvas* c1OR = (TCanvas*) f2.Get("c1"); c1OR->SetName("eff_OR"); c1OR->SetTitle("eff_OR"); TList* list = c1OR->GetListOfPrimitives(); TIter next(list); TObject* obj; TGraphAsymmErrors* eff_graphOR; c1->Draw(); while ((obj = next())) { std::cout << obj->GetName() << std::endl; if (obj->GetName()==TString("eff_graph")) { eff_graphOR = (TGraphAsymmErrors*) obj; eff_graphOR->SetLineStyle (eff_graph->GetLineStyle()); eff_graphOR->SetLineWidth (eff_graph->GetLineWidth()/2); eff_graphOR->SetMarkerStyle(eff_graph->GetMarkerStyle()); eff_graphOR->SetMarkerSize (eff_graph->GetMarkerSize()); eff_graphOR->SetFillColor (eff_graph->GetFillColor()); eff_graphOR->SetFillStyle (eff_graph->GetFillStyle()); eff_graphOR->SetMarkerColor(4); eff_graphOR->SetLineColor(4); eff_graphOR->GetYaxis()->SetTitle("#varepsilon"); eff_graphOR->Draw("same p"); } } tl = new TLegend(0.4,.13,0.95,0.35); tl->AddEntry(eff_graph ,"No Overlap Removal","p"); tl->AddEntry(eff_graphOR," Overlap Removal","p"); tl->Draw(); if (makePlots) { c1->SaveAs(dirPlots+TString("totalRecoEff_OR")+"__.png"); c1->SaveAs(dirPlots+TString("totalRecoEff_OR")+"__.pdf"); } return; }
/** * Extract ALICE PbPb @ 5.02TeV over |eta|<2 * * @param filename Input file name * @param outname Output file name * @param reweigh Whether it is reweighed */ void Extract(const char* filename="dndneta.pbpb502.20151124.root", const char* outname="TRACKLETS_5023_PbPb.input", Bool_t reweigh=false) { if (filename == 0) return; TFile* file = TFile::Open(filename, "READ"); TObjArray* arr = static_cast<TObjArray*>(file->Get("TObjArray")); // Now count number of bins Int_t nBins = 0; TIter next(arr); TObject* obj = 0; while ((obj = next())) { if (TString(obj->GetName()).Contains("DataCorrSignal")) nBins++; } Info("ExtractdNdeta", "Defining %d centrality bins", nBins); TArrayD c(nBins+1); if (nBins == 5) { c[0] = 0; c[1] = 10; c[2] = 20; c[3] = 40; c[4] = 60; c[5] = 80; } else if (nBins >= 9) { c[0] = 0; c[1] = 5; c[2] = 10; c[3] = 20; c[4] = 30; c[5] = 40; c[6] = 50; c[7] = 60; c[8] = 70; c[9] = 80; if (nBins >= 10) c[10] = 90; if (nBins >= 11) c[11] = 100; } THStack* all = new THStack("all","all"); std::ofstream out(outname); std::ostream& o = out; // std::cout; // std::ostream& o = std::cout; o << "*author: SHAHOYAN : 2015\n" << "*title: Full centrality dependence of the charged " << "particle pseudo-rapidity density over the widest " << "possible pseudo-rapidity range in Pb-Pb collisions " << "at 5.02 TeV\n" << "*detector: TRACKLETS\n" << "*experiment: CERN-LHC-TRACKLETS\n" << "*comment: CERN-LHC: We present the charged particle pseudo-rapidity " << "density of charged particles in Pb-Pb collisions at sqrt(s)/nucleon " "= 5.02 over the widest possible pseudo-rapidity and centrality range " << "possible.\n" << std::endl; for (Int_t i = 0; i < nBins; i++) { TString hName = Form("bin%d_DataCorrSignal_PbPb",i); TH1* h = static_cast<TH1*>(arr->FindObject(hName)); if (!h) { hName.ReplaceAll("PbPb", "PBPB"); h = static_cast<TH1*>(arr->FindObject(hName)); if (!h) { Warning("", "Histogram (%s) missing for bin %d", hName.Data(), i); arr->Print(); continue; } } Color_t col = PbPbColor(c[i], c[i+1]); h->SetLineColor(col); h->SetMarkerColor(col); h->SetFillColor(col); all->Add(h); Info("","Making GSE for %0d%% to %3d%% (%d)", Int_t(c[i]), Int_t(c[i+1]), col); MakeGSE(o, h, c[i], c[i+1], reweigh); } // all->Draw("nostack"); o << "*E" << std::endl; out.close(); TCanvas* can = new TCanvas("c","C", 1600, 800); can->SetRightMargin(0.2); can->SetTopMargin(0.01); TLegend* cl = new TLegend(1-can->GetRightMargin(), can->GetBottomMargin(),.99, 1-can->GetTopMargin()); cl->SetFillStyle(0); cl->SetBorderSize(0); gROOT->LoadMacro("$HOME/GraphSysErr/GraphSysErr.C+"); TList* ll = GraphSysErr::Import(outname); // ll->ls(); TIter next(ll); TObject* obj = 0; Bool_t first = true; TH1* frame = 0; Double_t min=100000, max=0; Int_t i = 0; while ((obj = next())) { if (c[i+1] > 80) break; GraphSysErr* g = static_cast<GraphSysErr*>(obj); Color_t col = PbPbColor(c[i], c[i+1]); TLegendEntry* e = cl->AddEntry("", Form("%4.1f-%4.1f%%", c[i], c[i+1]), "F"); e->SetFillColor(col); e->SetFillStyle(1001); g->SetLineColor(col); g->SetMarkerColor(col); g->SetFillColor(col); // g->Print("qual"); g->SetDataOption(GraphSysErr::kNoTick); g->SetSumOption(GraphSysErr::kBox); g->SetSumLineColor(col); g->SetSumFillColor(col); g->SetCommonSumOption(GraphSysErr::kBox); g->SetCommonSumLineColor(col); g->SetCommonSumFillColor(col); g->SetName(Form("tracklets%03dd%02d_%03dd%02d", Int_t(c[i]), Int_t(c[i]*100) % 100, Int_t(c[i+1]), Int_t(c[i+1]*100) % 100)); g->SetTitle(Form("%4.1f - %4.1f%%", c[i], c[i+1])); if (first) g->Draw("combine stat quad axis xbase=2.5"); else g->Draw("combine stat quad xbase=2.5"); if (!frame) frame = g->GetMulti()->GetHistogram(); first = false; Double_t mn, mx; g->GetMinMax("combine stat quad", mn, mx); FindLeastLargest(g, c[i], c[i+1]); min = TMath::Min(min, mn); max = TMath::Max(max, mx); i++; } frame->SetMinimum(min*.9); frame->SetMaximum(max*1.1); cl->Draw(); TFile* outFile = TFile::Open(Form("PbPb5023midRapidity%s.root", reweigh ? "Reweighed" : "Normal"), "RECREATE"); ll->Write("container",TObject::kSingleKey); outFile->Write(); can->SaveAs(Form("PbPb5023midRapidity%s.png", reweigh ? "Reweighed" : "Normal")); }
void Combine_HTBin(){ //========================================Define Variables================================================================= TFile* f[21]; TH1F* Event; TH1F* bg[21]; TH1F* Entry[21]; TH1F* HistPlot[16][15]; THStack* Stack[15]; TCanvas* can[16]; TCanvas* cMET[16]; TPad* p[6]; TLegend* leg; string str[15]; string str2[15]; Float_t Cuts[17]; Float_t xsecwzjet[16]={ 2.109e+06 , 7.785e+04 , 7.401e+03 , 6.824e+02 , 1.606e+02 , 5.545e+01 , 2.428e+01 , 4.945e+00 , 1.563e+00 , 6.254e-01 , 2.905e-01 , 8.535e-02 , 3.261e-02 , 1.310e-03 , 1.464e-04 , 2.075e-05 }; // in pb Float_t NormLumi = 1.0; // in fb-1 Int_t rebin_pt = 10; Int_t rebin_eta = 20; Int_t rebin_delphi = 2; Float_t can_w = 800; // Canvas Size Float_t can_h = 800; //=====================================================String Part====================================================== string selec = "Select"; string selec2 = "Plot_Select"; string Canvas = "Canvas"; string Stk = "Stack"; string saveAll; string proc[] = {"wzjet","tj","tt","BB"}; string phys[] = {"_MET_","_Jet1_Pt_","_Jet2_Pt_","_Jet1_Eta_","_Jet2_Eta_","_Jetdel_Phi_","_Jet_Multi_" ,"_Jet_Pt_","_Jet_Eta_" ,"_Elec_Pt_","_Elec_Eta_" ,"_Muon_Pt_","_Muon_Eta_" ,"_tau_Pt_","_tau_Eta_" }; Int_t bin[] = { 3000 , 3000 , 3000 , 1000 , 1000 , 64 , 20 , 3000 , 1000 , 3000 , 1000 , 3000 , 1000 , 3000 , 1000 }; Double_t min[] = { 0.0 , 0.0 , 0.0 , -5.0 , -5.0 , 0. , 0 , 0.0 , -5.0 , 0.0 , -5.0 , 0.0 , -5.0 , 0.0 , -5.0 }; Double_t max[] = { 30000.0, 30000.0 , 30000.0 , 5.0 , 5.0 , 6.4 , 20 , 30000.0 , 5.0 , 30000.0 , 5.0 , 30000.0 , 5.0 , 30000.0 , 5.0 }; f[0]=new TFile("tev100_wzjet_50_100_result.root"); f[1]=new TFile("tev100_wzjet_100_200_result.root"); f[2]=new TFile("tev100_wzjet_200_400_result.root"); f[3]=new TFile("tev100_wzjet_400_600_result.root"); f[4]=new TFile("tev100_wzjet_600_800_result.root"); f[5]=new TFile("tev100_wzjet_800_1000_result.root"); f[6]=new TFile("tev100_wzjet_1000_1500_result.root"); f[7]=new TFile("tev100_wzjet_1500_2000_result.root"); f[8]=new TFile("tev100_wzjet_2000_2500_result.root"); f[9]=new TFile("tev100_wzjet_2500_3000_result.root"); f[10]=new TFile("tev100_wzjet_3000_4000_result.root"); f[11]=new TFile("tev100_wzjet_4000_5000_result.root"); f[12]=new TFile("tev100_wzjet_5000_10000_result.root"); f[13]=new TFile("tev100_wzjet_10000_15000_result.root"); f[14]=new TFile("tev100_wzjet_15000_20000_result.root"); f[15]=new TFile("tev100_wzjet_20000_25000_result.root"); //==============================================Work Space======================================================== //===========================================Part 1: Plot=================================================== // ---------------------------------------------------------------------------------------------------- for (Int_t i = 0 ; i < 16 ; i ++ ) { // index for Selection Cut stringstream ss; ss<<i; for (Int_t i_stack = 0 ; i_stack < 15 ; i_stack++) { stringstream ss2; ss2<<i_stack; string str_can = Canvas+ss2.str(); string str_stk = Stk+ss2.str(); //cout << str_stk << endl; can[i_stack] = new TCanvas(str_can.c_str(),str_can.c_str(),can_w,can_h); can[i_stack]->SetCanvasSize(can_w,can_h); can[i_stack]->SetLogy(); //can[i_stack]->SetGrid(); Stack[i_stack] = new THStack(str_stk.c_str(),""); //Stack[i_stack] = new THStack("Stack",""); } for (Int_t i_main = 0 ;i_main<16;i_main++ ) { // index for open each file Entry[i_main]=(TH1F*)f[i_main]->Get("Select_MET_0"); factor = NormLumi*xsecwzjet[i_main]*1000.f/Entry[i_main]->GetEntries();//GetSumOfWeights(); cout << "Number: " << i_main << " xsec: " << xsecwzjet[i_main] << " factor: " << factor << " Entry: " << Entry[i_main]->GetEntries() << endl; for (Int_t i_hist = 0 ; i_hist < 15 ; i_hist++){ str[i_hist] = selec+phys[i_hist]+ss.str(); str2[i_hist] = selec2+phys[i_hist]+ss.str(); HistPlot[i_main][i_hist] = new TH1F(str2[i_hist].c_str(),phys[i_hist].c_str(), bin[i_hist], min[i_hist], max[i_hist]); bg[i_main]=(TH1F*)f[i_main]->Get(str[i_hist].c_str()); HistPlot[i_main][i_hist]->Add(bg[i_main],factor); //HistPlot[i_main][i_hist]->Draw(); //Set color if (i_main < 5){ HistPlot[i_main][i_hist]->SetLineColor(604-i_main); HistPlot[i_main][i_hist]->SetFillColor(604-i_main); } else if (i_main < 9) { HistPlot[i_main][i_hist]->SetLineColor(640-i_main); HistPlot[i_main][i_hist]->SetFillColor(640-i_main); } else if (i_main < 13) { HistPlot[i_main][i_hist]->SetLineColor(428-i_main); HistPlot[i_main][i_hist]->SetFillColor(428-i_main); } else { HistPlot[i_main][i_hist]->SetLineColor(632-i_main); HistPlot[i_main][i_hist]->SetFillColor(632-i_main); } // Rebinning if (i_hist == 0 || i_hist == 1 ||i_hist == 2 || i_hist == 7 || i_hist == 9 || i_hist == 11 || i_hist == 13 ) {// Rebin PT and MET HistPlot[i_main][i_hist]->Rebin(rebin_pt); } if (i_hist == 3 || i_hist == 4 || i_hist == 8 || i_hist == 10 || i_hist == 12 || i_hist == 14 ) {// Rebin Eta HistPlot[i_main][i_hist]->Rebin(rebin_eta); } if (i_hist == 5 ) {// Rebin DelPhi HistPlot[i_main][i_hist]->Rebin(rebin_delphi); } // Add to Hist Stack Stack[i_hist]->Add(HistPlot[i_main][i_hist]); } } // ================================================================================================ Cuts[i] = ((TH1*)(Stack[0]->GetStack()->Last()))->GetEntries(); //cout << "Entries: " << Cuts[i] << endl; gStyle->SetOptStat(0); gStyle->SetOptTitle(0); gStyle->SetLegendBorderSize(0); // Plot Parameters leg = new TLegend(0.50,0.35,0.8,0.8); leg->SetHeader("#splitline{#sqrt{s} = 100 TeV, #int L dt = 1 fb^{-1}}{W^{#pm}/Z^{0} + Jets}"); //leg->SetHeader("#sqrt{s} = 100 TeV, #int L dt = 10 pb^{-1}"); leg->AddEntry(HistPlot[0][0] ," ",""); leg->AddEntry(HistPlot[0][0] ," ",""); leg->AddEntry(HistPlot[0][0] ,"HTBin 50#rightarrow100 ","f"); leg->AddEntry(HistPlot[1][0] ,"HTBin 100#rightarrow200 ","f"); leg->AddEntry(HistPlot[2][0] ,"HTBin 200#rightarrow400 ","f"); leg->AddEntry(HistPlot[3][0] ,"HTBin 400#rightarrow600 ","f"); leg->AddEntry(HistPlot[4][0] ,"HTBin 600#rightarrow800 ","f"); leg->AddEntry(HistPlot[5][0] ,"HTBin 800#rightarrow1000 ","f"); leg->AddEntry(HistPlot[6][0] ,"HTBin 1000#rightarrow1500 ","f"); leg->AddEntry(HistPlot[7][0] ,"HTBin 1500#rightarrow2000 ","f"); leg->AddEntry(HistPlot[8][0] ,"HTBin 2000#rightarrow2500 ","f"); leg->AddEntry(HistPlot[9][0] ,"HTBin 2500#rightarrow3000 ","f"); leg->AddEntry(HistPlot[10][0],"HTBin 3000#rightarrow4000 ","f"); leg->AddEntry(HistPlot[11][0],"HTBin 4000#rightarrow5000 ","f"); leg->AddEntry(HistPlot[12][0],"HTBin 5000#rightarrow10000 ","f"); leg->AddEntry(HistPlot[13][0],"HTBin 10000#rightarrow15000","f"); leg->AddEntry(HistPlot[14][0],"HTBin 15000#rightarrow20000","f"); leg->AddEntry(HistPlot[15][0],"HTBin 20000#rightarrow25000","f"); //leg->SetFillColorAlpha(0,0); TLegendEntry *header = (TLegendEntry*)leg->GetListOfPrimitives()->First(); //header->SetTextAlign(22); //header->SetTextColor(2); header->SetTextSize(0.03); //Draw an axis on the right side //TGaxis *A1 = new TGaxis(0,5e9,6000,5e9,"",510,"-"); // MET can[0]->cd(); Stack[0]->Draw(); Stack[0]->GetXaxis()->SetTitle("E^{Miss}_{T} [GeV]"); Stack[0]->GetYaxis()->SetTitle("Events/100 GeV"); Stack[0]->GetYaxis()->SetTitleOffset(1.25); Stack[0]->GetXaxis()->SetRangeUser(0,6000); Stack[0]->SetMinimum(0.3); Stack[0]->SetMaximum(10e8); Stack[0]->Draw(); leg->Draw("same"); // Jet1 Pt can[1]->cd(); Stack[1]->Draw(); Stack[1]->GetXaxis()->SetTitle("P_{T} Jet_{1} [GeV/c]"); Stack[1]->GetYaxis()->SetTitle("Events/100 GeV"); Stack[1]->GetYaxis()->SetTitleOffset(1.25); Stack[1]->GetXaxis()->SetRangeUser(0,6000); Stack[1]->SetMinimum(0.3); Stack[1]->SetMaximum(10e8); Stack[1]->Draw(); leg->Draw("same"); // Jet2 Pt can[2]->cd(); Stack[2]->Draw(); Stack[2]->GetXaxis()->SetTitle("P_{T} Jet_{2} [GeV/c]"); Stack[2]->GetYaxis()->SetTitle("Events/100 GeV"); Stack[2]->GetYaxis()->SetTitleOffset(1.25); Stack[2]->GetXaxis()->SetRangeUser(0,6000); Stack[2]->SetMaximum(10e8); Stack[2]->SetMinimum(0.3); Stack[2]->Draw(); leg->Draw("same"); // Jet1 Eta can[3]->cd(); Stack[3]->Draw(); Stack[3]->GetXaxis()->SetTitle("#eta Jet_{1} "); Stack[3]->GetYaxis()->SetTitle("Events/0.2 "); Stack[3]->GetYaxis()->SetTitleOffset(1.25); Stack[3]->GetXaxis()->SetRangeUser(-5,5); Stack[3]->SetMinimum(0.3); Stack[3]->SetMaximum(10e8); Stack[3]->Draw(); leg->Draw("same"); // Jet2 Eta can[4]->cd(); Stack[4]->Draw(); Stack[4]->GetXaxis()->SetTitle("#eta Jet_{2} "); Stack[4]->GetYaxis()->SetTitle("Events/0.01 "); Stack[4]->GetYaxis()->SetTitleOffset(1.25); Stack[4]->GetXaxis()->SetRangeUser(-5,5); Stack[4]->SetMinimum(0.3); Stack[4]->SetMaximum(10e8); Stack[4]->Draw(); leg->Draw("same"); // JetDelPhi can[5]->cd(); Stack[5]->Draw(); Stack[5]->GetXaxis()->SetTitle("#Delta#phi Jet_{1,2}"); Stack[5]->GetYaxis()->SetTitle("Events/0.2 "); Stack[5]->GetYaxis()->SetTitleOffset(1.25); Stack[5]->GetXaxis()->SetRangeUser(0,6.4); Stack[5]->SetMinimum(0.3); Stack[5]->SetMaximum(10e8); Stack[5]->Draw(); leg->Draw("same"); // JetMulti can[6]->cd(); Stack[6]->Draw(); Stack[6]->GetXaxis()->SetTitle("Jet Multiplicity"); Stack[6]->GetYaxis()->SetTitle("Events "); Stack[6]->GetYaxis()->SetTitleOffset(1.40); Stack[6]->GetXaxis()->SetRangeUser(0,20); Stack[6]->SetMinimum(0.3); Stack[6]->SetMaximum(10e9); Stack[6]->Draw(); leg->Draw("same"); // Jet Pt can[7]->cd(); Stack[7]->Draw(); Stack[7]->GetXaxis()->SetTitle("P_{T} Jet [GeV/c]"); Stack[7]->GetYaxis()->SetTitle("Events/100 GeV"); Stack[7]->GetYaxis()->SetTitleOffset(1.25); Stack[7]->GetXaxis()->SetRangeUser(0,6000); Stack[7]->SetMinimum(0.03); Stack[7]->Draw(); leg->Draw("same"); // Jet Eta can[8]->cd(); Stack[8]->Draw(); Stack[8]->GetXaxis()->SetTitle("#eta Jet [GeV/c]"); Stack[8]->GetYaxis()->SetTitle("Events/0.2 "); Stack[8]->GetYaxis()->SetTitleOffset(1.25); Stack[8]->GetXaxis()->SetRangeUser(-5,5); Stack[8]->SetMinimum(0.3); Stack[8]->SetMaximum(10e8); Stack[8]->Draw(); leg->Draw("same"); // Elec Pt can[9]->cd(); Stack[9]->Draw(); Stack[9]->GetXaxis()->SetTitle("P_{T} Electron [GeV/c]"); Stack[9]->GetYaxis()->SetTitle("Events/100 GeV"); Stack[9]->GetYaxis()->SetTitleOffset(1.25); Stack[9]->GetXaxis()->SetRangeUser(0,6000); Stack[9]->SetMinimum(0.03); Stack[9]->Draw(); leg->Draw("same"); // Elec Eta can[10]->cd(); Stack[10]->Draw(); Stack[10]->GetXaxis()->SetTitle("#eta Elec [GeV/c]"); Stack[10]->GetYaxis()->SetTitle("Events/0.2 "); Stack[10]->GetYaxis()->SetTitleOffset(1.25); Stack[10]->GetXaxis()->SetRangeUser(-5,5); Stack[10]->SetMinimum(0.3); Stack[10]->SetMaximum(10e8); Stack[10]->Draw(); leg->Draw("same"); // Muon Pt can[11]->cd(); Stack[11]->Draw(); Stack[11]->GetXaxis()->SetTitle("P_{T} Muon [GeV/c]"); Stack[11]->GetYaxis()->SetTitle("Events/100 GeV"); Stack[11]->GetYaxis()->SetTitleOffset(1.25); Stack[11]->GetXaxis()->SetRangeUser(0,6000); Stack[11]->SetMinimum(0.03); Stack[11]->Draw(); leg->Draw("same"); // Muon Eta can[12]->cd(); Stack[12]->Draw(); Stack[12]->GetXaxis()->SetTitle("#eta Muon [GeV/c]"); Stack[12]->GetYaxis()->SetTitle("Events/0.2 "); Stack[12]->GetYaxis()->SetTitleOffset(1.25); Stack[12]->GetXaxis()->SetRangeUser(-5,5); Stack[12]->SetMinimum(0.3); Stack[12]->SetMaximum(10e8); Stack[12]->Draw(); leg->Draw("same"); // tau Pt can[13]->cd(); Stack[13]->Draw(); Stack[13]->GetXaxis()->SetTitle("P_{T} tau [GeV/c]"); Stack[13]->GetYaxis()->SetTitle("Events/100 GeV"); Stack[13]->GetYaxis()->SetTitleOffset(1.25); Stack[13]->GetXaxis()->SetRangeUser(0,6000); Stack[13]->SetMinimum(0.03); Stack[13]->Draw(); leg->Draw("same"); // tau Eta can[14]->cd(); Stack[14]->Draw(); Stack[14]->GetXaxis()->SetTitle("#eta tau [GeV/c]"); Stack[14]->GetYaxis()->SetTitle("Events/0.2 "); Stack[14]->GetYaxis()->SetTitleOffset(1.25); Stack[14]->GetXaxis()->SetRangeUser(-5,5); Stack[14]->SetMinimum(0.3); Stack[14]->SetMaximum(10e8); Stack[14]->Draw(); leg->Draw("same"); // Save for (Int_t i_hist = 0; i_hist<15 ; i_hist++){ saveAll = str[i_hist]+".pdf"; can[i_hist]->SaveAs(saveAll.c_str()); delete can[i_hist]; } } // Print Results // Create file for data aquisition fstream myfile; myfile.open("Results.txt", std::fstream::in | std::fstream::out | std::fstream::app); for (Int_t i = 0; i < 17 ; i++) { myfile << "Selection Cut " << i << " : " << Cuts[i] << endl; } myfile.close(); }
/** * Draw final plot for QM2011 * * @param max * * @ingroup pwglf_forward_scripts */ void dndeta_final(Double_t max=6) { gStyle->SetOptTitle(0); gStyle->SetOptFit(0); gStyle->SetTitleFont(132, "xyz"); gStyle->SetTitleSize(0.1, "xyz"); gStyle->SetTitleOffset(0.4, "y"); gStyle->SetTitleOffset(0.8, "x"); gStyle->SetLabelFont(132, "xyz"); gStyle->SetLabelSize(0.08, "xyz"); gStyle->SetNdivisions(212, "x"); gStyle->SetNdivisions(208, "y"); gStyle->SetTextFont(132); gStyle->SetPadColor(0); gStyle->SetPadBorderMode(0); // gStyle->SetFillColor(0); // gStyle->SetFillStyle(0); TCanvas* c = new TCanvas("c", "c", 900, 900); c->SetFillColor(0); c->SetFillStyle(0); c->SetBorderSize(0); c->SetBorderMode(0); c->SetRightMargin(0.02); c->SetTopMargin(0.02); c->SetBottomMargin(0.15); c->Divide(1,3,0,0); // --- INEL -------------------------------------------------------- TVirtualPad* p = c->cd(1); p->SetGridx(); p->SetRightMargin(.01); THStack* inel = new THStack("inel", "INEL"); TLatex* inelT = new TLatex(1-p->GetRightMargin()-.01, 1-p->GetTopMargin()-.01, "INEL"); inelT->SetNDC(); inelT->SetTextAlign(33); inelT->SetTextSize(0.12); TLegend* inelL = new TLegend(.3, .02, .8, .4); inelL->SetBorderSize(0); inelL->SetNColumns(2); inelL->SetFillColor(0); inelL->SetFillStyle(0); TLegendEntry* e = inelL->AddEntry("d1", "Forward", "lp"); e->SetMarkerColor(kRed+2); e->SetMarkerStyle(29); e = inelL->AddEntry("d2", "Central", "lp"); e->SetMarkerColor(kMagenta+2); e->SetMarkerStyle(29); e = inelL->AddEntry("d3", "Data", "lp"); e->SetMarkerStyle(29); e = inelL->AddEntry("d4", "Mirrored data", "lp"); e->SetMarkerStyle(30); e = inelL->AddEntry("d5", "Systematic error", "f"); e->SetFillColor(kGray); e->SetLineColor(kGray); e->SetLineWidth(0); e->SetFillStyle(3001); gROOT->LoadMacro("export_pp_0900GeV_INEL_m10p10cm_000100000ev.C"); export_pp_0900GeV_INEL_m10p10cm_000100000ev(inel, inelL, 20); export_pp_0900GeV_INEL_m10p10cm_000100000ev(inel, inelL, 21); export_pp_0900GeV_INEL_m10p10cm_000100000ev(inel, inelL, 22); inel->Draw("nostack e1"); inel->GetHistogram()->SetYTitle("#frac{1}{N}#frac{dN_{ch}}{d#eta}"); inel->GetHistogram()->SetXTitle("#eta"); inel->GetHistogram()->GetYaxis()->SetDecimals(); inelL->Draw(); inelT->Draw(); // --- INEL>0 ------------------------------------------------------ p = c->cd(2); p->SetGridx(); p->SetRightMargin(.01); THStack* inelgt0 = new THStack("inelgt0", "INEL>0"); TLatex* inelgt0T = new TLatex(1-p->GetRightMargin()-.01, 1-p->GetTopMargin()-.01, "INEL>0"); inelgt0T->SetNDC(); inelgt0T->SetTextAlign(33); inelgt0T->SetTextSize(0.12); gROOT->LoadMacro("export_pp_0900GeV_INEL_m10p10cm_000100000ev.C"); export_pp_0900GeV_INEL_m10p10cm_000100000ev(inelgt0, 0, 20); export_pp_0900GeV_INEL_m10p10cm_000100000ev(inelgt0, 0, 21); export_pp_0900GeV_INEL_m10p10cm_000100000ev(inelgt0, 0, 22); inelgt0->Draw("nostack e1"); inelgt0->GetHistogram()->SetXTitle("#eta"); inelgt0->GetHistogram()->GetYaxis()->SetDecimals(); inelgt0T->Draw(); // --- NSD --------------------------------------------------------- p = c->cd(3); p->SetGridx(); p->SetRightMargin(.01); THStack* nsd = new THStack("nsd", "NSD"); TLatex* nsdT = new TLatex(1-p->GetRightMargin()-.01, 1-p->GetTopMargin()-.01, "NSD"); nsdT->SetNDC(); nsdT->SetTextAlign(33); nsdT->SetTextSize(0.12); gROOT->LoadMacro("export_pp_0900GeV_NSD_m10p10cm_000100000ev.C"); export_pp_0900GeV_NSD_m10p10cm_000100000ev(nsd, 0, 20); export_pp_0900GeV_NSD_m10p10cm_000100000ev(nsd, 0, 21); export_pp_0900GeV_NSD_m10p10cm_000100000ev(nsd, 0, 22); nsd->Draw("nostack e1"); nsd->GetHistogram()->SetXTitle("#eta"); nsd->GetHistogram()->GetYaxis()->SetDecimals(); nsdT->Draw(); c->cd(); c->SaveAs("dndeta_final.png"); }
//____________________________________________________________________ void DrawResCollection(TCollection* top, const TString& name) { TCollection* c = GetCollection(top, name, false); if (!c) return; THStack* s = GetStack(c, "all"); s->SetTitle(""); DrawInPad(fBody, 0, s, "nostack", kLogy); TLegend* l = new TLegend(.5, .75, .98, .98, "P(#it{N}_{ch})"); l->SetBorderSize(0); // l->SetBorderMode(0); l->SetFillColor(0); l->SetFillStyle(0); TIter next(s->GetHists()); TH1* h = 0; Bool_t hasTrue = false; while ((h = static_cast<TH1*>(next()))) { TString n(h->GetTitle()); if (n.BeginsWith("True")) { hasTrue = true; continue; } n.ReplaceAll("Raw P(#it{N}_{ch}) in ", ""); TLegendEntry* e = l->AddEntry("dummy", n, "p"); e->SetMarkerStyle(h->GetMarkerStyle()); } if (hasTrue) { TLegendEntry* e = l->AddEntry("dummy", "Raw", "p"); e->SetMarkerStyle(20); e->SetMarkerColor(kRed+1); e = l->AddEntry("dummy", "MC truth", "p"); e->SetMarkerStyle(24); e->SetMarkerColor(kBlue+1); e = l->AddEntry("dummy", "MC truth selected", "p"); e->SetMarkerStyle(24); e->SetMarkerColor(kOrange+1); } fBody->cd(); l->Draw(); PrintCanvas(Form("%s results", name.Data())); // return; TIter nextO(c); TObject* o = 0; while ((o = nextO())) { Double_t etaMin = 999; Double_t etaMax = 999; TCollection* bin = GetEtaBin(o, etaMin, etaMax); if (!bin) continue; fBody->Divide(2,3); DrawInPad(fBody, 1, GetH1(bin, "rawDist"), "", kLogy); DrawInPad(fBody, 1, GetH1(bin, "truthAccepted", false), "same", kSilent); DrawInPad(fBody, 1, GetH1(bin, "truth", false),"same", kSilent|kLegend); DrawInPad(fBody, 2, GetH1(bin, "coverage")); DrawInPad(fBody, 3, GetH2(bin, "corr"), "colz"); DrawInPad(fBody, 4, GetH2(bin, "response", false), "colz", kLogz|kSilent); DrawInPad(fBody, 5, GetH1(bin, "triggerVertex", false), "", kSilent); PrintCanvas(Form("%+5.1f < #eta < %+5.1f", etaMin, etaMax)); } }