#ifndef STFEMTODSTQAMAKER_HH
#define STFEMTODSTQAMAKER_HH

#include <iostream>
#include "StMaker.h"
#include "StChain.h"
#include "TChain.h"
#include "TSystem.h"
#include "TH1.h"
#include "TH2.h"
#include "TProfile.h"
#include "StFemtoEvent.h"
#include <string>
#include <stdlib.h>

//_________________
class StFemtoDstQAMaker : public StMaker {

 public:
  StFemtoDstQAMaker(const char *aDirName, 
		    const char *aFileName,
		    const char *aFilter = ".", 
		    int aMaxFiles = 10000);
  void AddTrigId(unsigned int aTrigId);
  int GetNEvents();
  
  Int_t Init();
  Int_t Make();
  Int_t Finish();
  void SetOutFileName(const char *oFileName) {outFileName = oFileName;}
  //Should be set for each year and run period. The values can be found in: online.star.bnl.gov->RunLog Browser
  void SetRunIdParameters(unsigned int nbins, double lo, double hi) { mRunIdBins=nbins; mRunIdVal[0]=lo; mRunIdVal[1]=hi; }
  void SetTrigger(unsigned int trig, char mode);

 private:
  string dir;
  string fileName;
  string filter;

  unsigned int eventId;
  unsigned int nEvents;
  TFile        *outFile;
  TChain       *chain;
  TTree        *tree;
  StFemtoEvent *femtoEvent;
  const char   *outFileName;
  unsigned int mRunIdBins;
  double mRunIdVal[2];

  //Event histograms
  TH1F *hRefMultCorr;
  TH1F *hRefMult;
  TH1F *hRefMult2;
  TH1F *hRefMultWeight;
  TH1F *hTofMult;
  TH2F *hTofVsRef;
  TH2F *hTofVsRef2;
  TH2F *hRefVsRef2;
  TH1F *hPrimVertZ;
  TH1F *hPrimVertR;
  TH2F *hPrimVertXvsY;
  TH1F *hPrimVertVpdVzDiff;
  //Here is the way of how to look on the quantities over the run
  TProfile *hRefMultVsRunNumer;
  TProfile *hPrimTrackNumVsRunNumber;
  TProfile *hGlobTrackNumVsRunNumber;
  TProfile *hTofMultVsRunNumber;
  //Track histograms
  TH2F *hNSigmaPionVsMom;
  TH2F *hNSigmaKaonVsMom;
  TH2F *hNSigmaProtonVsMom;
  TH2F *hNSigmaElectronVsMom;

  TH1F *hP;
  TH1F *hPt;

  TH1F *hGlobPx;
  TH1F *hGlobPy;
  TH1F *hGlobPz;

  TH1F *hGlobX;
  TH1F *hGlobY;
  TH1F *hGlobZ;

  TH1F *hdEdx;
  TH2F *hdEdx_p;
  TH1F *hDCAxy;
  TH1F *hDCAz;
  TH1F *hDCAxyGlob;
  TH1F *hDCAzGlob;
  TH2F *hMSqr_P;
  TH2F *hInvBeta_P;
  TH2F *hBeta_P;
  TH1F *hEta;

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

  int maxFiles;
  
  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();
  
  ClassDef(StFemtoDstQAMaker, 3)
};

#endif
