00001 #ifndef StHbtTagReader_h
00002 #define StHbtTagReader_h
00003
00004 #include "StMaker.h"
00005 #include "StChain.h"
00006 #include "StIOMaker/StIOMaker.h"
00007
00008 #include "TTree.h"
00009 #include "TBranch.h"
00010 #include "TLeaf.h"
00011
00012 #ifdef __CC5__
00013 #include <Stiostream.h>
00014 #endif
00015
00016
00017 #include <string>
00018 #if !defined(ST_NO_NAMESPACES)
00019 using std::string;
00020 #endif
00021
00022 class StHbtTagReader {
00023 protected:
00024 const StIOMaker* mIOMaker;
00025 string mTagFileName;
00026 string mDstFileName;
00027 TFile* mTFile;
00028 TTree* mTTree;
00029
00030 int mIret;
00031 int mNEvents;
00032 int mEventIndex;
00033 int mRunNumber;
00034 int mEventNumber;
00035
00036
00037 int GetEventIndex(int runNumber, int eventNumber);
00038 void init();
00039 public:
00040 StHbtTagReader(const char* tagFileName);
00041 StHbtTagReader(const StIOMaker* ioMaker);
00042
00043 virtual ~StHbtTagReader();
00044
00045
00046
00047 int EventMatch(int runNumber, int eventNumber);
00048 double tag(char* name, unsigned int i=0) {
00049 if ( mTTree->GetLeaf(name) )
00050 if ( (unsigned int)mTTree->GetLeaf(name)->GetNdata() > i )
00051 return (double)mTTree->GetLeaf(name)->GetValue(i);
00052 return -9999;
00053 }
00054 int intTag(char* name, unsigned int i=0) {
00055 if ( mTTree->GetLeaf(name) && strcmp(mTTree->GetLeaf(name)->GetTypeName(),"Int_t") )
00056 if ( (unsigned int)mTTree->GetLeaf(name)->GetNdata() > i )
00057 return (int)mTTree->GetLeaf(name)->GetValue(i);
00058 return -9999;
00059 }
00060 float floatTag(char* name, unsigned int i=0) {
00061 if ( mTTree->GetLeaf(name) && strcmp(mTTree->GetLeaf(name)->GetTypeName(),"Float_t") )
00062 if ( (unsigned int)mTTree->GetLeaf(name)->GetNdata() > i )
00063 return (float)mTTree->GetLeaf(name)->GetValue(i);
00064 return -9999.;
00065 }
00066
00067
00068 #ifdef __ROOT__
00069 ClassDef(StHbtTagReader,0)
00070 #endif
00071 };
00072
00073
00074 #endif