StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StjTreeIndexListCreator.cxx
1 // $Id: StjTreeIndexListCreator.cxx,v 1.5 2009/12/03 09:57:36 pibero Exp $
2 // Copyright (C) 2008 Tai Sakuma <sakuma@bnl.gov>
3 #include "StjTreeIndexListCreator.h"
4 
5 #include "StjTreeIndexList.h"
6 
7 #include <TTree.h>
8 #include <TDirectory.h>
9 
10 #include <set>
11 
13 
14 using namespace std;
15 
16 StjTreeIndexList StjTreeIndexListCreator::create()
17 {
18  std::set<StjTreeIndex> indexSet;
19  for(TrgTreeNameList::const_iterator trgName = _trgTreeNameList.begin(); trgName != _trgTreeNameList.end(); ++trgName) {
20  StjTreeIndexList aList = getIndexListOfRunsPassedFor((*trgName).c_str());
21  indexSet.insert(aList.begin(), aList.end());
22  }
23 
24  StjTreeIndexList ret;;
25  copy(indexSet.begin(), indexSet.end(), back_inserter(ret));
26  return ret;
27 }
28 
29 StjTreeIndexList StjTreeIndexListCreator::getIndexListOfRunsPassedFor(const char* treeName)
30 {
31  StjTreeIndexList ret;
32  TTree *tree = dynamic_cast<TTree*>(_file->Get(treeName));
33  Int_t indexMajor, indexMinor;
34  tree->SetBranchAddress(_indexMajorName.c_str(), &indexMajor);
35  tree->SetBranchAddress(_indexMinorName.c_str(), &indexMinor);
36  // Int_t passed;
37  // tree->SetBranchAddress("passed", &passed);
38  for(Long64_t i = 0; i < tree->GetEntries(); ++i) {
39  if(tree->GetEntry(i) <= 0) continue;
40  // if(!passed) continue;
41  ret.push_back(StjTreeIndex(indexMajor, indexMinor));
42  }
43  return ret;
44 }