1 #include "StHbtMaker/Reader/StHbtTagReader.h"
16 cout <<
" StHbtTagReader::StHbtTagReader(const char* tagFileName)" << endl;
17 mTagFileName = string(tagFileName);
21 StHbtTagReader::StHbtTagReader(
const StIOMaker* ioMaker) : mTagFileName(
""), mDstFileName(
""), mTFile(0), mTTree(0) {
22 cout <<
" StHbtTagReader::StHbtTagReader(const StIOMaker* ioMaker)" << endl;
26 void StHbtTagReader::init() {
27 cout <<
" StHbtTagReader::init()" << endl;
29 if ( mTFile->IsOpen() ) {
30 cout <<
" StHbtTagReader::init() - closing file " << endl;
35 mTFile =
new TFile(mTagFileName.c_str(),
"r");
36 if ( mTFile->IsOpen() ) {
37 cout <<
" StHbtTagReader::init() - new tags file opend : -" << mTagFileName.c_str() <<
"-" << endl;
38 mDstFileName = mIOMaker->GetFile();
39 mTTree = (TTree*)mTFile->Get(
"Tag");
40 mNEvents = (int)mTTree->GetEntries();
43 cout <<
" StHbtTagReader::init() - coundn't open new tags file : -" << mTagFileName.c_str() <<
"-" << endl;
47 StHbtTagReader::~StHbtTagReader(){
48 if (mTFile) mTFile->Close();
51 int StHbtTagReader::EventMatch(
int runNumber,
int eventNumber) {
54 cout <<
" mIOMaker " << mIOMaker <<
" " << mDstFileName.c_str() <<
" " << mIOMaker->GetFile() << endl;
55 if (strcmp(mDstFileName.c_str(),mIOMaker->GetFile()) ) {
56 cout <<
" new file " << endl;
57 mTagFileName = mIOMaker->GetFile();
58 if (mTagFileName.find(
".dst.") != string::npos)
59 mTagFileName.replace(mTagFileName.find(
".dst."),5,
".tags.");
60 else if (mTagFileName.find(
".event.") != string::npos)
61 mTagFileName.replace(mTagFileName.find(
".event."),7,
".tags.");
65 return (GetEventIndex(runNumber,eventNumber)!=-1) ? 1 : 0;
68 int StHbtTagReader::GetEventIndex(
int runNumber,
int eventNumber){
69 cout <<
" StHbtTagReader::GetEventIndex(int runNumber, int eventNumber)" << endl;
73 for (
int i=0; i<mNEvents; i++) {
74 mIret = mTTree->GetEntry(i);
75 if ( mTTree->GetBranch(
"EvtHddr.mEventNumber")->GetLeaf(
"mEventNumber")->GetValue() == eventNumber &&
76 mTTree->GetBranch(
"EvtHddr.mRunNumber")->GetLeaf(
"mRunNumber")->GetValue() == runNumber ) {
78 mRunNumber = (int)mTTree->GetBranch(
"EvtHddr.mRunNumber")->GetLeaf(
"mRunNumber")->GetValue();
79 mEventNumber = (int)mTTree->GetBranch(
"EvtHddr.mEventNumber")->GetLeaf(
"mEventNumber")->GetValue();