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


C++ TH1D::Rebin方法代码示例

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


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

示例1: MCtoSTATerrors

void MCtoSTATerrors() {
  TLatex *tplus = labelLatex(0.1364943,0.8114407,"MC sample");

  TFile *file0 = TFile::Open("results/StandardCutflow/allmc.root");

  TCanvas *c1 = new TCanvas();
  //TCanvas *c2 = new TCanvas();
  TH1D * LPplus = (TH1D*)file0->Get("RECO_PolPlots_50toinf/RECO_ICVarPFPlus");
  TH1D * LPminus = (TH1D*)file0->Get("RECO_PolPlots_50toinf/RECO_ICVarPFMinus");

  LPplus->Rebin(20);
  LPminus->Rebin(20);

  LPplus->Scale(0.3);
  LPminus->Scale(0.3);

  TH1D * newLPplus = (TH1D*)LPplus->Clone();
  TH1D * newLPminus = (TH1D*)LPminus->Clone();

  for(unsigned int i=1; i < LPplus->GetXaxis()->GetNbins(); i++) {
    newLPplus->SetBinError(i, TMath::Sqrt(LPplus->GetBinContent(i)));
    newLPminus->SetBinError(i, TMath::Sqrt(LPminus->GetBinContent(i)));
  }

  c1->cd();
  newLPplus->GetYaxis()->SetTitle("Events / 300 nb^{-1}");
  //newLPplus->GetXaxis()->SetTitle("LP(#mu^{+})");
  newLPplus->GetXaxis()->SetTitle("LP(#mu)");
  newLPplus->GetXaxis()->SetRangeUser(-1.0,2.0);
  newLPplus->SetLineWidth(3);
  newLPplus->SetLineStyle(2);
  newLPplus->SetLineColor(kRed);
  newLPplus->DrawCopy();
  tplus->DrawClone("same");

//   c2->cd();
//   newLPminus->GetYaxis()->SetTitle("Events / 100 nb^{-1}");
//   newLPminus->GetXaxis()->SetTitle("LP(#mu^{-})");
  newLPminus->SetLineWidth(3);
  newLPminus->SetLineStyle(2);
  newLPminus->SetLineColor(kBlack);
  newLPminus->DrawCopy("same");
//   tplus->DrawClone("same");

  leg = new TLegend(0.762931,0.720339,0.8649425,0.8622881,NULL,"brNDC");
  leg->AddEntry(newLPplus,"#mu^{+}","l");
  leg->AddEntry(newLPminus,"#mu^{-}","l");

  leg->SetFillColor(kWhite);
  leg->SetBorderSize(0);
  leg->SetTextFont(62);
  leg->DrawClone();

  file0->Close();

  return;
}
开发者ID:bluejelibaby,项目名称:AnalysisV2,代码行数:57,代码来源:MCtoSTATerrors.C

示例2: Drawbbc

