]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGJE/AliAnalysisTaskJetCore.cxx
added method to propagate parameters only
[u/mrichter/AliRoot.git] / PWGJE / AliAnalysisTaskJetCore.cxx
index e16e40db3bef801c763a8997e784aefe32e0dab5..22f15f249966d311c309e6e5c0c32f13756bf1dd 100644 (file)
@@ -45,6 +45,7 @@
 #include "AliAnalysisHelperJetTasks.h"
 #include "AliInputEventHandler.h"
 #include "AliAODJetEventBackground.h"
+#include "AliAODMCParticle.h"
 #include "AliAnalysisTaskFastEmbedding.h"
 #include "AliAODEvent.h"
 #include "AliAODHandler.h"
 
 #include "AliAnalysisTaskJetCore.h"
 
+using std::cout;
+using std::endl;
+
 ClassImp(AliAnalysisTaskJetCore)
 
 AliAnalysisTaskJetCore::AliAnalysisTaskJetCore() :
 AliAnalysisTaskSE(),
 fESD(0x0),
-fAOD(0x0),
+fAODIn(0x0),
+fAODOut(0x0),
 fAODExtension(0x0),
 fBackgroundBranch(""),
 fNonStdFile(""),
 fIsPbPb(kTRUE),
+fDebug(0), 
 fOfflineTrgMask(AliVEvent::kAny),
 fMinContribVtx(1),
 fVtxZMin(-10.),
@@ -69,6 +75,8 @@ fVtxZMax(10.),
 fEvtClassMin(0),
 fEvtClassMax(4),
 fFilterMask(0),
+fFilterMaskBestPt(0),
+fFilterType(0),
 fRadioFrac(0.2),
 fMinDist(0.1),
 fCentMin(0.),
@@ -78,11 +86,21 @@ fNInputTracksMax(-1),
 fAngStructCloseTracks(0),
 fCheckMethods(0),
 fDoEventMixing(0), 
+fFlagPhiBkg(0),
+fFlagEtaBkg(0),
+fFlagJetHadron(0),
+fFlagRandom(0),
+fFlagOnlyRecoil(0),
+fFlagOnlyHardest(1),
+fTrackTypeRec(kTrackUndef),
+fRPAngle(0),
+fNRPBins(50),
 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),
@@ -104,6 +122,8 @@ fh2JetCoreMethod1C30(0x0),
 fh2JetCoreMethod2C30(0x0),
 fh2JetCoreMethod1C60(0x0),
 fh2JetCoreMethod2C60(0x0),
+fh3JetTrackC3060(0x0),
+fh3JetTrackC20(0x0),
 fh2AngStructpt1C10(0x0),
 fh2AngStructpt2C10(0x0),
 fh2AngStructpt3C10(0x0),
@@ -120,25 +140,19 @@ fh2AngStructpt1C60(0x0),
 fh2AngStructpt2C60(0x0),
 fh2AngStructpt3C60(0x0),
 fh2AngStructpt4C60(0x0),
-fh2JetsumHT1R2(0x0),
-fh2JetsumHT4R2(0x0),
-fh2JetsumHT8R2(0x0),
-fh2JetsumHT1R4(0x0),
-fh2JetsumHT4R4(0x0),
-fh2JetsumHT8R4(0x0),
-fh2JetsumHT1R6(0x0),
-fh2JetsumHT4R6(0x0),
-fh2JetsumHT8R6(0x0),
-fh2JetsumHT1R8(0x0),
-fh2JetsumHT4R8(0x0),
-fh2JetsumHT8R8(0x0),
-fh2JetsumHT1R10(0x0),
-fh2JetsumHT4R10(0x0),
-fh2JetsumHT8R10(0x0),
-fh3spectriggered(0x0),
-fh3specbiased(0x0),
-fh3spectot(0x0),
-fh3spectotb(0x0)
+fh2Ntriggers(0x0),
+fh2Ntriggers2C10(0x0),
+fh2Ntriggers2C20(0x0), 
+fh3JetDensity(0x0),
+fh3JetDensityA4(0x0),
+fh2RPJetsC10(0x0),
+fh2RPJetsC20(0x0),
+fh2RPTC10(0x0),
+fh2RPTC20(0x0), 
+fh3spectriggeredC10(0x0),
+fh3spectriggeredC20(0x0),
+fh3spectriggeredC3060(0x0)
+
  
 {
    // default Constructor
@@ -146,7 +160,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;
                }                               
        }       
