コード例 #1
0
void AnalyzeBKGShape(TString folder, TString sample1, TString sample2){
    gStyle->SetOptStat(000000);

    TH1::SetDefaultSumw2();

    TFile *f= TFile::Open("/Users/Tita/Desktop/analysis_HH_bbTauTau/src/HHbbTauTau/data/datacards_tautau_try_2/htt_tt.inputs-Hhh-8TeV.root");

    TH1D *histo_QCD = (TH1D*)f->Get((folder+"/"+sample1));
    TH1D *histo_QCDalt = (TH1D*)f->Get((folder+"/"+sample2));

    TCanvas * c1 = new TCanvas("c1","c1", 800,800);


    histo_QCD->Scale(1/(histo_QCD->Integral()),"width");

    histo_QCD->SetLineColor(kBlue);
    histo_QCD->SetMarkerColor(kBlue);
    histo_QCD->SetMarkerStyle(20);

    histo_QCDalt->Scale(1/(histo_QCDalt->Integral()),"width");

    histo_QCDalt->SetLineColor(kRed);
    histo_QCDalt->SetMarkerColor(kRed);
    histo_QCDalt->SetMarkerStyle(20);

    histo_QCD->Draw("");
    histo_QCDalt->Draw("same");

    cout<<"--------------------------------------------------------------KS--------------------------------------------------------------"<<endl;
    cout<<"**************************"<<endl;
    cout<<" Kolmogorov Test: "<<histo_QCD->KolmogorovTest(histo_QCDalt,"")<<endl;

    cout<<"**************************"<<endl;
    histo_QCD->SetTitle("QCD shape ");
    histo_QCD->GetXaxis()->SetTitle("M_{H} [GeV]");
    histo_QCD->GetYaxis()->SetTitleOffset(1.5);
    histo_QCD->GetYaxis()->SetTitle("Normalized Events");
//    histo_0tag_Difference->SetMaximum(8);

    TLegend* legend = new TLegend(0.6, 0.65, 0.99, 0.9);
    legend->SetFillColor(0);
    legend->SetTextSize(0.03);
    legend->SetEntrySeparation(0.05);
    legend->AddEntry(histo_QCD, "QCD" );
    legend->AddEntry(histo_QCDalt, "QCD alt" );

    legend->Draw();

    c1->SaveAs("./QCD_shape_"+folder+".pdf");

}
コード例 #2
0
void AnalyzeESshape(/*TString datacards_folder,*/ TString folder_0tag, TString folder_1tag, TString folder_2tag,
                     TString sample){
	gStyle->SetOptStat(000000);
	
	TH1::SetDefaultSumw2();
	
    TFile *f= TFile::Open("/Users/Tita/Desktop/analysis_HH_bbTauTau/Limits/auxiliaries/shapes/Italians/htt_tt.inputs-Hhh-8TeV.root");
	
    TH1D *histo_0tag_Up = (TH1D*)f->Get((folder_0tag+"/"+sample+"_CMS_scale_t_tautau_8TeVUp"));
    TH1D *histo_0tag_Central = (TH1D*)f->Get((folder_0tag+"/"+sample));
    TH1D *histo_0tag_Down = (TH1D*)f->Get((folder_0tag+"/"+sample+"_CMS_scale_t_tautau_8TeVDown"));
    TH1D *histo_1tag_Up = (TH1D*)f->Get((folder_1tag+"/"+sample+"_CMS_scale_t_tautau_8TeVUp"));
    TH1D *histo_1tag_Central = (TH1D*)f->Get((folder_1tag+"/"+sample));
    TH1D *histo_1tag_Down = (TH1D*)f->Get((folder_1tag+"/"+sample+"_CMS_scale_t_tautau_8TeVDown"));
    TH1D *histo_2tag_Up = (TH1D*)f->Get((folder_2tag+"/"+sample+"_CMS_scale_t_tautau_8TeVUp"));
    TH1D *histo_2tag_Central = (TH1D*)f->Get((folder_2tag+"/"+sample));
    TH1D *histo_2tag_Down = (TH1D*)f->Get((folder_2tag+"/"+sample+"_CMS_scale_t_tautau_8TeVDown"));

	
		
	TCanvas * c1 = new TCanvas("c1","c1", 800,800);

    TH1D* histo_0tag_Up_Central = (TH1D*)histo_0tag_Up->Clone("histo_0tag_Up_Central");
    histo_0tag_Up_Central->Divide(histo_0tag_Central);

    histo_0tag_Up_Central->SetLineColor(kBlue);
    histo_0tag_Up_Central->SetMarkerColor(kBlue);
    histo_0tag_Up_Central->SetMarkerStyle(20);

    TH1D* histo_1tag_Up_Central = (TH1D*)histo_1tag_Up->Clone("histo_1tag_Up_Central");
    histo_1tag_Up_Central->Divide(histo_1tag_Central);

    histo_1tag_Up_Central->SetLineColor(kRed);
    histo_1tag_Up_Central->SetMarkerColor(kRed);
    histo_1tag_Up_Central->SetMarkerStyle(20);

    TH1D* histo_2tag_Up_Central = (TH1D*)histo_2tag_Up->Clone("histo_2tag_Up_Central");
    histo_2tag_Up_Central->Divide(histo_2tag_Central);

    histo_2tag_Up_Central->SetLineColor(kBlack);
    histo_2tag_Up_Central->SetMarkerColor(kBlack);
    histo_2tag_Up_Central->SetMarkerStyle(20);
	
    
    
    histo_0tag_Up_Central->Draw("");
    histo_1tag_Up_Central->Draw("same");
    histo_2tag_Up_Central->Draw("same");
    
    

    
    cout<<"--------------------------------------------------------------KS   "<<sample<<"  --------------------------------------------------------------"<<endl;
    cout<<"**************************"<<endl;
    cout<<" Kolmogorov Test 0tag-1tag: "<<histo_0tag_Up_Central->KolmogorovTest(histo_1tag_Up_Central,"")<<endl;
    cout<<" Kolmogorov Test 0tag-2tag: "<<histo_0tag_Up_Central->KolmogorovTest(histo_2tag_Up_Central,"")<<endl;
    cout<<" Kolmogorov Test 1tag-2tag: "<<histo_1tag_Up_Central->KolmogorovTest(histo_2tag_Up_Central,"")<<endl;
    cout<<"**************************"<<endl;
    histo_0tag_Up_Central->SetTitle("Scale Up/ Central - "+sample);
    histo_0tag_Up_Central->GetXaxis()->SetTitle("M_{H} [GeV]");
    histo_0tag_Up_Central->GetYaxis()->SetTitleOffset(1.5);
    histo_0tag_Up_Central->GetYaxis()->SetTitle("Normalized Events");
    histo_0tag_Up_Central->SetMaximum(3.5);
		
	TLegend* legend = new TLegend(0.6, 0.65, 0.99, 0.9);
	legend->SetFillColor(0);
	legend->SetTextSize(0.03);
	legend->SetEntrySeparation(0.05);
    legend->AddEntry(histo_0tag_Up_Central, "2jet0tag" );
    legend->AddEntry(histo_1tag_Up_Central, "2jet1tag" );
    legend->AddEntry(histo_2tag_Up_Central, "2jet2tag" );
	
	legend->Draw();
	
    c1->SaveAs("./UP_CENTRAL_"+sample+".pdf");

    TCanvas * c2 = new TCanvas("c2","c2", 800,800);

    TH1D* histo_0tag_Down_Central = (TH1D*)histo_0tag_Down->Clone("histo_0tag_Down_Central");
    histo_0tag_Down_Central->Divide(histo_0tag_Central);

    histo_0tag_Down_Central->SetLineColor(kBlue);
    histo_0tag_Down_Central->SetMarkerColor(kBlue);
    histo_0tag_Down_Central->SetMarkerStyle(20);

    TH1D* histo_1tag_Down_Central = (TH1D*)histo_1tag_Down->Clone("histo_1tag_Down_Central");
    histo_1tag_Down_Central->Divide(histo_1tag_Central);

    histo_1tag_Down_Central->SetLineColor(kRed);
    histo_1tag_Down_Central->SetMarkerColor(kRed);
    histo_1tag_Down_Central->SetMarkerStyle(20);

    TH1D* histo_2tag_Down_Central = (TH1D*)histo_2tag_Down->Clone("histo_2tag_Down_Central");
    histo_2tag_Down_Central->Divide(histo_2tag_Central);

    histo_2tag_Down_Central->SetLineColor(kBlack);
    histo_2tag_Down_Central->SetMarkerColor(kBlack);
    histo_2tag_Down_Central->SetMarkerStyle(20);



    histo_0tag_Down_Central->Draw("");
    histo_1tag_Down_Central->Draw("same");
    histo_2tag_Down_Central->Draw("same");




    cout<<"--------------------------------------------------------------KS   "<<sample<<"  --------------------------------------------------------------"<<endl;
    cout<<"**************************"<<endl;
    cout<<" Kolmogorov Test 0tag-1tag: "<<histo_0tag_Down_Central->KolmogorovTest(histo_1tag_Down_Central,"")<<endl;
    cout<<" Kolmogorov Test 0tag-2tag: "<<histo_0tag_Down_Central->KolmogorovTest(histo_2tag_Down_Central,"")<<endl;
    cout<<" Kolmogorov Test 1tag-2tag: "<<histo_1tag_Down_Central->KolmogorovTest(histo_2tag_Down_Central,"")<<endl;
    cout<<"**************************"<<endl;
    histo_0tag_Down_Central->SetTitle("Scale Down/ Central - "+sample);
    histo_0tag_Down_Central->GetXaxis()->SetTitle("M_{H} [GeV]");
    histo_0tag_Down_Central->GetYaxis()->SetTitleOffset(1.5);
    histo_0tag_Down_Central->GetYaxis()->SetTitle("Normalized Events");
    histo_0tag_Down_Central->SetMaximum(2.5);

    TLegend* legend = new TLegend(0.6, 0.65, 0.99, 0.9);
    legend->SetFillColor(0);
    legend->SetTextSize(0.03);
    legend->SetEntrySeparation(0.05);
    legend->AddEntry(histo_0tag_Down_Central, "2jet0tag" );
    legend->AddEntry(histo_1tag_Down_Central, "2jet1tag" );
    legend->AddEntry(histo_2tag_Down_Central, "2jet2tag" );

    legend->Draw();

    c2->SaveAs("./DOWN_CENTRAL_"+sample+".pdf");
}
コード例 #3
0
void comparisonMCdataVsPV(){

  std::vector<TH1D*> IsoEcalplotsBarrelNotRemoved;
  std::vector<TH1D*> IsoEcalplotsBarrelRemoved;

  int numbofvertices=15;

	gROOT->ForceStyle();
	setTDRStyle();
	TFile *dataf = TFile::Open("rfio:/castor/cern.ch/user/m/marone/ZJets/results/PreselectionMay10_v1_1.root"); //data file
	TFile *dataremoved = TFile::Open("rfio:/castor/cern.ch/user/m/marone/ZJets/results/PreselectionMay10PURemoved_v1_1.root");


	for (int i=1;i<numbofvertices;i++){
	  //set the string
	  stringstream oss;
	  oss<<i;
	  string name=" Number of Vertices="+oss.str();
	  cout<<name<<endl;
	  string cut="numberOfVertices=="+oss.str();
	  cout<<cut<<endl;

	//DATA	
	dataf->cd("demo");

	//Creazione degli istogrammi
	//FIXME da duplicare per il file di MC
	//EB data

	TH1D *h_ieEB_data = new TH1D("h_ieEB_data","IsoEcal EB",40,0.,0.40);
	treeVJ_->Draw("IsoEcalEB>>h_ieEB_data",cut.c_str());

	TH1D *h_ihEB_data = new TH1D("h_ihEB_data","IsoHcal EB",40,0.,0.40);
	treeVJ_->Draw("IsoHcalEB>>h_ihEB_data",cut.c_str());

	//EE data

	TH1D *h_ieEE_data = new TH1D("h_ieEE_data","IsoEcal EE",40,0.,0.40);
	treeVJ_->Draw("IsoEcalEE>>h_ieEE_data",cut.c_str());

	TH1D *h_ihEE_data = new TH1D("h_ihEE_data","IsoHcal EE",40,0.,0.40);
	treeVJ_->Draw("IsoHcalEE>>h_ihEE_data",cut.c_str());


	//DATA REMOVED PU
	dataremoved->cd("demo");
	//Numero di entries

	//EB data


	TH1D *h_ieEB_rem = new TH1D("h_ieEB_rem","IsoEcal EB",40,0.,0.40);
	treeVJ_->Draw("IsoEcalEB>>h_ieEB_rem",cut.c_str());


	TH1D *h_ihEB_rem = new TH1D("h_ihEB_rem","IsoHcal EB",40,0.,0.40);
	treeVJ_->Draw("IsoHcalEB>>h_ihEB_rem",cut.c_str());

	//EE data


	TH1D *h_ieEE_rem = new TH1D("h_ieEE_rem","IsoEcal EE",40,0.,0.40);
	treeVJ_->Draw("IsoEcalEE>>h_ieEE_rem",cut.c_str());


	TH1D *h_ihEE_rem = new TH1D("h_ihEE_rem","IsoHcal EE",40,0.,0.40);
	treeVJ_->Draw("IsoHcalEE>>h_ihEE_rem",cut.c_str());


	//Definizione canvas e riempimento
	//EB

	TCanvas *Comp = new TCanvas("Comp","Comp",0,0,800,600);
	Comp->Divide(2,2);
	Comp->cd(1);
	MLogAxis(0,1);
	h_ieEB_data->SetTitle(name.c_str());
	h_ieEB_data->SetMarkerColor(kBlack);
	h_ieEB_data->GetXaxis()->SetTitle("IsoECAL Barrel");
	h_ieEB_data->GetYaxis()->SetTitle("Entries");
	h_ieEB_data->SetLineColor(kBlack);
	h_ieEB_data->SetMarkerColor(kBlack);
	h_ieEB_data->Draw("E1");
	h_ieEB_rem->SetMarkerColor(kRed);
	h_ieEB_rem->SetLineColor(kRed);
	h_ieEB_rem->Draw("E1 SAMES");
	Comp->Update();
	TPaveStats *r2 = (TPaveStats*)h_ieEB_rem->FindObject("stats"); 
	r2->SetY1NDC(0.878); 
	r2->SetY2NDC(0.75); 
	r2->SetTextColor(kRed);
	r2->Draw();
	Comp->Update();
	TLegend *leg = new TLegend(0.4,0.75,0.8,0.9);
	leg->SetBorderSize(0);
	leg->SetEntrySeparation(0.01);
	leg->SetFillColor(0);
	leg->AddEntry(h_ieEB_data,"data","p");
	leg->AddEntry(h_ieEB_rem,"data removed PU","p");
	leg->Draw();
	Comp->Update();

	Comp->cd(2);
	MLogAxis(0,1);
	h_ihEB_data->SetTitle(name.c_str());
	h_ihEB_data->SetMarkerColor(kBlack);
	h_ihEB_data->SetLineColor(kBlack);
	h_ihEB_data->GetXaxis()->SetTitle("IsoHCAL Barrel");
	h_ihEB_data->GetYaxis()->SetTitle("Entries");
	h_ihEB_data->Draw("E1");
	h_ihEB_rem->SetMarkerColor(kRed);
	h_ihEB_rem->SetLineColor(kRed);
	h_ihEB_rem->Draw("E1 SAMES");
	Comp->Update();

	TPaveStats *r3 = (TPaveStats*)h_ihEB_rem->FindObject("stats"); 
	r3->SetY1NDC(0.878); 
	r3->SetY2NDC(0.75); 
	r3->SetTextColor(kRed);
	r3->Draw();
	Comp->Update();
	
	TLegend *leg = new TLegend(0.4,0.75,0.8,0.9);
	leg->SetBorderSize(0);
	leg->SetEntrySeparation(0.01);
	leg->SetFillColor(0);
	leg->AddEntry(h_ihEB_data,"data","p");
	leg->AddEntry(h_ihEB_rem,"data removed PU","p");
	leg->Draw();
	Comp->Update();

	Comp->cd(3);
	MLogAxis(0,1);
	h_ieEE_data->SetTitle(name.c_str());
	h_ieEE_data->SetMarkerColor(kBlack);
	h_ieEE_data->SetLineColor(kBlack);
	h_ieEE_data->GetXaxis()->SetTitle("IsoECAL Endcap");
	h_ieEE_data->GetYaxis()->SetTitle("Entries");
	h_ieEE_data->Draw("E1");
	h_ieEE_rem->SetMarkerColor(kRed);
	h_ieEE_rem->SetLineColor(kRed);
	h_ieEE_rem->Draw("E1 SAMES");
	Comp->Update();
	
	TPaveStats *r5 = (TPaveStats*)h_ieEE_rem->FindObject("stats"); 
	r5->SetY1NDC(0.878); 
	r5->SetY2NDC(0.75); 
	r5->SetTextColor(kRed);
	r5->Draw();
	Comp->Update();
	
	TLegend *leg = new TLegend(0.4,0.75,0.8,0.9);
	leg->SetBorderSize(0);
	leg->SetEntrySeparation(0.01);
	leg->SetFillColor(0);
	leg->AddEntry(h_ieEE_data,"data","p");
	leg->AddEntry(h_ieEE_rem,"data removed PU","p");
	leg->Draw();
	Comp->Update();


	Comp->cd(4);
	MLogAxis(0,1);
	h_ihEE_data->SetTitle(name.c_str());
	h_ihEE_data->SetMarkerColor(kBlack);
	h_ihEE_data->SetLineColor(kBlack);
	h_ihEE_data->GetXaxis()->SetTitle("IsoHCAL Endcap");
	h_ihEE_data->GetYaxis()->SetTitle("Entries");
	h_ihEE_data->Draw("E1");
	h_ihEE_rem->SetMarkerColor(kRed);
	h_ihEE_rem->SetLineColor(kRed);
	h_ihEE_rem->Draw("E1 SAMES");
	Comp->Update();
	
	TPaveStats *r6 = (TPaveStats*)h_ihEE_rem->FindObject("stats"); 
	r6->SetY1NDC(0.878); 
	r6->SetY2NDC(0.75); 
	r6->SetTextColor(kRed);
	r6->Draw();
	Comp->Update();
	
	TLegend *leg = new TLegend(0.4,0.75,0.8,0.9);
	leg->SetBorderSize(0);
	leg->SetEntrySeparation(0.01);
	leg->SetFillColor(0);
	leg->AddEntry(h_ihEE_data,"data","p");
	leg->AddEntry(h_ihEE_rem,"data removed PU","p");
	leg->Draw();
	Comp->Update();

	string picname="IsolationWithWithoutPU"+oss.str()+".png";
	Comp->Print(picname.c_str());
	  oss.clear();
	  oss.str("");

	  IsoEcalplotsBarrelRemoved.push_back(h_ieEB_rem);
	  IsoEcalplotsBarrelNotRemoved.push_back(h_ieEB_data);
	  cout<<"entries "<<IsoEcalplotsBarrelRemoved[i-1]->GetEntries();
	  cout<<"entries "<<IsoEcalplotsBarrelNotRemoved[i-1]->GetEntries();
	}

	  //if (h_ieEB_data) delete h_ieEB_data;
	  //if (h_ihEB_data) delete h_ihEB_data;
	  //if (h_ieEE_data) delete h_ieEE_data;
	  //if (h_ihEE_data) delete h_ihEE_data;	
	  // if (h_ieEB_rem) delete h_ieEB_rem;
	  //if (h_ihEB_rem) delete h_ihEB_rem;
	  //if (h_ieEE_rem) delete h_ieEE_rem;
	  //if (h_ihEE_rem) delete h_ihEE_rem;
	  //if (Comp) delete Comp;
	  //if (r2) delete r2;
	  //if (leg) delete leg;
	  //if (r3) delete r3;
	  //if (r5) delete r5;
	  //if (r6) delete r6;

	TCanvas *ComparisonRemoved = new TCanvas("ComparisonRemoved","ComparisonRemoved",0,0,800,600);
	MLogAxis(0,1);
	TLegend *lege= new TLegend(0.4,0.75,0.8,0.9);
	  stringstream nu;
	for (int i=1;i<numbofvertices;i++){
	  nu<<i;
	  cout<<"a"<<endl;
	  string name="Vertices="+nu.str();
	  IsoEcalplotsBarrelRemoved[i-1]->SetMarkerColor(i);
	  IsoEcalplotsBarrelRemoved[i-1]->Sumw2();
	  IsoEcalplotsBarrelRemoved[i-1]->SetLineColor(i);
	  cout<<"aa"<<endl;
	  double plotentries=1.0/(double)IsoEcalplotsBarrelRemoved[i-1]->GetEntries();
	  IsoEcalplotsBarrelRemoved[i-1]->Scale(plotentries);
	  if (i==1){
	  cout<<"ab"<<endl;
	    //TPaveStats *r7 = (TPaveStats*)IsoEcalplotsBarrelRemoved[i-1]->FindObject("stats");
	    //r7->SetOptStat(0);
	    IsoEcalplotsBarrelRemoved[i-1]->SetTitle("Comparison between PURemoved distributions");
	    IsoEcalplotsBarrelRemoved[i-1]->GetXaxis()->SetTitle("IsoECAL Barrel");
	    IsoEcalplotsBarrelRemoved[i-1]->GetYaxis()->SetTitle("Fraction of Events");
	    IsoEcalplotsBarrelRemoved[i-1]->Draw("E1");
	    lege->AddEntry( IsoEcalplotsBarrelRemoved[i-1],name.c_str(),"p");
	  }
	  else{
	  cout<<"ac"<<endl;
	    IsoEcalplotsBarrelRemoved[i-1]->Draw("E1 SAMES");
	    lege->AddEntry( IsoEcalplotsBarrelRemoved[i-1],name.c_str(),"p");
	  }
	  nu.clear();
	  nu.str("");
	}
	ComparisonRemoved->Update();
	lege->SetBorderSize(0);
	lege->SetEntrySeparation(0.01);
	lege->SetFillColor(0);
	lege->Draw();
      	ComparisonRemoved->Print("AllRemoved.png");

	TCanvas *ComparisonNotRemoved = new TCanvas("ComparisonNotRemoved","ComparisonNotRemoved",0,0,800,600);
	MLogAxis(0,1);
	TLegend *lege= new TLegend(0.4,0.75,0.8,0.9);
	  stringstream nu;
	for (int i=1;i<numbofvertices;i++){
	  nu<<i;
	  cout<<"a"<<endl;
	  string name="Vertices="+nu.str();
	  IsoEcalplotsBarrelNotRemoved[i-1]->SetMarkerColor(i);
	  IsoEcalplotsBarrelNotRemoved[i-1]->Sumw2();
	  IsoEcalplotsBarrelNotRemoved[i-1]->SetLineColor(i);
	  cout<<"aa"<<endl;
	  double plotentries=1.0/(double)IsoEcalplotsBarrelNotRemoved[i-1]->GetEntries();
	  IsoEcalplotsBarrelNotRemoved[i-1]->Scale(plotentries);
	  if (i==1){
	  cout<<"ab"<<endl;
	    //TPaveStats *r7 = (TPaveStats*)IsoEcalplotsBarrelNotRemoved[i-1]->FindObject("stats");
	    //r7->SetOptStat(0);
	    IsoEcalplotsBarrelNotRemoved[i-1]->SetTitle("Comparison between PU Not Removed distributions");
	    IsoEcalplotsBarrelNotRemoved[i-1]->GetXaxis()->SetTitle("IsoECAL Barrel");
	    IsoEcalplotsBarrelNotRemoved[i-1]->GetYaxis()->SetTitle("Fraction of Events");
	    IsoEcalplotsBarrelNotRemoved[i-1]->Draw("E1");
	    lege->AddEntry( IsoEcalplotsBarrelNotRemoved[i-1],name.c_str(),"p");
	  }
	  else{
	  cout<<"ac"<<endl;
	    IsoEcalplotsBarrelNotRemoved[i-1]->Draw("E1 SAMES");
	    lege->AddEntry( IsoEcalplotsBarrelNotRemoved[i-1],name.c_str(),"p");
	  }
	  nu.clear();
	  nu.str("");
	}
	ComparisonNotRemoved->Update();
	lege->SetBorderSize(0);
	lege->SetEntrySeparation(0.01);
	lege->SetFillColor(0);
	lege->Draw();

      	ComparisonNotRemoved->Print("AllNotRemoved.png");
	
	return;

}
コード例 #4
0
vector<TH1*> PlotsFeeder::Loop(int NumOfVtx)
{
//   In a ROOT session, you can do:
//      Root > .L PlotsFeeder.C
//      Root > PlotsFeeder t
//      Root > t.GetEntry(12); // Fill t data members with entry number 12
//      Root > t.Show();       // Show values of entry 12
//      Root > t.Show(16);     // Read and show values of entry 16
//      Root > t.Loop();       // Loop on all entries
//

//     This is the loop skeleton where:
//    jentry is the global entry number in the chain
//    ientry is the entry number in the current Tree
//  Note that the argument to GetEntry must be:
//    jentry for TChain::GetEntry
//    ientry for TTree::GetEntry and TBranch::GetEntry
//
//       To read only selected branches, Insert statements like:
// METHOD1:
//    fChain->SetBranchStatus("*",0);  // disable all branches
//    fChain->SetBranchStatus("branchname",1);  // activate branchname
// METHOD2: replace line
//    fChain->GetEntry(jentry);       //read all branches
//by  b_branchname->GetEntry(ientry); //read only this branch

	vector<TH1 *> vHistograms;

//DS! PER IL MOMENTO LI LASCIO TUTTI, SE POI DECIDIAMO EFFETTIVAMENTE DI TENERE SOLO LE 3 ISO, 
//QUESTA MACRO È MEGLIO INTEGRARLA CON LA PlotsFeeder.C 
//(e modificare di conseguenza anche la DataMCValidation.C per far sparire la DataMCValidationPUR.C

	//EB Reweight
	TH1D * h_IsoTrk_EBR_PUR; 
	TH1D * h_IsoEcal_EBR_PUR;
	TH1D * h_IsoHcal_EBR_PUR;
	TH1D * h_HE_EBR;
	TH1F * h_DeltaPhiTkClu_EBR;
	TH1F * h_DeltaEtaTkClu_EBR;
	TH1F * h_sigmaIeIe_EBR;
	//EB Reweight
	h_IsoTrk_EBR_PUR = new TH1D("h_IsoTrk_EBR_PUR","IsoTrk_PUR",36,0.,0.09);
	h_IsoEcal_EBR_PUR = new TH1D("h_IsoEcal_EBR_PUR","IsoEcal_PUR",28,0.,0.07);
	h_IsoHcal_EBR_PUR = new TH1D("h_IsoHcal_EBR_PUR","IsoHcal_PUR",40,0.,0.10);
	/*h_IsoTrk_EBR_PUR = new TH1D("h_IsoTrk_EBR_PUR","IsoTrk_PUR",20,0.,0.20);
	h_IsoEcal_EBR_PUR = new TH1D("h_IsoEcal_EBR_PUR","IsoEcal_PUR",20,0.,0.20);
	h_IsoHcal_EBR_PUR = new TH1D("h_IsoHcal_EBR_PUR","IsoHcal_PUR",20,0.,0.20);*/
	h_HE_EBR = new TH1D("h_HE_EBR","H/E",20,0.,0.20);
	h_DeltaPhiTkClu_EBR = new TH1F("h_DeltaPhiTkClu_EBR","DeltaPhiTkClu",20,0.,0.2);
	h_DeltaEtaTkClu_EBR = new TH1F("h_DeltaEtaTkClu_EBR","DeltaEtaTkClu",20,0.,.05);
	h_sigmaIeIe_EBR = new TH1F("h_sigmaIeIe_EBR","sigmaIeIe",20,0.,0.1);

	/*=========================*/

	//EE Reweight
	TH1D * h_IsoTrk_EER_PUR; 
	TH1D * h_IsoEcal_EER_PUR;
	TH1D * h_IsoHcal_EER_PUR;
	TH1D * h_HE_EER;
	TH1F * h_DeltaPhiTkClu_EER;
	TH1F * h_DeltaEtaTkClu_EER;
	TH1F * h_sigmaIeIe_EER;
	//EE Reweight
	h_IsoTrk_EER_PUR = new TH1D("h_IsoTrk_EER_PUR","IsoTrk",16,0.,0.04);
	h_IsoEcal_EER_PUR = new TH1D("h_IsoEcal_EER_PUR","IsoEcal",20,0.,0.05);
	h_IsoHcal_EER_PUR = new TH1D("h_IsoHcal_EER_PUR","IsoHcal",10,0.,0.025);
	/*h_IsoTrk_EER_PUR = new TH1D("h_IsoTrk_EER_PUR","IsoTrk",20,0.,0.20);
	h_IsoEcal_EER_PUR = new TH1D("h_IsoEcal_EER_PUR","IsoEcal",20,0.,0.20);
	h_IsoHcal_EER_PUR = new TH1D("h_IsoHcal_EER_PUR","IsoHcal",20,0.,0.20);*/
	h_HE_EER = new TH1D("h_HE_EER","H/E",20,0.,0.20);
	h_DeltaPhiTkClu_EER = new TH1F("h_DeltaPhiTkClu_EER","DeltaPhiTkClu",20,0.,0.2);
	h_DeltaEtaTkClu_EER = new TH1F("h_DeltaEtaTkClu_EER","DeltaEtaTkClu",20,0.,.05);
	h_sigmaIeIe_EER = new TH1F("h_sigmaIeIe_EER","sigmaIeIe",20,0.,0.1);

	/*=========================*/

	if (fChain == 0){ cout << " something went wrong in PlotsFeeder "; return vHistograms;}

	Long64_t nentries = fChain->GetEntriesFast();

	Long64_t nbytes = 0, nb = 0;
	for (Long64_t jentry=0; jentry<nentries;jentry++) {
		Long64_t ientry = LoadTree(jentry);
		if (ientry < 0) break;
		nb = fChain->GetEntry(jentry);   nbytes += nb;
		// if (Cut(ientry) < 0) continue;

		if(numberOfVertices==NumOfVtx){

			if (IsoTrkEB_PUR->size()>0) {
				for (unsigned int i=0; i<IsoTrkEB_PUR->size();i++){
					float var=IsoTrkEB_PUR->at(i);
					h_IsoTrk_EBR_PUR->Fill(var,Weight);
				}
			} 
			if (IsoEcalEB_PUR->size()>0) {
				for (unsigned int i=0; i<IsoEcalEB_PUR->size();i++){
					float var=IsoEcalEB_PUR->at(i);
					h_IsoEcal_EBR_PUR->Fill(var,Weight);
				}
			}
			if (IsoHcalEB_PUR->size()>0) {
				for (unsigned int i=0; i<IsoEcalEB_PUR->size();i++){
					float var=IsoHcalEB_PUR->at(i);
					h_IsoHcal_EBR_PUR->Fill(var,Weight);
				}
			}
			if (HEEB->size()>0) {
				for (unsigned int i=0; i<HEEB->size();i++){
					float var=HEEB->at(i);
					h_HE_EBR->Fill(var,Weight);
				}
			}
			if (DeltaPhiTkCluEB->size()>0) {
				for (unsigned int i=0; i<DeltaPhiTkCluEB->size();i++){
					float var=DeltaPhiTkCluEB->at(i);
					h_DeltaPhiTkClu_EBR->Fill(var,Weight);
				}
			}
			if (DeltaEtaTkCluEB->size()>0) {
				for (unsigned int i=0; i<DeltaEtaTkCluEB->size();i++){
					float var=DeltaEtaTkCluEB->at(i);
					h_DeltaEtaTkClu_EBR->Fill(var,Weight);
				}
			}
			if (sigmaIeIeEB->size()>0) {
				for (unsigned int i=0; i<sigmaIeIeEB->size();i++){
					float var=sigmaIeIeEB->at(i);
					h_sigmaIeIe_EBR->Fill(var,Weight);
				}
			}

			//==== EE ====//

			if (IsoTrkEE_PUR->size()>0) {
				for (unsigned int i=0; i<IsoTrkEE_PUR->size();i++){
					float var=IsoTrkEE_PUR->at(i);
					h_IsoTrk_EER_PUR->Fill(var,Weight);
				}
			}
			if (IsoEcalEE_PUR->size()>0) {
				for (unsigned int i=0; i<IsoEcalEE_PUR->size();i++){
					float var=IsoEcalEE_PUR->at(i);
					h_IsoEcal_EER_PUR->Fill(var,Weight);
				}
			}
			if (IsoHcalEE_PUR->size()>0) {
				for (unsigned int i=0; i<IsoHcalEE_PUR->size();i++){
					float var=IsoHcalEE_PUR->at(i);
					h_IsoHcal_EER_PUR->Fill(var,Weight);
				}
			}
			if (HEEE->size()>0) {
				for (unsigned int i=0; i<HEEE->size();i++){
					float var=HEEE->at(i);
					h_HE_EER->Fill(var,Weight);
				}
			}
			if (DeltaPhiTkCluEE->size()>0) {
				for (unsigned int i=0; i<DeltaPhiTkCluEE->size();i++){
					float var=DeltaPhiTkCluEE->at(i);
					h_DeltaPhiTkClu_EER->Fill(var,Weight);
				}
			}
			if (DeltaEtaTkCluEE->size()>0) {
				for (unsigned int i=0; i<DeltaEtaTkCluEE->size();i++){
					float var=DeltaEtaTkCluEE->at(i);
					h_DeltaEtaTkClu_EER->Fill(var,Weight);
				}
			}
			if (sigmaIeIeEE->size()>0) {
				for (unsigned int i=0; i<sigmaIeIeEE->size();i++){
					float var=sigmaIeIeEE->at(i);
					h_sigmaIeIe_EER->Fill(var,Weight);
				}
			}
		}
	}

	vHistograms.push_back(h_IsoTrk_EBR_PUR); 
	vHistograms.push_back(h_IsoEcal_EBR_PUR);
	vHistograms.push_back(h_IsoHcal_EBR_PUR);
	vHistograms.push_back(h_HE_EBR);
	vHistograms.push_back(h_DeltaPhiTkClu_EBR);
	vHistograms.push_back(h_DeltaEtaTkClu_EBR);
	vHistograms.push_back(h_sigmaIeIe_EBR);
	
	vHistograms.push_back(h_IsoTrk_EER_PUR); 
	vHistograms.push_back(h_IsoEcal_EER_PUR);
	vHistograms.push_back(h_IsoHcal_EER_PUR);
	vHistograms.push_back(h_HE_EER);
	vHistograms.push_back(h_DeltaPhiTkClu_EER);
	vHistograms.push_back(h_DeltaEtaTkClu_EER);
	vHistograms.push_back(h_sigmaIeIe_EER);
	


//===================================//
//=========== DEBUG AREA ============//
//===================================//

	bool debug=0;
	if(debug==1){

		TCanvas * EB_plots;
		TCanvas * EE_plots;

		//EB - Create a Canvas and divide it in Pads
		EB_plots = new TCanvas("EB_plots","EB",400,20,1200,800);
		EB_plots->Divide(4,2);

		//First histogram
		EB_plots->cd(1);
		h_IsoTrk_EBR_PUR->GetYaxis()->SetTitle("Number of Events");
		gPad->SetLogy(1);
		h_IsoTrk_EBR_PUR->SetLineColor(1);
		h_IsoTrk_EBR_PUR->Draw();

		//WP Lines and Legend
		TLegend *leg = new TLegend(0.4,0.55,0.8,0.9);
		leg->SetBorderSize(0);
		leg->SetEntrySeparation(0.01);
		leg->SetFillColor(0);
		leg->AddEntry(h_IsoTrk_EBR_PUR,"MC Reweighted and PUR","l");
		TLine *Line80 = new TLine(0.09,0.,0.09,h_IsoTrk_EBR_PUR->GetMaximum());
		Line80->SetLineColor(kBlue);
		Line80->SetLineStyle(2);
		Line80->Draw();
		leg->AddEntry(Line80,"WP 80","l");
		TLine *Line90 = new TLine(0.12,0.,0.12,h_IsoTrk_EBR_PUR->GetMaximum());
		Line90->SetLineColor(kBlack);
		Line90->SetLineStyle(2);
		Line90->Draw();
		leg->AddEntry(Line90,"WP 90","l");
		leg->Draw();


		//Second histogram
		EB_plots->cd(2);
		h_IsoEcal_EBR_PUR->GetYaxis()->SetTitle("Number of Events");
		h_IsoEcal_EBR_PUR->Draw();
		BLine(0.07,0.,0.07,h_IsoEcal_EBR_PUR->GetMaximum());
		MLine(0.09,0.,0.09,h_IsoEcal_EBR_PUR->GetMaximum());

		EB_plots->cd(3);
		h_IsoHcal_EBR_PUR->GetYaxis()->SetTitle("Number of Events");
		gPad->SetLogy(1);
		h_IsoHcal_EBR_PUR->SetLineColor(1);
		h_IsoHcal_EBR_PUR->Draw();
		BLine(0.10,0.,0.10,h_IsoHcal_EBR_PUR->GetMaximum());
		MLine(0.10,0.,0.10,h_IsoHcal_EBR_PUR->GetMaximum());

		EB_plots->cd(4);
		h_HE_EBR->GetYaxis()->SetTitle("Number of Events");
		gPad->SetLogy(1);
		h_HE_EBR->SetLineColor(1);
		h_HE_EBR->Draw();
		BLine(0.04,0.,0.04,h_HE_EBR->GetMaximum());
		MLine(0.12,0.,0.12,h_HE_EBR->GetMaximum());

		EB_plots->cd(5);
		h_DeltaPhiTkClu_EBR->GetYaxis()->SetTitle("Number of Events");
		gPad->SetLogy(1);
		h_DeltaPhiTkClu_EBR->SetLineColor(1);
		h_DeltaPhiTkClu_EBR->Draw();
		BLine(0.06,0.,0.06,h_DeltaPhiTkClu_EBR->GetMaximum());
		MLine(0.8,0.,0.8,h_DeltaPhiTkClu_EBR->GetMaximum());

		EB_plots->cd(6);
		h_DeltaEtaTkClu_EBR->GetYaxis()->SetTitle("Number of Events");
		gPad->SetLogy(1);
		h_DeltaEtaTkClu_EBR->SetLineColor(1);
		h_DeltaEtaTkClu_EBR->Draw();
		BLine(0.004,0.,0.004,h_DeltaEtaTkClu_EBR->GetMaximum());
		MLine(0.007,0.,0.007,h_DeltaEtaTkClu_EBR->GetMaximum());

		EB_plots->cd(7);
		h_sigmaIeIe_EBR->GetYaxis()->SetTitle("Number of Events");
		gPad->SetLogy(1);
		h_sigmaIeIe_EBR->SetLineColor(1);
		h_sigmaIeIe_EBR->Draw();
		BLine(0.004,0.,0.004,h_sigmaIeIe_EBR->GetMaximum());
		MLine(0.007,0.,0.007,h_sigmaIeIe_EBR->GetMaximum());


		/*============================*/

		// qua dei draw copi diretto da all plots
		//EE - Create a Canvas and divide it in Pads
		EE_plots = new TCanvas("EE_plots","EE",400,20,1200,800);
		EE_plots->Divide(4,2);

		//First histogram
		EE_plots->cd(1);
		h_IsoTrk_EER_PUR->GetYaxis()->SetTitle("Number of Events");
		gPad->SetLogy(1);
		h_IsoTrk_EER_PUR->SetLineColor(1);
		h_IsoTrk_EER_PUR->Draw();

		//WP Lines and Legend
		TLegend *leg2 = new TLegend(0.4,0.55,0.8,0.9);
		leg2->SetBorderSize(0);
		leg2->SetEntrySeparation(0.01);
		leg2->SetFillColor(0);
		leg2->AddEntry(h_IsoTrk_EER_PUR,"MC Reweighted and PUR","l");
		Line80->SetLineColor(kBlue);
		Line80->SetLineStyle(2);
		Line80->Draw();
		leg2->AddEntry(Line80,"WP 80","l");
		Line90->SetLineColor(kBlack);
		Line90->SetLineStyle(2);
		Line90->Draw();
		leg2->AddEntry(Line90,"WP 90","l");
		leg2->Draw();


		//Second histogram
		EE_plots->cd(2);
		h_IsoEcal_EER_PUR->GetYaxis()->SetTitle("Number of Events");
		h_IsoEcal_EER_PUR->SetLineColor(1);
		h_IsoEcal_EER_PUR->Draw();
		BLine(0.07,0.,0.07,h_IsoEcal_EER_PUR->GetMaximum());
		MLine(0.09,0.,0.09,h_IsoEcal_EER_PUR->GetMaximum());

		EE_plots->cd(3);
		h_IsoHcal_EER_PUR->GetYaxis()->SetTitle("Number of Events");
		gPad->SetLogy(1);
		h_IsoHcal_EER_PUR->SetLineColor(1);
		h_IsoHcal_EER_PUR->Draw();
		BLine(0.10,0.,0.10,h_IsoHcal_EER_PUR->GetMaximum());
		MLine(0.10,0.,0.10,h_IsoHcal_EER_PUR->GetMaximum());

		EE_plots->cd(4);
		h_HE_EER->GetYaxis()->SetTitle("Number of Events");
		gPad->SetLogy(1);
		h_HE_EER->SetLineColor(1);
		h_HE_EER->Draw();
		BLine(0.04,0.,0.04,h_HE_EER->GetMaximum());
		MLine(0.12,0.,0.12,h_HE_EER->GetMaximum());

		EE_plots->cd(5);
		h_DeltaPhiTkClu_EER->GetYaxis()->SetTitle("Number of Events");
		gPad->SetLogy(1);
		h_DeltaPhiTkClu_EER->SetLineColor(1);
		h_DeltaPhiTkClu_EER->Draw();
		BLine(0.06,0.,0.06,h_DeltaPhiTkClu_EER->GetMaximum());
		MLine(0.8,0.,0.8,h_DeltaPhiTkClu_EER->GetMaximum());

		EE_plots->cd(6);
		h_DeltaEtaTkClu_EER->GetYaxis()->SetTitle("Number of Events");
		gPad->SetLogy(1);
		h_DeltaEtaTkClu_EER->SetLineColor(1);
		h_DeltaEtaTkClu_EER->Draw();
		BLine(0.004,0.,0.004,h_DeltaEtaTkClu_EER->GetMaximum());
		MLine(0.007,0.,0.007,h_DeltaEtaTkClu_EER->GetMaximum());

		EE_plots->cd(7);
		h_sigmaIeIe_EER->GetYaxis()->SetTitle("Number of Events");
		gPad->SetLogy(1);
		h_sigmaIeIe_EER->SetLineColor(1);
		h_sigmaIeIe_EER->Draw();
		BLine(0.004,0.,0.004,h_sigmaIeIe_EER->GetMaximum());
		MLine(0.007,0.,0.007,h_sigmaIeIe_EER->GetMaximum());

	}

return  vHistograms;

}
コード例 #5
0
ファイル: mkChanCorrPlots.C プロジェクト: jetatar/snowShovel
void mkChanCorrPlots( void )
{
    Float_t meancopo[kNfls];
    Float_t meancrspo[kNfls];
    Float_t rmscopo[kNfls];
    Float_t rmscrspo[kNfls];

    TFile* fout = TFile::Open( outfn, "recreate" );

    TGraphErrors* gCopo02 = new TGraphErrors;
    TGraphErrors* gCopo13 = new TGraphErrors;
    
    TGraphErrors* gCrspo02 = new TGraphErrors;
    TGraphErrors* gCrspo13 = new TGraphErrors;

    for( UChar_t f = 0; f < kNfls; f++ )
    {
        Float_t mean[kNChCmb];
        Float_t rms[kNChCmb];

        TFile* ifl = TFile::Open( infn[f] );
 
        for( UChar_t c = 0; c < NSnConstants::kNchans; c++ )
        {
            for( UChar_t c2 = c + 1; c2 < NSnConstants::kNchans; c2++ )
            {
                TH1F* h = dynamic_cast<TH1F*>(ifl->Get(Form("hCC%d%d", c, c2)));

                UInt_t idx  = TSnRecoChanOffsets::IndexFor(c2, c);
                mean[idx]   = h->GetMean( );
                rms[idx]    = h->GetRMS( );
            }
        }

        meancopo[f]     = mean[TSnRecoChanOffsets::IndexFor(copoC[f] + 2, 
                                                                   copoC[f])];
        meancrspo[f]    = mean[TSnRecoChanOffsets::IndexFor(crspoC[f] + 2, 
                                                                   crspoC[f])];

        rmscopo[f]      = rms[TSnRecoChanOffsets::IndexFor(copoC[f] + 2, 
                                                                   copoC[f])];
        rmscrspo[f]     = rms[TSnRecoChanOffsets::IndexFor(crspoC[f] + 2, 
                                                                   crspoC[f])];

        Printf( "co po mean: %f rms: %f run: %u", meancopo[f], rmscopo[f], 
                                                                    y[f] );
        Printf( "cross po mean: %f rms: %f run: %u\n", meancrspo[f], 
                                                        rmscrspo[f], y[f] );

        ifl->Close( );
    }

//    Float_t y[kNfls]    = { 1., 1., 1., 1., 1., 1., 1., 1. };
    Float_t ye[kNfls]   = { 0., 0., 0., 0., 0., 0., 0., 0. }; 

    fout->cd( );

    UInt_t nc0 = 0;
    UInt_t nc1 = 0;

    for( UChar_t f = 0; f < kNfls; f++ )
    {
        if( copoC[f] == 0 && crspoC[f] == 1 )
        {
            gCopo02->SetPoint( nc0, meancopo[f], 0. );
            gCrspo13->SetPoint( nc0, meancrspo[f], 0. );

            gCrspo13->SetPointError( nc0, rmscrspo[f], ye[f] );
            gCopo02->SetPointError( nc0++, rmscopo[f], ye[f] );

            gCopo02->SetMarkerColor( kRed );
            gCopo02->SetLineColor( kRed );
            gCopo02->GetHistogram()->SetMinimum( -0.5 );
            gCopo02->GetHistogram()->SetMaximum( 1.5 );

            gCrspo13->SetMarkerColor( kRed );
            gCrspo13->SetLineColor( kRed );
            gCrspo13->GetHistogram()->SetMinimum( -0.5 );
            gCrspo13->GetHistogram()->SetMaximum( 1.5 );
        }            
        if( copoC[f] == 1 && crspoC[f] == 0 )
        {
            gCopo13->SetPoint( nc1, meancopo[f], 1. );
            gCrspo02->SetPoint( nc1, meancrspo[f], 1. );

            gCrspo02->SetPointError( nc1, rmscrspo[f], ye[f] );
            gCopo13->SetPointError( nc1++, rmscopo[f], ye[f] );

            gCopo13->SetMarkerColor( kBlack );
            gCopo13->SetLineColor( kBlack );
            gCopo13->GetHistogram()->SetMinimum( -0.5 );
            gCopo13->GetHistogram()->SetMaximum( 1.5 );

            gCrspo02->SetMarkerColor( kBlack );
            gCrspo02->SetLineColor( kBlack );
            gCrspo02->GetHistogram()->SetMinimum( -0.5 );
            gCrspo02->GetHistogram()->SetMaximum( 1.5 );
        }
    }

    TLegend* leg = new TLegend( 0.258, 0.742, 0.410, 0.993 );
    leg->SetBorderSize( 0 );
    leg->SetFillColor( 0 );

    TLegend* legcr = new TLegend( 0.258, 0.742, 0.410, 0.993 );
    legcr->SetBorderSize( 0 );
    legcr->SetFillColor( 0 );
    legcr->SetFillStyle( 0 );
    legcr->SetEntrySeparation( 0.01 );
    legcr->SetTextSize( 0.04 );
//    gCopo = new TGraphErrors( kNfls, meancopo, y, rmscopo, ye );
    TCanvas* c = new TCanvas( "c", "", 800, 400 );
    c->Divide( 2, 1 );

    c->cd( 1 );
    gCopo02->SetName( "gcopoCC02" );
    gCopo02->Draw( "AP*" );
    gCopo13->Draw( "P*" );

    leg->AddEntry( gCopo02, "Ch 0 & Ch 2 Co. Po.", "lp" );
    leg->AddEntry( gCopo13, "Ch 1 & Ch 3 Co. Po.", "lp" );
    leg->Draw( );

    gCopo02->Write( ); 

    c->cd( 2 );
    gCrspo13->SetName( "gcrspoCC13" );
    gCrspo13->Draw( "AP*" );
    gCrspo13->GetXaxis()->SetLimits( 0.45, 0.85 );

    gCrspo02->SetName( "gcrspoCC02" );
    gCrspo02->Draw( "P*" );

    legcr->AddEntry( gCrspo13, "Ch 1 & Ch 3 Cross Po.", "lp" );
    legcr->AddEntry( gCrspo02, "Ch 0 & Ch 2 Cross Po.", "lp" );
    legcr->Draw( );

    gCrspo13->Write( ); 


    TCanvas* c2 = new TCanvas( "c2", "", 800, 800 );
    c2->cd( 1 );
    gCopo13->SetName( "gcopoCC13" );
    gCopo13->Draw( "AP*" );
    gCopo13->Write( );

//    fout->Write( );
    fout->Close( );
} 
コード例 #6
0
void AnalyzeBKGShape(TString folder, TString sample1, TString sample2){
	gStyle->SetOptStat(000000);
	
	TH1::SetDefaultSumw2();
	
	TFile *f= TFile::Open("/Users/Tita/Desktop/analysis_HH_bbTauTau/src/HHbbTauTau/data/datacards_TauTau_ZTT/htt_tt.inputs-Hhh-8TeV_m_ttbb_kinfit_KinFitConvergedWithMassWindow.root");
	

	
	TH1D *histoDY = (TH1D*)f->Get((folder+"/"+sample1));
	TH1D *histoTT = (TH1D*)f->Get((folder+"/"+sample2));
	
		
	TCanvas * c1 = new TCanvas("c1","c1", 800,800);

	histoDY->SetLineColor(kBlue);
	histoDY->SetMarkerColor(kBlue);
	histoDY->SetMarkerStyle(20);
	

	histoTT->SetLineColor(kRed);
	histoTT->SetMarkerColor(kRed);
	histoTT->SetMarkerStyle(20);

	
	
	
	
    // double error_histo = 0;
//     double integral_histo = histo->IntegralAndError(1, histo->GetNbinsX(),error_histo);
//     cout<<"--------------------------------------------------------------"<<sample<<"--------------------------------------------------------------"<<endl;
//     cout<<"*************"<<folder<<"  "<<sample<<"*************"<<endl;
//     cout<<" MC Shape "<<integral_histo<<"   ----  "<<error_histo<<endl;
//     cout<<" MC Shape Loose B "<<histoBLoose->Integral()<<endl;
//     cout<<" MC Shape Loose B + Relax Tau Iso "<<histoBLooseTauLoose->Integral()<<endl;
    
    
//     histoBLooseTauLoose->Scale(1/(histoBLooseTauLoose->Integral()));
    // histoTT->Scale(1/(histoTT->Integral()));
//     histoDY->Scale(1/(histoDY->Integral()));
	
	cout << "Integral DY = " << histoDY->Integral() << ", Integral TT = " << histoTT->Integral() << endl;
	cout << "percentage = " << histoTT->Integral()/histoDY->Integral() << endl;
    
    histoDY->Draw("");
    histoTT->Draw("same");
    
//     histoBLooseTauLoose->Draw("same");
    
    

    
    // cout<<"--------------------------------------------------------------KS   "<<sample<<"--------------------------------------------------------------"<<endl;
//     cout<<"*************"<<folder<<"  "<<sample<<"*************"<<endl;
//     cout<<" Kolmogorov Test "<<histoDY->KolmogorovTest(histoBLoose,"")<<endl;
	histoDY->SetTitle("M_{H}");
	histoDY->GetXaxis()->SetTitle("M_{H} [GeV]");
	histoDY->GetYaxis()->SetTitleOffset(1.5);
	histoDY->GetYaxis()->SetTitle("N Events");
	
	
	
		
	
	TLegend* legend = new TLegend(0.6, 0.65, 0.99, 0.9);
	legend->SetFillColor(0);
	legend->SetTextSize(0.05);
	legend->SetEntrySeparation(0.05);
	legend->AddEntry(histoDY, " DY embedded ");
	legend->AddEntry(histoTT, " TT embedded ");
	//legend->AddEntry(histoBLooseTauLoose, " No Btagging, TauIso<1 ");
	
	legend->Draw();
	
	c1->SaveAs("./plots_embedded/"+folder+"_embComparison.eps");
}
コード例 #7
0
ファイル: DataMCComp6.C プロジェクト: cms-ts/WbAnalysis
void DataMCComp6(int irun=0, string title="", int plot=0) {

int unfold=0; // use pre-unfolding distributions
//int unfold=1; // use unfolded distributions

//int drawInclusive = 0; // do not plot the "inclusive" histogram
int drawInclusive = 1; // do plot the "inclusive" histogram

string subdir="0";
string postfix="";
if (irun==1) {             // irun==1 => JEC Up
  subdir="1";
  postfix="Up";
}
if (irun==2) {             // irun==2 => JEC Down
  subdir="2";
  postfix="Down";
}
if (irun==3) {             // irun==3 => PU Up
  subdir="3";
  postfix="Pup";
}
if (irun==4) {             // irun==4 => PU Down
  subdir="4";
  postfix="Pum";
}
if (irun==5) {             // irun==5 => top bkg
  subdir="5";
  postfix="";  
}
if (irun==6) {             // irun==6 => b purity
  subdir="6";
  postfix="";   
}
if (irun==7) {             // irun==7 => unfolding
  subdir="7";
  postfix="";   
}
if (irun==8) {             // irun==8 => unfolding with Sherpa
  subdir="8";
  postfix="";
}
if (irun==9) {             // irun==9 => unfolding with Powheg
  subdir="9";
  postfix="";
}
if (irun==10) {            // irun==10 => bkg systematics
  subdir="10";
  postfix="";
}
if (irun==11) {            // irun==11 => JER Up
  subdir="11";
  postfix="JerUp";
}
if (irun==12) {            // irun==12 => JER Down
  subdir="12";
  postfix="JerDown";
}
if (irun==13) {            // irun==13 => bkg statistics
  subdir="13";
  postfix="";
}
if (irun==14) {            // irun==14 => unfolding with data weight
  subdir="14";
  postfix="";
}
if (irun==15) {            // irun==15 => qcd bkg
  subdir="15";
  postfix="";
}
if (irun==77) {            // irun==77 => unfolding with MadGraph 4FS
  subdir="77";
  postfix="";
}
if (irun==88) {            // irun==88 => deltaR
  subdir="88";
  postfix="DR";
}
if (irun==99) {            // irun==99 => pur
  subdir="99";
  postfix="Pur";
}

        string title_e = title;
        string title_m = title;

        if (title=="w_mt_b") {
	  title_e = "w_mt_wenu_b";
	  title_m = "w_mt_wmnu_b";
	}

        if (title=="w_delta_b") {
	  title_e = "w_delta_wenu_b";
	  title_m = "w_delta_wmnu_b";
	}

        if (title=="w_deltaR_b") {
	  title_e = "w_deltaR_wenu_b";
	  title_m = "w_deltaR_wmnu_b";
	}

	if (title=="w_pt_W_b") {
	  title_e = "w_pt_W_wenu_b";
	  title_m = "w_pt_W_wmnu_b";
	}

	if (title=="w_eta_W_b") {
	  title_e = "w_eta_W_wenu_b";
	  title_m = "w_eta_W_wmnu_b";
	}

        string title_e_b = title_e;
        string title_m_b = title_m;

        if (title.find("_bjet_")!=string::npos) {
          title_e.erase(title_e.find("_bjet_")+1, 1);
          title_m.erase(title_m.find("_bjet_")+1, 1);
        } else {
	  title_e_b = title_e_b + "b";
	  title_m_b = title_m_b + "b";
	}

        TFile* f_e;
        TFile* f_e_b;
        if (unfold) {
           f_e = TFile::Open((path + "/electrons/" + version + "/" + subdir + "/unfolding/" + title_e + "_unfolding.root").c_str());
           f_e_b = TFile::Open((path + "/electrons/" + version + "/" + subdir + "/unfolding/" + title_e_b + "_unfolding.root").c_str());
        } else {
          f_e = TFile::Open((path + "/electrons/" + version + "/" + subdir + "/xsecs/" + title_e_b + "_xsecs.root").c_str());
          f_e_b = TFile::Open((path + "/electrons/" + version + "/" + subdir + "/xsecs/" + title_e_b + "_xsecs.root").c_str());
        }
        TH1F* h_data_e = (TH1F*)f_e->Get(title_e.c_str())->Clone();
        TH1F* h_data_e_b = (TH1F*)f_e_b->Get(title_e_b.c_str())->Clone();
        h_data_e->SetDirectory(0);
        h_data_e_b->SetDirectory(0);
        f_e->Close();
        f_e_b->Close();

        TFile* f_m;
        TFile* f_m_b;
        if (unfold) {
          f_m = TFile::Open((path + "/muons/" + version + "/" + subdir + "/unfolding/" + title_m + "_unfolding.root").c_str());
          f_m_b= TFile::Open((path + "/muons/" + version + "/" + subdir + "/unfolding/" + title_m_b + "_unfolding.root").c_str());
        } else {
          f_m= TFile::Open((path + "/muons/" + version + "/" + subdir + "/xsecs/" + title_m_b + "_xsecs.root").c_str());
          f_m_b= TFile::Open((path + "/muons/" + version + "/" + subdir + "/xsecs/" + title_m_b + "_xsecs.root").c_str());
        }
        TH1F* h_data_m = (TH1F*)f_m->Get(title_m.c_str())->Clone();
        TH1F* h_data_m_b = (TH1F*)f_m_b->Get(title_m_b.c_str())->Clone();
        h_data_m->SetDirectory(0);
        h_data_m_b->SetDirectory(0);
        f_m->Close();
        f_m_b->Close();

        h_data_e->SetStats(0);
        h_data_e_b->SetStats(0);
        h_data_m->SetStats(0);
        h_data_m_b->SetStats(0);

	if (unfold) {
	  h_data_e->Scale(1./Lumi2012_ele, "width");
	  h_data_e_b->Scale(1./Lumi2012_ele, "width");
	  h_data_m->Scale(1./Lumi2012_muon, "width");
	  h_data_m_b->Scale(1./Lumi2012_muon, "width");
	}

        TCanvas* c1 = new TCanvas("c", "c", 800, 600);
        c1->cd();

        TPad *pad1 = new TPad("pad1","pad1",0.0,0.3,1.0,1.0);
        pad1->SetBottomMargin(0.001);
        pad1->Draw();
        pad1->cd();
        pad1->SetLogy();

        h_data_e->SetTitle("");
        h_data_e_b->SetTitle("");

        h_data_e->GetYaxis()->SetTitle("#sigma [pb]");

        h_data_e->SetMarkerStyle(20);
        h_data_e->SetMarkerSize(0.7);
        h_data_e->SetMarkerColor(kRed);
        h_data_e->SetLineColor(kRed);
        h_data_e_b->SetMarkerStyle(24);
        h_data_e_b->SetMarkerSize(0.7);
        h_data_e_b->SetMarkerColor(kRed);
        h_data_e_b->SetLineColor(kRed);
        h_data_m->SetMarkerStyle(20);
        h_data_m->SetMarkerSize(0.7);
        h_data_m->SetMarkerColor(kBlue);
        h_data_m->SetLineColor(kBlue);
        h_data_m_b->SetMarkerStyle(24);
        h_data_m_b->SetMarkerSize(0.7);
        h_data_m_b->SetMarkerColor(kBlue);
        h_data_m_b->SetLineColor(kBlue);

	if (drawInclusive) {
	  h_data_e_b->SetMaximum(4*h_data_e->GetMaximum());
	} else {
	  h_data_e_b->SetMaximum(4*h_data_e_b->GetMaximum());
	}
        h_data_e_b->SetMinimum(TMath::Max(0.002,0.25*h_data_e_b->GetBinContent(h_data_e_b->GetMinimumBin())));
	if (title.find("_mt")!=string::npos) h_data_e_b->SetMinimum(TMath::Max(0.00002,0.25*h_data_e_b->GetBinContent(h_data_e_b->GetMinimumBin())));
	if (title.find("_pt")!=string::npos) h_data_e_b->SetMinimum(TMath::Max(0.000004,0.25*h_data_e_b->GetBinContent(h_data_e_b->GetMinimumBin())));
	if (title.find("_mass")!=string::npos) h_data_e_b->SetMinimum(TMath::Max(0.0002,0.25*h_data_e_b->GetBinContent(h_data_e_b->GetMinimumBin())));

        h_data_e_b->Draw("E0PX");
        if (drawInclusive) h_data_e->Draw("E0PXSAME");
        h_data_m_b->Draw("E0PXSAME");
        if (drawInclusive) h_data_m->Draw("E0PXSAME");

        TLegend *leg = new TLegend(0.62, 0.580, 0.88, 0.88);
        leg->SetBorderSize(0);
        leg->SetEntrySeparation(0.01);
        leg->SetFillColor(0);
        leg->SetFillStyle(0);

        leg->AddEntry(h_data_e_b,"W(#rightarrow e#nu)+2b DATA","p");
        if (drawInclusive) leg->AddEntry(h_data_e,"W(#rightarrow e#nu)+1b DATA","p");
        leg->AddEntry(h_data_m_b,"W(#rightarrow #mu#nu)+2b DATA","p");
        if (drawInclusive) leg->AddEntry(h_data_m,"W(#rightarrow #mu#nu)+1b DATA","p");

        leg->Draw();

        pad1->Update();
        c1->Update();

        c1->cd();

        TLatex *latexLabel = CMSPrel((Lumi2012_ele+Lumi2012_muon)/2./1000.,"",0.15,0.94);
        latexLabel->Draw("same");

        TPad *pad2 = new TPad("pad2","pad2",0,0,1,0.3);
        pad2->SetTopMargin(0);
        pad2->SetBottomMargin(0.3);
        pad2->Draw();
        pad2->cd();

        TH1F* h_ratio = (TH1F*)h_data_e->Clone("h_ratio");
        TH1F* h_ratio_b = (TH1F*)h_data_e_b->Clone("h_ratio_b");
        h_ratio->Divide(h_data_m);
        h_ratio_b->Divide(h_data_m_b);

        h_ratio_b->SetTitle("");

        h_ratio_b->GetXaxis()->SetTitleOffset(0.9);
        h_ratio_b->GetXaxis()->SetTitleSize(0.1);
        h_ratio_b->GetXaxis()->SetLabelFont(42);
        h_ratio_b->GetXaxis()->SetLabelSize(0.08);
        h_ratio_b->GetXaxis()->SetTitleFont(42);
        h_ratio_b->GetYaxis()->SetTitle("Electrons/Muons");
        h_ratio_b->GetYaxis()->SetNdivisions(505);
        h_ratio_b->GetYaxis()->SetTitleSize(0.09);
        h_ratio_b->GetYaxis()->SetLabelSize(0.08);
        h_ratio_b->GetYaxis()->SetRangeUser(0.5, 1.5);
        h_ratio_b->GetYaxis()->SetTitleOffset(0.4);

        h_ratio->SetMarkerStyle(20);
        h_ratio->SetMarkerColor(kBlack);
        h_ratio->SetLineColor(kBlack);
        h_ratio_b->SetMarkerStyle(24);
        h_ratio_b->SetMarkerColor(kBlack);
        h_ratio_b->SetLineColor(kBlack);

        h_ratio_b->Draw("E0PX");
        if (drawInclusive) h_ratio->Draw("E0PXSAME");

        TLine *OLine = new TLine(h_ratio->GetXaxis()->GetXmin(),1.,h_ratio->GetXaxis()->GetXmax(),1.);
        OLine->SetLineColor(kGreen);
        OLine->SetLineWidth(1);
        OLine->Draw();

        c1->cd();

	if (plot) {
          if (unfold) {
            gSystem->mkdir((path + "/combined/" + version + "/" + subdir + "/xsecs_unfolding/").c_str(), kTRUE);
            c1->SaveAs((path + "/combined/" + version + "/" + subdir + "/xsecs_unfolding/" + title + "b" + "_xsecs_unfolding.pdf").c_str());
          } else {
            gSystem->mkdir((path + "/combined/" + version + "/" + subdir + "/xsecs/").c_str(), kTRUE);
            c1->SaveAs((path + "/combined/" + version + "/" + subdir + "/xsecs/" + title + "b" + "_xsecs.pdf").c_str());
          }
	}

}
コード例 #8
0
ファイル: VHPlotter.C プロジェクト: yuchanggit/new_git
//void VHPlotter(string title="", int plot=0) {
void VHPlotter(string title="", int plot=0,   TCanvas* c1=0 ) {


    string subdir="0";
    string postfix="";
    string dirbSel="";

    double norm11 = ((Lumi2016_ele * Xsec_dy_amc1) / Ngen_dy_amc1);
    double norm12 = ((Lumi2016_ele * Xsec_dy_amc2) / Ngen_dy_amc2);
    double norm13 = ((Lumi2016_ele * Xsec_dy_amc3) / Ngen_dy_amc3);
    double norm14 = ((Lumi2016_ele * Xsec_dy_amc4) / Ngen_dy_amc4);

    double norm2 = ((Lumi2016_ele * Xsec_tt) / Ngen_tt);
    double norm3 = ((Lumi2016_ele * Xsec_zz) / Ngen_zz);
    double norm4 = ((Lumi2016_ele * Xsec_wz) / Ngen_wz);
    double norm6 = ((Lumi2016_ele * Xsec_ww) / Ngen_ww);
    double norm7 = ((Lumi2016_ele * Xsec_zhm) / Ngen_zhm);
    double norm8 = ((Lumi2016_ele * Xsec_zhp) / Ngen_zhp);

//if (ilepton==1) Lumi2016 = Lumi2016_ele;

    /*double enorm1 = ((Lumi2012 * eXsec_dy) / Ngen_dy);
    double enorm1_amc = ((Lumi2012 * eXsec_dy_amc) / Ngen_dy_amc);
    double enorm1_1 = ((Lumi2012 * eXsec_dy_1) / Ngen_dy_1);
    double enorm1_2=0;
    double enorm2 = ((Lumi2012 * eXsec_tt) / Ngen_tt);
    double enorm4 = ((Lumi2012 * eXsec_wz) / Ngen_wz);
    double enorm5 = ((Lumi2012 * eXsec_qcd) / Ngen_qcd);
    double enorm6 = ((Lumi2012 * eXsec_ww) / Ngen_ww);
    double enorm7 = ((Lumi2012 * eXsec_wj) / Ngen_wj);
    double enorm8 = ((Lumi2012 * eXsec_tS) / Ngen_tS);
    double enorm9 = ((Lumi2012 * eXsec_tT) / Ngen_tT);
    double enorm10 = ((Lumi2012 * eXsec_tW) / Ngen_tW);
    double enorm11 = ((Lumi2012 * eXsec_tSb) / Ngen_tSb);
    double enorm12 = ((Lumi2012 * eXsec_tTb) / Ngen_tTb);
    double enorm13 = ((Lumi2012 * eXsec_tWb) / Ngen_tWb);
    */

    TFile* mc11 = TFile::Open((path + "DYJetsToLL_M-50_HT-100to200_13TeV.root").c_str());
    TH1F* h_mc11 = (TH1F*)gDirectory->Get(title.c_str());
    TFile* mc12 = TFile::Open((path + "DYJetsToLL_M-50_HT-200to400_13TeV.root").c_str());
    TH1F* h_mc12 = (TH1F*)gDirectory->Get(title.c_str());
    TFile* mc13 = TFile::Open((path + "DYJetsToLL_M-50_HT-400to600_13TeV.root").c_str());
    TH1F* h_mc13 = (TH1F*)gDirectory->Get(title.c_str());
    TFile* mc14 = TFile::Open((path + "DYJetsToLL_M-50_HT-600toInf_13TeV.root").c_str());
    TH1F* h_mc14 = (TH1F*)gDirectory->Get(title.c_str());
    TFile* mc2 = TFile::Open((path + "TT_TuneCUETP8M1_13TeV.root").c_str());
    TH1F* h_mc2 = (TH1F*)gDirectory->Get(title.c_str());
    TFile* mc3 = TFile::Open((path + "ZZ_TuneCUETP8M1_13TeV.root").c_str());
    TH1F* h_mc3 = (TH1F*)gDirectory->Get(title.c_str());
    TFile* mc4 = TFile::Open((path + "WZ_TuneCUETP8M1_13TeV.root").c_str());
    TH1F* h_mc4 = (TH1F*)gDirectory->Get(title.c_str());
    TFile* mc6 = TFile::Open((path + "WW_TuneCUETP8M1_13TeV.root").c_str());
    TH1F* h_mc6 = (TH1F*)gDirectory->Get(title.c_str());
    TFile* mc7 = TFile::Open((path + "ZH_HToBB_ZToLL_M125_13TeV_amcatnlo.root").c_str());
    TH1F* h_mc7 = (TH1F*)gDirectory->Get(title.c_str());
    TFile* mc8 = TFile::Open((path + "ZH_HToBB_ZToLL_M125_13TeV_powheg.root").c_str());
    TH1F* h_mc8 = (TH1F*)gDirectory->Get(title.c_str());

//TFile* data = TFile::Open((path + "SingleElectron-Run2016B-v2.root").c_str());;
//TH1F* h_data = (TH1F*)gDirectory->Get(title.c_str());

    TFile* data_runB = TFile::Open((path + "SingleElectron-Run2016B-v2.root").c_str());
    TH1F* h_data_runB = (TH1F*)gDirectory->Get(title.c_str());

    TFile* data_runC = TFile::Open((path + "SingleElectron-Run2016C-v2.root").c_str());
    TH1F* h_data_runC = (TH1F*)gDirectory->Get(title.c_str());

    TFile* data_runD = TFile::Open((path + "SingleElectron-Run2016D-v2.root").c_str());
    TH1F* h_data_runD = (TH1F*)gDirectory->Get(title.c_str());

    TH1F* h_data = (TH1F*)h_data_runB ->Clone("h_data");
    h_data->Reset();
    h_data->Add( h_data_runB );
    h_data->Add( h_data_runC );
    h_data->Add( h_data_runD );

    h_mc2 -> SetLineColor(kBlack);
    h_mc2 -> SetFillColor(kBlue);
//h_mc2 -> SetFillStyle(3004);

    h_mc3 -> SetLineColor(kBlack);
    h_mc3 -> SetFillColor(kGray+2);
//h_mc3 -> SetFillStyle(3004);

//h_mc4 -> SetLineColor(kBlack);
//h_mc4 -> SetFillColor(kGray+3);
//h_mc4 -> SetFillStyle(3004);

//h_mc6 -> SetLineColor(kBlack);
//h_mc6 -> SetFillColor(kRed+2);
//h_mc6 -> SetFillStyle(3004);

    h_mc7 -> SetLineColor(kBlack);
    h_mc7 -> SetFillColor(kMagenta);
//h_mc7 -> SetFillStyle(3004);

    h_mc8 -> SetLineColor(kGreen);
//h_mc8 -> SetLineColor(kBlack);
//h_mc8 -> SetFillColor(kPink);
//h_mc8 -> SetFillStyle(3004);
    h_mc8 ->SetLineWidth(3);

    h_mc11->Scale(norm11);
    h_mc12->Scale(norm12);
    h_mc13->Scale(norm13);
    h_mc14->Scale(norm14);
    h_mc2->Scale(norm2);
    h_mc3->Scale(norm3);
    h_mc4->Scale(norm4);
    h_mc6->Scale(norm6);
    h_mc7->Scale(norm7);
    h_mc8->Scale(norm8);

    TH1F* h_mcDY = (TH1F*)h_mc11->Clone("h_mcDY");
    h_mcDY->Reset();
    h_mcDY->Add(h_mc14);
    h_mcDY->Add(h_mc13);
    h_mcDY->Add(h_mc12);
    h_mcDY->Add(h_mc11);

    h_mcDY -> SetLineColor(kBlack);
    h_mcDY -> SetFillColor(kYellow-4);
//h_mcDY -> SetFillStyle(3004);

    TH1F* h_mcDiboson = (TH1F*)h_mc3->Clone("h_mcDiboson");
    h_mcDiboson->Reset();
    h_mcDiboson->Add(h_mc3);
    h_mcDiboson->Add(h_mc4);
    h_mcDiboson->Add(h_mc6);


    TH1F *ht = (TH1F*)h_mcDY->Clone("ht");
    ht->Reset();
//ht->Add(h_mc8);
    ht->Add(h_mc7);
//ht->Add(h_mc6);
//ht->Add(h_mc4);
//ht->Add(h_mc3);
    ht->Add(h_mcDiboson);
    ht->Add(h_mc2);
    ht->Add(h_mcDY);

    THStack *hs = new THStack("hs","");
//hs->Add(h_mc8); // ZH powheg
    hs->Add(h_mc7);   // ZH madgraph
//hs->Add(h_mc6);
//hs->Add(h_mc4);
//hs->Add(h_mc3);
    hs->Add(h_mcDiboson);
    hs->Add(h_mc2);
    hs->Add(h_mcDY);

//TCanvas* c1 = 0;
//c1 = new TCanvas("c","c",10,10,800,600);
    c1->cd();

    TPad *pad1 = new TPad("pad1","pad1",0.0,0.3,1.0,1.0);
    pad1->SetBottomMargin(0.001);
    pad1->Draw();
    pad1->cd();

    if( title=="FATjetSDmass" || title=="FATjetSDmassCorr" || title=="FATjetPRmass" || title=="FATjetPRmassCorr" || title=="FATnSubjet" || title=="ZHmass" )
    {
        pad1->SetLogy();
    }

    hs->Draw("HIST");
    hs->GetYaxis()->SetTitle("Events");
    hs->GetYaxis()->SetTitleSize(0.05);
    hs->GetYaxis()->SetLabelSize(0.045);
    hs->GetYaxis()->SetTitleOffset(1.0);// 0.7
//hs->SetMinimum(8);
    hs->SetMinimum(0.1);
    hs->SetMaximum(1.2*hs->GetMaximum());
    if (title=="ZHmass") {
        hs->GetXaxis()->SetRangeUser(0, 3000);
    }

    h_mc8->Draw("same hist");


    h_data->Draw("EPX0SAMES");
    h_data->SetMarkerColor(kBlack);
    h_data->SetMarkerStyle(20);
    h_data->SetMarkerSize (1.0);
    h_data->SetStats(0);

    TLegend *leg;

    if (title=="FATjetTau2dvTau1") {
        leg = new TLegend(0.15, 0.547, 0.41, 0.88);
    }
    else {
        leg = new TLegend(0.65, 0.547, 0.91, 0.88);
    }
//leg = new TLegend(0.65, 0.547, 0.91, 0.88);
    leg->SetBorderSize(0);
    leg->SetEntrySeparation(0.01);
    leg->SetFillColor(0);
    leg->SetFillStyle(0);

    leg->AddEntry(h_data,"Data","p");
    leg->AddEntry(h_mcDY,"DY","f");
    leg->AddEntry(h_mc2,"t#bar{t}","f");
//leg->AddEntry(h_mc3,"ZZ","f");
//leg->AddEntry(h_mc4,"WZ","f");
//leg->AddEntry(h_mc6,"WW","f");
    leg->AddEntry(h_mcDiboson,"Diboson","f");
    leg->AddEntry(h_mc7,"ZH madgraph","f");
    leg->AddEntry(h_mc8,"ZH powheg (not in stack)","f");

    leg->Draw();

    TLatex *lar = new TLatex();
    lar->SetNDC(kTRUE);
    lar->SetTextSize(0.04);
    lar->SetLineWidth(5);
    lar->DrawLatex(0.14, 0.94, "CMS #it{#bf{2016}}");
    lar->DrawLatex(0.60, 0.94, "L = 12.7 fb^{-1} at #sqrt{s} = 13 TeV");

    pad1->Update();
    c1->Update();

    c1->cd();

    TH1F *h_ratio = (TH1F*)h_data->Clone("h_ratio");

    TPad *pad2 = new TPad("pad2","pad2",0,0,1,0.3);// 0.3
    pad2->SetTopMargin(0);
    pad2->SetBottomMargin(0.3);
    pad2->Draw();
    pad2->cd();
    h_ratio->SetTitle("");
    h_ratio->SetStats(0);

    if (title=="Zpt") {
        h_ratio->GetXaxis ()->SetTitle("p_{T}(Z) [GeV/c]");
    } else if (title=="Zmass") {
        h_ratio->GetXaxis ()->SetTitle("M(Z) [GeV/c^{2}]");//
    } else if (title=="ZRapidity") {
        h_ratio->GetXaxis ()->SetTitle("y(Z)");
    } else if (title=="Zeta") {
        h_ratio->GetXaxis ()->SetTitle("#eta(Z)");
    } else if (title=="nVtx") {
        h_ratio->GetXaxis ()->SetTitle("Number of Vertices");
    } else if (title=="leadElePt") {
        h_ratio->GetXaxis ()->SetTitle("Leading Electron p_{T} [GeV/c]");
    } else if (title=="subleadElePt") {
        h_ratio->GetXaxis ()->SetTitle("Sub-Leading Electron p_{T} [GeV/c]");
    } else if (title=="leadEleEta") {
        h_ratio->GetXaxis ()->SetTitle("Leading Electron #eta");
    } else if (title=="subleadEleEta") {
        h_ratio->GetXaxis ()->SetTitle("Sub-Leading Electron #eta");
    } else if (title=="FATjetPt") {
        h_ratio->GetXaxis ()->SetTitle("FAT Jet p_{T} [GeV/c]");
    } else if (title=="FATjetEta") {
        h_ratio->GetXaxis ()->SetTitle("FAT Jet #eta");
    } else if (title=="FATjetCISVV2") {
        h_ratio->GetXaxis ()->SetTitle("FAT Jet CSVv2");
    } else if (title=="FATjetSDmass") {
        h_ratio->GetXaxis ()->SetTitle("FAT Jet Soft Drop Mass [GeV/c^{2}]");
    } else if (title=="FATjetSDmassCorr") {
        h_ratio->GetXaxis ()->SetTitle("FAT Jet Corrected Soft Drop Mass [GeV/c^{2}]");
    }   else if (title=="FATjetPRmass") {
        h_ratio->GetXaxis ()->SetTitle("FAT Jet Pruned Mass [GeV/c^{2}]");
    } else if (title=="FATjetPRmassCorr") {
        h_ratio->GetXaxis ()->SetTitle("FAT Jet L2L3 Corrected Pruned Mass [GeV/c^{2}]");
    } else if (title=="FATjetTau1") {
        h_ratio->GetXaxis ()->SetTitle("FAT Jet #tau_{1}");
    } else if (title=="FATjetTau2") {
        h_ratio->GetXaxis ()->SetTitle("FAT Jet #tau_{2}");
    } else if (title=="FATjetTau2dvTau1") {
        h_ratio->GetXaxis ()->SetTitle("FAT Jet #tau_{21}");
    } else if (title=="FATnSubjet") {
        h_ratio->GetXaxis ()->SetTitle("Number of Subjets");
    } else if (title=="FATsubjetLeadingPt") {
        h_ratio->GetXaxis ()->SetTitle("Leading SubJet p_{T} [GeV/c]");
    } else if (title=="FATsubjetLeadingEta") {
        h_ratio->GetXaxis ()->SetTitle("Leading SubJet #eta");
    } else if (title=="FATsubjetLeadingSDCSV") {
        h_ratio->GetXaxis ()->SetTitle("Leading SubJet Soft Drop CSV");
    } else if (title=="FATsubjetSubLeadingPt") {
        h_ratio->GetXaxis ()->SetTitle("Sub-Leading SubJet p_{T} [GeV/c]");
    } else if (title=="FATsubjetSubLeadingEta") {
        h_ratio->GetXaxis ()->SetTitle("Sub-Leading SubJet #eta");
    } else if (title=="FATsubjetSubLeadingSDCSV") {
        h_ratio->GetXaxis ()->SetTitle("Sub-Leading SubJet Soft Drop CSV");
    } else if (title=="ADDjet_DoubleSV") {
        h_ratio->GetXaxis ()->SetTitle("ADDjet double b-tagger discriminator");
    }  else if (title=="ZHmass") {
        h_ratio->GetXaxis ()->SetTitle("ZH invariant mass [GeV/c^{2}]");
    }

    if (title=="ZHmass") {
        h_ratio->GetXaxis()->SetRangeUser(0, 3000);
    }
    h_ratio->GetXaxis()->SetTitleSize(0.11);
    h_ratio->GetXaxis()->SetLabelFont(42);
    h_ratio->GetXaxis()->SetLabelSize(0.10);
    h_ratio->GetXaxis()->SetTitleFont(42);
    h_ratio->GetYaxis()->SetTitle("Data/MC");
    h_ratio->GetYaxis()->SetNdivisions(505);
    h_ratio->GetYaxis()->SetTitleSize(0.11);
    h_ratio->GetYaxis()->SetLabelSize(0.10);
    h_ratio->GetYaxis()->SetRangeUser(0.2, 2);
    h_ratio->GetYaxis()->SetTitleOffset(0.33);

    h_ratio->Divide(ht);
    h_ratio->SetMarkerStyle(20);
    h_ratio->Draw("E0PX0");

    TLine *OLine = new TLine(h_ratio->GetXaxis()->GetXmin(),1.,h_ratio->GetXaxis()->GetXmax(),1.);
    OLine->SetLineColor(kRed);
    OLine->SetLineWidth(2);
    OLine->Draw();

    /*
    TLatex *lar = new TLatex();
    lar->SetNDC(kTRUE);
    lar->SetTextSize(0.04);
    lar->SetLineWidth(5);
    lar->DrawLatex(0.14, 0.94, "CMS #it{#bf{2016}}");
    lar->DrawLatex(0.60, 0.94, "L = 4.327 fb^{-1} at #sqrt{s} = 13 TeV");
    */

    c1->cd();
//c1->SaveAs((path + title + ".pdf").c_str());

}