]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGJE/EMCALJetTasks/AliAnalysisTaskRhoSparse.cxx
add jet shape G(R) analysis class
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / AliAnalysisTaskRhoSparse.cxx
CommitLineData
9239b066 1// $Id$
181a7b93 2//
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").
181a7b93 6//
7// Authors: R.Reed, S.Aiola, M.Connors
8
9#include "AliAnalysisTaskRhoSparse.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"
7cd832c7 18#include "AliJetContainer.h"
181a7b93 19
20ClassImp(AliAnalysisTaskRhoSparse)
21
22//________________________________________________________________________
23AliAnalysisTaskRhoSparse::AliAnalysisTaskRhoSparse() :
24 AliAnalysisTaskRhoBase("AliAnalysisTaskRhoSparse"),
181a7b93 25 fNExclLeadJets(0),
3c5aff5d 26 fRhoCMS(0),
7cd832c7 27 fHistOccCorrvsCent(0)
181a7b93 28{
29 // Constructor.
30}
31
32//________________________________________________________________________
33AliAnalysisTaskRhoSparse::AliAnalysisTaskRhoSparse(const char *name, Bool_t histo) :
34 AliAnalysisTaskRhoBase(name, histo),
181a7b93 35 fNExclLeadJets(0),
3c5aff5d 36 fRhoCMS(0),
7cd832c7 37 fHistOccCorrvsCent(0)
181a7b93 38{
39 // Constructor.
40}
41
42//________________________________________________________________________
43void AliAnalysisTaskRhoSparse::UserCreateOutputObjects()
44{
7cd832c7 45 if (!fCreateHisto) return;
181a7b93 46
47 AliAnalysisTaskRhoBase::UserCreateOutputObjects();
48
49 fHistOccCorrvsCent = new TH2F("OccCorrvsCent", "OccCorrvsCent", 101, -1, 100, 2000, 0 , 2);
50 fOutput->Add(fHistOccCorrvsCent);
51}
52
3c5aff5d 53//________________________________________________________________________
54Bool_t AliAnalysisTaskRhoSparse::IsJetOverlapping(AliEmcalJet* jet1, AliEmcalJet* jet2)
55{
56 for (Int_t i = 0; i < jet1->GetNumberOfTracks(); ++i)
57 {
58 Int_t jet1Track = jet1->TrackAt(i);
59 for (Int_t j = 0; j < jet2->GetNumberOfTracks(); ++j)
60 {
61 Int_t jet2Track = jet2->TrackAt(j);
62 if (jet1Track == jet2Track)
63 return kTRUE;
64 }
65 }
66 return kFALSE;
67}
68
69//________________________________________________________________________
70Bool_t AliAnalysisTaskRhoSparse::IsJetSignal(AliEmcalJet* jet)
71{
72 if(jet->Pt()>5){
73 return kTRUE;
74 }else{
75 return kFALSE;
76 }
77}
78
79
181a7b93 80//________________________________________________________________________
81Bool_t AliAnalysisTaskRhoSparse::Run()
82{
83 // Run the analysis.
84
7cd832c7 85 fOutRho->SetVal(0);
86 if (fOutRhoScaled)
87 fOutRhoScaled->SetVal(0);
181a7b93 88
89 if (!fJets)
90 return kFALSE;
91
7cd832c7 92 const Int_t Njets = fJets->GetEntries();
181a7b93 93
7cd832c7 94 AliJetContainer *sigjets = static_cast<AliJetContainer*>(fJetCollArray.At(1));
3c5aff5d 95
96 Int_t NjetsSig = 0;
7cd832c7 97 if (sigjets) NjetsSig = sigjets->GetNJets();
3c5aff5d 98
181a7b93 99 Int_t maxJetIds[] = {-1, -1};
100 Float_t maxJetPts[] = { 0, 0};
101
102 if (fNExclLeadJets > 0) {
103 for (Int_t ij = 0; ij < Njets; ++ij) {
104 AliEmcalJet *jet = static_cast<AliEmcalJet*>(fJets->At(ij));
105 if (!jet) {
106 AliError(Form("%s: Could not receive jet %d", GetName(), ij));
107 continue;
108 }
109
110 if (!AcceptJet(jet))
111 continue;
112
113 if (jet->Pt() > maxJetPts[0]) {
114 maxJetPts[1] = maxJetPts[0];
115 maxJetIds[1] = maxJetIds[0];
116 maxJetPts[0] = jet->Pt();
117 maxJetIds[0] = ij;
118 } else if (jet->Pt() > maxJetPts[1]) {
119 maxJetPts[1] = jet->Pt();
120 maxJetIds[1] = ij;
121 }
122 }
123 if (fNExclLeadJets < 2) {
124 maxJetIds[1] = -1;
125 maxJetPts[1] = 0;
126 }
127 }
128
129 static Double_t rhovec[999];
130 Int_t NjetAcc = 0;
131 Double_t TotaljetArea=0;
132 Double_t TotaljetAreaPhys=0;
133
134 // push all jets within selected acceptance into stack
135 for (Int_t iJets = 0; iJets < Njets; ++iJets) {
136
137 // exlcuding lead jets
138 if (iJets == maxJetIds[0] || iJets == maxJetIds[1])
139 continue;
140
141 AliEmcalJet *jet = static_cast<AliEmcalJet*>(fJets->At(iJets));
142 if (!jet) {
143 AliError(Form("%s: Could not receive jet %d", GetName(), iJets));
144 continue;
145 }
146
508f6fcf 147 TotaljetArea+=jet->Area();
148
149 if(jet->Pt()>0.1){
150 TotaljetAreaPhys+=jet->Area();
151 }
152
181a7b93 153 if (!AcceptJet(jet))
154 continue;
155
3c5aff5d 156 // Search for overlap with signal jets
157 Bool_t isOverlapping = kFALSE;
7cd832c7 158 if (sigjets) {
3c5aff5d 159 for(Int_t j=0;j<NjetsSig;j++)
160 {
7cd832c7 161 AliEmcalJet* signalJet = sigjets->GetAcceptJet(j);
162 if(!signalJet)
3c5aff5d 163 continue;
164 if(!IsJetSignal(signalJet))
165 continue;
166
167 if(IsJetOverlapping(signalJet, jet))
168 {
169 isOverlapping = kTRUE;
170 break;
171 }
172 }
173 }
174
175 if(isOverlapping)
176 continue;
181a7b93 177
508f6fcf 178 if(jet->Pt()>0.1){
179 rhovec[NjetAcc] = jet->Pt() / jet->Area();
180 ++NjetAcc;
181 }
181a7b93 182 }
183
181a7b93 184 Double_t OccCorr=0.0;
508f6fcf 185 if(TotaljetArea>0) OccCorr=TotaljetAreaPhys/TotaljetArea;
181a7b93 186
6f0214bb 187 if (fCreateHisto)
188 fHistOccCorrvsCent->Fill(fCent, OccCorr);
181a7b93 189
181a7b93 190 if (NjetAcc > 0) {
191 //find median value
192 Double_t rho = TMath::Median(NjetAcc, rhovec);
193
194 if(fRhoCMS){
195 rho = rho * OccCorr;
196 }
197
7cd832c7 198 fOutRho->SetVal(rho);
181a7b93 199
7cd832c7 200 if (fOutRhoScaled) {
181a7b93 201 Double_t rhoScaled = rho * GetScaleFactor(fCent);
7cd832c7 202 fOutRhoScaled->SetVal(rhoScaled);
181a7b93 203 }
204 }
205
206 return kTRUE;
207}