@@ -165,11 +179,13 @@ fh3spectotb(0x0)
 AliAnalysisTaskJetCore::AliAnalysisTaskJetCore(const char *name) :
 AliAnalysisTaskSE(name),
 fESD(0x0),
-fAOD(0x0),
+fAODIn(0x0),
+fAODOut(0x0),
 fAODExtension(0x0),
 fBackgroundBranch(""),
 fNonStdFile(""),
 fIsPbPb(kTRUE),
+fDebug(0),
 fOfflineTrgMask(AliVEvent::kAny),
 fMinContribVtx(1),
 fVtxZMin(-10.),
@@ -177,6 +193,8 @@ fVtxZMax(10.),
 fEvtClassMin(0),
 fEvtClassMax(4),
 fFilterMask(0),
+fFilterMaskBestPt(0),
+fFilterType(0),
 fRadioFrac(0.2),
 fMinDist(0.1),
 fCentMin(0.),
@@ -186,11 +204,21 @@ fNInputTracksMax(-1),
 fAngStructCloseTracks(0),
 fCheckMethods(0),
 fDoEventMixing(0),
+fFlagPhiBkg(0),
+fFlagEtaBkg(0),
+fFlagJetHadron(0),
+fFlagRandom(0),
+fFlagOnlyRecoil(0),
+fFlagOnlyHardest(1),
+fTrackTypeRec(kTrackUndef),
+fRPAngle(0),
+fNRPBins(50),
 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),
@@ -212,6 +240,8 @@ fh2JetCoreMethod1C30(0x0),
 fh2JetCoreMethod2C30(0x0),
 fh2JetCoreMethod1C60(0x0),
 fh2JetCoreMethod2C60(0x0),
+fh3JetTrackC3060(0x0),
+fh3JetTrackC20(0x0),
 fh2AngStructpt1C10(0x0),
 fh2AngStructpt2C10(0x0),
 fh2AngStructpt3C10(0x0),
@@ -228,31 +258,25 @@ fh2AngStructpt1C60(0x0),
 fh2AngStructpt2C60(0x0),
 fh2AngStructpt3C60(0x0),
 fh2AngStructpt4C60(0x0),    
-fh2JetsumHT1R2(0x0),
-fh2JetsumHT4R2(0x0),
-fh2JetsumHT8R2(0x0),
-fh2JetsumHT1R4(0x0),
-fh2JetsumHT4R4(0x0),
-fh2JetsumHT8R4(0x0),
-fh2JetsumHT1R6(0x0),
-fh2JetsumHT4R6(0x0),
-fh2JetsumHT8R6(0x0),
-fh2JetsumHT1R8(0x0),
-fh2JetsumHT4R8(0x0),
-fh2JetsumHT8R8(0x0),
-fh2JetsumHT1R10(0x0),
-fh2JetsumHT4R10(0x0),
-fh2JetsumHT8R10(0x0),
-fh3spectriggered(0x0),
-fh3specbiased(0x0),
-fh3spectot(0x0),
-fh3spectotb(0x0)
+fh2Ntriggers(0x0),
+fh2Ntriggers2C10(0x0),
+fh2Ntriggers2C20(0x0),
+fh3JetDensity(0x0),
+fh3JetDensityA4(0x0),
+fh2RPJetsC10(0x0),
+fh2RPJetsC20(0x0),
+fh2RPTC10(0x0),
+fh2RPTC20(0x0), 
+fh3spectriggeredC10(0x0),
+fh3spectriggeredC20(0x0),
+fh3spectriggeredC3060(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;
                }                               
     }  
@@ -318,8 +342,8 @@ void AliAnalysisTaskJetCore::UserCreateOutputObjects()
      Double_t *xPt3 = new Double_t[10];
      xPt3[0] = 0.;
      for(int i = 1; i<=9;i++){
-      if(xPt3[i-1]<1)xPt3[i] = xPt3[i-1] + 0.2; // 1 - 5
-      else if(xPt3[i-1]<10)xPt3[i] = xPt3[i-1] + 3; // 5 - 12
+      if(xPt3[i-1]<2)xPt3[i] = xPt3[i-1] + 0.4; // 1 - 5
+      else if(xPt3[i-1]<11)xPt3[i] = xPt3[i-1] + 3; // 5 - 12
       else xPt3[i] = xPt3[i-1] + 150.; // 18 
      }
     fhnDeltaR->SetBinEdges(2,xPt3);
