////////////////////////////////////////////////////////////////////////
// Package: CandTrackCam
//
// CandTrackCam - TrackSegmentCam.h
//
// marshall@hep.phy.cam.ac.uk
////////////////////////////////////////////////////////////////////////

#ifndef TRACKSEGMENTCAM_H
#define TRACKSEGMENTCAM_H


#include <vector>
using std::vector;

class ClusterCam;

class TrackSegmentCam
{
 public:
  TrackSegmentCam(ClusterCam* clustm, ClusterCam* clust0, ClusterCam* clustp);
  virtual ~TrackSegmentCam();
  
  void AddCluster(ClusterCam* clust);
  bool ContainsCluster(ClusterCam* clust);
  ClusterCam* GetCluster(unsigned int i);
  unsigned int GetEntries() const;
  int GetBegPlane() const;
  int GetEndPlane() const;
  int GetPlaneView() const;

  double GetBegDir();
  double GetBegTPos();
  double GetBegZPos() const;

  double GetEndDir();
  double GetEndTPos();
  double GetEndZPos() const;
  void AddSegment(TrackSegmentCam* segment);
  bool IsAssoc(TrackSegmentCam* segment);


  //Associated Segments (Lowest level of association)
  void AddAssocSegToBeg(TrackSegmentCam* seg);   
  void AddAssocSegToEnd(TrackSegmentCam* seg);   
  TrackSegmentCam* GetAssocSegBeg(unsigned int i);
  TrackSegmentCam* GetAssocSegEnd(unsigned int i);
  unsigned int GetNAssocSegBeg() const{return fBegAssociatedSegList.size();};  
  unsigned int GetNAssocSegEnd() const{return fEndAssociatedSegList.size();};  

  //Preferred Segments (Second level of association)
  void AddPrefSegToBeg(TrackSegmentCam* seg);          
  void AddPrefSegToEnd(TrackSegmentCam* seg);          
  TrackSegmentCam* GetPrefSegBeg(unsigned int i);      
  TrackSegmentCam* GetPrefSegEnd(unsigned int i);      
  unsigned int GetNPrefSegBeg() const{return fBegPreferredSegList.size();};
  unsigned int GetNPrefSegEnd() const{return fEndPreferredSegList.size();};

  //Matched Segments (Third level of association)
  void AddMatchSegToBeg(TrackSegmentCam* seg);
  void AddMatchSegToEnd(TrackSegmentCam* seg);
  TrackSegmentCam* GetMatchSegBeg(unsigned int i); 
  TrackSegmentCam* GetMatchSegEnd(unsigned int i); 
  unsigned int GetNMatchSegBeg() const{return fBegMatchedSegList.size();};
  unsigned int GetNMatchSegEnd() const{return fEndMatchedSegList.size();};


  void SetTmpTrkFlag(int flag){ fTmpTrkFlag=flag; };
  int GetTmpTrkFlag() const { return fTmpTrkFlag; };

  void SetUID(int uid){ fUID=uid; };
  int GetUID() const { return fUID; };

  void SetTrkFlag(int flag){ fTrkFlag=flag; };
  int GetTrkFlag() const { return fTrkFlag; };

  void SetSeedSegment(TrackSegmentCam* segment) {fSeedSegment = segment;};
  TrackSegmentCam* GetSeedSegment() {return (TrackSegmentCam*)(fSeedSegment);};

  void SetNPlanes(int nplanes){ fNPlanes=nplanes; };
  int GetNPlanes() const { return fNPlanes; };

  double GetScore(vector<TrackSegmentCam*> *BegSegBank=0, vector<TrackSegmentCam*> *EndSegBank=0);

  double GetBegTime() const { return fBegTime; };
  double GetEndTime() const { return fEndTime; };

  void SetPartner(TrackSegmentCam* segment) {fPartner = segment;};
  TrackSegmentCam* GetPartner() {return (TrackSegmentCam*)(fPartner);};


 private:
  vector<ClusterCam*> ClustersInSegment;
  vector<TrackSegmentCam*> fBegAssociatedSegList;
  vector<TrackSegmentCam*> fEndAssociatedSegList;
  vector<TrackSegmentCam*> fBegPreferredSegList;
  vector<TrackSegmentCam*> fEndPreferredSegList;
  vector<TrackSegmentCam*> fBegMatchedSegList;
  vector<TrackSegmentCam*> fEndMatchedSegList;

  TrackSegmentCam* fSeedSegment; // Last segment in chain of segments to which this segment belongs

  TrackSegmentCam* fPartner;

  int fUID;
  int fBegPlane;
  int fEndPlane;
  double fBegVtxZ;
  double fEndVtxZ;
  int fTrkFlag;
  int fTmpTrkFlag;
  int fPlaneView;
  int fNPlanes;
  double fBegTime;
  double fEndTime;
  const double StripWidth;

  //  ClassDef(TrackSegmentCam,1)
};

#endif
