switches to using the centrality framework + some fixes
authorsnelling <snelling@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 1 Dec 2010 17:25:55 +0000 (17:25 +0000)
committersnelling <snelling@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 1 Dec 2010 17:25:55 +0000 (17:25 +0000)
PWG2/FLOW/AliFlowTasks/AliAnalysisTaskFlowEvent.cxx
PWG2/FLOW/AliFlowTasks/AliFlowEventCuts.cxx
PWG2/FLOW/AliFlowTasks/AliFlowEventCuts.h
PWG2/FLOW/AliFlowTasks/AliFlowTrackCuts.cxx
PWG2/FLOW/macros/AddTaskFlowCentrality.C
PWG2/FLOW/macros/CreateAlienHandler.C
PWG2/FLOW/macros/runFlowTaskCentralityTrain.C

index 54a7af0..480af88 100644 (file)
@@ -327,15 +327,15 @@ void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
     }
   }
 
-  //check event cuts
-  if (fCutsEvent) 
-  {
-    if (!fCutsEvent->IsSelected(InputEvent())) return;
-  }
-
   //use the new and temporarily inclomplete way of doing things
   if (fAnalysisType == "AUTOMATIC")
   {
+    //check event cuts
+    if (fCutsEvent) 
+    {
+      if (!fCutsEvent->IsSelected(InputEvent())) return;
+    }
+
     //PID
     recalibTOF(dynamic_cast<AliESDEvent*>(InputEvent()));
 
index 7b135e1..5b8d668 100644 (file)
@@ -27,6 +27,7 @@
 #include "AliVVertex.h"
 #include "AliVEvent.h"
 #include "AliESDEvent.h"
+#include "AliESDCentrality.h"
 #include "AliESDVZERO.h"
 #include "AliMultiplicity.h"
 #include "AliMCEvent.h"
@@ -62,7 +63,11 @@ AliFlowEventCuts::AliFlowEventCuts():
   fCutMeanPt(kFALSE),
   fMeanPtMax(-DBL_MAX),
   fMeanPtMin(DBL_MAX),
-  fCutSPDvertexerAnomaly(kTRUE)
+  fCutSPDvertexerAnomaly(kTRUE),
+  fCutCentralityPercentile(kFALSE),
+  fCentralityPercentileMethod(kTPConly),
+  fCentralityPercentileMax(100.),
+  fCentralityPercentileMin(0.)
 {
   //constructor 
 }
@@ -94,7 +99,11 @@ AliFlowEventCuts::AliFlowEventCuts(const char* name, const char* title):
   fCutMeanPt(kFALSE),
   fMeanPtMax(-DBL_MAX),
   fMeanPtMin(DBL_MAX),
-  fCutSPDvertexerAnomaly(kTRUE)
+  fCutSPDvertexerAnomaly(kTRUE),
+  fCutCentralityPercentile(kFALSE),
+  fCentralityPercentileMethod(kTPConly),
+  fCentralityPercentileMax(100.),
+  fCentralityPercentileMin(0.)
 {
   //constructor 
 }
@@ -126,7 +135,11 @@ AliFlowEventCuts::AliFlowEventCuts(const AliFlowEventCuts& that):
   fCutMeanPt(that.fCutMeanPt),
   fMeanPtMax(that.fMeanPtMax),
   fMeanPtMin(that.fMeanPtMin),
-  fCutSPDvertexerAnomaly(that.fCutSPDvertexerAnomaly)
+  fCutSPDvertexerAnomaly(that.fCutSPDvertexerAnomaly),
+  fCutCentralityPercentile(that.fCutCentralityPercentile),
+  fCentralityPercentileMethod(that.fCentralityPercentileMethod),
+  fCentralityPercentileMax(that.fCentralityPercentileMax),
+  fCentralityPercentileMin(that.fCentralityPercentileMin)
 {
   //copy constructor 
   if (that.fRefMultCuts)
@@ -170,22 +183,47 @@ AliFlowEventCuts& AliFlowEventCuts::operator=(const AliFlowEventCuts& that)
   fMeanPtMax=that.fMeanPtMax;
   fMeanPtMin=that.fMeanPtMin;
   fCutSPDvertexerAnomaly=that.fCutSPDvertexerAnomaly;
+  fCutCentralityPercentile=that.fCutCentralityPercentile;
+  fCentralityPercentileMethod=that.fCentralityPercentileMethod;
+  fCentralityPercentileMax=that.fCentralityPercentileMax;
+  fCentralityPercentileMin=that.fCentralityPercentileMin;
   return *this;
 }
 
 //----------------------------------------------------------------------- 
-Bool_t AliFlowEventCuts::IsSelected(const TObject* obj)
+Bool_t AliFlowEventCuts::IsSelected(TObject* obj)
 {
   //check cuts
-  const AliVEvent* vevent = dynamic_cast<const AliVEvent*>(obj);
+  AliVEvent* vevent = dynamic_cast<AliVEvent*>(obj);
   if (vevent) return PassesCuts(vevent);
   return kFALSE;  //when passed wrong type of object
 }
 //----------------------------------------------------------------------- 
-Bool_t AliFlowEventCuts::PassesCuts(const AliVEvent *event)
+Bool_t AliFlowEventCuts::PassesCuts(AliVEvent *event)
 {
   ///check if event passes cuts
-  if(fCutNumberOfTracks) {if (event->GetNumberOfTracks() < fNumberOfTracksMin || event->GetNumberOfTracks() >= fNumberOfTracksMax ) return kFALSE;}
+  AliESDEvent* esdevent = dynamic_cast<AliESDEvent*>(event);
+  if (fCutCentralityPercentile)
+  {
+    AliESDCentrality* centr = esdevent->GetCentrality();
+    return centr->IsEventInCentralityClass( fCentralityPercentileMin,
+                                            fCentralityPercentileMax,
+                                            CentrMethName(fCentralityPercentileMethod) );
+  }
+  if (fCutSPDvertexerAnomaly&&esdevent)
+  {
+    const AliESDVertex* sdpvertex = esdevent->GetPrimaryVertexSPD();
+    if (sdpvertex->GetNContributors()<1) return kFALSE;
+    if (sdpvertex->GetDispersion()>0.04) return kFALSE;
+    if (sdpvertex->GetZRes()>0.25) return kFALSE;
+    const AliESDVertex* tpcvertex = esdevent->GetPrimaryVertexTPC();
+    if (tpcvertex->GetNContributors()<1) return kFALSE;
+    const AliMultiplicity* tracklets = esdevent->GetMultiplicity();
+    if (tpcvertex->GetNContributors()<(-10.0+0.25*tracklets->GetNumberOfITSClusters(0)))
+      return kFALSE;
+  }
+  if(fCutNumberOfTracks) {if ( event->GetNumberOfTracks() < fNumberOfTracksMin ||
+                               event->GetNumberOfTracks() >= fNumberOfTracksMax ) return kFALSE;}
   if(fCutRefMult)
   {
     //reference multiplicity still to be defined
@@ -238,23 +276,29 @@ Bool_t AliFlowEventCuts::PassesCuts(const AliVEvent *event)
     meanpt=meanpt/nselected;
     if (meanpt<fMeanPtMin || meanpt >= fMeanPtMax) return kFALSE;
   }
-  const AliESDEvent* esdevent = dynamic_cast<const AliESDEvent*>(event);
-  if (fCutSPDvertexerAnomaly&&esdevent)
-  {
-    const AliESDVertex* sdpvertex = esdevent->GetPrimaryVertexSPD();
-    if (sdpvertex->GetNContributors()<1) return kFALSE;
-    if (sdpvertex->GetDispersion()>0.04) return kFALSE;
-    if (sdpvertex->GetZRes()>0.25) return kFALSE;
-    const AliESDVertex* tpcvertex = esdevent->GetPrimaryVertexTPC();
-    if (tpcvertex->GetNContributors()<1) return kFALSE;
-    const AliMultiplicity* tracklets = esdevent->GetMultiplicity();
-    if (tpcvertex->GetNContributors()<(-10.0+0.25*tracklets->GetNumberOfITSClusters(0)))
-      return kFALSE;
-  }
   return kTRUE;
 }
 
 //----------------------------------------------------------------------- 
+const char* AliFlowEventCuts::CentrMethName(refMultMethod method) const
+{
+  //get the string for refmultmethod, for use with AliESDCentrality in
+  //the cut on centrality percentile
+  switch (method)
+  {
+    case kSPDtracklets:
+      return "TKL";
+    case kSPD1clusters:
+      return "CL1";
+    case kTPConly:
+      return "TRK";
+    case kV0:
+      return "V0M";
+    default:
+      return "";
+  }
+}
+//----------------------------------------------------------------------- 
 AliFlowEventCuts* AliFlowEventCuts::StandardCuts()
 {
   //make a set of standard event cuts, caller becomes owner
@@ -263,11 +307,11 @@ AliFlowEventCuts* AliFlowEventCuts::StandardCuts()
 }
 
 //----------------------------------------------------------------------- 
-Int_t AliFlowEventCuts::RefMult(const AliVEvent* event)
+Int_t AliFlowEventCuts::RefMult(AliVEvent* event)
 {
   //calculate the reference multiplicity, if all fails return 0
   AliESDVZERO* vzero = NULL;
-  const AliESDEvent* esdevent = dynamic_cast<const AliESDEvent*>(event);
+  AliESDEvent* esdevent = dynamic_cast<AliESDEvent*>(event);
   const AliMultiplicity* mult = esdevent->GetMultiplicity();
   Int_t refmult=0;
 
@@ -299,7 +343,7 @@ Int_t AliFlowEventCuts::RefMult(const AliVEvent* event)
       return 0;
   }
 
-  fRefMultCuts->SetEvent(const_cast<AliVEvent*>(event));
+  fRefMultCuts->SetEvent(event);
   for (Int_t i=0; i<fRefMultCuts->GetNumberOfInputObjects(); i++)
   {
     if (fRefMultCuts->IsSelected(fRefMultCuts->GetInputObject(i),i))
index ea33645..d73afad 100644 (file)
@@ -27,9 +27,9 @@ class AliFlowEventCuts : public TNamed {
   AliFlowEventCuts& operator=(const AliFlowEventCuts& someCuts);
   virtual  ~AliFlowEventCuts();
   
-  virtual Bool_t IsSelected(const TObject* obj);
+  virtual Bool_t IsSelected(TObject* obj);
 
-  Bool_t PassesCuts(const AliVEvent* event);
+  Bool_t PassesCuts(AliVEvent* event);
   
   static AliFlowEventCuts* StandardCuts();
   
@@ -60,9 +60,14 @@ class AliFlowEventCuts : public TNamed {
   void SetMeanPtCuts( AliFlowTrackCuts* cuts ) {fMeanPtCuts=static_cast<AliFlowTrackCuts*>(cuts->Clone());}
   AliFlowTrackCuts* GetRefMultCuts() const {return fRefMultCuts;}
 
-  Int_t RefMult(const AliVEvent* event);
+  Int_t RefMult(AliVEvent* event);
   //Int_t GetRefMult() {return fRefMult;}
-  Int_t GetReferenceMultiplicity(const AliVEvent* event) {return RefMult(event);}
+  Int_t GetReferenceMultiplicity(AliVEvent* event) {return RefMult(event);}
+  const char* CentrMethName(refMultMethod) const;
+  void SetCentralityPercentileRange(Float_t min, Float_t max){ fCentralityPercentileMin=min;
+                                                               fCentralityPercentileMax=max;
+                                                               fCutCentralityPercentile=kTRUE; }
+  void SetCentralityPercentileMethod( refMultMethod m) {fRefMultMethod=m;}
 
  private:
   Bool_t fCutNumberOfTracks;//cut on # of tracks
@@ -90,6 +95,11 @@ class AliFlowEventCuts : public TNamed {
   Double_t fMeanPtMax; //max mean pt
   Double_t fMeanPtMin; //min mean pt
   Bool_t fCutSPDvertexerAnomaly; //cut on the spd vertexer anomaly
+  Bool_t fCutCentralityPercentile; //cut on centrality perc. from AliESDCentrality
+  refMultMethod fCentralityPercentileMethod; //where to get the percentile from
+  Float_t fCentralityPercentileMax; // max centr. perc
+  Float_t fCentralityPercentileMin; // min centr. perc
+
 
 
   ClassDef(AliFlowEventCuts,2)
index 2fb762e..83a3739 100644 (file)
@@ -833,6 +833,7 @@ void AliFlowTrackCuts::InitPIDcuts()
     }
     fTPCpidCuts=t;
   }
+  t = NULL;
   if (!fTOFpidCuts)
   {
     if (fAliPID==AliPID::kPion)
index ba2d14f..bb2546b 100644 (file)
@@ -71,8 +71,8 @@ AliFlowTrackCuts::trackParameterMix poimix = AliFlowTrackCuts::kPure;
 const char* rptypestr = AliFlowTrackCuts::GetParamTypeName(rptype);
 const char* poitypestr = AliFlowTrackCuts::GetParamTypeName(poitype);
 
-void AddTaskFlowCentrality( Int_t refMultMin=0,
-                            Int_t refMultMax=1e10,
+void AddTaskFlowCentrality( Float_t centrMin=0.,
+                            Float_t centrMax=100.,
                             TString fileNameBase="AnalysisResults",
                             Int_t binnumber=0 )
 {
@@ -85,12 +85,13 @@ void AddTaskFlowCentrality( Int_t refMultMin=0,
   cout << "Used for POI: "<< poitypestr << endl;  
   // EVENTS CUTS:
   AliFlowEventCuts* cutsEvent = new AliFlowEventCuts();
-  cutsEvent->SetRefMultRange(refMultMin,refMultMax);
-  //cutsEvent->SetRefMultMethod(AliFlowEventCuts::kTPConly);
-  //cutsEvent->SetRefMultMethod(AliFlowEventCuts::kV0);
-  cutsEvent->SetRefMultMethod(AliFlowEventCuts::kSPDtracklets);
+  cutsEvent->SetCentralityPercentileRange(centrMin,centrMax);
+  //cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kTPConly);
+  cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kV0);
+  //cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kSPDtracklets);
   cutsEvent->SetNContributorsRange(2);
   cutsEvent->SetPrimaryVertexZrange(-10.,10.);
+  cutsEvent->SetCutSPDvertexerAnomaly(kTRUE); //"Francesco's cut"
   
   // RP TRACK CUTS:
   AliFlowTrackCuts* cutsRP = new AliFlowTrackCuts();
@@ -142,24 +143,6 @@ void AddTaskFlowCentrality( Int_t refMultMin=0,
   //cutsPOI->SetPID(AliPID::kProton, AliFlowTrackCuts::kTPCTOFpid);
   //cutsPOI->SetTPCTOFpidCrossOverPt(0.4);
 
-  
-  // common constants:
-  Int_t nBinsMult = 10000;  
-  Int_t nBinsPt = 100;  
-  Int_t nBinsPhi = 360;  
-  Int_t nBinsEta = 100;  
-  Int_t nBinsQ = 500;
-  Double_t dMultMin = 0.;            
-  Double_t dMultMax = 10000.;
-  Double_t dPtMin = 0.;             
-  Double_t dPtMax = 10.;
-  Double_t dPhiMin(0.);            
-  Double_t dPhiMax(TMath::TwoPi());
-  Double_t dEtaMin(-5.);            
-  Double_t dEtaMax(5.);             
-  Double_t dQMin(0.);       
-  Double_t dQMax(3.);  
-  
   Bool_t useWeights  = WEIGHTS[0] || WEIGHTS[1] || WEIGHTS[2];
   if (useWeights) cout<<"Weights are used"<<endl;
   else cout<<"Weights are not used"<<endl;
@@ -328,24 +311,9 @@ void AddTaskFlowCentrality( Int_t refMultMin=0,
   taskFE->SetCutsRP(cutsRP);
   taskFE->SetCutsPOI(cutsPOI);
   taskFE->SetTOFresolution(80);
-
-  // Pass common constants:
-  taskFE->SetNbinsMult(nBinsMult);
-  taskFE->SetNbinsPt(nBinsPt);
-  taskFE->SetNbinsPhi(nBinsPhi); 
-  taskFE->SetNbinsEta(nBinsEta);
-  taskFE->SetNbinsQ(nBinsQ);
-  taskFE->SetMultMin(dMultMin);
-  taskFE->SetMultMax(dMultMax);
-  taskFE->SetPtMin(dPtMin);
-  taskFE->SetPtMax(dPtMax);
-  taskFE->SetPhiMin(dPhiMin);
-  taskFE->SetPhiMax(dPhiMax);
-  taskFE->SetEtaMin(dEtaMin);
-  taskFE->SetEtaMax(dEtaMax);
-  taskFE->SetQMin(dQMin);
-  taskFE->SetQMax(dQMax);
  
+
+
   // Create the analysis tasks, add them to the manager.
   //===========================================================================
   if (SP){
index 34c7faa..6ed81d2 100644 (file)
@@ -2,7 +2,6 @@ AliAnalysisGrid* CreateAlienHandler() {
   // Check if user has a valid token, otherwise make one. This has limitations.
   // One can always follow the standard procedure of calling alien-token-init 
   // then source /tmp/gclient_env_$UID in the current shell.
-  if (!AliAnalysisGrid::CreateToken()) return NULL;
   AliAnalysisAlien *plugin = new AliAnalysisAlien();
   
   // Set if you want to use par files on Grid:
index 3b6c256..422ed4f 100644 (file)
@@ -11,17 +11,18 @@ enum anaModes {mLocal,mLocalPAR,mPROOF,mGrid,mGridPAR};
 //Int_t binfirst = 4;  //where do we start numbering bins
 //Int_t binlast = 6;  //where do we stop numbering bins
 //const Int_t numberOfCentralityBins = 9;
-//Int_t centralityArray[numberOfCentralityBins+1] = {41,80,146,245,384,576,835,1203,1471,10000}; // in terms of reference multiplicity
 Int_t binfirst = 0;  //where do we start numbering bins
-Int_t binlast = 0;  //where do we stop numbering bins
-const Int_t numberOfCentralityBins = 1;
-Int_t centralityArray[numberOfCentralityBins+1] = {41,10000}; // in terms of reference multiplicity
+Int_t binlast = 8;  //where do we stop numbering bins
+const Int_t numberOfCentralityBins = 9;
+Float_t centralityArray[numberOfCentralityBins+1] = {0.,5.,10.,20.,30.,40.,50.,60.,70.,80.}; // in centrality percentile
+
 TString commonOutputFileName = "outputCentrality"; // e.g.: result for centrality bin 0 will be in the file "outputCentrality0.root", etc
 
+
 //void runFlowTaskCentralityTrain(Int_t mode=mLocal, Int_t nRuns = 10, 
 //Bool_t DATA = kFALSE, const Char_t* dataDir="/Users/snelling/alice_data/Therminator_midcentral", Int_t offset = 0)
 
-void runFlowTaskCentralityTrain(Int_t mode = mPROOF, Int_t nRuns = 50000000, 
+void runFlowTaskCentralityTrain(Int_t mode = mGridPAR, Int_t nRuns = 50000000, 
                 Bool_t DATA = kTRUE, const Char_t* dataDir="/alice/data/LHC10h_000137161_p1_plusplusplus", Int_t offset=0) 
 //void runFlowTaskCentralityTrain(Int_t mode = mLocal, Int_t nRuns = 50000000, 
 //                             Bool_t DATA = kTRUE, const Char_t* dataDir="./data/", Int_t offset=0) 
@@ -65,14 +66,21 @@ void runFlowTaskCentralityTrain(Int_t mode = mPROOF, Int_t nRuns = 50000000,
 
   // Task to check the offline trigger:
   gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); 
-  AliPhysicsSelectionTask* physicsSelTask = AddTaskPhysicsSelection(!DATA,0);
+  AddTaskPhysicsSelection(!DATA);
+
+  //Add also the centrality determination task
+  AliCentralitySelectionTask* centralityTask = new AliCentralitySelectionTask("CentralitySelection");
+  centralityTask->SetPercentileFile("$ALICE_ROOT/ANALYSIS/macros/AliCentralityBy1D_137161_v5.root");
+  centralityTask->SetPercentileFile2("$ALICE_ROOT/ANALYSIS/macros/AliCentralityBy1D_137366_v4.root");
+  mgr->AddTask(centralityTask);
+  mgr->ConnectInput(centralityTask,0,mgr->GetCommonInputContainer());
   
   // Setup analysis per centrality bin:
   gROOT->LoadMacro("AddTaskFlowCentrality.C");
   for (Int_t i=binfirst; i<binlast+1; i++)
   {
-    Int_t lowCentralityBinEdge = centralityArray[i];
-    Int_t highCentralityBinEdge = centralityArray[i+1];
+    Float_t lowCentralityBinEdge = centralityArray[i];
+    Float_t highCentralityBinEdge = centralityArray[i+1];
     Printf("\nWagon for centrality bin %i:",i);
     AddTaskFlowCentrality( lowCentralityBinEdge,
                            highCentralityBinEdge,