//*****************************************************
// Class   : D0Jet
// 
// Purpose : Defines a calorimeter D0Jet
//           
//                      
// Author  : A. Schwartzman
//
// Date    : 24-Sep-2001 : Creation of class
//         : 05-Dec-2001 : Add DR to closest EM object - Ariel Schwartzman
//         : 04-Nov-2002 : Update detector eta definition. (A.S.)
//         : 12-Nov-2002 : Add f90 variable (A.S.) 
//         : 17-Jan-2002 : Add IsTaggable method (A.S.)
//         : 20-Jul-2003 : Change DR variable to TString type, to account
//                         for different jet algorithms (cone, kt, etc.) -
//                         Frank Filthaut, Ariel Schwartzman.
//*****************************************************
#ifndef D0Jet_h
#define D0Jet_h

#include "d0root_analysis/objects/D0Particle.h"
#include "d0root_analysis/objects/D0Vertex.h"
class TClonesArray;

//namespace d0root {

class D0Jet : public D0Particle
{

public:

  /// default constructor
  D0Jet();

  /// constructor 
  D0Jet(const char* type, double px, double py, double pz, double E, double z, 
	double deta, double EMF, double EM1F, double EM2F,double EM3F, 
	double CHF, double FH1F, double FH2F, double FH3F, double HotF, 
	double n90, double f90 = 0.0, int split_merge = -1, int id = -1,
	double jes_C = 1., double jes_dC_stat = 0., double jes_dC_sys = 0.);
  
  /// destructor
  ~D0Jet();
  
  ///
  ///void print();

  ///
  const char* Type();
  ///
  double EMF();
  ///
  double EM1F();
  ///
  double EM2F();
  ///
  double EM3F();
  ///
  double CHF();
  ///
  double FH1F();
  ///
  double FH2F();
  ///
  double FH3F();
  ///
  double HotF();
  ///
  double N90();
  ///
  double f90();
  ///
  int SplitMerge();

  ///
  double DetectorEta();

  ///
  double          UncorrectedPt();
  TLorentzVector* UncorrectedP();


  ///
  double DeltaRvertex(D0Vertex& sv, D0Vertex& pv);
  double DeltaPhivertex(D0Vertex& sv, D0Vertex& pv);

  ///
  double DrClosestEM();  //DR of closest EM object
  int QualityClosestEM();  //D0Quality of closest EM object
  ///
  void SetDrClosestEM(double dr);
  void SetQualityClosestEM(int quality);
 
 ///
  void SetDrClosestEM(TObjArray& emObjects); 
 


  ///
  void SetQuality();

  ///
  void SetPhysicsCoordinates();
  ///
  void SetDetectorCoordinates();


  /// re-vertex
  void ReVertex(float zvtx, float x = 0.0, float y = 0.0);
  
  /// smear
  void Smear(TRandom* randomGenerator, char* option = "DATA");
  
  /// energy resolution
  float EnergyResolution(char* option = "DATA");



  void AddTracks(TObjArray tracks, float DR = 0.5);
  void AddTracks(TClonesArray* tracks, float DR = 0.5);
  TObjArray Tracks();


  // For b-id certification
  int IsTaggable();
  bool IsInCentralRegion();
  bool IsInForwardRegion();
 
  /// JES correction factor
  void Set_JES_C(double jes_C);
  double JES_C(){return _jes_C;};

  void Set_JES_dC_stat(double jes_dC_stat);
  double JES_dC_stat(){return _jes_dC_stat;};

  void Set_JES_dC_sys(double jes_dC_sys);
  double JES_dC_sys(){return _jes_dC_sys;};



  ///
  void print();

  ///
  void draw(int color = 2, int style = 1, double dim = 1);

 private:
  
  ///
  TString _type; 
  ///
  double _dr;
  ///
  double _eta;
  ///
  TLorentzVector _Raw_P;
  ///
  double _deta;
  ///
  double _emf;
  ///
  double _em1f;
  ///
  double _em2f;
  ///
  double _em3f;
  ///
  double _chf;
  ///
  double _fh1f;
  ///
  double _fh2f;
  ///
  double _fh3f;
  ///
  double _hotF;
  ///
  double _n90;
  ///
  double _f90;
  ///
  int _split_merge;

  ///
  double _drClosestEM;
  int _qualityClosestEM;

  //JES information.
  double _jes_C;
  double _jes_dC_stat;
  double _jes_dC_sys;


  TObjArray _tracks;


  ClassDef(D0Jet,1)  
};

//}
#endif /* D0Jet */