@@ -344,12 +368,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);
@@ -359,7 +381,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);}
 
-   
+    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.);
@@ -378,25 +401,23 @@ 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.); }
 
-    fh2JetsumHT1R2 = new TH2F("Pt sum R02 HT1","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT4R2 = new TH2F("Pt sum R02 HT4","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT8R2 = new TH2F("Pt sum R02 HT8","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT1R4 = new TH2F("Pt sum R04 HT1","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT4R4 = new TH2F("Pt sum R04 HT4","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT8R4 = new TH2F("Pt sum R04 HT8","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT1R6 = new TH2F("Pt sum R06 HT1","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT4R6 = new TH2F("Pt sum R06 HT4","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT8R6 = new TH2F("Pt sum R06 HT8","",20,0.,200.,100,0.,10.); 
-    fh2JetsumHT1R8 = new TH2F("Pt sum R08 HT1","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT4R8 = new TH2F("Pt sum R08 HT4","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT8R8 = new TH2F("Pt sum R08 HT8","",20,0.,200.,100,0.,10.); 
-    fh2JetsumHT1R10 = new TH2F("Pt sum R10 HT1","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT4R10 = new TH2F("Pt sum R10 HT4","",20,0.,200.,100,0.,10.);
-    fh2JetsumHT8R10 = new TH2F("Pt sum R10 HT8","",20,0.,200.,100,0.,10.);  
-    fh3spectriggered = new TH3F("Triggered spectrum","",10,0,100,50,0.,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 0-20","",50,0.,200.,50,0.,50.,50,0.,50.);    
+   
+
+    fh2Ntriggers=new TH2F("# of triggers","",10,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.4","",100,0.,4000.,100,0.,5.,10,0.,50.);
+    fh3JetDensityA4=new TH3F("Jet density vs multiplicity A>0.4","",100,0.,4000.,100,0.,5.,10,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.);  
+    fh3spectriggeredC10 = new TH3F("Triggered spectrumC10","",100,0.,1.,140,-80.,200.,50,0.,50.);
+    fh3spectriggeredC20 = new TH3F("Triggered spectrumC20","",100,0.,1.,140,-80.,200.,50,0.,50.);
+    fh3spectriggeredC3060 = new TH3F("Triggered spectrumC3060","",100,0.,1.,140,-80.,200.,10,0.,50.);
+
+    
+    
    fOutputList->Add(fHistEvtSelection);
 
    fOutputList->Add(fhnDeltaR);
@@ -416,7 +437,10 @@ void AliAnalysisTaskJetCore::UserCreateOutputObjects()
       fOutputList->Add(fh2JetCoreMethod1C60);
       fOutputList->Add(fh2JetCoreMethod2C60);}
       
-      
+      fOutputList->Add(fh3JetTrackC3060);
+      fOutputList->Add(fh3JetTrackC20);
+     
+            
      
 
 
@@ -439,30 +463,23 @@ void AliAnalysisTaskJetCore::UserCreateOutputObjects()
        fOutputList->Add(fh2AngStructpt4C60);}  
 
 
-       fOutputList->Add(fh2JetsumHT1R2);
-        fOutputList->Add(fh2JetsumHT4R2);
-               fOutputList->Add(fh2JetsumHT8R2);
-
-               fOutputList->Add(fh2JetsumHT1R4);
-        fOutputList->Add(fh2JetsumHT4R4);
-               fOutputList->Add(fh2JetsumHT8R4);
 
-        fOutputList->Add(fh2JetsumHT1R6);
-        fOutputList->Add(fh2JetsumHT4R6);
-               fOutputList->Add(fh2JetsumHT8R6);
 
-               fOutputList->Add(fh2JetsumHT1R8);
-        fOutputList->Add(fh2JetsumHT4R8);
-               fOutputList->Add(fh2JetsumHT8R8);
-
-        fOutputList->Add(fh2JetsumHT1R10);
-        fOutputList->Add(fh2JetsumHT4R10);
-               fOutputList->Add(fh2JetsumHT8R10); 
+       fOutputList->Add(fh2Ntriggers);
+        fOutputList->Add(fh2Ntriggers2C10);
+        fOutputList->Add(fh2Ntriggers2C20); 
+        fOutputList->Add(fh3JetDensity);
+        fOutputList->Add(fh3JetDensityA4);
+        fOutputList->Add(fh2RPJetsC10);
+        fOutputList->Add(fh2RPJetsC20);
+         fOutputList->Add(fh2RPTC10);
+        fOutputList->Add(fh2RPTC20);
+        fOutputList->Add(fh3spectriggeredC10); 
+        fOutputList->Add(fh3spectriggeredC20); 
+        fOutputList->Add(fh3spectriggeredC3060);   
 
-       fOutputList->Add(fh3spectriggered);
-       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));
@@ -492,10 +509,17 @@ void AliAnalysisTaskJetCore::UserExec(Option_t *)
    fESD=dynamic_cast<AliESDEvent*>(InputEvent());
    if (!fESD) {
       AliError("ESD not available");
-      fAOD = dynamic_cast<AliAODEvent*>(InputEvent());
-   } else {
-      fAOD = dynamic_cast<AliAODEvent*>(AODEvent());
-   }
+      fAODIn = dynamic_cast<AliAODEvent*>(InputEvent());
+   } 
+      fAODOut = dynamic_cast<AliAODEvent*>(AODEvent());
+
+       static AliAODEvent* aod = 0;
+       // take all other information from the aod we take the tracks from
+       if(!aod){
+       if(!fESD)aod = fAODIn;
+       else aod = fAODOut;}
+
+   
  
     if(fNonStdFile.Length()!=0){
     // case that we have an AOD extension we need can fetch the jets from the extended output
@@ -506,16 +530,13 @@ void AliAnalysisTaskJetCore::UserExec(Option_t *)
     }}
     
 
-
-
-
    // -- event selection --
    fHistEvtSelection->Fill(1); // number of events before event selection
 
    // physics 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);
@@ -524,12 +545,12 @@ void AliAnalysisTaskJetCore::UserExec(Option_t *)
    }
 
    // vertex selection
-   if(!fAOD){
+   if(!aod){
      if(fDebug) Printf("%s:%d No AOD",(char*)__FILE__,__LINE__);
      fHistEvtSelection->Fill(3);
       PostData(1, fOutputList);
    }
-   AliAODVertex* primVtx = fAOD->GetPrimaryVertex();
+   AliAODVertex* primVtx = aod->GetPrimaryVertex();
 
    if(!primVtx){
      if(fDebug) Printf("%s:%d No primVtx",(char*)__FILE__,__LINE__);
@@ -560,16 +581,17 @@ void AliAnalysisTaskJetCore::UserExec(Option_t *)
    // centrality selection
    AliCentrality *cent = 0x0;
    Double_t centValue = 0.; 
+   if(fIsPbPb){
    if(fESD) {cent = fESD->GetCentrality();
      if(cent) centValue = cent->GetCentralityPercentile("V0M");}
-   else     centValue=fAOD->GetHeader()->GetCentrality();
+   else     centValue=aod->GetHeader()->GetCentrality();
    
    if(fDebug) printf("centrality: %f\n", centValue);
-   if (centValue < fCentMin || centValue > fCentMax){
+      if (centValue < fCentMin || centValue > fCentMax){
       fHistEvtSelection->Fill(4);
       PostData(1, fOutputList);
       return;
-   }
+      }}
 
 
    fHistEvtSelection->Fill(0); 
@@ -578,28 +600,40 @@ void AliAnalysisTaskJetCore::UserExec(Option_t *)
   
    // get background
    AliAODJetEventBackground* externalBackground = 0;
-   if(fAOD&&!externalBackground&&fBackgroundBranch.Length()){
-      externalBackground =  (AliAODJetEventBackground*)(fAOD->FindListObject(fBackgroundBranch.Data()));
+   if(fAODOut&&!externalBackground&&fBackgroundBranch.Length()){
+      externalBackground =  (AliAODJetEventBackground*)(fAODOut->FindListObject(fBackgroundBranch.Data()));
       if(!externalBackground)Printf("%s:%d Background branch not found %s",(char*)__FILE__,__LINE__,fBackgroundBranch.Data());;
    }
    if(fAODExtension&&!externalBackground&&fBackgroundBranch.Length()){
      externalBackground =  (AliAODJetEventBackground*)(fAODExtension->GetAOD()->FindListObject(fBackgroundBranch.Data()));
       if(!externalBackground)Printf("%s:%d Background branch not found %s",(char*)__FILE__,__LINE__,fBackgroundBranch.Data());;
    }
+
+    if(fAODIn&&!externalBackground&&fBackgroundBranch.Length()){
+      externalBackground =  (AliAODJetEventBackground*)(fAODIn->FindListObject(fBackgroundBranch.Data()));
+      if(!externalBackground)Printf("%s:%d Background branch not found %s",(char*)__FILE__,__LINE__,fBackgroundBranch.Data());;
+    }
    
    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];
    aodJets[0]=0;
-   if(fAOD&&!aodJets[0]){
-   aodJets[0] = dynamic_cast<TClonesArray*>(fAOD->FindListObject(fJetBranchName[0].Data())); 
-   aodJets[1] = dynamic_cast<TClonesArray*>(fAOD->FindListObject(fJetBranchName[1].Data()));  }
+   if(fAODOut&&!aodJets[0]){
+   aodJets[0] = dynamic_cast<TClonesArray*>(fAODOut->FindListObject(fJetBranchName[0].Data())); 
+   aodJets[1] = dynamic_cast<TClonesArray*>(fAODOut->FindListObject(fJetBranchName[1].Data()));  }
    if(fAODExtension && !aodJets[0]){ 
    aodJets[0] = dynamic_cast<TClonesArray*>(fAODExtension->GetAOD()->FindListObject(fJetBranchName[0].Data())); 
    aodJets[1] = dynamic_cast<TClonesArray*>(fAODExtension->GetAOD()->FindListObject(fJetBranchName[1].Data()));  }
+     if(fAODIn&&!aodJets[0]){
+   aodJets[0] = dynamic_cast<TClonesArray*>(fAODIn->FindListObject(fJetBranchName[0].Data())); 
+   aodJets[1] = dynamic_cast<TClonesArray*>(fAODIn->FindListObject(fJetBranchName[1].Data()));  } 
+
 
    //Double_t ptsub[aodJets[0]->GetEntriesFast()];
    //Int_t inord[aodJets[0]->GetEntriesFast()];
@@ -612,10 +646,7 @@ void AliAnalysisTaskJetCore::UserExec(Option_t *)
      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);
@@ -630,46 +661,83 @@ void AliAnalysisTaskJetCore::UserExec(Option_t *)
    Double_t etasmall=0;
    Double_t ptsmall=0;
    Double_t areasmall=0;
-   //Double_t distr=0.;
    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();     
+
+   AliVParticle *partback = (AliVParticle*)ParticleList.At(nT);     
+   if(!partback){  
+   PostData(1, fOutputList);
+   return;}
+
+
+   //for(Int_t tt=0;tt<ParticleList.GetEntries();tt++){
+   //if(fFlagOnlyHardest!=0){if(tt!=nT) continue;}
+   //AliVParticle *partback = (AliVParticle*)ParticleList.At(tt);     
+
+   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());
+   Double_t accep=2.*TMath::Pi()*1.8;
+   Int_t injet4=0;
+   Int_t injet=0; 
+
    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(ptcorr<=0) continue;
           if((etabig<fJetEtaMin)||(etabig>fJetEtaMax)) continue;
+           if(areabig>=0.07) injet=injet+1;
+           if(areabig>=0.4) injet4=injet4+1;   
+           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!=0) 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(fFlagJetHadron!=0) if(TMath::Abs(dphi)>0.4) 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;
-                  
-               Int_t point=GetHardestTrackBackToJet(jetbig);    
-              AliVParticle *partback = (AliVParticle*)ParticleList.At(point);                            
-               if(!partback) continue; 
-                  fh3spectriggered->Fill(centValue,ptcorr,partback->Pt());
-                  //if(partback->Pt()<6.) continue;
-                       AliAODTrack* leadtrack; 
+          
+          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());
+
+                   if(ptcorr<=0) continue;
+
+                       AliAODTrack* leadtrack=0; 
                        Int_t ippt=0;
