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


C++ TCanvas::SetCanvasSize方法代码示例

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


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

示例1: plotVariation

void plotVariation(TH1F *nom, TH1F *up, TH1F *down, string phoCat, string name){

	TCanvas *canv = new TCanvas();
	canv->SetWindowSize(750,750);
	canv->SetCanvasSize(750,750);
	gStyle->SetOptStat(0);
	nom->SetLineWidth(3);
	nom->SetLineColor(kBlack);
	up->SetLineWidth(2);
	up->SetLineColor(kBlue);
	down->SetLineWidth(2);
	down->SetLineColor(kRed);

	double max=0.;
	max = nom->Integral()/(sqrt(2*TMath::Pi())*0.7)*nom->GetBinWidth(1);
	/// max = TMath::Max(max,nom->GetMaximum());
	/// max = TMath::Max(max,up->GetMaximum());
	/// max = TMath::Max(max,down->GetMaximum());

	nom->GetYaxis()->SetRangeUser(0,max*1.1);
	up->GetYaxis()->SetRangeUser(0,max*1.1);
	down->GetYaxis()->SetRangeUser(0,max*1.1);

	nom->GetXaxis()->SetRangeUser(mh_-10,mh_+10);
	up->GetXaxis()->SetRangeUser(mh_-10,mh_+10);
	down->GetXaxis()->SetRangeUser(mh_-10,mh_+10);

	nom->GetXaxis()->SetTitle("m_{#gamma#gamma} (GeV)");
	up->GetXaxis()->SetTitle("m_{#gamma#gamma} (GeV)");
	down->GetXaxis()->SetTitle("m_{#gamma#gamma} (GeV)");

	nom->SetTitle(Form("%s_%s",name.c_str(),phoCat.c_str()));
	up->SetTitle(Form("%s_%s",name.c_str(),phoCat.c_str()));
	down->SetTitle(Form("%s_%s",name.c_str(),phoCat.c_str()));

	TLegend *leg = new TLegend(0.6,0.6,0.89,0.89);
	leg->SetFillColor(0);
	leg->SetLineColor(0);
	leg->AddEntry(nom,"Nominal","L");
	if (quadInterpolate_!=0) {
		leg->AddEntry(up,Form("+%d#sigma",quadInterpolate_),"L");
		leg->AddEntry(down,Form("-%d#sigma",quadInterpolate_),"L");
	}
	else {
		leg->AddEntry(up,"+1#sigma","L");
		leg->AddEntry(down,"-1#sigma","L");
	}

	nom->Draw("HIST");
	up->Draw("HISTsame");
	down->Draw("HISTsame");
	nom->Draw("HISTsame");
	leg->Draw();

	canv->Print(Form("%s/systematics/%s_%s.pdf",plotDir_.c_str(),name.c_str(),phoCat.c_str()));
	canv->Print(Form("%s/systematics/%s_%s.png",plotDir_.c_str(),name.c_str(),phoCat.c_str()));
}
开发者ID:ldcorpe,项目名称:flashggFinalFit,代码行数:57,代码来源:calcPhotonSystConsts.cpp

示例2: corrLaser

