本文整理汇总了C++中TBranch::InheritsFrom方法的典型用法代码示例。如果您正苦于以下问题:C++ TBranch::InheritsFrom方法的具体用法?C++ TBranch::InheritsFrom怎么用?C++ TBranch::InheritsFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TBranch
的用法示例。
在下文中一共展示了TBranch::InheritsFrom方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ResetDeleteBranches
void ResetDeleteBranches(TTree* tree) {
TObjArray* branches = tree->GetListOfBranches();
Int_t nb = branches->GetEntriesFast();
for (Int_t i = 0; i < nb; ++i) {
TBranch* br = (TBranch*) branches->UncheckedAt(i);
if (br->InheritsFrom(TBranchElement::Class())) {
((TBranchElement*) br)->ResetDeleteObject();
}
}
}
示例2: 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;
}
}
示例3: dt_RunDrawTest
bool dt_RunDrawTest(const char* from, Int_t mode = 0, Int_t verboseLevel = 0) {
// This launch a test a TTree::Draw.
// The mode currently available are:
// 0: Do not load the shared library
// 1: Load the shared library before opening the file
// 2: Load the shared library after opening the file
// 3: Simple TChain test with shared library
// 4: Simple Friend test with shared library
// The verboseLeve currently available:
// 0: As silent as possible, only report errors and overall speed results.
// 1: Output 0 + label for the start of each phase
// 2: Output 1 + more details on the different phase being done
// 3: Output 2 + stop at the first and draw a canvas showing the differences
//gDebug = 5;
SetVerboseLevel(verboseLevel);
if (mode == 1) {
if (!TClassTable::GetDict("Event")) {
gSystem->Load("Event_cxx");
}
gHasLibrary = kTRUE;
}
TFile *hfile = 0;
TTree *tree = 0;
if (mode <3) {
hfile = new TFile(from);
tree = (TTree*)hfile->Get("T");
}
if (mode >= 2 && mode <= 4) {
if (!TClassTable::GetDict("Event")) {
gSystem->Load("Event_cxx");
} else {
cerr << "Since libEvent.so has already been loaded, mode 2 can not be tested!";
cerr << endl;
}
gHasLibrary = kTRUE;
}
if (mode == 3) {
// Test Chains.
TChain * chain = new TChain("T");
chain->Add(from);
chain->Add(from);
tree = chain;
}
if (mode == 4) {
// Test friends.
tree = new TTree("T","Base of friendship");
tree->AddFriend("T",from);
}
TBranch *eb = tree->GetBranch("event");
gBranchStyle = (int) eb->InheritsFrom(TBranchElement::Class());
// cerr << "Branch style is " << gBranchStyle << endl;
if (gQuietLevel<2) cout << "Generating histograms from TTree::Draw" << endl;
TDirectory* where = GenerateDrawHist(tree,2,gQuietLevel);
if (gQuietLevel<2) cout << "Comparing histograms" << endl;
if (Compare(where)>0) {
cout << "DrawTest: Comparison failed" << endl;
return false;
}
DrawMarks();
if (gQuietLevel<2) cout << "DrawTest: Comparison was successfull" << endl;
if (hfile) delete hfile;
else delete tree;
gROOT->GetList()->Delete();
return true;
}