Update
authordainese <dainese@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 21 Jun 2010 15:28:37 +0000 (15:28 +0000)
committerdainese <dainese@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 21 Jun 2010 15:28:37 +0000 (15:28 +0000)
PWG1/macros/RunAnalysisITS.C

index 212f757..0463dca 100644 (file)
@@ -1,22 +1,27 @@
 class AliAnalysisGrid;
 
-void RunAnalysisITS() {
+void RunAnalysisITS(TString pluginmode,Int_t firstrun,Int_t lastrun,
+                   Bool_t readMC=kFALSE,
+                   Bool_t runAlign=kTRUE,
+                   Bool_t runITS=kTRUE,
+                   Bool_t runImpPar=kTRUE,
+                   Bool_t runVtx=kFALSE,
+                   Bool_t runSPD=kFALSE) 
+{
   //
   // Macro to analyze ESDs from raw data reconstruction
   // A.Dainese, andrea.dainese@pd.infn.it
   //
-  //gSystem->Setenv("alien_CLOSE_SE","ALICE::CNAF::SE");
 
   gSystem->SetIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT -I$ALICE_ROOT/include -I$ALICE_ROOT/ITS -I$ALICE_ROOT/TPC -I$ALICE_ROOT/CONTAINERS -I$ALICE_ROOT/STEER -I$ALICE_ROOT/TRD -I$ALICE_ROOT/macros -I$ALICE_ROOT/ANALYSIS -g"); 
 
   //
-  TString analysisMode = "local"; // "local", "grid", or "proof" (not yet)
+  TString analysisMode = "grid"; // "local", "grid", or "proof" (not yet)
 
   Long64_t nentries=1000000000000000,firstentry=0;
-  Bool_t useAlienPlugin=kFALSE;
-  Bool_t uselibPWG1=kTRUE;
-  TString pluginmode="full";
-  TString loadMacroPath="./";
+  Bool_t useAlienPlugin=kTRUE;
+  Bool_t uselibPWG1=kFALSE;
+  TString loadMacroPath="../../";
   Bool_t readHLT=kFALSE;
   //
 
@@ -38,17 +43,17 @@ void RunAnalysisITS() {
 
   // Create Alien plugin, if requested
   if(useAlienPlugin) {  
-    AliAnalysisGrid *alienHandler = CreateAlienHandler(pluginmode,uselibPWG1);
+    AliAnalysisGrid *alienHandler = CreateAlienHandler(pluginmode,uselibPWG1,firstrun,lastrun);
     if(!alienHandler) return;
   }
 
   TChain *chainESD = 0;
   if(!useAlienPlugin) {
     // Prepare input chain
-    chainESD = CreateESDChain("/home/dainesea/alignEvents2/boxTRUNK280909_zero/event.",1,48);
-    //chainESD=new TChain("esdTree");
+    //    chainESD = CreateESDChain("/home/dainesea/alignData/RAWdata_CosmicsSum09/RecoSPD/chunk.",13,13);
+    chainESD=new TChain("esdTree");
     //chainESD->Add("alien:///alice/cern.ch/user/s/sitta/output/000088361/ESDs/pass1/09000088361017.10/AliESDs.root");
-    //chainESD->Add("./AliESDs.root");
+    chainESD->Add("AliESDs.root");
   }
 
   // Create the analysis manager
@@ -58,10 +63,8 @@ void RunAnalysisITS() {
   // Connect plug-in to the analysis manager
   if(useAlienPlugin) mgr->SetGridHandler(alienHandler);
 
-  //-------------------------------------------------------------------
-
   // Add ESD handler
-  Bool_t readRP=kTRUE;
+  Bool_t readRP=kFALSE;
   AliESDInputHandler *esdH = 0;
   if(readRP) {
     esdH = new AliESDInputHandlerRP();
@@ -71,18 +74,54 @@ void RunAnalysisITS() {
   esdH->SetActiveBranches("ESDfriend");
   if(readHLT) esdH->SetReadHLT();
   mgr->SetInputEventHandler(esdH);
+  if(readMC) {
+    AliMCEventHandler  *mcH = new AliMCEventHandler();
+    mgr->SetMCtruthEventHandler(mcH); 
+  }
+  //-------------------------------------------------------------------
+
   
   //-------------------------------------------------------------------
   // Analysis tasks (wagons of the train)   
   //
   TString taskName;
-  /*
-  if(!uselibPWG1) gROOT->LoadMacro("AliAlignmentDataFilterITS.cxx++g");
-  taskName="AddTaskAlignmentDataFilterITS.C"; 
-  taskName.Prepend(loadMacroPath.Data());
-  gROOT->LoadMacro(taskName.Data());
-  AliAlignmentDataFilterITS *itsTask = AddTaskAlignmentDataFilterITS();
-    
+  
+  if(runAlign) {
+    if(!uselibPWG1) gROOT->LoadMacro("AliAlignmentDataFilterITS.cxx++g");
+    taskName="AddTaskAlignmentDataFilterITS.C"; 
+    taskName.Prepend(loadMacroPath.Data());
+    gROOT->LoadMacro(taskName.Data());
+    AliAlignmentDataFilterITS *alignTask = AddTaskAlignmentDataFilterITS();
+  }
+  if(runITS) {
+    if(!uselibPWG1) gROOT->LoadMacro("AliAnalysisTaskITSTrackingCheck.cxx++g");
+    taskName="AddTaskPerformanceITS.C"; 
+    taskName.Prepend(loadMacroPath.Data());
+    gROOT->LoadMacro(taskName.Data());
+    AliAnalysisTaskITSTrackingCheck *itsTask = AddTaskPerformanceITS(readMC,kFALSE,kFALSE);  
+  }
+  if(runImpPar) {
+    if(!uselibPWG1) gROOT->LoadMacro("AliAnalysisTaskSEImpParRes.cxx++g");
+    taskName="AddTaskImpParRes.C"; 
+    taskName.Prepend(loadMacroPath.Data());
+    gROOT->LoadMacro(taskName.Data());
+    AliAnalysisTaskSEImpParRes *d0Task = AddTaskImpParRes(readMC,-1,kFALSE);  
+  }
+  if(runVtx) {
+    if(!uselibPWG1) gROOT->LoadMacro("AliAnalysisTaskVertexESD.cxx++g");
+    taskName="AddTaskVertexESD.C"; 
+    taskName.Prepend(loadMacroPath.Data());
+    gROOT->LoadMacro(taskName.Data());
+    AliAnalysisTaskVertexESD *vtxTask = AddTaskVertexESD(readMC);
+  }
+  if(runSPD) {
+    if(!uselibPWG1) gROOT->LoadMacro("AliAnalysisTaskSPD.cxx++g");
+    taskName="AddTaskSPDQA.C"; 
+    taskName.Prepend("$ALICE_ROOT/PWG1/PilotTrain/");
+    gROOT->LoadMacro(taskName.Data());
+    AliAnalysisTaskSPD *spdTask = AddTaskSPDQA();
+  }
+  /*  
   if(!uselibPWG1) gROOT->LoadMacro("AliTrackMatchingTPCITSCosmics.cxx++g");
   taskName="AddTaskTrackMatchingTPCITS.C"; 
   taskName.Prepend(loadMacroPath.Data());
@@ -90,24 +129,14 @@ void RunAnalysisITS() {
   AliTrackMatchingTPCITSCosmics *tpcitsTask = AddTaskTrackMatchingTPCITS();
   if(readHLT) tpcitsTask->SetReadHLTESD(kTRUE);  
   */
-  Bool_t readMC=kTRUE;
-  if(!uselibPWG1) gROOT->LoadMacro("AliAnalysisTaskVertexESD.cxx++g");
-  taskName="AddTaskVertexESD.C"; 
-  taskName.Prepend(loadMacroPath.Data());
-  gROOT->LoadMacro(taskName.Data());
-  //AliAnalysisTaskVertexESD *vtxTask = AddTaskVertexESD(readMC);
-    
-  if(!uselibPWG1) gROOT->LoadMacro("AliAnalysisTaskITSTrackingCheck.cxx++g");
-  taskName="AddTaskPerformanceITS.C"; 
-  taskName.Prepend(loadMacroPath.Data());
-  gROOT->LoadMacro(taskName.Data());
-  AliAnalysisTaskITSTrackingCheck *itsTask = AddTaskPerformanceITS(readMC,readRP);
 
-  if(readMC) {
-    AliMCEventHandler  *mcH = new AliMCEventHandler();
-    mgr->SetMCtruthEventHandler(mcH); 
-  }
   
+  // Apply the event selection
+  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
+  Bool_t bkgRej=kTRUE;
+  AliPhysicsSelectionTask *physSelTask = AddTaskPhysicsSelection(readMC,bkgRej);
+  
+
   //
   // Run the analysis
   //    
@@ -123,7 +152,8 @@ void RunAnalysisITS() {
 //_____________________________________________________________________________
 //
 AliAnalysisGrid* CreateAlienHandler(TString pluginmode="test",
-                                   Bool_t uselibPWG1=kFALSE)
+                                   Bool_t uselibPWG1=kFALSE,
+                                   Int_t firstrun,Int_t lastrun)
 {
   // Check if user has a valid token, otherwise make one. This has limitations.
   // One can always follow the standard procedure of calling alien-token-init then
@@ -135,20 +165,39 @@ AliAnalysisGrid* CreateAlienHandler(TString pluginmode="test",
    plugin->SetUser("dainesea");
    plugin->SetNtestFiles(1);
    // Set versions of used packages
-   plugin->SetAPIVersion("V2.4");
-   plugin->SetROOTVersion("v5-24-00");
-   plugin->SetAliROOTVersion("v4-18-07-AN");
+   plugin->SetAPIVersion("V1.1x");
+   plugin->SetROOTVersion("v5-26-00b-6");
+   plugin->SetAliROOTVersion("v4-19-15-AN");
+   // Define alien work directory where all files will be copied. Relative to alien $HOME.
+   TString wdname="analysisITS_Runs_";
+   wdname+=firstrun;
+   wdname.Append("_");
+   wdname+=lastrun;
+   plugin->SetGridWorkingDir(wdname.Data());
+   // Declare alien output directory. Relative to working directory.
+   plugin->SetGridOutputDir("output"); // In this case will be $HOME/work/output
    // Declare input data to be processed.
    // Method 1: Create automatically XML collections using alien 'find' command.
    // Define production directory LFN
-   plugin->SetGridDataDir("/alice/data/2009/LHC09c");
-   //plugin->SetGridDataDir("/alice/cern.ch/user/s/sitta/output/000088361/");
+   plugin->SetGridDataDir("/alice/data/2010/LHC10b");
    // Set data search pattern
-   //plugin->SetDataPattern("AliESDs.root");
-   plugin->SetDataPattern("ESD.tag.root");
+   plugin->SetDataPattern("pass2/*AliESDs.root");
+   //plugin->SetDataPattern("ESD.tag.root");
    Int_t n=0;
-   n++; plugin->AddRunNumber("000080015");
-   n++; plugin->AddRunNumber("000080261");
+   FILE *in = fopen("/home/dainesea/alignData/RAWdata_pp10/goodruns_pp10.txt","r");
+   if(!in) printf("run file not found\n");
+   Int_t lines=0; 
+   Float_t runnumber; 
+   while(1) {
+     Int_t ncol = fscanf(in,"%f",&runnumber);
+     if(ncol<1) break;
+     if(runnumber<firstrun || runnumber>lastrun) continue;
+     TString runnumberstring="000";
+     Int_t runnumberint=(Int_t)runnumber;
+     runnumberstring+=runnumberint;
+     n++; plugin->AddRunNumber(runnumberstring.Data());
+   }
+   fclose(in);
    plugin->SetNrunsPerMaster(n);
    // Method 2: Declare existing data files (raw collections, xml collections, root file)
    // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())
@@ -159,22 +208,22 @@ AliAnalysisGrid* CreateAlienHandler(TString pluginmode="test",
    //plugin->AddDataFile("80015.xml");
    //plugin->AddDataFile("80261.xml");
    //   plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");
-   // Define alien work directory where all files will be copied. Relative to alien $HOME.
-   plugin->SetGridWorkingDir("analysisITS");
-   // Declare alien output directory. Relative to working directory.
-   plugin->SetGridOutputDir("output151009"); // In this case will be $HOME/work/output
    // Declare the analysis source files names separated by blancs. To be compiled runtime
    // using ACLiC on the worker nodes.
    if(!uselibPWG1) {
-     plugin->SetAnalysisSource("AliAlignmentDataFilterITS.cxx");
-     plugin->SetAnalysisSource("AliTrackMatchingTPCITSCosmics.cxx");
+     plugin->SetAnalysisSource("AliAnalysisTaskITSTrackingCheck.cxx AliAlignmentDataFilterITS.cxx AliAnalysisTaskSEImpParRes.cxx AliAnalysisTaskVertexESD.cxx");
+     //plugin->SetAnalysisSource("AliAnalysisTaskVertexESD.cxx");
+     //plugin->SetAnalysisSource("AliAlignmentDataFilterITS.cxx");
+     //plugin->SetAnalysisSource("AliTrackMatchingTPCITSCosmics.cxx");
    }
    // Declare all libraries (other than the default ones for the framework. These will be
    // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
    //plugin->SetAdditionalLibs("AliAlignmentDataFilterITS.h AliAlignmentDataFilterITS.cxx libProof.so libRAWDatabase.so libRAWDatarec.so libCDB.so libSTEER.so libITSbase.so libITSrec.so");
    plugin->AddIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT -I$ALICE_ROOT/include -I$ALICE_ROOT/ITS -I$ALICE_ROOT/TPC -I$ALICE_ROOT/CONTAINERS -I$ALICE_ROOT/STEER -I$ALICE_ROOT/TRD -I$ALICE_ROOT/macros -I$ALICE_ROOT/ANALYSIS -g");
    if(!uselibPWG1) {
-     plugin->SetAdditionalLibs("AliAlignmentDataFilterITS.h AliAlignmentDataFilterITS.cxx AliTrackMatchingTPCITSCosmics.h AliTrackMatchingTPCITSCosmics.cxx libProof.so libRAWDatabase.so libRAWDatarec.so libCDB.so libSTEER.so libITSbase.so libITSrec.so");
+     //plugin->SetAdditionalLibs("AliAlignmentDataFilterITS.h AliAlignmentDataFilterITS.cxx libProof.so libRAWDatabase.so libRAWDatarec.so libCDB.so libSTEER.so libITSbase.so libITSrec.so");
+     plugin->SetAdditionalLibs("AliAlignmentDataFilterITS.h AliAlignmentDataFilterITS.cxx AliAnalysisTaskITSTrackingCheck.h AliAnalysisTaskITSTrackingCheck.cxx AliAnalysisTaskSEImpParRes.h AliAnalysisTaskSEImpParRes.cxx AliAnalysisTaskVertexESD.h AliAnalysisTaskVertexESD.cxx libGui.so libProof.so libRAWDatabase.so libRAWDatarec.so libCDB.so libSTEER.so libITSbase.so libITSrec.so");
+     //plugin->SetAdditionalLibs("AliAnalysisTaskVertexESD.h AliAnalysisTaskVertexESD.cxx libProof.so libRAWDatabase.so libRAWDatarec.so libCDB.so libSTEER.so libITSbase.so libITSrec.so");
    } else {
      plugin->SetAdditionalLibs("libGui.so libProof.so libMinuit.so libRAWDatabase.so libRAWDatarec.so libCDB.so libSTEER.so libITSbase.so libITSrec.so libTPCbase.so libTPCrec.so libTRDbase.so libTRDrec.so libTENDER.so libPWG1.so");
    }
@@ -186,14 +235,16 @@ AliAnalysisGrid* CreateAlienHandler(TString pluginmode="test",
    plugin->SetOutputArchive("log_archive.zip:stdout,stderr");
    // Optionally set a name for the generated analysis macro (default MyAnalysis.C)
    plugin->SetAnalysisMacro("AnalysisITS.C");
+   plugin->SetExecutable("analysisITS.sh");
+   plugin->SetExecutableCommand("root.exe -b -q");
    // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
-   plugin->SetSplitMaxInputFileNumber(1);
+   plugin->SetSplitMaxInputFileNumber(5);
    // Optionally set number of failed jobs that will trigger killing waiting sub-jobs.
    //plugin->SetMaxInitFailed(5);
    // Optionally resubmit threshold.
    //plugin->SetMasterResubmitThreshold(90);
    // Optionally set time to live (default 30000 sec)
-   //plugin->SetTTL(20000);
+   plugin->SetTTL(80000);
    // Optionally set input format (default xml-single)
    plugin->SetInputFormat("xml-single");
    // Optionally modify the name of the generated JDL (default analysis.jdl)
@@ -217,16 +268,6 @@ TChain *CreateESDChain(TString esdpath=".",Int_t ifirst=-1,Int_t ilast=-1) {
     chainESD->Add("AliESDs.root");
   } else {
     for(Int_t i=ifirst; i<=ilast; i++) {
-      TString command=".! ln -s ";
-      command+=esdpath.Data();
-      command+=i;
-      command+= "/AliESDs_def.root ";
-      command+=esdpath.Data();
-      command+=i;
-      command+= "/AliESDs.root ";
-      gROOT->ProcessLine(command.Data());
-      command.ReplaceAll("AliESDs","AliESDfriends");
-      gROOT->ProcessLine(command.Data());
       TString esdfile=esdpath; esdfile+=i; esdfile.Append("/AliESDs.root");
       chainESD->Add(esdfile.Data());
     }