-                       Double_t ppt=-10;   
+                       Double_t ppt=-10;
+                       if(fFlagJetHadron==0){   
                       TRefArray *genTrackList = jetbig->GetRefTracks();
                        Int_t nTracksGenJet = genTrackList->GetEntriesFast();
                        AliAODTrack* genTrack;
@@ -677,19 +745,28 @@ void AliAnalysisTaskJetCore::UserExec(Option_t *)
                        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<20)fh3spectotb->Fill(ptcorr,leadtrack->Pt(),partback->Pt()); 
+                       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((partback->Pt()>10.)&&(iCount==0)){                        
+                        if(iCount==0){                        
                          trigJet=i;
-                          trigBBTrack=point;
+                          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));
@@ -717,100 +794,57 @@ 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 sumpt2d=0.;
-                  Double_t sumpt4a=0.;
-                  Double_t sumpt4b=0.;
-                  Double_t sumpt4d=0.;
-                  Double_t sumpt6a=0.;
-                  Double_t sumpt6b=0.;
-                  Double_t sumpt6d=0.;
-                  Double_t sumpt8a=0.;
-                  Double_t sumpt8b=0.;
-                  Double_t sumpt8d=0.;  
-                  Double_t sumpt10a=0.;
-                  Double_t sumpt10b=0.;
-                  Double_t sumpt10d=0.;  
-
-          for(int it = 0;it<nT;++it){
+                 if(centValue<10) fh2Ntriggers2C10->Fill(leadtrack->Pt(),partback->Pt());                  
+                  if(centValue<20) 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);
-          if(partback->Pt()>10.){
-            if(centValue<10){
-
-                             if(deltaR<0.2){if(leadtrack->Pt()>1.) sumpt2a=sumpt2a+part->Pt();
-                                            if(leadtrack->Pt()>4.) sumpt2b=sumpt2b+part->Pt(); 
-                                            if(leadtrack->Pt()>8.) sumpt2d=sumpt2d+part->Pt();}    
-              if(deltaR>=0.2 && deltaR<0.4){if(leadtrack->Pt()>1.) sumpt4a=sumpt4a+part->Pt();
-                                            if(leadtrack->Pt()>4.) sumpt4b=sumpt4b+part->Pt(); 
-                                            if(leadtrack->Pt()>8.) sumpt4d=sumpt4d+part->Pt();}                                                    if(deltaR>=0.4 && deltaR<0.6){if(leadtrack->Pt()>1.) sumpt6a=sumpt6a+part->Pt();
-                                            if(leadtrack->Pt()>4.) sumpt6b=sumpt6b+part->Pt(); 
-                                            if(leadtrack->Pt()>8.) sumpt6d=sumpt6d+part->Pt();}      
-               if(deltaR>=0.6 && deltaR<0.8){if(leadtrack->Pt()>1.) sumpt8a=sumpt8a+part->Pt();
-                                            if(leadtrack->Pt()>4.) sumpt8b=sumpt8b+part->Pt(); 
-                                            if(leadtrack->Pt()>8.) sumpt8d=sumpt8d+part->Pt();}      
-               if(deltaR>=0.8 && deltaR<1.2){if(leadtrack->Pt()>1.)sumpt10a=sumpt10a+part->Pt();
-                                            if(leadtrack->Pt()>4.) sumpt10b=sumpt10b+part->Pt(); 
-                                            if(leadtrack->Pt()>8.) sumpt10d=sumpt10d+part->Pt();}   }}
-
           Double_t deltaEta = etabig-part->Eta();
