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


C++ TH1::Clone方法代码示例

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


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

示例1: GroupByStation

//_________________________________________________________________________________________________
void GroupByStation(AliMergeableCollection& hc, int timeResolution)
{
  int station(1);
  
  for ( Int_t ich = 1; ich < 10; ich += 2 )
  {
    TH1* h = hc.Histo(Form("/CHAMBER/HITS/%ds/CHAMBER%d",timeResolution,ich));
    TH1* h1 = hc.Histo(Form("/CHAMBER/HITS/%ds/CHAMBER%d",timeResolution,ich+1));
    
    TH1* hstation = static_cast<TH1*>(h->Clone(Form("STATION%d",station)));
    
    hstation->Add(h1);
    hc.Adopt(Form("/STATION/HITS/%ds",timeResolution),hstation);

    h = hc.Histo(Form("/CHAMBER/HITS/%ds/CHAMBER%dLEFT",timeResolution,ich));
    h1 = hc.Histo(Form("/CHAMBER/HITS/%ds/CHAMBER%dLEFT",timeResolution,ich+1));
    
    hstation = static_cast<TH1*>(h->Clone(Form("STATION%dLEFT",station)));
    
    hstation->Add(h1);
    hc.Adopt(Form("/STATION/HITS/%ds",timeResolution),hstation);

    h = hc.Histo(Form("/CHAMBER/HITS/%ds/CHAMBER%dRIGHT",timeResolution,ich));
    h1 = hc.Histo(Form("/CHAMBER/HITS/%ds/CHAMBER%dRIGHT",timeResolution,ich+1));
    
    hstation = static_cast<TH1*>(h->Clone(Form("STATION%dRIGHT",station)));
    
    hstation->Add(h1);
    hc.Adopt(Form("/STATION/HITS/%ds",timeResolution),hstation);
    
    ++station;
  }
}
开发者ID:aphecetche,项目名称:acode,代码行数:34,代码来源:OccupancyInTimeBins.C

示例2: GroupByChamber

//_________________________________________________________________________________________________
void GroupByChamber(AliMergeableCollection& hc, int timeResolution)
{
  for ( Int_t ich = 1; ich <= 10; ++ich )
  {
    AliMpDEIterator it;
  
    it.First(ich-1);
  
    TH1* hchamberLeft(0x0);
    TH1* hchamberRight(0x0);
    TList listLeft;
    TList listRight;
    listLeft.SetOwner(kFALSE);
    listRight.SetOwner(kFALSE);
    
    AliMpDCSNamer dcs("TRACKER");

    while (!it.IsDone())
    {
      Int_t detElemId = it.CurrentDEId();

       AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
    
      TH1* h = hc.Histo(Form("/DE/HITS/%ds/DE%04d",timeResolution,detElemId));
      
      if (dcs.DCSAliasName(detElemId).Contains("Left"))
      {
        if (!hchamberLeft)
        {
          hchamberLeft = static_cast<TH1*>(h->Clone(Form("CHAMBER%dLEFT",ich)));
        }
        else
        {
          listLeft.Add(h);
        }
      }
      else
      {
        if (!hchamberRight)
        {
          hchamberRight = static_cast<TH1*>(h->Clone(Form("CHAMBER%dRIGHT",ich)));
        }
        else
        {
          listRight.Add(h);
        }
      }
      
      it.Next();
    }
    
    hchamberLeft->Merge(&listLeft);
    hchamberRight->Merge(&listRight);
    hc.Adopt(Form("/CHAMBER/HITS/%ds",timeResolution),hchamberLeft);
    hc.Adopt(Form("/CHAMBER/HITS/%ds",timeResolution),hchamberRight);
    TH1* hchamber = static_cast<TH1*>(hchamberLeft->Clone(Form("CHAMBER%d",ich)));
    hchamber->Add(hchamberRight);
    hc.Adopt(Form("/CHAMBER/HITS/%ds",timeResolution),hchamber);
  }
}
开发者ID:aphecetche,项目名称:acode,代码行数:61,代码来源:OccupancyInTimeBins.C

示例3: GetEffHist

