]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGJE/EMCALJetTasks/AliEmcalJet.h
Merge branch 'master' into dev
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / AliEmcalJet.h
1 #ifndef AliEmcalJet_H
2 #define AliEmcalJet_H
3
4 // $Id$
5
6 #include <TArrayS.h>
7 #include <TLorentzVector.h>
8 #include <TMath.h>
9 #include <TClonesArray.h>
10
11 #include "AliVParticle.h"
12 #include "AliVCluster.h"
13 #include "AliVEvent.h"
14
15 class AliEmcalJet : public AliVParticle
16 {
17  public:
18      enum EFlavourTag{
19        kDStar = 1<<0,
20        kD0 = 1<<1
21        //.....
22     }; 
23  
24   AliEmcalJet();
25   AliEmcalJet(Double_t px, Double_t py, Double_t pz);
26   AliEmcalJet(Double_t pt, Double_t eta, Double_t phi, Double_t m);
27   AliEmcalJet(const AliEmcalJet &jet); 
28   AliEmcalJet& operator=(const AliEmcalJet &jet);
29
30   Double_t          Px()                         const { return fPt*TMath::Cos(fPhi);  }
31   Double_t          Py()                         const { return fPt*TMath::Sin(fPhi);  }
32   Double_t          Pz()                         const { return fPt*TMath::SinH(fEta); }
33   Double_t          Pt()                         const { return fPt;                   }
34   Double_t          P()                          const { return fPt*TMath::CosH(fEta); }
35   Bool_t            PxPyPz(Double_t p[3])        const { p[0]=Px();p[1]=Py();p[2]=Pz(); return 1;         }
36   Double_t          Xv()                         const { return 0.;      }
37   Double_t          Yv()                         const { return 0.;      }
38   Double_t          Zv()                         const { return 0.;      }
39   Bool_t            XvYvZv(Double_t x[3])        const { x[0]=0;x[1]=0;x[2]=0; return 1;                  }
40   Double_t          OneOverPt()                  const { return 1./fPt;  }
41   Double_t          Phi()                        const { return fPhi;    }
42   Double_t          Theta()                      const { return 2*TMath::ATan(TMath::Exp(-fEta));         }
43   Double_t          E()                          const { Double_t p=P(); return TMath::Sqrt(M()*M()+p*p); }
44   Double_t          M()                          const { return fM; }
45   Double_t          Eta()                        const { return fEta;    }
46   Double_t          Y()                          const { return 0.5*TMath::Log((E()+Pz())/(E()-Pz()));    }
47   Short_t           Charge()                     const { return 0;       }
48   Int_t             GetLabel()                   const { return -1;      }
49   Int_t             PdgCode()                    const { return 0;       }
50   const Double_t   *PID()                        const { return 0;       }
51   void              GetMom(TLorentzVector &vec)  const;
52   void              Print(Option_t* option = "") const;
53
54   Double_t          Area()                       const { return fArea;                     }
55   Double_t          AreaPt()                     const { return fArea;                     }
56   Double_t          AreaEta()                    const { return fAreaEta;                  }
57   Double_t          AreaPhi()                    const { return fAreaPhi;                  }
58   Double_t          AreaEmc()                    const { return fAreaEmc;                  }
59   Bool_t            AxisInEmcal()                const { return fAxisInEmcal;              }
60   Int_t             Compare(const TObject* obj)  const;
61   Short_t           ClusterAt(Int_t idx)         const { return fClusterIDs.At(idx);       }
62   AliVCluster      *ClusterAt(Int_t idx, TClonesArray *ca)  const { if (!ca) return 0; return dynamic_cast<AliVCluster*>(ca->At(ClusterAt(idx))); }
63   AliVCluster      *GetLeadingCluster(TClonesArray *clusters) const;
64   UShort_t          GetNumberOfClusters()        const { return fClusterIDs.GetSize();     }
65   UShort_t          GetNumberOfTracks()          const { return fTrackIDs.GetSize();       }
66   UShort_t          GetNumberOfConstituents()    const { return GetNumberOfClusters()+GetNumberOfTracks();       }
67   Double_t          FracEmcalArea()              const { return fAreaEmc/fArea;            }
68   Bool_t            IsInsideEmcal()              const { return (fAreaEmc/fArea>0.999);    }
69   Bool_t            IsInEmcal()                  const { return (fAreaEmc>0);              }
70   Bool_t            IsMC()                       const { return (Bool_t)(MCPt() > 0);      }
71   Bool_t            IsSortable()                 const { return kTRUE;                     }
72   Double_t          MaxNeutralPt()               const { return fMaxNPt;                   }
73   Double_t          MaxChargedPt()               const { return fMaxCPt;                   }
74   Double_t          NEF()                        const { return fNEF;                      }
75   UShort_t          Nn()                         const { return fNn;                       }
76   UShort_t          Nch()                        const { return fNch;                      }
77   UShort_t          N()                          const { return Nch()+Nn();                }
78   Int_t             NEmc()                       const { return fNEmc;                     }
79   Double_t          MCPt()                       const { return fMCPt;                     }
80   Double_t          MaxClusterPt()               const { return MaxNeutralPt();            }
81   Double_t          MaxTrackPt()                 const { return MaxChargedPt();            }
82   Double_t          MaxPartPt()                  const { return fMaxCPt < fMaxNPt ? fMaxNPt : fMaxCPt;     }
83   Double_t          PtEmc()                      const { return fPtEmc;                    }
84   Double_t          PtSub()                      const { return fPtSub;                    }
85   Double_t          PtSub(Double_t rho)          const { return fPt - fArea*rho;           }
86   Double_t          PtSubVect(Double_t rho)      const;
87   Short_t           TrackAt(Int_t idx)           const { return fTrackIDs.At(idx);         }
88   AliVParticle     *TrackAt(Int_t idx, TClonesArray *ta)  const { if (!ta) return 0; return dynamic_cast<AliVParticle*>(ta->At(TrackAt(idx))); } 
89   AliVParticle     *GetLeadingTrack(TClonesArray *tracks) const;
90   Int_t             GetFlavour()                 const { return fFlavourTagging;           } 
91   
92   void              AddClusterAt(Int_t clus, Int_t idx){ fClusterIDs.AddAt(clus, idx);     }
93   void              AddFlavourTag(Int_t tag)           { fFlavourTagging |= tag; }
94   void              AddTrackAt(Int_t track, Int_t idx) { fTrackIDs.AddAt(track, idx);      }
95   void              Clear(Option_t */*option*/="")     { fClusterIDs.Set(0); fTrackIDs.Set(0); fClosestJets[0] = 0; fClosestJets[1] = 0; 
96                                                          fClosestJetsDist[0] = 0; fClosestJetsDist[1] = 0; fMatched = 0; fPtSub = 0; }
97   void              SetArea(Double_t a)                { fArea    = a;                     }
98   void              SetAreaEta(Double_t a)             { fAreaEta = a;                     }
99   void              SetAreaPhi(Double_t a)             { fAreaPhi = a;                     }
100   void              SetAreaEmc(Double_t a)             { fAreaEmc = a;                     }
101   void              SetAxisInEmcal(Bool_t b)           { fAxisInEmcal = b;                 }
102   void              SetFlavour(Int_t flavour)          { fFlavourTagging = flavour;        }
103   void              SetMaxNeutralPt(Double32_t t)      { fMaxNPt  = t;                     }
104   void              SetMaxChargedPt(Double32_t t)      { fMaxCPt  = t;                     }
105   void              SetNEF(Double_t nef)               { fNEF     = nef;                   }
106   void              SetNumberOfClusters(Int_t n)       { fClusterIDs.Set(n);               }
107   void              SetNumberOfTracks(Int_t n)         { fTrackIDs.Set(n);                 }
108   void              SetNumberOfCharged(Int_t n)        { fNch = n;                         }
109   void              SetNumberOfNeutrals(Int_t n)       { fNn = n;                          }
110   void              SetMCPt(Double_t p)                { fMCPt = p;                        }
111   void              SortConstituents();
112   void              SetNEmc(Int_t n)                   { fNEmc           = n;              }
113   void              SetPtEmc(Double_t pt)              { fPtEmc          = pt;             }
114   void              SetPtSub(Double_t ps)              { fPtSub          = ps;             } 
115   void              SetPtSubVect(Double_t ps)          { fPtVectSub      = ps;             }
116   Bool_t            TestFlavourTag(Int_t tag)          { return (Bool_t)((tag & fFlavourTagging) !=0); }
117
118   // Trigger
119   Bool_t            IsTriggerJet(UInt_t trigger=AliVEvent::kEMCEJE) const   { return (Bool_t)((fTriggers & trigger) != 0); }
120   void              SetTrigger(UInt_t trigger)                              { fTriggers  = trigger;                        }
121   void              AddTrigger(UInt_t trigger)                              { fTriggers |= trigger;                        }
122
123   // Matching
124   void              SetClosestJet(AliEmcalJet *j, Double_t d)       { fClosestJets[0] = j; fClosestJetsDist[0] = d    ; }
125   void              SetSecondClosestJet(AliEmcalJet *j, Double_t d) { fClosestJets[1] = j; fClosestJetsDist[1] = d    ; }
126   void              SetMatchedToClosest(UShort_t m)                 { fMatched        = 0; fMatchingType       = m    ; }
127   void              SetMatchedToSecondClosest(UShort_t m)           { fMatched        = 1; fMatchingType       = m    ; }
128   void              ResetMatching();
129   AliEmcalJet*      ClosestJet()                              const { return fClosestJets[0]                          ; }
130   Double_t          ClosestJetDistance()                      const { return fClosestJetsDist[0]                      ; }
131   AliEmcalJet*      SecondClosestJet()                        const { return fClosestJets[1]                          ; }
132   Double_t          SecondClosestJetDistance()                const { return fClosestJetsDist[1]                      ; }
133   AliEmcalJet*      MatchedJet()                              const { return fMatched < 2 ? fClosestJets[fMatched] : 0; }
134   UShort_t          GetMatchingType()                         const { return fMatchingType                            ; }
135
136   void              SetTaggedJet(AliEmcalJet *j)                    { fTaggedJet = j                                  ; }
137   void              SetTagStatus(Int_t i)                           { fTagStatus = i                                  ; }
138   AliEmcalJet*      GetTaggedJet()                            const { return fTaggedJet                               ; }
139   Int_t             GetTagStatus()                            const { return fTagStatus                               ; }
140
141  protected:
142   Double32_t        fPt;                  //[0,0,12]   pt 
143   Double32_t        fEta;                 //[-1,1,12]  eta
144   Double32_t        fPhi;                 //[0,6.3,12] phi
145   Double32_t        fM;                   //[0,0,8]    mass
146   Double32_t        fNEF;                 //[0,1,8]    neutral energy fraction
147   Double32_t        fArea;                //[0,0,12]   area
148   Double32_t        fAreaEta;             //[0,0,12]   area eta
149   Double32_t        fAreaPhi;             //[0,0,12]   area phi
150   Double32_t        fAreaEmc;             //[0,0,12]   area on EMCAL surface (determined from ghosts)
151   Bool_t            fAxisInEmcal;         //           =true if jet axis inside EMCAL acceptance
152   Int_t             fFlavourTagging;      // tag jet with a falvour, bit 0 = no tag; bit 1= Dstar; bit 2 = D0
153   Double32_t        fMaxCPt;              //[0,0,12]   pt of maximum charged constituent
154   Double32_t        fMaxNPt;              //[0,0,12]   pt of maximum neutral constituent
155   Double32_t        fMCPt;                //           pt from MC particles contributing to the jet
156   Int_t             fNn;                  //           number of neutral constituents
157   Int_t             fNch;                 //           number of charged constituents
158   Double32_t        fPtEmc;               //[0,0,12]   pt in EMCAL acceptance
159   Int_t             fNEmc;                //           number of constituents in EMCAL acceptance
160   TArrayI           fClusterIDs;          //           array containing ids of cluster constituents  
161   TArrayI           fTrackIDs;            //           array containing ids of track constituents   
162   AliEmcalJet      *fClosestJets[2];      //!          if this is MC it contains the two closest detector level jets in order of distance and viceversa
163   Double32_t        fClosestJetsDist[2];  //!          distance to closest jets (see above)
164   UShort_t          fMatched;             //!          0,1 if it is matched with one of the closest jets; 2 if it is not matched
165   UShort_t          fMatchingType;        //!          matching type
166   AliEmcalJet      *fTaggedJet;           //!          jet tagged to this jet
167   Int_t             fTagStatus;           //!          status of tagging -1: NA 0: not tagged 1: tagged
168   Double_t          fPtSub;               //!          background subtracted pt (not stored set from outside) 
169   Double_t          fPtVectSub;           //!          background vector subtracted pt (not stored set from outside) 
170   UInt_t            fTriggers;            //!          triggers that the jet might have fired (AliVEvent::EOfflineTriggerTypes)
171
172   ClassDef(AliEmcalJet,12) // Emcal jet class in cylindrical coordinates
173 };
174 #endif