Adding a flag for the shuffling + kinematic cuts for the MC analysis
authorpchrist <pchrist@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 13 Oct 2011 22:31:49 +0000 (22:31 +0000)
committerpchrist <pchrist@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 13 Oct 2011 22:31:49 +0000 (22:31 +0000)
PWG2/EBYE/AliAnalysisTaskBF.cxx
PWG2/EBYE/AliAnalysisTaskBF.h
PWG2/EBYE/macros/AddTaskBalanceCentralityTrain.C
PWG2/EBYE/macros/configBalanceFunctionAnalysis.C

index b4c08a5..98ab88c 100755 (executable)
@@ -33,6 +33,7 @@ ClassImp(AliAnalysisTaskBF)
 AliAnalysisTaskBF::AliAnalysisTaskBF(const char *name) \r
 : AliAnalysisTaskSE(name), \r
   fBalance(0),\r
+  fRunShuffling(kFALSE),\r
   fShuffledBalance(0),\r
   fList(0),\r
   fListBF(0),\r
@@ -109,11 +110,13 @@ void AliAnalysisTaskBF::UserCreateOutputObjects() {
     //fBalance->SetNumberOfBins(-1,16);\r
     fBalance->SetInterval(-1,-0.8,0.8,16,0.,1.6);\r
   }\r
-  if(!fShuffledBalance) {\r
-    fShuffledBalance = new AliBalance();\r
-    fShuffledBalance->SetAnalysisLevel("ESD");\r
-    //fShuffledBalance->SetNumberOfBins(-1,16);\r
-    fShuffledBalance->SetInterval(-1,-0.8,0.8,16,0.,1.6);\r
+  if(fRunShuffling) {\r
+    if(!fShuffledBalance) {\r
+      fShuffledBalance = new AliBalance();\r
+      fShuffledBalance->SetAnalysisLevel("ESD");\r
+      //fShuffledBalance->SetNumberOfBins(-1,16);\r
+      fShuffledBalance->SetInterval(-1,-0.8,0.8,16,0.,1.6);\r
+    }\r
   }\r
 \r
   //QA list\r
@@ -126,9 +129,11 @@ void AliAnalysisTaskBF::UserCreateOutputObjects() {
   fListBF->SetName("listBF");\r
   fListBF->SetOwner();\r
 \r
-  fListBFS = new TList();\r
-  fListBFS->SetName("listBFShuffled");\r
-  fListBFS->SetOwner();\r
+  if(fRunShuffling) {\r
+    fListBFS = new TList();\r
+    fListBFS->SetName("listBFShuffled");\r
+    fListBFS->SetOwner();\r
+  }\r
 \r
   //Event stats.\r
   TString gCutName[4] = {"Total","Offline trigger",\r
@@ -171,11 +176,18 @@ void AliAnalysisTaskBF::UserCreateOutputObjects() {
   // Balance function histograms\r
 \r
   // Initialize histograms if not done yet\r
-  if(!fBalance->GetHistNp(0) || !fShuffledBalance->GetHistNp(0)){\r
+  if(!fBalance->GetHistNp(0)){\r
     AliWarning("Histograms not yet initialized! --> Will be done now");\r
     AliWarning("--> Add 'gBalance->InitHistograms()' in your configBalanceFunction");\r
     fBalance->InitHistograms();\r
-    fShuffledBalance->InitHistograms();\r
+  }\r
+\r
+  if(fRunShuffling) {\r
+    if(!fShuffledBalance->GetHistNp(0)) {\r
+      AliWarning("Histograms (shuffling) not yet initialized! --> Will be done now");\r
+      AliWarning("--> Add 'gBalance->InitHistograms()' in your configBalanceFunction");\r
+      fShuffledBalance->InitHistograms();\r
+    }\r
   }\r
 \r
   for(Int_t a = 0; a < ANALYSIS_TYPES; a++){\r
@@ -186,23 +198,24 @@ void AliAnalysisTaskBF::UserCreateOutputObjects() {
     fListBF->Add(fBalance->GetHistNpp(a));\r
     fListBF->Add(fBalance->GetHistNnp(a));\r
 \r
-    fListBFS->Add(fShuffledBalance->GetHistNp(a));\r
-    fListBFS->Add(fShuffledBalance->GetHistNn(a));\r
-    fListBFS->Add(fShuffledBalance->GetHistNpn(a));\r
-    fListBFS->Add(fShuffledBalance->GetHistNnn(a));\r
-    fListBFS->Add(fShuffledBalance->GetHistNpp(a));\r
-    fListBFS->Add(fShuffledBalance->GetHistNnp(a));\r
-  }  \r
-\r
+    if(fRunShuffling) {\r
+      fListBFS->Add(fShuffledBalance->GetHistNp(a));\r
+      fListBFS->Add(fShuffledBalance->GetHistNn(a));\r
+      fListBFS->Add(fShuffledBalance->GetHistNpn(a));\r
+      fListBFS->Add(fShuffledBalance->GetHistNnn(a));\r
+      fListBFS->Add(fShuffledBalance->GetHistNpp(a));\r
+      fListBFS->Add(fShuffledBalance->GetHistNnp(a));\r
+    }  \r
+  }\r
 \r
   if(fESDtrackCuts) fList->Add(fESDtrackCuts);\r
 \r
   // Post output data.\r
   PostData(1, fList);\r
   PostData(2, fListBF);\r
-  PostData(3, fListBFS);\r
+  if(fRunShuffling) PostData(3, fListBFS);\r
   \r
-}\r
+  }\r
 \r
 //________________________________________________________________________\r
 void AliAnalysisTaskBF::UserExec(Option_t *) {\r
@@ -292,11 +305,11 @@ void AliAnalysisTaskBF::UserExec(Option_t *) {
                      // fill BF array\r
                      array->Add(track);\r
 \r
-                     // fill charge vector\r
-                     chargeVector.push_back(track->Charge());\r
-                     chargeVectorShuffle.push_back(track->Charge());\r
-      \r
-                     \r
+                     if(fRunShuffling){\r
+                       // fill charge vector\r
+                       chargeVector.push_back(track->Charge());\r
+                       chargeVectorShuffle.push_back(track->Charge());\r
+                     }\r
                    } //track loop\r
                  }//Vz cut\r
                }//Vy cut\r
@@ -408,11 +421,11 @@ void AliAnalysisTaskBF::UserExec(Option_t *) {
                      // fill BF array\r
                      array->Add(aodTrack);\r
 \r
-                     // fill charge vector\r
-                     chargeVector.push_back(aodTrack->Charge());\r
-                     chargeVectorShuffle.push_back(aodTrack->Charge());\r
-      \r
-\r
+                     if(fRunShuffling) {\r
+                       // fill charge vector\r
+                       chargeVector.push_back(aodTrack->Charge());\r
+                       chargeVectorShuffle.push_back(aodTrack->Charge());\r
+                     }\r
                    } //track loop\r
                  }//Vz cut\r
                }//Vy cut\r
