implementing centrality flattening for 2011 data (copied from AliAnalysisTaskPhiCorre...
authorMichael Weber <m.weber@cern.ch>
Thu, 12 Dec 2013 09:55:59 +0000 (10:55 +0100)
committerMichael Weber <m.weber@cern.ch>
Thu, 12 Dec 2013 09:55:59 +0000 (10:55 +0100)
PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskBFPsi.cxx
PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskBFPsi.h

index dfa26be..cb077fc 100755 (executable)
@@ -119,6 +119,7 @@ AliAnalysisTaskBFPsi::AliAnalysisTaskBFPsi(const char *name)
   fHistdEdxVsPTPCafterPIDelectron(NULL), //+++++++\r
   fHistNSigmaTPCvsPtafterPIDelectron(NULL), //+++++++\r
   fCentralityArrayBinsForCorrections(kCENTRALITY),\r
+  fCentralityWeights(0x0),\r
   fPIDResponse(0x0),\r
   fPIDCombined(0x0),\r
   fParticleOfInterest(kPion),\r
@@ -909,6 +910,13 @@ Double_t AliAnalysisTaskBFPsi::IsEventAccepted(AliVEvent *event){
                  // take only events inside centrality class\r
                  if(fUseCentrality) {\r
                    if((gRefMultiplicity > fCentralityPercentileMin) && (gRefMultiplicity < fCentralityPercentileMax)){\r
+\r
+                     // centrality weighting (optional for 2011 if central and semicentral triggers are used)\r
+                     if (fCentralityWeights && !AcceptEventCentralityWeight(gRefMultiplicity)){\r
+                       AliInfo(Form("Rejecting event because of centrality weighting: %f", gRefMultiplicity));\r
+                       return -1;\r
+                     }\r
+                     \r
                      fHistEventStats->Fill(5,gRefMultiplicity); //events with correct centrality\r
                      return gRefMultiplicity;          \r
                    }//centrality class\r
@@ -2301,6 +2309,28 @@ Double_t AliAnalysisTaskBFPsi::GetEqualizationFactor(Int_t run,
   return 1.0;\r
 }\r
 \r
+//____________________________________________________________________\r
+Bool_t AliAnalysisTaskBFPsi::AcceptEventCentralityWeight(Double_t centrality)\r
+{\r
+  // copied from AliAnalysisTaskPhiCorrelations\r
+  //\r
+  // rejects "randomly" events such that the centrality gets flat\r
+  // uses fCentralityWeights histogram\r
+\r
+  // TODO code taken and adapted from AliRDHFCuts; waiting for general class AliCentralityFlattening\r
+  \r
+  Double_t weight = fCentralityWeights->GetBinContent(fCentralityWeights->FindBin(centrality));\r
+  Double_t centralityDigits = centrality*100. - (Int_t)(centrality*100.);\r
+  \r
+  Bool_t result = kFALSE;\r
+  if (centralityDigits < weight) \r
+    result = kTRUE;\r
+  \r
+  AliInfo(Form("Centrality: %f; Digits: %f; Weight: %f; Result: %d", centrality, centralityDigits, weight, result));\r
+  \r
+  return result;\r
+}\r
+\r
 //________________________________________________________________________\r
 void  AliAnalysisTaskBFPsi::FinishTaskOutput(){\r
   //Printf("END BF");\r
index 335cc7a..06e5a2c 100755 (executable)
@@ -133,6 +133,9 @@ class AliAnalysisTaskBFPsi : public AliAnalysisTaskSE {
   void CheckPileUp() {fCheckPileUp = kTRUE;}\r
   void CheckPrimaryFlagAOD() {fCheckPrimaryFlagAOD = kTRUE;}\r
   void UseMCforKinematics() {fUseMCforKinematics = kTRUE;}\r
+  void SetCentralityWeights(TH1* hist) { fCentralityWeights = hist; }\r
+  Bool_t AcceptEventCentralityWeight(Double_t centrality);\r
+\r
   \r
   //Acceptance filter\r
   void SetAcceptanceParameterization(TF1 *parameterization) {\r
@@ -276,6 +279,8 @@ class AliAnalysisTaskBFPsi : public AliAnalysisTaskSE {
   Double_t fCentralityArrayForCorrections[kCENTRALITY];\r
   Int_t fCentralityArrayBinsForCorrections;\r
 \r
+  TH1* fCentralityWeights;                  // for centrality flattening\r
+\r
   AliPIDResponse *fPIDResponse;     //! PID response object\r
   AliPIDCombined       *fPIDCombined;     //! combined PID object\r
   \r