+         
           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){
-         
-          fh2JetsumHT1R2->Fill(ptcorr,sumpt2a/rhoin2);
-          fh2JetsumHT4R2->Fill(ptcorr,sumpt2b/rhoin2);
-          fh2JetsumHT8R2->Fill(ptcorr,sumpt2d/rhoin2);
-         
-          fh2JetsumHT1R4->Fill(ptcorr,sumpt4a/rhoin4);
-          fh2JetsumHT4R4->Fill(ptcorr,sumpt4b/rhoin4);
-          fh2JetsumHT8R4->Fill(ptcorr,sumpt4d/rhoin4);
-         
-          fh2JetsumHT1R6->Fill(ptcorr,sumpt6a/rhoin6);
-          fh2JetsumHT4R6->Fill(ptcorr,sumpt6b/rhoin6);
-          fh2JetsumHT8R6->Fill(ptcorr,sumpt6d/rhoin6);
-         
-          fh2JetsumHT1R8->Fill(ptcorr,sumpt8a/rhoin8);
-          fh2JetsumHT4R8->Fill(ptcorr,sumpt8b/rhoin8);
-          fh2JetsumHT8R8->Fill(ptcorr,sumpt8d/rhoin8);
+         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
          
-          fh2JetsumHT1R10->Fill(ptcorr,sumpt10a/rhoin10);
-          fh2JetsumHT4R10->Fill(ptcorr,sumpt10b/rhoin10);
-          fh2JetsumHT8R10->Fill(ptcorr,sumpt10d/rhoin10);}
+
+
+
+
+       
+
+
 
    }