@@ -440,23 +453,28 @@ void AliAnalysisTaskBF::UserExec(Option_t *) {
        Printf("ERROR: Could not receive particle %d", iTracks);\r
        continue;\r
       }\r
-      array->Add(track);\r
 \r
+      if( track->Pt() < fPtMin || track->Pt() > fPtMax)      continue;\r
+      if( track->Eta() < fEtaMin || track->Eta() > fEtaMax)  continue;\r
 \r
-      // fill charge vector\r
-      chargeVector.push_back(track->Charge());\r
-      chargeVectorShuffle.push_back(track->Charge());\r
+      array->Add(track);\r
 \r
+      if(fRunShuffling) {\r
+       // fill charge vector\r
+       chargeVector.push_back(track->Charge());\r
+       chargeVectorShuffle.push_back(track->Charge());\r
+      }\r
     } //track loop\r
   }//MC analysis\r
   \r
-  // shuffle charges\r
-  random_shuffle( chargeVectorShuffle.begin(), chargeVectorShuffle.end() );\r
-\r
-  // calculate balance function (also for shuffled events)\r
+  // calculate balance function\r
   fBalance->CalculateBalance(array,chargeVector);\r
-  fShuffledBalance->CalculateBalance(array,chargeVectorShuffle);\r
 \r
+  if(fRunShuffling) {\r
+    // shuffle charges\r
+    random_shuffle( chargeVectorShuffle.begin(), chargeVectorShuffle.end() );\r
+    fShuffledBalance->CalculateBalance(array,chargeVectorShuffle);\r
+  }\r
   \r
   delete array;\r
   \r
@@ -471,12 +489,13 @@ void  AliAnalysisTaskBF::FinishTaskOutput(){
     Printf("ERROR: fBalance not available");\r
     return;\r
   }  \r
-  if (!fShuffledBalance) {\r
-    Printf("ERROR: fShuffledBalance not available");\r
-    return;\r
+  if(fRunShuffling) {\r
+    if (!fShuffledBalance) {\r
+      Printf("ERROR: fShuffledBalance not available");\r
+      return;\r
+    }\r
   }\r
 \r
-\r
 }\r
 \r
 //________________________________________________________________________\r
