]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
cleanup
authorsnelling <snelling@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 10 Feb 2011 21:44:25 +0000 (21:44 +0000)
committersnelling <snelling@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 10 Feb 2011 21:44:25 +0000 (21:44 +0000)
PWG2/FLOW/macros/runFlowTaskCentralityTrain.C

index 7698b8bf3a580ad9d2430d086c5804fe8314256a..33c9186634f8680b488e565d6fbb3f42f97973b9 100644 (file)
@@ -1,4 +1,4 @@
-enum anaModes {mLocal,mLocalPAR,mPROOF,mGrid,mGridPAR};
+enum anaModes {mLocal,mPROOF,mGrid};
 //mLocal: Analyze locally files in your computer using aliroot
 //mLocalPAR: Analyze locally files in your computer using root + PAR files
 //mPROOF: Analyze CAF files with PROOF
@@ -6,7 +6,7 @@ enum anaModes {mLocal,mLocalPAR,mPROOF,mGrid,mGridPAR};
 //       (Remark: When using this mode set also Bool_t bUseParFiles = kFALSE; in CreateAlienHandler.C)
 //mGridPAR: Analyze files on Grid via AliEn plug-in and using par files for FLOW package
 //          (Remark: when using this mode set also Bool_t bUseParFiles = kTRUE; in CreateAlienHandler.C)
+
 // CENTRALITY DEFINITION
 //Int_t binfirst = 4;  //where do we start numbering bins
 //Int_t binlast = 6;  //where do we stop numbering bins
