]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HMPID/AnalysisTrainHMPID.C
Class AliHMPIDRecoParamV1 introduced (29-11-2009) as a copy of AliHMPIDRecoParam...
[u/mrichter/AliRoot.git] / HMPID / AnalysisTrainHMPID.C
index 8d8c80e3be96b48cf9f7085ef94b4d510a00b5fd..9e03bb2aa686636abccfa9624f8115694c406236 100644 (file)
@@ -19,14 +19,16 @@ TString     kTrainName         = "hmpidAnalysis"; // (no blancs or special chara
 TString     kJobTag            = "HMPID Tasks analysis train configured"; //
 Bool_t      kUsePAR            = kFALSE;  // use par files for extra libs
 Bool_t      kUseCPAR           = kFALSE;  // use par files for common libs
-Bool_t      kFillAOD           = kTRUE;  // switch of AOD filling for on the fly analysis
+Bool_t      kFillAOD           = kFALSE;  // switch of AOD filling for on the fly analysis
 
+Int_t       iAODanalysis       = 0;      // Analysis on input AOD's
 Int_t       iAODhandler        = 1;      // Analysis produces an AOD or dAOD's
 Int_t       iESDfilter         = 0;      // ESD to AOD filter (barrel + muon tracks)
 Int_t       iPhysicsSelection  = 1;      // Physics selection task
+Int_t       iCentrality        = 0;      // Physics selection task
 Bool_t      kUseKinefilter     = kFALSE; // use Kinematics filter
 Bool_t      kUseMuonfilter     = kFALSE; // use muon filter
-TString     kCommonOutputFileName = "HMPIDTaskOutput.root";
+TString     kCommonOutputFileName = "HmpidOutput.root";
 
 
 //== general process variables
@@ -36,15 +38,18 @@ TString     kCommonOutputFileName = "HMPIDTaskOutput.root";
 Bool_t      kSkipTerminate      = kFALSE; // Do not call Teminate
 Bool_t      kDebugLevel         = kTRUE; // activate debugging
 Int_t       kUseSysInfo         = 0; // activate debugging
-Bool_t      kUseMC              = kTRUE;  // use MC info
-Bool_t      kIsMC               = kTRUE;  // is MC info, if false it overwrites Use(AOD)MC
-Bool_t      kUseESDTags         = kTRUE; // use ESD tags for selection
+Long64_t    kNumberOfEvents     = 1234567890; // number of events to process from the chain
+Bool_t      kUseMC              = kFALSE;  // use MC info
+Bool_t      kIsMC               = kFALSE;  // is MC info, if false it overwrites Use(AOD)MC
+Bool_t      kUseESDTags         = kFALSE;  // use ESD tags for selection
 Bool_t      kUseTR              = kFALSE;  // use track references
 
 // ### Analysis modules to be included. Some may not be yet fully implemented.
 //==============================================================================
 Int_t       iHMPID             = 1;      // Basic HMPID analysis task
-Int_t       iJETAN             = 0;      // Jet analysis (PWG4) // 1 write standard 2 write non-standard jets
+Int_t       iHMPIDperf         = 0;      // Basic HMPID performance task
+Int_t       iJETAN             = 0;      // Jet analysis (PWGJE) // 1 write standard 2 write non-standard jets
+Int_t       iHMPIDJets         = 0;      // Jet chemistry with HMPID
 Int_t       iJETANLib          = 0;
 Int_t       kHighPtFilterMask  = 16;     // change depending on the used AOD Filter
 
@@ -55,9 +60,9 @@ Int_t       kHighPtFilterMask  = 16;     // change depending on the used AOD Fil
 //== proof setup variables
 TString     kProofCluster      = "alice-caf.cern.ch";
 Bool_t      kProofUseAFPAR     = kTRUE;  // use AF special par file
-TString     kProofAFversion    = "VO_ALICE@AliRoot::v4-19-20-AN";
+TString     kProofAFversion    = "VO_ALICE@AliRoot::v4-20-08-AN";
 //== proof input and output variables
-TString     kProofDataSet      = "/alice/sim/LHC10c9_117118";
+TString     kProofDataSet      = "/alice/sim/LHC10d2_117220";
 //== proof process variables
 Bool_t      kProofClearPackages = kFALSE;
 Int_t       kProofEvents = 10000;
