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


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

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


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

示例1: DeltaZVsPt

//================================================
void DeltaZVsPt(const Int_t save = 0)
{
  THnSparseF *hn = (THnSparseF*)f->Get(Form("mhTrkDzDy_%s",trigName[kTrigType]));
  TH2F *hTrkDzVsPt = (TH2F*)hn->Projection(1,0);
  c = draw2D(hTrkDzVsPt,Form("%s: #Deltaz of matched track-hit pairs",trigName[kTrigType]));
  if(save) 
    {
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaZ_vs_pt_%s.pdf",run_type,trigName[kTrigType]));
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaZ_vs_pt_%s.png",run_type,trigName[kTrigType]));
    }

  Double_t pt_cut = 1;
  hTrkDzVsPt->GetXaxis()->SetRangeUser(pt_cut+0.1,100);
  TH1F *hMthDz = (TH1F*)hTrkDzVsPt->ProjectionY(Form("hTrkDzVsPt_%s_proj",trigName[kTrigType]));
  hMthDz->SetTitle(Form("%s: #Deltaz of matched track-hit pairs (p_{T}>%1.1f GeV/c);#Deltaz (cm)",trigName[kTrigType],pt_cut));
  TH1F *hClone = (TH1F*)hMthDz->Clone(Form("%s_clone",hMthDz->GetName()));
  c = draw1D(hClone,"",kFALSE,kFALSE);
  if(save) 
    {
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaZ_%s.pdf",run_type,trigName[kTrigType]));
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaZ_%s.png",run_type,trigName[kTrigType]));
    }

  Double_t range = 50;
  TF1 *func = new TF1("func","gaus(0)+gaus(3)",-1*range,range);
  func->SetParameters(10000,0,10,1000,0,40);
  c = FitDeltaZ(hMthDz,func,range,20.);
  if(save) 
    {
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/FitDz_Pt%1.0f_%s.pdf",run_type,pt_cut,trigName[kTrigType]));
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/FitDz_Pt%1.0f_%s.png",run_type,pt_cut,trigName[kTrigType]));
    }

  // pt dependence
  Double_t pt_cuts[5] = {1,2,3,5,20};
  for(Int_t i=0; i<4; i++)
    {
      hTrkDzVsPt->GetXaxis()->SetRangeUser(pt_cuts[i]+0.1,pt_cuts[i+1]-0.1);
      TH1F *htmp = (TH1F*)hTrkDzVsPt->ProjectionY(Form("hTrkDz_pt%1.0f-%1.0f_%s",pt_cuts[i],pt_cuts[i+1],trigName[kTrigType]));
      htmp->SetTitle(Form("%s: #Deltaz of matched track-hit pairs (%1.0f < p_{T} < %1.0f GeV/c);#Deltaz (cm)",trigName[kTrigType],pt_cuts[i],pt_cuts[i+1]));

      TF1 *func = new TF1(Form("func_pt%1.0f-%1.0f",pt_cuts[i],pt_cuts[i+1]),"gaus(0)+gaus(3)",-1*range,range);
      if(i==0) func->SetParameters(100,0,100,1000,0,10);
      if(i==1) func->SetParameters(1000,0,15,1000,0,60);
      if(i==2) func->SetParameters(1000,0,15,1000,0,60);
      if(i==3) func->SetParameters(1000,0,60,1000,0,15);
      c = FitDeltaZ(htmp,func,range,20.);
      if(save) 
	{
	  c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/FitDz_Pt%1.0f_%1.0f_%s.pdf",run_type,pt_cuts[i],pt_cuts[i+1],trigName[kTrigType]));
	  c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/FitDz_Pt%1.0f_%1.0f_%s.png",run_type,pt_cuts[i],pt_cuts[i+1],trigName[kTrigType]));
	}
    }
 
}
开发者ID:marrbnl,项目名称:STAR,代码行数:56,代码来源:ana_Match.C

示例2: ZVXT1HF0

