/****************************************/
/***                                  ***/
/***          StHijingQA              ***/
/***  VERSION: 1.0                    ***/
/***   AUTHOR: Nikita Ermakov         ***/
/***     DATE:                        ***/
/***   E-MAIL: coffe92@gmail.com      ***/
/***                                  ***/
/****************************************/

#ifndef STHIJINGQA_HH
#define STHIJINGQA_HH

#include "StMaker.h"
#include "StThreeVector.hh"
#include "StThreeVectorF.hh"
#include "StPhysicalHelixD.hh"

#include <StarGenerator/EVENT/StarGenParticle.h>
#include <StarGenerator/EVENT/StarGenEvent.h>

#include <TString.h>
#include <TSystem.h>
#include <TFile.h>
#include <TLorentzVector.h>
#include <TTree.h>
#include <TH1.h>
#include <TH2.h>
#include <TChain.h>

#include <vector>
#include <iostream>

#ifndef St_NO_NAMESPACES
using namespace std;
#endif



class StHijingQA : public StMaker
{
    
public:
    StHijingQA(const char *dir,
	       const char *fileName,
	       const char *filter,
	       int maxFiles,
	       const char *outFile);
    ~StHijingQA();
    //
    // Chain methods
    //
    void  Clear(Option_t *option = "");
    int Init();
    int Make();
    int Finish();
    unsigned int GetNEvents();

    void CleanVariables();
    //
    // Setup track
    //
    void SetP(float lo, float hi);
    void SetTrackEta(float lo, float hi);

private:
    int InitChain(string dir, string fileName,
		  string filter, int maxFiles);
    int FillChain(TChain *chain, const char *fileName,
		  int maxFiles);
    int FillChain(TChain *chain, char *dir,
		  const char *filter, int maxFiles);
    
    const char *mFileName;
    TFile      *mOutFile;
    TChain     *mChain;
    
    StarGenEvent *mSGEvent;
  
    //
    // Global counters
    //
    bool           mEventIsGood;
    unsigned int   mNEvents;
    unsigned int   mEventsPassed;

    //
    // Histogram parameters
    //
    int mRefMultMin;
    int mRefMultMax;
    int mRefMultBins;
    
    int mNTracksMin;
    int mNTracksMax;
    int mNTracksBins;

    int   mPBins;
    float mPMin;
    float mPMax;

    int   mPtBins;
    float mPtMin;
    float mPtMax;

    int   mPxBins;
    float mPxMin;
    float mPxMax;

    int   mPyBins;
    float mPyMin;
    float mPyMax;

    int   mPzBins;
    float mPzMin;
    float mPzMax;

    int   mEtaBins;
    float mEtaMin;
    float mEtaMax;

    //
    // Cut flags
    //
    bool  mIsGoodTrack;

    //
    // Single-particle cuts
    //
    float          mTrackP[2];
    float          mTrackEta[2];

    //
    // Histograms
    //
    //
    // General event distributions
    //
    TH1F *hRefMult;
    TH1F *hNTracks;
    
    //
    // General track distributions
    //
    TH1F *hP;
    TH1F *hPt;
    TH1F *hPx;
    TH1F *hPy;
    TH1F *hPz;
    TH1F *hEtaNoCut;
    TH1F *hEta;
    TH2F *hVxVy;
    TH2F *hVyVz;
    TH2F *hVxVz;
    TH2F *hEtaVsPt;
    TH2F *hMassSqrVsPt;

    ClassDef(StHijingQA, 1)
};

#endif
