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


C++ TVirtualPad::SetLogy方法代码示例

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


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

示例1: pHitSpecPos

TCanvas* pHitSpecPos( )
{
  TCanvas* c = new TCanvas("cHitSpecPos","cHitSpecPos",1000,1100);
  c->Divide(2,2);
  TVirtualPad* p; TH2D *h;
  TText t; t.SetTextColor(4);

  p =c->cd(1); p->SetLogy(); p->SetGrid(1,0);
  h = (TH2D*)gROOT->FindObject("hHitSpec_PtVsPhi_BarMinus"); 
  h->GetYaxis()->SetRange(4,33);
  h->DrawCopy("box");
  t.DrawTextNDC(0.17,0.15, "BARREL MU MINUS");

  p =c->cd(2); p->SetLogy(); p->SetGrid(1,0);
  h = (TH2D*)gROOT->FindObject("hHitSpec_PtVsPhi_BarPlus"); 
  h->GetYaxis()->SetRange(4,32);
  h->DrawCopy("box");
  t.DrawTextNDC(0.17,0.15, "BARREL MU PLUS");

  p =c->cd(3); p->SetLogy(); p->SetGrid(1,0);
  h = (TH2D*)gROOT->FindObject("hHitSpec_PtVsPhi_EndMinus"); 
  h->GetYaxis()->SetRange(4,32);
  h->DrawCopy("box");
  t.DrawTextNDC(0.17,0.15, "ENDCAP MU MINUS");

  p =c->cd(4); p->SetLogy(); p->SetGrid(1,0);
  h = (TH2D*)gROOT->FindObject("hHitSpec_PtVsPhi_EndPlus"); 
  h->GetYaxis()->SetRange(4,32);
  h->DrawCopy("box");
  t.DrawTextNDC(0.17,0.15, "ENDCAP MU PLUS");

  return c;
}
开发者ID:konec,项目名称:usercode-L1RpcTriggerAnalysis,代码行数:33,代码来源:plotsHitSpec.C

示例2: plotTrk

void plotTrk() {
  gStyle->SetOptStat(0);
  gStyle->SetOptTitle(1);
  char c[50];
  c1->Clear();  
  c1->Divide(2,3); 
  for(int hid=0; hid<6; hid++){
    TVirtualPad* pad = c1->cd(hid+1); 
    pad->SetLogy(lTrkHist[hid]);
    double xmin, xmax, ymin=0.0, ymax=0.0;
    if(lTrkHist[hid]==1) ymin=0.1;
    for(int quad=0; quad<kFgtNumQuads; quad++){
      sprintf(c,"Quad%1s-%s",cquad[quad],cTrkHist[hid]);
      //printf("Getting %s\n",c);
      TH1F *h = histTrk[quad][hid] = (TH1F*)file->Get(c);
      xmin=h->GetXaxis()->GetXmin();
      xmax=h->GetXaxis()->GetXmax();
      double m=h->GetMaximum();
      if(ymax<m) ymax=m;
      //printf("quad=%d max=%6.1f ymax=%6.1f xmin=%6.1f xmax=%6.1f\n",quad,m,ymax,xmin,xmax);
    }
    ymax*=1.2; if(lTrkHist[hid]==1){ymax*=20.0;}
    sprintf(c,"%s",cTrkHist[hid]);
    TH2F *frame = new TH2F(c,c,1,xmin,xmax,1,ymin,ymax); frame->SetStats(0); frame->Draw();
    for(int quad=0; quad<kFgtNumQuads; quad++){
      TH1F *h=histTrk[quad][hid];
      h->SetLineColor(colorQuad[quad]); h->SetLineWidth(3); 
      if(hid<5){
	h->Draw("SAME");  
	float mean=h->GetMean();
	if(hid==1 || hid==4) {sprintf(c,"%s mean=%6.4f",cquad[quad],mean);}
	else                 {sprintf(c,"%s mean=%6.2f",cquad[quad],mean);}
      }else{
	h->SetMarkerColor(colorQuad[quad]); h->SetMarkerStyle(20); h->SetMarkerSize(1);
	h->Draw("SAME PL");
	sprintf(c,"Quad%s",cquad[quad]);
      }
      TText *t1;
      float x1= 0.2, x2= 0.55;
      float y1=0.8 - 0.07*quad;
      float y2=0.8 - 0.07*(quad-2);
      if(quad<2) { t1 = new TText(x1,y1,c); }
      else       { t1 = new TText(x2,y2,c); }
      t1->SetNDC();
      t1->SetTextSize(0.06); 
      t1->SetTextColor(colorQuad[quad]); 
      t1->Draw();
    }
  }
  c1->Update();
  save("trk");
}
开发者ID:star-bnl,项目名称:star-fgt,代码行数:52,代码来源:makeqaplot.C

示例3: DrawInPad

//#endif
void DrawInPad(TVirtualPad* p,
               Int_t sub,
               TH1* h,
               Bool_t logy=false)
{
  TVirtualPad* pp = p->cd(sub);
  pp->SetRightMargin(0.02);
  if (logy) pp->SetLogy();
  TH1* copy = h->DrawCopy("hist");
  copy->GetXaxis()->SetLabelSize(0.13);
  copy->GetYaxis()->SetLabelSize(0.08);
  copy->SetDirectory(0);
}
开发者ID:XuQiao,项目名称:HI,代码行数:14,代码来源:Analyze.C

示例4: setLogy

/* *********** multi-pad canvases ******************** */
void setLogy(TCanvas *c, bool on = true) {
    c->Modified();
    c->Update();
    //gSystem->ProcessEvents();
    TObject *obj;
    TIter    next(c->GetListOfPrimitives());
    while ((obj = next())) {
      if (obj->InheritsFrom(TVirtualPad::Class())) {
	TVirtualPad *pad = (TVirtualPad*)obj;
	pad->Modified();
	pad->Update();
	pad->SetLogy(on);
	pad->Modified();
	pad->Update();
      }
    }
}
开发者ID:evan-phelps,项目名称:phys-ana-omega,代码行数:18,代码来源:rootutils.C

