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


C++ TLeaf类代码示例

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


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

示例1:

// This piece of code is borrowed from Argo written by Nathaniel Tagg
std::vector<std::string> DataFetcher::FindLeavesOfType(std::string pattern) {
  /// Look in the tree and try to find a leaf element that matches 'pattern'.
  /// Return the full name of that leaf.
  std::vector<std::string> leaf_names;

  // Strip whitespace from pattern.
  pattern.erase(std::remove_if(pattern.begin(), pattern.end(), ::isspace),
      pattern.end());

  TObjArray * list = tree_->GetListOfLeaves();
  for (int i = 0; i < list->GetEntriesFast(); ++i) {
    TObject * o = list->At(i);
    TLeaf * leaf = (TLeaf *) o;
    std::string name = leaf->GetTypeName();
    // Strip whitespace from pattern.
    name.erase(std::remove_if(name.begin(), name.end(), ::isspace),
        name.end());
    size_t found = name.find(pattern);
    if (found != std::string::npos) {
      // Return this match.
      leaf_names.push_back(leaf->GetName());
    }
  }
  return leaf_names;
}
开发者ID:lar1nd,项目名称:lar1evd,代码行数:26,代码来源:DataFetcher.cpp

示例2: dump_required_lvl2

void dump_required_lvl2(TTree *tree, TLeaf &leaf, CodedOutputStream &o, CodedOutputStream &o2) {
    const int DL = 1; // definition level multiplier
    const int RL = 4; // repetition level multiplier

    std::cout << "Dump vector vector: " << leaf.GetName() << " " << leaf.GetTypeName() << std::endl;
    auto * branch = leaf.GetBranch();

    std::vector<std::vector<T> > * data = NULL;
    tree->SetBranchAddress(leaf.GetBranch()->GetName(), &data);
    int entries = tree->GetEntries();
    for (int i = 0; i < entries; i++) { 
        branch->GetEntry(i);
        if (data->size() == 0) {
            write_out_32(o2, DL*0 + RL*0);
        }
        for (int j = 0; j < data->size(); j++) {
            if (data->at(j).size() == 0) {
                int dl = 1;
                int rl = (j > 0 ? 1 : 0);
                write_out_32(o2, dl*DL + rl*RL);
            }
            for (int k = 0; k < data->at(j).size(); k++) {
                int dl = 2;
                int rl = (k > 0 ? 2 : (j > 0 ? 1 : 0));
                write_out_32(o2, dl*DL + rl*RL);
                write_out_type(o, data->at(j).at(k));
            }
        }
    }
}
开发者ID:pwaller,项目名称:drillbit,代码行数:30,代码来源:root2stripes.cpp

示例3: fixLeafOffsets

void Output::fixLeafOffsets( TBranch * b)
{
  // recalculates the addresses for all the leaves.
  // 
  // when constructing a branch with containing a variable length array with the index
  // variable in the same branch it is not possible to specify the span of the index variable
  // This span defaults to zero. When the addresses are asigned to the various leaves in the branch
  // it calculates the size of the particular leaf (variable length array) in the buffer by looking 
  // at the span of the index variable - 0 in this case! using the method TLeaf::GetLen(). 
  // The following code shoudl be applied to the branch after the spans of the index variables have been
  // specified manually using the TLeaf::SetMaximum method. This time the GetLen method calculates the correct offset.

  TObjArray * leaves = b->GetListOfLeaves();
  char * addr = b->GetAddress();
  int offset = 0;
  int nleaves = leaves->GetEntriesFast();
  
  // loop over the leaves:
  for( int i =0; i < nleaves; ++i) {
    TLeaf * leaf = (TLeaf *)leaves->UncheckedAt(i);
    leaf->SetAddress( addr + offset );
    int oldOffset = leaf->GetOffset();
    leaf->SetOffset( offset );
    //std::cout << " offset changed from : " << oldOffset << " to " << offset << std::endl;
    TLeaf * index = leaf->GetLeafCount();
    int nelements = 1;
    if( index ) {
      nelements = index->GetMaximum(); // deal with variable length arrays
    } else {
      nelements = leaf->GetLenStatic(); // deal with single variables and fixed length arrays
    }
    offset += leaf->GetLenType() * nelements;
  }
}
开发者ID:rafaellopesdesa,项目名称:wmass_pythia_interface,代码行数:34,代码来源:Output.cpp

