AliPhysics  c7b8e89 (c7b8e89)
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 
16 #include <sstream>
17 #include <string>
19 
20 #include <TClonesArray.h>
21 #include <TList.h>
22 
23 #include "AliAnalysisManager.h"
24 #include "AliCentrality.h"
25 #include "AliEMCALGeometry.h"
26 #include "AliESDEvent.h"
27 #include "AliEmcalJet.h"
28 #include "AliLog.h"
29 #include "AliRhoParameter.h"
30 #include "AliLocalRhoParameter.h"
31 #include "AliVCluster.h"
32 #include "AliVEventHandler.h"
33 #include "AliVParticle.h"
34 
36 ClassImp(AliAnalysisTaskEmcalJet);
38 
43  AliAnalysisTaskEmcal("AliAnalysisTaskEmcalJet"),
44  fRhoName(),
45  fLocalRhoName(),
46  fJetCollArray(),
47  fJets(0),
48  fRho(0),
49  fLocalRho(0),
50  fRhoVal(0)
51 {
52  fJetCollArray.SetOwner(kTRUE);
53 }
54 
66  AliAnalysisTaskEmcal(name, histo),
67  fRhoName(),
68  fLocalRhoName(),
69  fJetCollArray(),
70  fJets(0),
71  fRho(0),
72  fLocalRho(0),
73  fRhoVal(0)
74 {
75  fJetCollArray.SetOwner(kTRUE);
76 }
77 
82 {
83 }
84 
92 {
93  AliRhoParameter *rho = 0;
94  TString sname(name);
95  if (!sname.IsNull()) {
96  rho = dynamic_cast<AliRhoParameter*>(InputEvent()->FindListObject(sname));
97  if (!rho) {
98  AliWarning(Form("%s: Could not retrieve rho with name %s!", GetName(), name));
99  return 0;
100  }
101  }
102  return rho;
103 }
104 
112 {
113  // Get local rho from event.
114  AliLocalRhoParameter *rho = 0;
115  TString sname(name);
116  if (!sname.IsNull()) {
117  rho = dynamic_cast<AliLocalRhoParameter*>(InputEvent()->FindListObject(sname));
118  if (!rho) {
119  AliWarning(Form("%s: Could not retrieve local rho with name %s!", GetName(), name));
120  return 0;
121  }
122  }
123  return rho;
124 }
125 
137 {
138  // Init the analysis.
139 
141 
142  if (!fRhoName.IsNull() && !fRho) { // get rho from the event
143  fRho = dynamic_cast<AliRhoParameter*>(InputEvent()->FindListObject(fRhoName));
144  if (!fRho) {
145  AliError(Form("%s: Could not retrieve rho %s!", GetName(), fRhoName.Data()));
146  fLocalInitialized = kFALSE;
147  return;
148  }
149  }
150 
151  if (!fLocalRhoName.IsNull() && !fLocalRho) {
152  fLocalRho = dynamic_cast<AliLocalRhoParameter*>(InputEvent()->FindListObject(fLocalRhoName));
153  if (!fLocalRho) {
154  AliError(Form("%s: Could not retrieve local rho %s!", GetName(), fLocalRhoName.Data()));
155  fLocalInitialized = kFALSE;
156  return;
157  }
158  }
159 
160  //Load all requested jet branches - each container knows name already
161  if(fJetCollArray.GetEntriesFast()==0) {
162  AliWarning("There are no jet collections");
163  return;
164  }
165 
166  for(Int_t i =0; i<fJetCollArray.GetEntriesFast(); i++) {
167  AliJetContainer *cont = static_cast<AliJetContainer*>(fJetCollArray.At(i));
168  cont->SetRunNumber(InputEvent()->GetRunNumber());
169  cont->SetArray(InputEvent());
170  cont->LoadRho(InputEvent());
171  }
172 
173  //Get Jets, cuts and rho for first jet container
174  AliJetContainer *cont = GetJetContainer(0);
175 
176  if (!cont->GetArrayName().IsNull()) {
177  fJets = cont->GetArray();
178  if(!fJets && fJetCollArray.GetEntriesFast()>0) {
179  AliErrorStream() << GetName() << ": Could not retrieve first jet branch!\n";
180  std::stringstream foundbranches;
181  bool first(true);
182  for(auto e : *(fInputEvent->GetList())){
183  if(first){
184  // Skip printing a comma on the first time through
185  first = false;
186  }
187  else {
188  foundbranches << ", ";
189  }
190  foundbranches << e->GetName();
191  }
192  std::string fbstring = foundbranches.str();
193  AliErrorStream() << "Found branches: " << fbstring << std::endl;
194  fLocalInitialized = kFALSE;
195  return;
196  }
197  }
198 
199  if (!fRho) { // if rho name is not provided, tries to use the rho object of the first jet branch
200  fRhoName = cont->GetRhoName();
201  fRho = cont->GetRhoParameter();
202  }
203 }
204 
213 {
214  for (Int_t i = 0; i < jet->GetNumberOfClusters(); ++i) {
215  Int_t ijetclus = jet->ClusterAt(i);
216  if (sorted && ijetclus > iclus)
217  return kFALSE;
218  if (ijetclus == iclus)
219  return kTRUE;
220  }
221  return kFALSE;
222 }
223 
232 {
233  for (Int_t i = 0; i < jet->GetNumberOfTracks(); ++i) {
234  Int_t ijettrack = jet->TrackAt(i);
235  if (sorted && ijettrack > itrack)
236  return kFALSE;
237  if (ijettrack == itrack)
238  return kTRUE;
239  }
240  return kFALSE;
241 }
242 
249 {
251  return kFALSE;
252 
253  if (fRho) fRhoVal = fRho->GetVal();
254 
255  AliEmcalContainer* cont = 0;
256 
257  TIter nextJetColl(&fJetCollArray);
258  while ((cont = static_cast<AliEmcalContainer*>(nextJetColl()))) cont->NextEvent(InputEvent());
259 
260  return kTRUE;
261 }
262 
275  UInt_t accType, TString tag)
276 {
279 
280  return AddJetContainer(jetType, jetAlgo, recoScheme, radius, accType, partCont, clusCont, tag);
281 }
282 
297  AliParticleContainer* partCont, AliClusterContainer* clusCont, TString tag)
298 {
299  AliJetContainer *cont = new AliJetContainer(jetType, jetAlgo, recoScheme, radius, partCont, clusCont, tag);
300  cont->SetJetAcceptanceType(accType);
301  fJetCollArray.Add(cont);
302 
303  return cont;
304 }
305 
315 {
316  if (TString(n).IsNull()) return 0;
317 
318  AliJetContainer *cont = new AliJetContainer(n);
319  cont->SetJetRadius(jetRadius);
320  cont->SetJetAcceptanceType(accType);
321  fJetCollArray.Add(cont);
322 
323  return cont;
324 }
325 
333 AliJetContainer* AliAnalysisTaskEmcalJet::AddJetContainer(const char *n, TString defaultCutType, Float_t jetRadius) {
334 
335  // Add particle container
336  // will be called in AddTask macro
337 
338  if(TString(n).IsNull()) return 0;
339 
341 
342  defaultCutType.ToUpper();
343 
344  if (defaultCutType.IsNull() || defaultCutType.EqualTo("USER")) {
345  acc = AliEmcalJet::kUser;
346  }
347  else if(defaultCutType.EqualTo("TPC")) {
348  acc = AliEmcalJet::kTPC;
349  }
350  else if(defaultCutType.EqualTo("TPCFID")) {
351  acc = AliEmcalJet::kTPCfid;
352  }
353  else if(defaultCutType.EqualTo("EMCAL")) {
354  acc = AliEmcalJet::kEMCAL;
355  }
356  else if(defaultCutType.EqualTo("EMCALFID")) {
358  }
359  else if(defaultCutType.EqualTo("DCAL")) {
360  acc = AliEmcalJet::kDCAL;
361  }
362  else if(defaultCutType.EqualTo("DCALFID")) {
363  acc = AliEmcalJet::kDCALfid;
364  }
365  else {
366  AliWarning(Form("%s: default cut type %s not recognized. Not setting cuts.",GetName(),defaultCutType.Data()));
367  }
368 
369  return AddJetContainer(n, acc, jetRadius);
370 }
371 
378 {
379  if (i < 0 || i >= fJetCollArray.GetEntriesFast()) return 0;
380  AliJetContainer *cont = static_cast<AliJetContainer*>(fJetCollArray.At(i));
381  return cont;
382 }
383 
390 {
391  AliJetContainer *cont = static_cast<AliJetContainer*>(fJetCollArray.FindObject(name));
392  return cont;
393 }
394 
396 {
397  AliJetContainer *cont = GetJetContainer(c);
398  if (cont) {
399  cont->SetJetAcceptanceType(t);
400  }
401  else {
402  AliError(Form("%s in SetJetAcceptanceType(...): container %d not found!",GetName(),c));
403  }
404 }
405 
407 {
408  AliJetContainer *cont = GetJetContainer(c);
409  if (!cont) {
410  AliError(Form("%s in SetJetAcceptanceType(...): container %d not found",GetName(),c));
411  return;
412  }
413 
414  cutType.ToUpper();
415 
416  if(!cutType.IsNull() && !cutType.EqualTo("USER")) {
417  if(cutType.EqualTo("TPC"))
419  else if(cutType.EqualTo("EMCAL"))
421  else
422  AliWarning(Form("%s: default cut type %s not recognized. Not setting cuts.",GetName(),cutType.Data()));
423  } else
425 }
431 {
432  AliJetContainer *cont = GetJetContainer(c);
433  if (cont)
434  {
435  cont->SetJetType(type);
436  }
437  else
438  {
439  AliError(Form("%s in SetJetType(...): container %d not found",GetName(),c));
440  return;
441  }
442 }
443 
445 {
446  if (c >= 0) {
447  AliJetContainer *cont = GetJetContainer(c);
448  if (cont) cont->SetRhoName(n);
449  else AliError(Form("%s in SetRhoName(...): container %d not found",GetName(),c));
450  }
451  else {
452  fRhoName = n;
453  }
454 }
455 
457 {
458  AliJetContainer *cont = GetJetContainer(c);
459  if (cont) cont->SetJetEtaLimits(min,max);
460  else AliError(Form("%s in SetJetEtaLimits(...): container %d not found",GetName(),c));
461 }
462 
464 {
465  AliJetContainer *cont = GetJetContainer(c);
466  if (cont) cont->SetJetPhiLimits(min,max);
467  else AliError(Form("%s in SetJetPhiLimits(...): container %d not found",GetName(),c));
468 }
469 
471 {
472  AliJetContainer *cont = GetJetContainer(c);
473  if (cont) cont->SetJetAreaCut(cut);
474  else AliError(Form("%s in SetJetAreaCut(...): container %d not found",GetName(),c));
475 }
476 
478 {
479  AliJetContainer *cont = GetJetContainer(c);
480  if (cont) cont->SetPercAreaCut(p);
481  else AliError(Form("%s in SetPercAreaCut(...): container %d not found",GetName(),c));
482 }
483 
485 {
486  AliJetContainer *cont = GetJetContainer(c);
487  if (cont) cont->SetZLeadingCut(zemc,zch);
488  else AliError(Form("%s in SetZLeadingCut(...): container %d not found",GetName(),c));
489 }
490 
492 {
493  AliJetContainer *cont = GetJetContainer(c);
494  if (cont) cont->SetNEFCut(min,max);
495  else AliError(Form("%s in SetNEFCut(...): container %d not found",GetName(),c));
496 }
497 
499 {
500  AliJetContainer *cont = GetJetContainer(c);
501  if (cont) cont->SetAreaEmcCut(a);
502  else AliError(Form("%s in SetAreaEmcCut(...): container %d not found",GetName(),c));
503 }
504 
506 {
507  AliJetContainer *cont = GetJetContainer(c);
508  if (cont) cont->SetJetPtCut(cut);
509  else AliError(Form("%s in SetJetPtCut(...): container %d not found",GetName(),c));
510 }
511 
513 {
514  AliJetContainer *cont = GetJetContainer(c);
515  if (cont) cont->SetJetRadius(r);
516  else AliError(Form("%s in SetJetRadius(...): container %d not found",GetName(),c));
517 }
518 
520 {
521  AliJetContainer *cont = GetJetContainer(c);
522  if (cont) cont->SetMaxClusterPt(cut);
523  else AliError(Form("%s in SetMaxClusterPt(...): container %d not found",GetName(),c));
524 }
525 
527 {
528  AliJetContainer *cont = GetJetContainer(c);
529  if (cont) cont->SetMaxTrackPt(cut);
530  else AliError(Form("%s in SetMaxTrackPt(...): container %d not found",GetName(),c));
531 }
532 
534 {
535  AliJetContainer *cont = GetJetContainer(c);
536  if (cont) cont->SetPtBiasJetClus(cut);
537  else AliError(Form("%s in SetPtBiasJetClus(...): container %d not found",GetName(),c));
538 }
539 
541 {
542  AliJetContainer *cont = GetJetContainer(c);
543  if (cont) cont->SetPtBiasJetTrack(cut);
544  else AliError(Form("%s in SetPtBiasJetTrack(...): container %d not found",GetName(),c));
545 }
546 
548 {
549  AliJetContainer *cont = GetJetContainer(c);
550  if (cont) cont->SetLeadingHadronType(t);
551  else AliError(Form("%s in SetLeadingHadronType(...): container %d not found",GetName(),c));
552 }
553 
555 {
556  AliJetContainer *cont = GetJetContainer(c);
557  if (cont) cont->SetNLeadingJets(t);
558  else AliError(Form("%s in SetNLeadingJets(...): container %d not found",GetName(),c));
559 }
560 
562 {
563  AliJetContainer *cont = GetJetContainer(c);
564  if (cont) cont->SetBitMap(m);
565  else AliError(Form("%s in SetJetBitMap(...): container %d not found",GetName(),c));
566 }
567 
569 {
570  AliJetContainer *cont = GetJetContainer(c);
571  if (cont) cont->SetIsParticleLevel(b);
572  else AliError(Form("%s in SetIsParticleLevel(...): container %d not found",GetName(),c));
573 }
574 
576 {
577  if (c >= 0) {
578  AliJetContainer *cont = GetJetContainer(c);
579  if (cont) return cont->GetRhoName();
580  else { AliError(Form("%s in GetRhoName(...): container %d not found. Returning fRhoName...",GetName(),c)); return fRhoName; }
581  }
582  else {
583  return fRhoName;
584  }
585 }
586 
588 {
589  AliJetContainer *cont = GetJetContainer(i);
590  if (!cont) {
591  AliError(Form("%s:Container %d not found",GetName(),i));
592  return 0;
593  }
594  return cont->GetArray();
595 }
596 
598 {
599  AliJetContainer *cont = GetJetContainer(i);
600  if (!cont) {
601  AliError(Form("%s:Container %d not found",GetName(),i));
602  return 0;
603  }
604 
605  return cont->GetJetRadius();
606 }
607 
609 {
610  AliJetContainer *cont = GetJetContainer(c);
611  if (!cont) {
612  AliError(Form("%s:Container %d not found",GetName(),c));
613  return 0;
614  }
615  AliEmcalJet *jet = cont->GetJet(j);
616 
617  return jet;
618 }
619 
621 {
622  AliJetContainer *cont = GetJetContainer(c);
623  if (!cont) {
624  AliError(Form("%s:Container %d not found",GetName(),c));
625  return 0;
626  }
627  AliEmcalJet *jet = cont->GetAcceptJet(j);
628 
629  return jet;
630 }
631 
633 {
634  AliJetContainer *cont = GetJetContainer(i);
635  if (!cont) {
636  AliError(Form("%s:Container %d not found",GetName(),i));
637  return 0;
638  }
639  return cont->GetNJets();
640 
641 }
642 
644 {
645  AliJetContainer *cont = GetJetContainer(i);
646  if (!cont) {
647  AliError(Form("%s:Container %d not found",GetName(),i));
648  return 0;
649  }
650  return cont->GetRhoVal();
651 }
652 
654 {
655  AliJetContainer *cont = GetJetContainer(c);
656  if (!cont) {
657  AliError(Form("%s:Container %d not found",GetName(),c));
658  return 0;
659  }
660 
661  return cont->GetLeadingHadronPt(jet);
662 }
663 
665 {
666  if (!jet)
667  return kFALSE;
668 
669  AliJetContainer *cont = GetJetContainer(c);
670  if (!cont) {
671  AliError(Form("%s:Container %d not found",GetName(),c));
672  return 0;
673  }
674 
675  UInt_t rejectionReason = 0;
676  return cont->AcceptJet(jet, rejectionReason);
677 }
void SetAreaEmcCut(Double_t a=0.99)
void SetPercAreaCut(Float_t p, Int_t c=0)
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
double Double_t
Definition: External.C:58
void LoadRho(const AliVEvent *event)
AliJetContainer * GetJetContainer(Int_t i=0) const
DCal acceptance – spans entire rectangular region in eta-phi (including most of PHOS) ...
Definition: AliEmcalJet.h:71
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)
Bool_t fLocalInitialized
whether or not the task has been already initialized
Int_t GetNJets(Int_t i=0) const
void SetAreaEmcCut(Double_t a=0.99, Int_t c=0)
void SetPtBiasJetTrack(Float_t b)
void SetJetType(EJetType_t type, Int_t c=0)
Int_t ClusterAt(Int_t idx) const
Definition: AliEmcalJet.h:137
Double_t GetLeadingHadronPt(AliEmcalJet *jet, Int_t c=0)
virtual Bool_t AcceptJet(Int_t i, UInt_t &rejectionReason) const
Full acceptance, i.e. no acceptance cut applied – left to user.
Definition: AliEmcalJet.h:77
TCanvas * c
Definition: TestFitELoss.C:172
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
Int_t TrackAt(Int_t idx) const
Definition: AliEmcalJet.h:160
UShort_t GetNumberOfTracks() const
Definition: AliEmcalJet.h:139
Bool_t IsJetTrack(AliEmcalJet *jet, Int_t itrack, Bool_t sorted=kFALSE) const
AliParticleContainer * GetParticleContainer(Int_t i=0) const
Get particle container attached to this task.
TString fLocalRhoName
name for local rho
void SetRhoName(const char *n)
TPC fiducial acceptance (each eta edge narrowed by jet R)
Definition: AliEmcalJet.h:68
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)
int Int_t
Definition: External.C:63
UShort_t GetNumberOfClusters() const
Definition: AliEmcalJet.h:138
void SetJetRadius(Float_t r)
void SetJetPtCut(Float_t cut)
TPC acceptance.
Definition: AliEmcalJet.h:67
unsigned int UInt_t
Definition: External.C:33
Double_t GetLeadingHadronPt(const AliEmcalJet *jet) const
void SetPtBiasJetTrack(Float_t b, Int_t c=0)
float Float_t
Definition: External.C:68
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
EMCal acceptance.
Definition: AliEmcalJet.h:69
Int_t GetNJets() const
void SetJetAcceptanceType(UInt_t t, Int_t c=0)
AliClusterContainer * GetClusterContainer(Int_t i=0) const
Get cluster container attached to this task.
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)
virtual Bool_t RetrieveEventObjects()
Retrieve common objects from event.
TObjArray fJetCollArray
jet collection array
TClonesArray * fJets
! jets
AliRhoParameter * GetRhoParameter()
void SetJetPhiLimits(Float_t min, Float_t max, Int_t c=0)
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)
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:51
virtual void ExecOnce()
Perform steps needed to initialize the analysis.
Int_t GetRunNumber(TString)
Definition: PlotMuonQA.C:2235
void SetMaxClusterPt(Float_t b)
void SetJetAcceptanceType(UInt_t type)
virtual Bool_t AcceptJet(AliEmcalJet *jet, Int_t c=0)
DCal fiducial acceptance (each eta, phi edge narrowed by jet R)
Definition: AliEmcalJet.h:72
bool Bool_t
Definition: External.C:53
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.
void SetZLeadingCut(Float_t zemc, Float_t zch)
EMCal fiducial acceptance (each eta, phi edge narrowed by jet R)
Definition: AliEmcalJet.h:70
Container for jet within the EMCAL jet framework.
void SetJetAreaCut(Float_t cut)
void SetNEFCut(Float_t min=0., Float_t max=1.)
void SetJetType(EJetType_t type)
AliEmcalJet * GetJet(Int_t i) const