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