示例4: dump_required_lvl0

void dump_required_lvl0(TTree *tree, TLeaf &leaf, CodedOutputStream &o) {
    std::cout << "Dump " << leaf.GetName() << std::endl;
    auto *branch = leaf.GetBranch();

    T data; 
    tree->SetBranchAddress(leaf.GetBranch()->GetName(), &data);
    int entries = tree->GetEntries();
    for (int i = 0; i < entries; i++) { 
        branch->GetEntry(i);
        write_out_type(o, data);
    }
}
开发者ID:pwaller,项目名称:drillbit,代码行数:12,代码来源:root2stripes.cpp

示例5: SetBranchAddressToHolder

void GAInputTreeData::SetBranchAddressToHolder(string branch_name){
    if(!fTTree->GetBranch(branch_name.c_str())){
        cout << "[GAInputTreeData-E]: branch " << branch_name << 
                " is not found";
        throw 1;
    }
    fBranchName.push_back(branch_name);
    TLeaf *leaf = fTTree->GetBranch(branch_name.c_str())
        ->GetLeaf(branch_name.c_str());
    Int_t n_data = leaf->GetNdata();
    string type_name = leaf->GetTypeName();
    fEventDataHolderManager->AddDetector(type_name,branch_name, n_data);
}
开发者ID:YJabberwocKy,项目名称:testganaroot,代码行数:13,代码来源:GAInputTreeData.cpp

示例6: addTree

void NCIdeogram::addTree(TTree *tree, const char *mu, const char *sigma)
{
	TLeaf *leafMu = tree->FindLeaf(mu);
	TLeaf *leafSigma = tree->FindLeaf(sigma);
	TEventList *elist = tree->GetEventList();
	Long64_t j,ix,nbr;
	
	nbr = elist ? elist->GetN() : tree->GetEntries();
	for (j = 0; j < nbr; j++) {
		ix = elist ? elist->GetEntry(j) : j;
		tree->GetEntry(ix);
		addPoint(leafMu->GetValue(), leafSigma->GetValue());
	}
} // addTree()
开发者ID:cms-analysis,项目名称:HeavyFlavorAnalysis-Bs2MuMu,代码行数:14,代码来源:NCIdeogram.cpp

示例7: TState

CThreadSlm::TState
CThreadSlm::history_state_of(TState st)
{
    if (st.getLevel() >= m_N) {
        TLeaf* pl = ((TLeaf *)m_Levels[m_N]) + st.getIdx();
        return TState(pl->bol(), pl->bon());
    } else {
        TNode* pn = ((TNode *)m_Levels[st.getLevel()]) + st.getIdx();
        if (pn->ch() == (pn+1)->ch())
            return TState(pn->bol(), pn->bon());
        else
            return st;
    }
}
开发者ID:XueWei,项目名称:sunpinyin,代码行数:14,代码来源:slm.cpp

示例8: CacheTestMCProductions

