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


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

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


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

示例1: drawFrequency

void drawFrequency(const char* ifname="output/HUMAN.pair.output", int type=2)
{
	gROOT->SetStyle("Plain");
	
	TFile outfile(TString(TString(ifname)+".root"),"RECREATE");
	int nbins = 400;
	if(type == 1)nbins = 20;
	TH1F* freq = new TH1F("freq","",nbins,-0.5,float(nbins)-0.5);
	
	int bin = 1;
	ifstream infile(ifname);
	while(1){
		TString name;
		float freq1,freq2;
		infile >> name >> freq1;
		if(type == 2) infile >> freq2;
		if(!infile.good()) break;
		freq->SetBinContent(bin,freq1);
		bin++;
	}
	infile.close();
	
	TCanvas* c = new TCanvas("c","",800,600);
	gStyle->SetOptStat(0);
	freq->SetYTitle("Frequency");
	freq->SetXTitle("Amino acid pair");
	if(type == 1)freq->SetXTitle("Amino acid");
	freq->SetLineWidth(2);
	freq->SetLineColor(kBlue);
	freq->Draw();
	c->SaveAs(TString(TString(ifname)+".pdf"));
	outfile.Close();
}
开发者ID:mhwalker,项目名称:Projects,代码行数:33,代码来源:drawFrequency.C

示例2: read21m

void read21m() {
    
    TFile *f = new TFile("read21.root");    //root file name
    TTree *ntuple = (TTree*)f->Get("ntuple");
    
    Float_t hm,zm;  //Values
    
    ntuple->SetBranchAddress("hm",&hm);   //Values
    ntuple->SetBranchAddress("zm",&zm);
    
    //create histogram
    TH1F *higg     = new TH1F("hm","Higgs invariant mass distribution",100,0,300.);
    TH1F *zboson   = new TH1F("zm","Z0 invariant mass distribution",100,0,300.);
    
    //read all entries and fill the histograms
    Long64_t nentries = ntuple->GetEntries();
    for (Long64_t q=0;q<nentries;q++) {
        ntuple->GetEntry(q);
        higg->Fill(hm);        //Histogram value
        zboson->Fill(zm);
        }
    
    {
        higg->SetXTitle("m[GeV]");
        higg->SetYTitle("Event");
        zboson->SetXTitle("m[GeV]");
        zboson->SetYTitle("Event");
    }
    
    if (gROOT->IsBatch()) return;
    f->Write();
    new TBrowser();
    ntuple->StartViewer();
    
}
开发者ID:yuichiok,项目名称:macros,代码行数:35,代码来源:read21.c

示例3: DrawOverflow

TH1F * DrawOverflow(TH1F *h)
{
      // This function paint the histogram h with an extra bin for overflows
   UInt_t nx    = h->GetNbinsX()+1;
   Double_t *xbins= new Double_t[nx+1];
   for (UInt_t i=0;i<nx;i++)
     xbins[i]=h->GetBinLowEdge(i+1);
   xbins[nx]=xbins[nx-1]+h->GetBinWidth(nx);
   char *tempName= new char[strlen(h->GetName())+10];
   sprintf(tempName,"%swtOverFlow",h->GetName());
   // Book a temporary histogram having ab extra bin for overflows
   TH1F *htmp = new TH1F(tempName, h->GetTitle(), nx, xbins);
   // Reset the axis labels
   htmp->SetXTitle(h->GetXaxis()->GetTitle());
   htmp->SetYTitle(h->GetYaxis()->GetTitle());
   // Fill the new hitogram including the extra bin for overflows
   for (UInt_t i=1; i<=nx; i++)
     htmp->Fill(htmp->GetBinCenter(i), h->GetBinContent(i));
   // Fill the underflows
   htmp->Fill(h->GetBinLowEdge(1)-1, h->GetBinContent(0));
   // Restore the number of entries
   htmp->SetEntries(h->GetEntries());
   // FillStyle and color
   htmp->SetFillStyle(h->GetFillStyle());
   htmp->SetFillColor(h->GetFillColor());
   return htmp;
}
开发者ID:lucasgautheron,项目名称:Atlas,代码行数:27,代码来源:zh.c

示例4: DrawJMS_vs_Eta

