1 |
loizides |
1.1 |
//
|
2 |
|
|
// $Id: TAMBranchInfo.cxx 3115 2006-07-30 22:10:47Z loizides $
|
3 |
|
|
//
|
4 |
|
|
|
5 |
|
|
#include "TAMBranchInfo.h"
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
#ifndef ROOT_TAMVirtualBranchLoader
|
9 |
|
|
#include "TAMVirtualBranchLoader.h"
|
10 |
|
|
#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 |
|
|
}
|