void ZVXT1HF0()
{

  NCanvas(1,1,"data");
  NCanvas(1,1,"ratio");

  TH1F * HDatHF0;
  TH1F * HDat;

  TFile *fzee = new TFile("ZDiffOutputfile_DataOnly_2010_2011.root");
  // TFile *fzee = new TFile("ZDiffOutputfile.root");
  HDat  =  (TH1F*)fzee->Get("NVTX1_InstLumiPerBx_DATA10");
  
  HDatHF0  =  (TH1F*)fzee->Get("HF0NVTX1_InstLumiPerBx_DATA10");
  data->cd(1);
  HDat->Draw();
  NSetTitle(HDat,"Luminosity [10^{-30} cm^{-2} s^{-1}]", "Entries");
  HDat->SetTitle("Number of Z produced in events without PU");
  HDatHF0->Draw("SAME HIST");
  NHSetMarker(HDat,2,20,0.4);
  TLegend *legend = new TLegend(0.6,0.7,0.9,0.8);
  legend->SetTextFont(72);
  legend->SetTextSize(0.03);
  legend->SetBorderSize(0);


  legend->AddEntry(HDat,"All Z","p");
  legend->AddEntry(HDatHF0,"Z with minE_HF=0","l");
  legend->Draw();


  TH1F * Hra = (TH1F * ) HDatHF0->Clone();
  //  Hra->GetXaxis->SetRange(0,12);
  NStat(Hra,0);
  Hra->Divide(HDat);
  NLogAxis(0,1);
  ratio->cd(1);

  Hra->Draw();
  Hra->SetTitle("Fraction of Z with (PU=0 && E_HF=0)");
  Hra->Fit("expo","","",0.,1.2);
  NSetTitle(Hra,"Luminosity [10^{-30} cm^{-2} s^{-1}]", "Fraction");
  NLogAxis(0,1);
  NText(.05,0.1, "0.62");
  NText(0.3,0.1, "2.47");
  NText(0.7,0.1, "4.93");
  NText(1.1,0.1, "7.4");
  NText(1.4,0.1, "<Number of Int.>");


}
开发者ID:dfigueiredo,项目名称:Torino,代码行数:51,代码来源:ZAnalysis_2011.C

示例3: EflowCASTOR

void EflowCASTOR()
{

  NCanvas(1,2,"data");

  TH1F * HDat;
  TH1F * HZ2;

  //  TFile *fzee = new TFile("ZDiffOutputfile_73Weight2010.root");
  TFile *fzee = new TFile("ZDiffOutputfile.root");
  // TFile *fzee = new TFile("ZDiffOutputfile.root");
  HDat  =  (TH1F*)fzee->Get("NVTX1_EnergyCastorModule_DATA");
  HZ2  =  (TH1F*)fzee->Get("NVTX1_EnergyCastorModule_Z2PY6");
  data->cd(1);
  NHSetMarker(HDat,2,20,0.8);
  HDat->SetMinimum(10);
  HDat->Draw();
  NStat(HDat,0);
  NSetTitle(HDat,"CASTOR Modules", "Entries");

  HDat->SetTitle("CASTOR Module Energy 2010");
  HZ2->Draw("SAME HIST");
  NHSetMarker(HDat,2,20,0.4);
  TLegend *legend = new TLegend(0.6,0.7,0.9,0.8);
  legend->SetTextFont(72);
  legend->SetTextSize(0.06);
  legend->SetBorderSize(0);


  legend->AddEntry(HDat,"Data2010","p");
  legend->AddEntry(HZ2,"Z2","l");
  legend->Draw();


  TH1F * Hra = (TH1F * ) HDat->Clone();
  //  Hra->GetXaxis->SetRange(0,12);
  NStat(Hra,0);
  NHSetMarker(Hra,4,20,0.8);
  Hra->SetMinimum(1);
  Hra->Divide(HZ2);
  NLogAxis(0,0);
  data->cd(2);
  Hra->Draw();
  Hra->SetTitle("Ratio DATA/MC");
  Hra->Fit("pol0");
  NSetTitle(Hra,"CASTOR Modules", "Ratio");
  NLogAxis(0,1);

}
开发者ID:dfigueiredo,项目名称:Torino,代码行数:49,代码来源:ZAnalysis_2011.C

示例4: normalizeYield

