2 // Dijet analysis task.
6 #include <TClonesArray.h>
10 #include <THnSparse.h>
12 #include <TLorentzVector.h>
19 #include "AliVCluster.h"
20 #include "AliVTrack.h"
21 #include "AliEmcalJet.h"
22 #include "AliRhoParameter.h"
24 #include "AliAnalysisUtils.h"
25 #include "AliEmcalParticle.h"
26 #include "AliMCEvent.h"
27 #include "AliGenPythiaEventHeader.h"
28 #include "AliAODMCHeader.h"
29 #include "AliMCEvent.h"
30 #include "AliAnalysisManager.h"
31 #include "AliJetContainer.h"
33 #include "AliAnalysisTaskEmcalDiJetAna.h"
35 ClassImp(AliAnalysisTaskEmcalDiJetAna)
37 //________________________________________________________________________
38 AliAnalysisTaskEmcalDiJetAna::AliAnalysisTaskEmcalDiJetAna() :
39 AliAnalysisTaskEmcalDiJetBase("AliAnalysisTaskEmcalDiJetAna"),
40 fDoMatchFullCharged(kTRUE),
43 fh3PtEtaPhiJetFull(0),
44 fh3PtEtaPhiJetCharged(0),
47 fhnDiJetVarsFullCharged(0),
48 fhnMatchingFullCharged(0),
49 fh3JetPtFullFractionDR(0)
51 // Default constructor.
53 SetMakeGeneralHistograms(kTRUE);
56 //________________________________________________________________________
57 AliAnalysisTaskEmcalDiJetAna::AliAnalysisTaskEmcalDiJetAna(const char *name) :
58 AliAnalysisTaskEmcalDiJetBase(name),
59 fDoMatchFullCharged(kTRUE),
62 fh3PtEtaPhiJetFull(0),
63 fh3PtEtaPhiJetCharged(0),
66 fhnDiJetVarsFullCharged(0),
67 fhnMatchingFullCharged(0),
68 fh3JetPtFullFractionDR(0)
70 // Standard constructor.
72 SetMakeGeneralHistograms(kTRUE);
75 //________________________________________________________________________
76 AliAnalysisTaskEmcalDiJetAna::~AliAnalysisTaskEmcalDiJetAna()
81 //________________________________________________________________________
82 Bool_t AliAnalysisTaskEmcalDiJetAna::RetrieveEventObjects() {
84 // retrieve event objects
87 if (!AliAnalysisTaskEmcalDiJetBase::RetrieveEventObjects())
93 //________________________________________________________________________
94 void AliAnalysisTaskEmcalDiJetAna::UserCreateOutputObjects()
96 // Create user output.
100 AliAnalysisTaskEmcalDiJetBase::UserCreateOutputObjects();
102 Bool_t oldStatus = TH1::AddDirectoryStatus();
103 TH1::AddDirectory(kFALSE);
105 const Int_t nBinsCent = 100.;
106 Double_t minCent = 0.;
107 Double_t maxCent = 100.;
109 const Int_t nBinsRho = 200;
110 Double_t minRho = 0.;
111 Double_t maxRho = 20.;
112 fh2CentRhoCh = new TH2F("fh2CentRhoCh","fh2CentRhoCh;centrality;#rho_{ch}",nBinsCent,minCent,maxCent,nBinsRho,minRho,maxRho);
113 fOutput->Add(fh2CentRhoCh);
114 fh2CentRhoScaled = new TH2F("fh2CentRhoScaled","fh2CentRhoScaled;centrality;s_{EMC}#rho_{ch}",nBinsCent,minCent,maxCent,nBinsRho,minRho,maxRho);
115 fOutput->Add(fh2CentRhoScaled);
117 const Int_t nBinsPt = 120;
118 Double_t minPt = -20.;
119 Double_t maxPt = 100.;
120 const Int_t nBinsEta = 40;
121 Double_t minEta = -1.;
122 Double_t maxEta = 1.;
123 const Int_t nBinsPhi = 18*6;
124 Double_t minPhi = 0.;
125 Double_t maxPhi = TMath::TwoPi();
127 fh3PtEtaPhiJetFull = new TH3F("fh3PtEtaPhiJetFull","fh3PtEtaPhiJetFull;#it{p}_{T}^{jet};#eta;#varphi",nBinsPt,minPt,maxPt,nBinsEta,minEta,maxEta,nBinsPhi,minPhi,maxPhi);
128 fOutput->Add(fh3PtEtaPhiJetFull);
130 fh3PtEtaPhiJetCharged = new TH3F("fh3PtEtaPhiJetCharged","fh3PtEtaPhiJetCharged;#it{p}_{T}^{jet};#eta;#varphi",nBinsPt,minPt,maxPt,nBinsEta,minEta,maxEta,nBinsPhi,minPhi,maxPhi);
131 fOutput->Add(fh3PtEtaPhiJetCharged);
133 const Int_t nBinsSparse0 = 6;
134 const Int_t nBinsDPhi = 72;
135 const Int_t nBinsKt = 100;
136 const Int_t nBinsDiJetEta = 40;
137 const Int_t nBinsCentr = 10;
138 const Int_t nBins0[nBinsSparse0] = {nBinsPt,nBinsPt,nBinsDPhi,nBinsKt,nBinsDiJetEta,nBinsCentr};
139 //pT1, pT2, deltaPhi, kT
140 const Double_t xmin0[nBinsSparse0] = { minPt, minPt, -0.5*TMath::Pi(),-100.,-1.,0.};
141 const Double_t xmax0[nBinsSparse0] = { maxPt, maxPt, 1.5*TMath::Pi(), 100., 1.,100.};
143 if(fDoChargedCharged) {
144 fhnDiJetVarsCh = new THnSparseF("fhnDiJetVarsCh",
145 "fhnDiJetVarsCh;#it{p}_{T,1} (GeV/#it{c});#it{p}_{T,2} (GeV/#it{c});#Delta#varphi;#it{k}_{T} = #it{p}_{T,1}sin(#Delta#varphi) (GeV/#it{c});(#eta_{1}+#eta_{2})/2);centrality",
146 nBinsSparse0,nBins0,xmin0,xmax0);
147 fOutput->Add(fhnDiJetVarsCh);
151 fhnDiJetVarsFullCharged = new THnSparseF("fhnDiJetVarsFullCharged",
152 "fhnDiJetVarsFullCharged;#it{p}_{T,1} (GeV/#it{c});#it{p}_{T,2} (GeV/#it{c});#Delta#varphi;#it{k}_{T} = #it{p}_{T,1}sin(#Delta#varphi) (GeV/#it{c});(#eta_{1}+#eta_{2})/2);centrality",
153 nBinsSparse0,nBins0,xmin0,xmax0);
154 fOutput->Add(fhnDiJetVarsFullCharged);
157 const Int_t nBinsSparseMatch = 7;
158 const Int_t nBinsDPhiMatch = 80;
159 const Int_t nBinsDEtaMatch = 80;
160 const Int_t nBinsDR = 20;
161 const Int_t nBinsFraction = 21;
162 const Int_t nBinsType = 3;
163 const Int_t nBinsMatch[nBinsSparseMatch] = {nBinsPt,nBinsPt,nBinsDPhiMatch,nBinsDEtaMatch,nBinsDR,nBinsFraction,nBinsType};
164 //pTfull, pTch, deltaPhi, deltaEta, deltaR, fraction, jet type (leading,subleading,other)
165 const Double_t xminMatch[nBinsSparseMatch] = { minPt, minPt, -0.5,-0.5, 0.,0. ,0};
166 const Double_t xmaxMatch[nBinsSparseMatch] = { maxPt, maxPt, 0.5, 0.5, 0.5,1.05,3};
167 fhnMatchingFullCharged = new THnSparseF("fhnMatchingFullCharged","fhnMatchingFullCharged;#it{p}_{T,full} (GeV/#it{c});#it{p}_{T,ch} (GeV/#it{c});#Delta#varphi;#Delta#eta;#Delta R;f_{ch};type",
168 nBinsSparseMatch,nBinsMatch,xminMatch,xmaxMatch);
169 fOutput->Add(fhnMatchingFullCharged);
171 fh3JetPtFullFractionDR = new TH3F("fh3JetPtFullFractionDR","fh3JetPtFullFractionDR;#it{p}_{T,full} (GeV/#it{c}); #it{f}_{ch};#Delta R",nBinsPt,minPt,maxPt,nBinsFraction,0.,1.05,nBinsDR,0.,1.);
172 fOutput->Add(fh3JetPtFullFractionDR);
174 // =========== Switch on Sumw2 for all histos ===========
175 for (Int_t i=0; i<fOutput->GetEntries(); ++i) {
176 TH1 *h1 = dynamic_cast<TH1*>(fOutput->At(i));
181 THnSparse *hn = dynamic_cast<THnSparse*>(fOutput->At(i));
188 TH1::AddDirectory(oldStatus);
190 PostData(1, fOutput); // Post data for ALL output slots > 0 here.
193 //________________________________________________________________________
194 Bool_t AliAnalysisTaskEmcalDiJetAna::FillHistograms()
198 fh2CentRhoCh->Fill(fCent,fRhoChVal);
199 fh2CentRhoScaled->Fill(fCent,fRhoFullVal);
202 Int_t nJetsFull = GetNJets(fContainerFull);
203 for(Int_t ij=0; ij<nJetsFull; ij++) {
204 AliEmcalJet *jet = static_cast<AliEmcalJet*>(GetAcceptJetFromArray(ij, fContainerFull));
205 if(!jet) continue; //jet not selected
207 Double_t jetPt = GetJetPt(jet,0);
208 fh3PtEtaPhiJetFull->Fill(jetPt,jet->Eta(),jet->Phi());
212 Int_t nJetsCh = GetNJets(fContainerCharged);
213 for(Int_t ij=0; ij<nJetsCh; ij++) {
214 AliEmcalJet *jet = static_cast<AliEmcalJet*>(GetAcceptJetFromArray(ij, fContainerCharged));
215 if(!jet) continue; //jet not selected
217 Double_t jetPt = GetJetPt(jet,1);
218 fh3PtEtaPhiJetCharged->Fill(jetPt,jet->Eta(),jet->Phi());
226 //________________________________________________________________________
227 Bool_t AliAnalysisTaskEmcalDiJetAna::Run()
229 // Run analysis code here, if needed. It will be executed before FillHistograms().
231 //Check if event is selected (vertex & pile-up)
235 fHistTrialsSelEvents->Fill(fPtHardBin, fNTrials);
242 fRhoFullVal = GetRhoVal(fContainerFull);
243 fRhoChVal = GetRhoVal(fContainerCharged);
246 // MatchFullAndChargedJets();
247 if(fDoChargedCharged) CorrelateJets(1);
249 if(fDoMatchFullCharged) FillMatchFullChargedHistos(fContainerFull,fContainerCharged);
252 SetChargedFractionIndex();
256 return kTRUE; // If return kFALSE FillHistogram() will NOT be executed.
259 //________________________________________________________________________
260 void AliAnalysisTaskEmcalDiJetAna::CorrelateJets(const Int_t type) {
262 // Correlate jets and fill histos
267 if(type==0) { //full-full
268 typet = fContainerFull;
269 typea = fContainerFull;
271 else if(type==1) { //charged-charged
272 typet = fContainerCharged;
273 typea = fContainerCharged;
275 else if(type==2) { //full-charged
276 typet = fContainerFull;
277 typea = fContainerCharged;
280 AliWarning(Form("%s: type %d of dijet correlation not defined!",GetName(),type));
285 Int_t nJetsAssoc = 0;
287 nJetsTrig = GetNJets(fContainerFull);
288 nJetsAssoc = nJetsTrig;
291 nJetsTrig = GetNJets(fContainerCharged);
292 nJetsAssoc = nJetsTrig;
295 nJetsTrig = GetNJets(fContainerFull);
296 nJetsAssoc = GetNJets(fContainerCharged);
299 for(Int_t ijt=0; ijt<nJetsTrig; ijt++) {
301 AliEmcalJet *jetTrig = static_cast<AliEmcalJet*>(GetAcceptJetFromArray(ijt, typet));
303 continue; //jet not selected
305 Double_t jetTrigPt = GetJetPt(jetTrig,typet);
307 if(jetTrigPt<fPtMinTriggerJet)
310 for(Int_t ija=0; ija<nJetsAssoc; ija++) {
311 if(IsSameJet(ijt,ija,type)) continue;
313 AliEmcalJet *jetAssoc = static_cast<AliEmcalJet*>(GetAcceptJetFromArray(ija, typea));
317 Double_t jetAssocPt = GetJetPt(jetAssoc,typea);
319 if(jetTrigPt>jetAssocPt)
320 FillDiJetHistos(jetTrig,jetAssoc, type);
322 } // associate jet loop
327 //________________________________________________________________________
328 void AliAnalysisTaskEmcalDiJetAna::FillDiJetHistos(const AliEmcalJet *jet1, const AliEmcalJet *jet2, const Int_t mode) {
331 // mode: charged+neutral = 0
333 // full vs charged = 2
351 AliWarning(Form("%s: mode %d of dijet correlation not defined!",GetName(),mode));
355 Double_t jetTrigPt = GetJetPt(jet1,typet);
356 Double_t jetAssocPt = GetJetPt(jet2,typea);
358 Double_t deltaPhi = GetDeltaPhi(jet1->Phi(),jet2->Phi());
359 if(fDebug>10) Printf("deltaPhi:%.2f",deltaPhi);
361 Double_t kT = jetTrigPt*TMath::Sin(deltaPhi);
363 Double_t dijetEta = (jet1->Eta()+jet2->Eta())/2.;
366 Double_t diJetVars[6] = {jetTrigPt,jetAssocPt,deltaPhi,kT,dijetEta,fCent};
369 fhnDiJetVarsFull->Fill(diJetVars);
371 fhnDiJetVarsCh->Fill(diJetVars);
373 fhnDiJetVarsFullCharged->Fill(diJetVars);
377 //________________________________________________________________________
378 void AliAnalysisTaskEmcalDiJetAna::FillMatchFullChargedHistos(Int_t cFull,Int_t cCharged) {
380 // Match full to charged jets and fill histo
383 Int_t match = MatchFullAndChargedJets(cFull,cCharged);
385 if(fDebug>1) AliWarning(Form("%s: matching failed",GetName()));
389 for(int ig = 0;ig < GetNJets(cFull);++ig){
390 AliEmcalJet *jetFull = static_cast<AliEmcalJet*>(GetAcceptJetFromArray(ig, cFull));
391 if(!jetFull) continue;
393 AliEmcalJet *jetCh = jetFull->ClosestJet();
396 Double_t shFraction = GetFractionSharedPt(jetFull,jetCh);
397 if(fDebug>10) Printf("shared charged pT:%.2f",shFraction);
398 Double_t matchVars[7] = {
401 GetDeltaPhi(jetFull->Phi(),jetCh->Phi()),
402 jetFull->Eta()-jetCh->Eta(),
403 GetDeltaR(jetFull,jetCh),
404 shFraction,TMath::Min((Float_t)ig+0.5,2.5)
406 fhnMatchingFullCharged->Fill(matchVars);
408 }//loop over full jets
413 //________________________________________________________________________
414 Int_t AliAnalysisTaskEmcalDiJetAna::MatchFullAndChargedJets(Int_t cFull, Int_t cCharged) {
416 // Match charged jets to full jets
419 if(GetNJets(cFull)<1) {
420 if(fDebug>1) AliInfo(Form("%s: no full jets: %d", GetName(),GetNJets(cFull)));
424 if(GetNJets(cCharged)<1) {
425 if(fDebug>1) AliInfo(Form("%s: no charged jets: %d", GetName(),GetNJets(cCharged)));
429 TClonesArray *cJetsFull = GetJetArray(cFull);
430 TClonesArray *cJetsCharged = GetJetArray(cCharged);
433 if(fDebug>1) AliInfo(Form("%s: no full jet array",GetName()));
438 if(fDebug>1) AliInfo(Form("%s: no charged jet array",GetName()));
444 MatchJetsGeo(cFull, cCharged, fDebug);
447 if(fDebug>1) AliInfo(Form("%s: Matching already done before",GetName()));
453 //_______________________________________________________________________
454 void AliAnalysisTaskEmcalDiJetAna::Terminate(Option_t *)
456 // Called once at the end of the analysis.