void make_psi2s_mupt(float ptmin=0.0, float ptmax=30.0, float ymin=0.0, float ymax=2.4, bool absRapidity=true, bool saveFile=false) { TCanvas *c1 = new TCanvas("c1","c1"); c1->SetLogy(); TCut defaultCut = "Reco_QQ_sign==0&&Reco_QQ_4mom.M()>3.35&&Reco_QQ_4mom.M()<4.0&&Reco_QQ_ctauTrue>-10"; TCut ptCut = Form("Reco_QQ_4mom.Pt()>%4.1f&&Reco_QQ_4mom.Pt()<%4.1f",ptmin,ptmax); TCut rapCut; if (absRapidity) rapCut = Form("abs(Reco_QQ_4mom.Rapidity())>%3.1f&&abs(Reco_QQ_4mom.Rapidity())<%3.1f",ymin,ymax); else rapCut = Form("Reco_QQ_4mom.Rapidity()>%3.1f&&Reco_QQ_4mom.Rapidity()<%3.1f",ymin,ymax); unsigned int trigBit=2; // DoubleMu0_HighQ TCut trigCut = Form("(HLTriggers&%u)==%u&&(Reco_QQ_trig&%u)==%u",trigBit,trigBit,trigBit,trigBit); TString fname; fname = Form("20140324/MC_psi2s_pp_mupt_Rap_%3.1f-%3.1f_Pt_%3.1f-%3.1f.root",ymin,ymax,ptmin,ptmax); std::cout << fname << std::endl; std::cout << "default: " << defaultCut.GetTitle() << std::endl; std::cout << "pt cut: " << ptCut.GetTitle() << std::endl; std::cout << "rapidity cut: " << rapCut.GetTitle() << std::endl; std::cout << "trigger bit: " << trigCut.GetTitle() << std::endl; TH1F *hMuPlPtRec = new TH1F("hMuPlPtRec","hMuPlPtRec;p_{T} (#mu^{+}) (GeV/c);Events",200,0,20); TH1F *hMuMiPtRec = new TH1F("hMuMiPtRec","hMuMiPtRec;p_{T} (#mu^{-}) (GeV/c);Events",200,0,20); TH1F *hMuPtRec = new TH1F("hMuPtRec","hMuPtRec;p_{T} (#mu^{#pm}) (GeV/c);Events",200,0,20); hMuPlPtRec->Sumw2(); hMuMiPtRec->Sumw2(); hMuPtRec->Sumw2(); hMuPlPtRec->SetMarkerColor(kRed); hMuMiPtRec->SetMarkerColor(kBlue); TChain *myTree = new TChain("myTree"); myTree->Add("../root_files/PRpsi2SMC_Histos_2013pp_GlbGlb_STARTHI53_V28-v1_muLessPV.root"); myTree->Draw("Reco_QQ_mupl_4mom.Pt()>>hMuPlPtRec",defaultCut&&ptCut&&rapCut&&trigCut,"e"); myTree->Draw("Reco_QQ_mumi_4mom.Pt()>>hMuMiPtRec",defaultCut&&ptCut&&rapCut&&trigCut,"e"); hMuPtRec->Add(hMuPlPtRec,hMuMiPtRec); hMuPtRec->Draw(); hMuPlPtRec->Draw("same"); hMuMiPtRec->Draw("same"); TFile *outf = NULL; if (saveFile) { outf = new TFile(fname,"RECREATE"); hMuPtRec->Write(); outf->Close(); } return; }
/// /// Make a plot out of a 1D histogram holding a 1-CL curve. /// This is a fall back function that does no fancy stuff. /// /// \param s The scanner to plot. /// \param first Set this to true for the first plotted scanner. /// void OneMinusClPlot::scan1dPlotSimple(MethodAbsScan* s, bool first, int CLsType) { if ( arg->debug ){ cout << "OneMinusClPlot::scan1dPlotSimple() : plotting "; cout << s->getName() << " (" << s->getMethodName() << ")" << endl; } m_mainCanvas->cd(); TH1F *hCL = (TH1F*)s->getHCL()->Clone(getUniqueRootName()); if (CLsType==1) hCL = (TH1F*)s->getHCLs()->Clone(getUniqueRootName()); else if (CLsType==2) hCL = (TH1F*)s->getHCLsFreq()->Clone(getUniqueRootName()); // get rid of nan and inf for ( int i=1; i<=hCL->GetNbinsX(); i++ ){ if ( hCL->GetBinContent(i)!=hCL->GetBinContent(i) || std::isinf(hCL->GetBinContent(i)) ) hCL->SetBinContent(i, 0.0); } int color = s->getLineColor(); if(CLsType==1) color = color + 2 ; hCL->SetStats(0); hCL->SetLineColor(color); hCL->SetMarkerColor(color); hCL->SetLineWidth(2); hCL->SetLineStyle(s->getLineStyle()); hCL->SetMarkerColor(color); hCL->SetMarkerStyle(8); hCL->SetMarkerSize(0.6); hCL->GetYaxis()->SetNdivisions(407, true); hCL->GetXaxis()->SetTitle(s->getScanVar1()->GetTitle()); hCL->GetYaxis()->SetTitle("1-CL"); hCL->GetXaxis()->SetLabelFont(font); hCL->GetYaxis()->SetLabelFont(font); hCL->GetXaxis()->SetTitleFont(font); hCL->GetYaxis()->SetTitleFont(font); hCL->GetXaxis()->SetTitleOffset(0.9); hCL->GetYaxis()->SetTitleOffset(0.85); hCL->GetXaxis()->SetLabelSize(labelsize); hCL->GetYaxis()->SetLabelSize(labelsize); hCL->GetXaxis()->SetTitleSize(titlesize); hCL->GetYaxis()->SetTitleSize(titlesize); if ( plotLegend && !arg->isQuickhack(22) ){ if ( arg->plotlog ) hCL->GetYaxis()->SetRangeUser(1e-3,10); else hCL->GetYaxis()->SetRangeUser(0.0,1.3); } else{ if ( arg->plotlog ) hCL->GetYaxis()->SetRangeUser(1e-3,1); else hCL->GetYaxis()->SetRangeUser(0.0,1.0); } hCL->Draw(first?"":"same"); }
void Difference(TH1* iH0,TH1 *iH1) { std::string lName = std::string(iH0->GetName()); //TH1F *lHDiff = new TH1F((lName+"Diff").c_str(),(lName+"Diff").c_str(),50,0,300); lHDiff->Sumw2(); TH1F *lHDiff = new TH1F((lName+"Diff").c_str(),(lName+"Diff").c_str(),iH0->GetNbinsX(),iH0->GetXaxis()->GetXmin(),iH0->GetXaxis()->GetXmax()); lHDiff->Sumw2(); lHDiff->SetFillColor(kViolet); lHDiff->SetFillStyle(1001); lHDiff->SetLineWidth(1); TH1F *lXHDiff1 = new TH1F((lName+"XDiff1").c_str(),(lName+"XDiff1").c_str(),iH0->GetNbinsX(),iH0->GetXaxis()->GetXmin(),iH0->GetXaxis()->GetXmax()); int i1 = 0; lXHDiff1->SetLineStyle(2); lXHDiff1->SetLineWidth(2); lXHDiff1->SetLineColor(kRed); lHDiff->GetYaxis()->SetRangeUser(0,2); lHDiff->GetYaxis()->SetTitleOffset(0.6); lHDiff->GetYaxis()->SetTitleSize(0.08); lHDiff->GetYaxis()->SetLabelSize(0.08); lHDiff->GetYaxis()->CenterTitle(); lHDiff->GetXaxis()->SetTitleOffset(1.2); lHDiff->GetXaxis()->SetTitleSize(0.10); lHDiff->GetXaxis()->SetLabelSize(0.08); lHDiff->GetXaxis()->SetTitle("#slash{E}_{T} [GeV]"); //lHDiff->GetXaxis()->CenterTitle(); //lHDiff->GetYaxis()->SetTitle(YLabel); for(int i0 = 0; i0 < lHDiff->GetNbinsX()+1; i0++) { double lXCenter = lHDiff->GetBinCenter(i0); double lXVal = iH0 ->GetBinContent(i0); lXHDiff1->SetBinContent(i0, 1.0); while(iH1->GetBinCenter(i1) < lXCenter) {i1++;} if(iH1->GetBinContent(i0) > 0) lHDiff->SetBinContent(i0,(lXVal-iH1->GetBinContent(i0))/(iH1->GetBinContent(i0))); if(iH1->GetBinContent(i0) > 0) lHDiff->SetBinError (i0,iH0->GetBinError(i0)/(iH1->GetBinContent(i0))); } lHDiff->SetMarkerStyle(kFullCircle); lHDiff->SetLineColor(kBlack); lHDiff->SetMarkerColor(kBlack); lHDiff->Draw("E1"); lXHDiff1->Draw("hist sames"); }
void plotVertex() { // Centrality binning TFile *inf = new TFile("pbpbSpectra.root"); TH1F *hData = (TH1F*)inf->Get("hVzData"); TH1F *hMC = (TH1F*)inf->Get("hVzMC"); hMC->SetLineColor(2); hMC->SetMarkerColor(2); hData->Scale(1./hData->Integral()); hMC->Scale(1./hMC->Integral()); makeHistTitle(hMC,"","Primary Vertex Z (cm)","Event Fraction"); TCanvas *c = new TCanvas("c","",600,600); hMC->Draw(); hData->Draw("same"); TLegend *leg = myLegend(0.37,0.22,0.78,0.41); leg->AddEntry(hMC,"Reweighted MC","pl"); leg->AddEntry(hData,"Data","pl"); leg->Draw(); c->SaveAs("fig/PrimaryVertex.C"); c->SaveAs("fig/PrimaryVertex.pdf"); c->SaveAs("fig/PrimaryVertex.gif"); }
void PlotScurveGroup( Char_t *fname, UInt_t pBeId = 0, UInt_t pFeId = 0, UInt_t pCbc = 0, UInt_t pGroup = 0, UInt_t color = 4 ){ TFile *fin = new TFile( fname ); UInt_t cCh1(0); for( int i=0; i < 16; i++ ){ cCh1 = i * 16 + pGroup*2; for( int j = cCh1; j < cCh1 + 2; j++ ){ if( j < 254 ){ TString hname = Form( "h_%02d_%02d_%02d_%03d", pBeId, pFeId, pCbc, j ); TH1F *h = (TH1F *) fin->Get( hname ); h->GetXaxis()->SetRangeUser( 50, 170 ); h->SetLineColor(1); h->SetMarkerColor(1); h->SetTitle( Form( "FE(00),CBC(%02d); VCth; Rate", pCbc ) ); TF1 *func = h->GetFunction( Form("f_%s", hname.Data() ) ); if( i == 0 ) h->Draw(); else h->Draw("same"); } } } TString cPadName( fname ); cPadName.ReplaceAll( ".root", Form( "G%d.png", pGroup ) ); gPad->Print( cPadName ); }
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++; }
CheckEnabledChannels(const Char_t *runlist) { ifstream is(runlist); Char_t buf[4096]; Int_t run[1024]; Int_t nrun = 0; while(!is.eof()) { is.getline(buf, 4096); if (is.eof()) break; run[nrun] = atoi(buf); printf("added run number %d\n", run[nrun]); nrun++; } printf("%d runs added\n", nrun); is.close(); TH1F *hActive = new TH1F("hActive", "active channels;run;fraction", nrun, 0, nrun); TH1F *hReadout = new TH1F("hReadout", "good readout;run;fraction", nrun, 0, nrun); for (Int_t irun = 0; irun < nrun; irun++) { hr = CheckEnabledChannels(run[irun], kTRUE); ha = CheckEnabledChannels(run[irun], kFALSE); hReadout->SetBinContent(irun + 1, hr->Integral()); hActive->SetBinContent(irun + 1, ha->Integral()); hReadout->GetXaxis()->SetBinLabel(irun + 1, Form("%d", run[irun])); delete hr; delete ha; } hReadout->SetMarkerStyle(20); hReadout->SetMarkerColor(4); hActive->SetMarkerStyle(25); hActive->SetMarkerColor(2); hReadout->Sumw2(); hActive->Sumw2(); hReadout->Divide(hReadout, hActive, 1., 1., "B"); hActive->Scale(1. / 152928.); hReadout->SetMinimum(0.); hReadout->SetMaximum(1.); hReadout->Draw("E"); hActive->Draw("E, same"); TLegend *l = gPad->BuildLegend(); l->SetFillStyle(0); }
void SetDataStyle(TH1F & ele) { ele.SetMarkerColor(1); ele.SetLineColor(1); ele.SetFillColor(1); ele.SetFillStyle(0); ele.SetLineWidth(2); ele.SetMarkerStyle(20); ele.SetMarkerSize(1.1); return; }
TH1F* newDumHistForLegend(const Plot_t* hist) { // caller is responsible for deleting the hist TH1F* h = 0; if (hist!=0) { TString hn(Form("%s_leg%s",hist->GetName(), (gPad!=0) ? gPad->GetName() : "")); h = new TH1F(hn.Data(), "", 1, 0, 1); h->SetFillColor(hist->GetLineColor()); h->SetLineColor(kWhite); h->SetMarkerColor(kWhite); h->SetMarkerStyle(hist->GetMarkerStyle()); h->SetMarkerSize(1); h->SetBit(TObject::kCanDelete); } return h; }
//------------------------------------------------------------// // Get histogram //------------------------------------------------------------// TH1F* getHist(TFile* file, TString pname, TString xtitle, TString ytitle, int color, int marker) { TH1F* hist = (TH1F*) (file->Get(pname.Data())->Clone(Form("%s_%i",pname.Data(),color))); hist->GetXaxis()->SetTitle(xtitle.Data()); hist->GetYaxis()->SetTitle(ytitle.Data()); hist->SetMarkerStyle(marker); hist->SetMarkerColor(color); hist->SetMarkerSize(0.5); hist->SetLineColor(color); hist->SetTitle(""); hist->SetStats(0); hist->GetYaxis()->SetTitleOffset(1.5); hist->SetLineWidth(2); return hist; }
void binomialEfficiency1D(TH1F * numerator,TH1F * denominator){ TH1F * efficiency = numerator->Clone("efficiency"); efficiency->SetXTitle(numerator->GetXaxis()->GetTitle()); efficiency->SetYTitle("#epsilon"); for(int j=0;j<=numerator->GetXaxis()->GetNbins() ;j++){ if(denominator->GetBinContent(j)!=0){ float eff = numerator->GetBinContent(j)/denominator->GetBinContent(j); float err = sqrt(eff*(1-eff)/denominator->GetBinContent(j)); efficiency->SetBinContent(j,eff); efficiency->SetBinError(j,err); cout<<"1Deff "<<j<<" "<<eff<<" +/- "<<err<<endl; } } efficiency->Draw("E"); efficiency->SetMarkerColor(kRed); efficiency->SetMarkerStyle(23); efficiency->SetMarkerSize(2); }
void Ef_Branch(){ gROOT->ProcessLine(" .L tdrstyle.C"); setTDRStyle(); gStyle->SetOptStat(0); TH1F *IsoPaftl = new TH1F("IsoPaftl","IsoP cut only",100,0,100); TH1F *IsoPaftlb = new TH1F("IsoPaftlb","IsoP cut only",100,0,100); //Pt dependency IsoPaftl->Divide(EffNp,EffN0,1.,1.,"B"); IsoPaftlb->Divide(EffNpb,EffN0b,1.,1.,"B"); TCanvas *c10 = new TCanvas("c10","Branch Out Cuts",900,600); c10->Divide(3,2); IsoPaftl->Draw(); IsoPaftlb->Draw("same"); IsoPaftl->SetLineColor(kRed); IsoPaftl->SetMarkerColor(kRed); IsoPaftl->SetMarkerSize(0.5); IsoPaftl->GetYaxis()->SetTitle("Only iso P Cut Efficiency"); IsoPaftl->GetXaxis()->SetTitle("Nvtx"); c10->Update(); c10->SaveAs("LCheck.png"); }
float GoodRun(int icent, int ihar, int isub, int irun){ float pi = acos(-1); TF1 *fun = new TF1("fun","pol0",-pi,pi); TString str; TFile *fin; ofstream fout; if(isub==1){ str = "FVTX1S"; } else if(isub==2){ str = "FVTX2S"; } else return -9999; fin = TFile::Open(Form("Run15pAu200MinBias/output_fvtxwithcntEP_%d.root",GetRun(irun))); TH1F* hpsi = new TH1F("psi","psi",100,-pi,pi); for(int ibbcz=0;ibbcz<nbbcz;ibbcz++){ hpsitemp = (TH1F*)fin->Get(Form("psi_%d_%d_%d_%d",icent,ibbcz,ihar,isub)); hpsi->Add(hpsitemp); } if(hpsi->GetEntries()>10000){ hpsi->SetMarkerStyle(20); hpsi->SetMarkerSize(0.6); hpsi->SetMarkerColor(4); hpsi->SetMinimum(10); hpsi->Fit("fun","QR0"); float par=fun->GetParameter(0); hpsi->SetMaximum(1.5*par); //hpsi->Draw(); fin->Close(); return fun->GetChisquare()/fun->GetNDF(); } else{ fin->Close(); return -9999; } }
void CheckSDDInESD(TString filename="AliESDs.root", Int_t optTracks=kAll){ TFile* esdFile = TFile::Open(filename.Data()); if (!esdFile || !esdFile->IsOpen()) { printf("Error in opening ESD file"); return; } AliESDEvent * esd = new AliESDEvent; TTree* tree = (TTree*) esdFile->Get("esdTree"); if (!tree) { printf("Error: no ESD tree found"); return; } esd->ReadFromTree(tree); TH1F* hpt=new TH1F("hpt","",100,0.,10.); TH1F* hphi=new TH1F("hphi","",100,-1,1); TH1F* hlam=new TH1F("hlam","",100,-2.,2.); TH1F* halpha=new TH1F("halpha","",100,-7,7); TH1F* hitscl=new TH1F("hitscl","",7,-0.5,6.5); TH1F* htpccl=new TH1F("htpccl","",200,-0.5,199.5); TH1F* hitsmap=new TH1F("hitsmap","",64,-0.5,63.5); TH1F* hclulay=new TH1F("hclulay","",7,-1.5,5.5); TH1F* hvx=new TH1F("hvx","",100,-1.,1.); TH1F* hvy=new TH1F("hvy","",100,-1.,1.); TH1F* hvz=new TH1F("hvz","",100,-20.,20.); TH1F* hdedx3=new TH1F("hdedx3","",100,0.,300.); TH1F* hdedx4=new TH1F("hdedx4","",100,0.,300.); TH1F* hdedx5=new TH1F("hdedx5","",100,0.,300.); TH1F* hdedx6=new TH1F("hdedx6","",100,0.,300.); TH1F* hStatus=new TH1F("hStatus","",11,-1.5,9.5); // -- Local coordinates // -- Module histos TH1F* hAllPMod = new TH1F("hAllPmod","Crossing Tracks vs. Module",260,239.5,499.5); TH1F* hGoodPMod = new TH1F("hGoodPmod","PointsAssocToTrack per Module",260,239.5,499.5); TH1F* hBadRegMod = new TH1F("hBadRegmod","Tracks in BadRegion per Module",260,239.5,499.5); TH1F* hMissPMod = new TH1F("hMissPmod","Missing Points per Module",260,239.5,499.5); TH1F* hSkippedMod = new TH1F("hSkippedmod","Tracks in Skipped Module",260,239.5,499.5); TH1F* hOutAccMod = new TH1F("hOutAccmod","Tracks outside zAcc per Module",260,239.5,499.5); TH1F* hNoRefitMod = new TH1F("hNoRefitmod","Points rejected in refit per Module",260,239.5,499.5); TH1F* hAllPXloc = new TH1F("hAllPxloc","Crossing Tracks vs. Xloc",75, -3.75, 3.75); TH1F* hGoodPXloc = new TH1F("hGoodPxloc","PointsAssocToTrack vs. Xloc",75, -3.75, 3.75); TH1F* hBadRegXloc = new TH1F("hBadRegxloc","Tracks in BadRegion vs. Xloc",75, -3.75, 3.75); TH1F* hMissPXloc = new TH1F("hMissPxloc","Missing Points vs. Xloc",75, -3.75, 3.75); TH1F* hAllPZloc = new TH1F("hAllPzloc","Crossing Tracks vs. Zloc",77, -3.85, 3.85); TH1F* hGoodPZloc = new TH1F("hGoodPzloc","PointsAssocToTrack vs. Zloc",77, -3.85, 3.85); TH1F* hBadRegZloc = new TH1F("hBadRegzloc","Tracks in BadRegion vs. Zloc",77, -3.85, 3.85); TH1F* hMissPZloc = new TH1F("hMissPzloc","Missing Points vs. Zloc",77, -3.85, 3.85); TH2F* hdEdxVsMod=new TH2F("hdEdxVsMod","dE/dx vs. mod",260,239.5,499.5,100,0.,500.); gStyle->SetPalette(1); for (Int_t iEvent = 0; iEvent < tree->GetEntries(); iEvent++) { tree->GetEvent(iEvent); if (!esd) { printf("Error: no ESD object found for event %d", iEvent); return; } cout<<"-------- Event "<<iEvent<<endl; printf(" Tracks # = %d\n",esd->GetNumberOfTracks()); const AliESDVertex *spdv=esd->GetVertex(); printf(" SPD Primary Vertex in %f %f %f with %d contributors\n",spdv->GetX(),spdv->GetY(),spdv->GetZ(),spdv->GetNContributors()); const AliESDVertex *trkv=esd->GetPrimaryVertex(); printf(" Track Primary Vertex with %d contributors\n",trkv->GetNContributors()); if(spdv->IsFromVertexer3D()){ hvx->Fill(spdv->GetX()); hvy->Fill(spdv->GetY()); hvz->Fill(spdv->GetZ()); } Double_t itss[4]; for (Int_t iTrack = 0; iTrack < esd->GetNumberOfTracks(); iTrack++) { AliESDtrack* track = esd->GetTrack(iTrack); Int_t nITSclus=track->GetNcls(0); UChar_t clumap=track->GetITSClusterMap(); Int_t nPointsForPid=0; for(Int_t i=2; i<6; i++){ if(clumap&(1<<i)) ++nPointsForPid; } // track->PropagateTo(4.,5.); htpccl->Fill(track->GetNcls(1)); ULong64_t status=track->GetStatus(); Bool_t tpcin=0; hStatus->Fill(-1.); if(status & AliESDtrack::kTPCin){ tpcin=1; hStatus->Fill(0.); } if(status & AliESDtrack::kTPCout){ hStatus->Fill(1.); } if(status & AliESDtrack::kTPCrefit){ hStatus->Fill(2.); } Bool_t itsin=0; if(status & AliESDtrack::kITSin){ itsin=1; hStatus->Fill(3.); } if(status & AliESDtrack::kITSout){ hStatus->Fill(4.); } if(status & AliESDtrack::kITSrefit){ hStatus->Fill(5.); } if(!tpcin && itsin){ hStatus->Fill(6.); } if(status & AliESDtrack::kITSpureSA){ hStatus->Fill(7.); } if(status & AliESDtrack::kITSrefit){ if((optTracks==kTPCITS) && !(status & AliESDtrack::kTPCin)) continue; if((optTracks==kITSsa) && (status & AliESDtrack::kTPCin)) continue; if((optTracks==kITSsa) && (status & AliESDtrack::kITSpureSA)) continue; if((optTracks==kITSpureSA) && (status & AliESDtrack::kITSpureSA)) continue; track->GetITSdEdxSamples(itss); // printf("Track %d (label %d) in ITS with %d clusters clumap %d pointspid= %d\n",iTrack,track->GetLabel(),nITSclus,clumap,nPointsForPid); //printf(" dedx=%f %f %f %f\n",itss[0],itss[1],itss[2],itss[3]); hitscl->Fill(nITSclus); hdedx3->Fill(itss[0]); hdedx4->Fill(itss[1]); hdedx5->Fill(itss[2]); hdedx6->Fill(itss[3]); hitsmap->Fill(clumap); hclulay->Fill(-1.); for(Int_t iLay=0;iLay<6;iLay++){ if(clumap&1<<iLay) hclulay->Fill(iLay); } hpt->Fill(track->Pt()); hphi->Fill(TMath::ASin(track->GetSnp())); hlam->Fill(TMath::ATan(track->GetTgl())); halpha->Fill(track->GetAlpha()); Int_t iMod,status; Float_t xloc,zloc; for(Int_t iLay=2; iLay<=3; iLay++){ Bool_t ok=track->GetITSModuleIndexInfo(iLay,iMod,status,xloc,zloc); if(ok){ iMod+=240; hAllPMod->Fill(iMod); hAllPXloc->Fill(xloc); hAllPZloc->Fill(zloc); if(status==1){ hGoodPMod->Fill(iMod); hGoodPXloc->Fill(xloc); hGoodPZloc->Fill(zloc); if(track->Pt()>1.) hdEdxVsMod->Fill(iMod,itss[iLay-2]); } else if(status==2){ hBadRegMod->Fill(iMod); hBadRegXloc->Fill(xloc); hBadRegZloc->Fill(zloc); } else if(status==3) hSkippedMod->Fill(iMod); else if(status==4) hOutAccMod->Fill(iMod); else if(status==5){ hMissPMod->Fill(iMod); hMissPXloc->Fill(xloc); hMissPZloc->Fill(zloc); } else if(status==6) hNoRefitMod->Fill(iMod); } } } } } Float_t norm=hclulay->GetBinContent(1); if(norm<1.) norm=1.; hclulay->Scale(1./norm); gStyle->SetLineWidth(2); TCanvas* c1=new TCanvas("c1","Track quantities",900,900); c1->Divide(2,2); c1->cd(1); htpccl->Draw(); htpccl->GetXaxis()->SetTitle("Clusters in TPC "); c1->cd(2); hitscl->Draw(); hitscl->GetXaxis()->SetTitle("Clusters in ITS "); c1->cd(3); hclulay->Draw(); hclulay->GetXaxis()->SetRange(2,7); hclulay->GetXaxis()->SetTitle("# ITS Layer"); hclulay->GetYaxis()->SetTitle("Fraction of tracks with point in Layer x"); c1->cd(4); TCanvas* c2=new TCanvas("c2","dedx per Layer",900,900); c2->Divide(2,2); c2->cd(1); hdedx3->Draw(); hdedx3->GetXaxis()->SetTitle("dE/dx Lay3"); c2->cd(2); hdedx4->Draw(); hdedx4->GetXaxis()->SetTitle("dE/dx Lay4"); c2->cd(3); hdedx5->Draw(); hdedx5->GetXaxis()->SetTitle("dE/dx Lay5"); c2->cd(4); hdedx6->Draw(); hdedx6->GetXaxis()->SetTitle("dE/dx Lay6"); hdEdxVsMod->SetStats(0); TCanvas* cdedx=new TCanvas("cdedx","dedx SDD",1400,600); cdedx->SetLogz(); hdEdxVsMod->Draw("col"); hdEdxVsMod->GetXaxis()->SetTitle("SDD Module Id"); hdEdxVsMod->GetYaxis()->SetTitle("dE/dx (keV/300 #mum)"); hdEdxVsMod->GetYaxis()->SetTitleOffset(1.25); TCanvas* cv=new TCanvas("cv","Vertex",600,900); cv->Divide(1,3); cv->cd(1); hvx->Draw(); hvx->GetXaxis()->SetTitle("Xv (cm)"); cv->cd(2); hvy->Draw(); hvy->GetXaxis()->SetTitle("Yv (cm)"); cv->cd(3); hvz->Draw(); hvz->GetXaxis()->SetTitle("Xv (cm)"); hGoodPMod->SetStats(0); hGoodPMod->SetTitle(""); TCanvas* ceff0=new TCanvas("ceff0","ModuleIndexInfo",1000,600); hGoodPMod->Draw("e"); hGoodPMod->GetXaxis()->SetTitle("SDD Module Id"); hGoodPMod->GetYaxis()->SetTitle("Number of tracks"); hMissPMod->SetLineColor(2); hMissPMod->SetMarkerColor(2); hMissPMod->SetMarkerStyle(22); hMissPMod->SetMarkerSize(0.5); hMissPMod->Draw("psame"); hBadRegMod->SetLineColor(kGreen+1); hBadRegMod->SetMarkerColor(kGreen+1); hBadRegMod->SetMarkerStyle(20); hBadRegMod->SetMarkerSize(0.5); hBadRegMod->Draw("esame"); hSkippedMod->SetLineColor(kYellow); hSkippedMod->Draw("esame"); hOutAccMod->SetLineColor(4); hOutAccMod->Draw("esame"); hNoRefitMod->SetLineColor(6); hNoRefitMod->Draw("esame"); TLatex* t1=new TLatex(0.7,0.85,"Good Point"); t1->SetNDC(); t1->SetTextColor(1); t1->Draw(); TLatex* t2=new TLatex(0.7,0.8,"Missing Point"); t2->SetNDC(); t2->SetTextColor(2); t2->Draw(); TLatex* t3=new TLatex(0.7,0.75,"Bad Region"); t3->SetNDC(); t3->SetTextColor(kGreen+1); t3->Draw(); ceff0->Update(); TH1F* heff=new TH1F("heff","",260,239.5,499.5); for(Int_t imod=0; imod<260;imod++){ Float_t numer=hGoodPMod->GetBinContent(imod+1)+hBadRegMod->GetBinContent(imod+1)+hOutAccMod->GetBinContent(imod+1)+hNoRefitMod->GetBinContent(imod+1); Float_t denom=hAllPMod->GetBinContent(imod+1); Float_t eff=0.; Float_t erreff=0.; if(denom>0){ eff=numer/denom; erreff=TMath::Sqrt(eff*(1-eff)/denom); } heff->SetBinContent(imod+1,eff); heff->SetBinError(imod+1,erreff); } printf("---- Modules with efficiency < 90%% ----\n"); heff->SetStats(0); TCanvas* ceff1=new TCanvas("ceff1","Efficiency",1000,600); heff->Draw(); heff->GetXaxis()->SetTitle("SDD Module Id"); heff->GetYaxis()->SetTitle("Fraction of tracks with point in good region"); for(Int_t ibin=1; ibin<=heff->GetNbinsX(); ibin++){ Float_t e=heff->GetBinContent(ibin); if(e<0.9){ Int_t iMod=(Int_t)heff->GetBinCenter(ibin); Int_t lay,lad,det; AliITSgeomTGeo::GetModuleId(iMod,lay,lad,det); printf("Module %d - Layer %d Ladder %2d Det %d - Eff. %.3f\n",iMod,lay,lad,det,heff->GetBinContent(ibin)); } } ceff1->Update(); hGoodPXloc->SetTitle(""); hGoodPZloc->SetTitle(""); hGoodPXloc->SetStats(0); hGoodPZloc->SetStats(0); hGoodPXloc->SetMinimum(0); hGoodPZloc->SetMinimum(0); TCanvas* ceff2=new TCanvas("ceff2","LocalCoord",1000,600); ceff2->Divide(2,1); ceff2->cd(1); hGoodPXloc->Draw("e"); hGoodPXloc->GetXaxis()->SetTitle("Xlocal (cm)"); hGoodPXloc->GetYaxis()->SetTitle("Number of tracks"); hMissPXloc->SetLineColor(2); hMissPXloc->SetMarkerColor(2); hMissPXloc->SetMarkerStyle(22); hMissPXloc->SetMarkerSize(0.5); hMissPXloc->Draw("psame"); hBadRegXloc->SetLineColor(kGreen+1); hBadRegXloc->SetMarkerColor(kGreen+1); hBadRegXloc->SetMarkerStyle(20); hBadRegXloc->SetMarkerSize(0.5); hBadRegXloc->Draw("psame"); t1->Draw(); t2->Draw(); t3->Draw(); ceff2->cd(2); hGoodPZloc->Draw("e"); hGoodPZloc->GetXaxis()->SetTitle("Zlocal (cm)"); hGoodPZloc->GetYaxis()->SetTitle("Number of tracks"); hMissPZloc->SetLineColor(2); hMissPZloc->SetMarkerColor(2); hMissPZloc->SetMarkerStyle(22); hMissPZloc->SetMarkerSize(0.5); hMissPZloc->Draw("psame"); hBadRegZloc->SetLineColor(kGreen+1); hBadRegZloc->SetMarkerColor(kGreen+1); hBadRegZloc->SetMarkerStyle(20); hBadRegZloc->SetMarkerSize(0.5); hBadRegZloc->Draw("psame"); t1->Draw(); t2->Draw(); t3->Draw(); ceff2->Update(); }
// Function for the computation of channeling efficiency at various incoming angle Int_t AnalyseChannelingEfficiency(TTree *fTree,Float_t fChannelingMinimum = 35., Float_t fChannelingMaximum = 70.){ //**//Channeling Gaussian Fit Function TF1 *vChanneling = new TF1("vChanneling","gaus",fChannelingMinimum,fChannelingMaximum); vChanneling->SetParNames("Const","Mean","Sigma"); vChanneling->SetLineColor(4); vChanneling->SetLineStyle(2); TH2D *hChannelingPlot = new TH2D("hChannelingPlot","Deflection Angle vs. Incoming Angle;Horizontal Incoming Angle [#murad];Horizontal Deflection Angle [#murad]",21,-10.5,10.5,256,-127.5,128.5); TH1F *hChannelingEfficiency = new TH1F("hChannelingEfficiency","G4Channeling;Horizontal Incoming Angle [#murad];Efficiency [%]",21,-10.5,10.5); fTree->Draw("-(angXout-angXin):-angXin>>hChannelingPlot"); Double_t vNormalizationToAmorphous = 0.965; // Normalization for channeling efficiency, see PRSTAB 11, 063501 (2008) for(int i=2;i<=21;i++){ TH1D* h1 = hChannelingPlot->ProjectionY("h1",i,i); h1->Fit(vChanneling,"QR"); Double_t *vChannelingParameters; vChannelingParameters = vChanneling->GetParameters(); hChannelingEfficiency->SetBinContent(i,ComputeEfficiency(h1,vChannelingParameters)/vNormalizationToAmorphous); h1->Delete(); } hChannelingEfficiency->SetLineColor(3); hChannelingEfficiency->SetLineStyle(4); hChannelingEfficiency->SetMarkerColor(3); hChannelingEfficiency->SetFillStyle(0); hChannelingEfficiency->SetMarkerStyle(20); hChannelingEfficiency->Draw("PL"); TGraph* gRoughExperimentalData = new TGraph(11); gRoughExperimentalData->SetPoint( 0 , -10 , 20 ); gRoughExperimentalData->SetPoint( 1 , -8 , 38 ); gRoughExperimentalData->SetPoint( 2 , -6 , 56 ); gRoughExperimentalData->SetPoint( 3 , -4 , 72 ); gRoughExperimentalData->SetPoint( 4 , -2 , 80 ); gRoughExperimentalData->SetPoint( 5 , 0 , 84 ); gRoughExperimentalData->SetPoint( 6 , 2 , 82 ); gRoughExperimentalData->SetPoint( 7 , 4 , 78 ); gRoughExperimentalData->SetPoint( 8 , 6 , 66 ); gRoughExperimentalData->SetPoint( 9 , 8 , 52 ); gRoughExperimentalData->SetPoint( 10 , 10 , 37 ); gRoughExperimentalData->SetLineColor(4); gRoughExperimentalData->SetLineStyle(3); gRoughExperimentalData->SetFillStyle(0); gRoughExperimentalData->SetFillColor(0); gRoughExperimentalData->SetMarkerColor(4); gRoughExperimentalData->SetMarkerStyle(21); gRoughExperimentalData->SetTitle("Phys. Lett. B 680, 129"); gRoughExperimentalData->Draw("sameCP"); TLegend *aLegend = new TLegend(0.30,0.15,0.55,0.3); aLegend->AddEntry(hChannelingEfficiency); aLegend->AddEntry(gRoughExperimentalData); aLegend->SetFillStyle(0); aLegend->SetLineColor(0); aLegend->Draw(); return 0; }
void Plots(TString plots="4Jets", TString sys="", bool EvtNorm=false){ /**************** Style ****************/ gROOT->SetStyle("Plain"); gStyle->SetOptFit(1000); gStyle->SetOptStat("emruo"); gStyle->SetOptStat(kFALSE); gStyle->SetPadTickY(1); gStyle->SetPadTickX(1); gROOT->ProcessLine(".L /home/brochero/ttbar/TopCodeljets/tdrStyle.C"); setTDRStyle(); Int_t chatch = 1756; TColor *color = new TColor(chatch, 0.3, 0.5, 0.5, "", 0.45); // alpha = 0.5 TString files = dirnameIn + fl; /**************** Channel ****************/ TString channel[3]; channel[0] = "mujets"; channel[1] = "ejets"; channel[2] = "lepjet"; /**************** Data ****************/ std::vector<histos> DataMu; DataMu = loadhistograms(plots, files + "_DataSingleMu"); std::vector<histos> DataEG; DataEG = loadhistograms(plots, files + "_DataSingleEG"); std::vector<histos> Data; Data = addhistograms(DataMu, DataEG); setuphistograms(Data, kBlack); /**************** ttbar Signal ****************/ std::vector<histos> ttbar_0; ttbar_0 = loadhistograms(plots, files + "_ttbar-PowhegPythia"); setuphistograms(ttbar_0, kRed+1); std::vector<histos> ttbar_1; ttbar_1 = loadhistograms(plots, files + "_ttbar-MCatNLO"); setuphistograms(ttbar_1, kRed+2); std::vector<histos> ttbar_2; ttbar_2 = loadhistograms(plots, files + "_ttbar-Madgraph"); setuphistograms(ttbar_2, kRed+3); /**************** Z+Jets ****************/ std::vector<histos> ZJets; ZJets = loadhistograms(plots, files + "_ZJets"); setuphistograms(ZJets, kAzure-2); /**************** VV ****************/ std::vector<histos> WW; WW = loadhistograms(plots, files + "_WW"); std::vector<histos> WZ; WZ = loadhistograms(plots, files + "_WZ"); std::vector<histos> ZZ; ZZ = loadhistograms(plots, files + "_ZZ"); std::vector<histos> VV; VV = addhistograms(WW, WZ); VV = addhistograms(VV, ZZ); setuphistograms(VV, kYellow-3); /**************** Single Top ****************/ std::vector<histos> tW; tW = loadhistograms(plots, files + "_tW"); std::vector<histos> tbarW; tbarW = loadhistograms(plots, files + "_tbarW"); std::vector<histos> t_tch; t_tch = loadhistograms(plots, files + "_t-tchannel"); std::vector<histos> tbar_tch; tbar_tch = loadhistograms(plots, files + "_tbar-tchannel"); std::vector<histos> Single_top; Single_top = addhistograms(tW, tbarW); Single_top = addhistograms(Single_top, t_tch); Single_top = addhistograms(Single_top, tbar_tch); setuphistograms(Single_top, kPink-3); /**************** W+Jets ****************/ std::vector<histos> WJets; WJets = loadhistograms(plots, files + "_WJets"); setuphistograms(WJets, kGreen-3); /**************** ttbar Bkg ****************/ std::vector<histos> ttbar_bkg; ttbar_bkg = loadhistograms(plots, files + "_ttbar-PowhegPythiaBkg"); setuphistograms(ttbar_bkg, kViolet-3); /**************** QCD ****************/ std::vector<histos> QCD; QCD = loadhistograms(plots, files + "_QCD-MuEnr"); setuphistograms(QCD, kOrange-3); /**************** Stacks ****************/ std::vector<histos> Stack_bkg; std::vector<histos> Stack; histos st_bkg; histos st; for(unsigned int h=0; h<WJets.size(); h++){ TString variable; for(int ch=0; ch<3; ch++){ st.mc[ch] = new THStack(variable, ""); st_bkg.mc[ch] = new THStack(variable, ""); st.mc[ch]->SetHistogram( (TH1F*)WJets[h].hist[ch]->Clone()); st_bkg.mc[ch]->SetHistogram( (TH1F*)WJets[h].hist[ch]->Clone()); } Stack.push_back(st); Stack_bkg.push_back(st_bkg); } //------------------------------------------------------- // Background Stack Stack_bkg = addstack(Stack_bkg, WJets); Stack_bkg = addstack(Stack_bkg, QCD); Stack_bkg = addstack(Stack_bkg, Single_top); Stack_bkg = addstack(Stack_bkg, VV); Stack_bkg = addstack(Stack_bkg, ttbar_bkg); Stack_bkg = addstack(Stack_bkg, ZJets); //------------------------------------------------------- // Stack Stack = addstack(Stack, WJets); Stack = addstack(Stack, QCD); Stack = addstack(Stack, Single_top); Stack = addstack(Stack, VV); Stack = addstack(Stack, ttbar_bkg); Stack = addstack(Stack, ZJets); Stack = addstack(Stack, ttbar_0); //------------------------------------------------------- // other ttbar Generators ttbar_1 = addhistograms(ttbar_1, Stack_bkg); ttbar_2 = addhistograms(ttbar_2, Stack_bkg); /**************** Draw Histos ****************/ TCanvas *histocanvas; histocanvas = new TCanvas("plots", "Plots"); for(unsigned int h=0; h<WJets.size(); h++){ for(int ch=0; ch<3; ch++){ histocanvas->Divide(1,2); TPad *pad[2]; //Plot Pad pad[0] = (TPad*)histocanvas->GetPad(1); pad[0]->SetPad(0.01, 0.23, 0.99, 0.99); pad[0]->SetTopMargin(0.1); pad[0]->SetRightMargin(0.04); //Ratio Pad pad[1] = (TPad*)histocanvas->GetPad(2); pad[1]->SetPad(0.01, 0.02, 0.99, 0.3); gStyle->SetGridWidth(0.5); gStyle->SetGridColor(14); pad[1]->SetGridx(); pad[1]->SetGridy(); pad[1]->SetTopMargin(0.05); pad[1]->SetBottomMargin(0.4); pad[1]->SetRightMargin(0.04); //------------------------------------------------------- // Stack pad[0]->cd(); Stack[h].mc[ch]->Draw("hist"); Stack[h].mc[ch]->GetYaxis()->SetTitle("Events"); Stack[h].mc[ch]->GetYaxis()->SetTitleOffset(1.2); Stack[h].mc[ch]->GetYaxis()->SetTitleSize(0.07); Stack[h].mc[ch]->GetYaxis()->SetLabelSize(0.055); Stack[h].mc[ch]->GetYaxis()->SetNdivisions(607); //Stack[h].mc[ch]->GetYaxis()->SetLabelSize(0.05); TGaxis *hYaxis = (TGaxis*)Stack[h].mc[ch]->GetYaxis(); //hYaxis->SetMaxDigits(3); Stack[h].mc[ch]->GetXaxis()->SetLabelSize(0.0); Stack[h].mc[ch]->GetXaxis()->SetTitle(""); float maxh = Data[h].hist[ch]->GetMaximum(); if(maxh < Stack[h].mc[ch]->GetMaximum()) maxh = Stack[h].mc[ch]->GetMaximum(); Stack[h].mc[ch]->SetMaximum(1.7*maxh); //------------------------------------------------------- // Band error TGraphErrors *thegraph = new TGraphErrors(Stack[h].hist[ch]); thegraph->SetName("thegraph"); thegraph->SetFillStyle(1001); thegraph->SetFillColor(chatch); thegraph->SetLineColor(chatch); thegraph->Draw("e2SAME"); //------------------------------------------------------- // Other ttbar generators ttbar_1[h].hist[ch]->SetLineColor(6); ttbar_1[h].hist[ch]->SetLineStyle(2); ttbar_1[h].hist[ch]->SetFillColor(0); ttbar_1[h].hist[ch]->Draw("histoSAME"); ttbar_2[h].hist[ch]->SetLineColor(8); ttbar_2[h].hist[ch]->SetLineStyle(4); ttbar_2[h].hist[ch]->SetFillColor(0); ttbar_2[h].hist[ch]->Draw("histoSAME"); //------------------------------------------------------- // Data Histogram Data[h].hist[ch]->SetMarkerStyle(20); Data[h].hist[ch]->SetMarkerSize(0.7); Data[h].hist[ch]->Draw("SAME"); /*********************** Legends ***********************/ TLegend *leg; float legx1=0.76; float legy1=0.54; float legx2=0.90; float legy2=0.87; leg = new TLegend(legx1,legy1,legx2,legy2); leg->SetFillColor(0); leg->SetLineColor(1); leg->SetTextFont(62); leg->SetTextSize(0.03); leg->AddEntry(Data[h].hist[ch],"Data","PL"); leg->AddEntry(ttbar_0[h].hist[ch],"t#bar{t} Signal","F"); leg->AddEntry(ZJets[h].hist[ch],"Z+Jets","F"); leg->AddEntry(ttbar_bkg[h].hist[ch],"t#bar{t} Bkg","F"); leg->AddEntry(VV[h].hist[ch],"VV","F"); leg->AddEntry(Single_top[h].hist[ch],"Single t","F"); leg->AddEntry(QCD[h].hist[ch],"QCD","F"); leg->AddEntry(WJets[h].hist[ch],"W+Jets","F"); leg->AddEntry("thegraph","Uncertainty","F"); leg->AddEntry((TObject*)0,"",""); leg->AddEntry(ttbar_1[h].hist[ch],"MC@NLO","L"); leg->AddEntry(ttbar_2[h].hist[ch],"Madgraph","L"); leg->Draw("SAME"); //------------------------------------------------------- // CMS TString htitleCMSChannel[3]; htitleCMSChannel[0] = "#mu^{#pm}+jets channel"; htitleCMSChannel[1] = "e^{#pm}+jets channel"; htitleCMSChannel[2] = "l^{#pm}+jets channel"; titlePr = new TLatex(-20.,50.,"Preliminary"); titlePr->SetNDC(); titlePr->SetTextAlign(12); titlePr->SetX(0.25); titlePr->SetY(0.93); titlePr->SetTextColor(2); titlePr->SetTextFont(42); titlePr->SetTextSize(0.05); titlePr->SetTextSizePixels(24); titlePr->Draw("SAME"); title = new TLatex(-20.,50.,"CMS #sqrt{s} = 13TeV, L = 42 pb^{-1}(50ns)"); title->SetNDC(); title->SetTextAlign(12); title->SetX(0.20); title->SetY(0.83); title->SetTextFont(42); title->SetTextSize(0.05); title->SetTextSizePixels(24); title->Draw("SAME"); chtitle = new TLatex(-20.,50.,htitleCMSChannel[ch]); chtitle->SetNDC(); chtitle->SetTextAlign(12); chtitle->SetX(0.20); chtitle->SetY(0.75); chtitle->SetTextFont(42); chtitle->SetTextSize(0.05); chtitle->SetTextSizePixels(24); chtitle->Draw("SAME"); /*********************** Ratio ***********************/ pad[1]->cd(); //------------------------------------------------------- //Graph Ratio Clone TH1F *Ratio; Ratio = (TH1F*)Data[h].hist[ch]->Clone(); Ratio->Divide(Stack[h].hist[ch]); TH1F *RatioSyst; RatioSyst = (TH1F*)Data[h].hist[ch]->Clone(); RatioSyst->Divide(Stack[h].hist[ch]); // Should be the histogram with the Total Syst. Unc. std::vector<double> ratioContent; for(unsigned int b_r = 1; b_r <= RatioSyst->GetNbinsX(); b_r++){ RatioSyst->SetBinContent(b_r,1.0); //RatioSyst->SetBinError(b_r,0.15); // Tempotal!!! } Ratio->SetMarkerStyle(20); Ratio->SetMarkerSize(0.5); Ratio->SetMarkerColor(1); Ratio->SetLineColor(1); Ratio->SetLineWidth(1); Ratio->SetMaximum(2); Ratio->SetMinimum(0); Ratio->SetTitle(""); Ratio->GetYaxis()->SetTitle("Obs/Exp"); Ratio->GetYaxis()->CenterTitle(); Ratio->GetYaxis()->SetTitleOffset(0.45); Ratio->GetYaxis()->SetTitleSize(0.16); Ratio->GetYaxis()->SetLabelSize(0.15); Ratio->GetYaxis()->SetNdivisions(402); Ratio->GetXaxis()->SetNdivisions(509); Ratio->GetXaxis()->SetTitleOffset(1.1); Ratio->GetXaxis()->SetLabelSize(0.20); Ratio->GetXaxis()->SetTitleSize(0.16); Ratio->SetMinimum(0.6); Ratio->SetMaximum(1.4); TGraphErrors *thegraphRatioSyst = new TGraphErrors(RatioSyst); thegraphRatioSyst->SetFillStyle(1001); thegraphRatioSyst->SetFillColor(chatch); thegraphRatioSyst->SetName("thegraphRatioSyst"); //------------------------------------------------------- //Graph Ratio other ttbar generators TH1F *Ratio_1; Ratio_1 = (TH1F*)Data[h].hist[ch]->Clone(); Ratio_1->Divide(ttbar_1[h].hist[ch]); Ratio_1->SetLineColor(6); Ratio_1->SetLineStyle(2); Ratio_1->SetLineWidth(2); Ratio_1->SetFillColor(0); TH1F *Ratio_2; Ratio_2 = (TH1F*)Data[h].hist[ch]->Clone(); Ratio_2->Divide(ttbar_2[h].hist[ch]); Ratio_2->SetLineColor(8); Ratio_2->SetLineStyle(4); Ratio_2->SetLineWidth(2); Ratio_2->SetFillColor(0); //------------------------------------------------------- // Draw Ratios Ratio->Draw(); thegraphRatioSyst->Draw("e2"); Ratio->Draw("histpSAME"); Ratio_1->Draw("histSAME"); Ratio_2->Draw("histSAME"); /*********************** Save Histos ***********************/ TString dirfigname_pdf=dirnameIn + "figures_" + fl + "/pdf/"; // make a dir if it does not exist!! gSystem->mkdir(dirfigname_pdf, kTRUE); histocanvas->SaveAs(dirfigname_pdf + WJets[h].hist[ch]->GetName() + ".pdf"); // clear Canvas histocanvas->Clear(); } } } //end Plots.C
void printBfraction(char *tagger="discr_ssvHighEff", Double_t workingPoint=2, char *taggerName="ssvHighEff", int doCent=2, int do3bin=1) { gROOT->ForceStyle(1); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); gStyle->SetTextFont(42); gStyle->SetLabelFont(42,"XYZ"); gStyle->SetTitleFont(42,"XYZ"); // hack if(doCent)gStyle->SetErrorX(0); gStyle->SetLabelSize(0.05,"xy"); gStyle->SetTitleSize(0.05,"xy"); gStyle->SetTitleOffset(1.5,"xy"); gStyle->SetPadLeftMargin(0.15); gStyle->SetPadBottomMargin(0.12); gStyle->SetNdivisions(408,"y"); TFile *fin1, *fin2; if(doCent){ if(doCent==1){ fin1 = new TFile("output/bFractionMerged_SSVHEat2.0FixCL1_centDep_80_100.root"); fin2 = new TFile("output/bFractionMerged_SSVHEat2.0FixCL0_centDep_80_100.root"); } if(doCent==2){ fin1 = new TFile("output/bFractionMerged_SSVHEat2.0FixCL1_centDep_100_120.root"); fin2 = new TFile("output/bFractionMerged_SSVHEat2.0FixCL0_centDep_100_120.root"); } // broken //fin1 = new TFile("output/bFractionMerged_ssvHighEffat2.0FixCL1_centDep_80_100.root"); //fin2 = new TFile("output/bFractionMerged_ssvHighEffat2.0FixCL0_centDep_80_100.root"); } else{ // try to smear by 2 sigma //fin1 = new TFile("output/bFractionMerged_Smear2Sigma_SSVHEat2.0FixCL1_bin_0_40_eta_0_2.root"); //fin2 = new TFile("output/bFractionMerged_Smear2Sigma_SSVHEat2.0FixCL0_bin_0_40_eta_0_2.root"); // with reg tracks in reco jets //fin1 = new TFile("output/bFractionMerged_regPFJets_SSVHEat2.0FixCL1_bin_0_40_eta_0_2.root"); //fin2 = new TFile("output/bFractionMerged_regPFJets_SSVHEat2.0FixCL0_bin_0_40_eta_0_2.root"); if(do3bin){ fin1 = new TFile("output/bFractionMerged_3bins_SSVHEat2.0FixCL1_bin_0_40_eta_0_2.root"); fin2 = new TFile("output/bFractionMerged_3bins_SSVHEat2.0FixCL0_bin_0_40_eta_0_2.root"); } else{ fin1 = new TFile("output/bFractionMerged_SSVHEat2.0FixCL1_bin_0_40_eta_0_2.root"); fin2 = new TFile("output/bFractionMerged_SSVHEat2.0FixCL0_bin_0_40_eta_0_2.root"); // old naming convention //fin1 = new TFile("output/bFractionMerged_ssvHighEffat2.0FixCL1_bin_0_40_eta_0_2.root"); //fin2 = new TFile("output/bFractionMerged_ssvHighEffat2.0FixCL0_bin_0_40_eta_0_2.root"); } } TH1F *hBFractionMC = (TH1F*) fin1->Get("hBFractionMC"); TH1F *hBFractionData = (TH1F*) fin1->Get("hBFractionData"); TH1F *hBFractionDataLTJP = (TH1F*) fin1->Get("hBFractionDataLTJP"); TH1F *hBFractionJPdirect = (TH1F*) fin1->Get("hBFractionJPdirect"); TH1F *hBFractionDataFixC = (TH1F*) fin2->Get("hBFractionData"); TH1F *hBFractionDataLTJPFixC = (TH1F*) fin2->Get("hBFractionDataLTJP"); TH1F *hBFractionJPdirectFixC = (TH1F*) fin2->Get("hBFractionJPdirect"); /* --- correction due to Jet Energy Scale (calcul) --- correct(hBFractionMC); correct(hBFractionData); correct(hBFractionDataMoreC); correct(hBFractionDataLessC); correct(hBFractionDataLTJP); correct(hBFractionDataLTJPMoreC); correct(hBFractionDataLTJPLessC); correct(hBFractionJPdirect); correct(hBFractionJPdirectMoreC); correct(hBFractionJPdirectLessC); //*/ //* --- correction due to Jet Energy Scale (by hand) --- if(doCent){ correctByCent(hBFractionMC,doCent); correctByCent(hBFractionData,doCent); correctByCent(hBFractionDataFixC,doCent); correctByCent(hBFractionDataLTJP,doCent); correctByCent(hBFractionDataLTJPFixC,doCent); correctByCent(hBFractionJPdirect,doCent); correctByCent(hBFractionJPdirectFixC,doCent); } else{ //* correct2(hBFractionMC,do3bin); correct2(hBFractionData,do3bin); correct2(hBFractionDataFixC,do3bin); correct2(hBFractionDataLTJP,do3bin); correct2(hBFractionDataLTJPFixC,do3bin); correct2(hBFractionJPdirect,do3bin); correct2(hBFractionJPdirectFixC,do3bin); //*/ } //*/ // --- plots with variation of charm --- TCanvas *cBFraction1 = new TCanvas("cBFraction1","b-jet fraction",600,600); hBFractionMC->SetLineColor(2); hBFractionMC->SetLineWidth(2); hBFractionMC->SetMarkerColor(2); //hBFractionMC->SetMarkerStyle(4); if(!doCent)hBFractionMC->SetAxisRange(80,200,"X"); hBFractionMC->SetAxisRange(0,0.06,"Y"); hBFractionMC->SetTitleOffset(1,"X"); hBFractionMC->GetYaxis()->SetTitle("b-jet fraction");; //hBFractionMC->Draw("e1"); //hBFractionMC->GetYaxis()->SetNdivisions(505); TH1F *hBFractionMC_dummy= (TH1F*)hBFractionMC->Clone("hBFractionMC_dummy"); hBFractionMC_dummy->SetLineWidth(0); hBFractionMC_dummy->SetLineColor(0); hBFractionMC_dummy->SetMarkerSize(0); hBFractionMC_dummy->Draw(); // hBFractionMC->Draw("hist"); hBFractionData->SetMarkerStyle(8); hBFractionData->Draw("e1,same"); hBFractionDataLTJP->SetLineColor(kGreen-2); hBFractionDataLTJP->SetMarkerColor(kGreen-2); hBFractionDataLTJP->SetMarkerStyle(8); hBFractionDataLTJP->Draw("e1,same"); hBFractionJPdirect->SetMarkerStyle(8); hBFractionJPdirect->SetMarkerColor(kBlue); hBFractionJPdirect->SetLineColor(kBlue); hBFractionJPdirect->Draw("e1,same"); hBFractionDataFixC->SetLineStyle(2); //hBFractionDataFixC->Draw("e1same"); hBFractionDataLTJPFixC->SetLineColor(kGreen-2); hBFractionDataLTJPFixC->SetMarkerColor(kGreen-2); hBFractionDataLTJPFixC->SetMarkerStyle(4); hBFractionDataLTJPFixC->SetLineStyle(2); hBFractionDataLTJPFixC->Draw("e1same"); hBFractionJPdirectFixC->SetLineStyle(2); //hBFractionJPdirectFixC->Draw("e1same"); TLegend *legFrac1 = new TLegend(0.15,0.65,0.87,0.95); legFrac1->SetBorderSize(0); legFrac1->SetFillStyle(0); legFrac1->SetHeader("PbPb, #sqrt{s_{NN}} = 2.76 TeV"); legFrac1->AddEntry(hBFractionDataLTJP,Form("SSVHE, LT method",taggerName,workingPoint),"pl"); legFrac1->AddEntry(hBFractionDataLTJPFixC,Form("SSVHE, LT method, Floating Charm Norm.",taggerName,workingPoint),"pl"); legFrac1->AddEntry(hBFractionData,Form("SSVHE, MC eff.",taggerName,workingPoint),"pl"); legFrac1->AddEntry(hBFractionJPdirect,"Jet Probability","pl"); //legFrac1->AddEntry(hBFractionMC,"MC Input (reconstructed)","l"); legFrac1->Draw(); // --- plots of LT method with syst. uncertainty --- TCanvas *cBFraction2 = new TCanvas("cBFraction2","b-jet fraction",600,600); TH1F *hBFractionMC2 = hBFractionMC->Clone("hBFractionMC2"); if(!doCent)hBFractionMC2->GetXaxis()->SetRangeUser(80,200); hBFractionMC2->SetMarkerSize(0); hBFractionMC2->SetMaximum(0.06); hBFractionMC2->SetMinimum(0.0); hBFractionMC2->Draw("hist"); TGraphAsymmErrors *gBFractionMC2 = new TGraphAsymmErrors(hBFractionMC); if(!doCent){ setMeanPt(gBFractionMC2,hBFractionMC,0,do3bin); gBFractionMC2->GetXaxis()->SetRangeUser(80,200); } TLatex *prel; if(doCent)prel= new TLatex(10,0.0615,"CMS preliminary"); else prel= new TLatex(85,0.0615,"CMS preliminary"); prel->Draw(); TLatex *roots = new TLatex(147,0.0615,"#sqrt{s_{NN}} = 2.76 TeV"); roots->Draw(); if(!doCent){ TLatex *csel = new TLatex(90,0.05,"Centrality 0-100%"); csel->Draw(); } TLatex *ptlabel; if(doCent==1) ptlabel= new TLatex(20,0.005,"80 < Jet p_{T} < 100 GeV/c"); if(doCent==2) ptlabel= new TLatex(20,0.005,"100 < Jet p_{T} < 120 GeV/c"); if(doCent)ptlabel->Draw(); // to be precise we should evaluate mcStatErr for 3 bins seperately float mcStatErr[4] = {0.03,0.06,0.07,0.15}; //TGraphAsymmErrors *gSyst = new TGraphAsymmErrors(3); TGraphErrors *gSyst; if(do3bin) gSyst= new TGraphErrors(3); else gSyst= new TGraphErrors(4); Double_t errCLratio, errMethod, totalSystErr; for(Int_t i=1;i<=hBFractionDataLTJP->GetNbinsX();i++) { gSyst->SetPoint(i-1,hBFractionDataLTJP->GetBinCenter(i),hBFractionDataLTJP->GetBinContent(i)); cout<<" central value "<<hBFractionDataLTJP->GetBinContent(i)<<endl; errCLratio = abs(hBFractionDataLTJP->GetBinContent(i)-hBFractionDataLTJPFixC->GetBinContent(i)); errMethod = max(abs(hBFractionDataLTJP->GetBinContent(i)-hBFractionData->GetBinContent(i)),abs(hBFractionDataLTJP->GetBinContent(i)-hBFractionJPdirect->GetBinContent(i))); double errJES = 0.14*hBFractionDataLTJP->GetBinContent(i); totalSystErr = norm(errCLratio,errMethod,errJES); gSyst->SetPointError(i-1,hBFractionDataLTJP->GetBinWidth(i)/2,totalSystErr); cout<<" sys error "<<totalSystErr<<endl; // add in MC template uncertainties float origStatErr = hBFractionDataLTJP->GetBinError(i); int statBin=i-1; if(doCent==1) statBin=0; if(doCent==2) statBin=1; float extraStatErr = mcStatErr[statBin]*hBFractionDataLTJP->GetBinContent(i); float totalStatErr = sqrt(origStatErr*origStatErr + extraStatErr*extraStatErr); hBFractionDataLTJP->SetBinError(i,totalStatErr); cout<<" total error "<<sqrt(totalSystErr*totalSystErr+totalStatErr*totalStatErr)<<endl; } gSyst->SetFillColor(5); gSyst->Draw("2"); gBFractionMC2->Draw("Z,p,same"); hBFractionMC2->Draw("hist,same"); TGraphAsymmErrors *gBFractionDataLTJP2 = new TGraphAsymmErrors(hBFractionDataLTJP); if(!doCent)setMeanPt(gBFractionDataLTJP2,hBFractionDataLTJP,1,do3bin); gBFractionDataLTJP2->SetLineColor(1); gBFractionDataLTJP2->SetMarkerColor(1); gBFractionDataLTJP2->SetMarkerSize(1.5); gBFractionDataLTJP2->Draw("p,e1,same"); TLegend *legFrac2 = new TLegend(0.2,0.15,0.8,0.34); if(doCent){ legFrac2->SetX1(0.365); legFrac2->SetY1(0.657); legFrac2->SetX2(0.965); legFrac2->SetY2(0.848); } legFrac2->SetHeader("#int L dt = 150 #mub^{-1}"); legFrac2->SetBorderSize(0); legFrac2->SetFillStyle(0); legFrac2->AddEntry(gBFractionDataLTJP2,"PbPb data","p"); legFrac2->AddEntry(gBFractionMC2,"PYTHIA+HYDJET 1.8","lp"); legFrac2->AddEntry(gSyst,"Exp. uncertainty","f"); legFrac2->Draw(); cBFraction2->RedrawAxis(); }
void fitBjetJES(int ppPbPb=1, int cbinlo=12, int cbinhi=40){ if(!ppPbPb){ cbinlo=0; cbinhi=40; } gStyle->SetOptTitle(0); gStyle->SetOptStat(0); TFile *fL; if(!ppPbPb)fL=new TFile("histos/ppMC_hiReco_jetTrig_highPurity_JEC.root"); else fL=new TFile("histos/PbPbQCDMC_pt30by3_ipHICalibCentWeight.root"); // these are dummy files for pp TFile *fB=new TFile("histos/PbPbBMC_pt30by3_ipHICalibCentWeight.root"); TFile *fC=new TFile("histos/PbPbCMC_pt30by3_ipHICalibCentWeight.root"); TNtuple *tL = (TNtuple*) fL->Get("nt"); TNtuple *tB = (TNtuple*) fB->Get("nt"); TNtuple *tC = (TNtuple*) fC->Get("nt"); float jtptL, refptL, jtetaL, weightL, refparton_flavorForBL, binL; tL->SetBranchAddress("jtpt",&jtptL); tL->SetBranchAddress("jteta",&jtetaL); tL->SetBranchAddress("refpt",&refptL); tL->SetBranchAddress("weight",&weightL); if(ppPbPb)tL->SetBranchAddress("bin",&binL); tL->SetBranchAddress("refparton_flavorForB",&refparton_flavorForBL); float jtptB, refptB, jtetaB, weightB, refparton_flavorForBB, binB; tB->SetBranchAddress("jtpt",&jtptB); tB->SetBranchAddress("jteta",&jtetaB); tB->SetBranchAddress("refpt",&refptB); tB->SetBranchAddress("weight",&weightB); if(ppPbPb)tB->SetBranchAddress("bin",&binB); tB->SetBranchAddress("refparton_flavorForB",&refparton_flavorForBB); float jtptC, refptC, jtetaC, weightC, refparton_flavorForBC, binC; tC->SetBranchAddress("jtpt",&jtptC); tC->SetBranchAddress("jteta",&jtetaC); tC->SetBranchAddress("refpt",&refptC); tC->SetBranchAddress("weight",&weightC); if(ppPbPb)tC->SetBranchAddress("bin",&binC); tC->SetBranchAddress("refparton_flavorForB",&refparton_flavorForBC); TProfile *hL = new TProfile("hL","hL",250,50,300,0,10); TProfile *hB = new TProfile("hB","hB",250,50,300,0,10); TProfile *hC = new TProfile("hC","hC",250,50,300,0,10); hL->Sumw2(),hB->Sumw2(),hC->Sumw2(); for(int i=0;i<tL->GetEntries();i++){ tL->GetEntry(i); if(!ppPbPb) binL=39; if(fabs(jtetaL)<2 && binL>=cbinlo && binL<cbinhi) hL->Fill(refptL,jtptL/refptL,weightL); if(!ppPbPb){ if(fabs(jtetaL)<2 && binL>=cbinlo && binL<cbinhi && abs(refparton_flavorForBL)==5) hB->Fill(refptL,jtptL/refptL,weightL); if(fabs(jtetaL)<2 && binL>=cbinlo && binL<cbinhi && abs(refparton_flavorForBL)==4) hC->Fill(refptL,jtptL/refptL,weightL); } } if(ppPbPb){ for(int i=0;i<tB->GetEntries();i++){ tB->GetEntry(i); if(fabs(jtetaB)<2 && binB>=cbinlo && binB<cbinhi && abs(refparton_flavorForBB)==5) hB->Fill(refptB,jtptB/refptB,weightB); } for(int i=0;i<tC->GetEntries();i++){ tC->GetEntry(i); if(fabs(jtetaC)<2 && binC>=cbinlo && binC<cbinhi && abs(refparton_flavorForBC)==4) hC->Fill(refptC,jtptC/refptC,weightC); } } hL->SetMinimum(0.); hL->SetLineColor(kBlue); hB->SetLineColor(kRed); hC->SetLineColor(kGreen); hL->SetMarkerColor(kBlue); hB->SetMarkerColor(kRed); hC->SetMarkerColor(kGreen); //hL->SetMarkerStyle(4); //hB->SetMarkerStyle(4); //hC->SetMarkerStyle(4); hL->SetXTitle("genJet p_{T} (GeV/c)"); hL->SetYTitle("<reco p_{T} / gen p_{T} >"); hL->GetXaxis()->SetRangeUser(50.,199.999); hL->GetYaxis()->SetRangeUser(0.5,1.05); TCanvas *c1=new TCanvas("c1","c1",800,600); c1->SetGridx(1); c1->SetGridy(1); hL->Draw("e1"); hB->Draw("e1,same"); hC->Draw("e1,same"); TLegend *leg=new TLegend(0.4,0.15,0.9,0.45); leg->SetBorderSize(0); leg->SetFillStyle(0); if(ppPbPb&&cbinlo==0&&cbinhi==40)leg->SetHeader("Pythia+Hydjet, 0-100%"); leg->AddEntry(hL,"Inclusive jets","pl"); leg->AddEntry(hC,"c-jets","pl"); leg->AddEntry(hB,"b-jets","pl"); leg->Draw(); TCanvas *c2=new TCanvas("c2","c2",1); /* TH1F *hL2 = (TH1F*)hL->Clone("hL2"); TH1F *hB2 = (TH1F*)hB->Clone("hB2"); hL2->Add(hB2,-1); hL2->Draw(); */ TH1F *hcorr = new TH1F("hcorr","hcorr",250,50,300); hcorr->Sumw2(); for(int i=0;i<hL->GetNbinsX();i++){ cout<<" b resp "<<hB->GetBinContent(i+1)<<endl; cout<<" l resp "<<hL->GetBinContent(i+1)<<endl; cout<<" l offset "<<1.-hL->GetBinContent(i+1)<<endl; cout<<" corrected b resp "<<hB->GetBinContent(i+1)+1.-hL->GetBinContent(i+1)<<endl; float jesOffset = 1.-hL->GetBinContent(i+1); hcorr->SetBinContent(i+1,hB->GetBinContent(i+1)+jesOffset); hcorr->SetBinError(i+1,sqrt(hB->GetBinError(i+1)*hB->GetBinError(i+1)+hL->GetBinError(i+1)*hL->GetBinError(i+1))); } hcorr->SetMinimum(0.5); hcorr->SetMaximum(1.1); hcorr->SetLineColor(kRed); hcorr->SetMarkerColor(kRed); hcorr->SetMarkerStyle(4); hcorr->Draw(); TF1 *fCorr = new TF1("fCorr","[0]+[1]*log(x)+[2]*log(x)*log(x)",50,300); fCorr->SetLineWidth(1); fCorr->SetLineColor(kBlue); hcorr->Fit(fCorr); TFile *fout; if(ppPbPb) fout =new TFile(Form("bJEShistos/bJetScale_PbPb_Cent_fineBin_%d_%d.root",cbinlo,cbinhi),"recreate"); else fout =new TFile("bJEShistos/bJetScale_PP_fineBin.root","recreate"); hcorr->Write(); fCorr->Write(); fout->Close(); }
void plotComparison( TH1F* h_dt , TH1F* h_mc , TH1F *h_extra, char* label, bool dolog, bool drawbkg) { TPad* fullpad = new TPad(); TPad* plotpad = new TPad(); TPad* respad = new TPad(); fullpad = new TPad("fullpad","fullpad",0,0,1,1); fullpad->Draw(); fullpad->cd(); plotpad = new TPad("plotpad","plotpad",0,0,1,0.8); plotpad->Draw(); plotpad->cd(); if (dolog) plotpad->SetLogy(); h_dt->GetYaxis()->SetTitle("Entries"); h_dt->GetXaxis()->SetTitle(Form("%s", label)); h_dt->GetYaxis()->SetTitleSize(0.05); h_dt->GetXaxis()->SetTitleSize(0.05); h_dt->GetYaxis()->SetTitleOffset(1.5); h_dt->GetXaxis()->SetTitleOffset(1.3); if (!dolog) h_dt->GetYaxis()->SetRangeUser(0., 1.4*h_dt->GetMaximum()); h_dt->SetLineColor(kBlack); h_dt->SetMarkerColor(kBlack); h_mc->SetLineColor(kBlue); h_mc->SetMarkerColor(kBlue); h_extra->SetLineColor(kRed); h_extra->SetLineWidth(2); h_mc->SetLineWidth(2); h_dt->Draw(); h_mc->Draw("HISTSAME"); if (drawbkg) h_extra->Draw("HISTSAME"); h_dt->Draw("ESAME"); TLegend *legComp = new TLegend( 0.653, 0.663, 0.944, 0.870); legComp->AddEntry(h_dt, "Data", "lp"); legComp->AddEntry(h_mc, "MC", "l"); if (drawbkg) legComp->AddEntry(h_extra, "MC Bkg", "l"); legComp->SetFillColor(0); legComp->SetBorderSize(0); legComp->Draw(); TLatex *text = new TLatex(); text->SetNDC(); text->SetTextSize(0.04); // float xtex = 0.65; // text->DrawLatex(xtex,0.88,"1 lepton + jets Sample"); fullpad->cd(); respad = new TPad("respad","respad",0,0.8,1,1); respad->Draw(); respad->cd(); //gPad->SetGridy(); TH1F* ratio = (TH1F*) h_dt->Clone("ratio"); ratio->Divide(h_mc); ratio->GetYaxis()->SetTitleOffset(0.3); ratio->GetYaxis()->SetTitleSize(0.2); ratio->GetYaxis()->SetNdivisions(5); ratio->GetYaxis()->SetLabelSize(0.2); if (dolog) ratio->GetYaxis()->SetRangeUser(0.5,1.5); else ratio->GetYaxis()->SetRangeUser(0.7,1.3); ratio->GetYaxis()->SetTitle("Ratio "); ratio->GetXaxis()->SetLabelSize(0); ratio->GetXaxis()->SetTitleSize(0); ratio->SetMarkerSize(1); ratio->SetLineWidth(2); ratio->SetLineColor(kBlue); ratio->SetMarkerColor(kBlue); ratio->SetFillColor(kBlue); ratio->SetFillStyle(3002); ratio->Draw("E2"); TLine line; line.SetLineWidth(2); line.DrawLine(h_dt->GetXaxis()->GetXmin(),1,h_dt->GetXaxis()->GetXmax(),1); }
void plotRegrVsNoRegr(int channel, int massBin) { stringstream filenom, filenoregr; filenom << "m4lplots/nominal/fitM" << massBin << "_channel" << channel << ".root"; filenoregr << "m4lplots/noregr/fitM" << massBin << "_channel" << channel << ".root"; int col; if(channel==0) col=kOrange+7; if(channel==1) col=kAzure+2; if(channel==2) col=kGreen+3; TCanvas *c1 = new TCanvas("c1","c1",750,750); TFile *tfilenom = TFile::Open(filenom.str().c_str()); RooPlot *plotnom = (RooPlot*)tfilenom->Get("m4lplot"); plotnom->SetMarkerStyle(kOpenSquare); plotnom->Draw(); TPaveText *pavenom = (TPaveText*)tfilenom->Get("TPave"); pavenom->SetTextColor(col); pavenom->Draw("same"); TFile *tfilenoregr = TFile::Open(filenoregr.str().c_str()); RooPlot *plotnoregr = (RooPlot*)tfilenoregr->Get("m4lplot"); plotnoregr->Draw("same"); TPaveText *pavenoregr = (TPaveText*)tfilenoregr->Get("TPave"); pavenoregr->Draw("same"); // cosmetics TLegend *legend = new TLegend(0.20,0.45,0.45,0.60,NULL,"brNDC"); legend->SetBorderSize( 0); legend->SetFillColor ( 0); legend->SetTextAlign ( 12); legend->SetTextFont ( 42); legend->SetTextSize (0.03); TH1F *dummyPointsNom = new TH1F("dummyPNom","dummyPNom",1,0,1); TH1F *dummyPointsNoRegr = new TH1F("dummyPNoregr","dummyPNoregr",1,0,1); TH1F *dummyLine = new TH1F("dummyL","dummyL",1,0,1); dummyPointsNoRegr->SetMarkerStyle(kFullCircle); dummyPointsNoRegr->SetMarkerSize(1.1); dummyPointsNom->SetMarkerStyle(kFullSquare); dummyPointsNom->SetMarkerColor(col); dummyPointsNom->SetLineColor(col); dummyPointsNom->SetMarkerSize(1.1); dummyLine->SetLineColor(col); legend->AddEntry(dummyPointsNoRegr, "Simulation (E_{std}-p comb.)", "pel"); legend->AddEntry(dummyPointsNom, "Simulation (E_{regr}-p comb.)", "pel"); legend->Draw(); TPaveText *text = new TPaveText(0.15,0.90,0.77,0.98,"brNDC"); text->AddText("CMS Simulation"); text->SetBorderSize(0); text->SetFillStyle(0); text->SetTextAlign(12); text->SetTextFont(42); text->SetTextSize(0.03); text->Draw(); stringstream frameTitle; if(channel==0){frameTitle << "4#mu, m_{H} = ";} if(channel==1){frameTitle << "4e, m_{H} = ";} if(channel==2){frameTitle << "2e2#mu, m_{H} = ";} frameTitle << massBin << " GeV"; TPaveText *titlet = new TPaveText(0.15,0.80,0.60,0.85,"brNDC"); titlet->AddText(frameTitle.str().c_str()); titlet->SetBorderSize(0); titlet->SetFillStyle(0); titlet->SetTextAlign(12); titlet->SetTextFont(132); titlet->SetTextSize(0.045); titlet->Draw(); c1->SaveAs("comp.pdf"); }
void ootpu_fit(TString files, TString comments="") { TChain* chain = new TChain("reduced_tree"); chain->Add(files); TH1::SetDefaultSumw2(); TH1F* hrelIso = new TH1F("hrelIso","", 30, 0, 0.5); TH1F* hOOTPU = new TH1F("hOOTPU","", 75, 0, 75); TH1F* hOOTPUvsIso = new TH1F("hOOTPUvsIso",";Out-of-time ints.;Isolation cut efficiency", 15, 0, 75); hrelIso->StatOverflows(true); int n1(0), n2(0); if (files.Contains("20bx25")) { n1=15; n2=75; } else if (files.Contains("S14")) { n1=0; n2=120; } else { // default: 8 TeV scenario n1=0; n2=70; } TString mu("num_gen_muons==1&&muon_reco_match>=0"); int low = 15; for (int bin(1); bin<hOOTPUvsIso->GetNbinsX()+1; bin++) { if (bin<4) continue; if (bin>4) low=low+5; if (low>hOOTPUvsIso->GetBinLowEdge(hOOTPUvsIso->GetNbinsX())) break; TString cuts = Form("(%s)&&(oot_pu>=%d&&oot_pu<%d)",mu.Data(),low,low+4); cout << "Cuts: " << cuts.Data() << endl; chain->Project(hrelIso->GetName(), "muon_relIso", cuts); chain->Project(hOOTPU->GetName(), "oot_pu", cuts); hrelIso->Scale(1/hrelIso->GetEntries()); Double_t left(0.), lerror(0.), right(0.), rerror(0.); left = hrelIso->IntegralAndError(1,12,lerror); right = hrelIso->IntegralAndError(13,31,rerror); float rat_error=sqrt((left*left*rerror*rerror+right*right*lerror*lerror)/((left+right)*(left+right))); printf("bin1: %3.2f +/- %3.3f\n", left/(left+right),rat_error); hOOTPUvsIso->SetBinContent(bin,left/(left+right)); hOOTPUvsIso->SetBinError(bin,rat_error); } hOOTPUvsIso->SetLineColor(1); hOOTPUvsIso->SetMarkerColor(1); hOOTPUvsIso->SetMarkerStyle(20); TCanvas* c1 = new TCanvas(); hOOTPUvsIso->Draw("e1"); // do a linear fit TF1 *flin = new TF1("flin", "1 ++ x", 15, 75); hOOTPUvsIso->Fit(flin); flin=hOOTPUvsIso->GetFunction("flin"); flin->SetLineColor(kBlue); flin->SetLineWidth(2); TString plotTitle ="OOTPU_fit"+comments+".pdf"; c1->Print(plotTitle); // cout << "Rejection rates" << endl; // Double_t left(0.), lerror(0.), right(0.), rerror(0.); // left = hA->IntegralAndError(1,12,lerror); // right = hA->IntegralAndError(13,31,rerror); // float rat_error=sqrt((left*left*rerror*rerror+right*right*lerror*lerror)/((left+right)*(left+right))); // printf("bin1: %3.2f +/- %3.3f\n", left/(left+right),rat_error); // left = hB->IntegralAndError(1,12,lerror); // right = hB->IntegralAndError(13,31,rerror); // rat_error=sqrt((left*left*rerror*rerror+right*right*lerror*lerror)/((left+right)*(left+right))); // printf("bin2: %3.2f +/- %3.3f\n", left/(left+right),rat_error); // left = hC->IntegralAndError(1,12,lerror); // right = hC->IntegralAndError(13,31,rerror); // rat_error=sqrt((left*left*rerror*rerror+right*right*lerror*lerror)/((left+right)*(left+right))); // printf("bin3: %3.2f +/- %3.3f\n", left/(left+right),rat_error); // left = hD->IntegralAndError(1,12,lerror); // right = hD->IntegralAndError(13,31,rerror); // rat_error=sqrt((left*left*rerror*rerror+right*right*lerror*lerror)/((left+right)*(left+right))); // printf("bin4: %3.2f +/- %3.3f\n", left/(left+right),rat_error); }
/* void formatCanvas(TCanvas *c){ c->Divide(1,2,0.01,0.01); c->cd(1); c->GetPad(1)->SetLogy(); c->GetPad(1)->SetPad(0.,0.425,1.,1.); c->GetPad(2)->SetPad(0.,0.0,1.,0.425); c->GetPad(2)->SetBottomMargin(0.3); c->GetPad(2)->SetGridy(1); } // divide by bin width void divideBinWidth(TH1 *h) { h->Sumw2(); for (int i=0;i<=h->GetNbinsX();i++) { Float_t val = h->GetBinContent(i); Float_t valErr = h->GetBinError(i); val/=h->GetBinWidth(i); valErr/=h->GetBinWidth(i); h->SetBinContent(i,val); h->SetBinError(i,valErr); } h->GetXaxis()->CenterTitle(); h->GetYaxis()->CenterTitle(); } void cleanup(TH1F *h) { for (int i=1;i<=h->GetNbinsX();i++) { double val1 = h->GetBinContent(i); double valErr1 = h->GetBinError(i); if (valErr1>=val1) { h->SetBinContent(i,0); h->SetBinError(i,0); } } } // rebin the spectra TH1F *rebin(TH1F *h, char *histName) { TH1F *hRebin = new TH1F(Form("%s_rebin",h->GetName()),Form("rebin %s",h->GetTitle()),nbins_recrebin,boundaries_recrebin); for (int i=1;i<=h->GetNbinsX();i++) { double val=h->GetBinContent(i); double valErr=h->GetBinError(i); int binNum = hRebin->FindBin(h->GetBinCenter(i)); double val1 = hRebin->GetBinContent(binNum); double valErr1 = hRebin->GetBinError(binNum); hRebin->SetBinContent(binNum,val+val1); hRebin->SetBinError(binNum,sqrt(valErr1*valErr1+valErr*valErr)); } cleanup(hRebin); hRebin->SetName(histName); return hRebin; } TH1F *rebin2(TH1F *h, char *histName) { TH1F *hRebin = new TH1F(Form("%s_rebin",h->GetName()),Form("rebin %s",h->GetTitle()),nbins_recrebin_2,boundaries_recrebin_2); for (int i=1;i<=h->GetNbinsX();i++) { double val=h->GetBinContent(i); double valErr=h->GetBinError(i); int binNum = hRebin->FindBin(h->GetBinCenter(i)); double val1 = hRebin->GetBinContent(binNum); double valErr1 = hRebin->GetBinError(binNum); hRebin->SetBinContent(binNum,val+val1); hRebin->SetBinError(binNum,sqrt(valErr1*valErr1+valErr*valErr)); } cleanup(hRebin); hRebin->SetName(histName); return hRebin; } void drawText(const char *text, float xp, float yp, int size){ TLatex *tex = new TLatex(xp,yp,text); tex->SetTextFont(63); tex->SetTextSize(size); tex->SetTextColor(kBlack); tex->SetLineWidth(1); //tex->SetTextFont(42); tex->SetNDC(); tex->Draw(); } void putCMSPrel(double x, double y, double size){ TLatex *tex=0; tex = new TLatex(x,y,"CMS Preliminary"); tex->SetTextSize(size); tex->SetLineWidth(2); tex->SetNDC(); tex->Draw(); } void putCMSSim(double x, double y, double size){ TLatex *tex=0; tex = new TLatex(x,y,"CMS Simulation"); tex->SetTextSize(size); tex->SetLineWidth(2); tex->SetNDC(); tex->Draw(); } TLegend *myLegend(double x1,double y1,double x2, double y2) { TLegend *leg = new TLegend(x1,y1,x2,y2); leg->SetBorderSize(0); leg->SetFillStyle(0); return leg; } */ void nlo_comp_macro(int radius = 3){ TH1::SetDefaultSumw2(); gStyle->SetOptStat(0); TFile *fPP = TFile::Open("/net/hisrv0001/home/rkunnawa/WORK/CMSSW_6_0_0/src/result-2013-akVs3PF-cent-1-isFineBin-0/pbpb_pp_merged_chmx_pt_isMC_0_Unfo_2013_akVs3PF_cent_1_isFineBin_0.root"); //TFile *fNLO_err = TFile::Open("fnl4350a_cteq"); TFile *fNLO_nnpdf = TFile::Open("/net/hisrv0001/home/rkunnawa/WORK/CMSSW_6_0_0/src/fnl4350a_nnpdf21-nlo_aspdf_new.root"); TFile *fNLO_cteq = TFile::Open("/net/hisrv0001/home/rkunnawa/WORK/CMSSW_6_0_0/src/fnl4350a_cteq66-nlo_aspdf_all_new.root"); TFile *fNLO_ct10n = TFile::Open("/net/hisrv0001/home/rkunnawa/WORK/CMSSW_6_0_0/src/fnl4350a_ct10n-nlo_aspdf_new.root"); TFile *fNLO_hera = TFile::Open("/net/hisrv0001/home/rkunnawa/WORK/CMSSW_6_0_0/src/fnl4350a_hera15all-nlo_aspdf_new.root"); //alright lets get the unfolded data here: remember we need it for eta range -2 to +2 //TFile* fPP_unfo_R3 = TFile::Open("pp_2013_2760_abs_eta_2_mc_ak3PF.root"); TFile* fPP_unfo_R4 = TFile::Open("/net/hisrv0001/home/rkunnawa/WORK/CMSSW_6_0_0/src/pp_2013_2760_abs_eta_2_mc_ak4PF.root"); TFile* fPP_unfo_R5 = TFile::Open("/net/hisrv0001/home/rkunnawa/WORK/CMSSW_6_0_0/src/pp_2013_2760_abs_eta_2_mc_ak5PF.root"); //TFile *f_unfold_R2 = TFile::Open("/net/hisrv0001/home/rkunnawa/WORK/RAA/CMSSW_5_3_20/src/Output/PbPb_pp_unfold_marguerite_jet80_chMaxjtpt_norawptcut_test_65GeVCut_akPu2PF_20150205_test.root"); TFile *f_unfold_R3 = TFile::Open(Form("Pawan_ntuple_PbPb_pp_calopfpt_ppNoJetidcut_nlobins_R0p%d_without80FakeRemoval_unfold_mcclosure_oppside_trgMC_noSmear_20_eta_20_%dGeVCut_akPF_20150522.root",3,40)); //TFile *f_unfold_R4 = TFile::Open("/net/hisrv0001/home/rkunnawa/WORK/RAA/CMSSW_5_3_20/src/Output/PbPb_pp_unfold_marguerite_jet80_chMaxjtpt_norawptcut_test_65GeVCut_akPu4PF_20150205_test.root"); TH1F* hPP_data_R_3 = (TH1F*)f_unfold_R3->Get("PP_bayesian_unfolded_spectra"); hPP_data_R_3->Print("base"); hPP_data_R_3 = (TH1F*)hPP_data_R_3->Rebin(nbins_yaxian, "PP_bayesian_unfolded_spectra", boundaries_yaxian); divideBinWidth(hPP_data_R_3); hPP_data_R_3->Print("base"); //PP_measured[0] = (TH1F*)f_unfold_R2->Get("PP_measured_unfolded_spectra"); //PP_binbybin[0] = (TH1F*)f_unfold_R2->Get("PP_binbybin_unfolded_spectra"); //TH1F* PP_bayesian[1] = (TH1F*)f_unfold_R4->Get("PP_bayesian_unfolded_spectra"); //PP_measured[1] = (TH1F*)f_unfold_R3->Get("PP_measured_unfolded_spectra"); //PP_binbybin[1] = (TH1F*)f_unfold_R3->Get("PP_binbybin_unfolded_spectra"); TFile fout("pp_2760GeV_nlo_histos.root","RECREATE"); fout.cd(); TH1F* hPP_nnpdf_NLO = (TH1F*)fNLO_nnpdf->Get(Form("h100%d00",radius-1)); TH1F* hPP_cteq_NLO = (TH1F*)fNLO_cteq->Get(Form("h100%d00",radius-1)); TH1F* hPP_ct10n_NLO = (TH1F*)fNLO_ct10n->Get(Form("h100%d00",radius-1)); TH1F* hPP_hera_NLO = (TH1F*)fNLO_hera->Get(Form("h100%d00",radius-1)); //TH1F* hPP_data_R_3 = (TH1F*)fPP_unfo_R3->Get("Unfolded_cent1"); TH1F* hPP_data_R_4 = (TH1F*)fPP_unfo_R4->Get("Unfolded_cent1"); TH1F* hPP_data_R_5 = (TH1F*)fPP_unfo_R5->Get("Unfolded_cent1"); hPP_data_R_3->Scale(5.3*1e3); hPP_data_R_3->Scale(1./5300e6); //hPP_data_R_3->Scale(1./4); //divideBinWidth(hPP_data_R_3); hPP_data_R_4->Scale(1./5300e6); hPP_data_R_4->Scale(1./4); divideBinWidth(hPP_data_R_4); hPP_data_R_5->Scale(1./5300e6); hPP_data_R_5->Scale(1./4); divideBinWidth(hPP_data_R_5); // NLO histograms without any R# at the end correspond to R=0.3 the standard. others are named accordingly TH1F* hPP_nnpdf_NLO_R4 = (TH1F*)fNLO_nnpdf->Get("h100300"); TH1F* hPP_nnpdf_NLO_R2 = (TH1F*)fNLO_nnpdf->Get("h100100"); TH1F* hPP_cteq_NLO_R4 = (TH1F*)fNLO_cteq->Get("h100300"); TH1F* hPP_ct10n_NLO_R4 = (TH1F*)fNLO_ct10n->Get("h100300"); TH1F* hPP_hera_NLO_R4 = (TH1F*)fNLO_hera->Get("h100300"); TH1F* hPP_cteq_NLO_R2 = (TH1F*)fNLO_cteq->Get("h100100"); TH1F* hPP_ct10n_NLO_R2 = (TH1F*)fNLO_ct10n->Get("h100100"); TH1F* hPP_hera_NLO_R2 = (TH1F*)fNLO_hera->Get("h100100"); TH1F* hPP_err = (TH1F*)fNLO_cteq->Get("h100203"); TH1F* hPP_err_R4 = (TH1F*)fNLO_cteq->Get("h100303"); TH1F* hPP_err_R2 = (TH1F*)fNLO_cteq->Get("h100103"); for(int i = 0;i<hPP_nnpdf_NLO->GetNbinsX();i++){ Float_t valErr = hPP_err->GetBinError(i); hPP_nnpdf_NLO->SetBinError(i,valErr); hPP_cteq_NLO->SetBinError(i,valErr); hPP_hera_NLO->SetBinError(i,valErr); hPP_ct10n_NLO->SetBinError(i,valErr); Float_t valErr_R4 = hPP_err_R4->GetBinError(i); hPP_nnpdf_NLO_R4->SetBinError(i,valErr_R4); hPP_cteq_NLO_R4->SetBinError(i,valErr_R4); hPP_ct10n_NLO_R4->SetBinError(i,valErr_R4); hPP_hera_NLO_R4->SetBinError(i,valErr_R4); Float_t valErr_R2 = hPP_err_R2->GetBinError(i); hPP_nnpdf_NLO_R2->SetBinError(i,valErr_R2); hPP_cteq_NLO_R2->SetBinError(i,valErr_R2); hPP_ct10n_NLO_R2->SetBinError(i,valErr_R2); hPP_hera_NLO_R2->SetBinError(i,valErr_R2); } //add the NPC factors char etaWidth[dir][256] = { "n10_eta_p10","n20_eta_p20","n25_eta_n20","n20_eta_n15", "n15_eta_n10","n10_eta_n05","n05_eta_p05","p05_eta_p10", "p10_eta_p15","p15_eta_p20", "n10_eta_p10","n20_eta_p20","n25_eta_n20","n20_eta_n15", "n15_eta_n10","n10_eta_n05","n05_eta_p05","p05_eta_p10", "p10_eta_p15","p15_eta_p20", "n10_eta_p10","n20_eta_p20","n25_eta_n20","n20_eta_n15", "n15_eta_n10","n10_eta_n05","n05_eta_p05","p05_eta_p10", "p10_eta_p15","p15_eta_p20", "n10_eta_p10","n20_eta_p20","n25_eta_n20","n20_eta_n15", "n15_eta_n10","n10_eta_n05","n05_eta_p05","p05_eta_p10", "p10_eta_p15","p15_eta_p20", "n10_eta_p10","n20_eta_p20","n25_eta_n20","n20_eta_n15", "n15_eta_n10","n10_eta_n05","n05_eta_p05","p05_eta_p10", "p10_eta_p15","p15_eta_p20" }; char radius_lable[dir][256] = { "R2","R2","R2","R2","R2","R2","R2","R2","R2","R2", "R3","R3","R3","R3","R3","R3","R3","R3","R3","R3", "R4","R4","R4","R4","R4","R4","R4","R4","R4","R4", "R5","R5","R5","R5","R5","R5","R5","R5","R5","R5", "R7","R7","R7","R7","R7","R7","R7","R7","R7","R7" }; ifstream fin_txt[dir]; int energy = 2760; for(int i = 0;i<dir;i++){ //ostringstream filename; //filename<<"/net/hisrv0001/home/rkunnawa/WORK/RAA/CMSSW_5_3_8_HI_patch2/src/Macros/RAA/nlo_files/input_np_txtfiles/NPC_ak_"<<radius_lable[i]<<etaWidth[i]<<"_energy"<<energy<<".txt"; fin_txt[i].open(Form("/net/hisrv0001/home/rkunnawa/WORK/RAA/CMSSW_5_3_8_HI_patch2_old/src/Macros/RAA/nlo_files/input_np_txtfiles/NPC_ak_%s_%s_energy%d.txt",radius_lable[i],etaWidth[i],energy)); } //apply the correction factors to the NLO histograms Float_t npc = 0; Float_t bin = 0; //before applying the corrections, lets get a clone of the uncorrected histogram. TH1F* hPP_nnpdf_NLO_noNPC = (TH1F*)hPP_nnpdf_NLO->Clone("hPP_nnpdf_NLO_noNPC"); int counter = 0; while(1){ fin_txt[11]>>bin>>npc; cout<<bin<<" "<<npc<<endl; if(!fin_txt[11].good())break; int bin_no = hPP_nnpdf_NLO->FindBin(bin); //cout<<"bin no = "<<bin_no<<endl; //cout<<"boundaries_pt of bin no"<<boundaries_yaxian_large[bin_no]<<endl; cout<<"value before applying = "<<hPP_nnpdf_NLO->GetBinContent(bin_no)<<endl; hPP_nnpdf_NLO->SetBinContent(bin_no,npc*hPP_nnpdf_NLO->GetBinContent(bin_no)); cout<<"value after applying = "<<hPP_nnpdf_NLO->GetBinContent(bin_no)<<endl; hPP_cteq_NLO->SetBinContent(bin_no,npc*hPP_cteq_NLO->GetBinContent(bin_no)); hPP_ct10n_NLO->SetBinContent(bin_no,npc*hPP_ct10n_NLO->GetBinContent(bin_no)); hPP_hera_NLO->SetBinContent(bin_no,npc*hPP_hera_NLO->GetBinContent(bin_no)); fin_txt[1]>>bin>>npc; if(!fin_txt[1].good())break; bin_no = hPP_nnpdf_NLO_R2->FindBin(bin); hPP_nnpdf_NLO_R2->SetBinContent(bin_no,npc*hPP_nnpdf_NLO_R2->GetBinContent(bin_no)); hPP_cteq_NLO_R2->SetBinContent(bin_no,npc*hPP_cteq_NLO_R2->GetBinContent(bin_no)); hPP_ct10n_NLO_R2->SetBinContent(bin_no,npc*hPP_ct10n_NLO_R2->GetBinContent(bin_no)); hPP_hera_NLO_R2->SetBinContent(bin_no,npc*hPP_hera_NLO_R2->GetBinContent(bin_no)); fin_txt[21]>>bin>>npc; if(!fin_txt[21].good())break; bin_no = hPP_nnpdf_NLO_R4->FindBin(bin); hPP_nnpdf_NLO_R4->SetBinContent(bin_no,npc*hPP_nnpdf_NLO_R4->GetBinContent(bin_no)); hPP_cteq_NLO_R4->SetBinContent(bin_no,npc*hPP_cteq_NLO_R4->GetBinContent(bin_no)); hPP_ct10n_NLO_R4->SetBinContent(bin_no,npc*hPP_ct10n_NLO_R4->GetBinContent(bin_no)); hPP_hera_NLO_R4->SetBinContent(bin_no,npc*hPP_hera_NLO_R4->GetBinContent(bin_no)); counter++; } cout<<"counter = "<<counter<<endl; //get a clone after applying the corrections, TH1F* hPP_nnpdf_NLO_NPC = (TH1F*)hPP_nnpdf_NLO->Clone("hPP_nnpdf_NLO_NPC"); TH1F* hPP_NPC_ratio = (TH1F*)hPP_nnpdf_NLO_NPC->Clone("hPP_NPC_ratio"); hPP_NPC_ratio->Divide(hPP_nnpdf_NLO_noNPC); /* TCanvas *cnpc = new TCanvas("cnpc","",800,600); //cnpc->SetLogy(); hPP_NPC_ratio->SetTitle("NPC 2.76 TeV R=0.3"); hPP_NPC_ratio->SetXTitle("Jet p_{T} (GeV/c)"); hPP_NPC_ratio->SetYTitle("NP factors"); hPP_NPC_ratio->SetAxisRange(0.7,1.3,"Y"); hPP_NPC_ratio->Draw(); cnpc->SaveAs("pp_2760_npc_R3.pdf","RECREATE"); */ hPP_nnpdf_NLO->SetName("hPP_nnpdf_NLO"); hPP_cteq_NLO->SetName("hPP_cteq_NLO"); hPP_ct10n_NLO->SetName("hPP_ct10n_NLO"); hPP_hera_NLO->SetName("hPP_hera_NLO"); hPP_nnpdf_NLO_R2->SetName("hPP_nnpdf_NLO_R2"); hPP_nnpdf_NLO_R2->Print("base"); hPP_cteq_NLO_R2->SetName("hPP_cteq_NLO_R2"); hPP_cteq_NLO_R2->Print("base"); hPP_ct10n_NLO_R2->SetName("hPP_ct10n_NLO_R2"); hPP_ct10n_NLO_R2->Print("base"); hPP_hera_NLO_R2->SetName("hPP_hera_NLO_R2"); hPP_nnpdf_NLO_R4->SetName("hPP_nnpdf_NLO_R4"); hPP_cteq_NLO_R4->SetName("hPP_cteq_NLO_R4"); hPP_ct10n_NLO_R4->SetName("hPP_ct10n_NLO_R4"); hPP_hera_NLO_R4->SetName("hPP_hera_NLO_R4"); hPP_nnpdf_NLO->Write(); hPP_cteq_NLO->Write(); hPP_ct10n_NLO->Write(); hPP_hera_NLO->Write(); hPP_nnpdf_NLO_R2->Write(); hPP_cteq_NLO_R2->Write(); hPP_ct10n_NLO_R2->Write(); hPP_hera_NLO_R2->Write(); hPP_nnpdf_NLO_R4->Write(); hPP_cteq_NLO_R4->Write(); hPP_ct10n_NLO_R4->Write(); hPP_hera_NLO_R4->Write(); TH1F* hPPrebin = (TH1F*)hPP_data_R_3->Clone("hPPrebin"); //TH1F* hPPrebin_test = (TH1F*)faditya->Get("Corrected Jet Spectrum Aditya"); //TH1F* hPPrebin = (TH1F*)hPPrebin_test->Rebin(nbins_yaxian_large,"hPPrebin",boundaries_yaxian_large); //TH1F* hPPunfo = (TH1F*)fPP->Get("Unfolded_cent6"); TH1F* hPPgen = (TH1F*)fPP->Get("hGen_cent1"); //hPPrebin->Scale(64);//remove the sigma scaling from the previous macros //dont need this now since we are taking it from a dedicated macro which gives us diff cross section hPP_data_R_3->Scale(1e9); hPP_data_R_4->Scale(1e9); hPP_data_R_5->Scale(1e9); //hPP_nnpdf_NLO->Scale(1./4); //hPP_cteq_NLO->Scale(1./4); //hPP_hera_NLO->Scale(1./4); hPPrebin->Scale(1e9); //hPPrebin->Scale(1./5300e6); //hPPrebin->Scale(1./4); //divideBinWidth(hPPrebin); hPPgen->Scale(1./4); hPPgen->Scale(1e9); fout.Write(); hPP_nnpdf_NLO = (TH1F*)hPP_nnpdf_NLO->Rebin(nbins_yaxian,"nnpdf_pp", boundaries_yaxian); hPP_nnpdf_NLO->Print("base"); hPP_cteq_NLO = (TH1F*)hPP_cteq_NLO->Rebin(nbins_yaxian,"cteq_pp", boundaries_yaxian); hPP_cteq_NLO->Print("base"); hPP_hera_NLO = (TH1F*)hPP_hera_NLO->Rebin(nbins_yaxian,"hera_pp", boundaries_yaxian); hPP_hera_NLO->Print("base"); hPP_ct10n_NLO = (TH1F*)hPP_ct10n_NLO->Rebin(nbins_yaxian,"ct10n_pp", boundaries_yaxian); hPP_ct10n_NLO->Print("base"); TH1F* hRatio_nnpdf_mc = (TH1F*)hPPgen->Rebin(nbins_yaxian,"hRatio_nnpdf_mc",boundaries_yaxian); hRatio_nnpdf_mc->Divide(hPP_nnpdf_NLO); TH1F* hRatio_cteq_mc = (TH1F*)hPPgen->Rebin(nbins_yaxian,"hRatio_cteq_mc",boundaries_yaxian); hRatio_cteq_mc->Divide(hPP_cteq_NLO); TH1F* hRatio_hera_mc = (TH1F*)hPPgen->Rebin(nbins_yaxian,"hRatio_hera_mc",boundaries_yaxian); hRatio_hera_mc->Divide(hPP_hera_NLO); TH1F* hRatio_ct10n_mc = (TH1F*)hPPgen->Rebin(nbins_yaxian,"hRatio_ct10n_mc",boundaries_yaxian); hRatio_ct10n_mc->Divide(hPP_ct10n_NLO); TH1F* hRatio_nnpdf = (TH1F*)hPP_nnpdf_NLO->Rebin(nbins_yaxian,"hRatio_nnpdf",boundaries_yaxian); hRatio_nnpdf->Divide(hPPrebin); TH1F* hRatio_cteq = (TH1F*)hPP_cteq_NLO->Rebin(nbins_yaxian,"hRatio_cteq",boundaries_yaxian); hRatio_cteq->Divide(hPPrebin); TH1F* hRatio_ct10n = (TH1F*)hPP_ct10n_NLO->Rebin(nbins_yaxian,"hRatio_ct10n",boundaries_yaxian); hRatio_ct10n->Divide(hPPrebin); TH1F* hRatio_hera = (TH1F*)hPP_hera_NLO->Rebin(nbins_yaxian,"hRatio_hera",boundaries_yaxian); hRatio_hera->Divide(hPPrebin); TH1F* hRatio_ppgen = (TH1F*)hPPgen->Rebin(nbins_yaxian,"hRatio_ppgen",boundaries_yaxian); hRatio_ppgen->Divide(hPPrebin); TH1F* hRatio_nnpdf_R_2_4 = (TH1F*)hPP_nnpdf_NLO_R2->Rebin(nbins_yaxian,"hRatio_nnpdf_R_2_4",boundaries_yaxian); hRatio_nnpdf_R_2_4->Divide(hPP_nnpdf_NLO_R4); TH1F* hRatio_nnpdf_R_3_4 = (TH1F*)hPP_nnpdf_NLO->Rebin(nbins_yaxian,"hRatio_nnpdf_R_3_4",boundaries_yaxian); hRatio_nnpdf_R_3_4->Divide(hPP_nnpdf_NLO_R4); TH1F* hRatio_cteq_R_2_4 = (TH1F*)hPP_cteq_NLO_R2->Rebin(nbins_yaxian,"hRatio_cteq_R_2_4",boundaries_yaxian); hRatio_cteq_R_2_4->Divide(hPP_cteq_NLO_R4); TH1F* hRatio_cteq_R_3_4 = (TH1F*)hPP_cteq_NLO->Rebin(nbins_yaxian,"hRatio_cteq_R_3_4",boundaries_yaxian); hRatio_cteq_R_3_4->Divide(hPP_cteq_NLO_R4); TH1F* hRatio_ct10n_R_2_4 = (TH1F*)hPP_ct10n_NLO_R2->Rebin(nbins_yaxian,"hRatio_ct10n_R_2_4",boundaries_yaxian); hRatio_ct10n_R_2_4->Divide(hPP_ct10n_NLO_R4); TH1F* hRatio_ct10n_R_3_4 = (TH1F*)hPP_ct10n_NLO->Rebin(nbins_yaxian,"hRatio_ct10n_R_3_4",boundaries_yaxian); hRatio_ct10n_R_3_4->Divide(hPP_ct10n_NLO_R4); TH1F* hRatio_hera_R_2_4 = (TH1F*)hPP_hera_NLO_R2->Rebin(nbins_yaxian,"hRatio_hera_R_2_4",boundaries_yaxian); hRatio_hera_R_2_4->Divide(hPP_hera_NLO_R4); TH1F* hRatio_hera_R_3_4 = (TH1F*)hPP_hera_NLO->Rebin(nbins_yaxian,"hRatio_hera_R_3_4",boundaries_yaxian); hRatio_hera_R_3_4->Divide(hPP_hera_NLO_R4); TH1F* hRatio_data_nnpdf_R_3 = (TH1F*)hPP_nnpdf_NLO->Rebin(nbins_yaxian,"hRatio_data_nnpdf_R_3",boundaries_yaxian); hRatio_data_nnpdf_R_3->Divide(hPP_data_R_3); TH1F* hRatio_data_nnpdf_R_4 = (TH1F*)hPP_nnpdf_NLO_R4->Rebin(nbins_yaxian,"hRatio_data_nnpdf_R_4",boundaries_yaxian); hRatio_data_nnpdf_R_4->Divide(hPP_data_R_4); TH1F* hRatio_data_R_3_4 = (TH1F*)hPP_data_R_3->Clone("hRatio_data_R_3_4"); hRatio_data_R_3_4->Divide(hPP_data_R_4); TH1F* hRatio_data_R_3_5 = (TH1F*)hPP_data_R_3->Clone("hRatio_data_R_3_5"); hRatio_data_R_3_5->Divide(hPP_data_R_5); TH1F* hRatio_data_R_4_5 = (TH1F*)hPP_data_R_4->Clone("hRatio_data_R_4_5"); hRatio_data_R_4_5->Divide(hPP_data_R_5); /* TCanvas *cnlo_mc = new TCanvas("cnlo_mc","",800,600); hRatio_nnpdf_mc->SetMarkerColor(kRed); hRatio_nnpdf_mc->SetMarkerStyle(20); hRatio_nnpdf_mc->SetXTitle("Jet p_{T} (GeV/c)"); hRatio_nnpdf_mc->SetYTitle("MC/NLO"); hRatio_nnpdf_mc->SetTitle(" "); hRatio_nnpdf_mc->SetAxisRange(0,1.5,"Y"); hRatio_nnpdf_mc->Draw(); hRatio_cteq_mc->SetMarkerColor(kBlue); hRatio_cteq_mc->SetMarkerStyle(20); hRatio_cteq_mc->Draw("same"); hRatio_ct10n_mc->SetMarkerColor(9); hRatio_ct10n_mc->SetMarkerStyle(20); hRatio_ct10n_mc->Draw("same"); hRatio_hera_mc->SetMarkerColor(kGreen); hRatio_hera_mc->SetMarkerStyle(20); hRatio_hera_mc->Draw("same"); TLegend *titlenlomc = myLegend(0.10,0.10,0.30,0.30); titlenlomc->AddEntry(hRatio_nnpdf_mc,"nnpdf","pl"); titlenlomc->AddEntry(hRatio_cteq_mc,"cteq","pl"); titlenlomc->AddEntry(hRatio_ct10n_mc,"ct10n","pl"); titlenlomc->AddEntry(hRatio_hera_mc,"hera","pl"); titlenlomc->SetTextSize(0.04); titlenlomc->Draw(); putCMSSim(0.1,0.92,0.06); drawText("pp #sqrt{s}=2.76(TeV)",0.65,0.92,16); drawText(Form("anti k_{T} R = 0.%d, NP corrections added to NLO",radius),0.15,0.83,16); cnlo_mc->SaveAs(Form("Ratio_mc_with_nlo_with_np_R%d.pdf",radius),"RECREATE"); */ TCanvas *c1 = new TCanvas("c1","",800,600); formatCanvas(c1); c1->cd(1); c1->cd(1)->SetLogy(); hPP_nnpdf_NLO->SetMarkerColor(kRed); hPP_nnpdf_NLO->SetMarkerStyle(33); hPP_cteq_NLO->SetMarkerColor(kBlue); hPP_cteq_NLO->SetMarkerStyle(33); hPP_ct10n_NLO->SetMarkerColor(9);//purple hPP_ct10n_NLO->SetMarkerStyle(33); hPP_hera_NLO->SetMarkerColor(kGreen); hPP_hera_NLO->SetMarkerStyle(33); hPPrebin->SetMarkerColor(kBlack); hPPrebin->SetMarkerStyle(8); hPPgen->SetMarkerColor(kOrange); hPPgen->SetMarkerStyle(8); //hPPgen->SetMarkerColor(kRed); //hPPgen->SetMarkerStyle(8); makeHistTitle(hPP_nnpdf_NLO,"","p_{T} (GeV/c)","#frac{d^{2} #sigma}{d p_{T} d #eta} (pb#frac{GeV}{c})"); //hPP_nnpdf_NLO->SetYTitle("#frac{d^{2} #sigma}{d p_{T} d #eta} (pb#frac{GeV}{c})"); //hPP_nnpdf_NLO->SetXTitle("p_{T} (GeV/c)"); hPP_nnpdf_NLO->SetAxisRange(22,500,"X"); hPP_nnpdf_NLO->SetTitle(" "); hPP_nnpdf_NLO->Draw("p"); hPP_cteq_NLO->Draw("same p"); hPP_ct10n_NLO->Draw("same p"); hPP_hera_NLO->Draw("same p"); hPPrebin->Draw("same p"); //hPPgen->Draw("same p"); TLegend * title = myLegend(0.47, 0.50,0.67, 0.8); title->AddEntry(hPP_nnpdf_NLO,"NLO nnpdf","pl"); title->AddEntry(hPP_cteq_NLO,"NLO cteq","pl"); title->AddEntry(hPP_ct10n_NLO,"NLO ct10n","pl"); title->AddEntry(hPP_hera_NLO,"NLO hera","pl"); //title->AddEntry(hPPgen,"pp MC spectra","pl"); title->AddEntry(hPPrebin,"pp unfolded 2013 data","pl"); title->SetTextSize(0.04); title->Draw(); putCMSPrel(0.1,0.92,0.06); drawText("pp 2013, #sqrt{s}=2.76(TeV), #int L dt = 5.3 (pb)^{-1}",0.35,0.92,16); drawText(Form("anti k_{T} R = 0.3, NP corrections added to NLO",radius),0.35,0.83,16); c1->cd(2); makeHistTitle(hRatio_nnpdf,"","p_{T} (GeV/c)","NLO / pp data"); //hRatio_nnpdf->SetYTitle(" X / pp data"); //hRatio_nnpdf->SetXTitle("p_{T} (GeV/c)"); hRatio_nnpdf->SetTitle(" "); hRatio_nnpdf->SetAxisRange(0.8,2,"Y"); hRatio_nnpdf->SetMarkerColor(kRed); hRatio_nnpdf->SetMarkerStyle(33); hRatio_hera->SetMarkerColor(kGreen); hRatio_hera->SetMarkerStyle(33); hRatio_cteq->SetMarkerColor(kBlue); hRatio_cteq->SetMarkerStyle(33); hRatio_ct10n->SetMarkerColor(9); hRatio_ct10n->SetMarkerStyle(33); hRatio_ppgen->SetMarkerColor(kOrange); hRatio_ppgen->SetMarkerStyle(33); hRatio_nnpdf->Draw("p"); hRatio_nnpdf->SetAxisRange(22,500,"X"); hRatio_hera->Draw("same p"); hRatio_cteq->Draw("same p"); hRatio_ct10n->Draw("same p"); //hRatio_ppgen->Draw("same p"); c1->SaveAs(Form("May22/pp_2760GeV_NLO_NPadded_ak%dPF_spectra.pdf",radius),"RECREATE"); /* //get the information from the ratio per bins - to use to scale down the NLO in 5.02 TeV. ofstream R_nnpdf,R_hera,R_cteq; R_nnpdf.open(Form("ratio_nnpdf_vs_pp_data_2760_ak%d.txt",radius)); R_hera.open(Form("ratio_hera_vs_pp_data_2760_ak%d.txt",radius)); R_cteq.open(Form("ratio_cteq_vs_pp_data_2760_ak%d.txt",radius)); for(int i = 0;i<hRatio_nnpdf->GetNbinsX();i++){ R_nnpdf<<i<<"\t"<<hRatio_nnpdf->GetBinContent(i)<<endl; R_hera<<i<<"\t"<<hRatio_hera->GetBinContent(i)<<endl; R_cteq<<i<<"\t"<<hRatio_cteq->GetBinContent(i)<<endl; } R_nnpdf.close(); R_hera.close(); R_cteq.close(); //draw the results for NLO comparison within different radius at the same energy TCanvas *c2 = new TCanvas("c2","",800,600); formatCanvas(c2); c2->cd(1); hPP_nnpdf_NLO->SetMarkerStyle(22); hPP_nnpdf_NLO->SetMarkerColor(3); hPP_nnpdf_NLO->Draw("p"); hPP_nnpdf_NLO_R2->SetMarkerStyle(22); hPP_nnpdf_NLO_R2->SetMarkerColor(2); hPP_nnpdf_NLO_R2->Draw("same p"); hPP_nnpdf_NLO_R4->SetMarkerStyle(22); hPP_nnpdf_NLO_R4->SetMarkerColor(4); hPP_nnpdf_NLO_R4->Draw("same p"); hPP_data_R_4->SetMarkerStyle(23); hPP_data_R_4->SetMarkerColor(4); hPP_data_R_4->Draw("same p"); hPP_data_R_3->SetMarkerStyle(23); hPP_data_R_3->SetMarkerColor(3); hPP_data_R_3->Draw("same p"); hPP_data_R_5->SetMarkerStyle(23); hPP_data_R_5->SetMarkerColor(9); hPP_data_R_5->Draw("same p"); TLegend * title2 = myLegend(0.47, 0.50,0.67, 0.8); title2->AddEntry(hPP_nnpdf_NLO_R2,"NNPDF21 R=0.2","pl"); title2->AddEntry(hPP_nnpdf_NLO,"NNPDF21 R=0.3","pl"); title2->AddEntry(hPP_nnpdf_NLO_R4,"NNPDF21 R=0.4","pl"); title2->AddEntry(hPP_data_R_3,"Data R=0.3","pl"); title2->AddEntry(hPP_data_R_4,"Data R=0.4","pl"); title2->AddEntry(hPP_data_R_5,"Data R=0.5","pl"); title2->SetTextSize(0.04); title2->Draw(); putCMSPrel(0.1,0.92,0.06); drawText("pp 2013, #sqrt{s}=2.76(TeV), #int L dt = 5.3 (pb)^{-1}",0.35,0.92,16); drawText(Form("anti k_{T}, Data vs Theory",radius),0.47,0.83,16); c2->cd(2); hRatio_nnpdf_R_2_4->SetMarkerStyle(29); hRatio_nnpdf_R_2_4->SetMarkerColor(2); hRatio_nnpdf_R_2_4->SetAxisRange(0.6,1.6,"Y"); hRatio_nnpdf_R_2_4->SetAxisRange(22,500,"X"); hRatio_nnpdf_R_2_4->SetTitle(" "); hRatio_nnpdf_R_2_4->SetYTitle("Ratios"); hRatio_nnpdf_R_2_4->SetXTitle("p_{T}(GeV/c)"); hRatio_nnpdf_R_2_4->Draw("p"); hRatio_nnpdf_R_3_4->SetMarkerStyle(29); hRatio_nnpdf_R_3_4->SetMarkerColor(3); hRatio_nnpdf_R_3_4->Draw("same p"); hRatio_data_nnpdf_R_3->SetMarkerStyle(33); hRatio_data_nnpdf_R_3->SetMarkerColor(4); hRatio_data_nnpdf_R_3->Draw("same p"); hRatio_data_nnpdf_R_4->SetMarkerStyle(33); hRatio_data_nnpdf_R_4->SetMarkerColor(7); hRatio_data_nnpdf_R_4->Draw("same p"); hRatio_data_R_3_4->SetMarkerStyle(34); hRatio_data_R_3_4->SetMarkerColor(6); hRatio_data_R_3_4->Draw("same p"); hRatio_data_R_3_5->SetMarkerStyle(34); hRatio_data_R_3_5->SetMarkerColor(7); hRatio_data_R_3_5->Draw("same p"); hRatio_data_R_4_5->SetMarkerStyle(34); hRatio_data_R_4_5->SetMarkerColor(8); hRatio_data_R_4_5->Draw("same p"); c2->cd(1); TLegend * title3 = myLegend(0.67, 0.40,0.77, 0.8); title3->AddEntry(hRatio_nnpdf_R_2_4,"NLO R=0.2/R=0.4","pl"); title3->AddEntry(hRatio_nnpdf_R_3_4,"NLO R=0.3/R=0.4","pl"); title3->AddEntry(hRatio_data_nnpdf_R_3,"R=0.3 NNPDF21/Data","pl"); title3->AddEntry(hRatio_data_nnpdf_R_4,"R=0.4 NNPDF21/Data","pl"); title3->AddEntry(hRatio_data_R_3_4,"Data R=0.3/R=0.4","pl"); title3->AddEntry(hRatio_data_R_3_5,"Data R=0.3/R=0.5","pl"); title3->AddEntry(hRatio_data_R_4_5,"Data R=0.4/R=0.5","pl"); title3->SetTextSize(0.04); title3->Draw(); c2->SaveAs("pp_2760GeV_data_NLO_NPCadded_radius_comparison.pdf","RECREATE"); fout.Write(); fout.Close(); */ /* TCanvas *c2 = new TCanvas("c2","",1000,800); c2->Divide(2,1); c2->cd(1); c2->cd(1)->SetLogy(); hPPunfo->SetTitle("PP 2013 2.76 TeV Merged, Unfolded p_{T} Spectra"); hPPunfo->SetYTitle("#frac{dN}{N_{MB} d p_{T} d #eta}"); hPPunfo->GetYaxis()->SetTitleOffset(1.4); hPPunfo->SetXTitle("Jet p_{T} GeV/c"); hPPunfo->GetXaxis()->SetRangeUser(50,500); hPPunfo->Draw(); hPPmeas->GetXaxis()->SetRangeUser(50,500); hPPmeas->SetMarkerStyle(22); hPPmeas->SetMarkerColor(kBlack); hPPmeas->Draw("same"); TLegend *titl = myLegend(0.54,0.65,0.85,0.9); titl->AddEntry(hPPmeas,"PP2013 Meas ak3PF","pl"); titl->AddEntry(hPPunfo,"PP2013 Unfo Bayesian","pl"); titl->SetTextSize(0.03); titl->Draw(); drawText("Anti-k_{T}PF R = 0.3",0.43,0.6,22); drawText("|#eta|<2, |vz|<15",0.47,0.5,22); c2->cd(2); TH1F* hPPRatio = (TH1F*)hPPmeas->Clone("hPPRatio"); hPPRatio->Divide(hPPunfo); hPPRatio->SetXTitle("Jet p_{T} GeV/c"); hPPRatio->SetYTitle("Ratio Measured/Unfolded"); hPPRatio->SetTitle("PP2013 ak3PF merged"); hPPRatio->GetYaxis()->SetRangeUser(0,2); hPPRatio->Draw(); c2->SaveAs("pp_2013_ak3_merged_unfolded_pt.pdf","RECREATE"); */ /* TH1F *hNLO_err = (TH1F*)fNLO->Get("h100203"); for(int i = 0;i<hNLO_err->GetNbinsX();i++){ Float_T valErr = hNLO_Err->GetBinError(i); hNLO->SetBinError(i,valErr); } */ /* //h100300 - ak4PF, h100200 - ak3PF TH1F* hNLO_2 = (TH1F*)hNLO->Clone("hNLO_2"); hNLO->Print("base"); TCanvas *cComp = new TCanvas("cComp","",800,600); cComp->Divide(2,1); cComp->cd(1); cComp->cd(1)->SetLogy(); hPPrebin->SetMarkerStyle(22); hPPrebin->SetMarkerColor(kRed); hNLO->SetMarkerStyle(20); hNLO->SetMarkerColor(kBlack); hNLO->SetTitle("PP 2.76 TeV"); hNLO->SetYTitle("#sigma pb"); hNLO->SetXTitle("Jet p_{T} GeV/c"); hNLO->Draw("pl"); hPPMCrebin->SetMarkerStyle(21); hPPMCrebin->SetMarkerColor(kBlue); hPPMCrebin->Draw("same"); hPPrebin->Draw("same"); TLegend *title = myLegend(0.34,0.65,0.54,0.75); title->AddEntry(hNLO,"NLO nnpdf21","pl"); title->AddEntry(hPPrebin,"PP ak3PF unfo","pl"); title->AddEntry(hPPMCrebin,"PP ak3PF MC Gen","pl"); title->SetTextSize(0.06); title->Draw(); cComp->cd(2); TH1F *hPP = (TH1F*)hPPrebin->Clone("hPP"); TH1F* hPPMC_v2 = (TH1F*)hPPMCrebin->Clone("hPPMC_v2"); hPP->Print("base"); hPPMC_v2->Print("base"); hPP->Divide(hNLO); hPPMC_v2->Divide(hNLO); hPP->SetTitle("Ratio of PP ak3PF unfolded and MC Gen to NLO"); //hPP->SetTitle("Ratio of PP ak4PF measured to NLO"); hPP->SetYTitle("#frac{#sigma_{PP}}{#sigma_{NLO}}"); hPP->SetXTitle("Jet p_{T} GeV/c"); hPP->Draw(); hPPMC_v2->Draw("same"); cComp->SaveAs("fastNLO_comparison/ratio_pp_ak3_merged_NLO_nnpdf21nlo.pdf","RECREATE"); TCanvas c1; c1.SetLogy(); hPPrebin->SetAxisRange(50,500,"X"); hPPrebin->SetYTitle("#sigma (pb)"); hPPrebin->SetXTitle("Jet p_{T} GeV/c"); hPPrebin->SetTitle("PP ak3PF unfolded"); hPPrebin->Draw(); c1.SaveAs("fastNLO_comparison/PP_2013_ak3_merged_Unfolded_crosssection.pdf","RECREATE"); c1.SaveAs("fastNLO_comparison/PP_2013_ak3_merged_Unfolded_crosssection.C","RECREATE"); TCanvas *c3 = new TCanvas("c3","",800,600); c3->SetGrid(); c3->SetLogy(); //TGraphErrors graph_Expected("./fastNLO_comparison/files/s2760_R0.3fine.tex","%lg %lg"); //graph_Expected.SetTitle("Non Perturbative corrections (extrapolation from Atlas) s2760;p_{T} GeV/c;#sigma nb"); //graph_Expected.DrawClone("E3AL"); TFile *fNPC = TFile::Open("fastNLO_comparison/files/npc_extrapolation_ivan.root"); TH1F* hNPC = (TH1F*)fNPC->Get("hNPC"); hNPC->Scale(1000);// 1000 for the pb from nb //hNPC->Print("base"); //TH1F* hNPC_rebin1 = rebin2(hNPC,"hNPC_rebin1"); //divideBinWidth(hNPC_rebin1); hNPC->SetTitle("Non Perturbative corrections (extrapolation from Atlas) s2760"); hNPC->SetXTitle("p_{T} GeV/c"); hNPC->SetYTitle("#sigma (pb)"); hNPC->Draw(); hPPrebin->Draw("same"); c3->SaveAs("fastNLO_comparison/NPC_atlas_ak3.pdf","RECREATE"); TCanvas *c4 = new TCanvas("c4","",800,600); c4->SetLogy(); //TH1F* hNPC_rebin = (TH1F*)hNPC->Clone("hNPC_rebin"); TH1F* hNPC_rebin = rebin2(hNPC,"hNPC_rebin"); divideBinWidth(hNPC_rebin); hPPrebin_2->SetTitle("PP Cross sections Data and Theory comparisons"); hPPrebin_2->SetYTitle("#sigma (pb)"); hPPrebin_2->SetXTitle("p_{T} GeV/c"); //hNPC_rebin->SetAxisRange(1e4,1e-2,"Y"); hPPrebin_2->SetMarkerStyle(23); hPPrebin_2->SetMarkerColor(kBlack); hPPrebin_2->SetAxisRange(50,450,"X"); hPPrebin_2->Draw("E"); //hPPrebin_2->SetAxisRange(50,450,"X"); hNPC_rebin->SetMarkerStyle(21); hNPC_rebin->SetMarkerColor(kRed); hNPC_rebin->Draw("same"); hNLO_2->SetMarkerStyle(25); hNLO_2->SetMarkerColor(kBlue); hNLO_2->Draw("same"); TLegend *title2 = myLegend(0.54,0.65,0.85,0.9); title2->AddEntry(hNPC_rebin,"Ivan NPC - Atlas R=0.3","pl"); title2->AddEntry(hPPrebin_2,"PP2013 ak3PF unfolded","pl"); title2->AddEntry(hNLO_2,"CMS NLO nnpdf21 R=0.3","l"); title2->SetTextSize(0.04); title2->Draw(); gStyle->SetOptStat(0); c4->SaveAs("fastNLO_comparison/pp_ak3_nlo_overlay_hist.pdf","RECREATE"); TCanvas *c6 = new TCanvas("c6","",800,600); TH1F* hPPratio = (TH1F*)hPPrebin_2->Clone("hPPratio"); //add the error bars directly before dividing them and then set that as the error. //FLoat_t delta_PP = 0; //Float_t delta_NPC = 0; //Float_t delta hPPratio->Divide(hNPC_rebin); hPPratio->SetTitle("Ratio of PP 2013 ak3 unfolded w/ Ivan's NPC Atlas"); hPPratio->SetYTitle(" "); hPPratio->SetXTitle("p_{T} GeV/c"); hPPratio->Draw(); c6->SaveAs("pp_ak3_npc_ratio.pdf","RECREATE"); TCanvas *c5 = new TCanvas("c5","",800,600); hNPC->Draw(); hNPC_rebin->Draw("same"); c5->SetLogy(); c5->SaveAs("Ivan_plot_rebin_ak3.pdf","RECREATE"); */ }
void plotDistribution( TChain* data , TChain *mc , TCut sel , TCut vtxweight , char* var , int nbins , float xmin , float xmax , char* xtitle , char* plottitle = "" , bool printplot = false , bool residual = false , bool log = false ){ //-------------------------------------- // define histograms and TGraphs //-------------------------------------- TH1F* hdata = new TH1F(Form("hdata_%i" , iplot),Form("hdata_%i" , iplot),nbins,xmin,xmax); TH1F* hmc = new TH1F(Form("hmc_%i" , iplot),Form("hmc_%i" , iplot),nbins,xmin,xmax); TH1F* hmc_novtx = new TH1F(Form("hmc_novtx_%i" , iplot),Form("hmc_novtx%i" , iplot),nbins,xmin,xmax); hdata->Sumw2(); hmc->Sumw2(); TGraphAsymmErrors* grdata = new TGraphAsymmErrors(); TGraphAsymmErrors* grmc = new TGraphAsymmErrors(); TH1F* hdata_denom = new TH1F(Form("hdata_denom_%i",iplot),"",nbins,xmin,xmax); TH1F* hmc_denom = new TH1F(Form("hmc_denom_%i" ,iplot),"",nbins,xmin,xmax); //-------------------------------------- // set up canvas and pads //-------------------------------------- TCanvas *can = new TCanvas(Form("can_%i",iplot),Form("can_%i",iplot),600,600); can->cd(); if( log ) gPad->SetLogy(); TPad *mainpad = new TPad("mainpad","mainpad",0.0,0.0,1.0,0.8); if( residual ){ mainpad->Draw(); mainpad->cd(); if( log ) mainpad->SetLogy(); } //-------------------------------------- // fill histos and TGraphs //-------------------------------------- data->Draw(Form("min(%s,%f)>>hdata_%i" , var,xmax-0.0001,iplot),sel); mc ->Draw(Form("min(%s,%f)>>hmc_%i" , var,xmax-0.0001,iplot),sel*vtxweight); mc ->Draw(Form("min(%s,%f)>>hmc_novtx_%i" , var,xmax-0.0001,iplot),sel); for( int ibin = 1 ; ibin <= nbins ; ibin++ ){ hdata_denom->SetBinContent(ibin,hdata->Integral()); hmc_denom->SetBinContent(ibin,hmc->Integral()); } grdata->BayesDivide(hdata,hdata_denom); grmc->BayesDivide(hmc_novtx,hmc_denom); //-------------------------------------- // get efficiencies and errors //-------------------------------------- /* float ndata1 = (float) hdata->GetBinContent(1); float ndata = (float) hdata->Integral(); float effdata = 1-ndata1 / ndata; // TGraphAsymmErrors* grdata_temp = new TGraphAsymmErrors(); // TH1F* hdata_num_temp = new TH1F(Form("hdata_num_temp_%i",iplot),"",1,0,1); // TH1F* hdata_den_temp = new TH1F(Form("hdata_den_temp_%i",iplot),"",1,0,1); // hdata_num_temp->SetBinContent(1,ndata-ndata1); // hdata_den_temp->SetBinContent(1,ndata); // grdata_temp->BayesDivide(hdata_num_temp,hdata_den_temp); //float effdataerr = sqrt(ndata1) / ndata; float effdataerr = 0.5 * ( grdata->GetErrorYlow(0) + grdata->GetErrorYhigh(0) ); //float effdataerr = 0.5 * ( grdata_temp->GetErrorYlow(0) + grdata_temp->GetErrorYhigh(0) ); float nmc1 = (float) hmc->GetBinContent(1); float nmc = (float) hmc->Integral(); float effmc = 1-nmc1 / nmc; //float effmcerr = hmc->GetBinError(1) / nmc; float effmcerr = 0.5 * ( grmc->GetErrorYlow(0) + grmc->GetErrorYhigh(0) ); float datatot = hdata->Integral(); float mctot = hmc->Integral(); cout << endl; cout << plottitle << endl; cout << "Data eff " << Form("%.2f +/- %.3f",effdata,effdataerr) << endl; cout << "MC eff " << Form("%.2f +/- %.3f",effmc ,effmcerr) << endl; cout << "Data/MC " << Form("%.2f +/- %.2f",ratio ,ratioerr) << endl; */ float ndata = hdata->Integral(); float ndata1 = hdata->Integral(2,20); float ndata2 = hdata->Integral(3,20); float ndata3 = hdata->Integral(4,20); float ndata4 = hdata->Integral(5,20); float ndata5 = hdata->Integral(6,20); float nmc = hmc->Integral(); float nmc1 = hmc->Integral(2,20); float nmc2 = hmc->Integral(3,20); float nmc3 = hmc->Integral(4,20); float nmc4 = hmc->Integral(5,20); float nmc5 = hmc->Integral(6,20); float effdata1 = ndata1/ndata; float effdata2 = ndata2/ndata; float effdata3 = ndata3/ndata; float effdata4 = ndata4/ndata; float effdata5 = ndata5/ndata; float effmc1 = nmc1/nmc; float effmc2 = nmc2/nmc; float effmc3 = nmc3/nmc; float effmc4 = nmc4/nmc; float effmc5 = nmc5/nmc; float effdata1err = getBinomialError(ndata1,ndata); float effdata2err = getBinomialError(ndata2,ndata); float effdata3err = getBinomialError(ndata3,ndata); float effdata4err = getBinomialError(ndata4,ndata); float effdata5err = getBinomialError(ndata5,ndata); float effmc1err = getBinomialError(nmc1,nmc); float effmc2err = getBinomialError(nmc2,nmc); float effmc3err = getBinomialError(nmc3,nmc); float effmc4err = getBinomialError(nmc4,nmc); float effmc5err = getBinomialError(nmc5,nmc); float ratio1 = effdata1/effmc1; float ratio2 = effdata2/effmc2; float ratio3 = effdata3/effmc3; float ratio4 = effdata4/effmc4; float ratio5 = effdata5/effmc5; float ratio1err = ratio1 * sqrt(pow(effdata1err/effdata1,2)+pow(effmc1err/effmc1,2)); float ratio2err = ratio2 * sqrt(pow(effdata2err/effdata2,2)+pow(effmc2err/effmc2,2)); float ratio3err = ratio3 * sqrt(pow(effdata3err/effdata3,2)+pow(effmc3err/effmc3,2)); float ratio4err = ratio4 * sqrt(pow(effdata4err/effdata4,2)+pow(effmc4err/effmc4,2)); float ratio5err = ratio5 * sqrt(pow(effdata5err/effdata5,2)+pow(effmc5err/effmc5,2)); cout << endl << endl << plottitle << endl; int left = 20; // char* delimstart = "|"; // char* delim = "|"; // char* delimend = "|"; // char* pm = "+/-"; char* delimstart = ""; char* delim = "&"; char* delimend = "\\\\"; char* pm = "$\\pm$"; cout << delimstart << setw(10) << "" << setw(4) << delim << setw(left) << "$>$ 1 GeV" << setw(4) << delim << setw(left) << "$>$ 2 GeV" << setw(4) << delim << setw(left) << "$>$ 3 GeV" << setw(4) << delim << setw(left) << "$>$ 4 GeV" << setw(4) << delim << setw(left) << "$>$ 5 GeV" << setw(4) << delimend << endl; cout << delimstart << setw(10) << "data" << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effdata1,pm,effdata1err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effdata2,pm,effdata2err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effdata3,pm,effdata3err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effdata4,pm,effdata4err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effdata5,pm,effdata5err) << setw(4) << delimend << endl; cout << delimstart << setw(10) << "mc" << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effmc1,pm,effmc1err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effmc2,pm,effmc2err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effmc3,pm,effmc3err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effmc4,pm,effmc4err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effmc5,pm,effmc5err) << setw(4) << delimend << endl; cout << delimstart << setw(10) << "data/mc" << setw(4) << delim << setw(left) << Form("%.2f %s %.2f",ratio1,pm,ratio1err) << setw(4) << delim << setw(left) << Form("%.2f %s %.2f",ratio2,pm,ratio2err) << setw(4) << delim << setw(left) << Form("%.2f %s %.2f",ratio3,pm,ratio3err) << setw(4) << delim << setw(left) << Form("%.2f %s %.2f",ratio4,pm,ratio4err) << setw(4) << delim << setw(left) << Form("%.2f %s %.2f",ratio5,pm,ratio5err) << setw(4) << delimend << endl; //-------------------------------------- // draw stuff //-------------------------------------- hdata->Scale(1.0/hdata->Integral()); hmc->Scale(1.0/hmc->Integral()); if( log ) hmc->GetYaxis()->SetRangeUser(0.0001,5); else hmc->GetYaxis()->SetRangeUser(0.0,1); hmc->GetXaxis()->SetTitle(xtitle); hmc->SetLineColor(2); hmc->SetMarkerColor(2); hmc->DrawNormalized("hist"); hmc->DrawNormalized("sameE1"); hdata->SetLineColor(4); hdata->SetMarkerColor(4); hdata->Draw("sameE1"); grdata->SetLineColor(6); grmc->SetLineColor(7); //grdata->Draw("sameP"); //grmc->Draw("sameP"); TLegend *leg = new TLegend(0.6,0.7,0.8,0.9); leg->AddEntry(hdata , "data" , "lp"); leg->AddEntry(hmc , "MC" , "lp"); leg->SetBorderSize(0); leg->SetFillColor(0); leg->Draw(); TLatex *t = new TLatex(); t->SetNDC(); if( TString(plottitle).Contains("el") ) t->DrawLatex(0.6,0.6,"electrons"); if( TString(plottitle).Contains("mu") ) t->DrawLatex(0.6,0.6,"muons"); if( TString(plottitle).Contains("0j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 0"); if( TString(plottitle).Contains("1j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 1"); if( TString(plottitle).Contains("2j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 2"); if( TString(plottitle).Contains("3j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 3"); if( TString(plottitle).Contains("4j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 4"); //-------------------------------------- // draw residual plots //-------------------------------------- if( residual ){ can->cd(); TPad *respad = new TPad("respad","respad",0.0,0.8,1.0,1.0); respad->Draw(); respad->cd(); respad->SetGridy(); TH1F* hratio = (TH1F*) hdata->Clone(Form("hratio_%i",iplot)); hratio->Divide(hmc); hratio->SetMarkerColor(1); hratio->SetLineColor(1); hratio->Draw(); hratio->GetYaxis()->SetRangeUser(0.5,1.5); hratio->GetYaxis()->SetNdivisions(5); hratio->GetYaxis()->SetLabelSize(0.2); hratio->GetXaxis()->SetLabelSize(0.0); TLine line; line.DrawLine(xmin,1.0,xmax,1.0); } //data->Scan("run:lumi:event:probe->pt():probe->eta():tkisonew:met:mt:njets:nbl:nbm",sel+"tkisonew>20"); //data->Scan("run:lumi:event:probe->pt():probe->eta():tkisonew:met:mt:njets:nbl:nbm",sel); if( printplot ) can->Print(Form("plots/%s.pdf",plottitle)); iplot++; // TCanvas *c2 = new TCanvas(); // c2->cd(); // grdata->Draw("AP"); }
void DeltaPhiPhoMETMax(double pt1_cutIN,double pt2_cutIN,double MET_cutIN, double DPHI_cutIN){ cout<<"#### Max[DeltaPhi(MET,pho1),DeltaPhi(MET,pho2)] #####"<<endl; gStyle->SetPadTickY(1); gStyle->SetPadTickX(1); TLegend* leg = new TLegend(0.13,0.55,0.68,0.87); leg->SetNColumns(2); leg->SetBorderSize(0); leg->SetFillStyle(0); TLegend* leg_norm = new TLegend(0.13,0.5,0.7,0.87); leg_norm->SetNColumns(2); leg_norm->SetBorderSize(0); leg_norm->SetFillStyle(0); TCanvas *canvas = new TCanvas("c1n","",1100,500); canvas->Divide(2,1); canvas->cd(1); TCut mggmax = "mgg<180"; TCut mggmin = "mgg>100"; TCut mggblind = "((mgg<115)||(mgg>135))"; TCut eveto1 = "eleveto1 == 1"; TCut eveto2 = "eleveto2 == 1"; TCut eveto = eveto1 && eveto2; TCut genmatch = "((genmatch1==1 && genmatch2==0)||(genmatch1==0 && genmatch2==1)||(genmatch1==0 && genmatch2==0))"; TCut metF = "((metF_GV==1) && (metF_HBHENoise==1) && (metF_HBHENoiseIso==1) && (metF_CSC==1) && (metF_eeBadSC==1))"; TCut pt1cut = Form("pt1/mgg>%lf",pt1_cutIN); TCut pt2cut = Form("pt2/mgg>%lf",pt2_cutIN); TCut METcut = Form("t1pfmet>%lf",MET_cutIN); TCut DPHIcut = Form("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhi)>%lf",DPHI_cutIN); TCut NegWeight = "weight>0."; TFile *data = TFile::Open("./25ns_2246inv_v3/DoubleEG.root","READ"); TFile *sig1 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP600.root","READ"); TFile *sig2 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP800.root","READ"); TFile *sig3 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1000.root","READ"); TFile *sig4 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1200.root","READ"); TFile *sig5 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1400.root","READ"); TFile *sig6 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1700.root","READ"); TFile *sig7 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP2500.root","READ"); TFile *bkg1 = TFile::Open("./25ns_2246inv_v3/DiPhoton.root","READ"); TFile *bkg2 = TFile::Open("./25ns_2246inv_v3/DYJetsToLL.root","READ"); TFile *bkg3 = TFile::Open("./25ns_2246inv_v3/GJets.root","READ"); TFile *bkg4 = TFile::Open("./25ns_2246inv_v3/GluGluHToGG.root","READ"); TFile *bkg5 = TFile::Open("./25ns_2246inv_v3/QCD.root","READ"); TFile *bkg6 = TFile::Open("./25ns_2246inv_v3/VH.root","READ"); TFile *bkg7 = TFile::Open("./25ns_2246inv_v3/ttHJetToGG.root","READ"); TFile *bkg8 = TFile::Open("./25ns_2246inv_v3/VBFHToGG.root","READ"); TFile *bkg9 = TFile::Open("./25ns_2246inv_v3/TGJets.root","READ"); TFile *bkg10 = TFile::Open("./25ns_2246inv_v3/TTGJets.root","READ"); TFile *bkg11 = TFile::Open("./25ns_2246inv_v3/WGToLNuG.root","READ"); TFile *bkg12 = TFile::Open("./25ns_2246inv_v3/ZGTo2LG.root","READ"); TTree *tree_data = (TTree*) data->Get("DiPhotonTree"); TTree *tree_sig1 = (TTree*) sig1->Get("DiPhotonTree"); TTree *tree_sig2 = (TTree*) sig2->Get("DiPhotonTree"); TTree *tree_sig3 = (TTree*) sig3->Get("DiPhotonTree"); TTree *tree_sig4 = (TTree*) sig4->Get("DiPhotonTree"); TTree *tree_sig5 = (TTree*) sig5->Get("DiPhotonTree"); TTree *tree_sig6 = (TTree*) sig6->Get("DiPhotonTree"); TTree *tree_sig7 = (TTree*) sig7->Get("DiPhotonTree"); TTree *tree_bkg1 = (TTree*) bkg1->Get("DiPhotonTree"); TTree *tree_bkg2 = (TTree*) bkg2->Get("DiPhotonTree"); TTree *tree_bkg3 = (TTree*) bkg3->Get("DiPhotonTree"); TTree *tree_bkg4 = (TTree*) bkg4->Get("DiPhotonTree"); TTree *tree_bkg5 = (TTree*) bkg5->Get("DiPhotonTree"); TTree *tree_bkg6 = (TTree*) bkg6->Get("DiPhotonTree"); TTree *tree_bkg7 = (TTree*) bkg7->Get("DiPhotonTree"); TTree *tree_bkg8 = (TTree*) bkg8->Get("DiPhotonTree"); TTree *tree_bkg9 = (TTree*) bkg9->Get("DiPhotonTree"); TTree *tree_bkg10 = (TTree*) bkg10->Get("DiPhotonTree"); TTree *tree_bkg11 = (TTree*) bkg11->Get("DiPhotonTree"); TTree *tree_bkg12 = (TTree*) bkg12->Get("DiPhotonTree"); tree_data->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hdata(25,0,3.5)",(mggblind && mggmax && mggmin && metF && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hdata =(TH1F*)gPad->GetPrimitive("hdata"); hdata->SetMarkerColor(kBlack); hdata->SetMarkerStyle(20); hdata->SetLineColor(kBlack); tree_sig1->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h1(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h1 =(TH1F*)gPad->GetPrimitive("h1"); tree_sig2->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h2(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h2 =(TH1F*)gPad->GetPrimitive("h2"); tree_sig3->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h3(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h3 =(TH1F*)gPad->GetPrimitive("h3"); tree_sig4->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h4(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h4 =(TH1F*)gPad->GetPrimitive("h4"); tree_sig5->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h5(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h5 =(TH1F*)gPad->GetPrimitive("h5"); tree_sig6->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h6(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h6 =(TH1F*)gPad->GetPrimitive("h6"); tree_sig7->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h7(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h7 =(TH1F*)gPad->GetPrimitive("h7"); tree_bkg1->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg1(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg1 =(TH1F*)gPad->GetPrimitive("hbkg1"); tree_bkg2->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg2(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg2 =(TH1F*)gPad->GetPrimitive("hbkg2"); tree_bkg3->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg3(25,0,3.5)","weight"*(mggmax && mggmin && eveto && genmatch && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg3 =(TH1F*)gPad->GetPrimitive("hbkg3"); tree_bkg4->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg4(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg4 =(TH1F*)gPad->GetPrimitive("hbkg4"); tree_bkg5->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg5(25,0,3.5)","weight"*(mggmax && mggmin && eveto && genmatch && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg5 =(TH1F*)gPad->GetPrimitive("hbkg5"); tree_bkg6->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg6(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg6 =(TH1F*)gPad->GetPrimitive("hbkg6"); tree_bkg7->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg7(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg7 =(TH1F*)gPad->GetPrimitive("hbkg7"); tree_bkg8->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg8(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg8 =(TH1F*)gPad->GetPrimitive("hbkg8"); tree_bkg9->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg9(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut && NegWeight)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg9 =(TH1F*)gPad->GetPrimitive("hbkg9"); tree_bkg10->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg10(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg10 =(TH1F*)gPad->GetPrimitive("hbkg10"); tree_bkg11->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg11(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg11 =(TH1F*)gPad->GetPrimitive("hbkg11"); tree_bkg12->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg12(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg12 =(TH1F*)gPad->GetPrimitive("hbkg12"); /* h1->Scale(0.00009338); h2->Scale(0.00010348); h3->Scale(0.00008394); h4->Scale(0.00006352); h5->Scale(0.00004712); h6->Scale(0.00003020); h7->Scale(0.00000972); */ h1->SetLineColor(kRed+3); h2->SetLineColor(kRed+1); h3->SetLineColor(kRed); h4->SetLineColor(kPink+2); h5->SetLineColor(kPink+4); //only for 25ns samples h6->SetLineColor(kPink+7); //only for 25ns samples h7->SetLineColor(kMagenta+2); //only for 25ns samples h1->SetLineWidth(2); h2->SetLineWidth(2); h3->SetLineWidth(2); h4->SetLineWidth(2); h5->SetLineWidth(2); //only for 25ns samples h6->SetLineWidth(2); //only for 25ns samples h7->SetLineWidth(2); //only for 25ns samples THStack *hs=new THStack("hs",""); hbkg7->SetFillColor(kGreen+2); hbkg6->SetFillColor(kGreen); hbkg8->SetFillColor(kYellow); hbkg4->SetFillColor(kOrange); hbkg9->SetFillColor(kOrange+7); hbkg10->SetFillColor(kOrange+4); hbkg11->SetFillColor(kCyan); hbkg12->SetFillColor(kCyan+1); hbkg5->SetFillColor(kBlue+3); hbkg2->SetFillColor(kBlue); hbkg3->SetFillColor(kMagenta-2); hbkg1->SetFillColor(kViolet); hbkg1->SetLineColor(kBlack); hbkg2->SetLineColor(kBlack); hbkg3->SetLineColor(kBlack); hbkg4->SetLineColor(kBlack); hbkg5->SetLineColor(kBlack); hbkg6->SetLineColor(kBlack); hbkg7->SetLineColor(kBlack); hbkg8->SetLineColor(kBlack); hbkg9->SetLineColor(kBlack); hbkg10->SetLineColor(kBlack); hbkg11->SetLineColor(kBlack); hbkg12->SetLineColor(kBlack); hs->Add(hbkg7); hs->Add(hbkg6); hs->Add(hbkg8); hs->Add(hbkg4); hs->Add(hbkg9); hs->Add(hbkg10); hs->Add(hbkg11); hs->Add(hbkg12); hs->Add(hbkg2); hs->Add(hbkg5); hs->Add(hbkg3); hs->Add(hbkg1); TH1F *hsum = (TH1F*)hbkg1->Clone("hsum"); hsum->Add(hbkg2); hsum->Add(hbkg3); hsum->Add(hbkg4); hsum->Add(hbkg5); hsum->Add(hbkg6); hsum->Add(hbkg7); hsum->Add(hbkg8); hsum->Add(hbkg9); hsum->Add(hbkg10); hsum->Add(hbkg11); hsum->Add(hbkg12); // hs->SetMaximum(700); // hs->SetMinimum(0.0001); hdata->SetTitle(""); hdata->Draw("e1"); hsum->SetMarkerStyle(1); hsum->SetFillColor(kGray+3); hsum->SetFillStyle(3001); hs->Draw("same hist"); hsum->Draw("same e2"); h2->Draw("same hist"); h3->Draw("same hist"); h4->Draw("same hist"); h1->Draw("same hist"); h5->Draw("same hist"); //only for 25ns samples h6->Draw("same hist"); //only for 25ns samples h7->Draw("same hist"); //only for 25ns samples hdata->Draw("same e1"); hdata->GetXaxis()->SetTitle("max[|#Delta#phi(#gamma_{1},MET)|,|#Delta#phi(#gamma_{2},MET)|]"); hdata->GetYaxis()->SetTitleOffset(1.2); hdata->GetYaxis()->SetTitle("Events/0.1 GeV"); gPad->Modified(); /*leg->AddEntry(h1,"m_{#chi} = 1 GeV","l"); leg->AddEntry(h2,"m_{#chi} = 10 GeV","l"); leg->AddEntry(h3,"m_{#chi} = 100 GeV","l"); leg->AddEntry(h4,"m_{#chi} = 1000 GeV","l");*/ leg->AddEntry(hdata,"Data","elp"); leg->AddEntry(h1,"m_{Z'} = 600 GeV","l"); leg->AddEntry(hbkg1,"#gamma #gamma","f"); leg->AddEntry(h2,"m_{Z'} = 800 GeV","l"); leg->AddEntry(hbkg2,"Drell Yann","f"); leg->AddEntry(h3,"m_{Z'} = 1000 GeV","l"); leg->AddEntry(hbkg3,"#gamma + Jets","f"); leg->AddEntry(h4,"m_{Z'} = 1200 GeV","l"); leg->AddEntry(hbkg5,"QCD","f"); leg->AddEntry(h5,"m_{Z'} = 1400 GeV","l"); //only for 25ns samples leg->AddEntry(hbkg4,"ggH","f"); leg->AddEntry(h6,"m_{Z'} = 1700 GeV","l"); //only for 25ns samples leg->AddEntry(hbkg6,"VH","f"); leg->AddEntry(h7,"m_{Z'} = 2500 GeV","l"); //only for 25ns samples leg->AddEntry(hbkg7,"ttH","f"); leg->AddEntry(hbkg8,"VBF H","f"); leg->AddEntry(hbkg9,"t + #gamma + Jets","f"); leg->AddEntry(hbkg10,"tt + #gamma +Jets","f"); leg->AddEntry(hbkg11,"#gamma+W","f"); leg->AddEntry(hbkg12,"#gamma+Z","f"); leg->AddEntry(hsum,"Bkg uncertainty","f"); leg->Draw("same"); gStyle->SetOptStat(0); tree_data->Scan("event:lumi:run:t1pfmet",(mggblind && METcut && metF && pt1cut && pt2cut)*"max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>2.5"); canvas->cd(2); tree_sig1->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h1_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h1_norm =(TH1F*)gPad->GetPrimitive("h1_norm"); tree_sig2->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h2_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h2_norm =(TH1F*)gPad->GetPrimitive("h2_norm"); tree_sig3->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h3_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h3_norm =(TH1F*)gPad->GetPrimitive("h3_norm"); tree_sig4->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h4_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h4_norm =(TH1F*)gPad->GetPrimitive("h4_norm"); tree_sig5->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h5_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h5_norm =(TH1F*)gPad->GetPrimitive("h5_norm"); tree_sig6->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h6_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h6_norm =(TH1F*)gPad->GetPrimitive("h6_norm"); tree_sig7->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h7_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *h7_norm =(TH1F*)gPad->GetPrimitive("h7_norm"); tree_bkg1->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg1_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg1_norm =(TH1F*)gPad->GetPrimitive("hbkg1_norm"); tree_bkg2->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg2_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg2_norm =(TH1F*)gPad->GetPrimitive("hbkg2_norm"); tree_bkg3->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg3_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && genmatch && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg3_norm =(TH1F*)gPad->GetPrimitive("hbkg3_norm"); tree_bkg4->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg4_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg4_norm =(TH1F*)gPad->GetPrimitive("hbkg4_norm"); tree_bkg5->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg5_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && genmatch && pt1cut && pt2cut && METcut&& DPHIcut)); TH1F *hbkg5_norm =(TH1F*)gPad->GetPrimitive("hbkg5_norm"); tree_bkg6->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg6_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg6_norm =(TH1F*)gPad->GetPrimitive("hbkg6_norm"); tree_bkg7->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg7_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg7_norm =(TH1F*)gPad->GetPrimitive("hbkg7_norm"); tree_bkg8->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg8_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg8_norm =(TH1F*)gPad->GetPrimitive("hbkg8_norm"); tree_bkg9->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg9_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut && NegWeight)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg9_norm =(TH1F*)gPad->GetPrimitive("hbkg9_norm"); tree_bkg10->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg10_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg10_norm =(TH1F*)gPad->GetPrimitive("hbkg10_norm"); tree_bkg11->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg11_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg11_norm =(TH1F*)gPad->GetPrimitive("hbkg11_norm"); tree_bkg12->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg12_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples TH1F *hbkg12_norm =(TH1F*)gPad->GetPrimitive("hbkg12_norm"); double norm = 1./h1_norm->Integral(); h1_norm->Scale(norm); norm = 1./h2_norm->Integral(); h2_norm->Scale(norm); norm = 1./h3_norm->Integral(); h3_norm->Scale(norm); norm = 1./h4_norm->Integral(); h4_norm->Scale(norm); norm = 1./h5_norm->Integral(); //only for 50ns samples h5_norm->Scale(norm); //only for 50ns samples norm = 1./h6_norm->Integral(); //only for 50ns samples h6_norm->Scale(norm); //only for 50ns samples norm = 1./h7_norm->Integral(); //only for 50ns samples h7_norm->Scale(norm); //only for 50ns samples norm = 1./hbkg1_norm->Integral(); hbkg1_norm->Scale(norm); norm = 1./hbkg2_norm->Integral(); hbkg2_norm->Scale(norm); norm = 1./hbkg3_norm->Integral(); hbkg3_norm->Scale(norm); norm = 1./hbkg4_norm->Integral(); hbkg4_norm->Scale(norm); norm = 1./hbkg5_norm->Integral(); hbkg5_norm->Scale(norm); norm = 1./hbkg6_norm->Integral(); hbkg6_norm->Scale(norm); norm = 1./hbkg7_norm->Integral(); hbkg7_norm->Scale(norm); norm = 1./hbkg8_norm->Integral(); hbkg8_norm->Scale(norm); norm = 1./hbkg9_norm->Integral(); hbkg9_norm->Scale(norm); norm = 1./hbkg10_norm->Integral(); hbkg10_norm->Scale(norm); norm = 1./hbkg11_norm->Integral(); hbkg11_norm->Scale(norm); norm = 1./hbkg12_norm->Integral(); hbkg12_norm->Scale(norm); h1_norm->SetLineColor(kRed+3); h2_norm->SetLineColor(kRed+1); h3_norm->SetLineColor(kRed); h4_norm->SetLineColor(kPink+2); h5_norm->SetLineColor(kPink+4); //only for 25ns samples h6_norm->SetLineColor(kPink+7); //only for 25ns samples h7_norm->SetLineColor(kMagenta+2); //only for 25ns samples h1_norm->SetLineWidth(2); h2_norm->SetLineWidth(2); h3_norm->SetLineWidth(2); h4_norm->SetLineWidth(2); h5_norm->SetLineWidth(2); //only for 25ns samples h6_norm->SetLineWidth(2); //only for 25ns samples h7_norm->SetLineWidth(2); //only for 25ns samples hbkg7_norm->SetLineColor(kGreen+2); hbkg6_norm->SetLineColor(kGreen); hbkg8_norm->SetLineColor(kYellow); hbkg4_norm->SetLineColor(kOrange); hbkg9_norm->SetLineColor(kOrange+7); hbkg10_norm->SetLineColor(kOrange+4); hbkg11_norm->SetLineColor(kCyan); hbkg12_norm->SetLineColor(kCyan+1); hbkg5_norm->SetLineColor(kBlue+3); hbkg2_norm->SetLineColor(kBlue); hbkg3_norm->SetLineColor(kMagenta-2); hbkg1_norm->SetLineColor(kViolet); hbkg1_norm->SetFillStyle(0); hbkg2_norm->SetFillStyle(0); hbkg3_norm->SetFillStyle(0); hbkg4_norm->SetFillStyle(0); hbkg5_norm->SetFillStyle(0); hbkg6_norm->SetFillStyle(0); hbkg7_norm->SetFillStyle(0); hbkg8_norm->SetFillStyle(0); hbkg9_norm->SetFillStyle(0); hbkg10_norm->SetFillStyle(0); hbkg11_norm->SetFillStyle(0); hbkg12_norm->SetFillStyle(0); h1_norm->SetTitle(""); h1_norm->SetMaximum(1); h1_norm->SetMinimum(0.001); h1_norm->Draw("HIST"); hbkg1_norm->Draw("same HIST"); hbkg2_norm->Draw("same HIST"); hbkg3_norm->Draw("same HIST"); hbkg5_norm->Draw("same HIST"); hbkg4_norm->Draw("same HIST"); hbkg6_norm->Draw("same HIST"); hbkg7_norm->Draw("same HIST"); hbkg8_norm->Draw("same HIST"); hbkg9_norm->Draw("same HIST"); hbkg10_norm->Draw("same HIST"); hbkg11_norm->Draw("same HIST"); hbkg12_norm->Draw("same HIST"); h1_norm->Draw("same hist"); h2_norm->Draw("same hist"); h3_norm->Draw("same hist"); h4_norm->Draw("same hist"); h5_norm->Draw("same hist"); h6_norm->Draw("same hist"); h7_norm->Draw("same hist"); h1_norm->GetXaxis()->SetTitle("max[|#Delta#phi(#gamma_{1},MET)|,|#Delta#phi(#gamma_{2},MET)|]"); h1_norm->GetYaxis()->SetTitle("Normalized events"); h1_norm->GetYaxis()->SetTitleOffset(1.2); gPad->Modified(); gStyle->SetOptStat(0); leg_norm->AddEntry(h1_norm,"m_{Z'} = 600 GeV","l"); leg_norm->AddEntry(hbkg1_norm,"#gamma #gamma","l"); leg_norm->AddEntry(h2_norm,"m_{Z'} = 800 GeV","l"); leg_norm->AddEntry(hbkg2_norm,"Drell Yann","l"); leg_norm->AddEntry(h3_norm,"m_{Z'} = 1000 GeV","l"); leg_norm->AddEntry(hbkg3_norm,"#gamma + Jets","l"); leg_norm->AddEntry(h4_norm,"m_{Z'} = 1200 GeV","l"); leg_norm->AddEntry(hbkg5_norm,"QCD","l"); leg_norm->AddEntry(h5_norm,"m_{Z'} = 1400 GeV","l"); //only for 25ns samples leg_norm->AddEntry(hbkg4_norm,"ggH","l"); leg_norm->AddEntry(h6_norm,"m_{Z'} = 1700 GeV","l"); //only for 25ns samples leg_norm->AddEntry(hbkg6_norm,"VH","l"); leg_norm->AddEntry(h7_norm,"m_{Z'} = 2500 GeV","l"); //only for 25ns samples leg_norm->AddEntry(hbkg7_norm,"ttH","l"); leg_norm->AddEntry(hbkg8_norm,"VBF H","l"); leg_norm->AddEntry(hbkg9_norm,"t + #gamma + Jets","l"); leg_norm->AddEntry(hbkg10_norm,"tt + #gamma +Jets","l"); leg_norm->AddEntry(hbkg11_norm,"#gamma+W","l"); leg_norm->AddEntry(hbkg12_norm,"#gamma+Z","l"); leg_norm->Draw("same"); TPad *p1 = ((TPad*)(canvas->GetPad(1))); TPad *p2 = ((TPad*)(canvas->GetPad(2))); // int iPos =0; // CMS_lumi(p1,true,iPos,true); //CMS_lumi(p2,true,iPos,true); if(pt1_cutIN==0 && pt2_cutIN == 0 && MET_cutIN == 0){ canvas->SaveAs("./25ns_2246inv_v3/plots/kinematics/DeltaPhiMax_Pho_MET.png"); canvas->SaveAs("./25ns_2246inv_v3/plots/kinematics/DeltaPhiMax_Pho_MET.pdf"); } if(pt1_cutIN==0.65 && pt2_cutIN == 0.25){ canvas->SaveAs(Form("./25ns_2246inv_v3/plots/kinematics/DeltaPhiMax_Pho_MET_optcuts_MET%.0lf.png",MET_cutIN)); canvas->SaveAs(Form("./25ns_2246inv_v3/plots/kinematics/DeltaPhiMax_Pho_MET_optcuts_MET%.0lf.pdf",MET_cutIN)); } }
void merge_pbpb_pp_HLT(){ TH1::SetDefaultSumw2(); //TFile *fpbpb1 = TFile::Open("/mnt/hadoop/cms/store/user/rkunnawa/rootfiles/PbPb/2011/data/ntuple_2011_pbpbJet80_v2.root"); //TFile *fpbpb2 = TFile::Open("/mnt/hadoop/cms/store/user/rkunnawa/rootfiles/PbPb/2011/data/ntuple_2011_pbpbJet65_v2.root"); //TFile *fpbpb3 = TFile::Open("/mnt/hadoop/cms/store/user/rkunnawa/rootfiles/PbPb/2011/data/ntuple_2011_pbpbJet55_v2.root"); //TFile *fpp1 = TFile::Open("/mnt/hadoop/cms/store/user/rkunnawa/rootfiles/PP/2013/data/ntuple_2013_ppJet80.root"); //TFile *fpp2 = TFile::Open("/mnt/hadoop/cms/store/user/rkunnawa/rootfiles/PP/2013/data/ntuple_2013_ppJet40.root"); TFile *fpp1_v2 = TFile::Open("/mnt/hadoop/cms/store/user/rkunnawa/rootfiles/PP/2013/data/ntuple_2013_JEC_applied_ppJet80_v2.root"); TFile *fpp2_v2 = TFile::Open("/mnt/hadoop/cms/store/user/rkunnawa/rootfiles/PP/2013/data/ntuple_2013_JEC_applied_ppJet40_v2.root"); /* TTree *jetpbpb1_v2 = (TTree*)fpbpb1->Get("jetR3"); TTree *jetpbpb2_v2 = (TTree*)fpbpb2->Get("jetR3"); TTree *jetpbpb3_v2 = (TTree*)fpbpb3->Get("jetR3"); TTree *evtpbpb1_v2 = (TTree*)fpbpb1->Get("evt"); TTree *evtpbpb2_v2 = (TTree*)fpbpb2->Get("evt"); TTree *evtpbpb3_v2 = (TTree*)fpbpb3->Get("evt"); jetpbpb1_v2->AddFriend(evtpbpb1_v2); jetpbpb2_v2->AddFriend(evtpbpb2_v2); jetpbpb3_v2->AddFriend(evtpbpb3_v2); */ //TTree *jetpp1 = (TTree*)fpp1->Get("ntjet"); // TTree *jetpp2 = (TTree*)fpp2->Get("ntjet"); TTree *jetpp1_v2 = (TTree*)fpp1_v2->Get("jetR3"); TTree *jetpp2_v2 = (TTree*)fpp2_v2->Get("jetR3"); TTree *evtpp1_v2 = (TTree*)fpp1_v2->Get("evt"); TTree *evtpp2_v2 = (TTree*)fpp2_v2->Get("evt"); jetpp1_v2->AddFriend(evtpp1_v2); jetpp2_v2->AddFriend(evtpp2_v2); //TCut pbpb3 = "abs(eta)<2&&jet55&&!jet65&&!jet80&&chMax/pt>0.01"; TCut pp3 = "abs(eta)<2&&jet40&&!jet60&&!jet80&&chMax/pt>0.01"; //TH1F *hpbpb1 = new TH1F("hpbpb1","",30,0,300); //TH1F *hpbpb2 = new TH1F("hpbpb2","",30,0,300); //TH1F *hpbpb3 = new TH1F("hpbpb3","",30,0,300); //TH1F *hpbpbComb = new TH1F("hpbpbComb","",30,0,300); TH1F *hpp1 = new TH1F("hpp1","",nbins_jetPtBin,boundaries_jetPtBin); TH1F *hpp2 = new TH1F("hpp2","",nbins_jetPtBin,boundaries_jetPtBin); TH1F *hpp3 = new TH1F("hpp3","",nbins_jetPtBin,boundaries_jetPtBin); TH1F *hppComb = new TH1F("hppComb","",nbins_jetPtBin,boundaries_jetPtBin); //get the prescl factor information. //Float_t presclpbpb3 = (Float_t)jetpbpb1_v2->GetEntries("jet80")/jetpbpb1_v2->GetEntries("jet55&&jet80"); //cout<<"pbpb prescl3 = "<<presclpbpb3<<endl;//1.99871 Float_t presclpp3 = (Float_t)jetpp1_v2->GetEntries("jet80")/jetpp1_v2->GetEntries("jet40&&jet80"); cout<<"pp prescl3 = "<<presclpp3<<endl; //9.24968 /* jetpbpb1_v2->Project("hpbpb1","pt","abs(eta)<2&&jet80&&chMax/pt>0.01"); hpbpb1->Print("base"); divideBinWidth(hpbpb1); jetpbpb2_v2->Project("hpbpb2","pt","abs(eta)<2&&jet65&&!jet80&&chMax/pt>0.01"); hpbpb2->Print("base"); divideBinWidth(hpbpb2); jetpbpb3_v2->Project("hpbpb3","pt","1.9987"*pbpb3); hpbpb3->Print("base"); divideBinWidth(hpbpb3); */ jetpp1_v2->Project("hpp1","pt","abs(eta)<2&&jet80&&chMax/pt>0.01"); hpp1->Print("base"); //divideBinWidth(hpp1); //hpp1->Scale(1./3.083e11); //hpp1->Scale(1./4); jetpp2_v2->Project("hpp2","pt","abs(eta)<2&&jet60&&!jet80&&chMax/pt>0.01"); hpp2->Print("base"); //divideBinWidth(hpp2); //hpp2->Scale(1./3.083e11); //hpp2->Scale(1./4); jetpp2_v2->Project("hpp3","pt","9.25038"*pp3); //9.25038 - ak5 //9.24955 - ak4 //9.24968 - ak3 hpp3->Print("base"); //divideBinWidth(hpp3); //hpp3->Scale(1./3.083e11); //hpp3->Scale(1./4); //scale the PbPb histograms before adding them //we have to scale them according to the lumi of the Jet80 file. // HLT file | Lumi // HLT_80 | 150 mub-1 // HLT_65 | 12.1 mub-1 // HLT_55 | 0.38 mub-1 // // therefore scale for HLT_55 = 150/0.38 = 394.73684 // scale for HLT_65 = 150/12.1 = 12.3967 //hpbpb2->Scale(12.3867); //hpbpb3->Scale(394.7368); //add the histograms /* hpbpbComb->Add(hpbpb1,1); hpbpbComb->Add(hpbpb2,1); hpbpbComb->Add(hpbpb3,1); hpbpbComb->Print("base"); */ hppComb->Add(hpp1,1); hppComb->Add(hpp2,1); hppComb->Add(hpp3,1); hppComb->Print("base"); /* TCanvas *c1 = new TCanvas("c1","",800,600); c1->SetLogy(); hpbpbComb->SetMarkerStyle(29); //hpbpbComb->SetYTitle("#frac{dN}{N_{MB} d p_{T} d #eta}"); hpbpbComb->SetYTitle("counts"); hpbpbComb->SetXTitle("Jet p_{T} GeV/c"); TF1 *fPowerLaw = new TF1("fPowerLaw","[0]*pow(x+[1],[2])"); hpbpbComb->Fit("fPowerLaw","","",30,300); hpbpbComb->Fit("fPowerLaw","","",30,300); hpbpbComb->Fit("fPowerLaw","","",30,300); hpbpbComb->Fit("fPowerLaw","","",30,300); hpbpbComb->Fit("fPowerLaw","","",30,300); hpbpbComb->Fit("fPowerLaw","","",30,300); hpbpbComb->Fit("fPowerLaw","","",30,300); hpbpbComb->Draw(); hpbpb3->SetMarkerStyle(24); hpbpb3->SetMarkerColor(kRed); hpbpb3->Draw("same"); hpbpb2->SetMarkerStyle(25); hpbpb2->SetMarkerColor(kBlue); hpbpb2->Draw("same"); hpbpb1->SetMarkerStyle(26); hpbpb1->SetMarkerColor(kGreen); hpbpb1->Draw("same"); TLegend *title = myLegend(0.54,0.65,0.85,0.9); title->AddEntry(hpbpbComb,"PbPb Merged","pl"); title->AddEntry(hpbpb3,"w_{3} * (HLT_55 && !HLT_65 && !HLT_80)","pl"); title->AddEntry(hpbpb2,"HLT_65 && !HLT_80","pl"); title->AddEntry(hpbpb1,"HLT_80","pl"); title->SetTextSize(0.03); title->Draw(); drawText("PbPb 2011, 55,65 scaled",0.3,0.65,20); drawText("Anti-k_{T} PU PF Jets R = 0.3, |#eta|<2, |vz|<15",0.3,0.56,20); c1->SaveAs("pbpb_2013_pt_combined.gif","RECREATE"); */ //plot the statistical uncertainty here //statistical error/meanvalue as a function of pt for the combined spectra. /* TCanvas *c2 = new TCanvas("c2","",800,600); //TH1F* hPbPb_Uncert = (TH1F*)hpbpbComb->Clone("hPbPb_Uncert"); TH1F* hPbPb_Uncert = new TH1F("hPbPb_Uncert","",30,0,300); for(int i = 1;i<=hpbpbComb->GetNbinsX();i++){ double val = hpbpbComb->GetBinContent(i); double valErr = hpbpbComb->GetBinError(i); double uncert = (double)valErr/val; cout<<"uncert = "<<uncert<<endl; hPbPb_Uncert->SetBinContent(i,uncert); hPbPb_Uncert->SetBinError(i,0); } hPbPb_Uncert->SetYTitle("uncertainty"); hPbPb_Uncert->SetXTitle("p_{T} GeV/c"); hPbPb_Uncert->Draw(); drawText("PbPb 2011, 55,65 scaled",0.3,0.65,20); drawText("Anti-k_{T} PU PF Jets R = 0.3, |#eta|<2, |vz|<15",0.3,0.56,20); c2->SaveAs("pbpb_2013_hlt_merge_scaled_uncert.gif","RECREATE"); */ TCanvas *c2 = new TCanvas("c2","",800,600); c2->SetLogy(); TH1F* hPPComb = (TH1F*)hppComb->Clone("hPPComb"); //TH1F* hPPComb_bins = rebin_yaxian(hppComb,"hPPComb_bins"); hPPComb->Scale(1./3.083e11); hPPComb->Print("base"); hPPComb->SetYTitle("#frac{dN}{N_{MB} d p_{T} d #eta}"); hPPComb->SetXTitle("Jet p_{T} GeV/c"); //hPPComb_bins->Scale(1./3.083e11); //hPPComb_bins->Print("base"); //hPPComb_bins->Scale(1./4); //divideBinWidth(hPPComb_bins); hPPComb->Scale(1./4); divideBinWidth(hPPComb); TF1 *fPowerLaw = new TF1("fPowerLaw","[0]/pow(x,[1])"); hPPComb->Fit("fPowerLaw","","",25,500); hPPComb->Fit("fPowerLaw","","",25,500); hPPComb->Fit("fPowerLaw","","",25,500); hPPComb->Fit("fPowerLaw","","",25,500); hPPComb->Fit("fPowerLaw","","",25,500); hPPComb->SetMarkerColor(kBlue); hPPComb->SetMarkerStyle(26); hPPComb->SetTitle("PP2013 ak3PF"); hPPComb->Draw(); //hPPComb_bins->SetMarkerColor(kRed); //hPPComb_bins->SetMarkerStyle(23); //hPPComb_bins->Draw("same"); c2->SaveAs("pp_2013_ak3_pt_evt_frac_merged.gif","RECREATE"); TCanvas *c5 = new TCanvas("c5","",800,600); TH1F* hppFunc = (TH1F*)functionHist(fPowerLaw,hppComb,"Fit Function p_{T} spectra PP 2013 merged"); TH1F* hPPRatio = (TH1F*)hppComb->Clone("hPPRatio"); hPPRatio->Divide(hppFunc); hPPRatio->SetTitle("Spectra to Fit Ratio"); hPPRatio->SetXTitle("Jet p_{T} GeV/c"); hPPRatio->SetYTitle("Measured data/Fit"); hPPRatio->SetMarkerStyle(8); hPPRatio->SetMarkerColor(4); hPPRatio->Draw(); c5->SaveAs("pp_2013_merged_spectra_fit_comp.gif","RECREATE"); TFile *fpbpbunfo = TFile::Open("result-2013-akPu3PF-cent-6-isFineBin-0/pbpb_pp_merged_chmx_pt_Unfo_2013_akPu3PF_cent_6_isFineBin_0.root"); TH1F* hppUnfo = (TH1F*)fpbpbunfo->Get("Unfolded_cent6"); TH1F* hPPGen = (TH1F*)fpbpbunfo->Get("hGen_cent6"); hppUnfo->Print("base"); hPPGen->Print("base"); hPPGen->Scale(1./4); divideBinWidth(hPPGen); hppUnfo->Scale(1./3.083e11); hppUnfo->Scale(1./4); divideBinWidth(hppUnfo); hppUnfo->Divide(hPPGen); TCanvas *c6 = new TCanvas("c6","",800,600); hppUnfo->SetMarkerStyle(21); hppUnfo->SetMarkerColor(kRed); hPPGen->SetMarkerStyle(21); hPPGen->SetMarkerColor(kBlue); hppUnfo->Draw(); // hPPGen->Draw("same"); c6->SaveAs("pp_2760GeV_unfold_vs_mc.gif","RECREATE"); /* TCanvas *c7 = new TCanvas("c7","",800,600); c7->SetLogy(); hPPComb->Draw(); hPPComb->SetYTitle(""); hPPComb->SetXTitle("p_{T} GeV/c"); //hppComb->SetTitle("PP 2013 2.76 TeV ak4PF measured vs unfolded"); hPPComb->SetMarkerStyle(23); hPPComb->SetMarkerColor(kBlue); //hppUnfo->SetAxisRange(10,500,"X"); //hppUnfo->SetMarkerStyle(24); //hppUnfo->SetMarkerColor(kRed); //hppUnfo->Draw("same"); TLegend *title5 = myLegend(0.54,0.65,0.85,0.9); title5->AddEntry(hppComb,"Measured","pl"); title5->AddEntry(hppUnfo,"Bayesian iter = 4","pl"); title5->SetTextSize(0.06); title5->Draw(); gStyle->SetOptStat(0); c7->SaveAs("PP2013_measured_vs_unfolded.gif","RECREATE"); //TCanvas */ //Create output file and save them. TFile f("merge_pp_ak3_HLT_V2.root","RECREATE"); //hpbpb1->Write(); //hpbpb2->Write(); //hpbpb3->Write(); //hPPComb_bins->Write(); hpp1->Write(); hpp2->Write(); hpp3->Write(); //hpbpbComb->Write(); hppComb->Write(); //hPPComb->Write(); //hPbPb_Uncert->Write(); hPPComb->Write(); hPPGen->Write(); f.Close(); }
void th2polyEurope(Int_t npoints=500000) { Int_t i,j; Double_t lon1 = -25; Double_t lon2 = 35; Double_t lat1 = 34; Double_t lat2 = 72; Double_t R = (lat2-lat1)/(lon2-lon1); Int_t W = 800; Int_t H = (Int_t)(R*800); gStyle->SetStatX(0.28); gStyle->SetStatY(0.45); gStyle->SetStatW(0.15); // Canvas used to draw TH2Poly (the map) TCanvas *ce = new TCanvas("ce", "ce",0,0,W,H); ce->ToggleEventStatus(); ce->SetGridx(); ce->SetGridy(); // Real surfaces taken from Wikipedia. const Int_t nx = 36; // see http://en.wikipedia.org/wiki/Area_and_population_of_European_countries const char *countries[nx] = { "france", "spain", "sweden", "germany", "finland", "norway", "poland", "italy", "yugoslavia", "united_kingdom", "romania", "belarus","greece", "czechoslovakia","bulgaria", "iceland", "hungary","portugal","austria", "ireland", "lithuania", "latvia", "estonia", "denmark", "netherlands", "switzerland","moldova","belgium", "albania", "cyprus", "luxembourg", "andorra","malta", "liechtenstein", "san_marino", "monaco" }; Float_t surfaces[nx] = { 547030, 505580, 449964, 357021, 338145, 324220, 312685, 301230, 255438, 244820, 237500, 207600, 131940, 127711, 110910, 103000, 93030, 89242, 83870, 70280, 65200, 64589, 45226, 43094, 41526, 41290, 33843, 30528, 28748, 9250, 2586, 468, 316, 160, 61, 2}; TH1F *h = new TH1F("h","Countries surfaces (in km^{2})",3,0,3); for (i=0; i<nx; i++) h->Fill(countries[i], surfaces[i]); h->LabelsDeflate(); TFile::SetCacheFileDir("."); TFile *f; f = TFile::Open("http://root.cern.ch/files/europe.root","cacheread"); if (!f) { printf("Cannot access europe.root. Is internet working ?\n"); return; } TH2Poly *p = new TH2Poly( "Europe", "Europe (bin contents are normalized to the surfaces in km^{2})", lon1,lon2,lat1,lat2); p->GetXaxis()->SetNdivisions(520); p->GetXaxis()->SetTitle("longitude"); p->GetYaxis()->SetTitle("latitude"); p->SetContour(100); TMultiGraph *mg; TKey *key; TIter nextkey(gDirectory->GetListOfKeys()); while ((key = (TKey*)nextkey())) { TObject *obj = key->ReadObj(); if (obj->InheritsFrom("TMultiGraph")) { mg = (TMultiGraph*)obj; p->AddBin(mg); } } TRandom r; Double_t longitude, latitude; Double_t x, y, pi4 = TMath::Pi()/4, alpha = TMath::Pi()/360; gBenchmark->Start("Partitioning"); p->ChangePartition(100, 100); gBenchmark->Show("Partitioning"); // Fill TH2Poly according to a Mercator projection. gBenchmark->Start("Filling"); for (i=0; i<npoints; i++) { longitude = r.Uniform(lon1,lon2); latitude = r.Uniform(lat1,lat2); x = longitude; y = 38*TMath::Log(TMath::Tan(pi4+alpha*latitude)); p->Fill(x,y); } gBenchmark->Show("Filling"); Int_t nbins = p->GetNumberOfBins(); Double_t maximum = p->GetMaximum(); // h2 contains the surfaces computed from TH2Poly. TH1F *h2 = (TH1F *)h->Clone("h2"); h2->Reset(); for (j=0; j<nx; j++) { for (i=0; i<nbins; i++) { if (strstr(countries[j],p->GetBinName(i+1))) { h2->Fill(countries[j],p->GetBinContent(i+1)); h2->SetBinError(j, p->GetBinError(i+1)); } } } // Normalize the TH2Poly bin contents to the real surfaces. Double_t scale = surfaces[0]/maximum; for (i=0; i<nbins; i++) p->SetBinContent(i+1, scale*p->GetBinContent(i+1)); gStyle->SetOptStat(1111); p->Draw("COLZ"); TCanvas *c1 = new TCanvas("c1", "c1",W+10,0,W-20,H); c1->SetRightMargin(0.047); scale = h->GetMaximum()/h2->GetMaximum(); h->SetStats(0); h->SetLineColor(kRed-3); h->SetLineWidth(2); h->SetMarkerStyle(20); h->SetMarkerColor(kBlue); h->SetMarkerSize(0.8); h->Draw("LP"); h->GetXaxis()->SetLabelFont(42); h->GetXaxis()->SetLabelSize(0.03); h->GetYaxis()->SetLabelFont(42); h2->Scale(scale); Double_t scale2=TMath::Sqrt(scale); for (i=0; i<nx; i++) h2->SetBinError(i+1, scale2*h2->GetBinError(i+1)); h2->Draw("E SAME"); h2->SetMarkerStyle(20); h2->SetMarkerSize(0.8); TLegend *leg = new TLegend(0.5,0.67,0.92,0.8,NULL,"NDC"); leg->SetTextFont(42); leg->SetTextSize(0.025); leg->AddEntry(h,"Real countries surfaces from Wikipedia (in km^{2})","lp"); leg->AddEntry(h2,"Countries surfaces from TH2Poly (with errors)","lp"); leg->Draw(); leg->Draw(); Double_t wikiSum = h->Integral(); Double_t polySum = h2->Integral(); Double_t error = TMath::Abs(wikiSum-polySum)/wikiSum; printf("THPoly Europe surface estimation error wrt wikipedia = %f per cent when using %d points\n",100*error,npoints); }
void unfoldPt(int mode=0) { // Matched Tracklets TFile *inf = new TFile("match-10TeV-12.root"); TNtuple *nt = (TNtuple*)inf->FindObjectAny("nt"); // Test sample TFile *infTest = new TFile("./TrackletTree-Run123596.root"); TNtuple *ntTest = (TNtuple*)infTest->FindObjectAny("TrackletTree12"); TFile *pdfFile; if (mode==0) pdfFile = new TFile("pdf.root","recreate"); else pdfFile = new TFile("pdf.root"); double nPtBin=15; double minPt=log(0.05); double maxPt=log(10); double nDphiBin=600; double maxDphi=0.4; char* mycut = Form("abs(eta)<2&&log(pt)>%f&&log(pt)<%f",minPt,maxPt); char* mycut1=Form("abs(eta)<2&&log(pt)>%f&&log(pt)<%f&&abs(eta-eta1)<0.01&&abs(deta)<0.01",minPt,maxPt); TH2F *h; TH1F *hdphi = new TH1F("hdphi","",nDphiBin,0,maxDphi); TH1F *hdphi2; TH1F *hpt; TH1F *hptH = new TH1F("hptH","",nPtBin,minPt,maxPt); TH1F *hptUnfold = new TH1F("hptUnfold","",nPtBin,minPt,maxPt); TH1F *hptMC = new TH1F("hptMC","",nPtBin,minPt,maxPt); TH1F *hptTemp = new TH1F("hptTemp","",nPtBin,minPt,maxPt); // Delta phi as a function of matched genparticle transverse momentum TCanvas *c = new TCanvas("c","",600,600); if (mode == 0) { h = new TH2F("h","",nPtBin,minPt,maxPt,nDphiBin,0,maxDphi); hdphi2 = new TH1F("hdphiMC","",nDphiBin,0,maxDphi); hpt = new TH1F("hpt","",nPtBin,minPt,maxPt); h->SetXTitle("ln(P_{T}) GeV/c"); h->SetYTitle("|#Delta#phi|"); nt->Draw("abs(dphi):log(pt)>>h",mycut1,"col"); // used to generate pdf nt->Draw("abs(dphi)>>hdphiMC",mycut,""); nt->Draw("log(pt)>>hpt",mycut,""); h->Write(); hpt->Write(); hdphi2->Write(); } else { h = (TH2F*) pdfFile->FindObjectAny("h"); hdphi2 = (TH1F*) pdfFile->FindObjectAny("hdphiMC"); hpt = (TH1F*) pdfFile->FindObjectAny("hpt"); } // Delta phi fit TCanvas *c2 = new TCanvas("c2","",600,600); c2->SetLogy(); c2->SetLogx(); // dphi for unfolding and MC truth: ntTest->Draw("abs(dphi)>>hdphi","abs(eta1)<2&&abs(deta)<0.1","",200000); ntTest->Draw("log(pt)>>hptH",mycut,"",200000); histFunction2D *myfun = new histFunction2D(h); TF1 *test = new TF1("histFun",myfun,&histFunction2D::evaluate,0,maxDphi,nPtBin+1); TF1 *test2 = new TF1("histFunMC",myfun,&histFunction2D::evaluate,0,maxDphi,nPtBin+1); for (int i=0;i<nPtBin+1;i++) { test->SetParameter(i,1); } hdphi2->SetXTitle("|#Delta#phi|"); hdphi2->SetYTitle("Arbitrary Normalization"); hdphi2->Fit("histFunMC","M"); hdphi->SetXTitle("|#Delta#phi|"); hdphi->SetYTitle("Arbitrary Normalization"); hdphi->Fit("histFun","M"); hdphi->SetStats(0); hdphi->Draw(); for (int i=0;i<nPtBin+1;i++) { TF1 *testPlot = new TF1(Form("histFun%d",i),myfun,&histFunction2D::evaluate,0,maxDphi,nPtBin+1); testPlot->SetParameter(i,test->GetParameter(i)); testPlot->SetLineColor(i+2); testPlot->Draw("same"); } int total=0,totalMC=0; for (int i=0;i<nPtBin;i++){ if (test->GetParameter(i)==0) continue; hptUnfold->SetBinContent(i+1,fabs(test->GetParameter(i))); hptUnfold->SetBinError(i+1,test->GetParError(i)); hptMC->SetBinContent(i+1,fabs(test2->GetParameter(i))); hptMC->SetBinError(i+1,test2->GetParError(i)); total+=fabs(test->GetParameter(i)); totalMC+=fabs(test2->GetParameter(i)); } hptUnfold->SetEntries(total); hptMC->SetEntries(totalMC); TCanvas *c3 = new TCanvas("c3","",600,600); hpt->Sumw2(); hptH->Sumw2(); //hptMC->Sumw2(); double normMC=0; double norm=0; double normTruth=0; hptUnfold->SetMarkerColor(2); hptUnfold->SetMarkerStyle(4); // hptUnfold->Scale(1./hptUnfold->GetEntries()); TH1F *hptCorrected = (TH1F*)hptUnfold->Clone(); hptCorrected->SetName("hptCorrected"); hptMC->Divide(hpt); hptCorrected->Divide(hptMC); for (int i=0;i<nPtBin;i++){ if (hptMC->GetBinContent(i)<=0.001)hptCorrected->SetBinContent(i,0); } hptCorrected->Scale(1./(hptCorrected->GetSum())); hptCorrected->SetMarkerStyle(20); hpt->Scale(1./hpt->GetEntries()); if (hptH->GetEntries())hptH->Scale(1./hptH->GetEntries()); hptTemp->SetXTitle("ln(P_{T}) GeV/c"); hptTemp->SetYTitle("Arbitrary Normalization"); hptTemp->Draw(); hptH->SetXTitle("ln(P_{T}) GeV/c"); hptH->SetYTitle("Arbitrary Normalization"); hptH->Draw("hist"); hptH->SetLineColor(4); hpt->Draw("hist same "); hptCorrected->Draw("same"); TH1F *hptUnfoldRatio = (TH1F*)hptUnfold->Clone(); hptUnfoldRatio->SetName("hptUnfoldRatio"); hptUnfoldRatio->Scale(1./hptUnfoldRatio->GetSum()); //hptUnfoldRatio->Divide(hptH); TH1F *hptCorrectedRatio = (TH1F*)hptCorrected->Clone(); hptCorrectedRatio->SetName("hptCorrectedRatio"); hptCorrectedRatio->SetMarkerColor(2); //hptCorrectedRatio->Divide(hptH); TCanvas *c4 = new TCanvas("c4","",600,600); TLine *l = new TLine(-2.5,1,2.5,1); hptUnfoldRatio->Draw(); hptMC->Draw("same"); hptCorrectedRatio->Draw("same"); l->Draw("same"); }
void produceHisto(std::string outputName="", std::string var="0.692-9.240*ecalIso/pt-11.117*hcalIso/pt",double genIsoCut=5.0,bool normalize=false ) { if(outputName=="")outputName = var; vector<string> mixFile; vector<double> mixWeight; vector<TTree*> mixTree; vector<int> mixPtHatLo; vector<int> mixPtHatHi; vector<string> phoFile; vector<double> phoWeight; vector<TTree*> phoTree; vector<int> phoPtHatLo; vector<int> phoPtHatHi; vector<string> jetFile; vector<double> jetWeight; vector<TTree*> jetTree; vector<int> jetPtHatLo; vector<int> jetPtHatHi; double lumi = 1.0; FILE *fTable = fopen("inputFile.txt","r"); int flag=1; int nfile=0; while (flag!=-1){ // first reading input file char filename[100]; flag=fscanf(fTable,"%s",filename); std::string tempFile = filename; bool isPhotonJet = false; if(tempFile.find("PhotonJet") != std::string::npos)isPhotonJet=true; char tmp[1000]; // read in x-section flag=fscanf(fTable,"%s",tmp); double cross=atof(tmp); // read in number of events flag=fscanf(fTable,"%s",tmp); double nevt=atof(tmp); double scale =lumi*cross/nevt; flag=fscanf(fTable,"%s",tmp); int ptHatLo=atof(tmp); flag=fscanf(fTable,"%s",tmp); int ptHatHi=atof(tmp); if (flag!=-1) { cout <<filename<<" "<<cross<<" "<<nevt<< " " << ptHatLo << " " << ptHatHi << endl; if(isPhotonJet) { cout << "filling photon jet" << endl; phoFile.push_back(tempFile); phoWeight.push_back(scale); phoPtHatLo.push_back(ptHatLo); phoPtHatHi.push_back(ptHatHi); } else { cout << "filling dijet" << endl; jetFile.push_back(tempFile); jetWeight.push_back(scale); jetPtHatLo.push_back(ptHatLo); jetPtHatHi.push_back(ptHatHi); } cout << "filling mixture" << endl; mixFile.push_back(tempFile); mixWeight.push_back(scale); mixPtHatLo.push_back(ptHatLo); mixPtHatHi.push_back(ptHatHi); nfile++; } } std::string treeName = "Analysis"; // first photon trees fillTrees(phoFile,phoTree,treeName); const unsigned int nSize_pho = phoFile.size(); if(phoTree.size()!= nSize_pho){cout << "error 1"<< endl; return;} if(phoWeight.size()!= nSize_pho){cout << "error 2"<< endl; return;} if(phoPtHatLo.size()!= nSize_pho){cout << "error 3"<< endl; return;} if(phoPtHatHi.size()!= nSize_pho){cout << "error 4"<< endl; return;} // second fill background trees fillTrees(jetFile,jetTree,treeName); const unsigned int nSize_jet = jetFile.size(); if(jetTree.size()!= nSize_jet){cout << "error 1"<< endl; return;} if(jetWeight.size()!= nSize_jet){cout << "error 2"<< endl; return;} if(jetPtHatLo.size()!= nSize_jet){cout << "error 3"<< endl; return;} if(jetPtHatHi.size()!= nSize_jet){cout << "error 4"<< endl; return;} // last fill mix trees fillTrees(mixFile,mixTree,treeName); const unsigned int nSize_mix = mixFile.size(); if(mixTree.size()!= nSize_mix){cout << "error 1"<< endl; return;} if(mixWeight.size()!= nSize_mix){cout << "error 2"<< endl; return;} if(mixPtHatLo.size()!= nSize_mix){cout << "error 3"<< endl; return;} if(mixPtHatHi.size()!= nSize_mix){cout << "error 4"<< endl; return;} TH1F *hTemplate = new TH1F("hTemplate","",70,-5,2); TH1F* hEcalIsoPho = (TH1F*)hTemplate->Clone(); std::string histoName = outputName + "Pho"; hEcalIsoPho->SetName(histoName.data()); TH1F* hEcalIsoJet = (TH1F*)hTemplate->Clone(); histoName = outputName + "Jet"; hEcalIsoJet->SetName(histoName.data()); TH1F* hEcalIsoMixSig = (TH1F*)hTemplate->Clone(); histoName = outputName + "MixSig"; hEcalIsoMixSig->SetName(histoName.data()); TH1F* hEcalIsoMixBkg = (TH1F*)hTemplate->Clone(); histoName = outputName + "MixBkg"; hEcalIsoMixBkg->SetName(histoName.data()); TH1F* hEcalIsoMixData = (TH1F*)hTemplate->Clone(); histoName = outputName + "MixData"; hEcalIsoMixData->SetName(histoName.data()); cout << "making histograms from photon+jet MC samples" << endl; TCut allCut = basicCut + sigCut; // makePlot(phoTree,phoWeight,Form("%s",var.data()),hardScatterCut,hEcalIsoPho,normalize); makePlot(phoTree,phoWeight,phoPtHatLo,phoPtHatHi,Form("%s",var.data()),allCut,hEcalIsoPho,normalize); cout << "making histograms from dijet MC samples" << endl; allCut = basicCut + decayCut; makePlot(jetTree,jetWeight,jetPtHatLo,jetPtHatHi,Form("%s",var.data()),allCut,hEcalIsoJet,normalize); cout << "making histograms from mixed MC signal samples" << endl; allCut = basicCut + sigCut; makePlot(mixTree,mixWeight,mixPtHatLo,mixPtHatHi,Form("%s",var.data()),allCut,hEcalIsoMixSig,normalize); cout << "making histograms from mixed MC background samples" << endl; allCut = basicCut + bkgCut; makePlot(mixTree,mixWeight,mixPtHatLo,mixPtHatHi,Form("%s",var.data()),allCut,hEcalIsoMixBkg,normalize); hEcalIsoPho->SetMarkerColor(2); hEcalIsoPho->SetLineColor(2); hEcalIsoJet->SetMarkerColor(1); hEcalIsoJet->SetLineColor(1); hEcalIsoMixSig->SetMarkerColor(5); hEcalIsoMixSig->SetLineColor(5); hEcalIsoMixBkg->SetMarkerColor(4); hEcalIsoMixBkg->SetLineColor(4); cout << "hEcalIsoPho->Integral() = " << hEcalIsoPho->Integral() << endl; cout << "hEcalIsoJet->Integral() = " << hEcalIsoJet->Integral() << endl; cout << "hEcalIsoMixSig->Integral() = " << hEcalIsoMixSig->Integral() << endl; cout << "hEcalIsoMixBkg->Integral() = " << hEcalIsoMixBkg->Integral() << endl; hEcalIsoMixData->Reset(); hEcalIsoMixData->Sumw2(); hEcalIsoMixData->Add(hEcalIsoMixSig,hEcalIsoMixBkg,1.0,1.0); cout << "hEcalIsoMixData->Integral() = " << hEcalIsoMixData->Integral() << endl; hEcalIsoPho->SetXTitle(var.data()); hEcalIsoPho->Draw("hist"); hEcalIsoJet->Draw("histesame"); hEcalIsoMixSig->Draw("histesame"); hEcalIsoMixBkg->Draw("histesame"); TLegend* leg = new TLegend(0.5,0.6,0.7,0.9); leg->SetFillColor(0); leg->SetFillStyle(0); leg->SetTextSize(0.03); leg->SetBorderSize(0); leg->AddEntry(hEcalIsoPho,"#gamma+jet MC"); leg->AddEntry(hEcalIsoJet,"Dijet MC"); leg->AddEntry(hEcalIsoMixSig,"Mixed MC: signal"); leg->AddEntry(hEcalIsoMixBkg,"Mixed MC: background"); leg->Draw("same"); // dump histogram to a root file std::string histoFile = outputName + "_histo.root"; TFile* outFile = new TFile(histoFile.data(),"recreate"); hEcalIsoPho->Write(); hEcalIsoJet->Write(); hEcalIsoMixSig->Write(); hEcalIsoMixBkg->Write(); hEcalIsoMixData->Write(); outFile->Close(); }
/*#include <TSystem.h> // interface to OS #include <TStyle.h> // class to handle ROOT plotting styles#include <TFile.h> // file handle class #include <TTree.h> // class to access ntuples #include <TBenchmark.h> // class to track macro running statistics #include <TH1D.h> // histogram class #include <vector> // STL vector class #include <iostream> // standard I/O #include <iomanip> // functions to format standard I/O #include <fstream> // functions for file I/O #include <string> // C++ string class #include <sstream> // class for parsing strings #include <TRandom3.h> #include <TGaxis.h> #include "Math/LorentzVector.h" // 4-vector class #include "../Utils/MyTools.hh" // various helper functions #include "../Utils/CPlot.hh" // helper class for plots #include "../Utils/MitStyleRemix.hh" // style settings for drawing #include "../Utils/WModels.hh" // definitions of PDFs for fitting #include "../Utils/RecoilCorrector.hh" // class to handle recoil corrections for MET */ void W_MET_Ratio() { TCanvas *c = new TCanvas("c","c",800,800); c->Divide(1,2,0,0); c->cd(1)->SetPad(0,0.3,1.0,1.0); c->cd(1)->SetTopMargin(0.1); c->cd(1)->SetBottomMargin(0.01); c->cd(1)->SetLeftMargin(0.15); c->cd(1)->SetRightMargin(0.07); c->cd(1)->SetTickx(1); c->cd(1)->SetTicky(1); c->cd(2)->SetPad(0,0,1.0,0.3); c->cd(2)->SetTopMargin(0.05); c->cd(2)->SetBottomMargin(0.45); c->cd(2)->SetLeftMargin(0.15); c->cd(2)->SetRightMargin(0.07); c->cd(2)->SetTickx(1); c->cd(2)->SetTicky(1); c->cd(2)->SetGridy(); TLegend * lgc = new TLegend(0.59, 0.67, 0.89, 0.89); lgc->SetTextSize(0.03); lgc->SetBorderSize(0); lgc->SetFillColor(0); // TFile *file = new TFile("../ElectronHighPU/Ele_RD_HighPU_A_Analysis.root"); TFile *file = new TFile("./ElectronHighPU_N/Ele_WToENu_S10_Analysis.root"); ///////////////Original Plot//////////////////////// c->cd(1); lgc->AddEntry(h1_W_Neut_pt1,"UnCorrected"); h1_W_Neut_pt1->SetYTitle("Events"); h1_W_Neut_pt1->SetFillColor(kWhite); h1_W_Neut_pt1->SetMarkerColor(kBlack); h1_W_Neut_pt1->SetMarkerStyle(1); h1_W_Neut_pt1->SetLineWidth(2); h1_W_Neut_pt1->Draw(); lgc->AddEntry(h1_W_Neut_pt_Corr,"Corrected"); h1_W_Neut_pt_Corr->SetLineColor(kRed); h1_W_Neut_pt_Corr->SetFillColor(kWhite); h1_W_Neut_pt_Corr->SetMarkerColor(kRed); h1_W_Neut_pt_Corr->SetMarkerStyle(1); h1_W_Neut_pt_Corr->SetLineWidth(2); h1_W_Neut_pt_Corr->Draw("same"); lgc->Draw(); /////////////////////////////////////////////////////// c->cd(2); TH1F * h1_Ori = (TH1F*)file->Get("h1_W_Neut_pt1"); TH1F * h1_Corr = (TH1F*)file->Get("h1_W_Neut_pt_Corr"); int Nbins = h1_Ori->GetNbinsX(); TH1F * ratio = new TH1F("ratio","", Nbins, h1_Ori->GetXaxis()->GetXmin(), h1_Ori->GetXaxis()->GetXmax()); ratio->Divide(h1_Ori, h1_Corr); ratio->SetXTitle("N_vtx"); ratio->SetMaximum(2); ratio->SetMinimum(0); ratio->SetNdivisions(10,"X"); ratio->SetNdivisions(4,"Y"); ratio->SetLabelSize(0.09,"XY"); ratio->SetTitleSize(0.12,"X"); ratio->SetMarkerStyle(20); ratio->SetMarkerSize(0.7); ratio->SetMarkerColor(kBlue); ratio->Draw("P"); // c->SaveAs("W_MET_Ratio_RD.png"); c->SaveAs("W_MET_Ratio_MC.png"); }
void DrawMass(int iSEL) { gROOT->ForceStyle(); TString SET[2] = {"A","B"}; RooMsgService::instance().setSilentMode(kTRUE); for(int i=0;i<2;i++) { RooMsgService::instance().setStreamStatus(i,kFALSE); } TString SELECTION[2] = {"NOM","VBF"}; TString MASS_RAW[2] = {"mbb[1]","mbb[2]"}; TString MASS_REG[2] = {"mbbReg[1]","mbbReg[2]"}; // TFile *inf = TFile::Open("Fit_VBFPowheg125_sel"+SELECTION[iSEL]+".root"); TFile *inf = TFile::Open("/usb/data2/UAData/2015/flatTree_VBFPowheg125.root"); TTree *tr = (TTree*)inf->Get("Hbb/events"); TH1F *hRaw = new TH1F("hRawMass","hRawMass",150,0,300); TH1F *hReg = new TH1F("hRegMass","hRegMass",150,0,300); RooRealVar x("mbb","mbb",60,170); TCanvas *can = new TCanvas("Mbb_sel"+SELECTION[iSEL],"Mbb_sel"+SELECTION[iSEL],900,750); TCut ct1 = TCut("triggerResult[0]==1||triggerResult[1]==1"); TCut cs1 = TCut("jetBtag[b1[1]]>0.244 && jetBtag[b2[1]]>0.244 && jetPt[3]>40. && jetPt[2]>50. && jetPt[1]>70. && jetPt[0]>80. && dEtaqq[1]>2.5 && mqq[1]>250 && dPhibb[1]<2.0 && nLeptons==0"); tr->Draw(MASS_RAW[iSEL]+">>hRawMass",ct1&&cs1); tr->Draw(MASS_REG[iSEL]+">>hRegMass",ct1&&cs1); hRaw->Sumw2(); hReg->Sumw2(); hRaw->Scale(1./(hRaw->Integral()*hRaw->GetBinWidth(1))); hReg->Scale(1./(hReg->Integral()*hReg->GetBinWidth(1))); RooDataHist *rRaw = new RooDataHist("rRaw","rRaw",x,hRaw); RooDataHist *rReg = new RooDataHist("rReg","rReg",x,hReg); RooRealVar m1("m1","m1",125,110,140); RooRealVar m2("m2","m2",125,110,140); RooRealVar sL1("sL1","sL1",12,3,30); RooRealVar sL2("sL2","sL2",12,3,30); RooRealVar sR1("sR1","sR1",12,3,30); RooRealVar sR2("sR2","sR2",12,3,30); RooRealVar a1("a1","a1",1,-10,10); RooRealVar a2("a2","a2",1,-10,10); RooRealVar n1("n1","n1",1,0,100); RooRealVar n2("n2","n2",1,0,100); RooRealVar b10("b10","b10",0.5,0.,1.); RooRealVar b11("b11","b11",0.5,0.,1.); RooRealVar b12("b12","b12",0.5,0.,1.); RooRealVar b13("b13","b13",0.5,0.,1.); RooRealVar b20("b20","b20",0.5,0.,1.); RooRealVar b21("b21","b21",0.5,0.,1.); RooRealVar b22("b22","b22",0.5,0.,1.); RooRealVar b23("b23","b23",0.5,0.,1.); RooBernstein bkg1("bkg1","bkg1",x,RooArgSet(b10,b11,b12,b13)); RooBernstein bkg2("bkg2","bkg2",x,RooArgSet(b20,b21,b22,b23)); RooRealVar fsig1("fsig1","fsig1",0.7,0.,1.); RooRealVar fsig2("fsig2","fsig2",0.7,0.,1.); RooBifurGauss sig1("sig1","sig1",x,m1,sL1,sR1); RooBifurGauss sig2("sig2","sig2",x,m2,sL2,sR2); //RooCBShape sig1("sig1","sig1",x,m1,s1,a1,n1); //RooCBShape sig2("sig2","sig2",x,m2,s2,a2,n2); RooAddPdf *model1 = new RooAddPdf("model1","model1",RooArgList(sig1,bkg1),fsig1); RooAddPdf *model2 = new RooAddPdf("model2","model2",RooArgList(sig2,bkg2),fsig2); model1->fitTo(*rRaw,SumW2Error(kFALSE),"q"); model2->fitTo(*rReg,SumW2Error(kFALSE),"q"); hRaw->SetLineWidth(2); hReg->SetLineWidth(2); hRaw->SetLineColor(kBlack); hReg->SetLineColor(kRed+1); hReg->SetFillColor(kRed-10); hRaw->SetMarkerStyle(21); hReg->SetMarkerStyle(20); hRaw->SetMarkerSize(1.5); hReg->SetMarkerSize(1.5); hRaw->SetMarkerColor(kBlack); hReg->SetMarkerColor(kRed+1); RooPlot* frame = x.frame(); rRaw->plotOn(frame,LineColor(kBlack),LineWidth(1),MarkerColor(kBlack),MarkerStyle(21)); model1->plotOn(frame,LineColor(kBlack),LineWidth(2)); rReg->plotOn(frame,LineColor(kRed+1),LineWidth(1),MarkerColor(kRed+1),MarkerStyle(20)); model2->plotOn(frame,LineColor(kRed+1),LineWidth(2)); TF1 *tmp_func1 = model1->asTF(x,fsig1,x); TF1 *tmp_func2 = model2->asTF(x,fsig2,x); double y01 = tmp_func1->GetMaximum(); double x01 = tmp_func1->GetMaximumX(); double x11 = tmp_func1->GetX(y01/2,60,x01); double x21 = tmp_func1->GetX(y01/2,x01,200); double FWHM1 = x21-x11; double y02 = tmp_func2->GetMaximum(); double x02 = tmp_func2->GetMaximumX(); double x12 = tmp_func2->GetX(y02/2,60,x02); double x22 = tmp_func2->GetX(y02/2,x02,200); double FWHM2 = x22-x12; hReg->GetXaxis()->SetRangeUser(60,170); hReg->GetXaxis()->SetTitle("m_{bb} (GeV)"); hReg->GetYaxis()->SetTitle("1/N #times dN/dm_{bb} (GeV^{-1})"); hReg->GetYaxis()->SetNdivisions(505); hReg->SetMaximum(0.035); hReg->Draw("HIST"); hRaw->Draw("HIST SAME"); frame->Draw("same"); TLegend *leg = new TLegend(0.18,0.7,0.43,0.91); leg->SetTextFont(42); leg->SetTextSize(0.05); leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetHeader("m_{H} = 125 GeV (set "+SET[iSEL]+")"); leg->AddEntry(hReg,"Regressed","LP"); leg->AddEntry(hRaw,"Raw","LP"); leg->Draw(); TPaveText *pave1 = new TPaveText(0.18,0.56,0.43,0.7,"NDC"); pave1->AddText(TString::Format("PEAK = %1.1f GeV",x02)); pave1->AddText(TString::Format("FWHM = %1.1f GeV",FWHM2)); pave1->SetTextFont(42); pave1->SetTextSize(0.04); pave1->SetTextColor(kRed+1); pave1->SetBorderSize(0); pave1->SetFillColor(0); pave1->Draw(); TPaveText *pave2 = new TPaveText(0.18,0.42,0.43,0.56,"NDC"); pave2->AddText(TString::Format("PEAK = %1.1f GeV",x01)); pave2->AddText(TString::Format("FWHM = %1.1f GeV",FWHM1)); pave2->SetTextFont(42); pave2->SetTextSize(0.04); pave2->SetTextColor(kBlack); pave2->SetBorderSize(0); pave2->SetFillColor(0); pave2->Draw(); can->SaveAs("regressionKost.pdf"); // CMS_lumi(can,0,0); }