TH1F* normalizeYield(TH1F* hYW)
{
  TH1F* hYWnorm = (TH1F*)hYW->Clone("hYWnorm");
  hYWnorm->SetTitle( TString::Format("Q2W = %s",_q2w_bng.Data()) );
  hYWnorm->SetYTitle(XSECTITLE.Data());  
  for (int ibin = 0; ibin < hYW->GetNbinsX(); ibin++)
    {
      float wmin = hYW->GetBinLowEdge(ibin+1);
      float dw   = hYW->GetBinWidth(ibin+1);
      float vgflux = getvgflux(wmin,_q2min);
      float factor = 1000000000;
      float norm = LUM*vgflux*_dq2*dw*factor;
      /*printf("[wmin,q2min] = %f:%f\n",wmin,_q2min);
      printf("lum:vgflux:dw:dq2:factor = %f:%f:%f:%f:%.0E\n",
              LUM,vgflux,dw,_dq2,factor);
      printf("norm = %f\n",norm);*/

      float yield     = hYW->GetBinContent(ibin+1);
      float normYield = yield/norm;
      
      hYWnorm->SetBinContent(ibin+1,normYield);
      hYWnorm->SetBinError(ibin+1,0); //tmp till errors are correctly propagated
    }
  return hYWnorm;
}
开发者ID:arjun-trivedi,项目名称:ana2pi,代码行数:25,代码来源:xsec-tools.092513.pretwoscales.C

示例5: CreateEffHisto

TH1F* CreateEffHisto(TH1F* hGen, TH1F* hRec)
{
// create an efficiency histogram

  Int_t nBins = hGen->GetNbinsX();
  TH1F* hEff = (TH1F*) hGen->Clone("hEff");
  hEff->SetTitle("");
  hEff->SetStats(kFALSE);
  hEff->SetMinimum(0.);
  hEff->SetMaximum(110.);
  hEff->GetYaxis()->SetTitle("#epsilon [%]");

  for (Int_t iBin = 0; iBin <= nBins; iBin++) {
    Double_t nGen = hGen->GetBinContent(iBin);
    Double_t nRec = hRec->GetBinContent(iBin);
    if (nGen > 0) {
      Double_t eff = nRec/nGen;
      hEff->SetBinContent(iBin, 100. * eff);
      Double_t error = sqrt(eff*(1.-eff) / nGen);
      if (error == 0) error = 0.0001;
      hEff->SetBinError(iBin, 100. * error);
    } else {
      hEff->SetBinContent(iBin, -100.);
      hEff->SetBinError(iBin, 0);
    }
  }

  return hEff;
}
开发者ID:catalinristea,项目名称:test,代码行数:29,代码来源:CheckESD.C

示例6: PlotScurveGroup

void PlotScurveGroup( Char_t *fname, UInt_t pBeId = 0, UInt_t pFeId = 0, UInt_t pCbc = 0, UInt_t pGroup = 0, UInt_t color = 4 ){

	TFile *fin = new TFile( fname );
	UInt_t cCh1(0);
	for( int i=0; i < 16; i++ ){
		cCh1 = i * 16 + pGroup*2;
		for( int j = cCh1; j < cCh1 + 2; j++ ){  
			if( j < 254 ){

				TString hname = Form( "h_%02d_%02d_%02d_%03d", pBeId, pFeId, pCbc, j );
				TH1F *h = (TH1F *) fin->Get( hname );
				h->GetXaxis()->SetRangeUser( 50, 170 );
				h->SetLineColor(1);
				h->SetMarkerColor(1);
				h->SetTitle( Form( "FE(00),CBC(%02d); VCth; Rate", pCbc ) );
				TF1 *func = h->GetFunction( Form("f_%s", hname.Data() ) );
				if( i == 0 ) h->Draw();
				else h->Draw("same");
			}
		}
	}
	TString cPadName( fname );
	cPadName.ReplaceAll( ".root", Form( "G%d.png", pGroup ) );
	gPad->Print( cPadName ); 
}
开发者ID:faball,项目名称:CbcTest,代码行数:25,代码来源:PlotScurveGroup.C

示例7: Deconvolution_wide_boost

