Fix in physics selection OADB
[u/mrichter/AliRoot.git] / ANALYSIS / macros / AODtrain.C
index 8204b80..1ff87a7 100644 (file)
@@ -1,12 +1,13 @@
 // ### Settings that make sense when using the Alien plugin
 //==============================================================================
 Int_t       runOnData          = 1;       // Set to 1 if processing real data
-Int_t       iCollision         = 1;       // 0=pp, 1=Pb-Pb
-Int_t       run_flag           = 1100;    // year (2011 = 1100)
+Int_t       iCollision         = 0;       // 0=pp, 1=Pb-Pb
+Int_t       run_flag           = 1000;    // year (2010 pp)
 //==============================================================================
+Bool_t      doCDBconnect        =1;
 Bool_t      usePhysicsSelection = kTRUE; // use physics selection
 Bool_t      useTender           = kFALSE; // use tender wagon
-Bool_t      useCentrality       = kTRUE; // centrality
+Bool_t      useCentrality       = kFALSE; // centrality
 Bool_t      useV0tender         = kFALSE;  // use V0 correction in tender
 Bool_t      useDBG              = kTRUE;  // activate debugging
 Bool_t      useMC               = kFALSE;  // use MC info
@@ -14,18 +15,22 @@ Bool_t      useKFILTER          = kFALSE;  // use Kinematics filter
 Bool_t      useTR               = kFALSE;  // use track references
 Bool_t      useCORRFW           = kFALSE; // do not change
 Bool_t      useAODTAGS          = kFALSE; // use AOD tags
-Bool_t      useSysInfo          = kFALSE; // use sys info
+Bool_t      useSysInfo          = kTRUE; // use sys info
 
 // ### Analysis modules to be included. Some may not be yet fully implemented.
 //==============================================================================
 Int_t       iAODhandler        = 1;      // Analysis produces an AOD or dAOD's
 Int_t       iESDfilter         = 1;      // ESD to AOD filter (barrel + muon tracks)
 Int_t       iMUONcopyAOD       = 1;      // Task that copies only muon events in a separate AOD (PWG3)
-Int_t       iJETAN             = 1;      // Jet analysis (PWG4)
-Int_t       iJETANdelta        = 1;      // Jet delta AODs
+Int_t       iJETAN             = 0;      // Jet analysis (PWG4)
+Int_t       iJETANdelta        = 0;      // Jet delta AODs
 Int_t       iPWGHFvertexing     = 1;      // Vertexing HF task (PWG3)
-Int_t       iPWGDQJPSIfilter    = 1;      // JPSI filtering (PWG3)
+Int_t       iPWGDQJPSIfilter    = 0;      // JPSI filtering (PWG3)
 Int_t       iPWGHFd2h           = 1;      // D0->2 hadrons (PWG3)
+Int_t       iPWGPP               =1;      // high pt filter task
+Int_t       iPWGLFForward       = 1;      // Forward mult task (PWGLF)
+Bool_t doPIDResponse  = 1;
+Bool_t doPIDqa        = 1; //new
 
 // ### Configuration macros used for each module
 //==============================================================================
@@ -39,13 +44,15 @@ Bool_t LoadCommonLibraries();
 Bool_t LoadAnalysisLibraries();
 Bool_t LoadLibrary(const char *);
 TChain *CreateChain();
