void makeValidPlot(){ setNCUStyle(true); c1 = new TCanvas("c1","",800,600); TFile* tf1=TFile::Open("MjjVC/data.root"); string validName[7]={ "0a","0c", "1a","1c", "2a","2b","2d" }; string tau21Name[2]={"withTau21","woTau21"}; for(int i=0;i<7;i++){ for(int j=0;j<2;j++){ TH1D* th1,* th2; th1= (TH1D*) tf1->Get(Form("fill_%s_105_135_%s",validName[i].data(),tau21Name[j].data())); th2= (TH1D*) tf1->Get(Form("valid_%s_105_135_%s",validName[i].data(),tau21Name[j].data())); th1->Rebin(10); th2->Rebin(10); th1->GetXaxis()->SetRangeUser(1000,2500); TLegend *leg = new TLegend(0.64, 0.68, 0.92, 0.87); leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetFillStyle(0); leg->SetTextSize(0.04); leg->AddEntry(th1,"1-antiTag"); leg->AddEntry(th2,"2-antiTag* PFRatio"); th1->SetTitle("DBT-TT(Pass_{j0},Fail_{j1})"); th1->Draw(""); th2->SetLineColor(2); th2->Draw("same"); leg->Draw("same"); c1->Print(Form("validPlots/%s/TT_%s.pdf",tau21Name[j].data(),validName[i].data())); } } for(int i=0;i<7;i++){ for(int j=0;j<2;j++){ TH1D* th1,* th2; th1= (TH1D*) tf1->Get(Form("fill_%sL_105_135_%s",validName[i].data(),tau21Name[j].data())); th2= (TH1D*) tf1->Get(Form("valid_%sL_105_135_%s",validName[i].data(),tau21Name[j].data())); th1->Rebin(10); th2->Rebin(10); th1->GetXaxis()->SetRangeUser(1000,2500); TLegend *leg = new TLegend(0.64, 0.68, 0.92, 0.87); leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetFillStyle(0); leg->SetTextSize(0.04); leg->AddEntry(th1,"1-antiTag"); leg->AddEntry(th2,"2-antiTag* PFRatio"); th1->SetTitle("DBT-LL(Pass_{j0},Fail_{j1})"); th1->Draw(""); th2->SetLineColor(2); th2->Draw("same"); leg->Draw("same"); c1->Print(Form("validPlots/%s/LL_%s.pdf",tau21Name[j].data(),validName[i].data())); } } }
void Limit(){ setNCUStyle(true); c1 = new TCanvas("c1","",800,600); int width [nWidth]={20,25,30,35,40}; int bmin[nBmin]={95,100,105,110,115,120,125,130,135,140,145}; string masspoint[11]={"1000","1200","1400","1600","1800","2000","2500","3000","3500","4000","4500"}; TLegend *leg = new TLegend(0.75, 0.68, 0.96, 0.95); leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetFillStyle(0); leg->SetTextSize(0.04); for(int k=2;k<nWidth;k++){ for(int m=0;m<nBmin;m++){ if(width[k]+bmin[m]>166)continue; if( // //(k==4 && m==6)|| (k==4 && m==5)|| (k==4 && m==4)|| (k==4 && m==3)|| // (k==4 && m==2)|| (k==4 && m==1)|| (k==4 && m==0)|| // // // // (k==3 && m==7)|| // // // // (k==3 && m==6)|| (k==3 && m==5)|| (k==3 && m==4)|| (k==3 && m==3)|| (k==3 && m==2)|| (k==3 && m==1)|| (k==3 && m==0)|| (k==2 && m==0)|| (k==2 && m==1)|| (k==2 && m==2)|| (k==2 && m==3)|| // (k==2 && m==4)|| (k==2 && m==5)|| // // // // (k==2 && m==6)|| (k==1 && m==0)|| (k==1 && m==1)|| (k==1 && m==2)|| (k==1 && m==3)|| // // (k==1 && m==4)|| (k==1 && m==5)|| (k==0 && m==0)|| (k==0 && m==1)|| (k==0 && m==2)|| (k==0 && m==3)|| // // (k==0 && m==4)|| // (k==0 && m==6) (k==10 && m==6) )continue; TFile* tf1=TFile::Open(Form("massOpt/MassPlotFineBins_subtr_Moriond_Silver%dto%d.root",bmin[m],bmin[m]+width[k])); if (!tf1 || !tf1->IsOpen())continue; TGraphAsymmErrors* tg1=(TGraphAsymmErrors*)tf1->Get("LimitExpectedCLs"); tg1->GetYaxis()->SetTitle("95% CLs on #sigma(X#rightarrowHH)#timesBR(HH#rightarrowb#bar{b}b#bar{b})[fb]"); tg1->SetLineStyle(1); tg1->SetFillColor(0); tg1->SetLineColor(m); leg->AddEntry(tg1,Form("%dto%d",bmin[m],bmin[m]+width[k])); tg1->SetMaximum(20); tg1->SetMinimum(1); cout<<k<<","<<m<<endl; // c1->SetLogy(1); if(k==2 && m==4)tg1->Draw("APL"); else tg1->Draw("PL same"); } } leg->Draw("same"); c1->Print("Limit.pdf"); }
void makeCorr3(){ setNCUStyle(true); c1 = new TCanvas("c1","",1360,768); TFile *f; f=TFile::Open("corr2/corr.root"); TFile *f2; f2=TFile::Open("pdgToReco2.root"); TFile* tf1[nMasspoint]; int masspoint[nMasspoint]={1000,1200,1400,1600,1800,2000,2500,3000}; for(int i=0;i<nMasspoint;i++){ tf1[i]=TFile::Open(Form("corr2/B%d.root",masspoint[i])); //f[i+11]=TFile::Open(Form("R%s.root",masspoint[i].data())); } double xsec[nMasspoint]={1.90,0.763,0.33,0.155,7.65e-2,1.58e-2,3.73e-3,2.08e-4,4.91e-5}; double ptBins[14]={300,400,500,600,700,800,900,1000,1250,1500,1750,2000,2500}; double ptBinsCenter[14]={350,450,550,650,750,850,950,1125,1375,1625,1875,2250,2750}; double ptBinsCenterE[14]={350,450,550,650,750,850,950,1125,1375,1625,1875,2250,2750}; double ptBinsError[14]={0}; double ptBinsErrorE[14]={0}; double mean[6][15]; double sigma[6][15]; TLegend *leg = new TLegend(0.68, 0.45, 0.94, 0.90); leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetFillStyle(0); leg->SetTextSize(0.04); TGraphErrors* tg1[nMasspoint]; for(int k=0;k<nMasspoint;k++){ for(int i=0;i<13;i++){ TH1D* th1=(TH1D *)tf1[k]->Get(Form("ptBarel%.0f",ptBins[i])); ptBinsCenter[i]=th1->GetMean(); ptBinsError[i]=th1->GetRMS(); cout<<i<<","<<ptBinsCenter[i]<<","<<ptBinsError[i]<<endl; } for(int i=0;i<13;i++){ TH1D* th1=(TH1D*)tf1[k]->Get(Form("recoBarelMass%.0f",ptBins[i])); TF1 *tf1[4]; if(i<3){ tf1[0]=new TF1("fa1","gaus(25000)",th1->GetMaximumBin()-30,th1->GetMaximumBin()+30); th1->Fit(tf1[0],"","",th1->GetMaximumBin()-30,th1->GetMaximumBin()+30); } else { tf1[0]=new TF1("fa1","gaus(25000)",th1->GetMaximumBin()-20,th1->GetMaximumBin()+20); th1->Fit(tf1[0],"","",th1->GetMaximumBin()-20,th1->GetMaximumBin()+20); } mean[4][i]=125/tf1[0]->GetParameter(1); sigma[4][i]=tf1[0]->GetParError(1)*(125/tf1[0]->GetParameter(1))/tf1[0]->GetParameter(1); double temp=tf1[0]->GetParError(1)/tf1[0]->GetParameter(1); //mean[4][i]=125/th1->GetMean(); //sigma[4][i]=th1->GetMeanError()/th1->GetMean(); //cout<<i<<"="<<mean[4][i]<<endl; //sigma[4][i]=0; th1->SetTitle(Form("%.0f",ptBins[i])); if(i==0)c1->Print(Form("plots/recoBarel%d.pdf(",masspoint[k])); else if(i==12)c1->Print(Form("plots/recoBarel%d.pdf)",masspoint[k])); else c1->Print(Form("plots/recoBarel%d.pdf",masspoint[k])); if(th1->GetEntries()<50|| mean[4][i]<0 || mean[4][i]>2.5||temp>0.3){ mean[4][i]=0; sigma[4][i]=0; } } tg1[k]=new TGraphErrors(12,ptBinsCenter,mean[4],ptBinsError,sigma[4]); tg1[k]->GetXaxis()->SetTitle("jet Pt"); tg1[k]->GetXaxis()->SetRangeUser(0,1800); tg1[k]->GetYaxis()->SetTitle("M_{PDG}/M_{Reco}"); tg1[k]->SetTitle("Gen Correction"); tg1[k]->SetMinimum(0.9); tg1[k]->SetMaximum(2.2); tg1[k]->SetFillColor(0); tg1[k]->SetLineColor(97-5*k); tg1[k]->SetMarkerColor(97-5*k); tg1[k]->SetMarkerStyle(20+k); tg1[k]->SetMarkerSize(2); tg1[k]->SetLineWidth(3); leg->AddEntry(tg1[k],Form("M=%d",masspoint[k])); } for(int k=0;k<nMasspoint;k++){ tg1[k]->GetXaxis()->SetRangeUser(200,2500); if(k==0)tg1[k]->Draw("APL"); else tg1[k]->Draw("samePL"); for(int j=0;j<12;j++){ double x,y; tg1[k]->GetPoint(j,x,y); cout<<"k="<<k<<",j="<<j<<","<<x<<","<<y<<endl; if(y<0.1){ tg1[k]->RemovePoint (j); //j--; } tg1[k]->GetPoint(j,x,y); cout<<"k="<<k<<",j="<<j<<","<<x<<","<<y<<endl; } for(int j=0;j<12;j++){ double x,y; tg1[k]->GetPoint(j,x,y); if(y<0.1){ tg1[k]->RemovePoint (j); //j--; } } for(int j=0;j<12;j++){ double x,y; tg1[k]->GetPoint(j,x,y); if(y<0.1){ tg1[k]->RemovePoint (j); //j--; } } } TGraphErrors* te1=(TGraphErrors*)f2->Get("barel"); //leg->AddEntry(te1,"avg"); //te1->Draw("samePL"); // te1->SetLineColor(1); // te1->SetLineWidth(3); // te1->SetMarkerColor(1); // te1->SetMarkerSize(1.5); // te1->SetMarkerStyle(20); leg->Draw("same"); c1->Print("plots/recoOneBarrel.pdf"); leg->Clear(); for(int k=0;k<nMasspoint;k++){ for(int i=0;i<11;i++){ TH1D* th1=(TH1D*)tf1[k]->Get(Form("ptEndcap%.0f",ptBins[i])); ptBinsCenterE[i]=th1->GetMean(); ptBinsErrorE[i]=th1->GetRMS(); cout<<i<<","<<ptBinsCenterE[i]<<","<<ptBinsErrorE[i]<<endl; } for(int i=0;i<13;i++){ TH1D* th1=(TH1D*)tf1[k]->Get(Form("recoEndcapMass%.0f",ptBins[i])); TF1 *tf1[4]; if(i<3){ tf1[0]=new TF1("fa1","gaus(25000)",th1->GetMaximumBin()-40,th1->GetMaximumBin()+40); th1->Fit(tf1[0],"","",th1->GetMaximumBin()-40,th1->GetMaximumBin()+40); } else { tf1[0]=new TF1("fa1","gaus(25000)",th1->GetMaximumBin()-30,th1->GetMaximumBin()+30); tf1[0]->SetParameter(1,100); th1->Fit(tf1[0],"","",th1->GetMaximumBin()-30,th1->GetMaximumBin()+30); } mean[4][i]=125/tf1[0]->GetParameter(1); sigma[4][i]=tf1[0]->GetParError(1)*(125/tf1[0]->GetParameter(1))/tf1[0]->GetParameter(1); double temp=tf1[0]->GetParError(1)/tf1[0]->GetParameter(1); //mean[4][i]=125/th1->GetMean(); //sigma[4][i]=th1->GetMeanError()/th1->GetMean(); //cout<<i<<"="<<mean[4][i]<<endl; //sigma[4][i]=0; th1->SetTitle(Form("%.0f",ptBins[i])); if(i==0)c1->Print(Form("plots/recoEndcap%d.pdf(",masspoint[k])); else if(i==12)c1->Print(Form("plots/recoEndcap%d.pdf)",masspoint[k])); else c1->Print(Form("plots/recoEndcap%d.pdf",masspoint[k])); if(th1->GetEntries()<50|| mean[4][i]<1 || mean[4][i]>2.5||temp>0.3){ mean[4][i]=0; sigma[4][i]=0; } } tg1[k]=new TGraphErrors(9,ptBinsCenter,mean[4],ptBinsError,sigma[4]); tg1[k]->GetXaxis()->SetTitle("jet Pt"); tg1[k]->GetXaxis()->SetRangeUser(0,1800); tg1[k]->GetYaxis()->SetTitle("M_{PDG}/M_{Reco}"); tg1[k]->SetTitle("Gen Correction"); tg1[k]->SetMinimum(1); tg1[k]->SetMaximum(1.7); tg1[k]->SetFillColor(0); tg1[k]->SetLineColor(97-5*k); tg1[k]->SetMarkerColor(97-5*k); tg1[k]->SetMarkerStyle(20+k); tg1[k]->SetMarkerSize(2); tg1[k]->SetLineWidth(3); leg->AddEntry(tg1[k],Form("M=%d",masspoint[k])); } for(int k=0;k<nMasspoint;k++){ tg1[k]->GetXaxis()->SetRangeUser(200,2500); if(k==0)tg1[k]->Draw("APL"); else tg1[k]->Draw("samePL"); for(int j=0;j<12;j++){ double x,y; tg1[k]->GetPoint(j,x,y); cout<<"k="<<k<<",j="<<j<<","<<x<<","<<y<<endl; if(y<0.1){ tg1[k]->RemovePoint (j); //j--; } tg1[k]->GetPoint(j,x,y); cout<<"k="<<k<<",j="<<j<<","<<x<<","<<y<<endl; } for(int j=0;j<12;j++){ double x,y; tg1[k]->GetPoint(j,x,y); if(y<0.1){ tg1[k]->RemovePoint (j); //j--; } } for(int j=0;j<12;j++){ double x,y; tg1[k]->GetPoint(j,x,y); if(y<0.1){ tg1[k]->RemovePoint (j); //j--; } } } te1=(TGraphErrors*)f2->Get("endcap"); //leg->AddEntry(te1,"avg"); //te1->Draw("samePL"); // te1->SetLineColor(1); // te1->SetLineWidth(3); // te1->SetMarkerColor(1); // te1->SetMarkerSize(1.5); // te1->SetMarkerStyle(20); leg->Draw("same"); c1->Print("plots/recoOneEndcap.pdf"); /* for(int i=0;i<13;i++){ TH1D* th1=(TH1D*)f->Get(Form("recoEndcapMass%.0f",ptBins[i])); TF1 *tf1[4]; if(i<2){ tf1[0]=new TF1("fa1","gaus(25000)",th1->GetMaximumBin()-30,th1->GetMaximumBin()+30); th1->Fit(tf1[0],"","",th1->GetMaximumBin()-30,th1->GetMaximumBin()+30); } else { tf1[0]=new TF1("fa1","gaus(25000)",th1->GetMaximumBin()-20,th1->GetMaximumBin()+20); th1->Fit(tf1[0],"","",th1->GetMaximumBin()-20,th1->GetMaximumBin()+20); } mean[5][i]=125/tf1[0]->GetParameter(1); sigma[5][i]=tf1[0]->GetParError(1)*(125/tf1[0]->GetParameter(1) )/tf1[0]->GetParameter(1); //mean[5][i]=125/th1->GetMean(); //sigma[5][i]=th1->GetMeanError()/th1->GetMean(); th1->Draw(); th1->SetTitle(Form("%.0f",ptBins[i])); tf1[0]->Draw("same"); //cout<<i<<"="<<mean[5][i]<<endl; } TGraphErrors* tg1[6]; tg1[4]=new TGraphErrors(12,ptBinsCenter,mean[4],ptBinsError,sigma[4]); tg1[5]=new TGraphErrors(9,ptBinsCenter,mean[5],ptBinsError,sigma[5]); for(int i=0;i<14;i++)cout<<i<<"="<<mean[4][i]<<endl; for(int i=0;i<14;i++)cout<<i<<"="<<mean[5][i]<<endl; tg1[4]->Draw("APL"); tg1[4]->SetFillColor(0); tg1[5]->SetFillColor(0); tg1[5]->SetLineColor(2); tg1[5]->SetMarkerColor(2); tg1[5]->Draw("PLsame"); leg->Clear(); leg->AddEntry(tg1[5],"reco endcap"); leg->AddEntry(puppisd_corrRECO_cen,"Thea barel"); leg->AddEntry(puppisd_corrRECO_for,"Thea endcap"); leg->Draw("same"); genBarel->Draw("same"); genEndcap->Draw("same"); puppisd_corrRECO_cen->SetLineColor(3); puppisd_corrRECO_for->SetLineColor(4); //tg1[2]->Draw("APL"); puppisd_corrRECO_cen->Draw("same"); puppisd_corrRECO_for->Draw("same"); c1->Print("plots/recoOne.pdf"); */ }
void dataMCplots(std::string outputFolder, std::string pdfName){ std::vector<string> infiles; TSystemDirectory *base = new TSystemDirectory("root","root"); base->SetDirectory(outputFolder.data()); TList *listOfFiles = base->GetListOfFiles(); TIter fileIt(listOfFiles); TFile *fileH = new TFile(); Long64_t nfiles = 0; while( (fileH = (TFile*)fileIt()) ){ std::string fileN = fileH->GetName(); std::string baseString = "root"; if( fileN.find(baseString) == std::string::npos ) continue; infiles.push_back(Form("%s/%s",outputFolder.data(),fileN.data())); nfiles++; } TFile *f_DY100 = NULL; TFile *f_DY200 = NULL; TFile *f_DY400 = NULL; TFile *f_DY600 = NULL; TFile *f_TTbar = NULL; TFile *f_WW = NULL; TFile *f_WZ = NULL; TFile *f_ZZ = NULL; TFile *f_data0 = NULL; TFile *f_data1 = NULL; Double_t xSecDY100 = 139.4*1.23; Double_t xSecDY200 = 42.75*1.23; Double_t xSecDY400 = 5.497*1.23; Double_t xSecDY600 = 2.21*1.23; Double_t xSecTTbar = 831.76; Double_t xSecWW = 118.7; Double_t xSecWZ = 47.13; Double_t xSecZZ = 16.523; Double_t scaleDY100 = 0; Double_t scaleDY200 = 0; Double_t scaleDY400 = 0; Double_t scaleDY600 = 0; Double_t scaleTTbar = 0; Double_t scaleWW = 0; Double_t scaleWZ = 0; Double_t scaleZZ = 0; Double_t dummy = -1; for(unsigned int i = 0; i < infiles.size(); i++){ cout << "Input file: " << infiles[i] << endl; if( infiles[i].find("HT-100") != std::string::npos ) f_DY100 = getFile(infiles[i].data(), xSecDY100, &scaleDY100); if( infiles[i].find("HT-200") != std::string::npos ) f_DY200 = getFile(infiles[i].data(), xSecDY200, &scaleDY200); if( infiles[i].find("HT-400") != std::string::npos ) f_DY400 = getFile(infiles[i].data(), xSecDY400, &scaleDY400); if( infiles[i].find("HT-600") != std::string::npos ) f_DY600 = getFile(infiles[i].data(), xSecDY600, &scaleDY600); if( infiles[i].find("TT_") != std::string::npos ) f_TTbar = getFile(infiles[i].data(), xSecTTbar, &scaleTTbar); if( infiles[i].find("WW_") != std::string::npos ) f_WW = getFile(infiles[i].data(), xSecWW, &scaleWW); if( infiles[i].find("WZ_") != std::string::npos ) f_WZ = getFile(infiles[i].data(), xSecWZ, &scaleWZ); if( infiles[i].find("ZZ_") != std::string::npos ) f_ZZ = getFile(infiles[i].data(), xSecZZ, &scaleZZ); if( infiles[i].find("V3_2015") != std::string::npos ) f_data0 = getFile(infiles[i].data(), dummy, &dummy); if( infiles[i].find("V4_2015") != std::string::npos ) f_data1 = getFile(infiles[i].data(), dummy, &dummy); } setNCUStyle(true); Double_t up_height = 0.8; Double_t dw_correction = 1.455; Double_t dw_height = (1-up_height)*dw_correction; TCanvas c("c","",0,0,1000,800); c.Divide(1,2); TPad* c_up = (TPad*) c.GetListOfPrimitives()->FindObject("c_1"); TPad* c_dw = (TPad*) c.GetListOfPrimitives()->FindObject("c_2"); c_up->SetPad(0,1-up_height,1,1); c_dw->SetPad(0,0,1,dw_height); c_dw->SetBottomMargin(0.25); // To get the name of histograms TFile *f_ = TFile::Open(infiles[0].data()); f_->cd(); TDirectory *current_sourcedir = gDirectory; TIter nextkey( current_sourcedir->GetListOfKeys() ); TKey *key; vector<std::string> h_name; while ( (key = (TKey*)nextkey()) ) { TObject *obj = key->ReadObj(); if ( obj->IsA()->InheritsFrom("TH1") ) h_name.push_back(obj->GetTitle()); } // Draw and output for(unsigned int i = 0; i < h_name.size()-1; i++){ if( h_name[i]=="eleHoverE" || h_name[i]=="eleMiniIso" || h_name[i]=="muMiniIso" ) c_up->cd()->SetLogy(1); else c_up->cd()->SetLogy(0); myPlot(((TH1D*)(f_DY100->Get(h_name[i].data()))), ((TH1D*)(f_DY200->Get(h_name[i].data()))), ((TH1D*)(f_DY400->Get(h_name[i].data()))), ((TH1D*)(f_DY600->Get(h_name[i].data()))), ((TH1D*)(f_TTbar->Get(h_name[i].data()))), ((TH1D*)(f_WW->Get(h_name[i].data()))), ((TH1D*)(f_WZ->Get(h_name[i].data()))), ((TH1D*)(f_ZZ->Get(h_name[i].data()))), ((TH1D*)(f_data0->Get(h_name[i].data()))), ((TH1D*)(f_data1->Get(h_name[i].data()))), scaleDY100, scaleDY200, scaleDY400, scaleDY600, scaleTTbar, scaleWW, scaleWZ, scaleZZ); c_up->RedrawAxis(); c_dw->cd(); myRatio(((TH1D*)(f_DY100->Get(h_name[i].data()))), ((TH1D*)(f_DY200->Get(h_name[i].data()))), ((TH1D*)(f_DY400->Get(h_name[i].data()))), ((TH1D*)(f_DY600->Get(h_name[i].data()))), ((TH1D*)(f_TTbar->Get(h_name[i].data()))), ((TH1D*)(f_WW->Get(h_name[i].data()))), ((TH1D*)(f_WZ->Get(h_name[i].data()))), ((TH1D*)(f_ZZ->Get(h_name[i].data()))), ((TH1D*)(f_data0->Get(h_name[i].data()))), ((TH1D*)(f_data1->Get(h_name[i].data()))), scaleDY100, scaleDY200, scaleDY400, scaleDY600, scaleTTbar, scaleWW, scaleWZ, scaleZZ); c.Draw(); if( i == 0 ) c.Print(Form("%s.pdf(", pdfName.data()), "pdf"); else if( i == h_name.size()-2 ) c.Print(Form("%s.pdf)", pdfName.data()), "pdf"); else c.Print(Form("%s.pdf", pdfName.data()), "pdf"); } }
void dataMCplots_v2(){ setNCUStyle(true); Float_t up_height = 0.8; Float_t dw_correction = 1.455; Float_t dw_height = (1-up_height)*dw_correction; TCanvas c("c","",0,0,800,1600); c.Divide(1,2); TPad* c_up = (TPad*) c.GetListOfPrimitives()->FindObject("c_1"); TPad* c_dw = (TPad*) c.GetListOfPrimitives()->FindObject("c_2"); c_up->SetPad(0,1-up_height,1,1); c_dw->SetPad(0,0,1,dw_height); c_dw->SetBottomMargin(0.25); // To get the name of histograms TFile* tf1[10]; tf1[0]=TFile::Open("sf2/QCD700.root"); tf1[1]=TFile::Open("sf2/QCD1000.root"); tf1[2]=TFile::Open("sf2/QCD1500.root"); tf1[3]=TFile::Open("sf2/QCD2000.root"); tf1[4]=TFile::Open("sf2/data.root"); tf1[5]=TFile::Open("sf2/bGen700.root"); tf1[6]=TFile::Open("sf2/bGen1000.root"); tf1[7]=TFile::Open("sf2/bGen1500.root"); tf1[8]=TFile::Open("sf2/bGen2000.root"); TFile* tf2[10]; tf2[0]=TFile::Open("sf2/B1400.root"); tf2[1]=TFile::Open("sf2/B1800.root"); tf2[2]=TFile::Open("sf2/B2500.root"); tf2[3]=TFile::Open("sf2/R1800.root"); vector<std::string> h_name; h_name.push_back("h_nvtx"); for(int i=0;i<2;i++){ for(int j=0;j<2;j++){ for(int k=0;k<5;k++){ h_name.push_back(Form("Pt_j%d_sj%d_%db",i,j,k)); h_name.push_back(Form("Eta_j%d_sj%d_%db",i,j,k)); h_name.push_back(Form("subCSV_j%d_sj%d_%db",i,j,k)); h_name.push_back(Form("subCSVCut_j%d_sj%d_%db",i,j,k)); } } for(int k=0;k<5;k++){ h_name.push_back(Form("deltaR_j%d_%db",i,k)); h_name.push_back(Form("Pt_j%d_%db",i,k)); h_name.push_back(Form("Eta_j%d_%db",i,k)); h_name.push_back(Form("prMassL2L3_j%d_%db",i,k)); h_name.push_back(Form("tau21_j%d_%db",i,k)); h_name.push_back(Form("PuppiSDMassL2L3_j%d_%db",i,k)); h_name.push_back(Form("puppiTau21_j%d_%db",i,k)); h_name.push_back(Form("prMass_j%d_%db",i,k)); h_name.push_back(Form("PuppiSDMass_j%d_%db",i,k)); h_name.push_back(Form("doubleSV_j%d_%db",i,k)); h_name.push_back(Form("FatSV_j%d_%db",i,k)); } } for(int k=0;k<5;k++){ h_name.push_back(Form("totalMass_%db",k)); h_name.push_back(Form("totalMassRed_%db",k)); h_name.push_back(Form("deltaEta_%db",k)); //h_name.push_back(Form("HT_%db",k)); } // h_name.push_back("cutflow"); string prMass_no[4]={"prMass","prMassL2L3","PuppiSDMass","PuppiSDMassL2L3"}; string tau21_no[2]={"tau21","puppiTau21"}; for (int i=0;i<4;i++){ h_name.push_back(Form("%s_j0_noPr_noTau21",prMass_no[i].data())); h_name.push_back(Form("%s_j1_noPr_noTau21",prMass_no[i].data())); h_name.push_back(Form("%s_j0_noPr",prMass_no[i].data())); h_name.push_back(Form("%s_j1_noPr",prMass_no[i].data())); h_name.push_back(Form("%s_j0_noTau21",prMass_no[i].data())); h_name.push_back(Form("%s_j1_noTau21",prMass_no[i].data())); } for (int i=0;i<2;i++){ h_name.push_back(Form("%s_j0_noPr_noTau21",tau21_no[i].data())); h_name.push_back(Form("%s_j1_noPr_noTau21",tau21_no[i].data())); h_name.push_back(Form("%s_j0_noPr",tau21_no[i].data())); h_name.push_back(Form("%s_j1_noPr",tau21_no[i].data())); h_name.push_back(Form("%s_j0_noTau21",tau21_no[i].data())); h_name.push_back(Form("%s_j1_noTau21",tau21_no[i].data())); } h_name.push_back("h_nvtx_cut"); h_name.push_back("Nbtagjet"); for(unsigned int i = 0; i < h_name.size(); i++){ // for(unsigned int i = 0; i < 1; i++){ //cout<<h_name[i]<<endl; TH1D *th1[10]; for(int k=0;k<5;k++){ th1[k]=(TH1D* )tf1[k]->FindObjectAny(Form("%s",h_name[i].data())); } if(h_name[i].find("3b")!= std::string::npos)continue; if(h_name[i].find("2b")!= std::string::npos)continue; if(h_name[i].find("1b")!= std::string::npos)continue; if(h_name[i].find("0b")!= std::string::npos)continue; //if(h_name[i].find("4b")!= std::string::npos)continue; bool drawSignal=1; //--------- TH1D* thh[5][4]; double fixNumber=22295/30584.3;//7306/11857.3; double Xsec[4]={6831,1207,119.9,25.24}; //string categories[4]={"0b","1b","2b","DSV"}; string hadflv[4]={"bb","b","cc","udcsg"}; TString endfix; endfix=gSystem->GetFromPipe(Form("file=%s; test=${file%%*_}; echo \"${test}\"",h_name[i].data())); for(int k=0;k<4;k++){ for(int j=0;j<4;j++){ TH1D *th2=(TH1D* )tf1[k]->FindObjectAny("cutflow"); thh[k][j]=(TH1D*)tf1[k]->FindObjectAny(Form("%s_%s",h_name[i].data(),hadflv[j].data())); TString endfix; if(h_name[i].find("4b")!= std::string::npos){ endfix=gSystem->GetFromPipe(Form("file=%s; test=${file%%*_4b}; echo \"${test}\"",h_name[i].data())); TH1D *th2; //cout<<endfix<<endl; th2=(TH1D* )tf1[k]->FindObjectAny(Form("%s_0b_%s",endfix.Data(),hadflv[j].data())); thh[k][j]->Add(th2); th2=(TH1D* )tf1[k]->FindObjectAny(Form("%s_1b_%s",endfix.Data(),hadflv[j].data())); thh[k][j]->Add(th2); th2=(TH1D* )tf1[k]->FindObjectAny(Form("%s_2b_%s",endfix.Data(),hadflv[j].data())); thh[k][j]->Add(th2); th2=(TH1D* )tf1[k]->FindObjectAny(Form("%s_3b_%s",endfix.Data(),hadflv[j].data())); thh[k][j]->Add(th2); } thh[k][j]->Scale(fixNumber* 12883.846147301*Xsec[k]/th2->GetBinContent(1)); // cout<<k<<","<<j<<","<<Form("%s_%s",h_name[i].data(),hadflv[j].data())<<","<<thh[k][j]->Integral()<<endl; } if(k==3){ for(int j=0;j<4;j++)thh[k][j]->Add(thh[0][j]); for(int j=0;j<4;j++)thh[k][j]->Add(thh[1][j]); for(int j=0;j<4;j++)thh[k][j]->Add(thh[2][j]); } } vector<TH1D* > v2; vector<TH1D* > vd; thh[4][0]=(TH1D*)tf1[4]->FindObjectAny(Form("%s_udcsg",h_name[i].data())); if(h_name[i].find("4b")!= std::string::npos){ endfix=gSystem->GetFromPipe(Form("file=%s; test=${file%%*_4b}; echo \"${test}\"",h_name[i].data())); TH1D *th2; th2=(TH1D* )tf1[4]->FindObjectAny(Form("%s_0b_udcsg",endfix.Data())); thh[4][0]->Add(th2); th2=(TH1D* )tf1[4]->FindObjectAny(Form("%s_1b_udcsg",endfix.Data())); thh[4][0]->Add(th2); th2=(TH1D* )tf1[4]->FindObjectAny(Form("%s_2b_udcsg",endfix.Data())); thh[4][0]->Add(th2); th2=(TH1D* )tf1[4]->FindObjectAny(Form("%s_3b_udcsg",endfix.Data())); thh[4][0]->Add(th2); } cout<<thh[4][0]->Integral(); v2.push_back(thh[3][0]); v2.push_back(thh[3][1]); v2.push_back(thh[3][2]); v2.push_back(thh[3][3]); double temp_scale=0; for(int i=0;i<4;i++){ temp_scale+=thh[3][i]->Integral(); } for(int i=0;i<4;i++){ if(h_name[i].find("HT")!= std::string::npos)continue; thh[3][i]->Scale(thh[4][0]->Integral()/temp_scale); } vd.push_back(thh[4][0]); //-------- TH1D *h_bkg = (TH1D* )th1[0]->Clone("h_bkg"); //TH1D *temp = (TH1D* )th1[0]->Clone("h_bkg"); TH1D *h_data = (TH1D* )th1[0]->Clone("h_data"); /* h_data->SetTitle(Form("%s",endfix.Data())); h_bkg->SetTitle(Form("%s",endfix.Data())); c_up->SetTitle(Form("%s",endfix.Data())); c.SetTitle(Form("%s",endfix.Data())); */ h_data->SetTitle(""); h_bkg->SetTitle(""); c_up->SetTitle(""); c_up->cd(); if (h_name[i].find("Nbtagjet")!= std::string::npos)c_up->SetLogy(); // if(h_name[i].find("cutflow")!= std::string::npos)c_up->SetLogy(); if(h_name[i].find("Pt")!= std::string::npos)isSetRange=1; if(h_name[i].find("logPt")!= std::string::npos){ isSetRange=0; c_up->SetLogy(1); } if(h_name[i].find("total")!= std::string::npos)isSetRange=1; double scaleTemp[4]; //vd.push_back(th1[4]); cout<<h_name[i]<<endl; myPlot(v2, vd, h_data, h_bkg,1); c_up->RedrawAxis(); if(drawSignal){ int colorNum[4]={kRed,kBlue,kOrange+2,kViolet}; double xsec2[4]={1.9,0.155,0.0158,17.3}; TH1D* th_signal[4]; TLegend *leg = new TLegend(0.63, 0.68, 0.78, 0.87); string legendS[4]={"M_{G}=1.4TeV","M_{G}=1.8TeV","M_{G}=2.5TeV","M_{R}=1.8TeV"}; leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetFillStyle(0); leg->SetTextSize(0.04); for(int k=0;k<4;k++){ th_signal[k]=(TH1D*)tf2[k]->FindObjectAny(Form("%s",h_name[i].data())); leg->AddEntry(th_signal[k],Form("%s",legendS[k].data())); th_signal[k]->SetLineColor(colorNum[k]); th_signal[k]->SetLineWidth(2); // th_signal[k]->SetLineStyle(k+1); TString endfix; if(h_name[i].find("4b")!= std::string::npos){ endfix=gSystem->GetFromPipe(Form("file=%s; test=${file%%*_4b}; echo \"${test}\"",h_name[i].data())); TH1D *th2; th2=(TH1D* )tf2[k]->FindObjectAny(Form("%s_0b",endfix.Data())); th_signal[k]->Add(th2); th2=(TH1D* )tf2[k]->FindObjectAny(Form("%s_1b",endfix.Data())); th_signal[k]->Add(th2); th2=(TH1D* )tf2[k]->FindObjectAny(Form("%s_2b",endfix.Data())); th_signal[k]->Add(th2); th2=(TH1D* )tf2[k]->FindObjectAny(Form("%s_3b",endfix.Data())); th_signal[k]->Add(th2); } TH1D *th3=(TH1D* )tf2[k]->FindObjectAny("cutflow"); //cout<<"k="<<k<<","<<th2->GetBinContent(1)<<","<<12.883846147301*xsec2[k]*200/th2->GetBinContent(1)<<endl; th_signal[k]->Scale(thh[4][0]->Integral()/(th_signal[k]->Integral()*2)); if(h_name[i].find("deltaR")!= std::string::npos)th_signal[k]->Scale(0.5); if(h_name[i].find("noPr")!= std::string::npos && h_name[i].find("noPr_")== std::string::npos&& h_name[i].find("tau21")== std::string::npos)th_signal[k]->Scale(0.4); //if(k<3)th_signal[k]->Scale(10); cout<<th_signal[k]->Integral()<<","; th_signal[k]->Draw("same hist "); } leg->Draw("same"); } c_dw->cd(); string tempName=h_name[i]; if(h_name[i].find("Eta")!= std::string::npos){ TString endfix2; endfix2=gSystem->GetFromPipe(Form("file=%s; test=${file##Eta}; echo \"${test}\"",h_name[i].data())); h_name[i]=Form("#eta%s",endfix2.Data()); } if(h_name[i].find("tau")!= std::string::npos){ TString endfix2; endfix2=gSystem->GetFromPipe(Form("file=%s; test=${file##tau}; echo \"${test}\"",h_name[i].data())); h_name[i]=Form("#tau%s",endfix2.Data()); } if (h_name[i].find("total")!= std::string::npos)myRatio(h_data, h_bkg,"M_{jj}[GeV]"); else if (h_name[i].find("_j0")!= std::string::npos){ TString endfix2; endfix2=gSystem->GetFromPipe(Form("file=%s; test=${file%%*_j0*}; echo \"${test}\"",h_name[i].data())); //cout<<endfix2<<endl; if (h_name[i].find("_sj0")!= std::string::npos) myRatio(h_data, h_bkg,Form("%s^{Jet0}_{subjet0}",endfix2.Data())); else if (h_name[i].find("_sj1")!= std::string::npos) myRatio(h_data, h_bkg,Form("%s^{Jet0}_{subjet1}",endfix2.Data())); else myRatio(h_data, h_bkg,Form("%s^{Jet0}",endfix2.Data())); } else if (h_name[i].find("_j1")!= std::string::npos){ TString endfix2; endfix2=gSystem->GetFromPipe(Form("file=%s; test=${file%%*_j1*}; echo \"${test}\"",h_name[i].data())); //cout<<endfix2<<endl; if (h_name[i].find("_sj0")!= std::string::npos) myRatio(h_data, h_bkg,Form("%s^{Jet1}_{subjet0}",endfix2.Data())); else if (h_name[i].find("_sj1")!= std::string::npos) myRatio(h_data, h_bkg,Form("%s^{Jet1}_{subjet1}",endfix2.Data())); else myRatio(h_data, h_bkg,Form("%s^{Jet1}",endfix2.Data())); } else if(h_name[i].find("Pt")!= std::string::npos|| //h_name[i].find("total")!= std::string::npos|| h_name[i].find("ass")!= std::string::npos)myRatio(h_data, h_bkg,Form("%s[GeV]",endfix.Data())); else if (h_name[i].find("Nbtagje")!= std::string::npos)myRatio(h_data, h_bkg,"Nbtagjet",1); else myRatio(h_data, h_bkg,Form("%s",endfix.Data())); h_name[i]=tempName; if(h_name[i].find("Pt")!= std::string::npos)isSetRange=0; if(h_name[i].find("total")!= std::string::npos)isSetRange=0; // c.Draw(); if(h_name[i].find("0b")!= std::string::npos)c.SaveAs(Form("dataMC_v2/0b/%s.png",h_name[i].data())); else if(h_name[i].find("1b")!= std::string::npos)c.SaveAs(Form("dataMC_v2/1b/%s.png",h_name[i].data())); else if(h_name[i].find("2b")!= std::string::npos)c.SaveAs(Form("dataMC_v2/2b/%s.png",h_name[i].data())); else if(h_name[i].find("4b")!= std::string::npos)c.SaveAs(Form("dataMC_v2/all/%s.png",endfix.Data())); else c.SaveAs(Form("dataMC_v2/all/%s.png",h_name[i].data())); if(h_name[i].find("0b")!= std::string::npos)c.Print(Form("dataMC_v2/0b/%s.pdf",h_name[i].data())); else if(h_name[i].find("1b")!= std::string::npos)c.Print(Form("dataMC_v2/1b/%s.pdf",h_name[i].data())); else if(h_name[i].find("2b")!= std::string::npos)c.Print(Form("dataMC_v2/2b/%s.pdf",h_name[i].data())); else if(h_name[i].find("4b")!= std::string::npos)c.Print(Form("dataMC_v2/all/%s.pdf",endfix.Data())); else c.Print(Form("dataMC_v2/all/%s.pdf",h_name[i].data())); if(h_name[i].find("logPt")!= std::string::npos){ isSetRange=0; c_up->SetLogy(0); } } }
void uncert_JES() { setNCUStyle(); c1 = new TCanvas("c1","",1360,768); TFile* tf1[11],* tf2[11]; TFile* tf3[11],* tf4[11]; TFile* tf5[11],* tf6[11]; string st[11]= {"1000","1200","1400","1600","1800","2000","2500","3000","3500","4000","4500"}; for (int i=0; i<11; i++)tf1[i]=TFile::Open(Form("../sf/B%s.root",st[i].data())); for (int i=0; i<11; i++)tf3[i]=TFile::Open(Form("../sf/B%s_JESUp.root",st[i].data())); for (int i=0; i<11; i++)tf5[i]=TFile::Open(Form("../sf/B%s_JESDown.root",st[i].data())); for (int i=0; i<11; i++)tf2[i]=TFile::Open(Form("../sf/R%s.root",st[i].data())); double x[11]= {1000,1200,1400,1600,1800,2000,2500,3000,3500,4000,4500}; double xx[11]= {1000,1200,1400,1600,1800,2000,2500,3000,4000,4500}; double y[6][11]; for (int i=0; i<11; i++) { TH1D * th1= (TH1D *)tf1[i]->FindObjectAny("totalMass"); y[0][i]=th1->GetMean(); th1=(TH1D *)tf3[i]->FindObjectAny("totalMass"); y[1][i]=th1->GetMean(); th1=(TH1D *)tf5[i]->FindObjectAny("totalMass"); y[2][i]=th1->GetMean(); y[1][i]/=y[0][i]; y[2][i]/=y[0][i]; y[0][i]/=y[0][i]; } double yy[6][10]; for (int i=0; i<11; i++) { if(i>=8) { yy[0][i]=y[0][i+1]; yy[1][i]=y[1][i+1]; yy[2][i]=y[2][i+1]; } else { yy[0][i]=y[0][i]; yy[1][i]=y[1][i]; yy[2][i]=y[2][i]; } } //TGraph * tg1=new TGraph(11,x,y[0]); //TGraph * tg2=new TGraph(11,x,y[1]); //TGraph * tg3=new TGraph(11,x,y[2]); TGraph * tg1=new TGraph(10,xx,yy[0]); TGraph * tg2=new TGraph(10,xx,yy[1]); TGraph * tg3=new TGraph(10,xx,yy[2]); tg1->SetTitle("JES uncertainty"); tg2->SetTitle("JES_up fit"); tg3->SetTitle("JES_down fit"); tg1->SetLineColor(1); tg2->SetLineColor(2); tg3->SetLineColor(3); tg1->SetFillColor(kWhite); tg2->SetFillColor(kWhite); tg3->SetFillColor(kWhite); tg1->GetXaxis()->SetTitle("M_{X}[GeV]"); tg1->GetYaxis()->SetTitle("Mean/Mean_{central}"); tg1->SetMaximum(1.02); tg1->SetMinimum(0.98); tg1->Draw("APL"); tg2->Draw("PL,same"); tg3->Draw("PL,same"); TLegend* leg ; leg=new TLegend(0.391452,0.712447,0.590645,0.863966); leg->AddEntry(tg1,"JES_central"); leg->AddEntry(tg2,"JES_up"); leg->AddEntry(tg3,"JES_down"); leg->Draw("same"); c1->Print("plot/all.pdf"); TF1 *fa1 = new TF1("fa1","[0]+[1]*x",1000,4500); TF1 *fa2 = new TF1("fa1","[0]+[1]*x",1000,4500); tg2->Fit(fa1); fa1->SetLineColor(4); tg2->Draw("APL"); fa1->Draw("same"); c1->Print("plot/fit_up.pdf"); tg3->Fit(fa2); fa2->SetLineColor(4); tg3->Draw("APL"); fa2->Draw("same"); c1->Print("plot/fit_down.pdf"); }
void plotHitEnergy(string inputDir, float radius=0.4){ setNCUStyle(true); TH1F* hecal; TH1F* hhcal; TString energy=gSystem->GetFromPipe(Form("file=%s; test=${file##*/}; test2=${test%%mumu*}; echo \"${test2##*tev}\"",inputDir.data())); cout << "energy = " << energy.Data() << endl; string inputFile = inputDir + "/radius" + Form("%0.1f",radius)+ "_rawhit.root"; cout << "opening " << inputFile.data() << endl; TFile *f = TFile::Open(inputFile.data()); hecal = (TH1F*)f->FindObjectAny("hecalhit_energy"); hecal->SetLineWidth(3); hecal->SetFillStyle(1001); hecal->SetFillColor(4); hecal->SetLineColor(4); hecal->SetXTitle("EM_BARREL hit energy [GeV]"); hecal->SetYTitle(Form("Number of hits per %d GeV",(int)hecal->GetBinWidth(1))); hecal->SetTitleOffset(1.2,"X"); hecal->SetTitleOffset(1.4,"Y"); hhcal = (TH1F*)f->FindObjectAny("hhcalhit_energy"); hhcal->SetLineWidth(3); hhcal->SetFillStyle(1001); hhcal->SetFillColor(2); hhcal->SetLineColor(2); hhcal->SetXTitle("HAD_BARREL hit energy [GeV]"); hhcal->SetYTitle(Form("Number of hits per %d GeV",(int)hhcal->GetBinWidth(1))); hhcal->SetTitleOffset(1.2,"X"); hhcal->SetTitleOffset(1.4,"Y"); TLegend* leg = new TLegend(0.444,0.690,0.990,0.903); leg->SetFillColor(0); leg->SetFillStyle(0); TCanvas* c1 = new TCanvas("c1","",500,500); int lastbin=hecal->FindLastBinAbove(0)+50; float xmax=hecal->GetBinLowEdge(lastbin); hecal->GetXaxis()->SetRangeUser(0,xmax); hecal->Draw("hist"); c1->SetLogy(1); leg->SetHeader("rfull012"); leg->AddEntry(hecal,Form("%s-TeV Z'#rightarrow qq",energy.Data()),"f"); leg->Draw("same"); c1->Print(Form("rfull012/rfull012_EM_BARREL_hit_energy_%sTeVZp.pdf",energy.Data())); c1->Print(Form("rfull012/rfull012_EM_BARREL_hit_energy_%sTeVZp.eps",energy.Data())); leg->Clear(); lastbin=hhcal->FindLastBinAbove(0)+50; xmax=hhcal->GetBinLowEdge(lastbin); hhcal->GetXaxis()->SetRangeUser(0,xmax); hhcal->Draw("hist"); c1->SetLogy(1); leg->SetHeader("rfull012"); leg->AddEntry(hhcal,Form("%s-TeV Z'#rightarrow qq",energy.Data()),"f"); leg->Draw("same"); c1->Print(Form("rfull012/rfull012_HAD_BARREL_hit_energy_%sTeVZp.pdf",energy.Data())); c1->Print(Form("rfull012/rfull012_HAD_BARREL_hit_energy_%sTeVZp.eps",energy.Data())); }