Changed handling of extra AODs, allow to run several instances of background subtraction
authorkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 27 Jan 2011 12:05:26 +0000 (12:05 +0000)
committerkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 27 Jan 2011 12:05:26 +0000 (12:05 +0000)
JETAN/AliAnalysisTaskFastEmbedding.cxx
JETAN/AliAnalysisTaskFastEmbedding.h
PWG4/macros/AddTaskFastEmbedding.C
PWG4/macros/AddTaskJetBackgroundSubtract.C
PWG4/macros/AddTaskJetResponse.C
PWG4/macros/AnalysisTrainPWG4Jets.C

index 7c0aec0..7e33f31 100644 (file)
@@ -58,9 +58,8 @@ AliAnalysisTaskFastEmbedding::AliAnalysisTaskFastEmbedding()
       ,fAODPath("AliAOD.root")
       ,fTrackBranch("aodExtraTracks")
       ,fMCparticlesBranch("aodExtraMCparticles")
+      ,fJetBranch("")
       ,fEntry(0)
-      ,fJobId(0)
-      ,fNEntriesPerJob(1000)
       ,fEmbedMode(0)
       ,fEvtSelecMode(0)
       ,fEvtSelMinJetPt(-1)
@@ -102,9 +101,8 @@ AliAnalysisTaskFastEmbedding::AliAnalysisTaskFastEmbedding(const char *name)
       ,fAODPath("AliAOD.root")
       ,fTrackBranch("aodExtraTracks")
       ,fMCparticlesBranch("aodExtraMCparticles")
+      ,fJetBranch("")
       ,fEntry(0)
-      ,fJobId(0)
-      ,fNEntriesPerJob(1000)
       ,fEmbedMode(0)
       ,fEvtSelecMode(0)
       ,fEvtSelMinJetPt(-1)
@@ -144,9 +142,8 @@ AliAnalysisTaskFastEmbedding::AliAnalysisTaskFastEmbedding(const AliAnalysisTask
       ,fAODPath(copy.fAODPath)
       ,fTrackBranch(copy.fTrackBranch)
       ,fMCparticlesBranch(copy.fMCparticlesBranch)
+      ,fJetBranch(copy.fJetBranch)
       ,fEntry(copy.fEntry)
-      ,fJobId(copy.fJobId)
-      ,fNEntriesPerJob(copy.fNEntriesPerJob)
       ,fEmbedMode(copy.fEmbedMode)
       ,fEvtSelecMode(copy.fEvtSelecMode)
       ,fEvtSelMinJetPt(copy.fEvtSelMinJetPt)
@@ -189,9 +186,8 @@ AliAnalysisTaskFastEmbedding& AliAnalysisTaskFastEmbedding::operator=(const AliA
         fAODPath           = o.fAODPath;
         fTrackBranch       = o.fTrackBranch;
         fMCparticlesBranch = o.fMCparticlesBranch;
+        fJetBranch         = o.fJetBranch;
         fEntry             = o.fEntry;
-        fJobId             = o.fJobId;
-        fNEntriesPerJob    = o.fNEntriesPerJob;
         fEmbedMode         = o.fEmbedMode;
         fEvtSelecMode      = o.fEvtSelecMode;
         fEvtSelMinJetPt    = o.fEvtSelMinJetPt;
@@ -245,33 +241,13 @@ void AliAnalysisTaskFastEmbedding::UserCreateOutputObjects()
 
        // open input AOD
        if(fAODPathArray){
-           Int_t nFiles = fAODPathArray->GetEntries();
-           Int_t n = rndm->Integer(nFiles);
-           AliInfo(Form("Select file %d", n));
-           TObjString *objStr = (TObjString*) fAODPathArray->At(n);
-           if(!objStr){
-              AliError("Could not get path of aod file.");
-              return;
-           }
-           fAODPath = objStr->GetString();
+           Int_t rc = SelectAODfile();
+           if(rc<0) return;
        }
 
-       TDirectory *owd = gDirectory;
-       fAODfile = TFile::Open(fAODPath.Data());
-       owd->cd();
-       if(!fAODfile){
-              AliError("Could not open AOD file.");
-              return;
-       }
+       Int_t rc = OpenAODfile();
+       if(rc<0) return;
 
-       fAODtree = (TTree*)fAODfile->Get("aodTree");
-          
-       if(!fAODtree){
-           AliError("AOD tree not found.");
-          return;
-       }
-       fAODevent = new AliAODEvent();
-       fAODevent->ReadFromTree(fAODtree);
     } //end: embed mode with AOD
 
 
@@ -371,20 +347,43 @@ void AliAnalysisTaskFastEmbedding::UserExec(Option_t *)
           return;
        }
 