void DrawJMS_vs_Eta(Str jetAlgo) {
  double massEbins[] = {50, 100, 250, 500, 750, 1500};
  double massNbins = sizeof(massEbins)/sizeof(double);
  myJES = new JetCalibrationTool(jetAlgo,_jesFile);
  TH1F *h = new TH1F("","",100,-4.8,4.8);
  h->SetXTitle("Jet #eta_{det}"); h->SetYTitle("Jet mass response");
  h->SetMaximum(1.4); h->SetMinimum(0.6);
  h->Draw();
  
  TLine *l = new TLine(); 
  l->SetLineWidth(2); l->SetLineColor(kGray+2); l->SetLineStyle(4);
  l->DrawLine(-4.65,1,4.65,1);

  for (int i=0;i<massNbins;++i) {
    Graph *g = GetJMSGraph(massEbins[i]);
    FormatGraph(g,i);
    g->Draw("PL");
    double x=0.52, y=0.3-0.05*i;
    if (i>2) { x=0.74; y=0.3-0.05*(i-3); }
    DrawLabel(Form("E = %.0f GeV",massEbins[i]),x,y,i);
  }
  
  tex->SetNDC(); tex->SetTextAlign(12);
  tex->DrawLatex(0.18,0.975,myJES->AbsoluteJES_Description());
  tex->DrawLatex(0.18,0.9,jetAlgo);
}
开发者ID:affablelochan,项目名称:2013codev2,代码行数:26,代码来源:DrawJES.C

示例5: DrawInsituCorr_vs_Pt

void DrawInsituCorr_vs_Pt(Str jetAlgo) {
  myJES = new JetCalibrationTool(jetAlgo,_jesFile);
  TH1F *h = new TH1F("","",100,15,2500);
  h->SetXTitle("Jet p_{T}");
  h->SetYTitle("Residual correction for data only");
  h->SetMaximum(1.1); h->SetMinimum(0.85);
  h->Draw();
  TLine *l = new TLine(); 
  l->SetLineWidth(2); l->SetLineColor(kGray+2); l->SetLineStyle(4);
  l->DrawLine(16,1,2400,1);
  for (int i=0;i<6;++i) {
    double eta=4.0*i/5;
    Graph *g = GetInsituGraphVsPt(eta);
    FormatGraph(g,i); g->Draw("PL");
    double x=0.52, y=0.3-0.05*i;
    if (i>2) { x=0.74; y=0.3-0.05*(i-3); }
    DrawLabel(Form("#eta = %.1f",eta),x,y,i);
  }

  l->SetLineWidth(2);
  l->SetLineColor(kGray+2);
  l->SetLineStyle(1);

  tex->SetNDC(); tex->SetTextAlign(12);
  //tex->DrawLatex(0.18,0.975,myJES->AbsoluteJES_Description());
  tex->DrawLatex(0.18,0.9,GetJetDesc(jetAlgo));
}
开发者ID:affablelochan,项目名称:2013codev2,代码行数:27,代码来源:DrawJES.C

示例6: gerrors2

void gerrors2() {
   TCanvas *c1 = new TCanvas("c1","gerrors2",200,10,700,500);
   c1->SetGrid();

   // draw a frame to define the range
   TH1F *hr = c1->DrawFrame(-0.4,0,1.2,12);
   hr->SetXTitle("X title");
   hr->SetYTitle("Y title");
   c1->GetFrame()->SetBorderSize(12);

   // create first graph
   const Int_t n1 = 10;
   Double_t xval1[]  = {-0.22, 0.05, 0.25, 0.35, 0.5, 0.61,0.7,0.85,0.89,0.95};
   Double_t yval1[]  = {1,2.9,5.6,7.4,9,9.6,8.7,6.3,4.5,1};
   Double_t ex1[] = {.05,.1,.07,.07,.04,.05,.06,.07,.08,.05};
   Double_t ey1[] = {.8,.7,.6,.5,.4,.4,.5,.6,.7,.8};
   TGraphErrors *gr1 = new TGraphErrors(n1,xval1,yval1,ex1,ey1);
   gr1->SetMarkerColor(kBlue);
   gr1->SetMarkerStyle(21);
   gr1->Draw("LP");

   // create second graph
   const Int_t n2 = 10;
   Float_t xval2[]  = {-0.28, 0.005, 0.19, 0.29, 0.45, 0.56,0.65,0.80,0.90,1.01};
   Float_t yval2[]  = {0.82,3.86,7,9,10,10.55,9.64,7.26,5.42,2};
   Float_t ex2[] = {.04,.12,.08,.06,.05,.04,.07,.06,.08,.04};
   Float_t ey2[] = {.6,.8,.7,.4,.3,.3,.4,.5,.6,.7};
   TGraphErrors *gr2 = new TGraphErrors(n2,xval2,yval2,ex2,ey2);
   gr2->SetMarkerColor(kRed);
   gr2->SetMarkerStyle(20);
   gr2->Draw("LP");
}
开发者ID:Y--,项目名称:root,代码行数:32,代码来源:gerrors2.C

