本文整理汇总了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;
}
示例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));
}
}
}
}
示例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;
}
}
示例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);
}
}
示例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);
}
示例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()
示例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;
}
}
示例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]);
}
}
}
示例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;
}
示例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;
}
}
示例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);
}
}
}
示例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);
}
}
}
}
示例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;
}
示例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;
}
示例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);
}
}