I did some modifications on the Event plane task, the diff to today's trunk is attach...
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 22 Jun 2011 16:47:21 +0000 (16:47 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 22 Jun 2011 16:47:21 +0000 (16:47 +0000)
1. The Phi distributions stored in the OADB is now an OADB container, which is then accessed by the EP task according to the run range the event is in.
The attached OADB Container is only for pass2 - I can also do it for pass1 of course, I just am not sure if it is needed...

2. I added the possibility to set user defined cuts.

3. The AddTaskEventplane.C macro is modified accordingly.

Johanna Lena Gramling <johanna.lena.gramling@cern.ch>

ANALYSIS/AliEPSelectionTask.cxx
ANALYSIS/AliEPSelectionTask.h
ANALYSIS/macros/AddTaskEventplane.C

index df6381ad6817266031d6306976fbaa2a715a4992..d04ef61c0a58bdacd37c9bb64d9759e688531b42 100644 (file)
@@ -55,6 +55,7 @@
 #include "AliPhysicsSelection.h"
 #include "AliBackgroundSelection.h"
 #include "AliESDUtils.h"
+#include "AliOADBContainer.h"
 
 #include "AliEventplane.h"
 
@@ -65,13 +66,17 @@ AliEPSelectionTask::AliEPSelectionTask():
 AliAnalysisTaskSE(),
   fDebug(0),
   fAnalysisInput("ESD"),
-  fStatus("TPC"),
+  fTrackType("TPC"),
   fUseMCRP(kFALSE),
   fUsePhiWeight(kFALSE),
   fUsePtWeight(kFALSE),
   fSaveTrackContribution(kFALSE),
+  fuserphidist(kFALSE),
+  fusercuts(kFALSE),
+  frunNumber(-15),
   fESDtrackCuts(0),
   ftracklist(0),
+  fEPContainer(0),
   fPhiDist(0),
   fQVector(0),
   fQContributionX(0),
@@ -99,13 +104,17 @@ AliEPSelectionTask::AliEPSelectionTask(const char *name):
   AliAnalysisTaskSE(name),
   fDebug(0),
   fAnalysisInput("ESD"),
-  fStatus("TPC"),
+  fTrackType("TPC"),
   fUseMCRP(kFALSE),
   fUsePhiWeight(kFALSE),
   fUsePtWeight(kFALSE),  
   fSaveTrackContribution(kFALSE),
+  fuserphidist(kFALSE),
+  fusercuts(kFALSE),
+  frunNumber(-15),
   fESDtrackCuts(0),
   ftracklist(0),
+  fEPContainer(0),
   fPhiDist(0),
   fQVector(0),
   fQContributionX(0),
@@ -149,10 +158,22 @@ AliEPSelectionTask::~AliEPSelectionTask()
       delete fQsub1;
       fQsub1 = 0;
   }
-    if (fQsub2){
+  if (fQsub2){
       delete fQsub2;
       fQsub2 = 0;
   }
+  if (fPhiDist){
+      delete fPhiDist;
+      fPhiDist = 0;
+  }
+  if (ftracklist){
+      delete ftracklist;
+      ftracklist = 0;
+  }
+  if (fEPContainer){
+      delete fEPContainer;
+      fEPContainer = 0;
+  }
 }  
 
 //________________________________________________________________________
@@ -183,6 +204,19 @@ void AliEPSelectionTask::UserCreateOutputObjects()
   fOutputList->Add(fHOutDiff);
   
   PostData(1, fOutputList); 
+  
+    if(!fuserphidist) { // if it's already set and custom class is required, we use the one provided by the user
+
+    TString oadbfilename = (Form("%s/COMMON/EVENTPLANE/data/epphidist.root", AliAnalysisManager::GetOADBPath()));
+
+    TFile foadb(oadbfilename); 
+    if(!foadb.IsOpen()) AliFatal(Form("Cannot open OADB file %s", oadbfilename.Data()));
+
+    AliInfo("Using Standard OADB");
+    fEPContainer = (AliOADBContainer*) foadb.Get("epphidist");    
+    if (!fEPContainer) AliFatal("Cannot fetch OADB container for EP selection");
+    foadb.Close();
+    }
 }
 
 //________________________________________________________________________