/// \brief Cache  MC production trees, store summary information in formated text files -> root trees
/// \param dataType  -
/// \param fileList
void CacheTestMCProductions(TString dataType, const char *fileList=NULL){
  AliExternalInfo info;
  info.fLoadMetadata=kFALSE;
  TObjArray* periodList = NULL;
  TArrayI nRuns;
  if (fileList!=NULL) {
    periodList=(gSystem->GetFromPipe(TString::Format("cat %s", fileList).Data())).Tokenize("\n");
    nRuns.Set(periodList->GetEntries());

  }else{
    TTree * tree = info.GetTree("MonALISA.ProductionMC","","");
    Int_t nProd=tree->GetEntries();
    periodList = new TObjArray(nProd);
    nRuns.Set(nProd);
    TLeaf *leaf = tree->GetLeaf("Tag");
    TLeaf *leafRuns = tree->GetLeaf("Number_of_runs");
    for (Int_t iProd=0; iProd<nProd; iProd++){
      tree->GetEntry(iProd);
      TString prodName=((char*)leaf->GetValuePointer());
      if (prodName.Contains("LHC")==0) continue;
      periodList->AddAt(new TObjString(((char*)leaf->GetValuePointer())),iProd);
      nRuns[iProd]=leafRuns->GetValue();
    }
    delete tree;
  }
  for (Int_t iPeriod=0; iPeriod<periodList->GetEntriesFast(); iPeriod++){
    TObjString * pName= (TObjString*)periodList->At(iPeriod);
    if (pName==NULL) continue;
    TTree* tree = info.GetTree(dataType.Data(),periodList->At(iPeriod)->GetName(),"passMC");
    if (tree){
      Int_t entries=tree->Draw("run","1","goff");
      TString sInfo=periodList->At(iPeriod)->GetName();
      sInfo+="\t";
      sInfo+=dataType;
      sInfo+="\t";
      sInfo+=TString::Format("%d\t",entries);
      sInfo+=TString::Format("%d\t",nRuns[iPeriod]);
      for (Int_t j=0; j<entries; j++) {
        sInfo+=TString::Format("%2.0f,",tree->GetV1()[j]);
        ::Info("CacheTestMCProductionsRun:","%s\t%s\t%d\t%d\t%d\t%2.0f",periodList->At(iPeriod)->GetName(),dataType.Data(),entries,nRuns[iPeriod],j, tree->GetV1()[j]);
      }
      sInfo+="0";
      ::Info("CacheTestMCProductionsPeriod:","%s\n",sInfo.Data());
      delete tree;
    }else{
      ::Error("CacheTestMCProductionsPeriod:","%s\t%s\t-1\t%d\t0",periodList->At(iPeriod)->GetName(), dataType.Data(),nRuns[iPeriod]);
    }
  }
}
开发者ID:alisw,项目名称:AliRoot,代码行数:52,代码来源:aliExternalInfo.C

示例9:

CThreadSlm::TState&
CThreadSlm::historify(TState& st)
{
    if (st.getLevel() >= m_N) {
        TLeaf* pl = ((TLeaf *)m_Levels[m_N]) + st.getIdx();
        st.setLevel(pl->bol());
        st.setIdx(pl->bon());
    } else {
        TNode* pn = ((TNode *)m_Levels[st.getLevel()]) + st.getIdx();
        if (pn->ch() == (pn+1)->ch()) {
            st.setLevel(pn->bol());
            st.setIdx(pn->bon());
        }
    }
    return st;
}
开发者ID:XueWei,项目名称:sunpinyin,代码行数:16,代码来源:slm.cpp

示例10: SetAllBranches

void GAInputTreeData::SetAllBranches(){
    TObjArray* ArrayOfBranches = fTTree->GetListOfBranches();
    Int_t n_branch = ArrayOfBranches->GetEntries();
    cout << "[GAInputTreeData-M]:Loading " << n_branch << " branches from "
        << fTTree->GetName() << endl;
    for(int i_branch=0; i_branch<n_branch; i_branch++){
        TBranch* Branch = (TBranch*)ArrayOfBranches->At(i_branch);
        string branch_name = Branch->GetName();
        TLeaf *leaf = (TLeaf*)Branch->GetListOfLeaves()->At(0);//(branch_name.c_str());
        Int_t n_data = leaf->GetNdata();
        string type_name = leaf->GetTypeName();
        fBranchName.push_back(branch_name);
        fEventDataHolderManager->AddDetector(type_name, branch_name, n_data);
        cout << "[GAInputTreeData-M]:Loading branch " << branch_name
            << " (" << type_name << "[" << n_data << "])" << endl;
    }
}
开发者ID:YJabberwocKy,项目名称:testganaroot,代码行数:17,代码来源:GAInputTreeData.cpp