+   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);         
@@ -819,34 +853,33 @@ 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;}
                }
-         }
+              }
          
-
+         }
 
 
 
@@ -959,50 +992,86 @@ 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;   
+      Int_t index=-1;
+     Double_t ptmax=-10;
 
 
-
-
-Int_t  AliAnalysisTaskJetCore::GetListOfTracks(TList *list){
-
-    Int_t iCount = 0;
     
-    for(int it = 0;it < fAOD->GetNumberOfTracks();++it){
-      AliAODTrack *tr = fAOD->GetTrack(it);
-      if((fFilterMask>0)&&!(tr->TestFilterBit(fFilterMask)))continue;
+     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(bGood==false) continue;
       if(TMath::Abs(tr->Eta())>0.9)continue;
       if(tr->Pt()<0.15)continue;
       list->Add(tr);
-      //cout<<fAOD->GetNumberOfTracks()<<" "<<tr->Pt()<<endl;
       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;
+       }
+      }
+     }
   
    
-  return iCount;
+    // 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::GetHardestTrackBackToJet(AliAODJet *jetbig){
-
-   
+    AliAODEvent *aod = 0;
+    if(!fESD)aod = fAODIn;
+    else aod = fAODOut;     
     Int_t index=-1;
     Double_t ptmax=-10;
     Double_t dphi=0;
     Double_t dif=0;
     Int_t iCount=0;
