ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/src/BranchTable.cc
Revision: 1.2
Committed: Mon Mar 16 19:31:14 2009 UTC (16 years, 1 month ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_008pre2
Changes since 1.1: +39 -4 lines
Log Message:
Added more convenient print

File Contents

# Content
1 // $Id: BranchTable.cc,v 1.1 2009/03/13 20:24:51 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 = new TList;
45 l->SetOwner(1);
46
47 TIter iter(MakeIterator());
48 const BranchName *bn = dynamic_cast<const BranchName*>(iter.Next());
49 while (bn) {
50 if (!l->FindObject(bn->Name())) {
51 l->Add(new TObjString(bn->Name()));
52 }
53 bn = dynamic_cast<const BranchName*>(iter.Next());
54 }
55 return l;
56 }
57
58 //--------------------------------------------------------------------------------------------------
59 void BranchTable::Print(Option_t *opt) const
60 {
61 // Print trigger table content (not ordered!)
62
63 TList *br = GetBranches();
64 if (!br)
65 return;
66
67 TIter iter(br->MakeIterator());
68 const TObjString *n = dynamic_cast<const TObjString*>(iter.Next());
69 while (n) {
70 TList *bl = GetListForObject(n->GetName());
71 if (bl) {
72 TIter iter2(bl->MakeIterator());
73 const BranchName *bn = dynamic_cast<const BranchName*>(iter2.Next());
74 printf("%s -> ", n->GetName());
75 while (bn) {
76 printf("%s ", bn->Dep());
77 bn = dynamic_cast<const BranchName*>(iter2.Next());
78 }
79 printf("\n");
80 }
81 n = dynamic_cast<const TObjString*>(iter.Next());
82 }
83 delete br;
84 }