AliPhysics  68dfc25 (68dfc25)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskRho.cxx
Go to the documentation of this file.
1 // $Id$
2 //
3 // Calculation of rho from a collection of jets.
4 // If scale function is given the scaled rho will be exported
5 // with the name as "fOutRhoName".Apppend("_Scaled").
6 //
7 // Authors: R.Reed, S.Aiola
8 
9 #include "AliAnalysisTaskRho.h"
10 
11 #include <TClonesArray.h>
12 #include <TMath.h>
13 
14 #include "AliAnalysisManager.h"
15 #include "AliEmcalJet.h"
16 #include "AliLog.h"
17 #include "AliRhoParameter.h"
18 
19 ClassImp(AliAnalysisTaskRho)
20 
21 //________________________________________________________________________
24  fNExclLeadJets(0)
25 {
26  // Constructor.
27 }
28 
29 //________________________________________________________________________
31  AliAnalysisTaskRhoBase(name, histo),
32  fNExclLeadJets(0)
33 {
34  // Constructor.
35 }
36 
37 
38 //________________________________________________________________________
40 {
41  // Run the analysis.
42 
43  fOutRho->SetVal(0);
44  if (fOutRhoScaled)
45  fOutRhoScaled->SetVal(0);
46 
47  if (!fJets)
48  return kFALSE;
49 
50  const Int_t Njets = fJets->GetEntries();
51 
52  Int_t maxJetIds[] = {-1, -1};
53  Float_t maxJetPts[] = { 0, 0};
54 
55  if (fNExclLeadJets > 0) {
56  for (Int_t ij = 0; ij < Njets; ++ij) {
57  AliEmcalJet *jet = static_cast<AliEmcalJet*>(fJets->At(ij));
58  if (!jet) {
59  AliError(Form("%s: Could not receive jet %d", GetName(), ij));
60  continue;
61  }
62 
63  if (!AcceptJet(jet))
64  continue;
65 
66  if (jet->Pt() > maxJetPts[0]) {
67  maxJetPts[1] = maxJetPts[0];
68  maxJetIds[1] = maxJetIds[0];
69  maxJetPts[0] = jet->Pt();
70  maxJetIds[0] = ij;
71  } else if (jet->Pt() > maxJetPts[1]) {
72  maxJetPts[1] = jet->Pt();
73  maxJetIds[1] = ij;
74  }
75  }
76  if (fNExclLeadJets < 2) {
77  maxJetIds[1] = -1;
78  maxJetPts[1] = 0;
79  }
80  }
81 
82  static Double_t rhovec[999];
83  Int_t NjetAcc = 0;
84 
85  // push all jets within selected acceptance into stack
86  for (Int_t iJets = 0; iJets < Njets; ++iJets) {
87 
88  // exlcuding lead jets
89  if (iJets == maxJetIds[0] || iJets == maxJetIds[1])
90  continue;
91 
92  AliEmcalJet *jet = static_cast<AliEmcalJet*>(fJets->At(iJets));
93  if (!jet) {
94  AliError(Form("%s: Could not receive jet %d", GetName(), iJets));
95  continue;
96  }
97 
98  if (!AcceptJet(jet))
99  continue;
100 
101  rhovec[NjetAcc] = jet->Pt() / jet->Area();
102  ++NjetAcc;
103  }
104 
105 
106  if (NjetAcc > 0) {
107  //find median value
108  Double_t rho = TMath::Median(NjetAcc, rhovec);
109  fOutRho->SetVal(rho);
110 
111  if (fOutRhoScaled) {
112  Double_t rhoScaled = rho * GetScaleFactor(fCent);
113  fOutRhoScaled->SetVal(rhoScaled);
114  }
115  }
116 
117  return kTRUE;
118 }
Double_t Area() const
Definition: AliEmcalJet.h:123
double Double_t
Definition: External.C:58
AliRhoParameter * fOutRhoScaled
output rho object
int Int_t
Definition: External.C:63
float Float_t
Definition: External.C:68
Double_t fCent
!event centrality
TClonesArray * fJets
! jets
Double_t Pt() const
Definition: AliEmcalJet.h:102
virtual Double_t GetScaleFactor(Double_t cent)
Represent a jet reconstructed using the EMCal jet framework.
Definition: AliEmcalJet.h:44
Bool_t Run()
Run function. This is the core function of the analysis and contains the user code. Therefore users have to implement this function.
virtual Bool_t AcceptJet(AliEmcalJet *jet, Int_t c=0)
bool Bool_t
Definition: External.C:53