示例7: binomialEfficiency2D

void binomialEfficiency2D(TH2F * numerator,TH2F * denominator,bool text2D){
  if(!numerator) cout<<"numerator not found"<<endl;
  if(!denominator) cout<<"denominator not found"<<endl;

  TH1F * efficiency = numerator->Clone("efficiency");
  
  efficiency->SetXTitle(numerator->GetXaxis()->GetTitle());
  efficiency->SetYTitle(numerator->GetYaxis()->GetTitle());
  
  float eff,err;
  for(int i=0;i<=numerator->GetXaxis()->GetNbins();i++)
    for(int j=0;j<=numerator->GetYaxis()->GetNbins();j++){
      if(denominator->GetBinContent(i,j)!=0){
	eff = numerator->GetBinContent(i,j)/denominator->GetBinContent(i,j);
	err = sqrt(eff*(1-eff)/denominator->GetBinContent(i,j));
	efficiency->SetBinContent(i,j,eff);
	efficiency->SetBinError(i,j,err);
	cout<<i<<" "<<j<<" "<<eff<<"+/-"<<err<<endl;
      }
    }
  if(text2D==true){
    efficiency->Draw("colztextE");
    //efficiency->Draw("colz");
  }else{
    efficiency->Draw("colz");
  }
}
开发者ID:camilocarrillo,项目名称:HiggsGenHltRecoAnalyzer,代码行数:27,代码来源:make_up.C

示例8: DrawInsituCorr_vs_Eta

void DrawInsituCorr_vs_Eta(Str jetAlgo) {
  Nbins=sizeof(Ebins)/sizeof(double);
  myJES = new JetCalibrationTool(jetAlgo,_jesFile);

  TH1F *h = new TH1F("","",100,-4.8,4.8);
  h->SetXTitle("Jet #eta_{det}");
  h->SetYTitle("Residual correction for data only");
  h->SetMaximum(1.1); h->SetMinimum(0.85);

  h->Draw();
  TLine *l = new TLine(); 
  l->SetLineWidth(2); l->SetLineColor(kGray+2); l->SetLineStyle(4);
  l->DrawLine(-4.65,1,4.65,1);
  
  for (int i=0;i<Nbins;++i) {
    Graph *g = GetInsituGraph(Ebins[i]);
    FormatGraph(g,i); g->Draw("PL");
    double x=0.52, y=0.3-0.05*i;
    if (i>2) { x=0.74; y=0.3-0.05*(i-3); }
    DrawLabel(Form("p_{T} = %.0f GeV",Ebins[i]),x,y,i);
  }

  l->SetLineWidth(2);
  l->SetLineColor(kGray+2);
  l->SetLineStyle(1);

  tex->SetNDC(); tex->SetTextAlign(12);
  //tex->DrawLatex(0.18,0.975,myJES->AbsoluteJES_Description());
  tex->DrawLatex(0.18,0.9,GetJetDesc(jetAlgo));
}
开发者ID:affablelochan,项目名称:2013codev2,代码行数:30,代码来源:DrawJES.C

示例9: read25cm

void read25cm() {
    
    TFile *f = new TFile("read25c.root");    //root file name
    TTree *ntuple = (TTree*)f->Get("ntuple");
    
    Float_t dRm,dRmbar,dRb,dRbbar;  //Values
    
    ntuple->SetBranchAddress("dRm",&dRm);   //Values
    ntuple->SetBranchAddress("dRmbar",&dRmbar);
    ntuple->SetBranchAddress("dRb",&dRb);
    ntuple->SetBranchAddress("dRbbar",&dRbbar);
    
    //create histogram
    TH1F *mudR     = new TH1F("dRm","dR distribution of mu and jet",100,0.,2 * M_PI);
    TH1F *mubardR   = new TH1F("dRmbar","dR distribution of mubar and jet",100,0.,2 * M_PI);
    TH1F *bdR     = new TH1F("dRb","dR distribution of b and jet",100,0.,2 * M_PI);
    TH1F *bbardR     = new TH1F("dRbbar","dR distribution of bbar and jet",100,0.,2 * M_PI);
    
    //read all entries and fill the histograms
    Long64_t nentries = ntuple->GetEntries();
    for (Long64_t q=0;q<nentries;q++) {
        ntuple->GetEntry(q);
        mudR->Fill(dRm);        //Histogram value
        mubardR->Fill(dRmbar);
        bdR->Fill(dRb);
        bbardR->Fill(dRbbar);
        }
    
    {
        mudR->SetXTitle("dR");
        mudR->SetYTitle("Event");
        mubardR->SetXTitle("dR");
        mubardR->SetYTitle("Event");
        bdR->SetXTitle("dR");
        bdR->SetYTitle("Event");
        bbardR->SetXTitle("dR");
        bbardR->SetYTitle("Event");
    }
    
    if (gROOT->IsBatch()) return;
    f->Write();
    new TBrowser();
    ntuple->StartViewer();
    
}
开发者ID:yuichiok,项目名称:macros,代码行数:45,代码来源:read25c.c