void Deconvolution_wide_boost() {
   Int_t i;
   const Int_t nbins = 256;
   Double_t xmin     = 0;
   Double_t xmax     = nbins;
   Double_t source[nbins];
   Double_t response[nbins];
   gROOT->ForceStyle();

   TH1F *h = new TH1F("h","Deconvolution",nbins,xmin,xmax);
   TH1F *d = new TH1F("d","",nbins,xmin,xmax);

   TString dir  = gROOT->GetTutorialDir();
   TString file = dir+"/spectrum/TSpectrum.root";
   TFile *f     = new TFile(file.Data());
   h = (TH1F*) f->Get("decon3");
   h->SetTitle("Deconvolution of closely positioned overlapping peaks using boosted Gold deconvolution method");
   d = (TH1F*) f->Get("decon_response_wide");

   for (i = 0; i < nbins; i++) source[i]=h->GetBinContent(i + 1);
   for (i = 0; i < nbins; i++) response[i]=d->GetBinContent(i + 1);

   h->SetMaximum(200000);
   h->Draw("L");
   TSpectrum *s = new TSpectrum();
   s->Deconvolution(source,response,256,200,50,1.2);

   for (i = 0; i < nbins; i++) d->SetBinContent(i + 1,source[i]);
   d->SetLineColor(kRed);
   d->Draw("SAME L");
}
开发者ID:davidlt,项目名称:root,代码行数:31,代码来源:Deconvolution_wide_boost.C

示例8: pv_dist

void pv_dist(const string& fFile, const string& fTitle, const string& fNameExt) {
  
   TH1F *h;
    
   TFile file(fFile.c_str());
   TDirectoryFile *dir = (TDirectoryFile*)file.Get("offsetAnalysis");
   TDirectoryFile *subDir = (TDirectoryFile*)dir->Get("PrimaryVertices");

   h = (TH1F*)subDir->Get("h_NofPVs"); 
   
   string name = h->GetName();
   string fileName = name + "__" + fNameExt + ".png";
   
   h->SetTitle(fTitle.c_str());
   
   TCanvas *c = new TCanvas("c","",1120,800);
   c->cd();
     
   h->SetLineWidth(2);
   h->Draw();
   
   c->SetLogy();
   c->SaveAs(fileName.c_str());
   
   delete c;
}
开发者ID:ferencek,项目名称:cms-Offset_Analysis,代码行数:26,代码来源:pvPlots.C

示例9: make_histos_syst_rawyield

void make_histos_syst_rawyield(TString file_syst, TString file_default, TString out_tag){

  TFile *f1 = new TFile(file_syst.Data(),"read");
  TFile *f2 = new TFile(file_default.Data(),"read");
  TDirectoryFile *dir1 = (TDirectoryFile*)(f1->Get("effunf"));
  TDirectoryFile *dir2 = (TDirectoryFile*)(f2->Get("effunf"));
  TList *list = dir1->GetListOfKeys();

  TFile *f = new TFile(Form("plots/ratiosyst_%s.root",out_tag.Data()),"recreate");

  for (int i=0; i<list->GetSize(); i++){
    TString name = dir1->GetListOfKeys()->At(i)->GetName();
    if (!(name.Contains("hreco_"))) continue;
    TObject *obj1 = dir1->Get(name.Data());
    assert(obj1);
    TObject *obj2 = dir2->Get(name.Data());
    assert(obj2);
    TString newname = name;
    newname.Append("_ratiosyst");
    if (name.EndsWith("_0")) newname.ReplaceAll("_0_","_EBEB_");
    if (name.EndsWith("_1")) newname.ReplaceAll("_1_","_EBEE_");
    if (name.EndsWith("_2")) newname.ReplaceAll("_2_","_EEEE_");
    TH1F *h = (TH1F*)(((TH1F*)obj1)->Clone(newname.Data()));
    h->SetTitle(h->GetName());
    h->Divide((TH1F*)obj2);
    for (int j=0; j<h->GetNbinsX(); j++) h->SetBinError(j+1,0);
    for (int j=0; j<h->GetNbinsX(); j++) h->SetBinContent(j+1,1+fabs(1-h->GetBinContent(j+1)));
    f->cd();
    h->Write();
  }

}
开发者ID:peruzzim,项目名称:diphoton,代码行数:32,代码来源:make_histos_syst_rawyield.C

示例10: compnclusts

