#ifndef TMBTaus_H
#define TMBTaus_H

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// File:  TMBTaus.hpp
// Created by E. Thomas
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include "tmb_tree/TPhysObj.hpp"
//#ifndef ROOT_TObject
//#include "TObject.h"
//#endif
#ifndef ROOT_TRef
#include "TRef.h"
#endif
#ifndef ROOT_TRefArray
#include "TRefArray.h"
#endif

class TMBTrks;
class TMBCps;
class TMBFps;
class TMBVrts;

//class TauQuality;

class TMBTaus : public TPhysObj {

private:
   Float_t        _px;  
   Float_t        _py;  
   Float_t        _pz;  
   Float_t        _E;   
   Float_t        _charge;
   Float_t        _pT;  
   Float_t        _eta; 
   Float_t        _phi; 
   TRefArray      _cpsptr;
   TRefArray      _fpsptr;
   TRefArray      _tracks;
   TRef           _vtxref;

   Float_t        _rms;
   Float_t        _profile;
   Float_t        _emf;
   Float_t        _icdf;
   Float_t        _chf;
   Float_t        _hot;
   Int_t          _ntrk;
   Int_t          _ntrk1;
   Int_t          _ntrk2;
   Int_t          _ntrk3;
   Float_t        _fsh;
   Float_t        _nnout1;
  Float_t        _nnout2;
   Float_t        _nnout3;
   Float_t        _nnout4;
   Int_t          _flag;

//  quality quantities
   Int_t          _iq[3];
   Float_t        _fq[34];
   Float_t        _et_7;
   Float_t        _et_3;
   Float_t        _EM12_Et;
   Float_t        _EM12_Et_core;
   Float_t        _EM3_Et;
   Float_t        _EM3_Et_core;
   Float_t        _EM4_Et;
   Float_t        _EM4_Et_core;
   Float_t        _typ;

  

public:
   TMBTaus() {;}
   TMBTaus(Float_t px, Float_t py, Float_t pz, Float_t E, Float_t charge, 
          Float_t pT, Float_t eta, Float_t phi,
          TRefArray* cpsptr, TRefArray* fpsptr,
          TRefArray* tracks, TRef& vtxref,
          Float_t rms, Float_t profile, Float_t emf,
          Float_t icdf, Float_t chf, Float_t hot,
          Int_t ntrk, Int_t ntrk1, Int_t ntrk2, Int_t ntrk3,
          Float_t fsh, Int_t flag,
          Int_t* iq, Float_t* fq,
          Float_t et_7, Float_t et_3, 
          Float_t EM12_Et, Float_t EM12_Et_core,
          Float_t EM3_Et, Float_t EM3_Et_core, Float_t  EM4_Et,
          Float_t EM4_Et_core, Float_t typ);

   void Set(Float_t px, Float_t py, Float_t pz, Float_t E, Float_t charge,
         Float_t pT, Float_t eta, Float_t phi, 
         TRefArray* cpsptr, TRefArray* fpsptr, 
         TRefArray* tracks, TRef& vtxref,
         Float_t rms, Float_t profile, Float_t emf,
         Float_t icdf, Float_t chf, Float_t hot,
         Int_t ntrk, Int_t ntrk1, Int_t ntrk2, Int_t ntrk3,
         Float_t fsh, Int_t flag,
         Int_t* iq, Float_t* fq,
         Float_t et_7, Float_t et_3,
         Float_t EM12_Et, Float_t EM12_Et_core,
         Float_t EM3_Et, Float_t EM3_Et_core, Float_t  EM4_Et,
         Float_t EM4_Et_core, Float_t typ);
  void SetNN(Float_t nnout1, Float_t nnout2, Float_t nnout3,  Float_t nnout4){
    _nnout1=nnout1;
    _nnout2=nnout2;
    _nnout3=nnout3;
    _nnout4=nnout4;
  }
   Float_t   px()      const {return _px;}
   Float_t   py()      const {return _py;}
   Float_t   pz()      const {return _pz;}
   Float_t   E()       const {return _E;}
   Float_t   charge()  const {return _charge;}
   Float_t   pT()      const {return _pT;}
   Float_t   eta()     const {return _eta;}
   Float_t   phi()     const {return _phi;}
   Float_t   rms()     const {return _rms;}
   Float_t   profile() const {return _profile;}
   Float_t   emf()     const {return _emf;}
   Float_t   icdf()    const {return _icdf;}
   Float_t   chf()     const {return _chf;}
   Float_t   hot()     const {return _hot;}
   Int_t     ntrk()    const {return _tracks.GetLast()+1;}
   Int_t     ntrk1()   const {return _ntrk1;}
   Int_t     ntrk2()   const {return _ntrk2;}
   Int_t     ntrk3()   const {return _ntrk3;}
   Float_t   fsh()     const {return _fsh;}
   Int_t     flag()    const {return _flag;}