示例5: Warning

void
TestSPD(const TString& which, Double_t nVar=2)
{
  TFile* file = TFile::Open("forward.root", "READ");
  if (!file) return;

  Bool_t spd = which.EqualTo("spd", TString::kIgnoreCase);
  
  TList* l = 0;
  if (spd) l = static_cast<TList*>(file->Get("CentralSums"));
  else     l = static_cast<TList*>(file->Get("ForwardSums"));
  if (!l) { 
    Warning("", "%sSums not found", spd ? "Central" : "Forward");
    return;
  }

  TList* ei = static_cast<TList*>(l->FindObject("fmdEventInspector"));
  if (!l) { 
    Warning("", "fmdEventInspector not found");
    return;
  }
  
  TObject* run = ei->FindObject("runNo");
  if (!run) 
    Warning("", "No run number found");
  ULong_t runNo = run ? run->GetUniqueID() : 0;

  TH2* h = 0;
  if (spd) h = static_cast<TH2*>(l->FindObject("nClusterVsnTracklet"));
  else { 
    TList* den = static_cast<TList*>(l->FindObject("fmdDensityCalculator"));
    if (!den) { 
      Error("", "fmdDensityCalculator not found");
      return;
    }
    TList* rng = static_cast<TList*>(den->FindObject(which));
    if (!rng) { 
      Error("", "%s not found", which.Data());
      return;
    }
    h = static_cast<TH2*>(rng->FindObject("elossVsPoisson"));
  }
  if (!h) { 
    Warning("", "%s not found", spd ? nClusterVsnTracklet : "elossVsPoisson");
    return;
  }

  gStyle->SetOptFit(1111);
  gStyle->SetOptStat(0);
  TCanvas* c = new TCanvas("c", Form("Run %u", runNo));
  c->Divide(2,2);
  
  TVirtualPad* p = c->cd(1);
  if (spd) {
    p->SetLogx();
    p->SetLogy();
  }
  p->SetLogz();
  h->Draw("colz");

  TObjArray* fits = new TObjArray;
  h->FitSlicesY(0, 1, -1, 0, "QN", fits);

  TF1* mean = new TF1("mean", "pol1");
  TF1* var  = new TF1("var", "pol1");
  // mean->FixParameter(0, 0);
  // var->FixParameter(0, 0);
  for (Int_t i = 0; i < 3; i++) { 
    p = c->cd(2+i);
    if (spd) { 
      p->SetLogx();
      p->SetLogy();
    }
    TH1* hh = static_cast<TH1*>(fits->At(i));
    hh->Draw();

    if (i == 0) continue;
    
    hh->Fit((i == 1? mean : var), "+Q");
    
  }

  TGraphErrors* g1 = new TGraphErrors(h->GetNbinsX());
  g1->SetFillColor(kBlue-10);
  g1->SetFillStyle(3001);
  g1->SetLineStyle(1);
  TGraph* u1 = new TGraph(h->GetNbinsX());
  TGraph* l1 = new TGraph(h->GetNbinsX());
  u1->SetLineColor(kBlue+1);
  l1->SetLineColor(kBlue+1);
  u1->SetName("u1");
  l1->SetName("l1");
  TGraphErrors* g2 = new TGraphErrors(h->GetNbinsX());
  g2->SetFillColor(kRed-10);
  g2->SetFillStyle(3001);
  g2->SetLineStyle(2);
  TGraph* u2 = new TGraph(h->GetNbinsX());
  TGraph* l2 = new TGraph(h->GetNbinsX());
  u2->SetLineColor(kRed+1);
  l2->SetLineColor(kRed+1);
//.........这里部分代码省略.........
开发者ID:ktf,项目名称:AliPhysics,代码行数:101,代码来源:Outliers.C

示例6: MakeIntegerAxis


//.........这里部分代码省略.........
    // Calculate the result 
    TH2D* res = c->Result(correct);
    
    // Now loop and compare 
    Double_t mBase = 0;
    Double_t mPois = 0;
    for (Int_t iEta = 0; iEta < nBin; iEta++) { 
      for (Int_t iPhi = 0; iPhi < nBin; iPhi++) { 
	Double_t p = res->GetBinContent(iEta, iPhi);
	Double_t t = base->GetBinContent(iEta, iPhi);

	mBase += t;
	mPois += p;
	corr->Fill(t, p);
	diff->Fill(p-t);
      }
    }
    Int_t nn = nBin * nBin;
    mean->Fill(mBase / nn, mPois / nn);
  }

  TCanvas* cc = new TCanvas("c", "c", 900, 900);
  cc->SetFillColor(0);
  cc->SetFillStyle(0);
  cc->SetBorderMode(0);
  cc->SetRightMargin(0.02);
  cc->SetTopMargin(0.02);
  cc->Divide(2,2);
  
  TVirtualPad* pp = cc->cd(1);
  pp->SetFillColor(0);
  pp->SetFillStyle(0);
  pp->SetBorderMode(0);
  pp->SetRightMargin(0.15);
  pp->SetTopMargin(0.02);
  pp->SetLogz();
  pp->SetGridx();
  pp->SetGridy();
  corr->Draw();
  lcorr->Draw();

  pp = cc->cd(2);
  pp->SetFillColor(0);
  pp->SetFillStyle(0);
  pp->SetBorderMode(0);
  pp->SetRightMargin(0.02);
  pp->SetTopMargin(0.02);
#if 0
  c->GetMean()->Draw();
#elif 1 
  pp->SetLogy();
  diff->Draw();
#elif 1
  c->GetOccupancy()->Draw();
