#ifndef DataProcessing_h
#define DataProcessing_h

#include <TFile.h>
#include <TSystem.h>
#include <TH1.h>
#include <TString.h>
#include <TAttMarker.h>
#include <TGraphErrors.h>
#include <iostream>
#include <vector>

using namespace std;

//_________________
class DataProcessing {

 public:

  DataProcessing();
  ~DataProcessing();

  void SetExpFile(const Char_t *name) { mExpFileName = name; }
  void SetOutFile(const Char_t *name) { mOutFileName = name; }
  void DoProcessing();
  void SetQinvBins(Int_t    qInvBins,
		   Double_t qInvLow,
		   Double_t qInvHi) {
    mQinvBins = qInvBins;
    mQinvLow = qInvLow;
    mQinvHi = qInvHi;
  }
  void SetDetectorSelection(Int_t sel) { mDetSelection = sel; }
  void SetMultiplicityBins(Int_t bins) { mMultBins = bins; }
  void SetCorrFctnStyle(Int_t color, Int_t width, Int_t style, Double_t size);
  void SetParticleType(Int_t type) { mPartType = type; } // 3-pion, 4-kaon
  void SetSourceFunction(Int_t source) { mSourceFunc = source; }
  void SetNonFemtoFunction(Int_t func) { mNonFemtoFunc = func; }
  void SetDrawLegend(Bool_t draw) { mDrawLegend = draw; }

 private:

  //
  // Functions
  //
  void OpenFiles();
  void ReadHistos();
  void ProcessHistos();
  void ProcessMultHistos();
  void ProcessMultKtHistos();
  void FitHistos();
  void MakeTGraphs();
  TH1F *BuildMultCF(Int_t charge, Int_t BinLo, Int_t BinHi);
  TH1F *BuildMultKtCF(Int_t charge, Int_t MultBinLo, Int_t MultBinHi,
		      Int_t KtBinLo, Int_t KtBinHi);
  
  void SetHistoStyle(TH1* h);
  void Finish();

  //
  // Variables
  //
  const Char_t *mExpFileName;
  const Char_t *mOutFileName;

  Int_t mQinvBins;
  Double_t mQinvLow;
  Double_t mQinvHi;

  Int_t mPartType;

  Int_t mDetSelection;   // 0-TPC, 1-TOF, 2-TPC+TOF, 3-TOF||TPC, 4-TPC+TOC(p>pthresh)||TPC(p<pthresh)

  Int_t mMultBins;
  Int_t mKtBins;
  Int_t mKtRanges;

  Int_t mCorrFctnColor;
  Int_t mCorrFctnLineWidth;
  Int_t mCorrFctnMarkerStyle;
  Double_t mCorrFctnMarkerSize;

  Double_t mYaxisLo;
  Double_t mYaxisHi;

  //
  // Fits
  //
  Int_t mSourceFunc;
  Int_t mNonFemtoFunc;
  Bool_t mDrawLegend;

  //
  // Files
  //
  TFile *mExpFile;
  TFile *mOutFile;

  //
  // Input histos
  //
  std::vector<TH1F *> hQinvMixNum;
  std::vector<TH1F *> hQinvMixDen;

  //
  // Multiplicity dependece
  //
  std::vector<TH1F *> hMultMixCF;

  //
  // Mulitplicity and kT dependence
  //
  std::vector<TH1F *> hMultKtMixCF;

  //
  // Fitted values
  // Multiplicity dependence
  //
  std::vector<double> mMultMixRadii;
  std::vector<double> mMultMixRadiiErr;
  std::vector<double> mMultMixLambda;
  std::vector<double> mMultMixLambdaErr;

  //
  // Multiplicity and kT
  //
  std::vector<double> mMultKtMixRadii;
  std::vector<double> mMultKtMixRadiiErr;
  std::vector<double> mMultKtMixLambda;
  std::vector<double> mMultKtMixLambdaErr;

  //
  // TGraphErrors
  //
  TGraphErrors *gMultDepRadiiGrErr[3];
  TGraphErrors *gMultKtDepRadiiGrErr[3][9];
  TGraphErrors *gMultKtDepRadiiMtGrErr[3][9];
};

#endif
