end-of-line normalization
[u/mrichter/AliRoot.git] / PWGCF / EBYE / macros / AddTaskBalanceMCCentralityTrain.C
index 3865c5d..e0586a2 100644 (file)
-// now in options\r
-//=============================================//\r
-//const char* centralityEstimator = "V0M";\r
-//const char* centralityEstimator = "CL1";\r
-//const char* centralityEstimator = "TRK";\r
-//=============================================//\r
-//Bool_t gRunShuffling = kFALSE;\r
-//Bool_t gRunShuffling = kTRUE;\r
-//=============================================//\r
-//_________________________________________________________//\r
-AliAnalysisTaskBF *AddTaskBalanceMCCentralityTrain(Double_t centrMin=0.,\r
-                                                  Double_t centrMax=100.,\r
-                                                  Double_t impactParameterMin=0.,\r
-                                                  Double_t impactParameterMax=20.,\r
-                                                  Bool_t gRunShuffling=kFALSE,\r
-                                                  Double_t vertexZ=10.,\r
-                                                  Double_t ptMin=0.3,\r
-                                                  Double_t ptMax=1.5,\r
-                                                  Double_t etaMin=-0.8,\r
-                                                  Double_t etaMax=0.8,\r
-                                                  TF1* gAcceptanceParameterization = 0x0,\r
-                                                  Int_t gPdgCode = -1,\r
-                                                  TString fileNameBase="AnalysisResults") {\r
-\r
-  // Creates a balance function analysis task and adds it to the analysis manager.\r
-  // Get the pointer to the existing analysis manager via the static access method.\r
-  TString centralityName("");\r
-  centralityName+=Form("%.0f",centrMin);\r
-  centralityName+="-";\r
-  centralityName+=Form("%.0f",centrMax);\r
-\r
-  TString outputFileName(fileNameBase);\r
-  outputFileName.Append(".root");\r
-\r
-  //===========================================================================\r
-  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();\r
-  if (!mgr) {\r
-    ::Error("AddTaskBF", "No analysis manager to connect to.");\r
-    return NULL;\r
-  }\r
-\r
-  // Check the analysis type using the event handlers connected to the analysis manager.\r
-  //===========================================================================\r
-  if (!mgr->GetInputEventHandler()) {\r
-    ::Error("AddTaskBF", "This task requires an input event handler");\r
-    return NULL;\r
-  }\r
-  TString analysisType = "MC";\r
-\r
-  // for local changed BF configuration\r
-  gROOT->LoadMacro("./configBalanceFunctionAnalysis.C");\r
-  //gROOT->LoadMacro("$ALICE_ROOT/PWGCF/EBYE/macros/configBalanceFunctionAnalysis.C");\r
-  AliBalance *bf  = 0;  // Balance Function object\r
-  AliBalance *bfs = 0;  // shuffled Balance function object\r
-\r
-  if (analysisType=="ESD"){\r
-    bf  = GetBalanceFunctionObject("ESD",centralityName.Data());\r
-    if(gRunShuffling) bfs = GetBalanceFunctionObject("ESD",centralityName.Data(),kTRUE);\r
-  }\r
-  else if (analysisType=="AOD"){\r
-    bf  = GetBalanceFunctionObject("AOD",centralityName.Data());\r
-    if(gRunShuffling) bfs = GetBalanceFunctionObject("AOD",centralityName.Data(),kTRUE);\r
-  }\r
-  else if (analysisType=="MC"){\r
-    bf  = GetBalanceFunctionObject("MC",centralityName.Data());\r
-    if(gRunShuffling) bfs = GetBalanceFunctionObject("MC",centralityName.Data(),kTRUE);\r
-  }\r
-  else{\r
-    ::Error("AddTaskBF", "analysis type NOT known.");\r
-    return NULL;\r
-  }\r
-\r
-  // Create the task, add it to manager and configure it.\r
-  //===========================================================================\r
-  AliAnalysisTaskBF *taskBF = new AliAnalysisTaskBF("TaskBF");\r
-  taskBF->SetAnalysisObject(bf);\r
-  if(gRunShuffling) taskBF->SetShufflingObject(bfs);\r
-\r
-  if(analysisType == "ESD") {\r
-    AliESDtrackCuts *trackCuts = GetTrackCutsObject(ptMin,ptMax,etaMin,etaMax,maxTPCchi2,DCAxy,DCAz,minNClustersTPC);\r
-    taskBF->SetAnalysisCutObject(trackCuts);\r
-    // centrality estimator (default = V0M)\r
-    taskBF->SetCentralityEstimator(centralityEstimator);\r
-    taskBF->SetCentralityPercentileRange(impactParameterMin,\r
-                                        impactParameterMax);\r
-  }\r
-  else if(analysisType == "AOD") {\r
-    // pt and eta cut (pt_min, pt_max, eta_min, eta_max)\r
-    taskBF->SetAODtrackCutBit(128);\r
-    taskBF->SetKinematicsCutsAOD(ptMin,ptMax,etaMin,etaMax);\r
-    taskBF->SetCentralityEstimator(centralityEstimator);\r
-    taskBF->SetCentralityPercentileRange(impactParameterMin,\r
-                                        impactParameterMax);\r
-\r
-    // set extra DCA cuts (-1 no extra cut)\r
-    taskBF->SetExtraDCACutsAOD(DCAxy,DCAz);\r
-\r
-    // set extra TPC chi2 / nr of clusters cut\r
-    taskBF->SetExtraTPCCutsAOD(maxTPCchi2, minNClustersTPC);\r
-    taskBF->SetCentralityEstimator(centralityEstimator);    \r
-  }\r
-  else if(analysisType == "MC") {\r
-    Printf("********************ANALYSIS TYPE MC********************************");\r
-    if(gAcceptanceParameterization)\r
-      taskBF->SetAcceptanceParameterization(gAcceptanceParameterization);\r
-    if(gPdgCode != -1)\r
-      taskBF->SetPDGCode(gPdgCode);\r
-    taskBF->SetKinematicsCutsAOD(ptMin,ptMax,etaMin,etaMax); \r
-    taskBF->SetImpactParameterRange(impactParameterMin,\r
-                                   impactParameterMax);\r
-  }\r
-\r
-  // offline trigger selection (AliVEvent.h)\r
-  // taskBF->UseOfflineTrigger(); // NOT used (selection is done with the AliAnalysisTaskSE::SelectCollisionCandidates()) \r
-  // with this only selected events are analyzed (first 2 bins in event QA histogram are the same))\r
-  // documentation in https://twiki.cern.ch/twiki/bin/viewauth/ALICE/PWG1EvSelDocumentation\r
-  //taskBF->SelectCollisionCandidates(AliVEvent::kMB);\r
-    \r
-  // vertex cut (x,y,z)\r
-  taskBF->SetVertexDiamond(.3,.3,vertexZ);\r
-  \r
-\r
-\r
-  //bf->PrintAnalysisSettings();\r
-  mgr->AddTask(taskBF);\r
-  \r
-  // Create ONLY the output containers for the data produced by the task.\r
-  // Get and connect other common input/output containers via the manager as below\r
-  //==============================================================================\r
-  TString outputFileName = AliAnalysisManager::GetCommonFileName();\r
-  outputFileName += ":PWGCFEbyE.outputBalanceFunctionAnalysis";\r
-  AliAnalysisDataContainer *coutQA = mgr->CreateContainer(Form("listQA_%s",centralityName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());\r
-  AliAnalysisDataContainer *coutBF = mgr->CreateContainer(Form("listBF_%s",centralityName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());\r
-  if(gRunShuffling) AliAnalysisDataContainer *coutBFS= mgr->CreateContainer(Form("listBFShuffled_%s",centralityName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());\r
-  mgr->ConnectInput(taskBF, 0, mgr->GetCommonInputContainer());\r
-  mgr->ConnectOutput(taskBF, 1, coutQA);\r
-  mgr->ConnectOutput(taskBF, 2, coutBF);\r
-  if(gRunShuffling) mgr->ConnectOutput(taskBF, 3, coutBFS);\r
-\r
-  return taskBF;\r
-}\r
+// now in options
+//=============================================//
+//const char* centralityEstimator = "V0M";
+//const char* centralityEstimator = "CL1";
+//const char* centralityEstimator = "TRK";
+//=============================================//
+//Bool_t gRunShuffling = kFALSE;
+//Bool_t gRunShuffling = kTRUE;
+//=============================================//
+//_________________________________________________________//
+AliAnalysisTaskBF *AddTaskBalanceMCCentralityTrain(Double_t centrMin=0.,
+                                                  Double_t centrMax=100.,
+                                                  Double_t impactParameterMin=0.,
+                                                  Double_t impactParameterMax=20.,
+                                                  Bool_t gRunShuffling=kFALSE,
+                                                  Double_t vertexZ=10.,
+                                                  Double_t ptMin=0.3,
+                                                  Double_t ptMax=1.5,
+                                                  Double_t etaMin=-0.8,
+                                                  Double_t etaMax=0.8,
+                                                  TF1* gAcceptanceParameterization = 0x0,
+                                                  Int_t gPdgCode = -1,
+                                                  TString fileNameBase="AnalysisResults") {
+
+  // Creates a balance function analysis task and adds it to the analysis manager.
+  // Get the pointer to the existing analysis manager via the static access method.
+  TString centralityName("");
+  centralityName+=Form("%.0f",centrMin);
+  centralityName+="-";
+  centralityName+=Form("%.0f",centrMax);
+
+  TString outputFileName(fileNameBase);
+  outputFileName.Append(".root");
+
+  //===========================================================================
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    ::Error("AddTaskBF", "No analysis manager to connect to.");
+    return NULL;
+  }
+
+  // Check the analysis type using the event handlers connected to the analysis manager.
+  //===========================================================================
+  if (!mgr->GetInputEventHandler()) {
+    ::Error("AddTaskBF", "This task requires an input event handler");
+    return NULL;
+  }
+  TString analysisType = "MC";
+
+  // for local changed BF configuration
+  gROOT->LoadMacro("./configBalanceFunctionAnalysis.C");
+  //gROOT->LoadMacro("$ALICE_ROOT/PWGCF/EBYE/macros/configBalanceFunctionAnalysis.C");
+  AliBalance *bf  = 0;  // Balance Function object
+  AliBalance *bfs = 0;  // shuffled Balance function object
+
+  if (analysisType=="ESD"){
+    bf  = GetBalanceFunctionObject("ESD",centralityName.Data());
+    if(gRunShuffling) bfs = GetBalanceFunctionObject("ESD",centralityName.Data(),kTRUE);
+  }
+  else if (analysisType=="AOD"){
+    bf  = GetBalanceFunctionObject("AOD",centralityName.Data());
+    if(gRunShuffling) bfs = GetBalanceFunctionObject("AOD",centralityName.Data(),kTRUE);
+  }
+  else if (analysisType=="MC"){
+    bf  = GetBalanceFunctionObject("MC",centralityName.Data());
+    if(gRunShuffling) bfs = GetBalanceFunctionObject("MC",centralityName.Data(),kTRUE);
+  }
+  else{
+    ::Error("AddTaskBF", "analysis type NOT known.");
+    return NULL;
+  }
+
+  // Create the task, add it to manager and configure it.
+  //===========================================================================
+  AliAnalysisTaskBF *taskBF = new AliAnalysisTaskBF("TaskBF");
+  taskBF->SetAnalysisObject(bf);
+  if(gRunShuffling) taskBF->SetShufflingObject(bfs);
+
+  if(analysisType == "ESD") {
+    AliESDtrackCuts *trackCuts = GetTrackCutsObject(ptMin,ptMax,etaMin,etaMax,maxTPCchi2,DCAxy,DCAz,minNClustersTPC);
+    taskBF->SetAnalysisCutObject(trackCuts);
+    // centrality estimator (default = V0M)
+    taskBF->SetCentralityEstimator(centralityEstimator);
+    taskBF->SetCentralityPercentileRange(impactParameterMin,
+                                        impactParameterMax);
+  }
+  else if(analysisType == "AOD") {
+    // pt and eta cut (pt_min, pt_max, eta_min, eta_max)
+    taskBF->SetAODtrackCutBit(128);
+    taskBF->SetKinematicsCutsAOD(ptMin,ptMax,etaMin,etaMax);
+    taskBF->SetCentralityEstimator(centralityEstimator);
+    taskBF->SetCentralityPercentileRange(impactParameterMin,
+                                        impactParameterMax);
+
+    // set extra DCA cuts (-1 no extra cut)
+    taskBF->SetExtraDCACutsAOD(DCAxy,DCAz);
+
+    // set extra TPC chi2 / nr of clusters cut
+    taskBF->SetExtraTPCCutsAOD(maxTPCchi2, minNClustersTPC);
+    taskBF->SetCentralityEstimator(centralityEstimator);    
+  }
+  else if(analysisType == "MC") {
+    Printf("********************ANALYSIS TYPE MC********************************");
+    if(gAcceptanceParameterization)
+      taskBF->SetAcceptanceParameterization(gAcceptanceParameterization);
+    if(gPdgCode != -1)
+      taskBF->SetPDGCode(gPdgCode);
+    taskBF->SetKinematicsCutsAOD(ptMin,ptMax,etaMin,etaMax); 
+    taskBF->SetImpactParameterRange(impactParameterMin,
+                                   impactParameterMax);
+  }
+
+  // offline trigger selection (AliVEvent.h)
+  // taskBF->UseOfflineTrigger(); // NOT used (selection is done with the AliAnalysisTaskSE::SelectCollisionCandidates()) 
+  // with this only selected events are analyzed (first 2 bins in event QA histogram are the same))
+  // documentation in https://twiki.cern.ch/twiki/bin/viewauth/ALICE/PWG1EvSelDocumentation
+  //taskBF->SelectCollisionCandidates(AliVEvent::kMB);
+    
+  // vertex cut (x,y,z)
+  taskBF->SetVertexDiamond(.3,.3,vertexZ);
+  
+
+
+  //bf->PrintAnalysisSettings();
+  mgr->AddTask(taskBF);
+  
+  // Create ONLY the output containers for the data produced by the task.
+  // Get and connect other common input/output containers via the manager as below
+  //==============================================================================
+  TString outputFileName = AliAnalysisManager::GetCommonFileName();
+  outputFileName += ":PWGCFEbyE.outputBalanceFunctionAnalysis";
+  AliAnalysisDataContainer *coutQA = mgr->CreateContainer(Form("listQA_%s",centralityName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());
+  AliAnalysisDataContainer *coutBF = mgr->CreateContainer(Form("listBF_%s",centralityName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());
+  if(gRunShuffling) AliAnalysisDataContainer *coutBFS= mgr->CreateContainer(Form("listBFShuffled_%s",centralityName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());
+  mgr->ConnectInput(taskBF, 0, mgr->GetCommonInputContainer());
+  mgr->ConnectOutput(taskBF, 1, coutQA);
+  mgr->ConnectOutput(taskBF, 2, coutBF);
+  if(gRunShuffling) mgr->ConnectOutput(taskBF, 3, coutBFS);
+
+  return taskBF;
+}