////////////////////////////////////////////////////////////////////////
// $Id: TrackClusterSR.h,v 1.20 2005/05/25 18:50:26 avva Exp $
//
// TrackClusterSR
//
// Author:  R. Lee 2001.02.26
////////////////////////////////////////////////////////////////////////

#ifndef TRACKCLUSTERSR_H
#define TRACKCLUSTERSR_H

#include "TObject.h"
#include "TObjArray.h"

#include "Conventions/PlaneView.h"
#include "Navigation/XxxItr.h"

class CandStripHandle;

class TrackClusterSR : public TObject
{

public:
  TrackClusterSR();
  TrackClusterSR(Double_t misalignmentError);
  TrackClusterSR(CandStripHandle *strip, Double_t misalignmentError);
  TrackClusterSR(const TrackClusterSR &rhs);    // Real copy-constructor
  virtual ~TrackClusterSR();

  void AddStrip(CandStripHandle *strip);
  Double_t DTPos(Double_t tpos) const;

  Double_t GetBegTime() const;
  Double_t GetCharge() const;
  Int_t GetMaxStrip() const;
  Double_t GetMaxTPos() const;
  Int_t GetMinStrip() const;
  Double_t GetMinTPos() const;
  Int_t GetNStrip() const;
  Int_t GetPlane() const;
  PlaneView::PlaneView_t GetPlaneView() const;
  const TObjArray* GetStripList() const; 
  Double_t GetTime3D() const;
  Double_t GetTPos() const;     // average tpos weighted by pulse height
  Double_t GetTPosError() const; // same as RMS except when only 1 strip
  Double_t GetTPosRMS() const;
  Double_t GetZPos() const;
  Double_t GetMisalignmentError() const;
  Double_t GetLPos() const { return fLPos; };     // return longitudinal position
  
  /// Get rotation corrected tpos of the strip at position along the strip
  /// corresponding to fLPos of this track cluster. 
  Double_t GetRotationCorrectedTPos(const CandStripHandle* csh) const;

  Bool_t InShowerLikePlane() const;
  Bool_t IsContained(CandStripHandle *target) const;
  Bool_t IsDoubleEnded() const; // true if at least one hit double ended
  virtual Bool_t IsEquivalent(const TObject *rhs) const;
  Bool_t IsValid() const;
  Bool_t IsWide() const;

  void SetInShowerLikePlane(Bool_t showerLike);
  void SetIsValid(Bool_t isValid);
  void SetIsWide(Bool_t iswide);
  void SetTime3D(Double_t dvar);
  void SetLPos(Double_t lpos);      // set longitudinal position
  void RecalculateTPos();           // recalculate tpos
  
  static NavKey KeyFromPlane(const TrackClusterSR *tcluster);
  static NavKey KeyFromPlaneTPosTime(const TrackClusterSR *tcluster);

private:
  TObjArray fStripList;       // Components owned from TrackClusterSR v9
  Int_t fNStrip;
  Int_t fMinStrip;
  Int_t fMaxStrip;

  Double_t fZPos;                                     // calculated once
  Double_t fCharge;
  Double_t fTime3D;                                      // 3D corrected
  Double_t fTPos;
  Double_t fTPosRMS;
  Double_t fLPos;                              // longitudinal position along the strip
  
  Bool_t fIsWide;                              // flag for wide clusters

// flag for valid clusters - catch all for whether to use cluster or not
  Bool_t fIsValid;
  
// flag for if this cluster is in a shower like plane
  Bool_t fInShowerLikePlane;

  Double_t fParmMisalignmentError;  // error in tpos due to misalignment

ClassDef(TrackClusterSR,10)
};

XXXITRDEF(TrackClusterSR)

#endif                                               // TRACKCLUSTERSR_H