@@ -69,30 +74,31 @@ Int_t       kProofOffset = 0;
 //== grid plugin setup variables
 Bool_t      kPluginUse         = kTRUE;   // do not change
 Bool_t      kPluginUseProductionMode  = kFALSE;   // use the plugin in production mode
-TString     kPluginRootVersion       = "v5-27-05";  // *CHANGE ME IF MORE RECENT IN GRID*
-TString     kPluginAliRootVersion    = "v4-20-07-AN";  // *CHANGE ME IF MORE RECENT IN GRID*                                          
-Bool_t      kPluginMergeViaJDL       = kFALSE;  // merge via JDL
+TString     kPluginRootVersion       = "v5-33-02b";  // *CHANGE ME IF MORE RECENT IN GRID*
+TString     kPluginAliRootVersion    = "v5-03-31-AN";  // *CHANGE ME IF MORE RECENT IN GRID*                                          
+Bool_t      kPluginMergeViaJDL       = kTRUE;  // merge via JDL
 Bool_t      kPluginFastReadOption    = kFALSE;  // use xrootd flags to reduce timeouts
 Bool_t      kPluginOverwriteMode     = kTRUE;  // overwrite existing collections
 Int_t       kPluginOutputToRunNumber = 1;     // write the output to subdirs named after run number
-TString kPluginExecutableCommand = "root -b -q";
+TString kPluginExecutableCommand = "aliroot -b -q";
 
 // == grid plugin input and output variables
-TString     kGridDatadir      = "/alice/sim/LHC10d4a";
+TString     kGridDatadir      = "/alice/data/2010/LHC10e";
 TString     kGridLocalRunList = "";
-TString     kGridWorkDir      = "HmpidAnalysis/LHC10d4a";   // Alien working directory
+TString     kGridWorkDir      = "";   // Alien working directory
 TString     kGridOutdir       = ""; // AliEn output directory. If blank will become output_<kTrainName>
 TString     kGridDataSet      = ""; // sub working directory not to confuse different run xmls 
-Int_t       kGridRunRange[2]       = {119841, 119844}; // Set the run range
+Int_t       kGridRunRange[2]       = {128260,128260}; // Set the run range
 TString     kGridRunPattern        = "%03d"; // important for leading zeroes!!
-TString     kGridPassPattern       = "";
+TString     kGridPassPattern       = "/ESDs/pass2";
 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
+Int_t       kGridMaxMergeStages     = 3;  // Number of stages in the merging procedure
 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     = 1; // Number of runs per master job
-Int_t       kGridFilesPerJob       = 100; // Maximum number of files per job (gives size of AOD)
+Int_t       kGridFilesPerJob       = 50; // Maximum number of files per job (gives size of AOD)
 
 //==============================================================================
 // ### Local Steering variables
