17 #include "StJetMuEvent.h"
18 #include "ChainMerger.h"
23 : mChain(new TChain("mTree")), mEvent(new
StJetMuEvent())
25 cout<<
"ChainMerger::ChainMerger()"<<endl;
26 buildChain(
string(dir),
string(outfile));
29 ChainMerger::~ChainMerger()
31 cout<<
"ChainMerger::~ChainMerger()"<<endl;
34 void ChainMerger::buildChain(
string dir,
string outfile)
36 cout <<
"ChainMerger::buildChain(string, string)"<<endl;
38 cout <<
"SetBranchAddress"<<endl;
39 mChain->SetBranchAddress(
"StJetMuEvent",&mEvent);
41 clock_t begin = clock();
43 cout <<
"MakeChain()"<<endl;
44 void *pDir = gSystem->OpenDirectory(dir.c_str());
47 const char* fileName(0);
51 while((fileName = gSystem->GetDirEntry(pDir))) {
53 string file(fileName);
54 if ( (file.find(
".MuDst.root")!=file.npos) && (file.find(
"_has_")!=file.npos) ) {
55 int n=findEntries(file);
56 cout <<
"file number "<<fileCount<<
":\t"<<fileName<<
"\twith nEntries:\t"<<n<<endl;
58 mChain->AddFile(file.c_str(), n);
62 cout <<
"\n TChain::GetEntries():\t"<<mChain->GetEntries()<<
"\t total:\t"<<total<<endl;
64 cout <<
"Merge chain"<<endl;
65 mChain->Merge(outfile.c_str());
67 clock_t end = clock();
68 cout <<
"\n Elapsed Time:\t"<<
static_cast<double>(end-begin)/static_cast<double>(CLOCKS_PER_SEC)<<endl;
71 int ChainMerger::findEntries(
string infile)
74 string begin =
"_has_";
75 string end =
"_events";
76 int where1 = infile.find(begin);
77 int where2 = infile.find(end);
83 int start=where1+begin.size();
91 for (
int i=start; i<stop; ++i) {
95 int nevents = atoi(number.c_str());