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


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

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


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

示例1: assert

void
dumpToPDF(string inName, string fitName){
  TFile *fin = TFile::Open(inName.c_str(), "read"); assert(fin);


  string outName = inName;
  outName.replace(outName.find(".root"), 5, ".pdf");

  //fitName = "HLT_10LS_delivered_vs_rate_Run190949-191090.root";
  TFile *fFit = TFile::Open(fitName.c_str(), "read"); assert(fFit);

  TCanvas c1;
  c1.Print(Form("%s[", outName.c_str()), "pdf"); //Open .pdf

  //get list of keys
  int nplots = fin->GetNkeys(); 
  int nfits = fFit->GetNkeys(); 
  printf("nplots: %i, nfits: %i\n", nplots, nfits);
  if(nplots != nfits){
    cout<<" PDF output will be wrong since different number of triggers in fit and current run"<<endl;
    abort();
  }
  TList* plots = fin->GetListOfKeys();  
  TList* fits  = fFit->GetListOfKeys();
  for(int i=0; i<nplots; ++i){
    TKey* plot = (TKey*) plots->At(i);
    TKey* fit = (TKey*) fits->At(i);//assume they're in the same order for now

    if(!fin->GetKey(plot->GetName())){
      cout<<"Didn't find "<<plot<<". Removing."<<endl;
      abort();
    }
    if(!fFit->GetKey(fit->GetName())){
      cout<<"Didn't find "<<fit<<". Removing."<<endl;
      abort();
    }
    TCanvas* c = new TCanvas();
    c->Divide(1,2);

    TCanvas* cPlot = (TCanvas*) fin->Get(plot->GetName());
    c->cd(1);
    cPlot->DrawClonePad();

    TCanvas* cFit  = (TCanvas*) fFit->Get(fit->GetName());
    c->cd(2);
    cFit->DrawClonePad();

    string bookmarkName = "Title: ";
    bookmarkName += plot->GetName();

    c->Print(outName.c_str(), bookmarkName.c_str());
  }

  c1.Print(Form("%s]", outName.c_str()), "pdf"); //Close .pdf

}
开发者ID:drankincms,项目名称:RateMon,代码行数:56,代码来源:dumpToPDF.C

示例2: readCurrentCamera

void readCurrentCamera(const char* fname)
{
  TGLCamera& c = gEve->GetDefaultGLViewer()->CurrentCamera();
  TFile* f = TFile::Open(fname, "READ");
  if (!f) 
    return;

  if (f->GetKey(c.ClassName())) {
    f->GetKey(c.ClassName())->Read(&c);
    c.IncTimeStamp();
    gEve->GetDefaultGLViewer()->RequestDraw();
  }
}
开发者ID:My-Source,项目名称:root,代码行数:13,代码来源:camera_restore.C

示例3: gammaJetHistogram


//.........这里部分代码省略.........

        switch (i) {
        case 0: //0-10
            resolutionJetSmear[i].CSN_HI = CSN_HI_cent0010;
            resolutionJetSmear[i].CSN_phi_HI = CSN_phi_HI_cent0010;
            break;
        case 1: //10-30
            resolutionJetSmear[i].CSN_HI = CSN_HI_cent1030;
            resolutionJetSmear[i].CSN_phi_HI = CSN_phi_HI_cent1030;
            break;
        case 2: //30-50
            resolutionJetSmear[i].CSN_HI = CSN_HI_cent3050;
            resolutionJetSmear[i].CSN_phi_HI = CSN_phi_HI_cent3050;
            break;
        case 3: //50-100
            resolutionJetSmear[i].CSN_HI = CSN_HI_cent50100;
            resolutionJetSmear[i].CSN_phi_HI = CSN_phi_HI_cent50100;
            break;
        case 4: // 0-30, for smeared pp only
            resolutionJetSmear[i].CSN_HI = CSN_HI_cent0030;
            resolutionJetSmear[i].CSN_phi_HI = CSN_phi_HI_cent0030;
            break;
        case 5: // 30-100, for smeared pp only
            resolutionJetSmear[i].CSN_HI = CSN_HI_cent30100;
            resolutionJetSmear[i].CSN_phi_HI = CSN_phi_HI_cent30100;
            break;
        }
    }

    /// End Input Bookkeeping block //

    TFile* output = TFile::Open(outputFile, "RECREATE");
    // histograms will be put under a directory whose name is the type of the collision
    if (!output->GetKey(collisionName))
        output->mkdir(collisionName, Form("input file is %s", inputFile.Data()));
    output->cd(collisionName);
    std::cout << "histograms will be put under directory : " << collisionName << std::endl;

    TTree *configTree = setupConfigurationTreeForWriting(configCuts);

    int nCorrHist = correlationHistNames.size();
    correlationHist corrHists[nCorrHist][nBins_pt][nBins_hiBin];

    // prepare histogram names for xjg, abs(dphi) and jet pt
    for (int iHist=0; iHist<nCorrHist; ++iHist) {
        for (int i=0; i<nBins_pt; ++i) {
            for (int j=0; j<nBins_hiBin; ++j) {
                corrHists[iHist][i][j].name = Form("%s_ptBin%d_hiBin%d", correlationHistNames[iHist].c_str(), i, j);

                for (int iCorr = 0; iCorr < CORR::kN_CORRFNC; ++iCorr) {
                    for (int jCorr = 0; jCorr < CORR::kN_CORRFNC; ++jCorr) {
                        std::string subHistName = Form("%s_ptBin%d_hiBin%d_%s_%s", correlationHistNames[iHist].c_str(), i, j,
                                                       CORR::CORR_PHO_LABELS[iCorr].c_str(), CORR::CORR_JET_LABELS[jCorr].c_str());
                        corrHists[iHist][i][j].h1D_name[iCorr][jCorr] = subHistName.c_str();
                        corrHists[iHist][i][j].h1D[iCorr][jCorr] = new TH1D(Form("h1D_%s", subHistName.c_str()), "",
                                nBinsx[iHist], xlow[iHist], xup[iHist]);

                        corrHists[iHist][i][j].h1D_titleX[iCorr][jCorr] = correlationHistTitleX[iHist].c_str();
                        corrHists[iHist][i][j].h1D_titleY_final_norm[iCorr][jCorr] = correlationHistTitleY_final_normalized[iHist].c_str();
                    }
                }
            }
        }
    }

    // histograms to store the number of photon events, not photon-Jet event
开发者ID:CmsHI,项目名称:ElectroWeak-Jet-Track-Analyses,代码行数:67,代码来源:gammaJetHistogram.C


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