void compnclusts(Int_t run)
{
  TFile* f = new TFile(Form("hodtest_%d.root",run));
  cout << "hcana root file " << Form("hodtest_%d.root",run) << endl;
  TH1F* h = nclust;

  TFile* f1 = new TFile(Form("%d_hbk.root",run));
  cout << "Engine root file " << Form("%d_hbk.root",run) << endl;
  TH1F* h1;
  switch (run) {
  case 50017 :
  //    h1 = h212;   //A+
    break;
  default :
    h1 = h412;   //hnclusters
  }

  TCanvas *c1 = new TCanvas("c1", "Shower Cluster Map", 1000, 667);

  gPad->SetLogy();

  h1->SetFillColor(kGreen);
  h1->SetLineColor(kGreen);
  h1->SetFillStyle(1111);
  h1->Draw();

  h->SetFillColor(kBlue);
  h->SetLineWidth(2);
  h->SetFillStyle(0);
  h->Draw("same");

  TLatex l;
  l.SetTextSize(0.04);
  Float_t maxy = h1->GetBinContent(h1->GetMaximumBin());
  Float_t xmin = h1->GetXaxis()->GetXmin();
  Float_t xmax = h1->GetXaxis()->GetXmax();
  Float_t xt = xmin + 0.67*(xmax-xmin);

  l.SetTextColor(kGreen);
  l.DrawLatex(xt,0.095*maxy,"Engine");
  l.SetTextColor(kBlue);
  l.DrawLatex(xt,0.045*maxy,"hcana");

  // Difference between the histograms.

  TCanvas *c2 = new TCanvas("c2", "Cluster differences", 1000, 667);

  TH1F* dif = h->Clone();

  dif->Add(h,h1,1.,-1.);

  dif->SetTitle("Difference");
  dif->SetFillColor(kRed);
  dif->SetLineColor(kRed);
  dif->SetLineWidth(1);
  dif->SetFillStyle(1111);
  dif->Draw();

}
开发者ID:MarkKJones,项目名称:hcana,代码行数:59,代码来源:compnclusts.C

示例11: plotBkgModel

void plotBkgModel(TList* HistList, std::string name){
  
  gROOT->SetBatch();
  system("mkdir -p plots/ada/bkgMod");
  system("mkdir -p plots/grad/bkgMod");

  std::string bdt;
  TString str = HistList->At(0)->GetName();
  if (str.Contains("ada")) bdt="ada";
  else if (str.Contains("grad")) bdt="grad";
  else std::cout << "Error find BDT type" << std::endl;
  assert (str.Contains("ada") || str.Contains("grad"));
  
  gStyle->SetOptStat(0);
  gROOT->SetStyle("Plain");
  gROOT->ForceStyle();
  int color[6] = {kGreen+4,kGreen-1,kGreen,kRed,kRed-2,kRed+4};

  TCanvas *canv = new TCanvas();
  TLegend *leg = new TLegend(0.45,0.6,0.85,0.85);
  leg->SetLineColor(0);
  leg->SetFillColor(0);
  TPaveText *txt = new TPaveText(0.2,0.1,0.4,0.35,"NDC");
  txt->SetFillColor(0);
  txt->SetLineColor(0);
  txt->AddText("#int L = 4.76 fb^{-1}");

  for (int i=1; i<HistList->GetEntries(); i++){
    //if (((TH1F*)HistList->At(i))->GetNbinsX()!=((TH1F*)HistList->At(0))->GetNbinsX()) std::cout << "Plot problem: calling plot for histograms with different number of bins" << std::endl;
    //assert (((TH1F*)HistList->At(i))->GetNbinsX()==((TH1F*)HistList->At(0))->GetNbinsX());
    TH1F *temp = linearBin((TH1F*)HistList->At(i));
    temp->Scale(((TH1F*)HistList->At(0))->Integral()/temp->Integral());
    temp->SetLineColor(color[i-1]);
    temp->SetMarkerStyle(20);
    temp->SetMarkerColor(color[i-1]);
    temp->SetTitle(Form("Data in sidebands %s %s",bdt.c_str(),name.c_str()));
    temp->GetXaxis()->SetTitle("");
    temp->GetYaxis()->SetRangeUser(1.0,2.*(((TH1F*)HistList->At(0))->GetMaximum()));
    if (i==1) temp->Draw("p");
    else temp->Draw("same p");
    if (i==1) leg->AddEntry(temp,"Low 3 sideband","lep");
    if (i==2) leg->AddEntry(temp,"Low 2 sideband","lep");
    if (i==3) leg->AddEntry(temp,"Low 1 sideband","lep");
    if (i==4) leg->AddEntry(temp,"High 1 sideband","lep");
    if (i==5) leg->AddEntry(temp,"High 2 sideband","lep");
    if (i==6) leg->AddEntry(temp,"High 3 sideband","lep");
  }
  leg->Draw("same");
  txt->Draw("same");

  canv->SetLogy();
  canv->Print(("plots/"+bdt+"/bkgMod/"+name+".png").c_str(),"png");
  
  delete canv;
  delete txt;
  delete leg;

  bkgCalls++;
}
开发者ID:kreczko,项目名称:HiggsAnalysisExample,代码行数:59,代码来源:BDTInterpolation.C

