本文整理汇总了C++中TBranch::GetName方法的典型用法代码示例。如果您正苦于以下问题:C++ TBranch::GetName方法的具体用法?C++ TBranch::GetName怎么用?C++ TBranch::GetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TBranch
的用法示例。
在下文中一共展示了TBranch::GetName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runtime_error
/// Open new data file
bool DDG4EventHandler::Open(const std::string&, const std::string& name) {
if ( m_file.first ) m_file.first->Close();
m_hasFile = false;
m_hasEvent = false;
TFile* f = TFile::Open(name.c_str());
if ( f && !f->IsZombie() ) {
m_file.first = f;
TTree* t = (TTree*)f->Get("EVENT");
if ( t ) {
TObjArray* br = t->GetListOfBranches();
m_file.second = t;
m_entry = -1;
m_branches.clear();
for(Int_t i=0; i<br->GetSize(); ++i) {
TBranch* b = (TBranch*)br->At(i);
if ( !b ) continue;
m_branches[b->GetName()] = make_pair(b,(void*)0);
printout(INFO,"DDG4EventHandler::open","+++ Branch %s has %ld entries.",b->GetName(),b->GetEntries());
}
for(Int_t i=0; i<br->GetSize(); ++i) {
TBranch* b = (TBranch*)br->At(i);
if ( !b ) continue;
b->SetAddress(&m_branches[b->GetName()].second);
}
m_hasFile = true;
return true;
}
throw runtime_error("+++ Failed to access tree EVENT in ROOT file:"+name);
}
throw runtime_error("+++ Failed to open ROOT file:"+name);
}
示例2: aliasname
vector<TString> getAliasNames(TTree *t) {
vector<TString> v_aliasnames;
TList *t_list = t->GetListOfAliases();
for(int i = 0; i < t_list->GetSize(); i++) {
TString aliasname(t_list->At(i)->GetName());
TBranch *branch = t->GetBranch(t->GetAlias(aliasname.Data()));
TString branchname(branch->GetName());
TString branchtitle(branch->GetTitle());
if(branchname.BeginsWith("intss") ||
branchname.BeginsWith("floatss") ||
branchname.BeginsWith("doubless") ||
branchname.Contains("LorentzVectorss") ||
branchname.Contains("timestamp") ) {
cout << "Sorry, I dont know about vector of vectors of objects. "
<< "Will be skipping " << aliasname << endl;
continue;
}
if(branchname.Contains("TString") ) {
cout << "Sorry, I don't know how to graphically represent TStrings in only 3 dimensions"
<< " Put in a feature request. Will be skipping " << aliasname << endl;
continue;
}
v_aliasnames.push_back(aliasname);
}
sort(v_aliasnames.begin(), v_aliasnames.end());
return v_aliasnames;
}
示例3: GetTreeVars
void OnlineGUI::GetTreeVars()
{
// Utility to find all of the variables (leaf's/branches) within a
// Specified TTree and put them within the treeVars vector.
treeVars.clear();
TObjArray *branchList;
vector <TString> currentTree;
for(UInt_t i=0; i<fRootTree.size(); i++) {
currentTree.clear();
branchList = fRootTree[i]->GetListOfBranches();
TIter next(branchList);
TBranch *brc;
while((brc=(TBranch*)next())!=0) {
TString found = brc->GetName();
// Not sure if the line below is so smart...
currentTree.push_back(found);
}
treeVars.push_back(currentTree);
}
#ifdef DEBUG2
for(UInt_t iTree=0; iTree<treeVars.size(); iTree++) {
cout << "In Tree " << iTree << ": " << endl;
for(UInt_t i=0; i<treeVars[iTree].size(); i++) {
cout << treeVars[iTree][i] << endl;
}
}
#endif
}
示例4: scanDiffRecoTracks
void scanDiffRecoTracks(std::string eName, std::string eoName,
std::string branchReg = "recoTracks_*"){
gSystem->Load("libFWCoreFWLite");
gROOT->ProcessLine("AutoLibraryLoader::enable();");
TChain* e = new TChain("Events");
e->SetScanField(0);
e->Add(eName.c_str());
TChain* eo = new TChain("Events");
eo->SetScanField(0);
eo->Add(eoName.c_str());
e->AddFriend(eo, "eo");
TRegexp regg(branchReg.c_str(), kTRUE);
TChain* tc = e ;
TObjArray* tl = tc->GetListOfBranches();
Int_t nBr = tl->GetSize();
for (int iB=0;iB<nBr;++iB){
TBranch* br = (TBranch*)(tl->At(iB));
TString ts(br->GetName());
if(ts.Index(regg)>=0){
std::cout<<ts.Data()<<std::endl;
tc->Scan(Form("Sum$(%s.obj.pt()>0):Sum$(eo.%s.obj.pt()>0):Sum$(%s.obj.pt()):Sum$(%s.obj.pt())-Sum$(eo.%s.obj.pt())",
ts.Data(), ts.Data(), ts.Data(), ts.Data(), ts.Data()),"", "");
}
} //> e.tecoTracks.recoT0.txt
}
示例5: 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!");
}
示例6: printTreeSummary
void printTreeSummary(TTree *t)
{
cout << "The TTree \"" << t->GetName() << "\" takes " << sizeOnDisk(t) << " bytes on disk\n";
size_t n = t->GetListOfBranches()->GetEntries();
for( size_t i = 0; i < n; ++ i ) {
TBranch *br =dynamic_cast<TBranch*>(t->GetListOfBranches()->At(i));
cout << " It's branch \"" << br->GetName() << "\" takes " << sizeOnDisk(br,true) << " bytes on disk\n";
}
}
示例7: printBranchSummary
void printBranchSummary(TBranch *br)
{
cout << "The branch \"" << br->GetName() << "\" takes " << sizeOnDisk(br,true) << " bytes on disk\n";
size_t n = br->GetListOfBranches()->GetEntries();
for( size_t i = 0; i < n; ++ i ) {
TBranch *subbr = dynamic_cast<TBranch*>(br->GetListOfBranches()->At(i));
cout << " It's sub-branch \"" << subbr->GetName() << "\" takes " << sizeOnDisk(subbr,true) << " bytes on disk\n";
}
}
示例8: mTree
mTree(TTree *t){
name=t->GetName();
entries=(long)t->GetEntries();
totSize=t->GetZipBytes();
leaves=t->GetListOfBranches()->GetEntriesFast();
for (int i=0; i<leaves; i++) {
TBranch* branch = (TBranch*)t->GetListOfBranches()->UncheckedAt(i);
branch->SetAddress(0);
// cout <<i<<"\t"<<branch->GetName()<<"\t BS: "<< branch->GetBasketSize()<<"\t size: "<< branch->GetTotalSize()<< "\ttotbytes: "<<branch->GetTotBytes() << endl;
branchSizes.insert(std::pair<string,long>(branch->GetName(),branch->GetZipBytes()));
}
}
示例9: 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);
}
}
示例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: dumpDDG4
int dumpDDG4(const char* fname, int event_num) {
TFile* data = TFile::Open(fname);
if ( !data || data->IsZombie() ) {
printf("+ File seems to not exist. Exiting\n");
usage();
return -1;
}
TTree* tree = (TTree*)data->Get("EVENT");
for(int event=0, num=tree->GetEntries(); event<num; ++event) {
TObjArray* arr = tree->GetListOfBranches();
if ( event_num>= 0 ) event = event_num;
for(int j=0, nj=arr->GetEntries(); j<nj; ++j) {
TBranch* b = (TBranch*)arr->At(j);
typedef vector<void*> _E;
_E* e = 0;
b->SetAddress(&e);
int nbytes = b->GetEvent(event);
if ( nbytes > 0 ) {
if ( e->empty() ) {
continue;
}
string br_name = b->GetName();
string cl_name = b->GetClassName();
if ( cl_name.find("dd4hep::sim::Geant4Tracker::Hit") != string::npos ) {
typedef vector<Geant4Tracker::Hit*> _H;
printHits(br_name,(_H*)e);
}
else if ( cl_name.find("dd4hep::sim::Geant4Calorimeter::Hit") != string::npos ) {
typedef vector<Geant4Calorimeter::Hit*> _H;
printHits(br_name,(_H*)e);
}
else if ( cl_name.find("dd4hep::sim::Geant4Particle") != string::npos ) {
typedef vector<Geant4Particle*> _H;
::printf("%s\n+ Particle Dump of event %8d [%8d bytes] +\n%s\n",
line,event,nbytes,line);
printParticles(br_name,(_H*)e);
}
}
}
if ( event_num >= 0 ) break;
}
delete data;
return 0;
}
示例12: doSinglePlots
void doSinglePlots(vector <std::string> branches, bool isNew, TTree* tree){
TH1F* empty = new TH1F("","", 1, 0, 1);
for (unsigned int i = 0; i < branches.size(); i++){
//isLorentz
TBranch *branch = tree->GetBranch(tree->GetAlias(branches[i].c_str()));
TString branchname(branch->GetName());
bool isLorentz = branchname.Contains("p4") || branchname.Contains("MathLorentzVectors");
//Draw
string alias = branches.at(i);
//Table of contents
myfile << "\\subsection*{" << alias << "}\\addcontentsline{toc}{subsection}{" << alias << "}" << endl;
tree->Draw(Form("%s%s>>hist", branches[i].c_str(), isLorentz ? ".Pt()" : ""), "", "", max_events);
TH1F *hist = (TH1F*)gDirectory->Get("hist");
if(hist==NULL){
cout << "********** Branch " << branches.at(i) << " exists, but is undrawable for some reason. Skipping this branch" << endl;
continue;
}
//Scale
hist->Scale(1./hist->GetEntries());
//Print plot, update ToC
vector<TH1F*> hvec;
hvec.push_back(hist);
vector<string> titles;
titles.push_back(isNew ? "New" : "Old");
dataMCplotMaker(empty, hvec, titles, "", alias, Form("--isLinear --noDivisionLabel --xAxisOverride --outputName hists/uncommon%d", plotNum));
myfile << "\\begin{figure}[H]" << endl
<< Form("\\includegraphics[width=0.6\\textwidth]{./hists/uncommon%d.pdf}", plotNum) << endl
<< "\\end{figure}" << endl;
plotNum++;
delete hist;
}
delete empty;
}
示例13: names
////////////////////////////////////////////////////////////
// names -- get the names of the branches and their details
SEXP RootChainManager::names() const {
// Advance to the first entry
//m_chain->GetEntry(0);
// Above commented out 20090616 - for TMBTrees this crashed root
// on an unresolved symbol for allocator<char>.
// Get the branches
TObjArray* branches = m_chain->GetListOfBranches();
// How many?
unsigned int nBranches = branches->GetEntriesFast();
// Make the R list for returning the list of branch and detail names
SEXP rBranchList, rBranchListNames;
PROTECT(rBranchList = NEW_LIST(nBranches));
PROTECT(rBranchListNames = NEW_CHARACTER(nBranches));
// Loop over the branches in the tree
for ( unsigned int branchIter = 0; branchIter < nBranches; ++branchIter ) {
// Get the branch
TBranch* branch = (TBranch*) branches->UncheckedAt(branchIter);
// Save away the name of this branch for use as an attribute
SET_STRING_ELT(rBranchListNames, branchIter, mkChar(branch->GetName()));
SEXP details = NEW_CHARACTER(1);
SET_ELEMENT(rBranchList, branchIter, details);
SET_STRING_ELT(details, 0, mkChar( branch->GetTitle() ) );
} // for over branches
// Set the names attribute
SET_NAMES(rBranchList, rBranchListNames);
// Release rBranchList and rBranchListNames
UNPROTECT(2);
return rBranchList;
}
示例14: aliasname
vector<std::string> getAliasNames(TTree *t){
//Vector to return results
vector<std::string> v_aliasnames;
//Skip if no entries
if (t->GetEntriesFast() == 0) return v_aliasnames;
//Get list of aliases
TList *t_list = t->GetListOfAliases();
//Loop over list, skip entries that are vectors of vectors, or strings
for(int i = 0; i < t_list->GetSize(); i++) {
std::string aliasname(t_list->At(i)->GetName());
TBranch *branch = t->GetBranch(t->GetAlias(aliasname.c_str()));
std::string branchname(branch->GetName());
std::string branchtitle(branch->GetTitle());
if(branchname.find("intss") == 0 || branchname.find("floatss") == 0 || branchname.find("doubless") == 0 || branchname.find("LorentzVectorss") < branchname.length() || branchname.find("timestamp") < branchname.length() || branchname.find("selectedPatJets") < branchname.length()){
cout << "Sorry, I dont know about vector of vectors of objects. Will be skipping " << aliasname << endl;
continue;
}
if(branchname.find("std::string") < branchname.length() || branchname.find("TStrings") < branchname.length()){
cout << "Sorry, I don't know how to graphically represent std::strings in only 3 dimensions." << " Put in a feature request. Will be skipping " << aliasname << endl;
continue;
}
v_aliasnames.push_back(aliasname);
}
//Sort alias names alphabetically
sort(v_aliasnames.begin(), v_aliasnames.end());
//Return aliases names
return v_aliasnames;
}
示例15: get_trg_info
void checkTrgMatch::get_trg_info(TTree* T)
{
reset();
TObjArray *branches = (TObjArray *)T->GetListOfBranches();
TIter branch_iter(branches);
TBranch* branch = 0;
while ((branch = (TBranch *)branch_iter.Next())) {
TString branch_name = branch->GetName();
for(int it = 0; it<n_trg; it++) {
if (branch_name.Contains(trg_name[it])){
if(branch_name.Contains("Prescl")) {
T->SetBranchAddress(branch_name.Data(), &prscl[it]);
} else if(branch_name.Contains("trigObject")) {
T->SetBranchAddress(branch_name.Data(), &trg_obj[it]);
} else {
T->SetBranchAddress(branch_name.Data(), &trg[it]);
}
break;
}
}
}
}