]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGJE/EMCALJetTasks/AliEmcalJet.cxx
create general emcal task lib
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / AliEmcalJet.cxx
1 // $Id$
2 //
3 // Emcal jet class.
4 //
5 // Author: C.Loizides
6
7 #include "AliEmcalJet.h"
8
9 ClassImp(AliEmcalJet)
10
11 //__________________________________________________________________________________________________
12 AliEmcalJet::AliEmcalJet() : 
13   AliVParticle(), 
14   fPt(0), 
15   fEta(0), 
16   fPhi(0), 
17   fM(0), 
18   fNEF(0),
19   fArea(0),       
20   fAreaEta(0),       
21   fAreaPhi(0),       
22   fAreaEmc(-1), 
23   fAxisInEmcal(0), 
24   fMaxCPt(0), 
25   fMaxNPt(0), 
26   fMCPt(0),
27   fNn(0), 
28   fNch(0),        
29   fPtEmc(0),
30   fNEmc(0),
31   fClusterIDs(),
32   fTrackIDs(),
33   fMatched(2),
34   fPtSub(0),
35   fPtVectSub(0)
36 {
37   // Constructor.
38
39   fClosestJets[0] = 0;
40   fClosestJets[1] = 0; 
41   fClosestJetsDist[0] = 999; 
42   fClosestJetsDist[1] = 999; 
43 }
44
45 //__________________________________________________________________________________________________
46 AliEmcalJet::AliEmcalJet(Double_t px, Double_t py, Double_t pz) : 
47   AliVParticle(), 
48   fPt(TMath::Sqrt(px*px+py*py)), 
49   fEta(TMath::ASinH(pz/fPt)),
50   fPhi(0), 
51   fM(0), 
52   fNEF(0), 
53   fArea(0), 
54   fAreaEta(0),       
55   fAreaPhi(0),       
56   fAreaEmc(-1), 
57   fAxisInEmcal(0),
58   fMaxCPt(0), 
59   fMaxNPt(0), 
60   fMCPt(0),
61   fNn(0),
62   fNch(0),
63   fPtEmc(0),
64   fNEmc(0),
65   fClusterIDs(), 
66   fTrackIDs(),
67   fMatched(2),
68   fPtSub(0),
69   fPtVectSub(0)
70 {    
71   // Constructor.
72
73   if (fPt != 0) {
74     fPhi = TMath::ATan2(py, px);
75     if (fPhi<0.) 
76       fPhi += 2. * TMath::Pi();
77   }
78
79   fClosestJets[0] = 0; 
80   fClosestJets[1] = 0;
81   fClosestJetsDist[0] = 999; 
82   fClosestJetsDist[1] = 999;
83 }
84
85 //_________________________________________________________________________________________________
86 AliEmcalJet::AliEmcalJet(Double_t pt, Double_t eta, Double_t phi, Double_t m) :
87   AliVParticle(), 
88   fPt(pt), 
89   fEta(eta), 
90   fPhi(phi), 
91   fM(m), 
92   fNEF(0), 
93   fArea(0), 
94   fAreaEta(0),       
95   fAreaPhi(0),       
96   fAreaEmc(-1), 
97   fAxisInEmcal(0),
98   fMaxCPt(0), 
99   fMaxNPt(0),
100   fMCPt(0),
101   fNn(0),
102   fNch(0), 
103   fPtEmc(0),
104   fNEmc(0),
105   fClusterIDs(), 
106   fTrackIDs(),
107   fMatched(2),
108   fPtSub(0),
109   fPtVectSub(0)
110 {
111   // Constructor.
112
113   if (fPhi<0.) 
114     fPhi += TMath::TwoPi();
115
116   fClosestJets[0] = 0; 
117   fClosestJets[1] = 0;
118   fClosestJetsDist[0] = 999; 
119   fClosestJetsDist[1] = 999;
120 }
121
122 //_________________________________________________________________________________________________
123 AliEmcalJet::AliEmcalJet(const AliEmcalJet &jet) :
124   AliVParticle(jet),
125   fPt(jet.fPt), 
126   fEta(jet.fEta), 
127   fPhi(jet.fPhi), 
128   fM(jet.fM), 
129   fNEF(jet.fNEF), 
130   fArea(jet.fArea), 
131   fAreaEta(jet.fAreaEta),       
132   fAreaPhi(jet.fAreaPhi),       
133   fAreaEmc(jet.fAreaEmc), 
134   fAxisInEmcal(jet.fAxisInEmcal),
135   fMaxCPt(jet.fMaxCPt), 
136   fMaxNPt(jet.fMaxNPt), 
137   fMCPt(jet.fMCPt),
138   fNn(jet.fNn),
139   fNch(jet.fNch),
140   fPtEmc(jet.fPtEmc),
141   fNEmc(jet.fNEmc),
142   fClusterIDs(jet.fClusterIDs), 
143   fTrackIDs(jet.fTrackIDs),
144   fMatched(jet.fMatched),
145   fPtSub(jet.fPtSub),
146   fPtVectSub(jet.fPtVectSub)
147 {
148   // Copy constructor.
149
150   fClosestJets[0]     = jet.fClosestJets[0]; 
151   fClosestJets[1]     = jet.fClosestJets[1]; 
152   fClosestJetsDist[0] = jet.fClosestJetsDist[0];  
153   fClosestJetsDist[1] = jet.fClosestJetsDist[1]; 
154 }
155
156 //_________________________________________________________________________________________________
157 AliEmcalJet &AliEmcalJet::operator=(const AliEmcalJet &jet)
158 {
159   // Assignment operator.
160
161   if (this!=&jet) {
162     AliVParticle::operator=(jet);
163     fPt                 = jet.fPt;
164     fEta                = jet.fEta;
165     fPhi                = jet.fPhi;
166     fM                  = jet.fM; 
167     fNEF                = jet.fNEF;
168     fArea               = jet.fArea; 
169     fAreaEta            = jet.fAreaEta; 
170     fAreaPhi            = jet.fAreaPhi; 
171     fAreaEmc            = jet.fAreaEmc; 
172     fAxisInEmcal        = jet.fAxisInEmcal; 
173     fMaxCPt             = jet.fMaxCPt; 
174     fMaxNPt             = jet.fMaxNPt;
175     fMCPt               = jet.fMCPt;
176     fNn                 = jet.fNn;
177     fNch                = jet.fNch;
178     fPtEmc              = jet.fPtEmc;
179     fNEmc               = jet.fNEmc;
180     fClusterIDs         = jet.fClusterIDs;
181     fTrackIDs           = jet.fTrackIDs;
182     fClosestJets[0]     = jet.fClosestJets[0]; 
183     fClosestJets[1]     = jet.fClosestJets[1]; 
184     fClosestJetsDist[0] = jet.fClosestJetsDist[0];  
185     fClosestJetsDist[1] = jet.fClosestJetsDist[1]; 
186     fMatched            = jet.fMatched;
187     fPtSub              = jet.fPtSub;
188     fPtVectSub              = jet.fPtVectSub;
189   }
190
191   return *this;
192 }
193
194 Int_t AliEmcalJet::Compare(const TObject* obj) const
195 {
196   //Return -1 if this is smaller than obj, 0 if objects are equal and 1 if this is larger than obj.
197
198   const AliEmcalJet *jet = static_cast<const AliEmcalJet *>(obj);
199   if (!obj)
200     return 0;
201   if (Pt()>jet->Pt())
202     return -1;
203   return 1;
204 }
205
206 //__________________________________________________________________________________________________
207 void AliEmcalJet::GetMom(TLorentzVector &vec) const
208 {
209   // Return momentum as four vector.
210
211   Double_t p = fPt *TMath::CosH(fEta);
212   vec.SetPtEtaPhiE(fPt,fEta,fPhi,TMath::Sqrt(p*p+fM*fM));
213 }
214
215 //__________________________________________________________________________________________________
216 void AliEmcalJet::Print(Option_t* /*option*/) const
217 {
218   // Print jet information.
219
220   printf("Jet pt=%.2f, eta=%.2f, phi=%.2f, area=%.2f, NEF=%.2f\n", fPt, fEta, fPhi, fArea, fNEF);
221 }
222
223 //__________________________________________________________________________________________________
224 Double_t AliEmcalJet::PtSubVect(Double_t rho) const
225 {
226   // Return vectorial subtracted transverse momentum.
227
228   Double_t dx = Px() - rho * fArea * TMath::Cos(fAreaPhi);
229   Double_t dy = Py() - rho * fArea * TMath::Sin(fAreaPhi);
230   //Double_t dz = Pz() - rho * fArea * TMath::SinH(fAreaEta);
231   return TMath::Sqrt(dx*dx+dy*dy);
232 }
233
234 //__________________________________________________________________________________________________
235 void AliEmcalJet::SortConstituents()
236 {
237   // Sort constituent by index (increasing).
238
239   std::sort(fClusterIDs.GetArray(), fClusterIDs.GetArray() + fClusterIDs.GetSize());
240   std::sort(fTrackIDs.GetArray(), fTrackIDs.GetArray() + fTrackIDs.GetSize());
241 }