void Drawbbc(){
	TFile *f = new TFile("merged.root");
	TH1D* hbbcs;
	TH1D* hbbcn;
	TCanvas *c1;
	TCanvas *c2;
	TLegend *leg = new TLegend(0.5,0.7,0.7,0.85);
	leg->SetBorderSize(0);
	leg->SetFillColor(0);
	leg->SetTextSize(0.048);
	TH2F* bbcsbbcn = (TH2F*)f->Get(Form("bbcsbbcn_0"));
	for(int xcent=1; xcent < 6; xcent++){
		TH1F* bbcsbbcndis_t = (TH1F*)f->Get(Form("bbcsbbcn_%d",xcent));
		bbcsbbcn->Add(bbcsbbcndis_t);
	}
	hbbcs = (TH1D*)bbcsbbcn->ProjectionX("bbcs",0,-1);
	hbbcn = (TH1D*)bbcsbbcn->ProjectionY("bbcn",0,-1);
	hbbcs->Rebin(4);
	hbbcn->Rebin(4);
	c1= new TCanvas();
	c1->cd();
	c1->SetLogy();
	SetTitle(*hbbcs,"bbc charge","# of events","");
	SetRange(*hbbcs,0,1e-1,100,hbbcn->GetMaximum()*5);
	SetStyle(*hbbcs,1.2,1,20,0,0);
	SetStyle(*hbbcn,1.2,2,24,0,0);
	hbbcs->Draw("P");
	hbbcn->Draw("Psame");
	leg->AddEntry(hbbcs,"bbc south");
	leg->AddEntry(hbbcn,"bbc north");
	leg->Draw("same");
	c1->Print(Form("bbcdis.png"));
	c2= new TCanvas();
	c2->cd();
	c2->SetLogy();
	hbbcs_norm = (TH1D*)hbbcs->Clone("hbbcs_norm");
	hbbcn_norm = (TH1D*)hbbcn->Clone("hbbcn_norm");
	hbbcs_norm->Scale(1./hbbcs_norm->Integral());
	hbbcn_norm->Scale(1./hbbcn_norm->Integral());
	SetRange(*hbbcs_norm,0,1e-9,100,1);
	hbbcs_norm->Draw("P");
	hbbcn_norm->Draw("Psame");
	leg->Draw("same");
	c2->Print(Form("bbcdis_norm.png"));	
	c3= new TCanvas();
	c3->cd();
	c3->SetLogz();
	SetTitle(*bbcsbbcn,"bbc charge south","bbc charge north","# of events");
	SetRange(*bbcsbbcn,0,0,100,100);
	bbcsbbcn->Draw("colz");
	c3->Print("bbcsbbcn.png");
}
开发者ID:XuQiao,项目名称:phenix,代码行数:52,代码来源:Drawbbc.C

示例3: getSample

TH1D* getSample(TString sample, double weight){
	TString dir = "rootFilesV4/central/";
	TFile* file = new TFile(dir + sample + "_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root");
	//TDirectoryFile* folder = (TDirectoryFile*) file->Get("TTbarPlusMetAnalysis/QCD No Iso/Muon/");
	
	TH1D* plot = (TH1D*) file->Get("EventCount/"+Variable);

        if(sample == "TTJet"){
	plot->SetFillColor(kRed+1);
        plot->SetLineColor(kRed+1);
	}else if(sample == "WJetsToLNu" || sample == "W1Jet" || sample == "W2Jets"|| sample == "W3Jets"|| sample == "W4Jets"){
	plot->SetLineColor(kGreen-3);	  
  	plot->SetFillColor(kGreen-3);
	}else if(sample == "DYJetsToLL" || sample == "DY1JetsToLL" || sample == "DY2JetsToLL" || sample == "DY3JetsToLL" || sample == "DY4JetsToLL"){
	plot->SetFillColor(kAzure-2);
	plot->SetLineColor(kAzure-2);
	}else if(sample == "QCD_Pt_20_MuEnrichedPt_15" || sample == "QCD_Pt-15to20_MuEnrichedPt5" || sample=="QCD_Pt-15to20_MuEnrichedPt5" || sample =="QCD_Pt-20to30_MuEnrichedPt5" || sample ==    "QCD_Pt-30to50_MuEnrichedPt5" || sample ==    "QCD_Pt-50to80_MuEnrichedPt5" || sample ==    "QCD_Pt-80to120_MuEnrichedPt5" || sample ==   "QCD_Pt-120to170_MuEnrichedPt5" || sample ==  "QCD_Pt-170to300_MuEnrichedPt5" || sample ==  "QCD_Pt-300to470_MuEnrichedPt5" || sample ==  "QCD_Pt-470to600_MuEnrichedPt5" || sample ==  "QCD_Pt-800to1000_MuEnrichedPt5" || sample =="QCD_Pt-1000_MuEnrichedPt5" 	 ){
	plot->SetFillColor(kYellow);
	plot->SetLineColor(kYellow);
	}else if(sample == "T_t-channel" || sample == "T_tW-channel" || sample == "T_s-channel" || sample == "Tbar_t-channel" || sample == "Tbar_tW-channel" || sample == "Tbar_s-channel"){
	plot->SetFillColor(kMagenta);
	plot->SetLineColor(kMagenta);
	}
	
	if(sample != "SingleMu")
	plot->Scale(19.605/19.584);
	//plot->Scale(weight);
	
	plot->Rebin(rebinFact);
	
	return plot;

}
开发者ID:phy6phs,项目名称:DailyCScripts,代码行数:33,代码来源:allCutFlow.C