示例10: DrawSmooth

void DrawSmooth(Int_t pad, const char *title, const char *xt, const char *yt)
{
   vC1->cd(pad);
   TH1F *vFrame = gPad->DrawFrame(0,-130,60,70);
   vFrame->SetTitle(title);
   vFrame->SetTitleSize(0.2);
   vFrame->SetXTitle(xt);
   vFrame->SetYTitle(yt);
   grin->Draw("P");
   grout->DrawClone("LPX");
}
开发者ID:davidlt,项目名称:root,代码行数:11,代码来源:motorcycle.C

示例11: plot

TCanvas * plot (TH1F* histoDataIn, TString legendData, TH1F* histoSimulationIn, TString legendSimulation,
                TString & canvasName, Float_t maximum = 0.15, TString xAxisTitle = "#eta",
                TString yAxisTitle = "Number of Clusters", TString error = "", bool useLegend = true,
                TString text = "", Float_t textX = 0.7, Float_t textY = 0.4, Float_t rebin = 0 ) {

  TH1F * histoData = (TH1F*)histoDataIn->Clone();
  TH1F * histoSimulation = (TH1F*)histoSimulationIn->Clone();

  // histoData->Sumw2();
  histoData->Scale(1/(histoData->Integral()));
  histoSimulation->Scale(1/(histoSimulation->Integral()));

  // Create also the legend and add the histograms
  TLegend * legend = new TLegend( 0.55, 0.65, 0.76, 0.82 );
  legend->AddEntry( histoData, xAxisTitle );
  legend->AddEntry( histoSimulation, yAxisTitle, "F" );

  cout << "histoData = " << histoData << endl;
  cout << "histoSimulation = " << histoSimulation << endl;

  TCanvas * c = new TCanvas( canvasName, canvasName, 1000, 800 );
  c->Draw();

  histoSimulation->SetMaximum(maximum);

  histoSimulation->SetFillColor(kRed);
  // histoSimulation->SetLineWidth(0);
  histoSimulation->SetLineColor(kRed);
  histoSimulation->SetXTitle(xAxisTitle);
  histoSimulation->SetYTitle(yAxisTitle);
  histoSimulation->SetTitleOffset(1.6,"Y");
  histoSimulation->SetTitle();

  histoData->SetLineStyle(1);
  histoData->SetLineWidth(2.5);

  histoSimulation->Draw();
  histoData->Draw("same");

  legend->SetFillColor(kWhite);
  if (useLegend) legend->Draw("same");

  if ( text != "" ) {
    TPaveText * pt = new TPaveText(textX, textY, textX+0.2, textY+0.17, "NDC" ); // "NDC" option sets coords relative to pad dimensions
    pt->SetFillColor(0); // text is black on white
    pt->SetTextSize(0.08); 
    pt->SetBorderSize(0);
    pt->SetTextAlign(12);
    pt->AddText(text);
    pt->Draw("same");       //to draw your text object
  }

  return c;
};
开发者ID:Hosein47,项目名称:usercode,代码行数:54,代码来源:plot.C

示例12: binomialEfficiency1D

void binomialEfficiency1D(TH1F * numerator,TH1F * denominator){
  TH1F * efficiency = numerator->Clone("efficiency");
  efficiency->SetXTitle(numerator->GetXaxis()->GetTitle());
  efficiency->SetYTitle("#epsilon");
  for(int j=0;j<=numerator->GetXaxis()->GetNbins() ;j++){
    if(denominator->GetBinContent(j)!=0){
      float eff = numerator->GetBinContent(j)/denominator->GetBinContent(j);
      float err = sqrt(eff*(1-eff)/denominator->GetBinContent(j));
      efficiency->SetBinContent(j,eff);
      efficiency->SetBinError(j,err);
      cout<<"1Deff "<<j<<" "<<eff<<" +/- "<<err<<endl;
    }
  }
  efficiency->Draw("E");
  efficiency->SetMarkerColor(kRed);
  efficiency->SetMarkerStyle(23);
  efficiency->SetMarkerSize(2);
}
开发者ID:camilocarrillo,项目名称:HiggsGenHltRecoAnalyzer,代码行数:18,代码来源:make_up.C