// ===  FUNCTION  ============================================================
//         Name:  TPlot::GetEffHist
//  Description:  
// ===========================================================================
TH1* TPlot::GetEffHist(std::string Eff, std::string det, std::string algo)
{

  TH1* hNum = GetHist1D(listEff[Eff].first, det, algo);

  TH1* hDem = GetHist1D(listEff[Eff].second, det, algo);

  TH1* temp = (TH1*)hNum->Clone(Eff.c_str());

  assert(hNum->GetNbinsX() == hDem->GetNbinsX());
  for (int i = 0; i < hNum->GetNbinsX(); ++i)
  {
    double val = hNum->GetBinContent(i) / hDem->GetBinContent(i);
    double valerr = val * sqrt( pow(hNum->GetBinError(i)/hNum->GetBinContent(i), 2) +
        pow(hDem->GetBinError(i)/hDem->GetBinContent(i), 2) );
    if (isnan(val)) { val = 0; valerr = 0; }
    temp->SetBinContent(i, val);
    temp->SetBinError(i, valerr);
    std::cout << " bin " <<i <<" val " << val << std::endl;
  }

  //temp->Divide(hDem);
  temp->GetYaxis()->SetTitle("Efficiency");

  return temp;
}       // -----  end of function TPlot::GetEffHist  -----
开发者ID:zhenbinwu,项目名称:PFAnalyzer,代码行数:30,代码来源:TPlot.C

示例4: dominik

void dominik()
{
  TH1* matHistogramRoman = static_cast<TH1*>(extractObjectFromFile("lyRoman.root", "lightYieldProjectionY")->At(0));
  TList* objects = extractObjectFromFile("c.root", "chargeBins");
  TH1* matHistogramDominik = new TH1D("matHistogramDominik", ";channel;light yield / pixels", 512, -0.5, 512-0.5);
  int sipmIt = 0;
  for (int i = 0; i < objects->GetSize(); ++i) {
    TH1* h = static_cast<TH1*>(objects->At(i));
    if (h->GetLineColor() == 8) {
      for (int bin = 1; bin <= 128; ++bin) {
        matHistogramDominik->SetBinContent(512 - (sipmIt * 128 + bin - 1), h->GetBinContent(bin));
        if (h->GetBinError(bin) > 0)
          matHistogramDominik->SetBinError(512 - (sipmIt * 128 + bin - 1), h->GetBinError(bin));
      }
      ++sipmIt;
    }
  }
  TCanvas* c = new TCanvas;
  c->Divide(1, 2);
  c->cd(1);
  matHistogramDominik->Draw();
  matHistogramRoman->Draw("SAME");
  c->cd(2);
  TH1* h = static_cast<TH1*>(matHistogramDominik->Clone());
  h->Add(matHistogramRoman, -1);
  h->Draw();
}
开发者ID:Dominik-Mitzel,项目名称:radiatedModule,代码行数:27,代码来源:dominik.C

示例5: GroupByDDL

//_________________________________________________________________________________________________
void GroupByDDL(AliMergeableCollection& hc, int timeResolution)
{
  Int_t nddls = AliDAQ::NumberOfDdls("MUONTRK");
  Int_t offset = AliDAQ::DdlIDOffset("MUONTRK");
  
  for ( Int_t i = 0; i < nddls; ++i )
  {
    Int_t ddlId = offset + i;
    
    AliMpDDL* ddl = AliMpDDLStore::Instance()->GetDDL(i);
    
    TH1* hddl(0x0);
    TList list;
    list.SetOwner(kFALSE);
    
    for ( Int_t ide = 0; ide < ddl->GetNofDEs(); ++ide )
    {
      Int_t detElemId = ddl->GetDEId(ide);
      
      TH1* h = hc.Histo(Form("/DE/HITS/%ds/DE%04d",timeResolution,detElemId));
      
      if (!hddl)
      {
        hddl = static_cast<TH1*>(h->Clone(Form("DDL%d",ddlId)));
      }
      else
      {
        list.Add(h);
      }
    }
    
    hddl->Merge(&list);
    hc.Adopt(Form("/DDL/HITS/%ds",timeResolution),hddl);
  }
}
开发者ID:aphecetche,项目名称:acode,代码行数:36,代码来源:OccupancyInTimeBins.C

示例6: get

// Extract and merge histograms in range [from, to) (to is not included)
//
TH1 *merge(const string &path, TFile **input, const int &from, const int &to,
        const bool &do_normalize = false)
{
    TH1 *result = 0;
    for(int i = from; to > i; ++i)
    {
        TH1 *hist = get(path, input[i], i);
        if (!hist)
        {
            cerr << "failed to extract: " << path << endl;

            continue;
        }

        if (!result)
            result = dynamic_cast<TH1 *>(hist->Clone());
        else
            result->Add(hist);
    }

    if (do_normalize
            && result
            && result->GetEntries())
    {
        result->Scale(1. / result->Integral());
    }

    return result;
}
开发者ID:PerilousApricot,项目名称:bsm_analyze,代码行数:31,代码来源:fig.C

示例7: testGlobalStyle

