Revision: | 1.3 |
Committed: | Thu Mar 19 22:17:17 2009 UTC (16 years, 1 month ago) by loizides |
Content type: | text/plain |
Branch: | MAIN |
CVS Tags: | Mit_032, Mit_031, Mit_025c_branch2, Mit_025c_branch1, Mit_030, Mit_029c, Mit_029b, Mit_030_pre1, Mit_029a, Mit_029, Mit_029_pre1, Mit_028a, Mit_025c_branch0, Mit_028, Mit_027a, Mit_027, Mit_026, Mit_025e, Mit_025d, Mit_025c, Mit_025b, Mit_025a, Mit_025, Mit_025pre2, Mit_024b, Mit_025pre1, Mit_024a, Mit_024, Mit_023, Mit_022a, Mit_022, Mit_020d, TMit_020d, Mit_020c, Mit_021, Mit_021pre2, Mit_021pre1, Mit_020b, Mit_020a, Mit_020, Mit_020pre1, Mit_018, Mit_017, Mit_017pre3, Mit_017pre2, Mit_017pre1, Mit_016, Mit_015b, Mit_015a, Mit_015, Mit_014e, Mit_014d, Mit_014c, Mit_014b, Mit_014a, Mit_014, Mit_014pre3, Mit_014pre2, Mit_014pre1, Mit_013d, Mit_013c, Mit_013b, Mit_013a, Mit_013, Mit_013pre1, Mit_012i, Mit_012h, Mit_012g, Mit_012f, Mit_012e, Mit_012d, Mit_012c, Mit_012b, Mit_012a, Mit_012, Mit_011a, Mit_011, Mit_010a, Mit_010, Mit_009c, Mit_009b, Mit_009a, Mit_009, Mit_008, HEAD |
Branch point for: | Mit_025c_branch |
Changes since 1.2: | +38 -9 lines |
Log Message: | Added GetDepBranches |
# | Content |
---|---|
1 | // $Id: BranchTable.cc,v 1.2 2009/03/16 19:31:14 loizides Exp $ |
2 | |
3 | #include "MitAna/DataTree/interface/BranchTable.h" |
4 | #include <TObjString.h> |
5 | #include <TList.h> |
6 | |
7 | ClassImp(mithep::BranchTable) |
8 | |
9 | using namespace mithep; |
10 | |
11 | //-------------------------------------------------------------------------------------------------- |
12 | Bool_t BranchTable::Find(const char *brname, const char *brdep) const |
13 | { |
14 | // Search for given pair of branch dependency. |
15 | |
16 | if (!brname || !brdep) |
17 | return kFALSE; |
18 | |
19 | TList *l = GetListForObject(brname); |
20 | if (!l) |
21 | return kFALSE; |
22 | |
23 | TIter next(l); |
24 | while (const BranchName *bn = dynamic_cast<const BranchName*>(next())) { |
25 | if (strcmp(bn->Dep(),brdep)==0) |
26 | return kTRUE; |
27 | } |
28 | return kFALSE; |
29 | } |
30 | |
31 | //-------------------------------------------------------------------------------------------------- |
32 | Bool_t BranchTable::Find(const BranchName &bn) const |
33 | { |
34 | // Search for given pair of branch dependency. |
35 | |
36 | return Find(bn.Name(), bn.Dep()); |
37 | } |
38 | |
39 | //-------------------------------------------------------------------------------------------------- |
40 | TList *BranchTable::GetBranches() const |
41 | { |
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 | 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 | } |