]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGJE/EMCALJetTasks/AliEmcalJet.cxx
up from Salvatore
[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 //_________________________________________________________________________________________________
199 Int_t AliEmcalJet::Compare(const TObject* obj) const
200 {
201   //Return -1 if this is smaller than obj, 0 if objects are equal and 1 if this is larger than obj.
202
203   const AliEmcalJet *jet = static_cast<const AliEmcalJet *>(obj);
204   if (!obj)
205     return 0;
206   if (Pt()>jet->Pt())
207     return -1;
208   return 1;
209 }
210
211 //__________________________________________________________________________________________________
212 void AliEmcalJet::GetMom(TLorentzVector &vec) const
213 {
214   // Return momentum as four vector.
215
216   Double_t p = fPt *TMath::CosH(fEta);
217   vec.SetPtEtaPhiE(fPt,fEta,fPhi,TMath::Sqrt(p*p+fM*fM));
218 }
219
220 //__________________________________________________________________________________________________
221 void AliEmcalJet::Print(Option_t* /*option*/) const
222 {
223   // Print jet information.
224
225   printf("Jet pt=%.2f, eta=%.2f, phi=%.2f, area=%.2f, NEF=%.2f\n", fPt, fEta, fPhi, fArea, fNEF);
226 }
227
228 //__________________________________________________________________________________________________
229 Double_t AliEmcalJet::PtSubVect(Double_t rho) const
230 {
231   // Return vectorial subtracted transverse momentum.
232
233   Double_t dx = Px() - rho * fArea * TMath::Cos(fAreaPhi);
234   Double_t dy = Py() - rho * fArea * TMath::Sin(fAreaPhi);
235   //Double_t dz = Pz() - rho * fArea * TMath::SinH(fAreaEta);
236   return TMath::Sqrt(dx*dx+dy*dy);
237 }
238
239 //__________________________________________________________________________________________________
240 void AliEmcalJet::SortConstituents()
241 {
242   // Sort constituent by index (increasing).
243
244   std::sort(fClusterIDs.GetArray(), fClusterIDs.GetArray() + fClusterIDs.GetSize());
245   std::sort(fTrackIDs.GetArray(), fTrackIDs.GetArray() + fTrackIDs.GetSize());
246 }
247
248 //__________________________________________________________________________________________________
249 AliVParticle* AliEmcalJet::GetLeadingTrack(TClonesArray *tracks) const
250 {
251   AliVParticle* maxTrack = 0;
252   for (Int_t i = 0; i < GetNumberOfTracks(); i++) {
253     AliVParticle *track = TrackAt(i, tracks);
254     if (!maxTrack || track->Pt() > maxTrack->Pt()) 
255       maxTrack = track;
256   }
257
258   return maxTrack;
259 }
260
261 //__________________________________________________________________________________________________
262 AliVCluster* AliEmcalJet::GetLeadingCluster(TClonesArray *clusters) const
263 {
264   AliVCluster* maxCluster = 0;
265   for (Int_t i = 0; i < GetNumberOfClusters(); i++) {
266     AliVCluster *cluster = ClusterAt(i, clusters);
267     if (!maxCluster || cluster->E() > maxCluster->E()) 
268       maxCluster = cluster;
269   }
270
271   return maxCluster;
272 }
273
274 //__________________________________________________________________________________________________
275 void AliEmcalJet::ResetMatching()
276 {
277   fClosestJets[0] = 0;
278   fClosestJets[1] = 0; 
279   fClosestJetsDist[0] = 999; 
280   fClosestJetsDist[1] = 999; 
281   fMatched = 2;
282 }