示例12: ZVXT1NVTX

void ZVXT1NVTX()
{

  NCanvas(1,1,"data");
  NCanvas(1,1,"ratio");

  TH1F * HDatHF0;
  TH1F * HDat;

  TFile *fzee = new TFile("ZDiffOutputfile_DataOnly_2010_2011.root");
  // TFile *fzee = new TFile("ZDiffOutputfile.root");
  HDat  =  (TH1F*)fzee->Get("NoCuts_InstLumiPerBx_DATA10");
  
  HDatNVTX1  =  (TH1F*)fzee->Get("NVTX1_InstLumiPerBx_DATA10");
  data->cd(1);
  HDat->Draw();
  NStat(HDat,0);

  NSetTitle(HDat,"Luminosity [10^{-30} cm^{-2} s^{-1}]", "Entries");
  HDat->SetTitle("Z production luminosity");
  HDatNVTX1->Draw("SAME HIST");
  NHSetMarker(HDat,2,20,0.4);
  TLegend *legend = new TLegend(0.6,0.7,0.9,0.8);
  legend->SetTextFont(72);
  legend->SetTextSize(0.03);
  legend->SetBorderSize(0);


  legend->AddEntry(HDat,"All Z","p");
  legend->AddEntry(HDatNVTX1,"Z with PU=0","l");
  legend->Draw();


  TH1F * Hra = (TH1F * ) HDatNVTX1->Clone();
  //  Hra->GetXaxis->SetRange(0,12);
  NStat(Hra,0);
  Hra->Divide(HDat);
  NLogAxis(0,1);
  ratio->cd(1);
  Hra->Draw();
  Hra->SetTitle("Fraction of Z with PU=0");
  //  Hra->Fit("expo","","",0.1,1.2);
  NSetTitle(Hra,"Luminosity [10^{-30} cm^{-2} s^{-1}]", "Fraction");
  NLogAxis(0,1);
}
开发者ID:dfigueiredo,项目名称:Torino,代码行数:45,代码来源:ZAnalysis_2011.C

示例13: createHistogram

TH1F* createHistogram(char* name, int nbins=12) {
  TH1F* hist = new TH1F(name,name, 20, 0, 20);
  hist->SetTitle("");
  char temp[100];
  sprintf(temp, "Events", 20);
  hist->GetXaxis()->SetTitle("nPV");
  hist->GetYaxis()->SetTitle(temp);
  return hist;
}
开发者ID:ajaykumar649,项目名称:scripts,代码行数:9,代码来源:CutCountTP_truth.C

示例14: eff_bg