@@ -132,10 +138,15 @@ void AnalysisTrainHMPID(const char *analysis_mode="local", const char *plugin_mo
    printf("===========    RUNNING ANALYSIS TRAIN %s IN %s MODE   ==========\n", kTrainName.Data(),smode.Data());
    printf("==================================================================\n");
    printf("=  Configuring analysis train for:                               =\n");
-   printf("=  ESD analysis                                                  =\n");
-   if (iPhysicsSelection)   printf("=  Physics selection                                                    =\n");
+   if (iAODanalysis) printf("=  AOD analysis                                                  =\n");
+   else              printf("=  ESD analysis                                                  =\n");
+   if (iPhysicsSelection)   printf("=  Physics selection                                             =\n");
+   if (iCentrality)  printf("=  Centrality                                                    =\n");
    if (iESDfilter)   printf("=  ESD filter                                                    =\n");
    if (iJETAN)       printf("=  Jet analysis                                                  =\n");
+   if (iHMPID)       printf("=  HMPID generic                                                 =\n");
+   if (iHMPIDperf)   printf("=  HMPID performance                                             =\n");
+   if (iHMPIDJets)   printf("=  HMPID Jet chemistry                                           =\n");
    printf("==================================================================\n");
    printf(":: use MC truth      %d\n", (UInt_t)kUseMC);
    printf(":: use KINE filter   %d\n", (UInt_t)kUseKinefilter);
@@ -158,7 +169,6 @@ void AnalysisTrainHMPID(const char *analysis_mode="local", const char *plugin_mo
       return;
    }
 
-
     
    // Make the analysis manager and connect event handlers
    AliAnalysisManager *mgr  = new AliAnalysisManager("HMPIDTrain", "HMPID train");
@@ -175,14 +185,20 @@ void AnalysisTrainHMPID(const char *analysis_mode="local", const char *plugin_mo
    }   
 
    // Create input handler (input container created automatically)
+   if (iAODanalysis) {
+   // AOD input handler
+      AliAODInputHandler *aodH = new AliAODInputHandler();
+      mgr->SetInputEventHandler(aodH);
+   } else {
    // ESD input handler
-   AliESDInputHandler *esdHandler = new AliESDInputHandler();
-   if (kUseESDTags) esdHandler->SetReadTags();
-   esdHandler->SetReadFriends(kFALSE);
-   mgr->SetInputEventHandler(esdHandler);       
+      AliESDInputHandler *esdHandler = new AliESDInputHandler();
+      if (kUseESDTags) esdHandler->SetReadTags();
+      esdHandler->SetReadFriends(kFALSE);
+      mgr->SetInputEventHandler(esdHandler);
+   }
 
    // Monte Carlo handler
-   if (kUseMC) {
+   if (kUseMC && !iAODanalysis) {
       AliMCEventHandler* mcHandler = new AliMCEventHandler();
       mgr->SetMCtruthEventHandler(mcHandler);
       mcHandler->SetReadTR(kUseTR); 
@@ -221,15 +237,30 @@ void AnalysisTrainHMPID(const char *analysis_mode="local", const char *plugin_mo
    // Load the tasks configuration macros for all wagons. These files are supposed now to be
    // in the current workdir, but in AliEn they will be in the file catalog, 
    // mapped from AliRoot and pecified in the jdl input list.
-   if(iPhysicsSelection){
+   if(iPhysicsSelection && !iAODanalysis){
      gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
      AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(kIsMC,kTRUE,kTRUE); // last flag also adds information on  
    }
+   
+   if(iCentrality && !iAODanalysis){
+     gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
+     AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
+     taskCentrality->SetPass(2); // remember to set the pass you are processing!!!   
+   }     
 
-   if (iESDfilter) {
+   if (iESDfilter && !iAODanalysis) {
       //  ESD filter task configuration.
       gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskESDFilter.C");
       AliAnalysisTaskESDfilter *taskesdfilter = AddTaskESDFilter(kUseKinefilter,kUseMuonfilter);
+//  if jet analysis is included, better use the following macro with kHighPtFilterMask=272
+/*      gROOT->LoadMacro("$ALICE_ROOT/PWGJE/macros/AddTaskESDFilterPWGJETrain.C");
+      AliAnalysisTaskESDfilter *taskesdfilter = AddTaskESDFilterPWGJETrain(kUseKinefilter,kUseMuonfilter);
+      taskesdfilter->DisableV0s();
+      taskesdfilter->DisableCascades();
+      taskesdfilter->DisableKinks();
+      taskesdfilter->DisablePmdClusters();
+      taskesdfilter->DisableCaloClusters();
+      taskesdfilter->DisableCells();*/
       if(kIsMC){
          mgr->RegisterExtraFile("pyxsec_hists.root");
          if(kGridMergeExclude.Length())kGridMergeExclude += " ";
@@ -239,18 +270,30 @@ void AnalysisTrainHMPID(const char *analysis_mode="local", const char *plugin_mo
 
     // Jet analysis
    if (iJETAN) {
-      gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJets.C");
+      gROOT->LoadMacro("$ALICE_ROOT/PWGJE/macros/AddTaskJets.C");
       AliAnalysisTaskJets *taskjets = 0;
-      if (iJETAN&1) taskjets = AddTaskJets(kHighPtFilterMask); 
+      if (iJETAN&1) taskjets = AddTaskJets("AOD","FASTJET",0.4,kHighPtFilterMask); 
       if (!taskjets) ::Warning("AnalysisTrainHMPID", "AliAnalysisTaskJets cannot run for this train conditions - EXCLUDED");
    }
 
    if(iHMPID){
      gROOT->LoadMacro("$ALICE_ROOT/HMPID/AddTaskHMPID.C");
      AliHMPIDAnalysisTask *taskHmpid = AddTaskHMPID(kUseMC);
-     if (!taskHmpid) ::Warning("AnalysisTrainHMPID", "AliAnalysisTaskHMPID cannot run for this train conditions - EXCLUDED");
+     if (!taskHmpid) ::Warning("AnalysisTrainHMPID", "AliHMPIDAnalysisTask cannot run for this train conditions - EXCLUDED");
    }
-
+   
+   if(iHMPIDperf){
+     gROOT->LoadMacro("$ALICE_ROOT/HMPID/AddTaskHMPIDPerformance.C");
+     AliHMPIDPerformanceTask *taskHmpidPerformance = AddTaskHMPIDPerformance(kUseMC);
+     if (!taskHmpidPerformance) ::Warning("AnalysisTrainHMPID", "AliHMPIDPerformanceTask cannot run for this train conditions - EXCLUDED");
+   }
+      
+   if(iHMPIDJets){
+     gROOT->LoadMacro("$ALICE_ROOT/HMPID/AddTaskJetsHMPID.C");
+     AliAnalysisTaskJetsHMPID *taskHmpidJets = AddTaskJetsHMPID("jetsAOD_FASTJET04_B0_Filter00272_Cut00150","jeteventbackground_clustersAOD_KT04_B0_Filter00256_Cut00150_Skip00");
+     if (!taskHmpidJets) ::Warning("AnalysisTrainHMPID", "AliAnalysisTaskJetsHMPID cannot run for this train conditions - EXCLUDED");
+   }
+   
    if (kPluginUse) {
       AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode);
       AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler);
@@ -321,7 +364,7 @@ void StartAnalysis(const char *mode, TChain *chain) {
             ::Error("AnalysisTrainHMPID.C::StartAnalysis", "Cannot create the chain");
             return;
          }
-         mgr->StartAnalysis(mode, chain,kNumberOfEvents);
+         mgr->StartAnalysis(mode, chain, kNumberOfEvents);
          return;
       case 1:
          if (!kProofDataSet.Length()) {
@@ -373,23 +416,46 @@ void CheckModuleFlags(const char *mode) {
    }
 
    if(!kIsMC){
-     // switch off anthin related to MC
-     kUseMC = 0;
-     kUseTR = kFALSE;
+      // switch off anything related to MC
+      kUseMC = kFALSE;
+      kUseTR = kFALSE;
    }
 
- // ESD analysis
-   if (!kUseMC){
-     kUseTR = kFALSE;
-     if(kUseKinefilter)::Info("AnalysisTrainHMPID.C::CheckModuleFlags", "Kine Filter disabled in analysis without MC");
-     kUseKinefilter = kFALSE;
-   }
-   if (iJETAN){
-     iESDfilter=1;
-   }
-   if (!iESDfilter){
-     kUseKinefilter = kFALSE;
-     kUseMuonfilter = kFALSE;
+   if (iAODanalysis) {
+   // AOD analysis
+      if (kUseMC)
+         ::Info("AnalysisTrainHMPID.C::CheckModuleFlags", "MC usage disabled in analysis on AOD's");
+      kUseMC = kFALSE;
+      kUseTR = kFALSE;
+      if (iESDfilter)
+         ::Info("AnalysisTrainHMPID.C::CheckModuleFlags", "ESD filter disabled in analysis on AOD's");
+      iESDfilter   = 0;
+      if (iPhysicsSelection)
+         ::Info("AnalysisTrainHMPID.C::CheckModuleFlags", "Physics Selection disabled in analysis on AOD's");
+      iPhysicsSelection   = 0;
+      if (!iAODhandler) {
+         if (iJETAN) 
+            ::Info("AnalysisTrainHMPID.C::CheckModuleFlags", "JETAN disabled in analysis on AOD's without AOD handler");
+         iJETAN = 0;
+      }
+      if(iHMPID)::Info("AnalysisTrainHMPID.C::CheckModuleFlags", "HMPID analysis disabled in analysis on AOD's");
+      iHMPID = 0;
+      if(iHMPIDperf)::Info("AnalysisTrainHMPID.C::CheckModuleFlags", "HMPID performance disabled in analysis on AOD's");
+      iHMPIDperf = 0;
+   } else {   
+   // ESD analysis
+      if (!kUseMC){
+         kUseTR = kFALSE;
+         if(kUseKinefilter)::Info("AnalysisTrainHMPID.C::CheckModuleFlags", "Kine Filter disabled in analysis without MC");
+         kUseKinefilter = kFALSE;
+      }
+      if (iJETAN){
+         iESDfilter=1;
+      }
+      if (!iESDfilter){
+         kUseKinefilter = kFALSE;
+         kUseMuonfilter = kFALSE;
+      }
    }
 
    iJETANLib = iJETAN && 1;
@@ -486,14 +552,14 @@ Bool_t LoadCommonLibraries(const char *mode)
             success &= LoadLibrary("ANALYSISalice", mode, kTRUE);
             success &= LoadLibrary("CORRFW", mode, kTRUE);
          } else {   
-            success &= LoadLibrary("libSTEERBase.so", mode);
-            success &= LoadLibrary("libESD.so", mode);
-            success &= LoadLibrary("libAOD.so", mode);
-            success &= LoadLibrary("libANALYSIS.so", mode);
-            success &= LoadLibrary("libANALYSISalice.so", mode);
-            success &= LoadLibrary("libCORRFW.so", mode);
+            success &= LoadLibrary("libSTEERBase.so",     mode, kTRUE);
+            success &= LoadLibrary("libESD.so",           mode, kTRUE);
+            success &= LoadLibrary("libAOD.so",           mode, kTRUE);
+            success &= LoadLibrary("libANALYSIS.so",      mode, kTRUE);
+            success &= LoadLibrary("libANALYSISalice.so", mode, kTRUE);
+            success &= LoadLibrary("libCORRFW.so",        mode, kTRUE);
             gROOT->ProcessLine(".include $ALICE_ROOT/include");
-         }   
+         }
          break;
       case 1:
          if (!kProofUseAFPAR) {
@@ -503,11 +569,11 @@ Bool_t LoadCommonLibraries(const char *mode)
             success &= LoadLibrary("ANALYSIS", mode);
             success &= LoadLibrary("ANALYSISalice", mode);
             success &= LoadLibrary("CORRFW", mode);
-         } else { 
+         } else {
             success &= !gProof->EnablePackage(kProofAFversion);
             success &= LoadLibrary("CORRFW", mode);
          }
-         break;         
+         break;
       default:
          ::Error("AnalysisTrainHMPID.C::LoadCommonLibraries", "Unknown run mode: %s", mode);
          return kFALSE;
@@ -516,10 +582,10 @@ Bool_t LoadCommonLibraries(const char *mode)
       ::Info("AnalysisTrainHMPID.C::LoadCommodLibraries", "Load common libraries:    SUCCESS");
       ::Info("AnalysisTrainHMPID.C::LoadCommodLibraries", "Include path for Aclic compilation:\n%s",
               gSystem->GetIncludePath());
-   } else {           
+   } else {
       ::Info("AnalysisTrainHMPID.C::LoadCommodLibraries", "Load common libraries:    FAILED");
-   }   
-      
+   }
+
    return success;
 }
 
@@ -530,14 +596,47 @@ Bool_t LoadAnalysisLibraries(const char *mode)
 // Load common analysis libraries.
    Bool_t success = kTRUE;
    if (iESDfilter) {
-      if (!LoadLibrary("PWG3base", mode, kTRUE) ||
-          !LoadLibrary("PWG3muon", mode, kTRUE)) return kFALSE;
+      if (!LoadLibrary("PWGHFbase", mode, kTRUE) ||
+          !LoadLibrary("PWGmuon", mode, kTRUE)) return kFALSE;
    }   
 
+   if (iJETANLib) {
+     // this part needs some rework in case we do not need the fastjed finders for processing
+     if (!LoadLibrary("JETAN", mode, kTRUE)) return kFALSE;
+     if (!strcmp(mode, "PROOF")){
+       gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libCGAL.so\"\)", kTRUE); 
+       gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libfastjet.so\"\)", kTRUE); 
+       // problem when loading siscone copiled with different gcc version??
+       // gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libsiscone.so\"\)", kTRUE); 
+       gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libSISConePlugin.so\"\)", kTRUE);      
+     }
+     if(!kUsePAR){ 
+       if (!LoadLibrary("CGAL", mode, kTRUE)) return kFALSE;
+       if (!LoadLibrary("fastjet", mode, kTRUE)) return kFALSE;
+       if (!LoadLibrary("siscone", mode, kTRUE)) return kFALSE;
+       if (!LoadLibrary("SISConePlugin", mode, kTRUE)) return kFALSE;
+     }
+     else{
+       if (!LoadLibrary("libCGAL.so", mode, kTRUE)) return kFALSE;
+       if (!LoadLibrary("libfastjet.so", mode, kTRUE)) return kFALSE;
+       if (!LoadLibrary("libsiscone.so", mode, kTRUE)) return kFALSE;
+       if (!LoadLibrary("libSISConePlugin.so", mode, kTRUE)) return kFALSE;
+     }
+     if (!LoadLibrary("FASTJETAN", mode, kTRUE)) return kFALSE;
+   }
+
    if(iHMPID){
      if (!LoadSource(Form("%s/HMPID/AliHMPIDAnalysisTask.cxx",gSystem->ExpandPathName("$ALICE_ROOT")), mode, kTRUE))return kFALSE;
    }
+   
+   if(iHMPIDperf){
+     if (!LoadSource(Form("%s/HMPID/AliHMPIDPerformanceTask.cxx",gSystem->ExpandPathName("$ALICE_ROOT")), mode, kTRUE))return kFALSE;
+   }   
 
+   if(iHMPIDJets){
+     if (!LoadSource(Form("%s/HMPID/AliAnalysisTaskJetsHMPID.cxx",gSystem->ExpandPathName("$ALICE_ROOT")), mode, kTRUE))return kFALSE;
+   }
+   
    if (iJETANLib) {
      if (!LoadLibrary("JETAN", mode, kTRUE)) return kFALSE;
    }
@@ -682,22 +781,41 @@ TChain *CreateChain(const char *mode, const char *plugin_mode)
    // Local chain
    switch (imode) {
       case 0:
-            if (!kLocalXMLDataset.Length()) {
-              // Local ESD
-              chain = new TChain("esdTree");
-              TString line;
-              ifstream in;
-              in.open(kLocalDataList.Data());
-              while (in.good()) {
-                in >> line;
-                if (line.Length() == 0) continue;
-                cout << " line = " << line << endl;
-                chain->Add(line.Data());
-              }       
-            } else {
-              // Interactive ESD
-           chain = CreateChainSingle(kLocalXMLDataset, "esdTree");
-            }   
+         if (iAODanalysis) {
+            if (!kLocalXMLDataset.Length()) {
+               // Local AOD
+               chain = new TChain("aodTree");
+               TString line;
+               ifstream in;
+               in.open(kLocalDataList.Data());
+                  while (in.good()) {
+                  in >> line;
+                  if (line.Length() == 0) continue;
+               // cout << " line = " << line << endl;
+               chain->Add(line.Data());
+                  }
+            } else {
+               // Interactive AOD
+               chain = CreateChainSingle(kLocalXMLDataset, "aodTree");
+            }
+         } else {
+            if (!kLocalXMLDataset.Length()) {
+               // Local ESD
+               chain = new TChain("esdTree");
+               TString line;
+               ifstream in;
+               in.open(kLocalDataList.Data());
+               while (in.good()) {
+                  in >> line;
+                  if (line.Length() == 0) continue;
+                  cout << " line = " << line << endl;
+                  chain->Add(line.Data());
+               }
+            } else {
+              // Interactive ESD
+              chain = CreateChainSingle(kLocalXMLDataset, "esdTree");
+               }
+         }
          break;
       case 1:
          break;
@@ -706,7 +824,8 @@ TChain *CreateChain(const char *mode, const char *plugin_mode)
             AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode);
             AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler);
          } else {
-            TString treeName = "esdTree";
+            TString           treeName = "esdTree";
+            if (iAODanalysis) treeName = "aodTree";
             chain = CreateChainSingle("wn.xml", treeName);
          }
          break;      
