]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalDiJetBase.cxx
from Chris
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / UserTasks / AliAnalysisTaskEmcalDiJetBase.cxx
1 //
2 // Dijet base analysis task.
3 //
4 // Author: M.Verweij
5
6 #include <TClonesArray.h>
7 #include <TH1F.h>
8 #include <TH2F.h>
9 #include <TH3F.h>
10 #include <THnSparse.h>
11 #include <TList.h>
12 #include <TLorentzVector.h>
13 #include <TProfile.h>
14 #include <TChain.h>
15 #include <TSystem.h>
16 #include <TFile.h>
17 #include <TKey.h>
18
19 #include "AliVCluster.h"
20 #include "AliVTrack.h"
21 #include "AliEmcalJet.h"
22 #include "AliRhoParameter.h"
23 #include "AliLog.h"
24 #include "AliEmcalParticle.h"
25 #include "AliMCEvent.h"
26 #include "AliGenPythiaEventHeader.h"
27 #include "AliAODMCHeader.h"
28 #include "AliMCEvent.h"
29 #include "AliAnalysisManager.h"
30 #include "AliJetContainer.h"
31
32 #include "AliAnalysisTaskEmcalDiJetBase.h"
33
34 ClassImp(AliAnalysisTaskEmcalDiJetBase)
35
36 //________________________________________________________________________
37 AliAnalysisTaskEmcalDiJetBase::AliAnalysisTaskEmcalDiJetBase() : 
38   AliAnalysisTaskEmcalJet("AliAnalysisTaskEmcalDiJetBase", kTRUE),
39   fDebug(kFALSE),
40   fJetCorrelationType(kCorrelateAll),
41   fJetFullChargedMatchingType(kFraction),
42   fTriggerClass(""),
43   fContainerCharged(1),
44   fContainerFull(0),
45   fContainerChargedMC(3),
46   fContainerFullMC(2),
47   fRhoType(0),
48   fRhoChVal(0),
49   fRhoFullVal(0),
50   fDoChargedCharged(kTRUE),
51   fDoFullCharged(kTRUE),
52   fDoFullFull(kFALSE),
53   fPtMinTriggerJet(10.),
54   fMinFractionShared(0.5),
55   fMatchingDone(kFALSE),
56   faFullFracIndex(0),
57   faFullFracIndexMC(0),
58   fhNEvents(0),
59   fHistTrialsSelEvents(0)
60 {
61   // Default constructor.
62
63   
64   SetMakeGeneralHistograms(kTRUE);
65
66 }
67
68 //________________________________________________________________________
69 AliAnalysisTaskEmcalDiJetBase::AliAnalysisTaskEmcalDiJetBase(const char *name) : 
70   AliAnalysisTaskEmcalJet(name, kTRUE),
71   fDebug(kFALSE),
72   fJetCorrelationType(kCorrelateAll),
73   fJetFullChargedMatchingType(kFraction),
74   fTriggerClass(""),
75   fContainerCharged(1),
76   fContainerFull(0),
77   fContainerChargedMC(3),
78   fContainerFullMC(2),
79   fRhoType(0),
80   fRhoChVal(0),
81   fRhoFullVal(0),
82   fDoChargedCharged(kTRUE),
83   fDoFullCharged(kTRUE),
84   fDoFullFull(kFALSE),
85   fPtMinTriggerJet(10.),
86   fMinFractionShared(0.5),
87   fMatchingDone(kFALSE),
88   faFullFracIndex(0),
89   faFullFracIndexMC(0),
90   fhNEvents(0),
91   fHistTrialsSelEvents(0)
92 {
93   // Standard constructor.
94
95   SetMakeGeneralHistograms(kTRUE);
96
97 }
98
99 //________________________________________________________________________
100 AliAnalysisTaskEmcalDiJetBase::~AliAnalysisTaskEmcalDiJetBase()
101 {
102   // Destructor.
103 }
104
105 //________________________________________________________________________
106 Bool_t AliAnalysisTaskEmcalDiJetBase::SelectEvent() {
107   //
108   // Decide if event should be selected for analysis
109   //
110
111   fhNEvents->Fill(3.5);
112
113   if(!fTriggerClass.IsNull()) {
114     //Check if requested trigger was fired
115     TString firedTrigClass = InputEvent()->GetFiredTriggerClasses();
116     if(!firedTrigClass.Contains(fTriggerClass))
117       return kFALSE;
118     if(fTriggerClass.Contains("J2") && firedTrigClass.Contains("J1")) //only accept J2 triggers which were not fired by J1 as well
119       return kFALSE;
120   }
121
122    fhNEvents->Fill(1.5);
123
124   fHistTrialsSelEvents->Fill(fPtHardBin, fNTrials);
125   
126   return kTRUE;
127
128 }
129
130 //________________________________________________________________________
131 void AliAnalysisTaskEmcalDiJetBase::UserCreateOutputObjects()
132 {
133   // Create user output.
134
135   AliAnalysisTaskEmcalJet::UserCreateOutputObjects();
136
137   Bool_t oldStatus = TH1::AddDirectoryStatus();
138   TH1::AddDirectory(kFALSE);
139
140   fhNEvents = new TH1F("fhNEvents","fhNEvents;selection;N_{evt}",5,0,5);
141   fOutput->Add(fhNEvents);
142
143   //Pythia info
144   fHistTrialsSelEvents = new TH1F("fHistTrialsSelEvents", "fHistTrialsSelEvents", 12, 0, 12);
145   fHistTrialsSelEvents->GetXaxis()->SetTitle("p_{T} hard bin");
146   fHistTrialsSelEvents->GetYaxis()->SetTitle("trials");
147   fOutput->Add(fHistTrialsSelEvents);
148
149   TH1::AddDirectory(oldStatus);
150
151   PostData(1, fOutput); // Post data for ALL output slots > 0 here.
152 }
153
154 //________________________________________________________________________
155 Bool_t AliAnalysisTaskEmcalDiJetBase::IsSameJet(const Int_t ijt, const Int_t ija, const Int_t type, const Bool_t isMC) {
156    //check if two jets are the same one
157
158    Bool_t bSame = kFALSE;
159
160    if(type<2 && ijt==ija)
161      bSame = kTRUE;
162    if(type==2) {
163
164      if(fJetFullChargedMatchingType==kFraction) {
165        if(isMC && faFullFracIndexMC.At(ijt)==ija)
166          bSame = kTRUE;
167        else if(!isMC && faFullFracIndex.At(ijt)==ija)
168          bSame = kTRUE;
169      }
170      else if(fJetFullChargedMatchingType==kGeo) {
171        Int_t contFull = fContainerFull;
172        Int_t contChar = fContainerCharged;
173        if(isMC) {
174          contFull = fContainerFullMC;
175          contChar = fContainerChargedMC;
176        }
177        AliEmcalJet *fullJet = static_cast<AliEmcalJet*>(GetAcceptJetFromArray(ijt, contFull));
178        AliEmcalJet *chJet   = static_cast<AliEmcalJet*>(GetAcceptJetFromArray(ija, contChar));
179        AliEmcalJet *matchJet = fullJet->ClosestJet();
180        if(chJet==matchJet)
181          bSame = kTRUE;
182      }
183      else if(fJetFullChargedMatchingType==kNoMatching) {
184        return kFALSE;
185      }
186      else{
187        AliWarning(Form("%s: matching type unknown", GetName()));
188      }
189    }
190
191    return bSame;
192  }
193
194
195 //________________________________________________________________________
196 Double_t AliAnalysisTaskEmcalDiJetBase::GetJetPt(const AliEmcalJet *jet, const Int_t type) {
197
198   if(!jet) return -99;
199
200   if(type==0)
201     return jet->Pt() - fRhoFullVal * jet->Area();
202   else if(type==1)
203     return jet->Pt() - fRhoChVal * jet->Area();
204   else
205     return jet->Pt();
206   
207 }
208
209 //________________________________________________________________________
210 Double_t AliAnalysisTaskEmcalDiJetBase::GetZ(const AliVParticle *trk, const AliEmcalJet *jet)          const
211 {  
212   // Get Z of constituent trk
213
214   return GetZ(trk->Px(),trk->Py(),trk->Pz(),jet->Px(),jet->Py(),jet->Pz());
215 }
216
217 //________________________________________________________________________
218 Double_t AliAnalysisTaskEmcalDiJetBase::GetZ(const Double_t trkPx, const Double_t trkPy, const Double_t trkPz, const Double_t jetPx, const Double_t jetPy, const Double_t jetPz) const
219 {
220   // 
221   // Get the z of a constituent inside of a jet
222   //
223
224   Double_t pJetSq = jetPx*jetPx+jetPy*jetPy+jetPz*jetPz;
225
226   if(pJetSq>0.)
227     return (trkPx*jetPx+trkPy*jetPy+trkPz*jetPz)/pJetSq;
228   else {
229     AliWarning(Form("%s: strange, pjet*pjet seems to be zero pJetSq: %f",GetName(), pJetSq)); 
230     return 0;
231   }
232 }
233
234 //________________________________________________________________________
235 Double_t AliAnalysisTaskEmcalDiJetBase::GetDeltaR(const AliEmcalJet* jet1, const AliEmcalJet* jet2) const {
236   //
237   // Helper function to calculate the distance between two jets
238   //
239
240   Double_t dPhi = jet1->Phi() - jet2->Phi();
241   if(dPhi>TMath::Pi())dPhi = dPhi - 2.*TMath::Pi();
242   if(dPhi<(-1.*TMath::Pi()))dPhi = dPhi + 2.*TMath::Pi();
243   Double_t dEta = jet1->Eta() - jet2->Eta();
244   Double_t dR = TMath::Sqrt(dPhi*dPhi+dEta*dEta);
245   return dR;
246 }
247
248 //________________________________________________________________________
249 Double_t AliAnalysisTaskEmcalDiJetBase::GetDeltaPhi(const AliEmcalJet* jet1, const AliEmcalJet* jet2) {
250   //
251   // Calculate azimuthal angle between the axises of the jets
252   //
253
254   return GetDeltaPhi(jet1->Phi(),jet2->Phi());
255
256 }
257
258 //________________________________________________________________________
259 Double_t AliAnalysisTaskEmcalDiJetBase::GetDeltaPhi(Double_t phi1,Double_t phi2) {
260   //
261   // Calculate azimuthal angle between the axises of the jets
262   //
263
264   Double_t dPhi = phi1-phi2;
265
266   if(dPhi <-0.5*TMath::Pi())  dPhi += TMath::TwoPi();
267   if(dPhi > 1.5*TMath::Pi())  dPhi -= TMath::TwoPi();
268
269   return dPhi;
270 }
271
272 //________________________________________________________________________
273 Double_t AliAnalysisTaskEmcalDiJetBase::GetFractionSharedPt(const AliEmcalJet *jetFull, const AliEmcalJet *jetCharged) const
274 {
275   //
276   // Get fraction of shared pT between matched full and charged jet
277   // Uses charged jet pT as baseline: fraction = \Sum_{const,full jet} pT,const,i / pT,jet,ch
278   //
279
280   Double_t fraction = 0.;
281   Double_t jetPtCh = jetCharged->Pt();
282  
283   if(jetPtCh>0) {
284
285     if(fDebug>10)  AliInfo(Form("%s: nConstituents: %d, ch: %d  chne: %d ne: %d",GetName(),jetFull->GetNumberOfConstituents(),jetCharged->GetNumberOfTracks(),jetFull->GetNumberOfTracks(),jetFull->GetNumberOfClusters()));
286     
287     Double_t sumPt = 0.;
288     AliVParticle *vpf = 0x0;
289     Int_t iFound = 0;
290     for(Int_t icc=0; icc<jetCharged->GetNumberOfTracks(); icc++) {
291       Int_t idx = (Int_t)jetCharged->TrackAt(icc);
292       iFound = 0;
293       for(Int_t icf=0; icf<jetFull->GetNumberOfTracks(); icf++) {
294         if(idx == jetFull->TrackAt(icf) && iFound==0 ) {
295           iFound=1;
296           vpf = static_cast<AliVParticle*>(jetFull->TrackAt(icf, fTracks));
297           if(!vpf) continue;
298           if(vpf->Charge()!=0)
299             sumPt += vpf->Pt();
300           continue;
301         }
302       }
303     }
304     
305     fraction = sumPt/jetPtCh;
306   }
307
308   if(fDebug>10) AliInfo(Form("%s: charged shared fraction: %.2f",GetName(),fraction));
309
310   return fraction;
311
312 }
313
314 //________________________________________________________________________
315 void AliAnalysisTaskEmcalDiJetBase::MatchJetsGeo(Int_t cFull, Int_t cCharged,
316                                                  Int_t iDebug, Float_t maxDist, Int_t type) {
317
318   //
319   // Match the full jets to the corresponding charged jets
320   // Translation of AliAnalysisHelperJetTasks::GetClosestJets to AliEmcalJet objects
321   // type: 0 = use acceptance cuts of container  1 = allow 0.1 one more for cCharged(MC) in eta 2 = allow 0.1 more in eta and phi for cCharged(MC)
322
323   const int kMode = 3;
324
325   const Int_t nChJets   = GetNJets(cCharged);
326   const Int_t nFullJets = GetNJets(cFull);
327
328   if(nFullJets==0 || nChJets==0) return;
329
330   TArrayI faChNeMatchIndex;
331   faChNeMatchIndex.Set(nChJets+1);
332
333   TArrayI faChMatchIndex;
334   faChMatchIndex.Set(nFullJets+1);
335
336   static TArrayS iFlag(nChJets*nFullJets);
337   if(iFlag.GetSize()<(nChJets*nFullJets)){
338     iFlag.Set(nChJets*nFullJets+1);
339   }
340   iFlag.Reset(0);
341
342   AliJetContainer *contCh = GetJetContainer(cCharged);
343
344   // find the closest distance to the full jet
345   for(int ifu = 0;ifu<nFullJets;ifu++){
346
347     AliEmcalJet *fullJet = static_cast<AliEmcalJet*>(GetAcceptJetFromArray(ifu, cFull));
348     if(!fullJet) continue;
349
350     Float_t dist = maxDist;
351     
352     for(int ich = 0;ich<nChJets;ich++){
353       AliEmcalJet *chJet = 0x0;
354       if(type==0)
355         chJet = static_cast<AliEmcalJet*>(GetAcceptJetFromArray(ich, cCharged));
356       else {
357         chJet = static_cast<AliEmcalJet*>(GetJetFromArray(ich, cCharged));
358         if(!chJet) continue;;
359         if(type>0) {
360           if(chJet->Eta()<(contCh->GetJetEtaMin()-0.1) || chJet->Eta()>(contCh->GetJetEtaMax()+0.1))
361             continue;
362           if(type==2) {
363             if(chJet->Phi()<(contCh->GetJetPhiMin()-0.1) || chJet->Phi()>(contCh->GetJetPhiMax()+0.1))
364               continue;
365           }
366         }
367       }
368       if(!chJet)
369         continue;
370
371       Double_t frac = GetFractionSharedPt(fullJet,chJet);
372       Double_t dR = GetDeltaR(fullJet,chJet);
373       if(dR<dist){
374         faChMatchIndex[ifu]=ich;
375         dist = dR;
376       }
377       if(iDebug>10) Printf("Distance (%d)--(%d) %3.3f frac:%.2f",ifu,ich,dR,frac);
378     }
379     if(faChMatchIndex[ifu]>=0) iFlag[ifu*nChJets+faChMatchIndex[ifu]]+=1;//ich closest to ifu
380     if(iDebug>10) Printf("Full Distance (%d)--(%d) %3.3f flag[%d] = %d",ifu,faChMatchIndex[ifu],dist,ifu*nChJets+faChMatchIndex[ifu],iFlag[ifu*nChJets+faChMatchIndex[ifu]]);
381     
382     // reset...
383     faChMatchIndex[ifu]=-1;
384
385            
386   }//full jet loop
387
388
389   // other way around
390   for(int ich = 0;ich<nChJets;ich++){
391     AliEmcalJet *chJet = 0x0;
392     if(type==0)
393       chJet = static_cast<AliEmcalJet*>(GetAcceptJetFromArray(ich, cCharged));
394     else {
395       chJet = static_cast<AliEmcalJet*>(GetJetFromArray(ich, cCharged));
396       if(!chJet) continue;;
397       if(type>0) {
398         if(chJet->Eta()<(contCh->GetJetEtaMin()-0.1) || chJet->Eta()>(contCh->GetJetEtaMax()+0.1))
399           continue;
400         if(type==2) {
401           if(chJet->Phi()<(contCh->GetJetPhiMin()-0.1) || chJet->Phi()>(contCh->GetJetPhiMax()+0.1))
402             continue;
403         }
404       }
405     }
406     if(!chJet)
407       continue;
408
409     Float_t dist = maxDist;
410     for(int ifu = 0;ifu<nFullJets;ifu++){
411       AliEmcalJet *fullJet = static_cast<AliEmcalJet*>(GetAcceptJetFromArray(ifu, cFull));
412       if(!fullJet)
413         continue;
414
415       Double_t dR = GetDeltaR(fullJet,chJet); 
416       if(dR<dist){
417         faChNeMatchIndex[ich]=ifu;
418         dist = dR;
419       }   
420     }
421     if(faChNeMatchIndex[ich]>=0) iFlag[faChNeMatchIndex[ich]*nChJets+ich]+=2;//ifu closest to ich
422     if(iDebug>10) Printf("Other way Distance (%d)--(%d) %3.3f flag[%d] = %d",faChNeMatchIndex[ich],ich,dist,faChNeMatchIndex[ich]*nChJets+ich,iFlag[faChNeMatchIndex[ich]*nChJets+ich]);
423
424     // reset...
425     faChNeMatchIndex[ich]=-1;
426     
427   }
428   
429   
430   // check for "true" correlations
431   for(int ifu = 0;ifu<nFullJets;ifu++){
432     for(int ich = 0;ich<nChJets;ich++){
433       if(iDebug>10) AliInfo(Form("%s: Flag[%d][%d] %d ",GetName(),ifu,ich,iFlag[ifu*nChJets+ich]));
434       
435       if(kMode==3){
436         // we have a uniqe correlation
437         if(iFlag[ifu*nChJets+ich]==3){
438
439           AliEmcalJet *chJet = static_cast<AliEmcalJet*>(GetJetFromArray(ich, cCharged));
440           AliEmcalJet *fullJet = static_cast<AliEmcalJet*>(GetJetFromArray(ifu, cFull));
441           Double_t dR = GetDeltaR(fullJet,chJet); 
442
443           if(iDebug>10) Printf("closest jets %d  %d  dR =  %f",ich,ifu,dR);
444
445           chJet->SetClosestJet(fullJet,dR);
446           fullJet->SetClosestJet(chJet,dR);
447
448         }
449       }
450     }
451   }
452
453   fMatchingDone = kTRUE;
454   
455 }
456
457 //________________________________________________________________________
458 void AliAnalysisTaskEmcalDiJetBase::SetChargedFractionIndex() {
459
460   // take each full jet and set the index of the charged jet with the largest shared charged fraction
461
462   const Int_t nJetsCh   = GetNJets(fContainerCharged);
463   const Int_t nJetsFull = GetNJets(fContainerFull);
464   faFullFracIndex.Set(nJetsFull+1);
465   faFullFracIndex.Reset(-1);
466
467   AliJetContainer  *cont = GetJetContainer(fContainerFull); 
468   Float_t radius =  cont->GetJetRadius();
469
470   for(Int_t ifu = 0; ifu<nJetsFull; ifu++) {
471     Double_t frac = 0.;
472     Double_t dist = 10.;
473     AliEmcalJet *jetFull = static_cast<AliEmcalJet*>(GetAcceptJetFromArray(ifu, fContainerFull));
474     if(!jetFull) {
475       faFullFracIndex.SetAt(-1,ifu);
476       continue;
477     }
478
479     for(Int_t ich = 0; ich<nJetsCh; ich++) {
480       AliEmcalJet *jetCh = static_cast<AliEmcalJet*>(GetAcceptJetFromArray(ich, fContainerCharged));
481       if(!jetCh)
482         continue;
483       Double_t tmpFrac = GetFractionSharedPt(jetFull,jetCh);
484       dist = GetDeltaR(jetFull,jetCh);
485       if(tmpFrac>frac && dist<radius) {
486         frac = tmpFrac;
487         faFullFracIndex.SetAt(ich,ifu);
488       }
489     }
490
491   }
492
493 }
494
495 //________________________________________________________________________
496 void AliAnalysisTaskEmcalDiJetBase::SetChargedFractionIndexMC() {
497
498   // take each full jet and set the index of the charged jet with the largest shared charged fraction
499
500   const Int_t nJetsCh   = GetNJets(fContainerChargedMC);
501   const Int_t nJetsFull = GetNJets(fContainerFullMC);
502   faFullFracIndexMC.Set(nJetsFull);
503   faFullFracIndexMC.Reset(-1);
504
505   AliJetContainer  *cont = GetJetContainer(fContainerFullMC); 
506   Float_t radius =  cont->GetJetRadius();
507
508   for(Int_t ifu = 0; ifu<nJetsFull; ifu++) {
509     Double_t frac = 0.;
510     Double_t dist = 10.;
511     AliEmcalJet *jetFull = static_cast<AliEmcalJet*>(GetAcceptJetFromArray(ifu, fContainerFullMC));
512     if(!jetFull) {
513       faFullFracIndexMC.SetAt(-1,ifu);
514       continue;
515     }
516
517     for(Int_t ich = 0; ich<nJetsCh; ich++) {
518       AliEmcalJet *jetCh = static_cast<AliEmcalJet*>(GetAcceptJetFromArray(ich, fContainerChargedMC));
519       if(!jetCh)
520         continue;
521       Double_t tmpFrac = GetFractionSharedPt(jetFull,jetCh);
522       dist = GetDeltaR(jetFull,jetCh);
523       if(tmpFrac>frac && dist<radius) {
524         frac = tmpFrac;
525         faFullFracIndexMC.SetAt(ich,ifu);
526       }
527     }
528
529   }
530
531 }
532
533 //_______________________________________________________________________
534 AliEmcalJet* AliAnalysisTaskEmcalDiJetBase::GetLeadingJetOppositeHemisphere(const Int_t type, const Int_t typea, const AliEmcalJet *jetTrig) {
535
536   // Get leading jet in opposite hemisphere from trigger jet
537   // type = correlation type
538   // typea = container of associated jets
539
540   Int_t nJetsAssoc = GetNJets(typea);
541   Double_t ptLead = -999;
542   Int_t    iJetLead = -1;
543   for(Int_t ija=0; ija<nJetsAssoc; ija++) {
544
545     AliEmcalJet *jetAssoc = NULL;
546     if(type==0) {
547       jetAssoc = static_cast<AliEmcalJet*>(GetJetFromArray(ija, typea));
548       if(TMath::Abs(jetAssoc->Eta())>0.5)
549         jetAssoc = NULL;
550     }
551     else
552       jetAssoc = static_cast<AliEmcalJet*>(GetAcceptJetFromArray(ija, typea));
553
554     if(!jetAssoc)
555       continue;
556
557     Double_t dPhi = GetDeltaPhi(jetTrig,jetAssoc);
558     Double_t phiMin = 0.5*TMath::Pi();
559     Double_t phiMax = 1.5*TMath::Pi();
560     if(dPhi<phiMin || dPhi>phiMax)
561       continue;
562
563     Double_t jetAssocPt = GetJetPt(jetAssoc,typea);
564
565     if(jetAssocPt>ptLead) {
566       ptLead = jetAssocPt;
567       iJetLead = ija;
568     }
569
570   }
571
572   AliEmcalJet *jetAssocLead = NULL;
573   if(iJetLead>-1)
574     jetAssocLead = static_cast<AliEmcalJet*>(GetJetFromArray(iJetLead, typea));
575
576   return jetAssocLead;
577
578 }
579
580 //_______________________________________________________________________
581 AliEmcalJet* AliAnalysisTaskEmcalDiJetBase::GetSecondLeadingJetOppositeHemisphere(const Int_t type, const Int_t typea, const AliEmcalJet *jetTrig) {
582
583   // Get leading jet in opposite hemisphere from trigger jet
584   // type = correlation type
585   // typea = container of associated jets
586
587   Int_t nJetsAssoc = GetNJets(typea);
588   Double_t ptLead = -999;
589   Int_t    iJetLead = -1;
590   Int_t    iJetLead2 = -1;
591   for(Int_t ija=0; ija<nJetsAssoc; ija++) {
592
593     AliEmcalJet *jetAssoc = NULL;
594     if(type==0) {
595       jetAssoc = static_cast<AliEmcalJet*>(GetJetFromArray(ija, typea));
596       if(TMath::Abs(jetAssoc->Eta())>0.5)
597         jetAssoc = NULL;
598     }
599     else
600       jetAssoc = static_cast<AliEmcalJet*>(GetAcceptJetFromArray(ija, typea));
601
602     if(!jetAssoc)
603       continue;
604
605     Double_t dPhi = GetDeltaPhi(jetTrig,jetAssoc);
606     Double_t phiMin = 0.5*TMath::Pi();
607     Double_t phiMax = 1.5*TMath::Pi();
608     if(dPhi<phiMin || dPhi>phiMax)
609       continue;
610
611     Double_t jetAssocPt = GetJetPt(jetAssoc,typea);
612
613     if(jetAssocPt>ptLead) {
614       iJetLead2 = iJetLead;
615       ptLead = jetAssocPt;
616       iJetLead = ija;
617     }
618
619   }
620
621   AliEmcalJet *jetAssocLead2 = NULL;
622   if(iJetLead2>-1)
623     jetAssocLead2 = static_cast<AliEmcalJet*>(GetJetFromArray(iJetLead2, typea));
624
625   return jetAssocLead2;
626
627 }
628
629 //________________________________________________________________________
630 Bool_t AliAnalysisTaskEmcalDiJetBase::RetrieveEventObjects() {
631   //
632   // Retrieve objects from event.
633   //
634
635   if (!AliAnalysisTaskEmcalJet::RetrieveEventObjects())
636     return kFALSE;
637
638   if(fRhoType==0) {
639     fRhoFullVal = 0.;
640     fRhoChVal = 0.;
641   }
642   if(fRhoType==1) {
643     fRhoFullVal = GetRhoVal(fContainerFull);
644     fRhoChVal = GetRhoVal(fContainerCharged);
645   }
646
647   return kTRUE;
648 }
649
650 //_______________________________________________________________________
651 void AliAnalysisTaskEmcalDiJetBase::Terminate(Option_t *) 
652 {
653   // Called once at the end of the analysis.
654 }