#ifndef StHbtStarGenReader_hh
#define StHbtStarGenReader_hh

#include "StHbtMaker/Base/StHbtEventReader.hh"
#include "StHbtMaker/Infrastructure/StHbtEvent.hh"
#include "StHbtMaker/Infrastructure/StHbtEnumeration.hh"
#include "StEvent/StEnumerations.h"

#include "StMaker.h"
#include "TSystem.h"
#include "TChain.h"
#include "StChain.h"
#include "TRandom3.h"
#include <StarGenerator/EVENT/StarGenParticle.h>
#include <StarGenerator/EVENT/StarGenEvent.h>

#include <string>
#include <stdlib.h>

class StFlowEvent;
class StIOMaker;
class TTree;
class TFile;

//_________________
class StHbtStarGenReader : public StHbtEventReader {
 private:
  //
  // General variables
  //
  string mDir;
  string mFileName;
  string mFilter;

  //
  // Internal variables
  //
  bool          mDebug;
  unsigned int  mEventIndex;
  unsigned int  mNEvents;
  TChain       *mTChain;
  TTree        *mTree;
  StarGenEvent *mSGEvent;
  float         mTotalTracks;
  int           mMaxFiles;
  TRandom3     *randy;

  int InitRead(string dir, string fileName,
               string filter, int maxFiles);
  int FillChain(TChain *aChain, const char *fileName, 
                int faxFiles);
  int FillChain(TChain *chain, char *dir,
                const char *filter, int maxFiles);
  void UninitRead();
  float dedxMean(float mass, float momentum);
  StHbtEvent *Read();

 public:
  StHbtStarGenReader(const char *dirName, const char *fileName,
                     const char *filter = ".", int maxFiles = 1e9, bool debug = false);
  StHbtEvent *ReturnHbtEvent();
  void PrintTotalTracks();
  void DoDebug(bool debug = false);
  StHbtString Report();
  int GetNEvents();


  ClassDef(StHbtStarGenReader, 1)
};

#endif