示例13: DrawSmooth

void DrawSmooth(Int_t pad, const char *title, const char *xt,
   const char *yt)
{
   vC1->cd(pad);
   TH1F *vFrame = gPad->DrawFrame(0,0,15,150);
   vFrame->SetTitle(title);
   vFrame->SetTitleSize(0.2);
   vFrame->SetXTitle(xt);
   vFrame->SetYTitle(yt);
   grxy->SetMarkerColor(kBlue);
   grxy->SetMarkerStyle(21);
   grxy->SetMarkerSize(0.5);
   grxy->Draw("P");
   grin->SetMarkerColor(kRed);
   grin->SetMarkerStyle(5);
   grin->SetMarkerSize(0.7);
   grin->Draw("P");
   grout->DrawClone("LP");
}
开发者ID:iahmad-khan,项目名称:root,代码行数:19,代码来源:approx.C

示例14: aPath

TList * aPath(TString tag, TString label,vector<module> modules){
  TList * result=new TList();

  bool canProceed=false;
  int Ndiv=0;
  for (int i=0;i!=(int)modules.size();++i){if(get(modules[i].name)) {canProceed=true;Ndiv++;}}
  if (!canProceed) return result;

  TCanvas * c = new TCanvas("c_"+tag,"timing for "+label+"path",modules.size()*bsize,bsize);
  c->Divide(modules.size(),1);
  //  c->Divide(Ndiv,1);
  TCanvas * d = new TCanvas("d_"+tag,"truncated mean for "+label+"path",modules.size()*bsize,bsize);
  d->Divide(modules.size(),1);
  //  d->Divide(Ndiv,1);

  result->Add(c);
  result->Add(d);
  
  for (int i=0;i!=(int)modules.size();++i){
    TH1F * h = get(modules[i].name);
    if (!h) {
      //      i--;
      continue;}
    c->cd(i+1)->SetGrid();
    if (modules[i].log) 
      c->cd(i+1)->SetLogy();

    if (modules[i].max!=-1){
      //resize the axis
      SetX(h,modules[i].max);}
    h->SetXTitle("time [ms]");
    h->Draw();
    //plot the means
    pave(h,modules[i].min)->Draw();
    d->cd(i+1)->SetGrid();
    TGraph * tr=truncatedMean(h,modules[i].max);
    tr->Draw("apl");
    tr->GetXaxis()->SetTitle("min time [ms]");
    tr->GetYaxis()->SetTitle("mean time starting from min [ms]");
    tr->GetXaxis()->SetRange(0,tr->GetXaxis()->FindBin(modules[i].max));
  }
  return result;}
开发者ID:vlimant,项目名称:usercode,代码行数:42,代码来源:ShowMe.C

示例15: sigHist

void sigHist(TChain & EventsVBF, TChain & EventsGF, string variable, string title, int nBins, float min, float max, float GF, float VBF ){

  TCanvas c("");
  TH1F *hVBF = new TH1F("hVBF","hVBF", nBins, min, max);
  TH1F *hGF = new TH1F("hGF","hGF", nBins, min, max);
  EventsVBF.Project("hVBF",variable.c_str() );
  EventsGF.Project("hGF",variable.c_str() );
  //hVBF->Draw();
  EventsVBF.Draw("h.mass()");
  TH1F * h = new TH1F(title.c_str(),title.c_str(), nBins, min,max);

  
  h->Add(hVBF,hGF,VBF,GF);

    h->SetLineColor(kBlue+1);
    h->SetFillColor(kAzure+7);

  //h->SetLineColor(kMagenta+3);
  //h->SetFillColor(kMagenta-3);

  //    h->SetLineColor(kTeal+3);
  //  h->SetFillColor(kTeal+2);

  //  h->SetLineColor(kOrange+7);
  //  h->SetFillColor(kYellow-9);

  h->SetMarkerStyle(0);
  h->SetTitle( ("H350, "+title).c_str() );
  h->SetXTitle("m_{H} (GeV/c^{2})");
  //h->hGF->GetXaxis()->SeXmin();
  //h->Scale(1/h->GetEntries());
  h->Draw("HIST");

  h->Write();
  //c.SaveAs( (title+".eps").c_str() );
  delete hVBF;
  delete hGF;
  delete h;

}
开发者ID:decosa,项目名称:usercode,代码行数:40,代码来源:plots.cpp


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