void corrLaser()
{
  const Int_t kXtals = 1700;
  gStyle->SetTitleFontSize(0.06);
  //gStyle->SetStatFontSize(0.04);    
  gStyle->SetStatColor(10);
  gStyle->SetTitleFillColor(10);
  gStyle->SetCanvasColor(10);
  //  gStyle->SetOptStat("e");
  gStyle->SetOptStat(111111);
  gStyle->SetOptFit(1001);
  gStyle->SetPaperSize(20,26);
  //gStyle->SetStatH(0.10);  
  //gStyle->SetStatW(0.08);
  gStyle->SetStatH(0.15);  
  gStyle->SetStatW(0.25);

  TFile* fout = new TFile("corrBeam.root","recreate");

  hRatio126laser  = new TH1F("hRatio126laser","SM6, Gain ratio x12/x6", 
			      50, 1.85, 2.05);
  hRatio126TP = new TH1F("hRatio126TP","SM6, Gain ratio x12/x6", 
			   50, 1.85, 2.05);

  hCorr126 = new TH2F("hCorr126","SM6, Gain ratio x12/x6 corr.", 
			50,1.9, 2.02,50, 1.9, 2.02);
  
  hDiff126 = new TH1F("hDiff126","SM6, Gain ratio x12/x6 diff.", 
			50, -0.015,0.025);

  TCanvas cPrint("cPrint");
 
  //  Double_t ratio121TP[kXtals];
  Double_t ratio126laser[kXtals];
  Double_t ratio126TP[kXtals];
  Double_t ratio121TP[kXtals];
  for(Int_t iXtal = 0; iXtal < kXtals; iXtal++) {
    ratio126laser[iXtal] = 0.;
    ratio126TP[iXtal] = 0.;
  }
  // Open laser ratio file
  ifstream fRatioInput;
  fRatioInput.open("relgain_laser.out");
  if(!fRatioInput.is_open()) {
    cout  << "can't open laser Ratio file " << endl;
    return;
  }

  for(Int_t i = 0; !fRatioInput.eof(); i++) {
    Int_t Xtal,iXtal;
    Double_t ratio126, error;
    fRatioInput >> Xtal >> iXtal >> ratio126 >> error;
    ratio126laser[iXtal - 1] = ratio126;
    //    cout << iXtal << " " << ratio126laser[iXtal - 1] << endl;
  }
  fRatioInput.close();

  // Open Test Pulse ratio file
  ifstream fRatioInput;
  fRatioInput.open("TestPulse_gainratio_SM06.txt");
  if(!fRatioInput.is_open()) {
    cout  << "can't open old Ratio file " << endl;
    return;
  }
  
  for(Int_t iXtal = 0; !fRatioInput.eof(); iXtal++) {
    Int_t Xtal;
    fRatioInput >>  Xtal >> ratio121TP[iXtal] >> ratio126TP[iXtal];
    if(Xtal != iXtal + 1) cout << " pb Xtal " << Xtal << " " << iXtal << endl;
    cout << iXtal << " " << ratio126TP[iXtal] << endl;
  }
  fRatioInput.close();

  for(Int_t iXtal = 0; iXtal < kXtals; iXtal++) {
    if (ratio126laser[iXtal] != 0) {
      hRatio126laser->Fill(ratio126laser[iXtal]);
      hRatio126TP->Fill(ratio126TP[iXtal]);
      hCorr126->Fill(ratio126laser[iXtal], ratio126TP[iXtal]);
      hDiff126->
	  Fill((ratio126laser[iXtal]-ratio126TP[iXtal])/ratio126laser[iXtal]);
      //      cout << iXtal << " " << ratio126laser[iXtal] << " " << ratio126TP[iXtal]
      //	   << endl;
    }
  }

  TLegend* legend1 = new TLegend(0.15,0.75,0.35,0.85);
  legend1->SetBorderSize(1); 
  legend1->SetFillColor(0); 
  legend1->SetTextSize(0.03); 
  legend1->SetTextFont(42);
 
  TCanvas* cRatio = new TCanvas("cRatio", "cRatio");
  cRatio->SetCanvasSize(630,885);
  cRatio->Divide(1,2);
  cRatio->cd(1);
  hRatio126laser->Draw();
  gPad->Update();
  TPaveStats* st1 = 
    (TPaveStats*)hRatio126laser->GetListOfFunctions()->FindObject("stats");
  st1->SetLineColor(3);
//.........这里部分代码省略.........
开发者ID:depasse,项目名称:UserCode,代码行数:101,代码来源:corrLaser.C

示例3: determineWorkingPoint

void determineWorkingPoint(TString algo="csv",TString baseURL="~/scratch0/top-nosyst/plotter.root")
{
  float workPoint(0.244);
  float sfb(1.020),    sfberr(0.04);      //from BTV-11-003
  float sflight(1.08), sflighterr(0.13);  //from BTV-11-002
  //  float sfb(0.99),        sfberr(0.099);      //from BTV-11-001
  //  float sflight(1.07882), sflighterr(0.244);  //from BTV-11-001
  if(algo=="tche")
    {
      workPoint=1.7;
      sfb=0.95; sfberr=0.095;
      sflight=1.08018; sflighterr=0.1125;
    }

  TObjArray bjets=getDistributionFromPlotter(algo+"b",baseURL);
  TObjArray lightjets=getDistributionFromPlotter(algo+"light",baseURL);
  
  TH1F *bDisc=(TH1F *) bjets.At(1);
  TH1F *lightDisc=(TH1F *) lightjets.At(1);
  
  setStyle();
  gStyle->SetOptFit(0);

  TCanvas *cnv = getNewCanvas("c","c",false);
  cnv->Clear();
  cnv->SetCanvasSize(1200,1200);
  cnv->SetWindowSize(1200,1200);
  cnv->Divide(2,2);

  //draw the discriminator
  TPad *p = (TPad *)cnv->cd(1); 
  bDisc->SetTitle("b");
  bDisc->SetLineColor(1);
  bDisc->SetMarkerColor(1);
  bDisc->SetMarkerStyle(20);
  bDisc->SetFillStyle(0);
  bDisc->DrawNormalized("histe1");
  lightDisc->SetLineColor(1);
  lightDisc->SetMarkerColor(1);
  lightDisc->SetMarkerStyle(24);
  lightDisc->SetFillStyle(0);
  lightDisc->SetTitle("udcsg");
  lightDisc->DrawNormalized("histe1same");
  TLegend *leg=p->BuildLegend();
  formatForCmsPublic(p,leg,"CMS simulation",2);

  //draw the b/light efficiencies
  p=(TPad *)cnv->cd(2);
  p->SetLogy();
  TGraphAsymmErrors *bEff     = getEfficiencyFrom(bDisc);
  TGraphAsymmErrors *lightEff = getEfficiencyFrom(lightDisc);
  bEff->SetMarkerStyle(20);
  bEff->SetFillStyle(0);
  bEff->Draw("ap");
  bEff->GetXaxis()->SetTitle(bDisc->GetXaxis()->GetTitle());
  bEff->GetYaxis()->SetTitle("Efficiency");
  lightEff->SetMarkerStyle(24);
  lightEff->SetFillStyle(0);
  lightEff->Draw("p");

  //draw relatively to a given working point
  p=(TPad *)cnv->cd(3);
  Double_t baseBEff=bEff->Eval(workPoint);
  TGraphAsymmErrors *relBEff=new TGraphAsymmErrors;
  relBEff->SetMarkerStyle(20);
  relBEff->SetFillStyle(0);
  Double_t baseLightEff=lightEff->Eval(workPoint);
  TGraphAsymmErrors *relLightEff=new TGraphAsymmErrors;
  relLightEff->SetMarkerStyle(24);
  relLightEff->SetFillStyle(0);
  for(int ip=0; ip<bEff->GetN(); ip++)
    {
      Double_t cut, y,ey; 
      bEff->GetPoint(ip,cut,y);     ey = bEff->GetErrorY(ip);
      Double_t relEff(y/baseBEff);
      if(relEff<sfb+2*sfberr && relEff>sfb-2*sfberr)
	{
	  int ipt=relBEff->GetN();
	  relBEff->SetPoint(ipt,cut,relEff);
	  relBEff->SetPointError(ipt,0,0,ey/baseBEff,ey/baseBEff);
	}

      lightEff->GetPoint(ip,cut,y);     ey = lightEff->GetErrorY(ip);
      relEff=y/baseLightEff;
      //      if(relEff<sflight+7*sflighterr && relEff>sflight-7*sflighterr)
      if(relEff<sflight+3*sflighterr && relEff>sflight-3*sflighterr)
	{
	  int ipt=relLightEff->GetN();
	  relLightEff->SetPoint(ipt,cut,relEff);
	  relLightEff->SetPointError(ipt,0,0,ey/baseLightEff,ey/baseLightEff);
	}
    }

  relLightEff->Draw("ap");
  relLightEff->GetXaxis()->SetTitle( bDisc->GetXaxis()->GetTitle() );
  relLightEff->GetYaxis()->SetTitle( "#varepsilon/#varepsilon_{0}" );
  relLightEff->Fit("expo","Q+");
  TF1 *ffunc=relLightEff->GetFunction("expo");
  float newLightCut=(TMath::Log(sflight)-ffunc->GetParameter(0))/ffunc->GetParameter(1);
  float newLightCutErrPlus=(TMath::Log(sflight+sflighterr)-ffunc->GetParameter(0))/ffunc->GetParameter(1)-newLightCut;
//.........这里部分代码省略.........
开发者ID:fedenguy,项目名称:LIPTop,代码行数:101,代码来源:analyzeDistributionsFromPlotter.C

示例4: main


//.........这里部分代码省略.........
  TGraphErrors *gp_Mjj3 = new TGraphErrors(4,x_Mjj,y_Mjj3,ex_Mjj,ey_Mjj3);
  TGraphErrors *gp_MjjF = new TGraphErrors(4,x_Mjj,frac_Mjj,ex_Mjj,efrac_Mjj);
  TGraphErrors *gp_MjjS = new TGraphErrors(4,x_Mjj,y_syst,ex_Mjj,e_syst); // systematic error bands

  TGraphErrors *gp_MET1 = new TGraphErrors(4,x_MET,y_MET1,ex_MET,ey_MET1);
  TGraphErrors *gp_MET2 = new TGraphErrors(4,x_MET,y_MET2,ex_MET,ey_MET2);
  TGraphErrors *gp_MET3 = new TGraphErrors(4,x_MET,y_MET3,ex_MET,ey_MET3);
  TGraphErrors *gp_METF = new TGraphErrors(4,x_MET,frac_MET,ex_MET,efrac_MET);
  TGraphErrors *gp_METS = new TGraphErrors(4,x_MET,y_syst,ex_MET,e_syst); // systematic error bands

  TGraphErrors *gp_CenJetEt1 = new TGraphErrors(4,x_CenJetEt,y_CenJetEt1,ex_CenJetEt,ey_CenJetEt1);
  TGraphErrors *gp_CenJetEt2 = new TGraphErrors(4,x_CenJetEt,y_CenJetEt2,ex_CenJetEt,ey_CenJetEt2);
  TGraphErrors *gp_CenJetEt3 = new TGraphErrors(4,x_CenJetEt,y_CenJetEt3,ex_CenJetEt,ey_CenJetEt3);
  TGraphErrors *gp_CenJetEtF = new TGraphErrors(4,x_CenJetEt,frac_CenJetEt,ex_CenJetEt,efrac_CenJetEt);
  TGraphErrors *gp_CenJetEtS = new TGraphErrors(4,x_CenJetEt,y_syst,ex_CenJetEt,e_syst); // systematic error bands

  TH1D *h_dPhi     = new TH1D("h_dPhi", "", 1, 0, TMath::Pi()); // For axes
  TH1D *h_Mjj      = new TH1D("h_Mjj", "", 1, 800, 3000); // For axes
  TH1D *h_MET      = new TH1D("h_MET", "", 1, 100, 300); // For axes
  TH1D *h_CenJetEt = new TH1D("h_CenJetEt", "", 1, 10, 150); // For axes

  TPaveText *cms = new TPaveText(0.12, 0.68, 0.58 , 0.88, "NDC");
  cms->SetFillColor(0);
  cms->SetFillStyle(4000);
  cms->SetBorderSize(0);
  cms->SetLineColor(0);
  cms->SetTextAlign(12);
  cms->AddText("CMS Preliminary");
  cms->AddText("");
  cms->AddText("#sqrt{s} = 8 TeV L = 19.6 fb^{-1}");
  cms->AddText("");

  TCanvas canvas; 
  canvas.SetCanvasSize(canvas.GetWindowWidth(), 1.2*canvas.GetWindowHeight());

  ///////////////////
  // DPhiJJ graphs //
  ///////////////////
  // Absolute numbers
  gp_dPhi1->SetTitle("");
  gp_dPhi1->SetMarkerStyle(20);
  gp_dPhi1->SetMarkerSize(0.9);
  gp_dPhi1->SetLineColor(kRed);
  gp_dPhi1->SetMarkerColor(kRed);
  gp_dPhi1->GetXaxis()->SetTitle("#Delta #phi_{jj}");
  gp_dPhi1->GetXaxis()->SetRangeUser(0,TMath::Pi());
  gp_dPhi1->GetYaxis()->SetTitle("N(W#rightarrow #tau#nu)");
  gp_dPhi1->GetYaxis()->SetTitleOffset(1.2);
  gp_dPhi1->GetYaxis()->SetRangeUser(0,80);
  gp_dPhi1->Draw("AP");
  gp_dPhi2->SetMarkerStyle(20);
  gp_dPhi2->SetMarkerSize(0.9);
  gp_dPhi2->SetLineColor(kBlue);
  gp_dPhi2->SetMarkerColor(kBlue);
  gp_dPhi2->Draw("P same");
  gp_dPhi3->SetMarkerStyle(20);
  gp_dPhi3->SetMarkerSize(0.9);
  gp_dPhi3->SetLineColor(kViolet);
  gp_dPhi3->SetMarkerColor(kViolet);
  gp_dPhi3->Draw("P same");

  TLegend leg(0.12,0.67,0.32,0.87);
  leg.SetBorderSize(0);
  leg.SetFillColor(0);
  leg.AddEntry(gp_dPhi1,"predicted (data)","P");
  leg.AddEntry(gp_dPhi2,"observed (data)","P");
开发者ID:chayanit,项目名称:InvisibleHiggs,代码行数:67,代码来源:wTauClosureEl.cpp

示例5: electronCompare


//.........这里部分代码省略.........
       }
     }
    if ((histo_new!=0)&&(histo_ref!=0)&&(histo_ref->GetMaximum()>histo_new->GetMaximum()))
     { histo_new->SetMaximum(histo_ref->GetMaximum()*1.1) ; }

    if (histo_new==0)
     {
      web_page<<"No <b>"<<histo_path<<"</b> for "<<CMP_RED_NAME<<".<br>" ;
     }
    else
     {
      // catch n_ele_charge
      if (histo_name=="h_ele_charge")
       { n_ele_charge = histo_new->GetEntries() ; }

      // draw histo_new
      TString newDrawOptions(err==1?"E1 P":"hist") ;
      gErrorIgnoreLevel = kWarning ;
      if (divide!=0)
       {
        num_full = file_new_dir ; num_full += num.c_str() ;
        denom_full = file_new_dir ; denom_full += denom.c_str() ;
        histo_new = DivideHistos(file_new,histo_new,num_full,denom_full) ;
       }
      histo_new->SetLineColor(kRed) ;
      histo_new->SetMarkerColor(2) ;
      histo_new->SetLineWidth(3) ;
      RenderHisto(histo_new,canvas) ;
      histo_new->Draw(newDrawOptions) ;
//	  std::cout << "SIZE : " << canvas->GetWw() << std::endl ; // 796 default
//	  std::cout << "SIZE : " << canvas->GetWh() << std::endl ; // 572 default
      //canvas->Update() ;
	  //canvas->SetWindowSize(440, 600);
	  canvas->SetCanvasSize(960, 600);
      canvas->Update() ;
      st_new = (TPaveStats*)histo_new->FindObject("stats");
      st_new->SetTextColor(kRed) ;

      // draw histo_ref
      if (histo_ref!=0)
       {
        if (divide!=0)
         {
          num_ref = num ;
          denom_ref = denom ;
          if (file_ref_dir.IsNull())
           {
            pos = num_ref.Last('/') ;
            if (pos!=kNPOS) num_ref.Remove(0,pos+1) ;
            pos = denom_ref.Last('/') ;
            if (pos!=kNPOS) denom_ref.Remove(0,pos+1) ;
           }
          histo_ref = DivideHistos(file_ref,histo_ref,file_ref_dir+num_ref,file_ref_dir+denom_ref) ;
         }
        RenderHisto(histo_ref,canvas) ;
        histo_ref->SetLineColor(kBlue) ;
        histo_ref->SetLineWidth(3) ;
        histo_ref->Draw("sames hist") ;
        canvas->Update() ;
        st_ref = (TPaveStats*)histo_ref->FindObject("stats");
        st_ref->SetTextColor(kBlue) ;
        Double_t y1 = st_ref->GetY1NDC() ;
        Double_t y2 = st_ref->GetY2NDC() ;
        st_ref->SetY1NDC(2*y1-y2) ;
        st_ref->SetY2NDC(y1) ;
        //Double_t x1 = st_ref->GetX1NDC() ;
开发者ID:kkiesel,项目名称:cmssw,代码行数:67,代码来源:electronCompare.C

示例6: flagNoiseMatrixGraphs

void flagNoiseMatrixGraphs(TString myFileName){  
gSystem->cd("images/NoiseMatrix");
gSystem->cd(myFileName);

TCanvas *flagNoiseMatrixCanv = new TCanvas("flagNoiseMatrixCanv", "flagNoiseMatrixCanv", 200,10,800,800);
flagNoiseMatrixCanv->SetCanvasSize(1200,800);
flagNoiseMatrixCanv->cd();
flagNoiseMatrixGraph_1D = new TH1F("flagNoiseMatrixGraph_1D", "flagNoiseMatrixGraph_1D", 5, 0, 5);
flagNoiseMatrixGraph_1D->GetYaxis()->SetTitle("Number of flag of each type");
flagNoiseMatrixGraph_1D->GetYaxis()->SetLabelSize(0.035);

TLegend *LegNoiseMatrix = new TLegend(0.7,0.5,0.89,0.7);
LegNoiseMatrix->SetHeader("Noise Matrix Flags Definitions");
LegNoiseMatrix->SetFillColor(0);
LegNoiseMatrix->SetTextSize(0);

Calibration->UseCurrentStyle(); 
Calibration->Draw("flagMatrix>>flagNoiseMatrixGraph_1D"); 

LegNoiseMatrix->AddEntry("", "1: Good");
LegNoiseMatrix->AddEntry("", "2: High Noise");
LegNoiseMatrix->AddEntry("", "3: Low Noise" );
LegNoiseMatrix->Draw("same");

flagNoiseMatrixCanv->Update();

PrintAsGif(flagNoiseMatrixCanv, "flagNoiseMatrixGraph_1D");

///////// CHAMBER flag Graph ///////////////////////
gStyle->SetOptStat(0);
TCanvas *flagNoiseMatrixChamberCanv = new TCanvas("flagNoiseMatrixChamberCanv", "flagNoiseMatrixChamberCanv", 200,10,800,800);
flagNoiseMatrixChamberCanv->SetCanvasSize(1200,800);

//create legend 
TLegend *LegNoiseMatrixChamber = new TLegend(0.85,0.8,0.98,0.98);
LegNoiseMatrixChamber->SetHeader("Noise Matrix Flags Definitions");
LegNoiseMatrixChamber->SetFillColor(0);
LegNoiseMatrixChamber->SetTextSize(0);

//final histogram for display
flagNoiseMatrixGraph_2D_Chamber = new TH2F("flagNoiseMatrixGraph_2D_Chamber", "flagNoiseMatrixGraph_2D_Chamber", 9, 0, 9, 4, 0, 4);
///dummy histo to get bin maximum
flagNoiseMatrixGraph_2D_Chamber0 = new TH2F("flagNoiseMatrixGraph_2D_Chamber0", "flagNoiseMatrixGraph_2D_Chamber0", 9, 0, 9, 4, 0, 4);
//one histo for each flag value. 
flagNoiseMatrixGraph_2D_Chamber1 = new TH2F("flagNoiseMatrixGraph_2D_Chamber1", "flagNoiseMatrixGraph_2D_Chamber1", 9, 0, 9, 4, 0, 4);
flagNoiseMatrixGraph_2D_Chamber2 = new TH2F("flagNoiseMatrixGraph_2D_Chamber2", "flagNoiseMatrixGraph_2D_Chamber2", 9, 0, 9, 4, 0, 4);
flagNoiseMatrixGraph_2D_Chamber3 = new TH2F("flagNoiseMatrixGraph_2D_Chamber3", "flagNoiseMatrixGraph_2D_Chamber3", 9, 0, 9, 4, 0, 4);
flagNoiseMatrixGraph_2D_Chamber4 = new TH2F("flagNoiseMatrixGraph_2D_Chamber4", "flagNoiseMatrixGraph_2D_Chamber4", 9, 0, 9, 4, 0, 4);

//fill completley, get bin maximum, set it for overall graph
Calibration->Project("flagNoiseMatrixGraph_2D_Chamber0", "flagMatrix:cham"); 
Double_t binMaxValCham = flagNoiseMatrixGraph_2D_Chamber0->GetMaximum();
//normalize each box appropriately, with respect to the most filled box
flagNoiseMatrixGraph_2D_Chamber->SetMaximum(binMaxValCham);

//fill each "bin"
Calibration->Project("flagNoiseMatrixGraph_2D_Chamber1","flagMatrix:cham", "flagMatrix==1", "box"); 
Calibration->Project("flagNoiseMatrixGraph_2D_Chamber2","flagMatrix:cham", "flagMatrix==2", "box"); 
Calibration->Project("flagNoiseMatrixGraph_2D_Chamber3","flagMatrix:cham", "flagMatrix==3", "box"); 

//set appropriate colors
flagNoiseMatrixGraph_2D_Chamber1->SetFillColor(1);//Black for eveything is OK
flagNoiseMatrixGraph_2D_Chamber2->SetFillColor(2);//red for VERY BAD
flagNoiseMatrixGraph_2D_Chamber3->SetFillColor(3);//Green for pretty good

int idArray[9];
GetChamberIDs(idArray);
for (int chamNum = 0; chamNum<9; ++chamNum){
int chamNumPlus = chamNum + 1; //for bin access

Int_t chamber_id_int = idArray[chamNum]; //set individual id as int
std::stringstream chamber_id_stream;     //define variable in intermediate format
chamber_id_stream << chamber_id_int;     //convert from int to intermediate "stringstream" format
TString chamber_id_str = chamber_id_stream.str();  //convert from stream into string
 if (chamber_id_str.BeginsWith("220")==0 ){  //binary check, i.e. if the string doesn't begin with 220
   chamber_id_str=0;                         //clean out; set to 0.
 }else{
   chamber_id_str.Remove(8,8);               //remove 0 at end
   chamber_id_str.Remove(0,3);               //remove 220 at beginning 
 }
flagNoiseMatrixGraph_2D_Chamber->GetXaxis()->SetBinLabel(chamNumPlus,chamber_id_str); //set bins to have chamber names
}

flagNoiseMatrixGraph_2D_Chamber->GetYaxis()->SetTitle("Flag");
flagNoiseMatrixGraph_2D_Chamber->GetXaxis()->SetTitle("Chamber");

flagNoiseMatrixChamberCanv->cd();  
//draw original histogram, empty
flagNoiseMatrixGraph_2D_Chamber->Draw("box");
//overlay the individual "bin" graphs
flagNoiseMatrixGraph_2D_Chamber1->Draw("samebox");
flagNoiseMatrixGraph_2D_Chamber2->Draw("samebox");
flagNoiseMatrixGraph_2D_Chamber3->Draw("samebox");
flagNoiseMatrixGraph_2D_Chamber4->Draw("samebox");

//set legend entries appropriately
LegNoiseMatrixChamber->AddEntry(flagNoiseMatrixGraph_2D_Chamber1, "Good", "f");
LegNoiseMatrixChamber->AddEntry(flagNoiseMatrixGraph_2D_Chamber2, "High Noise", "f");
LegNoiseMatrixChamber->AddEntry(flagNoiseMatrixGraph_2D_Chamber3, "Low noise", "f");
LegNoiseMatrixChamber->Draw("same");
//.........这里部分代码省略.........
开发者ID:Andrej-CMS,项目名称:cmssw,代码行数:101,代码来源:noiseMatrixMacro.C

示例7: main


//.........这里部分代码省略.........
  double x1[4]  = {0.5, 1.4, 2.2, 2.6 + (TMath::Pi()-2.6)/2};
  double ex1[4] = {0.5, 0.4, 0.4, (TMath::Pi()-2.6)/2};
  double y1[4],ey1[4],y2[4],ey2[4],y3[4],ey3[4];
  double diff[4],ediff[4];
  double frac[4],efrac[4];
  double y_syst[4],e_syst[4];

  for(int i=0; i<4; ++i) {
        y1[i]  = hZ_Est_WS_DPhi->GetBinContent(i+1);     //Prediction
        ey1[i] = hZ_Est_WS_DPhi->GetBinError(i+1);
        y2[i]  = hZ_Est_ZC_DPhi->GetBinContent(i+1);     //Observation
        ey2[i] = hZ_Est_ZC_DPhi->GetBinError(i+1); 
	y3[i]  = hZ_DY_C_DPhi->GetBinContent(i+1);       //MC Prediction
        ey3[i] = hZ_DY_C_DPhi->GetBinError(i+1);

	diff[i]  = y1[i]-y2[i];
	ediff[i] = sqrt(ey1[i]*ey1[i] + ey2[i]*ey2[i]);
        y_syst[i] = 0.;
        e_syst[i] = 0.21;

	if(y1[i] > 0) frac[i]  = (y1[i]-y2[i])/y2[i];
	efrac[i] = (y1[i]/y2[i])*sqrt(pow(ey1[i]/y1[i],2) + pow(ey2[i]/y2[i],2));
  }

  TGraphErrors *graph1 = new TGraphErrors(4,x1,y1,ex1,ey1);
  TGraphErrors *graph2 = new TGraphErrors(4,x1,y2,ex1,ey2);
  TGraphErrors *graph6 = new TGraphErrors(4,x1,y3,ex1,ey3);
  TGraphErrors *graph3 = new TGraphErrors(4,x1,diff,ex1,ediff);
  TGraphErrors *graph4 = new TGraphErrors(4,x1,frac,ex1,efrac);
  TGraphErrors *graph5 = new TGraphErrors(4,x1,y_syst,ex1,e_syst);
  TH1D *h = new TH1D("h", "", 1, 0, TMath::Pi());

  TCanvas canvas;
  canvas.SetCanvasSize(canvas.GetWindowWidth(), 1.2*canvas.GetWindowHeight());

  graph1->SetTitle("");
  graph1->SetMarkerStyle(20);
  graph1->SetMarkerSize(0.9);
  graph1->SetLineColor(kRed);
  graph1->SetMarkerColor(kRed);  
  graph1->GetXaxis()->SetTitle("#Delta #phi_{jj}");
  graph1->GetXaxis()->SetRangeUser(0,TMath::Pi());
  graph1->GetYaxis()->SetTitle("N(Z#rightarrow #mu#mu)");
  graph1->GetYaxis()->SetRangeUser(0,45);
  graph1->Draw("AP");  
  graph2->SetMarkerStyle(20);
  graph2->SetMarkerSize(0.9);
  graph2->SetLineColor(kBlue);
  graph2->SetMarkerColor(kBlue);
  graph2->Draw("P same");
  graph6->SetMarkerStyle(20);
  graph6->SetMarkerSize(0.9);
  graph6->SetLineColor(kViolet);
  graph6->SetMarkerColor(kViolet);
  graph6->Draw("P same");

  TLegend leg(0.12,0.67,0.37,0.88);
  leg.SetBorderSize(0);
  leg.SetFillColor(0);
  leg.AddEntry(graph1,"predicted (data)","P");
  leg.AddEntry(graph2,"observed (data)","P");
  leg.AddEntry(graph6,"predicted (MC)","P");
  leg.Draw();

  pdfName= oDir + std::string("/Zmumu_num.pdf");
  canvas.Print(pdfName.c_str());
开发者ID:chayanit,项目名称:InvisibleHiggs,代码行数:67,代码来源:zBackground_testC.cpp


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