// Test the global style settings for a generic histogram.  
void styles::testGlobalStyle(bool fixY, float scale) {
  
  readGroupStyle(); setGlobalStyle(); setDefaultStyle();
  
  TH1* h = new TH1F("h", "h", 50, 0, 50);
  TH1* hc[6];
  for (int i=1; i<=50; i++) {
    double value = scale*exp(-0.5*pow(((i-25.)/5.),2));  // Gaussian shape
    h->SetBinContent(i, value);
  }

  TCanvas c;
  if(nPads == 2) c.Divide(2);
  if(nPads == 3) c.Divide(3);
  if(nPads == 4) c.Divide(2,2);
  if(nPads == 6) c.Divide(3,2);
  c.cd(1);
  h->Draw();
  if(fixY) moveYAxisLabel(h,100);
  setTitles(h, "D^{(*)0/+} channels", "xlabel^{2}_{miss} (GeV^{2})", "Events/(10 MeV^{2})");
  float scales[] = {0.1, 10, 0.01};
  for(int pads = 2; pads<=4; pads++){
    if(nPads>=pads){
      c.cd(pads);
      hc[pads-2] = static_cast<TH1F*>(h->Clone());
      hc[pads-2]->Scale(scales[pads-2]); 
      if(fixY) moveYAxisLabel(hc[pads-2],hc[pads-2]->GetMaximum());
      hc[pads-2]->Draw();
      setTitles(hc[pads-2], "D^{(*)0/+} channels", "xlabel^{2}_{miss} (GeV^{2})", "Events/(1000 MeV^{2})");
    }
  }
  TString epsName = "babar_code/styles/Plot_"; epsName += nPads; epsName += "Pads.eps";
  c.Print(epsName);
  
}
开发者ID:manuelfs,项目名称:babar_code,代码行数:36,代码来源:styles.cpp

示例8: GetHist

TH1* GetHist(const std::string histname, const float scaleTo=1.0)
{
	TH1 *res_hist = 0;

	if (! bFLATSAMPLE)
	{
		TH1 *hists[nBins];

		for (int i=0; i<nBins; ++i)
		{
			hists[i] = 0; 
			if (files[i]->IsZombie())
			{
				cout << files[i]->GetName() << " not found!" <<  endl;
				assert (false);
			} else
			{
				hists[i] = dynamic_cast<TH1*> (files[i]->Get(histname.c_str()));
				if (hists[i] == 0 )
				{
					cout << "hist_pass " << histname << " not found in " << files[i]->GetName() << "!" << endl;
					assert (false);
				} else 
				{
					hists[i]->Sumw2();

					//temp: no scaling for lumi wgted samples
					//const float scale = scaleTo/ ( nEvents[i] / xSec[i] );
					//hists[i]->Scale(scale);

					if (i == 0) 
					{ 
						res_hist = dynamic_cast<TH1*> (hists[i]->Clone("histcopy")); 
						res_hist->SetDirectory(0);
					} else { res_hist->Add(hists[i]); }
				}
			}
		}

	} else
	{
		TFile f(sQCD_FLAT_FILE_NAME.c_str());
		if (f.IsZombie())
		{
			cout << __FUNCTION__ << ":" << __LINE__ << ":file " << sQCD_FLAT_FILE_NAME << " not found!"<< endl;
			assert(false);
		}
		TH1* hist = dynamic_cast<TH1*> (f.Get(histname.c_str()));
		if (hist == NULL)
		{
			cout << __FUNCTION__ << ":" << __LINE__ << ": " << histname << " not found!"<< endl;
			assert(false);
		}
		res_hist = dynamic_cast<TH1*> (hist->Clone());
		res_hist->SetDirectory(0);
	}

	return res_hist;
}
开发者ID:hkaushalya,项目名称:UserCode,代码行数:59,代码来源:makePassFail_QCDMC.C

