StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StjTreeEntryCoordinatorTest.C
1 // Copyright (C) 2008 Tai Sakuma <sakuma@bnl.gov>
2 
3 #include <StjTreeEntryCoordinator.h>
4 
5 #include <StjTreeIndex.h>
6 #include <StjTreeIndexList.h>
7 #include <StjTreeIndexListCreator.h>
8 
9 #include <StjBEMCTree.h>
10 #include <StjTPCTree.h>
11 
12 #include <StjTrackListReader.h>
13 #include <StjTowerEnergyListReader.h>
14 
15 #include <TFile.h>
16 #include <TTree.h>
17 
18 #include <iostream>
19 #include <string>
20 
21 #include "StjTreeEntryCoordinatorTest.hh"
22 
23 using namespace std;
24 
25 // Registers the fixture into the 'registry'
26 CPPUNIT_TEST_SUITE_REGISTRATION( StjTreeEntryCoordinatorTest );
27 
28 void StjTreeEntryCoordinatorTest::setUp()
29 {
30 
31 }
32 
33 void StjTreeEntryCoordinatorTest::tearDown()
34 {
35 
36 }
37 
38 void StjTreeEntryCoordinatorTest::testTree()
39 {
40  TFile* testDir = new TFile("./part_run6143024.root");
41  StjTreeIndexListCreator idxCreator(testDir);
42  idxCreator.AddTrgTreeName("trgBHT2");
43  idxCreator.AddTrgTreeName("trgBJP2");
44  StjTreeIndexList idxList = idxCreator.create();
45 
47 
48  TTree *tpctree = dynamic_cast<TTree*>(testDir->Get("tpcTracks"));
49  StjTrackListReader *tpcreader = new StjTrackListReader(tpctree);
50  StjTPCTree* tpc = new StjTPCTree(tpcreader);
51  coord->AddReader(tpcreader);
52 
53  TTree *bemctree = dynamic_cast<TTree*>(testDir->Get("bemcTowers"));
54  StjTowerEnergyListReader *bemcreader = new StjTowerEnergyListReader(bemctree);
55  StjBEMCTree* bemc = new StjBEMCTree(bemcreader);
56  coord->AddReader(bemcreader);
57 
58  coord->Init();
59 
60  int i(0);
61  while(!coord->eof()) {
62  coord->Make();
63  StjTrackList trackList = tpc->getTrackList();
64  StjTowerEnergyList energyList = bemc->getEnergyList();
65  // cout << " " << i++ << " " << trackList.size() << " " << energyList.size() << endl;
66  }
67 
68 }
69 
70 void StjTreeEntryCoordinatorTest::testEmpty()
71 {
72  StjTreeIndexList idxList;
74 
75  coord->Init();
76 
77  CPPUNIT_ASSERT( coord->eof() );
78 }
79 
80 void StjTreeEntryCoordinatorTest::testOne()
81 {
82  StjTreeIndexList idxList;
83  idxList.push_back(StjTreeIndex(10, 101));
84 
86 
87  coord->Init();
88 
89  CPPUNIT_ASSERT( ! coord->eof() );
90 
91  coord->Make();
92 
93  CPPUNIT_ASSERT( coord->eof() );
94 }
95 
96 void StjTreeEntryCoordinatorTest::testTwo()
97 {
98  StjTreeIndexList idxList;
99  idxList.push_back(StjTreeIndex(10, 101));
100  idxList.push_back(StjTreeIndex(10, 103));
101 
102  StjTreeEntryCoordinator* coord = new StjTreeEntryCoordinator(idxList);
103 
104  coord->Init();
105 
106  CPPUNIT_ASSERT( ! coord->eof() );
107 
108  coord->Make();
109 
110  CPPUNIT_ASSERT( ! coord->eof() );
111 
112  coord->Make();
113 
114  CPPUNIT_ASSERT( coord->eof() );
115 }