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


C++ TTree::IsZombie方法代码示例

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


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

示例1: GetTTree

TTree* GetTTree(const std::string TFILE, const std::string TTREE) {
  // Open the TFiles
  TFile* mc_tfile = new TFile(TFILE.c_str(), "READ");
  if (!mc_tfile || mc_tfile->IsZombie()) {
    const std::string ERR = "Could not open the file " + TFILE;
    throw std::runtime_error(ERR);
  }

  // Load the tree
  TTree* tree = new TTree();
  mc_tfile->GetObject(TTREE.c_str(), tree);
  if (!tree || tree->IsZombie()) {
    const std::string ERR = "Could not open the TTree " + TTREE;
    throw std::runtime_error(ERR);
  }

  return tree;
}
开发者ID:optimisticcynic,项目名称:ZFinder,代码行数:18,代码来源:MomPDFPlots.cpp

示例2: doPostProcessing

void doPostProcessing(TString infname, TString outfile, Int_t events, 
		      Float_t xsec, Float_t kfactor,
		      Float_t filt_eff, bool SortBasketsByEntry = false) {
  
  cout << "Processing File " << infname << endl;
  
  TFile *f = TFile::Open(infname.Data(), "READ");
  if (! f || f->IsZombie()) {
    cout << "File does not exist!" << endl;
    return;
  }
  
  TTree* t = (TTree*)f->Get("Events");
  if (! t || t->IsZombie()) {
    cout << "Tree does not exist!" << endl;
    return;
  }
        
  //-------------------------------------------------------------
  // Removes all non *_CMS2.* branches
  //-------------------------------------------------------------`
  t->SetBranchStatus("*", 0);
  t->SetBranchStatus("*_CMS2.*", 1);

  // Removes the branches (if they exist) that we want to replace
  //evt_xsec_excl
  TString bName = t->GetAlias("evt_xsec_excl");
  //cout << "evt_xsec_excl " << bName << endl;
  if(bName != "") {
    bName.ReplaceAll(".obj", "*");
    t->SetBranchStatus(bName.Data(), 0); 
  }

  //evt_xsec_incl
  bName = t->GetAlias("evt_xsec_incl");
  //cout << "evt_xsec_incl " << bName << endl;
  if(bName != "") {
    bName.ReplaceAll(".obj", "*");
    t->SetBranchStatus(bName.Data(), 0);   
  }
  
  //evt_kfactor
  bName = t->GetAlias("evt_kfactor");
  //cout << "evt_kfactor " << bName << endl;
  if(bName != "") {
    bName.ReplaceAll(".obj", "*");
    t->SetBranchStatus(bName.Data(), 0); 
  }

  //evt_nEvts
  bName = t->GetAlias("evt_nEvts");
  //cout << "evt_nEvts " << bName << endl;
  if(bName != "") {
    bName.ReplaceAll(".obj", "*");
    t->SetBranchStatus(bName.Data(), 0); 
  }

  //evt_filt_eff
  bName = t->GetAlias("evt_filt_eff");
  //cout << "evt_filt_eff " << bName << endl;
  if(bName != "") {
    bName.ReplaceAll(".obj", "*");
    t->SetBranchStatus(bName.Data(), 0); 
  }

  //evt_scale1fb
  bName = t->GetAlias("evt_scale1fb");
  //cout << "evt_scale1fb " << bName << endl;
  if(bName != "") {
    bName.ReplaceAll(".obj", "*");
    t->SetBranchStatus(bName.Data(), 0); 
  }

  TFile *out = TFile::Open(outfile.Data(), "RECREATE");
  TTree *clone;
  if(SortBasketsByEntry)
    clone = t->CloneTree(-1, "fastSortBasketsByEntry");
  else 
    clone = t->CloneTree(-1, "fast");
   

  //-------------------------------------------------------------

  //Calculate scaling factor and put variables into tree 
  Float_t scale1fb = xsec*kfactor*1000*filt_eff/(Float_t)events;
  cout << "scale1fb: " << scale1fb << endl; 

  TBranch* b1 = clone->Branch("evtscale1fb", &scale1fb, "evt_scale1fb/F");
  TBranch* b2 = clone->Branch("evtxsecexcl", &xsec, "evt_xsec_excl/F");
  TBranch* b3 = clone->Branch("evtxsecincl", &xsec, "evt_xsec_incl/F");
  TBranch* b4 = clone->Branch("evtkfactor", &kfactor, "evt_kfactor/F");
  TBranch* b5 = clone->Branch("evtnEvts", &events, "evt_nEvts/I");
  TBranch* b6 = clone->Branch("evtfilteff", &filt_eff, "evt_filt_eff/F");
   
  clone->SetAlias("evt_scale1fb",  "evtscale1fb");
  clone->SetAlias("evt_xsec_excl", "evtxsecexcl");
  clone->SetAlias("evt_xsec_incl",  "evtxsecincl");
  clone->SetAlias("evt_kfactor",   "evtkfactor");
  clone->SetAlias("evt_nEvts",     "evtnEvts");
  clone->SetAlias("evt_filt_eff",     "evtfilteff");
//.........这里部分代码省略.........
开发者ID:cmstas,项目名称:CMS2_ArchiveJul2013,代码行数:101,代码来源:skelPostProcessingMacro.C

示例3: addAgedVarsTPfinal

int addAgedVarsTPfinal(TString infname, TString outfile){
  
  cout << "Processing File " << infname << endl;

  TFile *f = TFile::Open(infname.Data(), "READ");
  if (! f || f->IsZombie()) {
    cout << "File does not exist!" << endl;
    return 1;
  }
  
  TTree* t = (TTree*)f->Get("t");
  if (! t || t->IsZombie()) {
    cout << "Tree does not exist!" << endl;
    return 2;
  }
        
  // old branches
  Float_t lep1pt;
  Float_t lep1eta;
  Float_t lep1phi;
  Float_t lep2pt;
  Float_t lep2eta;
  Float_t lep2phi;
  Int_t nleps;
  Float_t pujetmet;
  Float_t pujetmetphi;
  Float_t pujetmt;
  Int_t nb;
  Int_t nbgen;
  Int_t ncgen;
  Float_t bjet1pt;
  Float_t bjet1eta;
  Float_t bjet2pt;
  Float_t bjet2eta;

  TBranch* b_lep1pt;
  TBranch* b_lep1eta;
  TBranch* b_lep1phi;
  TBranch* b_lep2pt;
  TBranch* b_lep2eta;
  TBranch* b_lep2phi;
  TBranch* b_nleps;
  TBranch* b_pujetmet;
  TBranch* b_pujetmetphi;
  TBranch* b_pujetmt;
  TBranch* b_nb;
  TBranch* b_nbgen;
  TBranch* b_ncgen;
  TBranch* b_bjet1pt;
  TBranch* b_bjet1eta;
  TBranch* b_bjet2pt;
  TBranch* b_bjet2eta;

  // new branches
  Float_t agedweight = 1.;
  Int_t agednleps = -999;
  Float_t agedlep1pt = -999.;
  Float_t agedlep1eta = -999.;
  Float_t agedlep1phi = -999.;
  Float_t smearmet = -999.;
  Float_t smearmetphi = -999.;
  Float_t smearmt = -999.;

  // random generator
  TRandom3 rand;
  const float sigma = 20.; // smear by 20 GeV

  //-------------------------------------------------------------
  // Removes all non *_CMS2.* branches
  //-------------------------------------------------------------`
  t->SetBranchStatus("*", 1);

  TFile *out = TFile::Open(outfile.Data(), "RECREATE");
  TTree *clone;
  clone = t->CloneTree(-1, "fast");

  cout << "Cloning to File " << outfile << endl;

  //-------------------------------------------------------------

  // existing branches
  clone->SetBranchAddress("lep1pt"     ,  &lep1pt     , &b_lep1pt  );
  clone->SetBranchAddress("lep1eta"    ,  &lep1eta    , &b_lep1eta  );
  clone->SetBranchAddress("lep1phi"    ,  &lep1phi    , &b_lep1phi  );
  clone->SetBranchAddress("lep2pt"     ,  &lep2pt     , &b_lep2pt  );
  clone->SetBranchAddress("lep2eta"    ,  &lep2eta    , &b_lep2eta  );
  clone->SetBranchAddress("lep2phi"    ,  &lep2phi    , &b_lep2phi  );
  clone->SetBranchAddress("nleps"      ,  &nleps      , &b_nleps  );
  clone->SetBranchAddress("pujetmet"   ,  &pujetmet   , &b_pujetmet  );
  clone->SetBranchAddress("pujetmetphi",  &pujetmetphi, &b_pujetmetphi  );
  clone->SetBranchAddress("pujetmt"    ,  &pujetmt    , &b_pujetmt  );
  clone->SetBranchAddress("nb"         ,  &nb         , &b_nb  );
  clone->SetBranchAddress("nbgen"      ,  &nbgen      , &b_nbgen  );
  clone->SetBranchAddress("ncgen"      ,  &ncgen      , &b_ncgen  );
  clone->SetBranchAddress("bjet1pt"    ,  &bjet1pt    , &b_bjet1pt  );
  clone->SetBranchAddress("bjet1eta"   ,  &bjet1eta   , &b_bjet1eta  );
  clone->SetBranchAddress("bjet2pt"    ,  &bjet2pt    , &b_bjet2pt  );
  clone->SetBranchAddress("bjet2eta"   ,  &bjet2eta   , &b_bjet2eta  );

  // new branches
//.........这里部分代码省略.........
开发者ID:olivito,项目名称:phase2,代码行数:101,代码来源:addAgedVarsTPfinal.C


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