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


C++ TFile::GetPath方法代码示例

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


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

示例1: FluxErr_nomcheck

void FluxErr_nomcheck(){
    
    //TFile *fop = TFile::Open("/home/kikawa/for_pm_v3/flux_cov/flux_cov_full.root");
    TFile *fop = TFile::Open("/home/cvson/cc1picoh/syst/flux_cov_full.root");
    TMatrixDSym *mat = (TMatrixDSym*)fop->Get("flux_cov");
    if(mat==NULL){
        cout << "Cannot get matrix from " << fop->GetPath() << endl;
        exit;
    }
    
    float cov_mat[nbin][nbin];
    for(int i=0; i<nbin; i++)
        for(int j=0; j<nbin; j++)
            cov_mat[i][j] = (*mat)(i+258, j+258);
    
#ifdef MKPLOT
    draw_matrix(cov_mat);
#endif
    
    float chol_mat[nbin][nbin];
    cholcov_conv(cov_mat, chol_mat);
    
#ifdef MKPLOT
    draw_matrix(chol_mat);
#endif
    
    int nthrows = 1000000;
    float weight[nbin],nrand[nbin];
    TH1F*  hqeint;
    TH1F*  hqedet;
    TH1F*  hnqeint;
    TH1F*  hnqedet;
    TH1F*  hflux;
    
    //TFile *fccqe  = new TFile("cccoh.root");
    //TFile *fccqe  = new TFile("cccoh_frkikawa.root");
    //TFile *fccqe  = new TFile("cccoh_mva.root");
    TFile *fccqe  = new TFile("cccoh_nomcheck.root");
    
    hqeint  = (TH1F*)fccqe  -> Get("qeint");//all signal
    
    hnqeint  = (TH1F*)fccqe  -> Get("nqeint");//all background
    
    hqedet  = (TH1F*)fccqe  -> Get("qedet");//all signal-selected
    
    hnqedet  = (TH1F*)fccqe  -> Get("nqedet");// all background-selected
    
    hflux   = (TH1F*)fccqe  -> Get("flux");
    
    
    //TFile *fout = new TFile("toymc_nom.root","recreate");
    TFile *fout = new TFile("toymc_nomcheck.root","recreate");
    
    TTree *tree = new TTree("tree","tree");
    //float pm,ing,pm_int,ing_int,pm_det,ing_det;
    //float pm_ccint,ing_ccint,pm_ccdet,ing_ccdet,pm_ncint,ing_ncint,pm_ncdet,ing_ncdet,pm_cceff,ing_cceff,pm_nceff,ing_nceff,pm_flux,ing_flux;
    
    float qeint,nqeint,
    qedet,nqedet,
    qeeff,nqeeff,
    flux;
    
    tree->Branch("qeint",&qeint,"qeint/F");//all signal interaction
    tree->Branch("nqeint",&nqeint,"nqeint/F");//all background interaction
    
    tree->Branch("qedet",&qedet,"qedet/F");// all selected-signal
    
    tree->Branch("nqedet",&nqedet,"nqedet/F");//all selected-background
    
    tree->Branch("qeeff",&qeeff,"qeeff/F");//efficiency of signal selection
    
    tree->Branch("nqeeff",&nqeeff,"nqeeff/F");//efficiency of background selection
    
    tree->Branch("flux",&flux,"flux/F");
    
    
    //float pm0_ccint=0,ing0_ccint=0,pm0_ccdet=0,ing0_ccdet=0,pm0_ncint=0,ing0_ncint=0,pm0_ncdet=0,ing0_ncdet=0,pm0_cceff=0,ing0_cceff=0,pm0_nceff=0,ing0_nceff=0,pm0_flux=0,ing0_flux=0;
    
    float qeint_nomi=0,nqeint_nomi=0,
    qedet_nomi=0,nqedet_nomi=0,
    qeeff_nomi=0,nqeeff_nomi=0,
    flux_nomi=0;
    
    
    for(int j=0;j<nbin;j++){
        qeint_nomi   += hqeint   -> GetBinContent(j+1);
        nqeint_nomi  += hnqeint  -> GetBinContent(j+1);
        qedet_nomi  += hqedet  -> GetBinContent(j+1);
        nqedet_nomi += hnqedet -> GetBinContent(j+1);
        flux_nomi    += hflux    -> GetBinContent(j+1);
    }
    //make toy simulation
    for(int i=0;i<nthrows;i++){
        if(i%10000==0)cout<<i<<endl;
        //pm_ccint=0,ing_ccint=0,pm_ccdet=0,ing_ccdet=0,pm_ncint=0,ing_ncint=0,pm_ncdet=0,ing_ncdet=0,pm_cceff=0,ing_cceff=0,pm_nceff=0,ing_nceff=0,pm_flux=0,ing_flux=0;
        qeint=0;nqeint=0;
        qedet=0;nqedet=0;
        qeeff=0;nqeeff=0;
        flux=0;
        
//.........这里部分代码省略.........
开发者ID:cvson,项目名称:pmcccohana1x,代码行数:101,代码来源:FluxErr_nomcheck.C

示例2: save

/////////////////////////////////////////////////
////        Save Histograms or Profiles       ///
/////////////////////////////////////////////////
void hist_files::save(const char* root_name, bool ps, bool debug) {

  // skip saving if histograms do not exist!
  if( size()==0 ) return;

  gStyle->SetCanvasColor(0);
  gStyle->SetPadColor(0);
  gStyle->SetOptStat(111111);

  TCanvas c1;
  TFile *hist = new TFile(root_name);
 
  cout << "Saving histograms to file to " << hist->GetPath() << endl;

  if (debug) cout << "hist_files::save: 1D_HISTOS=" << size1D() << endl << flush;
  for(map<TString, TH1D*>::iterator it_1d = hist_files_1d.begin(); 
      it_1d != hist_files_1d.end(); it_1d++) 
    if ((*it_1d).first != "" && (*it_1d).second != NULL) {
      if (debug) cout << "hist_files::save: 1D_NAME=" << ((*it_1d).second)->GetName() << endl << flush;
      TString fn = ((*it_1d).second)->GetName(); fn = fn + ".ps";
      ((*it_1d).second)->Draw();
      ((*it_1d).second)->Write();
      if(ps) c1.Print(fn);
    }
  
  if (debug) cout << "hist_files::save: 2D_HISTOS=" << size2D() << endl << flush;
  for(map<TString, TH2D*>::iterator it_2d = hist_files_2d.begin();
      it_2d != hist_files_2d.end(); it_2d++) 
    if ((*it_2d).first != "" && (*it_2d).second != NULL) {
      if (debug) cout << "hist_files::save: 2D_NAME=" << ((*it_2d).second)->GetName() << endl << flush;
      TString fn = ((*it_2d).second)->GetName(); fn = fn + ".ps";
      ((*it_2d).second)->Draw();
      ((*it_2d).second)->Write();
      if(ps) c1.Print(fn);
    }

  if (debug) cout << "hist_files::save: 3D_HISTOS=" << size3D() << endl << flush;
  for(map<TString, TH3D*>::iterator it_3d = hist_files_3d.begin();
      it_3d != hist_files_3d.end(); it_3d++) 
    if ((*it_3d).first != "" && (*it_3d).second != NULL) {
      if (debug) cout << "hist_files::save: 3D_NAME=" << ((*it_3d).second)->GetName() << endl << flush;
      TString fn = ((*it_3d).second)->GetName(); fn = fn + ".ps";
      ((*it_3d).second)->Draw();
      ((*it_3d).second)->Write();
      if(ps) c1.Print(fn);
    }

  if (debug) cout << "hist_files::save: PROFILE_HISTOS=" << sizeProfile() << endl << flush;
  for(map<TString, TProfile*>::iterator it_profile = hist_files_profile.begin();
      it_profile != hist_files_profile.end(); it_profile++) 
    if ((*it_profile).first != "" && (*it_profile).second != NULL) {
      if (debug) cout << "hist_files::save: PROFILE_NAME=" << ((*it_profile).second)->GetName() << endl << flush;
      TString fn = ((*it_profile).second)->GetName(); fn = fn + ".ps";
      ((*it_profile).second)->Draw();
      ((*it_profile).second)->Write();
      if(ps) c1.Print(fn);
    }

  if (debug) cout << "hist_files::save: PROFILE_2D_HISTOS=" << sizeProfile2D() << endl << flush;
  for(map<TString, TProfile2D*>::iterator it_profile_2d = hist_files_profile_2d.begin();
      it_profile_2d != hist_files_profile_2d.end(); it_profile_2d++) 
    if ((*it_profile_2d).first != "" && (*it_profile_2d).second != NULL) {
      if (debug) cout << "hist_files::save: PROFILE_2D_NAME=" << ((*it_profile_2d).second)->GetName() << endl << flush;
      TString fn = ((*it_profile_2d).second)->GetName(); fn = fn + ".ps";
      ((*it_profile_2d).second)->Draw();
      ((*it_profile_2d).second)->Write();
      if(ps) c1.Print(fn);
    }

  hist->Close();  
  cout << "Done." << endl;
}
开发者ID:hengne,项目名称:d0wmass,代码行数:75,代码来源:hist_files.cpp


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