AliPhysics  5364b50 (5364b50)
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 }
426 
428 {
429  if (c >= 0) {
430  AliJetContainer *cont = GetJetContainer(c);
431  if (cont) cont->SetRhoName(n);
432  else AliError(Form("%s in SetRhoName(...): container %d not found",GetName(),c));
433  }
434  else {
435  fRhoName = n;
436  }
437 }
438 
440 {
441  AliJetContainer *cont = GetJetContainer(c);
442  if (cont) cont->SetJetEtaLimits(min,max);
443  else AliError(Form("%s in SetJetEtaLimits(...): container %d not found",GetName(),c));
444 }
445 
447 {
448  AliJetContainer *cont = GetJetContainer(c);
449  if (cont) cont->SetJetPhiLimits(min,max);
450  else AliError(Form("%s in SetJetPhiLimits(...): container %d not found",GetName(),c));
451 }
452 
454 {
455  AliJetContainer *cont = GetJetContainer(c);
456  if (cont) cont->SetJetAreaCut(cut);
457  else AliError(Form("%s in SetJetAreaCut(...): container %d not found",GetName(),c));
458 }
459 
461 {
462  AliJetContainer *cont = GetJetContainer(c);
463  if (cont) cont->SetPercAreaCut(p);
464  else AliError(Form("%s in SetPercAreaCut(...): container %d not found",GetName(),c));
465 }
466 
468 {
469  AliJetContainer *cont = GetJetContainer(c);
470  if (cont) cont->SetZLeadingCut(zemc,zch);
471  else AliError(Form("%s in SetZLeadingCut(...): container %d not found",GetName(),c));
472 }
473 
475 {
476  AliJetContainer *cont = GetJetContainer(c);
477  if (cont) cont->SetNEFCut(min,max);
478  else AliError(Form("%s in SetNEFCut(...): container %d not found",GetName(),c));
479 }
480 
482 {
483  AliJetContainer *cont = GetJetContainer(c);
484  if (cont) cont->SetAreaEmcCut(a);
485  else AliError(Form("%s in SetAreaEmcCut(...): container %d not found",GetName(),c));
486 }
487 
489 {
490  AliJetContainer *cont = GetJetContainer(c);
491  if (cont) cont->SetJetPtCut(cut);
492  else AliError(Form("%s in SetJetPtCut(...): container %d not found",GetName(),c));
493 }
494 
496 {
497  AliJetContainer *cont = GetJetContainer(c);
498  if (cont) cont->SetJetRadius(r);
499  else AliError(Form("%s in SetJetRadius(...): container %d not found",GetName(),c));
500 }
501 
503 {
504  AliJetContainer *cont = GetJetContainer(c);
505  if (cont) cont->SetMaxClusterPt(cut);
506  else AliError(Form("%s in SetMaxClusterPt(...): container %d not found",GetName(),c));
507 }
508 
510 {
511  AliJetContainer *cont = GetJetContainer(c);
512  if (cont) cont->SetMaxTrackPt(cut);
513  else AliError(Form("%s in SetMaxTrackPt(...): container %d not found",GetName(),c));
514 }
515 
517 {
518  AliJetContainer *cont = GetJetContainer(c);
519  if (cont) cont->SetPtBiasJetClus(cut);
520  else AliError(Form("%s in SetPtBiasJetClus(...): container %d not found",GetName(),c));
521 }
522 
524 {
525  AliJetContainer *cont = GetJetContainer(c);
526  if (cont) cont->SetPtBiasJetTrack(cut);
527  else AliError(Form("%s in SetPtBiasJetTrack(...): container %d not found",GetName(),c));
528 }
529 
531 {
532  AliJetContainer *cont = GetJetContainer(c);
533  if (cont) cont->SetLeadingHadronType(t);
534  else AliError(Form("%s in SetLeadingHadronType(...): container %d not found",GetName(),c));
535 }
536 
538 {
539  AliJetContainer *cont = GetJetContainer(c);
540  if (cont) cont->SetNLeadingJets(t);
541  else AliError(Form("%s in SetNLeadingJets(...): container %d not found",GetName(),c));
542 }
543 
545 {
546  AliJetContainer *cont = GetJetContainer(c);
547  if (cont) cont->SetBitMap(m);
548  else AliError(Form("%s in SetJetBitMap(...): container %d not found",GetName(),c));
549 }
550 
552 {
553  AliJetContainer *cont = GetJetContainer(c);
554  if (cont) cont->SetIsParticleLevel(b);
555  else AliError(Form("%s in SetIsParticleLevel(...): container %d not found",GetName(),c));
556 }
557 
559 {
560  if (c >= 0) {
561  AliJetContainer *cont = GetJetContainer(c);
562  if (cont) return cont->GetRhoName();
563  else { AliError(Form("%s in GetRhoName(...): container %d not found. Returning fRhoName...",GetName(),c)); return fRhoName; }
564  }
565  else {
566  return fRhoName;
567  }
568 }
569 
571 {
572  AliJetContainer *cont = GetJetContainer(i);
573  if (!cont) {
574  AliError(Form("%s:Container %d not found",GetName(),i));
575  return 0;
576  }
577  return cont->GetArray();
578 }
579 
581 {
582  AliJetContainer *cont = GetJetContainer(i);
583  if (!cont) {
584  AliError(Form("%s:Container %d not found",GetName(),i));
585  return 0;
586  }
587 
588  return cont->GetJetRadius();
589 }
590 
592 {
593  AliJetContainer *cont = GetJetContainer(c);
594  if (!cont) {
595  AliError(Form("%s:Container %d not found",GetName(),c));
596  return 0;
597  }
598  AliEmcalJet *jet = cont->GetJet(j);
599 
600  return jet;
601 }
602 
604 {
605  AliJetContainer *cont = GetJetContainer(c);
606  if (!cont) {
607  AliError(Form("%s:Container %d not found",GetName(),c));
608  return 0;
609  }
610  AliEmcalJet *jet = cont->GetAcceptJet(j);
611 
612  return jet;
613 }
614 
616 {
617  AliJetContainer *cont = GetJetContainer(i);
618  if (!cont) {
619  AliError(Form("%s:Container %d not found",GetName(),i));
620  return 0;
621  }
622  return cont->GetNJets();
623 
624 }
625 
627 {
628  AliJetContainer *cont = GetJetContainer(i);
629  if (!cont) {
630  AliError(Form("%s:Container %d not found",GetName(),i));
631  return 0;
632  }
633  return cont->GetRhoVal();
634 }
635 
637 {
638  AliJetContainer *cont = GetJetContainer(c);
639  if (!cont) {
640  AliError(Form("%s:Container %d not found",GetName(),c));
641  return 0;
642  }
643 
644  return cont->GetLeadingHadronPt(jet);
645 }
646 
648 {
649  if (!jet)
650  return kFALSE;
651 
652  AliJetContainer *cont = GetJetContainer(c);
653  if (!cont) {
654  AliError(Form("%s:Container %d not found",GetName(),c));
655  return 0;
656  }
657 
658  UInt_t rejectionReason = 0;
659  return cont->AcceptJet(jet, rejectionReason);
660 }
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)
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.)
AliEmcalJet * GetJet(Int_t i) const