示例9: Run

  //____________________________________________________________________
  void Run(const char* newName,        const char* oldName,
	   const char* newTitle="New", const char* oldTitle="Old")
  {
    TFile* newFile = TFile::Open(newName,"READ");
    TFile* oldFile = TFile::Open(oldName,"READ");
    if (!newFile || !oldFile) return;

    TH1* newCent = GetH1(newFile, "realCent");
    TH1* oldCent = GetH1(oldFile, "realCent");
    if (!newCent || !oldCent) return;

    TString  t; t.Form("#it{R}=#frac{%s}{%s}", newTitle, oldTitle);
    TCanvas* c     = new TCanvas("c", t, 1200, 800);
    c->SetTopMargin(0.01);
    c->SetRightMargin(0.20);
    fLegend = new TLegend(1-c->GetRightMargin(),
			  c->GetBottomMargin(),
			  1, 1-c->GetTopMargin(),
			  t);
    fLegend->SetFillStyle(0);
    fLegend->SetBorderSize(0);
    THStack* stack = new THStack("ratios","");
			       
    fMin = +1e6;
    fMax = -1e6;
    TH1* one = 0;
    for (Int_t i = newCent->GetNbinsX(); i--;) {
      Double_t c1 = newCent->GetXaxis()->GetBinLowEdge(i+1);
      Double_t c2 = newCent->GetXaxis()->GetBinUpEdge(i+1);
      Info("", "c1=%f c2=%f", c1, c2);
      TH1*     r  = One(newFile, oldFile, c1, c2);    
      if (!r) continue;
      if (!one) {
	one = static_cast<TH1*>(r->Clone("one"));
	one->SetDirectory(0);
	one->Reset();
	for (Int_t j = 1; j <= one->GetNbinsX(); j++) {
	  one->SetBinContent(j,1);
	  one->SetBinError  (j,0);
	}
      }
      // r->Add(one, i-1);
      // r->Scale(TMath::Power(10,i));
      stack->Add(r);
    }
    stack->Draw("nostack");
    stack->SetMinimum(0.95*fMin);
    stack->SetMaximum(1.05*fMax);
    stack->GetHistogram()->SetXTitle("#eta");
    stack->GetHistogram()->SetYTitle("#it{R}");
    fLegend->Draw();
    c->Modified();
    c->Update();
    c->cd();
    c->SaveAs(Form("%sover%s.png", newTitle, oldTitle));
  }  
开发者ID:ktf,项目名称:AliPhysics,代码行数:57,代码来源:CompareResults.C

示例10: fancyMerge

void fancyMerge( std::string beam, std::string target, std::string energy, std::string physlist, bool doScale=false )
{
      
   std::string output = beam + target + energy + "GeV" + physlist + ".root" ;
   
   targetFile = TFile::Open( output.c_str(), "RECREATE" );
   
   double scale = 1./32.;
   
   // std::string input = beam + target + model + energy + "GeV-1.root";
   // std::string input = "../t23-bld/harp-histo-no-res-decays/" + beam + target + energy + "GeV" + physlist +"-1.root";

   // std::string input = "../t23-bld/harp-histo/" + beam + target + energy + "GeV" + physlist +"-1.root";

   std::string input = "../t23-bld/na49-histo/" + beam + target + energy + "GeV" + physlist +"-1.root";
   
   TFile* iFile1 = TFile::Open( input.c_str() );
   TIter  next( iFile1->GetListOfKeys() );
   TKey*  key = (TKey*)next();
   TH1* h = 0;
   while ( key )
   {   
         if ( !(TClass::GetClass(key->GetClassName())->InheritsFrom(TH1::Class())) ) continue;
         const char* kName = key->GetName();
         h = (TH1*)key->ReadObj();
         const char* hName = h->GetName();
         std::cout << " histoname = " << hName << std::endl;
	 TH1F* h1 = h->Clone();
	 for ( int id=2; id<=32; id++ )
	 {
	    // std::string input_t = "../t23-bld/harp-histo-no-res-decays/" + beam + target + energy + "GeV" + physlist + "-" ;
	    // std::string input_t = "../t23-bld/harp-histo/" + beam + target + energy + "GeV" + physlist + "-" ;
	    std::string input_t = "../t23-bld/na49-histo/" + beam + target + energy + "GeV" + physlist + "-" ;
            char buf[5];
            sprintf( buf, "%i", id );
            input_t.append( buf ); 
            input_t += ".root"; 
	    TFile* iFile_t = TFile::Open( input_t.c_str() );
	    TH1F* h_t = (TH1F*)iFile_t->Get( h->GetName() );
	    h1->Add( h_t );  
	    iFile_t->Close();
	 }
	 if ( doScale )
	 {
	    if (!(strcmp(key->GetClassName(),"TProfile"))) h1->Scale( scale );
	 }
	 targetFile->cd();
	 h1->Write();
         key = (TKey*)next();
   }
   
   targetFile->Close();
     
   return;

}
开发者ID:gpestana,项目名称:thesis,代码行数:56,代码来源:PlotHARPAnalysis.C

示例11:

TH1 *MillePedeTrees::CreateHist(const char *exp, const char *selection, const char *hDef,
                                Option_t* opt)
{
  TH1 *h = this->Draw(exp, selection, hDef, "goff");

  TH1 *hResult = static_cast<TH1*>(h->Clone(Form("%sC", h->GetName())));
  if (opt) hResult->SetOption(opt);

  return hResult;
}
开发者ID:ANSH0712,项目名称:cmssw,代码行数:10,代码来源:MillePedeTrees.C

