]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGJE/AliAnalysisTaskJetCore.cxx
Fixes for coverity.
[u/mrichter/AliRoot.git] / PWGJE / AliAnalysisTaskJetCore.cxx
index 636971497b725c7e31b9905003c75af4bd5210d1..a9f92cb8650b3e8e5780106ffa4521d6c5fe714b 100644 (file)
@@ -1,4 +1,3 @@
-
 // ******************************************
 // This task computes several jet observables like 
 // the fraction of energy in inner and outer coronnas,
@@ -32,7 +31,7 @@
 #include "TH3F.h"
 #include "THnSparse.h"
 #include "TCanvas.h"
-
+#include "TRandom3.h"
 #include "AliLog.h"
 
 #include "AliAnalysisTask.h"
@@ -45,6 +44,7 @@
 #include "AliAnalysisHelperJetTasks.h"
 #include "AliInputEventHandler.h"
 #include "AliAODJetEventBackground.h"
+#include "AliAODMCParticle.h"
 #include "AliAnalysisTaskFastEmbedding.h"
 #include "AliAODEvent.h"
 #include "AliAODHandler.h"
@@ -52,6 +52,9 @@
 
 #include "AliAnalysisTaskJetCore.h"
 
+using std::cout;
+using std::endl;
+
 ClassImp(AliAnalysisTaskJetCore)
 
 AliAnalysisTaskJetCore::AliAnalysisTaskJetCore() :
@@ -70,26 +73,50 @@ fVtxZMax(10.),
 fEvtClassMin(0),
 fEvtClassMax(4),
 fFilterMask(0),
+fFilterMaskBestPt(0),
+fFilterType(0),
 fRadioFrac(0.2),
 fMinDist(0.1),
 fCentMin(0.),
 fCentMax(100.),
 fNInputTracksMin(0),
 fNInputTracksMax(-1),
+fRequireITSRefit(0),
+fApplySharedClusterCut(0),
 fAngStructCloseTracks(0),
 fCheckMethods(0),
 fDoEventMixing(0), 
+fFlagPhiBkg(0),
+fFlagEtaBkg(0),
+fFlagJetHadron(0),
+fFrac(0.8),
+fTTLowRef(11),
+fTTUpRef(13),
+fTTLowSig(15),
+fTTUpSig(19),
+fHardest(0),
+fFlagRandom(0),
+fFlagOnlyRecoil(0),
+fFlagOnlyHardest(1),
+fTrackTypeRec(kTrackUndef),
+fRPAngle(0),
+fNRPBins(50),
+fSemigoodCorrect(0),
+fHolePos(4.71),
+fHoleWidth(0.2),
 fJetEtaMin(-.5),
 fJetEtaMax(.5),
-fNevents(0x0),
-fTindex(0x0),
-fTrigBufferIndex(0x0),
+fNevents(0),
+fTindex(0),
+fTrigBufferIndex(0),
+fCountAgain(0), 
 fJetPtMin(20.),
 fJetTriggerExcludeMask(AliAODJet::kHighTrackPtTriggered),
 fJetPtFractionMin(0.5),
 fNMatchJets(4),
 fMatchMaxDist(0.8),
 fKeepJets(kFALSE),
+fRunAnaAzimuthalCorrelation(kFALSE),
 fkNbranches(2),
 fkEvtClasses(12),
 fOutputList(0x0),
@@ -105,8 +132,8 @@ fh2JetCoreMethod1C30(0x0),
 fh2JetCoreMethod2C30(0x0),
 fh2JetCoreMethod1C60(0x0),
 fh2JetCoreMethod2C60(0x0),
-fh2JetTrackC10(0x0),
-fh2JetTrackC20(0x0),
+fh3JetTrackC3060(0x0),
+fh3JetTrackC20(0x0),
 fh2AngStructpt1C10(0x0),
 fh2AngStructpt2C10(0x0),
 fh2AngStructpt3C10(0x0),
@@ -123,75 +150,21 @@ fh2AngStructpt1C60(0x0),
 fh2AngStructpt2C60(0x0),
 fh2AngStructpt3C60(0x0),
 fh2AngStructpt4C60(0x0),
-fh2JetsumHT3R2a(0x0),
-fh2JetsumHT3R2ap(0x0),
-fh2JetsumHT3R4a(0x0),
-fh2JetsumHT3R4ap(0x0),
-fh2JetsumHT3R6a(0x0),
-fh2JetsumHT3R6ap(0x0),
-fh2JetsumHT3R8a(0x0),
-fh2JetsumHT3R8ap(0x0),
-fh2JetsumHT3R10a(0x0),
-fh2JetsumHT3R10ap(0x0),
-fh2JetsumHT3R2aa(0x0),
-fh2JetsumHT3R2aap(0x0),
-fh2JetsumHT3R4aa(0x0),
-fh2JetsumHT3R4aap(0x0),
-fh2JetsumHT3R6aa(0x0),
-fh2JetsumHT3R6aap(0x0),
-fh2JetsumHT3R8aa(0x0),
-fh2JetsumHT3R8aap(0x0),
-fh2JetsumHT3R10aa(0x0),
-fh2JetsumHT3R10aap(0x0),
-fh2JetsumHT3R2aaa(0x0),
-fh2JetsumHT3R2aaap(0x0),
-fh2JetsumHT3R4aaa(0x0),
-fh2JetsumHT3R4aaap(0x0),
-fh2JetsumHT3R6aaa(0x0),
-fh2JetsumHT3R6aaap(0x0),
-fh2JetsumHT3R8aaa(0x0),
-fh2JetsumHT3R8aaap(0x0),
-fh2JetsumHT3R10aaa(0x0),
-fh2JetsumHT3R10aaap(0x0),
-fh2JetsumHT3R2b(0x0),
-fh2JetsumHT3R2bp(0x0),
-fh2JetsumHT3R4b(0x0),
-fh2JetsumHT3R4bp(0x0),
-fh2JetsumHT3R6b(0x0),
-fh2JetsumHT3R6bp(0x0),
-fh2JetsumHT3R8b(0x0),
-fh2JetsumHT3R8bp(0x0),
-fh2JetsumHT3R10b(0x0),
-fh2JetsumHT3R10bp(0x0),
-fh2JetsumHT3R2bb(0x0),
-fh2JetsumHT3R2bbp(0x0),
-fh2JetsumHT3R4bb(0x0),
-fh2JetsumHT3R4bbp(0x0),
-fh2JetsumHT3R6bb(0x0),
-fh2JetsumHT3R6bbp(0x0),
-fh2JetsumHT3R8bb(0x0),
-fh2JetsumHT3R8bbp(0x0),
-fh2JetsumHT3R10bb(0x0),
-fh2JetsumHT3R10bbp(0x0),
-fh2JetsumHT3R2bbb(0x0),
-fh2JetsumHT3R2bbbp(0x0),
-fh2JetsumHT3R4bbb(0x0),
-fh2JetsumHT3R4bbbp(0x0),
-fh2JetsumHT3R6bbb(0x0),
-fh2JetsumHT3R6bbbp(0x0),
-fh2JetsumHT3R8bbb(0x0),
-fh2JetsumHT3R8bbbp(0x0),
-fh2JetsumHT3R10bbb(0x0),
-fh2JetsumHT3R10bbbp(0x0),
+fh1TrigRef(0x0),
+fh1TrigSig(0x0),
 fh2Ntriggers(0x0),