示例11: Form

void DataInterface::getDataProfile(TH2F *hProfile, TH2F *hProjection, Int_t energy) {
   if (!existsEnergyFile(energy)) {
      cout << "There are no data files with energy " << energy << endl;
      return;
   }

   TString fn = Form("Data/ExperimentalData/DataFrame_%i_MeV.root", energy);
   TFile *f = new TFile(fn);
   TTree *tree = (TTree*) f->Get("tree");

   Int_t nentries = tree->GetEntries();
   printf("Found %d frames in the DataFrame.\n", nentries);

   TLeaf *lX = tree->GetLeaf("fDataFrame.fX");
   TLeaf *lY = tree->GetLeaf("fDataFrame.fY");
   TLeaf *lLayer = tree->GetLeaf("fDataFrame.fLayer");

   Float_t x, y, layer;

   for (Int_t i=0; i<nentries; i++) {
      tree->GetEntry(i);

      for (Int_t j=0; j<lY->GetLen(); j++) {
         x = lX->GetValue(j)  + nx/2;
         y = lY->GetValue(j)  + ny/2;
         layer = lLayer->GetValue(j);

         hProfile->Fill(y, layer);
         hProjection->Fill(x, y);
      }
   }
}
开发者ID:HelgeEgil,项目名称:focal,代码行数:32,代码来源:DataInterface.C

示例12: printf

void
CArpaSlm::load(const char* filename, const TLexicon& lexicon)
{
    printf("Loading ARPA slm..."); fflush(stdout);
    ifstream file(filename);
    char buf[1024];
    for (int i = 0; i <= N_GRAM; ++i) {
        unsigned lvl;
        int size;
        file.getline(buf, sizeof(buf));
        if (!file) {
            cerr << "Failed to read from" << filename << endl;
            exit(1);
        }
        sscanf(buf, "\\%d-gram\\%d%*[\n]", &lvl, &size);
        assert(lvl <= N_GRAM);
        if (lvl == 0) {
            TNode node0;
            node0.load_level0(file);
            m_levels[0].push_back(node0);
        } else if (lvl < m_N) {
            m_levels[lvl].reserve(size);
            for (int i = 0; i < size; ++i) {
                TNode node;
                node.load(file, lexicon);
                m_levels[lvl].push_back(node);
            }
        } else {
            // leaf nodes
            m_lastLevel.reserve(size);
            for (int i = 0; i < size; ++i) {
                TLeaf leaf;
                leaf.load(file, lexicon);
                m_lastLevel.push_back(leaf);
            }
        }
    }
}
开发者ID:WilliamRen,项目名称:sunpinyin,代码行数:38,代码来源:arpa_slm.cpp

示例13: main

