// LCDCalHit.h
// Apr 13,2001 Toshi, Add GetEtotMCE
// Apr 06,2001 Toshi, major changes
// Feb 02,1999 Rob Shanks Creation: In an attempt to speed up the reading
//                                  of the Event structure.

#ifndef LCDCALHIT_H
#define LCDCALHIT_H

#include "TObject.h"
#include "LCDtowerID.h"
#include "LCDEDeposit.h"

class LCDCalHit: public TObject {

public:
  LCDCalHit()               : m_Etot(0), m_tower(0)      , m_nMCE(0) {}
  LCDCalHit(UInt_t towerID) : m_Etot(0), m_tower(towerID), m_nMCE(0) {}
  LCDCalHit(UInt_t towerID, Float_t hitE) 
    : m_Etot(hitE), m_tower(towerID), m_nMCE(0) {}
  LCDCalHit(UInt_t towerID, Double_t hitE) 
    : m_Etot(hitE), m_tower(towerID), m_nMCE(0) {}
  ~LCDCalHit() {}

  //Double_t     AddE(Double_t hit);
  void         AddHit(Int_t mcindex, Double_t edep);

  void         Clean()         { m_Etot=0; m_nMCE=0; }

  Double_t     GetEtotRaw()    { return  m_Etot    ; }
  LCDtowerID*  GetTower()      { return &m_tower   ; }
  Int_t        GetMCEEntries() { return  m_nMCE    ; }
  LCDEDeposit* GetMCE()        { return  m_MCE     ; }
  Double_t     GetEtotMCE();

  Double_t GetEscale();
  Double_t GetThetaSeg();
  Double_t GetPhiSeg();

  Double_t GetEtot() { return GetEscale()  *m_Etot                    ; }
  Double_t GetTheta(){ return GetThetaSeg()*(m_tower.GetTheta() + 0.5); }
  Double_t GetPhi()  { return GetPhiSeg()  *(m_tower.GetPhi()   + 0.5); }
  Double_t GetR(); // R is not cylindrical but distance between IP and Hit
  Double_t GetRcyl(); // R is cylindrical

  void SetEtot(Double_t a) { m_Etot = a; }

private:
  Float_t    m_Etot   ; // Total energy deposited in calorimeter tower
  LCDtowerID  m_tower  ; // TowerID tag
  Int_t       m_nMCE   ;
  LCDEDeposit m_MCE[50];
  // List of particles and their energy contributions 
  //(LCDEDeposit)
  static Int_t sys2det[16];

public:
  static Float_t* energyScale;  // energy scale factor
  static Float_t* ThetaSeg;     // segmentation in theta
  static Float_t* phiSeg;       // segementation in phi
  
  static Float_t* barrelThick;  // Thickness between the layers
  static Float_t* endcapThick;  // Thickness between the layers
  static Float_t* barrelInner;  // Barrel Inner Radius
  static Float_t* endcapInner;  // Endcap Inner Z

  ClassDef(LCDCalHit,3) // Calorimeter tower hit information
};

#endif