TH1F* eff_bg(TH1F* h1, TH1F* h2, TH1F* h3, TH1F* h4, const char* name="eff"){

  // first, verify that all histograms have same binning
  // nx is the number of visible bins
  // nxtot = nx+2 includes underflow and overflow
  Int_t nx = h1->GetNbinsX();
  Int_t nxtot = nx + 2;
  if (h2->GetNbinsX() != nx) {
    //    cout << "Histograms must have same number of bins" << endl;
    return 0;
  }
  if (h3->GetNbinsX() != nx) {
    //    cout << "Histograms must have same number of bins" << endl;
    return 0;
  }
  if (h3->GetNbinsX() != nx) {
    //    cout << "Histograms must have same number of bins" << endl;
    return 0;
  }

  // get the new histogram
  TH1F* temp = (TH1F*) h1->Clone(name);
  temp->SetTitle(name);
  temp->Reset();
  temp->Sumw2();

  // Loop over bins, calculate efficiency and error, put it in histogram
  for (Int_t i=0; i<nxtot; i++) {
    Double_t x1 = h1->GetBinContent(i);
    Double_t x2 = h2->GetBinContent(i);
    Double_t x3 = h3->GetBinContent(i);
    Double_t x4 = h4->GetBinContent(i);
    Double_t denom = x1 - x3;
    Double_t eff;
    if (denom == 0.) {
      eff = 0;
    } else {
      eff   = (x2-x4)/denom;
    }
    Double_t failSig = x1 - x2;
    Double_t failBg  = x3 - x4;
    Double_t blah    = (1-eff)*(1-eff)*(x2+x4) + eff*eff*(failSig+failBg);
    if (blah <= 0.) blah=0.0;
    Double_t err;
    if (denom == 0) {
      err = 0.;
    } else {
      err = sqrt(blah)/denom;
    }
    temp->SetBinContent(i,eff);
    temp->SetBinError(i,err);
  }

  // Done
  return temp;
}
开发者ID:tedanielson,项目名称:oldUserCode,代码行数:56,代码来源:histtools.C

示例15: Background_order

void Background_order() {
   Int_t i;
   const Int_t nbins = 4096;
   Double_t xmin     = 0;
   Double_t xmax     = 4096;
   Double_t source[nbins];
   gROOT->ForceStyle();

   TH1F *d1 = new TH1F("d1","",nbins,xmin,xmax);
   TH1F *d2 = new TH1F("d2","",nbins,xmin,xmax);
   TH1F *d3 = new TH1F("d3","",nbins,xmin,xmax);
   TH1F *d4 = new TH1F("d4","",nbins,xmin,xmax);

   TString dir  = gROOT->GetTutorialsDir();
   TString file = dir+"/spectrum/TSpectrum.root";
   TFile *f     = new TFile(file.Data());
   TH1F *back = (TH1F*) f->Get("back2");
   back->SetTitle("Influence of clipping filter difference order on the estimated background");
   back->SetAxisRange(1220,1460);
   back->SetMaximum(3000);
   back->Draw("L");

   TSpectrum *s = new TSpectrum();

   for (i = 0; i < nbins; i++) source[i]=back->GetBinContent(i + 1);
   s->Background(source,nbins,40,TSpectrum::kBackDecreasingWindow,
                 TSpectrum::kBackOrder2,kFALSE,
                 TSpectrum::kBackSmoothing3,kFALSE);
   for (i = 0; i < nbins; i++) d1->SetBinContent(i + 1,source[i]);
   d1->SetLineColor(kRed);
   d1->Draw("SAME L");

   for (i = 0; i < nbins; i++) source[i]=back->GetBinContent(i + 1);
   s->Background(source,nbins,40,TSpectrum::kBackDecreasingWindow,
                 TSpectrum::kBackOrder4,kFALSE,
                 TSpectrum::kBackSmoothing3,kFALSE);
   for (i = 0; i < nbins; i++) d2->SetBinContent(i + 1,source[i]);
   d2->SetLineColor(kBlue);
   d2->Draw("SAME L");

   for (i = 0; i < nbins; i++) source[i]=back->GetBinContent(i + 1);
   s->Background(source,nbins,40,TSpectrum::kBackDecreasingWindow,
                 TSpectrum::kBackOrder6,kFALSE,
                 TSpectrum::kBackSmoothing3,kFALSE);
   for (i = 0; i < nbins; i++) d3->SetBinContent(i + 1,source[i]);
   d3->SetLineColor(kGreen);
   d3->Draw("SAME L");

   for (i = 0; i < nbins; i++) source[i]=back->GetBinContent(i + 1);
   s->Background(source,nbins,40,TSpectrum::kBackDecreasingWindow,
                 TSpectrum::kBackOrder8,kFALSE,
                 TSpectrum::kBackSmoothing3,kFALSE);
   for (i = 0; i < nbins; i++) d4->SetBinContent(i + 1,source[i]);
   d4->SetLineColor(kMagenta);
   d4->Draw("SAME L");
}
开发者ID:Y--,项目名称:root,代码行数:56,代码来源:Background_order.C


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