AliPhysics  a9863a5 (a9863a5)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskEmcalJet.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2016, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 
17 
18 #include <TClonesArray.h>
19 #include <TList.h>
20 
21 #include "AliAnalysisManager.h"
22 #include "AliCentrality.h"
23 #include "AliEMCALGeometry.h"
24 #include "AliESDEvent.h"
25 #include "AliEmcalJet.h"
26 #include "AliLog.h"
27 #include "AliRhoParameter.h"
28 #include "AliLocalRhoParameter.h"
29 #include "AliVCluster.h"
30 #include "AliVEventHandler.h"
31 #include "AliVParticle.h"
32 
36 
41  AliAnalysisTaskEmcal("AliAnalysisTaskEmcalJet"),
42  fRhoName(),
43  fLocalRhoName(),
44  fJetCollArray(),
45  fJets(0),
46  fRho(0),
47  fLocalRho(0),
48  fRhoVal(0)
49 {
50  fJetCollArray.SetOwner(kTRUE);
51 }
52 
63 AliAnalysisTaskEmcalJet::AliAnalysisTaskEmcalJet(const char *name, Bool_t histo) :
64  AliAnalysisTaskEmcal(name, histo),
65  fRhoName(),
66  fLocalRhoName(),
67  fJetCollArray(),
68  fJets(0),
69  fRho(0),
70  fLocalRho(0),
71  fRhoVal(0)
72 {
73  fJetCollArray.SetOwner(kTRUE);
74 }
75 
80 {
81 }
82 
90 {
91  AliRhoParameter *rho = 0;
92  TString sname(name);
93  if (!sname.IsNull()) {
94  rho = dynamic_cast<AliRhoParameter*>(InputEvent()->FindListObject(sname));
95  if (!rho) {
96  AliWarning(Form("%s: Could not retrieve rho with name %s!", GetName(), name));
97  return 0;
98  }
99  }
100  return rho;
101 }
102 
110 {
111  // Get local rho from event.
112  AliLocalRhoParameter *rho = 0;
113  TString sname(name);
114  if (!sname.IsNull()) {
115  rho = dynamic_cast<AliLocalRhoParameter*>(InputEvent()->FindListObject(sname));
116  if (!rho) {
117  AliWarning(Form("%s: Could not retrieve local rho with name %s!", GetName(), name));
118  return 0;
119  }
120  }
121  return rho;
122 }
123 
135 {
136  // Init the analysis.
137 
139 
140  if (!fRhoName.IsNull() && !fRho) { // get rho from the event
141  fRho = dynamic_cast<AliRhoParameter*>(InputEvent()->FindListObject(fRhoName));
142  if (!fRho) {
143  AliError(Form("%s: Could not retrieve rho %s!", GetName(), fRhoName.Data()));
144  fInitialized = kFALSE;
145  return;
146  }
147  }
148 
149  if (!fLocalRhoName.IsNull() && !fLocalRho) {
150  fLocalRho = dynamic_cast<AliLocalRhoParameter*>(InputEvent()->FindListObject(fLocalRhoName));
151  if (!fLocalRho) {
152  AliError(Form("%s: Could not retrieve local rho %s!", GetName(), fLocalRhoName.Data()));
153  fInitialized = kFALSE;
154  return;
155  }
156  }
157 
158  //Load all requested jet branches - each container knows name already
159  if(fJetCollArray.GetEntriesFast()==0) {
160  AliWarning("There are no jet collections");
161  return;
162  }
163 
164  for(Int_t i =0; i<fJetCollArray.GetEntriesFast(); i++) {
165  AliJetContainer *cont = static_cast<AliJetContainer*>(fJetCollArray.At(i));
166  cont->SetRunNumber(InputEvent()->GetRunNumber());
167  cont->SetArray(InputEvent());
168  cont->LoadRho(InputEvent());
169  }
170 
171  //Get Jets, cuts and rho for first jet container
172  AliJetContainer *cont = GetJetContainer(0);
173 
174  if (!cont->GetArrayName().IsNull()) {
175  fJets = cont->GetArray();
176  if(!fJets && fJetCollArray.GetEntriesFast()>0) {
177  AliError(Form("%s: Could not retrieve first jet branch!", GetName()));
178  fInitialized = kFALSE;
179  return;
180  }
181  }
182 
183  if (!fRho) { // if rho name is not provided, tries to use the rho object of the first jet branch
184  fRhoName = cont->GetRhoName();
185  fRho = cont->GetRhoParameter();
186  }
187 }
188 
196 Bool_t AliAnalysisTaskEmcalJet::IsJetCluster(AliEmcalJet* jet, Int_t iclus, Bool_t sorted) const
197 {
198  for (Int_t i = 0; i < jet->GetNumberOfClusters(); ++i) {
199  Int_t ijetclus = jet->ClusterAt(i);
200  if (sorted && ijetclus > iclus)
201  return kFALSE;
202  if (ijetclus == iclus)
203  return kTRUE;
204  }
205  return kFALSE;
206 }
207 
215 Bool_t AliAnalysisTaskEmcalJet::IsJetTrack(AliEmcalJet* jet, Int_t itrack, Bool_t sorted) const
216 {
217  for (Int_t i = 0; i < jet->GetNumberOfTracks(); ++i) {
218  Int_t ijettrack = jet->TrackAt(i);
219  if (sorted && ijettrack > itrack)
220  return kFALSE;
221  if (ijettrack == itrack)
222  return kTRUE;
223  }
224  return kFALSE;
225 }
226 
233 {
235  return kFALSE;
236 
237  if (fRho) fRhoVal = fRho->GetVal();
238 
239  AliEmcalContainer* cont = 0;
240 
241  TIter nextJetColl(&fJetCollArray);
242  while ((cont = static_cast<AliEmcalContainer*>(nextJetColl()))) cont->NextEvent();
243 
244  return kTRUE;
245 }
246 
258  JetAcceptanceType accType, TString tag)
259 {
262 
263  return AddJetContainer(jetType, jetAlgo, recoScheme, radius, accType, partCont, clusCont, tag);
264 }
265 
279  AliParticleContainer* partCont, AliClusterContainer* clusCont, TString tag)
280 {
281  AliJetContainer *cont = new AliJetContainer(jetType, jetAlgo, recoScheme, radius, partCont, clusCont, tag);
282  cont->SetJetAcceptanceType(accType);
283  fJetCollArray.Add(cont);
284 
285  return cont;
286 }
287 
296 {
297  if (TString(n).IsNull()) return 0;
298 
299  AliJetContainer *cont = new AliJetContainer(n);
300  cont->SetJetRadius(jetRadius);
301  cont->SetJetAcceptanceType(accType);
302  fJetCollArray.Add(cont);
303 
304  return cont;
305 }
306 
314 AliJetContainer* AliAnalysisTaskEmcalJet::AddJetContainer(const char *n, TString defaultCutType, Float_t jetRadius) {
315 
316  // Add particle container
317  // will be called in AddTask macro
318 
319  if(TString(n).IsNull()) return 0;
320 
322 
323  defaultCutType.ToUpper();
324 
325  if (defaultCutType.IsNull() || defaultCutType.EqualTo("USER")) {
327  }
328  else if(defaultCutType.EqualTo("TPC")) {
329  acc = AliJetContainer::kTPC;
330  }
331  else if(defaultCutType.EqualTo("TPCFID")) {
333  }
334  else if(defaultCutType.EqualTo("EMCAL")) {
336  }
337  else if(defaultCutType.EqualTo("EMCALFID")) {
339  }
340  else if(defaultCutType.EqualTo("DCAL")) {
342  }
343  else if(defaultCutType.EqualTo("DCALFID")) {
345  }
346  else {
347  AliWarning(Form("%s: default cut type %s not recognized. Not setting cuts.",GetName(),defaultCutType.Data()));
348  }
349 
350  return AddJetContainer(n, acc, jetRadius);
351 }
352 
359 {
360  if (i < 0 || i >= fJetCollArray.GetEntriesFast()) return 0;
361  AliJetContainer *cont = static_cast<AliJetContainer*>(fJetCollArray.At(i));
362  return cont;
363 }
364 
371 {
372  AliJetContainer *cont = static_cast<AliJetContainer*>(fJetCollArray.FindObject(name));
373  return cont;
374 }
375 
377 {
378  AliJetContainer *cont = GetJetContainer(c);
379  if (cont) {
381  }
382  else {
383  AliError(Form("%s in SetJetAcceptanceType(...): container %d not found!",GetName(),c));
384  }
385 }
386 
387 void AliAnalysisTaskEmcalJet::SetJetAcceptanceType(TString cutType, Int_t c)
388 {
389  AliJetContainer *cont = GetJetContainer(c);
390  if (!cont) {
391  AliError(Form("%s in SetJetAcceptanceType(...): container %d not found",GetName(),c));
392  return;
393  }
394 
395  cutType.ToUpper();
396 
397  if(!cutType.IsNull() && !cutType.EqualTo("USER")) {
398  if(cutType.EqualTo("TPC"))
400  else if(cutType.EqualTo("EMCAL"))
402  else
403  AliWarning(Form("%s: default cut type %s not recognized. Not setting cuts.",GetName(),cutType.Data()));
404  } else
406 }
407 
408 void AliAnalysisTaskEmcalJet::SetRhoName(const char *n, Int_t c)
409 {
410  if (c >= 0) {
411  AliJetContainer *cont = GetJetContainer(c);
412  if (cont) cont->SetRhoName(n);
413  else AliError(Form("%s in SetRhoName(...): container %d not found",GetName(),c));
414  }
415  else {
416  fRhoName = n;
417  }
418 }
419 
420 void AliAnalysisTaskEmcalJet::SetJetEtaLimits(Float_t min, Float_t max, Int_t c)
421 {
422  AliJetContainer *cont = GetJetContainer(c);
423  if (cont) cont->SetJetEtaLimits(min,max);
424  else AliError(Form("%s in SetJetEtaLimits(...): container %d not found",GetName(),c));
425 }
426 
427 void AliAnalysisTaskEmcalJet::SetJetPhiLimits(Float_t min, Float_t max, Int_t c)
428 {
429  AliJetContainer *cont = GetJetContainer(c);
430  if (cont) cont->SetJetPhiLimits(min,max);
431  else AliError(Form("%s in SetJetPhiLimits(...): container %d not found",GetName(),c));
432 }
433 
434 void AliAnalysisTaskEmcalJet::SetJetAreaCut(Float_t cut, Int_t c)
435 {
436  AliJetContainer *cont = GetJetContainer(c);
437  if (cont) cont->SetJetAreaCut(cut);
438  else AliError(Form("%s in SetJetAreaCut(...): container %d not found",GetName(),c));
439 }
440 
442 {
443  AliJetContainer *cont = GetJetContainer(c);
444  if (cont) cont->SetPercAreaCut(p);
445  else AliError(Form("%s in SetPercAreaCut(...): container %d not found",GetName(),c));
446 }
447 
448 void AliAnalysisTaskEmcalJet::SetZLeadingCut(Float_t zemc, Float_t zch, Int_t c)
449 {
450  AliJetContainer *cont = GetJetContainer(c);
451  if (cont) cont->SetZLeadingCut(zemc,zch);
452  else AliError(Form("%s in SetZLeadingCut(...): container %d not found",GetName(),c));
453 }
454 
455 void AliAnalysisTaskEmcalJet::SetNEFCut(Float_t min, Float_t max, Int_t c)
456 {
457  AliJetContainer *cont = GetJetContainer(c);
458  if (cont) cont->SetNEFCut(min,max);
459  else AliError(Form("%s in SetNEFCut(...): container %d not found",GetName(),c));
460 }
461 
462 void AliAnalysisTaskEmcalJet::SetAreaEmcCut(Double_t a, Int_t c)
463 {
464  AliJetContainer *cont = GetJetContainer(c);
465  if (cont) cont->SetAreaEmcCut(a);
466  else AliError(Form("%s in SetAreaEmcCut(...): container %d not found",GetName(),c));
467 }
468 
469 void AliAnalysisTaskEmcalJet::SetJetPtCut(Float_t cut, Int_t c)
470 {
471  AliJetContainer *cont = GetJetContainer(c);
472  if (cont) cont->SetJetPtCut(cut);
473  else AliError(Form("%s in SetJetPtCut(...): container %d not found",GetName(),c));
474 }
475 
477 {
478  AliJetContainer *cont = GetJetContainer(c);
479  if (cont) cont->SetJetRadius(r);
480  else AliError(Form("%s in SetJetRadius(...): container %d not found",GetName(),c));
481 }
482 
484 {
485  AliJetContainer *cont = GetJetContainer(c);
486  if (cont) cont->SetMaxClusterPt(cut);
487  else AliError(Form("%s in SetMaxClusterPt(...): container %d not found",GetName(),c));
488 }
489 
490 void AliAnalysisTaskEmcalJet::SetMaxTrackPt(Float_t cut, Int_t c)
491 {
492  AliJetContainer *cont = GetJetContainer(c);
493  if (cont) cont->SetMaxTrackPt(cut);
494  else AliError(Form("%s in SetMaxTrackPt(...): container %d not found",GetName(),c));
495 }
496 
498 {
499  AliJetContainer *cont = GetJetContainer(c);
500  if (cont) cont->SetPtBiasJetClus(cut);
501  else AliError(Form("%s in SetPtBiasJetClus(...): container %d not found",GetName(),c));
502 }
503 
505 {
506  AliJetContainer *cont = GetJetContainer(c);
507  if (cont) cont->SetPtBiasJetTrack(cut);
508  else AliError(Form("%s in SetPtBiasJetTrack(...): container %d not found",GetName(),c));
509 }
510 
512 {
513  AliJetContainer *cont = GetJetContainer(c);
514  if (cont) cont->SetLeadingHadronType(t);
515  else AliError(Form("%s in SetLeadingHadronType(...): container %d not found",GetName(),c));
516 }
517 
519 {
520  AliJetContainer *cont = GetJetContainer(c);
521  if (cont) cont->SetNLeadingJets(t);
522  else AliError(Form("%s in SetNLeadingJets(...): container %d not found",GetName(),c));
523 }
524 
526 {
527  AliJetContainer *cont = GetJetContainer(c);
528  if (cont) cont->SetBitMap(m);
529  else AliError(Form("%s in SetJetBitMap(...): container %d not found",GetName(),c));
530 }
531 
533 {
534  AliJetContainer *cont = GetJetContainer(c);
535  if (cont) cont->SetIsParticleLevel(b);
536  else AliError(Form("%s in SetIsParticleLevel(...): container %d not found",GetName(),c));
537 }
538 
539 const TString& AliAnalysisTaskEmcalJet::GetRhoName(Int_t c) const
540 {
541  if (c >= 0) {
542  AliJetContainer *cont = GetJetContainer(c);
543  if (cont) return cont->GetRhoName();
544  else { AliError(Form("%s in GetRhoName(...): container %d not found. Returning fRhoName...",GetName(),c)); return fRhoName; }
545  }
546  else {
547  return fRhoName;
548  }
549 }
550 
551 TClonesArray* AliAnalysisTaskEmcalJet::GetJetArray(Int_t i) const
552 {
553  AliJetContainer *cont = GetJetContainer(i);
554  if (!cont) {
555  AliError(Form("%s:Container %d not found",GetName(),i));
556  return 0;
557  }
558  return cont->GetArray();
559 }
560 
562 {
563  AliJetContainer *cont = GetJetContainer(i);
564  if (!cont) {
565  AliError(Form("%s:Container %d not found",GetName(),i));
566  return 0;
567  }
568 
569  return cont->GetJetRadius();
570 }
571 
573 {
574  AliJetContainer *cont = GetJetContainer(c);
575  if (!cont) {
576  AliError(Form("%s:Container %d not found",GetName(),c));
577  return 0;
578  }
579  AliEmcalJet *jet = cont->GetJet(j);
580 
581  return jet;
582 }
583 
585 {
586  AliJetContainer *cont = GetJetContainer(c);
587  if (!cont) {
588  AliError(Form("%s:Container %d not found",GetName(),c));
589  return 0;
590  }
591  AliEmcalJet *jet = cont->GetAcceptJet(j);
592 
593  return jet;
594 }
595 
597 {
598  AliJetContainer *cont = GetJetContainer(i);
599  if (!cont) {
600  AliError(Form("%s:Container %d not found",GetName(),i));
601  return 0;
602  }
603  return cont->GetNJets();
604 
605 }
606 
607 Double_t AliAnalysisTaskEmcalJet::GetRhoVal(Int_t i) const
608 {
609  AliJetContainer *cont = GetJetContainer(i);
610  if (!cont) {
611  AliError(Form("%s:Container %d not found",GetName(),i));
612  return 0;
613  }
614  return cont->GetRhoVal();
615 }
616 
618 {
619  AliJetContainer *cont = GetJetContainer(c);
620  if (!cont) {
621  AliError(Form("%s:Container %d not found",GetName(),c));
622  return 0;
623  }
624 
625  return cont->GetLeadingHadronPt(jet);
626 }
627 
629 {
630  if (!jet)
631  return kFALSE;
632 
633  AliJetContainer *cont = GetJetContainer(c);
634  if (!cont) {
635  AliError(Form("%s:Container %d not found",GetName(),c));
636  return 0;
637  }
638 
639  UInt_t rejectionReason = 0;
640  return cont->AcceptJet(jet, rejectionReason);
641 }
void SetAreaEmcCut(Double_t a=0.99)
void SetPercAreaCut(Float_t p, Int_t c=0)
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
void SetMaxClusterPt(Float_t b, Int_t c=0)
Double_t GetRhoVal() const
AliEmcalJet * GetJetFromArray(Int_t j, Int_t c=0) const
const TString & GetRhoName() const
void LoadRho(const AliVEvent *event)
AliJetContainer * GetJetContainer(Int_t i=0) const
const TString & GetRhoName(Int_t c=0) const
void SetJetBitMap(UInt_t m, Int_t c=0)
Base task in the EMCAL framework.
void SetLeadingHadronType(Int_t t)
Int_t GetNJets(Int_t i=0) const
void SetAreaEmcCut(Double_t a=0.99, Int_t c=0)
void SetPtBiasJetTrack(Float_t b)
Double_t GetLeadingHadronPt(AliEmcalJet *jet, Int_t c=0)
virtual Bool_t AcceptJet(Int_t i, UInt_t &rejectionReason) const
AliJetContainer * AddJetContainer(const char *n, TString defaultCutType, Float_t jetRadius=0.4)
AliLocalRhoParameter * GetLocalRhoFromEvent(const char *name)
void SetPercAreaCut(Float_t p)
void SetPtBiasJetClus(Float_t b, Int_t c=0)
TClonesArray * GetJetArray(Int_t i=0) const
void SetPtBiasJetClus(Float_t b)
Container for particles within the EMCAL framework.
Double_t GetJetRadius(Int_t i=0) const
UShort_t GetNumberOfTracks() const
Definition: AliEmcalJet.h:106
Bool_t IsJetTrack(AliEmcalJet *jet, Int_t itrack, Bool_t sorted=kFALSE) const
AliParticleContainer * GetParticleContainer(Int_t i=0) const
TString fLocalRhoName
name for local rho
void SetRhoName(const char *n)
void SetLeadingHadronType(Int_t t, Int_t c=0)
Bool_t IsJetCluster(AliEmcalJet *jet, Int_t iclus, Bool_t sorted=kFALSE) const
AliRhoParameter * GetRhoFromEvent(const char *name)
Short_t ClusterAt(Int_t idx) const
Definition: AliEmcalJet.h:104
UShort_t GetNumberOfClusters() const
Definition: AliEmcalJet.h:105
void SetJetRadius(Float_t r)
void SetJetPtCut(Float_t cut)
void SetBitMap(UInt_t m)
Double_t GetLeadingHadronPt(const AliEmcalJet *jet) const
void SetPtBiasJetTrack(Float_t b, Int_t c=0)
void SetNLeadingJets(Int_t t)
void SetJetRadius(Float_t r, Int_t c=0)
void SetJetEtaLimits(Float_t min, Float_t max, Int_t c=0)
void SetJetPhiLimits(Float_t min, Float_t max)
AliRhoParameter * fRho
! event rho
Int_t GetNJets() const
void SetJetAcceptanceType(UInt_t t, Int_t c=0)
AliClusterContainer * GetClusterContainer(Int_t i=0) const
Base class for container structures within the EMCAL framework.
TClonesArray * GetArray() const
AliLocalRhoParameter * fLocalRho
! local event rho
void SetZLeadingCut(Float_t zemc, Float_t zch, Int_t c=0)
AliEmcalJet * GetAcceptJetFromArray(Int_t j, Int_t c=0) const
virtual void SetRhoName(const char *n, Int_t c=0)
void SetJetAcceptanceType(JetAcceptanceType type)
virtual Bool_t RetrieveEventObjects()
TObjArray fJetCollArray
jet collection array
TClonesArray * fJets
! jets
AliRhoParameter * GetRhoParameter()
void SetJetPhiLimits(Float_t min, Float_t max, Int_t c=0)
const TString & GetArrayName() const
Double_t GetRhoVal(Int_t i=0) const
void SetJetAreaCut(Float_t cut, Int_t c=0)
Float_t GetJetRadius() const
void SetNLeadingJets(Int_t t, Int_t c=0)
Short_t TrackAt(Int_t idx) const
Definition: AliEmcalJet.h:127
void SetIsParticleLevel(Bool_t b)
void SetIsParticleLevel(Bool_t b, Int_t c=0)
void SetArray(const AliVEvent *event)
AliEmcalJet * GetAcceptJet(Int_t i) const
void SetRunNumber(Int_t r)
Base task in the EMCAL jet framework.
Represent a jet reconstructed using the EMCal jet framework.
Definition: AliEmcalJet.h:44
Int_t GetRunNumber(TString)
Definition: PlotMuonQA.C:2235
void SetMaxClusterPt(Float_t b)
virtual Bool_t AcceptJet(AliEmcalJet *jet, Int_t c=0)
Bool_t fInitialized
whether or not the task has been already initialized
void SetNEFCut(Float_t min, Float_t max, Int_t c=0)
void SetJetPtCut(Float_t cut, Int_t c=0)
void SetMaxTrackPt(Float_t b, Int_t c=0)
void SetMaxTrackPt(Float_t b)
void SetJetEtaLimits(Float_t min, Float_t max)
Double_t fRhoVal
! event rho value, same for local rho
Container structure for EMCAL clusters.
virtual void NextEvent()
void SetZLeadingCut(Float_t zemc, Float_t zch)
Container for jet within the EMCAL jet framework.
void SetJetAreaCut(Float_t cut)
void SetNEFCut(Float_t min=0., Float_t max=1.)
AliEmcalJet * GetJet(Int_t i) const