#ifndef BRAT_BrGeantToTpcTrackCandidate
#define BRAT_BrGeantToTpcTrackCandidate

#include <iostream.h>

// BRAHMS classes

#ifndef BRAT_BrModule
# include "BrModule.h"
#endif

#ifndef BRAT_BrEventNode
# include "BrEventNode.h"
#endif

#ifndef ROOT_TObjArray
# include "TObjArray.h"
#endif

#ifndef BRAT_BrDataTable
# include "BrDataTable.h"
#endif

#ifndef BRAT_BrTpcTrackCandidate
#include "BrTpcTrackCandidate.h"
#endif

#ifndef BRAT_BrGeantInput
#include "BrGeantInput.h"
#endif

#ifndef BRAT_BrDetectorParamsTPC
#  include "BrDetectorParamsTPC.h"
#endif

#ifndef BRAT_BrDetectorParamsDC
#  include "BrDetectorParamsDC.h"
#endif

#ifndef BRAT_BrGeantTrack
# include "BrGeantTrack.h"
#endif

#ifndef BRAT_BrGeantHit
#  include "BrGeantHit.h"
#endif

#ifndef BRAT_BrTpcHit
#  include "BrTpcHit.h"
#endif

#ifndef BRAT_ParameterDbManager
#include <BrParameterDbManager.h>
#endif
#ifndef ROOT_TH1
#include "TH1.h"
#endif
#ifndef ROOT_TH2
#include "TH2.h"
#endif

class BrParameterDbManager;


class BrGeantToTpcTrackCandidate : public BrModule {

public:
  
  BrGeantToTpcTrackCandidate();
  BrGeantToTpcTrackCandidate(const Char_t* Name, const Char_t* Title);
  virtual ~BrGeantToTpcTrackCandidate();

  void Init();
  void DefineHistograms();
  void Clear();
  void Print(Option_t* option="B") const;
  void Event(BrEventNode* InputNode, BrEventNode* OutputNode);

  //inline functions
  void SetMinDedx(Float_t mindedx) { fMinDedx = mindedx; }
  Float_t GetMinDedx ( void ) { return fMinDedx; }
  void SetEdgeCut(Float_t edgecut) { fEdgeCut = edgecut; }
  Float_t GetEdgeCut( void ) { return fEdgeCut; }
  void SetMaxSlopeX(Float_t maxslopex) { fMaxSlopeX = maxslopex; }
  Float_t GetMaxSlopeX( void ) { return fMaxSlopeX; }
  void SetMaxSlopeY(Float_t maxslopey) { fMaxSlopeY = maxslopey; }
  Float_t GetMaxSlopeY( void ) { return fMaxSlopeY; }
  void SetMaxChisq(Float_t chisq) { fMaxChisq = chisq; }
  Float_t GetMaxChisq( void ) { return fMaxChisq; }
  void SetAllowedToMiss( Int_t maxMiss ) { fAllowedMiss = maxMiss; }
  Int_t GetAllowedToMiss( void ) { return fAllowedMiss; }
  void SetCutTime( Int_t CutTime ) { fCutTime = CutTime; }
  Int_t GetCutTime( void ) { return fCutTime; }
  
private:

  UInt_t fDetectorBit;

  Float_t fMinDedx;   // minimum energy deposit for good Geant hit
  Float_t fEdgeCut;   // minimum distance from edge for good Geant hit
  Float_t fMaxSlopeX; 
  Float_t fMaxSlopeY;  // maximum slopes for good Geant track
  Float_t fMaxChisq;   // maximum chisq for good Geant track
  Int_t fAllowedMiss;  // maximum hitless padrows / DC planes for good track
  Int_t fRequiredNHits;
  Int_t fCutTime;

  TObjArray* fGeantHits; 
  
  TObjArray* fTpcTrackCandidates;

  BrGeantInput* fInputModule;
  BrDetectorParamsTPC* fParams_tpc;

  Bool_t CheckHit(BrGeantHit* hit);             //checks quality of a given geant hit

  BrTpcHit* GeantToTpcHit(BrGeantHit* hit);
  
  // histograms
  TH1F* hNtracks;
  TH1F* hNhits;
  TH1F* hChi2;
  TH1F* hX;
  TH1F* hY;
  TH2F* hPadTime;
  TH2F* hPadRow;

  public:


  ClassDef( BrGeantToTpcTrackCandidate, 0) // BrGeantHit(s) to BrTpcTrackCandidate(s)
    
};

#endif