@@ -190,6 +224,8 @@ void AliEPSelectionTask::UserExec(Option_t */*option*/)
 { 
   // Execute analysis for current event:
   if (fDebug>1) printf(" **** AliEPSelectionTask::UserExec() \n");
+  
+//   frunNumber = -15;
  
   AliEventplane* esdEP = 0;
   TVector2 QQ1;
@@ -200,6 +236,11 @@ void AliEPSelectionTask::UserExec(Option_t */*option*/)
     
     AliVEvent* event = InputEvent();
     AliESDEvent* esd = dynamic_cast<AliESDEvent*>(event);
+    if (!(frunNumber == esd->GetRunNumber())) {
+      frunNumber = esd->GetRunNumber();
+      SetPhiDist();      
+    }
+    
     
     if (fUseMCRP) {
       AliMCEvent* mcEvent  = MCEvent();      
@@ -215,8 +256,8 @@ void AliEPSelectionTask::UserExec(Option_t */*option*/)
        esdEP->GetQContributionYArray()->Set(esd->GetNumberOfTracks());
       }
       
-      if (fStatus.CompareTo("GLOBAL")==0) ftracklist = fESDtrackCuts->GetAcceptedTracks(esd,kFALSE);
-      if (fStatus.CompareTo("TPC")==0) ftracklist = fESDtrackCuts->GetAcceptedTracks(esd,kTRUE);
+      if (fTrackType.CompareTo("GLOBAL")==0) ftracklist = fESDtrackCuts->GetAcceptedTracks(esd,kFALSE);
+      if (fTrackType.CompareTo("TPC")==0) ftracklist = fESDtrackCuts->GetAcceptedTracks(esd,kTRUE);
       const int NT = ftracklist->GetEntries();
       
       if (NT>4){
@@ -226,6 +267,7 @@ void AliEPSelectionTask::UserExec(Option_t */*option*/)
        fQsub1 = new TVector2(QQ1);
        fQsub2 = new TVector2(QQ2);
        fQsubRes = (fQsub1->Phi()/2 - fQsub2->Phi()/2);
+       
        esdEP->SetQVector(fQVector);
        esdEP->SetEventplaneQ(fEventplaneQ);
        esdEP->SetQsub(fQsub1,fQsub2);
@@ -357,49 +399,21 @@ void AliEPSelectionTask::GetQsub(TVector2 &Q1, TVector2 &Q2, TObjArray* tracklis
 }
 
 //________________________________________________________________________
-void AliEPSelectionTask::SetESDtrackCuts(TString status){
+void AliEPSelectionTask::SetPersonalESDtrackCuts(AliESDtrackCuts* trackcuts){
   
-  fStatus = status;
-  if (fStatus.CompareTo("GLOBAL")==0) fESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kTRUE);
-  if (fStatus.CompareTo("TPC")==0)    fESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
-  fESDtrackCuts->SetPtRange(0.15,20);
-  fESDtrackCuts->SetEtaRange(-0.8,0.8);
+  fusercuts = kTRUE;
+  fESDtrackCuts = trackcuts;
 }
 
-//__________________________________________________________________________
-void AliEPSelectionTask::SetPhiDistribution(char* infilename, char* listname)
-{
-  TFile f(infilename);
-  TObject* list = f.Get(listname);
-  fPhiDist = (TH1F*)list->FindObject("fHOutPhi");
-  if (!fPhiDist) {
-    cout << "Phi Distribution not found!!!" << endl;
-    return;
-  }
-  
-  Bool_t emptybins;
-
-  int iter = 0;  
-  while (iter<3){
-      emptybins = kFALSE;
-   
-      for (int i=1; i<fPhiDist->GetNbinsX(); i++){
-       if (!((fPhiDist->GetBinContent(i))>0)) {
-         emptybins = kTRUE;
-       }
-      }  
-      if (emptybins) {
-       cout << "empty bins - rebinning!" << endl;
-       fPhiDist->Rebin();
-       iter++;
-      }      
-      else iter = 3;
-  }
-  
-  if (emptybins) {
-    AliError("After Maximum of rebinning still empty Phi-bins!!!");
+//_____________________________________________________________________________
+void AliEPSelectionTask::SetTrackType(TString tracktype){
+  fTrackType = tracktype;
+  if (!fusercuts) {
+  if (fTrackType.CompareTo("GLOBAL")==0) fESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kTRUE);
+  if (fTrackType.CompareTo("TPC")==0)    fESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
+  fESDtrackCuts->SetPtRange(0.15,20);
+  fESDtrackCuts->SetEtaRange(-0.8,0.8);
   }
-  f.Close();
 }
 
 //________________________________________________________________________
@@ -434,3 +448,54 @@ Double_t AliEPSelectionTask::GetPhiWeight(AliESDtrack* track)
   }
   return phiweight;
 }
+
+//__________________________________________________________________________
+void AliEPSelectionTask::SetPhiDist() 
+{
+  if(!fuserphidist) { // if it's already set and custom class is required, we use the one provided by the user
+
+    fPhiDist = (TH1F*) fEPContainer->GetObject(frunNumber, "Default");
+    if (!fPhiDist) AliFatal(Form("Cannot find OADB phi distribution for run %d", frunNumber));
+
+  } 
+  else {
+    AliInfo("Using Custom Phi Distribution");
+  }
+    
+  Bool_t emptybins;
+
+  int iter = 0;  
+  while (iter<3){
+      emptybins = kFALSE;
+   
+      for (int i=1; i<fPhiDist->GetNbinsX(); i++){
+       if (!((fPhiDist->GetBinContent(i))>0)) {
+         emptybins = kTRUE;
+       }
+      }  
+      if (emptybins) {
+       cout << "empty bins - rebinning!" << endl;
+       fPhiDist->Rebin();
+       iter++;
+      }      
+      else iter = 3;
+  }
+  
+  if (emptybins) {
+    AliError("After Maximum of rebinning still empty Phi-bins!!!");
+  }
+}
+
+//__________________________________________________________________________
+void AliEPSelectionTask::SetPersonalPhiDistribution(char* infilename, char* listname)
+{
+  
+  fuserphidist = kTRUE;
+  
+  TFile f(infilename);
+  TObject* list = f.Get(listname);
+  fPhiDist = (TH1F*)list->FindObject("fHOutPhi");
+  if (!fPhiDist) AliFatal("Phi Distribution not found!!!");
+
+  f.Close();
+} 
index 879937268d2a8eb7b698c7a011ad81b9ff163fc0..4979b2d33578a178c71ee64b993ab543919ee6e5 100644 (file)
@@ -23,6 +23,7 @@ class AliESDEvent;
 class AliESDtrackCuts;
 class AliESDtrack;
 class AliEventplane;
+class AliOADBContainer;
 
 class AliEPSelectionTask : public AliAnalysisTaskSE {
 
@@ -48,8 +49,10 @@ class AliEPSelectionTask : public AliAnalysisTaskSE {
   void SetUsePhiWeight()                  {fUsePhiWeight = kTRUE;}
   void SetUsePtWeight()                           {fUsePtWeight = kTRUE;}
   void SetSaveTrackContribution()         {fSaveTrackContribution = kTRUE;}
-  void SetESDtrackCuts(TString status);
-  void SetPhiDistribution(char* filename, char* listname);
+  void SetTrackType(TString tracktype);
+  void SetPhiDist();
+  void SetPersonalESDtrackCuts(AliESDtrackCuts* trackcuts);
+  void SetPersonalPhiDistribution(char* filename, char* listname);
   
  private:
    
@@ -58,15 +61,19 @@ class AliEPSelectionTask : public AliAnalysisTaskSE {
 
   Int_t    fDebug;                     // Debug flag
   TString  fAnalysisInput;             // "ESD", "AOD"
-  TString  fStatus;                    // "GLOBAL", "TPC"
+  TString  fTrackType;                 // "GLOBAL", "TPC"
   Bool_t   fUseMCRP;                   // i.e. usable for Therminator, when MC RP is provided
   Bool_t   fUsePhiWeight;              // use of phi weights
   Bool_t   fUsePtWeight;               // use of pT weights
   Bool_t   fSaveTrackContribution;     // storage of contribution of each track to Q-Vector
+  Bool_t   fuserphidist;               // bool, if personal phi distribution should be used
+  Bool_t   fusercuts;                  // bool, if personal cuts should be used
+  Int_t    frunNumber;                 // runnumber
   
   AliESDtrackCuts* fESDtrackCuts;       //! track cuts
   
   TObjArray* ftracklist;               //! list of accepted tracks for Q-Vector
+  AliOADBContainer* fEPContainer;      //! OADB Container
   TH1F*         fPhiDist;                      // Phi distribution used to calculate phi weights
 
   TVector2* fQVector;                  //! Q-Vector of the event  
@@ -87,7 +94,7 @@ class AliEPSelectionTask : public AliAnalysisTaskSE {
   TH2F*         fHOutDiff;                     //! control histogram: Difference of MC RP and EP - only filled if fUseMCRP is true!
   TH2F*  fHOutleadPTPsi;               //! control histogram: emission angle of leading pT track vs EP angle
 
-  ClassDef(AliEPSelectionTask,2); 
+  ClassDef(AliEPSelectionTask,3); 
 };
 
 #endif
index 1856e857e78d428d412bc35fafebd2a0dc282e94..fe35e6ab592482933eabc788aa9acd6f838da212 100644 (file)
@@ -20,12 +20,11 @@ AliEPSelectionTask *AddTaskEventplane()
   
   AliEPSelectionTask *eventplaneTask = new AliEPSelectionTask("EventplaneSelection");
   eventplaneTask->SelectCollisionCandidates(AliVEvent::kMB);
-  eventplaneTask->SetESDtrackCuts("TPC");
-//   eventplaneTask->SetUseMCRP();
-//   eventplaneTask->SetPhiDistribution("Phidist.root","EPStat");
+  eventplaneTask->SetTrackType("TPC");
   eventplaneTask->SetUsePtWeight();
-//   eventplaneTask->SetUsePhiWeight();
-//   eventplaneTask->SetSaveTrackContribution();
+  eventplaneTask->SetUsePhiWeight();
+  eventplaneTask->SetSaveTrackContribution();
+  
   mgr->AddTask(eventplaneTask);
 
   AliAnalysisDataContainer *cinput0 = mgr->GetCommonInputContainer();