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

# User Rev Content
1 loizides 1.2 // $Id: BranchTable.cc,v 1.1 2009/03/13 20:24:51 loizides Exp $
2 loizides 1.1
3     #include "MitAna/DataTree/interface/BranchTable.h"
4 loizides 1.2 #include <TObjString.h>
5 loizides 1.1 #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 loizides 1.2 TList *BranchTable::GetBranches() const
41 loizides 1.1 {
42 loizides 1.2 // 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 loizides 1.1
47     TIter iter(MakeIterator());
48     const BranchName *bn = dynamic_cast<const BranchName*>(iter.Next());
49     while (bn) {
50 loizides 1.2 if (!l->FindObject(bn->Name())) {
51     l->Add(new TObjString(bn->Name()));
52     }
53 loizides 1.1 bn = dynamic_cast<const BranchName*>(iter.Next());
54     }
55 loizides 1.2 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 loizides 1.1 }