-    for(int it = 0;it < fAOD->GetNumberOfTracks();++it){
-      AliAODTrack *tr = fAOD->GetTrack(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;
       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;  }}
@@ -1022,10 +1091,12 @@ Int_t  AliAnalysisTaskJetCore::GetListOfTracks(TList *list){
  Int_t  AliAnalysisTaskJetCore::GetListOfTracksCloseToJet(TList *list,AliAODJet *jetbig){
 
     Int_t iCount = 0;
+      AliAODEvent *aod = 0;
+     if(!fESD)aod = fAODIn;
+     else aod = fAODOut;   
   
-    for(int it = 0;it < fAOD->GetNumberOfTracks();++it){
-      AliAODTrack *tr = fAOD->GetTrack(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;
       if(tr->Pt()<0.15)continue;
@@ -1055,7 +1126,9 @@ Int_t AliAnalysisTaskJetCore::GetNInputTracks()
 {
 
    Int_t nInputTracks = 0;
-
+     AliAODEvent *aod = 0;
+     if(!fESD)aod = fAODIn;
+     else aod = fAODOut;   
    TString jbname(fJetBranchName[1]);
    //needs complete event, use jets without background subtraction
    for(Int_t i=1; i<=3; ++i){
@@ -1066,7 +1139,7 @@ Int_t AliAnalysisTaskJetCore::GetNInputTracks()
    if(jbname.Contains("AODextra")) jbname.ReplaceAll("AODextra","AOD");
 
    if(fDebug) Printf("Multiplicity from jet branch %s", jbname.Data());
-   TClonesArray *tmpAODjets = dynamic_cast<TClonesArray*>(fAOD->FindListObject(jbname.Data()));
+   TClonesArray *tmpAODjets = dynamic_cast<TClonesArray*>(aod->FindListObject(jbname.Data()));
    if(!tmpAODjets){
       Printf("Jet branch %s not found", jbname.Data());
       Printf("AliAnalysisTaskJetCore::GetNInputTracks FAILED");
@@ -1100,6 +1173,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)
@@ -1167,7 +1251,7 @@ void AliAnalysisTaskJetCore::GetDimParams(Int_t iEntry, TString &label, Int_t &n
      
          nbins = 9;
          xmin = 0.;
-         xmax = 150.;
+         xmax = 150;
          break;
       
       
@@ -1188,7 +1272,7 @@ void AliAnalysisTaskJetCore::GetDimParams(Int_t iEntry, TString &label, Int_t &n
       break;
 
 
-    case 5:
+  case 5:
       label = "deltaPhi";
       nbins = 90;
       xmin = -0.5*pi;
@@ -1207,7 +1291,7 @@ void AliAnalysisTaskJetCore::GetDimParams(Int_t iEntry, TString &label, Int_t &n
      case 7:
     
       label = "trigger track";
-      nbins =5;
+      nbins =10;
       xmin = 0;
       xmax = 50;
       break;