@@ -19,54 +19,61 @@ Float_t centralityArray[numberOfCentralityBins+1] = {0.,5.,10.,20.,30.,40.,50.,6
 
 TString commonOutputFileName = "outputCentrality"; // e.g.: result for centrality bin 0 will be in the file "outputCentrality0.root", etc
 
-
-//void runFlowTaskCentralityTrain(Int_t mode=mLocal, Int_t nRuns = 10, 
+//void runFlowTaskCentralityTrain(Int_t mode=mLocal, Int_t nEvents = 10,
 //Bool_t DATA = kFALSE, const Char_t* dataDir="/Users/snelling/alice_data/Therminator_midcentral", Int_t offset = 0)
 
-//void runFlowTaskCentralityTrain(Int_t mode = mGridPAR, Int_t nRuns = 50000000, 
-//              Bool_t DATA = kTRUE, const Char_t* dataDir="/alice/data/LHC10h_000137161_p1_plusplusplus", Int_t offset=0) 
-void runFlowTaskCentralityTrain(Int_t mode = mLocal, Int_t nRuns = 50000000, 
-                               Bool_t DATA = kTRUE, const Char_t* dataDir="./data/", Int_t offset=0) 
-//void runFlowTaskCentralityTrain(Int_t mode = mGridPAR, Bool_t DATA = kTRUE)
+//void runFlowTaskCentralityTrain(Int_t mode = mGridPAR, Int_t nEvents = 50000000,
+//              Bool_t DATA = kTRUE, const Char_t* dataDir="/alice/data/LHC10h_000137161_p1_plusplusplus", Int_t offset=0)
+void runFlowTaskCentralityTrain( Int_t mode = mPROOF,
+                                 Bool_t useFlowParFiles = kFALSE,
+                                 Bool_t DATA = kTRUE,
+                                 const Char_t* dataDir="/alice/data/LHC10h_000137162_p1_plusplusplus#esdTree",
+                                 Int_t nEvents = 1e4,
+                                 Int_t offset=0 )
 {
   // Time:
   TStopwatch timer;
   timer.Start();
   // Cross-check user settings before starting:
   //  CrossCheckUserSettings(DATA);
+
   // Load needed libraries:
-  LoadLibraries(mode);
+  LoadLibraries(mode,useFlowParFiles);
+
   // Create and configure the AliEn plug-in:
-  if(mode == mGrid || mode == mGridPAR) 
-    {    
-      gROOT->LoadMacro("CreateAlienHandler.C");
-      AliAnalysisGrid *alienHandler = CreateAlienHandler();  
-      if(!alienHandler) return;
-    }
-  // Chains: 
-  if(mode == mLocal || mode == mLocalPAR) {
-    TChain* chain = CreateESDChain(dataDir, nRuns, offset);
-    //TChain* chain = CreateAODChain(dataDir, nRuns, offset);
+  if(mode == mGrid)
+  {
+    gROOT->LoadMacro("CreateAlienHandler.C");
+    AliAnalysisGrid *alienHandler = CreateAlienHandler();
+    if(!alienHandler) return;
   }
-  
+
+  // Chains:
+  if(mode == mLocal)
+  {
+    TChain* chain = CreateESDChain(dataDir, nEvents, offset);
+    //TChain* chain = CreateAODChain(dataDir, nEvents, offset);
+  }
+
   // Create analysis manager:
-  AliAnalysisManager *mgr = new AliAnalysisManager("FlowAnalysisManager"); 
+  AliAnalysisManager *mgr = new AliAnalysisManager("FlowAnalysisManager");
   // Connect plug-in to the analysis manager:
-  if(mode == mGrid || mode == mGridPAR) 
-    { 
-      mgr->SetGridHandler(alienHandler);
-    }
-  
+  if(mode == mGrid)
+  {
+    mgr->SetGridHandler(alienHandler);
+  }
+
   // Event handlers:
   AliVEventHandler* esdH = new AliESDInputHandler;
   mgr->SetInputEventHandler(esdH);
-  if (!DATA) {
+  if (!DATA)
+  {
     AliMCEventHandler *mc = new AliMCEventHandler();
-    mgr->SetMCtruthEventHandler(mc); 
+    mgr->SetMCtruthEventHandler(mc);
   }
 
   // Task to check the offline trigger:
-  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); 
+  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
   AddTaskPhysicsSelection(!DATA);
 
   //Add the centrality determination task
@@ -79,40 +86,47 @@ void runFlowTaskCentralityTrain(Int_t mode = mLocal, Int_t nRuns = 50000000,
 
   // Setup analysis per centrality bin:
   gROOT->LoadMacro("AddTaskFlowCentrality.C");
-  for (Int_t i=binfirst; i<binlast+1; i++)
-  {
-    Float_t lowCentralityBinEdge = centralityArray[i];
-    Float_t highCentralityBinEdge = centralityArray[i+1];
-    Printf("\nWagon for centrality bin %i: %.0f-%.0f",i,lowCentralityBinEdge,highCentralityBinEdge);
-    AddTaskFlowCentrality( lowCentralityBinEdge,
-                           highCentralityBinEdge,
-                           commonOutputFileName );
-  } // end of for (Int_t i=0; i<numberOfCentralityBins; i++)
+  //for (Int_t i=binfirst; i<binlast+1; i++)
+  //{
+  //  Float_t lowCentralityBinEdge = centralityArray[i];
+  //  Float_t highCentralityBinEdge = centralityArray[i+1];
+  //  Printf("\nWagon for centrality bin %i: %.0f-%.0f",i,lowCentralityBinEdge,highCentralityBinEdge);
+  //  AddTaskFlowCentrality( lowCentralityBinEdge,
+  //                         highCentralityBinEdge,
+  //                         commonOutputFileName );
+  //} // end of for (Int_t i=0; i<numberOfCentralityBins; i++)
+
+  AddTaskFlowCentrality();
 
   // Enable debug printouts:
   mgr->SetDebugLevel(2);
   // Run the analysis:
-  if(!mgr->InitAnalysis()) return;  
+  if(!mgr->InitAnalysis()) return;
   mgr->PrintStatus();
-  if(mode == mLocal || mode == mLocalPAR) {
+  if(mode == mLocal)
+  {
     mgr->StartAnalysis("local",chain);
-  } else if(mode == mPROOF) {
-    mgr->StartAnalysis("proof",dataDir,nRuns,offset);
-  } else if(mode == mGrid || mode == mGridPAR) { 
+  }
+  else if(mode == mPROOF)
+  {
+    mgr->StartAnalysis("proof",dataDir,nEvents,offset);
+  }
+  else if(mode == mGrid)
+  {
     mgr->StartAnalysis("grid");
   }
 
   // Print real and CPU time used for analysis:
   timer.Stop();
-  timer.Print();  
-  
+  timer.Print();
+
 } // end of void runFlowTaskCentralityTrain(...)
 
 //===============================================================================================
 /*
-void CrossCheckUserSettings(Bool_t bData) 
+void CrossCheckUserSettings(Bool_t bData)
 {
- // Check in this method if the user settings make sense. 
+ // Check in this method if the user settings make sense.
  if(LYZ1SUM && LYZ2SUM) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); }
  if(LYZ1PROD && LYZ2PROD) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); }
  if(LYZ2SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ2 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); }
@@ -121,13 +135,13 @@ void CrossCheckUserSettings(Bool_t bData)
 */
 //===============================================================================================
 
-void LoadLibraries(const anaModes mode
+void LoadLibraries(const anaModes mode, Bool_t useFlowParFiles )
 {
   //--------------------------------------
   // Load the needed libraries most of them already loaded by aliroot
   //--------------------------------------
 
-  gSystem->Load("libCore");  
+  gSystem->Load("libCore");
   gSystem->Load("libTree");
   gSystem->Load("libGeom");
   gSystem->Load("libVMC");
@@ -136,8 +150,8 @@ void LoadLibraries(const anaModes mode)
   gSystem->Load("libXMLParser");
   gSystem->Load("libProof");
   gSystem->Load("libMinuit");
-  
-  if (mode==mLocal || mode==mGrid || mode == mGridPAR || mode == mLocalPAR )
+
+  if (mode==mLocal || mode==mGrid)
   {
     gSystem->Load("libSTEERBase");
     gSystem->Load("libCDB");
@@ -147,93 +161,66 @@ void LoadLibraries(const anaModes mode)
     gSystem->Load("libAOD");
     gSystem->Load("libSTEER");
     gSystem->Load("libANALYSIS");
-    gSystem->Load("libANALYSISalice");   
-    gSystem->Load("libTOFbase"); 
-    gSystem->Load("libTOFrec"); 
+    gSystem->Load("libANALYSISalice");
+    gSystem->Load("libTOFbase");
+    gSystem->Load("libTOFrec");
     gSystem->Load("libTRDbase");
     gSystem->Load("libVZERObase");
     gSystem->Load("libVZEROrec");
     gSystem->Load("libT0base");
-    gSystem->Load("libT0rec");    
+    gSystem->Load("libT0rec");
     gSystem->Load("libTENDER");
     gSystem->Load("libTENDERSupplies");
 
-    if (mode == mLocal || mode == mGrid)
-    {
-      gSystem->Load("libPWG2flowCommon"); 
-      gSystem->Load("libPWG2flowTasks"); 
-    }
-    if (mode == mLocalPAR || mode == mGridPAR )
+    if (useFlowParFiles)
     {
       AliAnalysisAlien::SetupPar("PWG2flowCommon");
       AliAnalysisAlien::SetupPar("PWG2flowTasks");
     }
+    else
+    {
+      gSystem->Load("libPWG2flowCommon");
+      gSystem->Load("libPWG2flowTasks");
+    }
   }
-  
-  //---------------------------------------------------------
-  // <<<<<<<<<< PROOF mode >>>>>>>>>>>>
-  //---------------------------------------------------------
-  else if (mode==mPROOF) {
-    //  set to debug root versus if needed
-    //TProof::Mgr("alicecaf")->SetROOTVersion("v5-24-00a_dbg");
-    //TProof::Mgr("alicecaf")->SetROOTVersion("v5-24-00a");
-    //TProof::Reset("proof://snelling@alicecaf.cern.ch");     
+  else if (mode==mPROOF)
+  {
+    TList* list = new TList();
+    list->Add(new TNamed("ALIROOT_MODE", "ALIROOT"));
+    if (useFlowParFiles)
+      list->Add(new TNamed("ALIROOT_EXTRA_LIBS", "ANALYSIS:ANALYSISalice:TENDER:TENDERSupplies"));
+    else
+      list->Add(new TNamed("ALIROOT_EXTRA_LIBS", "ANALYSIS:ANALYSISalice:TENDER:TENDERSupplies:PWG2flowCommon:PWG2flowTasks"));
+
+    //list->Add(new TNamed("ALIROOT_EXTRA_INCLUDES","PWG2/FLOW/AliFlowCommon:PWG2/FLOW/AliFlowTasks"));
+
     // Connect to proof
     printf("*** Connect to PROOF ***\n");
     gEnv->SetValue("XSec.GSI.DelegProxy","2");
-    TProof::Open("mkrzewic@alice-caf.cern.ch");
-    //TProof::Open("mkrzewic@skaf.saske.sk");
-     // list the data available
-    //gProof->ShowDataSets("/*/*"); 
+    //TProof* proof = TProof::Open("alice-caf.cern.ch");
+    TProof* proof = TProof::Open("skaf.saske.sk");
+
+    // list the data available
+    //gProof->ShowDataSets("/*/*");
     //gProof->ShowDataSets("/alice/sim/"); //for MC Data
-    //gProof->ShowDataSets("/alice/data/"); //for REAL Data 
-    // Clear the Packages
-    /*    
-    gProof->ClearPackage("STEERBase.par");
-    gProof->ClearPackage("ESD.par");
-    gProof->ClearPackage("AOD.par");
-    */
-    //gProof->ClearPackage("ANALYSIS.par");
-    //gProof->ClearPackage("ANALYSISalice.par");
-    //gProof->ClearPackage("CORRFW.par");
-    
-    gProof->ClearPackage("PWG2flowCommon");
-    gProof->ClearPackage("PWG2flowTasks");
-    
-    // Upload the Packages
-    //gProof->UploadPackage("STEERBase.par");
-    //gProof->UploadPackage("ESD.par");    
-    //gProof->UploadPackage("AOD.par");
-       
-    //gProof->UploadPackage("ANALYSIS.par"); 
-    //gProof->UploadPackage("ANALYSISalice.par");
-    gProof->UploadPackage("CORRFW.par");
-    gProof->UploadPackage("PWG2flowCommon.par");
-    gProof->UploadPackage("PWG2flowTasks.par");
-    gProof->UploadPackage("ALIRECO.par");
-
-    // Enable the Packages 
-    // The global package
-    TList* list = new TList();
-    list->Add(new TNamed("ALIROOT_EXTRA_INCLUDES","RAW:OCDB:STEER:TOF"));
-    gProof->EnablePackage("VO_ALICE@AliRoot::v4-21-07-AN",list);
-    gProof->EnablePackage("ALIRECO");
-    //gProof->EnablePackage("ANALYSIS");
-    //gProof->EnablePackage("ANALYSISalice");
-    //gProof->EnablePackage("CORRFW");
-    gProof->EnablePackage("PWG2flowCommon");
-    gProof->EnablePackage("PWG2flowTasks");
+    //gProof->ShowDataSets("/alice/data/"); //for REAL Data
+
+    proof->ClearPackages();
+    proof->EnablePackage("VO_ALICE@AliRoot::v4-21-14-AN",list);
+
+    if (useFlowParFiles)
+    {
+      gProof->UploadPackage("PWG2flowCommon.par");
+      gProof->UploadPackage("PWG2flowTasks.par");
+    }
 
     // Show enables Packages
     gProof->ShowEnabledPackages();
-  }  
-  
-} // end of void LoadLibraries(const anaModes mode) 
+  }
+} // end of void LoadLibraries(const anaModes mode)
 
 // Helper macros for creating chains
 // from: CreateESDChain.C,v 1.10 jgrosseo Exp
-
 TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
 {
   // creates chain of files in a given directory or file containing a list.
@@ -241,83 +228,84 @@ TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
   // <aDataDir>/<dir0>/AliESDs.root
   // <aDataDir>/<dir1>/AliESDs.root
   // ...
-  
+
   if (!aDataDir)
     return 0;
-  
+
   Long_t id, size, flags, modtime;
   if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
-    {
-      printf("%s not found.\n", aDataDir);
-      return 0;
-    }
-  
+  {
+    printf("%s not found.\n", aDataDir);
+    return 0;
+  }
+
   TChain* chain = new TChain("esdTree");
   TChain* chaingAlice = 0;
-  
+
   if (flags & 2)
+  {
+    TString execDir(gSystem->pwd());
+    TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
+    TList* dirList            = baseDir->GetListOfFiles();
+    Int_t nDirs               = dirList->GetEntries();
+    gSystem->cd(execDir);
+
+    Int_t count = 0;
+
+    for (Int_t iDir=0; iDir<nDirs; ++iDir)
     {
-      TString execDir(gSystem->pwd());
-      TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
-      TList* dirList            = baseDir->GetListOfFiles();
-      Int_t nDirs               = dirList->GetEntries();
-      gSystem->cd(execDir);
-      
-      Int_t count = 0;
-      
-      for (Int_t iDir=0; iDir<nDirs; ++iDir)
-       {
-         TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
-         if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
-           continue;
-         
-         if (offset > 0)
-           {
-             --offset;
-             continue;
-           }
-         
-         if (count++ == aRuns)
-           break;
-         
-         TString presentDirName(aDataDir);
-         presentDirName += "/";
-         presentDirName += presentDir->GetName();        
-         chain->Add(presentDirName + "/AliESDs.root/esdTree");
-         //  cerr<<presentDirName<<endl;
-       }
-      
+      TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
+      if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
+        continue;
+
+      if (offset > 0)
+      {
+        --offset;
+        continue;
+      }
+
+      if (count++ == aRuns)
+        break;
+
+      TString presentDirName(aDataDir);
+      presentDirName += "/";
+      presentDirName += presentDir->GetName();
+      chain->Add(presentDirName + "/AliESDs.root/esdTree");
+      //  cerr<<presentDirName<<endl;
     }
+
+  }
   else
+  {
+    // Open the input stream
+    ifstream in;
+    in.open(aDataDir);
+
+    Int_t count = 0;
+
+    // Read the input list of files and add them to the chain
+    TString esdfile;
+    while(in.good())
     {
-      // Open the input stream
-      ifstream in;
-      in.open(aDataDir);
-      
-      Int_t count = 0;
-      
-      // Read the input list of files and add them to the chain
-      TString esdfile;
-      while(in.good()) {
-       in >> esdfile;
-       if (!esdfile.Contains("root")) continue; // protection
-       
-       if (offset > 0)
-         {
-           --offset;
-           continue;
-         }
-       
-       if (count++ == aRuns)
-         break;
-       
-       // add esd file
-       chain->Add(esdfile);
+      in >> esdfile;
+      if (!esdfile.Contains("root")) continue; // protection
+
+      if (offset > 0)
+      {
+        --offset;
+        continue;
       }
-      
-      in.close();
+
+      if (count++ == aRuns)
+        break;
+
+      // add esd file
+      chain->Add(esdfile);
     }
-  
+
+    in.close();
+  }
+
   return chain;
 
 } // end of TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
@@ -331,83 +319,84 @@ TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
   // <aDataDir>/<dir0>/AliAOD.root
   // <aDataDir>/<dir1>/AliAOD.root
   // ...
-  
+
   if (!aDataDir)
     return 0;
-  
+
   Long_t id, size, flags, modtime;
   if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
-    {
-      printf("%s not found.\n", aDataDir);
-      return 0;
-    }
-  
+  {
+    printf("%s not found.\n", aDataDir);
+    return 0;
+  }
+
   TChain* chain = new TChain("aodTree");
   TChain* chaingAlice = 0;
-  
+
   if (flags & 2)
+  {
+    TString execDir(gSystem->pwd());
+    TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
+    TList* dirList            = baseDir->GetListOfFiles();
+    Int_t nDirs               = dirList->GetEntries();
+    gSystem->cd(execDir);
+
+    Int_t count = 0;
+
+    for (Int_t iDir=0; iDir<nDirs; ++iDir)
     {
-      TString execDir(gSystem->pwd());
-      TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
-      TList* dirList            = baseDir->GetListOfFiles();
-      Int_t nDirs               = dirList->GetEntries();
-      gSystem->cd(execDir);
-      
-      Int_t count = 0;
-      
-      for (Int_t iDir=0; iDir<nDirs; ++iDir)
-       {
-         TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
-         if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
-           continue;
-         
-         if (offset > 0)
-           {
-             --offset;
-             continue;
-           }
-         
-         if (count++ == aRuns)
-           break;
-         
-         TString presentDirName(aDataDir);
-         presentDirName += "/";
-         presentDirName += presentDir->GetName();        
-         chain->Add(presentDirName + "/AliAOD.root/aodTree");
-         // cerr<<presentDirName<<endl;
-       }
-      
+      TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
+      if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
+        continue;
+
+      if (offset > 0)
+      {
+        --offset;
+        continue;
+      }
+
+      if (count++ == aRuns)
+        break;
+
+      TString presentDirName(aDataDir);
+      presentDirName += "/";
+      presentDirName += presentDir->GetName();
+      chain->Add(presentDirName + "/AliAOD.root/aodTree");
+      // cerr<<presentDirName<<endl;
     }
+
+  }
   else
+  {
+    // Open the input stream
+    ifstream in;
+    in.open(aDataDir);
+
+    Int_t count = 0;
+
+    // Read the input list of files and add them to the chain
+    TString aodfile;
+    while(in.good())
     {
-      // Open the input stream
-      ifstream in;
-      in.open(aDataDir);
-      
-      Int_t count = 0;
-      
-      // Read the input list of files and add them to the chain
-      TString aodfile;
-      while(in.good()) {
-       in >> aodfile;
-       if (!aodfile.Contains("root")) continue; // protection
-       
-       if (offset > 0)
-         {
-           --offset;
-           continue;
-         }
-       
-       if (count++ == aRuns)
-         break;
-       
-       // add aod file
-       chain->Add(aodfile);
+      in >> aodfile;
+      if (!aodfile.Contains("root")) continue; // protection
+
+      if (offset > 0)
+      {
+        --offset;
+        continue;
       }
-      
-      in.close();
+
+      if (count++ == aRuns)
+        break;
+
+      // add aod file
+      chain->Add(aodfile);
     }
-  
+
+    in.close();
+  }
+
   return chain;
 
 } // end of TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)