StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StHbtTagReader.h
1 #ifndef StHbtTagReader_h
2 #define StHbtTagReader_h
3 
4 #include "StMaker.h"
5 #include "StChain.h"
6 #include "StIOMaker/StIOMaker.h"
7 
8 #include "TTree.h"
9 #include "TBranch.h"
10 #include "TLeaf.h"
11 
12 #ifdef __CC5__
13  #include <Stiostream.h>
14 #endif
15 
16 
17 #include <string>
18 #if !defined(ST_NO_NAMESPACES)
19 using std::string;
20 #endif
21 
23  protected:
24  const StIOMaker* mIOMaker;
25  string mTagFileName;
26  string mDstFileName;
27  TFile* mTFile;
28  TTree* mTTree;
29 
30  int mIret;
31  int mNEvents;
32  int mEventIndex;
33  int mRunNumber;
34  int mEventNumber;
35  // pointers to other makers
36 
37  int GetEventIndex(int runNumber, int eventNumber);
38  void init();
39  public:
40  StHbtTagReader(const char* tagFileName);
41  StHbtTagReader(const StIOMaker* ioMaker);
42 
43  virtual ~StHbtTagReader();
44 
45 
46  // is there a tag matching the current event and run-number ?
47  int EventMatch(int runNumber, int eventNumber);
48  double tag(char* name, unsigned int i=0) {
49  if ( mTTree->GetLeaf(name) )
50  if ( (unsigned int)mTTree->GetLeaf(name)->GetNdata() > i )
51  return (double)mTTree->GetLeaf(name)->GetValue(i);
52  return -9999;
53  }
54  int intTag(char* name, unsigned int i=0) {
55  if ( mTTree->GetLeaf(name) && strcmp(mTTree->GetLeaf(name)->GetTypeName(),"Int_t") )
56  if ( (unsigned int)mTTree->GetLeaf(name)->GetNdata() > i )
57  return (int)mTTree->GetLeaf(name)->GetValue(i);
58  return -9999;
59  }
60  float floatTag(char* name, unsigned int i=0) {
61  if ( mTTree->GetLeaf(name) && strcmp(mTTree->GetLeaf(name)->GetTypeName(),"Float_t") )
62  if ( (unsigned int)mTTree->GetLeaf(name)->GetNdata() > i )
63  return (float)mTTree->GetLeaf(name)->GetValue(i);
64  return -9999.;
65  }
66 
67 
68 #ifdef __ROOT__
69  ClassDef(StHbtTagReader,0)
70 #endif
71 };
72 
73 
74 #endif