Revision: | 1.2 |
Committed: | Thu Jul 16 21:02:04 2009 UTC (15 years, 9 months 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, HEAD |
Branch point for: | Mit_025c_branch |
Changes since 1.1: | +3 -3 lines |
Log Message: | use same include paths as rest of code. Remember to always remove this when committing to the svn version. |
# | User | Rev | Content |
---|---|---|---|
1 | loizides | 1.1 | // |
2 | loizides | 1.2 | // $Id: TAMBranchInfo.cxx,v 1.1 2008/05/27 19:13:21 loizides Exp $ |
3 | loizides | 1.1 | // |
4 | |||
5 | loizides | 1.2 | #include "MitAna/TAM/interface/TAMBranchInfo.h" |
6 | loizides | 1.1 | |
7 | |||
8 | #ifndef ROOT_TAMVirtualBranchLoader | ||
9 | loizides | 1.2 | #include "MitAna/TAM/interface/TAMVirtualBranchLoader.h" |
10 | loizides | 1.1 | #endif |
11 | |||
12 | ////////////////////////////////////////////////////////////////////////// | ||
13 | // // | ||
14 | // TAMBranchInfo // | ||
15 | // // | ||
16 | // Class that deals with the user pointers and interacts with // | ||
17 | // the TAMVirtualBranchLoader to set up the data addresses to // | ||
18 | // which these pointers point to. Also provides basic type // | ||
19 | // checking. // | ||
20 | // // | ||
21 | // Author : Corey Reed 07/20/2004 // | ||
22 | // Author : Maarten Ballintijn 12/01/2005 // | ||
23 | // Author : Constantin Loizides 12/22/2005 // | ||
24 | // // | ||
25 | ////////////////////////////////////////////////////////////////////////// | ||
26 | |||
27 | |||
28 | ClassImp(TAMBranchInfo) | ||
29 | |||
30 | |||
31 | //______________________________________________________________________________ | ||
32 | TAMBranchInfo::TAMBranchInfo(const Char_t* branchName) : | ||
33 | TNamed(branchName,0), fIsLoaded(kFALSE), fLoader(0), fUsrAddresses() | ||
34 | { | ||
35 | // Default constructor. | ||
36 | } | ||
37 | |||
38 | |||
39 | //______________________________________________________________________________ | ||
40 | TAMBranchInfo::~TAMBranchInfo() | ||
41 | { | ||
42 | // Destructor. | ||
43 | |||
44 | vector<BranchPtr_t*>::const_iterator bEnd = fUsrAddresses.end(); | ||
45 | for (vector<BranchPtr_t*>::iterator bIter = fUsrAddresses.begin(); | ||
46 | bIter!=bEnd; bIter++) { | ||
47 | delete (*bIter); | ||
48 | } | ||
49 | |||
50 | delete fLoader; | ||
51 | } | ||
52 | |||
53 | |||
54 | //______________________________________________________________________________ | ||
55 | Int_t TAMBranchInfo::GetEntry(Long64_t entry) | ||
56 | { | ||
57 | // Load the data for this entry and set the user pointers. | ||
58 | |||
59 | if ( fIsLoaded ) return 0; | ||
60 | |||
61 | Int_t ret = -1; | ||
62 | if(fLoader) { | ||
63 | ret = fLoader->GetEntry(entry); | ||
64 | if(ret>=0) | ||
65 | SetUsrAddrs(); | ||
66 | } else { | ||
67 | Error("GetEntry", "Pointer to loader is zero."); | ||
68 | } | ||
69 | |||
70 | return ret; | ||
71 | } | ||
72 | |||
73 | |||
74 | //______________________________________________________________________________ | ||
75 | void TAMBranchInfo::Init() | ||
76 | { | ||
77 | // Initialize the branch info by setting all user pointers to zero. | ||
78 | |||
79 | ZeroUsrAddrs(); | ||
80 | } | ||
81 | |||
82 | |||
83 | //______________________________________________________________________________ | ||
84 | Bool_t TAMBranchInfo::Notify(TTree* tree) | ||
85 | { | ||
86 | // This is called when a new file is opened. It then notifies | ||
87 | // the corresponding loader and sets the data address | ||
88 | // if necessary. | ||
89 | |||
90 | ZeroUsrAddrs(); | ||
91 | |||
92 | if(fLoader) { | ||
93 | if(!fLoader->Notify(tree)) { | ||
94 | return kFALSE; | ||
95 | } | ||
96 | } | ||
97 | |||
98 | return kTRUE; | ||
99 | } | ||
100 | |||
101 | |||
102 | //______________________________________________________________________________ | ||
103 | void TAMBranchInfo::SetUsrAddrs() | ||
104 | { | ||
105 | // Set all user pointers for this branch to point to the data address. | ||
106 | |||
107 | vector<BranchPtr_t*>::const_iterator bEnd = fUsrAddresses.end(); | ||
108 | for (vector<BranchPtr_t*>::iterator bIter = fUsrAddresses.begin(); | ||
109 | bIter!=bEnd; bIter++) { | ||
110 | (*((*bIter)->fPtr)) = fLoader->GetAddress(); | ||
111 | } | ||
112 | |||
113 | fIsLoaded = kTRUE; | ||
114 | } | ||
115 | |||
116 | |||
117 | //______________________________________________________________________________ | ||
118 | void TAMBranchInfo::ZeroUsrAddrs() | ||
119 | { | ||
120 | // Set all user pointers for this branch to zero. | ||
121 | |||
122 | vector<BranchPtr_t*>::const_iterator bEnd = fUsrAddresses.end(); | ||
123 | for (vector<BranchPtr_t*>::iterator bIter = fUsrAddresses.begin(); | ||
124 | bIter!=bEnd; bIter++) { | ||
125 | (*((*bIter)->fPtr)) = 0; | ||
126 | } | ||
127 | |||
128 | fIsLoaded = kFALSE; | ||
129 | } |