ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/src/BranchTable.cc
(Generate patch)

Comparing UserCode/MitAna/DataTree/src/BranchTable.cc (file contents):
Revision 1.1 by loizides, Fri Mar 13 20:24:51 2009 UTC vs.
Revision 1.3 by loizides, Thu Mar 19 22:17:17 2009 UTC

# Line 1 | Line 1
1   // $Id$
2  
3   #include "MitAna/DataTree/interface/BranchTable.h"
4 + #include <TObjString.h>
5   #include <TList.h>
6  
7   ClassImp(mithep::BranchTable)
# Line 36 | Line 37 | Bool_t BranchTable::Find(const BranchNam
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   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines