StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StjTreeReaderTwoTrees.cxx
1 // $Id: StjTreeReaderTwoTrees.cxx,v 1.2 2009/12/03 09:57:36 pibero Exp $
2 // Copyright (C) 2008 Tai Sakuma <sakuma@bnl.gov>
3 #include "StjTreeReaderTwoTrees.h"
4 
5 #include "StjTreeIndex.h"
6 
7 #include <TTree.h>
8 
9 #include <iostream>
10 
11 ClassImp(StjTreeReaderTwoTrees)
12 
13 using namespace std;
14 
15 void StjTreeReaderTwoTrees::Init()
16 {
17  _tree1->BuildIndex("runNumber", "eventId");
18  _tree2->BuildIndex("runNumber", "eventId");
19  SetBranchAddress(_tree1, _tree2);
20 }
21 
22 Long64_t StjTreeReaderTwoTrees::GetEntryWithIndex(const StjTreeIndex& idx)
23 {
24  return StjTreeReader::GetEntryWithIndex(idx);
25 }
26 
27 Long64_t StjTreeReaderTwoTrees::GetEntryWithIndex(Int_t major, Int_t minor)
28 {
29  clearEntry();
30 
31  Long64_t ret1 = _tree1->GetEntryWithIndex(major, minor);
32 
33  if(ret1 <= 0) return ret1;
34 
35  Long64_t ret2 = _tree2->GetEntryWithIndex(major, minor);
36 
37  if(ret2 <= 0) return ret2;
38 
39  readEntry();
40 
41  return ret1 + ret2;
42 }