示例12: Legend

void Legend()
{
  TLegend* leg = new TLegend(.6, .6, .9, .85);
  leg->SetFillStyle(0);

  TH1* dummy = new TH1F("", "", 1, 0, 1);
  dummy->SetMarkerStyle(kFullCircle);
  leg->AddEntry(dummy->Clone(), "Fake Data", "lep");
  dummy->SetLineColor(kTotalMCColor);
  leg->AddEntry(dummy->Clone(), "Total MC", "l");
  dummy->SetLineColor(kNCBackgroundColor);
  leg->AddEntry(dummy->Clone(), "NC", "l");
  dummy->SetLineColor(kNumuBackgroundColor);
  leg->AddEntry(dummy->Clone(), "#nu_{#mu} CC", "l");
  dummy->SetLineColor(kBeamNueBackgroundColor);
  leg->AddEntry(dummy->Clone(), "Beam #nu_{e} CC", "l");

  leg->Draw();
}
开发者ID:DUNE,项目名称:lblpwgtools,代码行数:19,代码来源:kirk_dune.C

示例13: combExpr

TProfile *MillePedeTrees::CreateHistProf(const char *expX, const char *expY, const char *selection,
                                         const char *hDef, Option_t* opt)
{

  const TString combExpr(Form("%s:%s", expY, expX));
  TH1 *h = this->Draw(combExpr, selection, hDef, "goff prof");

  TProfile *hResult = static_cast<TProfile*>(h->Clone(Form("%sClone", h->GetName())));
  if (opt) hResult->SetOption(opt);

  return hResult;
}
开发者ID:ANSH0712,项目名称:cmssw,代码行数:12,代码来源:MillePedeTrees.C

示例14: GetHist

TH1* GetHist(const string histname)
{
	//hists are already scaled to 10fb-1
	TH1* h = dynamic_cast<TH1*> (files[0]->Get(histname.c_str()));
	if (h == NULL)
	{
		cout << "hist " << histname << " not found in " <<  "!" << endl;
		assert (false);
	}
	TH1* hist = dynamic_cast<TH1*> (h->Clone());
	hist->Sumw2();
	hist->SetLineWidth(2);

	return hist;
}
开发者ID:hkaushalya,项目名称:UserCode,代码行数:15,代码来源:overlay_Merged_RecoSmeared.C

示例15:

TH1 *
YieldMean_ReturnExtremeHisto(TH1 *hin, Float_t sign)
{
  Double_t ptlow, pthigh;
  for (Int_t ibin = 0; ibin < hin->GetNbinsX(); ibin++) {
    if (hin->GetBinError(ibin + 1) <= 0.) continue;
    ptlow = hin->GetBinLowEdge(ibin + 1);
    break;
  }
  for (Int_t ibin = hin->GetNbinsX(); ibin >= 0; ibin--) {
    if (hin->GetBinError(ibin + 1) <= 0.) continue;
    pthigh = hin->GetBinLowEdge(ibin + 2);
    break;
  }

  Double_t mean = hin->GetMean();
  Double_t maxdiff = 0.;
  TH1 *hmax = NULL;
  for (Int_t inode = 0; inode < hin->GetNbinsX(); inode++) {

    Double_t ptnode = hin->GetBinCenter(inode + 1);
    TH1 *hout = (TH1 *)hin->Clone(Form("%s_extremehard", hin->GetName()));
    
    for (Int_t ibin = 0; ibin < hin->GetNbinsX(); ibin++) {
      if (hin->GetBinError(ibin + 1) <= 0.) continue;
      Double_t val = hin->GetBinContent(ibin + 1);
      Double_t err = hin->GetBinError(ibin + 1);
      Double_t cen = hin->GetBinCenter(ibin + 1);
      if (cen < ptnode)
        err *= -1. + (cen - ptlow) / (ptnode - ptlow);
      else
        err *= (cen - ptnode) / (pthigh - ptnode);

      hout->SetBinContent(ibin + 1, val + sign * err);
    }

    Double_t diff = TMath::Abs(mean - hout->GetMean());
    if (diff > maxdiff) {
      //      printf("found max at %f\n", ptnode);
      if (hmax) delete hmax;
      hmax = (TH1 *)hout->Clone("hmax");
      maxdiff = diff;
    }
    delete hout;
  }
  return hmax;
}
开发者ID:ktf,项目名称:AliPhysics,代码行数:47,代码来源:YieldMean.C


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