index 9a3629b..3c6227b 100755 (executable)
@@ -26,8 +26,11 @@ class AliAnalysisTaskBF : public AliAnalysisTaskSE {
   virtual void   FinishTaskOutput();\r
   virtual void   Terminate(Option_t *);\r
 \r
-  void SetAnalysisObject(AliBalance *const analysis, AliBalance *const analysisShuffled = NULL) {\r
+  void SetAnalysisObject(AliBalance *const analysis) {\r
     fBalance         = analysis;\r
+    }\r
+  void SetShufflingObject(AliBalance *const analysisShuffled) {\r
+    fRunShuffling = kTRUE;\r
     fShuffledBalance = analysisShuffled;\r
   }\r
   void SetAnalysisCutObject(AliESDtrackCuts *const trackCuts) {\r
@@ -51,7 +54,12 @@ class AliAnalysisTaskBF : public AliAnalysisTaskSE {
     fDCAxyCut  = DCAxy;\r
     fDCAzCut = DCAz;\r
   }\r
\r
+  void SetKinematicsCutsMC(Double_t ptmin, Double_t ptmax,\r
+                           Double_t etamin, Double_t etamax){\r
+    fPtMin  = ptmin; fPtMax  = ptmax;\r
+    fEtaMin = etamin; fEtaMax = etamax;\r
+  }\r
+\r
   //Centrality\r
   void SetCentralityEstimator(const char* centralityEstimator) {fCentralityEstimator = centralityEstimator;}\r
   const char* GetCentralityEstimator(void)                     {return fCentralityEstimator;}\r
@@ -64,6 +72,7 @@ class AliAnalysisTaskBF : public AliAnalysisTaskSE {
 \r
  private:\r
   AliBalance *fBalance; //BF object\r
+  Bool_t fRunShuffling;//run shuffling or not\r
   AliBalance *fShuffledBalance; //BF object (shuffled)\r
   TList *fList; //fList object\r
   TList *fListBF; //fList object\r
index d8f30ae..391e81b 100644 (file)
@@ -3,7 +3,8 @@ const char* centralityEstimator = "V0M";
 //const char* centralityEstimator = "CL1";\r
 //const char* centralityEstimator = "TRK";\r
 //=============================================//\r
-\r
+Bool_t gRunShuffling = kFALSE;\r
+//=============================================//\r
 //_________________________________________________________//\r
 AliAnalysisTaskBF *AddTaskBalanceCentralityTrain(Double_t centrMin=0.,\r
                                                 Double_t centrMax=100.,\r
@@ -60,15 +61,15 @@ AliAnalysisTaskBF *AddTaskBalanceCentralityTrain(Double_t centrMin=0.,
 \r
   if (analysisType=="ESD"){\r
     bf  = GetBalanceFunctionObject("ESD");\r
-    bfs = GetBalanceFunctionObject("ESD",kTRUE);\r
+    if(gRunShuffling) bfs = GetBalanceFunctionObject("ESD",kTRUE);\r
   }\r
   else if (analysisType=="AOD"){\r
     bf  = GetBalanceFunctionObject("AOD");\r
-    bfs = GetBalanceFunctionObject("AOD",kTRUE);\r
+    if(gRunShuffling) bfs = GetBalanceFunctionObject("AOD",kTRUE);\r
   }\r
   else{\r
     bf  = GetBalanceFunctionObject("MC");\r
-    bfs = GetBalanceFunctionObject("MC",kTRUE);\r
+    if(gRunShuffling) bfs = GetBalanceFunctionObject("MC",kTRUE);\r
   }\r
 \r
   // Create the task, add it to manager and configure it.\r
@@ -109,11 +110,11 @@ AliAnalysisTaskBF *AddTaskBalanceCentralityTrain(Double_t centrMin=0.,
   outputFileName += ":PWG2EbyE.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
-  AliAnalysisDataContainer *coutBFS= mgr->CreateContainer(Form("listBFShuffled_%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
-  mgr->ConnectOutput(taskBF, 3, coutBFS);\r
+  if(gRunShuffling) mgr->ConnectOutput(taskBF, 3, coutBFS);\r
 \r
   return taskBF;\r
 }\r
index 614932a..8f42be9 100644 (file)
@@ -1,6 +1,7 @@
 //__________________________________________________//\r
-AliBalance *GetBalanceFunctionObject(const char* analysisLevel = "ESD", Bool_t bShuffle = kFALSE) {\r
-  //Function to setup the AliProtonAnalysis object and return it\r
+AliBalance *GetBalanceFunctionObject(const char* analysisLevel = "ESD", \r
+                                    Bool_t bShuffle = kFALSE) {\r
+  //Function to setup the AliBalance object and return it\r
   AliBalance *gBalance = new AliBalance();\r
   gBalance->SetAnalysisLevel(analysisLevel);\r
   gBalance->SetShuffle(bShuffle);\r