00001
00002
00003 #include <StjTreeEntryCoordinator.h>
00004
00005 #include <StjTreeIndex.h>
00006 #include <StjTreeIndexList.h>
00007 #include <StjTreeIndexListCreator.h>
00008
00009 #include <StjBEMCTree.h>
00010 #include <StjTPCTree.h>
00011
00012 #include <StjTrackListReader.h>
00013 #include <StjTowerEnergyListReader.h>
00014
00015 #include <TFile.h>
00016 #include <TTree.h>
00017
00018 #include <iostream>
00019 #include <string>
00020
00021 #include "StjTreeEntryCoordinatorTest.hh"
00022
00023 using namespace std;
00024
00025
00026 CPPUNIT_TEST_SUITE_REGISTRATION( StjTreeEntryCoordinatorTest );
00027
00028 void StjTreeEntryCoordinatorTest::setUp()
00029 {
00030
00031 }
00032
00033 void StjTreeEntryCoordinatorTest::tearDown()
00034 {
00035
00036 }
00037
00038 void StjTreeEntryCoordinatorTest::testTree()
00039 {
00040 TFile* testDir = new TFile("./part_run6143024.root");
00041 StjTreeIndexListCreator idxCreator(testDir);
00042 idxCreator.AddTrgTreeName("trgBHT2");
00043 idxCreator.AddTrgTreeName("trgBJP2");
00044 StjTreeIndexList idxList = idxCreator.create();
00045
00046 StjTreeEntryCoordinator* coord = new StjTreeEntryCoordinator(idxList);
00047
00048 TTree *tpctree = dynamic_cast<TTree*>(testDir->Get("tpcTracks"));
00049 StjTrackListReader *tpcreader = new StjTrackListReader(tpctree);
00050 StjTPCTree* tpc = new StjTPCTree(tpcreader);
00051 coord->AddReader(tpcreader);
00052
00053 TTree *bemctree = dynamic_cast<TTree*>(testDir->Get("bemcTowers"));
00054 StjTowerEnergyListReader *bemcreader = new StjTowerEnergyListReader(bemctree);
00055 StjBEMCTree* bemc = new StjBEMCTree(bemcreader);
00056 coord->AddReader(bemcreader);
00057
00058 coord->Init();
00059
00060 int i(0);
00061 while(!coord->eof()) {
00062 coord->Make();
00063 StjTrackList trackList = tpc->getTrackList();
00064 StjTowerEnergyList energyList = bemc->getEnergyList();
00065
00066 }
00067
00068 }
00069
00070 void StjTreeEntryCoordinatorTest::testEmpty()
00071 {
00072 StjTreeIndexList idxList;
00073 StjTreeEntryCoordinator* coord = new StjTreeEntryCoordinator(idxList);
00074
00075 coord->Init();
00076
00077 CPPUNIT_ASSERT( coord->eof() );
00078 }
00079
00080 void StjTreeEntryCoordinatorTest::testOne()
00081 {
00082 StjTreeIndexList idxList;
00083 idxList.push_back(StjTreeIndex(10, 101));
00084
00085 StjTreeEntryCoordinator* coord = new StjTreeEntryCoordinator(idxList);
00086
00087 coord->Init();
00088
00089 CPPUNIT_ASSERT( ! coord->eof() );
00090
00091 coord->Make();
00092
00093 CPPUNIT_ASSERT( coord->eof() );
00094 }
00095
00096 void StjTreeEntryCoordinatorTest::testTwo()
00097 {
00098 StjTreeIndexList idxList;
00099 idxList.push_back(StjTreeIndex(10, 101));
00100 idxList.push_back(StjTreeIndex(10, 103));
00101
00102 StjTreeEntryCoordinator* coord = new StjTreeEntryCoordinator(idxList);
00103
00104 coord->Init();
00105
00106 CPPUNIT_ASSERT( ! coord->eof() );
00107
00108 coord->Make();
00109
00110 CPPUNIT_ASSERT( ! coord->eof() );
00111
00112 coord->Make();
00113
00114 CPPUNIT_ASSERT( coord->eof() );
00115 }