-       Int_t maxEntry = fEntry+fNEntriesPerJob-1;
+       // fetch jets
+       TClonesArray *aodJets = 0;
+       if(fJetBranch.Length()) aodJets = dynamic_cast<TClonesArray*>(fAODevent->FindListObject(fJetBranch.Data()));
+       else                    aodJets = fAODevent->GetJets();
+       if(!aodJets){
+          AliError("Could not find jets in AOD. Check jet branch when indicated.");
+          return;
+       }
+        
+
        Int_t nEvents = fAODtree->GetEntries();
-       if(maxEntry>nEvents) maxEntry=nEvents;
 
        Bool_t useEntry = kFALSE;
        while(!useEntry){  // protection need, if no event fulfills requierment
-          if(fEntry>maxEntry) fEntry=fJobId*fNEntriesPerJob;
+          if(fEntry>nEvents){
+              fEntry=0;
+              if(!fAODPathArray){
+                 AliDebug(AliLog::kDebug, "Last event in AOD reached, start from entry 0 again.");
+              } 
+              else {
+                 AliDebug(AliLog::kDebug, "Last event in AOD reached, select new AOD file ...");
+                 Int_t rc = SelectAODfile();
+                 if(rc<0) return;
+
+                 rc = OpenAODfile();
+                 if(rc<0) return;
+              }
+          }
+    
           fAODtree->GetEvent(fEntry);
 
          // jet pt selection
          if(fEvtSelecMode==kEventsJetPt){
-             Int_t nJets = fAODevent->GetNJets();
+             Int_t nJets = aodJets->GetEntries();
              for(Int_t ij=0; ij<nJets; ++ij){
-                 AliAODJet *jet = fAODevent->GetJet(ij);
+                 AliAODJet *jet = dynamic_cast<AliAODJet*>(aodJets->At(ij));
+                 if(!jet) continue;
 
                  if(   (fEvtSelMinJetPt==-1. || jet->Pt()>=fEvtSelMinJetPt)
                    && (fEvtSelMaxJetPt==-1. || jet->Pt()<=fEvtSelMaxJetPt)){
@@ -469,10 +468,11 @@ void AliAnalysisTaskFastEmbedding::UserExec(Option_t *)
        if(fEmbedMode==kAODJet4Mom){
 
           // loop over jets
-          Int_t nJets = fAODevent->GetNJets();
+          Int_t nJets = aodJets->GetEntries();
            fh1TrackN->Fill((Float_t)nJets);
           for(Int_t ij=0; ij<nJets; ++ij){
-              AliAODJet *jet = fAODevent->GetJet(ij);
+               AliAODJet *jet = dynamic_cast<AliAODJet*>(aodJets->At(ij));
+               if(!jet) continue;
               AliAODTrack *tmpTr = (AliAODTrack*)jet;
 
               new ((*tracks)[nAODtracks++]) AliAODTrack(*tmpTr);
@@ -571,7 +571,6 @@ void AliAnalysisTaskFastEmbedding::Terminate(Option_t *)
 }
 
 //__________________________________________________________________________
-/* NEEDS TO BE TESTED */
 Int_t AliAnalysisTaskFastEmbedding::GetJobID()
 {
    Int_t id=-1;
@@ -585,11 +584,6 @@ Int_t AliAnalysisTaskFastEmbedding::GetJobID()
    }
    else{
        AliInfo("Job index not found. Okay if running locally.");
-       /*
-       Int_t nEvents = fAODtree->GetEntries();
-       fNEntriesPerJob = nEvents;
-       AliInfo(Form("Asuming single job, set entries per job to maximum %d", fNEntriesPerJob));
-       */
    }
 
    return id;
@@ -597,5 +591,45 @@ Int_t AliAnalysisTaskFastEmbedding::GetJobID()
 
 //__________________________________________________________________________
 
+Int_t AliAnalysisTaskFastEmbedding::SelectAODfile(){
 
+     Int_t nFiles = fAODPathArray->GetEntries();
+     Int_t n = rndm->Integer(nFiles);
+     AliInfo(Form("Select AOD file %d", n));
+     TObjString *objStr = (TObjString*) fAODPathArray->At(n);
+     if(!objStr){
+          AliError("Could not get path of aod file.");
+          return -1;
+     }
+     fAODPath = objStr->GetString();
+
+     return n;
+}
+
+Int_t AliAnalysisTaskFastEmbedding::OpenAODfile(){
+
+    TDirectory *owd = gDirectory;
+    fAODfile = TFile::Open(fAODPath.Data());
+    owd->cd();
+    if(!fAODfile){
+       AliError("Could not open AOD file.");
+       return -1;
+    }
+
+    fAODtree = (TTree*)fAODfile->Get("aodTree");
+
+    if(!fAODtree){
+       AliError("AOD tree not found.");
+       return -1;
+    }
+
+    fAODevent = new AliAODEvent();
+    fAODevent->ReadFromTree(fAODtree);
+    if(!fAODevent){
+       AliError("AOD event not found.");
+       return -1;
+    }
+
+    return 1;
+}
 
index e5fc864..f3288bf 100644 (file)
@@ -38,9 +38,7 @@ class AliAnalysisTaskFastEmbedding : public AliAnalysisTaskSE {
        void SetArrayOfAODPaths(TObjArray* arr) {fAODPathArray = arr;}
         void SetTrackBranch(TString name) {fTrackBranch = name;}
         void SetMCparticlesBranch(TString name) {fMCparticlesBranch = name;}
-
-       void SetNEntriesPerJob(Int_t n) {fNEntriesPerJob = n;}
-       Int_t GetNEntriesPerJob() { return fNEntriesPerJob;}
+        void SetJetBranch(TString name) {fJetBranch = name;}
 
        void SetEmbedMode(Int_t m) {fEmbedMode = m;}
        Int_t GetEmbedMode() {return fEmbedMode;} 
@@ -79,10 +77,9 @@ class AliAnalysisTaskFastEmbedding : public AliAnalysisTaskSE {
 
         TString fTrackBranch; // name of branch for extra tracks in AOD out
         TString fMCparticlesBranch; // name of branch for extra mcparticles in AOD out
+        TString fJetBranch; // name of branch for extra jets AOD in
 
         Int_t fEntry; // entry of extra AOD
-       Int_t fJobId; // (sub-)job counter
-       Int_t fNEntriesPerJob; // number of entries of extra AOD used per (sub-)job
 
        Int_t fEmbedMode;
        Int_t fEvtSelecMode;
@@ -115,11 +112,12 @@ class AliAnalysisTaskFastEmbedding : public AliAnalysisTaskSE {
         TH2F  *fh2MCTrackEtaPhi;   //! MC track eta-phi
         TH1F  *fh1MCTrackN;        //! nb. of MC tracks
 
-        // NEEDS TO BE TESTED
        Int_t GetJobID();    // get job id (sub-job id on the GRID)
+        Int_t SelectAODfile();
+        Int_t OpenAODfile();
 
 
-       ClassDef(AliAnalysisTaskFastEmbedding, 2);
+       ClassDef(AliAnalysisTaskFastEmbedding, 3);
 };
 
 #endif
index 090bbec..28ee916 100644 (file)
@@ -19,7 +19,7 @@ AliAnalysisTaskFastEmbedding* AddTaskFastEmbedding(){
 
     // ## set ranges for toy ##
     //SetToyTrackRanges(
-    Double_t minPt = 40.;   Double_t maxPt = 300.;
+    Double_t minPt = 30.;   Double_t maxPt = 300.;
     Double_t minEta = -0.5; Double_t maxEta = 0.5;
     Double_t minPhi = 0.;   Double_t maxPhi = 2*TMath::Pi();
     //fToyDistributionTrackPt: 0 = uniform distribution
@@ -65,11 +65,32 @@ AliAnalysisTaskFastEmbedding* AddTaskFastEmbedding(TObjArray* aodarray){
 }
 
 
-AliAnalysisTaskFastEmbedding* AddTaskFastEmbedding(const char* filepath){
+AliAnalysisTaskFastEmbedding* AddTaskFastEmbedding(const char* filepath, Int_t mode = 0){
 
     AliAnalysisTaskFastEmbedding *task = AddTaskFastEmbedding();
     if(strlen(filepath)){
-       task->SetAODPath(filepath);
+
+       if(mode==0){ // path to single AOD
+          task->SetAODPath(filepath);
+       }
+       if(mode==1){ // path to text file with list of paths of multiple AODs
+           TObjArray* array = new TObjArray();
+           TObjString* ostr = 0;
+           TString line;
+           ifstream in;
+           in.open(filepath);
+           while(in.good()){
+              in >> line;
+              if(line.Length() == 0) continue;
+              Printf("found aod path %s", line.Data());
+              ostr = new TObjString(line.Data());
+              array->Add(ostr);
+           }
+           Printf("-> %d aod paths found", array->GetEntries());
+           
+           task->SetArrayOfAODPaths(array);
+       }
+
        task->SetEmbedMode(AliAnalysisTaskFastEmbedding::kAODFull);
     }
 
index 549530c..36ad77d 100644 (file)
@@ -1,4 +1,4 @@
-AliAnalysisTaskJetBackgroundSubtract *AddTaskJetBackgroundSubtract(TString sJetBranches,Int_t iSubtraction = 1,char* cToReplace = "B0",char* cReplaceMask = "B%d"){
+AliAnalysisTaskJetBackgroundSubtract *AddTaskJetBackgroundSubtract(TString sJetBranches,Int_t iSubtraction = 1,char* cToReplace = "B0",char* cReplaceMask = "B%d", char* cSuffix = ""){
 
 
 
@@ -21,6 +21,7 @@ AliAnalysisTaskJetBackgroundSubtract *AddTaskJetBackgroundSubtract(TString sJetB
 
   TString cAdd;
   cAdd += Form(cReplaceMask,iSubtraction);
+  if(cSuffix!="") cAdd += Form("_%s",cSuffix);
 
   AliAnalysisTaskJetBackgroundSubtract *task = new AliAnalysisTaskJetBackgroundSubtract(Form("JetSubtract_%s",cAdd.Data()));
   for(int iJB = 0;iJB<objArr->GetEntries();iJB++){
index 687d4a3..b034a92 100644 (file)
@@ -1,4 +1,4 @@
-AliAnalysisTaskJetResponse* AddTaskJetResponse(Char_t* jf = "FASTKT", Float_t radius = 0.4, UInt_t filterMask = 256 , Float_t ptTrackMin = 0.15, Int_t iBack = 1, Int_t eventClassMin = 1, Int_t eventClassMax = 5){
+AliAnalysisTaskJetResponse* AddTaskJetResponse(Char_t* type = "clusters", Char_t* jf = "FASTKT", Float_t radius = 0.4, UInt_t filterMask = 256 , Float_t ptTrackMin = 0.15, Int_t iBack = 1, Int_t eventClassMin = 1, Int_t eventClassMax = 5){
 
   Printf("adding task jet response\n");
 
@@ -12,26 +12,32 @@ AliAnalysisTaskJetResponse* AddTaskJetResponse(Char_t* jf = "FASTKT", Float_t ra
        return NULL;
     }
 
-    AliAnalysisTaskJetResponse *task = new AliAnalysisTaskJetResponse("JetResponse");
-
-    TString branch1 = "jetsAODextraonly";
-    branch1 += Form("_%s", jf);
-    branch1 += Form("%02d", (int)((radius+0.01)*10.));
-    branch1 += Form("_B%d", iBack);
-    branch1 += Form("_Filter%05d", filterMask); 
-    branch1 += Form("_Cut%05d", (int)((1000.*kPtTrackMin)));
+    TString suffix = "";
+    suffix += Form("_%s", jf);
+    suffix += Form("%02d", (int)((radius+0.01)*10.));
+    suffix += Form("_B0");                                // no background subtraction for extra-only
+    suffix += Form("_Filter%05d", filterMask);
+    suffix += Form("_Cut%05d", (int)((1000.*ptTrackMin)));
+    if(type=="clusters") suffix += Form("_Skip00");
+
+    TString suffix2 = "";
+    suffix2 += Form("_%s", jf);
+    suffix2 += Form("%02d", (int)((radius+0.01)*10.));
+    suffix2 += Form("_B%d", iBack);
+    suffix2 += Form("_Filter%05d", filterMask);
+    suffix2 += Form("_Cut%05d", (int)((1000.*ptTrackMin)));
+    if(type=="clusters") suffix2 += Form("_Skip00");
+
+    AliAnalysisTaskJetResponse *task = new AliAnalysisTaskJetResponse(Form("JetResponse%s", suffix2.Data()));
+
+    TString branch1 = Form("%sAODextraonly%s",type, suffix.Data());
     Printf("Branch1: %s",branch1.Data());
 
-    TString branch2 = "jetsAODextra";
-    branch2 += Form("_%s", jf);
-    branch2 += Form("%02d", (int)((radius+0.01)*10.));
-    branch2 += Form("_B%d", iBack);
-    branch2 += Form("_Filter%05d", filterMask); 
-    branch2 += Form("_Cut%05d", (int)((1000.*kPtTrackMin)));
+    TString branch2 = Form("%sAODextra%s",type, suffix2.Data());
     Printf("Branch2: %s",branch2.Data());
  
     task->SetBranchNames(branch1,branch2);
-    //task->SetOfflineTrgMask(AliVEvent::kMB);
+    task->SetOfflineTrgMask(AliVEvent::kMB);
 
     task->SetEvtClassMin(eventClassMin);
     task->SetEvtClassMax(eventClassMax);
@@ -42,8 +48,8 @@ AliAnalysisTaskJetResponse* AddTaskJetResponse(Char_t* jf = "FASTKT", Float_t ra
     mgr->AddTask(task);
 
     AliAnalysisDataContainer *coutputJetResponse = mgr->CreateContainer(
-         Form("jetresponse%s%02d_B%d_Filter%05d_Cut%05d", jf, (int)((radius+0.01)*10.), iBack, filterMask, (int)((1000.*kPtTrackMin))), TList::Class(), AliAnalysisManager::kOutputContainer,
-         Form("%s:PWG4_JetResponse_%s%02d_B%d_Filter%05d_Cut%05d", AliAnalysisManager::GetCommonFileName(), jf, (int)((radius+0.01)*10.), iBack, filterMask, (int)((1000.*kPtTrackMin))));
+         Form("jetresponse_%s%s", type,suffix2.Data()), TList::Class(), AliAnalysisManager::kOutputContainer,
+         Form("%s:PWG4_JetResponse_%s%s", AliAnalysisManager::GetCommonFileName(), type, suffix2.Data()));
 
     mgr->ConnectInput (task, 0, mgr->GetCommonInputContainer());
     mgr->ConnectOutput(task, 0, mgr->GetCommonOutputContainer());
index 863790b..ecef04b 100644 (file)
@@ -84,7 +84,9 @@ Int_t       iJETAN             = 1;      // Jet analysis (PWG4) // 1 write stand
 Int_t       iJETSUBTRACT        = 1;      // Jet background subtration
 TString     kDefaultJetBranch     = "";      // is currently set when filled (iJETAN or clusters) or from config macro 
 TString     kDefaultJetBackgroundBranch     = "";      // is currently set when filled (jet clsuters  
+TString     kDefaultJetBackgroundBranch_extra     = "";      // is currently set when filled (jet clsuters  
 TString     kJetSubtractBranches     = "";      // is currently set when filled (jet clsuters  
+TString     kJetSubtractBranches_extra     = "";      // is currently set when filled (jet clsuters  
 
 TString     kDefaultJetBranchMC     = "";      // is currently set when filled (iJETAN or clusters) or from config macro 
 TString     kDefaultJetBackgroundBranchMC     = "";      // is currently set when filled (jet clsuters  
@@ -131,6 +133,7 @@ TString     kDeltaAODJetName   = "AliAOD.Jets.root";
 TString     kDeltaAODJCORRANName   = "AliAOD.JCORRAN.root";     
 TString     kDeltaAODPartCorrName   = "AliAOD.PartCorr.root";     
 TString     kFastEmbeddingAOD  = "emb/AliAOD.root";
+TString     kFastEmbAODList    = "";
 
 //==============================================================================
 // ### PROOF Steering varibales
@@ -175,9 +178,9 @@ Int_t         kGridRunRange[2]       =  {0, -1}; // Set the run range
 TString     kGridRunPattern        = "%03d"; // important for leading zeroes!!
 TString     kGridPassPattern       = "";
 TString     kGridExtraFiles        = ""; // files that will be added to the input list in the JDL...
-Int_t         kGridMaxMergeFiles      = 12; // Number of files merged in a chunk grid run range
-TString     kGridMergeExclude       = "AliAOD.root"; // Files that should not be merged
-TString     kGridOutputStorages      = "disk=2"; // Make replicas on the storages
+Int_t       kGridMaxMergeFiles     = 12; // Number of files merged in a chunk grid run range
+TString     kGridMergeExclude      = "AliAOD.root"; // Files that should not be merged
+TString     kGridOutputStorages     = "disk=2"; // Make replicas on the storages
 // == grid process variables
 Int_t       kGridRunsPerMaster     = 100; // Number of runs per master job
 Int_t       kGridFilesPerJob       = 100; // Maximum number of files per job (gives size of AOD)
@@ -435,7 +438,10 @@ void AnalysisTrainPWG4Jets(const char *analysis_mode="local",
 
    if (iPWG4FastEmbedding) {
      gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskFastEmbedding.C");
-     AliAnalysisTask *taskEmbedding = AddTaskFastEmbedding(kFastEmbeddingAOD);
+     AliAnalysisTaskFastEmbedding *taskEmbedding = 0;
+     if(kFastEmbAODList.Length()) taskEmbedding = AddTaskFastEmbedding(kFastEmbAODList, 1);
+     else                         taskEmbedding = AddTaskFastEmbedding(kFastEmbeddingAOD, 0);
+     //taskEmbedding->SetJetBranch("jets");
    }
 
     // Jet analysis
@@ -482,9 +488,18 @@ void AnalysisTrainPWG4Jets(const char *analysis_mode="local",
 
 
    if (iPWG4FastEmbedding && iJETAN) {
-     AliAnalysisTaskJets *taskEmbJets = AddTaskJets("AODextra", "FASTKT", 0.4, kHighPtFilterMask);
+     AliAnalysisTaskJets *taskEmbJets = AddTaskJets("AODextra", "FASTJET", 0.4, kHighPtFilterMask);
      taskEmbJets->ReadAODFromOutput();
-     taskEmbJets = AddTaskJets("AODextraonly", "FASTKT", 0.4, kHighPtFilterMask);
+     kJetSubtractBranches_extra += Form("%s ", taskEmbJets->GetNonStdBranch());
+
+     taskEmbJets = AddTaskJets("AODextraonly", "FASTJET", 0.4, kHighPtFilterMask);
+     taskEmbJets->ReadAODFromOutput();
+    
+     taskEmbJets = AddTaskJets("AODextra", "UA1", 0.4, kHighPtFilterMask,1.,0);
+     taskEmbJets->ReadAODFromOutput();
+     taskEmbJets = AddTaskJets("AODextraonly", "UA1", 0.4, kHighPtFilterMask,1.,0);
+     taskEmbJets->ReadAODFromOutput();
+     taskEmbJets = AddTaskJets("AODextra", "UA1", 0.4, kHighPtFilterMask,1.,2);
      taskEmbJets->ReadAODFromOutput();
    }
 
@@ -506,15 +521,25 @@ void AnalysisTrainPWG4Jets(const char *analysis_mode="local",
         kDefaultJetBackgroundBranch = Form("%s_%s",AliAODJetEventBackground::StdBranchName(),taskCl->GetJetOutputBranch());
         
          if (iPWG4FastEmbedding) {
+           AliAnalysisTaskJetCluster *taskClEmb = 0;
            taskClEmb = AddTaskJetCluster("AODextra","",kHighPtFilterMask,iPhysicsSelectionFlag,"KT",0.4,0,1, kDeltaAODJetName.Data(),0.15); // this one is for the background and random jets
-           taskClEmb->SetBackgroundCalc(kFALSE);
+           taskClEmb->SetBackgroundCalc(kTRUE);
            taskClEmb->SetCentralityCut(fCenLo,fCenUp);
            taskClEmb->SetGhostEtamax(0.9);
+          kDefaultJetBackgroundBranch_extra = Form("%s_%s",AliAODJetEventBackground::StdBranchName(),taskClEmb->GetJetOutputBranch());
 
            taskClEmb = AddTaskJetCluster("AODextraonly","",kHighPtFilterMask,iPhysicsSelectionFlag,"KT",0.4,0,1, kDeltaAODJetName.Data(),0.15); // this one is for the background and random jets
            taskClEmb->SetBackgroundCalc(kFALSE);
            taskClEmb->SetCentralityCut(fCenLo,fCenUp);
            taskClEmb->SetGhostEtamax(0.9);
+
+           taskClEmb = AddTaskJetCluster("AODextra","",kHighPtFilterMask,iPhysicsSelectionFlag,"ANTIKT",0.4,0,1,kDeltaAODJetName.Data(),0.15);
+           taskClEmb->SetCentralityCut(fCenLo,fCenUp);
+           taskClEmb->SetBackgroundBranch(kDefaultJetBackgroundBranch_extra.Data());
+           kJetSubtractBranches_extra += Form("%s ",taskClEmb->GetJetOutputBranch());
+
+           taskClEmb = AddTaskJetCluster("AODextraonly","",kHighPtFilterMask,iPhysicsSelectionFlag,"ANTIKT",0.4,0,1,kDeltaAODJetName.Data(),0.15);
+           taskClEmb->SetCentralityCut(fCenLo,fCenUp);
          }
 
         taskCl = AddTaskJetCluster("AOD","",kHighPtFilterMask,iPhysicsSelectionFlag,"KT",0.2,0,1, kDeltaAODJetName.Data(),0.15); // this one is for the background and random jets
@@ -593,6 +618,16 @@ void AnalysisTrainPWG4Jets(const char *analysis_mode="local",
          kDefaultJetBranch.ReplaceAll(taskSubtract->GetToReplace(),Form(taskSubtract->GetReplacementMask(),taskSubtract->GetSubtractionMethod()));
        }
       }
+      if(kJetSubtractBranches_extra.Length()){
+
+       taskSubtract = AddTaskJetBackgroundSubtract(kJetSubtractBranches_extra,1,kJetSubtractMask1.Data(),kJetSubtractMask2.Data(),"extra");
+       taskSubtract->SetBackgroundBranch(kDefaultJetBackgroundBranch_extra.Data());
+       taskSubtract->SelectCollisionCandidates(iPhysicsSelectionFlag);
+        //taskSubtract->SetDebugLevel(3);
+       if(kJetSubtractBranches_extra.Contains(kDefaultJetBranch.Data())){
+         kDefaultJetBranch.ReplaceAll(taskSubtract->GetToReplace(),Form(taskSubtract->GetReplacementMask(),taskSubtract->GetSubtractionMethod()));
+       }
+      }
       if (!taskSubtract) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJetBackgroundSubtrac cannot run for this train conditions - EXCLUDED");     
    }
 
@@ -722,7 +757,21 @@ void AnalysisTrainPWG4Jets(const char *analysis_mode="local",
 
    if (iPWG4JetResponse) {
      gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetResponse.C");
-     AliAnalysisTask *taskJetResponse = AddTaskJetResponse("FASTKT", 0.4, kHighPtFilterMask, 0.15, 0);
+     AliAnalysisTask *taskJetResponse = 0;
+
+     if(iJETAN){
+        taskJetResponse = AddTaskJetResponse("jets", "FASTJET", 0.4, kHighPtFilterMask, 0.15, 0);
+        taskJetResponse = AddTaskJetResponse("jets", "FASTJET", 0.4, kHighPtFilterMask, 0.15, 1);
+
+        taskJetResponse = AddTaskJetResponse("jets", "UA1", 0.4, kHighPtFilterMask, 1., 0);
+        taskJetResponse = AddTaskJetResponse("jets", "UA1", 0.4, kHighPtFilterMask, 1., 2);
+     }
+     if(iPWG4Cluster){
+        taskJetResponse = AddTaskJetResponse("clusters", "ANTIKT", 0.4, kHighPtFilterMask, 0.15, 0);
+        taskJetResponse = AddTaskJetResponse("clusters", "ANTIKT", 0.4, kHighPtFilterMask, 0.15, 1);
+     }
+     if (!taskJetResponse) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJetResponse cannot run for this train conditions - EXCLUDED");
+
    }
 
    if(iPWG4JCORRAN){