]>
Commit | Line | Data |
---|---|---|
48d874ff | 1 | // $Id$ |
542ac102 | 2 | // |
3 | // Emcal jet finder task. | |
4 | // | |
b65fac7a | 5 | // Authors: C.Loizides, S.Aiola |
48d874ff | 6 | |
c64cb1f6 | 7 | #include <vector> |
04905231 | 8 | #include "AliEmcalJetTask.h" |
9 | ||
6ea168d0 | 10 | #include <TChain.h> |
48d874ff | 11 | #include <TClonesArray.h> |
6ea168d0 | 12 | #include <TList.h> |
13 | #include <TLorentzVector.h> | |
ca5c29fa | 14 | #include <TMath.h> |
6421eeb0 | 15 | #include <TRandom3.h> |
b65fac7a | 16 | |
48d874ff | 17 | #include "AliAnalysisManager.h" |
6ea168d0 | 18 | #include "AliCentrality.h" |
f5f3c8e9 | 19 | #include "AliEMCALGeometry.h" |
04905231 | 20 | #include "AliESDEvent.h" |
f5f3c8e9 | 21 | #include "AliEmcalJet.h" |
04905231 | 22 | #include "AliEmcalParticle.h" |
63206072 | 23 | #include "AliFJWrapper.h" |
04905231 | 24 | #include "AliMCEvent.h" |
35789a2d | 25 | #include "AliVCluster.h" |
b65fac7a | 26 | #include "AliVEvent.h" |
04905231 | 27 | #include "AliVParticle.h" |
c2aad3ae | 28 | using std::cout; |
29 | using std::endl; | |
30 | using std::cerr; | |
48d874ff | 31 | |
914d486c | 32 | ClassImp(AliEmcalJetTask) |
48d874ff | 33 | |
6ea168d0 | 34 | //________________________________________________________________________ |
914d486c | 35 | AliEmcalJetTask::AliEmcalJetTask() : |
36 | AliAnalysisTaskSE("AliEmcalJetTask"), | |
6ea168d0 | 37 | fTracksName("Tracks"), |
38 | fCaloName("CaloClusters"), | |
39 | fJetsName("Jets"), | |
6a20534a | 40 | fJetType(kNone), |
d1f2e0d9 | 41 | fConstSel(0), |
42 | fMCConstSel(0), | |
6a20534a | 43 | fMarkConst(kFALSE), |
6ea168d0 | 44 | fRadius(0.4), |
914d486c | 45 | fMinJetTrackPt(0.15), |
46 | fMinJetClusPt(0.15), | |
04905231 | 47 | fPhiMin(0), |
48 | fPhiMax(TMath::TwoPi()), | |
83086e6c | 49 | fEtaMin(-0.9), |
50 | fEtaMax(+0.9), | |
cba7b46e | 51 | fMinJetArea(0.005), |
f5f3c8e9 | 52 | fMinJetPt(1.0), |
c9ad772c | 53 | fJetPhiMin(-10), |
83086e6c | 54 | fJetPhiMax(+10), |
c9ad772c | 55 | fJetEtaMin(-1), |
83086e6c | 56 | fJetEtaMax(+1), |
cba7b46e | 57 | fGhostArea(0.005), |
a7477843 | 58 | fMinMCLabel(0), |
31bab07e | 59 | fRecombScheme(fastjet::BIpt_scheme), |
6421eeb0 | 60 | fTrackEfficiency(1.), |
04905231 | 61 | fIsInit(0), |
d14d6e2c | 62 | fIsPSelSet(0), |
04905231 | 63 | fIsMcPart(0), |
64 | fIsEmcPart(0), | |
5d0a5007 | 65 | fLegacyMode(kFALSE), |
ffdca6aa | 66 | fCodeDebug(kFALSE), |
b65fac7a | 67 | fJets(0), |
04905231 | 68 | fEvent(0), |
69 | fTracks(0), | |
70 | fClus(0) | |
6ea168d0 | 71 | { |
72 | // Default constructor. | |
6ea168d0 | 73 | } |
74 | ||
48d874ff | 75 | //________________________________________________________________________ |
914d486c | 76 | AliEmcalJetTask::AliEmcalJetTask(const char *name) : |
63206072 | 77 | AliAnalysisTaskSE(name), |
7efbea04 | 78 | fTracksName("Tracks"), |
48d874ff | 79 | fCaloName("CaloClusters"), |
7efbea04 | 80 | fJetsName("Jets"), |
6a20534a | 81 | fJetType(kAKT|kFullJet|kRX1Jet), |
d1f2e0d9 | 82 | fConstSel(0), |
83 | fMCConstSel(0), | |
6a20534a | 84 | fMarkConst(kFALSE), |
48d874ff | 85 | fRadius(0.4), |
6ea168d0 | 86 | fMinJetTrackPt(0.15), |
914d486c | 87 | fMinJetClusPt(0.15), |
04905231 | 88 | fPhiMin(0), |
89 | fPhiMax(TMath::TwoPi()), | |
83086e6c | 90 | fEtaMin(-0.9), |
91 | fEtaMax(+0.9), | |
cba7b46e | 92 | fMinJetArea(0.001), |
f5f3c8e9 | 93 | fMinJetPt(1.0), |
c9ad772c | 94 | fJetPhiMin(-10), |
83086e6c | 95 | fJetPhiMax(+10), |
c9ad772c | 96 | fJetEtaMin(-1), |
83086e6c | 97 | fJetEtaMax(+1), |
cba7b46e | 98 | fGhostArea(0.005), |
a7477843 | 99 | fMinMCLabel(0), |
31bab07e | 100 | fRecombScheme(fastjet::BIpt_scheme), |
6421eeb0 | 101 | fTrackEfficiency(1.), |
04905231 | 102 | fIsInit(0), |
d14d6e2c | 103 | fIsPSelSet(0), |
04905231 | 104 | fIsMcPart(0), |
105 | fIsEmcPart(0), | |
31bab07e | 106 | fLegacyMode(kFALSE), |
ffdca6aa | 107 | fCodeDebug(kFALSE), |
b65fac7a | 108 | fJets(0), |
04905231 | 109 | fEvent(0), |
110 | fTracks(0), | |
111 | fClus(0) | |
48d874ff | 112 | { |
113 | // Standard constructor. | |
7efbea04 | 114 | |
7efbea04 | 115 | fBranchNames="ESD:AliESDRun.,AliESDHeader.,PrimaryVertex."; |
48d874ff | 116 | } |
117 | ||
118 | //________________________________________________________________________ | |
914d486c | 119 | AliEmcalJetTask::~AliEmcalJetTask() |
48d874ff | 120 | { |
121 | // Destructor | |
122 | } | |
123 | ||
124 | //________________________________________________________________________ | |
914d486c | 125 | void AliEmcalJetTask::UserCreateOutputObjects() |
48d874ff | 126 | { |
127 | // Create user objects. | |
128 | ||
914d486c | 129 | fJets = new TClonesArray("AliEmcalJet"); |
48d874ff | 130 | fJets->SetName(fJetsName); |
48d874ff | 131 | } |
132 | ||
133 | //________________________________________________________________________ | |
914d486c | 134 | void AliEmcalJetTask::UserExec(Option_t *) |
48d874ff | 135 | { |
136 | // Main loop, called for each event. | |
04905231 | 137 | if (!fIsInit) { |
138 | if (!DoInit()) | |
139 | return; | |
140 | fIsInit = kTRUE; | |
1772fe65 | 141 | } |
b65fac7a | 142 | |
918dd8c8 | 143 | // clear the jet array (normally a null operation) |
144 | fJets->Delete(); | |
145 | ||
04905231 | 146 | FindJets(); |
48d874ff | 147 | } |
148 | ||
149 | //________________________________________________________________________ | |
914d486c | 150 | void AliEmcalJetTask::Terminate(Option_t *) |
48d874ff | 151 | { |
152 | // Called once at the end of the analysis. | |
48d874ff | 153 | } |
154 | ||
155 | //________________________________________________________________________ | |
04905231 | 156 | void AliEmcalJetTask::FindJets() |
48d874ff | 157 | { |
158 | // Find jets. | |
3c5aff5d | 159 | if (!fTracks && !fClus){ |
160 | cout << "WARNING NO TRACKS OR CLUSTERS:" <<endl; | |
d03084cd | 161 | return; |
3c5aff5d | 162 | } |
163 | ||
48d874ff | 164 | TString name("kt"); |
165 | fastjet::JetAlgorithm jalgo(fastjet::kt_algorithm); | |
6a20534a | 166 | if ((fJetType & kAKT) != 0) { |
48d874ff | 167 | name = "antikt"; |
168 | jalgo = fastjet::antikt_algorithm; | |
ca5c29fa | 169 | AliDebug(1,"Using AKT algorithm"); |
170 | } | |
171 | else { | |
172 | AliDebug(1,"Using KT algorithm"); | |
48d874ff | 173 | } |
174 | ||
6a20534a | 175 | if ((fJetType & kR020Jet) != 0) |
176 | fRadius = 0.2; | |
177 | else if ((fJetType & kR030Jet) != 0) | |
178 | fRadius = 0.3; | |
179 | else if ((fJetType & kR040Jet) != 0) | |
180 | fRadius = 0.4; | |
181 | ||
04905231 | 182 | // setup fj wrapper |
48d874ff | 183 | AliFJWrapper fjw(name, name); |
f5f3c8e9 | 184 | fjw.SetAreaType(fastjet::active_area_explicit_ghosts); |
1f9c287f | 185 | fjw.SetGhostArea(fGhostArea); |
04905231 | 186 | fjw.SetR(fRadius); |
7071e730 | 187 | fjw.SetAlgorithm(jalgo); |
31bab07e | 188 | fjw.SetRecombScheme(static_cast<fastjet::RecombinationScheme>(fRecombScheme)); |
83086e6c | 189 | fjw.SetMaxRap(fEtaMax); |
48d874ff | 190 | fjw.Clear(); |
191 | ||
04905231 | 192 | // get primary vertex |
193 | Double_t vertex[3] = {0, 0, 0}; | |
194 | fEvent->GetPrimaryVertex()->GetXYZ(vertex); | |
195 | ||
ca5c29fa | 196 | AliDebug(2,Form("Jet type = %d", fJetType)); |
6a20534a | 197 | |
198 | if ((fIsMcPart || ((fJetType & kFullJet) != 0) || ((fJetType & kChargedJet) != 0)) && fTracks) { | |
04905231 | 199 | const Int_t Ntracks = fTracks->GetEntries(); |
48d874ff | 200 | for (Int_t iTracks = 0; iTracks < Ntracks; ++iTracks) { |
04905231 | 201 | AliVParticle *t = static_cast<AliVParticle*>(fTracks->At(iTracks)); |
48d874ff | 202 | if (!t) |
203 | continue; | |
6a20534a | 204 | if (fIsMcPart) { |
5be3857d | 205 | if (((fJetType & kChargedJet) != 0) && (t->Charge() == 0)) { |
206 | AliDebug(2,Form("Skipping track %d because it is neutral.", iTracks)); | |
6a20534a | 207 | continue; |
5be3857d | 208 | } |
209 | if (((fJetType & kNeutralJet) != 0) && (t->Charge() != 0)) { | |
210 | AliDebug(2,Form("Skipping track %d because it is charged.", iTracks)); | |
6a20534a | 211 | continue; |
5be3857d | 212 | } |
6a20534a | 213 | } |
a7477843 | 214 | if (fIsMcPart || TMath::Abs(t->GetLabel()) > fMinMCLabel) { |
d1f2e0d9 | 215 | if (t->TestBits(fMCConstSel) != (Int_t)fMCConstSel) { |
216 | AliDebug(2,Form("Skipping track %d because it does not match the bit mask (%d, %d)", iTracks, fMCConstSel, t->TestBits(TObject::kBitMask))); | |
6a20534a | 217 | continue; |
218 | } | |
d1f2e0d9 | 219 | else { |
220 | AliDebug(2,Form("Track %d matches the bit mask (%d, %d)", iTracks, fMCConstSel, t->TestBits(TObject::kBitMask))); | |
ca5c29fa | 221 | } |
6a20534a | 222 | } |
223 | else { | |
d1f2e0d9 | 224 | if (t->TestBits(fConstSel) != (Int_t)fConstSel) { |
225 | AliDebug(2,Form("Skipping track %d because it does not match the bit mask (%d, %d)", iTracks, fConstSel, t->TestBits(TObject::kBitMask))); | |
6a20534a | 226 | continue; |
227 | } | |
d1f2e0d9 | 228 | else { |
229 | AliDebug(2,Form("Track %d matches the bit mask (%d, %d)", iTracks, fConstSel, t->TestBits(TObject::kBitMask))); | |
ca5c29fa | 230 | } |
231 | } | |
1772fe65 | 232 | if (t->Pt() < fMinJetTrackPt) |
914d486c | 233 | continue; |
04905231 | 234 | Double_t eta = t->Eta(); |
235 | Double_t phi = t->Phi(); | |
ddf74a88 | 236 | if ((eta<fEtaMin) || (eta>fEtaMax) || |
237 | (phi<fPhiMin) || (phi>fPhiMax)) | |
04905231 | 238 | continue; |
da67b88a | 239 | |
6421eeb0 | 240 | // artificial inefficiency |
241 | if (fTrackEfficiency < 1.) { | |
242 | Double_t rnd = gRandom->Rndm(); | |
243 | if (fTrackEfficiency < rnd) { | |
244 | AliDebug(2,Form("Track %d rejected due to artificial tracking inefficiency", iTracks)); | |
245 | continue; | |
246 | } | |
247 | } | |
248 | ||
a3c8c8c8 | 249 | // offset of 100 for consistency with cluster ids |
ca5c29fa | 250 | AliDebug(2,Form("Track %d accepted (label = %d, pt = %f)", iTracks, t->GetLabel(), t->Pt())); |
31bab07e | 251 | if (fCodeDebug) { |
ffdca6aa | 252 | fjw.AddInputVector(t->Px(), t->Py(), t->Pz(), t->E(), iTracks + 100); |
31bab07e | 253 | } else { |
ffdca6aa | 254 | fjw.AddInputVector(t->Px(), t->Py(), t->Pz(), t->P(), iTracks + 100); |
31bab07e | 255 | } |
48d874ff | 256 | } |
257 | } | |
6ea168d0 | 258 | |
6a20534a | 259 | if ((((fJetType & kFullJet) != 0) || ((fJetType & kNeutralJet) != 0)) && fClus) { |
da67b88a | 260 | const Int_t Nclus = fClus->GetEntries(); |
261 | for (Int_t iClus = 0; iClus < Nclus; ++iClus) { | |
262 | AliVCluster *c = 0; | |
263 | Double_t cEta=0,cPhi=0,cPt=0; | |
264 | Double_t cPx=0,cPy=0,cPz=0; | |
265 | if (fIsEmcPart) { | |
266 | AliEmcalParticle *ep = static_cast<AliEmcalParticle*>(fClus->At(iClus)); | |
267 | if (!ep) | |
268 | continue; | |
6a20534a | 269 | |
da67b88a | 270 | c = ep->GetCluster(); |
271 | if (!c) | |
6a20534a | 272 | continue; |
273 | ||
a7477843 | 274 | if (c->GetLabel() > fMinMCLabel) { |
d1f2e0d9 | 275 | if (ep->TestBits(fMCConstSel) != (Int_t)fMCConstSel) { |
276 | AliDebug(2,Form("Skipping cluster %d because it does not match the bit mask (%d, %d)", iClus, fMCConstSel, ep->TestBits(TObject::kBitMask))); | |
6a20534a | 277 | continue; |
ca5c29fa | 278 | } |
d1f2e0d9 | 279 | else { |
280 | AliDebug(2,Form("Cluster %d matches the bit mask (%d, %d)", iClus, fMCConstSel, ep->TestBits(TObject::kBitMask))); | |
ca5c29fa | 281 | } |
6a20534a | 282 | } |
283 | else { | |
d1f2e0d9 | 284 | if (ep->TestBits(fConstSel) != (Int_t)fConstSel) { |
285 | AliDebug(2,Form("Skipping cluster %d because it does not match the bit mask (%d, %d)", iClus, fConstSel, ep->TestBits(TObject::kBitMask))); | |
6a20534a | 286 | continue; |
ca5c29fa | 287 | } |
d1f2e0d9 | 288 | else { |
289 | AliDebug(2,Form("Cluster %d matches the bit mask (%d, %d)", iClus, fConstSel, ep->TestBits(TObject::kBitMask))); | |
ca5c29fa | 290 | } |
6a20534a | 291 | } |
292 | ||
da67b88a | 293 | cEta = ep->Eta(); |
294 | cPhi = ep->Phi(); | |
295 | cPt = ep->Pt(); | |
296 | cPx = ep->Px(); | |
297 | cPy = ep->Py(); | |
298 | cPz = ep->Pz(); | |
299 | } else { | |
300 | c = static_cast<AliVCluster*>(fClus->At(iClus)); | |
301 | if (!c) | |
302 | continue; | |
6a20534a | 303 | |
a7477843 | 304 | if (c->GetLabel() > fMinMCLabel) { |
d1f2e0d9 | 305 | if (c->TestBits(fMCConstSel) != (Int_t)fMCConstSel) { |
306 | AliDebug(2,Form("Skipping cluster %d because it does not match the bit mask (%d, %d)", iClus, fMCConstSel, c->TestBits(TObject::kBitMask))); | |
6a20534a | 307 | continue; |
ca5c29fa | 308 | } |
d1f2e0d9 | 309 | else { |
310 | AliDebug(2,Form("Cluster %d matches the bit mask (%d, %d)", iClus, fMCConstSel, c->TestBits(TObject::kBitMask))); | |
ca5c29fa | 311 | } |
6a20534a | 312 | } |
313 | else { | |
d1f2e0d9 | 314 | if (c->TestBits(fConstSel) != (Int_t)fConstSel) { |
315 | AliDebug(2,Form("Skipping cluster %d because it does not match the bit mask (%d, %d)", iClus, fConstSel, c->TestBits(TObject::kBitMask))); | |
6a20534a | 316 | continue; |
ca5c29fa | 317 | } |
d1f2e0d9 | 318 | else { |
319 | AliDebug(2,Form("Cluster %d matches the bit mask (%d, %d)", iClus, fConstSel, c->TestBits(TObject::kBitMask))); | |
ca5c29fa | 320 | } |
6a20534a | 321 | } |
322 | ||
da67b88a | 323 | TLorentzVector nP; |
324 | c->GetMomentum(nP, vertex); | |
325 | cEta = nP.Eta(); | |
326 | cPhi = nP.Phi(); | |
327 | cPt = nP.Pt(); | |
328 | cPx = nP.Px(); | |
329 | cPy = nP.Py(); | |
330 | cPz = nP.Pz(); | |
04905231 | 331 | } |
da67b88a | 332 | if (!c->IsEMCAL()) |
333 | continue; | |
334 | if (cPt < fMinJetClusPt) | |
335 | continue; | |
ddf74a88 | 336 | if ((cEta<fEtaMin) || (cEta>fEtaMax) || |
337 | (cPhi<fPhiMin) || (cPhi>fPhiMax)) | |
da67b88a | 338 | continue; |
339 | // offset of 100 to skip ghost particles uid = -1 | |
ca5c29fa | 340 | AliDebug(2,Form("Cluster %d accepted (label = %d)", iClus, c->GetLabel())); |
f660c2d6 | 341 | fjw.AddInputVector(cPx, cPy, cPz, TMath::Sqrt(cPx*cPx+cPy*cPy+cPz*cPz), -iClus - 100); |
48d874ff | 342 | } |
343 | } | |
5d0a5007 | 344 | |
345 | // setting legacy mode | |
346 | if (fLegacyMode) { | |
347 | fjw.SetLegacyMode(kTRUE); | |
348 | } | |
349 | ||
7efbea04 | 350 | // run jet finder |
48d874ff | 351 | fjw.Run(); |
f5f3c8e9 | 352 | |
353 | // get geometry | |
354 | AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance(); | |
355 | if (!geom) { | |
02c7e943 | 356 | AliFatal(Form("%s: Can not create geometry", GetName())); |
f5f3c8e9 | 357 | return; |
358 | } | |
04905231 | 359 | |
360 | // loop over fastjet jets | |
48d874ff | 361 | std::vector<fastjet::PseudoJet> jets_incl = fjw.GetInclusiveJets(); |
ca5c29fa | 362 | // sort jets according to jet pt |
363 | static Int_t indexes[9999] = {-1}; | |
364 | GetSortedArray(indexes, jets_incl); | |
365 | ||
366 | AliDebug(1,Form("%d jets found", (Int_t)jets_incl.size())); | |
367 | for (UInt_t ijet=0, jetCount=0; ijet<jets_incl.size(); ++ijet) { | |
368 | Int_t ij = indexes[ijet]; | |
369 | AliDebug(3,Form("Jet pt = %f, area = %f", jets_incl[ij].perp(), fjw.GetJetArea(ij))); | |
370 | ||
f5f3c8e9 | 371 | if (jets_incl[ij].perp()<fMinJetPt) |
372 | continue; | |
373 | if (fjw.GetJetArea(ij)<fMinJetArea) | |
48d874ff | 374 | continue; |
c9ad772c | 375 | if ((jets_incl[ij].eta()<fJetEtaMin) || (jets_incl[ij].eta()>fJetEtaMax) || |
376 | (jets_incl[ij].phi()<fJetPhiMin) || (jets_incl[ij].phi()>fJetPhiMax)) | |
377 | continue; | |
04905231 | 378 | |
914d486c | 379 | AliEmcalJet *jet = new ((*fJets)[jetCount]) |
380 | AliEmcalJet(jets_incl[ij].perp(), jets_incl[ij].eta(), jets_incl[ij].phi(), jets_incl[ij].m()); | |
04905231 | 381 | |
382 | // loop over constituents | |
c64cb1f6 | 383 | std::vector<fastjet::PseudoJet> constituents(fjw.GetJetConstituents(ij)); |
04905231 | 384 | jet->SetNumberOfTracks(constituents.size()); |
385 | jet->SetNumberOfClusters(constituents.size()); | |
386 | ||
b65fac7a | 387 | Int_t nt = 0; |
388 | Int_t nc = 0; | |
f5f3c8e9 | 389 | Double_t neutralE = 0; |
111318e8 | 390 | Double_t maxCh = 0; |
391 | Double_t maxNe = 0; | |
f5f3c8e9 | 392 | Int_t gall = 0; |
393 | Int_t gemc = 0; | |
04905231 | 394 | Int_t cemc = 0; |
111318e8 | 395 | Int_t ncharged = 0; |
396 | Int_t nneutral = 0; | |
02c7e943 | 397 | Double_t mcpt = 0; |
04905231 | 398 | Double_t emcpt = 0; |
b65fac7a | 399 | |
b65fac7a | 400 | for(UInt_t ic = 0; ic < constituents.size(); ++ic) { |
48d874ff | 401 | Int_t uid = constituents[ic].user_index(); |
5be3857d | 402 | AliDebug(3,Form("Processing constituent %d", uid)); |
04905231 | 403 | if ((uid == -1) /*&& (constituents[ic].kt2() < 1e-25)*/) { //ghost particle |
f5f3c8e9 | 404 | ++gall; |
04905231 | 405 | Double_t gphi = constituents[ic].phi(); |
406 | if (gphi<0) | |
407 | gphi += TMath::TwoPi(); | |
408 | gphi *= TMath::RadToDeg(); | |
f5f3c8e9 | 409 | Double_t geta = constituents[ic].eta(); |
b65fac7a | 410 | if ((gphi > geom->GetArm1PhiMin()) && (gphi < geom->GetArm1PhiMax()) && |
411 | (geta > geom->GetArm1EtaMin()) && (geta < geom->GetArm1EtaMax())) | |
04905231 | 412 | ++gemc; |
413 | } else if ((uid > 0) && fTracks) { // track constituent | |
111318e8 | 414 | Int_t tid = uid - 100; |
04905231 | 415 | AliVParticle *t = static_cast<AliVParticle*>(fTracks->At(tid)); |
ca5c29fa | 416 | if (!t) { |
417 | AliError(Form("Could not find track %d",tid)); | |
04905231 | 418 | continue; |
ca5c29fa | 419 | } |
420 | if (jetCount < fMarkConst) { | |
421 | AliDebug(2,Form("Marking track %d with bit map %d", tid, fJetType)); | |
6a20534a | 422 | t->SetBit(fJetType); |
ca5c29fa | 423 | } |
04905231 | 424 | Double_t cEta = t->Eta(); |
425 | Double_t cPhi = t->Phi(); | |
426 | Double_t cPt = t->Pt(); | |
427 | Double_t cP = t->P(); | |
428 | if (t->Charge() == 0) { | |
429 | neutralE += cP; | |
430 | ++nneutral; | |
431 | if (cPt > maxNe) | |
432 | maxNe = cPt; | |
433 | } else { | |
434 | ++ncharged; | |
435 | if (cPt > maxCh) | |
436 | maxCh = cPt; | |
437 | } | |
a7477843 | 438 | if (fIsMcPart || TMath::Abs(t->GetLabel()) > fMinMCLabel) // check if MC particle |
04905231 | 439 | mcpt += cPt; |
440 | ||
441 | if (cPhi<0) | |
442 | cPhi += TMath::TwoPi(); | |
443 | cPhi *= TMath::RadToDeg(); | |
444 | if ((cPhi > geom->GetArm1PhiMin()) && (cPhi < geom->GetArm1PhiMax()) && | |
445 | (cEta > geom->GetArm1EtaMin()) && (cEta < geom->GetArm1EtaMax())) { | |
446 | emcpt += cPt; | |
447 | ++cemc; | |
d03084cd | 448 | } |
04905231 | 449 | |
450 | jet->AddTrackAt(tid, nt); | |
451 | ++nt; | |
452 | } else if (fClus) { // cluster constituent | |
111318e8 | 453 | Int_t cid = -uid - 100; |
04905231 | 454 | AliVCluster *c = 0; |
455 | Double_t cEta=0,cPhi=0,cPt=0,cP=0; | |
456 | if (fIsEmcPart) { | |
457 | AliEmcalParticle *ep = static_cast<AliEmcalParticle*>(fClus->At(cid)); | |
458 | if (!ep) | |
459 | continue; | |
460 | c = ep->GetCluster(); | |
461 | if (!c) | |
462 | continue; | |
7030f36f | 463 | if (jetCount < fMarkConst) |
6a20534a | 464 | ep->SetBit(fJetType); |
04905231 | 465 | cEta = ep->Eta(); |
466 | cPhi = ep->Phi(); | |
467 | cPt = ep->Pt(); | |
468 | cP = ep->P(); | |
469 | } else { | |
470 | c = static_cast<AliVCluster*>(fClus->At(cid)); | |
471 | if (!c) | |
472 | continue; | |
7030f36f | 473 | if (jetCount < fMarkConst) |
6a20534a | 474 | c->SetBit(fJetType); |
04905231 | 475 | TLorentzVector nP; |
476 | c->GetMomentum(nP, vertex); | |
477 | cEta = nP.Eta(); | |
478 | cPhi = nP.Phi(); | |
479 | cPt = nP.Pt(); | |
480 | cP = nP.P(); | |
481 | } | |
482 | ||
483 | neutralE += cP; | |
484 | if (cPt > maxNe) | |
485 | maxNe = cPt; | |
486 | ||
a7477843 | 487 | if (c->GetLabel() > fMinMCLabel) // MC particle |
43032ce2 | 488 | mcpt += c->GetMCEnergyFraction() > 1e-6 ? cPt * c->GetMCEnergyFraction() : cPt; |
04905231 | 489 | |
490 | if (cPhi<0) | |
491 | cPhi += TMath::TwoPi(); | |
492 | cPhi *= TMath::RadToDeg(); | |
493 | if ((cPhi > geom->GetArm1PhiMin()) && (cPhi < geom->GetArm1PhiMax()) && | |
494 | (cEta > geom->GetArm1EtaMin()) && (cEta < geom->GetArm1EtaMax())) { | |
495 | emcpt += cPt; | |
496 | ++cemc; | |
497 | } | |
498 | ||
499 | jet->AddClusterAt(cid, nc); | |
500 | ++nc; | |
501 | ++nneutral; | |
02c7e943 | 502 | } else { |
503 | AliError(Form("%s: No logical way to end up here.", GetName())); | |
504 | continue; | |
48d874ff | 505 | } |
04905231 | 506 | } /* end of constituent loop */ |
507 | ||
35789a2d | 508 | jet->SetNumberOfTracks(nt); |
509 | jet->SetNumberOfClusters(nc); | |
f5f3c8e9 | 510 | jet->SortConstituents(); |
111318e8 | 511 | jet->SetMaxNeutralPt(maxNe); |
512 | jet->SetMaxChargedPt(maxCh); | |
b65fac7a | 513 | jet->SetNEF(neutralE / jet->E()); |
a88b5c99 | 514 | fastjet::PseudoJet area(fjw.GetJetAreaVector(ij)); |
515 | jet->SetArea(area.perp()); | |
516 | jet->SetAreaEta(area.eta()); | |
517 | jet->SetAreaPhi(area.phi()); | |
111318e8 | 518 | jet->SetNumberOfCharged(ncharged); |
519 | jet->SetNumberOfNeutrals(nneutral); | |
02c7e943 | 520 | jet->SetMCPt(mcpt); |
04905231 | 521 | jet->SetNEmc(cemc); |
522 | jet->SetPtEmc(emcpt); | |
523 | ||
b65fac7a | 524 | if (gall > 0) |
525 | jet->SetAreaEmc(fjw.GetJetArea(ij) * gemc / gall); | |
f5f3c8e9 | 526 | else |
527 | jet->SetAreaEmc(-1); | |
b65fac7a | 528 | if ((jet->Phi() > geom->GetArm1PhiMin() * TMath::DegToRad()) && |
1772fe65 | 529 | (jet->Phi() < geom->GetArm1PhiMax() * TMath::DegToRad()) && |
530 | (jet->Eta() > geom->GetArm1EtaMin()) && | |
531 | (jet->Eta() < geom->GetArm1EtaMax())) | |
f5f3c8e9 | 532 | jet->SetAxisInEmcal(kTRUE); |
ca5c29fa | 533 | |
534 | AliDebug(2,Form("Added jet n. %d, pt = %f, area = %f, constituents = %d", jetCount, jet->Pt(), jet->Area(), (Int_t)constituents.size())); | |
48d874ff | 535 | jetCount++; |
536 | } | |
7030f36f | 537 | //fJets->Sort(); |
48d874ff | 538 | } |
04905231 | 539 | |
ca5c29fa | 540 | //________________________________________________________________________ |
541 | Bool_t AliEmcalJetTask::GetSortedArray(Int_t indexes[], std::vector<fastjet::PseudoJet> array) const | |
542 | { | |
543 | // Get the leading jets. | |
544 | ||
545 | static Float_t pt[9999] = {0}; | |
546 | ||
547 | const Int_t n = (Int_t)array.size(); | |
548 | ||
549 | if (n < 1) | |
550 | return kFALSE; | |
551 | ||
552 | for (Int_t i = 0; i < n; i++) | |
553 | pt[i] = array[i].perp(); | |
554 | ||
555 | TMath::Sort(n, pt, indexes); | |
556 | ||
557 | return kTRUE; | |
558 | } | |
559 | ||
04905231 | 560 | //________________________________________________________________________ |
561 | Bool_t AliEmcalJetTask::DoInit() | |
562 | { | |
563 | // Init. Return true if successful. | |
564 | ||
6421eeb0 | 565 | if (fTrackEfficiency < 1.) { |
566 | if (gRandom) delete gRandom; | |
567 | gRandom = new TRandom3(0); | |
568 | } | |
569 | ||
04905231 | 570 | // get input collections |
571 | AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager(); | |
572 | ||
573 | // get the event | |
574 | fEvent = InputEvent(); | |
575 | if (!fEvent) { | |
576 | AliError(Form("%s: Could not retrieve event! Returning", GetName())); | |
577 | return 0; | |
578 | } | |
579 | ||
580 | // add jets to event if not yet there | |
581 | if (!(fEvent->FindListObject(fJetsName))) | |
582 | fEvent->AddObject(fJets); | |
583 | else { | |
f4b49fa6 | 584 | AliError(Form("%s: Object with name %s already in event! Returning", GetName(), fJetsName.Data())); |
04905231 | 585 | return 0; |
586 | } | |
587 | ||
da67b88a | 588 | if (fTracksName == "Tracks") |
589 | am->LoadBranch("Tracks"); | |
590 | if (!fTracks && !fTracksName.IsNull()) { | |
591 | fTracks = dynamic_cast<TClonesArray*>(fEvent->FindListObject(fTracksName)); | |
592 | if (!fTracks) { | |
593 | AliError(Form("%s: Pointer to tracks %s == 0", GetName(), fTracksName.Data())); | |
594 | return 0; | |
04905231 | 595 | } |
da67b88a | 596 | } |
597 | if (fTracks) { | |
598 | TClass cls(fTracks->GetClass()->GetName()); | |
5be3857d | 599 | if (cls.InheritsFrom("AliMCParticle") || cls.InheritsFrom("AliAODMCParticle")) |
04905231 | 600 | fIsMcPart = 1; |
601 | } | |
da67b88a | 602 | |
603 | if (fCaloName == "CaloClusters") | |
604 | am->LoadBranch("CaloClusters"); | |
605 | if (!fClus && !fCaloName.IsNull()) { | |
606 | fClus = dynamic_cast<TClonesArray*>(fEvent->FindListObject(fCaloName)); | |
607 | if (!fClus) { | |
608 | AliError(Form("%s: Pointer to clus %s == 0", GetName(), fCaloName.Data())); | |
609 | return 0; | |
04905231 | 610 | } |
da67b88a | 611 | } |
612 | if (fClus) { | |
613 | TClass cls(fClus->GetClass()->GetName()); | |
04905231 | 614 | if (cls.InheritsFrom("AliEmcalParticle")) |
615 | fIsEmcPart = 1; | |
616 | } | |
617 | ||
618 | return 1; | |
619 | } |