示例4: getQCD

TH1D* getQCD(int rebinFact){
	TString dir = "rootFiles/";
	
	TFile* file = new TFile(dir +"qcdest.root");		
	TH1D* plot = (TH1D*) file->Get("muon_AbsEta_0btag");

// 	for(int i = 1; i <= plot->GetNbinsX(); i++){
// 	plot->SetBinError(i, 0.0);
// 	}

	plot->SetFillColor(kYellow);
	plot->SetLineColor(kYellow);
	plot->SetMarkerStyle(1);
		
	TH1D* copyplot = new TH1D("qcd plot", "qcd plot", 30, 0.0, 3.0);
	
	for(int i = 1; i <= plot->GetNbinsX(); i++){
	copyplot->SetBinContent(i, plot->GetBinContent(i));
	//copyplot->SetBinError(i, plot->GetBinError(i));
	}
	copyplot->SetFillColor(kYellow);
	copyplot->SetLineColor(kYellow);
	copyplot->SetMarkerStyle(1);
	copyplot->Scale(1./copyplot->Integral());	
	copyplot->Rebin(rebinFact);
	
	//file->Close("R");
	return copyplot;
	//file->Close();
}
开发者ID:nikberry,项目名称:DailyCScripts,代码行数:30,代码来源:etaFit.C

示例5: FitCosTheta

  /*--------------------------------------------*/
 void FitCosTheta()
 /*--------------------------------------------*/
 {

//TH1F *brgauss = new TH1F("breitg","", 131, 0, 130);
TFile * file = new TFile("cosTheta_allnadjieh.root","READ");
 TH1D * h = (TH1D*)file->Get("cosThetaGen");
//h->Scale(1./h->Integral());

 h->Sumw2();
/*TFile * file= new TFile("WPol_SelectedTTBars.root","read");
TH1D* h = (TH1D*)file->Get("costheta_mm/hCosThetaPosLepton_Gen");*/
h->Rebin(10);
//h->Scale(1./h->Integral());
 TF1 *f = new TF1("f",cosTheta, -1, 1 ,3);
 Double_t par[3];
 par[0] = 1;
 par[1] = 1;
 par[2] = h->GetEntries();
 


 f->SetParameters(par);
 
 h->Fit(f, "RBO");
 h->Fit(f, "RBO");
 h->Fit(f, "RBO");
 h->Fit(f, "RBO");
 h->Fit(f, "RBO");

 }
开发者ID:nadjieh,项目名称:work,代码行数:32,代码来源:FitFunc.C

示例6: rebin

void rebin (const char* filename, const char* histname, double rebin=2.0) {
        TFile* f = new TFile(filename,"update");
        TH1D* h = (TH1D*)f->Get(histname);
        h->Rebin(rebin);
        h->Scale(1.0/rebin);
        TFile* fileOut = new TFile(Form("rebin_%s",filename), "update");
        h->Write();
}
开发者ID:maszyman,项目名称:FitResCorr,代码行数:8,代码来源:rebin.C

示例7: GetScaledHisto

TH1D* Prediction::GetScaledHisto(TH1D* histo, float scale_fact, float scale_fact_err){
	// takes histo, scale factor and uncertainty on scale factor
	// and returns scaled and rebinned histo with 1 bin with uncertainty on scale factor propagated.
	TH1D *h        = (TH1D*) histo->Clone(histo->GetName());
	h->Rebin(h->GetNbinsX());
	h->SetBinError(1, sqrt(h->GetBinError(1)*  h->GetBinError(1)   *scale_fact    *scale_fact + 
			  h->GetBinContent(1)*h->GetBinContent(1) *scale_fact_err*scale_fact_err));
	h->SetBinContent(1, h->GetBinContent(1)*scale_fact);
	return h;
}
开发者ID:EsmaeelEskandari,项目名称:MyPHDProjects,代码行数:10,代码来源:run_DataGammaJetsZllToZnunu.C

示例8: getNiceHistogram