#else
  pp->SetLogy();
  dist->SetStats(0);
  dist->Scale(1. / dist->Integral());
  dist->Draw();
  TH1D* m1 = c->GetMean();
  m1->Scale(1. / m1->Integral());
  m1->Draw("same");
  Double_t eI;
  Double_t ii = 100 * dist->Integral(2, 0);
  TLatex* ll = new TLatex(.97, .85, 
			  Form("Input #bar{m}: %5.3f", mp));
  ll->SetNDC();
  ll->SetTextFont(132);
  ll->SetTextAlign(31);
  ll->Draw();
  ll->DrawLatex(.97, .75, Form("Result #bar{m}: %5.3f", dist->GetMean()));
  ll->DrawLatex(.97, .65, Form("Occupancy: #int_{1}^{#infty}P(s)ds = %6.2f%%",
			       ii));
			 
#endif

  pp = cc->cd(3);
  pp->SetFillColor(0);
  pp->SetFillStyle(0);
  pp->SetBorderMode(0);
  pp->SetRightMargin(0.15);
  pp->SetTopMargin(0.02);
  pp->SetGridx();
  pp->SetGridy();
  c->GetCorrection()->Draw();

  pp = cc->cd(4);
  pp->SetFillColor(0);
  pp->SetFillStyle(0);
  pp->SetBorderMode(0);
  pp->SetRightMargin(0.15);
  pp->SetTopMargin(0.02);
  pp->SetLogz();
  pp->SetGridx();
  pp->SetGridy();
  mean->Draw();
  lmean->Draw();

  cc->cd();
}
开发者ID:ktf,项目名称:AliPhysics,代码行数:101,代码来源:TestPoisson.C

示例7: makeqaplot

