//
//  The version of the class should be changed every time
//  when any changes in the codes are done
//  Grigory Nigmatkulov: 2016/12/15
//
#ifndef StHbtFemtoDstReader_hh
#define StHbtFemtoDstReader_hh

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

#include "StMaker.h"
#include "StFemtoEvent.h"
#include "TSystem.h"
#include "TChain.h"
#include "StChain.h"
#include <string>
#include <stdlib.h>

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

//_________________
class StHbtFemtoDstReader : public StHbtEventReader {
 private:
  string mDir;
  string mFileName;
  string mFilter;

  bool          mDebug;
  unsigned int  mEventIndex;
  unsigned int  mNEvents;
  unsigned int  mTrig;
  TChain       *mTChain;
  TTree        *mTree;
  StFemtoEvent *mFemtoEvent;
  float         mTotalTracks;

  std::vector<unsigned int> mTrigIdCol;
  
  int mMaxFiles;
  

  int InitRead(string aDir, string aFileName,
	       string aFilter, int aMaxFiles);
  int FillChain(TChain *aChain, const char *aFileName, 
		int aMaxFiles);
  int FillChain(TChain *aChain, char *aDir,
		const char *aFilter, int aMaxFiles);
  void UninitRead();
  StHbtEvent *Read();
 public:
  StHbtFemtoDstReader(const char *aDirName, const char *aFileName,
		      const char *aFilter = ".", int aMaxFiles = 1e9, bool aDebug = false);
  StHbtEvent *ReturnHbtEvent();
  void AddTrigId(unsigned int aTrigId);
  void PrintTotalTracks();
  void DoDebug(bool aDebug = false);
  StHbtString Report();
  int GetNEvents();
  void SetTrigger(unsigned int trig, char mode);

  ClassDef(StHbtFemtoDstReader, 2)
};

#endif