   Int_t*    iq(Int_t ivar)        {return &_iq[ivar];}
   Float_t*  fq(Int_t fvar)        {return &_fq[fvar];}
   Float_t   Et_iso()        const {return _et_7;}
   Float_t   Et()            const {return _et_3;}
   Float_t   EM12_Et_iso()   const {return _EM12_Et;}
   Float_t   EM12_Et()       const {return _EM12_Et_core;}
   Float_t   EM3_Et_iso()    const {return _EM3_Et;}
   Float_t   EM3_Et()        const {return _EM3_Et_core;}
   Float_t   EM4_Et_iso()    const {return _EM4_Et;}
   Float_t   EM4_Et()        const {return _EM4_Et_core;}
   Float_t   type()          const {return _typ;}

   Int_t     nclus()         const {return _iq[2];}
   Float_t   ett1()          const {return _fq[0];}
   Float_t   ett2()          const {return _fq[1];}
   Float_t   ett3()          const {return _fq[2];}
   Float_t   mtrk()          const {return _fq[3];}
   Float_t   ettr()          const {return _fq[4];}
   Float_t   empt()          const {return _fq[5];}
   Float_t   emm()           const {return _fq[6];}
   Float_t   emeta()         const {return _fq[7];}
   Float_t   emphi()         const {return _fq[8];}
   Float_t   tzDCA()         const {return _fq[9];}
   Float_t   teta()          const {return _fq[10];}
   Float_t   tphi()          const {return _fq[11];}
   Float_t   tphiPS()        const {return _fq[12]+_fq[11];}
   Float_t   tphiEM3()       const {return _fq[13]+_fq[11];}
   Float_t   emcl_eta1()     const {return _fq[14];}
   Float_t   emcl_eta2()     const {return _fq[15];}
   Float_t   emcl_phi1()     const {return _fq[16];}
   Float_t   emcl_phi2()     const {return _fq[17];}
   Float_t   emcl_et1()      const {return _fq[18];}
   Float_t   emcl_et2()      const {return _fq[19];}
   Float_t   pseta()         const {return _fq[24];}
   Float_t   psphi()         const {return _fq[25];}
   Float_t   e1e2()          const {return _fq[26];}
   Float_t   dalpha()        const {return _fq[27];}

   Float_t   emcl_f12()      const {return _fq[31];}
   Float_t   emcl_f3()       const {return _fq[32];}
   Float_t   emcl_f4()       const {return _fq[33];}
  Float_t nnout1() const {return _nnout1;}
  Float_t nnout2() const {return _nnout2;}
  Float_t nnout3() const {return _nnout3;}
  Float_t nnout4() const {return _nnout4;}
   TMBTrks*  GetChargedTrack(Int_t itrk)  const {return (TMBTrks*)_tracks.At(itrk);}
   TMBVrts*  GetVertex()                  const {return (TMBVrts*)_vtxref.GetObject();}
   TMBCps*   GetCps(Int_t icps)           const {return (TMBCps*)_cpsptr.At(icps);}
   TMBFps*   GetFps(Int_t ifps)           const {return (TMBFps*)_fpsptr.At(ifps);}

   Float_t   EM12isof()         const {return _et_7 >= 0.001 ? _EM12_Et/_et_7      : _EM12_Et/0.001 ;}
   Float_t   EM12f()            const {return _et_3 >= 0.001 ? _EM12_Et_core/_et_3 : _EM12_Et_core/0.001;}
   Float_t   EM3isof()          const {return _et_7 >= 0.001 ? _EM3_Et/_et_7       : _EM3_Et/0.001;}
   Float_t   EM3f()             const {return _et_3 >= 0.001 ? _EM3_Et_core/_et_3  : _EM3_Et_core/0.001;}
   Float_t   EM4isof()          const {return _et_7 >= 0.001 ? _EM4_Et/_et_7       : _EM4_Et/0.001;}
   Float_t   EM4f()             const {return _et_3 >= 0.001 ? _EM4_Et_core/_et_3  : _EM4_Et_core/0.001;}
   Float_t   iso()              const {return _et_3 >= 0.001 ? (_et_7 - _et_3)/_et_3 : (_et_7 - _et_3)/0.001;}

   ~TMBTaus() {;}

   ClassDef(TMBTaus, 1)   //TMBTree Taus class
};

#endif