1 |
|
// $Id$ |
2 |
|
|
3 |
|
#include "MitAna/DataTree/interface/BranchTable.h" |
4 |
+ |
#include <TObjString.h> |
5 |
|
#include <TList.h> |
6 |
|
|
7 |
|
ClassImp(mithep::BranchTable) |
37 |
|
} |
38 |
|
|
39 |
|
//-------------------------------------------------------------------------------------------------- |
40 |
< |
void BranchTable::Print(Option_t *opt) const |
40 |
> |
TList *BranchTable::GetBranches() const |
41 |
|
{ |
42 |
< |
// Print trigger table content (not ordered!) |
42 |
> |
// Get list of branches. This list has to be deleted by the user of this function. |
43 |
|
|
44 |
+ |
TList *l = 0; |
45 |
|
TIter iter(MakeIterator()); |
46 |
|
const BranchName *bn = dynamic_cast<const BranchName*>(iter.Next()); |
47 |
+ |
if (bn) { |
48 |
+ |
l = new TList; |
49 |
+ |
l->SetOwner(1); |
50 |
+ |
} |
51 |
+ |
while (bn) { |
52 |
+ |
if (!l->FindObject(bn->Name())) { |
53 |
+ |
l->Add(new TObjString(bn->Name())); |
54 |
+ |
} |
55 |
+ |
bn = dynamic_cast<const BranchName*>(iter.Next()); |
56 |
+ |
} |
57 |
+ |
return l; |
58 |
+ |
} |
59 |
+ |
|
60 |
+ |
//-------------------------------------------------------------------------------------------------- |
61 |
+ |
TList *BranchTable::GetDepBranches(const char *brname) const |
62 |
+ |
{ |
63 |
+ |
// Get list of dependent branches for given branch name. |
64 |
+ |
// This list has to be deleted by the user of this function. |
65 |
+ |
|
66 |
+ |
TList *bl = GetListForObject(brname); |
67 |
+ |
if (!bl) |
68 |
+ |
return 0; |
69 |
+ |
|
70 |
+ |
TList *l = 0; |
71 |
+ |
TIter iter(bl->MakeIterator()); |
72 |
+ |
const BranchName *bn = dynamic_cast<const BranchName*>(iter.Next()); |
73 |
+ |
if (bn) { |
74 |
+ |
l = new TList; |
75 |
+ |
l->SetOwner(1); |
76 |
+ |
} |
77 |
|
while (bn) { |
78 |
< |
bn->Print(); |
78 |
> |
if ((strcmp(brname,bn->Name())==0) && (!l->FindObject(bn->Dep()))) { |
79 |
> |
l->Add(new TObjString(bn->Dep())); |
80 |
> |
} |
81 |
|
bn = dynamic_cast<const BranchName*>(iter.Next()); |
82 |
|
} |
83 |
+ |
return l; |
84 |
+ |
} |
85 |
+ |
|
86 |
+ |
//-------------------------------------------------------------------------------------------------- |
87 |
+ |
void BranchTable::Print(Option_t *opt) const |
88 |
+ |
{ |
89 |
+ |
// Print trigger table content (not ordered!) |
90 |
+ |
|
91 |
+ |
TList *br = GetBranches(); |
92 |
+ |
if (!br) |
93 |
+ |
return; |
94 |
+ |
|
95 |
+ |
TIter iter(br->MakeIterator()); |
96 |
+ |
const TObjString *n = dynamic_cast<const TObjString*>(iter.Next()); |
97 |
+ |
while (n) { |
98 |
+ |
TList *bl = GetDepBranches(n->GetName()); |
99 |
+ |
if (bl) { |
100 |
+ |
TIter iter2(bl->MakeIterator()); |
101 |
+ |
const TObjString *d = dynamic_cast<const TObjString*>(iter2.Next()); |
102 |
+ |
printf("%s -> ", n->GetName()); |
103 |
+ |
while (d) { |
104 |
+ |
printf("%s ", d->GetName()); |
105 |
+ |
d = dynamic_cast<const TObjString*>(iter2.Next()); |
106 |
+ |
} |
107 |
+ |
printf("\n"); |
108 |
+ |
delete bl; |
109 |
+ |
} |
110 |
+ |
n = dynamic_cast<const TObjString*>(iter.Next()); |
111 |
+ |
} |
112 |
+ |
delete br; |
113 |
|
} |