void DrawStatBox(TObject** Histos, std::vector<char*> legend, bool Mean, double X, double Y, double W, double H) { int N = legend.size(); char buffer[255]; if(Mean)H*=3; for(int i=0;i<N;i++){ TPaveText* stat = new TPaveText(X,Y-(i*H), X+W, Y-(i+1)*H, "NDC"); TH1* Histo = (TH1*)Histos[i]; sprintf(buffer,"Entries : %i\n",(int)Histo->GetEntries()); stat->AddText(buffer); if(Mean){ sprintf(buffer,"Mean : %6.2f\n",Histo->GetMean()); stat->AddText(buffer); sprintf(buffer,"RMS : %6.2f\n",Histo->GetRMS()); stat->AddText(buffer); } stat->SetFillColor(0); stat->SetLineColor(Color[i]); stat->SetTextColor(Color[i]); stat->SetBorderSize(0); stat->SetMargin(0.05); stat->SetTextAlign(12); stat->Draw(); } }
void plotBkgModel(TList* HistList, std::string name){ gROOT->SetBatch(); system("mkdir -p plots/ada/bkgMod"); system("mkdir -p plots/grad/bkgMod"); std::string bdt; TString str = HistList->At(0)->GetName(); if (str.Contains("ada")) bdt="ada"; else if (str.Contains("grad")) bdt="grad"; else std::cout << "Error find BDT type" << std::endl; assert (str.Contains("ada") || str.Contains("grad")); gStyle->SetOptStat(0); gROOT->SetStyle("Plain"); gROOT->ForceStyle(); int color[6] = {kGreen+4,kGreen-1,kGreen,kRed,kRed-2,kRed+4}; TCanvas *canv = new TCanvas(); TLegend *leg = new TLegend(0.45,0.6,0.85,0.85); leg->SetLineColor(0); leg->SetFillColor(0); TPaveText *txt = new TPaveText(0.2,0.1,0.4,0.35,"NDC"); txt->SetFillColor(0); txt->SetLineColor(0); txt->AddText("#int L = 4.76 fb^{-1}"); for (int i=1; i<HistList->GetEntries(); i++){ //if (((TH1F*)HistList->At(i))->GetNbinsX()!=((TH1F*)HistList->At(0))->GetNbinsX()) std::cout << "Plot problem: calling plot for histograms with different number of bins" << std::endl; //assert (((TH1F*)HistList->At(i))->GetNbinsX()==((TH1F*)HistList->At(0))->GetNbinsX()); TH1F *temp = linearBin((TH1F*)HistList->At(i)); temp->Scale(((TH1F*)HistList->At(0))->Integral()/temp->Integral()); temp->SetLineColor(color[i-1]); temp->SetMarkerStyle(20); temp->SetMarkerColor(color[i-1]); temp->SetTitle(Form("Data in sidebands %s %s",bdt.c_str(),name.c_str())); temp->GetXaxis()->SetTitle(""); temp->GetYaxis()->SetRangeUser(1.0,2.*(((TH1F*)HistList->At(0))->GetMaximum())); if (i==1) temp->Draw("p"); else temp->Draw("same p"); if (i==1) leg->AddEntry(temp,"Low 3 sideband","lep"); if (i==2) leg->AddEntry(temp,"Low 2 sideband","lep"); if (i==3) leg->AddEntry(temp,"Low 1 sideband","lep"); if (i==4) leg->AddEntry(temp,"High 1 sideband","lep"); if (i==5) leg->AddEntry(temp,"High 2 sideband","lep"); if (i==6) leg->AddEntry(temp,"High 3 sideband","lep"); } leg->Draw("same"); txt->Draw("same"); canv->SetLogy(); canv->Print(("plots/"+bdt+"/bkgMod/"+name+".png").c_str(),"png"); delete canv; delete txt; delete leg; bkgCalls++; }
void Plot(RooRealVar *mass, RooDataSet *data, RooAbsPdf *pdf, pair<double,double> sigRange, vector<double> fwhmRange, string title, string savename){ double semin=sigRange.first; double semax=sigRange.second; double fwmin=fwhmRange[0]; double fwmax=fwhmRange[1]; double halfmax=fwhmRange[2]; double binwidth=fwhmRange[3]; RooPlot *plot = mass->frame(Bins(binning_),Range("higgsRange")); if (data) data->plotOn(plot,Invisible()); pdf->plotOn(plot,NormRange("higgsRange"),Range(semin,semax),FillColor(19),DrawOption("F"),LineWidth(2),FillStyle(1001),VLines(),LineColor(15)); TObject *seffLeg = plot->getObject(int(plot->numItems()-1)); pdf->plotOn(plot,NormRange("higgsRange"),Range(semin,semax),LineColor(15),LineWidth(2),FillStyle(1001),VLines()); pdf->plotOn(plot,NormRange("higgsRange"),Range("higgsRange"),LineColor(kBlue),LineWidth(2),FillStyle(0)); TObject *pdfLeg = plot->getObject(int(plot->numItems()-1)); if (data) data->plotOn(plot,MarkerStyle(kOpenSquare)); TObject *dataLeg = plot->getObject(int(plot->numItems()-1)); TLegend *leg = new TLegend(0.15,0.89,0.5,0.55); leg->SetFillStyle(0); leg->SetLineColor(0); leg->SetTextSize(0.03); if (data) leg->AddEntry(dataLeg,"Simulation","lep"); leg->AddEntry(pdfLeg,"Parametric model","l"); leg->AddEntry(seffLeg,Form("#sigma_{eff} = %1.2f GeV",0.5*(semax-semin)),"fl"); plot->GetXaxis()->SetNdivisions(509); halfmax*=(plot->getFitRangeBinW()/binwidth); TArrow *fwhmArrow = new TArrow(fwmin,halfmax,fwmax,halfmax,0.02,"<>"); fwhmArrow->SetLineWidth(2.); TPaveText *fwhmText = new TPaveText(0.15,0.45,0.45,0.58,"brNDC"); fwhmText->SetFillColor(0); fwhmText->SetLineColor(kWhite); fwhmText->SetTextSize(0.03); fwhmText->AddText(Form("FWHM = %1.2f GeV",(fwmax-fwmin))); TLatex lat1(0.65,0.85,"#splitline{CMS Preliminary}{Simulation}"); lat1.SetNDC(1); lat1.SetTextSize(0.03); TLatex lat2(0.65,0.75,title.c_str()); lat2.SetNDC(1); lat2.SetTextSize(0.025); TCanvas *canv = new TCanvas("c","c",600,600); plot->SetTitle(""); plot->GetXaxis()->SetTitle("m_{#gamma#gamma} (GeV)"); plot->Draw(); leg->Draw("same"); fwhmArrow->Draw("same <>"); fwhmText->Draw("same"); lat1.Draw("same"); lat2.Draw("same"); canv->Print(Form("%s.pdf",savename.c_str())); canv->Print(Form("%s.png",savename.c_str())); string path = savename.substr(0,savename.find('/')); canv->Print(Form("%s/animation.gif+100",path.c_str())); delete canv; }
void s_intersection() { gROOT->GetListOfCanvases()->Delete(); TCanvas *c = new TCanvas("composite shape", "Intersection boolean operation", 700, 1000); c->Divide(1,2,0,0); c->cd(2); gPad->SetPad(0,0,1,0.4); c->cd(1); gPad->SetPad(0,0.4,1,1); if (gGeoManager) delete gGeoManager; new TGeoManager("xtru", "poza12"); TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7); TGeoMedium *med = new TGeoMedium("MED",1,mat); TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100); gGeoManager->SetTopVolume(top); // define shape components with names TGeoBBox *box = new TGeoBBox("bx", 40., 40., 40.); TGeoSphere *sph = new TGeoSphere("sph", 40., 45.); // define named geometrical transformations with names TGeoTranslation *tr = new TGeoTranslation(0., 0., 45.); tr->SetName("tr"); // register all used transformations tr->RegisterYourself(); // create the composite shape based on a Boolean expression TGeoCompositeShape *cs = new TGeoCompositeShape("mir", "sph:tr * bx"); TGeoVolume *vol = new TGeoVolume("COMP2",cs); top->AddNode(vol,1); gGeoManager->CloseGeometry(); gGeoManager->SetNsegments(100); top->Draw(); MakePicture(); c->cd(2); TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99); pt->SetLineColor(1); TText *text = pt->AddText("TGeoCompositeShape - composite shape class"); text->SetTextColor(2); pt->AddText("----- Here is an example of boolean intersection operation : A * B"); pt->AddText("----- A == sphere (with inner radius non-zero), B == box"); pt->AddText(" "); pt->SetAllWith("-----","color",4); pt->SetAllWith("-----","font",72); pt->SetAllWith("-----","size",0.04); pt->SetTextAlign(12); pt->SetTextSize(0.044); pt->Draw(); c->cd(1); }
void Plot10Mu(const char* text,float X, float Y, float size) { TPaveText* atext = new TPaveText(X,Y,X+size,Y+size); atext->AddText(text); atext->SetLineColor(0); atext->SetFillColor(0); atext->SetTextFont(42); atext->SetTextSize(0.04); atext->Draw(); }
void s_difference() { gROOT->GetListOfCanvases()->Delete(); TCanvas *c = new TCanvas("composite shape", "Difference boolean operation", 700, 1000); c->Divide(1,2,0,0); c->cd(2); gPad->SetPad(0,0,1,0.4); c->cd(1); gPad->SetPad(0,0.4,1,1); if (gGeoManager) delete gGeoManager; new TGeoManager("xtru", "poza12"); TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7); TGeoMedium *med = new TGeoMedium("MED",1,mat); TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100); gGeoManager->SetTopVolume(top); // define shape components with names TGeoTorus *tor = new TGeoTorus("tor", 45., 15., 20., 45., 145.); TGeoSphere *sph = new TGeoSphere("sph", 20., 45., 0., 180., 0., 270.); // create the composite shape based on a Boolean expression TGeoCompositeShape *cs = new TGeoCompositeShape("mir", "sph - tor"); TGeoVolume *vol = new TGeoVolume("COMP3",cs); top->AddNode(vol,1); gGeoManager->CloseGeometry(); gGeoManager->SetNsegments(60); top->Draw(); MakePicture(); c->cd(2); TPaveText *pt = new TPaveText(.01, .01, .99, .99); pt->SetLineColor(1); TText *text = pt->AddText("TGeoCompositeShape - composite shape class"); text->SetTextColor(2); pt->AddText("----- It's an example of boolean difference: A - B"); pt->AddText("----- A == part of sphere (0-180, 0-270), B == partial torus (45-145)"); pt->AddText(" "); pt->SetAllWith("-----","color",4); pt->SetAllWith("-----","font",72); pt->SetAllWith("-----","size",0.04); pt->SetTextAlign(12); pt->SetTextSize(0.044); pt->Draw(); c->cd(1); }
void banner4Plot (){ TPaveText* pt ; pt = new TPaveText(.14,0.91,.25,.94,"NDC"); pt->AddText("Preliminary"); pt->SetFillColor(0); pt->SetTextSize(0.035); pt->SetFillStyle(0); pt->SetLineColor(0); pt->SetLineWidth(0); pt->SetMargin(0); pt->SetShadowColor(0); pt->Draw(); }
int makeZPhiArrowPlot( TTree* data, const char* name, double zLim, double phiLim, double level, double sublevel, double zMin, double zMax, double rMin, double rMax, double barrelRPhiRescale){ TCanvas* OBPCanvas = new TCanvas(name,name,1050,875); OBPCanvas->DrawFrame(-zLim, -phiLim, 1.2*zLim, phiLim, ";module position z [cm];module position r*phi [cm]"); OBPCanvas->SetFillColor(0); OBPCanvas->SetFrameBorderMode(0); TFrame* aFrame = OBPCanvas->GetFrame(); aFrame->SetFillColor(0); int passcut = 0; for(int entry = 0;entry<data->GetEntries(); entry++) { data->GetEntry(entry); if ((level_ == level)&&(((sublevel_ == sublevel)&&(sublevel != 0))||(sublevel == 0))){ if ((z_ <= zMax)&&(z_ > zMin)&&(r_ <= rMax)&&(r_ > rMin)){ TArrow* aArraw = new TArrow( z_, r_*phi_ , z_ + barrelRPhiRescale*dz_, r_*phi_+barrelRPhiRescale*r_*dphi_,0.0075,">"); aArraw->Draw(); passcut++; } } } DrawRPhiLegend( zLim, phiLim, barrelRPhiRescale ); char sliceLeg[192]; sprintf( sliceLeg, "%s: %f < r <= %f", name, rMin, rMax ); //Plot10Mu( name, xLim/2, yLim, 0.2*xLim ); TPaveText* atext = new TPaveText(0.2*zLim,0.85*phiLim,0.66*zLim,0.99*phiLim); atext->AddText(sliceLeg); atext->SetLineColor(0); atext->SetFillColor(0); atext->SetTextFont(42); atext->SetTextSize(0.04); atext->Draw(); char outfile[192]; sprintf( outfile, "%s/%s.png", outputDir_, name ); OBPCanvas->Print( outfile ); return passcut; }
TPaveText* getHeader(double lumi, TString channelName) { TPaveText* pt = new TPaveText(0.18,0.75,0.18,0.88,"brNDC"); pt->SetBorderSize(1); pt->SetTextFont(42); pt->SetTextSize(0.04); pt->SetLineColor(0); pt->SetLineStyle(1); pt->SetLineWidth(1); pt->SetFillColor(0); pt->SetFillStyle(1001); pt->SetTextAlign(12); pt->AddText("CMS Preliminary"); pt->AddText(Form("%.1f fb^{-1} at #sqrt{s} = 7 TeV", lumi)); if ( channelName != "" ) pt->AddText(channelName); return pt; }
// ----------------------------------------------------------------------------- // TCanvas* createPlot( TDirectory* output_file, std::string output_canvas, //std::vector< std::vector<std::string> > input_files, std::vector<std::string> input_files, std::vector<std::string> input_histos, std::vector<std::string> input_legend, std::vector<int> marker_style, std::vector<int> marker_colour, std::vector<float> marker_size, std::vector<float> lumis, double lumi, int rebin, bool norm, bool log, double min = -1., double max = -1., int integral = -1 ) { // SetSomeStyles(); // Check integral if ( integral >= input_files.size() ) { integral = -1; } // Loop through histogram names std::vector<TH1D*> his; for ( uint ihis = 0; ihis < input_histos.size(); ++ihis ) { if ( integral < 0 || ihis <= integral ) { his.push_back( (TH1D*)getHisto( input_files[ihis], input_histos[ihis], "QcdBkgdEst", rebin ) ); } else { his.back()->Add( (TH1D*)getHisto( input_files[ihis], input_histos[ihis], "QcdBkgdEst", rebin ) ); } } // Create legend TLegend* legend = new TLegend( 0.65, 0.52-0.03*his.size(), 0.9, 0.52, NULL, "brNDC" ); legend->SetFillColor(0); legend->SetLineColor(0); legend->SetTextAlign(31); legend->SetTextSize(0.025); // Create canvas TCanvas* aCanvas = createCanvas( output_canvas, output_file, log ); TPaveText* stats = new TPaveText( 0.65, 0.54, 0.9, 0.54+0.03*his.size(), "brNDC" ); stats->SetFillColor(0); stats->SetLineColor(0); TLatex* prelim = new TLatex( 0.15, 0.96, "#scale[0.8]{CMS preliminary 2011}" ); prelim->SetTextSize(0.03); prelim->SetNDC(); std::stringstream ssl; ssl << "#scale[0.8]{#int L dt = " << lumi/1000. << " fb^{-1}, #sqrt{s} = 7 TeV}"; TLatex* lumistxt = new TLatex( 0.95, 0.96, ssl.str().c_str() ); lumistxt->SetTextSize(0.03); lumistxt->SetNDC(); lumistxt->SetTextAlign(31); // For Ted bool print_ted = true; std::stringstream ted; if ( print_ted ) { ted << "self._htMeans = ("; } // Loop through histograms double aMax = 0.; double aMin = 1.e12; for ( uint ihis = 0; ihis < his.size(); ++ihis ) { if ( !his[ihis] ) { continue; } // Line colour and fill his[ihis]->Scale(lumis[ihis]/100.); his[ihis]->SetMarkerStyle(marker_style[ihis]); his[ihis]->SetMarkerColor(marker_colour[ihis]); his[ihis]->SetMarkerSize(marker_size[ihis]); his[ihis]->SetLineColor(marker_colour[ihis]); his[ihis]->SetLineStyle(0); his[ihis]->SetLineWidth(0); // Populate legend if ( input_legend.size() > ihis ) { legend->AddEntry( his[ihis], input_legend[ihis].c_str(), "ep" ); } else { legend->AddEntry( his[ihis], input_histos[ihis].c_str(), "ep" ); } // Populate stats box std::stringstream ss; //ss << "Mean=" << int(his[ihis]->GetMean()*100.)/100. << ", RMS=" << int(his[ihis]->GetRMS()*100.)/100.; ss << "Entries=" << his[ihis]->GetEntries(); TText* text = stats->AddText(ss.str().c_str()); text->SetTextAlign(11); text->SetTextSize(0.025); text->SetTextColor(marker_colour[ihis]); // For Ted if ( print_ted ) ted << std::setw(9) << std::scientific << std::setprecision(3) << his[ihis]->GetMean() << ", "; // Calc min/max number of entries if ( his[ihis]->GetMaximum() > aMax ) { aMax = his[ihis]->GetMaximum(); } if ( his[ihis]->GetMinimum(1.e-12) < aMin ) { aMin = his[ihis]->GetMinimum(1.e-12); } } // For Ted if ( print_ted ) { ted << ")" << std::endl; std::cout << ted.str() << std::endl; } if ( !his.empty() ) { if ( his[0] ) his[0]->GetYaxis()->SetTitleOffset(1.43); if ( his[0] ) his[0]->GetYaxis()->SetTitleSize(0.06); if ( his[0] ) his[0]->GetXaxis()->SetTitleSize(0.06); if ( his[0] ) his[0]->GetXaxis()->SetTitleOffset(0.9); } // First histo be drawn bool first = true; for ( uint ihis = 0; ihis < his.size(); ++ihis ) { if ( !his[ihis] ) { continue; } //his[ihis]->GetYaxis()->SetTitle("a.u."); if ( log ) { his[ihis]->SetMaximum( aMax * 10. ); his[ihis]->SetMinimum( aMin * 0.1 ); } else { his[ihis]->SetMaximum( aMax * 1.1 ); his[ihis]->SetMinimum( aMin * 0.9 ); } if ( min > 0. ) his[ihis]->SetMinimum( min ); if ( max > 0. ) his[ihis]->SetMaximum( max ); if ( norm ) { std::string options = ""; if ( first ) { options = "Ehist"; first = false; } else { options = "psame"; } if ( his[ihis]->GetEntries() > 0. ) { his[ihis]->DrawNormalized(options.c_str()); } } else { std::string options = ""; if ( first ) { options = "Ehist"; first = false; } else { options = "psame"; } his[ihis]->Draw(options.c_str()); } } // Loop through histos output_file->cd(); legend->Draw("same"); stats->Draw("same"); prelim->Draw("same"); lumistxt->Draw("same"); aCanvas->Modified(); //aCanvas->SaveAs( std::string(output_canvas+".png").c_str() ); aCanvas->SaveAs( std::string(output_canvas+".pdf").c_str() ); aCanvas->SaveAs( std::string(output_canvas+".C").c_str() ); aCanvas->Write(); return aCanvas; }
void plotDavid(TH1F* bkgT, TH1F* sigT, TH1F* dataT, std::string name){ gROOT->SetBatch(); system("mkdir -p plots/ada/david"); system("mkdir -p plots/grad/david"); system("mkdir -p plots/ada/diff"); system("mkdir -p plots/grad/diff"); std::string bdt; TString str = dataT->GetName(); if (str.Contains("ada")) bdt="ada"; else if (str.Contains("grad")) bdt="grad"; else std::cout << "Error find BDT type" << std::endl; assert (str.Contains("ada") || str.Contains("grad")); if (bkgT->GetNbinsX() != sigT->GetNbinsX() || sigT->GetNbinsX() != dataT->GetNbinsX()) std::cout << "Plot problem: calling plot for histograms with different number of bins" << std::endl; assert(bkgT->GetNbinsX() == sigT->GetNbinsX() || sigT->GetNbinsX() == dataT->GetNbinsX()); TH1F *bkg = linearBin(bkgT); TH1F *sig2 = linearBin(sigT); TH1F *sig5 = (TH1F*)sig2->Clone(); TH1F *sig10 = (TH1F*)sig2->Clone(); TH1F *data = linearBin(dataT); TH1F *diff = (TH1F*)data->Clone(); diff->Add(bkg,-1); gStyle->SetOptStat(0); gROOT->SetStyle("Plain"); gROOT->ForceStyle(); TCanvas *canv = new TCanvas(); bkg->SetLineColor(kBlue); bkg->SetFillColor(kBlue-9); sig2->SetLineColor(kRed); sig2->SetLineStyle(3); sig2->Scale(1.); sig5->SetLineColor(kRed); sig5->SetLineStyle(7); sig5->Scale(3.); sig10->SetLineColor(kRed); sig10->Scale(5.); data->SetMarkerStyle(20); bkg->SetTitle(("Background, data and signal distributions for "+bdt+" "+name).c_str()); sig2->SetTitle(("Background, data and signal distributions for "+bdt+" "+name).c_str()); data->SetTitle(("Background, data and signal distributions for "+bdt+" "+name).c_str()); bkg->GetXaxis()->SetTitle(""); sig2->GetXaxis()->SetTitle(""); data->GetXaxis()->SetTitle(""); bkg->GetYaxis()->SetTitle("Events"); sig2->GetYaxis()->SetTitle("Events"); data->GetYaxis()->SetTitle("Events"); TLegend *leg = new TLegend(0.45,0.6,0.85,0.85); leg->SetLineColor(0); leg->SetFillColor(0); leg->AddEntry(bkg,"Background","f"); leg->AddEntry(data,"Data","lep"); leg->AddEntry(sig10,"Signal (1, 3, 5 #times SM)","l"); TPaveText *txt = new TPaveText(0.2,0.1,0.4,0.35,"NDC"); txt->SetFillColor(0); txt->SetLineColor(0); txt->AddText("#int L = 4.76 fb^{-1}"); bkg->GetYaxis()->SetRangeUser(1.0,2.*(data->GetMaximum())); bkg->Draw("e2"); sig2->Draw("same hist"); sig5->Draw("same hist"); sig10->Draw("same hist"); data->Draw("same e"); leg->Draw("same"); txt->Draw("same"); canv->SetLogy(); canv->Print(("plots/"+bdt+"/david/"+name+".png").c_str(),"png"); canv->SetLogy(false); canv->Clear(); TLegend *leg2 = new TLegend(0.45,0.6,0.85,0.85); leg2->SetFillColor(0); leg2->SetLineColor(0); sig10->GetYaxis()->SetRangeUser((-1*sig10->GetMaximum())+10,sig10->GetMaximum()+20); sig10->GetXaxis()->SetTitle(""); sig10->GetYaxis()->SetTitle("Events"); sig10->SetTitle(Form("Data, background difference compared to signal %s %s",bdt.c_str(),name.c_str())); diff->SetMarkerStyle(20); diff->GetXaxis()->SetTitle(""); diff->GetYaxis()->SetTitle("Events"); leg2->AddEntry(diff,"Data - background model","lep"); leg2->AddEntry(sig10,"Signal (1, 3, 5 #times SM)","l"); TF1 *line = new TF1("line","0.0",0.0,sig10->GetNbinsX()+1); line->SetLineColor(kBlue); sig10->Draw("hist"); sig5->Draw("same hist"); sig2->Draw("same hist"); line->Draw("same"); diff->Draw("p same"); leg2->Draw("same"); txt->Draw("same"); canv->Print(("plots/"+bdt+"/diff/"+name+".png").c_str(),"png"); delete canv; delete txt; delete leg; davidCalls++; }
void rsLimit7TeV(){ setTDRStyle(); //=========Macro generated from canvas: cLimit/Limit //========= (Mon Feb 22 22:44:48 2010) by ROOT version5.18/00a // TCanvas *cLimit = new TCanvas("cLimit", "Limit",450,40,800,550); // TCanvas *cLimit = new TCanvas("cLimit", "Limit",100,122,600,600); cLimit = new TCanvas("cLimit","cLimit",800,600); gStyle->SetOptStat(0); // cLimit->Range(595.5973,-0.03483694,1345.283,0.2539571); cLimit->SetFillColor(0); cLimit->SetBorderMode(0); cLimit->SetBorderSize(2); cLimit->SetLeftMargin(0.139262); cLimit->SetRightMargin(0.0604027); cLimit->SetTopMargin(0.0804196); cLimit->SetBottomMargin(0.120629); cLimit->SetFrameBorderMode(0); cLimit->SetFrameBorderMode(0); TGraph *graph = new TGraph(11); graph->SetName("Graph"); graph->SetTitle(""); graph->SetFillColor(1); Int_t ci; // for color index setting ci = TColor::GetColor("#ff0000"); graph->SetLineColor(ci); graph->SetLineWidth(3); ci = TColor::GetColor("#ff0000"); graph->SetMarkerColor(ci); graph->SetMarkerStyle(20); graph->SetMarkerSize(1.0); graph->SetPoint(0, 863,0.01); graph->SetPoint(1, 1132,0.02); graph->SetPoint(2, 1274,0.03); graph->SetPoint(3, 1395,0.04); graph->SetPoint(4, 1503,0.05); graph->SetPoint(5, 1597,0.06); graph->SetPoint(6, 1676,0.07); graph->SetPoint(7, 1742,0.08); graph->SetPoint(8, 1801,0.09); graph->SetPoint(9, 1844,0.1); graph->SetPoint(10,1881,0.11); cout << " Don't forget to change this..." << endl; TH1 *Graph6 = new TH1F("Graph6","",100,863,1881); Graph6->SetMinimum(0); Graph6->SetMaximum(0.12); Graph6->SetDirectory(0); Graph6->SetStats(0); Graph6->GetXaxis()->SetTitle("M_{1} [GeV]"); Graph6->GetYaxis()->SetTitle("Coupling k/#bar{M}_{Pl}"); Graph6->GetXaxis()->SetLabelFont(42); Graph6->GetYaxis()->SetLabelFont(42); Graph6->GetYaxis()->SetTitleOffset(1.8); graph->SetHistogram(Graph6); graph->GetYaxis()->SetTitleOffset(1.19); graph->Draw("al"); TGraph* graph2 = new TGraph(11); graph2->SetMarkerColor(ci); graph2->SetMarkerStyle(20); graph2->SetMarkerSize(0.0); graph2->SetPoint(0, 845,0.01); graph2->SetPoint(1, 1133,0.02); graph2->SetPoint(2, 1275,0.03); graph2->SetPoint(3, 1396,0.04); graph2->SetPoint(4, 1504,0.05); graph2->SetPoint(5, 1598,0.06); graph2->SetPoint(6, 1677,0.07); graph2->SetPoint(7, 1743,0.08); graph2->SetPoint(8, 1801,0.09); graph2->SetPoint(9, 1844,0.1); graph2->SetPoint(10,1881,0.11); graph2->SetLineStyle(kDashed); graph2->SetLineColor(ci); graph2->SetLineWidth(3); graph2->GetXaxis()->SetLabelFont(42); graph2->GetYaxis()->SetLabelFont(42); graph2->Draw("plsame"); // graph = new TGraph(3); // graph->SetName("Graph"); // graph->SetTitle(""); // graph->SetFillColor(1); // ci = TColor::GetColor("#0000ff"); // graph->SetLineColor(ci); // graph->SetLineWidth(3); // ci = TColor::GetColor("#0000ff"); // graph->SetMarkerColor(ci); // graph->SetMarkerStyle(22); // graph->SetMarkerSize(1.4); // graph->SetPoint(0,750,0.03355478); // graph->SetPoint(1,1000,0.07617687); // graph->SetPoint(2,1250,0.1542326); // TH1 *Graph7 = new TH1F("Graph7","",100,700,1300); // Graph7->SetMinimum(0.021487); // Graph7->SetMaximum(0.1663004); // Graph7->SetDirectory(0); // Graph7->SetStats(0); // Graph7->GetXaxis()->SetTitle("Graviton Mass (GeV)"); // Graph7->GetYaxis()->SetTitle("Coupling k/#bar{M}_{Pl}"); // graph->SetHistogram(Graph7); // graph->Draw("pc"); // graph = new TGraph(3); // graph->SetName("Graph"); // graph->SetTitle(""); // graph->SetFillColor(1); // ci = TColor::GetColor("#00ff00"); // graph->SetLineColor(ci); // graph->SetLineWidth(3); // ci = TColor::GetColor("#00ff00"); // graph->SetMarkerColor(ci); // graph->SetMarkerStyle(21); // graph->SetMarkerSize(1.3); // graph->SetPoint(0,750,0.02431275); // graph->SetPoint(1,1000,0.05519538); // graph->SetPoint(2,1250,0.1117521); // TH1 *Graph8 = new TH1F("Graph8","",100,700,1300); // Graph8->SetMinimum(0.01556881); // Graph8->SetMaximum(0.1204961); // Graph8->SetDirectory(0); // Graph8->SetStats(0); // Graph8->GetXaxis()->SetTitle("Graviton Mass (GeV/c^{2})"); // Graph8->GetYaxis()->SetTitle("Coupling k/#bar{M}_{Pl}"); // graph->SetHistogram(Graph8); // graph->Draw("pc"); // TF1 *LambdaPi = new TF1("LambdaPi","pol1",500,2500); // LambdaPi->SetFillColor(15); // LambdaPi->SetFillStyle(3004); // LambdaPi->SetLineColor(15); // LambdaPi->SetLineWidth(1); // LambdaPi->SetParameter(0,0); // LambdaPi->SetParError(0,0); // LambdaPi->SetParLimits(0,0,0); // LambdaPi->SetParameter(1,2.61097e-05); // LambdaPi->SetParError(1,0); // LambdaPi->SetParLimits(1,0,0); // LambdaPi->Draw("same"); // TF1 *LambdaPi = new TF1("LambdaPi","pol1",250,2500); LambdaPi->SetFillColor(15); LambdaPi->SetFillStyle(3004); LambdaPi->SetLineColor(15); LambdaPi->SetLineWidth(1); LambdaPi->SetParameter(0,0); LambdaPi->SetParError(0,0); LambdaPi->SetParLimits(0,0,0); LambdaPi->SetParameter(1,2.61097e-05); LambdaPi->SetParError(1,0); LambdaPi->SetParLimits(1,0,0); LambdaPi->GetXaxis()->SetLabelFont(42); LambdaPi->GetYaxis()->SetLabelFont(42); LambdaPi->Draw("same"); graph = new TGraph(27); graph->SetName("Graph"); graph->SetTitle("Graph"); graph->SetFillColor(1); graph->SetFillStyle(3004); graph->SetLineStyle(5); graph->SetLineWidth(3); graph->SetPoint(0,180,0.1071); graph->SetPoint(1,183,0.1062); graph->SetPoint(2,190,0.1043); graph->SetPoint(3,200,0.1016); graph->SetPoint(4,210,0.0989); graph->SetPoint(5,220,0.0963); graph->SetPoint(6,230,0.0938); graph->SetPoint(7,240,0.0913); graph->SetPoint(8,250,0.0889); graph->SetPoint(9,260,0.0866); graph->SetPoint(10,270,0.0843); graph->SetPoint(11,280,0.0821); graph->SetPoint(12,290,0.0799); graph->SetPoint(13,300,0.0778); graph->SetPoint(14,400,0.0603); graph->SetPoint(15,500,0.0481); graph->SetPoint(16,600,0.0397); graph->SetPoint(17,700,0.0337); graph->SetPoint(18,800,0.0292); graph->SetPoint(19,900,0.0258); graph->SetPoint(20,1000,0.0231); graph->SetPoint(21,1100,0.0209); graph->SetPoint(22,1200,0.0191); graph->SetPoint(23,1300,0.0176); graph->SetPoint(24,1400,0.0163); graph->SetPoint(25,1500,0.0152); graph->SetPoint(26,2200,0.01); graph->GetXaxis()->SetLabelFont(42); graph->GetYaxis()->SetLabelFont(42); graph->SetFillColor(kBlack); graph->SetFillStyle(3004); graph->SetLineWidth(1); graph->SetFillStyle(3002); graph->SetFillColor(kBlack); graph->SetLineWidth(-10000); graph->Draw("c"); // graph->Draw("same"); // TPaveText *pt = new TPaveText(0.194631,0.748252,0.436242,0.816434,"blNDC"); // pt->SetName("95% CL Limit"); // pt->SetFillColor(0); // pt->SetBorderSize(1); // pt->SetLineColor(0); // pt->SetTextSize(0.04); // TText *text = pt->AddText("95% CL Limit"); // pt->Draw(); TLegend *leg = new TLegend(0.2072864,0.4667832,0.4007538,0.7517483,NULL,"brNDC"); // TLegend *leg = new TLegend(0.2072864,0.5332168,0.4007538,0.7517483,NULL,"brNDC"); // TLegend *leg = new TLegend(0.2110553,0.4248252,0.4120603,0.6433566,NULL,"brNDC"); // TLegend *leg = new TLegend(0.2181208,0.5297203,0.4194631,0.7482517,NULL,"brNDC"); leg->SetBorderSize(1); leg->SetTextFont(62); leg->SetTextSize(0.05); leg->SetLineColor(0); leg->SetLineStyle(0); leg->SetLineWidth(0); leg->SetFillColor(0); leg->SetFillStyle(0); // TLegendEntry *entry=leg->AddEntry("graph","50/pb","pl"); // ci = TColor::GetColor("#ff0000"); // entry->SetLineColor(ci); // entry->SetLineStyle(1); // entry->SetLineWidth(3); entry=leg->AddEntry("graph","Electroweak Limits","lf"); entry->SetLineColor(1); entry->SetLineStyle(5); entry->SetLineWidth(3); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); ci = TColor::GetColor("#ff0000"); entry->SetMarkerColor(ci); entry->SetMarkerStyle(20); entry->SetMarkerSize(1.3); entry=leg->AddEntry("Graph","95% CL Limit","l"); leg->AddEntry(graph2,"Expected Limit","l"); ci = TColor::GetColor("#00ff00"); entry->SetMarkerColor(ci); entry->SetMarkerStyle(21); entry->SetMarkerSize(1.3); // entry=leg->AddEntry("LambdaPi","#Lambda_{#pi}> 10TeV","lf"); entry=leg->AddEntry("LambdaPi","M_{D} > 10TeV","lf"); // entry->SetFillColor(15); // entry->SetFillStyle(3004); // entry->SetLineColor(15); // entry->SetLineStyle(1); // entry->SetLineWidth(1); // entry->SetMarkerColor(1); // entry->SetMarkerStyle(1); // entry->SetMarkerSize(1); leg->Draw(); TPaveText *pt = new TPaveText(0.2236181,0.7884615,0.4736181,0.8583916,"blNDC"); // TPaveText *pt = new TPaveText(0.1959799,0.7954545,0.4459799,0.8653846,"blNDC"); // TPaveText *pt = new TPaveText(0.2130872,0.8339161,0.4630872,0.9038462,"blNDC"); pt->SetName("CMS Preliminary"); pt->SetBorderSize(1); pt->SetLineColor(0); pt->SetFillColor(0); // pt->SetTextFont(72); pt->SetTextSize(0.06); text = pt->AddText("CMS Preliminary"); pt->Draw(); pt = new TPaveText(0.629397,0.798951,0.8002513,0.8653846,"blNDC"); // pt = new TPaveText(0.6005025,0.8059441,0.7713568,0.8723776,"blNDC"); // pt = new TPaveText(0.2738693,0.7027972,0.4447236,0.7692308,"blNDC"); // pt = new TPaveText(0.2416107,0.7727273,0.4127517,0.8391608,"blNDC"); pt->SetFillColor(0); pt->SetBorderSize(1); pt->SetLineColor(0); pt->SetTextSize(0.06); text = pt->AddText("2.2 fb^{-1} at 7 TeV"); pt->Draw(); // pt = new TPaveText(0.6879195,0.8129371,0.7885906,0.9108392,"blNDC"); // pt->SetFillColor(0); // pt->SetBorderSize(1); // pt->SetLineColor(0); // pt->SetTextSize(0.0454545); // text = pt->AddText("L = 1091 pb^{-1}"); // pt->Draw(); cLimit->Modified(); cLimit->cd(); cLimit->SetSelected(cLimit); }
//void MergeMetHists(const int Nfiles=0, // const std::string filenamebase="", // const std::string title="", const std::string name="", // const float LoX=-1, const float HiX=-1, const int rebin=1, // const std::string printfile="", bool debug=false) void MergeMetHists(const int Nfiles, const std::string filenamebase, const std::string title, const std::string name, const float LoX=-1, const float HiX=-1, const int rebin=1, const std::string printfile="", const int MetSig=4, bool debug=false, const bool logy=false) { assert (Nfiles>0 && "Number of files must be > 0"); assert (name.length()>0 && "Require hist name!"); assert (filenamebase.length()>0 && "Require base of the file name!"); std::cout << "MetSig=" << MetSig << std::endl; std::cout << "Searching for obj = " << name <<std::endl; std::string data_path, bg_path, def_path; std::string ue1_path, ue2_path, ue3_path, ue4_path, ue5_path, ue6_path; std::string ue7_path, ue8_path, ue9_path; std::string jer1_path, jer2_path, jer3_path, jer4_path, jer5_path; std::string jer6_path, jer7_path, jer8_path, jer9_path, jer10_path; data_path="/Ana/MyJetFilter/Hist/Ana_data/"; bg_path="/Ana/MyJetFilter/Hist/Ana_bckg/"; def_path="/Ana/MyJetFilter/Hist/Ana_def/"; ue1_path="/Ana/MyJetFilter/Hist/Ana_ue1/"; ue2_path="/Ana/MyJetFilter/Hist/Ana_ue2/"; ue3_path="/Ana/MyJetFilter/Hist/Ana_ue3/"; ue4_path="/Ana/MyJetFilter/Hist/Ana_ue4/"; ue5_path="/Ana/MyJetFilter/Hist/Ana_ue5/"; ue6_path="/Ana/MyJetFilter/Hist/Ana_ue6/"; ue7_path="/Ana/MyJetFilter/Hist/Ana_ue7/"; ue8_path="/Ana/MyJetFilter/Hist/Ana_ue8/"; ue9_path="/Ana/MyJetFilter/Hist/Ana_ue9/"; jer1_path="/Ana/MyJetFilter/Hist/Ana_jer1/"; jer2_path="/Ana/MyJetFilter/Hist/Ana_jer2/"; jer3_path="/Ana/MyJetFilter/Hist/Ana_jer3/"; jer4_path="/Ana/MyJetFilter/Hist/Ana_jer4/"; jer5_path="/Ana/MyJetFilter/Hist/Ana_jer5/"; jer6_path="/Ana/MyJetFilter/Hist/Ana_jer6/"; jer7_path="/Ana/MyJetFilter/Hist/Ana_jer7/"; jer8_path="/Ana/MyJetFilter/Hist/Ana_jer8/"; jer9_path="/Ana/MyJetFilter/Hist/Ana_jer9/"; jer10_path="/Ana/MyJetFilter/Hist/Ana_jer10/"; /* data_path="Ana_data"; bg_path="Ana_bckg"; def_path="Ana_def"; ue1_path="Ana_ue1"; ue2_path="Ana_ue2"; ue3_path="Ana_ue3"; ue4_path="Ana_ue4"; ue5_path="Ana_ue5"; ue6_path="Ana_ue6"; ue7_path="Ana_ue7"; ue8_path="Ana_ue8"; ue9_path="Ana_ue9"; jer1_path="Ana_jer1"; jer2_path="Ana_jer2"; jer3_path="Ana_jer3"; jer4_path="Ana_jer4"; jer5_path="Ana_jer5"; jer6_path="Ana_jer6"; jer7_path="Ana_jer7"; jer8_path="Ana_jer8"; jer9_path="Ana_jer9"; jer10_path="Ana_jer10"; */ std::vector<std::string> vPaths; vPaths.push_back(data_path); vPaths.push_back(bg_path); vPaths.push_back(def_path); vPaths.push_back(ue1_path); vPaths.push_back(ue2_path); vPaths.push_back(ue3_path); vPaths.push_back(ue4_path); vPaths.push_back(ue5_path); vPaths.push_back(ue6_path); vPaths.push_back(ue7_path); vPaths.push_back(ue8_path); vPaths.push_back(ue9_path); vPaths.push_back(jer1_path); vPaths.push_back(jer2_path); vPaths.push_back(jer3_path); vPaths.push_back(jer4_path); vPaths.push_back(jer5_path); vPaths.push_back(jer6_path); vPaths.push_back(jer7_path); vPaths.push_back(jer8_path); vPaths.push_back(jer9_path); vPaths.push_back(jer10_path); TFile *f = 0; TH1 *hist_data = 0, *hist_bg = 0; int iNHists = vPaths.size(); std::vector<TH1*> vHist; for (int n= 0; n < iNHists; ++n) { TH1 *temp=0; vHist.push_back(temp); } int NfilesOpened = 0; //for (int i=1; i<=1; ++i) for (int i=1; i<=Nfiles; ++i) { std::stringstream file; file << filenamebase << i; //file << "myhisto_PhoJetAna_Pyth_phojet22_1Njet15_test_040208.root"; f = new TFile (file.str().c_str()); if (f->IsZombie()) { std::cout << "ERROR::File " << file.str() << " did not open! Exiting." << std::endl; exit (1); } else { NfilesOpened++; if (debug) { std::cout << "File Added::"; f->Print(); } } gROOT->ls(); TFolder *fold = (TFolder*) gDirectory->FindObjectAny("Ana"); assert(fold != NULL && "folder null"); TFolder *dir = (TFolder*) fold->FindObjectAny("MyJetFilter"); assert(dir != NULL && "dir null"); TFolder *dir2 = (TFolder*) dir->FindObjectAny("Hist"); assert(dir2 != NULL && "Hist null"); //TH1 *h = dynamic_cast<TH1*> (dir3->FindObjectAny(name.c_str())); //assert (h!=NULL && "hist null"); //h->Draw(); //return; for (unsigned int iPath = 0; iPath < vPaths.size(); ++iPath) { //std::cout << "iPath = " << iPath << std::endl; TFolder *dir3 = (TFolder*) dir2->FindObjectAny(vPaths.at(iPath).c_str()); assert(dir3 != NULL && "data null"); //f->cd(); //gDirectory->pwd(); //f->cd(vPaths.at(iPath).c_str()); //gDirectory->pwd(); //if (iPath<2) f->ls(); //TH1 *hTemp = dynamic_cast<TH1*> (gDirectory->FindObjectAny(name.c_str())); std::stringstream histpath; histpath << vPaths.at(iPath) << name; //TFolder *ana = (TFolder*) gDirectory->FindObjectAny("Ana"); //assert(ana !=NULL && "Ana folder not found"); //std::cout << "histpath = " << histpath.str() << std::endl; TH1 *hTemp = dynamic_cast<TH1*> (dir3->FindObjectAny(name.c_str())); assert(hTemp != NULL && "object not found!"); if (hTemp->GetEntries()) // this has to be done to avoid crashes when adding hists which some how have 'sum=nan' instead of 'sum=0' when they do not have any entries. { if (! vHist.at(iPath)) { std::string name = hTemp->GetName() + std::string ("_Clone"); vHist.at(iPath) = dynamic_cast<TH1*>(hTemp->Clone (name.c_str())); assert(vHist.at(iPath) != NULL && "Data hist cast failed"); vHist.at(iPath)->SetDirectory(0); } else { vHist.at(iPath)->Add(hTemp); } } } delete f; } /* assert(vHist.size() == vPaths.size()); for (int k=0; k < vHist.size(); ++k) { vHist.at(k)->Print(); } */ DoSystematics(vHist); hist_data = vHist.at(0); hist_bg = vHist.at(1); /* std::cout << "NORMALIZING BG TO DATA " << std::endl; double data_int = hist_data->Integral(); double bg_int = hist_bg->Integral(); hist_bg->Scale(data_int/bg_int); std::cout << "SCALE = " << data_int/bg_int << std::endl; */ if (debug) { hist_data->Print("all"); hist_bg->Print("all"); } std::cout << "Total file added = " << NfilesOpened << std::endl; gStyle->SetOptStat(""); if (hist_data->GetEntries()) hist_data->Rebin(rebin); if (hist_bg->GetEntries()) hist_bg->Rebin(rebin); TH1 *hist_err_copy = NULL; std::string bgname = hist_bg->GetName() + std::string ("err_copy"); hist_err_copy = dynamic_cast<TH1*>(hist_bg->Clone (bgname.c_str())); hist_err_copy->SetDirectory(0); TH1 *hist_data_copy = NULL; std::string dataname = hist_data->GetName() + std::string ("data_copy"); hist_data_copy = dynamic_cast<TH1*>(hist_data->Clone (dataname.c_str())); hist_data_copy->SetDirectory(0); float x_loLim, x_hiLim; if (LoX >0) x_loLim = LoX; else x_loLim = hist_data->GetBinLowEdge(1); if (HiX >0) x_hiLim = HiX; else x_hiLim = max(FindUpLimit(hist_data), FindUpLimit(hist_bg)) + hist_data->GetBinWidth(1) * 2; if (debug) { std::cout << "min, max = " << x_loLim << ", " << x_hiLim << std::endl; } float y_hiLim = max(FindUpLimit(hist_data,"Y"), FindUpLimit(hist_bg,"Y")); if (logy) y_hiLim *= 10; else y_hiLim += y_hiLim * 0.1; gStyle->SetCanvasColor (10); gStyle->SetCanvasBorderSize (0); gStyle->SetCanvasBorderMode (0); gStyle->SetPadColor (10); gStyle->SetFillColor (10); gStyle->SetTitleFillColor (10); gStyle->SetTitleBorderSize (0); gStyle->SetStatColor (10); gStyle->SetStatBorderSize (1); gStyle->SetCanvasDefW(1200); gStyle->SetCanvasDefH(600); int labelfont = 10 * 4 + 2; //10 * font ID + precision (2 = scalable) int titlefont = 10 * 4 + 2; //10 * font ID + precision (2 = scalable) gStyle->SetLabelFont(labelfont,"X"); gStyle->SetLabelFont(labelfont,"Y"); gStyle->SetTitleFont(titlefont,"X"); gStyle->SetTitleFont(titlefont,"Y"); gStyle->SetLabelSize(0.04,"X"); gStyle->SetLabelSize(0.027,"Y"); //gStyle->SetLabelOffset(0.9); gStyle->SetTitleSize(0.03,"Y"); gStyle->SetTitleOffset(1.8,"Y"); //TGaxis::SetMaxDigits(3); hist_data->UseCurrentStyle(); hist_bg->UseCurrentStyle(); TCanvas *c1= new TCanvas; c1->Divide(2,1); c1->cd(1); if (logy) { if (hist_data->GetEntries() > 0 && hist_bg->GetEntries() > 0) gPad->SetLogy(); } gPad->SetTickx(); gPad->SetTicky(); gPad->SetGridx(); gPad->SetGridy(); TPaveText *tp = new TPaveText(0.02,0.92,0.98,0.99,"NDC"); tp->SetLineColor(10); tp->SetTextFont(titlefont); std::string tt(hist_data->GetTitle()); // hist_data->SetTitle(""); // hist_bg->SetTitle(""); if (title.length()>0) { //tt += " - "; tt += title; //tt = title; if (debug) { std::cout << tt << std::endl; } tp->AddText(tt.c_str()); } std::stringstream ytitle, xtitle; ytitle << "Events / " << setprecision(3) << hist_data->GetXaxis()->GetBinWidth(1) << " GeV"; if (debug) { std::cout << hist_data->GetBinWidth(1) <<std::endl; } if (name == "MetAll") xtitle << "#slash{E}_{T} (for all events) (GeV)"; else if (name == "Met") xtitle << "#slash{E}_{T} (after cuts) (GeV)"; else if (name == "MetSig") xtitle << "#slash{E}_{T} Significance (for all events)"; else if (name == "Njet15") xtitle << "Njets^{E_{T}>15GeV} (After #slash{E}_{T}-Sig cut)"; else if (name == "Njet20") xtitle << "Njets^{E_{T}>20GeV} (After #slash{E}_{T}-Sig cut)"; else if (name == "Njet25") xtitle << "Njets^{E_{T}>25GeV} (After #slash{E}_{T}-Sig cut)"; else if (name == "Njet30") xtitle << "Njets^{E_{T}>30GeV} (After #slash{E}_{T}-Sig cut)"; else if (name == "Njet35") xtitle << "Njets^{E_{T}>35GeV} (After #slash{E}_{T}-Sig cut)"; if (debug) { std::cout << "xtitle=" << xtitle.str() << std::endl; } if (debug) { hist_data->Print(); std::cout << "bin#\tLoEdge\tdata\tdata_err\tbg_cont\tbg_err"<<std::endl; for (unsigned bin = 0; bin <= (unsigned) hist_data_copy->GetNbinsX() + 1; ++ bin) { float val = hist_data->GetBinContent (bin); float err = hist_data->GetBinError(bin); float val2 = hist_bg->GetBinContent (bin); float err2 = hist_bg->GetBinError(bin); float loEdge = hist_data->GetBinLowEdge(bin); if (val>0 || err>0 || val2>0 || err2>0) std::cout << bin << "\t" << loEdge <<"\t" << val << "\t" << err << "\t\t" << val2 << "\t" << err2 << std::endl; } } hist_data->GetXaxis()->SetTitle(xtitle.str().c_str()); if (name.find("Njet") == std::string::npos) hist_data->GetYaxis()->SetTitle(ytitle.str().c_str()); hist_data->GetXaxis()->CenterTitle(true); hist_data->GetYaxis()->CenterTitle(true); hist_bg->GetXaxis()->SetTitle(xtitle.str().c_str()); if (name.find("Njet") == std::string::npos) hist_bg->GetYaxis()->SetTitle(ytitle.str().c_str()); hist_bg->GetXaxis()->CenterTitle(true); hist_bg->GetYaxis()->CenterTitle(true); //temp x_loLim = 0; x_hiLim = 200; hist_data->GetXaxis()->SetRangeUser(x_loLim, x_hiLim); hist_bg->GetXaxis()->SetRangeUser(x_loLim, x_hiLim); hist_data->SetMinimum(0.1); hist_bg->SetMinimum(0.1); hist_data->SetMaximum(y_hiLim); hist_bg->SetMaximum(y_hiLim); hist_data->SetMarkerStyle(8); hist_data->SetMarkerSize(1.0); hist_data->SetMarkerColor(kBlue); hist_data->SetLineColor(kBlue); hist_bg->SetMarkerColor(kRed); hist_bg->SetLineColor(kRed); hist_bg->SetFillColor(kRed); hist_data->SetTitleSize(0.04); hist_bg->SetTitleSize(0.04); TH1* hist_bg_copy = dynamic_cast<TH1*>(hist_bg->Clone ("hist_bg_BlkLine")); hist_bg_copy->SetLineColor(kBlack); hist_bg_copy->SetLineWidth(2); hist_bg_copy->SetFillColor(0); //hist_bg_copy->Draw("L"); //hist_bg->Draw("sameE2"); // hist_bg->SetFillColor(10); // hist_bg->SetLineColor(10); hist_bg->Draw("E2"); hist_bg_copy->Draw("SAME HIST"); hist_data->Draw("sameP"); //tp->Draw(); TLegend *leg = new TLegend (0.4,0.8,0.90,0.90); leg->SetTextFont(42); leg->SetTextSize(0.025); leg->SetBorderSize (1); leg->SetFillColor (10); //std::stringstream leg_data, leg_bg; //leg_data << "Data (E=" << hist_data->GetEntries() << " M=" << hist_data->GetMean() // << " R=" << hist_data->GetRMS() << ")"; //leg_bg << "Bkg (E=" << hist_bg->GetEntries() << " M=" << hist_bg->GetMean() // << " R=" << hist_bg->GetRMS() << ")"; //leg->AddEntry(hist_data,leg_data.str().c_str()); //leg->AddEntry(hist_bg,leg_bg.str().c_str()); //leg->AddEntry(hist_data,"Data (Measured) (DET Jets) "); //leg->AddEntry(hist_bg, "MC Prediction (HAD Jets, Norm to Data)"); leg->AddEntry(hist_data,"Data (Measured)"); leg->AddEntry(hist_bg, "MC Prediction"); leg->Draw(); // now to make the ratio plots for (unsigned bin = 0; bin <= (unsigned) hist_data_copy->GetNbinsX() + 1; ++ bin) { const float val = hist_err_copy->GetBinContent (bin); const float scale = val ? 1. / val : 0; hist_data_copy->SetBinContent (bin, (hist_data_copy->GetBinContent (bin) - val) * scale); hist_data_copy->SetBinError (bin, hist_data_copy->GetBinError (bin) * scale); }; for (unsigned bin = 0; bin <= (unsigned) hist_err_copy->GetNbinsX() + 1; ++ bin) { float value = hist_err_copy->GetBinContent (bin); float error = hist_err_copy->GetBinError (bin); hist_err_copy->SetBinError (bin, value ? error / value : 0); hist_err_copy->SetBinContent (bin, 0); }; /* TH1 *hist_ratio = NULL; std::string myname = hist_data->GetName() + std::string ("_copy"); hist_ratio = dynamic_cast<TH1*>(hist_data->Clone (myname.c_str())); hist_ratio->Divide(hist_bg); */ hist_data_copy->UseCurrentStyle(); hist_err_copy->UseCurrentStyle(); //new TCanvas(); c1->cd(2); gPad->SetTickx(); gPad->SetTicky(); gPad->SetGridx(); gPad->SetGridy(); hist_data_copy->SetTitle(""); hist_err_copy->SetTitle(""); //hist_data_copy->SetTitle(tt.c_str()); //hist_err_copy->SetTitle(tt.c_str()); hist_data_copy->GetXaxis()->SetTitle(xtitle.str().c_str()); hist_err_copy->GetXaxis()->SetTitle(xtitle.str().c_str()); hist_data_copy->GetXaxis()->SetRangeUser(x_loLim, x_hiLim); hist_err_copy->GetXaxis()->SetRangeUser(x_loLim, x_hiLim); float fRatioHist_ymax = 1.0; float fRatioHist_ymin = -1.0; hist_data_copy->SetMinimum(fRatioHist_ymin); hist_data_copy->SetMaximum(fRatioHist_ymax); hist_err_copy->SetMinimum(fRatioHist_ymin); hist_err_copy->SetMaximum(fRatioHist_ymax); std::stringstream ratio_ytitle; ratio_ytitle << "(Data Measured - MC Prediction) / MC Prediction"; hist_data_copy->GetYaxis()->SetTitle(ratio_ytitle.str().c_str()); hist_err_copy->GetYaxis()->SetTitle(ratio_ytitle.str().c_str()); //hist_data_copy->SetTitle(ratio_ytitle.str().c_str()); //hist_err_copy->SetTitle(ratio_ytitle.str().c_str()); hist_data_copy->GetXaxis()->CenterTitle(true); hist_data_copy->GetYaxis()->CenterTitle(true); hist_err_copy->GetXaxis()->CenterTitle(true); hist_err_copy->GetYaxis()->CenterTitle(true); // hist_data->GetYaxis()->SetRangeUser(; //// hist_bg->SetMinimum(0.1); hist_data_copy->SetLineColor(kBlue); hist_data_copy->SetMarkerColor(kBlue); hist_data_copy->SetMarkerStyle (8); hist_data_copy->SetMarkerSize(1.0); hist_err_copy->SetFillColor(kRed); hist_err_copy->SetFillStyle(3002); hist_data_copy->Draw("P"); hist_err_copy->Draw("same E2"); //tp->Draw(); c1->cd(); if (printfile.length()>0) { c1->Print(printfile.c_str()); } DebugSystError(hist_data,hist_bg, hist_data_copy, hist_err_copy); }
void BackgroundPrediction(std::string pname,int rebin_factor,int model_number = 0,int imass=750, bool plotBands = false) { rebin = rebin_factor; std::string fname = std::string("../fitFilesMETPT34/") + pname + std::string("/histos_bkg.root"); stringstream iimass ; iimass << imass; std::string dirName = "info_"+iimass.str()+"_"+pname; gStyle->SetOptStat(000000000); gStyle->SetPadGridX(0); gStyle->SetPadGridY(0); setTDRStyle(); gStyle->SetPadGridX(0); gStyle->SetPadGridY(0); gStyle->SetOptStat(0000); writeExtraText = true; // if extra text extraText = "Preliminary"; // default extra text is "Preliminary" lumi_13TeV = "2.7 fb^{-1}"; // default is "19.7 fb^{-1}" lumi_7TeV = "4.9 fb^{-1}"; // default is "5.1 fb^{-1}" double ratio_tau=-1; TFile *f=new TFile(fname.c_str()); TH1F *h_mX_CR_tau=(TH1F*)f->Get("distribs_18_10_1")->Clone("CR_tau"); TH1F *h_mX_SR=(TH1F*)f->Get("distribs_18_10_0")->Clone("The_SR"); double maxdata = h_mX_SR->GetMaximum(); double nEventsSR = h_mX_SR->Integral(600,4000); ratio_tau=(h_mX_SR->GetSumOfWeights()/(h_mX_CR_tau->GetSumOfWeights())); //double nEventsSR = h_mX_SR->Integral(600,4000); std::cout<<"ratio tau "<<ratio_tau<<std::endl; TH1F *h_SR_Prediction; TH1F *h_SR_Prediction2; if(blind) { h_SR_Prediction2 = (TH1F*)h_mX_CR_tau->Clone("h_SR_Prediction2"); h_mX_CR_tau->Rebin(rebin); h_mX_CR_tau->SetLineColor(kBlack); h_SR_Prediction=(TH1F*)h_mX_CR_tau->Clone("h_SR_Prediction"); } else { h_SR_Prediction2=(TH1F*)h_mX_SR->Clone("h_SR_Prediction2"); h_mX_SR->Rebin(rebin); h_mX_SR->SetLineColor(kBlack); h_SR_Prediction=(TH1F*)h_mX_SR->Clone("h_SR_Prediction"); } h_SR_Prediction->SetMarkerSize(0.7); h_SR_Prediction->GetYaxis()->SetTitleOffset(1.2); h_SR_Prediction->Sumw2(); /*TFile *f_sig = new TFile((dirName+"/w_signal_"+iimass.str()+".root").c_str()); RooWorkspace* xf_sig = (RooWorkspace*)f_sig->Get("Vg"); RooAbsPdf *xf_sig_pdf = (RooAbsPdf *)xf_sig->pdf((std::string("signal_fixed_")+pname).c_str()); RooWorkspace w_sig("w"); w_sig.import(*xf_sig_pdf,RooFit::RenameVariable((std::string("signal_fixed_")+pname).c_str(),(std::string("signal_fixed_")+pname+std::string("low")).c_str()),RooFit::RenameAllVariablesExcept("low","x")); xf_sig_pdf = w_sig.pdf((std::string("signal_fixed_")+pname+std::string("low")).c_str()); RooArgSet* biasVars = xf_sig_pdf->getVariables(); TIterator *it = biasVars->createIterator(); RooRealVar* var = (RooRealVar*)it->Next(); while (var) { var->setConstant(kTRUE); var = (RooRealVar*)it->Next(); } */ RooRealVar x("x", "m_{X} (GeV)", SR_lo, SR_hi); RooRealVar nBackground((std::string("bg_")+pname+std::string("_norm")).c_str(),"nbkg",h_mX_SR->GetSumOfWeights()); RooRealVar nBackground2((std::string("alt_bg_")+pname+std::string("_norm")).c_str(),"nbkg",h_mX_SR->GetSumOfWeights()); std::string blah = pname; //pname=""; //Antibtag=tag to constrain b-tag to the anti-btag shape /* RooRealVar bg_p0((std::string("bg_p0_")+pname).c_str(), "bg_p0", 4.2, 0, 200.); RooRealVar bg_p1((std::string("bg_p1_")+pname).c_str(), "bg_p1", 4.5, 0, 300.); RooRealVar bg_p2((std::string("bg_p2_")+pname).c_str(), "bg_p2", 0.000047, 0, 10.1); RooGenericPdf bg_pure = RooGenericPdf((std::string("bg_pure_")+blah).c_str(),"(pow(1-@0/13000,@1)/pow(@0/13000,@2+@3*log(@0/13000)))",RooArgList(x,bg_p0,bg_p1,bg_p2)); */ RooRealVar bg_p0((std::string("bg_p0_")+pname).c_str(), "bg_p0", 0., -1000, 200.); RooRealVar bg_p1((std::string("bg_p1_")+pname).c_str(), "bg_p1", -13, -1000, 1000.); RooRealVar bg_p2((std::string("bg_p2_")+pname).c_str(), "bg_p2", -1.4, -1000, 1000.); bg_p0.setConstant(kTRUE); //RooGenericPdf bg_pure = RooGenericPdf((std::string("bg_pure_")+blah).c_str(),"(pow(@0/13000,@1+@2*log(@0/13000)))",RooArgList(x,bg_p1,bg_p2)); RooGenericPdf bg = RooGenericPdf((std::string("bg_")+blah).c_str(),"(pow(@0/13000,@1+@2*log(@0/13000)))",RooArgList(x,bg_p1,bg_p2)); /*TF1* biasFunc = new TF1("biasFunc","(0.63*x/1000-1.45)",1350,3600); TF1* biasFunc2 = new TF1("biasFunc2","TMath::Min(2.,2.3*x/1000-3.8)",1350,3600); double bias_term_s = 0; if ((imass > 2450 && blah == "antibtag") || (imass > 1640 && blah == "btag")) { if (blah == "antibtag") { bias_term_s = 2.7*biasFunc->Eval(imass); } else { bias_term_s = 2.7*biasFunc2->Eval(imass); } bias_term_s/=nEventsSR; } RooRealVar bias_term((std::string("bias_term_")+blah).c_str(), "bias_term", 0., -bias_term_s, bias_term_s); //bias_term.setConstant(kTRUE); RooAddPdf bg((std::string("bg_")+blah).c_str(), "bg_all", RooArgList(*xf_sig_pdf, bg_pure), bias_term); */ string name_output = "CR_RooFit_Exp"; std::cout<<"Nevents "<<nEventsSR<<std::endl; RooDataHist pred("pred", "Prediction from SB", RooArgList(x), h_SR_Prediction); RooFitResult *r_bg=bg.fitTo(pred, RooFit::Minimizer("Minuit2"), RooFit::Range(SR_lo, SR_hi), RooFit::SumW2Error(kTRUE), RooFit::Save()); //RooFitResult *r_bg=bg.fitTo(pred, RooFit::Range(SR_lo, SR_hi), RooFit::Save()); //RooFitResult *r_bg=bg.fitTo(pred, RooFit::Range(SR_lo, SR_hi), RooFit::Save(),RooFit::SumW2Error(kTRUE)); std::cout<<" --------------------- Building Envelope --------------------- "<<std::endl; //std::cout<< "bg_p0_"<< pname << " param "<<bg_p0.getVal() << " "<<bg_p0.getError()<<std::endl; std::cout<< "bg_p1_"<< pname << " param "<<bg_p1.getVal() << " "<<100*bg_p1.getError()<<std::endl; std::cout<< "bg_p2_"<< pname << " param "<<bg_p2.getVal() << " "<<100*bg_p2.getError()<<std::endl; //std::cout<< "bias_term_"<< blah << " param 0 "<<bias_term_s<<std::endl; RooPlot *aC_plot=x.frame(); pred.plotOn(aC_plot, RooFit::MarkerColor(kPink+2)); if (!plotBands) { bg.plotOn(aC_plot, RooFit::VisualizeError(*r_bg, 2), RooFit::FillColor(kYellow)); bg.plotOn(aC_plot, RooFit::VisualizeError(*r_bg, 1), RooFit::FillColor(kGreen)); } bg.plotOn(aC_plot, RooFit::LineColor(kBlue)); //pred.plotOn(aC_plot, RooFit::LineColor(kBlack), RooFit::MarkerColor(kBlack)); TGraph* error_curve[5]; //correct error bands TGraphAsymmErrors* dataGr = new TGraphAsymmErrors(h_SR_Prediction->GetNbinsX()); //data w/o 0 entries for (int i=2; i!=5; ++i) { error_curve[i] = new TGraph(); } error_curve[2] = (TGraph*)aC_plot->getObject(1)->Clone("errs"); int nPoints = error_curve[2]->GetN(); error_curve[0] = new TGraph(2*nPoints); error_curve[1] = new TGraph(2*nPoints); error_curve[0]->SetFillStyle(1001); error_curve[1]->SetFillStyle(1001); error_curve[0]->SetFillColor(kGreen); error_curve[1]->SetFillColor(kYellow); error_curve[0]->SetLineColor(kGreen); error_curve[1]->SetLineColor(kYellow); if (plotBands) { RooDataHist pred2("pred2", "Prediction from SB", RooArgList(x), h_SR_Prediction2); error_curve[3]->SetFillStyle(1001); error_curve[4]->SetFillStyle(1001); error_curve[3]->SetFillColor(kGreen); error_curve[4]->SetFillColor(kYellow); error_curve[3]->SetLineColor(kGreen); error_curve[4]->SetLineColor(kYellow); error_curve[2]->SetLineColor(kBlue); error_curve[2]->SetLineWidth(3); double binSize = rebin; for (int i=0; i!=nPoints; ++i) { double x0,y0, x1,y1; error_curve[2]->GetPoint(i,x0,y0); RooAbsReal* nlim = new RooRealVar("nlim","y0",y0,-100000,100000); //double lowedge = x0 - (SR_hi - SR_lo)/double(2*nPoints); //double upedge = x0 + (SR_hi - SR_lo)/double(2*nPoints); double lowedge = x0 - binSize/2.; double upedge = x0 + binSize/2.; x.setRange("errRange",lowedge,upedge); RooExtendPdf* epdf = new RooExtendPdf("epdf","extpdf",bg, *nlim,"errRange"); // Construct unbinned likelihood RooAbsReal* nll = epdf->createNLL(pred2,NumCPU(2)); // Minimize likelihood w.r.t all parameters before making plots RooMinimizer* minim = new RooMinimizer(*nll); minim->setMinimizerType("Minuit2"); minim->setStrategy(2); minim->setPrintLevel(-1); minim->migrad(); minim->hesse(); RooFitResult* result = minim->lastMinuitFit(); double errm = nlim->getPropagatedError(*result); //std::cout<<x0<<" "<<lowedge<<" "<<upedge<<" "<<y0<<" "<<nlim->getVal()<<" "<<errm<<std::endl; error_curve[0]->SetPoint(i,x0,(y0-errm)); error_curve[0]->SetPoint(2*nPoints-i-1,x0,y0+errm); error_curve[1]->SetPoint(i,x0,(y0-2*errm)); error_curve[1]->SetPoint(2*nPoints-i-1,x0,(y0+2*errm)); error_curve[3]->SetPoint(i,x0,-errm/sqrt(y0)); error_curve[3]->SetPoint(2*nPoints-i-1,x0,errm/sqrt(y0)); error_curve[4]->SetPoint(i,x0,-2*errm/sqrt(y0)); error_curve[4]->SetPoint(2*nPoints-i-1,x0,2*errm/sqrt(y0)); } int npois = 0; dataGr->SetMarkerSize(1.0); dataGr->SetMarkerStyle (20); const double alpha = 1 - 0.6827; for (int i=0; i!=h_SR_Prediction->GetNbinsX(); ++i){ if (h_SR_Prediction->GetBinContent(i+1) > 0) { int N = h_SR_Prediction->GetBinContent(i+1); double L = (N==0) ? 0 : (ROOT::Math::gamma_quantile(alpha/2,N,1.)); double U = ROOT::Math::gamma_quantile_c(alpha/2,N+1,1) ; dataGr->SetPoint(npois,h_SR_Prediction->GetBinCenter(i+1),h_SR_Prediction->GetBinContent(i+1)); dataGr->SetPointEYlow(npois, N-L); dataGr->SetPointEYhigh(npois, U-N); npois++; } } } double xG[2] = {-10,4000}; double yG[2] = {0.0,0.0}; TGraph* unityG = new TGraph(2, xG, yG); unityG->SetLineColor(kBlue); unityG->SetLineWidth(1); double xPad = 0.3; TCanvas *c_rooFit=new TCanvas("c_rooFit", "c_rooFit", 800*(1.-xPad), 600); c_rooFit->SetFillStyle(4000); c_rooFit->SetFrameFillColor(0); TPad *p_1=new TPad("p_1", "p_1", 0, xPad, 1, 1); p_1->SetFillStyle(4000); p_1->SetFrameFillColor(0); p_1->SetBottomMargin(0.02); TPad* p_2 = new TPad("p_2", "p_2",0,0,1,xPad); p_2->SetBottomMargin((1.-xPad)/xPad*0.13); p_2->SetTopMargin(0.03); p_2->SetFillColor(0); p_2->SetBorderMode(0); p_2->SetBorderSize(2); p_2->SetFrameBorderMode(0); p_2->SetFrameBorderMode(0); p_1->Draw(); p_2->Draw(); p_1->cd(); int nbins = (int) (SR_hi- SR_lo)/rebin; x.setBins(nbins); std::cout << "chi2(data) " << aC_plot->chiSquare()<<std::endl; //std::cout << "p-value: data under hypothesis H0: " << TMath::Prob(chi2_data->getVal(), nbins - 1) << std::endl; aC_plot->GetXaxis()->SetRangeUser(SR_lo, SR_hi); aC_plot->GetXaxis()->SetLabelOffset(0.02); aC_plot->GetYaxis()->SetRangeUser(0.1, 1000.); h_SR_Prediction->GetXaxis()->SetRangeUser(SR_lo, SR_hi); string rebin_ = itoa(rebin); aC_plot->GetXaxis()->SetTitle("M_{Z#gamma} [GeV] "); aC_plot->GetYaxis()->SetTitle(("Events / "+rebin_+" GeV ").c_str()); aC_plot->SetMarkerSize(0.7); aC_plot->GetYaxis()->SetTitleOffset(1.2); aC_plot->Draw(); if (plotBands) { error_curve[1]->Draw("Fsame"); error_curve[0]->Draw("Fsame"); error_curve[2]->Draw("Lsame"); dataGr->Draw("p e1 same"); } aC_plot->SetTitle(""); TPaveText *pave = new TPaveText(0.85,0.4,0.67,0.5,"NDC"); pave->SetBorderSize(0); pave->SetTextSize(0.05); pave->SetTextFont(42); pave->SetLineColor(1); pave->SetLineStyle(1); pave->SetLineWidth(2); pave->SetFillColor(0); pave->SetFillStyle(0); char name[1000]; sprintf(name,"#chi^{2}/n = %.2f",aC_plot->chiSquare()); pave->AddText(name); //pave->Draw(); TLegend *leg = new TLegend(0.88,0.65,0.55,0.90,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetTextSize(0.05); leg->SetTextFont(42); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(2); leg->SetFillColor(0); leg->SetFillStyle(0); h_SR_Prediction->SetMarkerColor(kBlack); h_SR_Prediction->SetLineColor(kBlack); h_SR_Prediction->SetMarkerStyle(20); h_SR_Prediction->SetMarkerSize(1.0); //h_mMMMMa_3Tag_SR->GetXaxis()->SetTitleSize(0.09); if (blind) leg->AddEntry(h_SR_Prediction, "Data: sideband", "ep"); else { if (blah == "antibtag" ) leg->AddEntry(h_SR_Prediction, "Data: anti-b-tag SR", "ep"); else leg->AddEntry(h_SR_Prediction, "Data: b-tag SR", "ep"); } leg->AddEntry(error_curve[2], "Fit model", "l"); leg->AddEntry(error_curve[0], "Fit #pm1#sigma", "f"); leg->AddEntry(error_curve[1], "Fit #pm2#sigma", "f"); leg->Draw(); aC_plot->Draw("axis same"); CMS_lumi( p_1, iPeriod, iPos ); p_2->cd(); RooHist* hpull; hpull = aC_plot->pullHist(); RooPlot* frameP = x.frame() ; frameP->SetTitle(""); frameP->GetXaxis()->SetRangeUser(SR_lo, SR_hi); frameP->addPlotable(hpull,"P"); frameP->GetYaxis()->SetRangeUser(-7,7); frameP->GetYaxis()->SetNdivisions(505); frameP->GetYaxis()->SetTitle("#frac{(data-fit)}{#sigma_{stat}}"); frameP->GetYaxis()->SetTitleSize((1.-xPad)/xPad*0.06); frameP->GetYaxis()->SetTitleOffset(1.0/((1.-xPad)/xPad)); frameP->GetXaxis()->SetTitleSize((1.-xPad)/xPad*0.06); //frameP->GetXaxis()->SetTitleOffset(1.0); frameP->GetXaxis()->SetLabelSize((1.-xPad)/xPad*0.05); frameP->GetYaxis()->SetLabelSize((1.-xPad)/xPad*0.05); frameP->Draw(); if (plotBands) { error_curve[4]->Draw("Fsame"); error_curve[3]->Draw("Fsame"); unityG->Draw("same"); hpull->Draw("psame"); frameP->Draw("axis same"); } c_rooFit->SaveAs((dirName+"/"+name_output+".pdf").c_str()); const int nModels = 9; TString models[nModels] = { "env_pdf_0_13TeV_dijet2", //0 "env_pdf_0_13TeV_exp1", //1 "env_pdf_0_13TeV_expow1", //2 "env_pdf_0_13TeV_expow2", //3 => skip "env_pdf_0_13TeV_pow1", //4 "env_pdf_0_13TeV_lau1", //5 "env_pdf_0_13TeV_atlas1", //6 "env_pdf_0_13TeV_atlas2", //7 => skip "env_pdf_0_13TeV_vvdijet1" //8 }; int nPars[nModels] = { 2, 1, 2, 3, 1, 1, 2, 3, 2 }; TString parNames[nModels][3] = { "env_pdf_0_13TeV_dijet2_log1","env_pdf_0_13TeV_dijet2_log2","", "env_pdf_0_13TeV_exp1_p1","","", "env_pdf_0_13TeV_expow1_exp1","env_pdf_0_13TeV_expow1_pow1","", "env_pdf_0_13TeV_expow2_exp1","env_pdf_0_13TeV_expow2_pow1","env_pdf_0_13TeV_expow2_exp2", "env_pdf_0_13TeV_pow1_p1","","", "env_pdf_0_13TeV_lau1_l1","","", "env_pdf_0_13TeV_atlas1_coeff1","env_pdf_0_13TeV_atlas1_log1","", "env_pdf_0_13TeV_atlas2_coeff1","env_pdf_0_13TeV_atlas2_log1","env_pdf_0_13TeV_atlas2_log2", "env_pdf_0_13TeV_vvdijet1_coeff1","env_pdf_0_13TeV_vvdijet1_log1","" } if(bias){ //alternative model gSystem->Load("libHiggsAnalysisCombinedLimit"); gSystem->Load("libdiphotonsUtils"); TFile *f = new TFile("antibtag_multipdf.root"); RooWorkspace* xf = (RooWorkspace*)f->Get("wtemplates"); RooWorkspace *w_alt=new RooWorkspace("Vg"); for(int i=model_number; i<=model_number; i++){ RooMultiPdf *alternative = (RooMultiPdf *)xf->pdf("model_bkg_AntiBtag"); std::cout<<"Number of pdfs "<<alternative->getNumPdfs()<<std::endl; for (int j=0; j!=alternative->getNumPdfs(); ++j){ std::cout<<alternative->getPdf(j)->GetName()<<std::endl; } RooAbsPdf *alt_bg = alternative->getPdf(alternative->getCurrentIndex()+i);//->clone(); w_alt->import(*alt_bg, RooFit::RenameVariable(alt_bg->GetName(),("alt_bg_"+blah).c_str())); w_alt->Print("V"); std::cerr<<w_alt->var("x")<<std::endl; RooRealVar * range_ = w_alt->var("x"); range_->setRange(SR_lo,SR_hi); char* asd = ("alt_bg_"+blah).c_str() ; w_alt->import(nBackground2); std::cout<<alt_bg->getVal() <<std::endl; w_alt->pdf(asd)->fitTo(pred, RooFit::Minimizer("Minuit2"), RooFit::Range(SR_lo, SR_hi), RooFit::SumW2Error(kTRUE), RooFit::Save()); RooArgSet* altVars = w_alt->pdf(asd)->getVariables(); TIterator *it2 = altVars->createIterator(); RooRealVar* varAlt = (RooRealVar*)it2->Next(); while (varAlt) { varAlt->setConstant(kTRUE); varAlt = (RooRealVar*)it2->Next(); } alt_bg->plotOn(aC_plot, RooFit::LineColor(i+1), RooFit::LineStyle(i+2)); p_1->cd(); aC_plot->GetYaxis()->SetRangeUser(0.01, maxdata*50.); aC_plot->Draw("same"); TH1F *h=new TH1F(); h->SetLineColor(1+i); h->SetLineStyle(i+2); leg->AddEntry(h, alt_bg->GetName(), "l"); w_alt->SaveAs((dirName+"/w_background_alternative.root").c_str()); } leg->Draw(); p_1->SetLogy(); c_rooFit->Update(); c_rooFit->SaveAs((dirName+"/"+name_output+blah+"_multipdf.pdf").c_str()); for (int i=0; i!=nPars[model_number]; ++i) { std::cout<<parNames[model_number][i]<<" param "<< w_alt->var(parNames[model_number][i])->getVal()<<" "<<w_alt->var(parNames[model_number][i])->getError()<<std::endl; } } else { p_1->SetLogy(); c_rooFit->Update(); c_rooFit->SaveAs((dirName+"/"+name_output+"_log.pdf").c_str()); } RooWorkspace *w=new RooWorkspace("Vg"); w->import(bg); w->import(nBackground); w->SaveAs((dirName+"/w_background_GaussExp.root").c_str()); TH1F *h_mX_SR_fakeData=(TH1F*)h_mX_SR->Clone("h_mX_SR_fakeData"); h_mX_SR_fakeData->Scale(nEventsSR/h_mX_SR_fakeData->GetSumOfWeights()); RooDataHist data_obs("data_obs", "Data", RooArgList(x), h_mX_SR_fakeData); std::cout<<" Background number of events = "<<nEventsSR<<std::endl; RooWorkspace *w_data=new RooWorkspace("Vg"); w_data->import(data_obs); w_data->SaveAs((dirName+"/w_data.root").c_str()); }
//************************************************************* void arrangeCanvas(TCanvas *canv,TH1F* meanplots[100],TH1F* widthplots[100],Int_t nFiles, TString LegLabels[10], bool onlyBias){ //************************************************************* TPaveText *ali = new TPaveText(0.18,0.87,0.50,0.93,"NDC"); ali->SetFillColor(10); ali->SetTextColor(1); ali->SetTextFont(42); ali->SetMargin(0.); ali->SetLineColor(10); ali->SetShadowColor(10); // pt->SetTextAlign(11); TText *alitext = ali->AddText("Alignment: PCL"); //"Preliminary 2015 - 0T collision data"); alitext->SetTextSize(0.04); TLegend *lego = new TLegend(0.18,0.80,0.78,0.92); lego-> SetNColumns(2); //TLegend *lego = new TLegend(0.18,0.77,0.50,0.86); lego->SetFillColor(10); lego->SetTextSize(0.04); lego->SetTextFont(42); lego->SetFillColor(10); lego->SetLineColor(10); lego->SetShadowColor(10); TPaveText *pt = NULL; TPaveText *pt2 = NULL; TPaveText *pt3 = NULL; if(!onlyBias){ pt =new TPaveText(0.179,0.955,0.260,0.985,"NDC"); } else { pt =new TPaveText(0.179,0.955,0.260,0.985,"NDC"); } pt->SetFillColor(10); pt->SetTextColor(1); pt->SetTextFont(61); // pt->SetTextAlign(11); TText *text1 = pt->AddText("CMS"); //"Preliminary 2015 - 0T collision data"); text1->SetTextSize(0.05); float extraOverCmsTextSize = 0.76; if(!onlyBias){ pt2 =new TPaveText(0.3,0.95,0.503,0.98,"NDC"); } else { pt2 =new TPaveText(0.3,0.95,0.503,0.98,"NDC"); } pt2->SetFillColor(10); pt2->SetTextColor(1); pt2->SetTextFont(52); pt2->SetTextAlign(22); TText *text2 = pt2->AddText("work in progress"); text2->SetTextSize(0.05*extraOverCmsTextSize); if(!onlyBias){ pt3 =new TPaveText(0.6,0.95,0.98,0.98,"NDC"); } else { pt3 =new TPaveText(0.6,0.95,0.98,0.98,"NDC"); } pt3->SetFillColor(10); pt3->SetTextColor(1); pt3->SetTextFont(42); // pt2->SetTextAlign(11); TText *text3 = pt3->AddText("3.8T collision data 2015"); text3->SetTextSize(0.05*extraOverCmsTextSize); canv->SetFillColor(10); if(!onlyBias) { canv->Divide(2,1); canv->cd(1)->SetBottomMargin(0.12); canv->cd(1)->SetLeftMargin(0.17); canv->cd(1)->SetRightMargin(0.02); canv->cd(1)->SetTopMargin(0.06); canv->cd(2)->SetBottomMargin(0.12); canv->cd(2)->SetLeftMargin(0.17); canv->cd(2)->SetRightMargin(0.02); canv->cd(2)->SetTopMargin(0.06); canv->cd(1); } else { canv->cd()->SetBottomMargin(0.14); canv->cd()->SetLeftMargin(0.17); canv->cd()->SetRightMargin(0.02); canv->cd()->SetTopMargin(0.06); canv->cd(); } Double_t absmin(999.); Double_t absmax(-999.); for(Int_t i=0; i<nFiles; i++){ if(meanplots[i]->GetMaximum()>absmax) absmax = meanplots[i]->GetMaximum(); if(meanplots[i]->GetMinimum()<absmin) absmin = meanplots[i]->GetMinimum(); } Double_t safeDelta=(absmax-absmin)/2.; Double_t theExtreme=std::max(absmax,TMath::Abs(absmin)); for(Int_t i=0; i<nFiles; i++){ TString myTitle = meanplots[i]->GetName(); float axmin = -999; float axmax = 999.; int ndiv = 510; if(myTitle.Contains("eta")){ axmin = -2.5; axmax = 2.5; ndiv = 505; } else if (myTitle.Contains("phi")){ axmin = -TMath::Pi(); axmax = TMath::Pi(); ndiv = 510; } else { std::cout<<"unrecongnized variable"; } meanplots[i]->GetXaxis()->SetLabelOffset(999); meanplots[i]->GetXaxis()->SetTickLength(0); // Redraw the new axis gPad->Update(); TGaxis *newaxis = new TGaxis(gPad->GetUxmin(),gPad->GetUymin(), gPad->GetUxmax(),gPad->GetUymin(), axmin, axmax, //meanplots[i]->GetXaxis()->GetXmin(), //meanplots[i]->GetXaxis()->GetXmax(), ndiv,"SDH"); TGaxis *newaxisup = new TGaxis(gPad->GetUxmin(),gPad->GetUymax(), gPad->GetUxmax(),gPad->GetUymax(), axmin, axmax, //meanplots[i]->GetXaxis()->GetXmin(), //meanplots[i]->GetXaxis()->GetXmax(), ndiv,"-SDH"); newaxis->SetLabelOffset(0.02); newaxis->SetLabelFont(42); newaxis->SetLabelSize(.05); newaxis->Draw(); newaxisup->SetLabelOffset(-0.02); newaxisup->SetLabelFont(42); newaxisup->SetLabelSize(0); newaxisup->Draw(); if(i==0){ //meanplots[i]->GetYaxis()->SetRangeUser(absmin-safeDelta/2.,absmax+safeDelta); std::cout<<"name is: "<< meanplots[i]->GetName() << " absmin:" <<absmin<<" absmax: "<<absmax<<" safeDelta: "<<safeDelta<<std::endl; TString theTitle = meanplots[i]->GetName(); if( theTitle.Contains("Norm")){ meanplots[i]->GetYaxis()->SetRangeUser(std::min(-0.48,absmin-safeDelta),std::max(0.48,absmax+safeDelta)); } else { if(!onlyBias){ meanplots[i]->GetYaxis()->SetRangeUser(absmin-safeDelta,absmax+safeDelta); } else { meanplots[i]->GetYaxis()->SetRangeUser(-theExtreme-(TMath::Abs(absmin)/10.),theExtreme+(TMath::Abs(absmax/10.))); } //meanplots[i]->GetYaxis()->SetRangeUser(-theExtreme,theExtreme); } meanplots[i]->Draw("e1"); if(onlyBias){ Int_t nbins = meanplots[i]->GetNbinsX(); Double_t lowedge = meanplots[i]->GetBinLowEdge(1); Double_t highedge = meanplots[i]->GetBinLowEdge(nbins+1); TH1F* hzero = DrawZero(meanplots[i],nbins,lowedge,highedge); hzero->Draw("PLsame"); } } else meanplots[i]->Draw("e1sames"); lego->AddEntry(meanplots[i],LegLabels[i]); } //ali->Draw(); lego->Draw(); pt->Draw("same"); pt2->Draw("same"); pt3->Draw("same"); if(!onlyBias){ canv->cd(2); Double_t absmax2(-999.); for(Int_t i=0; i<nFiles; i++){ if(widthplots[i]->GetMaximum()>absmax2) absmax2 = widthplots[i]->GetMaximum(); } Double_t safeDelta2=absmax2/3.; for(Int_t i=0; i<nFiles; i++){ TString myTitle = widthplots[i]->GetName(); float axmin = -999; float axmax = 999.; int ndiv = 510; if(myTitle.Contains("eta")){ axmin = -2.5; axmax = 2.5; ndiv = 505; } else if (myTitle.Contains("phi")){ axmin = -TMath::Pi(); axmax = TMath::Pi(); ndiv = 510; } else { std::cout<<"unrecongnized variable"; } widthplots[i]->GetXaxis()->SetLabelOffset(999); widthplots[i]->GetXaxis()->SetTickLength(0); // Redraw the new axis gPad->Update(); TGaxis *newaxis2 = new TGaxis(gPad->GetUxmin(),gPad->GetUymin(), gPad->GetUxmax(),gPad->GetUymin(), axmin, axmax, //widthplots[i]->GetXaxis()->GetXmin(), //widthplots[i]->GetXaxis()->GetXmax(), ndiv,"SDH"); newaxis2->SetLabelOffset(0.02); newaxis2->SetLabelFont(42); newaxis2->SetLabelSize(.05); newaxis2->Draw(); TGaxis *newaxis2up = new TGaxis(gPad->GetUxmin(),gPad->GetUymax(), gPad->GetUxmax(),gPad->GetUymax(), axmin, axmax, //widthplots[i]->GetXaxis()->GetXmin(), //widthplots[i]->GetXaxis()->GetXmax(), ndiv,"-SDH"); newaxis2up->SetLabelOffset(-0.02); newaxis2up->SetLabelFont(42); newaxis2up->SetLabelSize(0.); newaxis2up->Draw(); if(i==0) widthplots[i]->Draw("e1"); else widthplots[i]->Draw("e1sames"); widthplots[i]->SetMinimum(0.5); widthplots[i]->SetMaximum(absmax2+safeDelta2); } lego->Draw(); pt->Draw("same"); pt2->Draw("same"); pt3->Draw("same"); } }
void drawMeasurement(int i, double m[5], char label[2][100], int aux[5], double vstep, TH2F* histo, TCanvas* canvas) { double lowY = (i+1)*vstep; double uppY = (i+2)*vstep; //double lowX = histo->GetBinLowEdge(1); //double uppX = histo->GetBinLowEdge(histo->GetNbinsX()) + // histo->GetBinWidth(histo->GetNbinsX()); double lowX = 0.25; double uppX = 2.80; double widthX = uppX - lowX; // y-range of the histogram is [0...1] double startX = lowX + 0.04*widthX; TPaveText* text = new TPaveText(startX, lowY, startX, uppY, "BR"); text->SetTextAlign(12); text->SetFillColor(aux[1]); text->SetTextColor(aux[0]); text->SetLineColor(1); text->SetBorderSize(0); TText* t0 = text->AddText(" "); t0->SetTextSize(0.08); t0->SetTextFont(aux[2]); TText* t1 = text->AddText(label[0]); t1->SetTextSize(0.08); t1->SetTextFont(aux[2]); TText* t2 = text->AddText(label[1]); t2->SetTextSize(0.08); t2->SetTextFont(aux[2]); text->Draw(); double ypos = 0.5*(lowY+uppY); double mean = m[0]; double nErr1 = m[1]; double pErr1 = m[2]; double nErr2 = sqrt(m[1]*m[1]+m[3]*m[3]); double pErr2 = sqrt(m[2]*m[2]+m[4]*m[4]); // draw TGraphAsymmErrors 1 (stat only) |---*---| TMarker* measurement = new TMarker(mean, ypos, aux[4]); measurement->SetMarkerColor(aux[0]); measurement->SetMarkerStyle(aux[4]); measurement->SetMarkerSize(1.5); //measurement->SetMarkerSize(1.75); measurement->Draw(); double vsizeErr1 = 0.09*vstep; TLine* l1 = new TLine(mean, ypos, mean-nErr1, ypos); l1->SetLineWidth(aux[3]); l1->SetLineColor(aux[0]); l1->Draw(); TLine* l2 = new TLine(mean, ypos, mean+pErr1, ypos); l2->SetLineWidth(aux[3]); l2->SetLineColor(aux[0]); l2->Draw(); TLine* l3 = new TLine(mean-nErr1, ypos-vsizeErr1, mean-nErr1, ypos+vsizeErr1); l3->SetLineWidth(aux[3]); l3->SetLineColor(aux[0]); l3->Draw(); TLine* l4 = new TLine(mean+pErr1, ypos-vsizeErr1, mean+pErr1, ypos+vsizeErr1); l4->SetLineWidth(aux[3]); l4->SetLineColor(aux[0]); l4->Draw(); // overlay TGraphAsymmErrors 2 (stat+syst) |----*-----| double vsizeErr2 = 0.12*vstep; TLine* l5 = new TLine(mean, ypos, mean-nErr2, ypos); l5->SetLineWidth(aux[3]); l5->SetLineColor(aux[0]); l5->Draw(); TLine* l6 = new TLine(mean, ypos, mean+pErr2, ypos); l6->SetLineWidth(aux[3]); l6->SetLineColor(aux[0]); l6->Draw(); TLine* l7 = new TLine(mean-nErr2, ypos-vsizeErr2, mean-nErr2, ypos+vsizeErr2); l7->SetLineWidth(aux[3]); l7->SetLineColor(aux[0]); l7->Draw(); TLine* l8 = new TLine(mean+pErr2, ypos-vsizeErr2, mean+pErr2, ypos+vsizeErr2); l8->SetLineWidth(aux[3]); l8->SetLineColor(aux[0]); l8->Draw(); // draw measurement label "XXX+/-YY+/-ZZ" TPaveText* num = new TPaveText(uppX-0.32*widthX, lowY, uppX-0.02*widthX, uppY, "BR"); num->SetTextAlign(12); num->SetFillColor(aux[1]); num->SetTextColor(aux[0]); num->SetLineColor(aux[0]); num->SetBorderSize(0); TString str; char s[100]; sprintf(s, "%4.2f#color[%d]{X}", m[0], aux[1]); str +=s; if (m[1]==m[2]) { // sym. stat. errors sprintf(s, "#pm %4.2f", m[1]); str +=s; } else { sprintf(s, "^{+%4.2f}", m[2]); str +=s; sprintf(s, "_{-#color[%d]{|}%4.2f}", aux[1], m[1]); str +=s; } str += " (stat)"; if (m[3]!=0.0 || m[4]!=0.0) { if (m[3]==m[4]) { // sym. syst. errors sprintf(s, "#color[%d]{X}#pm% 4.2f", aux[1], m[3]); str +=s; } else { sprintf(s, "#color[%d]{X}", aux[1]); str +=s; sprintf(s, "^{+%4.2f}", m[4]); str +=s; sprintf(s, "_{-#color[%d]{|}%4.2f}", aux[1], m[3]); str +=s; } } str += " (syst)"; TText* n0 = num->AddText(str); n0->SetTextFont(aux[2]); num->Draw(); return; }
// main method void LEDRef_evtdis(const int runno = 615, const int gainv = 0, /*0=low, 1=high*/ const int evtnum= -10, int ymax=1023, // set the scale of plots const int delay = 1) // -1=no delay, wait for input, X>=0 => sleep aprox. X sec. after making plot { // set ranges to plot const int strip_f = 0; // first const int strip_l = NSTRIPS - 1; const int nsamples = 65; // number of ADC time samples per channel and event const int saveplot = 0; const int numbering = 1; // 0: no numbering, 1: nubering on each plot const int dofit = 0; // 0: no fit, 1: try to fit the spectra const int debug = 0; const float gammaN = 2; // end of setup // Assume we are just interested in the 1st segment, _0.root below for fname* Char_t fname[256]; sprintf(fname, "/local/data/Run_%09d.Seq_1A.Stream_0.root",runno); cout << "TOTCHAN " << TOTCHAN << endl; // set up a raw reader of the data AliRawReader *rawReader = NULL; rawReader = new AliRawReaderRoot(fname); AliCaloRawStream *in = NULL; in = new AliCaloRawStream(rawReader,"EMCAL"); // set up histograms TH1F *hfit[TOTCHAN]; TF1 *f1[TOTCHAN]; char ch_label[TOTCHAN][100]; char buff1[100]; char name[80]; for(int i=0; i<TOTCHAN; i++) { sprintf(buff1,"hfit_%d",i); hfit[i] = new TH1F(buff1,"hfit", nsamples , -0.5, nsamples - 0.5); hfit[i]->SetDirectory(0); sprintf(name,"f1_%d",i); f1[i] = new TF1(name,fitfun,0,70,5); f1[i]->SetLineWidth(2); f1[i]->SetLineColor(2); // int idx = istrip + NSTRIPS * gain; // encoding used later int gain = i / (NSTRIPS); int istrip = i % NSTRIPS; sprintf(ch_label[i], "Strip%02d", istrip); } TCanvas *cc1 = new TCanvas("cc1","3 columns of 8 strips each",600,800); int numcol = NSETS; int numrow = NSTRIPS_IN_SET; cc1->Divide(numcol, numrow); TText *t = new TText; t->SetTextSize(0.17); int clr[2] = {4,2}; // colors // figure out which events we should look at int firstevent = evtnum; int lastevent = evtnum; if (evtnum < 0) { // get a bunch of events firstevent = 0; lastevent = - evtnum; } if (evtnum == 0) { // get all events firstevent = 0; lastevent = 1000000; } Int_t iev =0; AliRawEventHeaderBase *aliHeader=NULL; while ( rawReader->NextEvent() && iev < firstevent) { aliHeader = (AliRawEventHeaderBase*) rawReader->GetEventHeader(); iev++; } // loop over selected events while ( rawReader->NextEvent() && iev <= lastevent) { aliHeader = (AliRawEventHeaderBase*) rawReader->GetEventHeader(); int runNumber = aliHeader->Get("RunNb"); cout << "Found run number " << runNumber << endl; // reset histograms for(int i=0; i<TOTCHAN; i++) { hfit[i]->Reset(); } // get events (the "1" ensures that we actually select all events for now) if ( 1 || aliHeader->Get("Type") == AliRawEventHeaderBase::kPhysicsEvent ) { const UInt_t * evtId = aliHeader->GetP("Id"); int evno_raw = (int) evtId[0]; int timestamp = aliHeader->Get("Timestamp"); cout << " evno " << evno_raw << " size " << aliHeader->GetEventSize() << " type " << aliHeader->Get("Type") << " type name " << aliHeader->GetTypeName() << " timestamp " << timestamp << endl; /// process_event stream while ( in->Next() ) { int strip = in->GetColumn(); int gain = in->GetRow(); if (in->IsLEDMonData()) { int idx = strip + NSTRIPS*gain; //cout << "hist idx " << idx << endl; if (idx < 0 || idx > TOTCHAN) { cout << "Hist idx out of range: " << idx << endl; } else { // reasonable range of idx hfit[idx]->SetBinContent(in->GetTime(), in->GetSignal()); } } // LED Ref data only } // Raw data read // Next: let's actually plot the data.. for (Int_t strip = strip_f; strip <= strip_l; strip++) { int idx = strip + NSTRIPS*gainv; // which set/column does the strip belong in int iset = strip / NSTRIPS_IN_SET; int within_set = strip % NSTRIPS_IN_SET; // on which pad should we plot it? int pad_id = (NSTRIPS_IN_SET-1-within_set)*NSETS + iset + 1; cout << "strip " << strip << ". set="<< iset << ", within_set=" << within_set << ", pad=" << pad_id << endl; cc1->cd(pad_id); hfit[idx]->SetTitle(""); hfit[idx]->SetFillColor(5); hfit[idx]->SetMaximum(ymax); hfit[idx]->SetMinimum(0); // we may or may not decide to fit the data if (dofit) { f1[i]->SetParameter(0, 0); // initial guess; zero amplitude :=) hfit[idx]->Fit(f1[i]); } hfit[idx]->Draw(); if( numbering ) { t->SetTextColor(clr[gainv]); t->DrawTextNDC(0.65,0.65,ch_label[idx]); } } // add some extra text on the canvas // print a box showing run #, evt #, and timestamp cc1->cd(); // first draw transparent pad TPad *trans = new TPad("trans","",0,0,1,1); trans->SetFillStyle(4000); trans->Draw(); trans->cd(); // then draw text TPaveText *label = new TPaveText(.2,.11,.8,.14,"NDC"); // label->Clear(); label->SetBorderSize(1); label->SetFillColor(0); label->SetLineColor(clr[gainv]); label->SetTextColor(clr[gainv]); //label->SetFillStyle(0); TDatime d; d.Set(timestamp); sprintf(name,"Run %d, Event %d, Hist Max %d, %s",runno,iev,ymax,d.AsString()); label->AddText(name); label->Draw(); cc1->Update(); cout << "Done" << endl; // some shenanigans to hold the plotting, if requested if (firstevent != lastevent) { if (delay == -1) { // wait for character input before proceeding cout << " enter y to proceed " << endl; char dummy[2]; cin >> dummy; cout << " read " << dummy << endl; if (strcmp(dummy, "y")==0) { cout << " ok, continuing with event " << iev+1 << endl; } else { cout << " ok, exiting " << endl; //exit(1); } } else { cout << "Sleeping for " << delay * 500 << endl; gSystem->Sleep(delay * 500); } } // save plot, if setup/requested to do so char plotname[100]; if (saveplot==1) { sprintf(plotname,"Run_%d_LEDRef_Ev%d_Gain%d_MaxHist%d.gif", runno,iev,gainv,ymax); cout <<"SAVING plot:"<< plotname << endl; cc1->SaveAs(plotname); } } // event selection
void MakeClosurePlot(TH1D* hObs, TH1D* hPred, TString name, bool logy=true) { set_style(hObs,"data_obs"); set_style(hPred,"pred"); // Setup canvas and pads TCanvas * c1 = new TCanvas("c1", "c1", 700, 700); c1->SetFillStyle(4000); TPad * pad1 = new TPad("pad1", "top pad" , 0.0, 0.3, 1.0, 1.0); pad1->SetFillStyle(4000); pad1->SetBottomMargin(0.0); pad1->Draw(); TPad * pad2 = new TPad("pad2", "bottom pad", 0.0, 0.0, 1.0, 0.3); pad2->SetFillStyle(4000); pad2->SetTopMargin(0.0); pad2->SetBottomMargin(0.35); pad2->Draw(); pad1->cd(); pad1->SetLogy(logy); TH1D * staterr = (TH1D *) hPred->Clone("staterr"); // staterr->Sumw2(); //staterr->SetFillColor(kRed); staterr->SetFillColor(kGray+3); staterr->SetMarkerSize(0); staterr->SetFillStyle(3013); //cout << "Compute ratio hist..." << endl; TH1D * ratio = (TH1D *) hPred->Clone("ratio"); //ratio->Sumw2(); ratio->SetMarkerSize(0.8); ratio->SetMarkerColor(1); //ratio->SetMarkerSize(0.5); ratio->Divide(hObs, hPred, 1., 1., "B"); ratio->Print("all"); TH1D * ratiostaterr = (TH1D *) hObs->Clone("ratiostaterr"); // ratiostaterr->Sumw2(); ratiostaterr->SetStats(0); ratiostaterr->SetTitle(hPred->GetTitle()); ratiostaterr->GetYaxis()->SetTitle("Obs/Pred."); ratiostaterr->SetMaximum(2.2); ratiostaterr->SetMinimum(0); ratiostaterr->SetMarkerSize(0); //ratiostaterr->SetFillColor(kRed); ratiostaterr->SetFillColor(kGray+3); ratiostaterr->SetFillStyle(3013); ratiostaterr->GetXaxis()->SetLabelSize(0.2); ratiostaterr->GetXaxis()->SetLabelOffset(0.03); ratiostaterr->GetXaxis()->SetTitleSize(0.14); ratiostaterr->GetXaxis()->SetTitleOffset(1.10); ratiostaterr->GetYaxis()->SetLabelSize(0.10); ratiostaterr->GetYaxis()->SetTitleSize(0.12); ratiostaterr->GetYaxis()->SetTitleOffset(0.6); ratiostaterr->GetYaxis()->SetNdivisions(505); TLine* ratiounity = new TLine(hPred->GetBinLowEdge(1),1,hPred->GetBinLowEdge(hPred->GetNbinsX()+1),1); ratiounity->SetLineStyle(2); for (Int_t i = 0; i < hPred->GetNbinsX()+2; i++) { // if (hObs->GetBinContent(i)>0.) ratio->SetBinError(i, hObs->GetBinError(i)/hObs->GetBinContent(i)); // just the fractional uncertainty on the observation ratiostaterr->SetBinContent(i, 1.0); if (hPred->GetBinContent(i) > 1e-6) { //< not empty double binerror = hPred->GetBinError(i) / hPred->GetBinContent(i); ratiostaterr->SetBinError(i, binerror); } else { ratiostaterr->SetBinError(i, 999.); } } TH1D * ratiosysterr = (TH1D *) ratiostaterr->Clone("ratiosysterr"); // ratiosysterr->Sumw2(); ratiosysterr->SetMarkerSize(0); ratiosysterr->SetFillColor(kYellow-4); //ratiosysterr->SetFillStyle(3002); ratiosysterr->SetFillStyle(1001); for (Int_t i = 0; i < hPred->GetNbinsX()+2; i++) { if (hPred->GetBinContent(i) > 1e-6) { //< not empty double binerror2 = (pow(hPred->GetBinError(i), 2)); double binerror = sqrt(binerror2); ratiosysterr->SetBinError(i, binerror / hPred->GetBinContent(i)); } } double max = hObs->GetMaximum(); if (hPred->GetMaximum() > max) max = hPred->GetMaximum(); if (logy) { hPred->SetMaximum(max*10); hPred->SetMinimum(0.09); } else { hPred->SetMaximum(max*1.5); hPred->SetMinimum(0.); } hPred->GetYaxis()->SetTitle("Events / bin"); hPred->Draw("hist"); hObs->Draw("e1,same"); staterr->Draw("e2 same"); hPred->GetXaxis()->SetTitleSize(0.035); hPred->GetXaxis()->SetLabelSize(0.035); /* hObs->GetYaxis()->SetTitleSize(0.035); */ /* hObs->GetYaxis()->SetLabelSize(0.035); */ TLegend * leg2 = new TLegend(0.72, 0.68, 0.94, 0.92); set_style(leg2,0.035); leg2->AddEntry(hObs,"Obs.","elp"); leg2->AddEntry(hPred,"Pred.","f"); leg2->AddEntry(staterr, "Syst. uncert.", "f"); leg2->Draw(); TLatex * latex = new TLatex(); latex->SetNDC(); latex->SetTextAlign(12); latex->SetTextFont(62); latex->SetTextSize(0.042); latex->DrawLatex(0.19, 0.89, "CMS Simulation"); latex->SetTextSize(0.03); TString stamp = Form("#sqrt{s} = 13 TeV, L = %3.1f fb^{-1}", int_lumi); latex->DrawLatex(0.19, 0.84, stamp); pad2->cd(); pad2->SetGridy(0); ratiostaterr->GetXaxis()->SetRangeUser(0,6); ratiostaterr->Draw("e2"); //ratiosysterr->Draw("e2 same"); ratiostaterr->Draw("e2 same"); ratiounity->Draw(); ratio->Draw("e1 same"); TPaveText * pave = new TPaveText(0.18, 0.86, 0.4, 0.96, "brNDC"); pave->SetLineColor(0); pave->SetFillColor(kWhite); pave->SetShadowColor(0); pave->SetBorderSize(1); double nchisq = hObs->Chi2Test(hPred, "UWCHI2/NDF, P"); // MC uncert. (stat) double p_value = hObs->Chi2Test(hPred, "UW"); // MC uncert. (stat) // //double kolprob = hdata_obs->KolmogorovTest(hmc_pred); // MC uncert. (stat) TText * text = pave->AddText(Form("#chi_{#nu}^{2}/ndf = %.3f, p = %.3f", nchisq, p_value)); // //TText * text = pave->AddText(Form("#chi_{#nu}^{2} = %.3f, K_{s} = %.3f", nchisq, kolprob)); text->SetTextFont(62); text->SetTextSize(0.07); // text->SetTextSize(0.06); pave->Draw(); /* TLegend * ratioleg = new TLegend(0.72, 0.88, 0.94, 0.96); */ /* set_style(ratioleg); */ /* ratioleg->SetTextSize(0.07); */ /* ratioleg->AddEntry(ratiostaterr, "MC uncert. (stat)", "f"); */ /* ratioleg->Draw(); */ pad1->cd(); gPad->RedrawAxis(); gPad->Modified(); gPad->Update(); pad2->cd(); gPad->RedrawAxis(); gPad->Modified(); gPad->Update(); c1->cd(); c1->Print("Closure/plots/no_dp_cut/"+name+".pdf"); delete staterr; delete ratio; delete ratiostaterr; delete ratiosysterr; delete leg2; // delete ratioleg; delete pad1; delete pad2; delete c1; delete latex; }
plot() { //=========Macro generated from canvas: FigExample/FigExample //========= (Thu Feb 11 11:37:59 2016) by ROOT version5.34/32 TCanvas *FigExample = new TCanvas("FigExample", "FigExample",1,23,1364,719); gStyle->SetOptFit(1); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); FigExample->Range(-1158.419,-0.195,8561.764,1.43); FigExample->SetFillColor(0); FigExample->SetBorderMode(0); FigExample->SetBorderSize(2); FigExample->SetLeftMargin(0.12); FigExample->SetRightMargin(0.04); FigExample->SetTopMargin(0.08); FigExample->SetBottomMargin(0.12); FigExample->SetFrameFillStyle(0); FigExample->SetFrameBorderMode(0); FigExample->SetFrameFillStyle(0); FigExample->SetFrameBorderMode(0); TGraphErrors *gre = new TGraphErrors(11); gre->SetName("Graph1"); gre->SetTitle(""); gre->SetFillColor(1); gre->SetLineColor(4); gre->SetMarkerColor(4); gre->SetMarkerStyle(22); gre->SetMarkerSize(1.5); gre->SetPoint(0,8.892308,0.97914); gre->SetPointError(0,0,0.00119056); gre->SetPoint(1,10.38462,0.973453); gre->SetPointError(1,0,0.00225169); gre->SetPoint(2,23.53846,0.980456); gre->SetPointError(2,0,0.00126418); gre->SetPoint(3,43.84615,0.97976); gre->SetPointError(3,0,0.001007); gre->SetPoint(4,120.3077,0.971649); gre->SetPointError(4,0,0.000816721); gre->SetPoint(5,164.6154,0.970778); gre->SetPointError(5,0,0.000914539); gre->SetPoint(6,389.2308,0.953326); gre->SetPointError(6,0,0.00131593); gre->SetPoint(7,753.8462,0.942877); gre->SetPointError(7,0,0.0019686); gre->SetPoint(8,1266.154,0.914665); gre->SetPointError(8,0,0.00283506); gre->SetPoint(9,3400,0.867066); gre->SetPointError(9,0,0.00370407); gre->SetPoint(10,7430.769,0.807229); gre->SetPointError(10,0,0.0060241); TH1F *Graph_Graph_Graph_Graph11611 = new TH1F("Graph_Graph_Graph_Graph11611","",100,8.003077,8172.957); Graph_Graph_Graph_Graph11611->SetMinimum(0); Graph_Graph_Graph_Graph11611->SetMaximum(1.3); Graph_Graph_Graph_Graph11611->SetDirectory(0); Graph_Graph_Graph_Graph11611->SetStats(0); Int_t ci; // for color index setting TColor *color; // for color definition with alpha ci = TColor::GetColor("#000099"); Graph_Graph_Graph_Graph11611->SetLineColor(ci); Graph_Graph_Graph_Graph11611->SetLineStyle(0); Graph_Graph_Graph_Graph11611->SetMarkerStyle(20); Graph_Graph_Graph_Graph11611->GetXaxis()->SetTitle("Average rate ( N_{#mu}.s^{-1}.cm^{-2} )"); Graph_Graph_Graph_Graph11611->GetXaxis()->CenterTitle(true); Graph_Graph_Graph_Graph11611->GetXaxis()->SetLabelFont(42); Graph_Graph_Graph_Graph11611->GetXaxis()->SetLabelOffset(0.01); Graph_Graph_Graph_Graph11611->GetXaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph11611->GetXaxis()->SetTitleSize(0.05); Graph_Graph_Graph_Graph11611->GetXaxis()->SetTitleOffset(1.1); Graph_Graph_Graph_Graph11611->GetXaxis()->SetTitleFont(42); Graph_Graph_Graph_Graph11611->GetYaxis()->SetTitle("#mu detection efficiency"); Graph_Graph_Graph_Graph11611->GetYaxis()->CenterTitle(true); Graph_Graph_Graph_Graph11611->GetYaxis()->SetLabelFont(42); Graph_Graph_Graph_Graph11611->GetYaxis()->SetLabelOffset(0.007); Graph_Graph_Graph_Graph11611->GetYaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph11611->GetYaxis()->SetTitleSize(0.05); Graph_Graph_Graph_Graph11611->GetYaxis()->SetTitleOffset(0.9); Graph_Graph_Graph_Graph11611->GetYaxis()->SetTitleFont(42); Graph_Graph_Graph_Graph11611->GetZaxis()->SetLabelFont(42); Graph_Graph_Graph_Graph11611->GetZaxis()->SetLabelOffset(0.007); Graph_Graph_Graph_Graph11611->GetZaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph11611->GetZaxis()->SetTitleSize(0.06); Graph_Graph_Graph_Graph11611->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph_Graph_Graph11611); gre->Draw("pa"); gre = new TGraphErrors(11); gre->SetName("Graph3"); gre->SetTitle(""); gre->SetFillColor(1); gre->SetLineColor(4); gre->SetMarkerColor(4); gre->SetMarkerStyle(23); gre->SetMarkerSize(1.5); gre->SetPoint(0,8.892308,0.945552); gre->SetPointError(0,0,0.00222099); gre->SetPoint(1,10.38462,0.937882); gre->SetPointError(1,0,0.00397671); gre->SetPoint(2,23.53846,0.945317); gre->SetPointError(2,0,0.0024096); gre->SetPoint(3,43.84615,0.950864); gre->SetPointError(3,0,0.00176728); gre->SetPoint(4,120.3077,0.94505); gre->SetPointError(4,0,0.00122324); gre->SetPoint(5,164.6154,0.942688); gre->SetPointError(5,0,0.00136884); gre->SetPoint(6,389.2308,0.921693); gre->SetPointError(6,0,0.00178155); gre->SetPoint(7,753.8462,0.905909); gre->SetPointError(7,0,0.002633); gre->SetPoint(8,1266.154,0.891392); gre->SetPointError(8,0,0.00331251); gre->SetPoint(9,3400,0.868524); gre->SetPointError(9,0,0.003775); gre->SetPoint(10,7430.769,0.847397); gre->SetPointError(10,0,0.00551738); TH1F *Graph_Graph_Graph_Graph32712 = new TH1F("Graph_Graph_Graph_Graph32712","",100,8.003077,8172.957); Graph_Graph_Graph_Graph32712->SetMinimum(0.8308045); Graph_Graph_Graph_Graph32712->SetMaximum(0.9637064); Graph_Graph_Graph_Graph32712->SetDirectory(0); Graph_Graph_Graph_Graph32712->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph_Graph_Graph32712->SetLineColor(ci); Graph_Graph_Graph_Graph32712->SetLineStyle(0); Graph_Graph_Graph_Graph32712->SetMarkerStyle(20); Graph_Graph_Graph_Graph32712->GetXaxis()->SetTitle("Average rate ( N_{#mu}.s^{-1}.cm^{-2} )"); Graph_Graph_Graph_Graph32712->GetXaxis()->CenterTitle(true); Graph_Graph_Graph_Graph32712->GetXaxis()->SetLabelFont(42); Graph_Graph_Graph_Graph32712->GetXaxis()->SetLabelOffset(0.007); Graph_Graph_Graph_Graph32712->GetXaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph32712->GetXaxis()->SetTitleSize(0.05); Graph_Graph_Graph_Graph32712->GetXaxis()->SetTitleOffset(1.1); Graph_Graph_Graph_Graph32712->GetXaxis()->SetTitleFont(42); Graph_Graph_Graph_Graph32712->GetYaxis()->SetTitle("#mu detection efficiency"); Graph_Graph_Graph_Graph32712->GetYaxis()->CenterTitle(true); Graph_Graph_Graph_Graph32712->GetYaxis()->SetLabelFont(42); Graph_Graph_Graph_Graph32712->GetYaxis()->SetLabelOffset(0.007); Graph_Graph_Graph_Graph32712->GetYaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph32712->GetYaxis()->SetTitleSize(0.05); Graph_Graph_Graph_Graph32712->GetYaxis()->SetTitleOffset(0.9); Graph_Graph_Graph_Graph32712->GetYaxis()->SetTitleFont(42); Graph_Graph_Graph_Graph32712->GetZaxis()->SetLabelFont(42); Graph_Graph_Graph_Graph32712->GetZaxis()->SetLabelOffset(0.007); Graph_Graph_Graph_Graph32712->GetZaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph32712->GetZaxis()->SetTitleSize(0.06); Graph_Graph_Graph_Graph32712->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph_Graph_Graph32712); gre->Draw("p&"); gre = new TGraphErrors(10); gre->SetName("Graph4"); gre->SetTitle(""); gre->SetFillColor(1); gre->SetLineColor(4); gre->SetMarkerColor(4); gre->SetMarkerStyle(26); gre->SetMarkerSize(1.5); gre->SetPoint(0,10.38462,0.818118); gre->SetPointError(0,0,0.00652498); gre->SetPoint(1,23.53846,0.859551); gre->SetPointError(1,0,0.00371018); gre->SetPoint(2,43.84615,0.869325); gre->SetPointError(2,0,0.00275425); gre->SetPoint(3,120.3077,0.852496); gre->SetPointError(3,0,0.00191306); gre->SetPoint(4,164.6154,0.844565); gre->SetPointError(4,0,0.00214338); gre->SetPoint(5,389.2308,0.801642); gre->SetPointError(5,0,0.00267808); gre->SetPoint(6,753.8462,0.77863); gre->SetPointError(6,0,0.00379423); gre->SetPoint(7,1266.154,0.751091); gre->SetPointError(7,0,0.00470814); gre->SetPoint(8,3400,0.700803); gre->SetPointError(8,0,0.00534877); gre->SetPoint(9,7430.769,0.681421); gre->SetPointError(9,0,0.00746557); TH1F *Graph_Graph_Graph_Graph43813 = new TH1F("Graph_Graph_Graph_Graph43813","",100,9.346154,8172.808); Graph_Graph_Graph_Graph43813->SetMinimum(0.654143); Graph_Graph_Graph_Graph43813->SetMaximum(0.8918916); Graph_Graph_Graph_Graph43813->SetDirectory(0); Graph_Graph_Graph_Graph43813->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph_Graph_Graph43813->SetLineColor(ci); Graph_Graph_Graph_Graph43813->SetLineStyle(0); Graph_Graph_Graph_Graph43813->SetMarkerStyle(20); Graph_Graph_Graph_Graph43813->GetXaxis()->SetTitle("Average rate ( N_{#mu}.s^{-1}.cm^{-2} )"); Graph_Graph_Graph_Graph43813->GetXaxis()->CenterTitle(true); Graph_Graph_Graph_Graph43813->GetXaxis()->SetLabelFont(42); Graph_Graph_Graph_Graph43813->GetXaxis()->SetLabelOffset(0.01); Graph_Graph_Graph_Graph43813->GetXaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph43813->GetXaxis()->SetTitleSize(0.05); Graph_Graph_Graph_Graph43813->GetXaxis()->SetTitleOffset(1.1); Graph_Graph_Graph_Graph43813->GetXaxis()->SetTitleFont(42); Graph_Graph_Graph_Graph43813->GetYaxis()->SetTitle("#mu detection efficiency"); Graph_Graph_Graph_Graph43813->GetYaxis()->CenterTitle(true); Graph_Graph_Graph_Graph43813->GetYaxis()->SetLabelFont(42); Graph_Graph_Graph_Graph43813->GetYaxis()->SetLabelOffset(0.007); Graph_Graph_Graph_Graph43813->GetYaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph43813->GetYaxis()->SetTitleSize(0.05); Graph_Graph_Graph_Graph43813->GetYaxis()->SetTitleOffset(0.9); Graph_Graph_Graph_Graph43813->GetYaxis()->SetTitleFont(42); Graph_Graph_Graph_Graph43813->GetZaxis()->SetLabelFont(42); Graph_Graph_Graph_Graph43813->GetZaxis()->SetLabelOffset(0.007); Graph_Graph_Graph_Graph43813->GetZaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph43813->GetZaxis()->SetTitleSize(0.06); Graph_Graph_Graph_Graph43813->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph_Graph_Graph43813); gre->Draw("p&"); gre = new TGraphErrors(11); gre->SetName("Graph5"); gre->SetTitle(""); gre->SetFillColor(1); gre->SetLineColor(4); gre->SetMarkerColor(4); gre->SetMarkerStyle(32); gre->SetMarkerSize(1.5); gre->SetPoint(0,8.892308,0.964904); gre->SetPointError(0,0,0.00161884); gre->SetPoint(1,10.38462,0.968371); gre->SetPointError(1,0,0.00261764); gre->SetPoint(2,23.53846,0.966203); gre->SetPointError(2,0,0.00172469); gre->SetPoint(3,43.84615,0.966627); gre->SetPointError(3,0,0.00131816); gre->SetPoint(4,120.3077,0.952356); gre->SetPointError(4,0,0.00103524); gre->SetPoint(5,164.6154,0.947467); gre->SetPointError(5,0,0.00119486); gre->SetPoint(6,389.2308,0.920595); gre->SetPointError(6,0,0.00164465); gre->SetPoint(7,753.8462,0.899052); gre->SetPointError(7,0,0.00250036); gre->SetPoint(8,1266.154,0.871394); gre->SetPointError(8,0,0.00333283); gre->SetPoint(9,3400,0.817966); gre->SetPointError(9,0,0.00415542); gre->SetPoint(10,7430.769,0.771213); gre->SetPointError(10,0,0.00633324); TH1F *Graph_Graph_Graph_Graph54914 = new TH1F("Graph_Graph_Graph_Graph54914","",100,8.003077,8172.957); Graph_Graph_Graph_Graph54914->SetMinimum(0.7442689); Graph_Graph_Graph_Graph54914->SetMaximum(0.9915995); Graph_Graph_Graph_Graph54914->SetDirectory(0); Graph_Graph_Graph_Graph54914->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph_Graph_Graph54914->SetLineColor(ci); Graph_Graph_Graph_Graph54914->SetLineStyle(0); Graph_Graph_Graph_Graph54914->SetMarkerStyle(20); Graph_Graph_Graph_Graph54914->GetXaxis()->SetTitle("Average rate ( N_{#mu}.s^{-1}.cm^{-2} )"); Graph_Graph_Graph_Graph54914->GetXaxis()->CenterTitle(true); Graph_Graph_Graph_Graph54914->GetXaxis()->SetLabelFont(42); Graph_Graph_Graph_Graph54914->GetXaxis()->SetLabelOffset(0.01); Graph_Graph_Graph_Graph54914->GetXaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph54914->GetXaxis()->SetTitleSize(0.05); Graph_Graph_Graph_Graph54914->GetXaxis()->SetTitleOffset(1.1); Graph_Graph_Graph_Graph54914->GetXaxis()->SetTitleFont(42); Graph_Graph_Graph_Graph54914->GetYaxis()->SetTitle("#mu detection efficiency"); Graph_Graph_Graph_Graph54914->GetYaxis()->CenterTitle(true); Graph_Graph_Graph_Graph54914->GetYaxis()->SetLabelFont(42); Graph_Graph_Graph_Graph54914->GetYaxis()->SetLabelOffset(0.007); Graph_Graph_Graph_Graph54914->GetYaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph54914->GetYaxis()->SetTitleSize(0.05); Graph_Graph_Graph_Graph54914->GetYaxis()->SetTitleOffset(0.9); Graph_Graph_Graph_Graph54914->GetYaxis()->SetTitleFont(42); Graph_Graph_Graph_Graph54914->GetZaxis()->SetLabelFont(42); Graph_Graph_Graph_Graph54914->GetZaxis()->SetLabelOffset(0.007); Graph_Graph_Graph_Graph54914->GetZaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph54914->GetZaxis()->SetTitleSize(0.06); Graph_Graph_Graph_Graph54914->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph_Graph_Graph54914); gre->Draw("p&"); gre = new TGraphErrors(11); gre->SetName("Graph6"); gre->SetTitle(""); gre->SetFillColor(1); gre->SetLineColor(2); gre->SetMarkerColor(2); gre->SetMarkerStyle(31); gre->SetMarkerSize(1.5); gre->SetPoint(0,8.892308,0.937506); gre->SetPointError(0,0,0.00238084); gre->SetPoint(1,10.38462,0.932408); gre->SetPointError(1,0,0.00416789); gre->SetPoint(2,23.53846,0.852038); gre->SetPointError(2,0,0.00397868); gre->SetPoint(3,43.84615,0.707619); gre->SetPointError(3,0,0.00429972); gre->SetPoint(4,120.3077,0.38838); gre->SetPointError(4,0,0.00401168); gre->SetPoint(5,164.6154,0.348649); gre->SetPointError(5,0,0.00451826); gre->SetPoint(6,389.2308,0.254837); gre->SetPointError(6,0,0.00521552); gre->SetPoint(7,753.8462,0.245527); gre->SetPointError(7,0,0.00698108); gre->SetPoint(8,1266.154,0.250365); gre->SetPointError(8,0,0.00802127); gre->SetPoint(9,3400,0.232597); gre->SetPointError(9,0,0.00840615); gre->SetPoint(10,7430.769,0.186328); gre->SetPointError(10,0,0.0117775); TH1F *Graph_Graph_Graph_Graph651015 = new TH1F("Graph_Graph_Graph_Graph651015","",100,8.003077,8172.957); Graph_Graph_Graph_Graph651015->SetMinimum(0.09801687); Graph_Graph_Graph_Graph651015->SetMaximum(1.01642); Graph_Graph_Graph_Graph651015->SetDirectory(0); Graph_Graph_Graph_Graph651015->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph_Graph_Graph651015->SetLineColor(ci); Graph_Graph_Graph_Graph651015->SetLineStyle(0); Graph_Graph_Graph_Graph651015->SetMarkerStyle(20); Graph_Graph_Graph_Graph651015->GetXaxis()->SetTitle("Average rate ( N_{#mu}.s^{-1}.cm^{-2} )"); Graph_Graph_Graph_Graph651015->GetXaxis()->CenterTitle(true); Graph_Graph_Graph_Graph651015->GetXaxis()->SetLabelFont(42); Graph_Graph_Graph_Graph651015->GetXaxis()->SetLabelOffset(0.01); Graph_Graph_Graph_Graph651015->GetXaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph651015->GetXaxis()->SetTitleSize(0.05); Graph_Graph_Graph_Graph651015->GetXaxis()->SetTitleOffset(3); Graph_Graph_Graph_Graph651015->GetXaxis()->SetTitleFont(42); Graph_Graph_Graph_Graph651015->GetYaxis()->SetTitle("#mu detection efficiency"); Graph_Graph_Graph_Graph651015->GetYaxis()->CenterTitle(true); Graph_Graph_Graph_Graph651015->GetYaxis()->SetLabelFont(42); Graph_Graph_Graph_Graph651015->GetYaxis()->SetLabelOffset(0.007); Graph_Graph_Graph_Graph651015->GetYaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph651015->GetYaxis()->SetTitleSize(0.05); Graph_Graph_Graph_Graph651015->GetYaxis()->SetTitleOffset(1.1); Graph_Graph_Graph_Graph651015->GetYaxis()->SetTitleFont(42); Graph_Graph_Graph_Graph651015->GetZaxis()->SetLabelFont(42); Graph_Graph_Graph_Graph651015->GetZaxis()->SetLabelOffset(0.007); Graph_Graph_Graph_Graph651015->GetZaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph651015->GetZaxis()->SetTitleSize(0.06); Graph_Graph_Graph_Graph651015->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph_Graph_Graph651015); gre->Draw("p&"); TLatex * tex = new TLatex(0.96,0.936," "); tex->SetNDC(); tex->SetTextAlign(31); tex->SetTextFont(42); tex->SetTextSize(0.048); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(0.1722,0.892,"Preliminary"); tex->SetNDC(); tex->SetTextAlign(13); tex->SetTextFont(52); tex->SetTextSize(0.0456); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(0.1722,0.851872,"Gas mixture : 93% TFE, 5%CO_{2}, 2%SF_{6}"); tex->SetNDC(); tex->SetTextAlign(13); tex->SetTextFont(52); tex->SetTextSize(0.0264); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(0.1722,0.811744,"Threshold : 0.13pC"); tex->SetNDC(); tex->SetTextAlign(13); tex->SetTextFont(52); tex->SetTextSize(0.0264); tex->SetLineWidth(2); tex->Draw(); TH1F *Graph1 = new TH1F("Graph1","",100,8.003077,8172.957); Graph1->SetMinimum(0.7831534); Graph1->SetMaximum(0.9997717); Graph1->SetDirectory(0); Graph1->SetStats(0); ci = TColor::GetColor("#000099"); Graph1->SetLineColor(ci); Graph1->SetLineStyle(0); Graph1->SetMarkerStyle(20); Graph1->GetXaxis()->SetTitle("Average rate ( N_{#mu}.s^{-1}.cm^{-2} )"); Graph1->GetXaxis()->CenterTitle(true); Graph1->GetXaxis()->SetLabelFont(42); Graph1->GetXaxis()->SetLabelOffset(0.01); Graph1->GetXaxis()->SetLabelSize(0.05); Graph1->GetXaxis()->SetTitleSize(0.05); Graph1->GetXaxis()->SetTitleOffset(1.4); Graph1->GetXaxis()->SetTitleFont(42); Graph1->GetYaxis()->SetTitle("#mu detection efficiency"); Graph1->GetYaxis()->CenterTitle(true); Graph1->GetYaxis()->SetLabelFont(42); Graph1->GetYaxis()->SetLabelOffset(0.007); Graph1->GetYaxis()->SetLabelSize(0.05); Graph1->GetYaxis()->SetTitleSize(0.05); Graph1->GetYaxis()->SetTitleOffset(0.9); Graph1->GetYaxis()->SetTitleFont(42); Graph1->GetZaxis()->SetLabelFont(42); Graph1->GetZaxis()->SetLabelOffset(0.007); Graph1->GetZaxis()->SetLabelSize(0.05); Graph1->GetZaxis()->SetTitleSize(0.06); Graph1->GetZaxis()->SetTitleFont(42); Graph1->Draw("sameaxis"); TH1F *Graph1 = new TH1F("Graph1","",100,8.003077,8172.957); Graph1->SetMinimum(0.7831534); Graph1->SetMaximum(0.9997717); Graph1->SetDirectory(0); Graph1->SetStats(0); ci = TColor::GetColor("#000099"); Graph1->SetLineColor(ci); Graph1->SetLineStyle(0); Graph1->SetMarkerStyle(20); Graph1->GetXaxis()->SetTitle("Average rate ( N_{#mu}.s^{-1}.cm^{-2} )"); Graph1->GetXaxis()->CenterTitle(true); Graph1->GetXaxis()->SetLabelFont(42); Graph1->GetXaxis()->SetLabelOffset(0.01); Graph1->GetXaxis()->SetLabelSize(0.05); Graph1->GetXaxis()->SetTitleSize(0.05); Graph1->GetXaxis()->SetTitleOffset(1.4); Graph1->GetXaxis()->SetTitleFont(42); Graph1->GetYaxis()->SetTitle("#mu detection efficiency"); Graph1->GetYaxis()->CenterTitle(true); Graph1->GetYaxis()->SetLabelFont(42); Graph1->GetYaxis()->SetLabelOffset(0.007); Graph1->GetYaxis()->SetLabelSize(0.05); Graph1->GetYaxis()->SetTitleSize(0.05); Graph1->GetYaxis()->SetTitleOffset(0.9); Graph1->GetYaxis()->SetTitleFont(42); Graph1->GetZaxis()->SetLabelFont(42); Graph1->GetZaxis()->SetLabelOffset(0.007); Graph1->GetZaxis()->SetLabelSize(0.05); Graph1->GetZaxis()->SetTitleSize(0.06); Graph1->GetZaxis()->SetTitleFont(42); Graph1->Draw("sameaxis"); TLegend *leg = new TLegend(0.5,0.8,0.9,0.9,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetTextSize(0.025); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(1001); leg-> SetNColumns(4); TLegendEntry *entry=leg->AddEntry("NULL","SPS test beams 06.2015","h"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("Graph1","","p"); entry->SetFillStyle(1001); entry->SetLineColor(2); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(4); entry->SetMarkerStyle(22); entry->SetMarkerSize(1.5); entry->SetTextAlign(13); entry->SetTextFont(42); entry=leg->AddEntry("Graph3","","p"); entry->SetFillStyle(1001); entry->SetLineColor(4); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(4); entry->SetMarkerStyle(23); entry->SetMarkerSize(1.5); entry->SetTextFont(42); entry=leg->AddEntry("Graph4","","p"); entry->SetFillStyle(1001); entry->SetLineColor(5); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(4); entry->SetMarkerStyle(26); entry->SetMarkerSize(1.5); entry->SetTextFont(42); entry=leg->AddEntry("Graph5","Low resistive glass RPC - 10^{10} #Omega.cm : 1,2,3,4","p"); entry->SetFillStyle(1001); entry->SetLineColor(0); entry->SetLineStyle(0); entry->SetLineWidth(0); entry->SetMarkerColor(0); entry->SetMarkerStyle(0); entry->SetMarkerSize(0); entry->SetTextFont(0); entry=leg->AddEntry(""," ","p"); entry->SetFillStyle(1001); entry->SetLineColor(0); entry->SetLineWidth(0); entry->SetMarkerColor(0); entry->SetMarkerStyle(0); entry->SetTextFont(0); entry=leg->AddEntry(""," ","p"); entry->SetFillStyle(1001); entry->SetLineColor(0); entry->SetLineWidth(0); entry->SetMarkerColor(0); entry->SetMarkerStyle(0); entry->SetTextFont(0); entry=leg->AddEntry(""," ","p"); entry->SetFillStyle(1001); entry->SetLineColor(0); entry->SetLineWidth(0); entry->SetMarkerColor(0); entry->SetMarkerStyle(0); entry->SetTextFont(0); entry=leg->AddEntry("Graph6","Float glass RPC ~10^{12}-10^{13} #Omega.cm","p"); entry->SetFillStyle(1001); entry->SetLineColor(7); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(2); entry->SetMarkerStyle(31); entry->SetMarkerSize(1.5); entry->SetTextFont(42); leg->Draw(); TPaveText* Box = new TPaveText(0.08, 0.8, 0.115, 0.9, "nbNDC"); Box->SetFillColor(10); Box->SetLineColor(10); Box->Draw(); TLine *line = new TLine(0,1,8185,1); line->SetLineStyle(2); line->Draw(); FigExample->Modified(); FigExample->cd(); FigExample->SetSelected(FigExample); }
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(); }
int main(int argc, char* argv[]) { TH1::SetDefaultSumw2(); ProgramOptions options(argc, argv); double lumi = options.lumi; std::cout << "Integrated luminosity : " << lumi << " pb-1" << std::endl; Datasets datasets(options.iDir); datasets.readFile(options.datasetFile); LeptonWeights lw; // cuts Cuts cuts; TCut puWeight("puWeight"); TCut trigCorr( "(trigCorrWeight>0) ? trigCorrWeight : 1." ); // For lepton weights TCut elTightWeight = cuts.elTightWeight(options.leptCorr); TCut muTightWeight = cuts.muTightWeight(options.leptCorr); TCut leptonTightWeight = elTightWeight * muTightWeight; // ok to use muon and electron tight weights in control regions, since we use a lepton veto, so you would have a muon weight = 1 TCut elVetoWeight = cuts.elVetoWeight(options.leptCorr); TCut muVetoWeight = cuts.muVetoWeight(options.leptCorr); TCut leptonVetoWeight = elVetoWeight * muVetoWeight; TCut otherCutsTight = puWeight * trigCorr * leptonTightWeight; TCut otherCutsVeto = puWeight * trigCorr * leptonVetoWeight; TCut cutSignalNoMETNoDPhi = cuts.HLTandMETFilters() + cuts.leptonVeto() + cuts.vbf(); // Tau cuts // Get puWeight etc added below if necessary // standard TightMjj selection - essentially signal selection but no DPhiJJ and no cjv TCut cutTightMjj_basic = cuts.HLTandMETFilters() + cuts.cutWTau("lVeto") + cuts.cutWTau("dijet") + cuts.cutWTau("dEtaJJ") + cuts.cutWTau("MET") + cuts.cutWTau("Mjj"); TCut cutwElnoMjj = cuts.cutWEl("trigger")+ cuts.cutWEl("wEl")+cuts.cutWEl("lVeto")+cuts.cutWEl("dijet")+cuts.cutWEl("dEtaJJ")+cuts.cutWEl("MET")+cuts.cutWEl("CJV")+cuts.cutWEl("dPhiJJ"); //for W->el regions TCut cutTightMjj(""); // used to add in PU, trig corr, wWeight etc // double dphiEdges[4] = { 0., 1.0, 2.6, TMath::Pi() }; double dphiEdges[5] = { 0., 1.0, 1.8, 2.6, TMath::Pi() }; double MjjEdges[5] = { 800., 1000., 1200., 1800., 3000. }; double METEdges[5] = { 100., 150., 200., 250., 300. }; //double CenJetEtEdges[5] = { 10., 40., 70., 120. ,200}; double CenJetEtEdges[5] = { 10., 30., 60., 100., 150.}; TH1D* hWEl_MCGen_DPhi = new TH1D("hWEl_MCGen_DPhi", "", 1, 0,1); // W+jets MC gen level el TH1D* hWTau_MCGen_DPhi = new TH1D("hWTau_MCGen_DPhi", "", 1, 0,1); // W+jets MC gen level Tau - for ID // DPhiJJ histograms // WEl histograms TH1D* hWEl_MCC_DPhi = new TH1D("hWEl_MCC_DPhi", "", 4, dphiEdges); // W+jets MC el ctrl region TH1D* hWEl_BGC_DPhi = new TH1D("hWEl_BGC_DPhi", "", 4, dphiEdges); // background MC ctrl region TH1D* hWEl_DataC_DPhi = new TH1D("hWEl_DataC_DPhi", "", 4, dphiEdges); // Data ctrl region // WTau histograms TH1D* hWTau_MCC_DPhi = new TH1D("hWTau_MCC_DPhi", "", 4, dphiEdges); // W+jets MC tau ctrl region - for CJV ratio TH1D* hWTau_BGC_DPhi = new TH1D("hWTau_BGC_DPhi", "", 4, dphiEdges); // background MC ctrl region TH1D* hWTau_DataC_DPhi = new TH1D("hWTau_DataC_DPhi", "", 4, dphiEdges); // Data ctrl region // Mjj histograms // WEl histograms TH1D* hWEl_MCC_Mjj = new TH1D("hWEl_MCC_Mjj", "", 4, MjjEdges); // W+jets MC el ctrl region TH1D* hWEl_BGC_Mjj = new TH1D("hWEl_BGC_Mjj", "", 4, MjjEdges); // background MC ctrl region TH1D* hWEl_DataC_Mjj = new TH1D("hWEl_DataC_Mjj", "", 4, MjjEdges); // Data ctrl region // WTau histograms TH1D* hWTau_MCC_Mjj = new TH1D("hWTau_MCC_Mjj", "", 4, MjjEdges); // W+jets MC tau ctrl region - for CJV ratio TH1D* hWTau_BGC_Mjj = new TH1D("hWTau_BGC_Mjj", "", 4, MjjEdges); // background MC ctrl region TH1D* hWTau_DataC_Mjj = new TH1D("hWTau_DataC_Mjj", "", 4, MjjEdges); // Data ctrl region // Mjj histograms // MET histograms // WEl histograms TH1D* hWEl_MCC_MET = new TH1D("hWEl_MCC_MET", "", 4, METEdges); // W+jets MC el ctrl region TH1D* hWEl_BGC_MET = new TH1D("hWEl_BGC_MET", "", 4, METEdges); // background MC ctrl region TH1D* hWEl_DataC_MET = new TH1D("hWEl_DataC_MET", "", 4, METEdges); // Data ctrl region // WTau histograms TH1D* hWTau_MCC_MET = new TH1D("hWTau_MCC_MET", "", 4, METEdges); // W+jets MC tau ctrl region - for CJV ratio TH1D* hWTau_BGC_MET = new TH1D("hWTau_BGC_MET", "", 4, METEdges); // background MC ctrl region TH1D* hWTau_DataC_MET = new TH1D("hWTau_DataC_MET", "", 4, METEdges); // Data ctrl region // MET histograms // Central Jet Et histograms // WEl histograms TH1D* hWEl_MCC_CenJetEt = new TH1D("hWEl_MCC_CenJetEt", "", 4, CenJetEtEdges); // W+jets MC el ctrl region TH1D* hWEl_BGC_CenJetEt = new TH1D("hWEl_BGC_CenJetEt", "", 4, CenJetEtEdges); // background MC ctrl region TH1D* hWEl_DataC_CenJetEt = new TH1D("hWEl_DataC_CenJetEt", "", 4, CenJetEtEdges); // Data ctrl region // WTau histograms TH1D* hWTau_MCC_CenJetEt = new TH1D("hWTau_MCC_CenJetEt", "", 4, CenJetEtEdges); // W+jets MC tau ctrl region - for CJV ratio TH1D* hWTau_BGC_CenJetEt = new TH1D("hWTau_BGC_CenJetEt", "", 4, CenJetEtEdges); // background MC ctrl region TH1D* hWTau_DataC_CenJetEt = new TH1D("hWTau_DataC_CenJetEt", "", 4, CenJetEtEdges); // Data ctrl region // loop over MC datasets for (unsigned i=0; i<datasets.size(); ++i) { Dataset dataset = datasets.getDataset(i); TFile* file = datasets.getTFile(dataset.name); TTree* tree = (TTree*) file->Get("invHiggsInfo/InvHiggsInfo"); // setup cuts TCut wWeight(""); TCut cutD = cuts.cutDataset(dataset.name); TCut cutWEl_Gen = cuts.wElGen(); TCut cutWTau_Gen = cuts.wTauGen(); TCut cutWEl_MCC_DPhi = cuts.wElGen() + cuts.wElVBF() + cuts.cutWEl("MET"); TCut cutWEl_C_DPhi = cutD + cuts.wElVBF() + cuts.cutWEl("MET"); // WEl MC control region; WEl MC gen only; control region for data/bg - all for DPhiJJ TCut cutWTau_MCC_DPhi = cuts.wTauGen() + cutTightMjj_basic + cuts.cutWTau("wTau"); TCut cutWTau_C_DPhi = cutD + cutTightMjj_basic + cuts.cutWTau("wTau"); // WTau MC control region; WTau MC gen only; control region for data/bg - all for DPhiJJ TCut cutWEl_MCC_Mjj = cuts.wElGen() + cutwElnoMjj; TCut cutWEl_C_Mjj = cutD + cutwElnoMjj; TCut cutWTau_MCC_Mjj = cuts.wTauGen() + cuts.cutWTau("wTau") + cuts.cutWTau("trigger") + cuts.cutWTau("lVeto") + cuts.cutWTau("dijet") + cuts.cutWTau("dEtaJJ") + cuts.cutWTau("MET") + cuts.cutWTau("dPhiJJ"); TCut cutWTau_C_Mjj = cutD + cuts.cutWTau("wTau") + cuts.cutWTau("trigger") + cuts.cutWTau("lVeto") + cuts.cutWTau("dijet") + cuts.cutWTau("dEtaJJ") + cuts.cutWTau("MET") + cuts.cutWTau("dPhiJJ"); TCut cutWEl_MCC_MET = cuts.wElGen() + cuts.wElVBF() + cuts.cutWEl("dPhiJJ"); TCut cutWEl_C_MET = cutD + cuts.wElVBF() + cuts.cutWEl("dPhiJJ"); TCut cutWTau_MCC_MET = cuts.wTauGen() + cuts.cutWTau("wTau") + cuts.cutWTau("trigger") + cuts.cutWTau("lVeto") + cuts.cutWTau("dijet") + cuts.cutWTau("dEtaJJ") + cuts.cutWTau("Mjj") + cuts.cutWTau("dPhiJJ"); TCut cutWTau_C_MET = cutD + cuts.cutWTau("wTau") + cuts.cutWTau("trigger") + cuts.cutWTau("lVeto") + cuts.cutWTau("dijet") + cuts.cutWTau("dEtaJJ") + cuts.cutWTau("Mjj") + cuts.cutWTau("dPhiJJ"); TCut cutWEl_MCC_CenJetEt = cuts.wElGen() + cuts.cutWEl("trigger") + cuts.cutWEl("lVeto") + cuts.cutWEl("wEl") + cuts.cutWEl("dijet") + cuts.cutWEl("dEtaJJ") + cuts.cutWEl("Mjj") + cuts.cutWEl("MET") + cuts.cutWEl("dPhiJJ"); TCut cutWEl_C_CenJetEt = cutD + cuts.cutWEl("trigger") + cuts.cutWEl("lVeto") + cuts.cutWEl("wEl") + cuts.cutWEl("dijet") + cuts.cutWEl("dEtaJJ") + cuts.cutWEl("Mjj") + cuts.cutWEl("MET") + cuts.cutWEl("dPhiJJ"); TCut cutWTau_MCC_CenJetEt = cuts.wTauGen() + cutTightMjj_basic + cuts.cutWTau("wTau") + cuts.cutWTau("dPhiJJ"); TCut cutWTau_C_CenJetEt = cutD + cutTightMjj_basic + cuts.cutWTau("wTau") + cuts.cutWTau("dPhiJJ"); // TEMP HISTS - DPhiJJ TH1D* hWEl_MCGen_DPhi_tmp = new TH1D("hWEl_MCGen_DPhi_tmp", "",1, 0,1); // W+jets El MC gen TH1D* hWTau_MCGen_DPhi_tmp = new TH1D("hWTau_MCGen_DPhi_tmp", "",1, 0,1); // W+jets Tau MC gen // tmp histograms - WEl TH1D* hWEl_MCC_DPhi_tmp = new TH1D("hWEl_MCC_DPhi_tmp", "",4,dphiEdges); // W+jets MC ctrl region TH1D* hWEl_DataC_DPhi_tmp = new TH1D("hWEl_DataC_DPhi_tmp", "",4,dphiEdges); // Data in WEl ctrl region TH1D* hWEl_BGC_DPhi_tmp = new TH1D("hWEl_BGC_DPhi_tmp", "",4,dphiEdges); //BG in WEl ctrl region // tmp histograms - wTau TH1D* hWTau_MCC_DPhi_tmp = new TH1D("hWTau_MCC_DPhi_tmp", "",4,dphiEdges); // W+jets MC ctrl region TH1D* hWTau_DataC_DPhi_tmp = new TH1D("hWTau_DataC_DPhi_tmp", "",4,dphiEdges); // Data in WTau ctrl region TH1D* hWTau_BGC_DPhi_tmp = new TH1D("hWTau_BGC_DPhi_tmp", "",4,dphiEdges); // BG in WTau ctrl region // TEMP HISTS - Mjj // tmp histograms - WEl TH1D* hWEl_MCC_Mjj_tmp = new TH1D("hWEl_MCC_Mjj_tmp", "",4,MjjEdges); // W+jets MC ctrl region TH1D* hWEl_DataC_Mjj_tmp = new TH1D("hWEl_DataC_Mjj_tmp", "",4,MjjEdges); TH1D* hWEl_BGC_Mjj_tmp = new TH1D("hWEl_BGC_Mjj_tmp", "",4,MjjEdges); // tmp histograms - wTau TH1D* hWTau_MCC_Mjj_tmp = new TH1D("hWTau_MCC_Mjj_tmp", "",4,MjjEdges); // W+jets MC ctrl region TH1D* hWTau_DataC_Mjj_tmp = new TH1D("hWTau_DataC_Mjj_tmp", "",4,MjjEdges); TH1D* hWTau_BGC_Mjj_tmp = new TH1D("hWTau_BGC_Mjj_tmp", "",4,MjjEdges); // TEMP HISTS - MET // tmp histograms - WEl TH1D* hWEl_MCC_MET_tmp = new TH1D("hWEl_MCC_MET_tmp", "",4,METEdges); // W+jets MC ctrl region TH1D* hWEl_DataC_MET_tmp = new TH1D("hWEl_DataC_MET_tmp", "",4,METEdges); TH1D* hWEl_BGC_MET_tmp = new TH1D("hWEl_BGC_MET_tmp", "",4,METEdges); // tmp histograms - wTau TH1D* hWTau_MCC_MET_tmp = new TH1D("hWTau_MCC_MET_tmp", "",4,METEdges); // W+jets MC ctrl region TH1D* hWTau_DataC_MET_tmp = new TH1D("hWTau_DataC_MET_tmp", "",4,METEdges); TH1D* hWTau_BGC_MET_tmp = new TH1D("hWTau_BGC_MET_tmp", "",4,METEdges); // TEMP HISTS - CenJetEt // tmp histograms - WEl TH1D* hWEl_MCC_CenJetEt_tmp = new TH1D("hWEl_MCC_CenJetEt_tmp", "",4,CenJetEtEdges); // W+jets MC ctrl region TH1D* hWEl_DataC_CenJetEt_tmp = new TH1D("hWEl_DataC_CenJetEt_tmp", "",4,CenJetEtEdges); TH1D* hWEl_BGC_CenJetEt_tmp = new TH1D("hWEl_BGC_CenJetEt_tmp", "",4,CenJetEtEdges); // tmp histograms - wTau TH1D* hWTau_MCC_CenJetEt_tmp = new TH1D("hWTau_MCC_CenJetEt_tmp", "",4,CenJetEtEdges); // W+jets MC ctrl region TH1D* hWTau_DataC_CenJetEt_tmp = new TH1D("hWTau_DataC_CenJetEt_tmp", "",4,CenJetEtEdges); TH1D* hWTau_BGC_CenJetEt_tmp = new TH1D("hWTau_BGC_CenJetEt_tmp", "",4,CenJetEtEdges); // Weight to lumi double weight = (dataset.isData) ? 1. : (lumi * dataset.sigma / dataset.nEvents); if(dataset.name == "EWK_ZvvFake") weight *= constants::ratioZToNuNuZToLL; // check it's W+Jets bool isWJets = false; bool isEwkW = false; if (dataset.name == "WJets" || dataset.name == "W1Jets" || dataset.name == "W2Jets" || dataset.name == "W3Jets" || dataset.name == "W4Jets" || dataset.name == "EWK_Wp2Jets" || dataset.name == "EWK_Wm2Jets") { std::cout << "Analysing W MC : " << dataset.name << std::endl; std::cout << " weight : " << weight << std::endl; if (dataset.name == "EWK_Wp2Jets" || dataset.name == "EWK_Wm2Jets") isEwkW = true; else isWJets = true; if(isWJets) wWeight = cuts.wWeight(); // El cuts tree->Draw("vbfDPhi>>hWEl_MCC_DPhi_tmp", otherCutsTight * wWeight * cutWEl_MCC_DPhi); tree->Draw("0.5>>hWEl_MCGen_DPhi_tmp", otherCutsTight * wWeight * cutWEl_Gen); tree->Draw("vbfM>>hWEl_MCC_Mjj_tmp", otherCutsTight * wWeight * cutWEl_MCC_Mjj); tree->Draw("metNoWLepton>>hWEl_MCC_MET_tmp", otherCutsTight * wWeight * cutWEl_MCC_MET); tree->Draw("cenJetEt>>hWEl_MCC_CenJetEt_tmp", otherCutsTight * wWeight * cutWEl_MCC_CenJetEt); hWEl_MCC_DPhi_tmp->Scale(weight); hWEl_MCGen_DPhi_tmp->Scale(weight); hWEl_MCC_Mjj_tmp->Scale(weight); hWEl_MCC_MET_tmp->Scale(weight); hWEl_MCC_CenJetEt_tmp->Scale(weight); // add to final histogram hWEl_MCC_DPhi->Add(hWEl_MCC_DPhi_tmp); hWEl_MCGen_DPhi->Add(hWEl_MCGen_DPhi_tmp); hWEl_MCC_Mjj->Add(hWEl_MCC_Mjj_tmp); hWEl_MCC_MET->Add(hWEl_MCC_MET_tmp); hWEl_MCC_CenJetEt->Add(hWEl_MCC_CenJetEt_tmp); tree->Draw("vbfDPhi>>hWTau_MCC_DPhi_tmp", otherCutsVeto * wWeight * cutWTau_MCC_DPhi); tree->Draw("0.5>>hWTau_MCGen_DPhi_tmp", otherCutsVeto * wWeight * cutWTau_Gen); tree->Draw("vbfM>>hWTau_MCC_Mjj_tmp", otherCutsVeto * wWeight * cutWTau_MCC_Mjj); tree->Draw("met>>hWTau_MCC_MET_tmp", otherCutsVeto * wWeight * cutWTau_MCC_MET); tree->Draw("cenJetEt>>hWTau_MCC_CenJetEt_tmp", otherCutsVeto * wWeight * cutWTau_MCC_CenJetEt); hWTau_MCC_DPhi_tmp->Scale(weight); hWTau_MCGen_DPhi_tmp->Scale(weight); hWTau_MCC_Mjj_tmp->Scale(weight); hWTau_MCC_MET_tmp->Scale(weight); hWTau_MCC_CenJetEt_tmp->Scale(weight); // add to final histogram hWTau_MCC_DPhi->Add(hWTau_MCC_DPhi_tmp); hWTau_MCGen_DPhi->Add(hWTau_MCGen_DPhi_tmp); hWTau_MCC_Mjj->Add(hWTau_MCC_Mjj_tmp); hWTau_MCC_MET->Add(hWTau_MCC_MET_tmp); hWTau_MCC_CenJetEt->Add(hWTau_MCC_CenJetEt_tmp); } else if (dataset.isData) { std::cout << "Analysing Data : " << dataset.name << std::endl; // El region tree->Draw("vbfDPhi>>hWEl_DataC_DPhi_tmp", cutWEl_C_DPhi); hWEl_DataC_DPhi->Add(hWEl_DataC_DPhi_tmp); tree->Draw("vbfM>>hWEl_DataC_Mjj_tmp", cutWEl_C_Mjj); hWEl_DataC_Mjj->Add(hWEl_DataC_Mjj_tmp); tree->Draw("metNoWLepton>>hWEl_DataC_MET_tmp", cutWEl_C_MET); hWEl_DataC_MET->Add(hWEl_DataC_MET_tmp); tree->Draw("cenJetEt>>hWEl_DataC_CenJetEt_tmp", cutWEl_C_CenJetEt); hWEl_DataC_CenJetEt->Add(hWEl_DataC_CenJetEt_tmp); // Tau region tree->Draw("vbfDPhi>>hWTau_DataC_DPhi_tmp", cutWTau_C_DPhi); hWTau_DataC_DPhi->Add(hWTau_DataC_DPhi_tmp); tree->Draw("vbfM>>hWTau_DataC_Mjj_tmp", cutWTau_C_Mjj); hWTau_DataC_Mjj->Add(hWTau_DataC_Mjj_tmp); tree->Draw("met>>hWTau_DataC_MET_tmp", cutWTau_C_MET); hWTau_DataC_MET->Add(hWTau_DataC_MET_tmp); tree->Draw("cenJetEt>>hWTau_DataC_CenJetEt_tmp", cutWTau_C_CenJetEt); hWTau_DataC_CenJetEt->Add(hWTau_DataC_CenJetEt_tmp); std::cout << " N ctrl region (dphi<1) : " << hWTau_DataC_DPhi_tmp->GetBinContent(1) << " +/- " << hWTau_DataC_DPhi_tmp->GetBinError(1) << std::endl;// debug output } else { std::cout << "Analysing BG MC : " << dataset.name << std::endl; std::cout << " weight : " << weight << std::endl; if (dataset.name.compare(0,17,"SignalM125_POWHEG")== 0 || dataset.name.compare(0,3,"QCD") == 0) continue; if(dataset.name.compare(0,3,"Zvv") != 0 && dataset.name != "EWK_ZvvFake"){ // Don't need Zvv in WEl estimates tree->Draw("vbfDPhi>>hWEl_BGC_DPhi_tmp", otherCutsTight * cutWEl_C_DPhi); tree->Draw("vbfM>>hWEl_BGC_Mjj_tmp", otherCutsTight * cutWEl_C_Mjj); tree->Draw("metNoWLepton>>hWEl_BGC_MET_tmp", otherCutsTight * cutWEl_C_MET); tree->Draw("cenJetEt>>hWEl_BGC_CenJetEt_tmp", otherCutsTight * cutWEl_C_CenJetEt); hWEl_BGC_DPhi_tmp->Scale(weight); hWEl_BGC_Mjj_tmp->Scale(weight); hWEl_BGC_MET_tmp->Scale(weight); hWEl_BGC_CenJetEt_tmp->Scale(weight); hWEl_BGC_DPhi->Add(hWEl_BGC_DPhi_tmp); hWEl_BGC_Mjj->Add(hWEl_BGC_Mjj_tmp); hWEl_BGC_MET->Add(hWEl_BGC_MET_tmp); hWEl_BGC_CenJetEt->Add(hWEl_BGC_CenJetEt_tmp); } // Count number of tau in control region in bg mc tree->Draw("vbfDPhi>>hWTau_BGC_DPhi_tmp", otherCutsVeto * cutWTau_C_DPhi); tree->Draw("vbfM>>hWTau_BGC_Mjj_tmp", otherCutsVeto * cutWTau_C_Mjj); tree->Draw("met>>hWTau_BGC_MET_tmp", otherCutsVeto * cutWTau_C_MET); tree->Draw("cenJetEt>>hWTau_BGC_CenJetEt_tmp", otherCutsVeto * cutWTau_C_CenJetEt); hWTau_BGC_DPhi_tmp->Scale(weight); hWTau_BGC_Mjj_tmp->Scale(weight); hWTau_BGC_MET_tmp->Scale(weight); hWTau_BGC_CenJetEt_tmp->Scale(weight); hWTau_BGC_DPhi->Add(hWTau_BGC_DPhi_tmp); hWTau_BGC_Mjj->Add(hWTau_BGC_Mjj_tmp); hWTau_BGC_MET->Add(hWTau_BGC_MET_tmp); hWTau_BGC_CenJetEt->Add(hWTau_BGC_CenJetEt_tmp); // debug output std::cout << " N ctrl region (dphi<1) : " << hWTau_BGC_DPhi_tmp->GetBinContent(1) << " +/- " << hWTau_BGC_DPhi_tmp->GetBinError(1) << std::endl; std::cout << " N ctrl region (MET) : " << hWTau_BGC_MET_tmp->GetBinContent(1) << " +/- " << hWTau_BGC_MET_tmp->GetBinError(1) << std::endl; } // debug output // std::cout << " N ctrl region (dphi<1) : " << hWEl_C_DPhi->GetBinContent(1) << " +/- " << hWEl_C_DPhi->GetBinError(1) << std::endl; delete hWEl_MCC_DPhi_tmp; delete hWEl_MCGen_DPhi_tmp; delete hWEl_DataC_DPhi_tmp; delete hWEl_BGC_DPhi_tmp; delete hWTau_MCC_DPhi_tmp; delete hWTau_MCGen_DPhi_tmp; delete hWTau_DataC_DPhi_tmp; delete hWTau_BGC_DPhi_tmp; delete hWEl_MCC_Mjj_tmp; delete hWEl_DataC_Mjj_tmp; delete hWEl_BGC_Mjj_tmp; delete hWTau_MCC_Mjj_tmp; delete hWTau_DataC_Mjj_tmp; delete hWTau_BGC_Mjj_tmp; delete hWEl_MCC_MET_tmp; delete hWEl_DataC_MET_tmp; delete hWEl_BGC_MET_tmp; delete hWTau_MCC_MET_tmp; delete hWTau_DataC_MET_tmp; delete hWTau_BGC_MET_tmp; delete hWEl_MCC_CenJetEt_tmp; delete hWEl_DataC_CenJetEt_tmp; delete hWEl_BGC_CenJetEt_tmp; delete hWTau_MCC_CenJetEt_tmp; delete hWTau_DataC_CenJetEt_tmp; delete hWTau_BGC_CenJetEt_tmp; file->Close(); } // end of datasets loop //for (int i=1; i<=hWTau_BGC_DPhi->GetNbinsX(); ++i) hWTau_BGC_DPhi->SetBinError(i,0.); // no stat error from mc //for (int i=1; i<=hWEl_BGC_DPhi->GetNbinsX(); ++i) hWEl_BGC_DPhi->SetBinError(i,0.); // no stat error from mc //for (int i=1; i<=hWTau_BGC_MET->GetNbinsX(); ++i) hWTau_BGC_MET->SetBinError(i,0.); // no stat error from mc //for (int i=1; i<=hWEl_BGC_MET->GetNbinsX(); ++i) hWEl_BGC_MET->SetBinError(i,0.); // no stat error from mc //for (int i=1; i<=hWTau_BGC_CenJetEt->GetNbinsX(); ++i) hWTau_BGC_CenJetEt->SetBinError(i,0.); // no stat error from mc //for (int i=1; i<=hWEl_BGC_CenJetEt->GetNbinsX(); ++i) hWEl_BGC_CenJetEt->SetBinError(i,0.); // no stat error from mc // W->el TH1D* hWEl_EstC_DPhi = new TH1D("hWEl_EstC_DPhi", "", 4, dphiEdges); // n_data - n_bg in WEl control hWEl_EstC_DPhi->Add(hWEl_DataC_DPhi, hWEl_BGC_DPhi, 1., -1.); TH1D* hWEl_EstC_Mjj = new TH1D("hWEl_EstC_Mjj", "", 4, MjjEdges); // n_data - n_bg in WEl control hWEl_EstC_Mjj->Add(hWEl_DataC_Mjj, hWEl_BGC_Mjj, 1., -1.); TH1D* hWEl_EstC_MET = new TH1D("hWEl_EstC_MET", "", 4, METEdges); // n_data - n_bg in WEl control hWEl_EstC_MET->Add(hWEl_DataC_MET, hWEl_BGC_MET, 1., -1.); TH1D* hWEl_EstC_CenJetEt = new TH1D("hWEl_EstC_CenJetEt", "", 4, CenJetEtEdges); // n_data - n_bg in WEl control hWEl_EstC_CenJetEt->Add(hWEl_DataC_CenJetEt, hWEl_BGC_CenJetEt, 1., -1.); // W->Tau TH1D* hWTau_EstC_DPhi = new TH1D("hWTau_EstC_DPhi", "", 4, dphiEdges); // n_data - n_bg in WTau control hWTau_EstC_DPhi->Add(hWTau_DataC_DPhi, hWTau_BGC_DPhi, 1., -1.); TH1D* hWTau_EstC_Mjj = new TH1D("hWTau_EstC_Mjj", "", 4, MjjEdges); // n_data - n_bg in WTau control hWTau_EstC_Mjj->Add(hWTau_DataC_Mjj, hWTau_BGC_Mjj, 1., -1.); TH1D* hWTau_EstC_MET = new TH1D("hWTau_EstC_MET", "", 4, METEdges); // n_data - n_bg in WTau control hWTau_EstC_MET->Add(hWTau_DataC_MET, hWTau_BGC_MET, 1., -1.); TH1D* hWTau_EstC_CenJetEt = new TH1D("hWTau_EstC_CenJetEt", "", 4, CenJetEtEdges); // n_data - n_bg in WTau control hWTau_EstC_CenJetEt->Add(hWTau_DataC_CenJetEt, hWTau_BGC_CenJetEt, 1., -1.); TH1D* h_RGEN = new TH1D("h_RGEN","",1,0,1.); h_RGEN->Divide(hWEl_MCGen_DPhi,hWTau_MCGen_DPhi,1.,1.); TH1D* h_RVBF_DPhi = new TH1D("h_RVBF_DPhi","",4,dphiEdges); h_RVBF_DPhi->Divide(hWTau_MCC_DPhi,hWEl_MCC_DPhi,1.,1.); TH1D* h_RVBF_Mjj = new TH1D("h_RVBF_Mjj","",4,MjjEdges); h_RVBF_Mjj->Divide(hWTau_MCC_Mjj,hWEl_MCC_Mjj,1.,1.); TH1D* h_RVBF_MET = new TH1D("h_RVBF_MET","",4,METEdges); h_RVBF_MET->Divide(hWTau_MCC_MET,hWEl_MCC_MET,1.,1.); TH1D* h_RVBF_CenJetEt = new TH1D("h_RVBF_CenJetEt","",4,CenJetEtEdges); h_RVBF_CenJetEt->Divide(hWTau_MCC_CenJetEt,hWEl_MCC_CenJetEt,1.,1.); //for (int i=1; i<=h_RGEN->GetNbinsX(); ++i)h_RGEN->SetBinError(i,0.); // no stat error from mc //for (int i=1; i<=h_RVBF_DPhi->GetNbinsX(); ++i) h_RVBF_DPhi->SetBinError(i,0.); // no stat error from mc //for (int i=1; i<=h_RVBF_MET->GetNbinsX(); ++i) h_RVBF_MET->SetBinError(i,0.); // no stat error from mc //for (int i=1; i<=h_RVBF_CenJetEt->GetNbinsX(); ++i) h_RVBF_CenJetEt->SetBinError(i,0.); // no stat error from mc TH1D* h_R_DPhi = new TH1D("h_R_DPhi","",4,dphiEdges); TH1D* h_R_Mjj = new TH1D("h_R_Mjj","",4,MjjEdges); TH1D* h_R_MET = new TH1D("h_R_MET","",4,METEdges); TH1D* h_R_CenJetEt = new TH1D("h_R_CenJetEt","",4,CenJetEtEdges); for (int ibin = 1; ibin <= h_R_DPhi->GetNbinsX(); ++ibin){ h_R_DPhi->SetBinContent(ibin, h_RVBF_DPhi->GetBinContent(ibin) * h_RGEN->GetBinContent(1)); h_R_DPhi->SetBinError(ibin, h_R_DPhi->GetBinContent(ibin) * sqrt(pow(h_RVBF_DPhi->GetBinError(ibin)/h_RVBF_DPhi->GetBinContent(ibin),2) + pow(h_RGEN->GetBinError(1)/ h_RGEN->GetBinContent(1),2))); } for (int ibin = 1; ibin <= h_R_Mjj->GetNbinsX(); ++ibin){ h_R_Mjj->SetBinContent(ibin, h_RVBF_Mjj->GetBinContent(ibin) * h_RGEN->GetBinContent(1)); h_R_Mjj->SetBinError(ibin, h_R_Mjj->GetBinContent(ibin) * sqrt(pow(h_RVBF_Mjj->GetBinError(ibin)/h_RVBF_Mjj->GetBinContent(ibin),2) + pow(h_RGEN->GetBinError(1)/ h_RGEN->GetBinContent(1),2))); } for (int ibin = 1; ibin <= h_R_MET->GetNbinsX(); ++ibin){ h_R_MET->SetBinContent(ibin, h_RVBF_MET->GetBinContent(ibin) * h_RGEN->GetBinContent(1)); h_R_MET->SetBinError(ibin, h_R_MET->GetBinContent(ibin) * sqrt(pow(h_RVBF_MET->GetBinError(ibin)/h_RVBF_MET->GetBinContent(ibin),2) + pow(h_RGEN->GetBinError(1)/ h_RGEN->GetBinContent(1),2))); } for (int ibin = 1; ibin <= h_R_CenJetEt->GetNbinsX(); ++ibin){ h_R_CenJetEt->SetBinContent(ibin, h_RVBF_CenJetEt->GetBinContent(ibin) * h_RGEN->GetBinContent(1)); h_R_CenJetEt->SetBinError(ibin, h_R_CenJetEt->GetBinContent(ibin) * sqrt(pow(h_RVBF_CenJetEt->GetBinError(ibin)/h_RVBF_CenJetEt->GetBinContent(ibin),2) + pow(h_RGEN->GetBinError(1)/ h_RGEN->GetBinContent(1),2))); } // lets calculate some stuff TH1D* hWTau_Prediction_DPhi = new TH1D("hWTau_Prediction_DPhi","",4,dphiEdges); hWTau_Prediction_DPhi->Add(hWEl_EstC_DPhi,1.); hWTau_Prediction_DPhi->Multiply(h_R_DPhi); TH1D* hWTau_Prediction_Mjj = new TH1D("hWTau_Prediction_Mjj","",4,MjjEdges); hWTau_Prediction_Mjj->Add(hWEl_EstC_Mjj,1.); hWTau_Prediction_Mjj->Multiply(h_R_Mjj); TH1D* hWTau_Prediction_MET = new TH1D("hWTau_Prediction_MET","",4,METEdges); hWTau_Prediction_MET->Add(hWEl_EstC_MET,1.); hWTau_Prediction_MET->Multiply(h_R_MET); TH1D* hWTau_Prediction_CenJetEt = new TH1D("hWTau_Prediction_CenJetEt","",4,CenJetEtEdges); hWTau_Prediction_CenJetEt->Add(hWEl_EstC_CenJetEt,1.); hWTau_Prediction_CenJetEt->Multiply(h_R_CenJetEt); double xsecRatio = (0.1125*0.6476)/(0.1057+(0.1125*0.1741)); // Ratio of w->Tau cross-section to w-?el cross section (includes w->el and w->tau->el) hWTau_Prediction_DPhi->Scale(xsecRatio); hWTau_Prediction_Mjj->Scale(xsecRatio); hWTau_Prediction_MET->Scale(xsecRatio); hWTau_Prediction_CenJetEt->Scale(xsecRatio); /////////////////////////// // Lots of screen output // /////////////////////////// std::cout << std::endl; std::cout << "***************** W Tau closure test from W El *****************" << std::endl; std::cout << std::endl; std::cout << "--- Binned by DPhiJJ ---" << std::endl; for (int a = 0; a < 4; a++){ std::cout << std::endl; std::cout << "Bin: " << dphiEdges[a] << " < dphi < " << dphiEdges[a+1] << "" << std::endl; std::cout << "W->el channel" << std::endl; std::cout << " W+jets reco'd in ctrl : " << hWEl_MCC_DPhi->GetBinContent(a+1) << " +/- " << hWEl_MCC_DPhi->GetBinError(a+1) << std::endl; std::cout << " W+jets at gen level : " << hWEl_MCGen_DPhi->GetBinContent(a+1) << " +/- " << hWEl_MCGen_DPhi->GetBinError(a+1) << std::endl; std::cout << " Background ctrl region : " << hWEl_BGC_DPhi->GetBinContent(a+1) << " +/- " << hWEl_BGC_DPhi->GetBinError(a+1) << std::endl; std::cout << " Data ctrl region : " << hWEl_DataC_DPhi->GetBinContent(a+1) << " +/- " << hWEl_DataC_DPhi->GetBinError(a+1) << std::endl; std::cout << " Data-bg ctrl region : " << hWEl_EstC_DPhi->GetBinContent(a+1) << " +/- " << hWEl_EstC_DPhi->GetBinError(a+1) << std::endl; std::cout << std::endl; std::cout << "W->tau channel" << std::endl; std::cout << " W+jets reco'd in ctrl (MC estimate in ctrl) : " << hWTau_MCC_DPhi->GetBinContent(a+1) << " +/- " << hWTau_MCC_DPhi->GetBinError(a+1) << std::endl; std::cout << " W+jets at gen level : " << hWTau_MCGen_DPhi->GetBinContent(a+1) << " +/- " << hWTau_MCGen_DPhi->GetBinError(a+1) << std::endl; std::cout << " Background ctrl region : " << hWTau_BGC_DPhi->GetBinContent(a+1) << " +/- " << hWTau_BGC_DPhi->GetBinError(a+1) << std::endl; std::cout << " Data ctrl region : " << hWTau_DataC_DPhi->GetBinContent(a+1) << " +/- " << hWTau_DataC_DPhi->GetBinError(a+1) << std::endl; std::cout << std::endl; std::cout << " WTau in ctrl region observed : " << hWTau_EstC_DPhi->GetBinContent(a+1) << " +/- " << hWTau_EstC_DPhi->GetBinError(a+1) << std::endl; std::cout << std::endl; std::cout << " Closure test: WTau from WEl : " << hWTau_Prediction_DPhi->GetBinContent(a+1) << " +/- " << hWTau_Prediction_DPhi->GetBinError(a+1) << std::endl; std::cout << std::endl; } std::cout << std::endl; std::cout << "--- Binned by Mjj ---" << std::endl; for (int b = 0; b < 4; b++) { std::cout << std::endl; std::cout << "Bin: " << MjjEdges[b] << " < Mjj < " << MjjEdges[b+1] << "" << std::endl; std::cout << "W->el channel" << std::endl; std::cout << " W+jets reco'd in ctrl : " << hWEl_MCC_Mjj->GetBinContent(b+1) << " +/- " << hWEl_MCC_Mjj->GetBinError(b+1) << std::endl; std::cout << " Background ctrl region : " << hWEl_BGC_Mjj->GetBinContent(b+1) << " +/- " << hWEl_BGC_Mjj->GetBinError(b+1) << std::endl; std::cout << " Data ctrl region : " << hWEl_DataC_Mjj->GetBinContent(b+1) << " +/- " << hWEl_DataC_Mjj->GetBinError(b+1) << std::endl; std::cout << " Data-bg ctrl region : " << hWEl_EstC_Mjj->GetBinContent(b+1) << " +/- " << hWEl_EstC_Mjj->GetBinError(b+1) << std::endl; std::cout << std::endl; std::cout << "W->tau channel" << std::endl; std::cout << " W+jets reco'd in ctrl (MC estimate in ctrl) : " << hWTau_MCC_Mjj->GetBinContent(b+1) << " +/- " << hWTau_MCC_Mjj->GetBinError(b+1) << std::endl; std::cout << " Background ctrl region : " << hWTau_BGC_Mjj->GetBinContent(b+1) << " +/- " << hWTau_BGC_Mjj->GetBinError(b+1) << std::endl; std::cout << " Data ctrl region : " << hWTau_DataC_Mjj->GetBinContent(b+1) << " +/- " << hWTau_DataC_Mjj->GetBinError(b+1) << std::endl; std::cout << std::endl; std::cout << " WTau in ctrl region observed : " << hWTau_EstC_Mjj->GetBinContent(b+1) << " +/- " << hWTau_EstC_Mjj->GetBinError(b+1) << std::endl; std::cout << std::endl; std::cout << " Closure test: WTau from WEl : " << hWTau_Prediction_Mjj->GetBinContent(b+1) << " +/- " << hWTau_Prediction_Mjj->GetBinError(b+1) << std::endl; std::cout << std::endl; } std::cout << std::endl; std::cout << "--- Binned by MET ---" << std::endl; for (int b = 0; b < 4; b++) { std::cout << std::endl; std::cout << "Bin: " << METEdges[b] << " < MET < " << METEdges[b+1] << "" << std::endl; std::cout << "W->el channel" << std::endl; std::cout << " W+jets reco'd in ctrl : " << hWEl_MCC_MET->GetBinContent(b+1) << " +/- " << hWEl_MCC_MET->GetBinError(b+1) << std::endl; std::cout << " Background ctrl region : " << hWEl_BGC_MET->GetBinContent(b+1) << " +/- " << hWEl_BGC_MET->GetBinError(b+1) << std::endl; std::cout << " Data ctrl region : " << hWEl_DataC_MET->GetBinContent(b+1) << " +/- " << hWEl_DataC_MET->GetBinError(b+1) << std::endl; std::cout << " Data-bg ctrl region : " << hWEl_EstC_MET->GetBinContent(b+1) << " +/- " << hWEl_EstC_MET->GetBinError(b+1) << std::endl; std::cout << std::endl; std::cout << "W->tau channel" << std::endl; std::cout << " W+jets reco'd in ctrl (MC estimate in ctrl) : " << hWTau_MCC_MET->GetBinContent(b+1) << " +/- " << hWTau_MCC_MET->GetBinError(b+1) << std::endl; std::cout << " Background ctrl region : " << hWTau_BGC_MET->GetBinContent(b+1) << " +/- " << hWTau_BGC_MET->GetBinError(b+1) << std::endl; std::cout << " Data ctrl region : " << hWTau_DataC_MET->GetBinContent(b+1) << " +/- " << hWTau_DataC_MET->GetBinError(b+1) << std::endl; std::cout << std::endl; std::cout << " WTau in ctrl region observed : " << hWTau_EstC_MET->GetBinContent(b+1) << " +/- " << hWTau_EstC_MET->GetBinError(b+1) << std::endl; std::cout << std::endl; std::cout << " Closure test: WTau from WEl : " << hWTau_Prediction_MET->GetBinContent(b+1) << " +/- " << hWTau_Prediction_MET->GetBinError(b+1) << std::endl; std::cout << std::endl; } std::cout << std::endl; std::cout << "--- Binned by CenJetEt ---" << std::endl; for (int c = 0; c<4; c++){ std::cout << std::endl; std::cout << "Bin: " << CenJetEtEdges[c] << " < Central Jet Et < " << CenJetEtEdges[c+1] << "" << std::endl; std::cout << "W->el channel" << std::endl; std::cout << " W+jets reco'd in ctrl : " << hWEl_MCC_CenJetEt->GetBinContent(c+1) << " +/- " << hWEl_MCC_CenJetEt->GetBinError(c+1) << std::endl; std::cout << " Background ctrl region : " << hWEl_BGC_CenJetEt->GetBinContent(c+1) << " +/- " << hWEl_BGC_CenJetEt->GetBinError(c+1) << std::endl; std::cout << " Data ctrl region : " << hWEl_DataC_CenJetEt->GetBinContent(c+1) << " +/- " << hWEl_DataC_CenJetEt->GetBinError(c+1) << std::endl; std::cout << " Data-bg ctrl region : " << hWEl_EstC_CenJetEt->GetBinContent(c+1) << " +/- " << hWEl_EstC_CenJetEt->GetBinError(c+1) << std::endl; std::cout << std::endl; std::cout << "W->tau channel" << std::endl; std::cout << " W+jets reco'd in ctrl (MC estimate in ctrl) : " << hWTau_MCC_CenJetEt->GetBinContent(c+1) << " +/- " << hWTau_MCC_CenJetEt->GetBinError(c+1) << std::endl; std::cout << " Background ctrl region : " << hWTau_BGC_CenJetEt->GetBinContent(c+1) << " +/- " << hWTau_BGC_CenJetEt->GetBinError(c+1) << std::endl; std::cout << " Data ctrl region : " << hWTau_DataC_CenJetEt->GetBinContent(c+1) << " +/- " << hWTau_DataC_CenJetEt->GetBinError(c+1) << std::endl; std::cout << std::endl; std::cout << " WTau in ctrl region observed : " << hWTau_EstC_CenJetEt->GetBinContent(c+1) << " +/- " << hWTau_EstC_CenJetEt->GetBinError(c+1) << std::endl; std::cout << std::endl; std::cout << " Closure test: WTau from WEl : " << hWTau_Prediction_CenJetEt->GetBinContent(c+1) << " +/- " << hWTau_Prediction_CenJetEt->GetBinError(c+1) << std::endl; std::cout << std::endl; } //////////////////////// // draw closure plots // //////////////////////// std::string pdfName; gStyle->SetOptStat(0); gStyle->SetOptFit(111111111); double x_dPhi[4] = {0.5, 1.4, 2.2, 2.6 + (TMath::Pi()-2.6)/2}; double ex_dPhi[4] = {0.5, 0.4, 0.4, (TMath::Pi()-2.6)/2}; double y_dPhi1[4],ey_dPhi1[4],y_dPhi2[4],ey_dPhi2[4],y_dPhi3[4],ey_dPhi3[4]; // For raw numbers - prediceted (data), observed, predicted (MC) double frac_dPhi[4],efrac_dPhi[4]; // For Frac diff double x_Mjj[4] = {900., 1100., 1500., 2400.}; double ex_Mjj[4] = {100, 100, 300, 600}; double y_Mjj1[4],ey_Mjj1[4],y_Mjj2[4],ey_Mjj2[4],y_Mjj3[4],ey_Mjj3[4]; // For raw numbers - prediceted (data), observed, predicted (MC) double frac_Mjj[4],efrac_Mjj[4]; // For Frac diff double x_MET[4] = {125., 175., 225., 275.}; double ex_MET[4] = {25, 25, 25, 25}; double y_MET1[4],ey_MET1[4],y_MET2[4],ey_MET2[4],y_MET3[4],ey_MET3[4]; // For raw numbers - prediceted (data), observed, predicted (MC) double frac_MET[4],efrac_MET[4]; // For Frac diff //double x_CenJetEt[4] = {25, 55, 95, 160}; //double ex_CenJetEt[4] = {15, 15, 25, 40}; double x_CenJetEt[4] = {20., 45., 80., 125.}; double ex_CenJetEt[4] = {10, 15, 20, 25}; double y_CenJetEt1[4],ey_CenJetEt1[4],y_CenJetEt2[4],ey_CenJetEt2[4],y_CenJetEt3[4],ey_CenJetEt3[4]; // For raw numbers - prediceted (data), observed, predicted (MC) double frac_CenJetEt[4],efrac_CenJetEt[4]; // For Frac diff double y_syst[4],e_syst[4]; // for systematic bands for(int i=0; i<4; ++i) { y_syst[i] = 0.; //e_syst[i] = sqrt( pow(0.2,2) + pow(constants::syst_WTau,2) ); // 20% from MC stats, plus whatever the current value of Tau syst from TAU ID, w-e contamination, JER etc e_syst[i] = constants::syst_WTau; y_dPhi1[i] = hWTau_Prediction_DPhi->GetBinContent(i+1); //Predicted WTau ey_dPhi1[i] = hWTau_Prediction_DPhi->GetBinError(i+1); y_dPhi2[i] = hWTau_EstC_DPhi->GetBinContent(i+1); //Observed WTau ey_dPhi2[i] = hWTau_EstC_DPhi->GetBinError(i+1); y_dPhi3[i] = hWTau_MCC_DPhi->GetBinContent(i+1); //MC prediction ey_dPhi3[i] = hWTau_MCC_DPhi->GetBinError(i+1); frac_dPhi[i] = (y_dPhi1[i]/y_dPhi2[i])-1.; efrac_dPhi[i] = (y_dPhi1[i]/y_dPhi2[i])*sqrt(pow(ey_dPhi1[i]/y_dPhi1[i],2) + pow(ey_dPhi2[i]/y_dPhi2[i],2)); y_Mjj1[i] = hWTau_Prediction_Mjj->GetBinContent(i+1); //Predicted WTau ey_Mjj1[i] = hWTau_Prediction_Mjj->GetBinError(i+1); y_Mjj2[i] = hWTau_EstC_Mjj->GetBinContent(i+1); //Observed WTau ey_Mjj2[i] = hWTau_EstC_Mjj->GetBinError(i+1); y_Mjj3[i] = hWTau_MCC_Mjj->GetBinContent(i+1); //MC prediction ey_Mjj3[i] = hWTau_MCC_Mjj->GetBinError(i+1); frac_Mjj[i] = (y_Mjj1[i]/y_Mjj2[i])-1.; efrac_Mjj[i] = (y_Mjj1[i]/y_Mjj2[i])*sqrt(pow(ey_Mjj1[i]/y_Mjj1[i],2) + pow(ey_Mjj2[i]/y_Mjj2[i],2)); y_MET1[i] = hWTau_Prediction_MET->GetBinContent(i+1); //Predicted WTau ey_MET1[i] = hWTau_Prediction_MET->GetBinError(i+1); y_MET2[i] = hWTau_EstC_MET->GetBinContent(i+1); //Observed WTau ey_MET2[i] = hWTau_EstC_MET->GetBinError(i+1); y_MET3[i] = hWTau_MCC_MET->GetBinContent(i+1); //MC prediction ey_MET3[i] = hWTau_MCC_MET->GetBinError(i+1); frac_MET[i] = (y_MET1[i]/y_MET2[i])-1.; efrac_MET[i] = (y_MET1[i]/y_MET2[i])*sqrt(pow(ey_MET1[i]/y_MET1[i],2) + pow(ey_MET2[i]/y_MET2[i],2)); y_CenJetEt1[i] = hWTau_Prediction_CenJetEt->GetBinContent(i+1); //Predicted WTau ey_CenJetEt1[i] = hWTau_Prediction_CenJetEt->GetBinError(i+1); y_CenJetEt2[i] = hWTau_EstC_CenJetEt->GetBinContent(i+1); //Observed WTau ey_CenJetEt2[i] = hWTau_EstC_CenJetEt->GetBinError(i+1); y_CenJetEt3[i] = hWTau_MCC_CenJetEt->GetBinContent(i+1); //MC prediction ey_CenJetEt3[i] = hWTau_MCC_CenJetEt->GetBinError(i+1); frac_CenJetEt[i] = (y_CenJetEt1[i]/y_CenJetEt2[i])-1.; efrac_CenJetEt[i] = (y_CenJetEt1[i]/y_CenJetEt2[i])*sqrt(pow(ey_CenJetEt1[i]/y_CenJetEt1[i],2) + pow(ey_CenJetEt2[i]/y_CenJetEt2[i],2)); } TGraphErrors *gp_dPhi1 = new TGraphErrors(4,x_dPhi,y_dPhi1,ex_dPhi,ey_dPhi1); TGraphErrors *gp_dPhi2 = new TGraphErrors(4,x_dPhi,y_dPhi2,ex_dPhi,ey_dPhi2); TGraphErrors *gp_dPhi3 = new TGraphErrors(4,x_dPhi,y_dPhi3,ex_dPhi,ey_dPhi3); TGraphErrors *gp_dPhiF = new TGraphErrors(4,x_dPhi,frac_dPhi,ex_dPhi,efrac_dPhi); TGraphErrors *gp_dPhiS = new TGraphErrors(4,x_dPhi,y_syst,ex_dPhi,e_syst); // systematic error bands TGraphErrors *gp_Mjj1 = new TGraphErrors(4,x_Mjj,y_Mjj1,ex_Mjj,ey_Mjj1); TGraphErrors *gp_Mjj2 = new TGraphErrors(4,x_Mjj,y_Mjj2,ex_Mjj,ey_Mjj2); TGraphErrors *gp_Mjj3 = new TGraphErrors(4,x_Mjj,y_Mjj3,ex_Mjj,ey_Mjj3); TGraphErrors *gp_MjjF = new TGraphErrors(4,x_Mjj,frac_Mjj,ex_Mjj,efrac_Mjj); TGraphErrors *gp_MjjS = new TGraphErrors(4,x_Mjj,y_syst,ex_Mjj,e_syst); // systematic error bands TGraphErrors *gp_MET1 = new TGraphErrors(4,x_MET,y_MET1,ex_MET,ey_MET1); TGraphErrors *gp_MET2 = new TGraphErrors(4,x_MET,y_MET2,ex_MET,ey_MET2); TGraphErrors *gp_MET3 = new TGraphErrors(4,x_MET,y_MET3,ex_MET,ey_MET3); TGraphErrors *gp_METF = new TGraphErrors(4,x_MET,frac_MET,ex_MET,efrac_MET); TGraphErrors *gp_METS = new TGraphErrors(4,x_MET,y_syst,ex_MET,e_syst); // systematic error bands TGraphErrors *gp_CenJetEt1 = new TGraphErrors(4,x_CenJetEt,y_CenJetEt1,ex_CenJetEt,ey_CenJetEt1); TGraphErrors *gp_CenJetEt2 = new TGraphErrors(4,x_CenJetEt,y_CenJetEt2,ex_CenJetEt,ey_CenJetEt2); TGraphErrors *gp_CenJetEt3 = new TGraphErrors(4,x_CenJetEt,y_CenJetEt3,ex_CenJetEt,ey_CenJetEt3); TGraphErrors *gp_CenJetEtF = new TGraphErrors(4,x_CenJetEt,frac_CenJetEt,ex_CenJetEt,efrac_CenJetEt); TGraphErrors *gp_CenJetEtS = new TGraphErrors(4,x_CenJetEt,y_syst,ex_CenJetEt,e_syst); // systematic error bands TH1D *h_dPhi = new TH1D("h_dPhi", "", 1, 0, TMath::Pi()); // For axes TH1D *h_Mjj = new TH1D("h_Mjj", "", 1, 800, 3000); // For axes TH1D *h_MET = new TH1D("h_MET", "", 1, 100, 300); // For axes TH1D *h_CenJetEt = new TH1D("h_CenJetEt", "", 1, 10, 150); // For axes TPaveText *cms = new TPaveText(0.12, 0.68, 0.58 , 0.88, "NDC"); cms->SetFillColor(0); cms->SetFillStyle(4000); cms->SetBorderSize(0); cms->SetLineColor(0); cms->SetTextAlign(12); cms->AddText("CMS Preliminary"); cms->AddText(""); cms->AddText("#sqrt{s} = 8 TeV L = 19.6 fb^{-1}"); cms->AddText(""); TCanvas canvas; canvas.SetCanvasSize(canvas.GetWindowWidth(), 1.2*canvas.GetWindowHeight()); /////////////////// // DPhiJJ graphs // /////////////////// // Absolute numbers gp_dPhi1->SetTitle(""); gp_dPhi1->SetMarkerStyle(20); gp_dPhi1->SetMarkerSize(0.9); gp_dPhi1->SetLineColor(kRed); gp_dPhi1->SetMarkerColor(kRed); gp_dPhi1->GetXaxis()->SetTitle("#Delta #phi_{jj}"); gp_dPhi1->GetXaxis()->SetRangeUser(0,TMath::Pi()); gp_dPhi1->GetYaxis()->SetTitle("N(W#rightarrow #tau#nu)"); gp_dPhi1->GetYaxis()->SetTitleOffset(1.2); gp_dPhi1->GetYaxis()->SetRangeUser(0,80); gp_dPhi1->Draw("AP"); gp_dPhi2->SetMarkerStyle(20); gp_dPhi2->SetMarkerSize(0.9); gp_dPhi2->SetLineColor(kBlue); gp_dPhi2->SetMarkerColor(kBlue); gp_dPhi2->Draw("P same"); gp_dPhi3->SetMarkerStyle(20); gp_dPhi3->SetMarkerSize(0.9); gp_dPhi3->SetLineColor(kViolet); gp_dPhi3->SetMarkerColor(kViolet); gp_dPhi3->Draw("P same"); TLegend leg(0.12,0.67,0.32,0.87); leg.SetBorderSize(0); leg.SetFillColor(0); leg.AddEntry(gp_dPhi1,"predicted (data)","P"); leg.AddEntry(gp_dPhi2,"observed (data)","P"); leg.AddEntry(gp_dPhi3,"predicted (MC)","P"); leg.Draw(); pdfName= options.oDir + std::string("/Wtaunu_dphi_num.pdf"); canvas.Print(pdfName.c_str()); // Fractional diff h_dPhi->Draw(); h_dPhi->GetXaxis()->SetTitle("#Delta #phi_{jj}"); h_dPhi->GetYaxis()->SetTitle("#frac{Predicted - Observed}{Observed}"); h_dPhi->GetYaxis()->SetTitleOffset(1.2); h_dPhi->GetYaxis()->SetRangeUser(-1.0,2.0); h_dPhi->SetLineColor(kBlue); h_dPhi->SetLineWidth(2); h_dPhi->Draw(); gp_dPhiS->SetLineColor(kGray); gp_dPhiS->SetLineWidth(0); gp_dPhiS->SetFillColor(kGray); gp_dPhiS->SetFillStyle(3001); gp_dPhiF->SetMarkerStyle(20); gp_dPhiF->SetMarkerSize(1.4); gp_dPhiF->SetMarkerColor(kBlue); gp_dPhiF->SetLineWidth(2); TF1 *f_dPhi = new TF1("f_dPhi","pol0",0,2.6); //To do a fit in first 3 bins only gp_dPhiF->Fit("f_dPhi","R"); h_dPhi->Draw(); gp_dPhiS->Draw("2 same"); gp_dPhiF->Draw("P same"); TLegend leg2_dphi(0.12,0.67,0.40,0.87); leg2_dphi.SetBorderSize(0); leg2_dphi.SetFillColor(0); leg2_dphi.AddEntry(f_dPhi,"pol0 fit (0 < #Delta #phi_{jj} < 2.6)","l"); leg2_dphi.AddEntry(gp_dPhiS,"Systematic error","f"); leg2_dphi.Draw(); pdfName= options.oDir + std::string("/Wtaunu_dphi_frac.pdf"); canvas.Print(pdfName.c_str()); //////////////// // Mjj graphs // //////////////// gp_Mjj1->SetTitle(""); gp_Mjj1->SetMarkerStyle(20); gp_Mjj1->SetMarkerSize(0.9); gp_Mjj1->SetLineColor(kRed); gp_Mjj1->SetMarkerColor(kRed); gp_Mjj1->GetXaxis()->SetTitle("M_{jj} [GeV]"); gp_Mjj1->GetXaxis()->SetRangeUser(800.,3000.); gp_Mjj1->GetYaxis()->SetTitle("N(W#rightarrow #tau#nu)"); gp_Mjj1->GetYaxis()->SetTitleOffset(1.2); gp_Mjj1->GetYaxis()->SetRangeUser(0.,50.); gp_Mjj1->Draw("AP"); gp_Mjj2->SetMarkerStyle(20); gp_Mjj2->SetMarkerSize(0.9); gp_Mjj2->SetLineColor(kBlue); gp_Mjj2->SetMarkerColor(kBlue); gp_Mjj2->Draw("P same"); gp_Mjj3->SetMarkerStyle(20); gp_Mjj3->SetMarkerSize(0.9); gp_Mjj3->SetLineColor(kViolet); gp_Mjj3->SetMarkerColor(kViolet); gp_Mjj3->Draw("P same"); leg.Draw(); pdfName= options.oDir + std::string("/Wtaunu_mjj_num.pdf"); canvas.Print(pdfName.c_str()); h_Mjj->Draw(); h_Mjj->GetXaxis()->SetTitle("M_{jj} [GeV]"); h_Mjj->GetYaxis()->SetTitle("#frac{Predicted - Observed}{Observed}"); h_Mjj->GetYaxis()->SetTitleOffset(1.2); h_Mjj->GetYaxis()->SetRangeUser(-3.0,10.0); h_Mjj->SetLineColor(kBlue); h_Mjj->SetLineWidth(2); h_Mjj->Draw(); gp_MjjS->SetLineColor(kGray); gp_MjjS->SetLineWidth(0); gp_MjjS->SetFillColor(kGray); gp_MjjS->SetFillStyle(3001); gp_MjjF->SetMarkerStyle(20); gp_MjjF->SetMarkerSize(1.4); gp_MjjF->SetMarkerColor(kBlue); gp_MjjF->SetLineWidth(2); TF1 *f_Mjj = new TF1("f_Mjj","pol0",800,3000); gp_MjjF->Fit("f_Mjj","R"); h_Mjj->Draw(); gp_MjjS->Draw("2 same"); gp_MjjF->Draw("P same"); TLegend leg2_mjj(0.12,0.67,0.40,0.87); leg2_mjj.SetBorderSize(0); leg2_mjj.SetFillColor(0); leg2_mjj.AddEntry(f_Mjj,"pol0 fit","l"); leg2_mjj.AddEntry(gp_MjjS,"Systematic error","f"); leg2_mjj.Draw(); pdfName= options.oDir + std::string("/Wtaunu_mjj_frac.pdf"); canvas.Print(pdfName.c_str()); //////////////// // MET graphs // //////////////// gp_MET1->SetTitle(""); gp_MET1->SetMarkerStyle(20); gp_MET1->SetMarkerSize(0.9); gp_MET1->SetLineColor(kRed); gp_MET1->SetMarkerColor(kRed); gp_MET1->GetXaxis()->SetTitle("E_{T}^{miss} [GeV]"); gp_MET1->GetXaxis()->SetRangeUser(100,300); gp_MET1->GetYaxis()->SetTitle("N(W#rightarrow #tau#nu)"); gp_MET1->GetYaxis()->SetTitleOffset(1.2); gp_MET1->GetYaxis()->SetRangeUser(0,40); gp_MET1->Draw("AP"); gp_MET2->SetMarkerStyle(20); gp_MET2->SetMarkerSize(0.9); gp_MET2->SetLineColor(kBlue); gp_MET2->SetMarkerColor(kBlue); gp_MET2->Draw("P same"); gp_MET3->SetMarkerStyle(20); gp_MET3->SetMarkerSize(0.9); gp_MET3->SetLineColor(kViolet); gp_MET3->SetMarkerColor(kViolet); gp_MET3->Draw("P same"); leg.Draw(); pdfName= options.oDir + std::string("/Wtaunu_met_num.pdf"); canvas.Print(pdfName.c_str()); h_MET->Draw(); h_MET->GetXaxis()->SetTitle("E_{T}^{miss} [GeV]"); h_MET->GetYaxis()->SetTitle("#frac{Predicted - Observed}{Observed}"); h_MET->GetYaxis()->SetTitleOffset(1.2); h_MET->GetYaxis()->SetRangeUser(-3.0,5.0); h_MET->SetLineColor(kBlue); h_MET->SetLineWidth(2); h_MET->Draw(); gp_METS->SetLineColor(kGray); gp_METS->SetLineWidth(0); gp_METS->SetFillColor(kGray); gp_METS->SetFillStyle(3001); gp_METF->SetMarkerStyle(20); gp_METF->SetMarkerSize(1.4); gp_METF->SetMarkerColor(kBlue); gp_METF->SetLineWidth(2); TF1 *f_MET = new TF1("f_MET","pol0",100,300); gp_METF->Fit("f_MET","R"); h_MET->Draw(); gp_METS->Draw("2 same"); gp_METF->Draw("P same"); TLegend leg2_met(0.12,0.67,0.40,0.87); leg2_met.SetBorderSize(0); leg2_met.SetFillColor(0); leg2_met.AddEntry(f_MET,"pol0 fit","l"); leg2_met.AddEntry(gp_METS,"Systematic error","f"); leg2_met.Draw(); pdfName= options.oDir + std::string("/Wtaunu_met_frac.pdf"); canvas.Print(pdfName.c_str()); ///////////////////// // CenJetEt graphs // ///////////////////// gp_CenJetEt1->SetTitle(""); gp_CenJetEt1->SetMarkerStyle(20); gp_CenJetEt1->SetMarkerSize(0.9); gp_CenJetEt1->SetLineColor(kRed); gp_CenJetEt1->SetMarkerColor(kRed); gp_CenJetEt1->GetXaxis()->SetTitle("Central Jet E_{T} [Gev]"); gp_CenJetEt1->GetXaxis()->SetRangeUser(10,150); gp_CenJetEt1->GetYaxis()->SetTitle("N(W#rightarrow #tau#nu)"); gp_CenJetEt1->GetYaxis()->SetTitleOffset(1.2); gp_CenJetEt1->GetYaxis()->SetRangeUser(0,40); gp_CenJetEt1->Draw("AP"); gp_CenJetEt2->SetMarkerStyle(20); gp_CenJetEt2->SetMarkerSize(0.9); gp_CenJetEt2->SetLineColor(kBlue); gp_CenJetEt2->SetMarkerColor(kBlue); gp_CenJetEt2->Draw("P same"); gp_CenJetEt3->SetMarkerStyle(20); gp_CenJetEt3->SetMarkerSize(0.9); gp_CenJetEt3->SetLineColor(kViolet); gp_CenJetEt3->SetMarkerColor(kViolet); gp_CenJetEt3->Draw("P same"); leg.Draw(); pdfName= options.oDir + std::string("/Wtaunu_CenJetEt_num.pdf"); canvas.Print(pdfName.c_str()); h_CenJetEt->Draw(); h_CenJetEt->GetXaxis()->SetTitle("Central Jet E_{T} [Gev]"); h_CenJetEt->GetYaxis()->SetTitle("#frac{Predicted - Observed}{Observed}"); h_CenJetEt->GetYaxis()->SetTitleOffset(1.2); h_CenJetEt->GetYaxis()->SetRangeUser(-3.0,5.0); h_CenJetEt->SetLineColor(kBlue); h_CenJetEt->SetLineWidth(2); h_CenJetEt->Draw(); gp_CenJetEtS->SetLineColor(kGray); gp_CenJetEtS->SetLineWidth(0); gp_CenJetEtS->SetFillColor(kGray); gp_CenJetEtS->SetFillStyle(3001); gp_CenJetEtF->SetMarkerStyle(20); gp_CenJetEtF->SetMarkerSize(1.4); gp_CenJetEtF->SetMarkerColor(kBlue); gp_CenJetEtF->SetLineWidth(2); TF1 *f_CenJetEt = new TF1("f_CenJetEt","pol0",10,150); gp_CenJetEtF->Fit("f_CenJetEt","R"); h_CenJetEt->Draw(); gp_CenJetEtS->Draw("2 same"); gp_CenJetEtF->Draw("P same"); TLegend leg2_cenjet(0.12,0.67,0.40,0.87); leg2_cenjet.SetBorderSize(0); leg2_cenjet.SetFillColor(0); leg2_cenjet.AddEntry(f_CenJetEt,"pol0 fit","l"); leg2_cenjet.AddEntry(gp_CenJetEtS,"Systematic error","f"); leg2_cenjet.Draw(); pdfName= options.oDir + std::string("/Wtaunu_CenJetEt_frac.pdf"); canvas.Print(pdfName.c_str()); }
void EleScaleClosureTest() { //-------------------------------------------------------------------------------------------------------------- // Settings //============================================================================================================== // event category enumeration enum { eEleEle2HLT=1, eEleEle1HLT1L1, eEleEle1HLT, eEleEleNoSel, eEleSC }; // Create output directory TString outputDir = "EleScaleClosureTestResults"; TString pufname = "../Tools/pileup_weights_2015B.root"; gSystem->mkdir(outputDir,kTRUE); vector<TString> infilenamev; infilenamev.push_back("/afs/cern.ch/work/c/cmedlock/public/wz-ntuples/Zee/ntuples/data_select.root"); // data infilenamev.push_back("/afs/cern.ch/work/c/cmedlock/public/wz-ntuples/Zee/ntuples/zee_select.raw.root"); // MC (raw) infilenamev.push_back("/afs/cern.ch/work/c/cmedlock/public/wz-ntuples/Zee/ntuples/zee_select.raw.root"); // MC2 (corrected) enum { eData=0, eMC, eMC2 }; Float_t lumi=40.0; const Int_t NBINS = 40; const Double_t MASS_LOW = 80; const Double_t MASS_HIGH = 100; const Double_t PT_CUT = 25; const Double_t ETA_CUT = 2.5; const Double_t ELE_MASS = 0.000511; vector<pair<Double_t,Double_t> > scEta_limits; scEta_limits.push_back(make_pair(0.0,0.4)); scEta_limits.push_back(make_pair(0.4,0.8)); scEta_limits.push_back(make_pair(0.8,1.4442)); scEta_limits.push_back(make_pair(1.566,2.5)); CPlot::sOutDir = outputDir; const TString format("png"); TRandom3 *rnd = new TRandom3(); //-------------------------------------------------------------------------------------------------------------- // Main analysis code //============================================================================================================== TFile *pufile = new TFile(pufname); assert(pufile); TH1D *puWeights = (TH1D*)pufile->Get("npv_rw"); TH1D* hData_Tot = new TH1D("hData_Tot","",NBINS,MASS_LOW,MASS_HIGH); hData_Tot->Sumw2(); TH1D* hMC_Tot = new TH1D("hMC_Tot","",NBINS,MASS_LOW,MASS_HIGH); hMC_Tot->Sumw2(); TH1D* hMC2_Tot = new TH1D("hMC2_Tot","",NBINS,MASS_LOW,MASS_HIGH); hMC2_Tot->Sumw2(); char hname[100]; vector<TH1D*> hMCv, hDatav, hMC2v; for(UInt_t ibin=0; ibin<scEta_limits.size(); ibin++) { for(UInt_t jbin=ibin; jbin<scEta_limits.size(); jbin++) { sprintf(hname,"data_%i_%i",ibin,jbin); hDatav.push_back(new TH1D(hname,"",NBINS,MASS_LOW,MASS_HIGH)); hDatav.back()->Sumw2(); sprintf(hname,"mc_%i_%i",ibin,jbin); hMCv.push_back(new TH1D(hname,"",NBINS,MASS_LOW,MASS_HIGH)); hMCv.back()->Sumw2(); sprintf(hname,"mc2_%i_%i",ibin,jbin); hMC2v.push_back(new TH1D(hname,"",NBINS,MASS_LOW,MASS_HIGH)); hMC2v.back()->Sumw2(); } } // // Declare output ntuple variables // UInt_t runNum, lumiSec, evtNum; UInt_t matchGen; UInt_t category; UInt_t npv, npu; Int_t q1, q2; Float_t scale1fb, puWeight; TLorentzVector *dilep=0, *lep1=0, *lep2=0; ///// electron specific ///// TLorentzVector *sc1=0, *sc2=0; for(UInt_t ifile=0; ifile<infilenamev.size(); ifile++) { cout << "Processing " << infilenamev[ifile] << "..." << endl; TFile *infile = TFile::Open(infilenamev[ifile]); assert(infile); TTree *intree = (TTree*)infile->Get("Events"); assert(intree); intree->SetBranchAddress("runNum", &runNum); // event run number intree->SetBranchAddress("lumiSec", &lumiSec); // event lumi section intree->SetBranchAddress("evtNum", &evtNum); // event number intree->SetBranchAddress("scale1fb", &scale1fb); // event weight intree->SetBranchAddress("puWeight", &puWeight); // pileup reweighting intree->SetBranchAddress("matchGen", &matchGen); // event has both leptons matched to MC Z->ll intree->SetBranchAddress("category", &category); // dilepton category intree->SetBranchAddress("npv", &npv); // number of primary vertices intree->SetBranchAddress("npu", &npu); // number of in-time PU events (MC) intree->SetBranchAddress("q1", &q1); // charge of lead lepton intree->SetBranchAddress("q2", &q2); // charge of trail lepton intree->SetBranchAddress("dilep", &dilep); // dilepton 4-vector intree->SetBranchAddress("lep1", &lep1); // lead lepton 4-vector intree->SetBranchAddress("lep2", &lep2); // trail lepton 4-vector intree->SetBranchAddress("sc1", &sc1); // lead Supercluster 4-vector intree->SetBranchAddress("sc2", &sc2); // trail Supercluster 4-vector for(UInt_t ientry=0; ientry<intree->GetEntries(); ientry++) { intree->GetEntry(ientry); Double_t weight = 1; if(ifile==eMC || ifile==eMC2) weight=scale1fb*lumi*puWeights->GetBinContent(npv+1); if((category!=eEleEle2HLT) && (category!=eEleEle1HLT) && (category!=eEleEle1HLT1L1)) continue; if(q1 == q2) continue; if(dilep->M() < MASS_LOW) continue; if(dilep->M() > MASS_HIGH) continue; if(sc1->Pt() < PT_CUT) continue; if(sc2->Pt() < PT_CUT) continue; if(fabs(sc1->Eta()) > ETA_CUT) continue; if(fabs(sc2->Eta()) > ETA_CUT) continue; TLorentzVector vLep1(0,0,0,0); TLorentzVector vLep2(0,0,0,0); if (ifile==eData) { vLep1.SetPtEtaPhiM(lep1->Pt(), lep1->Eta(), lep1->Phi(), ELE_MASS); vLep2.SetPtEtaPhiM(lep2->Pt(), lep2->Eta(), lep2->Phi(), ELE_MASS); } else if (ifile==eMC) { vLep1.SetPtEtaPhiM(lep1->Pt(), lep1->Eta(), lep1->Phi(), ELE_MASS); vLep2.SetPtEtaPhiM(lep2->Pt(), lep2->Eta(), lep2->Phi(), ELE_MASS); } else { vLep1.SetPtEtaPhiM(gRandom->Gaus(lep1->Pt()*getEleScaleCorr(lep1->Eta(),0),getEleResCorr(lep1->Eta(),0)), lep1->Eta(), lep1->Phi(), ELE_MASS); vLep2.SetPtEtaPhiM(gRandom->Gaus(lep2->Pt()*getEleScaleCorr(lep2->Eta(),0),getEleResCorr(lep2->Eta(),0)), lep2->Eta(), lep2->Phi(), ELE_MASS); } TLorentzVector vDilep = vLep1 + vLep2; Int_t bin1=-1, bin2=-1; for(UInt_t i=0; i<scEta_limits.size(); i++) { Double_t etalow = scEta_limits.at(i).first; Double_t etahigh = scEta_limits.at(i).second; if(fabs(sc1->Eta())>=etalow && fabs(sc1->Eta())<=etahigh) bin1=i; if(fabs(sc2->Eta())>=etalow && fabs(sc2->Eta())<=etahigh) bin2=i; } assert(bin1>=0); assert(bin2>=0); Int_t ibin= (bin1<=bin2) ? bin1 : bin2; Int_t jbin= (bin1<=bin2) ? bin2 : bin1; if (ifile==eData) hData_Tot->Fill(vDilep.M(),weight); else if (ifile==eMC) hMC_Tot->Fill(vDilep.M(),weight); else if (ifile==eMC2) hMC2_Tot->Fill(vDilep.M(),weight); UInt_t n=jbin-ibin; for(Int_t k=0; k<ibin; k++) n+=(scEta_limits.size()-k); if(ifile==eData) hDatav[n]->Fill(vDilep.M(),weight); else if(ifile==eMC) hMCv[n]->Fill(vDilep.M(),weight); else if(ifile==eMC2) hMC2v[n]->Fill(vDilep.M(),weight); } delete infile; infile=0, intree=0; } TCanvas *c1 = MakeCanvas("c1", "", 800, 800); char pname[100]; c1->Divide(1,2,0,0); c1->cd(1)->SetPad(0,0.3,1.0,1.0); c1->cd(1)->SetTopMargin(0.1); c1->cd(1)->SetBottomMargin(0.01); //0.01 c1->cd(1)->SetLeftMargin(0.15); c1->cd(1)->SetRightMargin(0.07); c1->cd(1)->SetTickx(1); c1->cd(1)->SetTicky(1); c1->cd(2)->SetPad(0,0,1.0,0.3); c1->cd(2)->SetTopMargin(0.05); c1->cd(2)->SetBottomMargin(0.45);//0.25 c1->cd(2)->SetLeftMargin(0.15); c1->cd(2)->SetRightMargin(0.07); c1->cd(2)->SetTickx(1); c1->cd(2)->SetTicky(0); TGaxis::SetMaxDigits(3); for (UInt_t ibin=0; ibin<scEta_limits.size(); ibin++) { for(UInt_t jbin=ibin; jbin<scEta_limits.size(); jbin++) { UInt_t n=jbin-ibin; for(UInt_t k=0; k<ibin; k++) n+=(scEta_limits.size()-k); //hMCv[n] ->Scale(1.0/hMCv[n]->Integral()); //hDatav[n] ->Scale(1.0/hDatav[n]->Integral()); //hMC2v[n]->Scale(1.0/hMC2v[n]->Integral()); c1->cd(1); hMCv[n]->SetLineColor(kRed); hMCv[n]->GetYaxis()->SetTitleOffset(1.100); hMCv[n]->GetYaxis()->SetTitle("Events"); hMCv[n]->GetYaxis()->SetRangeUser(0.01, 1.3*TMath::Max(hMCv[n]->GetMaximum(),hDatav[n]->GetMaximum())); hMCv[n]->Draw("hist"); hDatav[n]->Draw("EX0 same"); hMC2v[n]->SetLineColor(kBlue); hMC2v[n]->Draw("histsame"); c1->cd(2); TH1D* hDiffMC = returnRelDiff(hMCv[n],hDatav[n],"foo"); TH1D* hDiffMC2 = returnRelDiff(hMC2v[n],hDatav[n],"foo2"); hDiffMC->GetYaxis()->SetRangeUser(-1.0,1.0); hDiffMC->GetXaxis()->SetTitle("m_{ee} [GeV]"); hDiffMC->GetYaxis()->SetTitle("#chi"); hDiffMC->GetYaxis()->SetTitleOffset(0.42); hDiffMC->GetYaxis()->SetTitleSize(0.13); hDiffMC->GetXaxis()->SetTitleSize(0.13); hDiffMC->GetYaxis()->SetLabelSize(0.12); hDiffMC->GetXaxis()->SetLabelSize(0.12); hDiffMC->GetYaxis()->SetNdivisions(102); hDiffMC->GetYaxis()->CenterTitle(); hDiffMC->GetXaxis()->SetTitleOffset(1.2); hDiffMC->GetXaxis()->CenterTitle(); hDiffMC->Draw("hist"); TLine l(80,0.0,100,0.0); l.Draw(); hDiffMC->Draw("histsame"); hDiffMC2->SetMarkerColor(kBlue); hDiffMC2->SetMarkerSize(1); hDiffMC2->SetLineColor(kBlue); hDiffMC2->Draw("EX0 same"); c1->cd(1); TLegend *leg = new TLegend(0.65, 0.55, 0.90, 0.80); leg->SetShadowColor(0); leg->SetLineColor(0); leg->AddEntry(hMCv[n],"Raw MC","l"); leg->AddEntry(hDatav[n],"Data","l"); leg->AddEntry(hMC2v[n],"Corr. MC","l"); leg->Draw(); // CMS label TPaveText tb1(0.65,0.92,0.95,0.99,"NDC"); tb1.SetFillStyle(0); tb1.SetBorderSize(0); tb1.SetTextAlign(32); tb1.AddText("CMS Preliminary"); tb1.Draw(); char buffer[200]; // lumi label sprintf(buffer,"%.1f pb^{-1} at #sqrt{s} = 13 TeV",lumi); TPaveText tb2(0.55,0.82,0.90,0.90,"NDC"); tb2.SetFillStyle(0); tb2.SetBorderSize(0); tb2.SetTextAlign(32); tb2.AddText(buffer); tb2.Draw(); char str1[200],str2[200]; sprintf(str1,"[%.1f, %.1f]",scEta_limits.at(ibin).first,scEta_limits.at(ibin).second); sprintf(str2,"[%.1f, %.1f]",scEta_limits.at(jbin).first,scEta_limits.at(jbin).second); TPaveText *a = new TPaveText(0.16,0.75,0.40,0.82,"NDC"); a->SetFillColor(0); a->SetShadowColor(0); a->SetLineColor(0); a->AddText(str1); TPaveText *b = new TPaveText(0.16,0.68,0.40,0.75,"NDC"); b->SetFillColor(0); b->SetShadowColor(0); b->SetLineColor(0); b->AddText(str2); a->Draw(); b->Draw(); sprintf(pname,"ele_comp_%i_%i.png",ibin,jbin); c1->SaveAs(outputDir+"/"+pname); delete hDiffMC; delete hDiffMC2; } } cout << endl; cout << hMC_Tot->Integral() << ", " << hData_Tot->Integral() << ", " << hMC2_Tot->Integral() << endl; c1->cd(1); hMC_Tot->SetLineColor(kRed); hMC_Tot->SetMarkerColor(kRed); hMC_Tot->GetYaxis()->SetTitleOffset(1.100); hMC_Tot->GetYaxis()->SetTitle("Events"); hMC_Tot->GetYaxis()->SetRangeUser(0.01, 1.2*hMC_Tot->GetMaximum()); hMC_Tot->Draw("hist"); hData_Tot->Draw("EX0 same"); hMC2_Tot->SetLineColor(kBlue); hMC2_Tot->SetMarkerColor(kBlue); hMC2_Tot->Draw("hist same"); c1->cd(2); TH1D* hDiffMC = returnRelDiff(hMC_Tot,hData_Tot,"foo"); TH1D* hDiffMC2 = returnRelDiff(hMC2_Tot,hData_Tot,"foo2"); hDiffMC->GetYaxis()->SetRangeUser(-1.0,1.0); hDiffMC->GetXaxis()->SetTitle("m_{ee} [GeV]"); hDiffMC->GetYaxis()->SetTitle("#chi"); hDiffMC->GetYaxis()->SetTitleOffset(0.42); hDiffMC->GetYaxis()->SetTitleSize(0.13); hDiffMC->GetXaxis()->SetTitleSize(0.13); hDiffMC->GetYaxis()->SetLabelSize(0.12); hDiffMC->GetXaxis()->SetLabelSize(0.12); hDiffMC->GetYaxis()->SetNdivisions(102); hDiffMC->GetYaxis()->CenterTitle(); hDiffMC->GetXaxis()->SetTitleOffset(1.2); hDiffMC->GetXaxis()->CenterTitle(); hDiffMC->SetMarkerColor(kRed); hDiffMC->SetMarkerSize(1); hDiffMC->SetLineColor(kRed); hDiffMC->Draw("hist"); TLine l(80,0.0,100,0.0); l.Draw(); //hDiffMC->Draw("EX0 same"); hDiffMC2->SetMarkerColor(kBlue); hDiffMC2->SetMarkerSize(1); hDiffMC2->SetLineColor(kBlue); hDiffMC2->Draw("EX0 same"); c1->cd(1); TLegend *leg = new TLegend(0.65, 0.55, 0.90, 0.80); leg->SetShadowColor(0); leg->SetLineColor(0); leg->AddEntry(hMC_Tot,"Raw MC","l"); leg->AddEntry(hData_Tot,"Data","l"); leg->AddEntry(hMC2_Tot,"Corr. MC","l"); leg->Draw(); // CMS label TPaveText tb1(0.65,0.92,0.95,0.99,"NDC"); tb1.SetFillStyle(0); tb1.SetBorderSize(0); tb1.SetTextAlign(32); tb1.AddText("CMS Preliminary"); tb1.Draw(); char buffer[200]; // lumi label sprintf(buffer,"%.1f pb^{-1} at #sqrt{s} = 13 TeV",lumi); TPaveText tb2(0.55,0.82,0.90,0.90,"NDC"); tb2.SetFillStyle(0); tb2.SetBorderSize(0); tb2.SetTextAlign(32); tb2.AddText(buffer); tb2.Draw(); char str1[200],str2[200]; sprintf(str1,"[%.1f, %.1f]",scEta_limits.at(0).first,scEta_limits.at(scEta_limits.size()-1).second); sprintf(str2,"[%.1f, %.1f]",scEta_limits.at(0).first,scEta_limits.at(scEta_limits.size()-1).second); TPaveText *a = new TPaveText(0.16,0.75,0.40,0.82,"NDC"); a->SetFillColor(0); a->SetShadowColor(0); a->SetLineColor(0); a->AddText(str1); TPaveText *b = new TPaveText(0.16,0.68,0.40,0.75,"NDC"); b->SetFillColor(0); b->SetShadowColor(0); b->SetLineColor(0); b->AddText(str2); a->Draw(); b->Draw(); sprintf(pname,"ele_comp_tot.png"); c1->SaveAs(outputDir+"/"+pname); }
void DrawPtResolutionComparison(const char algorithm[100]) { const int NETA = 6; const double eta_boundaries[NETA+1]={0.0,0.55,1.1,1.7,2.5,3.2,5.0}; TCanvas *c[NETA],*c1[NETA]; int i,j,etabin,counter; char name[100],cname[100],filename[100]; TF1 *fitRes[NETA][2]; TFile *inf[2]; sprintf(filename,"ResolutionResults_%s_AllJets.root",algorithm); inf[0] = new TFile(filename); sprintf(filename,"ResolutionResults_%s_LeadingJets.root",algorithm); inf[1] = new TFile(filename); for(etabin=0;etabin<NETA;etabin++) { sprintf(name,"ResolutionFit_Eta%d",etabin); fitRes[etabin][0] = (TF1*)inf[0]->Get(name); fitRes[etabin][1] = (TF1*)inf[1]->Get(name); } for(etabin=0;etabin<NETA;etabin++) { double ptmax = TMath::Min(2000.,5000./cosh(eta_boundaries[etabin])); TH1F *tmp = new TH1F("tmp","tmp",100,20,ptmax); sprintf(name,"%1.2f<|y|<%1.2f",eta_boundaries[etabin],eta_boundaries[etabin+1]); TPaveText *pave = new TPaveText(0.6,0.7,0.9,0.9,"NDC"); pave->AddText("Monte Carlo Truth"); pave->AddText(name); if (strcmp(algorithm,"SC7")==0) pave->AddText("Seedless Cone R = 0.7"); else pave->AddText("k_{T} D = 0.6"); pave->SetFillColor(0); pave->SetLineColor(0); pave->SetBorderSize(0); pave->SetTextFont(42); TLegend *leg = new TLegend(0.6,0.6,0.9,0.7); sprintf(cname,"%s_Resolution_EtaBin%d",algorithm,etabin); c1[etabin] = new TCanvas(cname,cname); c1[etabin]->cd(); gPad->SetLogx(); tmp->SetTitle(""); tmp->SetMaximum(0.4); tmp->SetMinimum(0.); tmp->GetXaxis()->SetTitle("Particle jet p_{T} (GeV)"); tmp->GetYaxis()->SetTitle("Relative Energy Resolution"); fitRes[etabin][0]->SetLineColor(1); fitRes[etabin][1]->SetLineColor(2); tmp->Draw(); fitRes[etabin][0]->Draw("same"); fitRes[etabin][1]->Draw("same"); leg->AddEntry(fitRes[etabin][0],"All jets","L"); leg->AddEntry(fitRes[etabin][1],"2 leading jets","L"); leg->SetFillColor(0); leg->SetLineColor(0); leg->SetBorderSize(0); leg->SetTextFont(42); leg->Draw(); pave->Draw(); } }
void complex_1() { gROOT->GetListOfCanvases()->Delete(); TCanvas *c = new TCanvas("composite shape", "A * B - C", 700, 1000); c->Divide(1,2,0,0); c->cd(2); gPad->SetPad(0,0,1,0.4); c->cd(1); gPad->SetPad(0,0.4,1,1); if (gGeoManager) delete gGeoManager; new TGeoManager("xtru", "poza12"); TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7); TGeoMedium *med = new TGeoMedium("MED",1,mat); TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100); gGeoManager->SetTopVolume(top); // define shape components with names TGeoBBox *box = new TGeoBBox("box", 20., 20., 20.); TGeoBBox *box1 = new TGeoBBox("box1", 5., 5., 5.); TGeoSphere *sph = new TGeoSphere("sph", 5., 25.); TGeoSphere *sph1 = new TGeoSphere("sph1", 1., 15.); // create the composite shape based on a Boolean expression TGeoTranslation *tr = new TGeoTranslation(0., 30., 0.); TGeoTranslation *tr1 = new TGeoTranslation(0., 40., 0.); TGeoTranslation *tr2 = new TGeoTranslation(0., 30., 0.); TGeoTranslation *tr3 = new TGeoTranslation(0., 30., 0.); tr->SetName("tr"); tr1->SetName("tr1"); tr2->SetName("tr2"); tr3->SetName("tr3"); // register all used transformations tr->RegisterYourself(); tr1->RegisterYourself(); tr2->RegisterYourself(); tr3->RegisterYourself(); TGeoCompositeShape *cs = new TGeoCompositeShape("mir", "(sph * box) + (sph1:tr - box1:tr1)"); TGeoVolume *vol = new TGeoVolume("COMP4",cs); // vol->SetLineColor(randomColor()); top->AddNode(vol,1); gGeoManager->CloseGeometry(); gGeoManager->SetNsegments(80); top->Draw(); MakePicture(); c->cd(2); TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99); pt->SetLineColor(1); TText *text = pt->AddText("TGeoCompositeShape - composite shape class"); text->SetTextColor(2); pt->AddText("----- (sphere * box) + (sphere - box) "); pt->AddText(" "); pt->SetAllWith("-----","color",4); pt->SetAllWith("-----","font",72); pt->SetAllWith("-----","size",0.04); pt->SetTextAlign(12); pt->SetTextSize(0.044); pt->Draw(); c->cd(1); }
TPaveText* RDK2AnalysisPlotter::makeTitleBox(CoDet detType) { TString line; TPaveText* titleBox = new TPaveText(.00,.0,1,1,"NDC"); titleBox->SetFillColor(kWhite); titleBox->SetLineColor(kWhite); titleBox->SetTextAlign(11); titleBox->SetTextFont(102); //Make outline for title // TBox* theBox; // int numLines=getTitleBoxLines( detType); // int numLinesPerExpAnalysis; // int numLinesPerMCAnalysis; // int currentLine=0; // double y0, y1; // if(detType!=DET_EP) // { // numLinesPerExpAnalysis=4; // numLinesPerMCAnalysis=3; // } // else // { // numLinesPerExpAnalysis=2; // numLinesPerMCAnalysis=2; // } // y0=1.-1/(double)numLines; // y1=1; // theBox=titleBox->AddBox(0,y0,1.,y1); // theBox->SetFillStyle(0); // titleBox->AddText(""); TString coTypeString; if(detType==DET_EP) { coTypeString="EP"; } else if(detType==DET_EPG) { coTypeString="EPG (BGO)"; } else if(detType==DET_EPBG) { coTypeString="EPBG (BAPD)"; } double answer,error; titleBox->AddText("Title: "+titleString+" Coincidence: "+coTypeString+" Date made: "+getCurrentDateString()); for (int i = 0;i< numExp;i++) { // y0=y0-numLinesPerExpAnalysis/(double) numLines; // y1=y0; // theBox=titleBox->AddBox(0,y0,1,y1); // theBox->SetFillStyle(0); int theColor=colorList[(i+4)%GRAPHICS_NUM_TYPES]; line="#color["+int2str(theColor)+"]{"; line+=TString("Exp: ") + exp[i]->GetName()+" \"" + exp[i]->GetTitle() + "\" " + exp[i]->GetPIDString()+" " + exp[i]->GetGroupString(); line+=TString(" EP Counts: ") + int2str(exp[i]->GetEPCounts()); line+="}"; titleBox->AddText(line); if(detType==DET_EPG) { line="#color["+int2str(theColor)+"]{"; answer=exp[i]->GetEPGCounts(error); line+=TString(" EPG Counts: ") + int2str((int) (answer+0.5))+" #pm " + int2str((int) (error+0.5)); answer=exp[i]->GetEPGPerEP(error); line+=TString(" #frac{EPG}{EP}: ") + d2str(answer,2,2)+" #pm " + d2str(error,1,2) +" (#pm"+d2str(error*100./answer,1,1)+"%)"; line +="}"; titleBox->AddText(line); } else if(detType==DET_EPBG) { line="#color["+int2str(theColor)+"]{"; answer=exp[i]->GetEPBGCounts(error); line+=TString(" EPBG Counts: ") + int2str((int) (answer+0.5))+" #pm " + int2str((int) (error+0.5)); answer=exp[i]->GetEPBGPerEP(error); line+=TString(" #frac{EPBG}{EP}: ") + d2str(answer,2,2)+" #pm " + d2str(error,1,2)+" (#pm"+d2str(error*100./answer,1,1)+"%)"; line +="}"; titleBox->AddText(line); } //Third Line if(detType != DET_EP) { line="#color["+int2str(theColor)+"]{"; line+=" Prepeak BG Window: ["+d2str(exp[i]->GetWindowVal(detType,0))+","+d2str(exp[i]->GetWindowVal(detType,1))+"]"; line+=" Peak Window: ["+d2str(exp[i]->GetWindowVal(detType,2))+","+d2str(exp[i]->GetWindowVal(detType,3))+"] "; line+=" Postpeak BG Window: ["+d2str(exp[i]->GetWindowVal(detType,4))+","+d2str(exp[i]->GetWindowVal(detType,5))+"] "; line +="}"; titleBox->AddText(line); } //Fourth Line line="#color["+int2str(theColor)+"]{"; line+=" "+exp[i]->GetCutSet().GetDisplayString( detType); line +="}"; titleBox->AddText(line); } //Plot MC for (int i = 0;i< numMC;i++) { // y0=y0-numLinesPerMCAnalysis/(double) numLines; // y1=y0; // theBox=titleBox->AddBox(0,y0,1,y1); // theBox->SetFillStyle(0); // currentLine+=numLinesPerMCAnalysis; int theColor=colorList[(i)%GRAPHICS_NUM_TYPES]; //First MC Line line="#color["+int2str(theColor)+"]{"; line+=TString("MC: ") + mc[i]->GetName()+" \"" + mc[i]->GetTitle() + "\""; line+=" P_{3}"+mc[i]->GetP3ID()(3,3)+" E_{3}"+mc[i]->GetE3ID()(3,3); if(detType==DET_EPG || detType==DET_EPBG) { line+=" P_{4}"+mc[i]->GetP4ID()(3,3)+" E_{4}"+mc[i]->GetE4ID()(3,3)+" G_{4}"+mc[i]->GetG4ID()(3,3); } answer=mc[i]->GetEPPer3Decay(error); line+=TString(" EP per 3 Decay: ") + d2str(answer,5,1)+" #pm " + d2str(error,5,1); line +="}"; titleBox->AddText(line); //Second MC Line if(detType==DET_EPG) { line="#color["+int2str(theColor)+"]{"; answer=mc[i]->GetEPGPer4Decay(error); line+=TString(" EPG per 4 Decay: ") + d2str(answer,6,1)+" #pm " + d2str(error,6,1); answer=mc[i]->GetEPGPerEP(error); line+=TString(" #frac{EPG}{EP}: ") + d2str(answer,3,2)+" #pm " + d2str(error,1,2)+" (#pm"+d2str(error*100./answer,1,1)+"%)"; if(numExp>0) { double expAnswer,expError; double mcAnswer, mcError; expAnswer=exp[0]->GetEPGPerEP(expError); mcAnswer=mc[i]->GetEPGPerEP(mcError); answer=(expAnswer/mcAnswer)-1; error=getBasicErrorProgation(expAnswer,mcAnswer,expError,mcError,DIVISION); line+=TString(" #frac{Exp - MC}{MC}: ") +d2str(answer*100,1,1)+"% #pm " + d2str(error*100,1,1)+"%"; } line +="}"; titleBox->AddText(line); } else if(detType==DET_EPBG) { line="#color["+int2str(theColor)+"]{"; answer=mc[i]->GetEPBGPer4Decay(error); line+=TString(" EPBG per 4 Decay: ") + d2str(answer,6,1)+" #pm " + d2str(error,6,1); answer=mc[i]->GetEPBGPerEP(error); line+=TString(" #frac{EPBG}{EP}: ") + d2str(answer,3,2)+" #pm " + d2str(error,1,2)+" (#pm"+d2str(error*100./answer,1,1)+"%)"; if(numExp>0) { double expAnswer,expError; double mcAnswer, mcError; expAnswer=exp[0]->GetEPGPerEP(expError); mcAnswer=mc[i]->GetEPGPerEP(mcError); answer=(expAnswer/mcAnswer)-1; error=getBasicErrorProgation(expAnswer,mcAnswer,expError,mcError,DIVISION); line+=TString(" #frac{Exp - MC}{MC}: ") +d2str(answer*100,1,1)+"% #pm " + d2str(error*100,1,1)+"%"; } line +="}"; titleBox->AddText(line); } //Third Line line="#color["+int2str(theColor)+"]{"; line+=" "+mc[i]->GetCutSet().GetDisplayString( detType); line +="}"; titleBox->AddText(line); } return titleBox; }
void DrawL2(int etabin) { gROOT->SetStyle("Plain"); gStyle->SetOptStat(0000); gStyle->SetOptFit(000); gStyle->SetPalette(1); if (etabin<0 || etabin>=NETA) { cout<<"Eta bin must be >=0 and <"<<NETA<<endl; break; } TPaveText *pave = new TPaveText(0.3,0.7,0.5,0.85,"NDC"); pave->AddText(Version); pave->AddText(Algorithm); pave->SetLineColor(0); pave->SetBorderSize(0); pave->SetFillColor(0); pave->SetBorderSize(0); TGraphErrors *g_EtaCorrection; TGraph *g_L2Correction; TCanvas *c_Resp; TCanvas *c_L2Cor; TF1 *L2Fit; TF1 *CorFit; TFile *rel_f; char filename[100],name[100]; rel_f = new TFile(L2OutputROOTFilename,"r"); if (!rel_f->IsOpen()) break; /////////////////////////////// Correction ///////////////////////// sprintf(name,"EtaCorrection"); c_Cor = new TCanvas(name,name,900,700); sprintf(name,"Correction_EtaBin%d",etabin); g_EtaCorrection = (TGraphErrors*)rel_f->Get(name); sprintf(name,"Correction%d",etabin); CorFit = (TF1*)g_EtaCorrection->GetFunction(name); if (CorFit->GetXmax()>200) gPad->SetLogx(); CorFit->SetLineColor(2); g_EtaCorrection->GetXaxis()->SetTitle("Uncorrected jet p_{T} (GeV)"); g_EtaCorrection->GetYaxis()->SetTitle("Absolute Correction"); sprintf(name,"%1.3f<#eta<%1.3f",eta_boundaries[etabin],eta_boundaries[etabin+1]); g_EtaCorrection->SetTitle(name); g_EtaCorrection->SetMarkerStyle(20); g_EtaCorrection->Draw("AP"); pave->Draw(); /////////////////////////////// L2 correction ///////////////////////// sprintf(name,"L2Correction"); c_L2Cor = new TCanvas(name,name,900,700); sprintf(name,"L2Correction_EtaBin%d",etabin); g_L2Correction = (TGraph*)rel_f->Get(name); sprintf(name,"L2Correction%d",etabin); L2Fit = (TF1*)g_L2Correction->GetFunction(name); if (L2Fit->GetXmax()>200) gPad->SetLogx(); g_L2Correction->SetMinimum(0.3); g_L2Correction->SetMaximum(1.4); g_L2Correction->GetXaxis()->SetTitle("Uncorrected jet p_{T} (GeV)"); g_L2Correction->GetYaxis()->SetTitle("Relative Correction"); sprintf(name,"%1.3f<#eta<%1.3f",eta_boundaries[etabin],eta_boundaries[etabin+1]); g_L2Correction->SetTitle(name); g_L2Correction->Draw("AP"); g_L2Correction->SetMarkerStyle(20); L2Fit->SetLineColor(2); pave->Draw(); }
void csv2() { TString sysname ="CSV.root"; TFile *sysinput(0); sysinput = TFile::Open( sysname ); // if not: download from ROOT server std::vector<string> variables_; TString name; variables_.push_back("BDT__zjethist"); // variables_.push_back("BDT__phjethist"); variables_.push_back("BDT__tbartchhist"); variables_.push_back("BDT__tt3hist"); variables_.push_back("BDT__ttphhist"); variables_.push_back("BDT__wwphhist"); variables_.push_back("BDT__zzhist"); variables_.push_back("BDT__zgammahist"); variables_.push_back("BDT__singleantitopphotonhist"); std::vector<TH1F*> addhists; std::vector<TH1F*> wjetandwphjet; wjetandwphjet.push_back((TH1F*) sysinput->Get((std::string("BDT__wjet").c_str()))); wjetandwphjet.push_back((TH1F*) sysinput->Get((std::string("BDT__wphjethist").c_str()))); std::vector<TH1F*> jesuphists; for(unsigned int i=0; i<variables_.size(); ++i){ name=variables_[i]+"__JES__plus"; jesuphists.push_back((TH1F*) sysinput->Get(name)); } //jesuphists.push_back((TH1F*) sysinput->Get((std::string("BDT__wjet").c_str()))); //jesuphists.push_back((TH1F*) sysinput->Get((std::string("BDT__wphjethist").c_str()))); for(unsigned int idx=1; idx<variables_.size(); ++idx){ jesuphists[idx]->Add(jesuphists[idx-1]); } addhists.push_back(jesuphists[variables_.size()-1]); std::vector<TH1F*> jesdownhists; for(unsigned int i=0; i<variables_.size(); ++i){ name=variables_[i]+"__JES__minus"; jesdownhists.push_back((TH1F*) sysinput->Get(name));} for(unsigned int idx=1; idx<variables_.size(); ++idx){ jesdownhists[idx]->Add(jesdownhists[idx-1]);} addhists.push_back(jesdownhists[variables_.size()-1]); std::vector<TH1F*> jeruphists; for(unsigned int i=0; i<variables_.size(); ++i){ name=variables_[i]+"__JER__plus"; jeruphists.push_back((TH1F*) sysinput->Get(name));} for(unsigned int idx=1; idx<variables_.size(); ++idx){ jeruphists[idx]->Add(jeruphists[idx-1]);} addhists.push_back(jeruphists[variables_.size()-1]); std::vector<TH1F*> jerdownhists; for(unsigned int i=0; i<variables_.size(); ++i){ name=variables_[i]+"__JER__minus"; jerdownhists.push_back((TH1F*) sysinput->Get(name));} for(unsigned int idx=1; idx<variables_.size(); ++idx){ jerdownhists[idx]->Add(jerdownhists[idx-1]);} addhists.push_back(jerdownhists[variables_.size()-1]); std::vector<TH1F*> phesuphists; for(unsigned int i=0; i<variables_.size(); ++i){ name=variables_[i]+"__PhES__plus"; phesuphists.push_back((TH1F*) sysinput->Get(name));} for(unsigned int idx=1; idx<variables_.size(); ++idx){ phesuphists[idx]->Add(phesuphists[idx-1]);} addhists.push_back(phesuphists[variables_.size()-1]); std::vector<TH1F*> phesdownhists; for(unsigned int i=0; i<variables_.size(); ++i){ name=variables_[i]+"__PhES__minus"; phesdownhists.push_back((TH1F*) sysinput->Get(name));} for(unsigned int idx=1; idx<variables_.size(); ++idx){ phesdownhists[idx]->Add(phesdownhists[idx-1]);} addhists.push_back(phesdownhists[variables_.size()-1]); std::vector<TH1F*> puuphists; for(unsigned int i=0; i<variables_.size(); ++i){ name=variables_[i]+"__PU__plus"; puuphists.push_back((TH1F*) sysinput->Get(name));} for(unsigned int idx=1; idx<variables_.size(); ++idx){ puuphists[idx]->Add(puuphists[idx-1]);} addhists.push_back(puuphists[variables_.size()-1]); std::vector<TH1F*> pudownhists; for(unsigned int i=0; i<variables_.size(); ++i){ name=variables_[i]+"__PU__minus"; pudownhists.push_back((TH1F*) sysinput->Get(name));} for(unsigned int idx=1; idx<variables_.size(); ++idx){ pudownhists[idx]->Add(pudownhists[idx-1]);} addhists.push_back(pudownhists[variables_.size()-1]); std::vector<TH1F*> triguphists; for(unsigned int i=0; i<variables_.size(); ++i){ name=variables_[i]+"__TRIG__plus"; triguphists.push_back((TH1F*) sysinput->Get(name));} for(unsigned int idx=1; idx<variables_.size(); ++idx){ triguphists[idx]->Add(triguphists[idx-1]);} addhists.push_back(triguphists[variables_.size()-1]); std::vector<TH1F*> trigdownhists; for(unsigned int i=0; i<variables_.size(); ++i){ name=variables_[i]+"__TRIG__minus"; trigdownhists.push_back((TH1F*) sysinput->Get(name));} for(unsigned int idx=1; idx<variables_.size(); ++idx){ trigdownhists[idx]->Add(trigdownhists[idx-1]);} addhists.push_back(trigdownhists[variables_.size()-1]); std::vector<TH1F*> btaguphists; for(unsigned int i=0; i<variables_.size(); ++i){ name=variables_[i]+"__BTAG__plus"; btaguphists.push_back((TH1F*) sysinput->Get(name));} for(unsigned int idx=1; idx<variables_.size(); ++idx){ btaguphists[idx]->Add(btaguphists[idx-1]);} addhists.push_back(btaguphists[variables_.size()-1]); std::vector<TH1F*> btagdownhists; for(unsigned int i=0; i<variables_.size(); ++i){ name=variables_[i]+"__BTAG__minus"; btagdownhists.push_back((TH1F*) sysinput->Get(name));} for(unsigned int idx=1; idx<variables_.size(); ++idx){ btagdownhists[idx]->Add(btagdownhists[idx-1]);} addhists.push_back(btagdownhists[variables_.size()-1]); std::vector<TH1F*> misstaguphists; for(unsigned int i=0; i<variables_.size(); ++i){ name=variables_[i]+"__MISSTAG__plus"; misstaguphists.push_back((TH1F*) sysinput->Get(name));} for(unsigned int idx=1; idx<variables_.size(); ++idx){ misstaguphists[idx]->Add(misstaguphists[idx-1]);} addhists.push_back(misstaguphists[variables_.size()-1]); std::vector<TH1F*> misstagdownhists; for(unsigned int i=0; i<variables_.size(); ++i){ name=variables_[i]+"__MISSTAG__minus"; misstagdownhists.push_back((TH1F*) sysinput->Get(name));} for(unsigned int idx=1; idx<variables_.size(); ++idx){ misstagdownhists[idx]->Add(misstagdownhists[idx-1]);} addhists.push_back(misstagdownhists[variables_.size()-1]); std::vector<TH1F*> muonuphists; for(unsigned int i=0; i<variables_.size(); ++i){ name=variables_[i]+"__MUON__plus"; muonuphists.push_back((TH1F*) sysinput->Get(name));} for(unsigned int idx=1; idx<variables_.size(); ++idx){ muonuphists[idx]->Add(muonuphists[idx-1]);} addhists.push_back(muonuphists[variables_.size()-1]); std::vector<TH1F*> muondownhists; for(unsigned int i=0; i<variables_.size(); ++i){ name=variables_[i]+"__MUON__minus"; muondownhists.push_back((TH1F*) sysinput->Get(name));} for(unsigned int idx=1; idx<variables_.size(); ++idx){ muondownhists[idx]->Add(muondownhists[idx-1]);} addhists.push_back(muondownhists[variables_.size()-1]); std::vector<TH1F*> photonuphists; for(unsigned int i=0; i<variables_.size(); ++i){ name=variables_[i]+"__PHOTON__plus"; photonuphists.push_back((TH1F*) sysinput->Get(name));} for(unsigned int idx=1; idx<variables_.size(); ++idx){ photonuphists[idx]->Add(photonuphists[idx-1]);} addhists.push_back(photonuphists[variables_.size()-1]); std::vector<TH1F*> photondownhists; for(unsigned int i=0; i<variables_.size(); ++i){ name=variables_[i]+"__PHOTON__minus"; photondownhists.push_back((TH1F*) sysinput->Get(name));} for(unsigned int idx=1; idx<variables_.size(); ++idx){ photondownhists[idx]->Add(photondownhists[idx-1]);} addhists.push_back(photondownhists[variables_.size()-1]); std::vector<std::vector<double_t> > vec(photondownhists[0]->GetNbinsX(), vector<double>(18)); for(int p = 0; p <photondownhists[0]->GetNbinsX(); p++){ //loop over bins for(int m = 0; m < 18; m++){ //loop over systematics vec[p][m]=addhists[m]->GetBinContent(p+1)+wjetandwphjet[0]->GetBinContent(p+1)+wjetandwphjet[1]->GetBinContent(p+1); cout<<vec[p][m]<<endl; }} // Book output histograms UInt_t nbin = 20; double min=0; double max=1; // Prepare input tree (this must be replaced by your data source) // in this example, there is a toy tree with signal and one with background events // we'll later on use only the "signal" events for the test in this example. // TFile *input(0); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// std::vector<string> samples_; std::vector<string> datasamples_; std::vector<TH1F*> hists; std::vector<TH1F*> datahists; std::vector<TH1F*> revDATAhists; float scales[] = {0.628,0.0978,34.01,6.133,1.04,0.32,0.02,0.002,0.0961,0.0253,0.0224,0.0145,0.0125,0.0160,0.0158,0.0341,0.0341,0.0341,0.020,0.0017,0.0055,0.0032,0.00084,0.02,0.01139,0.01139,0.049094905/19.145}; samples_.push_back("WJET.root"); samples_.push_back("ZJET.root"); samples_.push_back("G_Pt_50to80.root"); samples_.push_back("G_Pt_80to120.root"); samples_.push_back("G_Pt_120to170.root"); samples_.push_back("G_Pt_170to300.root"); samples_.push_back("G_Pt_300to470.root"); samples_.push_back("G_Pt_470to800.root"); samples_.push_back("WPHJET.root"); samples_.push_back("T-W-CH.root"); samples_.push_back("TBAR-W-CH.root"); samples_.push_back("T-S-CH.root"); samples_.push_back("TBAR-S-CH.root"); samples_.push_back("T-T-CH.root"); samples_.push_back("TBAR-T-CH.root"); samples_.push_back("TTBAR1.root"); samples_.push_back("TTBAR2.root"); samples_.push_back("TTBAR3.root"); samples_.push_back("TTG.root"); samples_.push_back("WWG.root"); samples_.push_back("WW.root"); samples_.push_back("WZ.root"); samples_.push_back("ZZ.root"); samples_.push_back("ZGAMMA.root"); samples_.push_back("SINGLE-TOP-PH.root"); samples_.push_back("SINGLE-ANTITOP-PH.root"); samples_.push_back("SIGNALtGu.root"); datasamples_.push_back("REALDATA1.root"); datasamples_.push_back("REALDATA2.root"); datasamples_.push_back("REALDATA3.root"); std::vector<string> datasamplesreverse_; datasamplesreverse_.push_back("etarev/REALDATA1.root"); datasamplesreverse_.push_back("etarev/REALDATA2.root"); datasamplesreverse_.push_back("etarev/REALDATA3.root"); TH1F *wphjethist(0), *zjethist(0) , *phjethist(0), *wjethist(0), *twchhist(0), *tbarwhist(0), *tschhist(0), *tbarschhist(0), *ttchhist(0), *tbartchhist(0), *tt1hist(0) ,*tt2hist(0), *tt3hist(0), *ttphhist(0), *wwphhist(0), *wwhist(0), *wzhist(0), *zzhist(0), *zgammahist(0),*singletopphotonhist(0), *singleantitopphotonhist(0), *signalhist(0), *G_Pt_50to80(0),*G_Pt_80to120(0), *G_Pt_120to170(0), *G_Pt_170to300(0) ,*G_Pt_300to470(0),*G_Pt_470to800(0) ; TH1F *wphjethistSB(0), *zjethistSB(0) , *phjethistSB(0), *wjethistSB(0), *twchhistSB(0), *tbarwhistSB(0), *tschhistSB(0), *tbarschhistSB(0), *ttchhistSB(0), *tbartchhistSB(0), *tt1histSB(0) ,*tt2histSB(0), *tt3histSB(0), *ttphhistSB(0), *wwphhistSB(0), *wwhistSB(0), *wzhistSB(0), *zzhistSB(0), *zgammahistSB(0),*singletopphotonhistSB(0), *singleantitopphotonhistSB(0), *signalhistSB(0), *G_Pt_50to80SB(0),*G_Pt_80to120SB(0), *G_Pt_120to170SB(0), *G_Pt_170to300SB(0) ,*G_Pt_300to470SB(0),*G_Pt_470to800SB(0) ; TH1F *data1hist(0), *data2hist(0) ,*data3hist(0) ,*datahistsideband(0); TH1F *data1histrev(0), *data2histrev(0) ,*data3histrev(0), *datahistrevsideband(0); wphjethist = new TH1F( "mu_BDT__wphjethist", "mu_BDT__wphjethist", nbin, min, max ); zjethist = new TH1F( "mu_BDT__zjethist", "mu_BDT__zjethist", nbin, min, max ); G_Pt_50to80= new TH1F( "mu_BDT__G_Pt_50to80", "mu_BDT__G_Pt_50to80", nbin, min, max ); G_Pt_80to120= new TH1F( "mu_BDT__G_Pt_80to120", "mu_BDT__G_Pt_80to120", nbin, min, max ); G_Pt_120to170= new TH1F( "mu_BDT__G_Pt_120to170", "mu_BDT__G_Pt_120to170", nbin, min, max ); G_Pt_170to300= new TH1F( "mu_BDT__G_Pt_170to300", "mu_BDT__G_Pt_170to300", nbin, min, max ); G_Pt_300to470= new TH1F( "mu_BDT__G_Pt_300to470", "mu_BDT__G_Pt_300to470", nbin, min, max ); G_Pt_470to800= new TH1F( "mu_BDT__G_Pt_470to800", "mu_BDT__G_Pt_470to800", nbin, min, max ); wjethist = new TH1F( "mu_BDT__wjethist", "mu_BDT__wjethist", nbin, min, max); twchhist = new TH1F( "mu_BDT__twchhist", "mu_BDT__twchhist", nbin, min, max ); tbarwhist = new TH1F( "mu_BDT__tbarwhist", "mu_BDT__tbarwhist", nbin, min, max ); tschhist = new TH1F( "mu_BDT__tschhist", "mu_BDT__tschhist", nbin, min, max ); tbarschhist = new TH1F( "mu_BDT__tbarschhist", "mu_BDT__tbarschhist", nbin, min, max ); ttchhist = new TH1F( "mu_BDT__ttchhist", "mu_BDT__ttchhist", nbin, min, max ); tbartchhist = new TH1F( "mu_BDT__tbartchhist", "mu_BDT__tbartchhist", nbin, min, max); tt1hist = new TH1F( "mu_BDT__tt1hist", "mu_BDT__tt1hist", nbin,min, max ); tt2hist = new TH1F( "mu_BDT__tt2hist", "mu_BDT__tt2hist", nbin, min, max); tt3hist = new TH1F( "mu_BDT__tt3hist", "mu_BDT__tt3hist", nbin, min, max); ttphhist = new TH1F( "mu_BDT__ttphhist", "mu_BDT__ttphhist", nbin, min, max); wwphhist = new TH1F( "mu_BDT__wwphhist", "BDT__wwphhist", nbin,min, max ); wwhist = new TH1F( "mu_BDT__wwhist", "mu_BDT__wwhist", nbin,min, max ); wzhist = new TH1F( "mu_BDT__wzhist", "mu_BDT__wzhist", nbin, min, max ); zzhist = new TH1F( "mu_BDT__zzhist", "mu_BDT__zzhist", nbin, min, max ); zgammahist = new TH1F( "mu_BDT__zgammahist", "mu_BDT__zgammahist", nbin,min, max ); singletopphotonhist = new TH1F( "mu_BDT__singletopphotonhist", "mu_BDT__singletopphotonhist", nbin, min, max); singleantitopphotonhist = new TH1F( "mu_BDT__singleantitopphotonhist", "mu_BDT__singleantitopphotonhist", nbin,min, max ); signalhist = new TH1F( "mu_BDT__signal100", "mu_BDT__signal100", nbin, min, max ); data1hist = new TH1F( "mu_BDT__data1hist", "mu_BDT__data1hist", nbin, min, max ); data2hist = new TH1F( "mu_BDT__data2hist", "mu_BDT__data2hist", nbin, min, max ); data3hist = new TH1F( "mu_BDT__DATA", "mu_BDT__DATA", nbin, min, max ); datahistsideband = new TH1F( "mu_BDT__DATA_sideband", "mu_BDT__DATA_sideband", nbin, min, max); data1histrev = new TH1F( "mu_BDT__data1histrev", "mu_BDT__data1histrev", nbin, min, max ); data2histrev = new TH1F( "mu_BDT__data2histrev", "mu_BDT__data2histrev", nbin,min, max ); data3histrev = new TH1F( "mu_BDT__DATArev", "mu_BDT__DATArev", nbin, min, max ); datahistrevsideband = new TH1F( "mu_BDT__DATArevsideband", "mu_BDT__DATArevsideband", nbin, min, max ); wphjethistSB = new TH1F( "mu_BDT__wphjethist__JES__SB", "mu_BDT__wphjethist__JES__SB", nbin,min, max ); zjethistSB = new TH1F( "mu_BDT__zjethist__JES__SB", "mu_BDT__zjethist__JES__SB", nbin, min, max ); G_Pt_50to80SB= new TH1F( "mu_BDT__G_Pt_50to80SB", "mu_BDT__G_Pt_50to80SB", nbin, min, max ); G_Pt_80to120SB= new TH1F( "mu_BDT__G_Pt_80to120SB", "mu_BDT__G_Pt_80to120SB", nbin, min, max ); G_Pt_120to170SB= new TH1F( "mu_BDT__G_Pt_120to170SB", "mu_BDT__G_Pt_120to170SB", nbin, min, max ); G_Pt_170to300SB= new TH1F( "mu_BDT__G_Pt_170to300SB", "mu_BDT__G_Pt_170to300SB", nbin, min, max ); G_Pt_300to470SB= new TH1F( "mu_BDT__G_Pt_300to470SB", "mu_BDT__G_Pt_300to470SB", nbin, min, max ); G_Pt_470to800SB= new TH1F( "mu_BDT__G_Pt_470to800SB", "mu_BDT__G_Pt_470to800SB", nbin, min, max ); wjethistSB = new TH1F( "mu_BDT__wjethist__JES__SB", "mu_BDT__wjethist__JES__SB", nbin, min, max ); twchhistSB = new TH1F( "mu_BDT__twchhist__JES__SB", "mu_BDT__twchhist__JES__SB", nbin,min, max); tbarwhistSB = new TH1F( "mu_BDT__tbarwhist__JES__SB", "mu_BDT__tbarwhist__JES__SB", nbin,min, max ); tschhistSB = new TH1F( "mu_BDT__tschhist__JES__SB", "mu_BDT__tschhist__JES__SB", nbin, min, max ); tbarschhistSB = new TH1F( "mu_BDT__tbarschhist__JES__SB", "mu_BDT__tbarschhist__JES__SB", nbin, min, max ); ttchhistSB = new TH1F( "mu_BDT__ttchhist__JES__SB", "mu_BDT__ttchhist__JES__SB", nbin, min, max ); tbartchhistSB = new TH1F( "mu_BDT__tbartchhist__JES__SB", "mu_BDT__tbartchhist__JES__SB", nbin, min, max); tt1histSB = new TH1F( "mu_BDT__tt1hist__JES__SB", "mu_BDT__tt1hist__JES__SB", nbin, min, max ); tt2histSB = new TH1F( "mu_BDT__tt2hist__JES__SB", "mu_BDT__tt2hist__JES__SB", nbin, min, max ); tt3histSB = new TH1F( "mu_BDT__tt3hist__JES__SB", "mu_BDT__tt3hist__JES__SB", nbin, min, max ); ttphhistSB = new TH1F( "mu_BDT__ttphhist__JES__SB", "mu_BDT__ttphhist__JES__SB", nbin,min, max ); wwphhistSB = new TH1F( "mu_BDT__wwphhist__JES__SB", "BDT__wwphhist__JES__SB", nbin,min, max ); wwhistSB = new TH1F( "mu_BDT__wwhist__JES__SB", "mu_BDT__wwhist__JES__SB", nbin, min, max ); wzhistSB = new TH1F( "mu_BDT__wzhist__JES__SB", "mu_BDT__wzhist__JES__SB", nbin, min, max ); zzhistSB = new TH1F( "mu_BDT__zzhist__JES__SB", "mu_BDT__zzhist__JES__SB", nbin, min, max); zgammahistSB = new TH1F( "mu_BDT__zgammahist__JES__SB", "mu_BDT__zgammahist__JES__SB", nbin, min, max ); singletopphotonhistSB = new TH1F( "mu_BDT__singletopphotonhistSB", "mu_BDT__singletopphotonhistSB", nbin,min, max ); singleantitopphotonhistSB = new TH1F( "mu_BDT__singleantitopphotonhistSB", "mu_BDT__singleantitopphotonhistSB", nbin, min, max); signalhistSB = new TH1F( "mu_BDT__signal100__JES__SB", "mu_BDT__signal100__JES__SB", nbin,min, max ); std::vector<TH1F*> SBhists; SBhists.push_back(wjethistSB); SBhists.push_back(zjethistSB); SBhists.push_back(G_Pt_50to80SB); SBhists.push_back(G_Pt_80to120SB); SBhists.push_back(G_Pt_120to170SB); SBhists.push_back(G_Pt_170to300SB); SBhists.push_back(G_Pt_300to470SB); SBhists.push_back(G_Pt_470to800SB); SBhists.push_back(wphjethistSB); SBhists.push_back(twchhistSB); SBhists.push_back(tbarwhistSB); SBhists.push_back(tschhistSB); SBhists.push_back(tbarschhistSB); SBhists.push_back(ttchhistSB); SBhists.push_back(tbartchhistSB); SBhists.push_back(tt1histSB); SBhists.push_back(tt2histSB); SBhists.push_back(tt3histSB); SBhists.push_back(ttphhistSB); SBhists.push_back(wwphhistSB); SBhists.push_back(wwhistSB); SBhists.push_back(wzhistSB); SBhists.push_back(zzhistSB); SBhists.push_back(zgammahistSB); SBhists.push_back(singletopphotonhistSB); SBhists.push_back(singleantitopphotonhistSB); SBhists.push_back(signalhistSB); hists.push_back(wjethist); hists.push_back(zjethist); hists.push_back(G_Pt_50to80); hists.push_back(G_Pt_80to120); hists.push_back(G_Pt_120to170); hists.push_back(G_Pt_170to300); hists.push_back(G_Pt_300to470); hists.push_back(G_Pt_470to800); hists.push_back(wphjethist); hists.push_back(twchhist); hists.push_back(tbarwhist); hists.push_back(tschhist); hists.push_back(tbarschhist); hists.push_back(ttchhist); hists.push_back(tbartchhist); hists.push_back(tt1hist); hists.push_back(tt2hist); hists.push_back(tt3hist); hists.push_back(ttphhist); hists.push_back(wwphhist); hists.push_back(wwhist); hists.push_back(wzhist); hists.push_back(zzhist); hists.push_back(zgammahist); hists.push_back(singletopphotonhist); hists.push_back(singleantitopphotonhist); hists.push_back(signalhist); for(unsigned int idx=0; idx<samples_.size(); ++idx){ hists[idx]->Sumw2();} datahists.push_back(data1hist); datahists.push_back(data2hist); datahists.push_back(data3hist); datahists.push_back(datahistsideband); for(unsigned int idx=0; idx<datasamples_.size(); ++idx){ datahists[idx]->Sumw2();} revDATAhists.push_back(data1histrev); revDATAhists.push_back(data2histrev); revDATAhists.push_back(data3histrev); revDATAhists.push_back(datahistrevsideband); double insidewphjet=0; double outsidewphjet=0; double insidewjet=0; double outsidewjet=0; double nsignalevent=0; double mtopup=220; double mtopdown=130; //bool SR=false; //bool SB=true; bool SR=true; bool SB=false; for(unsigned int idx=0; idx<samples_.size(); ++idx){ TString fname =samples_[idx]; if (!gSystem->AccessPathName( fname )) input = TFile::Open( fname ); // check if file in local directory exists else input = TFile::Open( "http://root.cern.ch/files/tmva_class_example.root" ); // if not: download from ROOT server if (!input) { std::cout << "ERROR: could not open data file" << std::endl; exit(1); } std::cout << "--- TMVAClassificationApp : Using input file: " << input->GetName() << std::endl; // --- Event loop // Prepare the event tree // - here the variable names have to corres[1]ponds to your tree // - you can use the same variables as above which is slightly faster, // but of course you can use different ones and copy the values inside the event loop // //Double_t myptphoton,myetaphoton,myptmuon,myetamuon,myptjet,myetajet,mymasstop,mymtw,mydeltaRphotonjet,mydeltaRphotonmuon,myht,mycostopphoton,mydeltaphiphotonmet,mycvsdiscriminant,myjetmultiplicity,mybjetmultiplicity,myleptoncharge; std::vector<double> *myptphoton=0; std::vector<double> *myetaphoton=0; std::vector<double> *myptmuon=0; std::vector<double> *myetamuon=0; std::vector<double> *myptjet=0; std::vector<double> *myetajet=0; std::vector<double> *mymasstop=0; //std::vector<double> *mymtw=0; std::vector<double> *mydeltaRphotonjet=0; std::vector<double> *mydeltaRphotonmuon=0; //std::vector<double> *myht=0; std::vector<double> *mycostopphoton=0; std::vector<double> *mydeltaphiphotonmet=0; std::vector<double> *mycvsdiscriminant=0; std::vector<double> *myjetmultiplicity=0; //std::vector<double> *mybjetmultiplicity=0; //std::vector<double> *myleptoncharge=0; std::vector<double> *myweight=0; std::vector<double> *myjetmatchinginfo=0; std::vector<double> *mycoswphoton=0; std::cout << "--- Select signal sample" << std::endl; TTree* theTree = (TTree*)input->Get("analyzestep2/atq"); // Int_t myjetmultiplicity, mybjetmultiplicity , myleptoncharge; // Float_t userVar1, userVar2; theTree->SetBranchAddress("ptphoton", &myptphoton ); theTree->SetBranchAddress( "etaphoton", &myetaphoton ); theTree->SetBranchAddress( "ptmuon", &myptmuon ); theTree->SetBranchAddress( "etamuon", &myetamuon ); theTree->SetBranchAddress( "ptjet", &myptjet ); theTree->SetBranchAddress( "etajet", &myetajet ); theTree->SetBranchAddress( "masstop", &mymasstop ); // theTree->SetBranchAddress( "mtw", &mymtw ); theTree->SetBranchAddress( "deltaRphotonjet", &mydeltaRphotonjet ); theTree->SetBranchAddress( "deltaRphotonmuon", &mydeltaRphotonmuon ); // theTree->SetBranchAddress( "ht", &myht ); theTree->SetBranchAddress( "costopphoton", &mycostopphoton ); theTree->SetBranchAddress( "jetmultiplicity", &myjetmultiplicity ); // theTree->SetBranchAddress( "bjetmultiplicity", &mybjetmultiplicity ); theTree->SetBranchAddress( "deltaphiphotonmet", &mydeltaphiphotonmet ); theTree->SetBranchAddress( "cvsdiscriminant", &mycvsdiscriminant ); // theTree->SetBranchAddress( "leptoncharge", &myleptoncharge ); theTree->SetBranchAddress( "weight", &myweight); theTree->SetBranchAddress( "coswphoton", &mycoswphoton ); theTree->SetBranchAddress( "jetmatchinginfo", &myjetmatchinginfo ); // std::cout << "--- Processing: " << theTree->GetEntries() << " events" << std::endl; TStopwatch sw; sw.Start(); for (Long64_t ievt=0; ievt<theTree->GetEntries();ievt++) { // std::cout << "--- ... Processing event: " << ievt << std::endl; double finalweight; if (ievt%1000 == 0) std::cout << "--- ... Processing event: " << ievt << std::endl; theTree->GetEntry(ievt); //for (int l=0;l<sizeof(myptphoton);l++){ //std::cout << "--- ... reza: " << myptphoton[l] <<std::endl; //} //std::cout << "--- ......................."<< (*mycvsdiscriminant)[0]<<std::endl; // --- Return the MVA outputs and fill into histograms finalweight=(*myweight)[0]; //cout<<(*myweight)[0]<<endl; if((*mymasstop )[0]>mtopdown && (*mymasstop )[0]<mtopup){ hists[idx] ->Fill(Bmodification((*mycvsdiscriminant)[0],(*myjetmatchinginfo)[0]),finalweight ); if (samples_[idx]=="WPHJET.root")insidewphjet=insidewphjet+finalweight; if (samples_[idx]=="SIGNALtGu.root")nsignalevent=nsignalevent+1; //cout<<insidewphjet<<endl; } else { SBhists[idx] ->Fill( Bmodification((*mycvsdiscriminant)[0],(*myjetmatchinginfo)[0]),finalweight ); if (samples_[idx]=="WPHJET.root")outsidewphjet=outsidewphjet+finalweight;} // Retrieve also per-event error } delete myptphoton; delete myetaphoton; delete myptmuon; delete myetamuon; delete myptjet; delete myetajet; delete mymasstop; //delete mymtw; delete mydeltaRphotonjet; delete mydeltaRphotonmuon; //delete myht; delete mycostopphoton; delete mydeltaphiphotonmet; delete mycvsdiscriminant; delete myjetmultiplicity; //delete mybjetmultiplicity; //delete myleptoncharge; //delete myplot; } for(unsigned int idx=0; idx<datasamples_.size(); ++idx){ TString fname =datasamples_[idx]; if (!gSystem->AccessPathName( fname )) input = TFile::Open( fname ); // check if file in local directory exists else input = TFile::Open( "http://root.cern.ch/files/tmva_class_example.root" ); // if not: download from ROOT server if (!input) { std::cout << "ERROR: could not open data file" << std::endl; exit(1); } std::cout << "--- TMVAClassificationApp : Using input file: " << input->GetName() << std::endl; // --- Event loop // Prepare the event tree // - here the variable names have to corres[1]ponds to your tree // - you can use the same variables as above which is slightly faster, // but of course you can use different ones and copy the values inside the event loop // //Double_t myptphoton,myetaphoton,myptmuon,myetamuon,myptjet,myetajet,mymasstop,mymtw,mydeltaRphotonjet,mydeltaRphotonmuon,myht,mycostopphoton,mydeltaphiphotonmet,mycvsdiscriminant,myjetmultiplicity,mybjetmultiplicity,myleptoncharge; std::vector<double> *myptphoton=0; std::vector<double> *myetaphoton=0; std::vector<double> *myptmuon=0; std::vector<double> *myetamuon=0; std::vector<double> *myptjet=0; std::vector<double> *myetajet=0; std::vector<double> *mymasstop=0; //std::vector<double> *mymtw=0; std::vector<double> *mydeltaRphotonjet=0; std::vector<double> *mydeltaRphotonmuon=0; //std::vector<double> *myht=0; std::vector<double> *mycostopphoton=0; std::vector<double> *mydeltaphiphotonmet=0; std::vector<double> *mycvsdiscriminant=0; std::vector<double> *myjetmultiplicity=0; //std::vector<double> *mybjetmultiplicity=0; //std::vector<double> *myleptoncharge=0; std::vector<double> *mycoswphoton=0; std::cout << "--- Select signal sample" << std::endl; TTree* theTree = (TTree*)input->Get("analyzestep2/atq"); // Int_t myjetmultiplicity, mybjetmultiplicity , myleptoncharge; // Float_t userVar1, userVar2; theTree->SetBranchAddress("ptphoton", &myptphoton ); theTree->SetBranchAddress( "etaphoton", &myetaphoton ); theTree->SetBranchAddress( "ptmuon", &myptmuon ); theTree->SetBranchAddress( "etamuon", &myetamuon ); theTree->SetBranchAddress( "ptjet", &myptjet ); theTree->SetBranchAddress( "etajet", &myetajet ); theTree->SetBranchAddress( "masstop", &mymasstop ); // theTree->SetBranchAddress( "mtw", &mymtw ); theTree->SetBranchAddress( "deltaRphotonjet", &mydeltaRphotonjet ); theTree->SetBranchAddress( "deltaRphotonmuon", &mydeltaRphotonmuon ); // theTree->SetBranchAddress( "ht", &myht ); theTree->SetBranchAddress( "costopphoton", &mycostopphoton ); theTree->SetBranchAddress( "jetmultiplicity", &myjetmultiplicity ); // theTree->SetBranchAddress( "bjetmultiplicity", &mybjetmultiplicity ); theTree->SetBranchAddress( "deltaphiphotonmet", &mydeltaphiphotonmet ); theTree->SetBranchAddress( "cvsdiscriminant", &mycvsdiscriminant ); theTree->SetBranchAddress( "coswphoton", &mycoswphoton ); // theTree->SetBranchAddress( "leptoncharge", &myleptoncharge ); for (Long64_t ievt=0; ievt<theTree->GetEntries();ievt++) { // std::cout << "--- ... Processing event: " << ievt << std::endl; theTree->GetEntry(ievt); // --- Return the MVA outputs and fill into histograms //leptoncharge=(float)(*myleptoncharge )[0]; if((*mymasstop )[0]>mtopdown && (*mymasstop )[0]<mtopup) datahists[idx] ->Fill( (*mycvsdiscriminant)[0] ); else datahists[3]->Fill( (*mycvsdiscriminant)[0] ); } delete myptphoton; delete myetaphoton; delete myptmuon; delete myetamuon; delete myptjet; delete myetajet; delete mymasstop; //delete mymtw; delete mydeltaRphotonjet; delete mydeltaRphotonmuon; //delete myht; delete mycostopphoton; delete mydeltaphiphotonmet; delete mycvsdiscriminant; delete myjetmultiplicity; //delete mybjetmultiplicity; //delete myleptoncharge; //delete myplot; } for(unsigned int idx=0; idx<datasamplesreverse_.size(); ++idx){ TString fname =datasamplesreverse_[idx]; if (!gSystem->AccessPathName( fname )) input = TFile::Open( fname ); // check if file in local directory exists else input = TFile::Open( "http://root.cern.ch/files/tmva_class_example.root" ); // if not: download from ROOT server if (!input) { std::cout << "ERROR: could not open data file" << std::endl; exit(1); } std::cout << "--- TMVAClassificationApp : Using input file: " << input->GetName() << std::endl; std::vector<double> *myptphoton=0; std::vector<double> *myetaphoton=0; std::vector<double> *myptmuon=0; std::vector<double> *myetamuon=0; std::vector<double> *myptjet=0; std::vector<double> *myetajet=0; std::vector<double> *mymasstop=0; //std::vector<double> *mymtw=0; std::vector<double> *mydeltaRphotonjet=0; std::vector<double> *mydeltaRphotonmuon=0; //std::vector<double> *myht=0; std::vector<double> *mycostopphoton=0; std::vector<double> *mydeltaphiphotonmet=0; std::vector<double> *mycvsdiscriminant=0; std::vector<double> *myjetmultiplicity=0; std::vector<double> *mycoswphoton=0; //std::vector<double> *mybjetmultiplicity=0; //std::vector<double> *myleptoncharge=0; TTree* theTree = (TTree*)input->Get("analyzestep2/atq"); theTree->SetBranchAddress("ptphoton", &myptphoton ); theTree->SetBranchAddress( "etaphoton", &myetaphoton ); theTree->SetBranchAddress( "ptmuon", &myptmuon ); theTree->SetBranchAddress( "etamuon", &myetamuon ); theTree->SetBranchAddress( "ptjet", &myptjet ); theTree->SetBranchAddress( "etajet", &myetajet ); theTree->SetBranchAddress( "masstop", &mymasstop ); // theTree->SetBranchAddress( "mtw", &mymtw ); theTree->SetBranchAddress( "deltaRphotonjet", &mydeltaRphotonjet ); theTree->SetBranchAddress( "deltaRphotonmuon", &mydeltaRphotonmuon ); // theTree->SetBranchAddress( "ht", &myht ); theTree->SetBranchAddress( "costopphoton", &mycostopphoton ); theTree->SetBranchAddress( "jetmultiplicity", &myjetmultiplicity ); // theTree->SetBranchAddress( "bjetmultiplicity", &mybjetmultiplicity ); theTree->SetBranchAddress( "deltaphiphotonmet", &mydeltaphiphotonmet ); theTree->SetBranchAddress( "cvsdiscriminant", &mycvsdiscriminant ); theTree->SetBranchAddress( "coswphoton", &mycoswphoton ); // theTree->SetBranchAddress( "leptoncharge", &myleptoncharge ); // Efficiency calculator for cut method for (Long64_t ievt=0; ievt<theTree->GetEntries();ievt++) { // std::cout << "--- ... Processing event: " << ievt << std::endl; if (ievt%1000 == 0) std::cout << "--- ... Processing event: " << ievt << std::endl; theTree->GetEntry(ievt); if((*mymasstop )[0]>mtopdown && (*mymasstop )[0]<mtopup) { //revDATAhists[idx]->Fill( reader->EvaluateMVA( "BDT method" ) ); insidewjet=insidewjet+1; revDATAhists[idx]->Fill( (*mycvsdiscriminant)[0]); } else { //revDATAhists[3]->Fill( reader->EvaluateMVA( "BDT method" ) ); outsidewjet=outsidewjet+1; revDATAhists[3]->Fill( (*mycvsdiscriminant)[0]); } //cout<<insidewjet<<endl; } delete myptphoton; delete myetaphoton; delete myptmuon; delete myetamuon; delete myptjet; delete myetajet; delete mymasstop; //delete mymtw; delete mydeltaRphotonjet; delete mydeltaRphotonmuon; //delete myht; delete mycostopphoton; delete mydeltaphiphotonmet; delete mycvsdiscriminant; delete myjetmultiplicity; ////delete mybjetmultiplicity; ////delete myleptoncharge; ////delete myplot; // } double wphjetscale; wphjetscale=insidewphjet/(insidewphjet+outsidewphjet); cout<<"wphjetscale= "<<wphjetscale<<endl; double wjetscale; wjetscale=insidewjet/(insidewjet+outsidewjet); cout<<"wjetscale= "<<wjetscale<<endl; cout<<"nsignalevent= "<<nsignalevent<<endl; //cout<<insidewphjet<<"insidewphjet"<<" "<<wphjetscale<<" "<<insidewjet/(insidewjet+outsidewjet)<<endl; float lumi = 1; if (SR==true){ double ff=0; for(unsigned int idx=0; idx<samples_.size(); ++idx){ hists[idx]->Scale(lumi*scales[idx]); if (idx !=0 && idx!=3){ ff=hists[idx]->Integral()+ff; cout<<samples_[idx]<<" = "<<hists[idx]->Integral()<<" " <<ff<<endl;} } for(unsigned int idx=0; idx<samples_.size(); ++idx){ SBhists[idx]->Scale(lumi*scales[idx]);} THStack *hs1 = new THStack("hs1","BDT output"); for(unsigned int idx=1; idx<datasamplesreverse_.size(); ++idx){ revDATAhists[idx]->Add(revDATAhists[idx-1]); } //cout<<"*********************"<< datahists[3]->Integral()<<" "<<wphjetscale<<endl; //cout<<"*********************"<< revDATAhists[2]->Integral()<<" "<<wjetscale<<endl; revDATAhists[2]->Scale(219.373/revDATAhists[2]->Integral()); for(unsigned int idx=1; idx<revDATAhists[2]->GetNbinsX()+1; ++idx){ //revDATAhists[2]->SetBinError(idx,(revDATAhists[2]->GetBinContent(idx)/revDATAhists[2]->Integral())*74.84); revDATAhists[2]->SetBinError(idx,0); //if (revDATAhists[2]->GetBinError(idx)>revDATAhists[2]->GetBinContent(idx)) revDATAhists[2]->SetBinError(idx, revDATAhists[2]->GetBinContent(idx)/2); } //revDATAhists[2]->Scale(wjetscale); revDATAhists[3]->Scale(219.373/revDATAhists[3]->Integral()); revDATAhists[3]->Scale((1-wjetscale)/wjetscale); for(unsigned int idx=1; idx<datasamples_.size(); ++idx){ datahists[idx]->Add(datahists[idx-1]);} cout<<" " <<datahists[2]->Integral()<<endl; datahists[3]->Add(revDATAhists[3],-1); datahists[3]->Add(SBhists[1],-1); datahists[3]->Add(SBhists[2],-1); for(unsigned int idx=9; idx<samples_.size()-1; ++idx){ datahists[3]->Add(SBhists[idx],-1);} for(unsigned int idx=1; idx<nbin; ++idx){ if (datahists[3]->GetBinContent(idx)<0)datahists[3]->SetBinContent(idx,0); } datahists[3]->Scale(1112.2/datahists[3]->Integral()); for(unsigned int idx=1; idx<datahists[3]->GetNbinsX()+1; ++idx){ //datahists[3]->SetBinError(idx,(datahists[3]->GetBinContent(idx)/datahists[3]->Integral())*139.11);} datahists[3]->SetBinError(idx,0);} TH1F *datatoMC(0); //datahists[3]->Scale(wphjetscale); //hists[1]->Add(revDATAhists[2]); //hists[2]->Add(hists[1]); //datahists[3]->Add(hists[2]); //hists[4]->Add(datahists[3]); //for(unsigned int idx=5; idx<samples_.size()-1; ++idx){ // hists[idx]->Add(hists[idx-1]);} //cout<<"**********real data***********"<< datahists[2]->Integral()<<" "<<wphjetscale<<endl; //cout<<"********** mc ***********"<< hists[18]->Integral()<<" "<<wjetscale<<endl; // setup the canvas and draw the histograms TH1F *sum_h= new TH1F ( *hists[1] ) ; sum_h->Sumw2(); for(unsigned int idx=2; idx<samples_.size()-1; ++idx){ if (idx!=8)sum_h->Add(hists[idx],1); } sum_h->Add(revDATAhists[2],1); sum_h->Add(datahists[3],1); std::vector<std::vector<double_t> > vecplus(photondownhists[0]->GetNbinsX(), vector<double>(18)); std::vector<std::vector<double_t> > vecminus(photondownhists[0]->GetNbinsX(), vector<double>(18)); for(int p = 0; p <photondownhists[0]->GetNbinsX(); p++){ //loop over bins for(int m = 0; m < 18; m++){ //loop over systematics vecplus[p][m]=0; vecminus[p][m]=0; if (vec[p][m]>sum_h->GetBinContent(p+1)) vecplus[p][m] = vec[p][m]-sum_h->GetBinContent(p+1); else if (vec[p][m]<sum_h->GetBinContent(p+1)) vecminus[p][m] = sum_h->GetBinContent(p+1)-vec[p][m]; cout<<vecplus[p][m]<<endl; }} TCanvas *c1 = new TCanvas("c1","signal region",50,50,865,780); c1->cd(); TPad *pad1 = new TPad("pad1","pad1",0,0.25,1,1); pad1->SetFillStyle(0); pad1->SetFrameFillStyle(0); pad1->SetBottomMargin(0); TPad *pad2 = new TPad("pad2","pad2",0,0,1,0.25); pad2->SetFillStyle(0); pad2->SetFrameFillStyle(0); pad2->SetTopMargin(0); pad2->SetBottomMargin(0.12/0.46); pad2->Draw(); pad1->Draw(); pad1->cd(); //W+jet revDATAhists[2]->SetFillColor(kBlue-2); revDATAhists[2]->SetLineColor(kBlack); hs1->Add(revDATAhists[2]); //Z+jet hists[1]->SetFillColor(kOrange-4); hists[1]->SetLineColor(kBlack); hs1->Add(hists[1]); //photon+jet hists[3]->Add(hists[2]); hists[4]->Add(hists[3]); hists[5]->Add(hists[4]); hists[6]->Add(hists[5]); hists[7]->Add(hists[6]); hists[7]->SetFillColor(19); //hs1->Add(hists[7]); //W+photon+jet datahists[3]->SetFillColor(kGreen-3); datahists[3]->SetLineColor(kBlack); hs1->Add(datahists[3]); //single top+singletop photon hists[5+5]->Add(hists[4+5]); hists[6+5]->Add(hists[5+5]); hists[7+5]->Add(hists[6+5]); hists[8+5]->Add(hists[7+5]); hists[9+5]->Add(hists[8+5]); hists[19+5]->Add(hists[9+5]); hists[20+5]->Add(hists[19+5]); hists[20+5]->SetFillColor(kRed+3); hists[20+5]->SetLineColor(kBlack); hs1->Add(hists[20+5]); //hists[9+5]->SetFillColor(kAzure+10); //hs1->Add(hists[9+5]); hists[11+5]->Add(hists[10+5]); hists[12+5]->Add(hists[11+5]); hists[13+5]->Add(hists[12+5]); hists[13+5]->SetFillColor(kPink+1); hists[13+5]->SetLineColor(kBlack); hs1->Add(hists[13+5]); //hists[13+5]->SetFillColor(17); //hs1->Add(hists[13+5]); //hists[14+5]->SetFillColor(kSpring-9); //hs1->Add(hists[14+5]); hists[15+5]->Add(hists[14+5]); hists[16+5]->Add(hists[15+5]); hists[17+5]->Add(hists[16+5]); hists[17+5]->SetFillColor(kViolet-7); hists[17+5]->SetLineColor(kBlack); hs1->Add(hists[17+5]); hists[18+5]->SetFillColor(kAzure+10); hists[18+5]->SetLineColor(kBlack); hs1->Add(hists[18+5]); //hists[20+5]->Add(hists[19+5]); //hists[20+5]->SetFillColor(kYellow+3); //hs1->Add(hists[20+5]); hs1->Draw("hist"); hs1->SetMaximum(1.6*datahists[2]->GetMaximum()); //hs1->GetXaxis()->SetTitle("BDT output"); hs1->GetYaxis()->SetTitle("Events / 0.05"); hs1->GetYaxis()->SetTitleSize(0.045); hs1->GetYaxis()->SetTitleFont(22); hs1->GetYaxis()->SetTitleOffset(0.8); hs1->GetYaxis()->SetLabelSize(0.044); hists[21+5]->SetLineColor(kRed+3); hists[21+5]->SetLineWidth(3); hists[21+5]->Draw("histsame"); datahists[2]->SetLineWidth(3.); datahists[2]->SetLineColor(kBlack); datahists[2]->SetMarkerColor(kBlack); datahists[2]->SetMarkerStyle(20.); datahists[2]->SetMarkerSize(1.35); datahists[2]->Draw("esame"); sum_h->SetLineColor(kBlack); sum_h->SetFillColor(1); sum_h->SetFillStyle(3001); sum_h->Draw("e2same"); TPaveText *pt = new TPaveText(0.1,0.95,0.4,0.95, "NDC"); // NDC sets coords pt->SetLineColor(10); // relative to pad dimensions pt->SetFillColor(10); // text is black on white pt->SetTextSize(0.045); pt->SetTextAlign(12); pt->AddText("CMS Preliminary, 19.1 fb^{-1}, #sqrt{s} = 8 TeV"); pt->SetShadowColor(10); pt->Draw("same"); std::vector<double_t> errorup(photondownhists[0]->GetNbinsX()); std::vector<double_t> errordown(photondownhists[0]->GetNbinsX()); for(int p = 0; p <photondownhists[0]->GetNbinsX(); p++){ //loop over bins for(int m = 0; m < 18; m++){ //loop over systematics if (m==0) {errorup[p]=0; errordown[p]=0;} errorup[p]=pow(vecplus[p][m],2)+errorup[p]; errordown[p]=pow(vecminus[p][m],2)+errordown[p]; } errorup[p]=pow(0.024*sum_h->GetBinContent(p+1),2)+errorup[p]; errordown[p]=pow(0.024*sum_h->GetBinContent(p+1),2)+errordown[p]; errorup[p]=pow(0.4*wjetandwphjet[0]->GetBinContent(p+1),2)+errorup[p]; errordown[p]=pow(0.4*wjetandwphjet[0]->GetBinContent(p+1),2)+errordown[p]; errorup[p]=pow(0.3*wjetandwphjet[1]->GetBinContent(p+1),2)+errorup[p]; errordown[p]=pow(0.3*wjetandwphjet[1]->GetBinContent(p+1),2)+errordown[p]; errorup[p]=pow(0.3*hists[1]->GetBinContent(p+1),2)+errorup[p]; errordown[p]=pow(0.3*hists[1]->GetBinContent(p+1),2)+errordown[p]; errorup[p]=pow(0.3*hists[20+5]->GetBinContent(p+1),2)+errorup[p]; errordown[p]=pow(0.3*hists[20+5]->GetBinContent(p+1),2)+errordown[p]; errorup[p]=pow(0.3*hists[13+5]->GetBinContent(p+1),2)+errorup[p]; errordown[p]=pow(0.3*hists[13+5]->GetBinContent(p+1),2)+errordown[p]; errorup[p]=pow(0.3*hists[17+5]->GetBinContent(p+1),2)+errorup[p]; errordown[p]=pow(0.3*hists[17+5]->GetBinContent(p+1),2)+errordown[p]; errorup[p]=pow(0.3*hists[18+5]->GetBinContent(p+1),2)+errorup[p]; errordown[p]=pow(0.3*hists[18+5]->GetBinContent(p+1),2)+errordown[p]; cout<<errorup[p]<<endl; cout<<errordown[p]<<endl; } double ax[photondownhists[0]->GetNbinsX()]; double ay[photondownhists[0]->GetNbinsX()]; double aexl[photondownhists[0]->GetNbinsX()]; double aexh[photondownhists[0]->GetNbinsX()]; double aeyl[photondownhists[0]->GetNbinsX()]; double aeyh[photondownhists[0]->GetNbinsX()]; for(int p = 0; p <photondownhists[0]->GetNbinsX(); p++){ //loop over bins ax[p]=min+(max-min)/(2*nbin)+p*((max-min)/nbin); ay[p]=sum_h->GetBinContent(p+1); aexl[p]=(max-min)/(2*nbin); aexh[p]=(max-min)/(2*nbin); aeyl[p]=sqrt(errordown[p]); aeyh[p]=sqrt(errorup[p]); } TGraphAsymmErrors* gae = new TGraphAsymmErrors(photondownhists[0]->GetNbinsX(), ax, ay, aexl, aexh, aeyl, aeyh); gae->SetFillColor(1); gae->SetFillStyle(3003); gae->Draw("e2same"); TLegend* leg = new TLegend(0.60,0.40,0.89,0.87); leg->SetFillStyle ( 0); leg->SetFillColor ( 0); leg->SetBorderSize( 0); leg->AddEntry( datahists[2], "Data" , "PL"); // leg->AddEntry( hists[25], "Single top+#gamma" , "F"); leg->AddEntry( hists[23], "Z#gamma" , "F"); leg->AddEntry( hists[22], "WW,WZ,ZZ,WW#gamma " , "F"); // leg->AddEntry( hists[19], "WW#gamma" , "F"); leg->AddEntry( hists[18], "t#bar{t}, t#bar{t}#gamma" , "F"); // leg->AddEntry( hists[17], "t#bar{t}" , "F"); leg->AddEntry( hists[25], "Single top, Single top+#gamma" , "F"); // leg->AddEntry( hists[14], "Single top" , "F"); leg->AddEntry( datahists[3], "W#gamma" , "F"); // leg->AddEntry( hists[7], "#gamma+jets" , "F"); leg->AddEntry( hists[1], "Z+jets" , "F"); leg->AddEntry(revDATAhists[2], "W+jets" , "F"); leg->AddEntry( hists[26], "Signal(tu#gamma) 1 pb" , "L"); leg->AddEntry(sum_h, "Stat uncertainty" , "F"); leg->AddEntry(gae, "Syst uncertainty" , "F"); // leg->AddEntry( datahists[2], "CMS Data 2012(19.145/fb)" , "PL"); leg->Draw("same"); sum_h->Draw("AXISSAMEY+"); sum_h->Draw("AXISSAMEX+"); pad1->Draw(); TCanvas *c22 = new TCanvas("c22","signal region22",50,50,865,780); c22->cd(); gae->Draw("a2"); gae->Draw("psame"); TH1F *h_ratio = (TH1F*)datahists[2]->Clone("h_copy"); h_ratio->Sumw2(); pad2->cd(); pad2->SetGridy(); datatoMC = new TH1F( "datatoMC", "datatoMC", nbin, min, max ); datatoMC->Sumw2(); datatoMC->Divide(datahists[2],sum_h); h_ratio->Divide(sum_h); h_ratio->SetFillStyle(3004); h_ratio->GetXaxis()->SetTitle("CSV discriminator"); h_ratio->GetYaxis()->SetTitle("DATA/MC"); h_ratio->GetXaxis()->SetTitleSize(0.12); h_ratio->GetYaxis()->SetTitleSize(0.12); h_ratio->GetXaxis()->SetTitleFont(22); h_ratio->GetYaxis()->SetTitleFont(22); h_ratio->GetXaxis()->SetTickLength(0.05); h_ratio->GetYaxis()->SetTickLength(0.05); h_ratio->GetXaxis()->SetLabelSize(0.14); h_ratio->GetYaxis()->SetLabelSize(0.14); h_ratio->GetYaxis()->SetTitleOffset(0.25); h_ratio->GetYaxis()->SetNdivisions(504); h_ratio->SetLineWidth(2); //h_ratio->SetStats(0); //h_ratio->SetMarkerStyle(20); h_ratio->SetMinimum(0); h_ratio->SetMaximum(2); h_ratio->Draw("E"); //datatoMC->Draw(""); TLine *l3 = new TLine(h_ratio->GetXaxis()->GetXmin(), 1.00, h_ratio->GetXaxis()->GetXmax(), 1.00); l3->SetLineWidth(1); //l3->SetLineStyle(7); //l3->Draw(); h_ratio->Draw("AXISSAMEY+"); h_ratio->Draw("AXISSAMEX+"); c1->Update(); for(unsigned int idx=1; idx<nbin+1; ++idx){ cout<<"MC "<<"nbin= "<<idx<<" content= "<<sum_h->GetBinContent(idx)<<endl; cout<<"signal "<<"nbin= "<<idx<<" content= "<<hists[21+5]->GetBinContent(idx)<<endl; cout<<"Data "<<"nbin= "<<idx<<" content= "<<datahists[2]->GetBinContent(idx)<<endl; } cout<<"signal Integral "<<hists[21+5]->Integral()<<endl; } if (SB==true){ for(unsigned int idx=0; idx<samples_.size(); ++idx){ SBhists[idx]->Scale(lumi*scales[idx]);} revDATAhists[3]->Scale(620.32/revDATAhists[3]->Integral()); revDATAhists[3]->Scale(1-wjetscale); SBhists[1]->Add(revDATAhists[3]); SBhists[2]->Add(SBhists[1]); SBhists[4]->Add(SBhists[2]); for(unsigned int idx=5; idx<samples_.size()-1; ++idx){ SBhists[idx]->Add(SBhists[idx-1]);} SBhists[20]->SetMaximum(1.5*datahists[3]->GetMaximum()); SBhists[20]->SetFillColor(kMagenta+2); SBhists[20]->Draw(); SBhists[18]->SetFillColor(kOrange+4); SBhists[18]->Draw("same"); SBhists[17]->SetFillColor(kOrange-2); SBhists[17]->Draw("same"); SBhists[16]->SetFillColor(kRed); SBhists[16]->Draw("same"); SBhists[15]->SetFillColor(kViolet+1); SBhists[15]->Draw("same"); SBhists[14]->SetFillColor(kSpring-9); SBhists[14]->Draw("same"); SBhists[13]->SetFillColor(32); SBhists[13]->Draw("same"); SBhists[12]->SetFillColor(6); SBhists[12]->Draw("same"); SBhists[9]->SetFillColor(4); SBhists[9]->Draw("same"); //hists[8]->SetFillColor(4); //hists[8]->Draw("same"); //hists[7]->SetFillColor(3); //hists[7]->Draw("same"); //hists[6]->SetFillColor(3); //hists[6]->Draw("same"); //hists[5]->SetFillColor(2); //hists[5]->Draw("same"); //hists[4]->SetFillColor(2); //hists[4]->Draw("same"); //hists[3]->SetFillColor(5); //hists[3]->Draw("same"); //datahists[3]->SetFillColor(5); //datahists[3]->Draw("same"); SBhists[2]->SetFillColor(8); SBhists[2]->Draw("same"); SBhists[1]->SetFillColor(kOrange+7); SBhists[1]->Draw("same"); revDATAhists[3]->SetFillColor(7); revDATAhists[3]->Draw("same"); //hists[0]->SetFillColor(7); //hists[0]->Draw("same"); SBhists[21]->SetFillColor(1); SBhists[21]->SetFillStyle(3004); SBhists[21]->Draw("same"); // plot data points datahists[3]->SetLineWidth(3.); datahists[3]->SetLineColor(kBlack); datahists[3]->SetMarkerColor(kBlack); datahists[3]->SetMarkerStyle(20.); datahists[3]->Draw("esame"); //conv->RedrawAxis(); TLegend* leg = new TLegend(0.60,0.40,0.89,0.87); leg->SetFillStyle ( 0); leg->SetFillColor ( 0); leg->SetBorderSize( 0); leg->AddEntry( revDATAhists[2], "W JET" , "F"); leg->AddEntry( SBhists[1], "Z JET" , "F"); leg->AddEntry( SBhists[2], "PH JET" , "F"); // leg->AddEntry( datahists[3], "W PH JET" , "F"); // leg->AddEntry( hists[5], "TOP-W-CH" , "F"); // leg->AddEntry( hists[5], "T-S-CH" , "F"); // leg->AddEntry( hists[7], "TOP-S-CH" , "F"); // leg->AddEntry( hists[7], "TTBAR-CH" , "F"); // leg->AddEntry( hists[8], "TBAR-W-CH" , "F"); leg->AddEntry( SBhists[9], "SINGLE TOP " , "F"); leg->AddEntry( SBhists[12], "TTBAR" , "F"); leg->AddEntry( SBhists[13], "TTG" , "F"); leg->AddEntry( SBhists[14], "WWG" , "F"); leg->AddEntry( SBhists[15], "WW" , "F"); leg->AddEntry( SBhists[16], "WZ" , "F"); leg->AddEntry( SBhists[17], "ZZ" , "F"); leg->AddEntry( SBhists[18], "ZGAMMA" , "F"); leg->AddEntry( SBhists[20], "SINGLE TOP+PHOTON" , "F"); leg->AddEntry( SBhists[21], "SIGNAL" , "F"); leg->AddEntry( datahists[3], "CMS Data 2012(19.145/fb)" , "PL"); leg->Draw("same"); } }
void plot3(TString infile = "fp-d", TString pltmd = "cos") { // CHECK FOR RIGHT INPUT //////////////////////////////////////////////// string strpltmd = pltmd, filename = infile, strfile = infile; if( (strpltmd.compare("cos") != 0 ) && (strpltmd.compare("sin") != 0 ) && (strpltmd.compare("tan") != 0 ) && (strpltmd.compare("mmp") != 0 ) ) {error(4);}; // GLOBAL VARIABLES //////////////////////////////////////////////////// Int_t file, point, color, style; Float_t fits2b, fittph, tphold, fitsph, fitcph, fitx, fitxmin, fitxmax = -1.0; Float_t xVal, yVal; Float_t xMin = 100000, xMax = -1.0, yMin = 100000, yMax = -1.0; Float_t MZ, MW, Mmin = 100000; Float_t Cz1, Cz2, Cz3, Cw1, Cw2, Cw3, Cw4, C1, C2; Float_t phiMin, phiMax, cphmin, cphmax, sphmin, sphmax; // CUSTOMIZE PLOT /////////////////////////////////////////////////////// gROOT->Reset(); gROOT->SetStyle("Plain"); gStyle->SetTitleBorderSize(0); gStyle->SetPalette(1); TCanvas *MyC = new TCanvas("MyC","Plot of the GAPP fit results",200,10,700,500); Float_t mmlegxmin, mmlegxmax, mmlegymin, mmlegymax; Float_t s2blegxmin, s2blegymin, s2blegxmax, s2blegymax; Float_t lblxmin, lblxmax, lblymin, lblymax; string plottitle = "Model: " + infile + " | Plot: "; string xtitle, ytitle, NPleg, SMleg, display; NPleg = "#font[52]{M_{H}^{(NP)}, #bar{m}_{t}^{(NP)}}"; SMleg = "#font[52]{M_{H}^{(SM)}, #bar{m}_{t}^{(SM)}}"; if (strpltmd.compare("tan") == 0) { plottitle += "#font[42]{tan^{2}(#tilde{#phi}) over }#font[52]{#tilde{x}}#font[42]{.}"; xtitle = "#font[52]{#tilde{x}}"; ytitle = "#font[42]{tan^{2}(#tilde{#phi})}"; display = "C"; mmlegxmin = 0.15; mmlegxmax = 0.30; mmlegymin = 0.75; mmlegymax = 0.85; s2blegxmin = 0.15; s2blegxmax = 0.40; s2blegymin = 0.30; s2blegymax = 0.50; lblxmin = 0.88; lblxmax = 0.88; lblymin = 0.60; lblymax = 0.65; } else if (strpltmd.compare("cos") == 0) { plottitle += "#font[42]{cos(#tilde{#phi}) over }#font[52]{#tilde{x}}#font[42]{.}"; xtitle = "#font[52]{#tilde{x}}"; ytitle = "#font[42]{cos(#tilde{#phi})}"; display = "C"; mmlegxmin = 0.70; mmlegxmax = 0.85; mmlegymin = 0.75; mmlegymax = 0.85; s2blegxmin = 0.15; s2blegxmax = 0.40; s2blegymin = 0.30; s2blegymax = 0.50; lblxmin = 0.65; lblxmax = 0.80; lblymin = 0.60; lblymax = 0.65; } else if (strpltmd.compare("sin") == 0) { plottitle += "#font[42]{sin(#tilde{#phi}) over }#font[52]{#tilde{x}}#font[42]{.}"; xtitle = "#font[52]{#tilde{x}}"; ytitle = "#font[42]{sin(#tilde{#phi})}"; display = "C"; mmlegxmin = 0.15; mmlegxmax = 0.30; mmlegymin = 0.75; mmlegymax = 0.85; s2blegxmin = 0.60; s2blegxmax = 0.85; s2blegymin = 0.30; s2blegymax = 0.50; lblxmin = 0.65; lblxmax = 0.80; lblymin = 0.60; lblymax = 0.65; } else if (strpltmd.compare("mmp") == 0) { plottitle += "#font[42]{Masses of the new heavy gauge bosons.}"; xtitle = "#font[52]{M_{Z'}}#font[42]{ (TeV)}"; ytitle = "#font[52]{M_{W'}}#font[42]{ (TeV)}"; display = "C"; mmlegxmin = 0.15; mmlegxmax = 0.30; mmlegymin = 0.75; mmlegymax = 0.85; s2blegxmin = 0.60; s2blegxmax = 0.85; s2blegymin = 0.45; s2blegymax = 0.65; lblxmin = 0.35; lblxmax = 0.50; lblymin = 0.45; lblymax = 0.50; }; // PREPARE BOSON MASSES AND PHI BOUNDS ////////////////////////////////// string mdl(filename,0,2); if ( (mdl.compare("lr") == 0) || (mdl.compare("lp") == 0) || (mdl.compare("hp") == 0) || (mdl.compare("fp") == 0) ) { phiMin = 5.600; phiMax = 84.400; string Higgs(filename,3,1); if (Higgs.compare("d") == 0) { Cz1 = 11.95349795785275; Cz2 = 30.63269990028513; Cz3 = 42.58619785813789; Cw1 = 21.29309892906894; Cw2 = 9.339600971216193; Cw3 = 30.63269990028513; Cw4 = 42.58619785813789; } else if (Higgs.compare("t") == 0) { Cz1 = 5.976748978926375; Cz2 = 30.63269990028513; Cz3 = 85.17239571627579; Cw1 = 15.05649464522066; Cw2 = 3.302047590161717; Cw3 = 21.66058982554409; Cw4 = 60.22597858088265; } } else if ( (mdl.compare("uu") == 0) || (mdl.compare("nu") == 0) ) { phiMin = 10.179, phiMax = 79.821; C1 = 94.0397928463607; C2 = 77.1253849720165; } else {error(6);} cphmin = cos(TMath::Pi()*phiMin/180.0)*cos(TMath::Pi()*phiMin/180.0); cphmax = cos(TMath::Pi()*phiMax/180.0)*cos(TMath::Pi()*phiMax/180.0); sphmin = sin(TMath::Pi()*phiMin/180.0)*sin(TMath::Pi()*phiMin/180.0); sphmax = sin(TMath::Pi()*phiMax/180.0)*sin(TMath::Pi()*phiMax/180.0); // LOOP OVER ROOT FILES //////////////////////////////////////////////// for(file=0; file<=1; file++) { if(file==0) string epsfile = filename + "_" + strpltmd + ".eps"; if(file==1) string filename = filename + "_sm"; string rootname = filename + ".root"; TFile *rootfile = TFile::Open(rootname.c_str()); if(rootfile == NULL) error(1); TTree *tree = (TTree*)rootfile->Get(filename.c_str()); if(tree == NULL) error(2); TBranch *fits2bbranch = (TBranch*)tree->GetBranch("fits2b"); TBranch *fittphbranch = (TBranch*)tree->GetBranch("fittph"); TBranch *fitxbranch = (TBranch*)tree->GetBranch("fitx"); if( (fits2bbranch == NULL) || (fittphbranch == NULL) || (fitxbranch == NULL) ) error(3); tree->SetBranchAddress("fits2b",&fits2b); tree->SetBranchAddress("fittph",&fittph); tree->SetBranchAddress("fitx", &fitx); // GET ARRAYS /////////////////////////////////////////////////////////// Int_t Npoints = (Int_t)tree->GetEntries(); Int_t tphStep = 0; Float_t tphMax = -1.0; for(point=0; point<Npoints; point++) { tree->GetEntry(point); if( fittph > tphMax ) {tphStep++; tphMax = fittph;} }; const int tphSteps = tphStep; Float_t xArray[tphSteps], yArray[tphSteps], zArray[tphSteps]; tphStep = -1, tphold = -1.0, fitxmin = 100000; for(point=0; point<Npoints; point++) { tree->GetEntry(point); if(fittph > tphold) {tphStep++; fitxmin = 100000;} fitsph = fittph / (1.0 + fittph); fitcph = 1.0 - fitsph; if (strpltmd.compare("tan") == 0) { xVal = fitx; yVal = fittph; } else if (strpltmd.compare("cos") == 0) { xVal = fitx; yVal = sqrt(fitcph); } else if (strpltmd.compare("sin") == 0) { xVal = fitx; yVal = sqrt(fitsph); } else if (strpltmd.compare("mmp") == 0) { if (fitsph != 0.0) { if ( (mdl.compare("lr") == 0) || (mdl.compare("lp") == 0) || (mdl.compare("hp") == 0) || (mdl.compare("fp") == 0) ) { MMI(Cz1,Cz2,Cz3,Cw1,Cw2,Cw3,Cw4,fitx,fitsph,fitcph,fits2b,xVal,yVal); } else if ( (mdl.compare("uu") == 0) || (mdl.compare("nu") == 0) ) { MMII(C1,C2,fitx,fitsph,fitcph,xVal,yVal); } } } if( (strpltmd.compare("mmp") == 0) && (tphStep==1) ) { xArray[0] = xArray[1]; yArray[0] = yArray[1]; zArray[0] = zArray[1]; } if(fitx>fitxmax) fitxmax = fitx; if(fitx<fitxmin) { xArray[tphStep] = xVal; yArray[tphStep] = yVal; zArray[tphStep] = fits2b; fitxmin = fitx; } tphold = fittph; } if(file==0) TGraph *NPplot = new TGraph(tphSteps,xArray,yArray); if(file==1) TGraph *SMplot = new TGraph(tphSteps,xArray,yArray); TMarker *NPmrk[tphSteps], *SMmrk[tphSteps]; for(tphStep=0; tphStep<tphSteps; tphStep++){ marker(zArray[tphStep],color,style); if(file==0) { NPmrk[tphStep] = new TMarker(xArray[tphStep],yArray[tphStep],style); NPmrk[tphStep]->SetMarkerSize(0.8); NPmrk[tphStep]->SetMarkerColor(color);} if(file==1) { SMmrk[tphStep] = new TMarker(xArray[tphStep],yArray[tphStep],style); SMmrk[tphStep]->SetMarkerSize(0.8); SMmrk[tphStep]->SetMarkerColor(color);} if( (strpltmd.compare("mmp") != 0) || (tphStep !=0 )) { if (xArray[tphStep] < xMin) xMin = xArray[tphStep]; if (xArray[tphStep] > xMax) xMax = xArray[tphStep]; if (yArray[tphStep] < yMin) yMin = yArray[tphStep]; if (yArray[tphStep] > yMax) yMax = yArray[tphStep]; } if( ((strfile.compare("uu-d") == 0) || (strfile.compare("nu-d") == 0)) && (strpltmd.compare("sin") == 0) ) { fitx = xArray[tphStep]; fitsph = yArray[tphStep]*yArray[tphStep]; fitcph = 1.0 - fitsph; if( (sphmin < fitsph) && (fitsph<sphmax) ) { MMII(C1,C2,fitx,fitsph,fitcph,MZ,MW); if(MZ < Mmin) { Mmin = MZ; cout << MZ << "\t" << sqrt(fitsph) << endl;} } } } } // CREATE PLOTS ///////////////////////////////////////////////////////// NPplot->SetLineStyle(2); NPplot->SetMarkerStyle(20); NPplot->SetMarkerSize(0.4); SMplot->SetMarkerStyle(20); SMplot->SetMarkerSize(0.4); if(strpltmd.compare("cos") == 0) {yMin = 0.0; yMax = 1.0;} if(strpltmd.compare("sin") == 0) {yMin = 0.0; yMax = 1.0;} if(strpltmd.compare("mmp") == 0) {xMin = 0.0; xMax = 5.0; yMin = 0.0; yMax = 5;} TH1F* frame = MyC->DrawFrame(0.9*xMin,0.9*yMin,1.1*xMax,1.0*yMax); frame->SetTitle(plottitle.c_str()); TAxis *xaxis = frame->GetXaxis(); TAxis *yaxis = frame->GetYaxis(); xaxis->SetTitle(xtitle.c_str()); xaxis->CenterTitle(); xaxis->SetTitleOffset(1.); xaxis->SetDecimals(); xaxis->SetLabelSize(0.03); xaxis->SetLabelOffset(0.01); yaxis->SetTitle(ytitle.c_str()); yaxis->CenterTitle(); yaxis->SetTitleOffset(1.2); yaxis->SetDecimals(); yaxis->SetLabelSize(0.03); yaxis->SetLabelOffset(0.01); TLegend *mmleg = new TLegend(mmlegxmin,mmlegymin,mmlegxmax,mmlegymax); mmleg->AddEntry(NPplot,NPleg.c_str(),"l"); mmleg->AddEntry(SMplot,SMleg.c_str(),"l"); mmleg->SetTextSize(0.025); mmleg->SetFillStyle(0); if( (strfile.compare("uu-d") != 0) && (strfile.compare("nu-d") != 0) ) { for(tphStep=0; tphStep<tphSteps; tphStep++){NPmrk[tphStep]->Draw(); SMmrk[tphStep]->Draw();} } Float_t xdummy[1] = {0.0}, ydummy[1] = {0.0}; TGraph *circle = new TGraph(1,xdummy,ydummy); circle->SetMarkerStyle(24); circle->SetMarkerColor(kGreen+1); circle->SetMarkerSize(0.8); TGraph *square = new TGraph(1,xdummy,ydummy); square->SetMarkerStyle(25); square->SetMarkerColor(kCyan+1); square->SetMarkerSize(0.8); TGraph *triangle = new TGraph(1,xdummy,ydummy); triangle->SetMarkerStyle(26); triangle->SetMarkerColor(kBlue+1); triangle->SetMarkerSize(0.8); TGraph *diamond = new TGraph(1,xdummy,ydummy); diamond->SetMarkerStyle(27); diamond->SetMarkerColor(kMagenta+1); diamond->SetMarkerSize(0.8); TLegend *s2bleg = new TLegend(s2blegxmin,s2blegymin,s2blegxmax,s2blegymax); s2bleg->AddEntry(circle,"#font[42]{0.00 < sin^{2}(2#tilde{#beta}) #leq 0.25}","p"); s2bleg->AddEntry(square,"#font[42]{0.25 < sin^{2}(2#tilde{#beta}) #leq 0.50}","p"); s2bleg->AddEntry(triangle,"#font[42]{0.50 < sin^{2}(2#tilde{#beta}) #leq 0.75}","p"); s2bleg->AddEntry(diamond,"#font[42]{0.75 < sin^{2}(2#tilde{#beta}) #leq 1.00}","p"); s2bleg->SetTextSize(0.025); s2bleg->SetFillStyle(0); NPplot->Draw(display.c_str()); SMplot->Draw(display.c_str()); mmleg->Draw(); if( (strfile.compare("uu-d") != 0) && (strfile.compare("nu-d") != 0) ) s2bleg->Draw(); // BOUNDS ON PHI ////////////////////////////////////////////////////// Int_t i; const int iSteps = 100; fitxmin = 1.0, fitxmax *= 1.5; Float_t deltax = (fitxmax-fitxmin)/iSteps; Float_t phixmin0[iSteps], phixmax0[iSteps], phixmin1[iSteps], phixmax1[iSteps]; Float_t phiymin0[iSteps], phiymax0[iSteps], phiymin1[iSteps], phiymax1[iSteps]; if ( (strpltmd.compare("tan") == 0) || (strpltmd.compare("cos") == 0) || (strpltmd.compare("sin") == 0) ) { for(i=0; i<100; i++) { fitx = fitxmin + i*deltax; phixmin0[i] = fitx; if (strpltmd.compare("tan") == 0) { phiymin0[i] = sphmin / cphmin; phiymax0[i] = sphmax / cphmax; } if (strpltmd.compare("cos") == 0) { phiymin0[i] = sqrt(cphmin); phiymax0[i] = sqrt(cphmax); } if (strpltmd.compare("sin") == 0) { phiymin0[i] = sqrt(sphmin); phiymax0[i] = sqrt(sphmax); } } TGraph *phiMin0 = new TGraph(iSteps,phixmin0,phiymin0); TGraph *phiMax0 = new TGraph(iSteps,phixmin0,phiymax0); } else if (strpltmd.compare("mmp") == 0) { if ( (mdl.compare("lr") == 0) || (mdl.compare("lp") == 0) || (mdl.compare("hp") == 0) || (mdl.compare("fp") == 0) ) { for(i=0; i<100; i++) { fitx = fitxmin + i*deltax; MMI(Cz1,Cz2,Cz3,Cw1,Cw2,Cw3,Cw4,fitx,sphmin,cphmin,0.0,phixmin0[i],phiymin0[i]); MMI(Cz1,Cz2,Cz3,Cw1,Cw2,Cw3,Cw4,fitx,sphmin,cphmin,1.0,phixmin1[i],phiymin1[i]); MMI(Cz1,Cz2,Cz3,Cw1,Cw2,Cw3,Cw4,fitx,sphmax,cphmax,0.0,phixmax0[i],phiymax0[i]); MMI(Cz1,Cz2,Cz3,Cw1,Cw2,Cw3,Cw4,fitx,sphmax,cphmax,1.0,phixmax1[i],phiymax1[i]); } TGraph *phiMin0 = new TGraph(iSteps,phixmin0,phiymin0); TGraph *phiMin1 = new TGraph(iSteps,phixmin1,phiymin1); TGraph *phiMax0 = new TGraph(iSteps,phixmax0,phiymax0); TGraph *phiMax1 = new TGraph(iSteps,phixmax1,phiymax1); phiMin1->SetLineStyle(7); phiMin1->SetMarkerStyle(22); phiMin1->SetMarkerSize(1.0); phiMax1->SetLineStyle(7); phiMax1->SetMarkerStyle(22); phiMax1->SetMarkerSize(1.0); phiMin1->Draw("C"); phiMax1->Draw("C"); } else if ( (mdl.compare("uu") == 0) || (mdl.compare("nu") == 0) ) { for(i=0; i<100; i++) { fitx = fitxmin + i*deltax; MMII(C1,C2,fitx,sphmin,cphmin,phixmin0[i],phiymin0[i]); MMII(C1,C2,fitx,sphmax,cphmax,phixmax0[i],phiymax0[i]); } TGraph *phiMin0 = new TGraph(iSteps,phixmin0,phiymin0); TGraph *phiMax0 = new TGraph(iSteps,phixmax0,phiymax0); } } phiMin0->SetLineStyle(3); phiMin0->SetMarkerStyle(20); phiMin0->SetMarkerSize(0.4); phiMax0->SetLineStyle(3); phiMax0->SetMarkerStyle(20); phiMax0->SetMarkerSize(0.4); phiMin0->Draw("C"); phiMax0->Draw("C"); // LABEL ALLOWED REGION /////////////////////////////////////////////// TPaveText *allowed = new TPaveText(lblxmin,lblymin,lblxmax,lblymax,"NDC"); TText *text = allowed->AddText("#font[42]{allowed (95% CL)}"); allowed->SetTextSize(0.04); if (strpltmd.compare("tan") == 0) text->SetTextAngle(270); allowed->SetFillStyle(0); allowed->SetLineColor(0); allowed->SetBorderSize(1); allowed->Draw(); // SAVE GRAPHIC /////////////////////////////////////////////////////// MyC->Print(epsfile.c_str()); }
void plottingmacro_IVF() { double fa = 0.46502; double fb = 0.53498; bool debug_ = true; // std::string path("Nov10thFall11Plots/"); // std::string path("Nov10Fall1160MTopSlimPlots/"); std::string path("Nov10Fall1160MTopIVFPlots_b/"); if(debug_) std::cout << "Init the style form setTDRStyle" << std::endl; setTDRStyle(); gStyle->SetErrorX(0.5); gROOT->ForceStyle(); initOptions(); if(debug_) std::cout << "Init the sample" << std::endl; // std::vector<Sample> s = Nov10thDiJetPtUpdatedSlimHistos(); //std::vector<Sample> s = Nov10Fall1160MTopSlimHistos(); std::vector<Sample> s = Nov10Fall1160MTopIVFHistos(); Sample data(1,"fake data","S1.root",0,true,1000); if(debug_) std::cout << "Init the data sample" << std::endl; for(size_t i=0;i< s.size();i++) if(s[i].data) {data=s[i];break;} if(debug_) std::cout << "Ls data sample" << std::endl; data.file()->ls(); if(debug_) std::cout << "Init the mc sample" << std::endl; for(size_t i=0;i< s.size();i++) s[i].dump(1,fa,fb); std::vector<std::string> names; if(debug_) std::cout << "Get List of Keys" << std::endl; TList * subs = data.file()->GetListOfKeys(); for(size_t i=0;i< subs->GetSize();i++) { TString nn = subs->At(i)->GetName(); if( nn.Contains(TRegexp("Count*")) ) continue; if(debug_) std::cout << "Get List of Keys in subdirs" << std::endl; TList * objs = ((TDirectoryFile *)data.file()->Get(subs->At(i)->GetName()))->GetListOfKeys(); for(size_t j=0;j< objs->GetSize();j++) { if(debug_) std::cout << "Name = " << subs->At(i)->GetName()+std::string("/") + objs->At(j)->GetName() << std::endl; names.push_back(subs->At(i)->GetName()+std::string("/") + objs->At(j)->GetName()); // std::cout << subs->At(i)->GetName() << "/" << objs->At(j)->GetName() << std::endl; //TODO: select plots via regexp } } if(debug_) std::cout << "Starting plotting" << std::endl; std::string process; for(size_t i = 0 ; i < names.size() ; i++) { std::map<std::string,TH1F *> grouped; TString n=names[i]; // if(!n.Contains(TRegexp("VlightRegionHZee/HiggsPtVlightRegionHZee"))) continue; // if(!n.Contains(TRegexp("VlightRegionHZee/ZPtVlightRegionHZee"))) continue; // if(!n.Contains(TRegexp("VlightRegionHZee"))) continue; // if(!n.Contains(TRegexp("ZSVRegionZmmSV"))) continue; // if(!n.Contains(TRegexp("ZSVRegionZeeSV"))) continue; // if(!n.Contains(TRegexp("ZSVRegionZcombSV"))) continue; // if(!n.Contains(TRegexp("ZSVPureRegionZcombSV"))) continue; // if(!n.Contains(TRegexp("ZSVTTbarPureRegionZcombSV"))) continue; if(!n.Contains(TRegexp("TTbarRegionZeeSVJets"))) continue; if(n.Contains(TRegexp("RegionHZcomb"))) process = "Z(l^{+}l^{-})H(b#bar{b})"; if(n.Contains(TRegexp("RegionHZmm"))) process = "Z(#mu^{+}#mu^{-})H(b#bar{b})"; if(n.Contains(TRegexp("RegionHZee"))) process = "Z(e^{+}e^{-})H(b#bar{b})"; if(debug_) std::cout << "Creating the Canvas" << std::endl; TCanvas *c = new TCanvas(); c->SetLogy(false); c->SetTitle(names[i].c_str()); if(debug_) std::cout << "Creating histograms" << std::endl; TH1F *hd = ((TH1F*)data.file()->Get(names[i].c_str())); hd->Sumw2(); Options o=options[names[i]]; // hd->Rebin(o.rebin); hd->SetMarkerStyle(20); hd->GetXaxis()->SetLabelOffset(99); hd->SetYTitle(o.yaxis.c_str()); double nbin = hd->GetNbinsX(); double min_bin = hd->GetXaxis()->GetXmin(); double max_bin = hd->GetXaxis()->GetXmax(); TH1F *hmc = new TH1F("hmc","hmc", nbin, min_bin, max_bin); hmc->SetFillColor(kWhite); hmc->Sumw2(); // hmc->Rebin(o.rebin); if(debug_) std::cout << "Creating the THStack and Legend" << std::endl; THStack * sta = new THStack("sta",hd->GetTitle()); TLegend * l = new TLegend(o.legendx1,o.legendy1,o.legendx2,o.legendy2); //0.7,0.1,0.9,0.6); l->SetFillColor(kWhite); l->SetBorderSize(0); l->SetTextFont(62); l->SetTextSize(0.03); if(debug_) std::cout << "Adding data to the legend" << std::endl; l->AddEntry(hd, "Data","P"); if(debug_) std::cout << "Adding MC to the THStack" << std::endl; //with the proper trigger eff // double SF[] = {1.01,1.03,1.00}; // double SF[] = {1.03,1.054,1.032}; double SF[] = {1.0,1.0,1.0}; if(debug_){ for(int i = 0; i< 3; ++i) std::cout << "SF [" << i << "] = " << SF[i] << std::endl; } double mcIntegral=0; for(size_t j=0;j< s.size() ;j++) { if(!s[j].data) { if(debug_) std::cout << "Creating TH1F from file " << s[j].name << std::endl; TH1F * h = ((TH1F*)s[j].file()->Get(names[i].c_str())); h->Sumw2(); if(debug_){ std::cout << "TH1F created from file " << s[j].name << std::endl; std::cout << "Scaling : " << s[j].scale(data.lumi(),fa,fb) << std::endl; std::cout << "Scaling with SF : " << s[j].scale(data.lumi(),fa,fb,SF) << std::endl; std::cout << "Histo integral before scaling = " << h->Integral() << std::endl; } h->Scale(s[j].scale(data.lumi(),fa,fb,SF)); if(debug_){ std::cout << "Histo integral after scaling = " << h->Integral() << std::endl; std::cout << "Managing style... " << std::endl; } h->SetLineWidth(1.); h->SetFillColor(s[j].color); h->SetLineColor(s[j].color); // h->Rebin(options[names[i]].rebin); if(debug_) std::cout << "Cloning and update legend " << std::endl; if(grouped.find(s[j].name) == grouped.end()){ l->AddEntry(h,s[j].name.c_str(),"F"); } std::cout << "Sample : " << s[j].name << " - Integral for plot " << names[i] << " = " << h->Integral(-10000,10000) << std::endl; mcIntegral += h->Integral(); sta->Add(h); hmc->Add(h); //TO FIX grouped map // sovrascrive histo con lo stesso nome tipo VV o ST etc... grouped[s[j].name]=(TH1F *)h->Clone(("_"+names[i]).c_str()); } } if(debug_){ std::cout << "Data total = " << hd->Integral() << std::endl; std::cout << "MC = " << mcIntegral << std::endl; std::cout << "Data/MC = " << hd->Integral()/mcIntegral << std::endl; } TPad * TopPad = new TPad("TopPad","Top Pad",0.,0.3,1.,1. ) ; TPad * BtmPad = new TPad("BtmPad","Bottom Pad",0.,0.,1.,0.313 ) ; TopPad->SetBottomMargin(0.02); BtmPad->SetTopMargin(0.0); BtmPad->SetFillStyle(4000); TopPad->SetFillStyle(4000); BtmPad->SetFillColor(0); BtmPad->SetBottomMargin(0.35); TopPad->Draw() ; BtmPad->Draw() ; std::cout << "hd maximum = " << hd->GetMaximum() << " sta maximum = " << sta->GetMaximum() << std::endl; double maxY; if(hd->GetMaximum() > sta->GetMaximum()) maxY = (hd->GetMaximum())*1.5; else maxY = (sta->GetMaximum())*1.5; TopPad->cd(); hd->Draw("E1X0"); sta->Draw("sameHIST"); hmc->Draw("sameE2"); hmc->SetFillColor(2); hmc->SetMarkerSize(0); hmc->SetFillStyle(3013); hd->Draw("E1X0same"); l->Draw("same"); std::cout << "Set Maximum to = " << maxY << std::endl; hd->GetYaxis()->SetRangeUser(0.,maxY); hd->GetXaxis()->SetRangeUser(options[names[i]].min,options[names[i]].max); BtmPad->cd(); std::cout << "Division" << std::endl; TH1D * divisionErrorBand = (TH1D*)(hmc)->Clone("divisionErrorBand"); divisionErrorBand->Sumw2(); divisionErrorBand->Divide(hmc); divisionErrorBand->Draw("E2"); divisionErrorBand->SetMaximum(2.49); divisionErrorBand->SetMinimum(0); divisionErrorBand->SetMarkerStyle(20); divisionErrorBand->SetMarkerSize(0.55); divisionErrorBand->GetXaxis()->SetTitleOffset(1.12); divisionErrorBand->GetXaxis()->SetLabelSize(0.12); divisionErrorBand->GetXaxis()->SetTitleSize(0.5); divisionErrorBand->GetYaxis()->SetTitle("Data/MC"); divisionErrorBand->GetYaxis()->SetLabelSize(0.12); divisionErrorBand->GetYaxis()->SetTitleSize(0.12); divisionErrorBand->GetYaxis()->SetTitleOffset(0.40); divisionErrorBand->GetYaxis()->SetNdivisions(505); //divisionErrorBand->UseCurrentStyle(); divisionErrorBand->SetFillColor(2); divisionErrorBand->SetFillStyle(3001); divisionErrorBand->SetMarkerSize(0.); TH1D * division = (TH1D*)(hd)->Clone("division"); division->Sumw2(); division->Divide(hmc); // division->SetMaximum(2.5); // division->SetMinimum(0); // division->SetMarkerStyle(20); // division->SetMarkerSize(0.55); // division->GetXaxis()->SetLabelSize(0.12); // division->GetXaxis()->SetTitleSize(0.14); // division->GetYaxis()->SetLabelSize(0.10); // division->GetYaxis()->SetTitleSize(0.10); // division->GetYaxis()->SetTitle("Data/MC"); Double_t min = division->GetXaxis()->GetXmin(); Double_t max = division->GetXaxis()->GetXmax(); division->Draw("E1X0same"); TLine *line = new TLine(min, 1.0, max, 1.0); line->SetLineColor(kRed); line->Draw("same"); TLegend * leg3 =new TLegend(0.50,0.86,0.69,0.96); leg3->AddEntry(divisionErrorBand,"MC uncert. (stat.)","f"); leg3->SetFillColor(0); leg3->SetLineColor(0); leg3->SetShadowColor(0); leg3->SetTextFont(62); leg3->SetTextSize(0.06); leg3->Draw(); TPaveText *pave = new TPaveText(0.15,0.85,0.32,0.96,"brNDC"); pave->SetTextAlign(12); pave->SetLineColor(0); pave->SetFillColor(0); pave->SetShadowColor(0); //TText *text = pave->AddText(Form("#chi_{#nu}^{2} = %.3f, K_{s} = %.3f",histDt->Chi2Test(histCopyMC5,"UWCHI2/NDF"),histDt->KolmogorovTest(histCopyMC5))); // stat + sys TText *text = pave->AddText(Form("#chi_{#nu}^{2} = %.3f, K_{s} = %.3f",hd->Chi2Test(hmc,"UWCHI2/NDF"),hd->KolmogorovTest(hmc))); // stat only text->SetTextFont(62); text->SetTextSize(0.08); pave->Draw(); TopPad->cd(); TLatex latex; latex.SetNDC(); latex.SetTextAlign(12); latex.SetTextSize(0.052); latex.DrawLatex(0.17,0.89,"CMS Preliminary"); latex.SetTextSize(0.04); latex.DrawLatex(0.17,0.84,"#sqrt{s} = 7 TeV, L = 4.7 fb^{-1}"); // latex.DrawLatex(0.17,0.79,"Z(e^{+}e^{-})H(b#bar{b})"); latex.DrawLatex(0.17,0.79,process.c_str()); c->Update(); std::string cName= hd->GetName(); cName += "_bare.pdf"; cName = path+cName; c->Print(cName.c_str(),"pdf"); // std::cout << names[i] << " d: " << hd->Integral() << " "; // THStack * sta2 = new THStack("sta2",hd->GetTitle()); // float tot=0; // float toterr2=0; // if(debug_) // std::cout << "Putting the iterator in the for loop" << std::endl; // for(std::map<std::string,TH1F *>::reverse_iterator it=grouped.rbegin(); it!=grouped.rend();++it) // { // if(debug_) // std::cout << "Using the iterator" << std::endl; // std::cout << (*it).first << " " << (*it).second->Integral() << " | " << std::endl ; // if((*it).second->GetEntries() > 0) { // float er=1.*sqrt((*it).second->GetEntries())/(*it).second->GetEntries()*(*it).second->Integral(); // toterr2+=er*er; // } // tot+=(*it).second->Integral(); // sta2->Add(it->second); // } // std::cout << " Tot: " << tot << "+-" << sqrt(toterr2) << " SF: " << hd->Integral()/tot << std::endl; // TCanvas *c2 = new TCanvas(); // c2->SetTitle(names[i].c_str()); // std::cout << "hd maximum = " << hd->GetMaximum() << " sta2 maximum = " << sta2->GetMaximum() << std::endl; // if(hd->GetMaximum() > sta2->GetMaximum()) maxY = hd->GetBinContent(hd->GetMaximumBin()) * 1.5; // else maxY = ( sta2->GetMaximum())*1.5; // // hd->Draw("E1"); // sta2->Draw("PADSHIST"); // // hd->Draw("E1same"); // // l->Draw("same"); // std::cout << "Set Maximum to = " << maxY << std::endl; // hd->GetYaxis()->SetRangeUser(0.,maxY); // hd->GetXaxis()->SetRangeUser(options[names[i]].min,options[names[i]].max); // c2->Update(); // std::string c2Name = hd->GetName(); // c2Name = path+c2Name; // c2Name += "_norm.pdf"; // c2->Print(c2Name.c_str(),"pdf"); } }
void newBrezilianflagneventstGc(){ TF1 *fa = new TF1("fa","7.15*x*x",0.001,0.13); TCanvas *c1 = new TCanvas("c1","upper limit results ",200,10,700,500); c1->SetGrid(); const int N=2; //double X[N]={0.001,0.13}; //double nO[N]={0.0365,0.0365 }; //double nE[N]={0.0469,0.0469}; double X[N]={0.001,0.13}; double nO[N]={0.0372,0.0372 }; double nE[N]={0.0481,0.0481}; cout<<"expected tgammac coupling"<<sqrt(nE[0]/7.15)<<endl; cout<<"observed tgammac coupling"<<sqrt(nO[0]/7.15)<<endl; cout<<"expected tgammac coupling including k-factor"<<sqrt(nE[0]/(1.375*7.15))<<endl; cout<<"observed tgammac coupling including k-factor"<<sqrt(nO[0]/(1.375*7.15))<<endl; double nE1sigmaup[N]={0.0648,0.0648}; double nE1sigmadown[N]={0.0351,0.0351}; double nE2sigmaup[N]={0.0949,0.0949}; double nE2sigmadown[N]={0.0266,0.0266}; double sigma1up[N]; double sigma1down[N]; double sigma2up[N]; double sigma2down[N]; for (int idx=0; idx<N; ++idx){ sigma1up[idx]=nE1sigmaup[idx]-nE[idx]; sigma1down[idx]=nE[idx]-nE1sigmadown[idx]; sigma2up[idx]=nE2sigmaup[idx]-nE[idx]; sigma2down[idx]=nE[idx]-nE2sigmadown[idx]; } TGraphAsymmErrors *grafexp1sigma=new TGraphAsymmErrors(N); grafexp1sigma->SetName("grafexp1sigma"); grafexp1sigma->SetTitle("Graph"); grafexp1sigma->SetFillColor(1); //grafexp1sigma->SetPoint(point number ,x value,y value); //grafexp1sigma->SetPointError(point number ,0,0,y lower error ,y upper error); grafexp1sigma->SetPoint(0,X[0],nE[0]); grafexp1sigma->SetPointError(0,0,0,sigma1down[0],sigma1up[0]); grafexp1sigma->SetPoint(1,X[1],nE[1]); grafexp1sigma->SetPointError(1,0,0,sigma1down[1],sigma1up[1]); /* grafexp1sigma->SetPoint(2,X[2],nE[2]); grafexp1sigma->SetPointError(2,0,0,sigma1down[2],sigma1up[2]); grafexp1sigma->SetPoint(3,X[3],nE[3]); grafexp1sigma->SetPointError(3,0,0,sigma1down[3],sigma1up[3]); grafexp1sigma->SetPoint(4,X[4],nE[4]); grafexp1sigma->SetPointError(4,0,0,sigma1down[4],sigma1up[4]); */ grafexp1sigma->SetFillColor(kGreen); // grafexp1sigma-> // grafexp1sigma-> // grafexp1sigma-> // grafexp1sigma-> TGraphAsymmErrors *grafexp2sigma=new TGraphAsymmErrors(N); grafexp2sigma->SetPoint(0,X[0],nE[0]); grafexp2sigma->SetPointError(0,0,0,sigma2down[0],sigma2up[0]); grafexp2sigma->SetPoint(1,X[1],nE[1]); grafexp2sigma->SetPointError(1,0,0,sigma2down[1],sigma2up[1]); /* grafexp2sigma->SetPoint(2,X[2],nE[2]); grafexp2sigma->SetPointError(2,0,0,sigma2down[2],sigma2up[2]); grafexp2sigma->SetPoint(3,X[3],nE[3]); grafexp2sigma->SetPointError(3,0,0,sigma2down[3],sigma2up[3]); grafexp2sigma->SetPoint(4,X[4],nE[4]); grafexp2sigma->SetPointError(4,0,0,sigma2down[4],sigma2up[4]); */ grafexp2sigma->SetFillColor(kYellow); grafexp2sigma->GetXaxis()->SetLabelFont(42); // grafexp2sigma->SetLabel(""); grafexp2sigma->GetXaxis()->SetLabelOffset(0.007); grafexp2sigma->GetXaxis()->SetLabelSize(0.034); grafexp2sigma->GetXaxis()->SetTitleSize(0.045); grafexp2sigma->GetXaxis()->SetTitleFont(22); grafexp2sigma->GetXaxis()->SetTitleOffset(0.90); grafexp2sigma->GetXaxis()->SetRangeUser(0, 0.2); grafexp2sigma->GetYaxis()->SetRangeUser(0, 0.16); grafexp2sigma->GetYaxis()->SetTitle("95% CL Limit on [#sigma_{tc#gamma} * Br(w #rightarrow l#nu)] (pb)"); grafexp2sigma->GetYaxis()->SetLabelFont(42); grafexp2sigma->GetYaxis()->SetLabelOffset(0.007); grafexp2sigma->GetYaxis()->SetLabelSize(0.034); grafexp2sigma->GetYaxis()->SetTitleSize(0.045); grafexp2sigma->GetYaxis()->SetTitleOffset(0.9); grafexp2sigma->GetYaxis()->SetTitleFont(22); grafexp2sigma->GetXaxis()->SetTitle("#kappa_{c}"); grafexp2sigma->SetTitle(""); // grafexp2sigma->SetMaximum(8); TGraph *Expected= new TGraph(N,X,nE); Expected->SetLineColor(4); Expected->SetLineWidth(2); Expected->SetMarkerColor(1); Expected->SetMarkerStyle(20); Expected->SetLineStyle(2); Expected->GetYaxis()->SetTitle("Cross Section [pb]"); Expected->GetXaxis()->SetTitle("#Lambda_{T} [GeV]"); Expected->SetTitle("with "); Expected->SetFillColor(10); TGraph *Observed= new TGraph(N,X,nO); Observed->SetLineColor(1); Observed->SetLineWidth(2); Observed->SetMarkerColor(1); Observed->SetMarkerStyle(20); // Observed->SetLineStyle(2); Observed->GetYaxis()->SetTitle("Cross Section [pb]"); Observed->GetXaxis()->SetTitle("#Lambda_{T} [GeV]"); Observed->SetTitle("with "); Observed->SetFillColor(10); grafexp2sigma->Draw("AL3"); grafexp1sigma->Draw("L3same"); Expected->Draw("L"); Observed->Draw("L"); fa->SetLineColor(2); fa->SetLineWidth(3); fa->SetMarkerColor(1); fa->Draw("same"); Observed->GetHistogram()->Draw("AXISSAMEY+"); Observed->GetHistogram()->Draw("AXISSAMEX+"); TLegend *leg1 = new TLegend(0.2, 0.6, 0.35, 0.8); leg1->SetTextSize(0.03); leg1->SetBorderSize(0); leg1->SetLineColor(0); leg1->SetLineWidth(0); leg1->SetFillColor(kWhite); leg1->AddEntry(fa, "Predicted", "L"); leg1->AddEntry(Observed, "95% CL Observed Limit", "L"); leg1->AddEntry(Expected, "95% CL Expected Limit", "L"); leg1->AddEntry(grafexp1sigma, "#pm1#sigma Exp.Limit", "F"); leg1->AddEntry(grafexp2sigma, "#pm2#sigma Exp.Limit", "F"); leg1->Draw(); TLine *line1 = new TLine(5, 1, 40, 1); line1->SetLineColor(2); line1->SetLineWidth(2); // line1->Draw("same"); TPaveText *pt = new TPaveText(0.1,0.95,0.4,0.95, "NDC"); // NDC sets coords pt->SetLineColor(10); // relative to pad dimensions pt->SetFillColor(10); // text is black on white pt->SetTextSize(0.045); pt->SetTextAlign(12); pt->AddText("CMS Preliminary, 19.1 fb^{-1}, #sqrt{s} = 8 TeV"); pt->SetShadowColor(10); pt->Draw("same"); }