TH1D * getNiceHistogram(int nbins, std::vector<Double_t> binning, TFile * file, TString hist) {
  TH1D *sample = (TH1D*)(file->Get(hist)->Clone());
  TH1D *binned = dynamic_cast<TH1D*>(sample->Rebin(nbins,"madgraph",&binning.front()));
  for (Int_t bin=0; bin < nbins; bin++) {
    // Divide rebinned histogram's bin content by bin width factor (new/old):
    binned->SetBinError(bin+1,sqrt(binned->GetBinContent(bin+1))/((binning.at(bin+1)-binning.at(bin))/sample->GetBinWidth(1)));
    binned->SetBinContent(bin+1,binned->GetBinContent(bin+1)/((binning.at(bin+1)-binning.at(bin))/sample->GetBinWidth(1)));
  }
  binned->Scale(1/binned->Integral("width"));
  return binned;
}
开发者ID:simonspa,项目名称:topmassextractor,代码行数:11,代码来源:powheg_vs_data.C

示例9: DrawHistogram

TH1D * DrawHistogram(TList *list, char *name,char *option, Int_t rebin, Int_t color, Int_t marker, Float_t scale, Bool_t draw = kTRUE){

  TH1D *histo = list->FindObject(name);
  histo->SetMarkerColor(color);
  histo->SetMarkerStyle(marker);
  histo->SetLineColor(color);
  histo->Rebin(rebin);
  histo->Scale(1.0/((Float_t)rebin));
  histo->Scale(scale);
  histo->SetMarkerSize(1.2);
  if(draw) histo->Draw(option);
  return histo;
}
开发者ID:ktf,项目名称:AliPhysics,代码行数:13,代码来源:PlotHadEtDistributions.C

示例10: readHist

TH1D* readHist(TString nameHist,TString nameFile, int rebin)
{
 TFile* file = new TFile(nameFile);

 TH1D* hist = (TH1D*)file->Get(nameHist);
 hist->GetSumw2();
 // hist->SetLineWidth(2);
 if(rebin>0) hist->Rebin(rebin);
 hist->GetXaxis()->SetTitleSize(.055);
 hist->GetYaxis()->SetTitleSize(.055);
 hist->GetXaxis()->SetLabelSize(.05);
 hist->GetYaxis()->SetLabelSize(.05);
 hist->SetStats(kFALSE);
 return hist;
}
开发者ID:tapperad,项目名称:HCALprefiringAnalysis,代码行数:15,代码来源:compare_samples.C

示例11:

TH1D* combineRebin10bins(std::vector<TFile*> files, std::string histName, std::vector<double> scalingFactors) {
    TH1::SetDefaultSumw2();
    std::vector<double> massBins = generate10Bins();
    int nBinsX = massBins.size()-1;
    // Get 1st hist in list
    TH1D* h = (TH1D*)files[0]->Get(histName.c_str())->Clone(files[0]->Get(histName.c_str())->GetName());
    h->Scale(scalingFactors[0]);
    
    for (unsigned i = 1; i < files.size(); i++) {
        TH1D* hTmp = (TH1D*) (files[i]->Get(histName.c_str()));
        h->Add(hTmp, scalingFactors[i]);
    }
    // /files[0]->Get(histName.c_str())->GetTitle()
    TH1D* hNew = h->Rebin(nBinsX, files[0]->Get(histName.c_str())->GetTitle(), &massBins[0]);
    return hNew;
}
开发者ID:raggleton,项目名称:4tau_work,代码行数:16,代码来源:paperConvert.C

示例12: getQCD

//always data
TH1D* getQCD(TString Obj, TString Variable, int rebinFact){
	TString dir = "rootFilesV4/central/";
	TFile* file = new TFile(dir + "SingleMu_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root");
	//TDirectoryFile* folder = (TDirectoryFile*) file->Get("TTbarPlusMetAnalysis/QCD No Iso/Muon/");

	TH1D* plot = (TH1D*) file->Get("TTbar_plus_X_analysis/MuPlusJets/QCD non iso mu+jets ge4j/"+Obj+Variable+"0btag");

	plot->SetFillColor(kYellow);
	plot->SetLineColor(kYellow);
    	
	plot->Scale(1/plot->Integral());
	plot->Rebin(rebinFact);

	plot->SetDirectory(gROOT);
	file->Close();

	return plot;

}
开发者ID:phy6phs,项目名称:DailyCScripts,代码行数:20,代码来源:getSamples.C

示例13: Com

