TLegend *GetLegendData(TH1D *hpp,Int_t identifier){
    
  // TLegend * legend = new TLegend(0.011/gPad->GetWNDC()+gPad->GetLeftMargin(),0.13/gPad->GetHNDC()+gPad->GetBottomMargin(),0.2/gPad->GetWNDC()+gPad->GetLeftMargin(),0.18/gPad->GetHNDC()+gPad->GetBottomMargin());
   TLegend * legend = new TLegend(0.3,0.48,0.6,0.57,NULL,"brNDC");
  
    legend->SetFillColor(0);
    legend->SetFillStyle(0);
    legend->SetBorderSize(0);
    legend->SetTextFont(43);
    //    legend->SetTextSize(0.06/(gPad->GetHNDC())*scaleHeightPads);
    legend->SetTextSize(22.1*innerPadHeight/referencePadHeight*resizeTextFactor);// settings for font 42: 0.07/(gPad->GetHNDC())*scaleHeight
 
    legend->AddEntry(hpp,"pp, #sqrt{#it{s}} = 7 TeV","lep");
    legend->SetName(Form("LegendDataPP_%d",identifier));
    return legend;
  }
TLegend *GetLegendBaselines(TGraphAsymmErrors *gpp,Int_t identifier){
  TLegend * legend = new TLegend(0.27,0.39,0.55,0.47);//pad 0
  //  TLegend * legend = new TLegend(0.40,0.45,0.85,0.55);//pad 1
  // TLegend * legend = new TLegend(0.40,0.6,0.85,0.67);
  // TLegend * legend = new TLegend(0.40,0.64,0.85,0.72);
  //  TLegend * legend = new TLegend(0.011/gPad->GetWNDC()+gPad->GetLeftMargin(),0.22/gPad->GetHNDC()+gPad->GetBottomMargin(),0.27/gPad->GetWNDC()+gPad->GetLeftMargin(),0.28/gPad->GetHNDC()+gPad->GetBottomMargin());
  legend->SetFillColor(0);
  legend->SetFillStyle(0);
  legend->SetBorderSize(0);
  legend->SetTextFont(43);
  legend->SetTextAlign(12);
  // legend->SetTextSize(0.055/(gPad->GetHNDC())*scaleHeightPads);
  legend->SetTextSize(22*innerPadHeight/referencePadHeight*resizeTextFactor);// settings for font 42: 0.07/(gPad->GetHNDC())*scaleHeight
 
  legend->AddEntry(gpp,"baseline-subtraction uncertainty","f");
  legend->SetName(Form("LegendBaselineUncPPandpPb_%d",identifier));
  return legend;
}
Esempio n. 3
0
  /** 
   * Get or create a stack legend.  This is done by adding a TLegend
   * object to the list of functions for the first histogram in the
   * stack.
   * 
   * @param stack Stack to get the legend from/modify 
   * 
   * @return The legend object or null
   */
  TLegend* StackLegend(THStack* stack) 
  {
    TList* hists = stack->GetHists();
    if (!hists) return 0;
    
    TObject* first = hists->First();
    if (!first) return 0;

    TH1*    hist = static_cast<TH1*>(first);
    TList*  list = hist->GetListOfFunctions();
    TObject* o   = list->FindObject("legend");
    if (o) return static_cast<TLegend*>(o);
    
    TLegend* l = new TLegend(0.65, 0.65, 0.9, 0.9, "", "NDC");
    l->SetName("legend");
    l->SetBorderSize(0);
    l->SetFillColor(0);
    l->SetFillStyle(0);
    l->SetTextFont(42);
    list->Add(l);
    
    return l;
  }