+const char *cdbPath = "raw://";
+Int_t run_number = 0;
 
 //______________________________________________________________________________
 void AODtrain(Int_t merge=0)
 {
 // Main analysis train macro.
 
-  if (merge) {
+  if (merge || doCDBconnect) {
     TGrid::Connect("alien://");
     if (!gGrid || !gGrid->IsConnected()) {
       ::Error("QAtrain", "No grid connection");
@@ -78,7 +85,11 @@ void AODtrain(Int_t merge=0)
     
    // Make the analysis manager and connect event handlers
    AliAnalysisManager *mgr  = new AliAnalysisManager("Analysis Train", "Production train");
-   if (useSysInfo) mgr->SetNSysInfo(100);
+    mgr->SetCacheSize(0);
+   if (useSysInfo) {
+ //     mgr->SetNSysInfo(100);
+      AliSysInfo::SetVerbose(kTRUE);
+   }   
    // Load analysis specific libraries
    if (!LoadAnalysisLibraries()) {
       ::Error("AnalysisTrain", "Could not load analysis libraries");
@@ -105,7 +116,7 @@ void AODtrain(Int_t merge=0)
    // Debugging if needed
    if (useDBG) mgr->SetDebugLevel(3);
 
-   AddAnalysisTasks();
+   AddAnalysisTasks(cdbPath);
    if (merge) {
       AODmerge();
       mgr->InitAnalysis();
@@ -129,7 +140,7 @@ void AODtrain(Int_t merge=0)
 }                                                                                                                                          
                                                                                                                                             
 //______________________________________________________________________________                                                           
-void AddAnalysisTasks(){                                                                                                                                          
+void AddAnalysisTasks(const char *cdb_location){                                                                                                                                          
   // Add all analysis task wagons to the train                                                                                               
    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();                                                                     
 
@@ -143,7 +154,44 @@ void AddAnalysisTasks(){
       AliAnalysisTaskSE *tender = AddTaskTender(useV0tender);
 //      tender->SetDebugLevel(2);
    }
-
+   
+   // Clean Geometry: Ruben
+  gROOT->LoadMacro("$ALICE_ROOT/PWGPP/CalibMacros/commonMacros/CleanGeom.C++");
+  CleanGeom* clgmTask = new CleanGeom("cleanGeom");
+  mgr->AddTask(clgmTask);
+  AliAnalysisDataContainer *dummyInp = mgr->GetCommonInputContainer();
+  if (dummyInp) mgr->ConnectInput(clgmTask,0,dummyInp);  
+   
+   //
+  // PIDResponse(JENS)
+  //
+  if (doPIDResponse) {
+    gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C"); 
+    AliAnalysisTaskPIDResponse *PIDResponse = AddTaskPIDResponse();
+     PIDResponse->SetUserDataRecoPass(1);
+//    PIDResponse->SelectCollisionCandidates(AliVEvent::kAny);
+  }  
+  //
+  // PIDqa(JENS)
+  //
+  if (doPIDqa) {
+    gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDqa.C");
+    AliAnalysisTaskPIDqa *PIDQA = AddTaskPIDqa();
+    PIDQA->SelectCollisionCandidates(AliVEvent::kAny);
+  }  
+  // CDB connection
+  //
+  if (doCDBconnect && !useTender) {
+    gROOT->LoadMacro("$ALICE_ROOT/PWGPP/PilotTrain/AddTaskCDBconnect.C");
+    AliTaskCDBconnect *taskCDB = AddTaskCDBconnect(cdb_location, run_number);
+    if (!taskCDB) return;
+    AliCDBManager *cdb = AliCDBManager::Instance();
+    cdb->SetDefaultStorage(cdb_location);
+//    taskCDB->SetRunNumber(run_number);
+  }    
    if (usePhysicsSelection) {
    // Physics selection task
       gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
@@ -153,24 +201,56 @@ void AddAnalysisTasks(){
 //      physSelTask->GetPhysicsSelection()->SetCustomOADBObjects(oadbDefaultPbPb,0,0);
       mgr->AddStatisticsTask(AliVEvent::kAny);
    }
+   
+
+//Jacek
+   if (iPWGPP) {
+      gROOT->LoadMacro("$ALICE_ROOT/PWGPP/macros/AddTaskFilteredTree.C");
+      AddTaskFilteredTree("FilterEvents_Trees.root");
+   }   
+   
    // Centrality (only Pb-Pb)
-   if (iCollision && useCentrality) {
+   if (useCentrality) {
       gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
       AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
-      taskCentrality->SelectCollisionCandidates(AliVEvent::kAny);
+      //taskCentrality->SelectCollisionCandidates(AliVEvent::kAny);
+   }
+   
+// --- PWGLF - Forward (cholm@nbi.dk) -----------------------------
+   if (iPWGLFForward && usePhysicsSelection) { 
+        gROOT->LoadMacro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/AddTaskForwardMult.C");
+     UShort_t pwglfForwardSys = 0; // iCollision+1; // pp:1, PbPb:2, pPb:3
+     UShort_t pwglfSNN        = 0;            // GeV, 0==unknown
+     Short_t  pwglfField      = 0;
+     AddTaskForwardMult(useMC && useTR,        // Need track-refs 
+                       pwglfForwardSys,       // Collision system
+                       pwglfSNN, 
+                       pwglfField);
+        gROOT->LoadMacro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/AddTaskCentralMult.C");
+        AddTaskCentralMult(useMC, pwglfForwardSys, pwglfSNN, pwglfField);
    }
+    
 
    if (iESDfilter) {
       //  ESD filter task configuration.
-      gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskESDFilter.C");
+      gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/ESDfilter/macros/AddTaskESDFilter.C");
       if (iMUONcopyAOD) {
          printf("Registering delta AOD file\n");
          mgr->RegisterExtraFile("AliAOD.Muons.root");
-         mgr->RegisterExtraFile("AliAOD.Dimuons.root");
-         AliAnalysisTaskESDfilter *taskesdfilter = AddTaskESDFilter(useKFILTER, kTRUE, kFALSE, kFALSE /*usePhysicsSelection*/,kFALSE,AliESDpid::kTOF_T0,kTRUE,kFALSE,kFALSE,run_flag);
-      } else {
-          AliAnalysisTaskESDfilter *taskesdfilter = AddTaskESDFilter(useKFILTER, kFALSE, kFALSE, kFALSE /*usePhysicsSelection*/,kFALSE,AliESDpid::kTOF_T0,kTRUE,kFALSE,kFALSE,run_flag); // others
-      }   
+          mgr->RegisterExtraFile("AliAOD.Dimuons.root");
+      }
+      AliAnalysisTaskESDfilter *taskesdfilter = 
+                 AddTaskESDFilter(useKFILTER, 
+                                  iMUONcopyAOD,         // write Muon AOD
+                                  kFALSE,               // write dimuon AOD 
+                                  kFALSE,               // usePhysicsSelection 
+                                  kFALSE,               // centrality OBSOLETE
+                                  kTRUE,                // enable TPS only tracks
+                                  kFALSE,               // disable cascades
+                                  kFALSE,               // disable kinks
+                                  run_flag);            // run flag (YY00)
+        mgr->RegisterExtraFile("AliAOD.Dimuons.root");
    }   
 
 // ********** PWG3 wagons ******************************************************           
@@ -208,8 +288,8 @@ void AddAnalysisTasks(){
    Bool_t  kIsPbPb = (iCollision==0)?false:true; // can be more intlligent checking the name of the data set
    TString kDefaultJetBackgroundBranch = "";
    TString kJetSubtractBranches = "";
-   UInt_t kHighPtFilterMask = 128;// from esd filter
-   UInt_t iPhysicsSelectionFlag = AliVEvent::kMB;
+   UInt_t kHighPtFilterMask = 272;// from esd filter
+   UInt_t iPhysicsSelectionFlag = 0;
    if (iJETAN) {
      gROOT->LoadMacro("$ALICE_ROOT/PWGJE/macros/AddTaskJets.C");
      // Default jet reconstructor running on ESD's
@@ -266,7 +346,6 @@ void AddAnalysisTasks(){
      } 
    }
 }
-
 //______________________________________________________________________________
 Bool_t LoadCommonLibraries()
 {
@@ -283,6 +362,7 @@ Bool_t LoadCommonLibraries()
    success &= LoadLibrary("libANALYSIS.so");
    success &= LoadLibrary("libOADB.so");
    success &= LoadLibrary("libANALYSISalice.so");
+     success &= LoadLibrary("libESDfilter.so");
    success &= LoadLibrary("libCORRFW.so");
    gROOT->ProcessLine(".include $ALICE_ROOT/include");
    if (success) {
@@ -299,10 +379,15 @@ Bool_t LoadCommonLibraries()
 Bool_t LoadAnalysisLibraries()
 {
 // Load common analysis libraries.
-   if (useTender) {
+   if (useTender || doCDBconnect) {
       if (!LoadLibrary("TENDER") ||
           !LoadLibrary("TENDERSupplies")) return kFALSE;
    }       
+   // CDBconnect
+   if (doCDBconnect && !useTender) {
+      if (!LoadLibrary("PWGPP")) return kFALSE;
+   }
+          
    if (iESDfilter || iPWGMuonTrain) {
       if (!LoadLibrary("PWGmuon")) return kFALSE;
    }   
@@ -317,12 +402,24 @@ Bool_t LoadAnalysisLibraries()
           !LoadLibrary("siscone") ||
           !LoadLibrary("SISConePlugin") ||
           !LoadLibrary("FASTJETAN")) return kFALSE;
-   }     
+   }  
+   // PWG2 FORWARD
+   if (iPWGLFForward) {
+      //if (!LoadLibrary("PWGLFforward", mode, kTRUE)) return kFALSE;
+     if (!LoadLibrary("PWGLFforward2")) return kFALSE;
+  }   
+   
    // PWG3 Vertexing HF
-   if (iPWGHFvertexing || iPWG3d2h) {
-      if (!LoadLibrary("PWG3base") ||
+   if (iPWGHFvertexing || iPWGHFd2h) {
+      if (!LoadLibrary("PWGflowBase") ||
+          !LoadLibrary("PWGflowTasks") ||
+          !LoadLibrary("PWGTRD") ||
           !LoadLibrary("PWGHFvertexingHF")) return kFALSE;
-   }   
+   }    
+ //    if (iPWGHFvertexing || iPWG3d2h) {
+ //     if (!LoadLibrary("PWG3base") ||
+ //         !LoadLibrary("PWGHFvertexingHF")) return kFALSE;
+ //  }   
    // PWG3 dielectron
    if (iPWGDQJPSIfilter) {
       if (!LoadLibrary("PWGDQdielectron")) return kFALSE;
@@ -383,8 +480,7 @@ void AODmerge()
   TStopwatch timer;
   timer.Start();
   TString outputDir = "wn.xml";
-  TString outputFiles = "EventStat_temp.root,AODQA.root,AliAOD.root,AliAOD.VertexingHF.root,";
-  outputFiles +=        "AliAOD.Muons.root,AliAOD.Jets.root";
+  TString outputFiles = "EventStat_temp.root,AODQA.root,AliAOD.root,AliAOD.VertexingHF.root,FilterEvents_Trees.root,AliAOD.Muons.root,AliAOD.Jets.root";
   TString mergeExcludes = "";
   TObjArray *list = outputFiles.Tokenize(",");
   TIter *iter = new TIter(list);
@@ -402,7 +498,7 @@ void AODmerge()
     merged = AliAnalysisAlien::MergeOutput(outputFile, outputDir, 10, 0);
     if (!merged) {
        printf("ERROR: Cannot merge %s\n", outputFile.Data());
-       return;
+       continue;
     }
   }
   // all outputs merged, validate