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


C++ TH1F::GetYaxis方法代码示例

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


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

示例1: SignfificanceT2tt

void SignfificanceT2tt(bool pval, int exp=0){


    TFile *f = TFile::Open("Significances2DHistograms_T2tt.root");
    TH2F *h;
    if(pval){
        if(exp==0) h = (TH2F*)f->Get("hpObs");
        else if(exp==1) h = (TH2F*)f->Get("hpExpPosteriori");
        else if(exp==2) h = (TH2F*)f->Get("hpExpPriori");
    }
    else {
        if(exp==0) h = (TH2F*)f->Get("hObs");
        else if(exp==1) h = (TH2F*)f->Get("hExpPosteriori");
        else if(exp==2) h = (TH2F*)f->Get("hExpPriori");
    }
    h->GetXaxis()->SetTitle("m_{#tilde{t}} [GeV]");
    h->GetXaxis()->SetLabelFont(42);
    h->GetXaxis()->SetLabelSize(0.035);
    h->GetXaxis()->SetTitleSize(0.05);
    h->GetXaxis()->SetTitleOffset(1.2);
    h->GetXaxis()->SetTitleFont(42);
    h->GetYaxis()->SetTitle("m_{#tilde{#chi}_{1}^{0}} [GeV]");
    h->GetYaxis()->SetLabelFont(42);
    h->GetYaxis()->SetLabelSize(0.035);
    h->GetYaxis()->SetTitleSize(0.05);
    h->GetYaxis()->SetTitleOffset(1.35);
    h->GetYaxis()->SetTitleFont(42);
    double maximum = h->GetMaximum();
    double minimum = h->GetMinimum();
    double sigmin = 99; int sigminx=-1; int sigminy=-1; if(pval) sigmin = -99;
    h->GetZaxis()->SetRangeUser(minimum,maximum);
    for(int x = 1; x<=h->GetNbinsX();++x){
        for(int y = 1; y<=h->GetNbinsX();++y){
            if(!pval&&h->GetBinContent(x,y)<sigmin){ sigmin =h->GetBinContent(x,y); sigminx = x; sigminy = y; }
            if( pval&&h->GetBinContent(x,y)>sigmin){ sigmin =h->GetBinContent(x,y); sigminx = x; sigminy = y; }
            if(!pval&&h->GetXaxis()->GetBinLowEdge(x)<h->GetYaxis()->GetBinLowEdge(y)+75) h->SetBinContent(x,y,-999);
            if(h->GetXaxis()->GetBinLowEdge(x)<374) continue;
            if(h->GetXaxis()->GetBinLowEdge(x)>424) continue;
            if(h->GetYaxis()->GetBinLowEdge(y)<199) continue;
            if(h->GetYaxis()->GetBinLowEdge(y)>249) continue;
            if(!pval&&h->GetBinContent(x,y)>0.3) h->SetBinContent(x,y,0.05);
        }
    }
    h->GetZaxis()->SetRangeUser(minimum,maximum);
    if(!pval) cout << "minimal significance " << sigmin << " at " << h->GetXaxis()->GetBinLowEdge(sigminx) << "-" << h->GetYaxis()->GetBinLowEdge(sigminy) << endl;
    else cout << "maximal p- value " << sigmin << " at " << h->GetXaxis()->GetBinLowEdge(sigminx) << "-" << h->GetYaxis()->GetBinLowEdge(sigminy) << endl;
    
   TCanvas *c1 = new TCanvas("c1", "c1",50,50,600,600);
   gStyle->SetOptFit(1);
   gStyle->SetOptStat(0);
   gStyle->SetOptTitle(0);
   gStyle->SetErrorX(0.5); 
   //c1->Range(-6.311689,-1.891383,28.75325,4.56342);
   c1->SetFillColor(0);
   c1->SetBorderMode(0);
   c1->SetBorderSize(2);
   //c1->SetLogy();
   c1->SetTickx(1);
   c1->SetTicky(1);
   c1->SetLeftMargin(0.15);
//   c1->SetRightMargin(0.05);
    c1->SetRightMargin(0.15);
   c1->SetTopMargin(0.07);
   c1->SetBottomMargin(0.15);
   c1->SetFrameFillStyle(0);
   c1->SetFrameBorderMode(0);
   c1->SetFrameFillStyle(0);
   c1->SetFrameBorderMode(0);
   gStyle->SetHatchesLineWidth(0);

   TH1F *hSum = new TH1F("hSum","",10,100,900);
   hSum->SetMinimum(0.);
   hSum->SetMaximum(550);
   hSum->SetDirectory(0);
   hSum->SetStats(0);
    hSum->Draw();
    hSum->GetYaxis()->SetRangeUser(0,500);
    hSum->GetXaxis()->SetRangeUser(100,900);

   Int_t ci;   // for color index setting
   ci = TColor::GetColor("#000099");
   hSum->SetLineColor(ci);
   hSum->SetLineStyle(0);
   hSum->SetMarkerStyle(20);
   hSum->GetXaxis()->SetTitle("m_{#tilde{t}} [GeV]");
   //hSum->GetXaxis()->SetBit(TAxis::kLabelsVert);
   hSum->GetXaxis()->SetLabelFont(42);
   //hSum->GetXaxis()->SetLabelOffset(0.005);
   hSum->GetXaxis()->SetLabelSize(0.035);
   hSum->GetXaxis()->SetTitleSize(0.06);
   hSum->GetXaxis()->SetTitleOffset(1.2);
   hSum->GetXaxis()->SetTitleFont(42);
   hSum->GetYaxis()->SetTitle("m_{#tilde{#chi}}_{1}^{0} [GeV]");
   hSum->GetYaxis()->SetLabelFont(42);
   //hSum->GetYaxis()->SetLabelOffset(0.007);
   hSum->GetYaxis()->SetLabelSize(0.035);
   hSum->GetYaxis()->SetTitleSize(0.05);
   hSum->GetYaxis()->SetTitleOffset(1.3);
   hSum->GetYaxis()->SetTitleFont(42);
    
//.........这里部分代码省略.........
开发者ID:haweber,项目名称:OneLepStop,代码行数:101,代码来源:SignificanceT2tt.C

示例2: plotTreeNorms

void plotTreeNorms(TTree *tree_, std::string selectString, bool do7TeV){

	// Create a map for plotting the pullsummaries:
	std::map < const char*, std::pair <double,double> > pullSummaryMap;
	int nPulls=0;

	TObjArray *l_branches = tree_->GetListOfBranches();
	int nBranches = l_branches->GetEntries();

	gStyle->SetPadTopMargin(0.01);

	TCanvas *c = new TCanvas("c","",960,800);

	std::string treename = tree_->GetName();
	c->SaveAs(Form("%s_normresiduals.pdf[",treename.c_str()));
	// File to store plots in 
	TFile *fOut = new TFile(Form("%s_normresiduals.root",treename.c_str()),"RECREATE");

        TH1F *bHd = new TH1F("bHd","",50,-1.0,1.0);
        TH1F *bHfd = new TH1F("bHfd","",50,-1.0,1.0);

	for (int iobj=0;iobj<nBranches;iobj++){

		TBranch *br =(TBranch*) l_branches->At(iobj);

		// Draw the normal histogram
		const char* name = br->GetName();

                // select only the normalizations
                string namestr(name);
                if(namestr.find("n_exp")==string::npos) continue;

                bool fitPull=true;
                bool fitPullf=true;

		double p_mean =0;

		int nToysInTree = tree_->GetEntries();
		// Find out if paramter is fitted value or constraint term.
                bool isFitted = true;
			
                p_mean = prenorms_[name].first;	// toy initial parameters from the datacards
                std::cout << "******* "<< name << " *******"<<std::endl;
                std::cout << p_mean << std::endl;
                std::cout << "******************************" <<std::endl;

                TH1F* bH = (TH1F*)bHd->Clone(Form("%s",name));
                TH1F* bHf = (TH1F*)bHfd->Clone(Form("%s_fail",name));
                
                const char* drawInput = Form("(%s-%f)/%f",name,p_mean,p_mean);
                tree_->Draw(Form("%s>>%s",drawInput,name),"");
                tree_->Draw(Form("%s>>%s_fail",drawInput,name),selectString.c_str(),"same");
                fitPull  = true;
                fitPullf = true;
                  
		bHf->SetLineColor(2);
		bH->GetXaxis()->SetTitle(bH->GetTitle());
		bH->GetYaxis()->SetTitle(Form("no toys (%d total)",nToysInTree));
		bH->GetYaxis()->SetTitleOffset(1.05);
		bH->GetXaxis()->SetTitleOffset(0.9);
		bH->GetYaxis()->SetTitleSize(0.05);
		bH->GetXaxis()->SetTitleSize(0.05);
		bH->GetXaxis()->SetTitle(Form("%s",name));
                
		
		bH->SetTitle("");	

		if ( bH->Integral() <=0 )  fitPull = false;
		if (fitPull) {bH->Fit("gaus"); bH->GetFunction("gaus")->SetLineColor(4);}
		
		if ( bHf->Integral() <=0 )  fitPullf = false;
		if (fitPullf) {bHf->Fit("gaus"); bHf->GetFunction("gaus")->SetLineColor(2);}

		c->Clear();
		
 		TPad pad1("t1","",0.01,0.01,0.66,0.95);
 		TPad pad2("t2","",0.70,0.20,0.98,0.80);

		pad1.SetNumber(1); pad2.SetNumber(2);

                if ( isFitted ) {pad2.Draw();}

		pad1.Draw();
		pad1.SetGrid(true);


		TLatex *titletext = new TLatex();titletext->SetNDC();

		
		c->cd(1); bH->Draw(); bHf->Draw("same");
		TLegend *legend = new TLegend(0.6,0.8,0.9,0.89);
		legend->SetFillColor(0);
		legend->AddEntry(bH,"All Toys","L");
		legend->AddEntry(bHf,selectString.c_str(),"L");
		legend->Draw();

		if (fitPull){
			c->cd(2);
			double gap;
			TLatex *tlatex = new TLatex(); tlatex->SetNDC(); 
//.........这里部分代码省略.........
开发者ID:VecbosApp,项目名称:HiggsAnalysisTools,代码行数:101,代码来源:plotParametersFromToys.C

示例3: analyzer_stack


//.........这里部分代码省略.........
        else out_efficiency<<leg_names[files]<<"&\t  "<<histos[4]->Integral()*1000. <<"&\t"<< histos[4]->Integral()/xsec[files] <<endl;
        if (files==nfiles-1) out_efficiency<<"Total BG"<<"&\t \t \t  "<<totalBG*1000.<< endl;
        files++;
    } while (files<nfiles);
    out_efficiency.close();

    for (int d=0; d<nhistos; d++) {
        discriminators[d] = Discr(discr_histos[d],signal_histos[d]);
    }

    bubblesort(discriminators, hist_names_sort,nhistos);

    out_discrimination.open(trigger+dir_name+"discrimination.txt");
    for (int d=0; d<nhistos; d++) {
        if (d==0) out_discrimination<<"Variable &\t d"<<endl;
        out_discrimination<<"$"<<hist_names_sort[d]<<"$"<<" & \t "<< std::setprecision(2)<< discriminators[d]<<endl;
    }
    out_discrimination.close();
    TLatex* tex = new TLatex(0.90,0.92,"13 TeV, PU = 20, bx = 25 ns, 1 pb^{-1}");
    tex->SetNDC();
    tex->SetTextAlign(35);
    tex->SetTextFont(42);
    tex->SetTextSize(0.04);
    tex->SetLineWidth(2);
    TLatex *tex1 = new TLatex(0.13,0.83,"CMS");
    tex1->SetNDC();
    tex1->SetTextAlign(20);
    tex1->SetTextFont(61);
    tex1->SetTextSize(0.06);
    tex1->SetLineWidth(2);
    TLatex* tex2 = new TLatex(0.22,0.77,"Work in progress");
    tex2->SetNDC();
    tex2->SetTextAlign(20);
    tex2->SetTextFont(52);
    tex2->SetTextSize(0.04);
    tex2->SetLineWidth(2);
    TLatex* tex_file = new TLatex(0.35,0.92,"Spring15, DoubleBtag");
    //	TLatex* tex_file = new TLatex(0.35,0.92,"Spring15, SingleBtag");
    tex_file->SetNDC();
    tex_file->SetTextAlign(35);
    tex_file->SetTextFont(42);
    tex_file->SetTextSize(0.04);
    tex_file->SetLineWidth(2);
    for (int i=0; i<nhistos; i++) {
        TString temp_str;
        temp_str.Form("%2.2f",Discr(discr_histos[i],signal_histos[i]));
        TString disc_value = temp_str.Prepend(", d = ");
        TLatex *disc_value_text = new TLatex(0.86,0.853,disc_value);
        disc_value_text->SetNDC();
        disc_value_text->SetTextAlign(35);
        disc_value_text->SetTextFont(42);
        disc_value_text->SetTextSize(0.04);
        disc_value_text->SetLineWidth(2);

        TCanvas *c1 = new TCanvas();
        c1->SetBottomMargin(.12);
        c1->cd();
        c1->SetLogy();
        Double_t xmin = signal_histos[i]->GetBinCenter(0);
        Double_t xmax = signal_histos[i]->GetBinCenter(signal_histos[i]->GetNbinsX());
        TH1F *frame = new TH1F("frame","",1,xmin,xmax);
        frame->SetMinimum(1e-4);
        frame->SetMaximum(1e10);
        frame->GetYaxis()->SetTitleOffset(0.9);
        frame->GetXaxis()->SetTitleOffset(0.91);
        frame->SetStats(0);
        frame->SetTitleFont(42,"x");
        frame->SetTitleFont(42,"y");
        frame->SetTitleSize(0.05, "XYZ");
        frame->SetXTitle(signal_histos[i]->GetXaxis()->GetTitle());

        if ((i<4))frame->SetYTitle("Events  /  20 GeV");
        else if (i==37)frame->SetYTitle("Events  /  20 GeV");
        else if (i==41)frame->SetYTitle("Events  /  20 GeV");
        else if ((i>=4) && (i<8)) frame->SetYTitle("Events  /  0.5");
        else if (i==15) frame->SetYTitle("Events  /  0.5");
        else if ((i>=8) && (i<12)) frame->SetYTitle("Events  /  0.2");
        else if (i==40) frame->SetYTitle("Events / 100 GeV");
        else if ((i==10)||(i==12)||(i==16)||(i==17)||(i==18) || (i==20) || (i==25) || (i==26) || (i==27) || (i==35) || (i==36) ||(i==38) || (i==39)) frame->SetYTitle("Events / 10 GeV");
        else if ((i==13)||(i==14)) frame->SetYTitle("Events / 0.1");
        else if ((i==21)||(i==22)) frame->SetYTitle("Events / 0.05");
        else if ((i==23)||(i==24)) frame->SetYTitle("Events / 0.01");
        else if (i==28) frame->SetYTitle("Events / 0.02");
        else if ((i==29) || (i==30) || (i==31) || (i==32) )frame->SetYTitle("Events / 0.1");
        else if ((i==33) || (i==33))frame->SetYTitle("Events / 0.01");
        else frame->SetYTitle("Events");
        frame->Draw();
        tex->Draw();
        tex1->Draw();
        tex2->Draw();
        tex_file->Draw();
        stacks[i]->Draw("nostacksame");
        leg->Draw("same");
        signal_histos[i]->Draw("same");
        disc_value_text->Draw();
        c1->Print(output_names[i]);
        c1->Delete();
    }

}
开发者ID:chernyavskaya,项目名称:Hbb,代码行数:101,代码来源:analyzer_stack.C

示例4: ofsfit

int
TrackParametrization( TString csvfile="fitslices_out.csv" )
{

  /* Read data from input file */
  TTree *tres = new TTree();
  tres->ReadFile( csvfile, "ptrue:etatrue:psig:psig_err:pmean:pmean_err:norm", ',' );

  /* Print read-in tree */
  tres->Print();

  /* colors array */
  unsigned colors[8] = {1,2,3,4,6,7,14,16};

  /* Create vector of theta values to include for visualization*/
  vector< double > etas_vis;
  etas_vis.push_back(-2.75);
  etas_vis.push_back(-2.25);
  etas_vis.push_back(-1.75);
  etas_vis.push_back(-0.25);
  etas_vis.push_back( 0.25);
  etas_vis.push_back( 1.75);
  etas_vis.push_back( 2.25);

//  etas_vis.push_back(-3.25);
//  etas_vis.push_back(-2.25);
//  etas_vis.push_back(-1.25);
//  etas_vis.push_back(-0.25);
//  etas_vis.push_back( 0.25);
//  etas_vis.push_back( 1.25);
//  etas_vis.push_back( 2.25);
//  etas_vis.push_back( 3.25);

  /* Create vector of theta values to include for fitting*/
  vector< double > etas_fit;
  for ( double eta = -4.45; eta < 4.5; eta += 0.1 )
    etas_fit.push_back( eta );

  /* Create fit function */
  TF1* f_momres = new TF1("f_momres", "sqrt( [0]*[0] + [1]*[1]*x*x )" );

  cout << "\nFit function: " << f_momres->GetTitle() << "\n" << endl;

  /* Create scratch canvas */
  TCanvas *cscratch = new TCanvas("cscratch");

  /* Create framehistogram */
  TH1F* hframe = new TH1F("hframe","",100,0,40);
  hframe->GetYaxis()->SetRangeUser(0,0.15);
  hframe->GetYaxis()->SetNdivisions(505);
  hframe->GetXaxis()->SetTitle("Momentum (GeV/c)");
  hframe->GetYaxis()->SetTitle("#sigma_{p}/p");

  /* create combined canvas plot */
  TCanvas *c1 = new TCanvas();
  hframe->Draw();

  /* Create legend */
  TLegend* leg_eta = new TLegend( 0.2, 0.6, 0.5, 0.9);
  leg_eta->SetNColumns(2);

  /* Create ofstream to write fit parameter results */
  ofstream ofsfit("track_momres_new.csv");
  ofsfit<<"eta,par1,par1err,par2,par2err"<<endl;

  /* Create resolution-vs-momentum plot with fits for each selected theta value */
  for ( int i = 0; i < etas_fit.size(); i++ )
    {
      /* Switch to scratch canvas */
      cscratch->cd();

      double eta = etas_fit.at(i);

      /* No tracking outside -4 < eta < 4 */
      if ( eta < -4 || eta > 4 )
	continue;

      cout << "\n***Eta = " << eta << endl;

      /* Define range of theta because float comparison with fixed value doesn't work
	 too well for cuts in ROOT trees */
      double eta_min = eta * 0.999;
      double eta_max = eta * 1.001;

      /* Cut for tree */
      TCut cutx( Form("ptrue > 1 && ( (etatrue > 0 && (etatrue > %f && etatrue < %f)) || (etatrue < 0 && (etatrue < %f && etatrue > %f)) )", eta_min, eta_max, eta_min, eta_max) );

      /* "Draw" tree on scratch canvas to fill V1...V4 arrays */
      tres->Draw("psig:ptrue:psig_err:0", cutx );

      /* Create TGraphErrors with selected data from tree */
      TGraphErrors *gres = new TGraphErrors( tres->GetEntries(cutx),
					     &(tres->GetV2())[0],
					     &(tres->GetV1())[0],
					     &(tres->GetV4())[0],
					     &(tres->GetV3())[0] );

      /* reset function parameters before fit */
      f_momres->SetParameter(0,0.1);
      f_momres->SetParameter(1,0.1);
//.........这里部分代码省略.........
开发者ID:sPHENIX-Collaboration,项目名称:analysis,代码行数:101,代码来源:TrackParametrization.C

示例5: Loop

void AccTimesEff::Loop()
{
   TStopwatch timer;
   timer.Start();
   // parameters /////////////////////////////////////////////////////////////
   vector<TString> files;
   files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-500_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9999ev.root");
   files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-750_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_10000ev.root");
   files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-1000_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9998ev.root");
   files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-1250_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9998ev.root");
   files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-1500_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9997ev.root");
   files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-1750_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9997ev.root");
   files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-2000_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9999ev.root");
   files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-2500_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9999ev.root");
   files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-3000_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_10000ev.root");
   files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-3500_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9898ev.root");
   files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-4000_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9998ev.root");
   files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-5000_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9966ev.root");
   string outfileName = "accTimesEffHistos";

   // output file formats
   const bool saveSpec = 0;
   const bool saveAsPdf = 0;
   const bool saveAsPng = 1;
   const bool saveAsRoot = 0;
   TString plotDir = "./plots/";

   int font = 42; //62
   // selection cuts /////////////////////////////////////////////////////////
   float elePtCut = 35.;
   float muPtCut = 35.;
   float minInvMass = 0.;

   TH1::SetDefaultSumw2(kTRUE);

   ///////////////////////////////////////////////////////////////////////////

   ///////////////////////////////////////////////////////////////////////////

   TH1F *hGenEvts = new TH1F("hGenEvts", "hGenEvts", 145, 0., 5010.);
   hGenEvts->GetXaxis()->SetTitle("M_{Z'}^{truth}");
   hGenEvts->GetXaxis()->SetTitleFont(font);
   hGenEvts->GetXaxis()->SetLabelFont(font);
   hGenEvts->GetYaxis()->SetTitle("Events");
   hGenEvts->GetYaxis()->SetTitleFont(font);
   hGenEvts->GetYaxis()->SetLabelFont(font);
   hGenEvts->GetYaxis()->SetTitleOffset(1.2);
   hGenEvts->SetLineColor(kBlack);
   hGenEvts->SetLineWidth(2);
   hGenEvts->SetMarkerStyle(20);
   hGenEvts->SetMarkerColor(kBlack);
   TH1F *hGenEvtsEleInAcc = (TH1F*)hGenEvts->Clone("hGenEvtsEleInAcc");
   TH1F *hGenEvtsEleInAccEB = (TH1F*)hGenEvts->Clone("hGenEvtsEleInAccEB");
   TH1F *hGenEvtsEleInAccEE = (TH1F*)hGenEvts->Clone("hGenEvtsEleInAccEE");
   TH1F *hGenEvtsMuInAcc = (TH1F*)hGenEvts->Clone("hGenEvtsMuInAcc");
   TH1F *hGenEvtsInAcc = (TH1F*)hGenEvts->Clone("hGenEvtsInAcc");
   TH1F *hTrgEvts = (TH1F*)hGenEvts->Clone("hTrgEvts");
   hTrgEvts->SetTitle("hTrgEvts");
   TH1F *hRecoEvts = (TH1F*)hGenEvts->Clone("hRecoEvts");
   hRecoEvts->SetTitle("hRecoEvts");
   TH1F *hRecoEvtsEB = (TH1F*)hRecoEvts->Clone("hRecoEvtsEB");
   TH1F *hRecoEvtsEE = (TH1F*)hRecoEvts->Clone("hRecoEvtsEE");
   TH1F *hRecoEleEvts = (TH1F*)hRecoEvts->Clone("hRecoEleEvts");
   TH1F *hRecoEleEvtsEB = (TH1F*)hRecoEvts->Clone("hRecoEleEvtsEB");
   TH1F *hRecoEleEvtsEE = (TH1F*)hRecoEvts->Clone("hRecoEleEvtsEE");
   TH1F *hRecoMuEvts = (TH1F*)hRecoEvts->Clone("hRecoMuEvts");
   TH1F *hRecoNoTrgEvts = (TH1F*)hGenEvts->Clone("hRecoNoTrgEvts");
   hRecoNoTrgEvts->SetTitle("hRecoNoTrgEvts");
   TH1F *hRecoNoTrgEvtsEB = (TH1F*)hRecoNoTrgEvts->Clone("hRecoNoTrgEvtsEB");
   TH1F *hRecoNoTrgEvtsEE = (TH1F*)hRecoNoTrgEvts->Clone("hRecoNoTrgEvtsEE");
   TH1F *hRecoNoTrgEleEvts = (TH1F*)hRecoNoTrgEvts->Clone("hRecoNoTrgEleEvts");
   TH1F *hRecoNoTrgEleEvtsEB = (TH1F*)hRecoNoTrgEvts->Clone("hRecoNoTrgEleEvtsEB");
   TH1F *hRecoNoTrgEleEvtsEE = (TH1F*)hRecoNoTrgEvts->Clone("hRecoNoTrgEleEvtsEE");
   TH1F *hRecoNoTrgMuEvts = (TH1F*)hRecoNoTrgEvts->Clone("hRecoNoTrgMuEvts");
   TH1F* hAcc;
   TH1F* hAccEle;
   TH1F* hAccEleEB;
   TH1F* hAccEleEE;
   TH1F* hAccMu;
   TH1F* hAccTimesTrgEff;
   TH1F* hTrgEff;
   TH1F* hAccTimesEff;
   TH1F* hAccTimesEffEB;
   TH1F* hAccTimesEffEE;
   TH1F* hAccTimesEffEle;
   TH1F* hAccTimesEffEleEB;
   TH1F* hAccTimesEffEleEE;
   TH1F* hAccTimesEffMu;
   TH1F* hAccTimesEffNoTrg;
   //TH1F* hAccTimesEffNoTrgEB;
   //TH1F* hAccTimesEffNoTrgEE;
   TH1F* hAccTimesEffNoTrgEle;
   TH1F* hAccTimesEffNoTrgEleEB;
   TH1F* hAccTimesEffNoTrgEleEE;
   TH1F* hAccTimesEffNoTrgMu;
   TH1F* hEffAftTrg;
   TH1F* hEffAftTrgEle;
   TH1F* hEffAftTrgEleEB;
   TH1F* hEffAftTrgEleEE;
   TH1F* hEffAftTrgMu;
//.........这里部分代码省略.........
开发者ID:gfasanel,项目名称:myCmsCode,代码行数:101,代码来源:accTimesEff.C

示例6: plotter


//.........这里部分代码省略.........
    while(!myReadFile.eof()) {
      myReadFile >> cat >> line;
      char a[100];
      if (categories.find(cat) == categories.end() ) {
	sprintf(a, "cat%d_%d", cat, 0);
	std::cout << a << " " << line << std::endl;
	categories[cat].push_back(new TTreeFormula(a, line.c_str(), chain));
      } else {
	sprintf(a, "cat%d_%zu", cat, categories[cat].size());
	std::cout << a << " " << line << std::endl;
	categories[cat].push_back(new TTreeFormula(a, line.c_str(), chain));
      }
    }
    myReadFile.close();
    //std::cout<< "Debug level 3" << std::endl; 

    
    std::vector<HistoDefinition> histoDef;
    // READING PLOT DEFINITION
    std::cout << "Reading plots..." << std::endl;
    myReadFile.open("probesvar.dat");
    std::map<int, HistoContainer> histos;
    histos[samples[sampletype].second] = HistoContainer();
    
    while(!myReadFile.eof()) {
      // type ncat==1 xbin ybins xmin xmax ymin ymax name xaxis yaxis var cat????
      HistoDefinition temp;
      myReadFile >> temp.type >> temp.log >> temp.ncat >> temp.xbins >> temp.ybins >> temp.xmin >> temp.xmax
		 >> temp.ymin >> temp.ymax >> temp.name >> temp.xaxis >> temp.yaxis >> temp.var;
      histoDef.push_back(temp);
      
      TH1F* h = new TH1F("h", "", temp.xbins, temp.xmin, temp.xmax);
      h->GetXaxis()->SetTitle(temp.xaxis.c_str());
      h->GetYaxis()->SetTitle(temp.yaxis.c_str());
      
      int ncats = categories[temp.ncat].size();
      for (int c=0; c<ncats; c++) {
	
	std::ostringstream convert; 
	convert << c;
	std::string name = temp.name + "_cat"+ convert.str() + "_" + samples[sampletype].first;  
	std::cout << c << " " << name << std::endl;
	histos[samples[sampletype].second].histoF[temp.name].push_back(*((TH1F*)h->Clone(name.c_str())));
      }
      delete h;
    }
    myReadFile.close();
    // std::cout<< "Debug level 4 " << chain->GetEntries() << std::endl; 

    for (int z=0; z<chain->GetEntries(); z++) {
      if (z%10000 == 0)
	std::cout << z << std::endl;
      
      chain->GetEntry(z);

      float mass = branchesF["mass"];
      if ((mass > 70 && mass < 110) && ((abs(branchesF["probe_sc_eta"]) < 1.5 && branchesF["probe_Pho_sieie"] < 0.0105) || (abs(branchesF["probe_sc_eta"]) > 1.5 && branchesF["probe_Pho_sieie"] < 0.028))) {
	double weight = 1.0; 
	if (sampletype == 1 && isfinite(branchesF["totWeight"])) {
	  weight = branchesF["totWeight"];
	  // std::cout << "weight in the loop: " << weight << "and:  " << branchesD["totWeight"] << std::endl; 
	}  
	// cout << "mass: " << mass << " - " << "tag_Pho_mva" << branchesF["tag_Pho_mva"] << " - " << "probe_Pho_mva" << branchesF["probe_Pho_mva"] << endl;
	for (unsigned int s=0; s<samples.size(); s++) {
	  for (unsigned int h=0; h<histoDef.size(); h++) {
	    // std::cout << histoDef[h].name << " " << histoDef[h].var << " " << histoDef[h].ncat << std::endl;
开发者ID:kmondal,项目名称:plotZeeValidation,代码行数:67,代码来源:plotterProbe_data.C

示例7: compareDataMC


//.........这里部分代码省略.........
	mctothist->Add(mchist[imc]);
	smtothist->Add(mchist[imc]);
      }
    }
    else{
      mctothist->Add(mchist[imc]);
      sighist.push_back( 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");
    
    for( unsigned int isig = 0 ; isig < sighist.size() ; isig++ ){
      sighist.at(isig)->Add(smtothist);
      sighist.at(isig)->Draw("samehist");
    } 

    datahist->Draw("sameE1");
    datahist->Draw("sameaxis");

    if(!log) datahist->GetYaxis()->SetRangeUser(0.,1.4*max);
    
  }
  else{
    float max = mctothist->GetMaximum();
    if( log ) mctothist->SetMaximum( 15 * max );
    else      mctothist->SetMaximum( 1.4 * max );

    mctothist->SetLineColor(0);
    mctothist->SetFillColor(0);

    mctothist->GetXaxis()->SetTitle(xtitle);
    mctothist->Draw("hist");
    mcstack->Draw("samehist");

    for( unsigned int isig = 0 ; isig < sighist.size() ; isig++ ){
      sighist.at(isig)->Add(smtothist);
      sighist.at(isig)->Draw("samehist");
    } 

    mctothist->Draw("sameaxis");
  }

  if( drawLegend ){
    TLegend* myleg = getLegend( chmc , labels , overlayData );
    myleg->Draw();
  }

  TLatex *text = new TLatex();
  text->SetNDC();
  text->SetTextSize(0.04);
  text->DrawLatex(0.2,0.88,"CMS Preliminary");
  //text->DrawLatex(0.2,0.83,"0.98 fb^{-1} at #sqrt{s} = 7 TeV");
开发者ID:hooberman,项目名称:UserCode,代码行数:67,代码来源:Hootilities.C

示例8: plot_eff_vs_general_var_grand_pas

void plot_eff_vs_general_var_grand_pas(Bool_t rebin=false, Bool_t range=false){

   //-------------------------------------------------------------------------------------
   // variable: 1 - eta, 2 - pt, 3 - jet 
   //-------------------------------------------------------------------------------------
   

   int variable = 2;
   rebin = false;
   range = true;
   
   bool MBonly = false;
   bool effonly = true;
   bool fakonly = false;
   bool lowerhalf = false;
   int logX = 1;

   double minpt = 5.0;
   double maxpt = 200;

   double minjet = 0;
   double maxjet = 0;
   
   double minjet2 = 130;
   double maxjet2 = 170;



   double maxeta = 1.0;

   Char_t VARIABLE[100];


   if(variable==1){
      TH1F *dum = new TH1F("dum","",100,-2.5,2.5);
      dum->GetXaxis()->SetTitle("#eta");
      sprintf(VARIABLE,"ETA_%1.1f",maxeta);
      if(lowerhalf) dum->SetMaximum(0.5);
   }else if(variable==2){
      TH1F *dum = new TH1F("dum","",100,0.5,320);
      //if(range) dum->SetAxisRange(0,160);
      dum->GetXaxis()->SetTitle("p_{T} [GeV/c]");
      dum->GetXaxis()->CenterTitle();
      dum->GetYaxis()->SetDecimals();
      sprintf(VARIABLE,"PT_minpt_%1.1f_%1.1f_%1.1f",minpt,minjet,maxjet);
   }else if(variable==3){
      TH1F *dum = new TH1F("dum","",100,0,1200);
      dum->GetXaxis()->SetTitle("Corrected leading jet E_{T} (GeV)");
      sprintf(VARIABLE,"JETET_minpt_%1.1f",minpt);
   }   


   dum->SetMinimum(-0.05);
   dum->SetMaximum(1.0);
   dum->SetStats(0);
   //dum->GetYaxis()->SetTitle("Fractional efficiency");
   dum->GetYaxis()->SetTitle("A #times #epsilon_{TR}");
   dum->GetXaxis()->SetTitleSize(0.05);
   dum->GetYaxis()->SetTitleSize(0.05);
   dum->GetYaxis()->SetTitleOffset(1.5);
   dum->GetYaxis()->SetNdivisions(911);
   
   //gROOT->LoadMacro("trkeffanalyzer_hist_jet.C");      
   gROOT->LoadMacro("trkeffanalyzer_hist_general_variable.C");
   
   Char_t fileName1[100];
   Char_t fileName2[100];
   Char_t fileName3[100];
   Char_t fileName4[100];
   Char_t fileName5[100];
   Char_t fileName6[100];

   
   Char_t fileString1[200];
   Char_t fileString2[200];
   Char_t fileString3[200];
   Char_t fileString4[200];
   Char_t fileString5[200];
   Char_t fileString6[200];


   //sprintf(fileName1,"TrkHistMC_QCD_10M.root");
   //sprintf(fileName1,"TrkHistMC_july09v2_qcdMBD6TdJuly09V3_div2.root");
   //sprintf(fileString1,"/Users/andreyoon/Research/ana/spectra/pp_spectra/7TeV/root_files/%s",fileName1);

   sprintf(fileName1,"TrkHistGEN_oct06_qcdMBD6TV1.root");
   sprintf(fileString1,"/Users/andreyoon/Research/pp7TeV/root_files_postApp/mc/%s",fileName1);
   cout<<"input file 1 is "<<fileString1<<endl;
   
   //sprintf(fileName2,"TrkHistMC_QCD_Pt15.root");
   //sprintf(fileName2,"TrkHistMC_july09v2_qcdPt15dJuly09_div2.root");
   //sprintf(fileString2,"/Users/andreyoon/Research/ana/spectra/pp_spectra/7TeV/root_files/%s",fileName2);

   sprintf(fileName2,"TrkHistGEN_oct01_qcdPt15V1.root");
   sprintf(fileString2,"/Users/andreyoon/Research/pp7TeV/root_files_postApp/mc/%s",fileName2);
   cout<<"input file 2 is "<<fileString2<<endl;
   
   //sprintf(fileName3,"TrkHistMC_QCD_Pt30v2.root");
   //sprintf(fileName3,"TrkHistMC_july09v2_qcdPt30dJuly09V2_div2.root");
   //sprintf(fileString3,"/Users/andreyoon/Research/ana/spectra/pp_spectra/7TeV/root_files/%s",fileName3);
//.........这里部分代码省略.........
开发者ID:CmsHI,项目名称:CVS_edwenger,代码行数:101,代码来源:plot_eff_vs_general_var_grand_pas.C

示例9: plotLimit


//.........这里部分代码省略.........
  double* MassAxis   = new double[N];
  double* ObsLimit   = new double[N];  fillLimitArray(tree,-1   ,ObsLimit,MassAxis);  if(!strengthLimit)scaleLimitsByXSecXBR(N, MassAxis, ObsLimit);
  double* ExpLimitm2 = new double[N];  fillLimitArray(tree,0.025,ExpLimitm2);         if(!strengthLimit)scaleLimitsByXSecXBR(N, MassAxis, ExpLimitm2);
  double* ExpLimitm1 = new double[N];  fillLimitArray(tree,0.160,ExpLimitm1);         if(!strengthLimit)scaleLimitsByXSecXBR(N, MassAxis, ExpLimitm1);
  double* ExpLimit   = new double[N];  fillLimitArray(tree,0.500,ExpLimit  );         if(!strengthLimit)scaleLimitsByXSecXBR(N, MassAxis, ExpLimit);
  double* ExpLimitp1 = new double[N];  fillLimitArray(tree,0.840,ExpLimitp1);         if(!strengthLimit)scaleLimitsByXSecXBR(N, MassAxis, ExpLimitp1);
  double* ExpLimitp2 = new double[N];  fillLimitArray(tree,0.975,ExpLimitp2);         if(!strengthLimit)scaleLimitsByXSecXBR(N, MassAxis, ExpLimitp2);
  file->Close();

  //make TH Cross-sections
  double* ThXSec   = new double[N]; for(unsigned int i=0;i<N;i++){ThXSec[i] = xsecXbr[MassAxis[i]];} 

  //scale TH cross-section and limits according to scale factor 
  //this only apply to NarrowResonnance case
  for(unsigned int i=0;i<N;i++){
    if(strengthLimit){
    ObsLimit[i]  /= XSecScaleFactor;
    ExpLimitm2[i]/= XSecScaleFactor;
    ExpLimitm1[i]/= XSecScaleFactor;
    ExpLimit  [i]/= XSecScaleFactor;
    ExpLimitp1[i]/= XSecScaleFactor;
    ExpLimitp2[i]/= XSecScaleFactor;
    }
    ThXSec[i]    *= XSecScaleFactor;
  }

    
  //limits in terms of signal strength
  TCanvas* c = new TCanvas("c", "c",600,600);
  TH1F* framework = new TH1F("Graph","Graph",1,90,160);
  framework->SetStats(false);
  framework->SetTitle("");
  framework->GetXaxis()->SetTitle("Higgs boson mass [GeV]");
  framework->GetYaxis()->SetTitleOffset(1.70);
  if(strengthLimit){
  framework->GetYaxis()->SetTitle("#mu = #sigma_{95%} / #sigma_{th}");
  framework->GetYaxis()->SetRangeUser(9E-1,1E3);
  c->SetLogy(true);
  }else{
  framework->GetYaxis()->SetTitle("#sigma_{95%} (fb)");
  framework->GetYaxis()->SetRangeUser(1E-1,1E3);
  c->SetLogy(true);
  }
  framework->Draw();

  TGraph* TGObsLimit   = new TGraph(N,MassAxis,ObsLimit);  TGObsLimit->SetLineWidth(2);
  TGraph* TGExpLimit   = new TGraph(N,MassAxis,ExpLimit);  TGExpLimit->SetLineWidth(2); TGExpLimit->SetLineStyle(2);
  TCutG* TGExpLimit1S  = GetErrorBand("1S", N, MassAxis, ExpLimitm1, ExpLimitp1);  
  TCutG* TGExpLimit2S  = GetErrorBand("2S", N, MassAxis, ExpLimitm2, ExpLimitp2);  TGExpLimit2S->SetFillColor(5);
  TGraph* THXSec        = new TGraph(N,MassAxis,ThXSec); THXSec->SetLineWidth(2); THXSec->SetLineStyle(1); THXSec->SetLineColor(4);


  TGExpLimit->SetLineColor(2);  TGExpLimit->SetLineStyle(1);
  TGObsLimit->SetLineWidth(2);  TGObsLimit->SetMarkerStyle(20);
  TGExpLimit2S->Draw("fc same");
  TGExpLimit1S->Draw("fc same");
  if(!blind) TGObsLimit->Draw("same CP");
  TGExpLimit->Draw("same C");

  if(strengthLimit){
     TLine* SMLine = new TLine(framework->GetXaxis()->GetXmin(),1.0,framework->GetXaxis()->GetXmax(),1.0);
     SMLine->SetLineWidth(2); SMLine->SetLineStyle(1); SMLine->SetLineColor(4);      
     SMLine->Draw("same C");
  }else{
     THXSec->Draw("same C");
  }
开发者ID:danielguerrero,项目名称:2l2v_fwk,代码行数:67,代码来源:plotLimit.C

示例10: finalLimitPlot

void finalLimitPlot(){
  gStyle->SetOptStat(0);
  gStyle->SetOptTitle(0);
  //   setTDRStyle();
   gStyle->SetPadTopMargin   (0.04);
   gStyle->SetPadBottomMargin(0.12);
   gStyle->SetPadRightMargin (0.05);
   gStyle->SetPadLeftMargin  (0.12);
   gStyle->SetTitleSize(0.04, "XYZ");
   gStyle->SetTitleXOffset(1.1);
   gStyle->SetTitleYOffset(1.45);
   gStyle->SetPalette(1);
   gStyle->SetNdivisions(505);

   TCanvas* c1;
   TH1F* framework;
   TH2F* framework2d;
   TLegend* LEG, *LEGTH;
   TGraph* Ref;


   string Directories[]={"cards_CC8TeV_GG", "cards_SB8TeV_GG", "cards_CC8TeV_QQ", "cards_SB8TeV_QQ",  "cards_CC7TeV_GG", "cards_SB7TeV_GG", "cards_CC7TeV_QQ", "cards_SB7TeV_QQ"};
   for(unsigned int D=0;D<sizeof(Directories)/sizeof(string);D++){
      string Dir = Directories[D];
      for(int observed=0;observed<=1;observed++){


         c1 = new TCanvas("c", "c",600,600);
         c1->SetLogy(true);
         framework = new TH1F("Graph","Graph",1,150,1050);
         framework->SetStats(false);
         framework->SetTitle("");
         framework->GetXaxis()->SetTitle("M_{H} [GeV/c^{2}]");
         framework->GetYaxis()->SetTitle("#sigma_{95%} (fb)");
         framework->GetYaxis()->SetTitleOffset(1.40);
         framework->GetYaxis()->SetRangeUser(1.0,100);
         framework->Draw();

         LEG = new TLegend(0.70,0.70,0.95,0.94);
         LEG->SetFillStyle(0);
         LEG->SetBorderSize(0);
         LEG->SetHeader(observed==0?"Expected @95% CL":"Observed @95% CL");

         LEGTH = new TLegend(0.45,0.70,0.70,0.94);
         LEGTH->SetFillStyle(0);
         LEGTH->SetBorderSize(0);
         LEGTH->SetHeader("Theoretical");


         getGraph("SM"                         , 1, 1, 2, LEGTH, NULL, 0, Dir+               "/XSec_LimitSummary")->Draw("C same");
         getGraph("C'=1.0"                     , 2, 1, 2, LEGTH, NULL, 0, Dir+"_cp1.00_brn0.00/XSec_LimitSummary")->Draw("C same");
         getGraph("C'=0.8"                     , 3, 1, 2, LEGTH, NULL, 0, Dir+"_cp0.80_brn0.00/XSec_LimitSummary")->Draw("C same");
         getGraph("C'=0.6"                     , 4, 1, 2, LEGTH, NULL, 0, Dir+"_cp0.60_brn0.00/XSec_LimitSummary")->Draw("C same");
//       getGraph("C'=0.5"                     , 6, 1, 2, LEGTH, NULL, 0, Dir+"_cp0.50_brn0.00/XSec_LimitSummary")->Draw("C same");
         getGraph("C'=0.4"                     , 6, 1, 2, LEGTH, NULL, 0, Dir+"_cp0.40_brn0.00/XSec_LimitSummary")->Draw("C same");
//       getGraph("C'=0.3"                     , 6, 1, 2, LEGTH, NULL, 0, Dir+"_cp0.30_brn0.00/XSec_LimitSummary")->Draw("C same");
         getGraph("C'=0.2"                     , 8, 1, 2, LEGTH, NULL, 0, Dir+"_cp0.20_brn0.00/XSec_LimitSummary")->Draw("C same");
   //      getGraph("C'=0.1"                     , 8, 1, 2, LEGTH, NULL, 0, Dir+"_cp0.10_brn0.00/XSec_LimitSummary")->Draw("C same");

         getGraph("SM"                         , 1, 2, 1, LEG  , NULL, 1+observed, Dir+               "/XSec_LimitSummary")->Draw("C same");
         getGraph("C'=1.0"                     , 2, 2, 1, LEG  , NULL, 1+observed, Dir+"_cp1.00_brn0.00/XSec_LimitSummary")->Draw("C same");
         getGraph("C'=0.8"                     , 3, 2, 1, LEG  , NULL, 1+observed, Dir+"_cp0.80_brn0.00/XSec_LimitSummary")->Draw("C same");
         getGraph("C'=0.6"                     , 4, 2, 1, LEG  , NULL, 1+observed, Dir+"_cp0.60_brn0.00/XSec_LimitSummary")->Draw("C same");
//         getGraph("C'=0.5"                     , 4, 2, 1, LEG  , NULL, 1+observed, Dir+"_cp0.50_brn0.00/XSec_LimitSummary")->Draw("C same");
         getGraph("C'=0.4"                     , 6, 2, 1, LEG  , NULL, 1+observed, Dir+"_cp0.40_brn0.00/XSec_LimitSummary")->Draw("C same");
//         getGraph("C'=0.3"                     , 4, 2, 1, LEG  , NULL, 1+observed, Dir+"_cp0.30_brn0.00/XSec_LimitSummary")->Draw("C same");
         getGraph("C'=0.2"                     , 8, 2, 1, LEG  , NULL, 1+observed, Dir+"_cp0.20_brn0.00/XSec_LimitSummary")->Draw("C same");
   //      getGraph("C'=0.1"                     , 8, 2, 1, LEG  , NULL, 1+observed, Dir+"_cp0.10_brn0.00/XSec_LimitSummary")->Draw("C same");

         LEGTH->Draw("same");
         LEG  ->Draw("same");

         char LumiLabel[1024];
         if(Dir.find("7TeV")!=string::npos)sprintf(LumiLabel,"CMS preliminary,  #sqrt{s}=7 TeV, #int L=%6.1ffb^{-1}",5.035);
         if(Dir.find("8TeV")!=string::npos)sprintf(LumiLabel,"CMS preliminary,  #sqrt{s}=8 TeV, #int L=%6.1ffb^{-1}",19.6);
         if(Dir.find("Comb")!=string::npos)sprintf(LumiLabel,"CMS preliminary,  #sqrt{s}=%.0f TeV #scale[0.5]{#int} L=%6.1ffb^{-1}, #sqrt{s}=%.0f TeV #scale[0.5]{#int} L=%6.1ffb^{-1}",7.0,5.0,8.0,19.7);
         TPaveText *pave = new TPaveText(0.1,0.96,0.94,0.99,"NDC");
         pave->SetBorderSize(0);
         pave->SetFillStyle(0);
         pave->SetTextAlign(32);
         pave->SetTextFont(42);
         pave->AddText(LumiLabel);
         pave->Draw("same");

         //system("mkdir -p LimitPlots");
         if(observed==0){
            c1->SaveAs((Dir+"/XSec_FinalPlot.png").c_str());
            c1->SaveAs((Dir+"/XSec_FinalPlot.pdf").c_str());
            c1->SaveAs((Dir+"/XSec_FinalPlot.C"  ).c_str());
         }else{
            c1->SaveAs((Dir+"/XSec_FinalPlot_Obs.png").c_str());
            c1->SaveAs((Dir+"/XSec_FinalPlot_Obs.pdf").c_str());
            c1->SaveAs((Dir+"/XSec_FinalPlot_Obs.C"  ).c_str());
         }
      }
   }

//      string Directories2[]={"cards_CC7TeV", "cards_SB7TeV", "cards_CC7TeV_GG", "cards_SB7TeV_GG", "cards_CC7TeV_QQ", "cards_SB7TeV_QQ",    "cards_CC8TeV", "cards_SB8TeV", "cards_CC8TeV_GG", "cards_SB8TeV_GG", "cards_CC8TeV_QQ", "cards_SB8TeV_QQ",  "cards_CCComb", "cards_SBComb", "cards_CCComb_GG", "cards_SBComb_GG", "cards_CCComb_QQ", "cards_SBComb_QQ"};
   string Directories2[]={"cards_CC7TeV", "cards_SB7TeV", "cards_CC7TeV_GG", "cards_SB7TeV_GG", "cards_CC7TeV_QQ", "cards_SB7TeV_QQ",    "cards_CC8TeV", "cards_SB8TeV", "cards_CC8TeV_GG", "cards_SB8TeV_GG", "cards_CC8TeV_QQ", "cards_SB8TeV_QQ",  "cards_CCComb", "cards_SBComb"};
   for(unsigned int D=0;D<sizeof(Directories2)/sizeof(string);D++){
//.........这里部分代码省略.........
开发者ID:amagitte,项目名称:2l2v_fwk,代码行数:101,代码来源:finalLimitPlot.C

示例11: coupling_measurement

void coupling_measurement(TString sel="prova", bool sideband=true, float min=0, float max=2)
{	
  if(sel=="prova") return;
	
  gROOT->Reset();
  gStyle->SetCanvasColor(0);
  gStyle->SetFrameBorderMode(0);
  gStyle->SetMarkerStyle(22);
  gStyle->SetOptStat(0);
	
  TCanvas *c1 = new TCanvas("coupling","coupling",30,30,800,600);
  c1->SetGrid();
	
  // draw a frame to define the range
  TH1F *hr = c1->DrawFrame(-5,0,7,65);
  //hr->SetXTitle("p_t");
  hr->GetYaxis()->SetTitleOffset(1.0);
  hr->SetYTitle("MET cut");
  hr->SetXTitle("#sigma on rV measurement");
  hr->GetYaxis()->SetTitleSize(0.045);
  hr->GetXaxis()->SetTitleSize(0.045);
  hr->GetYaxis()->SetLabelSize(0.045);
  hr->GetXaxis()->SetLabelSize(0.040);
  hr->GetYaxis()->SetNdivisions(015);
  const Int_t n = 20;
	
  //LOW MET CUT
  Double_t y_centr[n] = {-1.0,-0.9,-0.8,-0.7,-0.6,-0.5,-0.4,-0.3,-0.2,-0.1,0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9};
  Double_t y_erlow[n] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  Double_t y_erhig[n] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  Double_t x_centr[n] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
	
  //                           -1      -0.9    -0.8    -0.7    -0.6   -0.5     -0.4      -0.3    -0.2    -0.1    0.0     0.1      0.2    0.3     0.4     0.5     0.6     0.7     0.8  
  if(!sideband){  
    //MC BKG
    //VHlep1
    if(sel=="VHlep1") {
      Double_t x_erlow[n] = {0.865345,0.844741,0.826624,0.814634,0.804645,0.802949,0.804242,0.809796,201,201,201,201,201,201,201,201,201,201,201,201};
      Double_t x_erhig[n] = {1.57891,1.56241,1.54981,1.54917,1.54998,1.57084,1.59965,1.64251,1.19334,1.22874,1.26373,1.3193,1.39003,1.47625,1.59185,1.75099,1.98393,2.33453,2.90948,4.68023};
    }
    //VHlep2
    if(sel=="VHlep2") {
      Double_t x_erlow[n] = {2.56557,2.38531,2.22304,2.09321,2.00704,1.98628,1.981,1.98794,2.01623,2.05354,2.08783,201,201,201,201,201,201,201,201,201};
      Double_t x_erhig[n] = {3.43476,3.29173,3.16909,3.08308,3.05138,3.11495,3.20622,3.32696,3.50211,3.72148,3.97364,2.97657,3.2132,3.55633,4.08556,4.90006,6.3567,8.29943,30.5657,128.278};
    }
    //VHmetT
    if(sel=="VHmetT") {
      Double_t x_erlow[n] = {2.8874,2.56138,2.26013,2.01522,1.85125,1.71143,1.59633,1.4957,1.41358,1.35894,1.30951,1.2762,1.23767,1.21275,1.19742,1.20805,1.23355,201,201,201};
      Double_t x_erhig[n] = {3.18255,2.91988,2.67321,2.47263,2.34945,2.24189,2.15582,2.08163,2.02718,2.00829,1.99598,2.00913,2.0161,2.05034,2.11062,2.24004,2.43898,1.94345,2.26239,3.36364};
    }
    //ttHhad
    if(sel=="ttHhad") {
      Double_t x_erlow[n] = {3.84643,3.23125,2.96495,2.82116,2.70509,2.596,2.49624,2.40113,2.31831,2.28309,2.19436,2.09837,2.00986,201,201,201,201,201,201,201};
      Double_t x_erhig[n] = {4.58439,4.0736,3.86196,3.75742,3.68325,3.62087,3.57653,3.54561,3.54225,3.62824,3.651,3.68787,3.77815,2.76994,2.82907,2.93495,3.24079,3.61888,4.50953,7.14343};
    }
    //VHhadB
    if(sel=="VHhadB") {
      Double_t x_erlow[n] = {5.35001,5.09173,4.84396,4.64062,4.43147,4.20828,3.9993,3.79365,3.625,3.48895,3.39049,3.24834,3.17256,3.11595,2.99101,2.80766,2.85888,3.11851,201,201};
      Double_t x_erhig[n] = {5.66319,5.45352,5.25341,5.09811,4.93559,4.75593,4.5908,4.42958,4.31223,4.23727,4.21498,4.15067,4.18357,4.26287,4.27935,4.24169,4.62244,5.53665,5.1091,22.3609};
    }
    //VHhad0
    if(sel=="VHhad0") {
      Double_t x_erlow[n] = {2.67097,2.58138,2.49218,2.4054,2.31249,2.21792,2.12431,2.07219,1.98572,1.8808,1.78948,1.70381,1.66196,1.58922,1.55664,1.53952,1.58572,201,201,201};
      Double_t x_erhig[n] = {3.29995,3.22518,3.1511,3.08043,3.00298,2.92372,2.84768,2.82851,2.7679,2.68509,2.62409,2.57511,2.59963,2.58517,2.65137,2.77153,3.07152,2.4114,3.14665,8.34286};
    }
  }
	
  if(sideband){
    //SIDEBAND
    //VHlep1
    if(sel=="VHlep1") {
      Double_t x_erlow[n] = {1.21869,1.15681,1.10054,1.05793,1.02142,1.00191,0.988866,0.983631,0.979968,0.983412,201,201,201,201,201,201,201,201,201,201};
      Double_t x_erhig[n] = {1.91116,1.85891,1.81291,1.78525,1.76234,1.7673,1.78322,1.81641,1.85603,1.91849,1.40949,1.46047,1.52805,1.61182,1.72804,1.89225,2.13811,2.51264,3.12966,5.10852};
    }
    //VHlep2
    if(sel=="VHlep2") {
      Double_t x_erlow[n] = {3.11548,2.87988,2.66834,2.49813,2.38352,2.35112,2.33867,2.34185,2.37193,2.41362,2.45208,2.4729,201,201,201,201,201,201,201,201};
      Double_t x_erhig[n] = {3.90609,3.71908,3.55668,3.43838,3.38426,3.43987,3.52696,3.64649,3.82548,4.05123,4.30982,4.58501,3.57694,3.9542,4.54303,5.45666,7.10646,9.3052,32.0946,133.269};
    }
    //VHmetT
    if(sel=="VHmetT") {
      Double_t x_erlow[n] = {3.03829,2.69084,2.36918,2.10777,1.93241,1.78255,1.65984,1.55225,1.4643,1.40533,1.35191,1.31545,1.27356,1.24594,1.22833,1.23785,1.26274,201,201,201};
      Double_t x_erhig[n] = {3.30609,3.02607,2.76347,2.54997,2.4179,2.30279,2.21046,2.13076,2.07169,2.0494,2.03395,2.04464,2.04893,2.08101,2.13949,2.26815,2.46687,1.97301,2.29484,3.4136};
    }
    //ttHhad
    if(sel=="ttHhad") {
      Double_t x_erlow[n] = {3.32048,2.81115,2.59078,2.47157,2.376,2.2863,2.20459,2.12683,2.0596,2.03317,1.96088,1.8825,201,201,201,201,201,201,201,201};
      Double_t x_erhig[n] = {4.14027,3.71348,3.53826,3.45367,3.39573,3.3487,3.31856,3.3013,3.31007,3.40212,3.43787,3.48884,2.54189,2.59388,2.66517,2.78245,3.08706,3.46504,4.32835,6.84114};
    }
    //VHhadB
    if(sel=="VHhadB") {
      Double_t x_erlow[n] = {3.89188,3.71798,3.55106,3.41527,3.27502,3.12374,2.9822,2.84268,2.72989,2.64161,2.58054,2.48755,2.44351,2.41267,2.33155,2.20676,2.25397,201,201,201};
      Double_t x_erhig[n] = {4.46581,4.3219,4.18483,4.08197,3.9728,3.84949,3.73721,3.62792,3.55392,3.5148,3.5197,3.49253,3.54717,3.64371,3.69268,3.7009,4.07076,3.44509,4.33376,20.209};
    }
    //VHhad0
    if(sel=="VHhad0") {
      Double_t x_erlow[n] = {2.09522,2.0317,1.96848,1.90712,1.84121,1.77369,1.70736,1.67273,1.61226,1.53798,1.47428,1.41515,1.38975,1.34111,1.32351,1.31815,201,201,201,201};
      Double_t x_erhig[n] = {2.80897,2.75498,2.70162,2.6512,2.59535,2.53825,2.48422,2.47853,2.43882,2.38101,2.34246,2.31508,2.35232,2.35753,2.43535,2.56426,1.98796,2.19105,2.85189,7.29571};
    }
  }
//.........这里部分代码省略.........
开发者ID:aspiezia,项目名称:HggMacros,代码行数:101,代码来源:coupling_measurement.C

示例12: makeRisetimeDistributionT9

void makeRisetimeDistributionT9(string filename, string plotname, string plotTitle,
			      double ampCutOnMCP, double ampCutOnLYSO, double ampCutOnTrigger,
			    double beamXMin, double beamXMax, double beamYMin, double beamYMax,
			    int nbins, double xmin, double xmax, double fitmin, double fitmax) {


  TFile *inputfile = TFile::Open(filename.c_str(),"READ");
  
  TTree *tree = (TTree*)inputfile->Get("t1065");

  // get the variables from the ntuple
  float amp[36];
  float risetime[36];
  float gauspeak[36];
  float linearTime30[36];
  float beamX;
  float beamY;

  tree->SetBranchStatus("*",0);
  tree->SetBranchStatus("gauspeak",1);
  tree->SetBranchStatus("amp",1);
  tree->SetBranchStatus("risetime",1);
  tree->SetBranchStatus("linearTime30",1);
  tree->SetBranchStatus("TDCx",1);
  tree->SetBranchStatus("TDCy",1);
  tree->SetBranchAddress("gauspeak",gauspeak);
  tree->SetBranchAddress("amp",amp);
  tree->SetBranchAddress("risetime",risetime);
  tree->SetBranchAddress("linearTime30",linearTime30);
  tree->SetBranchAddress("TDCx",&beamX);
  tree->SetBranchAddress("TDCy",&beamY);

  //create histograms
  TH1F *histRisetime;
  histRisetime = new TH1F("histRisetime","; Integrated Charge [pC];Number of Events", nbins, xmin, xmax);

  
  //read all entries and fill the histograms
  Long64_t nentries = tree->GetEntries();

  std::cout<<"Number of events in Sample: "<<nentries<<std::endl;  
  for (Long64_t iEntry=0;iEntry<nentries;iEntry++) {
    if (iEntry %1000 == 0) 
      cout << "Processing Event " << iEntry << "\n";
    tree->GetEntry(iEntry);    
    // cout << "here1\n";
    float MCPTimeGauss = gauspeak[0];
    float CdTeTime = linearTime30[1];
    float MCPAmp = amp[0];
    float LYSOAmp = amp[2];
    float TriggerAmp = amp[3];
    float CherenkovAmp = amp[7];
    float CdTeAmp = amp[1]*(1.0/63.0957);
    float CdTeRisetime = risetime[1];
    // cout << "here2\n";
       
    //use MCP amplitude cut for electron ID
    //cout << "test: " << MCPAmp << " " << siliconIntegral << "\n";
    if( !(MCPAmp > ampCutOnMCP)) continue;
    if( !(TriggerAmp > ampCutOnTrigger)) continue;
    if( !(LYSOAmp > ampCutOnLYSO)) continue;
    if(!(beamX > beamXMin && beamX < beamXMax)) continue;
    if(!(beamY > beamYMin && beamY < beamYMax)) continue;
     // cout << "here3\n";

    //don't fill overflow bins
    //if (1000* siliconIntegral * attenuationFactor / amplificationFactor > xmax) continue;
    
    histRisetime->Fill( CdTeRisetime );

    //cout << CdTeRisetime << " " << beamX << " " << beamY << " " << CdTeAmp << "\n";

    //cout << 1000* amp[21] << " : " << amplificationFactor << " : " << siliconIntegral * attenuationFactor / amplificationFactor << "\n";
 
  }


  TCanvas * c = 0;


  //Energy plot
  c = new TCanvas("c","c",600,600);  
  c->SetRightMargin(0.05);
  c->SetLeftMargin(0.17);
  histRisetime->SetAxisRange(xmin,xmax,"X");
  histRisetime->SetTitle("");
  histRisetime->GetXaxis()->SetTitle("Risetime [ns]");
  histRisetime->GetXaxis()->SetTitleSize(0.045);
  histRisetime->GetXaxis()->SetLabelSize(0.045);
  histRisetime->GetYaxis()->SetTitle("Number of Events");
  histRisetime->GetYaxis()->SetTitleOffset(1.3);
  histRisetime->GetYaxis()->SetTitleSize(0.05);
  histRisetime->GetYaxis()->SetLabelSize(0.045);
  histRisetime->GetYaxis()->SetLabelOffset(0.015);
  histRisetime->GetYaxis()->SetTitleOffset(1.7);
  histRisetime->SetMaximum(1.2*histRisetime->GetMaximum());
  histRisetime->Draw();
  histRisetime->SetStats(0);
  histRisetime->Fit("gaus","","",fitmin,fitmax);
  TVirtualFitter * fitter = TVirtualFitter::GetFitter();
//.........这里部分代码省略.........
开发者ID:CaltechPrecisionTiming,项目名称:t1065-jun-2016,代码行数:101,代码来源:plotRisetime.C

示例13: PlotUnifier

////////////////////////////////////////////////////////////////////////////////////////
// Draw and save the canvas
// This bit shouldn't need to be updated except the region and channel labels
// As of Jan 10,2013 - the known issues are:
// ++ Error bands don't show correctly
// ++ Data histogram needs to be converted to TGraphAsymmErrors and 
//    plotted w/ poisson errors
// ++ Ratio plot needs to divide the Data TGraphAsymmErrors and
//    TGraphAsymmErrors for the total SM (by turning off the errors since they are
//    shown explicitly)
////////////////////////////////////////////////////////////////////////////////////////
void PlotUnifier(
                  TH1F* histos[9],                   // Array of pointers to histograms
                  TGraphAsymmErrors* smErrorBand,    // Error band for the top pad
                  TGraphAsymmErrors* ratioErrorBand  // Error band for the bottom pad
                )
{
  ////////////////////////////////////////////////////////////////////////////////////////
  // Set Histogram Properties, build the stack and make the ratio plot
  histos[0]->SetMarkerStyle(20)     ; histos[0]->SetMarkerSize(1.2); 
  histos[1]->SetFillColor(kOrange-2); histos[4]->SetLineWidth (2);
  histos[2]->SetFillColor(kAzure-9 ); histos[1]->SetLineWidth (2);
  histos[3]->SetFillColor(kSpring+1); histos[2]->SetLineWidth (2);
  histos[4]->SetFillColor(kAzure+4 ); histos[3]->SetLineWidth (2);
  histos[5]->SetFillColor(kGray    ); histos[5]->SetLineWidth (2);
  histos[6]->SetFillColor(kYellow-9); histos[6]->SetLineWidth (2);
  histos[7]->SetLineColor(kMagenta ); histos[7]->SetLineWidth (3); histos[7]->SetLineStyle(2);
  histos[8]->SetLineColor(kGreen+1 ); histos[8]->SetLineWidth (3); histos[8]->SetLineStyle(2);
  
  ////////////////////////////////////////////////////////////////////////////////////////
  // Here comes the stack 
  THStack* sm = new THStack("sm","sm");
  sm->Add(histos[6]);
  sm->Add(histos[5]);
  sm->Add(histos[4]);
  sm->Add(histos[3]);
  sm->Add(histos[2]);
  sm->Add(histos[1]);

  ////////////////////////////////////////////////////////////////////////////////////////
  // Define the legend and fill in the stack order
  TLegend* legendA        = new TLegend(0.49,0.65,0.74,0.85);
  TLegend* legendB        = new TLegend(0.62,0.65,0.87,0.85);
  legendA->SetTextFont(42);    
  legendB->SetTextFont(42);    
  legendA->SetTextSize(0.03);
  legendB->SetTextSize(0.03);
  legendA->SetBorderSize(0);
  legendB->SetBorderSize(0);
  legendA->SetFillColor(0);
  legendB->SetFillColor(0);
  legendA->AddEntry(histos[0],"Data"               ,"p");
  legendA->AddEntry(histos[1],"Z+jets"             ,"f");
  legendA->AddEntry(histos[2],"WW"                 ,"f");
  legendA->AddEntry(histos[3],"t#bar{t}+Wt"        ,"f");
  legendA->AddEntry(histos[4],"ZV"                 ,"f");
  legendB->AddEntry(histos[5],"Non-prompt leptons" ,"f");
  legendB->AddEntry(histos[6],"Higgs"              ,"f");
  TH1F* histoError = new TH1F("histoError"         ,"histoError",1,0,1);
  histoError->SetFillStyle(3004);
  histoError->SetFillColor(kBlack);
  legendB->AddEntry(histoError,"Bkg. Uncert."      ,"f");
  legendB->AddEntry(histos[7],"Signal 1"           ,"l");
  legendB->AddEntry(histos[8],"Signal 2"           ,"l");

  ////////////////////////////////////////////////////////////////////////////////////////
  // 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
//.........这里部分代码省略.........
开发者ID:JosephineWittkowski,项目名称:analysis_SUSYTools_03_04_SusyNt_01_16_n0150,代码行数:101,代码来源:PlotExample_v3.C

示例14: plotPPBalanceAll

void plotPPBalanceAll(){

  bool isPF = true;

  TString data_tag;
  TString mc_tag;
  TString jetfinder, jetfinder_tag;

  if(!isPF){
    data_tag = "hdata_ak5calo_DijetBalance";
    mc_tag = "hmc_ak5calo_DijetBalance_histonly";
    jetfinder_tag = "calo";
  }else{
    data_tag = "hdata_ak5pf_DijetBalance";
    mc_tag = "hmc_ak5pf_DijetBalance_histonly";
    jetfinder_tag ="pf";
  }

  TFile *fDATA = new TFile(Form("./%s.root",data_tag.Data()));
  TFile *fMC = new TFile(Form("./%s.root",mc_tag.Data()));

  TH1F *hDijetBal_data = (TH1F*) fDATA->Get("hDataDijetBalance");
  TH1F *hDijetBal_mc = (TH1F*) fMC->Get("hQCDDijetBalance");


  // normalization should be matched with what's in ANA
  hDijetBal_data->Scale(1./hDijetBal_data->Integral());
  hDijetBal_data->Rebin(2);

  hDijetBal_mc->Scale(1./hDijetBal_mc->Integral());
  hDijetBal_mc->Rebin(2);

  cout<<"Bin Width = "<<hDijetBal_data->GetBinWidth(1)<<endl;


  // canvas setting ---
  TCanvas *c1 = new TCanvas("c1","",560,620);

  // dum styling ----
  TH1F *hDum = new TH1F("hDum","",10,0,1.0);
  hDum->SetLineColor(kBlue);
  hDum->SetFillColor(kAzure-8);
  hDum->SetFillStyle(3005);

  hDum->SetStats(0);
  hDum->SetXTitle("A_{J} = (p_{T}^{j1}-p_{T}^{j2})/(p_{T}^{j1}+p_{T}^{j2})");
  hDum->SetYTitle("Event Fraction");

  hDum->GetXaxis()->SetLabelSize(30);
  hDum->GetXaxis()->SetLabelFont(43);
  hDum->GetXaxis()->SetTitleSize(30);
  hDum->GetXaxis()->SetTitleFont(43);
  hDum->GetXaxis()->SetTitleOffset(1.4);
  hDum->GetXaxis()->CenterTitle();

  hDum->GetXaxis()->SetNdivisions(905,true);
  
  hDum->GetYaxis()->SetLabelSize(30);
  hDum->GetYaxis()->SetLabelFont(43);
  hDum->GetYaxis()->SetTitleSize(30);
  hDum->GetYaxis()->SetTitleFont(43);
  hDum->GetYaxis()->SetTitleOffset(1.8);
  hDum->GetYaxis()->CenterTitle();

  hDum->SetAxisRange(0,0.25,"Y");


  // data, mc styling
  hDijetBal_mc->SetLineColor(kBlue);
  hDijetBal_mc->SetFillColor(kAzure-8);
  hDijetBal_mc->SetFillStyle(3352);
// 3352
  hDum->Draw("hist");
  
  hDijetBal_mc->SetMarkerSize(2.0);
  hDijetBal_mc->Draw("histsame");
  hDijetBal_data->SetMarkerSize(2.0);
  hDijetBal_data->Draw("pzsame");


  // Legend
  TLegend *t3=new TLegend(0.53,0.57,0.91,0.82);
  //t3->SetHeader("ant-k_{T} (R=0.5) CaloJets");
  t3->AddEntry(hDijetBal_data,"p + p  #sqrt{s}=7.0 TeV","pl");
  t3->AddEntry(hDijetBal_mc,"PYTHIA","lf");
  t3->SetFillColor(0);
  t3->SetBorderSize(0);
  t3->SetFillStyle(0);
  t3->SetTextFont(63);
  t3->SetTextSize(20);
  t3->Draw();


  // other labeling
  TLatex *cms = new TLatex(0.20,0.23,"CMS");
  cms->SetTextFont(63);
  cms->SetTextSize(20);
  cms->Draw();

  TLatex *lumi = new TLatex(0.35,0.23,"#intL dt = 35.1 pb^{-1}");
//.........这里部分代码省略.........
开发者ID:mandrenguyen,项目名称:usercode,代码行数:101,代码来源:plotPPBalanceAll.C

示例15: Draw

        void Draw(TCanvas *c1, const int &rebin=1, const bool &showErr=true) {

            gStyle->SetOptStat(0);
            c1->cd();
            c1->Clear();

            TPad *pad1;
            pad1 = new TPad("pad1","pad1",0,1-0.614609572,1,1);
            pad1->SetTopMargin(0.0983606557);
            pad1->SetBottomMargin(0.025);
            pad1->Draw();
            pad1->cd();

            RebinHists(rebin);
            THStack *hstack = GetStack(c1->GetLogy());
            TH1F *signal = GetSignalHist();
            TH1F *data   = GetDataHist();

            if(c1->GetLogy()) gPad->SetLogy();
            hstack->GetHistogram()->SetLabelSize(0.00,"X");
            hstack->GetHistogram()->SetLabelSize(0.06,"Y");
            hstack->GetHistogram()->SetTitleSize(0.06,"XY");
            hstack->Draw("hist");
            if(signal && ! _stackSignal) signal->Draw("hist,same");
            if(data)     data->Draw("ep,same");
            DrawLabels();
            pad1->GetFrame()->DrawClone();


            TH1F *summed = GetSummedMCHist();

            TH1F *rdat = (TH1F*)data->Clone("rdat");   
            if(gROOT->FindObject("rref")) gROOT->FindObject("rref")->Delete();
            TH1F *rref = new TH1F("rref","rref",
                summed->GetNbinsX(),
                summed->GetBinLowEdge(1),
                summed->GetBinLowEdge(summed->GetNbinsX()+1)
            );
            for (int i = 1, n = rref->GetNbinsX(); i <= n+1; ++i) {
                rref->SetBinContent(i,summed->GetBinContent(i));
                rref->SetBinError(i,summed->GetBinError(i));
            }
            rref->SetTitle("");
            rref->SetLineWidth(0);
            rref->SetFillColor(kGray+1);
            rref->SetFillStyle(1001);
            double absmax = 0;
            for (int i = 0, n = rdat->GetNbinsX(); i <= n+1; ++i) {
                double scale = rref->GetBinContent(i);
                if (scale == 0) {
                    rdat->SetBinContent(i, 0);
                    rref->SetBinContent(i, 10000);
                    rdat->SetBinError(i, 0);
                    rref->SetBinError(i, 0);
                } else {
                    rdat->SetBinContent(i, rdat->GetBinContent(i)/scale);
                    rref->SetBinContent(i, rref->GetBinContent(i)/scale);
                    rdat->SetBinError(i, rdat->GetBinError(i)/scale);
                    rref->SetBinError(i, rref->GetBinError(i)/scale);
                    double mymax = TMath::Max(1.2*fabs(rdat->GetBinContent(i)-1)+1.4*rdat->GetBinError(i), 2.0*rref->GetBinError(i));
                    absmax = TMath::Max(mymax, absmax);
                }
            }

            c1->cd();
            TPad *pad2 = new TPad("pad2","pad2",0,0,1,1-0.614609572);
            pad2->SetTopMargin(0.0261437908);
            pad2->SetBottomMargin(0.392156863);
            pad2->Draw();
            pad2->cd();

            TLine *line = new TLine(rref->GetXaxis()->GetXmin(), 1.0, rref->GetXaxis()->GetXmax(), 1.0);
            line->SetLineColor(kBlack);
            line->SetLineWidth(1);
            line->SetLineStyle(1);

            if(showErr) {
                rref->GetYaxis()->SetRangeUser(TMath::Max(-1.,1.-absmax), TMath::Min(3.,absmax+1.));
                AxisFonts(rref->GetXaxis(), "x", hstack->GetXaxis()->GetTitle());
                rref->GetYaxis()->SetTitle("data/mc");
                rref->GetYaxis()->SetLabelSize(0.10);
                rref->GetYaxis()->SetTitleSize(0.10);
                rref->GetYaxis()->SetTitleOffset(0.85);
                rref->GetXaxis()->SetLabelSize(0.10);
                rref->GetXaxis()->SetTitleSize(0.10);
                rref->GetXaxis()->SetTitleOffset(1.5);
                rref->Draw("E2"); 
                rdat->SetMarkerStyle(20);
                rdat->Draw("E SAME p");
                line->Draw("SAME"); 
                c1->Update();
                pad2->GetFrame()->DrawClone();

            } else {
                rdat->GetYaxis()->SetRangeUser(TMath::Max(-1.,1.-absmax), TMath::Min(3.,absmax+1.));
                rdat->GetYaxis()->SetTitle("data/mc");
                rdat->GetYaxis()->SetLabelSize(0.10);
                rdat->GetYaxis()->SetTitleSize(0.10);
                rdat->GetYaxis()->SetTitleOffset(0.85);
                AxisFonts(rdat->GetXaxis(), "x", hstack->GetXaxis()->GetTitle());
//.........这里部分代码省略.........
开发者ID:HuguesBrun,项目名称:WWAnalysis,代码行数:101,代码来源:DivPlot.C


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