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


C++ TH2D::Delete方法代码示例

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


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

示例1: makeTable


//.........这里部分代码省略.........
  fitSlices(hb,fGaus);

  TH1D* hNpartMean = (TH1D*)gDirectory->Get("hNpart_1");
  TH1D* hNpartSigma = (TH1D*)gDirectory->Get("hNpart_2");
  TH1D* hNcollMean = (TH1D*)gDirectory->Get("hNcoll_1");
  TH1D* hNcollSigma = (TH1D*)gDirectory->Get("hNcoll_2");
  TH1D* hNhardMean = (TH1D*)gDirectory->Get("hNhard_1");
  TH1D* hNhardSigma = (TH1D*)gDirectory->Get("hNhard_2");
  TH1D* hbMean = (TH1D*)gDirectory->Get("hb_1");
  TH1D* hbSigma = (TH1D*)gDirectory->Get("hb_2");

  cout<<"-------------------------------------"<<endl;
  cout<<"# Bin NpartMean NpartSigma NcollMean NcollSigma bMean bSigma BinEdge"<<endl;

  // Enter values in table
  for(int i = 0; i < nbins; ++i){
     int ii = nbins-i;
     bins->table_[i].n_part_mean = hNpartMean->GetBinContent(ii);
     bins->table_[i].n_part_var = hNpartSigma->GetBinContent(ii);
     bins->table_[i].n_coll_mean = hNcollMean->GetBinContent(ii);
     bins->table_[i].n_coll_var = hNcollSigma->GetBinContent(ii);
     bins->table_[i].b_mean = hbMean->GetBinContent(ii);
     bins->table_[i].b_var = hbSigma->GetBinContent(ii);
     bins->table_[i].n_hard_mean = hNhardMean->GetBinContent(ii);
     bins->table_[i].n_hard_var = hNhardSigma->GetBinContent(ii);
     bins->table_[i].bin_edge = binboundaries[ii-1];

     cout<<i<<" "
	 <<hNpartMean->GetBinContent(ii)<<" "
	 <<hNpartSigma->GetBinContent(ii)<<" "
	 <<hNcollMean->GetBinContent(ii)<<" "
	 <<hNcollSigma->GetBinContent(ii)<<" "
	 <<hbMean->GetBinContent(ii)<<" "
	 <<hbSigma->GetBinContent(ii)<<" "
	 <<binboundaries[ii]<<" "
	 <<endl;
  }
  cout<<"-------------------------------------"<<endl;

  // Save the table in output file
  if(onlySaveTable){

     hNpart->Delete();
     hNpartMean->Delete();
     hNpartSigma->Delete();
     hNcoll->Delete();
     hNcollMean->Delete();
     hNcollSigma->Delete();
     hNhard->Delete();
     hNhardMean->Delete();
     hNhardSigma->Delete();
     hb->Delete();
     hbMean->Delete();
     hbSigma->Delete();
  }
 
  }else{
    cout<<"-------------------------------------"<<endl;
    cout<<"# Bin NpartMean NpartSigma NcollMean NcollSigma bMean bSigma BinEdge"<<endl;

    // Enter values in table
    for(int i = 0; i < nbins; ++i){
      int ii = nbins-i;
      bins->table_[i].n_part_mean = inputMCtable->NpartMeanOfBin(i);
      bins->table_[i].n_part_var = inputMCtable->NpartSigmaOfBin(i);
      bins->table_[i].n_coll_mean = inputMCtable->NcollMeanOfBin(i);
      bins->table_[i].n_coll_var = inputMCtable->NcollSigmaOfBin(i);
      bins->table_[i].b_mean = inputMCtable->bMeanOfBin(i);
      bins->table_[i].b_var = inputMCtable->bSigmaOfBin(i);
      bins->table_[i].n_hard_mean = inputMCtable->NhardMeanOfBin(i);
      bins->table_[i].n_hard_var = inputMCtable->NhardSigmaOfBin(i);
      bins->table_[i].bin_edge = binboundaries[ii-1];

      cout<<i<<" "
	  <<bins->table_[i].n_part_mean<<" "
          <<bins->table_[i].n_part_var<<" "
          <<bins->table_[i].n_coll_mean<<" "
          <<bins->table_[i].n_coll_var<<" "
          <<bins->table_[i].b_mean<<" "
          <<bins->table_[i].b_var<<" "
          <<bins->table_[i].n_hard_mean<<" "
          <<bins->table_[i].n_hard_var<<" "
          <<bins->table_[i].bin_edge<<" "<<endl;

    }
    cout<<"-------------------------------------"<<endl;

  }


  outFile->cd(); 
  dir->cd();

  bins->SetName(Form("run%d",1));
  bins->Write();
  nt->Write();  
  bins->Delete();
  outFile->Write();
  
}
开发者ID:geonmo,项目名称:cmg-cmssw,代码行数:101,代码来源:makeTable.C

示例2: makeCentralityTable


