]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGJE/EMCALJetTasks/AliAnalysisTaskRho.cxx
070614 cyaldo Changes to AliAnalysisTaskFullpAJets
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / AliAnalysisTaskRho.cxx
CommitLineData
5b5bad1d 1// $Id$
192fc3f4 2//
f09b22c5 3// Calculation of rho from a collection of jets.
4// If scale function is given the scaled rho will be exported
7cd832c7 5// with the name as "fOutRhoName".Apppend("_Scaled").
192fc3f4 6//
7// Authors: R.Reed, S.Aiola
8
5b5bad1d 9#include "AliAnalysisTaskRho.h"
10
020052e4 11#include <TClonesArray.h>
c60e0a21 12#include <TMath.h>
020052e4 13
020052e4 14#include "AliAnalysisManager.h"
020052e4 15#include "AliEmcalJet.h"
297edd60 16#include "AliLog.h"
17#include "AliRhoParameter.h"
020052e4 18
020052e4 19ClassImp(AliAnalysisTaskRho)
20
21//________________________________________________________________________
22AliAnalysisTaskRho::AliAnalysisTaskRho() :
a487deae 23 AliAnalysisTaskRhoBase("AliAnalysisTaskRho"),
24 fNExclLeadJets(0)
020052e4 25{
6a12db52 26 // Constructor.
020052e4 27}
28
5d845887 29//________________________________________________________________________
30AliAnalysisTaskRho::AliAnalysisTaskRho(const char *name, Bool_t histo) :
a487deae 31 AliAnalysisTaskRhoBase(name, histo),
32 fNExclLeadJets(0)
5d845887 33{
6a12db52 34 // Constructor.
5d845887 35}
36
3c5aff5d 37
020052e4 38//________________________________________________________________________
a487deae 39Bool_t AliAnalysisTaskRho::Run()
020052e4 40{
a487deae 41 // Run the analysis.
020052e4 42
7cd832c7 43 fOutRho->SetVal(0);
44 if (fOutRhoScaled)
45 fOutRhoScaled->SetVal(0);
a5621834 46
e44e8726 47 if (!fJets)
a487deae 48 return kFALSE;
020052e4 49
f09b22c5 50 const Int_t Njets = fJets->GetEntries();
020052e4 51
f09b22c5 52 Int_t maxJetIds[] = {-1, -1};
53 Float_t maxJetPts[] = { 0, 0};
c60e0a21 54
c60e0a21 55 if (fNExclLeadJets > 0) {
f09b22c5 56 for (Int_t ij = 0; ij < Njets; ++ij) {
57 AliEmcalJet *jet = static_cast<AliEmcalJet*>(fJets->At(ij));
c60e0a21 58 if (!jet) {
f09b22c5 59 AliError(Form("%s: Could not receive jet %d", GetName(), ij));
c60e0a21 60 continue;
61 }
ed777bb8 62
a487deae 63 if (!AcceptJet(jet))
ed777bb8 64 continue;
65
c60e0a21 66 if (jet->Pt() > maxJetPts[0]) {
67 maxJetPts[1] = maxJetPts[0];
5b5bad1d 68 maxJetIds[1] = maxJetIds[0];
c60e0a21 69 maxJetPts[0] = jet->Pt();
70 maxJetIds[0] = ij;
f09b22c5 71 } else if (jet->Pt() > maxJetPts[1]) {
c60e0a21 72 maxJetPts[1] = jet->Pt();
73 maxJetIds[1] = ij;
74 }
75 }
76 if (fNExclLeadJets < 2) {
77 maxJetIds[1] = -1;
a487deae 78 maxJetPts[1] = 0;
c60e0a21 79 }
80 }
81
82 static Double_t rhovec[999];
020052e4 83 Int_t NjetAcc = 0;
84
c60e0a21 85 // push all jets within selected acceptance into stack
020052e4 86 for (Int_t iJets = 0; iJets < Njets; ++iJets) {
f09b22c5 87
c60e0a21 88 // exlcuding lead jets
89 if (iJets == maxJetIds[0] || iJets == maxJetIds[1])
90 continue;
91
f09b22c5 92 AliEmcalJet *jet = static_cast<AliEmcalJet*>(fJets->At(iJets));
ed777bb8 93 if (!jet) {
94 AliError(Form("%s: Could not receive jet %d", GetName(), iJets));
95 continue;
96 }
c60e0a21 97
a487deae 98 if (!AcceptJet(jet))
020052e4 99 continue;
c60e0a21 100
dfa2c5f2 101 rhovec[NjetAcc] = jet->Pt() / jet->Area();
f09b22c5 102 ++NjetAcc;
020052e4 103 }
192fc3f4 104
3c5aff5d 105
f09b22c5 106 if (NjetAcc > 0) {
020052e4 107 //find median value
a487deae 108 Double_t rho = TMath::Median(NjetAcc, rhovec);
7cd832c7 109 fOutRho->SetVal(rho);
a487deae 110
7cd832c7 111 if (fOutRhoScaled) {
dfa2c5f2 112 Double_t rhoScaled = rho * GetScaleFactor(fCent);
7cd832c7 113 fOutRhoScaled->SetVal(rhoScaled);
f09b22c5 114 }
f09b22c5 115 }
020052e4 116
a487deae 117 return kTRUE;
118}