int main() {
    // Get a map of the histograms of the Z Masses
    const std::string Tree_HighCut = "ZFinder/Combined Single Reco/Combined Single Reco";
    const std::string Tree_LowCut = "ZFinder/Combined Single Lowered Threshold Reco/Combined Single Lowered Threshold Reco";
    const std::string file_name = "/data/whybee0a/user/gude_2/Data/20150324_SingleElectron_2012ALL/hadded.root";
    // Open the file and load the tree
    TTree* treeH = GetTTree(file_name, Tree_HighCut);
    TBranch* event_infoH = treeH->GetBranch("event_info");
    TLeaf* EVNumbH = event_infoH->GetLeaf("event_number");
    // Pack into a hitogram
    std::set<int> eventnumber;
    std::set<int> eventnumberLow;
    for (int i = 0; i < treeH->GetEntries(); i++) {
        treeH->GetEntry(i);
        if (eventnumber.find(EVNumbH->GetValue()) == eventnumber.end()) {
            eventnumber.insert(EVNumbH->GetValue());
        } else {
            cout << "multiple events numbered :" << EVNumbH->GetValue()<<" in higher cuts" << endl;
        }

    }

    TTree* TreeLow = GetTTree(file_name, Tree_LowCut);
    TBranch* event_infoL = TreeLow->GetBranch("event_info");
    TLeaf* EVNumbLow = event_infoL->GetLeaf("event_number");
    for (int i = 0; i < TreeLow->GetEntries(); i++) {
        TreeLow->GetEntry(i);
        eventnumberLow.insert(EVNumbLow->GetValue());
        if (eventnumberLow.find(EVNumbLow->GetValue()) == eventnumber.end()) {
            eventnumberLow.insert(EVNumbLow->GetValue());
        } else {
cout << "multiple events numbered :" << EVNumbLow->GetValue()<<" in lowered cuts" << endl;
        }

    }

    return EXIT_SUCCESS;
}
开发者ID:Spudmeister,项目名称:tuningAna,代码行数:38,代码来源:EventDupFind.cpp

示例14:

map<TString, vector<TString> >GetCounterBranchListMap(TTree *t)
{
  map<TString, vector<TString> > m;
  TObjArray *l = t->GetListOfLeaves(); //sometimes leave can be named wrong - rely on branches
  int n = l->GetEntries();// cout<<t->GetName()<<" has "<<n<<" leaves"<<endl;
  for (int i=0;i<n;i++) {
    TLeaf * leaf = (TLeaf *)(*l)[i];
    TLeaf *lc = leaf->GetLeafCount();
    
    if (lc!=0) {
      m[lc->GetBranch()->GetName()].push_back(leaf->GetBranch()->GetName()); //get leaf's branch name
      if (VERBOSE) cout<<lc->GetBranch()->GetName()<<" _ "<<leaf->GetBranch()->GetName()<<endl;
    }
  }

  return m;
}
开发者ID:istaslis,项目名称:pPbmacro,代码行数:17,代码来源:HelperProcess.C

示例15: getlist

void getlist(ostream& out, TBranch* branch, int depth=0)
{
  TObjArray* array = branch->GetListOfBranches();
  if ( ! array ) return;
  if ( depth > 10 ) return;

  string name;
  int nitems = array->GetEntries();

  for (int i = 0; i < nitems; i++)
	{
	  TBranch* b = (TBranch*)((*array)[i]);
      if ( ! b ) continue;

      string branchname(b->GetName());
      out << SPACE.substr(0,4*depth) << branchname << endl;
 
      TObjArray* a = b->GetListOfLeaves();
      if ( a )
        {
          int n = a->GetEntries();
          {
              for (int j = 0; j < n; j++)
                {
                  TLeaf* leaf = (TLeaf*)((*a)[j]);
                  int count = 0;
                  int ndata = 0;
                  TLeaf* leafc = leaf->GetLeafCounter(count);
                  if ( ! leafc)
                    ndata = leaf->GetLen();
                  else
                    ndata = leafc->GetMaximum();

                  string leafname(leaf->GetName());
                  out << SPACE.substr(0,4*(depth+1)) 
                      << ndata << " " << leafname << endl;
                }
          }
//           else if ( n == 1 )
//             {
//               TBranch* bc = (TBranch*)((*a)[j]);
//               string leafname(bc->GetName());
//               if ( leafname != branchname )
//               out << SPACE.substr(0,4*(depth+1)) << leafname << endl;
//             }
        }
      getlist(out, b, depth+1);
    }
}
开发者ID:hbprosper,项目名称:SusySapien,代码行数:49,代码来源:getlist.cpp


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