//.........这里部分代码省略.........
     hNpart->Fill(parameter,npart);
     hNcoll->Fill(parameter,ncoll);
     hNhard->Fill(parameter,nhard);
     hb->Fill(parameter,b);
  }

  // Fitting Glauber distributions in bins to get mean and sigma values


  TF1* fGaus = new TF1("fb","gaus(0)",0,2); 
  fGaus->SetParameter(0,1);
  fGaus->SetParameter(1,0.04);
  fGaus->SetParameter(2,0.02); 
  
  fitSlices(hNpart,fGaus);
  fitSlices(hNcoll,fGaus);
  fitSlices(hNhard,fGaus);
  fitSlices(hb,fGaus);

 /*
  hNpart->FitSlicesY();
  hNcoll->FitSlicesY();
  hNhard->FitSlicesY();
  hb->FitSlicesY();
 */

  TH1D* hNpartMean = (TH1D*)gDirectory->Get("hNpart_1");
  TH1D* hNpartSigma = (TH1D*)gDirectory->Get("hNpart_2");
  TH1D* hNcollMean = (TH1D*)gDirectory->Get("hNcoll_1");
  TH1D* hNcollSigma = (TH1D*)gDirectory->Get("hNcoll_2");
  TH1D* hNhardMean = (TH1D*)gDirectory->Get("hNhard_1");
  TH1D* hNhardSigma = (TH1D*)gDirectory->Get("hNhard_2");
  TH1D* hbMean = (TH1D*)gDirectory->Get("hb_1");
  TH1D* hbSigma = (TH1D*)gDirectory->Get("hb_2");

  cout<<"-------------------------------------"<<endl;
  cout<<"# Bin NpartMean NpartSigma NcollMean NcollSigma bMean bSigma BinEdge"<<endl;


  // Enter values in table
  for(int i = 0; i < nbins; ++i){
     bins->table_[nbins-i-1].n_part_mean = hNpartMean->GetBinContent(i);
     bins->table_[nbins-i-1].n_part_var = hNpartSigma->GetBinContent(i);
     bins->table_[nbins-i-1].n_coll_mean = hNcollMean->GetBinContent(i);
     bins->table_[nbins-i-1].n_coll_var = hNcollSigma->GetBinContent(i);
     bins->table_[nbins-i-1].b_mean = hbMean->GetBinContent(i);
     bins->table_[nbins-i-1].b_var = hbSigma->GetBinContent(i);
     bins->table_[nbins-i-1].n_hard_mean = hNhardMean->GetBinContent(i);
     bins->table_[nbins-i-1].n_hard_var = hNhardSigma->GetBinContent(i);
     bins->table_[nbins-i-1].bin_edge = binboundaries[i];

     cout<<i<<" "
	 <<hNpartMean->GetBinContent(i)<<" "
	 <<hNpartSigma->GetBinContent(i)<<" "
	 <<hNcollMean->GetBinContent(i)<<" "
	 <<hNcollSigma->GetBinContent(i)<<" "
	 <<hbMean->GetBinContent(i)<<" "
	 <<hbSigma->GetBinContent(i)<<" "
	 <<binboundaries[i]<<" "
	 <<endl;
  }
  cout<<"-------------------------------------"<<endl;

  // Save the table in output file

  if(onlySaveTable){

     TH1D* hh = (TH1D*)gDirectory->Get("hNpart_0");
     hh->Delete();
     hh = (TH1D*)gDirectory->Get("hNcoll_0");
     hh->Delete();
     hh = (TH1D*)gDirectory->Get("hNhard_0");
     hh->Delete();
     hh = (TH1D*)gDirectory->Get("hb_0");
     hh->Delete();

     hNpart->Delete();
     hNpartMean->Delete();
     hNpartSigma->Delete();
     hNcoll->Delete();
     hNcollMean->Delete();
     hNcollSigma->Delete();
     hNhard->Delete();
     hNhardMean->Delete();
     hNhardSigma->Delete();
     hb->Delete();
     hbMean->Delete();
     hbSigma->Delete();
  }
  
  for(int i = 0; i < runnums.size(); ++i){
     CentralityBins* binsForRun = (CentralityBins*) bins->Clone();
     binsForRun->SetName(Form("run%d",runnums[i]));
     binsForRun->Write();
  }
  
  bins->Delete();
  outFile->Write();
  
}
开发者ID:KiSooLee,项目名称:TnP_B,代码行数:101,代码来源:makeCentralityTable.C

示例3: parm

