StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StjTPCTreeTest.C
1 // Copyright (C) 2008 Tai Sakuma <sakuma@bnl.gov>
2 #include <StjTPCTree.h>
3 #include "StjTPCTreeTest.hh"
4 
5 #include <StjTreeEntryCoordinator.h>
6 #include <StjTreeIndexList.h>
7 
8 #include <StjTrackListReader.h>
9 
10 #include <TFile.h>
11 #include <TTree.h>
12 
13 #include <iostream>
14 
15 using namespace std;
16 
17 // Registers the fixture into the 'registry'
18 CPPUNIT_TEST_SUITE_REGISTRATION( StjTPCTreeTest );
19 
20 void StjTPCTreeTest::setUp()
21 {
22 
23 }
24 
25 void StjTPCTreeTest::tearDown()
26 {
27 
28 }
29 
30 void StjTPCTreeTest::testGetEntry()
31 {
32  TFile* file = new TFile("./part_run6143024.root");
33 
34  TTree *tree = dynamic_cast<TTree*>(file->Get("tpcTracks"));
35 
36  StjTrackListReader *reader = new StjTrackListReader(tree);
37 
38  tree->BuildIndex("runNumber", "eventId");
39 
40  reader->Init();
41 
42  StjTPCTree* tpc = new StjTPCTree(reader);
43 
44  reader->GetEntryWithIndex(6143024, 38);
45 
46  StjTrackList trackList = tpc->getTrackList();
47  CPPUNIT_ASSERT_EQUAL( (size_t)13, trackList.size() );
48  CPPUNIT_ASSERT_EQUAL((Short_t) 87, trackList[0].id );
49  CPPUNIT_ASSERT_EQUAL((Short_t) 80, trackList[1].id );
50  CPPUNIT_ASSERT_EQUAL((Short_t) 77, trackList[2].id );
51  CPPUNIT_ASSERT_EQUAL((Short_t) 76, trackList[3].id );
52  CPPUNIT_ASSERT_EQUAL((Short_t) 67, trackList[4].id );
53  CPPUNIT_ASSERT_EQUAL((Short_t) 65, trackList[5].id );
54  CPPUNIT_ASSERT_EQUAL((Short_t) 51, trackList[6].id );
55  CPPUNIT_ASSERT_EQUAL((Short_t) 29, trackList[7].id );
56  CPPUNIT_ASSERT_EQUAL((Short_t) 11, trackList[8].id );
57  CPPUNIT_ASSERT_EQUAL((Short_t)199, trackList[9].id );
58  CPPUNIT_ASSERT_EQUAL((Short_t)192, trackList[10].id );
59  CPPUNIT_ASSERT_EQUAL((Short_t)185, trackList[11].id );
60  CPPUNIT_ASSERT_EQUAL((Short_t)181, trackList[12].id );
61 
62 
63  reader->GetEntryWithIndex(6143024, 41);
64  trackList = tpc->getTrackList();
65  CPPUNIT_ASSERT_EQUAL( (size_t)0, trackList.size() );
66 
67  delete tpc;
68  delete file;
69 }
70