@@ -790,7 +909,7 @@ AliAnalysisAlien* CreateAlienHandler(const char *plugin_mode)
    plugin->SetRunMode(plugin_mode);
    if (kPluginUseProductionMode) plugin->SetProductionMode();
    plugin->SetJobTag(kJobTag);
-   plugin->SetNtestFiles(2);
+   plugin->SetNtestFiles(1);
 //   plugin->SetPreferedSE("ALICE::NIHAM::File");
 // Set versions of used packages
    plugin->SetAPIVersion("V1.1x");
@@ -802,8 +921,10 @@ AliAnalysisAlien* CreateAlienHandler(const char *plugin_mode)
 // Define production directory LFN
    plugin->SetGridDataDir(kGridDatadir.Data());
 // Set data search pattern
-   plugin->SetDataPattern(Form(" %s/*/*ESD.tag.root",kGridPassPattern.Data()));
+   if (iAODanalysis) plugin->SetDataPattern(" *AliAOD.root");
+   else plugin->SetDataPattern(Form(" %s/*/*ESDs.root",kGridPassPattern.Data()));
 // ...then add run numbers to be considered
+   plugin->SetRunPrefix("000"); // if real data
    plugin->SetRunRange(kGridRunRange[0], kGridRunRange[1]);
 
    if(kGridLocalRunList.Length()>0){
@@ -838,6 +959,13 @@ AliAnalysisAlien* CreateAlienHandler(const char *plugin_mode)
    if (!kGridOutdir.Length()) kGridOutdir = Form("output_%s",kTrainName.Data());
    plugin->SetGridOutputDir(kGridOutdir);
 
+   // Add external packages
+   if (iJETAN) {
+      plugin->AddExternalPackage("boost::v1_43_0");
+      plugin->AddExternalPackage("cgal::v3.6");
+      plugin->AddExternalPackage("fastjet::v2.4.2");
+   }   
+
    // set extra libs before par file compilation
    anaLibs += kGridExtraFiles;
    anaLibs  = anaLibs.Strip();   
@@ -866,17 +994,19 @@ AliAnalysisAlien* CreateAlienHandler(const char *plugin_mode)
 // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
 
    if (ana_sources.Length()) plugin->SetAnalysisSource(ana_sources);
-   plugin->SetExecutableCommand(kPluginExecutableCommand.Data());  
+   plugin->SetExecutableCommand(kPluginExecutableCommand.Data());
    // Declare the output file names separated by blancs.
    // (can be like: file.root or file.root@ALICE::Niham::File)
+   plugin->SetUseSubmitPolicy(kFALSE);
    plugin->SetMergeExcludes(kGridMergeExclude);
    plugin->SetMaxMergeFiles(kGridMaxMergeFiles);
+   plugin->SetMaxMergeStages(kGridMaxMergeStages);
    plugin->SetNrunsPerMaster(kGridRunsPerMaster);
    plugin->SetMergeViaJDL(kPluginMergeViaJDL);
    // Use fastread option
    plugin->SetFastReadOption(kPluginFastReadOption);
    // UseOverwrite mode
-   plugin->SetOverwriteMode(kPluginOverwriteMode); 
+   plugin->SetOverwriteMode(kPluginOverwriteMode);
    // Optionally define the files to be archived.
    //   plugin->SetOutputArchive("log_archive.zip:stdout,stderr@ALICE::NIHAM::File root_archive.zip:AliAOD.root,AOD.tag.root@ALICE::NIHAM::File");
    plugin->SetOutputToRunNo(kPluginOutputToRunNumber);     // write the output to subdirs named after run number
@@ -918,15 +1048,15 @@ AliAnalysisAlien* CreateAlienHandler(const char *plugin_mode)
    if (!listhists.Length() && !listaods.Length()) {
       ::Fatal("AnalysisTrainHMPID", "No task output !");
    }
-   
+
    if (listaods.Length()) {
       outputArchive += " ";
       outputArchive += listaods;
-   }   
+   }
    if (listhists.Length()) {
       outputArchive += " ";
       outputArchive += listhists;
-   }   
+   }
 //   plugin->SetOutputArchive(outputArchive);
 
 // Optionally set a name for the generated analysis macro (default MyAnalysis.C)