TCanvas* Com(TString plot,TString plot_dir,UInt_t rbin, TString xtitle, Double_t max, TString title){
  gROOT->SetStyle("Plain");
  gStyle->SetTitleFontSize(0.07);
 TH1D *Sig = ((TH1D*)Sig->Get(plot_dir+"/"+plot))->Clone();
 TH1D *Bkgd= ((TH1D*)Bkgd->Get(plot_dir+"/"+plot))->Clone();
 Sig->Rebin(rbin);
 Bkgd->Rebin(rbin);
 Sig->Scale(1/(Sig->Integral()));
 Bkgd->Scale(1/(Bkgd->Integral()));
 //TLine *li =new TLine(0.55,0.,0.55,100000);
TCanvas* c = new TCanvas(plot_dir+plot,plot_dir+plot);
 c->SetLogy();

 TLegend *leg = new TLegend(0.5,0.8,0.99,0.99);
 leg->SetFillColor(0);
 leg->AddEntry(Sig,"Selected events","L");
 leg->AddEntry(Bkgd,"Anti-selected events","L");
 Sig->SetLineColor(kRed);
 Sig->SetLineWidth(2);
 Bkgd->SetLineColor(kBlue);
 Bkgd->SetLineWidth(2);
 Sig->Draw("EHIST");
 Bkgd->Draw("HISTSAME");
 leg->Draw("SAME");
 //      li->Draw("SAME");
 Sig->SetTitle(title);

Sig->SetStats(kFALSE);
 Sig->GetXaxis()->SetTitle(xtitle);
 if (max == 999999){

 }
 else{
   Sig->GetXaxis()->SetRangeUser(0.2,max);}
 Sig->GetYaxis()->SetTitle("");
 c->Update();
 c->SaveAs(saving+"IDinv_Delta_"+plot_dir+plot+".png");
 return c;


}
开发者ID:bluejelibaby,项目名称:ZoesThesis,代码行数:41,代码来源:IDInversion.C

示例14: trksplit

void trksplit()
{
  TFile* f = new TFile("../cfg/dihadroncorrelation_wsplit_real_cent010_mc.root");
  TFile* f1 = new TFile("../cfg/dihadroncorrelation_wosplit_cent010_mc.root");
 
  TH1D* hpt = (TH1D*)f->Get("corr_ana_HI/ptall_trg");
  TH1D* hpt1 = (TH1D*)f1->Get("corr_ana_HI/ptall_trg");
  hpt->SetMarkerStyle(20);
  hpt1->SetMarkerStyle(20);
  hpt->SetMarkerColor(4);
  hpt->Rebin(4);
  hpt1->Rebin(4);

  TCanvas* c = new TCanvas("c","c",500,450);
  hpt->SetAxisRange(0,5.0,"X");
  hpt->Draw("PE");
  hpt1->Draw("PESAME");

  TH1D* hratio = (TH1D*)hpt->Clone("hratio");
  hratio->Divide(hpt1);

  TCanvas* c1 = new TCanvas("c1","c1",500,450);
  hratio->Draw("PE");
}
开发者ID:SangeonPark,项目名称:RiceHIG,代码行数:24,代码来源:trksplit.C

示例15: RebinHist

void RebinHist(TH1D* h1, TFile *out)
{
  // This rebinning method doesn't work
  // It needs to divide by the entries to make an average
  // Also, it doesn't include error weighting.
  cout<<"Rebinning histogram"<<endl;
  Int_t nBins = h1->GetNbinsX();
  TH1D *rebinHist = (TH1D*) h1->Clone();
  rebinHist->Rebin(nBins/2);

  // TFile out("Compare.root","update");
  TDirectory *dir = out->GetDirectory("Rebin");
  if(!dir) dir = out->mkdir("Rebin");
  dir->cd();

  TString histName = h1->GetName();
  histName += "Rebin";
  rebinHist->SetName(histName);
  rebinHist->SetTitle(histName);
  rebinHist->SetDirectory(0);
  rebinHist->Write(rebinHist->GetName(), TObject::kOverwrite);
  // out->Close();

}
开发者ID:jsalzwedel,项目名称:AnalysisMacros,代码行数:24,代码来源:CompareCFLADiffCuts.C


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