ROOT logo
#ifndef ALIEMCALPARTICLE_H
#define ALIEMCALPARTICLE_H

#include <TLorentzVector.h>
#include <TMath.h>
#include <TObjArray.h>
#include "AliVCluster.h"
#include "AliVParticle.h"
#include "AliVTrack.h"

class AliEmcalParticle: public AliVParticle {
 public:
  AliEmcalParticle();
  AliEmcalParticle(TObject *particle, Int_t id = -1, Double_t vx=0, Double_t vy=0, Double_t vz=0);
  AliEmcalParticle(const AliEmcalParticle &p); 
  AliEmcalParticle &operator=(const AliEmcalParticle &p);
  virtual ~AliEmcalParticle();

  // AliVParticle interface
  Double_t          Px()        const { return fPt*TMath::Cos(fPhi);  }
  Double_t          Py()        const { return fPt*TMath::Sin(fPhi);  };
  Double_t          Pz()        const { return fPt*TMath::SinH(fEta); }
  Double_t          Pt()        const { return fPt ; }
  Double_t          P()         const { return TMath::Sqrt(Px()*Px()+Py()*Py()+Pz()*Pz()); }
  Bool_t            PxPyPz(Double_t p[3]) const { p[0] = Px(); p[1] = Py(); p[2] = Pz(); return 1; }
  Double_t          Xv()        const { return 0; }
  Double_t          Yv()        const { return 0; }
  Double_t          Zv()        const { return 0; }
  Bool_t            XvYvZv(Double_t x[3]) const { x[0] = Xv(); x[1] = Yv(); x[2] = Zv(); return 1; }
  Double_t          OneOverPt() const { return 1./fPt; }
  Double_t          Phi()       const { return fPhi; }
  Double_t          Theta()     const { return 0.; }
  Double_t          E()         const { if (fTrack) return fTrack->E(); return fCluster->E(); }
  Double_t          M()         const { if (fTrack) return fTrack->M(); return 0; }
  Double_t          Eta()       const { return fEta; }
  Double_t          Y()         const { if (fTrack) return fTrack->Y(); return fEta; }
  Short_t           Charge()    const { if (fTrack) return fTrack->Charge(); else return 0; }
  Int_t             GetLabel()  const { if (fTrack) return fTrack->GetLabel(); return fCluster->GetLabel(); }
  Int_t             PdgCode()   const { return 0; }
  const Double_t   *PID()       const { return 0; }

  void              AddMatchedObj(Int_t id, Double_t d);
  AliVCluster      *GetCluster()           const { return fCluster                                                  ; }
  Int_t             GetMatchedObjId(UShort_t i = 0)         const { return fNMatched > i ? fMatchedIds[i]  : -1     ; }
  Double_t          GetMatchedObjDistance(UShort_t i = 0)   const { return fNMatched > i ? fMatchedDist[i] : -1     ; }
  UShort_t          GetNumberOfMatchedObj()                 const { return fNMatched                                ; }
  AliVCluster      *GetMatchedCluster(UShort_t i = 0)       const { if (fTrack && fMatchedPtr && (fNMatched > i)) 
                                                                      return static_cast<AliVCluster*>(fMatchedPtr->At(fMatchedIds[i]));
                                                                    return 0                                        ; } 
  AliVTrack        *GetMatchedTrack(UShort_t i = 0)         const { if (fCluster && fMatchedPtr && (fNMatched > i)) 
                                                                      return static_cast<AliVTrack*>(fMatchedPtr->At(fMatchedIds[i]));
                                                                    return 0                                        ; } 
  AliVTrack        *GetTrack()             const { return fTrack                                                    ; }
  Double_t          GetTrackPhiOnEMCal()   const { if (fTrack) return fTrack->GetTrackPhiOnEMCal(); else return -999; }
  Double_t          GetTrackEtaOnEMCal()   const { if (fTrack) return fTrack->GetTrackEtaOnEMCal(); else return -999; }
  Double_t          GetTrackPtOnEMCal()    const { if (fTrack) return fTrack->GetTrackPtOnEMCal();  else return -999; }
  Int_t             IdInCollection()       const { return fId                                                       ; }
  Bool_t            IsCluster()            const { return (Bool_t) fCluster != 0                                    ; }
  Bool_t            IsEMCAL()              const { if (fCluster) return fCluster->IsEMCAL(); 
                                                   if (fTrack)   return fTrack->IsEMCAL(); 
                                                   return kFALSE; }
  Bool_t            IsTrack()              const { return (Bool_t) fTrack   != 0                                    ; }
  Bool_t            IsMC(Int_t minLabel=0) const { if (fTrack) return (TMath::Abs(fTrack->GetLabel()) > minLabel); 
                                                   return (fCluster->GetLabel() > minLabel); }
  void              ResetMatchedObjects();
  void              SetIdInCollection(Int_t id)          { fId = id                                                                      ; }
  void              SetMatchedObj(Int_t id, Double_t d)  { ResetMatchedObjects(); fMatchedIds[0] = id; fMatchedDist[0] = d; fNMatched = 1; }
  void              SetMatchedPtr(TObjArray *arr)        { fMatchedPtr = arr; }

