00001
00002
00003 #include "StjTreeIndexListCreator.h"
00004
00005 #include "StjTreeIndexList.h"
00006
00007 #include <TTree.h>
00008 #include <TDirectory.h>
00009
00010 #include <set>
00011
00012 ClassImp(StjTreeIndexListCreator)
00013
00014 using namespace std;
00015
00016 StjTreeIndexList StjTreeIndexListCreator::create()
00017 {
00018 std::set<StjTreeIndex> indexSet;
00019 for(TrgTreeNameList::const_iterator trgName = _trgTreeNameList.begin(); trgName != _trgTreeNameList.end(); ++trgName) {
00020 StjTreeIndexList aList = getIndexListOfRunsPassedFor((*trgName).c_str());
00021 indexSet.insert(aList.begin(), aList.end());
00022 }
00023
00024 StjTreeIndexList ret;;
00025 copy(indexSet.begin(), indexSet.end(), back_inserter(ret));
00026 return ret;
00027 }
00028
00029 StjTreeIndexList StjTreeIndexListCreator::getIndexListOfRunsPassedFor(const char* treeName)
00030 {
00031 StjTreeIndexList ret;
00032 TTree *tree = dynamic_cast<TTree*>(_file->Get(treeName));
00033 Int_t indexMajor, indexMinor;
00034 tree->SetBranchAddress(_indexMajorName.c_str(), &indexMajor);
00035 tree->SetBranchAddress(_indexMinorName.c_str(), &indexMinor);
00036
00037
00038 for(Long64_t i = 0; i < tree->GetEntries(); ++i) {
00039 if(tree->GetEntry(i) <= 0) continue;
00040
00041 ret.push_back(StjTreeIndex(indexMajor, indexMinor));
00042 }
00043 return ret;
00044 }