StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StjBEMCTreeTest.C
1 // Copyright (C) 2008 Tai Sakuma <sakuma@bnl.gov>
2 #include <StjBEMCTree.h>
3 #include "StjBEMCTreeTest.hh"
4 
5 #include <StjTowerEnergyListReader.h>
6 
7 #include <TFile.h>
8 #include <TTree.h>
9 
10 #include <iostream>
11 
12 using namespace std;
13 
14 // Registers the fixture into the 'registry'
15 CPPUNIT_TEST_SUITE_REGISTRATION( StjBEMCTreeTest );
16 
17 void StjBEMCTreeTest::setUp()
18 {
19 
20 }
21 
22 void StjBEMCTreeTest::tearDown()
23 {
24 
25 }
26 
27 
28 void StjBEMCTreeTest::testGetEntry()
29 {
30  TFile* file = new TFile("./part_run6143024.root");
31 
32  TTree *tree = dynamic_cast<TTree*>(file->Get("bemcTowers"));
33 
35 
36  tree->BuildIndex("runNumber", "eventId");
37 
38  reader->Init();
39 
40  StjBEMCTree* bemc = new StjBEMCTree(reader);
41 
42  reader->GetEntryWithIndex(6143024, 38);
43  StjTowerEnergyList energyList = bemc->getEnergyList();
44  CPPUNIT_ASSERT_EQUAL( (size_t)65, energyList.size() );
45 
46  reader->GetEntryWithIndex(6143024, 41);
47  energyList = bemc->getEnergyList();
48  CPPUNIT_ASSERT_EQUAL( (size_t)0, energyList.size() );
49 
50 
51  delete bemc;
52  delete file;
53 }
54