  void              SetPt(Double_t pt)           { fPt  = pt ; }
  void              SetPhi(Double_t phi)         { fPhi = phi; }
  void              SetEta(Double_t eta)         { fEta = eta; }

 protected:
  TLorentzVector   &GetLorentzVector(const Double_t *vertex = 0)  const;

  static const UShort_t fSizeMatched = 99;        //!size of matched clusters array

  AliVTrack        *fTrack;                       //!track
  AliVCluster      *fCluster;                     //!cluster
  UShort_t          fMatchedIds[fSizeMatched];    //!ids of matched tracks/clusters, ordered from the closest to the farthest
  Double_t          fMatchedDist[fSizeMatched];   //!distances of matched tracks/clusters
  UShort_t          fNMatched;                    //!number of matched objects 
  Int_t             fId;                          //!id in original collection
  Double_t          fPhi;                         //!phi
  Double_t          fEta;                         //!eta
  Double_t          fPt;                          //!pt
  TObjArray        *fMatchedPtr;                  //!pointer to array of matched tracks/clusters

  ClassDef(AliEmcalParticle, 2) // Emcal particle class
};
#endif
 AliEmcalParticle.h:1
 AliEmcalParticle.h:2
 AliEmcalParticle.h:3
 AliEmcalParticle.h:4
 AliEmcalParticle.h:5
 AliEmcalParticle.h:6
 AliEmcalParticle.h:7
 AliEmcalParticle.h:8
 AliEmcalParticle.h:9
 AliEmcalParticle.h:10
 AliEmcalParticle.h:11
 AliEmcalParticle.h:12
 AliEmcalParticle.h:13
 AliEmcalParticle.h:14
 AliEmcalParticle.h:15
 AliEmcalParticle.h:16
 AliEmcalParticle.h:17
 AliEmcalParticle.h:18
 AliEmcalParticle.h:19
 AliEmcalParticle.h:20
 AliEmcalParticle.h:21
 AliEmcalParticle.h:22
 AliEmcalParticle.h:23
 AliEmcalParticle.h:24
 AliEmcalParticle.h:25
 AliEmcalParticle.h:26
 AliEmcalParticle.h:27
 AliEmcalParticle.h:28
 AliEmcalParticle.h:29
 AliEmcalParticle.h:30
 AliEmcalParticle.h:31
 AliEmcalParticle.h:32
 AliEmcalParticle.h:33
 AliEmcalParticle.h:34
 AliEmcalParticle.h:35
 AliEmcalParticle.h:36
 AliEmcalParticle.h:37
 AliEmcalParticle.h:38
 AliEmcalParticle.h:39
 AliEmcalParticle.h:40
 AliEmcalParticle.h:41
 AliEmcalParticle.h:42
 AliEmcalParticle.h:43
 AliEmcalParticle.h:44
 AliEmcalParticle.h:45
 AliEmcalParticle.h:46
 AliEmcalParticle.h:47
 AliEmcalParticle.h:48
 AliEmcalParticle.h:49
 AliEmcalParticle.h:50
 AliEmcalParticle.h:51
 AliEmcalParticle.h:52
 AliEmcalParticle.h:53
 AliEmcalParticle.h:54
 AliEmcalParticle.h:55
 AliEmcalParticle.h:56
 AliEmcalParticle.h:57
 AliEmcalParticle.h:58
 AliEmcalParticle.h:59
 AliEmcalParticle.h:60
 AliEmcalParticle.h:61
 AliEmcalParticle.h:62
 AliEmcalParticle.h:63
 AliEmcalParticle.h:64
 AliEmcalParticle.h:65
 AliEmcalParticle.h:66
 AliEmcalParticle.h:67
 AliEmcalParticle.h:68
 AliEmcalParticle.h:69
 AliEmcalParticle.h:70
 AliEmcalParticle.h:71
 AliEmcalParticle.h:72
 AliEmcalParticle.h:73
 AliEmcalParticle.h:74
 AliEmcalParticle.h:75
 AliEmcalParticle.h:76
 AliEmcalParticle.h:77
 AliEmcalParticle.h:78
 AliEmcalParticle.h:79
 AliEmcalParticle.h:80
 AliEmcalParticle.h:81
 AliEmcalParticle.h:82
 AliEmcalParticle.h:83
 AliEmcalParticle.h:84
 AliEmcalParticle.h:85
 AliEmcalParticle.h:86
 AliEmcalParticle.h:87
 AliEmcalParticle.h:88
 AliEmcalParticle.h:89
 AliEmcalParticle.h:90
 AliEmcalParticle.h:91
 AliEmcalParticle.h:92