当前位置: 首页>>代码示例>>C++>>正文


C++ TPad::Draw方法代码示例

本文整理汇总了C++中TPad::Draw方法的典型用法代码示例。如果您正苦于以下问题:C++ TPad::Draw方法的具体用法?C++ TPad::Draw怎么用?C++ TPad::Draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TPad的用法示例。


在下文中一共展示了TPad::Draw方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AnalysisSparse

void AnalysisSparse(Bool_t save_output = kFALSE)
{
  gStyle->SetGridColor(kGray);
  //  TString tmpstr(fname);
  //  if (tmpstr.Contains("data")) {
  //    Printf("!!! Real Data !!!");
  //    mc = kFALSE;
  //  }
  TString gtitle = Form("Monte Carlo, %s", graph_name.Data());
  grapht = graph_name.Data();
  Double_t grx[999], gry[999], gry2[999], gry3[999], gry4[999],
    gry_eff[999], gry_fix[999], grxE[999];
  Double_t gry22[999], gry22E[999], grx22E[999];
  Double_t gry_true[999], gry_true_eff[999], gry_true_effE[999];
  TH1::AddDirectory(kFALSE);
  TFile::SetCacheFileDir(gSystem->HomeDirectory());
  TFile *f = TFile::Open(fname.Data(), "CACHEREAD");
  if (!f) return;
  TList *l; f->GetObject(lname.Data(), l);
  if (!l) return;
  Int_t bf[999], bl[999];
  Int_t nn = FindExactRange(((THnSparse *)(l->FindObject(s1name.Data())))->
                            Projection(1), del_step, bf, bl);
  //  Int_t nn = FindRange5(bf, bl);
  Bool_t binhaluska = kFALSE;
  if (binAnders) {
    nn = 8;
    bf[0] = 6;bf[1] =  9;bf[2] = 11;bf[3] = 16;bf[4] = 21;bf[5] = 26;
    bl[0] = 8;bl[1] = 10;bl[2] = 15;bl[3] = 20;bl[4] = 25;bl[5] = 30;

    bf[6] = 31;bf[7] = 41;
    bl[6] = 40;bl[7] = 50;
  }
  Printf("number of intervals = %d =>", nn);

  Int_t count = 0;
  Double_t ptmean = 0, value = 0;
  Int_t fitStatus = -1;
  gStyle->SetOptStat(0);
  TCanvas *c = new TCanvas("c", "Signal & Background");
  c->Divide(5, 5); c->Modified(); c->Draw();
  TCanvas *c2 = (TCanvas *)c->DrawClone("c2");
  c2->SetTitle("Phi mesons (raw)"); c2->Modified(); c2->Draw();
  TCanvas *c3, *c4;
  if (mc) {
    c3 = (TCanvas *)c->DrawClone("c3");
    c3->SetTitle("Phi mesons (gen)"); c3->Modified(); c3->Draw();
    c4 = (TCanvas *)c->DrawClone("c4");
    c4->SetTitle("Phi mesons (true)"); c4->Modified(); c4->Draw();
  }

  for (Int_t i = 0; i < nn; i++) {
    c->cd(count + 1)->SetGrid();
    h1 = (TH1D *)PullHisto(l, s1name.Data(), bf[i], bl[i], ptmean);
    h1->SetLineColor(kRed);
    h1->GetXaxis()->SetTitle("inv. mass, GeV/c^2");
    h1->Draw("hist");

    h3_p = (TH1D *)PullHisto(l, s3name_p.Data(), bf[i], bl[i], ptmean);
    h3_m = (TH1D *)PullHisto(l, s3name_m.Data(), bf[i], bl[i], ptmean);
    // !!!!!!!!!!!!!!!!!!!!!!!!
    if (count==0) h3_p = h1;
    // !!!!!!!!!!!!!!!!!!!!!!!!
    else {
      h3_p->Add(h3_m);
      //      h3_p->Add((TH1D *)PullHisto(l, smix.Data(), bf[i], bl[i], ptmean));
      //      h3_p->Add((TH1D *)PullHisto(l, smixpp.Data(), bf[i], bl[i], ptmean));
      //      h3_p->Add((TH1D *)PullHisto(l, smixmm.Data(), bf[i], bl[i], ptmean));
      Norm(h1, h3_p, norm[0], norm[1]);
    }
    h3_p->SetLineColor(kBlue);
    h3_p->Draw("hist, same");

    if (mc) {
      c3->cd(count + 1)->SetGrid();
      Printf("%s", s1namegen.Data());
      hg = (TH1D *)PullHisto(l, s1namegen.Data(), bf[i], bl[i], ptmean);
      hg->SetLineColor(kMagenta);
      hg->GetXaxis()->SetTitle("inv. mass, GeV/c^2");
      hg->Draw("hist");
      c4->cd(count + 1)->SetGrid();
      ht = (TH1D *)PullHisto(l, s1nametrue.Data(), bf[i], bl[i], ptmean);
      ht->SetLineColor(kMagenta-5);
      ht->GetXaxis()->SetTitle("inv. mass, GeV/c^2");
      ht->Draw("hist");
    }
    c2->cd(count + 1)->SetGrid();
    TH1 *hh = (TH1 *)h1->Clone("hh");
    hh->SetLineColor(kRed+1);
    hh->Add(h3_p, -1);
    /// !!!!!!!!!!!!!!!!!!!!!!
    //////////    if ((ilist == 3) && (count < 2)) hh->Reset();
    // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    hh->Draw("hist");

    // !!!!!!!!!!!!!!!!!!
    ff->SetParameters(0.1, 1.02, 0.004, -25000., 0., 0., 0.);
    ff->SetLineColor(hh->GetLineColor());
    ff->SetLineWidth(1);
    //    ff->SetLineStyle(kDashed);
//.........这里部分代码省略.........
开发者ID:musinsky,项目名称:bordel,代码行数:101,代码来源:Sparse_MC.C

示例2: if


//.........这里部分代码省略.........
  fdy = (fymax-fymin) / Double_t(fmy);
  z = fzref3;
  for (Int_t ix=0; ix<fmx; ix++) {
    x = fxmin + (Double_t(ix)+0.5) * fdx;
    for (Int_t iy=0; iy<fmy; iy++) {
      y = fymin + (Double_t(iy)+0.5) * fdy;
      bx = field->GetBx(x,y,z) / 10.;
      by = field->GetBy(x,y,z) / 10.;
      bz = field->GetBz(x,y,z) / 10.;
      b = TMath::Sqrt(bx*bx + by*by + bz*bz);
      hB3.SetBinContent(ix, iy, b);
    }
  }
  // ----------------------------------------------------------------------



  // --------   Calculate field integral along z axis   -------------------
  Double_t zint1 = -400.;
  Double_t zint2 =  400.;
  Int_t nz = Int_t(zint2-zint1);
  Double_t bint = 0;
  z = zint1 - 1.;
  for (Int_t iz=0; iz<=nz; iz++) {
    z += 1;
    by = field->GetBy(targX, targY, z) / 10.;
    bint += by * 0.01;
  }
  // ----------------------------------------------------------------------



  // -------  Draw graphs and histogram   ---------------------------------
  cout << endl << "=====>  Drawing..." << endl;
  gROOT->SetStyle("Plain");
  gStyle->SetOptStat(0000);
  gStyle->SetPalette(1,0);
  gStyle->SetTitleW(0.5);
  gStyle->SetTitleAlign(13);
  gStyle->SetTitleBorderSize(0.);
  gStyle->SetTitleOffset(2.,"y");
  gStyle->SetOptDate(2);
  gStyle->GetAttDate()->SetTextSize(0.02);

  TPostScript* ps = new TPostScript(psFile, -111);
  ps->Range(20,30);

  TCanvas* c1 = new TCanvas("c1", "canvas", 768, 1152);
  TPad* master = new TPad("master","", 0.10, 0.05, 0.95, 0.95);
  master->Draw();
  master->cd();

  TPad* padinf = new TPad("padinf", "", 0.12, 0.80, 0.88, 0.90);
  TPad* pad1   = new TPad("pad1",   "", 0.05, 0.60, 0.48, 0.78);
  TPad* pad2   = new TPad("pad2",   "", 0.52, 0.60, 0.95, 0.78);
  TPad* pad3   = new TPad("pad3",   "", 0.05, 0.41, 0.48, 0.59);
  TPad* pad4   = new TPad("pad4",   "", 0.52, 0.41, 0.95, 0.59);
  TPad* pad5   = new TPad("pad5",   "", 0.30, 0.22, 0.70, 0.40);
  TPad* pad6   = new TPad("pad6",   "", 0.10, 0.02, 0.47, 0.20);
  TPad* pad7   = new TPad("pad7",   "", 0.53, 0.02, 0.90, 0.20);

  padinf->Draw();
  pad1->Draw();
  pad2->Draw();
  pad3->Draw();
  pad4->Draw();
开发者ID:NicolasWinckler,项目名称:CbmRoot,代码行数:67,代码来源:checkFieldMap.C

示例3: drawDCA

// infilename - root file with relevant histograms
// system - PP,APAP,PP
// status - Pass,Fail
// rWrite - 0-no,1-png,2-eps
// rPerformance - 0-no,1-yes (ALICE logo etc.)
// bin: 0 - all, 1- 0:5, 2- 5:10, etc
void drawDCA(const char* infilename, const char* system, const char* status, Int_t rWrite, Int_t rPerformance, int isMC, Int_t bin, Int_t ptrange)
{

    myOptions(0);

    gROOT->ForceStyle();
    gStyle->SetPalette(1.0);

    TDatime now;
    int iDate = now.GetDate();
    int iYear=iDate/10000;
    int iMonth=(iDate%10000)/100;
    int iDay=iDate%100;
    char* cMonth[12]={"Jan","Feb","Mar","Apr","May","Jun",
                      "Jul","Aug","Sep","Oct","Nov","Dec"};
    char cStamp1[25],cStamp2[25];
    sprintf(cStamp1,"%i %s %i",iDay, cMonth[iMonth-1], iYear);
    sprintf(cStamp2,"%i/%.2d/%i",iDay, iMonth, iYear);

    TFile *f = new TFile(infilename, "read");

    // DCA xy
    TH2D* DCAxy =(TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%d","Pass", system,0));


    if (!bin) {
        int minMultBin = 0;
        int maxMultBin = 6; // 8
    }
    else {
        int minMultBin = bin-1;
        int maxMultBin = bin; // 8
    }

    // int minMultBin = 0;
    // int maxMultBin = 0; // 8

    double EvMultall = 0;

    for(int i = minMultBin; i<maxMultBin; i++) {

        TH2D* DCAxyN = (TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%d",status, system,i));
        DCAxy->Add(DCAxyN);

        cout<<i<<" "<<DCAxyN->GetEntries()<<endl;

        //delete hEvMult;
    }


    if (!isMC) {
        TCanvas *c2 = new TCanvas("DCA xy prim", "DCA xy prim");
        c2->SetGridx();
        c2->SetGridy();
        c2->SetFillColor(10);
        c2->SetRightMargin(1.9);
        c2->SetLogz();

        DCAxy->GetXaxis()->SetTitle("DCA_{XY} (cm)");
        DCAxy->GetXaxis()->SetRangeUser(-5.0,5.0);
        DCAxy->GetYaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})");
        // DCAxy->GetZaxis()->SetLabelSize(0.05);
        DCAxy->Draw("colz");
        postprocess(c2,Form("DCAxy%s",status),rWrite,rPerformance,system);

        // TCanvas *c4 = new TCanvas("DCA xy Projection X", "DCA xy Projection X");
        // c4->SetGridx();
        // c4->SetGridy();
        // c4->SetFillColor(10);
        // c4->SetRightMargin(1.9);
        // c4->SetLogy();

        gStyle->SetOptTitle(1);
        TCanvas *myCan = new TCanvas("myCan",cStamp1,600,400);
        myCan->Draw();
        myCan->cd();

        TPad *myPad = new TPad("myPad", "The pad",0,0,1,1);
        myPadSetUp(myPad,0.15,0.04,0.04,0.15);
        myPad->Draw();
        myPad->SetLogy();

        myPad->cd();

        if (ptrange == 0) {
            TH1D* pripp = (TH1D*)DCAxy->ProjectionX("zxc1",1,100);
            pripp->SetTitle("0.5 < #it{p}_{T} < 3 GeV/#it{c}");
        }
        else if (ptrange == 1) {
            TH1D* pripp = (TH1D*)DCAxy->ProjectionX("zxc1",15,33);
            pripp->SetTitle("0.5 < #it{p}_{T} < 1 GeV/#it{c}");
        }
        else if (ptrange == 2) {
            TH1D* pripp = (TH1D*)DCAxy->ProjectionX("zxc1",33,100);
//.........这里部分代码省略.........
开发者ID:maszyman,项目名称:PlotMacros,代码行数:101,代码来源:drawDCA.C

示例4: fit


//.........这里部分代码省略.........
  
  TF1* massSwap = new TF1(Form("fmassSwap_%.0f_%.0f",ptmin,ptmax),"[0]*(1-[2])*Gaus(x,[1],[3])/(sqrt(2*3.14159)*[3])");
  massSwap->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(7),f->GetParameter(8));
  massSwap->SetParError(0,f->GetParError(0));
  massSwap->SetParError(1,f->GetParError(1));
  massSwap->SetParError(2,f->GetParError(7));
  massSwap->SetParError(3,f->GetParError(8));
  massSwap->SetFillColor(kGreen+4);
  massSwap->SetFillStyle(3005);
  massSwap->SetLineColor(kGreen+4);
  massSwap->SetLineWidth(3);
  massSwap->SetLineStyle(1);
  
  h->SetXTitle("m_{#piK} (GeV/c^{2})");
  h->SetYTitle("Entries / (5 MeV/c^{2})");
  h->GetXaxis()->CenterTitle();
  h->GetYaxis()->CenterTitle();
  h->SetAxisRange(0,h->GetMaximum()*1.4*1.2,"Y");
  h->GetXaxis()->SetTitleOffset(1.3);
  h->GetYaxis()->SetTitleOffset(1.8);
  h->GetXaxis()->SetLabelOffset(0.007);
  h->GetYaxis()->SetLabelOffset(0.007);
  h->GetXaxis()->SetTitleSize(0.045);
  h->GetYaxis()->SetTitleSize(0.045);
  h->GetXaxis()->SetTitleFont(42);
  h->GetYaxis()->SetTitleFont(42);
  h->GetXaxis()->SetLabelFont(42);
  h->GetYaxis()->SetLabelFont(42);
  h->GetXaxis()->SetLabelSize(0.04);
  h->GetYaxis()->SetLabelSize(0.04);
  h->SetMarkerSize(0.8);
  h->SetMarkerStyle(20);
  h->SetStats(0);
  h->Draw("e");

  background->Draw("same");   
  mass->SetRange(minhisto,maxhisto);	
  mass->Draw("same");
  massSwap->SetRange(minhisto,maxhisto);
  massSwap->Draw("same");
  f->Draw("same");
  
  Double_t yield = mass->Integral(minhisto,maxhisto)/binwidthmass;
  Double_t yieldErr = mass->Integral(minhisto,maxhisto)/binwidthmass*mass->GetParError(0)/mass->GetParameter(0);
  
  std::cout<<"YIELD="<<yield<<std::endl;

  TLegend* leg = new TLegend(0.65,0.58,0.82,0.88,NULL,"brNDC");
  leg->SetBorderSize(0);
  leg->SetTextSize(0.04);
  leg->SetTextFont(42);
  leg->SetFillStyle(0);
  leg->AddEntry(h,"Data","pl");
  leg->AddEntry(f,"Fit","l");
  leg->AddEntry(mass,"D^{0}+#bar{D^{#lower[0.2]{0}}} Signal","f");
  leg->AddEntry(massSwap,"K-#pi swapped","f");
  leg->AddEntry(background,"Combinatorial","l");
  leg->Draw("same");

  TLatex* texCms = new TLatex(0.18,0.93, "#scale[1.25]{CMS} Preliminary");
  texCms->SetNDC();
  texCms->SetTextAlign(12);
  texCms->SetTextSize(0.04);
  texCms->SetTextFont(42);
  texCms->Draw();
开发者ID:boundino,项目名称:Dntuple,代码行数:66,代码来源:fitDexpo.C

示例5: eta1

void eta1(double pt1min, double pt2min, double METmin){


  TLegend* leg = new TLegend(0.13,0.6,0.87,0.87);
  leg->SetNColumns(3);
  leg->SetBorderSize(0);
  leg->SetFillStyle(0);
  gStyle->SetPadTickY(1);
  gStyle->SetPadTickX(1);

  TFile *data =  TFile::Open("./25ns_2246inv_v3/DoubleEG.root","READ");
  TFile *sig1 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP600.root","READ");
  TFile *sig2 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP800.root","READ");
  TFile *sig3 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1000.root","READ");
  TFile *sig4 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1200.root","READ");
  TFile *sig5 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1400.root","READ");
  TFile *sig6 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1700.root","READ");
  TFile *sig7 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP2500.root","READ");


  TFile *bkg1 =  TFile::Open("./25ns_2246inv_v3/DiPhoton.root","READ"); 
  TFile *bkg2 =  TFile::Open("./25ns_2246inv_v3/DYJetsToLL.root","READ");
  TFile *bkg3 =  TFile::Open("./25ns_2246inv_v3/GJets.root","READ");  
  TFile *bkg4 =  TFile::Open("./25ns_2246inv_v3/GluGluHToGG.root","READ");
  TFile *bkg5 =  TFile::Open("./25ns_2246inv_v3/QCD.root","READ");
  TFile *bkg6 =  TFile::Open("./25ns_2246inv_v3/VH.root","READ");
  TFile *bkg7 =  TFile::Open("./25ns_2246inv_v3/ttHJetToGG.root","READ");
  TFile *bkg8 =  TFile::Open("./25ns_2246inv_v3/VBFHToGG.root","READ");
  TFile *bkg9 =  TFile::Open("./25ns_2246inv_v3/TGJets.root","READ");
  TFile *bkg10 =  TFile::Open("./25ns_2246inv_v3/TTGJets.root","READ");
  TFile *bkg11 =  TFile::Open("./25ns_2246inv_v3/WGToLNuG.root","READ");
  TFile *bkg12 =  TFile::Open("./25ns_2246inv_v3/ZGTo2LG.root","READ");
 
  TTree *tree_data = (TTree*) data->Get("DiPhotonTree");

  TTree *tree_sig1 = (TTree*) sig1->Get("DiPhotonTree"); 
  TTree *tree_sig2 = (TTree*) sig2->Get("DiPhotonTree"); 
  TTree *tree_sig3 = (TTree*) sig3->Get("DiPhotonTree"); 
  TTree *tree_sig4 = (TTree*) sig4->Get("DiPhotonTree"); 
  TTree *tree_sig5 = (TTree*) sig5->Get("DiPhotonTree"); 
  TTree *tree_sig6 = (TTree*) sig6->Get("DiPhotonTree");
  TTree *tree_sig7 = (TTree*) sig7->Get("DiPhotonTree");  


  TTree *tree_bkg1 = (TTree*) bkg1->Get("DiPhotonTree");
  TTree *tree_bkg2 = (TTree*) bkg2->Get("DiPhotonTree");
  TTree *tree_bkg3 = (TTree*) bkg3->Get("DiPhotonTree");
  TTree *tree_bkg4 = (TTree*) bkg4->Get("DiPhotonTree");
  TTree *tree_bkg5 = (TTree*) bkg5->Get("DiPhotonTree");
  TTree *tree_bkg6 = (TTree*) bkg6->Get("DiPhotonTree");
  TTree *tree_bkg7 = (TTree*) bkg7->Get("DiPhotonTree");
  TTree *tree_bkg8 = (TTree*) bkg8->Get("DiPhotonTree");
  TTree *tree_bkg9 = (TTree*) bkg9->Get("DiPhotonTree");
  TTree *tree_bkg10 = (TTree*) bkg10->Get("DiPhotonTree");
  TTree *tree_bkg11 = (TTree*) bkg11->Get("DiPhotonTree");
  TTree *tree_bkg12 = (TTree*) bkg12->Get("DiPhotonTree");

  TCanvas *c1 = new TCanvas("c1","",500,600);
  TPad *mainPad = new TPad("mainPad","",0,0.3,1,1); 
  TPad *smallPad = new TPad("smallPad","",0,0.05,1,0.3);
  mainPad->SetBottomMargin(0.015);
 
  
  smallPad->SetTopMargin(0.05); 
smallPad->SetBottomMargin(0.25); 

  c1->cd();
  
  mainPad->Draw();
  mainPad->cd(); 
 
  
  
  
  
  
  
  // gPad->SetLogy();  
  
  TCut mggmax = "mgg<180";
  TCut mggmin = "mgg>100";
  TCut mggblind = "((mgg<115)||(mgg>135))";

  TCut pt1Cut = Form("pt1/mgg>%lf",pt1min);
  TCut pt2Cut = Form("pt2/mgg>%lf",pt2min);
  TCut METCut = Form("t1pfmet>%lf",METmin);
  TCut eveto1 = "eleveto1 == 1";
  TCut eveto2 = "eleveto2 == 1";
  TCut eveto = eveto1 && eveto2;
  TCut genmatch = "((genmatch1==1 && genmatch2==0)||(genmatch1==0 && genmatch2==1)||(genmatch1==0 && genmatch2==0))";  
  TCut metF = "((metF_GV==1) && (metF_HBHENoise==1) && (metF_HBHENoiseIso==1) && (metF_CSC==1) && (metF_eeBadSC==1))";  
  
  tree_data->Draw("(eta1)>>hdata(15,-3,3)",(mggmax && mggmin && metF&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *hdata =(TH1F*)gPad->GetPrimitive("hdata");
  
  
  tree_sig1->Draw("(eta1)>>h1(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *h1 =(TH1F*)gPad->GetPrimitive("h1");
  tree_sig2->Draw("(eta1)>>h2(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *h2 =(TH1F*)gPad->GetPrimitive("h2");
//.........这里部分代码省略.........
开发者ID:camendola,项目名称:macro,代码行数:101,代码来源:eta1.C

示例6: CompareAllHistos


//.........这里部分代码省略.........
			profileHist1[iProf12+iSuff*nProfile][iFile]=(TProfile*)f[iFile]->Get(TString(dirNames[0]+"/"+prefix_12+profileX[iProf12]+suffix_12[iSuff]));
		//	profileHist2[iProf12+iSuff*nProfile][iFile]=(TProfile*)f[iFile]->Get(TString(dirNames[0]+"/"+prefix_12+profileX[iProf12]+suffix_12[iSuff]));
		}
	}
  }
  
  //~ for(uint iFile = 0; iFile < nFiles; iFile++)
  //~ {
	//~ for(uint iWP=0; iWP<nWP; iWP++)
		//~ {
			//~ for(uint iProf123=0; iProf123< nProfile; iProf123++)
			//~ {
				//~ for(uint i123=0; i123 < n123; i123++)
				//~ {
					//~ std::cout << dirNames[0]+"/"+profile123_prefix+profileX[iProf123]+profile123_WP[iWP]+profile123_suffix[i123] << std::endl;
					//~ profileHist[i123][iWP*nProfile+iProf123][iFile]=(TProfile*)f[iFile]->Get(TString(dirNames[0]+"/"+profile123_prefix+profileX[iProf123]+profile123_WP[iWP]+profile123_suffix[i123]));
				//~ }
			//~ }
		//~ }
  //~ }
  
  
  
  
  TCanvas *c1 = new TCanvas("c1","",5,30,1024,1024);
  c1->SetGrid(0,0);
  c1->SetFillStyle(4000);
  c1->SetFillColor(10);
  c1->SetTicky();
  c1->SetObjectStat(0);
  
  TPad* histPad = new TPad("histPad","histPad",0.01,0.25,0.99,0.99);
  histPad->SetBottomMargin(0.02);
  histPad->Draw();
  
  TPad* diffPad = new TPad("diffPad","diffPad",0.01,0.01,0.99,0.25);
  diffPad->SetBottomMargin(0.3);
  diffPad->SetTopMargin(0.0);
  diffPad->Draw();
  
  // plotting
  
	TString XTitle[4] = {"True P_{T} [GeV]","True #eta", "nVx","True #phi"};
   // c1->SetLogy();
	std::cout << "hej hola " << std::endl;
	for(uint iProf12=0; iProf12< nTotal; iProf12++)
	{
		 int title_id=iProf12%4;
		
		 if(title_id!=2){
			 profileHist1[iProf12][0]->Rebin(5);
			 profileHist1[iProf12][1]->Rebin(5);
		 }
	
		 TH1D* baseHist = (TH1D*)profileHist1[iProf12][0]->Clone();
		 TH1D* overHist = (TH1D*)profileHist1[iProf12][1]->Clone();
		 
		 if(MakeTotal && iProf12>7){ 
			 double binLow = baseHist->GetXaxis()->GetBinLowEdge(baseHist->GetXaxis()->GetFirst());
			 double binUp = baseHist->GetXaxis()->GetBinUpEdge(baseHist->GetXaxis()->GetLast());
			 int nBins = baseHist->GetXaxis()->GetNbins();
			 
			 TH1D* newBaseHist = new TH1D(TString(baseHist->GetName())+"TOT",baseHist->GetTitle(),nBins,binLow,binUp);
			 TH1D* newDMHist = new TH1D("newDMHist","",nBins,binLow,binUp);
			 TH1D* newOverHist = new TH1D(TString(overHist->GetName())+"TOTover",baseHist->GetTitle(),nBins,binLow,binUp);
			 TH1D* newDMHist2 = new TH1D("newDMHist2","",nBins,binLow,binUp);
开发者ID:jpavel,项目名称:TauIDPlots,代码行数:67,代码来源:CompareAllHistos_jetPreselection_QCD.C

示例7: compareDataMC

void compareDataMC( vector<TChain*> chmc , vector<char*> labels , TChain* chdata , char* var , 
		    TCut sel , TCut weight , int nbins ,  float xmin , float xmax ,  
		    char* xtitle , bool overlayData , bool residual , bool drawLegend , bool log , char* flavor ){

  TPad* fullpad = new TPad();
  TPad* plotpad = new TPad();
  TPad* respad  = new TPad();

  if( residual ){
    fullpad = new TPad("fullpad","fullpad",0,0,1,1);
    fullpad->Draw();
    fullpad->cd();

    plotpad = new TPad("plotpad","plotpad",0,0,1,0.8);
    plotpad->Draw();
    plotpad->cd();
    if( log ) plotpad->SetLogy();
  }
  else{
    if( log ) gPad->SetLogy();
  }

  TString tvar(var);
  tvar.ReplaceAll("()","");
  tvar.ReplaceAll(".","");
  const char* myvar = tvar;

  cout << "Plotting var " << myvar << " flavor " << flavor << endl;

  //int colors[]={6,2,7,4,5,8,9,15,12};
  int colors[]={kBlue-6,kRed+2,7,5,5,8,9,15,12};

  assert( chmc.size() == labels.size() );
  const unsigned int nmc = chmc.size();

  THStack* mcstack = new THStack("mcstack","mcstack");
  TH1F*    mctothist = new TH1F();
  TH1F*    mchist[nmc];
  TH1F*    datahist = new TH1F(Form("%s_datahist_%s",myvar,flavor),Form("%s_datahist_%s",myvar,flavor),nbins,xmin,xmax);

  float trigeff = 1.0;
  //if     ( TString(flavor).Contains("ee")  ) trigeff = 1.00;
  //else if( TString(flavor).Contains("mm")  ) trigeff = 0.90;
  //else if( TString(flavor).Contains("em")  ) trigeff = 0.95;
  //else if( TString(flavor).Contains("all") ) trigeff = 0.95;
  if     ( TString(flavor).Contains("ee")  ) sel+="leptype==0";
  else if( TString(flavor).Contains("mm")  ) sel+="leptype==1";
  else if( TString(flavor).Contains("em")  ) sel+="leptype==2";
  //else if( TString(flavor).Contains("all") ) 

  TCut trigweight(Form("%.2f",trigeff));

  for( unsigned int imc = 0 ; imc < nmc ; imc++ ){
  //for( int imc = nmc-1 ; imc > -1 ; imc-- ){

    mchist[imc] = new TH1F(Form("%s_mc_%i_%s",myvar,imc,flavor),Form("%s_mc_%i_%s",myvar,imc,flavor),nbins,xmin,xmax);
    mchist[imc]->Sumw2();

    chmc.at(imc)->Draw(Form("TMath::Min(%s,%f)>>%s_mc_%i_%s",var,xmax-0.01,myvar,imc,flavor),sel*weight*trigweight);

    if( TString( labels.at(imc) ).Contains("LM") || TString( labels.at(imc) ).Contains("T2tt") ){
      mchist[imc]->SetFillColor( 0 );
      mchist[imc]->SetLineStyle(2);
    }else{
      mchist[imc]->SetFillColor( colors[imc] );
    }

    // if( strcmp(labels[imc],"ttfake")  == 0 || strcmp(labels[imc],"wjets")  == 0 ){
    //   cout << "Scaling " << labels[imc] << " by 3.8" << endl;
    //   mchist[imc]->Scale(3.8);
    // }

    mcstack->Add( mchist[imc] );

    if( imc == 0 ) mctothist = (TH1F*) mchist[imc]->Clone();
    else           mctothist->Add(mchist[imc]);

    cout << "MC yield " << labels[imc] << " " << Form("%.2f",mchist[imc]->Integral()) << endl;
  }

  chdata->Draw(Form("TMath::Min(%s,%f)>>%s_datahist_%s",var,xmax-0.01,myvar,flavor),sel);

  if( overlayData ){

    float max = datahist->GetMaximum() + datahist->GetBinError(datahist->GetMaximumBin());
    if( mctothist->GetMaximum() > max ) max = mctothist->GetMaximum();
    if( log ) datahist->SetMaximum( 15 * max );
    else      datahist->SetMaximum( 1.4 * max );

    datahist->GetXaxis()->SetTitle(xtitle);
    datahist->Draw("E1");
    mcstack->Draw("samehist");
    datahist->Draw("sameE1");
    datahist->Draw("sameaxis");
    
    if(!log) datahist->GetYaxis()->SetRangeUser(0.,1.4*max);
    
    cout << "data yield " << datahist->Integral() << endl;

  }
//.........这里部分代码省略.........
开发者ID:hooberman,项目名称:UserCode,代码行数:101,代码来源:Hootilities.C

示例8: PlotUnifier


//.........这里部分代码省略.........
  // Ratio plot 
  TH1F* ratio      = (TH1F*) histos[0]->Clone(); ratio->Reset(); 
  TH1F* stackHisto = (TH1F*) sm->GetStack()->Last();
  ratio->Divide(histos[0],stackHisto);
  ratio->SetMarkerSize(1.2);
  ratio->SetMarkerStyle(20);
  ratio->SetLineColor(kBlack);
  ratio->SetLineWidth(2);

  ratio->GetXaxis()->SetTitle("Observable");
  ratio->GetYaxis()->SetTitle("Data/SM");
  ratio->GetXaxis()->SetLabelSize(0.13);
  ratio->GetXaxis()->SetLabelOffset(0.02);
  ratio->GetXaxis()->SetTitleSize(0.14);
  ratio->GetXaxis()->SetTitleOffset(1.2);

  ratio->GetYaxis()->SetRangeUser(0,2);
  ratio->GetYaxis()->SetLabelSize(0.13);
  ratio->GetYaxis()->SetLabelOffset(0.0125);
  ratio->GetYaxis()->SetTitleSize(0.14);
  ratio->GetYaxis()->SetTitleOffset(0.5);
  ratio->GetYaxis()->SetNdivisions(5);

  ////////////////////////////////////////////////////////////////////////////////////////
  // Error bands
  smErrorBand->SetMarkerSize(0); 
  smErrorBand->SetFillStyle(3004);
  smErrorBand->SetFillColor(kBlack);
  ratioErrorBand->SetMarkerSize(0); 
  ratioErrorBand->SetFillStyle(3004);
  ratioErrorBand->SetFillColor(kBlack);
 
  ////////////////////////////////////////////////////////////////////////////////////////
  // Draw and save the canvas
  TCanvas* canvas = new TCanvas("canvas","canvas",500,500);
  TPad*    topPad = new TPad("pTop","pTop",0,0.2,1,1);
  TPad*    botPad = new TPad("pBot","pBot",0,0.0,1,0.3);
  topPad->Draw();
  botPad->Draw();

  ////////////////////////////////////////////////////////////////////////////////////////
  // Data is special since I use it to draw the axis labels etc.
  histos[0]->GetXaxis()->SetTitle("Observable"); 
  histos[0]->GetYaxis()->SetTitle("Events / Bin"); 
  histos[0]->GetXaxis()->SetLabelOffset(1.2); 
  histos[0]->GetXaxis()->SetLabelSize(0.03);
  histos[0]->GetYaxis()->SetRangeUser(1.e-2,1.e5);
  histos[0]->GetYaxis()->SetTitleSize(0.055);
  histos[0]->GetYaxis()->SetTitleOffset(1.28);
  histos[0]->GetYaxis()->SetLabelSize(0.05);
  histos[0]->GetYaxis()->SetLabelOffset(0.01);

  ////////////////////////////////////////////////////////////////////////////////////////
  // Top Pad
  topPad      ->cd();
  topPad      ->SetBottomMargin(0.15);
  histos[0]   ->Draw("p && e && x0");
  sm          ->Draw("same && hists");
  smErrorBand ->Draw("same && E2");
  histos[0]   ->Draw("same && p && e && x0");
  histos[7]   ->Draw("same && hist");
  histos[8]   ->Draw("same && hist");
  legendA     ->Draw();
  legendB     ->Draw();
  gPad        ->RedrawAxis();
  gPad        ->SetLogy(1);

  ////////////////////////////////////////////////////////////////////////////////////////
  // Decoration
  char annoyingLabel1[100] = "#bf{#it{ATLAS}}, #sqrt{s} = 8 TeV, 20.3 fb^{-1}";
  char annoyingLabel2[100] = "SF/DF channel"; 
  char annoyingLabel3[100] = "- Top CR for SR-#scale[0.9]{m_{T2}} and SR-WWb/c";
  myText(0.53,0.880,kBlack,annoyingLabel1);
  myText(0.17,0.965,kBlack,annoyingLabel2);
  myText(0.37,0.965,kBlack,annoyingLabel3);

  ////////////////////////////////////////////////////////////////////////////////////////
  // Bottom Pad
  botPad ->cd();
  botPad ->SetBottomMargin(0.4);
  
  ////////////////////////////////////////////////////////////////////////////////////////
  // 1 Line
  TLine* line = new TLine(histos[0]->GetXaxis()->GetXmin(),1,histos[0]->GetXaxis()->GetXmax(),1);
  line   ->SetLineColor(kRed);
  line   ->SetLineStyle(7);

  ////////////////////////////////////////////////////////////////////////////////////////
  // Draw
  ratio          ->Draw("p && e && x0");
  ratioErrorBand ->Draw("same && E2");
  line           ->Draw("same");
  ratio          ->Draw("same && p && e && x0");
  gPad           ->SetGridy(1);

  ////////////////////////////////////////////////////////////////////////////////////////
  // Save
  canvas ->SaveAs("Test_v3.eps");

} 
开发者ID:JosephineWittkowski,项目名称:analysis_SUSYTools_03_04_SusyNt_01_16_n0150,代码行数:101,代码来源:PlotExample_v3.C

示例9: makePlot


//.........这里部分代码省略.........
//  }

  TFile * signalInputFile3= new TFile (signal3+anaType+".root", "READ");
  TH1F * histoSignal3 = (TH1F*)signalInputFile3->Get(histoName);
  histoSignal3->SetStats(0);
  histoSignal3->Scale(lumi);

  //
  // BACKGROUND MC
  //

  THStack stack("Background MC","");
  setPlotTitle(stack, lumi);

  // Add all different background MC to this stack
  TLegend *legend= new TLegend(0.5,0.6,0.85,0.85);

  totalBkgMCIntegral = addBackgroundHistos(anaType, histoName, stack, legend, lumi, minIntegral, maxIntegral);


//  if ( histoName=="nMinus1_isolationLeptonH_removedLifetimeCuts" || histoName=="nMinus1_relIsolationLeptonH_removedLifetimeCuts" ) {
//    std::cout << "Integral of background between " << minIntegral << " and " << maxIntegral << " : " << totalBkgMCIntegral << std::endl;
//  }

  // Output histograms to file
  outputFile->cd();

  // Setup canvas
  TCanvas canvas(histoName);
  canvas.cd();
  // Draw one or two pads
  TPad * up = new TPad("u","u",0.01,0.25,0.99,0.99);
  up->SetNumber(1);
  up->Draw();
  TPad * dp = new TPad("d","d",0.01,0.01,0.99,0.25);

  if ( drawRatioPlot ) {
    dp->SetNumber(2);
    dp->UseCurrentStyle();
    dp->Draw();
  }
  else {
    up->SetPad(0.01,0.01,0.99,0.99);
    up->Draw();
  }

  if ( logY ) up->SetLogy();
  canvas.Draw();
  canvas.cd(1);
  up->cd();
  canvas.SetFillColor(kWhite);
  canvas.SetBorderMode(0);


  // Draw background MC
  // There may be zero entries, which will mess up drawing options
  // Not a good fix at the moment
  bool axesExist=false;
  if (totalBkgMCIntegral>0) {
    axesExist=true;

    stack.Draw("HISTE");

    stack.GetXaxis()->SetRangeUser(xMin, xMax);
    stack.SetMaximum(yMax);
    stack.SetMinimum(yMin);
开发者ID:TENorbert,项目名称:usercode-2,代码行数:67,代码来源:makeAllPlots.C

示例10: DrawQCDClosure

void DrawQCDClosure(TString VAR,int NBINS,float XMIN,float XMAX,TString XTITLE)
{
  gROOT->ForceStyle();
  
  const int N = 11;
  float XSEC[N] = {471100.,117276.,7823.,648.2,186.9,32.293,9.4183,0.84265,0.114943,0.00682981,0.000165445};

  TString SAMPLE[N] = {
    "QCD_Pt_120to170",
    "QCD_Pt_170to300",
    "QCD_Pt_300to470",
    "QCD_Pt_470to600",
    "QCD_Pt_600to800",
    "QCD_Pt_800to1000",
    "QCD_Pt_1000to1400",
    "QCD_Pt_1400to1800",
    "QCD_Pt_1800to2400",
    "QCD_Pt_2400to3200",
    "QCD_Pt_3200toInf" 
  }; 

  TFile *inf[N];
  TTree *tr0[N],*tr1[N],*tr2[N];
  TH1F  *h0[N],*h1[N],*h2[N];

  TCanvas *can = new TCanvas("can_QCDClosure_"+VAR,"can_QCDClosure_"+VAR,900,600);
  can->cd(1);
  can->SetBottomMargin(0.3);
  can->SetRightMargin(0.15);

  for(int i=0;i<N;i++) {
    inf[i] = TFile::Open("flatTree_"+SAMPLE[i]+".root");
    tr0[i] = (TTree*)inf[i]->Get("hadtopNoBtag/events");
    tr1[i] = (TTree*)inf[i]->Get("hadtopOneBtag/events");
    tr2[i] = (TTree*)inf[i]->Get("hadtop/events");
    TH1F *hpu = (TH1F*)inf[i]->Get("hadtop/pileup");
    h0[i]  = new TH1F("h0_"+SAMPLE[i],"h0_"+SAMPLE[i],NBINS,XMIN,XMAX);
    h1[i]  = new TH1F("h1_"+SAMPLE[i],"h1_"+SAMPLE[i],NBINS,XMIN,XMAX);
    h2[i]  = new TH1F("h2_"+SAMPLE[i],"h2_"+SAMPLE[i],NBINS,XMIN,XMAX);
    h0[i]->Sumw2();
    h1[i]->Sumw2();
    h2[i]->Sumw2();
    tr0[i]->Draw(VAR+">>"+"h0_"+SAMPLE[i],"triggerBit[0] && prob>0.05 && nBJets==0 && dRbbTop>2");
    tr1[i]->Draw(VAR+">>"+"h1_"+SAMPLE[i],"triggerBit[0] && prob>0.05 && nBJets==1 && dRbbTop>2");
    tr2[i]->Draw(VAR+">>"+"h2_"+SAMPLE[i],"triggerBit[0] && prob>0.05 && nBJets>1 && dRbbTop>2");
    h0[i]->Scale(XSEC[i]/hpu->GetEntries());
    h1[i]->Scale(XSEC[i]/hpu->GetEntries());
    h2[i]->Scale(XSEC[i]/hpu->GetEntries()); 
    cout<<SAMPLE[i]<<" "<<hpu->GetEntries()<<" "<<h0[i]->GetEntries()<<" "<<h1[i]->GetEntries()<<" "<<h2[i]->GetEntries()<<endl;
  }

  TH1F *hQCD0 = (TH1F*)h0[0]->Clone("hQCD0");
  TH1F *hQCD1 = (TH1F*)h1[0]->Clone("hQCD1");
  TH1F *hQCD2 = (TH1F*)h2[0]->Clone("hQCD2");

  for(int i=1;i<N;i++) {
    hQCD0->Add(h0[1]);
    hQCD1->Add(h1[1]);
    hQCD2->Add(h2[1]);
  }  
   
  hQCD0->SetFillColor(kGray);
  hQCD1->SetLineColor(kBlack);
  hQCD1->SetMarkerColor(kBlack);
  hQCD1->SetMarkerStyle(21);
  hQCD2->SetLineColor(kRed);
  hQCD2->SetMarkerColor(kRed);
  hQCD2->SetMarkerStyle(20);

  hQCD0->Scale(1./hQCD0->Integral());
  hQCD1->Scale(1./hQCD1->Integral());
  hQCD2->Scale(1./hQCD2->Integral());

  hQCD0->GetXaxis()->SetLabelSize(0.0);
  double max = 1.1*TMath::Max(hQCD0->GetBinContent(hQCD0->GetMaximumBin()),hQCD2->GetBinContent(hQCD2->GetMaximumBin()));
  hQCD0->SetMinimum(1e-5);
  hQCD0->SetMaximum(max);
  hQCD0->Draw("hist");
  hQCD1->Draw("sameE");
  hQCD2->Draw("sameE");
  gPad->RedrawAxis();

  TLegend *leg = new TLegend(0.86,0.65,0.99,0.9);
  leg->SetFillColor(0);
  leg->SetTextFont(42);
  leg->SetTextSize(0.03);
  leg->AddEntry(hQCD0,"Zero btag","F");
  leg->AddEntry(hQCD1,"One btag","LP");
  leg->AddEntry(hQCD2,"Two btag","LP");
  leg->Draw();

  TH1F *hRatio0 = (TH1F*)hQCD2->Clone("Ratio0");
  hRatio0->Divide(hQCD0);
  TH1F *hRatio1 = (TH1F*)hQCD2->Clone("Ratio1");
  hRatio1->Divide(hQCD1);

  hRatio0->SetLineColor(kBlack);
  hRatio0->SetMarkerColor(kBlack);

  TPad* pad = new TPad("pad", "pad", 0., 0., 1., 1.);
//.........这里部分代码省略.........
开发者ID:gflouris,项目名称:UserCode,代码行数:101,代码来源:DrawQCDClosure.C

示例11: ptBestFit


//.........这里部分代码省略.........
      pdfi->plotOn(frame1,Components("shapeBkg_qcd_"+ds_name),LineWidth(2),LineStyle(5),LineColor(kGreen+2));
      pdfi->plotOn(frame1,Components("shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name),LineWidth(2),LineStyle(2),LineColor(kBlack)); 
      cout<<"chi2/ndof (bkg) = "<<frame1->chiSquare()<<endl;
		chi2sumB += frame1->chiSquare()*ds_coarse.numEntries();
		pdfi->plotOn(frame1,Components("shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name),LineWidth(2),LineStyle(2),LineColor(kBlack),VisualizeError(*res_s,1,kTRUE),FillColor(0),MoveToBack()); 
      hresid = frame1->residHist();
      frame2->addPlotable(hresid,"pE1");
    
      float yield_sig = rFit->getValV()*(yield_vbf->getValV()+yield_gf->getValV());
      RooAbsPdf *signal_pdf = (RooAbsPdf*)w->pdf("shapeSig_qqH_"+ds_name);
      signal_pdf->plotOn(frame2,LineWidth(2),LineColor(kRed),Normalization(yield_sig,RooAbsReal::NumEvent),MoveToBack());
    }
//	 hresid0->Print();
//	 hresid->Print();
//	 double x2,y2;
//	 for (int i=0; i<3; ++i) {
//		 hresid0->GetPoint(i,x2,y2);
//		 cout << "BKG+SIG\t" << x2 << "\t" << y2 << endl;
//		 hresid->GetPoint(i,x2,y2);
//		 cout << "BKG\t" << x2 << "\t" << y2 << endl;
//		 ds_coarse.get(i);
//		 cout << ds_coarse.weightError(RooAbsData::SumW2) << endl;
//		 cout << endl;
//	 }

    TCanvas* canFit = new TCanvas("Higgs_fit_"+ds_name,"Higgs_fit_"+ds_name,900,750);
    canFit->cd(1)->SetBottomMargin(0.4);
    frame1->SetMinimum(MIN_VAL);
    frame1->SetMaximum(MAX_VAL);
    frame1->GetYaxis()->SetNdivisions(510);
    frame1->GetXaxis()->SetTitleSize(0);
    frame1->GetXaxis()->SetLabelSize(0);
    frame1->GetYaxis()->SetTitle(TString::Format("Events / %1.1f GeV",BIN_SIZE));
    frame1->Draw();
    gPad->Update();
    
    TList *list = (TList*)gPad->GetListOfPrimitives();
    //list->Print();
    TH1F *hUncH  = new TH1F("hUncH"+ds_name,"hUncH"+ds_name,(XMAX-XMIN)/BIN_SIZE,XMIN,XMAX);
    TH1F *hUncL  = new TH1F("hUncL"+ds_name,"hUncL"+ds_name,(XMAX-XMIN)/BIN_SIZE,XMIN,XMAX);
    TH1F *hUnc2H = new TH1F("hUnc2H"+ds_name,"hUnc2H"+ds_name,(XMAX-XMIN)/BIN_SIZE,XMIN,XMAX);
    TH1F *hUnc2L = new TH1F("hUnc2L"+ds_name,"hUnc2L"+ds_name,(XMAX-XMIN)/BIN_SIZE,XMIN,XMAX); 
    TH1F *hUncC  = new TH1F("hUncC"+ds_name,"hUncC"+ds_name,(XMAX-XMIN)/BIN_SIZE,XMIN,XMAX); 
    
    RooCurve *errorBand,*gFit,*gQCDFit,*gBkgFit;
    
	//list->Print();
    if (BLIND) {
      errorBand = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]_errorband_Comp[shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name+"]");
      gFit = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]"+"_Comp[shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name+"]");
    }
    else {
      //errorBand = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]_errorband");
      errorBand = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]_errorband_Comp[shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name+"]");
      gFit = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]");
    } 
    gQCDFit = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]"+"_Comp[shapeBkg_qcd_"+ds_name+"]");  
    gBkgFit = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]"+"_Comp[shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name+"]");
    for(int i=0;i<hUncH->GetNbinsX();i++) {
      double x0 = hUncH->GetBinCenter(i+1);
      double e1 = fabs(errorBand->Eval(x0)-gBkgFit->Eval(x0));
      //double e1 = fabs(errorBand->Eval(x0)-gFit->Eval(x0));
      double e2 = eNqcd/hUncH->GetNbinsX();
      hUncH->SetBinContent(i+1,sqrt(pow(e2,2)+pow(e1,2)));
      hUnc2H->SetBinContent(i+1,2*sqrt(pow(e2,2)+pow(e1,2)));
      hUncL->SetBinContent(i+1,-sqrt(pow(e2,2)+pow(e1,2)));
开发者ID:chernyavskaya,项目名称:vbfHbbShare,代码行数:67,代码来源:ptBestFit.C

示例12: plotComparison

void plotComparison( TH1F* h_dt , TH1F* h_mc , TH1F *h_extra, char* label, bool dolog, bool drawbkg) {

  TPad* fullpad = new TPad();
  TPad* plotpad = new TPad();
  TPad* respad  = new TPad();
  fullpad = new TPad("fullpad","fullpad",0,0,1,1);
  fullpad->Draw();
  fullpad->cd();
  plotpad = new TPad("plotpad","plotpad",0,0,1,0.8);
  plotpad->Draw();
  plotpad->cd();
  if (dolog) plotpad->SetLogy();

  h_dt->GetYaxis()->SetTitle("Entries");
  h_dt->GetXaxis()->SetTitle(Form("%s", label));
  h_dt->GetYaxis()->SetTitleSize(0.05);
  h_dt->GetXaxis()->SetTitleSize(0.05);
  h_dt->GetYaxis()->SetTitleOffset(1.5);
  h_dt->GetXaxis()->SetTitleOffset(1.3);
  if (!dolog) h_dt->GetYaxis()->SetRangeUser(0., 1.4*h_dt->GetMaximum());
  h_dt->SetLineColor(kBlack);
  h_dt->SetMarkerColor(kBlack);
  h_mc->SetLineColor(kBlue);
  h_mc->SetMarkerColor(kBlue);
  h_extra->SetLineColor(kRed);
  h_extra->SetLineWidth(2);
  h_mc->SetLineWidth(2);
  h_dt->Draw();
  h_mc->Draw("HISTSAME");
  if (drawbkg) h_extra->Draw("HISTSAME");
  h_dt->Draw("ESAME");

  TLegend *legComp = new TLegend( 0.653, 0.663, 0.944, 0.870);
  legComp->AddEntry(h_dt, "Data", "lp");
  legComp->AddEntry(h_mc, "MC", "l");
  if (drawbkg) legComp->AddEntry(h_extra, "MC Bkg", "l");
  legComp->SetFillColor(0);
  legComp->SetBorderSize(0);
  legComp->Draw();
  
  TLatex *text = new TLatex();
  text->SetNDC();
  text->SetTextSize(0.04);
  //  float xtex = 0.65;
  //  text->DrawLatex(xtex,0.88,"1 lepton + jets Sample");
  
  fullpad->cd();
  
  respad = new TPad("respad","respad",0,0.8,1,1);
  respad->Draw();
  respad->cd();
  
  //gPad->SetGridy();
  
  TH1F* ratio = (TH1F*) h_dt->Clone("ratio");
  ratio->Divide(h_mc);

  ratio->GetYaxis()->SetTitleOffset(0.3);
  ratio->GetYaxis()->SetTitleSize(0.2);
  ratio->GetYaxis()->SetNdivisions(5);
  ratio->GetYaxis()->SetLabelSize(0.2);
  if (dolog) ratio->GetYaxis()->SetRangeUser(0.5,1.5);
  else ratio->GetYaxis()->SetRangeUser(0.7,1.3);
  ratio->GetYaxis()->SetTitle("Ratio    ");
  ratio->GetXaxis()->SetLabelSize(0);
  ratio->GetXaxis()->SetTitleSize(0);
  ratio->SetMarkerSize(1);
  ratio->SetLineWidth(2);
  ratio->SetLineColor(kBlue);
  ratio->SetMarkerColor(kBlue);
  ratio->SetFillColor(kBlue);
  ratio->SetFillStyle(3002);
  ratio->Draw("E2");
  
  TLine line;
  line.SetLineWidth(2);
  line.DrawLine(h_dt->GetXaxis()->GetXmin(),1,h_dt->GetXaxis()->GetXmax(),1);

}
开发者ID:cmstas,项目名称:SingleLepton2012,代码行数:79,代码来源:doPrintYields2l.C

示例13: Dist

void Dist()
{
  TH1::AddDirectory(kFALSE);
  gStyle->SetOptStat(0);
  gStyle->SetOptTitle(0);
  gStyle->SetFrameLineWidth(1);
  
  TCanvas *c1 = new TCanvas("c1","multipads",700,500);
  gPad->SetLeftMargin(0.15);
  
  TLegend* leg = new TLegend(0.35, 0.12, 0.7, 0.22);
  leg-> SetNColumns(2);
  leg->SetHeader("After Sub.:");

  TFile f("../../data/Sample/Distance/P12e_1.5MeV/H5m/Near.root");
  TH1F* Near = (TH1F*)f.Get("h1dDistAccSum");
  Near->GetYaxis()->SetRangeUser(-3000,12000);
  Near->SetLineColor(4);
  Near->GetYaxis()->SetTitleOffset(1.5);
  //Near->Rebin(5);
  Near->DrawCopy();
  leg->AddEntry( Near, "Near site", "lep" );

  TFile f("../../data/Sample/Distance/P12e_1.5MeV/H5m/EH3.root");
  TH1F* Far = (TH1F*)f.Get("h1dDistAccSum");
  Far->SetLineColor(2);
  Far->GetYaxis()->SetTitleOffset(1.5);
  //Far->Rebin(5);
  Far->DrawCopy("same");
  leg->AddEntry( Far, "Far site", "lep" );

  leg->SetFillColor(0);
  leg->Draw();
  TLine line;
  line.SetLineStyle(2);
  line.DrawLine(0,0,5000,0);

  //h1dDistAccSum->Fit("pol0","","",2000,5000);
  {
    TFile f("../../data/Sample/Distance/P12e_1.5MeV/H5m/Near.root");

    TLegend* leg = new TLegend(0.51, 0.22, 0.80, 0.53);

    TPad* pad = new TPad("name","Title",0.3,0.3,0.935,0.935);
    pad->SetTopMargin(0.05);
    pad->SetBottomMargin(0.2);
    pad->SetLeftMargin(0.2);
    pad->SetRightMargin(0.05);
    pad->Draw();
    pad->cd();
    
    h1dDistVtxSum->SetLineColor(4);
    h1dDistVtxSum->GetYaxis()->SetTitleOffset(1.6);
    h1dDistVtxSum->GetYaxis()->SetLabelSize(0.06);
    h1dDistVtxSum->GetYaxis()->SetTitleSize(0.06);
    h1dDistVtxSum->GetYaxis()->SetNdivisions(405);
    
    h1dDistVtxSum->GetXaxis()->SetNdivisions(405);
    h1dDistVtxSum->GetXaxis()->SetLabelSize(0.06);
    h1dDistVtxSum->GetXaxis()->SetTitleSize(0.06);

    h1dDistVtxSum->DrawCopy();
    h1dDistBkgSum->SetLineColor(1);
    h1dDistBkgSum->DrawCopy("same");
    
    TLine line;
    line.SetLineStyle(2);
    line.DrawLine(2000,0,2000,22250);

    leg->SetHeader("Near site:");
    leg->AddEntry( h1dDistVtxSum, "Before Sub.", "lep" );
    leg->AddEntry( h1dDistBkgSum, "Accidental", "lep" );
    leg->SetFillColor(0);
    leg->Draw();
      
    /*
      label->AddText("Subtraction");
      label->AddText("Validation");
      label->SetFillColor(0);
      label->SetShadowColor(0);
      label->SetBorderSize(1);
      label->Draw();
    */
  }
}
开发者ID:zhangzc11,项目名称:CPTV,代码行数:85,代码来源:Dist.C

示例14: quarks

void quarks () {
   TCanvas *c1 = new TCanvas("c1", "c1",10,10,630,760);
   c1->SetFillColor(kBlack);
   Int_t quarkColor  = 50;
   Int_t leptonColor = 16;
   Int_t forceColor  = 38;
   Int_t titleColor  = kYellow;
   Int_t border = 8;

   TLatex *texf = new TLatex(0.90,0.455,"Force Carriers");
   texf->SetTextColor(forceColor);
   texf->SetTextAlign(22); texf->SetTextSize(0.07);
   texf->SetTextAngle(90);
   texf->Draw();

   TLatex *texl = new TLatex(0.11,0.288,"Leptons");
   texl->SetTextColor(leptonColor);
   texl->SetTextAlign(22); texl->SetTextSize(0.07);
   texl->SetTextAngle(90);
   texl->Draw();

   TLatex *texq = new TLatex(0.11,0.624,"Quarks");
   texq->SetTextColor(quarkColor);
   texq->SetTextAlign(22); texq->SetTextSize(0.07);
   texq->SetTextAngle(90);
   texq->Draw();

   TLatex tex(0.5,0.5,"u");
   tex.SetTextColor(titleColor); tex.SetTextFont(32);
   tex.SetTextAlign(22);
   tex.SetTextSize(0.14);
   tex.DrawLatex(0.5,0.93,"Elementary");
   tex.SetTextSize(0.12);
   tex.DrawLatex(0.5,0.84,"Particles");
   tex.SetTextSize(0.05);
   tex.DrawLatex(0.5,0.067,"Three Generations of Matter");

   tex.SetTextColor(kBlack); tex.SetTextSize(0.8);

// ------------>Create main pad and its subdivisions
   TPad *pad = new TPad("pad", "pad",0.15,0.11,0.85,0.79);
   pad->Draw();
   pad->cd();
   pad->Divide(4,4,0.0003,0.0003);

   pad->cd(1); gPad->SetFillColor(quarkColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.5,"u");

   pad->cd(2); gPad->SetFillColor(quarkColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.5,"c");

   pad->cd(3); gPad->SetFillColor(quarkColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.5,"t");

   pad->cd(4); gPad->SetFillColor(forceColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.55,"#gamma");

   pad->cd(5); gPad->SetFillColor(quarkColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.5,"d");

   pad->cd(6); gPad->SetFillColor(quarkColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.5,"s");

   pad->cd(7); gPad->SetFillColor(quarkColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.5,"b");

   pad->cd(8); gPad->SetFillColor(forceColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.55,"g");

   pad->cd(9); gPad->SetFillColor(leptonColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.5,"#nu_{e}");

   pad->cd(10); gPad->SetFillColor(leptonColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.5,"#nu_{#mu}");

   pad->cd(11); gPad->SetFillColor(leptonColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.5,"#nu_{#tau}");

   pad->cd(12); gPad->SetFillColor(forceColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.5,"Z");

   pad->cd(13); gPad->SetFillColor(leptonColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.5,"e");

   pad->cd(14); gPad->SetFillColor(leptonColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.56,"#mu");
//.........这里部分代码省略.........
开发者ID:bbannier,项目名称:root-1,代码行数:101,代码来源:quarks.C

示例15: makePlot


//.........这里部分代码省略.........
  }
  histogram_Rares_density->SetFillColor(851);
  histogram_Rares_density->SetLineColor(1);
  histogram_Rares_density->SetLineWidth(1);

  TH1* histogram_fakes_density = 0;
  if ( histogram_fakes ) {
    if ( histogram_data ) checkCompatibleBinning(histogram_fakes, histogram_data);
    histogram_fakes_density = divideHistogramByBinWidth(histogram_fakes);
  }
  histogram_fakes_density->SetFillColor(1);
  histogram_fakes_density->SetFillStyle(3005);
  histogram_fakes_density->SetLineColor(1);
  histogram_fakes_density->SetLineWidth(1);
  
  TH1* histogramSum_mc_density = 0;
  if ( histogramSum_mc ) {
    if ( histogram_data ) checkCompatibleBinning(histogramSum_mc, histogram_data);
    histogramSum_mc_density = divideHistogramByBinWidth(histogramSum_mc);
  }
  std::cout << "histogramSum_mc_density = " << histogramSum_mc_density << std::endl;
  dumpHistogram(histogramSum_mc_density);

  TH1* histogramErr_mc_density = 0;
  if ( histogramErr_mc ) {
    if ( histogram_data ) checkCompatibleBinning(histogramErr_mc, histogram_data);
    histogramErr_mc_density = divideHistogramByBinWidth(histogramErr_mc);
  }
  setStyle_uncertainty(histogramErr_mc_density);

  TCanvas* canvas = new TCanvas("canvas", "canvas", 950, 1100);
  canvas->SetFillColor(10);
  canvas->SetBorderSize(2);
  canvas->Draw();

  TPad* topPad = new TPad("topPad", "topPad", 0.00, 0.34, 1.00, 0.995);
  topPad->SetFillColor(10);
  topPad->SetTopMargin(0.065);
  topPad->SetLeftMargin(0.20);
  topPad->SetBottomMargin(0.00);
  topPad->SetRightMargin(0.04);
  topPad->SetLogy(useLogScale);
  
  TPad* bottomPad = new TPad("bottomPad", "bottomPad", 0.00, 0.01, 1.00, 0.335);
  bottomPad->SetFillColor(10);
  bottomPad->SetTopMargin(0.085);
  bottomPad->SetLeftMargin(0.20);
  bottomPad->SetBottomMargin(0.35);
  bottomPad->SetRightMargin(0.04);
  bottomPad->SetLogy(false);

  canvas->cd();
  topPad->Draw();
  topPad->cd();

  THStack* histogramStack_mc = new THStack();
  histogramStack_mc->Add(histogram_fakes_density);
  histogramStack_mc->Add(histogram_Rares_density);
  histogramStack_mc->Add(histogram_EWK_density);
  histogramStack_mc->Add(histogram_ttW_density);
  histogramStack_mc->Add(histogram_ttZ_density);
  histogramStack_mc->Add(histogram_ttH_density);

  TH1* histogram_ref = histogram_data_density;
  histogram_ref->SetTitle("");
  histogram_ref->SetStats(false);
开发者ID:capalmer85,项目名称:CombineHarvester,代码行数:67,代码来源:makePostFitPlots_3l_1tau.C


注:本文中的TPad::Draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。