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