HardRecoil_Manager::HardRecoil_Manager(const char* parameter_filename) {

  PParameterReader parm(parameter_filename);
  std::cout << "HardRecoil_Manager Initialization" << std::endl;

  ptnbins = parm.GetInt("HardRecoil_pTbins");
  ptbins = parm.GetVDouble("HardRecoil_pTbins_edges");
  zbsetmodel = parm.GetBool("HardRecoil_zbsetmodel", kFALSE);
  run3bool = parm.GetBool("Run3");
  run4bool = parm.GetBool("Run4");

 if (run3bool == run4bool && zbsetmodel) {
    std::cout << "ERROR:  HardRecoil_Manager can only process Run3 or Run4 at a time.  Set only one of the Run3 and Run4 parameters at top of parameters file to true." << std::endl;
    exit(0);
  }

  if(zbsetmodel){
    ptnbinsset = parm.GetInt("HardRecoil_pTbinsSET");
    ptbinsset = parm.GetVDouble("HardRecoil_pTbinsSET_edges");
    luminbins = parm.GetInt("HardRecoil_lumibins");
    lumibins = parm.GetVDouble("HardRecoil_lumibins_edges");
    dphinbins = parm.GetInt("HardRecoil_dphibins");
    dphibins = parm.GetVDouble("HardRecoil_dphibins_edges");

    zphirespnbins = parm.GetInt("HardRecoil_zphirespbins");
    zphirespbins = parm.GetVDouble("HardRecoil_zphirespbins_edges");
    if(run3bool){
      zphirespA = parm.GetVDouble("HardRecoil_zphiresp_ParameterA");
      zphirespB = parm.GetVDouble("HardRecoil_zphiresp_ParameterB");
      zphirespC = parm.GetVDouble("HardRecoil_zphiresp_ParameterC");
      zphirespD = parm.GetVDouble("HardRecoil_zphiresp_ParameterD");
      zphirespMean = parm.GetVDouble("HardRecoil_zphiresp_Mean");
    }else{
      zphirespA = parm.GetVDouble("HardRecoil_zphiresp_ParameterA_run4");
      zphirespB = parm.GetVDouble("HardRecoil_zphiresp_ParameterB_run4");
      zphirespC = parm.GetVDouble("HardRecoil_zphiresp_ParameterC_run4");
      zphirespD = parm.GetVDouble("HardRecoil_zphiresp_ParameterD_run4");
      zphirespMean = parm.GetVDouble("HardRecoil_zphiresp_Mean_run4");
    }
  }else{
    ptnbinsset = ptnbins;
    ptbinsset = ptbins;
  }

  flipped = false;

  if(parm.GetInt("EtFlowFudge")==8){//so don't grab file for old versions of etflow, like option 3
    TString etflow_fname(parm.GetChar("EtFlowFile"));
    TFile* etflow_binned_file = new TFile(etflow_fname);
    etflow_binned3 = (TH1D*) etflow_binned_file->Get("etflow_run2b3");
    etflow_binned4 = (TH1D*) etflow_binned_file->Get("etflow_run2b4");
    etflow_binned3->SetDirectory(0);
    etflow_binned4->SetDirectory(0);
    etflow_binned_file->Close();
  }


  // hard recoil library file
  if (getenv("HRLibraryRootPath") == NULL ) {
    std::cout << "ERROR:  HRLibraryRootPath is not defined" << std::endl;
    exit(0);
  }
 
  TString hrLibraryRootPath(getenv("HRLibraryRootPath"));
  TString model_filename = "";
  if(run3bool) model_filename = hrLibraryRootPath + '/' + parm.GetChar("HardRecoil_FileName"); 
  else{
    if (zbsetmodel) model_filename = hrLibraryRootPath + '/' + parm.GetChar("HardRecoil_FileName_run4"); 
    else model_filename = hrLibraryRootPath + '/' + parm.GetChar("HardRecoil_FileName"); //backwards compatibility
  }
  std::cout << model_filename << " will be used for hard recoil model" << std::endl;
  TFile* tf = new TFile(model_filename);
    
  for (Int_t j=0; j<ptnbins; j++) {
    
    if(! zbsetmodel){
      TH2D* HRHist = (TH2D*) tf->Get(TString::Format("recoil_resp_hist_bin_%d", j));
      resp_pdf.push_back(new TH2rclsa(*HRHist));
      HRHist->Delete();
      resp_pdf[j]->SetDirectory(0);
      resp_pdf[j]->ComputeYIntegral();
      resp_pdf[j]->ComputeIntegral();  
     
    }else{ //we will assign histograms below to be resp_pdf and resp_zbset_pdf later in the code
      //dphi model is in true phi bins, other two in true zpt bins (and others)
     
      if(luminbins !=7 || dphinbins !=6) {
	std::cout<<"settings for number of lumi or dphi bins is not correct.  HardRecoil_Manager code must be altered for other binning."<<std::endl;
	exit(0);
      }

      TH2D* HRHist0 = (TH2D*) tf->Get(TString::Format("recoil_resp_hist_truephi0_bin_%d", j)); //0th
      resp_pdf0.push_back(new TH2rclsa(*HRHist0));
      HRHist0->Delete();
      resp_pdf0[j]->SetDirectory(0);
      
      TH2D* HRHist1 = (TH2D*) tf->Get(TString::Format("recoil_resp_hist_truephi1_bin_%d", j));
      resp_pdf1.push_back(new TH2rclsa(*HRHist1));
      HRHist1->Delete();
      resp_pdf1[j]->SetDirectory(0);
//.........这里部分代码省略.........
开发者ID:rafaellopesdesa,项目名称:wz_epmcs,代码行数:101,代码来源:HardRecoil_Manager.cpp


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