void makeqaplot(int run=0, int plt=0, int save=0){
  runnum=run;
  yearday=run/1000;
  if(save==0) {png=0; pdf=0;}
  if(save==1) {png=1; pdf=0;}
  if(save==2) {png=0; pdf=1;}
  if(save==3) {png=1; pdf=1;}

  c1 = new TCanvas("c1","QA",50,50,800,800);
  gStyle->SetLabelSize(0.04,"xy");
  //colortable();
  gStyle->SetPalette(1);
  gStyle->SetStatW(0.4);

  char fname[50];
  if(run==0) {sprintf(fname,"fgtQA.root");}
  else {sprintf(fname,"%d/fgtQA_%d.root",yearday,run);}

  cout << "Opening "<<fname<<endl;
  file=new TFile(fname,"");

  char c[50];
  if(plt==0 || plt==1) {
    gStyle->SetOptStat(111110);
    c1->Divide(1,3); 
    for(int i=0; i<3; i++){
      TVirtualPad* pad = c1->cd(i+1);
      int log=0;
      if(i>0) {log=1;} 
      pad->SetLogy(log); 
      hist0[i]=(TH1F*) file->Get(cHist[i]);
      hist0[i]->SetFillColor(kBlue); 
      hist0[i]->Draw();
      if(i==2){
	float ntot  = float(hist0[i]->GetEntries());
	if(ntot>0.0){
	  int    nbin = hist0[i]->GetNbinsX();
	  float nofgt = hist0[i]->Integral(1,1);	
	  int     bin = hist0[i]->FindBin(float(kFgtNumElecIds));
	  float nonzs = hist0[i]->Integral(bin-1,nbin+1);
	  float    zs = hist0[i]->Integral(2,bin-2);
	  hist0[i]->GetXaxis()->SetRange(2, bin-2);
	  float mean =  hist0[i]->GetMean() / float(kFgtNumElecIds);
	  char c[100];
	  sprintf(c,"Total  %d",ntot);                         TText *t1 = new TText(0.3,0.8,c); t1->SetNDC(); t1->SetTextSize(0.06); t1->Draw();
	  sprintf(c,"NoFGT  %d (%5.2f)",nofgt,nofgt/ntot);     TText *t2 = new TText(0.3,0.7,c); t2->SetNDC(); t2->SetTextSize(0.06); t2->Draw();
	  sprintf(c,"NoneZS %d (%5.2f)",nonzs,nonzs/ntot);     TText *t3 = new TText(0.3,0.6,c); t3->SetNDC(); t3->SetTextSize(0.06); t3->Draw();
	  sprintf(c,"ZS     %d (%5.2f)",zs,zs/ntot);           TText *t4 = new TText(0.3,0.5,c); t4->SetNDC(); t4->SetTextSize(0.06); t4->Draw();
	  sprintf(c,"Mean ZS data size/fullsize= %5.3f",mean); TText *t5 = new TText(0.3,0.4,c); t5->SetNDC(); t5->SetTextSize(0.06); t5->Draw();
	  if(mean>0.08) { t5->SetTextColor(2); }
	  else          { t5->SetTextColor(4); }
	}
      }
    }
    c1->Update();
    save("plot");
  }  
  if(plt==0 || plt==2) {
    c1->Clear();
    gStyle->SetOptStat(0);
    gStyle->SetOptTitle(0);
    c1->Divide(1,3);
    for(int i=3; i<6; i++){ hist0[i]=(TH1F*) file->Get(cHist[i]); }
    int nevt=hist0[5]->GetEntries();
    printf("Nevent=%d\n",nevt);
    TVirtualPad* pad;
    pad=c1->cd(1); pad->SetLogy(); pad->SetTopMargin(0.01); pad->SetRightMargin(0.01);
    hist0[3]->GetXaxis()->SetLabelSize(0.07); hist0[3]->GetYaxis()->SetLabelSize(0.07);     
    hist0[3]->SetFillColor(kRed);  hist0[3]->Scale(1/float(nevt)); hist0[3]->Draw();
    TText *tx= new TText(0.87,0.0,"EleID"); tx->SetNDC(); tx->SetTextSize(0.1); tx->Draw();
    TText *t3= new TText(0.05,0.1,"F3=frac in 3sig/2tb"); t3->SetNDC(); t3->SetTextSize(0.08); t3->SetTextAngle(90); t3->Draw();

    pad=c1->cd(2); pad->SetLogy(); pad->SetTopMargin(0.01); pad->SetRightMargin(0.01);
    hist0[4]->GetXaxis()->SetLabelSize(0.07); hist0[4]->GetYaxis()->SetLabelSize(0.07); 
    hist0[4]->SetFillColor(kBlue); hist0[4]->Scale(1/float(nevt)); hist0[4]->Draw(); 
    tx->Draw();
    TText *t4= new TText(0.05,0.1,"F10=frac in 10sig & >500"); t4->SetNDC(); t4->SetTextSize(0.08); t4->SetTextAngle(90); t4->Draw();

    float min=-4;
    int max=hist0[3]->GetNbinsX();
    printf("Max=%d\n",max);
    TH1F *h1 = new TH1F("ZSdataFrac","ZSdataFrac",50,min,0);
    TH1F *h2 = new TH1F("10SigmaFrac","10SigmaFrac",50,min,0);
    float f1[kFgtNumElecIds],f2[kFgtNumElecIds];
    for(int i=0; i<max; i++){
      f1[i] = log10(hist0[3]->GetBinContent(i+1)); if(f1[i]<min) {f1[i]=min;} h1->Fill(f1[i]);
      f2[i] = log10(hist0[4]->GetBinContent(i+1)); if(f2[i]<min) {f2[i]=min;} h2->Fill(f2[i]);
    }
    pad = c1->cd(3); pad->Divide(2,1);
    TVirtualPad *pad2;
    pad2 = pad->cd(1);
    pad2->SetLogy(); pad2->SetTopMargin(0.01); pad2->SetRightMargin(0.01);
    h1->GetXaxis()->SetLabelSize(0.1); h1->GetYaxis()->SetLabelSize(0.1);
    h2->GetXaxis()->SetLabelSize(0.1); h2->GetYaxis()->SetLabelSize(0.1);
    h1->SetLineColor(kRed);  h2->SetLineColor(kBlue); 
    if(h1->GetMaximum()>h2->GetMaximum()){
      h1->Draw(); h2->Draw("SAME");
    }else{
      h2->Draw(); h1->Draw("SAME");
    }
//.........这里部分代码省略.........
开发者ID:star-bnl,项目名称:star-fgt,代码行数:101,代码来源:makeqaplot.C

示例8: mc2ibd_gtDiff

void mc2ibd_gtDiff(TChain *tMC, TFile *fBgnd, TCanvas *cv, const char *pdfname)
{
	char str[1024];
	TLatex *txt = new TLatex();
	TVirtualPad *pd;

	TH1D *hExp = (TH1D *) fBgnd->Get("hgtDiffA-diff");
	if (!hExp) {
		printf("Histogram hgtDiffA-diff not found in %s\n", fBgnd->GetName());
		return;
	}
	hExp->SetTitle("Time between prompt and delayed events (IBD);us;Events/us");
	hExp->SetLineColor(kBlack);
	hExp->SetMinimum(0);

	gROOT->cd();
	TH1D *hMC = new TH1D("hgtDiffMC", "Time between prompt and delayed events (MC);us;Events/us", 50, 0, 50);
	hMC->SetLineColor(kBlack);
	tMC->Project(hMC->GetName(), "gtDiff", cX && cY && cZ && cR && cGamma && cGammaMax && cPe && cN);
	hMC->Sumw2();
	hMC->Scale(hExp->Integral(2,50) / hMC->Integral(2,50));
//		Exp vs MC
	cv->Clear();
	cv->Divide(1, 2);
	cv->cd(1);
	hExp->SetLineColor(kBlack);
	hExp->SetLineWidth(3);
	hMC->SetLineColor(kBlue);
	hMC->SetLineWidth(1);
	hExp->Draw();
	hMC->Draw("hist,same");
	TLegend *lg = new TLegend(0.15, 0.2, 0.4, 0.35);
	lg->AddEntry(hExp, "IBD", "LE");
	lg->AddEntry(hMC, "MC", "L");
	lg->Draw();

	pd = cv->cd(2);
	hExp->SetMinimum(2000);
	hExp->Draw();
	hMC->Draw("hist,same");
	lg->Draw();
	pd->SetLogy(1);
	cv->Update();
	cv->SaveAs(pdfname);
	hExp->SetMinimum(0);
	hExp->SetLineWidth(1);
	hMC->SetLineColor(kBlack);
	
//		Fits
	TF1 *f2Exp = new TF1("f2Exp", "[0]*(exp(-x/[1]) - exp(-x/[2]))", 0, 100);
	f2Exp->SetParNames("Const.", "#tau_{capt}", "#tau_{th}");
	f2Exp->SetLineColor(kBlue);
	
	TF1 *fExp = new TF1("fExp", "expo", 0, 100);
	fExp->SetLineColor(kRed);
	
	cv->Clear();
	cv->Divide(1, 2);
	cv->cd(1);
	f2Exp->SetParameters(hExp->GetMaximum(), 13, 5);
	hExp->Fit(f2Exp, "", "", 1, 50);
	hExp->Fit(fExp, "+", "", 15, 50);
	lg = new TLegend(0.15, 0.2, 0.4, 0.35);
	lg->AddEntry(hExp, "Data", "LE");
	lg->AddEntry(f2Exp, "Fit with two exponents", "L");
	lg->AddEntry(fExp, "Capture exponent fit", "L");
	lg->Draw();
	sprintf(str, "#tau_{capt}=%5.2f us", -1/fExp->GetParameter(1));
	txt->DrawLatex(20, hExp->GetMaximum()/5, str);
	sprintf(str, "#chi^{2}/NDF=%6.1f/34", fExp->GetChisquare());
	txt->DrawLatex(20, hExp->GetMaximum()/10, str);
	
	cv->cd(2);
	f2Exp->SetParameters(hMC->GetMaximum(), 13, 5);
	hMC->Fit(f2Exp, "", "", 1, 50);
	hMC->Fit(fExp, "+", "", 15, 50);
	lg->Draw();
	sprintf(str, "#tau_{capt}=%5.2f us", -1/fExp->GetParameter(1));
	txt->DrawLatex(20, hMC->GetMaximum()/5, str);
	sprintf(str, "#chi^{2}/NDF=%6.1f/34", fExp->GetChisquare());
	txt->DrawLatex(20, hMC->GetMaximum()/10, str);
	cv->SaveAs(pdfname);
//		Tha same in log scale
	hExp->SetMinimum(2000);
	cv->Clear();
	cv->Divide(1, 2);
	pd = cv->cd(1);
	hExp->Draw();
	lg->Draw();
	pd->SetLogy(1);
	
	pd = cv->cd(2);
	hMC->Draw();
	lg->Draw();
	pd->SetLogy(1);
	cv->Update();
}
开发者ID:lab305itep,项目名称:digi,代码行数:97,代码来源:mc2ibd.C

示例9: compareNtuples


//.........这里部分代码省略.........
    if( branchname.Contains("LorentzVector") ) {
      histname = "h1_"+ alias + "_pt";
      command  = alias + ".Pt()>>" + histname;      
    }
    tree1->Draw(command.Data());
    TH1F *h1 = (TH1F*)gDirectory->Get(histname.Data());
    if(h1==NULL) {
      cout << "********** Branch " << v1_notCommonBranches.at(i) 
	   << " in file " << file1 << "exists, but is undrawable for some reason. " 
	   << "Skipping this branch" << endl;
      c1->Clear();
      continue; 
    }
    c1->Clear();

    if(drawWithErrors)
      h1->TH1F::Sumw2();
    

    h1->Scale(1./h1->GetEntries());
    if(!drawWithErrors) {
      h1->SetLineColor(0);
      h1->SetMarkerSize(1.1);
      h1->SetMarkerStyle(3);
    } else {
      h1->SetMarkerSize(1.3);
      h1->SetMarkerStyle(3);
    }
    
    TString histtitle = alias + ", " + fname1;
    h1->SetTitle(histtitle.Data());
    h1->Draw();
    c1->SaveAs("diff.ps(");
    c1->SetLogy();
    
    //if the canvas has been divided, want to set the logy
    for(int ii = 0; ii < c1->GetListOfPrimitives()->GetSize(); ii++) {
      if(string(c1->GetListOfPrimitives()->At(ii)->ClassName()) != "TVirtualPad")
	continue;
      TVirtualPad *vPad = (TVirtualPad*)(c1->GetListOfPrimitives()->At(ii));
      if(vPad != NULL) {
	vPad->SetLogy();
      }
    }
    c1->SaveAs("diff.ps(");
    c1->SetLogy(0);
  }

  for(unsigned int i = 0; i < v2_notCommonBranches.size(); i++) {
    
    TString alias = v2_notCommonBranches.at(i);
    cout << "Branch: " << alias << " was found in " 
	 << file1 << " but not in " << file2 << endl;
    TString histname = "h2_"+(alias);
    TString command  = (alias) + ">>" + histname;
    TBranch *branch = tree2->GetBranch(tree2->GetAlias(alias));
    TString branchname(branch->GetName());
    
    if( branchname.Contains("LorentzVector") ) {
      histname = "h2_"+ alias + "_pt";
      command  = alias + ".Pt()>>" + histname;      
    }
    tree2->Draw(command.Data());
    TH1F *h2 = (TH1F*)gDirectory->Get(histname.Data());
    if(h2==NULL) {
      cout << "********** Branch " << v2_notCommonBranches.at(i) 
开发者ID:cmstas,项目名称:Tools-run1,代码行数:67,代码来源:compareNtuples.C

示例10: validation


//.........这里部分代码省略.........
		if(it->first=="2000")
		{
			legMap[it->first]->AddEntry(h1Template,"ME^{2} method: Template histogram at  #it{g=1} (SSM)","lep");
			legMap[it->first]->AddEntry(graphSSM,  "ME^{2} method: Template function  at  #it{g=1} (SSM)","p");
			legMap[it->first]->AddEntry(graphDY,   "ME^{2} method: Template function  at  #it{g=0} (DY)","p");
		}
		if(!doTruth)
		{
			h1dTlvTmpltMap[it->first]->SetLineColor(kCyan+2);
			h1dTlvTmpltMap[it->first]->SetMarkerColor(kCyan+2);
			h1dTlvTmpltMap[it->first]->SetMarkerStyle(5);
			h1dTlvTmpltMap[it->first]->SetMarkerSize(0.5);
			legMap[it->first]->AddEntry(h1dTlvTmpltMap[it->first],"ME^{2} method: DY+Template (no interference)","p");
		
			h1dBrandeisTmpltMap[it->first]->SetLineColor(kRed);
			h1dBrandeisTmpltMap[it->first]->SetMarkerColor(kRed);
			h1dBrandeisTmpltMap[it->first]->SetMarkerStyle(27);
			h1dBrandeisTmpltMap[it->first]->SetMarkerSize(0.5);
			legMap[it->first]->AddEntry(h1dBrandeisTmpltMap[it->first],"Flat Z' method: DY+Template (no interference)","p");
		}

		it->second->Divide(1,2);
		TVirtualPad* ph = it->second->cd(1);
		TVirtualPad* pr = it->second->cd(2);	
		ph->SetPad(0.00, 0.35, 1.00, 1.00);
		pr->SetPad(0.00, 0.00, 1.00, 0.35);
		ph->SetBottomMargin(0.012);
		pr->SetBottomMargin(0.20);
		pr->SetTopMargin(0.012);
		
		ph->cd();
		ph->Draw();
		ph->SetTicks(1,1);
		ph->SetLogy();
		ph->SetLogx();
		// h1Map[it->first+"o"]->SetMaximum( h1Map[it->first+"t"]->GetMaximum()*1.5 );
		// h1Map[it->first+"o"]->Draw();
		TH1D* hTmpNoErr = (TH1D*)resetErrors(h1Map[it->first+"o"])->Clone();
		hTmpNoErr->SetMaximum( h1Map[it->first+"t"]->GetMaximum()*1.5 );
		hTmpNoErr->SetLineStyle(1);
		hTmpNoErr->SetLineColor(kBlack);
		hTmpNoErr->SetFillColor(kAzure-9);
		hTmpNoErr->Draw();
		TH1D* hTmpErr = (TH1D*)ShiftLog(h1Map[it->first+"o"],0.2)->Clone();
		hTmpErr->SetFillStyle(4000); //will be transparent
		hTmpErr->SetFillColor(0);
		hTmpErr->DrawCopy("epx0SAMES");
		hDY->Draw("SAMES");
		h1Map[it->first+"t"]->Draw("epSAMES");
		//poissonGraphMap[it->first]->Draw("pSAMES");
		if(it->first=="2000")
		{
			graphDY->Draw("SAMESp");
			graphSSM->Draw("SAMESp");
			h1Template->Draw("epSAMES");
		}
		_INFO("");
		h1dTlvTmpltMap[it->first]->Draw("SAMESp");
		h1dBrandeisTmpltMap[it->first]->Draw("SAMESp");
		
		TLine* chopline = new TLine(0.12805,getYmin(h1Map[it->first+"o"]),0.12805,7.e5);
		chopline->SetLineStyle(2);
		chopline->SetLineColor(kBlack);
		chopline->Draw("SAMES");
		ptxt->Draw("SAMES");
		
开发者ID:noamhod,项目名称:KK.7TeV,代码行数:66,代码来源:validation.C

示例11: FinishRun

//______________________________________________________________________________
void CMSApplicationTBB::FinishRun() {
#ifdef USE_ROOT
  if (fScore == kNoScore)
    return;
  TCanvas *c1 = new TCanvas("CMS test flux", "Simple scoring in CMS geometry", 700, 1200);
  double norm = 1. / fRunMgr->GetNprimaries();
  TVirtualPad *pad;
  TFile *f = TFile::Open("ScoreECAL.root", "RECREATE");
  c1->Divide(2, 3);
  pad = c1->cd(1);
  pad->SetLogx();
  pad->SetLogy();
  fFluxElec->Sumw2();
  fFluxElec->Scale(norm);
  fFluxElec->Draw("9");
  pad = c1->cd(2);
  pad->SetLogx();
  pad->SetLogy();
  fFluxGamma->Sumw2();
  fFluxGamma->Scale(norm);
  fFluxGamma->Draw("9");
  pad = c1->cd(3);
  pad->SetLogx();
  pad->SetLogy();
  fFluxP->Sumw2();
  fFluxP->Scale(norm);
  fFluxP->Draw("9");
  pad = c1->cd(4);
  pad->SetLogx();
  pad->SetLogy();
  fFluxPi->Sumw2();
  fFluxPi->Scale(norm);
  fFluxPi->Draw("9");
  pad = c1->cd(5);
  pad->SetLogx();
  pad->SetLogy();
  fFluxK->Sumw2();
  fFluxK->Scale(norm);
  fFluxK->Draw("9");
  fFluxElec->Write();
  fFluxGamma->Write();
  fFluxP->Write();
  fFluxPi->Write();
  fFluxK->Write();

  TCanvas *c2 = new TCanvas("CMS test edep", "Simple scoring in CMS geometry", 700, 1200);
  c2->Divide(2, 3);
  pad = c2->cd(1);
  pad->SetLogx();
  pad->SetLogy();
  fEdepElec->Sumw2();
  fEdepElec->Scale(norm);
  fEdepElec->Draw("9");
  pad = c2->cd(2);
  pad->SetLogx();
  pad->SetLogy();
  fEdepP->Sumw2();
  fEdepP->Scale(norm);
  fEdepP->Draw("9");
  pad = c2->cd(3);
  pad->SetLogx();
  pad->SetLogy();
  fEdepPi->Sumw2();
  fEdepPi->Scale(norm);
  fEdepPi->Draw("9");
  pad = c2->cd(4);
  pad->SetLogx();
  pad->SetLogy();
  fEdepK->Sumw2();
  fEdepK->Scale(norm);
  fEdepK->Draw("9");
  pad = c2->cd(5);
  pad->SetLogx();
  pad->SetLogy();
  fEdepGamma->Sumw2();
  fEdepGamma->Scale(norm);
  fEdepGamma->Draw("9");
  fEdepElec->Write();
  fEdepGamma->Write();
  fEdepP->Write();
  fEdepPi->Write();
  fEdepK->Write();

  // Close file
  f->Close();
#endif
}
开发者ID:mrguilima,项目名称:toy-mt-framework,代码行数:88,代码来源:CMSApplicationTBB.cpp

示例12: pHitSpecPosGen

TCanvas* pHitSpecPosGen( )
{
  TCanvas* c = new TCanvas("cHitSpecPosGen","cHitSpecPosGen",1200,600);
  c->Divide(2,1);
  TVirtualPad* p; TH2D *h; TH2D *hAtPhi0;
  TText t; t.SetTextColor(4);

  p =c->cd(1); p->SetLogy(); p->SetGrid(0,1);
  h = (TH2D*)gROOT->FindObject("hHitSpec_PtVsPhiGen_Minus"); 
  hAtPhi0 = (TH2D*)gROOT->FindObject("hHitSpec_PtVsPhiGenAtPhi0_Minus"); 
  h->GetYaxis()->SetRange(4,33);
  h->GetXaxis()->SetNdivisions(505); h->GetXaxis()->SetLabelSize(0.04);
  h->DrawCopy("box");
  hAtPhi0->SetLineColor(2);
  hAtPhi0->DrawCopy("box same");
  t.DrawTextNDC(0.17,0.15, "BARREL MU MINUS");
  std::cout <<h->GetTitle() << std::endl;
  for (int iy = 1; iy <=h->GetNbinsY(); iy++) {
  std::cout <<" pt: " << h->GetYaxis()->GetBinLowEdge(iy);
  double xmin=100.;
  double xAtMax = 0.; double valAtMax = 0.;
  double xmax=-100.;
  for (int ix = 1; ix <=h->GetNbinsX(); ix++) {
     double val = h->GetBinContent(ix,iy); 
     double xbmin = h->GetXaxis()->GetBinLowEdge(ix);
     double xcent = h->GetXaxis()->GetBinCenter(ix);
     double xbmax = h->GetXaxis()->GetBinUpEdge(ix);
     if (val > valAtMax) { valAtMax = val; xAtMax = xcent; }
     if (val > 1 && (xbmin < xmin)) xmin = xbmin;    
     if (val > 1 && (xbmax > xmax)) xmax = xbmax;    
  }
  std::cout <<"  set DPHI0 = "<<1.025-xAtMax 
            <<"; set DPHI_MARGIN = " <<std::max( (xAtMax-xmin), (xmax-xAtMax))
<<";" << std::endl;
  }

  p =c->cd(2); p->SetLogy(); p->SetGrid(1,1);
  h = (TH2D*)gROOT->FindObject("hHitSpec_PtVsPhiGen_Plus"); 
  hAtPhi0 = (TH2D*)gROOT->FindObject("hHitSpec_PtVsPhiGenAtPhi0_Plus"); 
  h->GetYaxis()->SetRange(4,32);
  h->GetXaxis()->SetNdivisions(505); h->GetXaxis()->SetLabelSize(0.04);
  h->DrawCopy("box");
  hAtPhi0->SetLineColor(2);
  hAtPhi0->DrawCopy("box same");
  t.DrawTextNDC(0.17,0.15, "BARREL MU PLUS");
  std::cout <<h->GetTitle() << std::endl;
  for (int iy = 1; iy <=h->GetNbinsY(); iy++) {
  std::cout <<" pt: " << h->GetYaxis()->GetBinLowEdge(iy);
  double xmin=100.;
  double xAtMax = 0.; double valAtMax = 0.;
  double xmax=-100.;
  for (int ix = 1; ix <=h->GetNbinsX(); ix++) {
     double val = h->GetBinContent(ix,iy); 
     double xbmin = h->GetXaxis()->GetBinLowEdge(ix);
     double xcent = h->GetXaxis()->GetBinCenter(ix);
     double xbmax = h->GetXaxis()->GetBinUpEdge(ix);
     if (val > valAtMax) { valAtMax = val; xAtMax = xcent; }
     if (val > 1 && (xbmin < xmin)) xmin = xbmin;    
     if (val > 1 && (xbmax > xmax)) xmax = xbmax;    
  }
  std::cout <<"  set DPHI0 = "<<1.025-xAtMax 
            <<"; set DPHI_MARGIN = " <<std::max( (xAtMax-xmin), (xmax-xAtMax))
<<";" << std::endl;
  }

  return c;
}
开发者ID:konec,项目名称:usercode-L1RpcTriggerAnalysis,代码行数:67,代码来源:plotsHitSpec.C

示例13: EstimateBg_76X


//.........这里部分代码省略.........
      TH1D *h_side = (TH1D*)can->GetListOfPrimitives()->At(i_h_side[iMethod]);
      TH1D *h_signal = (TH1D*)can->GetListOfPrimitives()->At(i_h_signal[iMethod]);
      // Simulate different cross section by scaling a certain background
      if (iMethod==1) {
        TH1D *h_side_temp_scaled = (TH1D*)h_side->Clone(); h_side_temp_scaled->Scale(scale_factors[iSample]);
        TH1D *h_signal_temp_scaled = (TH1D*)h_signal->Clone(); h_signal_temp_scaled->Scale(scale_factors[iSample]);
        if (iSample==0) {
          h_side_sum = h_side_temp_scaled;
          h_signal_sum = h_signal_temp_scaled;
        } else {
          h_side_sum->Add(h_side_temp_scaled);
          h_signal_sum->Add(h_signal_temp_scaled);
        }
      } else if (iMethod==2) {
        h_side = h_side_sum;
        h_signal = h_signal_sum;
      }
      TH1D *h_pred =(TH1D*)h_side->Clone();
      if (iMethod!=0&&rebin>1) { h_side->Rebin(rebin); h_signal->Rebin(rebin); h_pred->Rebin(rebin); }
      TLegend *leg = (TLegend*)can->GetListOfPrimitives()->At(can->GetListOfPrimitives()->GetEntries()-1);
      leg->SetX1(0.35); leg->SetX2(0.65); leg->SetY1(0.6);
      
      // Add ratio plot
      int y1 = 350;
      int y2 = 150;
      int mid2 = 10;
      can->Divide(1,2);
      // Pad 1 (80+500+20 x 40+500)
      TVirtualPad* p = can->cd(1);
      p->SetPad(0,(y2+60+mid2)/(y1+y2+100.0+mid2),1,1);
      p->SetTopMargin(40.0/(y1+40));
      p->SetBottomMargin(0);
      p->SetRightMargin(0.05);
      p->SetLogy(1);
      h_side->GetYaxis()->SetRangeUser(1.00001e-4,1e4);
      h_side->Draw("HIST");
      h_signal->Draw("SAMEHISTE1");
      leg->Draw();
      // Pad 2 (80+500+20 x 200+60)
      p = can->cd(2);
      p->SetGrid(0,1);
      p->SetPad(0,0,1,(y2+60+mid2)/(y1+y2+100.0+mid2));
      p->SetTopMargin(((float)mid2)/(y2+60+mid2));
      p->SetBottomMargin(60.0/(y2+60+mid2));
      p->SetRightMargin(0.05);
      TH1D* ratio = (TH1D*)h_signal->Clone();
      TH1D* div = (TH1D*)h_side->Clone();
      //ratio->Scale(1/ratio->GetSumOfWeights());
      double sum_bins_ratio = iMethod==0 ? ratio->Integral():
	ratio->Integral(ratio->FindBin(R_CUT_LOW),ratio->FindBin(Rranges_ABCD[iMethod][3]));
      ratio->Scale(1/sum_bins_ratio);
      ratio->SetTitleSize(32.0/(y2+60+mid2),"xyz");
      ratio->SetLabelSize(20.0/(y2+60+mid2),"xyz");
      //ratio->Scale(1/div->GetSumOfWeights());
      double sum_bins_div = iMethod==0 ? div->Integral():
	div->Integral(div->FindBin(R_CUT_LOW),div->FindBin(Rranges_ABCD[iMethod][3]));
      div->Scale(1/sum_bins_div);
      ratio->Divide(div);
      //ratio->GetYaxis()->SetRangeUser(0,2);
      ratio->GetXaxis()->SetTitleOffset(0.7);
      ratio->GetYaxis()->SetNdivisions(305);
      ratio->GetYaxis()->SetTitle("Ratio (Norm.)");
      ratio->GetYaxis()->SetTitleOffset(0.4);
      ratio->SetTitleSize(24.0/(y2+60+mid2),"y");
      ratio->SetTitle("");
      ratio->SetMarkerStyle(20);
开发者ID:jkarancs,项目名称:BoostedRazorAnalysis,代码行数:67,代码来源:EstimateBg_76X.C

示例14: DrawTwoInPad

void DrawTwoInPad(TVirtualPad* p,
                  Int_t        sub,
                  TH1*         h1,
                  TH1*         h2,
		  Bool_t       ratio,
		  Bool_t       logy=false,
		  Bool_t       legend=false)
{
  TVirtualPad* pp = p->cd(sub);
  pp->SetRightMargin(0.02);
  pp->SetLeftMargin(0.10);
  TVirtualPad* ppp = pp;
  if (ratio) {
    pp->Divide(1,2,0,0);
    ppp = pp->cd(1);				
    ppp->SetRightMargin(0.02);
  }
  if (logy) ppp->SetLogy();
  TH1* hs[] = { h1, h2, 0 };
  if (h1->GetMaximum() < h2->GetMaximum()) {
    hs[0] = h2;
    hs[1] = h1;
  }
  TH1** ph = hs;
  Double_t size = (ratio ? 0.1 : 0.05);
  Double_t off  = (ratio ? 0.6 : 0.5);
  h1->SetFillStyle(3004);
  h2->SetFillStyle(3005);
  while (*ph) {
    TString opt("hist");
    if (ph != hs) opt.Append(" same");

    TH1* copy = (*ph)->DrawCopy(opt);
    copy->GetXaxis()->SetLabelSize(2*size);
    copy->GetYaxis()->SetLabelSize(size);
    copy->GetYaxis()->SetTitleSize(size);
    copy->GetYaxis()->SetTitleOffset(off);
    copy->SetYTitle(copy->GetTitle());
    copy->SetTitle("");
    copy->SetDirectory(0);
    ph++;
  }
  TString s1 = h1->GetYaxis()->GetTitle();
  TString s2 = h2->GetYaxis()->GetTitle();
  
  if (legend) { 
    TLegend* l = new TLegend(0.6, 0.1, 0.9, 0.9);
    l->SetBorderSize(0);
    TLegendEntry* e = l->AddEntry("dummy", s1, "lf");
    l->SetFillColor(kWhite);
    e->SetFillColor(kBlack);
    e->SetFillStyle(h1->GetFillStyle());
    e = l->AddEntry("dummy", s2, "lf");
    e->SetFillColor(kBlack);
    e->SetFillStyle(h2->GetFillStyle());
    l->Draw();
  }
  if (!ratio) return;
  ppp = pp->cd(2);
  ppp->SetRightMargin(0.02);
  TH1* r = static_cast<TH1*>(h1->Clone(Form("ratio%s", h1->GetName())));
  r->SetDirectory(0);
  r->SetTitle("");
  r->GetXaxis()->SetLabelSize(size);
  r->GetYaxis()->SetLabelSize(size);
  r->GetYaxis()->SetTitleSize(0.9*size);
  r->GetYaxis()->SetTitleOffset(0.9*off);
  r->SetMarkerStyle(20);
  r->SetMarkerColor(h1->GetFillColor()+1);
  r->SetFillStyle(3007);
  r->SetYTitle(Form("#frac{%s}{%s}", s1.Data(), s2.Data()));

  // r->Add(h2, -1);
  // r->Divide(h1);
  if (!r->IsA()->InheritsFrom(TProfile::Class())) {
    r->GetSumw2()->Set(0); // r->Sumw2(false);
    h2->GetSumw2()->Set(0); // h2->Sumw2(false);
  }
  r->Divide(h2);
  Printf("%s", r->GetName());
  for (UShort_t bin = 1; bin <= r->GetNbinsX(); bin++) {
    Printf("  bin # %2d: Diff=%g+/-%g", bin, r->GetBinContent(bin),
	   r->GetBinError(bin));
    r->SetBinError(bin, 0);
  }
  r->GetSumw2()->Set(0); //r->Sumw2(false);
  r->SetMarkerSize(4);
  r->SetMaximum(r->GetMaximum()*1.2);
  r->SetMinimum(r->GetMinimum()*0.8);
  r->Draw("hist text30");  
  p->Modified();
  p->Update();
  p->cd();
}
开发者ID:BetterWang,项目名称:mcorrelations,代码行数:94,代码来源:Compare.C


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