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


C++ TBranch::GetAddress方法代码示例

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


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

示例1: loop

unsigned int loop(T& tree, TH3F* hist3D, TH2F* hist2D)
{
  unsigned int nEvtsRead = 0;
  unsigned int nEB = 0;
  Long64_t N = tree.fChain->GetEntriesFast();
  for (Long64_t iEvt = 0; iEvt < N; ++iEvt) {
    Long64_t localEntry = tree.LoadTree(iEvt);
    if (localEntry < 0) break;
    ++nEvtsRead;
    tree.fChain->GetEntry(iEvt);
    TObject* object = tree.fChain->GetListOfBranches()->FindObject("totalWeight");
    TBranch* branch = NULL;
    Float_t totalWeight = 1.0;
    if (object != 0) {
      branch = (TBranch*)object;
      totalWeight = *(Float_t*)branch->GetAddress();
    }
    if (fabs(tree.probe_SC_eta) < 1.4442) {
      ++nEB;
      hist3D->Fill(tree.dRTagProbe, tree.probe_nJets05, tree.event_nPV, totalWeight);
      hist2D->Fill(tree.dRTagProbe, tree.probe_passing, totalWeight);
    }
  }
  cout << "No. of probes in EB: " << nEB << endl;
  return nEvtsRead;
}
开发者ID:rpyohay,项目名称:physics-tools,代码行数:26,代码来源:KinematicAnalysis.C

示例2: if

/// Load the specified event
Int_t DDG4EventHandler::ReadEvent(Long64_t event_number)   {
    m_data.clear();
    m_hasEvent = false;
    if ( hasFile() )  {
        if ( event_number >= m_file.second->GetEntries() )  {
            event_number = m_file.second->GetEntries()-1;
            printout(ERROR,"DDG4EventHandler","+++ ReadEvent: Cannot read across End-of-file! Reading last event:%d.",event_number);
        }
        else if ( event_number < 0 )  {
            event_number = 0;
            printout(ERROR,"DDG4EventHandler","+++ nextEvent: Cannot read across Start-of-file! Reading first event:%d.",event_number);
        }

        Int_t nbytes = m_file.second->GetEntry(event_number);
        if ( nbytes >= 0 )   {
            printout(ERROR,"DDG4EventHandler","+++ ReadEvent: Read %d bytes of event data for entry:%d",nbytes,event_number);
            for(Branches::const_iterator i=m_branches.begin(); i != m_branches.end(); ++i)  {
                TBranch* b = (*i).second.first;
                std::vector<void*>* ptr_data = *(std::vector<void*>**)b->GetAddress();
                m_data[b->GetClassName()].push_back(make_pair(b->GetName(),ptr_data->size()));
            }
            m_hasEvent = true;
            return nbytes;
        }
        printout(ERROR,"DDG4EventHandler","+++ ReadEvent: Cannot read event data for entry:%d",event_number);
        throw runtime_error("+++ EventHandler::readEvent: Failed to read event");
    }
    throw runtime_error("+++ EventHandler::readEvent: No file open!");
}
开发者ID:vvolkl,项目名称:DD4hep,代码行数:30,代码来源:DDG4EventHandler.cpp

示例3: verifyBranch

template <class HolderClass> bool verifyBranch(const char *testname, TTree *chain, const char *bname, int type = 0) {
   static HolderClass *gHolder = new HolderClass;
   HolderClass **add = 0;
   HolderClass *holder = 0;

   TBranch *branch = chain->GetBranch(bname);
   if (branch==0) {
      TestError("treeReading",Form("Missing branch: %s",bname));
      return false;
   }
   
   if (branch->InheritsFrom("TBranchObject")) {
      TLeafObject *tbo = dynamic_cast<TLeafObject*>(branch->GetListOfLeaves()->At(0));
      holder = (HolderClass*)(tbo->GetObject());

      if (holder==0) {
         TestError("treeReading",Form("BranchObject %s with holder == 0!",bname));
         return false;         
      }
   } else {
      add = (HolderClass**)branch->GetAddress();
      if (add==0) {
         TestError("treeReading",Form("Branch %s with add == 0!",bname));
         return false;
      }
      void **p;
      switch (type) {
         case 0: holder = *add; break;
         case 1: p = (void**) &(gHolder->fScalarPtr); *p = ((TBranchElement*)branch)->GetObject(); break;
         case 2: p = (void**) &(gHolder->fObjectPtr); *p = ((TBranchElement*)branch)->GetObject(); break;
         case 3: p = (void**) &(gHolder->fNestedPtr); *p = ((TBranchElement*)branch)->GetObject(); break;
      }
   }
   
   int splitlevel = branch->GetSplitLevel();

   switch (type) {
      case 0: return holder->Verify(chain->GetTree()->GetReadEntry(),Form("%s %s",testname,bname),splitlevel);
      case 1: return gHolder->VerifyScalarPtr(chain->GetTree()->GetReadEntry(),Form("%s %s",testname,bname),splitlevel);
      case 2: return gHolder->VerifyObjectPtr(chain->GetTree()->GetReadEntry(),Form("%s %s",testname,bname),splitlevel);
      case 3: return gHolder->VerifyNestedPtr(chain->GetTree()->GetReadEntry(),Form("%s %s",testname,bname),splitlevel);
      default: 
         TestError("treeReading",Form("Unknown type %d in verifyBranch",type));
         return false;
   }
}
开发者ID:asmagina1995,项目名称:roottest,代码行数:46,代码来源:test.C


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