]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG2/runProtonAnalysisQA.C
Adopting the new analysis scheme with the base class + setting the classdef to 1...
[u/mrichter/AliRoot.git] / PWG2 / runProtonAnalysisQA.C
index 037e599c27a2427206f186a57e690168fc0c6e87..0f8e9022ec85eda5a485f22ce336b1a0ce64f656 100644 (file)
@@ -1,26 +1,43 @@
-void runProtonAnalysisQA(const char *analysisType = "TPC") {
+void runProtonAnalysisQA(const char* analysisType = "Hybrid",
+                        const char* pidMode = "Bayesian") {
   //Macro to run the proton QA analysis tested for local, proof & GRID.
-  //Proof: Takes three arguments, the number of events, the dataset name 
-  //       and the analysis type
-  //Interactive: Takes two arguments, the name of the collection file with 
-  //             the event list for each file and the analysis type
-  //Batch: Takes two arguments, the name of the collection file with 
-  //             the ESDs and the analysis type
-  //Analysis type can be one of the three: "TPC", "Hybrid", "Global"
+  //Local: Takes four arguments, the analysis mode, the type of the ESD 
+  //       analysis, the PID mode and the path where the tag and ESD or 
+  //       AOD files reside.
+  //Interactive: Takes four arguments, the analysis mode, the type of the ESD 
+  //             analysis, the PID mode and the name of the collection of tag 
+  //             files.
+  //Batch: Takes four arguments, the analysis mode, the type of the ESD 
+  //       analysis, the PID mode and the name of the collection file with 
+  //       the event list for each file.
+  //Proof: Takes five arguments, the analysis level, the analysis mode in 
+  //       case of ESD, the PID mode, the number of events and the dataset 
+  //       name and .  
+  //Analysis mode can be: "MC", "ESD", "AOD"
+  //ESD analysis type can be one of the three: "TPC", "Hybrid", "Global"
+  //PID mode can be one of the three: "Bayesian" (standard Bayesian approach) 
+  //   "Ratio" (ratio of measured over expected/theoretical dE/dx a la STAR) 
+  //   "Sigma" (N-sigma area around the fitted dE/dx vs P band)
   TStopwatch timer;
   timer.Start();
   
+  runLocal("ESD",
+          esdAnalysisType,
+          pidMode,
+          "/home/pchrist/ALICE/Baryons/QA/Local");
   //runProof(200000,"/COMMON/COMMON/LHC08c11_10TeV_0.5T",analysisType);
   //runInteractive("wn.xml",analysisType);
   runBatch("wn.xml",analysisType);
-  //runLocal(analysisType);
 
   timer.Stop();
   timer.Print();
 }
 
 //_________________________________________________//
-void runLocal(const char* analysisType) {
+void runLocal(const char* mode = "ESD",
+             const char* analysisType = 0x0,
+             const char* pidMode = 0x0,
+             const char* path = "/home/pchrist/ALICE/Alien/Tutorial/November2007/Tags") {
   TString outputFilename1 = "Protons.QA."; outputFilename1 += analysisType;
   outputFilename1 += ".root"; //main QA file
   TString outputFilename2 = "Protons.MC.QA."; outputFilename2 += analysisType;
@@ -51,15 +68,27 @@ void runLocal(const char* analysisType) {
   setupPar("PWG2spectra");
   gSystem->Load("libPWG2spectra.so");
 
-  gROOT->LoadMacro("AliAnalysisTaskProtonsQA.cxx+");
-  //____________________________________________//
-  //Create the chain from the xml collection of esd files
-  TChain *chain = new TChain("esdTree");  
-  chain->Add("AliESDs.root");
+   //____________________________________________//
+  AliTagAnalysis *tagAnalysis = new AliTagAnalysis("ESD"); 
+  tagAnalysis->ChainLocalTags(path);
+
+  AliRunTagCuts *runCuts = new AliRunTagCuts();
+  AliLHCTagCuts *lhcCuts = new AliLHCTagCuts();
+  AliDetectorTagCuts *detCuts = new AliDetectorTagCuts();
+  AliEventTagCuts *evCuts = new AliEventTagCuts();
   
+  TChain* chain = 0x0;
+  chain = tagAnalysis->QueryTags(runCuts,lhcCuts,detCuts,evCuts);
+  chain->SetBranchStatus("*Calo*",0);
+
+  //____________________________________________//
+  gROOT->LoadMacro("configProtonAnalysis.C");
+  AliProtonQAAnalysis *analysis = GetProtonQAAnalysisObject(mode,
+                                                           analysisType,
+                                                           pidMode);
   //____________________________________________//
   // Make the analysis manager
-  AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
+  AliAnalysisManager *mgr = new AliAnalysisManager("protonAnalysisQAManager");
   AliVEventHandler* esdH = new AliESDInputHandler;
   mgr->SetInputEventHandler(esdH);
   AliMCEventHandler *mc = new AliMCEventHandler();
@@ -68,21 +97,7 @@ void runLocal(const char* analysisType) {
   //____________________________________________//
   // 1st Proton task
   AliAnalysisTaskProtonsQA *taskProtonsQA = new AliAnalysisTaskProtonsQA("TaskProtonsQA");
-  taskProtonsQA->SetTriggerMode(AliAnalysisTaskProtonsQA::kMB2);
-  switch(analysisType) {
-  case "TPC":
-    taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kTPC);
-    break;
-  case "Hybrid":
-    taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kHybrid);
-    break;
-  case "Global":
-    taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kGlobal);
-    break;
-  default:
-    break;
-  }
-  taskProtonsQA->SetAcceptedVertexDiamond(5.,5.,15.);
+  taskProtonsQA->SetAnalysisObject(analysis);
   mgr->AddTask(taskProtonsQA);
 
   // Create containers for input/output
@@ -121,7 +136,7 @@ void runLocal(const char* analysisType) {
                                                            TList::Class(),
                                                            AliAnalysisManager::kOutputContainer,
                                                            outputFilename5.Data());
-
+  
   //____________________________________________//
   mgr->ConnectInput(taskProtonsQA,0,cinput1);
   mgr->ConnectOutput(taskProtonsQA,0,coutput1);
@@ -138,8 +153,10 @@ void runLocal(const char* analysisType) {
 }
 
 //_________________________________________________//
-void runBatch(const char *collectionfile,
-             const char *analysisType) {
+void runInteractive(const char* mode = "ESD",
+                   const char* analysisType = 0x0,
+                   const char* pidMode = 0x0,
+                   const char* collectionName = "tag.xml") {
   TString outputFilename1 = "Protons.QA."; outputFilename1 += analysisType;
   outputFilename1 += ".root"; //main QA file
   TString outputFilename2 = "Protons.MC.QA."; outputFilename2 += analysisType;
@@ -153,7 +170,6 @@ void runBatch(const char *collectionfile,
   TString outputFilename5 = "Vertex.QA.root"; //vertex QA
 
   TGrid::Connect("alien://");
-  gSystem->Load("libProofPlayer.so");
 
   //Setup the par files
   setupPar("STEERBase");
@@ -171,22 +187,30 @@ void runBatch(const char *collectionfile,
   setupPar("PWG2spectra");
   gSystem->Load("libPWG2spectra.so");
 
-  gROOT->LoadMacro("AliAnalysisTaskProtonsQA.cxx+");
   //____________________________________________//
-  //Create the chain from the xml collection of esd files
-  TAlienCollection* coll = TAlienCollection::Open(collectionfile);
-  TGridResult* gridResult = coll->GetGridResult("",0,0);
-  Int_t nEntries = gridResult->GetEntries();
-  TChain *chain = new TChain("esdTree");  
-  TString alienUrl = 0;
-  for(Int_t i = 0; i < nEntries; i++) {
-    alienUrl = gridResult->GetKey(i,"turl");
-    chain->Add(alienUrl);
-  }
-  
+  AliTagAnalysis *tagAnalysis = new AliTagAnalysis("ESD");
+  AliRunTagCuts *runCuts = new AliRunTagCuts();
+  AliLHCTagCuts *lhcCuts = new AliLHCTagCuts();
+  AliDetectorTagCuts *detCuts = new AliDetectorTagCuts();
+  AliEventTagCuts *evCuts = new AliEventTagCuts();
+  //grid tags
+  TAlienCollection* coll = TAlienCollection::Open(collectionName);
+  TGridResult* TagResult = coll->GetGridResult("",0,0);
+  tagAnalysis->ChainGridTags(TagResult);
+  TChain* chain = 0x0;
+  chain = tagAnalysis->QueryTags(runCuts,lhcCuts,detCuts,evCuts);
+  chain->SetBranchStatus("*Calo*",0);
+
+  //____________________________________________//
+  gROOT->LoadMacro("configProtonAnalysis.C");
+  AliProtonQAAnalysis *analysis = GetProtonQAAnalysisObject(mode,
+                                                           analysisType,
+                                                           pidMode);
   //____________________________________________//
   // Make the analysis manager
-  AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
+  AliAnalysisManager *mgr = new AliAnalysisManager("protonAnalysisQAManager");
   AliVEventHandler* esdH = new AliESDInputHandler;
   mgr->SetInputEventHandler(esdH);
   AliMCEventHandler *mc = new AliMCEventHandler();
@@ -195,27 +219,11 @@ void runBatch(const char *collectionfile,
   //____________________________________________//
   // 1st Proton task
   AliAnalysisTaskProtonsQA *taskProtonsQA = new AliAnalysisTaskProtonsQA("TaskProtonsQA");
-  taskProtonsQA->SetTriggerMode(AliAnalysisTaskProtonsQA::kMB2);
-  switch(analysisType) {
-  case "TPC":
-    taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kTPC);
-    break;
-  case "Hybrid":
-    taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kHybrid);
-    break;
-  case "Global":
-    taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kGlobal);
-    break;
-  default:
-    break;
-  }
-  taskProtonsQA->SetAcceptedVertexDiamond(5.,5.,15.);
+  taskProtonsQA->SetAnalysisObject(analysis);
   mgr->AddTask(taskProtonsQA);
 
   // Create containers for input/output
-  AliAnalysisDataContainer *cinput1 = mgr->CreateContainer("dataChain",
-                                                          TChain::Class(),
-                                                          AliAnalysisManager::kInputContainer);
+  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
   AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("globalQAList", 
                                                            TList::Class(),
                                                            AliAnalysisManager::kOutputContainer,
@@ -265,8 +273,10 @@ void runBatch(const char *collectionfile,
 }
 
 //_________________________________________________//
-void runInteractive(const char *collectionfile,
-                   const char *analysisType) {
+void runBatch(const char* mode = "ESD",
+             const char* analysisType = 0x0,
+             const char* pidMode = 0x0,
+             const char *collectionfile = "wn.xml") {
   TString outputFilename1 = "Protons.QA."; outputFilename1 += analysisType;
   outputFilename1 += ".root"; //main QA file
   TString outputFilename2 = "Protons.MC.QA."; outputFilename2 += analysisType;
@@ -280,6 +290,7 @@ void runInteractive(const char *collectionfile,
   TString outputFilename5 = "Vertex.QA.root"; //vertex QA
 
   TGrid::Connect("alien://");
+  gSystem->Load("libProofPlayer.so");
 
   //Setup the par files
   setupPar("STEERBase");
@@ -297,16 +308,21 @@ void runInteractive(const char *collectionfile,
   setupPar("PWG2spectra");
   gSystem->Load("libPWG2spectra.so");
 
-  gROOT->LoadMacro("AliAnalysisTaskProtonsQA.cxx+");
   //____________________________________________//
   //Usage of event tags
-  AliTagAnalysis *analysis = new AliTagAnalysis();
+  AliTagAnalysis *tagAnalysis = new AliTagAnalysis();
   TChain *chain = 0x0;
-  chain = analysis->GetChainFromCollection(collectionfile,"esdTree");
-
+  chain = tagAnalysis->GetChainFromCollection(collectionfile,"esdTree");
+  chain->SetBranchStatus("*Calo*",0);
+  
+  //____________________________________________//
+  gROOT->LoadMacro("configProtonAnalysis.C");
+  AliProtonQAAnalysis *analysis = GetProtonQAAnalysisObject(mode,
+                                                           analysisType,
+                                                           pidMode);
   //____________________________________________//
   // Make the analysis manager
-  AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
+  AliAnalysisManager *mgr = new AliAnalysisManager("protonAnalysisQAManager");
   AliVEventHandler* esdH = new AliESDInputHandler;
   mgr->SetInputEventHandler(esdH);
   AliMCEventHandler *mc = new AliMCEventHandler();
@@ -315,25 +331,13 @@ void runInteractive(const char *collectionfile,
   //____________________________________________//
   // 1st Proton task
   AliAnalysisTaskProtonsQA *taskProtonsQA = new AliAnalysisTaskProtonsQA("TaskProtonsQA");
-  taskProtonsQA->SetTriggerMode(AliAnalysisTaskProtonsQA::kMB2);
-  switch(analysisType) {
-  case "TPC":
-    taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kTPC);
-    break;
-  case "Hybrid":
-    taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kHybrid);
-    break;
-  case "Global":
-    taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kGlobal);
-    break;
-  default:
-    break;
-  }
-  taskProtonsQA->SetAcceptedVertexDiamond(5.,5.,15.);
+  taskProtonsQA->SetAnalysisObject(analysis);
   mgr->AddTask(taskProtonsQA);
 
   // Create containers for input/output
-  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
+  AliAnalysisDataContainer *cinput1 = mgr->CreateContainer("dataChain",
+                                                          TChain::Class(),
+                                                          AliAnalysisManager::kInputContainer);
   AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("globalQAList", 
                                                            TList::Class(),
                                                            AliAnalysisManager::kOutputContainer,
@@ -383,9 +387,11 @@ void runInteractive(const char *collectionfile,
 }
  
 //_________________________________________________//
-void runProof(Int_t stats = 0, 
-             const char* dataset = 0x0,
-             const char *analysisType) {
+void runProof(const char* mode = "ESD",
+             const char* analysisType = 0x0,
+             const char* pidMode = 0x0,
+             Int_t stats = 0, 
+             const char* dataset = 0x0) {
   TString outputFilename1 = "Protons.QA."; outputFilename1 += analysisType;
   outputFilename1 += ".root"; //main QA file
   TString outputFilename2 = "Protons.MC.QA."; outputFilename2 += analysisType;
@@ -418,11 +424,14 @@ void runProof(Int_t stats = 0,
   gProof->UploadPackage("PWG2spectra.par");
   gProof->EnablePackage("PWG2spectra");
   
-  gProof->Load("AliAnalysisTaskProtonsQA.cxx++");
-
+  //____________________________________________//
+  gROOT->LoadMacro("configProtonAnalysis.C");
+  AliProtonQAAnalysis *analysis = GetProtonQAAnalysisObject(mode,
+                                                           analysisType,
+                                                           pidMode);
   //____________________________________________//
   // Make the analysis manager
-  AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
+  AliAnalysisManager *mgr = new AliAnalysisManager("protonAnalysisQAManager");
   AliVEventHandler* esdH = new AliESDInputHandler;
   mgr->SetInputEventHandler(esdH);
   AliMCEventHandler *mc = new AliMCEventHandler();
@@ -431,21 +440,7 @@ void runProof(Int_t stats = 0,
   //____________________________________________//
   // 1st Proton task
   AliAnalysisTaskProtonsQA *taskProtonsQA = new AliAnalysisTaskProtonsQA("TaskProtonsQA");
-  taskProtonsQA->SetTriggerMode(AliAnalysisTaskProtonsQA::kMB2);
-  switch(analysisType) {
-  case "TPC":
-    taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kTPC);
-    break;
-  case "Hybrid":
-    taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kHybrid);
-    break;
-  case "Global":
-    taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kGlobal);
-    break;
-  default:
-    break;
-  }
-  taskProtonsQA->SetAcceptedVertexDiamond(5.,5.,15.);
+  taskProtonsQA->SetAnalysisObject(analysis);
   mgr->AddTask(taskProtonsQA);
 
   // Create containers for input/output