Esempio n. 4
0
int main(int argc, char * argv[]){
        cout<<"****************************** FILES OPENING ***************************************"<<endl;

        string INPUT(argv[1]);
        string OUTPUT(argv[2]);

        FileSaver finalHistos;
        FileSaver Plots;
	finalHistos.setName(INPUT.c_str());
	Plots.setName(OUTPUT.c_str());


        bool checkfile = finalHistos.CheckFile();


        cout<<"****************************** BINS ***************************************"<<endl;

        SetBins();

	PRB.Print();

        cout<<"**TOF**"<<endl;
        ToFDB.Print();

        cout<<"**NaF**"<<endl;
        NaFDB.Print();

        cout<<"**Agl**"<<endl;
        AglDB.Print();

        ToFDB.UseBetaEdges();
        NaFDB.UseBetaEdges();
        AglDB.UseBetaEdges();

        PRB.UseREdges();


        cout<<endl;

	cout<<"****************************** READING DATABASES *************************************"<<endl;
	
	string filename2="./database_P.root";
        TFile * file2 = TFile::Open(filename2.c_str(),"READ");
        
        string filename3="./database_D.root";
        TFile * file3 = TFile::Open(filename3.c_str(),"READ");

        string filename4="./database_PD.root";
        TFile * file4 = TFile::Open(filename4.c_str(),"READ");

	std::vector<TGraphAsymmErrors *> D_Graphs;
	std::vector<TGraphAsymmErrors *> PD_Graphs;

        TList *ExperimentsD = file3->GetListOfKeys();
        TIter nextD(ExperimentsD);
        TKey * keyD;
	TObject * obj;

        while((keyD = (TKey*)nextD())){
                obj = file3->Get(keyD->GetName());
                if(obj->InheritsFrom("TGraphAsymmErrors")) D_Graphs.push_back((TGraphAsymmErrors *)obj);
        }

	TList *ExperimentsPD = file4->GetListOfKeys();
        TIter nextPD(ExperimentsPD);
        TKey * keyPD;

        while((keyPD = (TKey*)nextPD())){
                obj = file4->Get(keyPD->GetName());
                if(obj->InheritsFrom("TGraphAsymmErrors")) PD_Graphs.push_back((TGraphAsymmErrors *)obj);
        }


        cout<<"****************************** PLOTTING FLUXES ***************************************"<<endl;
	
	Flux * DFluxTOF = new Flux(finalHistos, "DFluxTOF", "FullsetEff_D_TOF","FullsetEfficiency","TOFfits/Fit Results/Primary Deuteron Counts","ExposureTOF","Gen. Acceptance",ToFDB);
	Flux * DFluxNaF = new Flux(finalHistos, "DFluxNaF", "FullsetEff_D_NaF","FullsetEfficiency","NaFfits/Fit Results/Primary Deuteron Counts","ExposureNaF","Gen. Acceptance",NaFDB);
	Flux * DFluxAgl = new Flux(finalHistos, "DFluxAgl", "FullsetEff_D_Agl","FullsetEfficiency","Aglfits/Fit Results/Primary Deuteron Counts","ExposureAgl","Gen. Acceptance",AglDB);

	TCanvas *c1 = new TCanvas("Gen. Acceptance");
	c1->SetCanvasSize(2000,1500);

	PlotTH1FintoGraph(gPad,ToFDB, DFluxTOF->GetGenAcceptance(),"Kinetic Energy [GeV/nucl.]", "Gen. Acceptance [m^{2} sr]",1,true,"Psame",0.1,10,0.1,3,"TOF range",8);
	PlotTH1FintoGraph(gPad,NaFDB, DFluxNaF->GetGenAcceptance(),"Kinetic Energy [GeV/nucl.]", "Gen. Acceptance [m^{2} sr]",1,true,"Psame",0.1,10,0.1,3,"NaF range",22);
	PlotTH1FintoGraph(gPad,AglDB, DFluxAgl->GetGenAcceptance(),"Kinetic Energy [GeV/nucl.]", "Gen. Acceptance [m^{2} sr]",1,true,"Psame",0.1,10,0.1,3,"Agl range",29);

	Plots.Add(c1);
	Plots.writeObjsInFolder("Fluxes");


	float potenza = 0;
	TCanvas *c2 = new TCanvas("Deuteron Primary Flux");
	c2->SetCanvasSize(2000,1500);

	TH2F * Frame = CreateFrame(0.01,25,0.01,1000,"Kin.En./nucl. [GeV/nucl.]","Flux [(m^2 sr GeV/nucl.)^{-1}]");	
        c2->cd();
        gPad->SetLogx();
        gPad->SetLogy();
        gPad->SetGridx();
        gPad->SetGridy();
        TGraph* galprop3P=new TGraph();
        TGraph* galprop3P2=new TGraph();
        float x,y=0;
        int j=0;
        {
                string filename="./Galprop/Tom/deut_1500.dat";
                cout<<filename<<endl;
                ifstream fp(filename.c_str());
                while (!fp.eof()){
                        fp>>x>>y;
                        if(x/1e3>0.05&&x/1e3<=100)
                                galprop3P->SetPoint(j,x/1e3,y*1e7*pow(x/1e3,potenza));
                        j++;
                }
        }
	
	        j=0;
        {
                string filename="./Galprop/Tom/deut_100.dat";
                cout<<filename<<endl;
                ifstream fp(filename.c_str());
                while (!fp.eof()){
                        fp>>x>>y;
                        if(x/1e3>0.05&&x/1e3<=100)
                                galprop3P2->SetPoint(j,x/1e3,y*1e7*pow(x/1e3,potenza));
                        j++;
                }
        }
        galprop3P->GetXaxis()->SetRangeUser(0.1,20);
        galprop3P->GetYaxis()->SetRangeUser(1e-3,1e3);

        galprop3P->SetTitle("Deutons Flux: Geo. Zones");
        galprop3P->GetXaxis()->SetTitle("Kin.En./nucl. [GeV/nucl.]");
        galprop3P ->GetYaxis()->SetTitle("Flux [(m^2 sr GeV/nucl.)^-1]");
        galprop3P ->GetXaxis()->SetTitleSize(0.045);
        galprop3P->GetYaxis()->SetTitleSize(0.045);
        galprop3P ->GetYaxis()->SetRangeUser(1e-2,1e4);

	Frame->Draw();
	galprop3P->Draw("sameC");
        galprop3P2->Draw("sameC");
	
	TLegend * leg =new TLegend(0.8, 0.1,0.95,0.95);
	leg->SetName("leg");
        for(uint n=0;n<D_Graphs.size();n++){
                D_Graphs[n] ->Draw("Psame");
                D_Graphs[n]->SetMarkerSize(2); 
                leg->AddEntry(D_Graphs[n],D_Graphs[n]->GetTitle(),"p");
        }

	leg->SetFillColor(0);
	leg->SetLineWidth(2);
	leg->Draw("same");

	DFluxNaF->GetFlux()->Smooth();        

	PlotTH1FintoGraph(gPad,ToFDB, DFluxTOF->GetFlux(),"Kinetic Energy [GeV/nucl.]", "Flux",1,true,"Psame",0.1,10,0.01,1000,"This Work (TOF)",8);
	PlotTH1FintoGraph(gPad,NaFDB, DFluxNaF->GetFlux(),"Kinetic Energy [GeV/nucl.]", "Flux",1,true,"Psame",0.1,10,0.01,1000,"This Work (NaF)",22);
	PlotTH1FintoGraph(gPad,AglDB, DFluxAgl->GetFlux(),"Kinetic Energy [GeV/nucl.]", "Flux",1,true,"Psame",0.1,10,0.01,1000,"This Work (Agl)",29);

	
	Plots.Add(c2);
	Plots.writeObjsInFolder("Fluxes");

	TCanvas *c3 = new TCanvas("D/P ratio");
	c3->SetCanvasSize(2000,1500);
	j=0;
	TGraph* galprop3DP=new TGraph();
        TGraph* galprop3DP2=new TGraph();
        {
                string filename="./Galprop/Tom/dP_1500.dat";
                cout<<filename<<endl;
                ifstream fp(filename.c_str());
                while (!fp.eof()){
                        fp>>x>>y;
                        if(x/1e3>0.05&&x/1e3<=100)
                                galprop3DP->SetPoint(j,x/(0.5*1e3),y);
                        j++;
                }
        }
	
	       j=0;
        {
                string filename="./Galprop/Tom/dP_500.dat";
                cout<<filename<<endl;
                ifstream fp(filename.c_str());
                while (!fp.eof()){
                        fp>>x>>y;
                        if(x/1e3>0.05&&x/1e3<=100)
                                galprop3DP2->SetPoint(j,x/(0.5*1e3),y);
                        j++;
                }
        }
        galprop3DP->GetXaxis()->SetRangeUser(0.1,20);

        galprop3DP->SetTitle("Deutons Flux: Geo. Zones");
        galprop3DP->GetXaxis()->SetTitle("Kin.En./nucl. [GeV/nucl.]");
        galprop3DP ->GetYaxis()->SetTitle("Flux [(m^2 sr GeV/nucl.)^-1]");
        galprop3DP ->GetXaxis()->SetTitleSize(0.045);

	TH1F * DPRatioTOF = (TH1F *)finalHistos.Get("Fluxes/DP ratio TOF");
	TH1F * DPRatioNaF = (TH1F *)finalHistos.Get("Fluxes/DP ratio NaF");
	TH1F * DPRatioAgl = (TH1F *)finalHistos.Get("Fluxes/DP ratio Agl");

	DPRatioNaF->Smooth();	

	cout<<DPRatioTOF<<endl;

	PlotTH1FintoGraph(gPad,ToFDB, DPRatioTOF ,"Kinetic Energy [GeV/nucl.]", "Flux",1,true,"Psame",0.1,10,0.00001,0.07,"This Work (TOF)",8);
	PlotTH1FintoGraph(gPad,NaFDB, DPRatioNaF ,"Kinetic Energy [GeV/nucl.]", "Flux",1,true,"Psame",0.1,10,0.00001,0.07,"This Work (NaF)",22);
	PlotTH1FintoGraph(gPad,AglDB, DPRatioAgl ,"Kinetic Energy [GeV/nucl.]", "Flux",1,true,"Psame",0.1,10,0.00001,0.07,"This Work (Agl)",29);

	galprop3DP->Draw("sameC");
        galprop3DP2->Draw("sameC");

	leg = (TLegend*) gPad->FindObject("leg");

        for(uint n=0;n<PD_Graphs.size();n++){
                PD_Graphs[n] ->Draw("Psame");
                PD_Graphs[n]->SetMarkerSize(2); 
                leg->AddEntry(PD_Graphs[n],PD_Graphs[n]->GetTitle(),"p");
        }


	Plots.Add(c3);
	Plots.writeObjsInFolder("Fluxes");


	return 0;
}
Esempio n. 5
0
//this makes shape plots of MT2 distributions for several VSPT bins for various SM types (W,Z,ttbar,susy,data)
void UTMplots(){

gROOT->cd();
gROOT->SetStyle("Plain");
gStyle->SetPalette(1);
gStyle->SetOptStat(0);

TChain *LM6 = new TChain("MassTree");
TChain *WJets = new TChain("MassTree");
TChain *ZJets = new TChain("MassTree");
TChain *TTbar = new TChain("MassTree");
TChain *Data = new TChain("MassTree");

//read in trees
LM6->Add("dcap://t3se01.psi.ch:22125/pnfs/psi.ch/cms/trivcat/store/user/mmasciov/SUSY/MassTrees/MT2_V02-03-02/20130430_8TeV/SUSY-LM6-sftsht-8TeV-pythia6-Summer12-DR53X-PU-S10-START53-V7A-v1/*.root");
WJets->Add("dcap://t3se01.psi.ch:22125/pnfs/psi.ch/cms/trivcat/store/user/mmasciov/SUSY/MassTrees/MT2_V02-03-02/20130318_8TeV/WJetsToLNu-HT-400ToInf-8TeV-madgraph-Summer12-DR53X-PU-S10-START53-V7A-v1/*.root");
WJets->Add("dcap://t3se01.psi.ch:22125/pnfs/psi.ch/cms/trivcat/store/user/mmasciov/SUSY/MassTrees/MT2_V02-03-02/20130318_8TeV/WJetsToLNu-HT-400ToInf-8TeV-madgraph-v2-Summer12-DR53X-PU-S10-START53-V7A-v1/*.root");
ZJets->Add("dcap://t3se01.psi.ch:22125/pnfs/psi.ch/cms/trivcat/store/user/haweber/SUSY/MassTrees/MT2_V02-03-02/20130318_8TeV/ZJetsToNuNu-400-HT-inf-TuneZ2Star-8TeV-madgraph-Summer12-DR53X-PU-S10-START53-V7A-v1/*.root");
ZJets->Add("dcap://t3se01.psi.ch:22125/pnfs/psi.ch/cms/trivcat/store/user/haweber/SUSY/MassTrees/MT2_V02-03-02/20130318_8TeV/ZJetsToNuNu-400-HT-inf-TuneZ2Star-8TeV-madgraph-ext-Summer12-DR53X-PU-S10-START53-V7A-v1/*.root");
TTbar->Add("dcap://t3se01.psi.ch:22125/pnfs/psi.ch/cms/trivcat/store/user/casal/SUSY/MassTrees/MT2_V02-03-02/20130503_8TeV/TTJets-SemiLeptMGDecays-8TeV-madgraph-tauola-Summer12-DR53X-PU-S10-START53-V7C-v1/*.root");
int nd = Data->Add("dcap://t3se01.psi.ch:22125/pnfs/psi.ch/cms/trivcat/store/user/casal/SUSY/MassTrees/MT2_V02-03-02/20130318_8TeV/HT-Run2012A-13Jul2012-v1-2/*.root");
nd += Data->Add("dcap://t3se01.psi.ch:22125/pnfs/psi.ch/cms/trivcat/store/user/casal/SUSY/MassTrees/MT2_V02-03-02/20130318_8TeV/HT-Run2012A-recover-06Aug2012-v1-2/*.root");
nd += Data->Add("dcap://t3se01.psi.ch:22125/pnfs/psi.ch/cms/trivcat/store/user/casal/SUSY/MassTrees/MT2_V02-03-02/20130318_8TeV/JetHT-Run2012B-13Jul2012-v1-2/*.root");
nd += Data->Add("dcap://t3se01.psi.ch:22125/pnfs/psi.ch/cms/trivcat/store/user/casal/SUSY/MassTrees/MT2_V02-03-02/20130318_8TeV/JetHT-Run2012C-24Aug2012-v2-2/*.root");
nd += Data->Add("dcap://t3se01.psi.ch:22125/pnfs/psi.ch/cms/trivcat/store/user/casal/SUSY/MassTrees/MT2_V02-03-02/20130318_8TeV/JetHT-Run2012C-EcalRecover-11Dec2012-v1-2/*.root");
nd += Data->Add("dcap://t3se01.psi.ch:22125/pnfs/psi.ch/cms/trivcat/store/user/casal/SUSY/MassTrees/MT2_V02-03-02/20130318_8TeV/JetHT-Run2012C-PromptReco-v2-3/*.root");
nd += Data->Add("dcap://t3se01.psi.ch:22125/pnfs/psi.ch/cms/trivcat/store/user/casal/SUSY/MassTrees/MT2_V02-03-02/20130318_8TeV/JetHT-Run2012D-PromptReco-v1-3/*.root");
cout << nd << endl;

//define histograms
TH1D *LM6VSPT0   = new TH1D("LM6VSPT0"  ,"", 75, 0, 750); LM6VSPT0  ->Sumw2(); LM6VSPT0  ->SetLineColor(kBlack);  LM6VSPT0  ->SetLineWidth(2);
TH1D *LM6VSPT20  = new TH1D("LM6VSPT20" ,"", 75, 0, 750); LM6VSPT20 ->Sumw2(); LM6VSPT20 ->SetLineColor(kRed);    LM6VSPT20 ->SetLineWidth(2);
TH1D *LM6VSPT30  = new TH1D("LM6VSPT30" ,"", 75, 0, 750); LM6VSPT30 ->Sumw2(); LM6VSPT30 ->SetLineColor(kGreen);  LM6VSPT30 ->SetLineWidth(2);
TH1D *LM6VSPT40  = new TH1D("LM6VSPT40" ,"", 75, 0, 750); LM6VSPT40 ->Sumw2(); LM6VSPT40 ->SetLineColor(kBlue);   LM6VSPT40 ->SetLineWidth(2);
TH1D *LM6VSPT50  = new TH1D("LM6VSPT50" ,"", 75, 0, 750); LM6VSPT50 ->Sumw2(); LM6VSPT50 ->SetLineColor(kYellow); LM6VSPT50 ->SetLineWidth(2);
TH1D *LM6VSPT70  = new TH1D("LM6VSPT70" ,"", 75, 0, 750); LM6VSPT70 ->Sumw2(); LM6VSPT70 ->SetLineColor(kMagenta);LM6VSPT70 ->SetLineWidth(2);
TH1D *LM6VSPT100 = new TH1D("LM6VSPT100","", 75, 0, 750); LM6VSPT100->Sumw2(); LM6VSPT100->SetLineColor(kCyan);   LM6VSPT100->SetLineWidth(2);
TH1D *WJetsVSPT0   = new TH1D("WJetsVSPT0"  ,"", 75, 0, 750); WJetsVSPT0  ->Sumw2(); WJetsVSPT0  ->SetLineColor(kBlack);   WJetsVSPT0  ->SetLineWidth(2);
TH1D *WJetsVSPT20  = new TH1D("WJetsVSPT20" ,"", 75, 0, 750); WJetsVSPT20 ->Sumw2(); WJetsVSPT20 ->SetLineColor(kRed);     WJetsVSPT20 ->SetLineWidth(2);
TH1D *WJetsVSPT30  = new TH1D("WJetsVSPT30" ,"", 75, 0, 750); WJetsVSPT30 ->Sumw2(); WJetsVSPT30 ->SetLineColor(kGreen);   WJetsVSPT30 ->SetLineWidth(2);
TH1D *WJetsVSPT40  = new TH1D("WJetsVSPT40" ,"", 75, 0, 750); WJetsVSPT40 ->Sumw2(); WJetsVSPT40 ->SetLineColor(kBlue);    WJetsVSPT40 ->SetLineWidth(2);
TH1D *WJetsVSPT50  = new TH1D("WJetsVSPT50" ,"", 75, 0, 750); WJetsVSPT50 ->Sumw2(); WJetsVSPT50 ->SetLineColor(kYellow);  WJetsVSPT50 ->SetLineWidth(2);
TH1D *WJetsVSPT70  = new TH1D("WJetsVSPT70" ,"", 75, 0, 750); WJetsVSPT70 ->Sumw2(); WJetsVSPT70 ->SetLineColor(kMagenta); WJetsVSPT70 ->SetLineWidth(2);
TH1D *WJetsVSPT100 = new TH1D("WJetsVSPT100","", 75, 0, 750); WJetsVSPT100->Sumw2(); WJetsVSPT100->SetLineColor(kCyan);    WJetsVSPT100->SetLineWidth(2);
TH1D *ZJetsVSPT0   = new TH1D("ZJetsVSPT0"  ,"", 75, 0, 750); ZJetsVSPT0  ->Sumw2(); ZJetsVSPT0  ->SetLineColor(kBlack);   ZJetsVSPT0  ->SetLineWidth(2);
TH1D *ZJetsVSPT20  = new TH1D("ZJetsVSPT20" ,"", 75, 0, 750); ZJetsVSPT20 ->Sumw2(); ZJetsVSPT20 ->SetLineColor(kRed);     ZJetsVSPT20 ->SetLineWidth(2);
TH1D *ZJetsVSPT30  = new TH1D("ZJetsVSPT30" ,"", 75, 0, 750); ZJetsVSPT30 ->Sumw2(); ZJetsVSPT30 ->SetLineColor(kGreen);   ZJetsVSPT30 ->SetLineWidth(2);
TH1D *ZJetsVSPT40  = new TH1D("ZJetsVSPT40" ,"", 75, 0, 750); ZJetsVSPT40 ->Sumw2(); ZJetsVSPT40 ->SetLineColor(kBlue);    ZJetsVSPT40 ->SetLineWidth(2);
TH1D *ZJetsVSPT50  = new TH1D("ZJetsVSPT50" ,"", 75, 0, 750); ZJetsVSPT50 ->Sumw2(); ZJetsVSPT50 ->SetLineColor(kYellow);  ZJetsVSPT50 ->SetLineWidth(2);
TH1D *ZJetsVSPT70  = new TH1D("ZJetsVSPT70" ,"", 75, 0, 750); ZJetsVSPT70 ->Sumw2(); ZJetsVSPT70 ->SetLineColor(kMagenta); ZJetsVSPT70 ->SetLineWidth(2);
TH1D *ZJetsVSPT100 = new TH1D("ZJetsVSPT100","", 75, 0, 750); ZJetsVSPT100->Sumw2(); ZJetsVSPT100->SetLineColor(kCyan);    ZJetsVSPT100->SetLineWidth(2);
TH1D *TTbarVSPT0   = new TH1D("TTbarVSPT0"  ,"", 75, 0, 750); TTbarVSPT0  ->Sumw2(); TTbarVSPT0  ->SetLineColor(kBlack);   TTbarVSPT0  ->SetLineWidth(2);
TH1D *TTbarVSPT20  = new TH1D("TTbarVSPT20" ,"", 75, 0, 750); TTbarVSPT20 ->Sumw2(); TTbarVSPT20 ->SetLineColor(kRed);     TTbarVSPT20 ->SetLineWidth(2);
TH1D *TTbarVSPT30  = new TH1D("TTbarVSPT30" ,"", 75, 0, 750); TTbarVSPT30 ->Sumw2(); TTbarVSPT30 ->SetLineColor(kGreen);   TTbarVSPT30 ->SetLineWidth(2);
TH1D *TTbarVSPT40  = new TH1D("TTbarVSPT40" ,"", 75, 0, 750); TTbarVSPT40 ->Sumw2(); TTbarVSPT40 ->SetLineColor(kBlue);    TTbarVSPT40 ->SetLineWidth(2);
TH1D *TTbarVSPT50  = new TH1D("TTbarVSPT50" ,"", 75, 0, 750); TTbarVSPT50 ->Sumw2(); TTbarVSPT50 ->SetLineColor(kYellow);  TTbarVSPT50 ->SetLineWidth(2);
TH1D *TTbarVSPT70  = new TH1D("TTbarVSPT70" ,"", 75, 0, 750); TTbarVSPT70 ->Sumw2(); TTbarVSPT70 ->SetLineColor(kMagenta); TTbarVSPT70 ->SetLineWidth(2);
TH1D *TTbarVSPT100 = new TH1D("TTbarVSPT100","", 75, 0, 750); TTbarVSPT100->Sumw2(); TTbarVSPT100->SetLineColor(kCyan);    TTbarVSPT100->SetLineWidth(2);
//small MinDPhi
TH1D *DataQCDVSPT0   = new TH1D("DataQCDVSPT0"  ,"", 75, 0, 750); DataQCDVSPT0  ->Sumw2(); DataQCDVSPT0  ->SetLineColor(kBlack);  DataQCDVSPT0  ->SetLineWidth(2);
TH1D *DataQCDVSPT20  = new TH1D("DataQCDVSPT20" ,"", 75, 0, 750); DataQCDVSPT20 ->Sumw2(); DataQCDVSPT20 ->SetLineColor(kRed);    DataQCDVSPT20 ->SetLineWidth(2);
TH1D *DataQCDVSPT30  = new TH1D("DataQCDVSPT30" ,"", 75, 0, 750); DataQCDVSPT30 ->Sumw2(); DataQCDVSPT30 ->SetLineColor(kGreen);  DataQCDVSPT30 ->SetLineWidth(2);
TH1D *DataQCDVSPT40  = new TH1D("DataQCDVSPT40" ,"", 75, 0, 750); DataQCDVSPT40 ->Sumw2(); DataQCDVSPT40 ->SetLineColor(kBlue);   DataQCDVSPT40 ->SetLineWidth(2);
TH1D *DataQCDVSPT50  = new TH1D("DataQCDVSPT50" ,"", 75, 0, 750); DataQCDVSPT50 ->Sumw2(); DataQCDVSPT50 ->SetLineColor(kYellow); DataQCDVSPT50 ->SetLineWidth(2);
TH1D *DataQCDVSPT70  = new TH1D("DataQCDVSPT70" ,"", 75, 0, 750); DataQCDVSPT70 ->Sumw2(); DataQCDVSPT70 ->SetLineColor(kMagenta);DataQCDVSPT70 ->SetLineWidth(2);
TH1D *DataQCDVSPT100 = new TH1D("DataQCDVSPT100","", 75, 0, 750); DataQCDVSPT100->Sumw2(); DataQCDVSPT100->SetLineColor(kCyan);   DataQCDVSPT100->SetLineWidth(2);
//1lep,0b
TH1D *DataWVSPT0   = new TH1D("DataWVSPT0"  ,"", 75, 0, 750); DataWVSPT0  ->Sumw2(); DataWVSPT0  ->SetLineColor(kBlack);  DataWVSPT0  ->SetLineWidth(2);
TH1D *DataWVSPT20  = new TH1D("DataWVSPT20" ,"", 75, 0, 750); DataWVSPT20 ->Sumw2(); DataWVSPT20 ->SetLineColor(kRed);    DataWVSPT20 ->SetLineWidth(2);
TH1D *DataWVSPT30  = new TH1D("DataWVSPT30" ,"", 75, 0, 750); DataWVSPT30 ->Sumw2(); DataWVSPT30 ->SetLineColor(kGreen);  DataWVSPT30 ->SetLineWidth(2);
TH1D *DataWVSPT40  = new TH1D("DataWVSPT40" ,"", 75, 0, 750); DataWVSPT40 ->Sumw2(); DataWVSPT40 ->SetLineColor(kBlue);   DataWVSPT40 ->SetLineWidth(2);
TH1D *DataWVSPT50  = new TH1D("DataWVSPT50" ,"", 75, 0, 750); DataWVSPT50 ->Sumw2(); DataWVSPT50 ->SetLineColor(kYellow); DataWVSPT50 ->SetLineWidth(2);
TH1D *DataWVSPT70  = new TH1D("DataWVSPT70" ,"", 75, 0, 750); DataWVSPT70 ->Sumw2(); DataWVSPT70 ->SetLineColor(kMagenta);DataWVSPT70 ->SetLineWidth(2);
TH1D *DataWVSPT100 = new TH1D("DataWVSPT100","", 75, 0, 750); DataWVSPT100->Sumw2(); DataWVSPT100->SetLineColor(kCyan);   DataWVSPT100->SetLineWidth(2);
//1lep,1b 
TH1D *DataTopVSPT0   = new TH1D("DataTopVSPT0"  ,"", 75, 0, 750); DataTopVSPT0  ->Sumw2(); DataTopVSPT0  ->SetLineColor(kBlack);  DataTopVSPT0  ->SetLineWidth(2);
TH1D *DataTopVSPT20  = new TH1D("DataTopVSPT20" ,"", 75, 0, 750); DataTopVSPT20 ->Sumw2(); DataTopVSPT20 ->SetLineColor(kRed);    DataTopVSPT20 ->SetLineWidth(2);
TH1D *DataTopVSPT30  = new TH1D("DataTopVSPT30" ,"", 75, 0, 750); DataTopVSPT30 ->Sumw2(); DataTopVSPT30 ->SetLineColor(kGreen);  DataTopVSPT30 ->SetLineWidth(2);
TH1D *DataTopVSPT40  = new TH1D("DataTopVSPT40" ,"", 75, 0, 750); DataTopVSPT40 ->Sumw2(); DataTopVSPT40 ->SetLineColor(kBlue);   DataTopVSPT40 ->SetLineWidth(2);
TH1D *DataTopVSPT50  = new TH1D("DataTopVSPT50" ,"", 75, 0, 750); DataTopVSPT50 ->Sumw2(); DataTopVSPT50 ->SetLineColor(kYellow); DataTopVSPT50 ->SetLineWidth(2);
TH1D *DataTopVSPT70  = new TH1D("DataTopVSPT70" ,"", 75, 0, 750); DataTopVSPT70 ->Sumw2(); DataTopVSPT70 ->SetLineColor(kMagenta);DataTopVSPT70 ->SetLineWidth(2);
TH1D *DataTopVSPT100 = new TH1D("DataTopVSPT100","", 75, 0, 750); DataTopVSPT100->Sumw2(); DataTopVSPT100->SetLineColor(kCyan);   DataTopVSPT100->SetLineWidth(2);
//highDeltaPhi,0b 
TH1D *DataZVSPT0   = new TH1D("DataZVSPT0"  ,"", 75, 0, 750); DataZVSPT0  ->Sumw2(); DataZVSPT0  ->SetLineColor(kBlack);  DataZVSPT0  ->SetLineWidth(2);
TH1D *DataZVSPT20  = new TH1D("DataZVSPT20" ,"", 75, 0, 750); DataZVSPT20 ->Sumw2(); DataZVSPT20 ->SetLineColor(kRed);    DataZVSPT20 ->SetLineWidth(2);
TH1D *DataZVSPT30  = new TH1D("DataZVSPT30" ,"", 75, 0, 750); DataZVSPT30 ->Sumw2(); DataZVSPT30 ->SetLineColor(kGreen);  DataZVSPT30 ->SetLineWidth(2);
TH1D *DataZVSPT40  = new TH1D("DataZVSPT40" ,"", 75, 0, 750); DataZVSPT40 ->Sumw2(); DataZVSPT40 ->SetLineColor(kBlue);   DataZVSPT40 ->SetLineWidth(2);
TH1D *DataZVSPT50  = new TH1D("DataZVSPT50" ,"", 75, 0, 750); DataZVSPT50 ->Sumw2(); DataZVSPT50 ->SetLineColor(kYellow); DataZVSPT50 ->SetLineWidth(2);
TH1D *DataZVSPT70  = new TH1D("DataZVSPT70" ,"", 75, 0, 750); DataZVSPT70 ->Sumw2(); DataZVSPT70 ->SetLineColor(kMagenta);DataZVSPT70 ->SetLineWidth(2);
TH1D *DataZVSPT100 = new TH1D("DataZVSPT100","", 75, 0, 750); DataZVSPT100->Sumw2(); DataZVSPT100->SetLineColor(kCyan);   DataZVSPT100->SetLineWidth(2);

//fill histograms
gROOT->cd();
cout << "LM6VSPT0" << endl;
LM6->Draw("misc.MT2>>LM6VSPT0",  "NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=0&&misc.Vectorsumpt<20","goff");
cout << "LM6VSPT20" << endl;
LM6->Draw("misc.MT2>>LM6VSPT20", "NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=20&&misc.Vectorsumpt<30","goff");
cout << "LM6VSPT30" << endl;
LM6->Draw("misc.MT2>>LM6VSPT30", "NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=30&&misc.Vectorsumpt<40","goff");
cout << "LM6VSPT40" << endl;
LM6->Draw("misc.MT2>>LM6VSPT40", "NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=40&&misc.Vectorsumpt<50","goff");
cout << "LM6VSPT50" << endl;
LM6->Draw("misc.MT2>>LM6VSPT50", "NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=50&&misc.Vectorsumpt<70","goff");
cout << "LM6VSPT70" << endl;
LM6->Draw("misc.MT2>>LM6VSPT70", "NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=70&&misc.Vectorsumpt<100","goff");
cout << "LM6VSPT100" << endl;
LM6->Draw("misc.MT2>>LM6VSPT100","NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=100","goff");

cout << "WJetsVSPT0" << endl;
WJets->Draw("misc.MT2>>WJetsVSPT0",  "NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=0&&misc.Vectorsumpt<20","goff");
cout << "WJetsVSPT20" << endl;
WJets->Draw("misc.MT2>>WJetsVSPT20", "NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=20&&misc.Vectorsumpt<30","goff");
cout << "WJetsVSPT30" << endl;
WJets->Draw("misc.MT2>>WJetsVSPT30", "NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=30&&misc.Vectorsumpt<40","goff");
cout << "WJetsVSPT40" << endl;
WJets->Draw("misc.MT2>>WJetsVSPT40", "NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=40&&misc.Vectorsumpt<50","goff");
cout << "WJetsVSPT50" << endl;
WJets->Draw("misc.MT2>>WJetsVSPT50", "NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=50&&misc.Vectorsumpt<70","goff");
cout << "WJetsVSPT70" << endl;
WJets->Draw("misc.MT2>>WJetsVSPT70", "NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=70&&misc.Vectorsumpt<100","goff");
cout << "WJetsVSPT100" << endl;
WJets->Draw("misc.MT2>>WJetsVSPT100","NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=100","goff");

cout << "ZJetsVSPT0" << endl;
ZJets->Draw("misc.MT2>>ZJetsVSPT0",  "NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=0&&misc.Vectorsumpt<20","goff");
cout << "ZJetsVSPT20" << endl;
ZJets->Draw("misc.MT2>>ZJetsVSPT20", "NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=20&&misc.Vectorsumpt<30","goff");
cout << "ZJetsVSPT30" << endl;
ZJets->Draw("misc.MT2>>ZJetsVSPT30", "NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=30&&misc.Vectorsumpt<40","goff");
cout << "ZJetsVSPT40" << endl;
ZJets->Draw("misc.MT2>>ZJetsVSPT40", "NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=40&&misc.Vectorsumpt<50","goff");
cout << "ZJetsVSPT50" << endl;
ZJets->Draw("misc.MT2>>ZJetsVSPT50", "NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=50&&misc.Vectorsumpt<70","goff");
cout << "ZJetsVSPT70" << endl;
ZJets->Draw("misc.MT2>>ZJetsVSPT70", "NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=70&&misc.Vectorsumpt<100","goff");
cout << "ZJetsVSPT100" << endl;
ZJets->Draw("misc.MT2>>ZJetsVSPT100","NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=100","goff");

cout << "TTbarVSPT0" << endl;
TTbar->Draw("misc.MT2>>TTbarVSPT0",  "NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=0&&misc.Vectorsumpt<20","goff");
cout << "TTbarVSPT20" << endl;
TTbar->Draw("misc.MT2>>TTbarVSPT20", "NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=20&&misc.Vectorsumpt<30","goff");
cout << "TTbarVSPT30" << endl;
TTbar->Draw("misc.MT2>>TTbarVSPT30", "NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=30&&misc.Vectorsumpt<40","goff");
cout << "TTbarVSPT40" << endl;
TTbar->Draw("misc.MT2>>TTbarVSPT40", "NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=40&&misc.Vectorsumpt<50","goff");
cout << "TTbarVSPT50" << endl;
TTbar->Draw("misc.MT2>>TTbarVSPT50", "NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=50&&misc.Vectorsumpt<70","goff");
cout << "TTbarVSPT70" << endl;
TTbar->Draw("misc.MT2>>TTbarVSPT70", "NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=70&&misc.Vectorsumpt<100","goff");
cout << "TTbarVSPT100" << endl;
TTbar->Draw("misc.MT2>>TTbarVSPT100","NJetsIDLoose40>=2&&misc.HT>450&&misc.MET>30&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.Vectorsumpt>=100","goff");

cout << "DataQCDVSPT0" << endl;
Data->Draw("misc.MT2>>DataQCDVSPT0",  "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40<0.2&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=0&&misc.Vectorsumpt<20","goff");
cout << "DataQCDVSPT20" << endl;
Data->Draw("misc.MT2>>DataQCDVSPT20", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40<0.2&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=20&&misc.Vectorsumpt<30","goff");
cout << "DataQCDVSPT30" << endl;
Data->Draw("misc.MT2>>DataQCDVSPT30", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40<0.2&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=30&&misc.Vectorsumpt<40","goff");
cout << "DataQCDVSPT40" << endl;
Data->Draw("misc.MT2>>DataQCDVSPT40", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40<0.2&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=40&&misc.Vectorsumpt<50","goff");
cout << "DataQCDVSPT50" << endl;
Data->Draw("misc.MT2>>DataQCDVSPT50", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40<0.2&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=50&&misc.Vectorsumpt<70","goff");
cout << "DataQCDVSPT70" << endl;
Data->Draw("misc.MT2>>DataQCDVSPT70", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40<0.2&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=70&&misc.Vectorsumpt<100","goff");
cout << "DataQCDVSPT100" << endl;
Data->Draw("misc.MT2>>DataQCDVSPT100","NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40<0.2&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=100","goff");

cout << "DataZVSPT0" << endl;
Data->Draw("misc.MT2>>DataZVSPT0",  "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM==0&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=0&&misc.Vectorsumpt<20","goff");
cout << "DataZVSPT20" << endl;
Data->Draw("misc.MT2>>DataZVSPT20", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM==0&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=20&&misc.Vectorsumpt<30","goff");
cout << "DataZVSPT30" << endl;
Data->Draw("misc.MT2>>DataZVSPT30", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM==0&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=30&&misc.Vectorsumpt<40","goff");
cout << "DataZVSPT40" << endl;
Data->Draw("misc.MT2>>DataZVSPT40", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM==0&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=40&&misc.Vectorsumpt<50","goff");
cout << "DataZVSPT50" << endl;
Data->Draw("misc.MT2>>DataZVSPT50", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM==0&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=50&&misc.Vectorsumpt<70","goff");
cout << "DataZVSPT70" << endl;
Data->Draw("misc.MT2>>DataZVSPT70", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM==0&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=70&&misc.Vectorsumpt<100","goff");
cout << "DataZVSPT100" << endl;
Data->Draw("misc.MT2>>DataZVSPT100","NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&NEles==0&&NMuons==0&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM==0&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=100","goff");

cout << "DataWVSPT0" << endl;
Data->Draw("misc.MT2>>DataWVSPT0",  "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&(NEles+NMuons)==1&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM==0&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=0&&misc.Vectorsumpt<20","goff");
cout << "DataWVSPT20" << endl;
Data->Draw("misc.MT2>>DataWVSPT20", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&(NEles+NMuons)==1&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM==0&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=20&&misc.Vectorsumpt<30","goff");
cout << "DataWVSPT30" << endl;
Data->Draw("misc.MT2>>DataWVSPT30", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&(NEles+NMuons)==1&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM==0&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=30&&misc.Vectorsumpt<40","goff");
cout << "DataWVSPT40" << endl;
Data->Draw("misc.MT2>>DataWVSPT40", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&(NEles+NMuons)==1&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM==0&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=40&&misc.Vectorsumpt<50","goff");
cout << "DataWVSPT50" << endl;
Data->Draw("misc.MT2>>DataWVSPT50", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&(NEles+NMuons)==1&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM==0&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=50&&misc.Vectorsumpt<70","goff");
cout << "DataWVSPT70" << endl;
Data->Draw("misc.MT2>>DataWVSPT70", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&(NEles+NMuons)==1&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM==0&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=70&&misc.Vectorsumpt<100","goff");
cout << "DataWVSPT100" << endl;
Data->Draw("misc.MT2>>DataWVSPT100","NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&(NEles+NMuons)==1&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM==0&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=100","goff");

cout << "DataWVSPT0" << endl;
Data->Draw("misc.MT2>>DataTopVSPT0",  "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&(NEles+NMuons)==1&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM>=1&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=0&&misc.Vectorsumpt<20","goff");
cout << "DataTopVSPT20" << endl;
Data->Draw("misc.MT2>>DataTopVSPT20", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&(NEles+NMuons)==1&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM>=1&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=20&&misc.Vectorsumpt<30","goff");
cout << "DataTopVSPT30" << endl;
Data->Draw("misc.MT2>>DataTopVSPT30", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&(NEles+NMuons)==1&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM>=1&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=30&&misc.Vectorsumpt<40","goff");
cout << "DataTopVSPT40" << endl;
Data->Draw("misc.MT2>>DataTopVSPT40", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&(NEles+NMuons)==1&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM>=1&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=40&&misc.Vectorsumpt<50","goff");
cout << "DataTopVSPT50" << endl;
Data->Draw("misc.MT2>>DataTopVSPT50", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&(NEles+NMuons)==1&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM>=1&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=50&&misc.Vectorsumpt<70","goff");
cout << "DataTopVSPT70" << endl;
Data->Draw("misc.MT2>>DataTopVSPT70", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&(NEles+NMuons)==1&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM>=1&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=70&&misc.Vectorsumpt<100","goff");
cout << "DataTopVSPT100" << endl;
Data->Draw("misc.MT2>>DataTopVSPT100","NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&(NEles+NMuons)==1&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM>=1&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=100","goff");

TLegend *leg = new TLegend(.6,.6,.90,.90);
leg->SetName("leg");
leg -> SetFillColor(0);
leg -> SetBorderSize(0);
leg->AddEntry(LM6VSPT0,"0 #leq VSPT < 20 GeV", "l");
leg->AddEntry(LM6VSPT20,"20 #leq VSPT < 30 GeV", "l");
leg->AddEntry(LM6VSPT30,"30 #leq VSPT < 40 GeV", "l");
leg->AddEntry(LM6VSPT40,"40 #leq VSPT < 50 GeV", "l");
leg->AddEntry(LM6VSPT50,"50 #leq VSPT < 70 GeV", "l");
leg->AddEntry(LM6VSPT70,"70 #leq VSPT < 100 GeV", "l");
leg->AddEntry(LM6VSPT100,"100 GeV #leq VSPT", "l");

//store the file
TFile *file = new TFile("UTMfile.root","RECREATE");
file->cd();
LM6VSPT0  ->Write();
LM6VSPT20 ->Write();
LM6VSPT30 ->Write();
LM6VSPT40 ->Write();
LM6VSPT50 ->Write();
LM6VSPT70 ->Write();
LM6VSPT100->Write();
WJetsVSPT0  ->Write();
WJetsVSPT20 ->Write();
WJetsVSPT30 ->Write();
WJetsVSPT40 ->Write();
WJetsVSPT50 ->Write();
WJetsVSPT70 ->Write();
WJetsVSPT100->Write();
ZJetsVSPT0  ->Write();
ZJetsVSPT20 ->Write();
ZJetsVSPT30 ->Write();
ZJetsVSPT40 ->Write();
ZJetsVSPT50 ->Write();
ZJetsVSPT70 ->Write();
ZJetsVSPT100->Write();
TTbarVSPT0  ->Write();
TTbarVSPT20 ->Write();
TTbarVSPT30 ->Write();
TTbarVSPT40 ->Write();
TTbarVSPT50 ->Write();
TTbarVSPT70 ->Write();
TTbarVSPT100->Write();
DataQCDVSPT0  ->Write();
DataQCDVSPT20 ->Write();
DataQCDVSPT30 ->Write();
DataQCDVSPT40 ->Write();
DataQCDVSPT50 ->Write();
DataQCDVSPT70 ->Write();
DataQCDVSPT100->Write();
DataWVSPT0  ->Write();
DataWVSPT20 ->Write();
DataWVSPT30 ->Write();
DataWVSPT40 ->Write();
DataWVSPT50 ->Write();
DataWVSPT70 ->Write();
DataWVSPT100->Write();
DataZVSPT0  ->Write();
DataZVSPT20 ->Write();
DataZVSPT30 ->Write();
DataZVSPT40 ->Write();
DataZVSPT50 ->Write();
DataZVSPT70 ->Write();
DataZVSPT100->Write();
DataTopVSPT0  ->Write();
DataTopVSPT20 ->Write();
DataTopVSPT30 ->Write();
DataTopVSPT40 ->Write();
DataTopVSPT50 ->Write();
DataTopVSPT70 ->Write();
DataTopVSPT100->Write();
leg->Write();
file->Close();

cout << "File saved: " << file->GetName() << endl;

}