-fh2JetDensity(0x0),
-fh2JetDensityA4(0x0),
-fh3spectriggeredC10(0x0),
-fh3spectriggeredC20(0x0),
-fh3spectriggeredC3060(0x0),
-fh3specbiased(0x0),
-fh3spectot(0x0),
-fh3spectotb(0x0)
+fh2Ntriggers2C10(0x0),
+fh2Ntriggers2C20(0x0), 
+fh3JetDensity(0x0),
+fh3JetDensityA4(0x0),
+fh2RPJetsC10(0x0),
+fh2RPJetsC20(0x0),
+fh2RPTC10(0x0),
+fh2RPTC20(0x0), 
+fHJetSpec(0x0),
+fhTTPt(0x0),
+fHJetPhiCorr(0x0),
+fRandom(0x0)
  
 {
    // default Constructor
@@ -199,7 +172,7 @@ fh3spectotb(0x0)
 
  // Trigger buffer.
    for(Int_t i=0; i<10; i++) {
-               for(Int_t j=0; j<7; j++) {
+               for(Int_t j=0; j<6; j++) {
                        fTrigBuffer[i][j]=0;
                }                               
        }       
@@ -231,26 +204,50 @@ fVtxZMax(10.),
 fEvtClassMin(0),
 fEvtClassMax(4),
 fFilterMask(0),
+fFilterMaskBestPt(0),
+fFilterType(0),
 fRadioFrac(0.2),
 fMinDist(0.1),
 fCentMin(0.),
 fCentMax(100.),
 fNInputTracksMin(0),
 fNInputTracksMax(-1),
+fRequireITSRefit(0),
+fApplySharedClusterCut(0),
 fAngStructCloseTracks(0),
 fCheckMethods(0),
 fDoEventMixing(0),
+fFlagPhiBkg(0),
+fFlagEtaBkg(0),
+fFlagJetHadron(0),
+fFrac(0.8),
+fTTLowRef(11),
+fTTUpRef(13),
+fTTLowSig(15),
+fTTUpSig(19),
+fHardest(0),
+fFlagRandom(0),
+fFlagOnlyRecoil(0),
+fFlagOnlyHardest(1),
+fTrackTypeRec(kTrackUndef),
+fRPAngle(0),
+fNRPBins(50),
+fSemigoodCorrect(0),
+fHolePos(4.71),
+fHoleWidth(0.2),
 fJetEtaMin(-.5),
 fJetEtaMax(.5),
-fNevents(0x0),
-fTindex(0x0),
-fTrigBufferIndex(0x0),
+fNevents(0),
+fTindex(0),
+fTrigBufferIndex(0),
+fCountAgain(0),
 fJetPtMin(20.),
 fJetTriggerExcludeMask(AliAODJet::kHighTrackPtTriggered),
 fJetPtFractionMin(0.5),
 fNMatchJets(4),
 fMatchMaxDist(0.8),
 fKeepJets(kFALSE),
+fRunAnaAzimuthalCorrelation(kFALSE),
 fkNbranches(2),
 fkEvtClasses(12),
 fOutputList(0x0),
@@ -266,8 +263,8 @@ fh2JetCoreMethod1C30(0x0),
 fh2JetCoreMethod2C30(0x0),
 fh2JetCoreMethod1C60(0x0),
 fh2JetCoreMethod2C60(0x0),
-fh2JetTrackC10(0x0),
-fh2JetTrackC20(0x0),
+fh3JetTrackC3060(0x0),
+fh3JetTrackC20(0x0),
 fh2AngStructpt1C10(0x0),
 fh2AngStructpt2C10(0x0),
 fh2AngStructpt3C10(0x0),
@@ -284,81 +281,28 @@ fh2AngStructpt1C60(0x0),
 fh2AngStructpt2C60(0x0),
 fh2AngStructpt3C60(0x0),
 fh2AngStructpt4C60(0x0),    
-fh2JetsumHT3R2a(0x0),
-fh2JetsumHT3R2ap(0x0),
-fh2JetsumHT3R4a(0x0),
-fh2JetsumHT3R4ap(0x0),
-fh2JetsumHT3R6a(0x0),
-fh2JetsumHT3R6ap(0x0),
-fh2JetsumHT3R8a(0x0),
-fh2JetsumHT3R8ap(0x0),
-fh2JetsumHT3R10a(0x0),
-fh2JetsumHT3R10ap(0x0),
-fh2JetsumHT3R2aa(0x0),
-fh2JetsumHT3R2aap(0x0),
-fh2JetsumHT3R4aa(0x0),
-fh2JetsumHT3R4aap(0x0),
-fh2JetsumHT3R6aa(0x0),
-fh2JetsumHT3R6aap(0x0),
-fh2JetsumHT3R8aa(0x0),
-fh2JetsumHT3R8aap(0x0),
-fh2JetsumHT3R10aa(0x0),
-fh2JetsumHT3R10aap(0x0),
-fh2JetsumHT3R2aaa(0x0),
-fh2JetsumHT3R2aaap(0x0),
-fh2JetsumHT3R4aaa(0x0),
-fh2JetsumHT3R4aaap(0x0),
-fh2JetsumHT3R6aaa(0x0),
-fh2JetsumHT3R6aaap(0x0),
-fh2JetsumHT3R8aaa(0x0),
-fh2JetsumHT3R8aaap(0x0),
-fh2JetsumHT3R10aaa(0x0),
-fh2JetsumHT3R10aaap(0x0),
-fh2JetsumHT3R2b(0x0),
-fh2JetsumHT3R2bp(0x0),
-fh2JetsumHT3R4b(0x0),
-fh2JetsumHT3R4bp(0x0),
-fh2JetsumHT3R6b(0x0),
-fh2JetsumHT3R6bp(0x0),
-fh2JetsumHT3R8b(0x0),
-fh2JetsumHT3R8bp(0x0),
-fh2JetsumHT3R10b(0x0),
-fh2JetsumHT3R10bp(0x0),
-fh2JetsumHT3R2bb(0x0),
-fh2JetsumHT3R2bbp(0x0),
-fh2JetsumHT3R4bb(0x0),
-fh2JetsumHT3R4bbp(0x0),
-fh2JetsumHT3R6bb(0x0),
-fh2JetsumHT3R6bbp(0x0),
-fh2JetsumHT3R8bb(0x0),
-fh2JetsumHT3R8bbp(0x0),
-fh2JetsumHT3R10bb(0x0),
-fh2JetsumHT3R10bbp(0x0),
-fh2JetsumHT3R2bbb(0x0),
-fh2JetsumHT3R2bbbp(0x0),
-fh2JetsumHT3R4bbb(0x0),
-fh2JetsumHT3R4bbbp(0x0),
-fh2JetsumHT3R6bbb(0x0),
-fh2JetsumHT3R6bbbp(0x0),
-fh2JetsumHT3R8bbb(0x0),
-fh2JetsumHT3R8bbbp(0x0),
-fh2JetsumHT3R10bbb(0x0),
-fh2JetsumHT3R10bbbp(0x0),
+fh1TrigRef(0x0),
+fh1TrigSig(0x0),
 fh2Ntriggers(0x0),
-fh2JetDensity(0x0),
-fh2JetDensityA4(0x0),
-fh3spectriggeredC10(0x0),
-fh3spectriggeredC20(0x0),
-fh3spectriggeredC3060(0x0),
-fh3specbiased(0x0),
-fh3spectot(0x0),
-fh3spectotb(0x0)
+fh2Ntriggers2C10(0x0),
+fh2Ntriggers2C20(0x0),
+fh3JetDensity(0x0),
+fh3JetDensityA4(0x0),
+fh2RPJetsC10(0x0),
+fh2RPJetsC20(0x0),
+fh2RPTC10(0x0),
+fh2RPTC20(0x0), 
+fHJetSpec(0x0),
+fhTTPt(0x0),
+fHJetPhiCorr(0x0),
+fRandom(0x0)
+
  {
    // Constructor
 
 
     for(Int_t i=0; i<10; i++) {
-       for(Int_t j=0; j<7; j++) {
+       for(Int_t j=0; j<6; j++) {
            fTrigBuffer[i][j]=0;
                }                               
     }  
@@ -408,6 +352,12 @@ void AliAnalysisTaskJetCore::UserCreateOutputObjects()
    TH1::AddDirectory(kFALSE);
 
 
+        // set seed
+   fRandom = new TRandom3(0);
+  
+
+
+
    fHistEvtSelection = new TH1I("fHistEvtSelection", "event selection", 6, -0.5, 5.5);
    fHistEvtSelection->GetXaxis()->SetBinLabel(1,"ACCEPTED");
    fHistEvtSelection->GetXaxis()->SetBinLabel(2,"events IN");
@@ -450,11 +400,10 @@ void AliAnalysisTaskJetCore::UserCreateOutputObjects()
    
      if(fDoEventMixing){    
      UInt_t cifras = 0; // bit coded, see GetDimParams() below 
-     cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 |1<<7; 
+     cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<7; 
      fhnMixedEvents = NewTHnSparseF("fhnMixedEvents", cifras);}
 
     if(fCheckMethods){
-
     fh2JetCoreMethod1C10 = new TH2F("JetCoreMethod1C10","",150, 0., 150.,100, 0., 1.5);
     fh2JetCoreMethod2C10 = new TH2F("JetCoreMethod2C10","",150, 0., 150.,100, 0., 1.5);
     fh2JetCoreMethod1C20 = new TH2F("JetCoreMethod1C20","",150, 0., 150.,100, 0., 1.5);
@@ -464,9 +413,8 @@ void AliAnalysisTaskJetCore::UserCreateOutputObjects()
     fh2JetCoreMethod1C60 = new TH2F("JetCoreMethod1C60","",150, 0., 150.,100, 0., 1.5);
     fh2JetCoreMethod2C60 = new TH2F("JetCoreMethod2C60","",150, 0., 150.,100, 0., 1.5);}
 
-    fh2JetTrackC10=new TH2F("JetTrackC10","",150,0.,150.,32,0,3.2);
-    fh2JetTrackC20=new TH2F("JetTrackC20","",150,0.,150.,32,0,3.2);
-   
+    fh3JetTrackC3060=new TH3F("JetTrackC3060","",50,0,50,150,0.,150.,35,0.,3.5);
+    fh3JetTrackC20=new TH3F("JetTrackC20","",50,0,50,150,0.,150.,35,0.,3.5);
     if(fAngStructCloseTracks>0){
     fh2AngStructpt1C10 = new TH2F("Ang struct pt1 C10","",15,0.,1.5,150,0.,10.);
     fh2AngStructpt2C10 = new TH2F("Ang struct pt2 C10","",15,0.,1.5,150,0.,10.);
@@ -485,84 +433,22 @@ void AliAnalysisTaskJetCore::UserCreateOutputObjects()
     fh2AngStructpt3C60 = new TH2F("Ang struct pt3 C60","",15,0.,1.5,150,0.,10.);
     fh2AngStructpt4C60 = new TH2F("Ang struct pt4 C60","",15,0.,1.5,150,0.,10.); }
 
-    fh2JetsumHT3R2a = new TH2F("Pt sum R02 HT0 TT10","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R2ap = new TH2F("Pt sum R02 HT0 TT10 p","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R4a = new TH2F("Pt sum R04 HT0 TT10","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R4ap = new TH2F("Pt sum R04 HT0 TT10 p","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R6a = new TH2F("Pt sum R06 HT0 TT10","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R6ap = new TH2F("Pt sum R06 HT0 TT10 p","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R8a = new TH2F("Pt sum R08 HT0 TT10","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R8ap = new TH2F("Pt sum R08 HT0 TT10 p","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R10a = new TH2F("Pt sum R10 HT0 TT10","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R10ap = new TH2F("Pt sum R10 HT0 TT10 p","",20,0.,200.,100,0.,10.);  
-
-    fh2JetsumHT3R2aa = new TH2F("Pt sum R02 HT0 TT20","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R2aap = new TH2F("Pt sum R02 HT0 TT20 p","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R4aa = new TH2F("Pt sum R04 HT0 TT20","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R4aap = new TH2F("Pt sum R04 HT0 TT20 p","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R6aa = new TH2F("Pt sum R06 HT0 TT20","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R6aap = new TH2F("Pt sum R06 HT0 TT20 p","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R8aa = new TH2F("Pt sum R08 HT0 TT20","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R8aap = new TH2F("Pt sum R08 HT0 TT20 p","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R10aa = new TH2F("Pt sum R10 HT0 TT20","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R10aap = new TH2F("Pt sum R10 HT0 TT20 p","",20,0.,200.,100,0.,10.);  
-
-    fh2JetsumHT3R2aaa = new TH2F("Pt sum R02 HT0 TT0","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R2aaap = new TH2F("Pt sum R02 HT0 TT0 p","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R4aaa = new TH2F("Pt sum R04 HT0 TT0","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R4aaap = new TH2F("Pt sum R04 HT0 TT0 p","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R6aaa = new TH2F("Pt sum R06 HT0 TT0","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R6aaap = new TH2F("Pt sum R06 HT0 TT0 p","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R8aaa = new TH2F("Pt sum R08 HT0 TT0","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R8aaap = new TH2F("Pt sum R08 HT0 TT0 p","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R10aaa = new TH2F("Pt sum R10 HT0 TT0","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R10aaap = new TH2F("Pt sum R10 HT0 TT0 p","",20,0.,200.,100,0.,10.);  
-
-    fh2JetsumHT3R2b = new TH2F("Pt sum R02 HT6 TT10","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R2bp = new TH2F("Pt sum R02 HT6 TT10 p","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R4b = new TH2F("Pt sum R04 HT6 TT10","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R4bp = new TH2F("Pt sum R04 HT6 TT10 p","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R6b = new TH2F("Pt sum R06 HT6 TT10","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R6bp = new TH2F("Pt sum R06 HT6 TT10 p","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R8b = new TH2F("Pt sum R08 HT6 TT10","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R8bp = new TH2F("Pt sum R08 HT6 TT10 p","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R10b = new TH2F("Pt sum R10 HT6 TT10","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R10bp = new TH2F("Pt sum R10 HT6 TT10 p","",20,0.,200.,100,0.,10.);  
-
-    fh2JetsumHT3R2bb = new TH2F("Pt sum R02 HT6 TT20","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R2bbp = new TH2F("Pt sum R02 HT6 TT20 p","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R4bb = new TH2F("Pt sum R04 HT6 TT20","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R4bbp = new TH2F("Pt sum R04 HT6 TT20 p","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R6bb = new TH2F("Pt sum R06 HT6 TT20","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R6bbp = new TH2F("Pt sum R06 HT6 TT20 p","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R8bb = new TH2F("Pt sum R08 HT6 TT20","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R8bbp = new TH2F("Pt sum R08 HT6 TT20 p","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R10bb = new TH2F("Pt sum R10 HT6 TT20","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R10bbp = new TH2F("Pt sum R10 HT6 TT20 p","",20,0.,200.,100,0.,10.);  
-
-    fh2JetsumHT3R2bbb = new TH2F("Pt sum R02 HT6 TT0","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R2bbbp = new TH2F("Pt sum R02 HT6 TT0 p","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R4bbb = new TH2F("Pt sum R04 HT6 TT0","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R4bbbp = new TH2F("Pt sum R04 HT6 TT0 p","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R6bbb = new TH2F("Pt sum R06 HT6 TT0","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R6bbbp = new TH2F("Pt sum R06 HT6 TT0 p","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R8bbb = new TH2F("Pt sum R08 HT6 TT0","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R8bbbp = new TH2F("Pt sum R08 HT6 TT0 p","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R10bbb = new TH2F("Pt sum R10 HT6 TT0","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT3R10bbbp = new TH2F("Pt sum R10 HT6 TT0 p","",20,0.,200.,100,0.,10.);  
-
    
+    fh1TrigRef=new TH1D("Trig Ref","",10,0.,10);
+    fh1TrigSig=new TH1D("Trig Sig","",10,0.,10);  
+    fh2Ntriggers=new TH2F("# of triggers","",100,0.,100.,50,0.,50.);
+    fh2Ntriggers2C10=new TH2F("# of triggers2C10","",50,0.,50.,50,0.,50.);
+    fh2Ntriggers2C20=new TH2F("# of triggers2C20","",50,0.,50.,50,0.,50.);
+    fh3JetDensity=new TH3F("Jet density vs mutliplicity A>0.07","",100,0.,4000.,100,0.,5.,25,0.,50.);
+    fh3JetDensityA4=new TH3F("Jet density vs multiplicity A>0.4","",100,0.,4000.,100,0.,5.,25,0.,50.);
+    fh2RPJetsC10=new TH2F("RPJetC10","",35,0.,3.5,100,0.,100.);
+    fh2RPJetsC20=new TH2F("RPJetC20","",35,0.,3.5,100,0.,100.); 
+    fh2RPTC10=new TH2F("RPTriggerC10","",35,0.,3.5,50,0.,50.); 
+    fh2RPTC20=new TH2F("RPTriggerC20","",35,0.,3.5,50,0.,50.);  
 
-    fh2Ntriggers=new TH2F("# of triggers","",10,0.,100.,50,0.,50.);
-    fh2JetDensity=new TH2F("Jet density vs centrality A>0.4","",100,0.,4000.,100,0.,5.);
-    fh2JetDensityA4=new TH2F("Jet density vs multiplicity A>0.4","",100,0.,4000.,100,0.,5.);
-    fh3spectriggeredC10 = new TH3F("Triggered spectrumC10","",5,0.,1.,140,-80.,200.,50,0.,50.);
-    fh3spectriggeredC20 = new TH3F("Triggered spectrumC20","",5,0.,1.,140,-80.,200.,50,0.,50.);
-    fh3spectriggeredC3060 = new TH3F("Triggered spectrumC3060","",5,0.,1.,140,-80.,200.,50,0.,50.);
 
-    fh3specbiased = new TH3F("Biased spectrum","",10,0,100,50,0.,200.,50,0.,50.);
-    fh3spectot = new TH3F("Total spectrum 0-10","",50,0.,200.,50,0.,50.,50,0.,50.);
-    fh3spectotb = new TH3F("Total spectrum 30-60","",50,0.,200.,50,0.,50.,50,0.,50.);    
+    
+    
    fOutputList->Add(fHistEvtSelection);
 
    fOutputList->Add(fhnDeltaR);
@@ -582,8 +468,9 @@ void AliAnalysisTaskJetCore::UserCreateOutputObjects()
       fOutputList->Add(fh2JetCoreMethod1C60);
       fOutputList->Add(fh2JetCoreMethod2C60);}
       
-      fOutputList->Add(fh2JetTrackC10);
-      fOutputList->Add(fh2JetTrackC20);
+      fOutputList->Add(fh3JetTrackC3060);
+      fOutputList->Add(fh3JetTrackC20);
+     
             
      
 
@@ -607,80 +494,61 @@ void AliAnalysisTaskJetCore::UserCreateOutputObjects()
        fOutputList->Add(fh2AngStructpt4C60);}  
 
 
-       fOutputList->Add(fh2JetsumHT3R2a);
-        fOutputList->Add(fh2JetsumHT3R2ap);
-               fOutputList->Add(fh2JetsumHT3R4a);
-        fOutputList->Add(fh2JetsumHT3R4ap);
-        fOutputList->Add(fh2JetsumHT3R6a);
-        fOutputList->Add(fh2JetsumHT3R6ap);
-               fOutputList->Add(fh2JetsumHT3R8a);
-        fOutputList->Add(fh2JetsumHT3R8ap);
-        fOutputList->Add(fh2JetsumHT3R10a);
-        fOutputList->Add(fh2JetsumHT3R10ap);
-       fOutputList->Add(fh2JetsumHT3R2aa);
-        fOutputList->Add(fh2JetsumHT3R2aap);
-               fOutputList->Add(fh2JetsumHT3R4aa);
-        fOutputList->Add(fh2JetsumHT3R4aap);
-        fOutputList->Add(fh2JetsumHT3R6aa);
-        fOutputList->Add(fh2JetsumHT3R6aap);
-               fOutputList->Add(fh2JetsumHT3R8aa);
-        fOutputList->Add(fh2JetsumHT3R8aap);
-        fOutputList->Add(fh2JetsumHT3R10aa);
-        fOutputList->Add(fh2JetsumHT3R10aap);
-        fOutputList->Add(fh2JetsumHT3R2aaa);
-        fOutputList->Add(fh2JetsumHT3R2aaap);
-               fOutputList->Add(fh2JetsumHT3R4aaa);
-        fOutputList->Add(fh2JetsumHT3R4aaap);
-        fOutputList->Add(fh2JetsumHT3R6aaa);
-        fOutputList->Add(fh2JetsumHT3R6aaap);
-               fOutputList->Add(fh2JetsumHT3R8aaa);
-        fOutputList->Add(fh2JetsumHT3R8aaap);
-        fOutputList->Add(fh2JetsumHT3R10aaa);
-        fOutputList->Add(fh2JetsumHT3R10aaap);
-
-        fOutputList->Add(fh2JetsumHT3R2b);
-        fOutputList->Add(fh2JetsumHT3R2bp);
-               fOutputList->Add(fh2JetsumHT3R4b);
-        fOutputList->Add(fh2JetsumHT3R4bp);
-        fOutputList->Add(fh2JetsumHT3R6b);
-        fOutputList->Add(fh2JetsumHT3R6bp);
-               fOutputList->Add(fh2JetsumHT3R8b);
-        fOutputList->Add(fh2JetsumHT3R8bp);
-        fOutputList->Add(fh2JetsumHT3R10b);
-        fOutputList->Add(fh2JetsumHT3R10bp);
-       fOutputList->Add(fh2JetsumHT3R2bb);
-        fOutputList->Add(fh2JetsumHT3R2bbp);
-               fOutputList->Add(fh2JetsumHT3R4bb);
-        fOutputList->Add(fh2JetsumHT3R4bbp);
-        fOutputList->Add(fh2JetsumHT3R6bb);
-        fOutputList->Add(fh2JetsumHT3R6bbp);
-               fOutputList->Add(fh2JetsumHT3R8bb);
-        fOutputList->Add(fh2JetsumHT3R8bbp);
-        fOutputList->Add(fh2JetsumHT3R10bb);
-        fOutputList->Add(fh2JetsumHT3R10bbp);
-        fOutputList->Add(fh2JetsumHT3R2bbb);
-        fOutputList->Add(fh2JetsumHT3R2bbbp);
-               fOutputList->Add(fh2JetsumHT3R4bbb);
-        fOutputList->Add(fh2JetsumHT3R4bbbp);
-        fOutputList->Add(fh2JetsumHT3R6bbb);
-        fOutputList->Add(fh2JetsumHT3R6bbbp);
-               fOutputList->Add(fh2JetsumHT3R8bbb);
-        fOutputList->Add(fh2JetsumHT3R8bbbp);
-        fOutputList->Add(fh2JetsumHT3R10bbb);
-        fOutputList->Add(fh2JetsumHT3R10bbbp);
 
+
+        fOutputList->Add(fh1TrigRef);
+        fOutputList->Add(fh1TrigSig); 
        fOutputList->Add(fh2Ntriggers);
-        fOutputList->Add(fh2JetDensity);
-        fOutputList->Add(fh2JetDensityA4);
+        fOutputList->Add(fh2Ntriggers2C10);
+        fOutputList->Add(fh2Ntriggers2C20); 
+        fOutputList->Add(fh3JetDensity);
+        fOutputList->Add(fh3JetDensityA4);
+        fOutputList->Add(fh2RPJetsC10);
+        fOutputList->Add(fh2RPJetsC20);
+         fOutputList->Add(fh2RPTC10);
+        fOutputList->Add(fh2RPTC20);
+
+        const Int_t dimSpec = 5;
+       const Int_t nBinsSpec[dimSpec]     = {100,6, 140, 50, fNRPBins};
+       const Double_t lowBinSpec[dimSpec] = {0,0,-80, 0, 0};
+       const Double_t hiBinSpec[dimSpec]  = {100,1, 200, 50,  static_cast<Double_t>(fNRPBins)};
+       fHJetSpec = new THnSparseF("fHJetSpec","Recoil jet spectrum",dimSpec,nBinsSpec,lowBinSpec,hiBinSpec);
+
+             //change binning in jet area
+     Double_t *xPt6 = new Double_t[7];
+     xPt6[0] = 0.;
+     xPt6[1]=0.07;
+     xPt6[2]=0.2;
+     xPt6[3]=0.4;
+     xPt6[4]=0.6;
+     xPt6[5]=0.8; 
+     xPt6[6]=1;
+    fHJetSpec->SetBinEdges(1,xPt6);
+    delete [] xPt6;
+
+
+
+
+
+       fOutputList->Add(fHJetSpec);  
+
+
+       if(fRunAnaAzimuthalCorrelation)
+         {
+           fhTTPt = new TH2F("fhTTPt","Trigger track p_{T} vs centrality",10,0,100,100,0,100);
+           fOutputList->Add(fhTTPt);
+
+           const Int_t dimCor = 5;
+           const Int_t nBinsCor[dimCor]     = {50, 200, 100,              8,   10};
+           const Double_t lowBinCor[dimCor] = {0,  -50, -0.5*TMath::Pi(), 0,   0};
+           const Double_t hiBinCor[dimCor]  = {50, 150, 1.5*TMath::Pi(),  0.8, 100};
+           fHJetPhiCorr = new THnSparseF("fHJetPhiCorr","TT p_{T} vs jet p_{T} vs dPhi vs area vs centrality",dimCor,nBinsCor,lowBinCor,hiBinCor);
+           fOutputList->Add(fHJetPhiCorr);
+         }
 
-       fOutputList->Add(fh3spectriggeredC10);
-       fOutputList->Add(fh3spectriggeredC20); 
-       fOutputList->Add(fh3spectriggeredC3060);   
 
-       fOutputList->Add(fh3specbiased);
-       fOutputList->Add(fh3spectot);
-       fOutputList->Add(fh3spectotb); 
+        
+     
    // =========== Switch on Sumw2 for all histos ===========
    for (Int_t i=0; i<fOutputList->GetEntries(); ++i) {
       TH1 *h1 = dynamic_cast<TH1*>(fOutputList->At(i));
@@ -731,16 +599,23 @@ void AliAnalysisTaskJetCore::UserExec(Option_t *)
     }}
     
 
+   // -- event selection --
+   fHistEvtSelection->Fill(1); // number of events before event selection
 
 
+       Bool_t selected=kTRUE;
+       selected = AliAnalysisHelperJetTasks::Selected();
+       if(!selected){
+      // no selection by the service task, we continue
+       PostData(1,fOutputList);
+       return;}
+    
 
-   // -- event selection --
-   fHistEvtSelection->Fill(1); // number of events before event selection
 
-   // physics selection
+  // physics selection: this is now redundant, all should appear as accepted after service task selection
    AliInputEventHandler* inputHandler = (AliInputEventHandler*)
    ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
-   cout<<inputHandler->IsEventSelected()<<" "<<fOfflineTrgMask<<endl;
+        std::cout<<inputHandler->IsEventSelected()<<" "<<fOfflineTrgMask<<std::endl;
    if(!(inputHandler->IsEventSelected() & fOfflineTrgMask)){
       if(fDebug) Printf(" Trigger Selection: event REJECTED ... ");
       fHistEvtSelection->Fill(2);
@@ -748,6 +623,8 @@ void AliAnalysisTaskJetCore::UserExec(Option_t *)
       return;
    }
 
+
+      
    // vertex selection
    if(!aod){
      if(fDebug) Printf("%s:%d No AOD",(char*)__FILE__,__LINE__);
@@ -819,8 +696,11 @@ void AliAnalysisTaskJetCore::UserExec(Option_t *)
     }
    
    Float_t rho = 0;
-   if(externalBackground)rho = externalBackground->GetBackground(0);
 
+   if(fFlagRandom==0){
+     if(externalBackground)rho = externalBackground->GetBackground(0);}
+   if(fFlagRandom==1){
+      if(externalBackground)rho = externalBackground->GetBackground(2);}
 
    // fetch jets
    TClonesArray *aodJets[2];
@@ -836,21 +716,33 @@ void AliAnalysisTaskJetCore::UserExec(Option_t *)
    aodJets[1] = dynamic_cast<TClonesArray*>(fAODIn->FindListObject(fJetBranchName[1].Data()));  } 
 
 
-   //Double_t ptsub[aodJets[0]->GetEntriesFast()];
-   //Int_t inord[aodJets[0]->GetEntriesFast()];
-   //for(Int_t n=0;n<aodJets[0]->GetEntriesFast();n++){
-   //  ptsub[n]=0;
-   //  inord[n]=0;}   
 
+   Int_t nT=0;
    TList ParticleList;
-   Int_t nT = GetListOfTracks(&ParticleList);
+   Double_t minT=0;
+   Double_t maxT=0;
+   Int_t number=0;
+   Double_t dice=fRandom->Uniform(0,1);
+   if(dice>fFrac){ minT=fTTLowRef;
+                   maxT=fTTUpRef;}
+   if(dice<=fFrac){minT=fTTLowSig;
+                   maxT=fTTUpSig;} 
+
+
+
+   if(fHardest==1 || fHardest==2) nT = GetListOfTracks(&ParticleList);
+   if(fHardest==0) nT=SelectTrigger(&ParticleList,minT,maxT,number);
+   if(nT<0){  
+   PostData(1, fOutputList);
+   return;}   
+
+      if(dice>fFrac) fh1TrigRef->Fill(number);
+      if(dice<=fFrac)fh1TrigSig->Fill(number);
+
      for (Int_t iJetType = 0; iJetType < 2; iJetType++) {
       fListJets[iJetType]->Clear();
       if (!aodJets[iJetType]) continue;
-
       if(fDebug) Printf("%s: %d jets",fJetBranchName[iJetType].Data(),aodJets[iJetType]->GetEntriesFast());
-      
-   
       for (Int_t iJet = 0; iJet < aodJets[iJetType]->GetEntriesFast(); iJet++) {
          AliAODJet *jet = dynamic_cast<AliAODJet*>((*aodJets[iJetType])[iJet]);
          if (jet) fListJets[iJetType]->Add(jet);
@@ -868,89 +760,152 @@ void AliAnalysisTaskJetCore::UserExec(Option_t *)
    Double_t phismall=0.;
          
   
-   // Double_t up1[15]={0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
-   // Double_t up2[15]={0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
-   // Double_t up3[15]={0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
-   // Double_t up4[15]={0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
-   // Double_t down1[15]={0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
-   // Double_t down2[15]={0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
-   // Double_t down3[15]={0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
-   // Double_t down4[15]={0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
+
    Int_t iCount=0; 
    Int_t trigJet=-1;
    Int_t trigBBTrack=-1;
    Int_t trigInTrack=-1;
-     
+   fRPAngle = aod->GetHeader()->GetEventplane();     
 
+   if(fHardest==0 || fHardest==1){
    AliVParticle *partback = (AliVParticle*)ParticleList.At(nT);     
    if(!partback){  
    PostData(1, fOutputList);
    return;}
-   fh2Ntriggers->Fill(centValue,partback->Pt());
+
+    if(fSemigoodCorrect){
+   Double_t disthole=RelativePhi(partback->Phi(),fHolePos);
+   if(TMath::Abs(disthole)+fHoleWidth>TMath::Pi()-0.6){ 
+   PostData(1, fOutputList);
+   return;}} 
+
+
+    }
+
+
+   for(Int_t tt=0;tt<ParticleList.GetEntries();tt++){
+     if(fHardest==0||fHardest==1){if(tt!=nT) continue;}
+     AliVParticle *partback = (AliVParticle*)ParticleList.At(tt);     
+     if(!partback) continue;
+     if(partback->Pt()<8) continue;
+
    Double_t accep=2.*TMath::Pi()*1.8;
    Int_t injet4=0;
    Int_t injet=0; 
+
+   if(fSemigoodCorrect){
+   Double_t disthole=RelativePhi(partback->Phi(),fHolePos);
+   if(TMath::Abs(disthole)+fHoleWidth>TMath::Pi()-0.6) continue;}
+
+   
+
+   fh2Ntriggers->Fill(centValue,partback->Pt());
+   Double_t phiBinT = RelativePhi(partback->Phi(),fRPAngle);
+   if(centValue<20.) fh2RPTC20->Fill(TMath::Abs(phiBinT),partback->Pt());
+   if(centValue<10.) fh2RPTC10->Fill(TMath::Abs(phiBinT),partback->Pt());
+
+
+
    for(Int_t i=0; i<fListJets[0]->GetEntries(); ++i){
            AliAODJet* jetbig = (AliAODJet*)(fListJets[0]->At(i));
            etabig  = jetbig->Eta();
            phibig  = jetbig->Phi();
            ptbig   = jetbig->Pt();
            if(ptbig==0) continue; 
+           Double_t phiBin = RelativePhi(phibig,fRPAngle);       
            areabig = jetbig->EffectiveAreaCharged();
            Double_t ptcorr=ptbig-rho*areabig;
           if((etabig<fJetEtaMin)||(etabig>fJetEtaMax)) continue;
-          
-           if(areabig>=0.2) injet=injet+1;
+           if(areabig>=0.07) injet=injet+1;
            if(areabig>=0.4) injet4=injet4+1;   
-           Double_t dphi=RelativePhi(partback->Phi(),phibig);  
-           if(centValue<10.) fh2JetTrackC10->Fill(ptcorr,TMath::Abs(dphi));
-           if(centValue<20.) fh2JetTrackC20->Fill(ptcorr,TMath::Abs(dphi));
+           Double_t dphi=RelativePhi(partback->Phi(),phibig); 
+
+           if(fFlagEtaBkg==1){
+          Double_t etadif= partback->Eta()-etabig;
+           if(TMath::Abs(etadif)<=0.5){             
+          
+           if(centValue<20.) fh3JetTrackC20->Fill(partback->Pt(),ptcorr,TMath::Abs(dphi));
+           if(centValue>30. && centValue<60.) fh3JetTrackC3060->Fill(partback->Pt(),ptcorr,TMath::Abs(dphi));}}
+           if(fFlagEtaBkg==0){
+           if(centValue<20.) fh3JetTrackC20->Fill(partback->Pt(),ptcorr,TMath::Abs(dphi));
+           if(centValue>30. && centValue<60.) fh3JetTrackC3060->Fill(partback->Pt(),ptcorr,TMath::Abs(dphi));}
+
+
+           if(fFlagJetHadron==0){
+           if(fFlagPhiBkg==1) if((TMath::Abs(dphi)<TMath::Pi()/2.-0.1)||(TMath::Abs(dphi)>TMath::Pi()/2.+0.1)) continue;
+           if(fFlagPhiBkg==0) if(TMath::Abs(dphi)<TMath::Pi()-0.6) continue;
+           if(fFlagPhiBkg==2) if(TMath::Abs(dphi)<TMath::Pi()-0.7) continue;
+           if(fFlagPhiBkg==3) if(TMath::Abs(dphi)<TMath::Pi()-0.5) continue;}
+           if(fFlagJetHadron!=0) if(TMath::Abs(dphi)>0.4) continue;
+
 
-           if(TMath::Abs(dphi)<TMath::Pi()-0.6) continue;
+          if(centValue<10.) fh2RPJetsC10->Fill(TMath::Abs(phiBin), ptcorr);
+          if(centValue<20.) fh2RPJetsC20->Fill(TMath::Abs(phiBin), ptcorr);
                    Double_t dismin=100.;
                    Double_t ptmax=-10.; 
                    Int_t index1=-1;
                    Int_t index2=-1;
-           if(centValue<10.)  fh3spectriggeredC10->Fill(jetbig->EffectiveAreaCharged(),ptcorr,partback->Pt());
-           if(centValue<20.)  fh3spectriggeredC20->Fill(jetbig->EffectiveAreaCharged(),ptcorr,partback->Pt());
-           if(centValue>30. && centValue<60.)  fh3spectriggeredC3060->Fill(jetbig->EffectiveAreaCharged(),ptcorr,partback->Pt());
+         
+                  Float_t phitt=partback->Phi();
+                   if(phitt<0)phitt+=TMath::Pi()*2.; 
+                   Int_t phiBintt = GetPhiBin(phitt-fRPAngle);
+
+                  Double_t fillspec[] = {centValue,jetbig->EffectiveAreaCharged(),ptcorr,partback->Pt(), static_cast<Double_t>(phiBintt)};
+                 fHJetSpec->Fill(fillspec);
+           
+          
 
                    if(ptcorr<=0) continue;
-                       AliAODTrack* leadtrack; 
+
+                       AliAODTrack* leadtrack=0; 
                        Int_t ippt=0;
-                       Double_t ppt=-10;   
-                      TRefArray *genTrackList = jetbig->GetRefTracks();
-                       Int_t nTracksGenJet = genTrackList->GetEntriesFast();
-                       AliAODTrack* genTrack;
-                       for(Int_t ir=0; ir<nTracksGenJet; ++ir){
-                       genTrack = (AliAODTrack*)(genTrackList->At(ir));
-                      if(genTrack->Pt()>ppt){ppt=genTrack->Pt();
-                        ippt=ir;}}
-                        leadtrack=(AliAODTrack*)(genTrackList->At(ippt));
-                        if(!leadtrack) continue;
-                        fh3specbiased->Fill(centValue,ptcorr,leadtrack->Pt());
-                        if(centValue<10)fh3spectot->Fill(ptcorr,leadtrack->Pt(),partback->Pt());
-                        if(centValue>30. && centValue<60.)fh3spectotb->Fill(ptcorr,leadtrack->Pt(),partback->Pt()); 
-                       //store one trigger info                   
-                        if((partback->Pt()>10.)&&(iCount==0)){                        
-                         trigJet=i;
-                          trigBBTrack=nT;
-                          trigInTrack=ippt;
-                          iCount=iCount+1;} 
-
-
-                 if(fCheckMethods){
-                  for(Int_t j=0; j<fListJets[1]->GetEntries(); ++j){
-                  AliAODJet* jetsmall = (AliAODJet*)(fListJets[1]->At(j));
-                  etasmall  = jetsmall->Eta();
-                  phismall = jetsmall->Phi();
-                  ptsmall   = jetsmall->Pt();
-                  areasmall = jetsmall->EffectiveAreaCharged();
-                  Double_t tmpDeltaR=(phismall-phibig)*(phismall-phibig)+(etasmall-etabig)*(etasmall-etabig);
-                 tmpDeltaR=TMath::Sqrt(tmpDeltaR);
-                    //Fraction in the jet core  
-                    if((ptsmall>ptmax)&&(tmpDeltaR<=fRadioFrac)){ptmax=ptsmall;  
-                   index2=j;}  
+                       Double_t ppt=-10;
+                       if(fFlagJetHadron==0){   
+                        TRefArray *genTrackList = jetbig->GetRefTracks();
+                        Int_t nTracksGenJet = genTrackList->GetEntriesFast();
+                        AliAODTrack* genTrack;
+                        for(Int_t ir=0; ir<nTracksGenJet; ++ir){
+                          genTrack = (AliAODTrack*)(genTrackList->At(ir));
+                          if(genTrack->Pt()>ppt){ppt=genTrack->Pt();
+                            ippt=ir;}}
+                        leadtrack=(AliAODTrack*)(genTrackList->At(ippt));
+                        if(!leadtrack) continue;
+                      }
+
+
+
+                      AliVParticle* leadtrackb=0;
+                       if(fFlagJetHadron!=0){
+                        Int_t nTb = GetHardestTrackBackToJet(jetbig);
+                         leadtrackb = (AliVParticle*)ParticleList.At(nTb);
+                         if(!leadtrackb) continue;  
+                      }
+
+
+
+
+                       
+                      //store one trigger info                   
+                      if(iCount==0){                        
+                        trigJet=i;
+                        trigBBTrack=nT;
+                        trigInTrack=ippt;
+                        iCount=iCount+1;} 
+                      
+   
+                      if(fCheckMethods){
+                        for(Int_t j=0; j<fListJets[1]->GetEntries(); ++j){
+                          AliAODJet* jetsmall = (AliAODJet*)(fListJets[1]->At(j));
+                          etasmall  = jetsmall->Eta();
+                          phismall = jetsmall->Phi();
+                          ptsmall   = jetsmall->Pt();
+                          areasmall = jetsmall->EffectiveAreaCharged();
+                          Double_t tmpDeltaR=(phismall-phibig)*(phismall-phibig)+(etasmall-etabig)*(etasmall-etabig);
+                          tmpDeltaR=TMath::Sqrt(tmpDeltaR);
+                          //Fraction in the jet core  
+                          if((ptsmall>ptmax)&&(tmpDeltaR<=fRadioFrac)){ptmax=ptsmall;  
+                            index2=j;}  
                     if(tmpDeltaR<=dismin){ dismin=tmpDeltaR;
                      index1=j;}} //en of loop over R=0.2 jets
                 //method1:most concentric jet=core 
@@ -966,199 +921,29 @@ void AliAnalysisTaskJetCore::UserExec(Option_t *)
                   if((centValue>20)&&(centValue<40)) fh2JetCoreMethod2C20->Fill(ptcorr,jetmethod2->Pt()/ptbig); 
                  if((centValue>30)&&(centValue<60)) fh2JetCoreMethod2C30->Fill(ptcorr,jetmethod2->Pt()/ptbig);
                  if(centValue>60) fh2JetCoreMethod2C60->Fill(ptcorr,jetmethod2->Pt()/ptbig); }}  
-                 Double_t sumpt2a=0.;
-                  Double_t sumpt2b=0.;
-                  Double_t sumpt4a=0.;
-                  Double_t sumpt4b=0.;
-                  Double_t sumpt6a=0.;
-                  Double_t sumpt6b=0.;
-                  Double_t sumpt8a=0.;
-                  Double_t sumpt8b=0.;
-                  Double_t sumpt10a=0.;
-                  Double_t sumpt10b=0.;
-                  Double_t sumpt2aaa=0.;
-                  Double_t sumpt2bbb=0.;
-                  Double_t sumpt4aaa=0.;
-                  Double_t sumpt4bbb=0.;
-                  Double_t sumpt6aaa=0.;
-                  Double_t sumpt6bbb=0.;
-                  Double_t sumpt8aaa=0.;
-                  Double_t sumpt8bbb=0.;
-                  Double_t sumpt10aaa=0.;
-                  Double_t sumpt10bbb=0.; 
-                  Double_t sumpt2ap=0.;
-                  Double_t sumpt2bp=0.;
-                  Double_t sumpt4ap=0.;
-                  Double_t sumpt4bp=0.;
-                  Double_t sumpt6ap=0.;
-                  Double_t sumpt6bp=0.;
-                  Double_t sumpt8ap=0.;
-                  Double_t sumpt8bp=0.;
-                  Double_t sumpt10ap=0.;
-                  Double_t sumpt10bp=0.;
-                  Double_t sumpt2aaap=0.;
-                  Double_t sumpt2bbbp=0.;
-                  Double_t sumpt4aaap=0.;
-                  Double_t sumpt4bbbp=0.;
-                  Double_t sumpt6aaap=0.;
-                  Double_t sumpt6bbbp=0.;
-                  Double_t sumpt8aaap=0.;
-                  Double_t sumpt8bbbp=0.;
-                  Double_t sumpt10aaap=0.;
-                  Double_t sumpt10bbbp=0.; 
-
-
-
-                  
-
-                 for(int it = 0;it<ParticleList.GetEntries();++it){
+                 if(centValue<10&&leadtrack) fh2Ntriggers2C10->Fill(leadtrack->Pt(),partback->Pt());                  
+                  if(centValue<20&&leadtrack) fh2Ntriggers2C20->Fill(leadtrack->Pt(),partback->Pt());  
+         if(fDoEventMixing==0 && fFlagOnlyRecoil==0){ 
+        for(int it = 0;it<ParticleList.GetEntries();++it){
          AliVParticle *part = (AliVParticle*)ParticleList.At(it);
                  Double_t deltaR = jetbig->DeltaR(part);
           Double_t deltaEta = etabig-part->Eta();
-          if(partback->Pt()>14.){
-
-          if(centValue<10){
-           //for one more centrality
-               if(deltaR<0.2){if(leadtrack->Pt()>0.)sumpt2a=sumpt2a+part->Pt();
-                             if(leadtrack->Pt()>6) sumpt2b=sumpt2b+part->Pt();}
-              if(deltaR>=0.2 && deltaR<0.4){if(leadtrack->Pt()>0.)sumpt4a=sumpt4a+part->Pt();
-                                              if(leadtrack->Pt()>6.)sumpt4b=sumpt4b+part->Pt();}
-
-               if(deltaR>=0.4 && deltaR<0.6){if(leadtrack->Pt()>0.)sumpt6a=sumpt6a+part->Pt();
-                                            if(leadtrack->Pt()>6.) sumpt6b=sumpt6b+part->Pt();} 
-               if(deltaR>=0.6 && deltaR<0.8){if(leadtrack->Pt()>0.)sumpt8a=sumpt8a+part->Pt();
-                                            if(leadtrack->Pt()>6.) sumpt8b=sumpt8b+part->Pt();}                               
-               if(deltaR>=0.8 && deltaR<1.2){if(leadtrack->Pt()>0.)sumpt10a=sumpt10a+part->Pt();
-                if(leadtrack->Pt()>6.) sumpt10b=sumpt10b+part->Pt();}}
-
-               if(centValue>30. && centValue<60.){
-           //for one more centrality
-               if(deltaR<0.2){if(leadtrack->Pt()>0.)sumpt2ap=sumpt2ap+part->Pt();
-                             if(leadtrack->Pt()>6) sumpt2bp=sumpt2bp+part->Pt();}
-              if(deltaR>=0.2 && deltaR<0.4){if(leadtrack->Pt()>0.)sumpt4ap=sumpt4ap+part->Pt();
-                                              if(leadtrack->Pt()>6.)sumpt4bp=sumpt4bp+part->Pt();}
-
-               if(deltaR>=0.4 && deltaR<0.6){if(leadtrack->Pt()>0.)sumpt6ap=sumpt6ap+part->Pt();
-                                            if(leadtrack->Pt()>6.) sumpt6bp=sumpt6bp+part->Pt();} 
-               if(deltaR>=0.6 && deltaR<0.8){if(leadtrack->Pt()>0.)sumpt8ap=sumpt8ap+part->Pt();
-                                            if(leadtrack->Pt()>6.) sumpt8bp=sumpt8bp+part->Pt();}                               
-               if(deltaR>=0.8 && deltaR<1.2){if(leadtrack->Pt()>0.)sumpt10ap=sumpt10ap+part->Pt();
-                if(leadtrack->Pt()>6.) sumpt10bp=sumpt10bp+part->Pt();}}}
-
-              
-
-             if(partback->Pt()<1.){
-
-              if(centValue<10){
-           //for one more centrality
-               if(deltaR<0.2){if(leadtrack->Pt()>0.)sumpt2aaa=sumpt2aaa+part->Pt();
-                             if(leadtrack->Pt()>6.) sumpt2bbb=sumpt2bbb+part->Pt();}
-              if(deltaR>=0.2 && deltaR<0.4){if(leadtrack->Pt()>0.)sumpt4aaa=sumpt4aaa+part->Pt();
-                                              if(leadtrack->Pt()>6.)sumpt4bbb=sumpt4bbb+part->Pt();}
-
-               if(deltaR>=0.4 && deltaR<0.6){if(leadtrack->Pt()>0.)sumpt6aaa=sumpt6aaa+part->Pt();
-                                            if(leadtrack->Pt()>6.) sumpt6bbb=sumpt6bbb+part->Pt();} 
-               if(deltaR>=0.6 && deltaR<0.8){if(leadtrack->Pt()>0.)sumpt8aaa=sumpt8aaa+part->Pt();
-                                            if(leadtrack->Pt()>6.) sumpt8bbb=sumpt8bbb+part->Pt();}                               
-               if(deltaR>=0.8 && deltaR<1.2){if(leadtrack->Pt()>0.)sumpt10aaa=sumpt10aaa+part->Pt();
-                if(leadtrack->Pt()>6.) sumpt10bbb=sumpt10bbb+part->Pt();}}
-
-               if(centValue>30. && centValue<60.){
-           //for one more centrality
-               if(deltaR<0.2){if(leadtrack->Pt()>0.)sumpt2aaap=sumpt2aaap+part->Pt();
-                             if(leadtrack->Pt()>6) sumpt2bbbp=sumpt2bbbp+part->Pt();}
-              if(deltaR>=0.2 && deltaR<0.4){if(leadtrack->Pt()>0.)sumpt4aaap=sumpt4aaap+part->Pt();
-                                              if(leadtrack->Pt()>6.)sumpt4bbbp=sumpt4bbbp+part->Pt();}
-
-               if(deltaR>=0.4 && deltaR<0.6){if(leadtrack->Pt()>0.)sumpt6aaap=sumpt6aaap+part->Pt();
-                                            if(leadtrack->Pt()>6.) sumpt6bbbp=sumpt6bbbp+part->Pt();} 
-               if(deltaR>=0.6 && deltaR<0.8){if(leadtrack->Pt()>0.)sumpt8aaap=sumpt8aaap+part->Pt();
-                                            if(leadtrack->Pt()>6.) sumpt8bbbp=sumpt8bbbp+part->Pt();}                               
-               if(deltaR>=0.8 && deltaR<1.2){if(leadtrack->Pt()>0.)sumpt10aaap=sumpt10aaap+part->Pt();
-                if(leadtrack->Pt()>6.) sumpt10bbbp=sumpt10bbbp+part->Pt();}}}
-
-
-
-
+         
           Double_t deltaPhi=phibig-part->Phi();
           if(deltaPhi<-0.5*TMath::Pi()) deltaPhi+=2.*TMath::Pi();
           if(deltaPhi>3./2.*TMath::Pi()) deltaPhi-=2.*TMath::Pi();
-                 Double_t jetEntries[8] = {centValue,ptcorr,part->Pt(),deltaR,deltaEta,deltaPhi,leadtrack->Pt(),partback->Pt()};                     fhnDeltaR->Fill(jetEntries);
-          }
-          //end of track loop
-            Double_t rhoin2=rho*TMath::Pi()*0.2*0.2; 
-            Double_t rhoin4=rho*TMath::Pi()*(0.4*0.4-0.2*0.2);
-            Double_t rhoin6=rho*TMath::Pi()*(0.6*0.6-0.4*0.4);
-            Double_t rhoin8=rho*TMath::Pi()*(0.8*0.8-0.6*0.6);
-            Double_t rhoin10=rho*TMath::Pi()*(1.2*1.2-0.8*0.8); 
-           
-              
-          if(rho!=0){
-
-          if(partback->Pt()>14.){
-           if(centValue<10.){
-           if(leadtrack->Pt()>0.){
-          fh2JetsumHT3R2a->Fill(ptcorr,sumpt2a/rhoin2);
-          fh2JetsumHT3R4a->Fill(ptcorr,sumpt4a/rhoin4);
-          fh2JetsumHT3R6a->Fill(ptcorr,sumpt6a/rhoin6);
-          fh2JetsumHT3R8a->Fill(ptcorr,sumpt8a/rhoin8);
-          fh2JetsumHT3R10a->Fill(ptcorr,sumpt10a/rhoin10);}
-           if(leadtrack->Pt()>6.){
-          fh2JetsumHT3R2b->Fill(ptcorr,sumpt2b/rhoin2);
-          fh2JetsumHT3R4b->Fill(ptcorr,sumpt4b/rhoin4);
-          fh2JetsumHT3R6b->Fill(ptcorr,sumpt6b/rhoin6);
-          fh2JetsumHT3R8b->Fill(ptcorr,sumpt8b/rhoin8);
-          fh2JetsumHT3R10b->Fill(ptcorr,sumpt10b/rhoin10);}}
-
-                   if(centValue>30 && centValue<60.){
-            if(leadtrack->Pt()>0.){
-          fh2JetsumHT3R2ap->Fill(ptcorr,sumpt2ap/rhoin2);
-          fh2JetsumHT3R4ap->Fill(ptcorr,sumpt4ap/rhoin4);
-          fh2JetsumHT3R6ap->Fill(ptcorr,sumpt6ap/rhoin6);
-          fh2JetsumHT3R8ap->Fill(ptcorr,sumpt8ap/rhoin8);
-          fh2JetsumHT3R10ap->Fill(ptcorr,sumpt10ap/rhoin10);}
-           if(leadtrack->Pt()>6.){
-          fh2JetsumHT3R2bp->Fill(ptcorr,sumpt2bp/rhoin2);
-          fh2JetsumHT3R4bp->Fill(ptcorr,sumpt4bp/rhoin4);
-          fh2JetsumHT3R6bp->Fill(ptcorr,sumpt6bp/rhoin6);
-          fh2JetsumHT3R8bp->Fill(ptcorr,sumpt8bp/rhoin8);
-          fh2JetsumHT3R10bp->Fill(ptcorr,sumpt10bp/rhoin10);}}}
-
-
-
-                        if(partback->Pt()<1.){
-           if(centValue<10.){
-             if(leadtrack->Pt()>0.){
-          fh2JetsumHT3R2aaa->Fill(ptcorr,sumpt2aaa/rhoin2);
-          fh2JetsumHT3R4aaa->Fill(ptcorr,sumpt4aaa/rhoin4);
-          fh2JetsumHT3R6aaa->Fill(ptcorr,sumpt6aaa/rhoin6);
-          fh2JetsumHT3R8aaa->Fill(ptcorr,sumpt8aaa/rhoin8);
-          fh2JetsumHT3R10aaa->Fill(ptcorr,sumpt10aaa/rhoin10);}
-           if(leadtrack->Pt()>6.){
-          fh2JetsumHT3R2bbb->Fill(ptcorr,sumpt2bbb/rhoin2);
-          fh2JetsumHT3R4bbb->Fill(ptcorr,sumpt4bbb/rhoin4);
-          fh2JetsumHT3R6bbb->Fill(ptcorr,sumpt6bbb/rhoin6);
-          fh2JetsumHT3R8bbb->Fill(ptcorr,sumpt8bbb/rhoin8);
-          fh2JetsumHT3R10bbb->Fill(ptcorr,sumpt10bbb/rhoin10);}}
-
-                   if(centValue>30 && centValue<60.){
-            if(leadtrack->Pt()>0.){
-          fh2JetsumHT3R2aaap->Fill(ptcorr,sumpt2aaap/rhoin2);
-          fh2JetsumHT3R4aaap->Fill(ptcorr,sumpt4aaap/rhoin4);
-          fh2JetsumHT3R6aaap->Fill(ptcorr,sumpt6aaap/rhoin6);
-          fh2JetsumHT3R8aaap->Fill(ptcorr,sumpt8aaap/rhoin8);
-          fh2JetsumHT3R10aaap->Fill(ptcorr,sumpt10aaap/rhoin10);}
-           if(leadtrack->Pt()>6.){
-          fh2JetsumHT3R2bbbp->Fill(ptcorr,sumpt2bbbp/rhoin2);
-          fh2JetsumHT3R4bbbp->Fill(ptcorr,sumpt4bbbp/rhoin4);
-          fh2JetsumHT3R6bbbp->Fill(ptcorr,sumpt6bbbp/rhoin6);
-          fh2JetsumHT3R8bbbp->Fill(ptcorr,sumpt8bbbp/rhoin8);
-          fh2JetsumHT3R10bbbp->Fill(ptcorr,sumpt10bbbp/rhoin10);}}}
+         Double_t pTcont=0;
+          if(fFlagJetHadron==0) pTcont=leadtrack->Pt();
+          if(fFlagJetHadron!=0) pTcont=leadtrackb->Pt(); 
+          Double_t jetEntries[8] = {centValue,ptcorr,part->Pt(),deltaR,deltaEta,deltaPhi,pTcont,partback->Pt()};  
+           fhnDeltaR->Fill(jetEntries);}
+
 
          }
+        
+        
+          //end of track loop, we only do it if EM is switched off
+         
 
 
 
@@ -1168,26 +953,25 @@ void AliAnalysisTaskJetCore::UserExec(Option_t *)
 
 
    }
-   if(injet>0) fh2JetDensity->Fill(ParticleList.GetEntries(),injet/accep);
-   if(injet4>0)fh2JetDensityA4->Fill(ParticleList.GetEntries(),injet4/accep);
+   if(injet>0) fh3JetDensity->Fill(ParticleList.GetEntries(),injet/accep,partback->Pt());
+   if(injet4>0)fh3JetDensityA4->Fill(ParticleList.GetEntries(),injet4/accep,partback->Pt());
           //end of jet loop
 
+   //}
 
 
-
-          if(fDoEventMixing){
+          if(fDoEventMixing>0){
             //check before if the trigger exists
             // fTrigBuffer[i][0] = zvtx
             // fTrigBuffer[i][1] = phi
             // fTrigBuffer[i][2] = eta
             // fTrigBuffer[i][3] = pt_jet
             // fTrigBuffer[i][4] = pt_trig
-            // fTrigBuffer[i][5]= pt_track_in
-            // fTrigBuffer[i][6]= centrality
-           if(fTindex==11) fTindex=0;
+            // fTrigBuffer[i][5]= centrality
+            if(fTindex==10) fTindex=0;
             if(fTrigBuffer[fTindex][3]>0){
            if (TMath::Abs(fTrigBuffer[fTindex][0]-primVtx->GetZ()<2.)){
-           if (TMath::Abs(fTrigBuffer[fTindex][6]-centValue<10)){  
+           if (TMath::Abs(fTrigBuffer[fTindex][5]-centValue<5)){  
              
                         for(int it = 0;it<nT;++it){
                        AliVParticle *part = (AliVParticle*)ParticleList.At(it);         
@@ -1196,35 +980,61 @@ void AliAnalysisTaskJetCore::UserExec(Option_t *)
                         Double_t DR=TMath::Sqrt(DPhi*DPhi+DEta*DEta);
                         if(DPhi<-0.5*TMath::Pi()) DPhi+=2.*TMath::Pi();
                         if(DPhi>3./2.*TMath::Pi()) DPhi-=2.*TMath::Pi();
-                        Double_t triggerEntries[8] = {centValue,fTrigBuffer[fTindex][3],part->Pt(),DR,DEta,DPhi,fTrigBuffer[fTindex][4],fTrigBuffer[fTindex][5]};                      
+                        Double_t triggerEntries[7] = {centValue,fTrigBuffer[fTindex][3],part->Pt(),DR,DEta,DPhi,fTrigBuffer[fTindex][4]};                      
                         fhnMixedEvents->Fill(triggerEntries);
                         }
                         fNevents=fNevents+1;  
-                        if(fNevents==9) {fTindex=fTindex+1;
-                       fNevents=0;} 
+                        if(fNevents==10) fTindex=fTindex+1; 
            }}}
-        
+
+              if(fTindex==10&&fNevents==10) fCountAgain=0;
 
                // Copy the triggers from the current event into the buffer.
                //again, only if the trigger exists:
+              if(fCountAgain==0){
                if(trigJet>-1){
-                AliAODJet* jetT = (AliAODJet*)(fListJets[0]->At(trigJet));                 
-                AliVParticle *partL = (AliVParticle*)ParticleList.At(trigInTrack);
-                AliVParticle *partT = (AliVParticle*)ParticleList.At(trigBBTrack);         
+                AliAODJet* jetT = (AliAODJet*)(fListJets[0]->At(trigJet));                      AliVParticle *partT = (AliVParticle*)ParticleList.At(trigBBTrack);         
                 fTrigBuffer[fTrigBufferIndex][0] = primVtx->GetZ();
                 fTrigBuffer[fTrigBufferIndex][1] = jetT->Phi();
                 fTrigBuffer[fTrigBufferIndex][2] = jetT->Eta();
                 fTrigBuffer[fTrigBufferIndex][3] = jetT->Pt()-rho*jetT->EffectiveAreaCharged();
                 fTrigBuffer[fTrigBufferIndex][4] = partT->Pt();
-                fTrigBuffer[fTrigBufferIndex][5] = partL->Pt();
-                fTrigBuffer[fTrigBufferIndex][6] = centValue;
+                fTrigBuffer[fTrigBufferIndex][5] = centValue;
                 fTrigBufferIndex++;
-               if(fTrigBufferIndex==9) fTrigBufferIndex=0;
+                if(fTrigBufferIndex==9) {fTrigBufferIndex=0; 
+                                        fCountAgain=1;}
                }
-         }
+              }
          
+         }
 
-
+         /////////////////////////////////////////////////////////////////////////////
+         ////////////////////// Rongrong's analysis //////////////////////////////////
+         if(fRunAnaAzimuthalCorrelation)
+           {
+             fhTTPt->Fill(centValue,partback->Pt());
+             for(Int_t ij=0; ij<fListJets[0]->GetEntries(); ij++)
+               {
+                 AliAODJet* jet = (AliAODJet*)(fListJets[0]->At(ij));
+                 Double_t jetPt   = jet->Pt();
+                 Double_t jetEta  = jet->Eta();
+                 Double_t jetPhi  = jet->Phi();
+                 if(jetPt==0) continue; 
+                 if((jetEta<fJetEtaMin)||(jetEta>fJetEtaMax)) continue;
+                 Double_t jetArea = jet->EffectiveAreaCharged();
+                 Double_t jetPtCorr=jetPt-rho*jetArea;
+                 Double_t dPhi=jetPhi-partback->Phi();
+                 if(dPhi>2*TMath::Pi()) dPhi -= 2*TMath::Pi();
+                 if(dPhi<-2*TMath::Pi()) dPhi += 2*TMath::Pi();
+                 if(dPhi<-0.5*TMath::Pi()) dPhi += 2*TMath::Pi();
+                 if(dPhi>1.5*TMath::Pi()) dPhi -= 2*TMath::Pi();
+
+                 Double_t fill[] = {partback->Pt(),jetPtCorr,dPhi,jetArea,centValue};
+                 fHJetPhiCorr->Fill(fill);
+               }
+           }
+         /////////////////////////////////////////////////////////////////////////////
+         /////////////////////////////////////////////////////////////////////////////
 
 
      //////////////////ANGULAR STRUCTURE//////////////////////////////////////
@@ -1318,7 +1128,7 @@ void AliAnalysisTaskJetCore::UserExec(Option_t *)
 
     
 
-
+   }
 
 
 
@@ -1341,29 +1151,135 @@ void AliAnalysisTaskJetCore::Terminate(const Option_t *)
 
 Int_t  AliAnalysisTaskJetCore::GetListOfTracks(TList *list){
 
+      Int_t iCount = 0;
+      AliAODEvent *aod = 0;
+
+     if(!fESD)aod = fAODIn;
+     else aod = fAODOut;   
+
+     if(!aod)return 0;
+
+     Int_t index=-1;
+     Double_t ptmax=-10;
+
+
+    
+     for(int it = 0;it < aod->GetNumberOfTracks();++it){
+      AliAODTrack *tr = aod->GetTrack(it);
+      Bool_t bGood = false;
+      if(fFilterType == 0)bGood = true;
+      else if(fFilterType == 1)bGood = tr->IsHybridTPCConstrainedGlobal();
+      else if(fFilterType == 2)bGood = tr->IsHybridGlobalConstrainedGlobal();    
+      if((fFilterMask>0)&&!(tr->TestFilterBit(fFilterMask)))continue;
+      if(fRequireITSRefit==1){if((tr->GetStatus()&AliESDtrack::kITSrefit)==0)continue;}
+      if(bGood==false) continue;
+      if (fApplySharedClusterCut) {
+           Double_t frac = Double_t(tr->GetTPCnclsS()) /Double_t(tr->GetTPCncls());
+           if (frac > 0.4) continue;
+      }
+     if(TMath::Abs(tr->Eta())>0.9)continue;
+      if(tr->Pt()<0.15)continue;
+      list->Add(tr);
+      iCount++;
+      if(fFilterType==2 && fFilterMaskBestPt>0){// only set the trigger track index for good quality tracks
+       if(tr->TestFilterBit(fFilterMaskBestPt)){
+         if(tr->Pt()>ptmax){ 
+           ptmax=tr->Pt();     
+           index=iCount-1;
+         }
+       }
+      }
+      else{
+       if(tr->Pt()>ptmax){ 
+         ptmax=tr->Pt();       
+         index=iCount-1;
+       }
+      }
+     }
+  
+   
+    // else if (type == kTrackAODMCCharged) {
+    // TClonesArray *tca = dynamic_cast<TClonesArray*>(aod->FindListObject(AliAODMCParticle::StdBranchName()));
+    // if(!tca)return iCount;
+    // for(int it = 0;it < tca->GetEntriesFast();++it){
+    //   AliAODMCParticle *part = dynamic_cast<AliAODMCParticle*>(tca->At(it));
+    //   if(!part)continue;
+    //   if(part->Pt()<0.15)continue;
+    //   if(!part->IsPhysicalPrimary())continue;
+    //   if(part->Charge()==0)continue;
+    //   if(TMath::Abs(part->Eta())>0.9)continue;
+    //   list->Add(part);
+    //   iCount++;
+    //   if(part->Pt()>ptmax){ ptmax=part->Pt();
+    //         index=iCount-1;}}}
+      return index;
+}
+
+
+
+Int_t  AliAnalysisTaskJetCore::SelectTrigger(TList *list,Double_t minT,Double_t maxT,Int_t &number){
      Int_t iCount = 0;
      AliAODEvent *aod = 0;
      if(!fESD)aod = fAODIn;
      else aod = fAODOut;   
+     if(!aod)return 0;
      Int_t index=-1;
-     Double_t ptmax=-10;
-    for(int it = 0;it < aod->GetNumberOfTracks();++it){
+     Int_t triggers[100];
+     for(Int_t cr=0;cr<100;cr++){triggers[cr]=-1;}
+     Int_t im=0;
+     for(int it = 0;it < aod->GetNumberOfTracks();++it){
       AliAODTrack *tr = aod->GetTrack(it);
+      Bool_t bGood = false;
+      if(fFilterType == 0)bGood = true;
+      else if(fFilterType == 1)bGood = tr->IsHybridTPCConstrainedGlobal();
+      else if(fFilterType == 2)bGood = tr->IsHybridGlobalConstrainedGlobal();
       if((fFilterMask>0)&&!(tr->TestFilterBit(fFilterMask)))continue;
+       if(fRequireITSRefit==1){if((tr->GetStatus()&AliESDtrack::kITSrefit)==0)continue;}
+      if(bGood==false) continue;
+      if (fApplySharedClusterCut) {
+           Double_t frac = Double_t(tr->GetTPCnclsS()) /Double_t(tr->GetTPCncls());
+           if (frac > 0.4) continue;
+      }
       if(TMath::Abs(tr->Eta())>0.9)continue;
       if(tr->Pt()<0.15)continue;
       list->Add(tr);
       iCount++;
-      if(tr->Pt()>ptmax){ ptmax=tr->Pt();
-      index=iCount-1;}
       
-    }
+      if(tr->Pt()>=minT && tr->Pt()<maxT){
+       triggers[im]=iCount-1;
+        im=im+1;}
+
+     }
+      number=im;
+      Int_t rd=0;
+      if(im==0) rd=0;
+      if(im>0) rd=fRandom->Integer(im);
+      index=triggers[rd];
+
+     
   
    
-  return index;
+  
+      return index;
  
 }
 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
    Int_t  AliAnalysisTaskJetCore::GetHardestTrackBackToJet(AliAODJet *jetbig){
  
     AliAODEvent *aod = 0;
@@ -1381,7 +1297,7 @@ Int_t  AliAnalysisTaskJetCore::GetListOfTracks(TList *list){
       if(tr->Pt()<0.15)continue;
       iCount=iCount+1;
       dphi=RelativePhi(tr->Phi(),jetbig->Phi());  
-      if(TMath::Abs(dphi)<TMath::Pi()-0.2) continue;
+      if(TMath::Abs(dphi)<TMath::Pi()-0.6) continue;
       if(tr->Pt()>ptmax){ ptmax=tr->Pt();
       index=iCount-1;
       dif=dphi;  }}
@@ -1405,7 +1321,7 @@ Int_t  AliAnalysisTaskJetCore::GetListOfTracks(TList *list){
      if(!fESD)aod = fAODIn;
      else aod = fAODOut;   
   
-    for(int it = 0;it < aod->GetNumberOfTracks();++it){
+      for(int it = 0;it < aod->GetNumberOfTracks();++it){
       AliAODTrack *tr = aod->GetTrack(it);
       if((fFilterMask>0)&&!(tr->TestFilterBit(fFilterMask)))continue;
       if(TMath::Abs(tr->Eta())>0.9)continue;
@@ -1483,6 +1399,17 @@ Double_t AliAnalysisTaskJetCore::RelativePhi(Double_t mphi,Double_t vphi){
   return dphi;//dphi in [-Pi, Pi]
 }
 
+Int_t AliAnalysisTaskJetCore::GetPhiBin(Double_t phi)
+{
+    Int_t phibin=-1;
+    if(!(TMath::Abs(phi)<=2*TMath::Pi())){AliError("phi w.r.t. RP out of defined range");return -1;}
+    Double_t phiwrtrp=TMath::ACos(TMath::Abs(TMath::Cos(phi)));
+    phibin=Int_t(fNRPBins*phiwrtrp/(0.5*TMath::Pi()));
+    if(phibin<0||phibin>=fNRPBins){AliError("Phi Bin not defined");}
+    return phibin;
+}
+
+
 
 
 THnSparse* AliAnalysisTaskJetCore::NewTHnSparseF(const char* name, UInt_t entries)