]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGJE/EMCALJetTasks/AliEmcalJet.cxx
Updates Salvatore Aiola
[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   fMatchingType(0),
35   fPtSub(0),
36   fPtVectSub(0)
37 {
38   // Constructor.
39
40   fClosestJets[0] = 0;
41   fClosestJets[1] = 0; 
42   fClosestJetsDist[0] = 999; 
43   fClosestJetsDist[1] = 999; 
44 }
45
46 //__________________________________________________________________________________________________
47 AliEmcalJet::AliEmcalJet(Double_t px, Double_t py, Double_t pz) : 
48   AliVParticle(), 
49   fPt(TMath::Sqrt(px*px+py*py)), 
50   fEta(TMath::ASinH(pz/fPt)),
51   fPhi(0), 
52   fM(0), 
53   fNEF(0), 
54   fArea(0), 
55   fAreaEta(0),       
56   fAreaPhi(0),       
57   fAreaEmc(-1), 
58   fAxisInEmcal(0),
59   fMaxCPt(0), 
60   fMaxNPt(0), 
61   fMCPt(0),
62   fNn(0),
63   fNch(0),
64   fPtEmc(0),
65   fNEmc(0),
66   fClusterIDs(), 
67   fTrackIDs(),
68   fMatched(2),
69   fMatchingType(0),
70   fPtSub(0),
71   fPtVectSub(0)
72 {    
73   // Constructor.
74
75   if (fPt != 0) {
76     fPhi = TMath::ATan2(py, px);
77     if (fPhi<0.) 
78       fPhi += 2. * TMath::Pi();
79   }
80
81   fClosestJets[0] = 0; 
82   fClosestJets[1] = 0;
83   fClosestJetsDist[0] = 999; 
84   fClosestJetsDist[1] = 999;
85 }
86
87 //_________________________________________________________________________________________________
88 AliEmcalJet::AliEmcalJet(Double_t pt, Double_t eta, Double_t phi, Double_t m) :
89   AliVParticle(), 
90   fPt(pt), 
91   fEta(eta), 
92   fPhi(phi), 
93   fM(m), 
94   fNEF(0), 
95   fArea(0), 
96   fAreaEta(0),       
97   fAreaPhi(0),       
98   fAreaEmc(-1), 
99   fAxisInEmcal(0),
100   fMaxCPt(0), 
101   fMaxNPt(0),
102   fMCPt(0),
103   fNn(0),
104   fNch(0), 
105   fPtEmc(0),
106   fNEmc(0),
107   fClusterIDs(), 
108   fTrackIDs(),
109   fMatched(2),
110   fMatchingType(0),
111   fPtSub(0),
112   fPtVectSub(0)
113 {
114   // Constructor.
115
116   if (fPhi<0.) 
117     fPhi += TMath::TwoPi();
118
119   fClosestJets[0] = 0; 
120   fClosestJets[1] = 0;
121   fClosestJetsDist[0] = 999; 
122   fClosestJetsDist[1] = 999;
123 }
124
125 //_________________________________________________________________________________________________
126 AliEmcalJet::AliEmcalJet(const AliEmcalJet &jet) :
127   AliVParticle(jet),
128   fPt(jet.fPt), 
129   fEta(jet.fEta), 
130   fPhi(jet.fPhi), 
131   fM(jet.fM), 
132   fNEF(jet.fNEF), 
133   fArea(jet.fArea), 
134   fAreaEta(jet.fAreaEta),       
135   fAreaPhi(jet.fAreaPhi),       
136   fAreaEmc(jet.fAreaEmc), 
137   fAxisInEmcal(jet.fAxisInEmcal),
138   fMaxCPt(jet.fMaxCPt), 
139   fMaxNPt(jet.fMaxNPt), 
140   fMCPt(jet.fMCPt),
141   fNn(jet.fNn),
142   fNch(jet.fNch),
143   fPtEmc(jet.fPtEmc),
144   fNEmc(jet.fNEmc),
145   fClusterIDs(jet.fClusterIDs), 
146   fTrackIDs(jet.fTrackIDs),
147   fMatched(jet.fMatched),
148   fMatchingType(jet.fMatchingType),
149   fPtSub(jet.fPtSub),
150   fPtVectSub(jet.fPtVectSub)
151 {
152   // Copy constructor.
153
154   fClosestJets[0]     = jet.fClosestJets[0]; 
155   fClosestJets[1]     = jet.fClosestJets[1]; 
156   fClosestJetsDist[0] = jet.fClosestJetsDist[0];  
157   fClosestJetsDist[1] = jet.fClosestJetsDist[1]; 
158 }
159
160 //_________________________________________________________________________________________________
161 AliEmcalJet &AliEmcalJet::operator=(const AliEmcalJet &jet)
162 {
163   // Assignment operator.
164
165   if (this!=&jet) {
166     AliVParticle::operator=(jet);
167     fPt                 = jet.fPt;
168     fEta                = jet.fEta;
169     fPhi                = jet.fPhi;
170     fM                  = jet.fM; 
171     fNEF                = jet.fNEF;
172     fArea               = jet.fArea; 
173     fAreaEta            = jet.fAreaEta; 
174     fAreaPhi            = jet.fAreaPhi; 
175     fAreaEmc            = jet.fAreaEmc; 
176     fAxisInEmcal        = jet.fAxisInEmcal; 
177     fMaxCPt             = jet.fMaxCPt; 
178     fMaxNPt             = jet.fMaxNPt;
179     fMCPt               = jet.fMCPt;
180     fNn                 = jet.fNn;
181     fNch                = jet.fNch;
182     fPtEmc              = jet.fPtEmc;
183     fNEmc               = jet.fNEmc;
184     fClusterIDs         = jet.fClusterIDs;
185     fTrackIDs           = jet.fTrackIDs;
186     fClosestJets[0]     = jet.fClosestJets[0]; 
187     fClosestJets[1]     = jet.fClosestJets[1]; 
188     fClosestJetsDist[0] = jet.fClosestJetsDist[0];  
189     fClosestJetsDist[1] = jet.fClosestJetsDist[1]; 
190     fMatched            = jet.fMatched;
191     fPtSub              = jet.fPtSub;
192     fPtVectSub          = jet.fPtVectSub;
193   }
194
195   return *this;
196 }
197
198 Int_t AliEmcalJet::Compare(const TObject* obj) const
199 {
200   //Return -1 if this is smaller than obj, 0 if objects are equal and 1 if this is larger than obj.
201
202   const AliEmcalJet *jet = static_cast<const AliEmcalJet *>(obj);
203   if (!obj)
204     return 0;
205   if (Pt()>jet->Pt())
206     return -1;
207   return 1;
208 }
209
210 //__________________________________________________________________________________________________
211 void AliEmcalJet::GetMom(TLorentzVector &vec) const
212 {
213   // Return momentum as four vector.
214
215   Double_t p = fPt *TMath::CosH(fEta);
216   vec.SetPtEtaPhiE(fPt,fEta,fPhi,TMath::Sqrt(p*p+fM*fM));
217 }
218
219 //__________________________________________________________________________________________________
220 void AliEmcalJet::Print(Option_t* /*option*/) const
221 {
222   // Print jet information.
223
224   printf("Jet pt=%.2f, eta=%.2f, phi=%.2f, area=%.2f, NEF=%.2f\n", fPt, fEta, fPhi, fArea, fNEF);
225 }
226
227 //__________________________________________________________________________________________________
228 Double_t AliEmcalJet::PtSubVect(Double_t rho) const
229 {
230   // Return vectorial subtracted transverse momentum.
231
232   Double_t dx = Px() - rho * fArea * TMath::Cos(fAreaPhi);
233   Double_t dy = Py() - rho * fArea * TMath::Sin(fAreaPhi);
234   //Double_t dz = Pz() - rho * fArea * TMath::SinH(fAreaEta);
235   return TMath::Sqrt(dx*dx+dy*dy);
236 }
237
238 //__________________________________________________________________________________________________
239 void AliEmcalJet::SortConstituents()
240 {
241   // Sort constituent by index (increasing).
242
243   std::sort(fClusterIDs.GetArray(), fClusterIDs.GetArray() + fClusterIDs.GetSize());
244   std::sort(fTrackIDs.GetArray(), fTrackIDs.GetArray() + fTrackIDs.GetSize());
245 }
246
247 //__________________________________________________________________________________________________
248 AliVParticle* AliEmcalJet::GetLeadingTrack(TClonesArray *tracks) const
249 {
250   AliVParticle* maxTrack = 0;
251   for (Int_t i = 0; i < GetNumberOfTracks(); i++) {
252     AliVParticle *track = TrackAt(i, tracks);
253     if (!maxTrack || track->Pt() > maxTrack->Pt()) 
254       maxTrack = track;
255   }
256
257   return maxTrack;
258 }
259
260 //__________________________________________________________________________________________________
261 AliVCluster* AliEmcalJet::GetLeadingCluster(TClonesArray *clusters) const
262 {
263   AliVCluster* maxCluster = 0;
264   for (Int_t i = 0; i < GetNumberOfClusters(); i++) {
265     AliVCluster *cluster = ClusterAt(i, clusters);
266     if (!maxCluster || cluster->E() > maxCluster->E()) 
267       maxCluster = cluster;
268   }
269
270   return maxCluster;
271 }