Fix the CRLF new line to unix type via dos2unix
authoriseliouj <iseliouj@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 14 Oct 2013 13:42:38 +0000 (13:42 +0000)
committeriseliouj <iseliouj@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 14 Oct 2013 13:42:38 +0000 (13:42 +0000)
16 files changed:
PWG/FLOW/Tasks/AliAnalysisTaskFlowEPCascade.h
PWG/FLOW/Tasks/AliAnalysisTaskFlowStrange.cxx
PWG/FLOW/Tasks/AliAnalysisTaskFlowStrange.h
PWG/FLOW/Tasks/AliAnalysisTaskJetFlowMC.h
PWG/FLOW/Tasks/AliFlowEvent.cxx
PWGCF/FLOW/macros/AddTaskFlowCentralityPIDQC.C
PWGCF/FLOW/macros/AddTaskFlowCentralityPIDSP.C
PWGCF/FLOW/macros/AddTaskFlowEPCascade.C
PWGCF/FLOW/macros/AddTaskJetFlowMC.C
PWGCF/FLOW/macros/AddTaskPidQC.C
PWGCF/FLOW/macros/AddTaskPidVZEROSP.C
PWGCF/FLOW/papers/PRL105_252302/v2edepAlice.C
PWGCF/FLOW/papers/arXiv_1207.0900/SetFlowStyle.C
PWGCF/FLOW/papers/arXiv_1207.0900/SetPlotStyle.C
PWGCF/FLOW/papers/arXiv_1207.0900/drawPaperFigure1.C
PWGCF/FLOW/papers/arXiv_1207.0900/drawPaperFigure3.C

index b87bb13..7a3c223 100644 (file)
-//********************************************************************\r
-//********************************************************************\r
-// Author : Zhongbao Yin\r
-//********************************************************************\r
-//********************************************************************\r
-#ifndef AliAnalysisTaskFlowEPCascade_cxx\r
-#define AliAnalysisTaskFlowEPCascade_cxx\r
-\r
-#include "AliAnalysisTaskSE.h"\r
-#include "AliEventplane.h"\r
-\r
-class AliESDEvent;\r
-//class AliFlowEventCuts;\r
-class AliFlowTrackCuts;\r
-class TH1F;\r
-class TH2F;\r
-class AliPIDResponse;\r
-class TProfile;\r
-class TProfile2D;\r
-class TFile;\r
-\r
-class AliAnalysisTaskFlowEPCascade : public AliAnalysisTaskSE {\r
- public:\r
-\r
-  AliAnalysisTaskFlowEPCascade();\r
-    \r
-  AliAnalysisTaskFlowEPCascade(const char *name, Double_t centMin, \r
-                              Double_t centMax, \r
-                              Double_t xis[3][2], \r
-                              Double_t omegas[3][2] );\r
-  virtual ~AliAnalysisTaskFlowEPCascade();\r
-  virtual void   UserCreateOutputObjects();\r
-  virtual void   UserExec(Option_t *option);\r
-  virtual void   Terminate(Option_t *);\r
-  \r
-  //  void  SetFlowEventCuts(AliFlowEventCuts* cuts){fFlowEventCuts = cuts;}\r
-  //  void  SetFlowTrackCuts(AliFlowTrackCuts* cuts){fFlowTrackCuts = cuts;}\r
-  void  SetFlowDauTrackCuts(AliFlowTrackCuts* cuts){fCutsDau = cuts;}\r
-  void  SetVertexCut(Double_t vtxCut = 10.){fVtxCut = vtxCut;}\r
-\r
- private:\r
-  // AliFlowEventCuts*     fFlowEventCuts       ;\r
-  //AliFlowTrackCuts*     fFlowTrackCuts       ;\r
-  AliFlowTrackCuts *fCutsDau; // cuts for daughters\r
-  AliPIDResponse * fPIDResponse;\r
-\r
-  Double_t fXiBands[3][2]; //\r
-  Double_t fOmegaBands[3][2]; //\r
-\r
-  Double_t fMinCent, fMaxCent;\r
-  Double_t fVtxCut;\r
-  // Double_t fEtaCut;\r
-  //Double_t fMinPt;\r
-  //Int_t fNTPCcls;\r
-\r
-  TFile * fOADB; //\r
-  Int_t fRun; //! current run checked to load VZERO calibration\r
-  Int_t fICent; //! centrality bin number\r
-\r
-  TProfile *fMultV0; //! object containing VZERO calibration info\r
-  Float_t fV0Cpol;          //! loaded by OADB       \r
-  Float_t fV0Apol;          //! loaded by OADB                                \r
-  Float_t fMeanQ[9][2][2];//! and recentering                  \r
-  Float_t fWidthQ[9][2][2]; //! ...                              \r
-  \r
-  TList* fHistList; //!\r
-  TH1I * fhEvent;  //!\r
-  TH1F * fhEPangleVZero; //!\r
-  TH1F * fhEPangleV0A; //!\r
-  TH1F * fhEPangleV0C; //!\r
-  TH1F * fhEPangleTPC; //!\r
-\r
-  TH1F *fh1Chi2Xi; //!\r
-  TH1F *fh1DCAXiDaughters; //!\r
-  TH1F *fh1DCABachToPrimVertex; //!\r
-  TH1F *fh1XiCosOfPointingAngle; //!\r
-  TH1F *fh1XiRadius; //!\r
-  \r
-  TH1F *fh1MassLambda; //! mass of lambda as the cascade daughter\r
-  TH1F *fh1V0Chi2; //! for V0 associated to a cascade\r
-  TH1F *fh1V0CosOfPointingAngle; //!\r
-  TH1F *fh1V0Radius; //!\r
-  TH1F *fh1DcaV0DaughtersXi; //!\r
-  TH1F *fh1DcaV0ToPrimVertex; //! DCA of V0 to prim. vtx\r
-  TH1F *fh1DCAPosToPrimVertex; //! V0 positive daughter to prim. vertex\r
-  TH1F *fh1DCANegToPrimVertex; //! V0 neg. daughter to prim. vertex\r
-  \r
-  TH1F *fh1MassXiMinus; //! effective mass under Xi- hyp.\r
-  TH1F *fh1MassXiPlus; //!\r
-  TH1F *fh1MassOmegaMinus; //! effective mass under Omega- hyp.\r
-  TH1F *fh1MassOmegaPlus; //!\r
-\r
-  TH1F *fh1MassXi;    //!\r
-  TH1F *fh1MassOmega; //!\r
-\r
-  TH1F *fh1XiPt; //! transverse momentum\r
-  TH1F *fh1XiP; //! total momentum\r
-  TH1F *fh1XiBachPt; //!  \r
-  TH1F *fh1XiBachP; //!\r
-\r
-  TH1F *fh1ChargeXi;//!\r
-  TH1F *fh1V0toXiCosOfPointingAngle; //! cos of pointing angle btw the V0 mom and the Xi-V0 vtx line\r
-\r
-  TH1F *fh1PhiXi; //!\r
-  \r
-  TH2F *fh2Armenteros; //! alpha vs ptArm for casc. candidate\r
-  \r
-  TH2F *fh2MassLambdaVsMassXiMinus; //! Xi- effective mass vs V0 eff. mass\r
-  TH2F *fh2MassXiVsMassOmegaMinus; //!\r
-  TH2F *fh2MassLambdaVsMassXiPlus; //!\r
-  TH2F *fh2MassXiVsMassOmegaPlus; //!\r
-\r
-  TH2F *fh2XiRadiusVsMassXiMinus; //! decay radius under Xi- hyp.\r
-  TH2F *fh2XiRadiusVsMassXiPlus; //!\r
-  TH2F *fh2XiRadiusVsMassOmegaMinus; //! decay radius under Omega- hyp.\r
-  TH2F *fh2XiRadiusVsMassOmegaPlus; //!\r
-\r
-  TH2F *fh2TPCdEdxOfCascDghters; //! dEdx with the cascade daughters\r
-  \r
-  TH2F *fh2MassVsPtXiMinus; //!\r
-  TH2F *fh2MassVsPtXiPlus; //!\r
-  TH2F *fh2MassVsPtXiAll; //!\r
-  \r
-  TH2F *fh2MassVsPtOmegaMinus; //!\r
-  TH2F *fh2MassVsPtOmegaPlus; //!\r
-  TH2F *fh2MassVsPtOmegaAll; //!\r
-\r
-  TH1F * fhXiRapidity; //! \r
-  TH1F * fhOmegaRapidity; //!\r
-  \r
-  TProfile *fProfXiV2PtV0A[3]; //! three mass bands V0A\r
-  TProfile *fProfOmegaV2PtV0A[3];//!\r
-  TProfile *fProfXiSinePtV0A[3];//!\r
-  TProfile *fProfOmegaSinePtV0A[3];//!\r
-  \r
-  TProfile *fProfXiV2PtV0C[3]; //! three mass bands V0C\r
-  TProfile *fProfOmegaV2PtV0C[3];//!\r
-  TProfile *fProfXiSinePtV0C[3];//!\r
-  TProfile *fProfOmegaSinePtV0C[3];//!\r
-\r
-  TProfile *fProfXiV2Pt[3]; //! three mass bands V0A&V0C\r
-  TProfile *fProfOmegaV2Pt[3]; //!\r
-  TProfile *fProfXiSinePt[3]; //!\r
-  TProfile *fProfOmegaSinePt[3]; //!\r
-\r
-  TProfile2D *fProf2dXiV2PtV0A[3]; //! three mass bands V0A                 \r
-  TProfile2D *fProf2dOmegaV2PtV0A[3];//! \r
-  TProfile2D *fProf2dXiV2PtV0C[3]; //! three mass bands V0C\r
-  TProfile2D *fProf2dOmegaV2PtV0C[3];//!\r
-  TProfile2D *fProf2dXiV2Pt[3]; //! three mass bands V0A&V0C\r
-  TProfile2D *fProf2dOmegaV2Pt[3]; //!\r
-\r
-  TProfile * fProfResolution;  //!\r
-\r
-  TH1F *fh1DistToVtxZAfter; //! After propagation to vertex \r
-  TH1F *fh1DistToVtxXYAfter; //!                                               \r
-  TH2F *fh2DistToVtxZBeforeVsAfter; //!\r
-  TH2F *fh2DistToVtxXYBeforeVsAfter; //!\r
-  TH2F *fh2PxBeforeVsAfter; //!\r
-  TH2F *fh2PyBeforeVsAfter; //!\r
-  TH2F *fh2PhiPosBeforeVsAfter; //! \r
-  TH2F *fh2PhiNegBeforeVsAfter; //!\r
-  \r
-  //  void ReadFromESDv0(AliESDEvent *fESD);\r
-  void ReadFromAODv0(AliAODEvent *fAOD);\r
-\r
-  //Progate to the primary vertex\r
-  void Propagate(Double_t vv[3], Double_t x[3], Double_t p[3], \r
-                Double_t bz, Short_t sign);\r
-\r
-  void OpenInfoCalbration(Int_t run );//9 bins: 0-5,5-10,10-20\r
-\r
-  AliAnalysisTaskFlowEPCascade(const AliAnalysisTaskFlowEPCascade&); // not implemented\r
-  AliAnalysisTaskFlowEPCascade& operator=(const AliAnalysisTaskFlowEPCascade&); // not implemented\r
-  \r
-  ClassDef(AliAnalysisTaskFlowEPCascade, 1); // example of analysis\r
-};\r
-#endif\r
+//********************************************************************
+//********************************************************************
+// Author : Zhongbao Yin
+//********************************************************************
+//********************************************************************
+#ifndef AliAnalysisTaskFlowEPCascade_cxx
+#define AliAnalysisTaskFlowEPCascade_cxx
+
+#include "AliAnalysisTaskSE.h"
+#include "AliEventplane.h"
+
+class AliESDEvent;
+//class AliFlowEventCuts;
+class AliFlowTrackCuts;
+class TH1F;
+class TH2F;
+class AliPIDResponse;
+class TProfile;
+class TProfile2D;
+class TFile;
+
+class AliAnalysisTaskFlowEPCascade : public AliAnalysisTaskSE {
+ public:
+
+  AliAnalysisTaskFlowEPCascade();
+    
+  AliAnalysisTaskFlowEPCascade(const char *name, Double_t centMin, 
+                              Double_t centMax, 
+                              Double_t xis[3][2], 
+                              Double_t omegas[3][2] );
+  virtual ~AliAnalysisTaskFlowEPCascade();
+  virtual void   UserCreateOutputObjects();
+  virtual void   UserExec(Option_t *option);
+  virtual void   Terminate(Option_t *);
+  
+  //  void  SetFlowEventCuts(AliFlowEventCuts* cuts){fFlowEventCuts = cuts;}
+  //  void  SetFlowTrackCuts(AliFlowTrackCuts* cuts){fFlowTrackCuts = cuts;}
+  void  SetFlowDauTrackCuts(AliFlowTrackCuts* cuts){fCutsDau = cuts;}
+  void  SetVertexCut(Double_t vtxCut = 10.){fVtxCut = vtxCut;}
+
+ private:
+  // AliFlowEventCuts*     fFlowEventCuts       ;
+  //AliFlowTrackCuts*     fFlowTrackCuts       ;
+  AliFlowTrackCuts *fCutsDau; // cuts for daughters
+  AliPIDResponse * fPIDResponse;
+
+  Double_t fXiBands[3][2]; //
+  Double_t fOmegaBands[3][2]; //
+
+  Double_t fMinCent, fMaxCent;
+  Double_t fVtxCut;
+  // Double_t fEtaCut;
+  //Double_t fMinPt;
+  //Int_t fNTPCcls;
+
+  TFile * fOADB; //
+  Int_t fRun; //! current run checked to load VZERO calibration
+  Int_t fICent; //! centrality bin number
+
+  TProfile *fMultV0; //! object containing VZERO calibration info
+  Float_t fV0Cpol;          //! loaded by OADB       
+  Float_t fV0Apol;          //! loaded by OADB                                
+  Float_t fMeanQ[9][2][2];//! and recentering                  
+  Float_t fWidthQ[9][2][2]; //! ...                              
+  
+  TList* fHistList; //!
+  TH1I * fhEvent;  //!
+  TH1F * fhEPangleVZero; //!
+  TH1F * fhEPangleV0A; //!
+  TH1F * fhEPangleV0C; //!
+  TH1F * fhEPangleTPC; //!
+
+  TH1F *fh1Chi2Xi; //!
+  TH1F *fh1DCAXiDaughters; //!
+  TH1F *fh1DCABachToPrimVertex; //!
+  TH1F *fh1XiCosOfPointingAngle; //!
+  TH1F *fh1XiRadius; //!
+  
+  TH1F *fh1MassLambda; //! mass of lambda as the cascade daughter
+  TH1F *fh1V0Chi2; //! for V0 associated to a cascade
+  TH1F *fh1V0CosOfPointingAngle; //!
+  TH1F *fh1V0Radius; //!
+  TH1F *fh1DcaV0DaughtersXi; //!
+  TH1F *fh1DcaV0ToPrimVertex; //! DCA of V0 to prim. vtx
+  TH1F *fh1DCAPosToPrimVertex; //! V0 positive daughter to prim. vertex
+  TH1F *fh1DCANegToPrimVertex; //! V0 neg. daughter to prim. vertex
+  
+  TH1F *fh1MassXiMinus; //! effective mass under Xi- hyp.
+  TH1F *fh1MassXiPlus; //!
+  TH1F *fh1MassOmegaMinus; //! effective mass under Omega- hyp.
+  TH1F *fh1MassOmegaPlus; //!
+
+  TH1F *fh1MassXi;    //!
+  TH1F *fh1MassOmega; //!
+
+  TH1F *fh1XiPt; //! transverse momentum
+  TH1F *fh1XiP; //! total momentum
+  TH1F *fh1XiBachPt; //!  
+  TH1F *fh1XiBachP; //!
+
+  TH1F *fh1ChargeXi;//!
+  TH1F *fh1V0toXiCosOfPointingAngle; //! cos of pointing angle btw the V0 mom and the Xi-V0 vtx line
+
+  TH1F *fh1PhiXi; //!
+  
+  TH2F *fh2Armenteros; //! alpha vs ptArm for casc. candidate
+  
+  TH2F *fh2MassLambdaVsMassXiMinus; //! Xi- effective mass vs V0 eff. mass
+  TH2F *fh2MassXiVsMassOmegaMinus; //!
+  TH2F *fh2MassLambdaVsMassXiPlus; //!
+  TH2F *fh2MassXiVsMassOmegaPlus; //!
+
+  TH2F *fh2XiRadiusVsMassXiMinus; //! decay radius under Xi- hyp.
+  TH2F *fh2XiRadiusVsMassXiPlus; //!
+  TH2F *fh2XiRadiusVsMassOmegaMinus; //! decay radius under Omega- hyp.
+  TH2F *fh2XiRadiusVsMassOmegaPlus; //!
+
+  TH2F *fh2TPCdEdxOfCascDghters; //! dEdx with the cascade daughters
+  
+  TH2F *fh2MassVsPtXiMinus; //!
+  TH2F *fh2MassVsPtXiPlus; //!
+  TH2F *fh2MassVsPtXiAll; //!
+  
+  TH2F *fh2MassVsPtOmegaMinus; //!
+  TH2F *fh2MassVsPtOmegaPlus; //!
+  TH2F *fh2MassVsPtOmegaAll; //!
+
+  TH1F * fhXiRapidity; //! 
+  TH1F * fhOmegaRapidity; //!
+  
+  TProfile *fProfXiV2PtV0A[3]; //! three mass bands V0A
+  TProfile *fProfOmegaV2PtV0A[3];//!
+  TProfile *fProfXiSinePtV0A[3];//!
+  TProfile *fProfOmegaSinePtV0A[3];//!
+  
+  TProfile *fProfXiV2PtV0C[3]; //! three mass bands V0C
+  TProfile *fProfOmegaV2PtV0C[3];//!
+  TProfile *fProfXiSinePtV0C[3];//!
+  TProfile *fProfOmegaSinePtV0C[3];//!
+
+  TProfile *fProfXiV2Pt[3]; //! three mass bands V0A&V0C
+  TProfile *fProfOmegaV2Pt[3]; //!
+  TProfile *fProfXiSinePt[3]; //!
+  TProfile *fProfOmegaSinePt[3]; //!
+
+  TProfile2D *fProf2dXiV2PtV0A[3]; //! three mass bands V0A                 
+  TProfile2D *fProf2dOmegaV2PtV0A[3];//! 
+  TProfile2D *fProf2dXiV2PtV0C[3]; //! three mass bands V0C
+  TProfile2D *fProf2dOmegaV2PtV0C[3];//!
+  TProfile2D *fProf2dXiV2Pt[3]; //! three mass bands V0A&V0C
+  TProfile2D *fProf2dOmegaV2Pt[3]; //!
+
+  TProfile * fProfResolution;  //!
+
+  TH1F *fh1DistToVtxZAfter; //! After propagation to vertex 
+  TH1F *fh1DistToVtxXYAfter; //!                                               
+  TH2F *fh2DistToVtxZBeforeVsAfter; //!
+  TH2F *fh2DistToVtxXYBeforeVsAfter; //!
+  TH2F *fh2PxBeforeVsAfter; //!
+  TH2F *fh2PyBeforeVsAfter; //!
+  TH2F *fh2PhiPosBeforeVsAfter; //! 
+  TH2F *fh2PhiNegBeforeVsAfter; //!
+  
+  //  void ReadFromESDv0(AliESDEvent *fESD);
+  void ReadFromAODv0(AliAODEvent *fAOD);
+
+  //Progate to the primary vertex
+  void Propagate(Double_t vv[3], Double_t x[3], Double_t p[3], 
+                Double_t bz, Short_t sign);
+
+  void OpenInfoCalbration(Int_t run );//9 bins: 0-5,5-10,10-20
+
+  AliAnalysisTaskFlowEPCascade(const AliAnalysisTaskFlowEPCascade&); // not implemented
+  AliAnalysisTaskFlowEPCascade& operator=(const AliAnalysisTaskFlowEPCascade&); // not implemented
+  
+  ClassDef(AliAnalysisTaskFlowEPCascade, 1); // example of analysis
+};
+#endif
index d14391f..9f7822c 100644 (file)
-/*************************************************************************\r
-* Copyright(c) 1998-2008,ALICE Experiment at CERN,All rights reserved. *\r
-*                                                                        *\r
-* Author: The ALICE Off-line Project.                                    *\r
-* Contributors are mentioned in the code where appropriate.              *\r
-*                                                                        *\r
-* Permission to use,copy,modify and distribute this software and its   *\r
-* documentation strictly for non-commercial purposes is hereby granted   *\r
-* without fee,provided that the above copyright notice appears in all   *\r
-* copies and that both the copyright notice and this permission notice   *\r
-* appear in the supporting documentation. The authors make no claims     *\r
-* about the suitability of this software for any purpose. It is          *\r
-* provided "as is" without express or implied warranty.                  *\r
-**************************************************************************/\r
-\r
-/////////////////////////////////////////////////////\r
-// AliAnalysisTaskFlowStrange:\r
-// Analysis task to select K0/Lambda candidates for flow analysis.\r
-// Authors: Cristian Ivan (civan@cern.ch)\r
-//          Carlos Perez  (cperez@cern.ch)\r
-//          Pawel Debski  (pdebski@cern.ch)\r
-//////////////////////////////////////////////////////\r
-\r
-#include "TChain.h"\r
-#include "TList.h"\r
-#include "TH1D.h"\r
-#include "TH2D.h"\r
-#include "TH3D.h"\r
-#include "TF1.h"\r
-#include "TProfile.h"\r
-#include "TProfile2D.h"\r
-#include "TVector3.h"\r
-#include "TStopwatch.h"\r
-#include "TFile.h"\r
-\r
-#include "TRandom3.h"\r
-\r
-#include "AliAnalysisManager.h"\r
-#include "AliInputEventHandler.h"\r
-\r
-#include "AliVVertex.h"\r
-#include "AliVVZERO.h"\r
-#include "AliStack.h"\r
-#include "AliMCEvent.h"\r
-\r
-#include "AliESDEvent.h"\r
-#include "AliESDtrack.h"\r
-#include "AliESDVertex.h"\r
-#include "AliESDv0.h"\r
-#include "AliESDtrackCuts.h"\r
-\r
-#include "AliAODEvent.h"\r
-#include "AliAODTrack.h"\r
-#include "AliAODVertex.h"\r
-#include "AliAODv0.h"\r
-#include "AliAODTracklets.h"\r
-#include "AliAODHeader.h"\r
-\r
-#include "AliAODMCHeader.h"\r
-#include "AliAODMCParticle.h"\r
-#include "TClonesArray.h"\r
-#include "TDatabasePDG.h"\r
-#include "TParticlePDG.h"\r
-\r
-#include "TMath.h"\r
-#include "TObjArray.h"\r
-#include "AliFlowCandidateTrack.h"\r
-\r
-#include "AliFlowTrackCuts.h"\r
-#include "AliFlowEventCuts.h"\r
-#include "AliFlowEvent.h"\r
-#include "AliFlowBayesianPID.h"\r
-#include "AliFlowCommonConstants.h"\r
-#include "AliFlowVector.h"\r
-\r
-#include "AliAnalysisTaskFlowStrange.h"\r
-\r
-ClassImp(AliAnalysisTaskFlowStrange)\r
-\r
-//=======================================================================\r
-AliAnalysisTaskFlowStrange::AliAnalysisTaskFlowStrange() :\r
-  AliAnalysisTaskSE(),\r
-  fPIDResponse(NULL),\r
-  fFB1(NULL),\r
-  fFB1024(NULL),\r
-  fTPCevent(NULL),\r
-  fVZEevent(NULL),\r
-  fCandidates(NULL),\r
-  fList(NULL),\r
-  fRunNumber(-1),\r
-  fDebug(0),\r
-  fQAlevel(0),\r
-  fReadESD(kFALSE),\r
-  fReadMC(kFALSE),\r
-  fAvoidExec(kFALSE),\r
-  fSkipSelection(kFALSE),\r
-  fSkipFlow(kFALSE),\r
-  fSkipDHcorr(kTRUE),\r
-  fUseFP(kFALSE),\r
-  fRunOnpA(kFALSE),\r
-  fRunOnpp(kFALSE),\r
-  fExtraEventRejection(kFALSE),\r
-  fCentMethod("V0MTRK"),\r
-  fCentPerMin(0),\r
-  fCentPerMax(100),\r
-  fThisCent(-1.0),\r
-  fExcludeTPCEdges(kFALSE),\r
-  fSpecie(0),\r
-  fOnline(kFALSE),\r
-  fHomemade(kFALSE),\r
-  fWhichPsi(1),\r
-  fVZEsave(kFALSE),\r
-  fVZEload(NULL),\r
-  fVZEResponse(NULL),\r
-  fVZEmb(kFALSE),\r
-  fVZEByDisk(kTRUE),\r
-  fVZECa(0),\r
-  fVZECb(3),\r
-  fVZEAa(0),\r
-  fVZEAb(3),\r
-  fVZEQA(NULL),\r
-  fPsi2(0.0),\r
-  fMCEP(0.0),\r
-  fMassBins(0),\r
-  fMinMass(0.0),\r
-  fMaxMass(0.0),\r
-  fRFPFilterBit(1),\r
-  fRFPminPt(0.2),\r
-  fRFPmaxPt(5.0),\r
-  fRFPminEta(-0.8),\r
-  fRFPmaxEta(+0.8),\r
-  fRFPTPCsignal(10.0),\r
-  fRFPmaxIPxy(2.4),\r
-  fRFPmaxIPz(3.2),\r
-  fRFPTPCncls(70),\r
-  fDecayMass(0.0),\r
-  fDecayPhi(0.0),\r
-  fDecayEta(0.0),\r
-  fDecayPt(0.0),\r
-  fDecayDCAdaughters(0.0),\r
-  fDecayCosinePointingAngleXY(0.0),\r
-  fDecayRadXY(0.0),\r
-  fDecayDecayLength(0.0),\r
-  fDecayQt(0.0),\r
-  fDecayAlpha(0.0),\r
-  fDecayRapidity(0.0),\r
-  fDecayProductIPXY(0.0),\r
-  fDecayIDneg(-1),\r
-  fDecayIDpos(-1),\r
-  fDecayID(-1),\r
-  fDecayMinEta(0.0),\r
-  fDecayMaxEta(0.0),\r
-  fDecayMinPt(0.0),\r
-  fDecayMaxDCAdaughters(0.0),\r
-  fDecayMinCosinePointingAngleXY(0.0),\r
-  fDecayMinQt(0.0),\r
-  fDecayAPCutPie(kTRUE),\r
-  fDecayMinRadXY(0.0),\r
-  fDecayMaxDecayLength(0.0),\r
-  fDecayMaxProductIPXY(0.0),\r
-  fDecayMaxRapidity(0.0),\r
-  fDaughterPhi(0.0),\r
-  fDaughterEta(0.0),\r
-  fDaughterPt(0.0),\r
-  fDaughterNClsTPC(0),\r
-  fDaughterCharge(0),\r
-  fDaughterNFClsTPC(0),\r
-  fDaughterNSClsTPC(0),\r
-  fDaughterChi2PerNClsTPC(0.0),\r
-  fDaughterXRows(0.0),\r
-  fDaughterImpactParameterXY(0.0),\r
-  fDaughterImpactParameterZ(0.0),\r
-  fDaughterStatus(0),\r
-  fDaughterNSigmaPID(0.0),\r
-  fDaughterKinkIndex(0),\r
-  fDaughterUnTag(kTRUE),\r
-  fDaughterMinEta(0.0),\r
-  fDaughterMaxEta(0.0),\r
-  fDaughterMinPt(0.0),\r
-  fDaughterMinNClsTPC(0),\r
-  fDaughterMinXRows(0),\r
-  fDaughterMaxChi2PerNClsTPC(0.0),\r
-  fDaughterMinXRowsOverNClsFTPC(0.0),\r
-  fDaughterMinImpactParameterXY(0.0),\r
-  fDaughterMaxNSigmaPID(0.0) {\r
-  //ctor\r
-}\r
-//=======================================================================\r
-AliAnalysisTaskFlowStrange::AliAnalysisTaskFlowStrange(const char *name) :\r
-  AliAnalysisTaskSE(name),\r
-  fPIDResponse(NULL),\r
-  fFB1(NULL),\r
-  fFB1024(NULL),\r
-  fTPCevent(NULL),\r
-  fVZEevent(NULL),\r
-  fCandidates(NULL),\r
-  fList(NULL),\r
-  fRunNumber(-1),\r
-  fDebug(0),\r
-  fQAlevel(0),\r
-  fReadESD(kFALSE),\r
-  fReadMC(kFALSE),\r
-  fAvoidExec(kFALSE),\r
-  fSkipSelection(kFALSE),\r
-  fSkipFlow(kFALSE),\r
-  fSkipDHcorr(kTRUE),\r
-  fUseFP(kFALSE),\r
-  fRunOnpA(kFALSE),\r
-  fRunOnpp(kFALSE),\r
-  fExtraEventRejection(kFALSE),\r
-  fCentMethod("V0MTRK"),\r
-  fCentPerMin(0),\r
-  fCentPerMax(100),\r
-  fThisCent(-1.0),\r
-  fExcludeTPCEdges(kFALSE),\r
-  fSpecie(0),\r
-  fOnline(kFALSE),\r
-  fHomemade(kFALSE),\r
-  fWhichPsi(1),\r
-  fVZEsave(kFALSE),\r
-  fVZEload(NULL),\r
-  fVZEResponse(NULL),\r
-  fVZEmb(kFALSE),\r
-  fVZEByDisk(kTRUE),\r
-  fVZECa(0),\r
-  fVZECb(3),\r
-  fVZEAa(0),\r
-  fVZEAb(3),\r
-  fVZEQA(NULL),\r
-  fPsi2(0.0),\r
-  fMCEP(0.0),\r
-  fMassBins(0),\r
-  fMinMass(0.0),\r
-  fMaxMass(0.0),\r
-  fRFPFilterBit(1),\r
-  fRFPminPt(0.2),\r
-  fRFPmaxPt(5.0),\r
-  fRFPminEta(-0.8),\r
-  fRFPmaxEta(+0.8),\r
-  fRFPTPCsignal(10.0),\r
-  fRFPmaxIPxy(2.4),\r
-  fRFPmaxIPz(3.2),\r
-  fRFPTPCncls(70),\r
-  fDecayMass(0.0),\r
-  fDecayPhi(0.0),\r
-  fDecayEta(0.0),\r
-  fDecayPt(0.0),\r
-  fDecayDCAdaughters(0.0),\r
-  fDecayCosinePointingAngleXY(0.0),\r
-  fDecayRadXY(0.0),\r
-  fDecayDecayLength(0.0),\r
-  fDecayQt(0.0),\r
-  fDecayAlpha(0.0),\r
-  fDecayRapidity(0.0),\r
-  fDecayProductIPXY(0.0),\r
-  fDecayIDneg(-1),\r
-  fDecayIDpos(-1),\r
-  fDecayID(-1),\r
-  fDecayMinEta(0.0),\r
-  fDecayMaxEta(0.0),\r
-  fDecayMinPt(0.0),\r
-  fDecayMaxDCAdaughters(0.0),\r
-  fDecayMinCosinePointingAngleXY(0.0),\r
-  fDecayMinQt(0.0),\r
-  fDecayAPCutPie(kTRUE),\r
-  fDecayMinRadXY(0.0),\r
-  fDecayMaxDecayLength(0.0),\r
-  fDecayMaxProductIPXY(0.0),\r
-  fDecayMaxRapidity(0.0),\r
-  fDaughterPhi(0.0),\r
-  fDaughterEta(0.0),\r
-  fDaughterPt(0.0),\r
-  fDaughterNClsTPC(0),\r
-  fDaughterCharge(0),\r
-  fDaughterNFClsTPC(0),\r
-  fDaughterNSClsTPC(0),\r
-  fDaughterChi2PerNClsTPC(0.0),\r
-  fDaughterXRows(0.0),\r
-  fDaughterImpactParameterXY(0.0),\r
-  fDaughterImpactParameterZ(0.0),\r
-  fDaughterStatus(0),\r
-  fDaughterNSigmaPID(0.0),\r
-  fDaughterKinkIndex(0),\r
-  fDaughterUnTag(kTRUE),\r
-  fDaughterMinEta(0.0),\r
-  fDaughterMaxEta(0.0),\r
-  fDaughterMinPt(0.0),\r
-  fDaughterMinNClsTPC(0),\r
-  fDaughterMinXRows(0),\r
-  fDaughterMaxChi2PerNClsTPC(0.0),\r
-  fDaughterMinXRowsOverNClsFTPC(0.0),\r
-  fDaughterMinImpactParameterXY(0.0),\r
-  fDaughterMaxNSigmaPID(0.0) {\r
-  //ctor\r
-  DefineInput( 0,TChain::Class());\r
-  DefineOutput(1,TList::Class());\r
-  DefineOutput(2,AliFlowEventSimple::Class()); // TPC object\r
-  DefineOutput(3,AliFlowEventSimple::Class()); // VZE object\r
-}\r
-//=======================================================================\r
-AliAnalysisTaskFlowStrange::~AliAnalysisTaskFlowStrange() {\r
-  //dtor\r
-  if (fCandidates) delete fCandidates;\r
-  if (fTPCevent)   delete fTPCevent;\r
-  if (fVZEevent)   delete fVZEevent;\r
-  if (fList)       delete fList;\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::UserCreateOutputObjects() {\r
-  //UserCreateOutputObjects\r
-  fList=new TList();\r
-  fList->SetOwner();\r
-  AddQAEvents();\r
-  AddQACandidates();\r
-\r
-  if(fReadESD) MakeFilterBits();\r
-\r
-  AliFlowCommonConstants *cc = AliFlowCommonConstants::GetMaster();\r
-  cc->SetNbinsMult(3000); cc->SetMultMin(0);   cc->SetMultMax(30000);\r
-  cc->SetNbinsPt(200); cc->SetPtMin(0.0);   cc->SetPtMax(20.0);\r
-  cc->SetNbinsPhi(100);  cc->SetPhiMin(0.0);  cc->SetPhiMax(TMath::TwoPi());\r
-  cc->SetNbinsEta(100);  cc->SetEtaMin(-5.0); cc->SetEtaMax(+5.0);\r
-  cc->SetNbinsQ(100);    cc->SetQMin(0.0);    cc->SetQMax(3.0);\r
-  cc->SetNbinsMass(fMassBins);\r
-  cc->SetMassMin(fMinMass);\r
-  cc->SetMassMax(fMaxMass);\r
-\r
-  //loading pid response\r
-  AliAnalysisManager *man = AliAnalysisManager::GetAnalysisManager();\r
-  AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());\r
-  fPIDResponse = inputHandler->GetPIDResponse();\r
-\r
-  fTPCevent = new AliFlowEvent(100);\r
-  fVZEevent = new AliFlowEvent(100);\r
-\r
-  //array of candidates\r
-  fCandidates = new TObjArray(100);\r
-  fCandidates->SetOwner();\r
-\r
-  PostData(1,fList);\r
-  if(fUseFP) { // for connection to the flow package\r
-    PostData(2,fTPCevent);\r
-    PostData(3,fVZEevent);\r
-  }\r
-\r
-  gRandom->SetSeed();\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::AddQAEvents() {\r
-  // function to add event qa\r
-  TH1D *tH1D;\r
-  TProfile *tProfile;\r
-  TList *tQAEvents=new TList();\r
-  tQAEvents->SetName("Event");\r
-  tQAEvents->SetOwner();\r
-  tH1D = new TH1D("Events","Number of Events",6,0,6); tQAEvents->Add(tH1D);\r
-  tH1D->GetXaxis()->SetBinLabel(1,"exec");\r
-  tH1D->GetXaxis()->SetBinLabel(2,"userexec");\r
-  tH1D->GetXaxis()->SetBinLabel(3,"reached");\r
-  tH1D->GetXaxis()->SetBinLabel(4,"selected");\r
-  tH1D->GetXaxis()->SetBinLabel(5,"rejectedByLowQw");\r
-  tH1D->GetXaxis()->SetBinLabel(6,"rejectedByErrorLoadVZEcal");\r
-  tProfile = new TProfile("Configuration","Configuration",20,0,20); tQAEvents->Add(tProfile);\r
-  tProfile->Fill( 0.5,fCentPerMin,1); tProfile->GetXaxis()->SetBinLabel( 1,"fCentPerMin");\r
-  tProfile->Fill( 1.5,fCentPerMax,1); tProfile->GetXaxis()->SetBinLabel( 2,"fCentPerMax");\r
-  tProfile->Fill( 2.5,fDaughterMinEta,1);               tProfile->GetXaxis()->SetBinLabel( 3,"fDaughterMinEta");\r
-  tProfile->Fill( 3.5,fDaughterMaxEta,1);               tProfile->GetXaxis()->SetBinLabel( 4,"fDaughterMaxEta");\r
-  tProfile->Fill( 4.5,fDaughterMinPt,1);                tProfile->GetXaxis()->SetBinLabel( 5,"fDaughterMinPt");\r
-  tProfile->Fill( 5.5,fDaughterMinNClsTPC,1);           tProfile->GetXaxis()->SetBinLabel( 6,"fDaughterMinNClsTPC");\r
-  tProfile->Fill( 6.5,fDaughterMaxChi2PerNClsTPC,1);    tProfile->GetXaxis()->SetBinLabel( 7,"fDaughterMaxChi2PerNClsTPC");\r
-  tProfile->Fill( 7.5,fDaughterMinXRowsOverNClsFTPC,1); tProfile->GetXaxis()->SetBinLabel( 8,"fDaughterMinXRowsOverNClsFTPC");\r
-  tProfile->Fill( 8.5,fDaughterMinImpactParameterXY,1); tProfile->GetXaxis()->SetBinLabel( 9,"fDaughterMinImpactParameterXY");\r
-  tProfile->Fill( 9.5,fDaughterMaxNSigmaPID,1);         tProfile->GetXaxis()->SetBinLabel(10,"fDaughterMaxNSigmaPID");\r
-  tProfile->Fill(10.5,fDecayMaxDCAdaughters,1);          tProfile->GetXaxis()->SetBinLabel(11,"fDecayMaxDCAdaughters");\r
-  tProfile->Fill(11.5,fDecayMinCosinePointingAngleXY,1); tProfile->GetXaxis()->SetBinLabel(12,"fDecayMinCosinePointingAngleXY");\r
-  tProfile->Fill(12.5,fDecayMinQt,1);                    tProfile->GetXaxis()->SetBinLabel(13,"fDecayMinQt");\r
-  tProfile->Fill(13.5,fDecayMinRadXY,1);                 tProfile->GetXaxis()->SetBinLabel(14,"fDecayMinRadXY");\r
-  tProfile->Fill(14.5,fDecayMaxDecayLength,1);           tProfile->GetXaxis()->SetBinLabel(15,"fDecayMaxDecayLength");\r
-  tProfile->Fill(15.5,fDecayMaxProductIPXY,1);           tProfile->GetXaxis()->SetBinLabel(16,"fDecayMaxProductIPXY");\r
-  tProfile->Fill(16.5,fDecayMaxRapidity,1);              tProfile->GetXaxis()->SetBinLabel(17,"fDecayMaxRapidity");\r
-  tProfile->Fill(17.5,fDecayMinEta,1);                   tProfile->GetXaxis()->SetBinLabel(18,"fDecayMinEta");\r
-  tProfile->Fill(18.5,fDecayMaxEta,1);                   tProfile->GetXaxis()->SetBinLabel(19,"fDecayMaxEta");\r
-  tProfile->Fill(19.5,fDecayMinPt,1);                    tProfile->GetXaxis()->SetBinLabel(20,"fDecayMinPt");\r
-\r
-  tH1D = new TH1D("POI","POIs;multiplicity",800,0,800);         tQAEvents->Add(tH1D);\r
-  tH1D = new TH1D("UNTAG","UNTAG;Untagged Daughters",800,0,800);tQAEvents->Add(tH1D);\r
-  tH1D = new TH1D("RealTime","RealTime;LogT sec",2000,-10,+10); tQAEvents->Add(tH1D);\r
-  fList->Add(tQAEvents);\r
-  AddEventSpy();\r
-  AddMakeQSpy();\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::AddEventSpy() {\r
-  TH1D *tH1D;\r
-  TH2D *tH2D;\r
-  TList *tList=new TList();\r
-  tList->SetName("EventSpy");\r
-  tList->SetOwner();\r
-  if(fQAlevel>0) {\r
-    tH2D = new TH2D("VTXZ","VTXZ;Global||SPD;SPD",60,-25,+25,60,-25,+25); tList->Add( tH2D );\r
-    tH2D = new TH2D("CCCC","CCCC;V0M;TRK",60,-10,110,60,-10,110);         tList->Add( tH2D );\r
-    tH2D = new TH2D("REFM","REFM;TPC;GLOBAL",100,0,3000,100,0,3000);      tList->Add( tH2D );\r
-    if(fReadMC) {\r
-      tH1D = new TH1D("MCCC","MCCC;Xsection",100,-10,110); tList->Add( tH1D );\r
-      tH1D = new TH1D("MCEP","MCEP;MCEP",100,-TMath::TwoPi(),TMath::TwoPi()); tList->Add( tH1D );\r
-    }\r
-  }\r
-  fList->Add(tList);\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::AddMakeQSpy() {\r
-  if(fSkipFlow) return;\r
-  TH1D *tH1D;\r
-  TH2D *tH2D;\r
-  TProfile *tPF1;\r
-  TList *tList=new TList();\r
-  tList->SetName("MakeQSpy");\r
-  tList->SetOwner();\r
-  tH1D = new TH1D("RFPTPC","TPC Refrence Multiplicity;multiplicity",3000,0,3000);     tList->Add( tH1D );\r
-  tH1D = new TH1D("RFPVZE","VZERO Reference Multiplicity;multiplicity",3000,0,30000); tList->Add( tH1D );\r
-  tH2D = new TH2D("TPCAllPhiEta","TPCall;Phi;Eta",180,0,TMath::TwoPi(),80,-0.9,+0.9); tList->Add( tH2D );\r
-  tH2D = new TH2D("VZEAllPhiEta","VZEall;Phi;Eta",20,0,TMath::TwoPi(),40,-4.0,+6.0);  tList->Add( tH2D );\r
-  tH1D = new TH1D("TPCPSI","TPCPSI;PSI",72,0,TMath::Pi()); tList->Add( tH1D );\r
-  tH1D = new TH1D("TPCPSIA","TPCPSIA;PSIA",72,0,TMath::Pi()); tList->Add( tH1D );\r
-  tH1D = new TH1D("TPCPSIB","TPCPSIB;PSIB",72,0,TMath::Pi()); tList->Add( tH1D );\r
-  tH1D = new TH1D("VZEPSI","VZEPSI;PSI",72,0,TMath::Pi()); tList->Add( tH1D );\r
-  tH1D = new TH1D("VZEPSIA","VZEPSIA;PSIA",72,0,TMath::Pi()); tList->Add( tH1D );\r
-  tH1D = new TH1D("VZEPSIB","VZEPSIB;PSIB",72,0,TMath::Pi()); tList->Add( tH1D );\r
-  tPF1 = new TProfile("TPCQ","TPCQ",6,0.5,6.5,"s");\r
-  tPF1->GetXaxis()->SetBinLabel(1,"Qay"); tPF1->GetXaxis()->SetBinLabel(2,"Qax");\r
-  tPF1->GetXaxis()->SetBinLabel(3,"Qby"); tPF1->GetXaxis()->SetBinLabel(4,"Qbx");\r
-  tPF1->GetXaxis()->SetBinLabel(5,"Qy");  tPF1->GetXaxis()->SetBinLabel(6,"Qx");\r
-  tList->Add( tPF1 );\r
-  tPF1 = new TProfile("VZEQ","VZEQ",6,0.5,6.5,"s");\r
-  tPF1->GetXaxis()->SetBinLabel(1,"Qay"); tPF1->GetXaxis()->SetBinLabel(2,"Qax");\r
-  tPF1->GetXaxis()->SetBinLabel(3,"Qby"); tPF1->GetXaxis()->SetBinLabel(4,"Qbx");\r
-  tPF1->GetXaxis()->SetBinLabel(5,"Qy");  tPF1->GetXaxis()->SetBinLabel(6,"Qx");\r
-  tList->Add( tPF1 );\r
-  \r
-  fList->Add(tList);\r
-  if(!fSkipFlow) {\r
-    tList=new TList(); tList->SetName("TPCRFPall"); tList->SetOwner(); AddTPCRFPSpy(tList); fList->Add(tList);\r
-    tList=new TList(); tList->SetName("TPCRFPsel"); tList->SetOwner(); AddTPCRFPSpy(tList); fList->Add(tList);\r
-  }\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::AddQACandidates() {\r
-  // function to add histogramming for candidates\r
-  if(fSkipSelection) return;\r
-\r
-  TList *tList;\r
-  TH1D *tH1D;\r
-  TH2D *tH2D;\r
-  TH3D *tH3D;\r
-\r
-  //reconstruction\r
-  if(fReadESD) {\r
-    tList=new TList(); tList->SetName("TrkAll"); tList->SetOwner(); AddTracksSpy(tList); fList->Add(tList);\r
-    tList=new TList(); tList->SetName("TrkSel"); tList->SetOwner(); AddTracksSpy(tList); fList->Add(tList);\r
-    tH2D = new TH2D("NPAIR", "NPAIR;NPOS;NNEG",1000,0,5000,1000,0,5000); tList->Add(tH2D);\r
-    tH2D = new TH2D("PtIPXY","PtIPXY;Pt;IPxy", 100,0,10,200,-10,+10); tList->Add(tH2D);\r
-  }\r
-  //candidates\r
-  tList=new TList(); tList->SetName("RecAll"); tList->SetOwner(); AddCandidatesSpy(tList); fList->Add(tList);\r
-  tH2D = new TH2D("V0SADC","V0S AFTER DAUGHTER CUTS;V0ALL;V0IMW",100,0,1000,100,0,1000); tList->Add(tH2D);\r
-  tList=new TList(); tList->SetName("RecSel"); tList->SetOwner(); AddCandidatesSpy(tList); fList->Add(tList);\r
-  //daughters\r
-  tList=new TList(); tList->SetName("TrkDau"); tList->SetOwner(); AddTracksSpy(tList); fList->Add(tList);\r
-  if(!fSkipDHcorr) {\r
-    //corr\r
-    tList=new TList(); tList->SetName("DHCORR"); tList->SetOwner(); \r
-    tH3D = new TH3D("DPHI","DPHI;dPT;dPHI;dETA", 20, -1, +1, 120, -TMath::TwoPi(), TMath::TwoPi(), 16, -1.6, +1.6 ); tList->Add(tH3D);\r
-    fList->Add(tList);\r
-  }\r
-  if(fQAlevel>1) {\r
-    // IN-OUT\r
-    tList=new TList(); tList->SetName("RecAllIP"); tList->SetOwner(); AddCandidatesSpy(tList); fList->Add(tList);\r
-    tList=new TList(); tList->SetName("RecAllOP"); tList->SetOwner(); AddCandidatesSpy(tList); fList->Add(tList);\r
-    tList=new TList(); tList->SetName("RecSelIP"); tList->SetOwner(); AddCandidatesSpy(tList); fList->Add(tList);\r
-    tList=new TList(); tList->SetName("RecSelOP"); tList->SetOwner(); AddCandidatesSpy(tList); fList->Add(tList);\r
-  }\r
-  //match\r
-  if(fReadMC) {\r
-    tList=new TList(); tList->SetName("RecMth"); tList->SetOwner(); AddCandidatesSpy(tList); fList->Add(tList);\r
-    tH1D = new TH1D("MCOrigin", "MCOrigin;Rad2",1000,0,100); tList->Add(tH1D);\r
-    tH2D = new TH2D("PTRes", "PTRes;MCPt;DAT-MC/MC",  100,   0,  20,100,-0.2,+0.2); tList->Add(tH2D);\r
-    tH2D = new TH2D("ETARes","ETARes;MCETA;DAT-MC/MC", 16,   0, 0.8,100,-0.5,+0.5); tList->Add(tH2D);\r
-    tH2D = new TH2D("RXYRes","RXYRes;MCRXY;DAT-MC/MC",100,   0,  20,100,-1,1);      tList->Add(tH2D);\r
-    tH2D = new TH2D("DLERes","DLERes;MCDLE;DAT-MC/MC",100,   0,  20,100,-1,1);      tList->Add(tH2D);\r
-    tH2D = new TH2D("RAPRes","RAPRes;MCRAP;DAT-MC/MC", 10,   0, 0.5,100,-0.5,+0.5); tList->Add(tH2D);\r
-    tH2D = new TH2D("APARes","APARes;MCAPA;DAT-MC/MC", 24,-1.2, 1.2,100,-0.5,+0.5); tList->Add(tH2D);\r
-    tH2D = new TH2D("APQRes","APQRes;MCAPQ;DAT-MC/MC", 25,   0,0.25,100,-0.3,+0.3); tList->Add(tH2D);\r
-\r
-    tList=new TList(); tList->SetName("TrkMth"); tList->SetOwner(); AddTracksSpy(tList); fList->Add(tList);\r
-    tList=new TList(); tList->SetName("MthFDW"); tList->SetOwner(); AddCandidatesSpy(tList); fList->Add(tList);\r
-    tH1D = new TH1D("MCOrigin", "MCOrigin;Rad2",1000,0,100); tList->Add(tH1D);\r
-  }\r
-  //stack\r
-  if(fReadMC) {\r
-    tList=new TList(); tList->SetName("GenTru"); tList->SetOwner(); AddCandidatesSpy(tList); fList->Add(tList);\r
-    tList=new TList(); tList->SetName("MCTK0sGenAcc"); tList->SetOwner(); AddMCParticleSpy(tList); fList->Add(tList);\r
-    tList=new TList(); tList->SetName("MCTLdaGenAcc"); tList->SetOwner(); AddMCParticleSpy(tList); fList->Add(tList);\r
-    tList=new TList(); tList->SetName("MCTPhiGenAcc"); tList->SetOwner(); AddMCParticleSpy(tList); fList->Add(tList);\r
-    tList=new TList(); tList->SetName("MCTXiGenAcc");  tList->SetOwner(); AddMCParticleSpy(tList); fList->Add(tList);\r
-    tList=new TList(); tList->SetName("MCTK0s"); tList->SetOwner(); AddMCParticleSpy(tList); fList->Add(tList);\r
-    tList=new TList(); tList->SetName("MCTLda"); tList->SetOwner(); AddMCParticleSpy(tList); fList->Add(tList);\r
-  }\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::Exec(Option_t* option) {\r
-  // bypassing ::exec (needed because of AMPT)\r
-  ((TH1D*)((TList*)fList->FindObject("Event"))->FindObject("Events"))->Fill(0);\r
-  if(fAvoidExec) {\r
-    AliAnalysisTaskFlowStrange::UserExec(option);\r
-  } else {\r
-    AliAnalysisTaskSE::Exec(option);\r
-  }\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::UserExec(Option_t *option) {\r
-  // bridge\r
-  ((TH1D*)((TList*)fList->FindObject("Event"))->FindObject("Events"))->Fill(1);\r
-  AliAnalysisTaskFlowStrange::MyUserExec(option);\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::MyNotifyRun() {\r
-  if(fQAlevel>5 && !fReadESD) AddVZEQA();\r
-  if(fVZEsave) AddVZEROResponse();\r
-}\r
-//=======================================================================\r
-Bool_t AliAnalysisTaskFlowStrange::CalibrateEvent() {\r
-  if(fVZEsave) SaveVZEROResponse();\r
-  if(fQAlevel>5 && !fReadESD) SaveVZEROQA(); // 2BIMPROVED\r
-  Bool_t okay=kTRUE;\r
-  if(fVZEload) {\r
-    LoadVZEROResponse();\r
-    if(!fVZEResponse) okay = kFALSE;\r
-  }\r
-  return okay;\r
-}\r
-//=======================================================================\r
-Bool_t AliAnalysisTaskFlowStrange::AcceptAAEvent(AliESDEvent *tESD) {\r
-  Double_t acceptEvent=kTRUE;\r
-  Double_t tTPCVtxZ = tESD->GetPrimaryVertexTPC()->GetZ();\r
-  if(tESD->GetPrimaryVertexTPC()->GetNContributors()<=0) return kFALSE;\r
-  Double_t tSPDVtxZ = tESD->GetPrimaryVertexSPD()->GetZ();\r
-  if(tESD->GetPrimaryVertexSPD()->GetNContributors()<=0) return kFALSE;\r
-  // EventCuts\r
-  AliCentrality *cent = tESD->GetCentrality();\r
-  Double_t cc1, cc2;\r
-  cc1 = cent->GetCentralityPercentile("V0M");\r
-  cc2 = cent->GetCentralityPercentile("TRK");\r
-  TString mycent = fCentMethod;\r
-  if(fCentMethod.Contains("V0MTRK")) {\r
-    acceptEvent = TMath::Abs(cc1-cc2)>5.0?kFALSE:acceptEvent; // a la Alex\r
-    mycent = "V0M";\r
-  }\r
-  fThisCent = cent->GetCentralityPercentile( mycent );\r
-  acceptEvent = (fThisCent<fCentPerMin||fThisCent>fCentPerMax)?kFALSE:acceptEvent;\r
-  acceptEvent = TMath::Abs(tTPCVtxZ-tSPDVtxZ)>0.5?kFALSE:acceptEvent;\r
-  acceptEvent = TMath::Abs(tTPCVtxZ)>10.0?kFALSE:acceptEvent;\r
-  if(fQAlevel>0) ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("VTXZ"))->Fill( tTPCVtxZ, tSPDVtxZ );\r
-  if(fQAlevel>0) ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("CCCC"))->Fill( cc1, cc2 );\r
-  // EndOfCuts\r
-  return acceptEvent;\r
-}\r
-//=======================================================================\r
-Bool_t AliAnalysisTaskFlowStrange::AcceptAAEvent(AliAODEvent *tAOD) {\r
-  Double_t acceptEvent=kTRUE;\r
-  //=>Pile-up rejection (hardcoded)\r
-  Double_t tVtxZ = tAOD->GetPrimaryVertex()->GetZ();\r
-  if(tAOD->GetPrimaryVertex()->GetNContributors()<=0) return kFALSE;\r
-  Double_t tSPDVtxZ = tAOD->GetPrimaryVertexSPD()->GetZ();\r
-  if(tAOD->GetPrimaryVertexSPD()->GetNContributors()<=0) return kFALSE;\r
-  Int_t tpc = RefMultTPC();\r
-  Int_t glo = RefMultGlobal();\r
-  if(fExtraEventRejection) {\r
-    TString name = tAOD->GetPrimaryVertex()->GetTitle();\r
-    if( !name.Contains("VertexerTracks") ) return kFALSE;\r
-    if( ( Float_t(tpc) < -40.3+1.22*glo ) || ( Float_t(tpc)>(32.1+1.59*glo) ) ) return kFALSE;\r
-  }\r
-  // EventCuts\r
-  AliCentrality *cent = tAOD->GetHeader()->GetCentralityP();\r
-  Double_t cc1, cc2;\r
-  cc1 = cent->GetCentralityPercentile("V0M");\r
-  cc2 = cent->GetCentralityPercentile("TRK");\r
-  TString mycent = fCentMethod;\r
-  if(fCentMethod.Contains("V0MTRK")) {\r
-    acceptEvent = TMath::Abs(cc1-cc2)>5.0?kFALSE:acceptEvent;\r
-    mycent = "V0M";\r
-  }\r
-  fThisCent = cent->GetCentralityPercentile( mycent );\r
-\r
-  Double_t xsec=0;\r
-  if(fReadMC) {\r
-    AliAODMCHeader *mcHeader = dynamic_cast<AliAODMCHeader*>(tAOD->GetList()->FindObject(AliAODMCHeader::StdBranchName()));\r
-    if (!mcHeader) {\r
-      return kFALSE;\r
-    }\r
-    xsec = mcHeader->GetCrossSection();\r
-    //fMCEP = mcHeader->GetReactionPlaneAngle();\r
-    fMCEP = mcHeader->GetReactionPlaneAngle() + (gRandom->Rndm()>0.5)*TMath::Pi();\r
-  }\r
-\r
-  acceptEvent = (fThisCent<fCentPerMin||fThisCent>fCentPerMax)?kFALSE:acceptEvent;\r
-  acceptEvent = TMath::Abs(tVtxZ-tSPDVtxZ)>0.5?kFALSE:acceptEvent;\r
-  acceptEvent = TMath::Abs(tVtxZ)>10.0?kFALSE:acceptEvent;\r
-  if(fQAlevel>0) {\r
-    ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("VTXZ"))->Fill( tVtxZ, tSPDVtxZ );\r
-    ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("CCCC"))->Fill( cc1, cc2 );\r
-    ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("REFM"))->Fill( tpc, glo );\r
-    if(fReadMC) {\r
-      ((TH1D*)((TList*)fList->FindObject("EventSpy"))->FindObject("MCCC"))->Fill( xsec );\r
-      ((TH1D*)((TList*)fList->FindObject("EventSpy"))->FindObject("MCEP"))->Fill( fMCEP );\r
-    }\r
-  }\r
-  // EndOfCuts\r
-  return acceptEvent;\r
-}\r
-//=======================================================================\r
-Bool_t AliAnalysisTaskFlowStrange::AcceptPPEvent(AliAODEvent *tAOD) {\r
-  Double_t acceptEvent=kTRUE;\r
-  Double_t tVtxZ = tAOD->GetPrimaryVertex()->GetZ();\r
-  if(tAOD->GetPrimaryVertex()->GetNContributors()<=0) return kFALSE;\r
-  Double_t tSPDVtxZ = tAOD->GetPrimaryVertexSPD()->GetZ();\r
-  if(tAOD->GetPrimaryVertexSPD()->GetNContributors()<=0) return kFALSE;\r
-  // EventCuts\r
-  AliCentrality *cent = tAOD->GetHeader()->GetCentralityP();\r
-  Double_t cc1, cc2;\r
-  cc1 = cent->GetCentralityPercentile("V0M");\r
-  cc2 = cent->GetCentralityPercentile("TRK");\r
-  fThisCent = GetReferenceMultiplicity();\r
-  //for pp i use fCentPerXXX to select on multiplicity\r
-  acceptEvent = (fThisCent<fCentPerMin||fThisCent>fCentPerMax)?kFALSE:acceptEvent;\r
-  acceptEvent = TMath::Abs(tVtxZ-tSPDVtxZ)>0.5?kFALSE:acceptEvent;\r
-  acceptEvent = TMath::Abs(tVtxZ)>10.0?kFALSE:acceptEvent;\r
-  if(fQAlevel>0) ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("VTXZ"))->Fill( tVtxZ, tSPDVtxZ );\r
-  if(fQAlevel>0) ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("CCCC"))->Fill( cc1, cc2 );\r
-  // EndOfCuts\r
-  return acceptEvent;\r
-}\r
-//=======================================================================\r
-Int_t AliAnalysisTaskFlowStrange::GetReferenceMultiplicity() { //toberefined\r
-  AliAODEvent *tAOD = (AliAODEvent *) InputEvent();\r
-  if(!tAOD) return -1;\r
-  AliAODTrack *track;\r
-  Int_t rawN = tAOD->GetNumberOfTracks();\r
-  Int_t ref=0;\r
-  for(Int_t id=0; id!=rawN; ++id) {\r
-    track = tAOD->GetTrack(id);\r
-    if(!track->TestFilterBit(fRFPFilterBit)) continue;\r
-    ++ref;\r
-  }\r
-  return ref;\r
-}\r
-//=======================================================================\r
-Bool_t AliAnalysisTaskFlowStrange::AcceptPAEvent(AliAODEvent *tAOD) {\r
-  //if(aod->GetHeader()->GetEventNumberESDFile() == 0) return; //rejecting first chunk NOT NEEDED ANYMORE\r
-  Int_t bc2 = tAOD->GetHeader()->GetIRInt2ClosestInteractionMap();\r
-  if(bc2!=0) return kFALSE;\r
-  Int_t bc1 = tAOD->GetHeader()->GetIRInt1ClosestInteractionMap();\r
-  if(bc1!=0) return kFALSE;\r
-  Short_t isPileup = tAOD->IsPileupFromSPD(5);\r
-  if(isPileup!=0) return kFALSE;\r
-  if(tAOD->GetHeader()->GetRefMultiplicityComb08()<0) return kFALSE;\r
-\r
-  const AliAODVertex* spdVtx = tAOD->GetPrimaryVertexSPD();\r
-  if(!spdVtx) return kFALSE;\r
-  if(spdVtx->GetNContributors()<=0) return kFALSE;\r
-\r
-  const AliAODVertex* tpcVtx=NULL;\r
-  Int_t nVertices = tAOD->GetNumberOfVertices();\r
-  for(Int_t iVertices = 0; iVertices < nVertices; iVertices++){\r
-    const AliAODVertex* vertex = tAOD->GetVertex(iVertices);\r
-    if (vertex->GetType() != AliAODVertex::kMainTPC) continue;\r
-    tpcVtx = vertex;\r
-  }\r
-  if(!tpcVtx) return kFALSE;\r
-  if(tpcVtx->GetNContributors()<=0) return kFALSE;\r
-  Double_t tTPCVtxZ = tpcVtx->GetZ();\r
-  Double_t tSPDVtxZ = spdVtx->GetZ();\r
-  if (TMath::Abs(tSPDVtxZ - tTPCVtxZ)>2.0) return kFALSE;\r
-  if(plpMV(tAOD)) return kFALSE;\r
-\r
-  Double_t acceptEvent=kTRUE;\r
-  // EventCuts\r
-  AliCentrality *cent = tAOD->GetHeader()->GetCentralityP();\r
-  Double_t cc1, cc2;\r
-  cc1 = cent->GetCentralityPercentile("V0M");\r
-  cc2 = cent->GetCentralityPercentile("TRK");\r
-  if(fCentMethod.Contains("V0MTRK")) fCentMethod = "V0M";\r
-  fThisCent = cent->GetCentralityPercentile( fCentMethod );\r
-  acceptEvent = (fThisCent<fCentPerMin||fThisCent>fCentPerMax)?kFALSE:acceptEvent;\r
-  acceptEvent = TMath::Abs(tTPCVtxZ)>10.0?kFALSE:acceptEvent;\r
-  // EndOfCuts\r
-  if(fQAlevel>0) ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("VTXZ"))->Fill( tTPCVtxZ, tSPDVtxZ );\r
-  if(fQAlevel>0) ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("CCCC"))->Fill( cc1, cc2 );\r
-  return acceptEvent;\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::MyUserExec(Option_t *) {\r
-  // MAIN ROUTINE\r
-  TStopwatch tTime;\r
-  tTime.Start();\r
-  fCandidates->SetLast(-1);\r
-  AliESDEvent *tESD=dynamic_cast<AliESDEvent*>(InputEvent());\r
-  AliAODEvent *tAOD=dynamic_cast<AliAODEvent*>(InputEvent());\r
-  Int_t thisRun = fRunNumber;\r
-  //=>check event\r
-  Bool_t acceptEvent=kFALSE;\r
-  if(fReadESD) {\r
-    if(!tESD) {ResetContainers(); Publish(); return;}\r
-    acceptEvent = fRunOnpp?kFALSE:fRunOnpA?kFALSE:AcceptAAEvent(tESD);\r
-    thisRun = tESD->GetRunNumber();\r
-  } else {\r
-    if(!tAOD) {ResetContainers(); Publish(); return;}\r
-    acceptEvent = fRunOnpp?AcceptPPEvent(tAOD):fRunOnpA?AcceptPAEvent(tAOD):AcceptAAEvent(tAOD);\r
-    thisRun = tAOD->GetRunNumber();\r
-  }\r
-  if(thisRun!=fRunNumber) {\r
-    fRunNumber = thisRun;\r
-    MyNotifyRun();\r
-  }\r
-  ((TH1D*)((TList*)fList->FindObject("Event"))->FindObject("Events"))->Fill(2);\r
-  //=>does the event clear?\r
-  if(!acceptEvent) {ResetContainers(); Publish(); return;}\r
-  // healthy event incomming\r
-  if( !CalibrateEvent() ) { // saves/retrieves/qas VZEROCAL\r
-    ((TH1D*)((TList*)fList->FindObject("Event"))->FindObject("Events"))->Fill(5);\r
-    ResetContainers(); Publish(); return; // issue retrieving callibration\r
-  }\r
-  if(!fSkipFlow) {\r
-    MakeQVectors();\r
-    if(fPsi2<-0.1) {\r
-      ((TH1D*)((TList*)fList->FindObject("Event"))->FindObject("Events"))->Fill(4);\r
-      ResetContainers(); Publish(); return;\r
-    }\r
-  }\r
-  //=>great, lets do our stuff!\r
-  ((TH1D*)((TList*)fList->FindObject("Event"))->FindObject("Events"))->Fill(3);\r
-  //=>load candidates\r
-  if(!fSkipSelection) {\r
-    if(fReadESD) {\r
-      ReadFromESD(tESD);\r
-    } else {\r
-      if(fSpecie<10) ReadFromAODv0(tAOD);\r
-      else ChargeParticles(tAOD);\r
-    }\r
-    if(fUseFP) {\r
-      if(!fSkipDHcorr) MakeDHcorr();\r
-      AddCandidates();\r
-    }\r
-    //=>flow\r
-    //=>done\r
-  }\r
-  tTime.Stop();\r
-  ((TH1D*)((TList*)fList->FindObject("Event"))->FindObject("RealTime"))->Fill( TMath::Log( tTime.RealTime() ) );\r
-  Publish();\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::Publish() {\r
-  PostData(1,fList);\r
-  if(fUseFP) {\r
-    PostData(2,fTPCevent);\r
-    PostData(3,fVZEevent);\r
-  }\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::ReadFromESD(AliESDEvent *tESD) {\r
-  AliStack *stack=NULL;\r
-  if(fReadMC) {\r
-    AliMCEvent *mcevent=NULL;\r
-    mcevent = MCEvent();\r
-    if(mcevent) stack = mcevent->Stack();\r
-  }\r
-\r
-  Int_t num = tESD->GetNumberOfTracks();\r
-  AliESDtrack *myTrack;\r
-  Int_t plist[3000], nlist[3000], np=0, nn=0;\r
-  Double_t pd0[3000], nd0[3000];\r
-  for (Int_t i=0; i!=num; ++i) {\r
-    myTrack = (AliESDtrack*) tESD->GetTrack(i);\r
-    if(!myTrack) continue;\r
-    LoadTrack(myTrack);\r
-    FillTrackSpy("TrkAll");\r
-    if(!AcceptDaughter()) continue;\r
-    FillTrackSpy("TrkSel");\r
-    ((TH2D*)((TList*)fList->FindObject("TrkSel"))->FindObject("PtIPXY" ))->Fill( myTrack->Pt(), fDaughterImpactParameterXY );\r
-    if( myTrack->Charge()>0 ) {\r
-      pd0[np] = fDaughterImpactParameterXY;\r
-      plist[np++] = i;\r
-    } else {\r
-      nd0[nn] = fDaughterImpactParameterXY;\r
-      nlist[nn++] = i;\r
-    }\r
-  }\r
-  ((TH1D*)((TList*)fList->FindObject("TrkSel"))->FindObject("NPAIR" ))->Fill( np,nn );\r
-  const AliESDVertex *vtx = tESD->GetPrimaryVertex();\r
-  AliESDtrack *pT, *nT;\r
-  for(int p=0; p!=np; ++p) {\r
-    pT = (AliESDtrack*) tESD->GetTrack( plist[p] );\r
-    for(int n=0; n!=nn; ++n) {\r
-      nT = (AliESDtrack*) tESD->GetTrack( nlist[n] );\r
-      fDecayProductIPXY = pd0[p]*nd0[n];\r
-      AliExternalTrackParam pETP(*pT), nETP(*nT);\r
-      Double_t xa, xb;\r
-      pETP.GetDCA(&nETP,tESD->GetMagneticField(),xa,xb);\r
-      fDecayDCAdaughters = pETP.PropagateToDCA(&nETP,tESD->GetMagneticField());\r
-      AliESDv0 vertex( nETP,nlist[n], pETP,plist[p] );\r
-      fDecayCosinePointingAngleXY = CosThetaPointXY( &vertex, vtx );\r
-      fDecayRadXY = DecayLengthXY( &vertex, vtx );\r
-      fDecayPt = vertex.Pt();\r
-      fDecayPhi = vertex.Phi();\r
-      fDecayEta = vertex.Eta();\r
-      Double_t pmx, pmy, pmz, nmx, nmy, nmz;\r
-      vertex.GetNPxPyPz(nmx,nmy,nmz);\r
-      vertex.GetPPxPyPz(pmx,pmy,pmz);\r
-      TVector3 mom1(pmx,pmy,pmz), mom2(nmx,nmy,nmz), mom(vertex.Px(),vertex.Py(),vertex.Pz());\r
-      Double_t qlpos = mom1.Dot(mom)/mom.Mag();\r
-      Double_t qlneg = mom2.Dot(mom)/mom.Mag();\r
-      fDecayQt = mom1.Perp(mom);\r
-      fDecayAlpha = (qlpos-qlneg)/(qlpos+qlneg);\r
-      Double_t mpi = 0.13957018;\r
-      if(fSpecie==0) {\r
-        Double_t eppi = TMath::Sqrt( mpi*mpi + pmx*pmx + pmy*pmy + pmz*pmz );\r
-        Double_t enpi = TMath::Sqrt( mpi*mpi + nmx*nmx + nmy*nmy + nmz*nmz );\r
-        fDecayMass = TMath::Sqrt( mpi*mpi + mpi*mpi + 2*(eppi*enpi - pmx*nmx - pmy*nmy - pmz*nmz ) );\r
-        fDecayRapidity = vertex.RapK0Short();\r
-      } else {\r
-        Double_t mpr = 0.938272013;\r
-        Double_t epi, epr;\r
-        if(fDecayAlpha>0) {\r
-          epr = TMath::Sqrt( mpr*mpr + pmx*pmx + pmy*pmy + pmz*pmz );\r
-          epi = TMath::Sqrt( mpi*mpi + nmx*nmx + nmy*nmy + nmz*nmz );\r
-        } else {\r
-          epi = TMath::Sqrt( mpi*mpi + pmx*pmx + pmy*pmy + pmz*pmz );\r
-          epr = TMath::Sqrt( mpr*mpr + nmx*nmx + nmy*nmy + nmz*nmz );\r
-        }\r
-        fDecayMass = TMath::Sqrt( mpi*mpi + mpr*mpr + 2*(epi*epr - pmx*nmx - pmy*nmy - pmz*nmz ) );\r
-        fDecayRapidity = vertex.RapLambda();\r
-      }\r
-      Double_t energy = TMath::Sqrt( fDecayMass*fDecayMass + vertex.Px()*vertex.Px() + vertex.Py()*vertex.Py() + vertex.Pz()*vertex.Pz() );\r
-      Double_t gamma = energy/fDecayMass;\r
-      fDecayDecayLength = DecayLength( &vertex, vtx )/gamma;\r
-      Double_t dPHI = fDecayPhi;\r
-      Double_t dDPHI = dPHI - fPsi2;\r
-      if( dDPHI < 0 ) dDPHI += TMath::TwoPi();\r
-      if( dDPHI > TMath::Pi() ) dDPHI = TMath::TwoPi()-dDPHI;\r
-      if(fQAlevel>1) {\r
-        if( (dDPHI>TMath::PiOver4()) && (dDPHI<3*TMath::PiOver4()) ) FillCandidateSpy("RecAllOP");\r
-        else FillCandidateSpy("RecAllIP");\r
-      }\r
-      FillCandidateSpy("RecAll");\r
-      ((TH2D*)((TList*)fList->FindObject("RecAll"))->FindObject("D0PD0N"))->Fill( pd0[p],nd0[n] );\r
-      ((TH2D*)((TList*)fList->FindObject("RecAll"))->FindObject("XPOSXNEG"))->Fill( xa, xb );\r
-      if(!AcceptCandidate()) continue;\r
-      if(fDecayMass<fMinMass) continue;\r
-      if(fDecayMass>fMaxMass) continue;\r
-      // PID missing\r
-      if(fQAlevel>1) {\r
-        if( (dDPHI>TMath::PiOver4()) && (dDPHI<3*TMath::PiOver4()) ) FillCandidateSpy("RecSelOP");\r
-        else FillCandidateSpy("RecSelIP");\r
-      }\r
-      FillCandidateSpy("RecSel");\r
-      ((TH2D*)((TList*)fList->FindObject("RecSel"))->FindObject("D0PD0N"))->Fill( pd0[p],nd0[n] );\r
-      ((TH2D*)((TList*)fList->FindObject("RecSel"))->FindObject("XPOSXNEG"))->Fill( xa, xb );\r
-\r
-      fDecayIDneg = nT->GetID();\r
-      fDecayIDpos = pT->GetID();\r
-      MakeTrack();\r
-      LoadTrack(pT); FillTrackSpy("TrkDau");\r
-      LoadTrack(nT); FillTrackSpy("TrkDau");\r
-\r
-      //===== BEGIN OF MCMATCH\r
-      if(stack) {\r
-        bool matched = false;\r
-        Int_t labelpos = pT->GetLabel();\r
-        Int_t labelneg = nT->GetLabel();\r
-        Double_t rOri=-1;\r
-        if( labelpos>0 && labelneg>0 ) {\r
-          TParticle *mcpos = stack->Particle( labelpos );\r
-          TParticle *mcneg = stack->Particle( labelneg );\r
-          Int_t pdgRecPos = mcpos->GetPdgCode();\r
-          Int_t pdgRecNeg = mcneg->GetPdgCode();\r
-          if( pdgRecPos==211&&pdgRecNeg==-211 ) if(mcpos->GetMother(0)>0) {\r
-            if( mcpos->GetMother(0)==mcneg->GetMother(0) ) {\r
-              TParticle *mcmot = stack->Particle( mcpos->GetMother(0) );\r
-              rOri = TMath::Sqrt( mcmot->Vx()*mcmot->Vx() + mcmot->Vy()*mcmot->Vy() );\r
-              if( TMath::Abs(mcmot->GetPdgCode())==310) {\r
-                if(mcmot->GetNDaughters()==2) matched=true;\r
-              }\r
-            }\r
-          }\r
-        }\r
-        if(matched) {\r
-          FillCandidateSpy("RecMth");\r
-          ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("D0PD0N"))->Fill( pd0[p],nd0[n] );\r
-          ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("XPOSXNEG"))->Fill( xa, xb );\r
-          ((TH1D*)((TList*)fList->FindObject("RecMth"))->FindObject("MCOrigin"))->Fill( rOri );\r
-          LoadTrack(pT); FillTrackSpy("TrkMth");\r
-          LoadTrack(nT); FillTrackSpy("TrkMth");\r
-        }\r
-      }\r
-      //===== END OF MCMATCH\r
-    }\r
-  }\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::ReadStack(TClonesArray* mcArray) {\r
-  if(!mcArray) return;\r
-  AliAODMCParticle *myMCTrack, *iMCDau, *jMCDau;\r
-  for(int i=0; i!=mcArray->GetEntriesFast(); ++i) {\r
-    myMCTrack = dynamic_cast<AliAODMCParticle*>(mcArray->At( i ));\r
-    if(!myMCTrack) continue;\r
-    int tPDG=310;\r
-    if(fSpecie>0) tPDG = 3122;\r
-    if( TMath::Abs(myMCTrack->PdgCode())==tPDG )\r
-      if( myMCTrack->GetNDaughters() == 2 ) {\r
-        Int_t iDau = myMCTrack->GetDaughter(0);\r
-        Int_t jDau = myMCTrack->GetDaughter(1);\r
-        AliAODMCParticle *posDau=NULL;\r
-        AliAODMCParticle *negDau=NULL;\r
-        if(iDau>0&&jDau>0) {\r
-          iMCDau = dynamic_cast<AliAODMCParticle*>(mcArray->At( iDau ));\r
-          jMCDau = dynamic_cast<AliAODMCParticle*>(mcArray->At( jDau ));\r
-          if(iMCDau) {\r
-            if(iMCDau->Charge()>0) posDau=iMCDau;\r
-            else negDau=iMCDau;\r
-          }\r
-          if(jMCDau) {\r
-            if(jMCDau->Charge()>0) posDau=jMCDau;\r
-            else negDau=jMCDau;\r
-          }\r
-        } //got two daughters\r
-        if(posDau&&negDau) {\r
-          Double_t dx = myMCTrack->Xv() - posDau->Xv();\r
-          Double_t dy = myMCTrack->Yv() - posDau->Yv();\r
-          Double_t dz = myMCTrack->Zv() - posDau->Zv();\r
-          fDecayRadXY = TMath::Sqrt( dx*dx + dy*dy );\r
-          TVector3 momPos(posDau->Px(),posDau->Py(),posDau->Pz());\r
-          TVector3 momNeg(negDau->Px(),negDau->Py(),negDau->Pz());\r
-          TVector3 momTot(myMCTrack->Px(),myMCTrack->Py(),myMCTrack->Pz());\r
-          Double_t qlpos = momPos.Dot(momTot)/momTot.Mag();\r
-          Double_t qlneg = momNeg.Dot(momTot)/momTot.Mag();\r
-          fDecayQt = momPos.Perp(momTot);\r
-          fDecayAlpha = 1.-2./(1.+qlpos/qlneg);\r
-          fDecayMass = myMCTrack->GetCalcMass();\r
-          Double_t energy = myMCTrack->E();\r
-          Double_t gamma = energy/fDecayMass;\r
-          fDecayDecayLength = TMath::Sqrt(dx*dx+dy*dy+dz*dz)/gamma;\r
-          fDecayPt = myMCTrack->Pt();\r
-          fDecayPhi = myMCTrack->Phi();\r
-          fDecayEta = myMCTrack->Eta();\r
-          fDecayRapidity = myMCTrack->Y();\r
-          fDecayDCAdaughters = 0;\r
-          fDecayCosinePointingAngleXY = 1;\r
-          fDecayProductIPXY = -1;\r
-          if(AcceptCandidate()) FillCandidateSpy("GenTru");\r
-        }\r
-      } // k0/lda with two daughters\r
-    //==== BEGIN TRACK CUTS\r
-    if(myMCTrack->Eta()<-0.8) continue;\r
-    if(myMCTrack->Eta()>+0.8) continue;\r
-    //==== END TRACK CUTS\r
-    switch( TMath::Abs(myMCTrack->PdgCode()) ) {\r
-    case (310): //k0s\r
-      FillMCParticleSpy( "MCTK0s", myMCTrack );\r
-      if( myMCTrack->IsPrimary() )\r
-        FillMCParticleSpy( "MCTK0sGenAcc", myMCTrack );\r
-      break;\r
-    case (3122): //lda\r
-      FillMCParticleSpy( "MCTLda", myMCTrack );\r
-      if( myMCTrack->IsPrimary() )\r
-        FillMCParticleSpy( "MCTLdaGenAcc", myMCTrack );\r
-      break;\r
-    case (333): //phi\r
-      if( myMCTrack->IsPrimary() )\r
-        FillMCParticleSpy( "MCTPhiGenAcc", myMCTrack );\r
-      break;\r
-    case (3312): //xi\r
-      if( myMCTrack->IsPrimary() )\r
-        FillMCParticleSpy( "MCTXiGenAcc", myMCTrack );\r
-      break;\r
-    }\r
-    \r
-  }\r
-}\r
-//=======================================================================\r
-Double_t AliAnalysisTaskFlowStrange::CosThetaPointXY(AliESDv0 *me, const AliVVertex *vtx) {\r
-  TVector3 mom( me->Px(), me->Py(), 0 );\r
-  TVector3 fli( me->Xv()-vtx->GetX(), me->Yv()-vtx->GetY(), 0 );\r
-  Double_t ctp = mom.Dot(fli) / mom.Mag() / fli.Mag();\r
-  return ctp;\r
-}\r
-//=======================================================================\r
-Double_t AliAnalysisTaskFlowStrange::CosThetaPointXY(AliAODv0 *me, const AliVVertex *vtx) {\r
-  TVector3 mom( me->Px(), me->Py(), 0 );\r
-  TVector3 fli( me->Xv()-vtx->GetX(), me->Yv()-vtx->GetY(), 0 );\r
-  Double_t ctp = mom.Dot(fli) / mom.Mag() / fli.Mag();\r
-  return ctp;\r
-}\r
-//=======================================================================\r
-Double_t AliAnalysisTaskFlowStrange::DecayLengthXY(AliESDv0 *me, const AliVVertex *vtx) {\r
-  Double_t dx = me->Xv()-vtx->GetX();\r
-  Double_t dy = me->Yv()-vtx->GetY();\r
-  Double_t dxy = TMath::Sqrt( dx*dx + dy*dy );\r
-  return dxy;\r
-}\r
-//=======================================================================\r
-Double_t AliAnalysisTaskFlowStrange::DecayLengthXY(AliAODv0 *me, const AliVVertex *vtx) {\r
-  Double_t dx = me->Xv()-vtx->GetX();\r
-  Double_t dy = me->Yv()-vtx->GetY();\r
-  Double_t dxy = TMath::Sqrt( dx*dx + dy*dy );\r
-  return dxy;\r
-}\r
-//=======================================================================\r
-Double_t AliAnalysisTaskFlowStrange::DecayLength(AliESDv0 *me, const AliVVertex *vtx) {\r
-  Double_t dx = me->Xv()-vtx->GetX();\r
-  Double_t dy = me->Yv()-vtx->GetY();\r
-  Double_t dz = me->Zv()-vtx->GetZ();\r
-  Double_t dxy = TMath::Sqrt( dx*dx + dy*dy + dz*dz );\r
-  return dxy;\r
-}\r
-//=======================================================================\r
-Double_t AliAnalysisTaskFlowStrange::DecayLength(AliAODv0 *me, const AliVVertex *vtx) {\r
-  Double_t dx = me->Xv()-vtx->GetX();\r
-  Double_t dy = me->Yv()-vtx->GetY();\r
-  Double_t dz = me->Zv()-vtx->GetZ();\r
-  Double_t dxy = TMath::Sqrt( dx*dx + dy*dy + dz*dz );\r
-  return dxy;\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::ReadFromAODv0(AliAODEvent *tAOD) {\r
-  TClonesArray* mcArray=NULL;\r
-  if(fReadMC) {\r
-    mcArray = dynamic_cast<TClonesArray*>(tAOD->FindListObject(AliAODMCParticle::StdBranchName()));\r
-    ReadStack(mcArray);\r
-  }\r
-\r
-  Int_t nV0s = tAOD->GetNumberOfV0s();\r
-  AliAODv0 *myV0;\r
-  Int_t v0all=0, v0imw=0;\r
-  for (Int_t i=0; i!=nV0s; ++i) {\r
-    myV0 = (AliAODv0*) tAOD->GetV0(i);\r
-    if(!myV0) continue;\r
-    if(!fOnline) if(myV0->GetOnFlyStatus() ) continue;\r
-    if(fOnline) if(!myV0->GetOnFlyStatus() ) continue;\r
-    AliAODTrack *iT, *jT;\r
-    AliAODVertex *vtx = tAOD->GetPrimaryVertex();\r
-    Double_t pos[3],cov[6];\r
-    vtx->GetXYZ(pos);\r
-    vtx->GetCovarianceMatrix(cov);\r
-    const AliESDVertex vESD(pos,cov,100.,100);\r
-    // TESTING CHARGE\r
-    int iPos, iNeg;\r
-    iT=(AliAODTrack*) myV0->GetDaughter(0);\r
-    if(iT->Charge()>0) {\r
-      iPos = 0; iNeg = 1;\r
-    } else {\r
-      iPos = 1; iNeg = 0;\r
-    }\r
-    // END OF TEST\r
-\r
-    iT=(AliAODTrack*) myV0->GetDaughter(iPos); // positive\r
-    AliESDtrack ieT( iT );\r
-    ieT.SetTPCClusterMap( iT->GetTPCClusterMap() );\r
-    ieT.SetTPCSharedMap( iT->GetTPCSharedMap() );\r
-    ieT.SetTPCPointsF( iT->GetTPCNclsF() );\r
-    ieT.PropagateToDCA(&vESD, tAOD->GetMagneticField(), 100);\r
-    LoadTrack(&ieT,iT->Chi2perNDF());\r
-    Float_t ip[2];\r
-    ieT.GetDZ(pos[0], pos[1], pos[2], tAOD->GetMagneticField(), ip);\r
-    fDaughterImpactParameterXY = ip[0];\r
-    fDaughterImpactParameterZ = ip[1];\r
-    Double_t dD0P = fDaughterImpactParameterXY; //ieT.GetD(pos[0], pos[1], tAOD->GetMagneticField());\r
-    if(!AcceptDaughter()) continue;\r
-\r
-    jT=(AliAODTrack*) myV0->GetDaughter(iNeg); // negative\r
-    AliESDtrack jeT( jT );\r
-    jeT.SetTPCClusterMap( jT->GetTPCClusterMap() );\r
-    jeT.SetTPCSharedMap( jT->GetTPCSharedMap() );\r
-    jeT.SetTPCPointsF( jT->GetTPCNclsF() );\r
-    jeT.PropagateToDCA(&vESD, tAOD->GetMagneticField(), 100);\r
-    LoadTrack(&jeT,jT->Chi2perNDF());\r
-    jeT.GetDZ(pos[0], pos[1], pos[2], tAOD->GetMagneticField(), ip);\r
-    fDaughterImpactParameterXY = ip[0];\r
-    fDaughterImpactParameterZ = ip[1];\r
-    Double_t dD0N = fDaughterImpactParameterXY; //jeT.GetD(pos[0], pos[1], tAOD->GetMagneticField());\r
-    if(!AcceptDaughter()) continue;\r
-    if( fExcludeTPCEdges ) {\r
-      if( IsAtTPCEdge(iT->Phi(),iT->Pt(),+1,tAOD->GetMagneticField()) ) continue;\r
-      if( IsAtTPCEdge(jT->Phi(),jT->Pt(),-1,tAOD->GetMagneticField()) ) continue;\r
-    }\r
-    Double_t xa, xb;\r
-    ieT.GetDCA(&jeT,tAOD->GetMagneticField(),xa,xb);\r
-    /*\r
-    // cutting out population close to TPC edges :: strange excess saw in 2010\r
-    if( fExcludeTPCEdges ) {\r
-    Double_t phimod = myV0->Phi();\r
-    int sectors[6] = {5,6,9,10,11,12};\r
-    for(int ii=0; ii!=6; ++ii)\r
-    if( (phimod<(sectors[ii]+1)*TMath::Pi()/9.0) && (phimod>sectors[ii]*TMath::Pi()/9.0) )\r
-    return 0;\r
-    }\r
-    */\r
-    if(fSpecie==0)\r
-      fDecayRapidity = myV0->RapK0Short();\r
-    else\r
-      fDecayRapidity = myV0->RapLambda();\r
-    fDecayDCAdaughters = myV0->DcaV0Daughters();\r
-    fDecayCosinePointingAngleXY = CosThetaPointXY( myV0, vtx );\r
-    fDecayRadXY = DecayLengthXY( myV0, vtx );\r
-    fDecayPt = myV0->Pt();\r
-    fDecayPhi = myV0->Phi();\r
-    fDecayEta = myV0->Eta();\r
-    fDecayProductIPXY = dD0P*dD0N;\r
-    fDecayQt = myV0->PtArmV0();\r
-    fDecayAlpha = myV0->AlphaV0(); // AlphaV0 -> AODRecoDecat::Alpha -> return 1.-2./(1.+QlProng(0)/QlProng(1));\r
-    if(myV0->ChargeProng(iPos)<0) fDecayAlpha = -fDecayAlpha; // protects for a change in convention\r
-    fDecayPt = myV0->Pt();\r
-    fDecayEta = myV0->Eta();\r
-    if( fSpecie==0 ) {\r
-      fDecayMass = myV0->MassK0Short();\r
-    } else {\r
-      if(fDecayAlpha>0) fDecayMass = myV0->MassLambda();\r
-      else fDecayMass = myV0->MassAntiLambda();\r
-    }\r
-    v0all++;\r
-    if(fDecayMass<fMinMass) continue;\r
-    if(fDecayMass>fMaxMass) continue;\r
-    v0imw++;\r
-    Double_t energy = TMath::Sqrt( fDecayMass*fDecayMass + myV0->Px()*myV0->Px() + myV0->Py()*myV0->Py() + myV0->Pz()*myV0->Pz() );\r
-    Double_t gamma = energy/fDecayMass;\r
-    fDecayDecayLength = DecayLength( myV0, vtx )/gamma;\r
-    Double_t dPHI = fDecayPhi;\r
-    Double_t dDPHI = dPHI - fPsi2;\r
-    if( dDPHI < 0 ) dDPHI += TMath::TwoPi();\r
-    if( dDPHI > TMath::Pi() ) dDPHI = TMath::TwoPi()-dDPHI;\r
-    if(fQAlevel>1) {\r
-      if( (dDPHI>TMath::PiOver4()) && (dDPHI<3*TMath::PiOver4()) ) FillCandidateSpy("RecAllOP");\r
-      else FillCandidateSpy("RecAllIP");\r
-    }\r
-    FillCandidateSpy("RecAll");\r
-    ((TH2D*)((TList*)fList->FindObject("RecAll"))->FindObject("D0PD0N"))->Fill( dD0P, dD0N );\r
-    ((TH2D*)((TList*)fList->FindObject("RecAll"))->FindObject("XPOSXNEG"))->Fill( xa, xb );\r
-    if(!AcceptCandidate()) continue;\r
-    //PID for lambda::proton\r
-    if( fSpecie>0 )\r
-      if(fDecayPt<1.2) {\r
-        if(fDecayAlpha>0) {\r
-          if( !PassesPIDCuts(&ieT) ) continue; //positive track\r
-        } else {\r
-          if( !PassesPIDCuts(&jeT) ) continue; //negative track\r
-        }\r
-      }\r
-    if(fQAlevel>1) {\r
-      if( (dDPHI>TMath::PiOver4()) && (dDPHI<3*TMath::PiOver4()) ) FillCandidateSpy("RecSelOP");\r
-      else FillCandidateSpy("RecSelIP");\r
-    }\r
-    FillCandidateSpy("RecSel");\r
-    ((TH2D*)((TList*)fList->FindObject("RecSel"))->FindObject("D0PD0N"))->Fill( dD0P, dD0N );\r
-    ((TH2D*)((TList*)fList->FindObject("RecSel"))->FindObject("XPOSXNEG"))->Fill( xa, xb );\r
-    fDecayIDneg = iT->GetID();\r
-    fDecayIDpos = jT->GetID();\r
-    MakeTrack();\r
-    LoadTrack(&ieT,iT->Chi2perNDF());\r
-    ieT.GetDZ(pos[0], pos[1], pos[2], tAOD->GetMagneticField(), ip);\r
-    fDaughterImpactParameterXY = ip[0];\r
-    fDaughterImpactParameterZ = ip[1];\r
-    FillTrackSpy("TrkDau");\r
-    LoadTrack(&jeT,jT->Chi2perNDF()); \r
-    jeT.GetDZ(pos[0], pos[1], pos[2], tAOD->GetMagneticField(), ip);\r
-    fDaughterImpactParameterXY = ip[0];\r
-    fDaughterImpactParameterZ = ip[1];\r
-    FillTrackSpy("TrkDau");\r
-    //===== BEGIN OF MCMATCH                                                                                                                         \r
-    if(mcArray) {\r
-      bool matched = false;\r
-      bool feeddown = false;\r
-      Int_t labelpos = iT->GetLabel();\r
-      Int_t labelneg = jT->GetLabel();\r
-      Double_t rOri=-1;\r
-      Double_t mcPt=-1, mcEta=-1, mcRap=-1, mcRxy=-1, mcDle=-1, mcApa=-100, mcApq=-1;\r
-      Double_t resPt=-1, resEta=-1, resRap=-1, resRxy=-1, resDle=-1, resApa=-1, resApq=-1;\r
-      if( labelpos>0 && labelneg>0 ) {\r
-        AliAODMCParticle *mcpos = (AliAODMCParticle*) mcArray->At( labelpos );\r
-        AliAODMCParticle *mcneg = (AliAODMCParticle*) mcArray->At( labelneg );\r
-        Int_t pdgRecPos = mcpos->GetPdgCode();\r
-        Int_t pdgRecNeg = mcneg->GetPdgCode();\r
-        int pospdg=211, negpdg=211;\r
-        int mompdg=310, fdwpdg=333;\r
-        if(fSpecie>0) {\r
-          mompdg=3122;\r
-          fdwpdg=3312;\r
-          if(fDecayAlpha>0) {\r
-            pospdg=2212; negpdg=211;\r
-          } else {\r
-            negpdg=2212; pospdg=211;\r
-          }\r
-        }\r
-        if( TMath::Abs(pdgRecPos)==pospdg&&TMath::Abs(pdgRecNeg)==negpdg )\r
-          if(mcpos->GetMother()>0)\r
-            if( mcpos->GetMother()==mcneg->GetMother() ) {\r
-              AliAODMCParticle *mcmot = (AliAODMCParticle*) mcArray->At( mcpos->GetMother() );\r
-              rOri = TMath::Sqrt( mcmot->Xv()*mcmot->Xv() + mcmot->Yv()*mcmot->Yv() );\r
-              mcPt = mcmot->Pt();\r
-              mcEta = TMath::Abs( mcmot->Eta() );\r
-              mcRap = TMath::Abs( mcmot->Y() );\r
-              if(!TMath::AreEqualAbs(mcPt,0,1e-6))  resPt = (fDecayPt - mcPt) / mcPt;\r
-              if(!TMath::AreEqualAbs(mcEta,0,1e-6)) resEta = (fDecayEta - mcEta) / mcEta;\r
-              if(!TMath::AreEqualAbs(mcRap,0,1e-6)) resRap = (fDecayRapidity - mcRap) / mcRap;\r
-              if( TMath::Abs(mcmot->GetPdgCode())==mompdg) {\r
-                if(mcmot->GetNDaughters()==2) {\r
-                  matched=true;\r
-                  Double_t dx = mcmot->Xv() - mcpos->Xv();\r
-                  Double_t dy = mcmot->Yv() - mcpos->Yv();\r
-                  Double_t dz = mcmot->Zv() - mcpos->Zv();\r
-                  Double_t mcGamma = mcmot->E() / mcmot->GetCalcMass();\r
-                  mcRxy = TMath::Sqrt( dx*dx + dy*dy );\r
-                  mcDle = TMath::Sqrt(dx*dx+dy*dy+dz*dz)/mcGamma;\r
-                  if(!TMath::AreEqualAbs(mcRxy,0,1e-6)) resRxy = (fDecayRadXY - mcRxy) / mcRxy;\r
-                  if(!TMath::AreEqualAbs(mcDle,0,1e-6)) resDle = (fDecayDecayLength - mcDle) / mcDle;\r
-                  TVector3 momPos(mcpos->Px(),mcpos->Py(),mcpos->Pz());\r
-                  TVector3 momNeg(mcneg->Px(),mcneg->Py(),mcneg->Pz());\r
-                  TVector3 momTot(mcmot->Px(),mcmot->Py(),mcmot->Pz());\r
-                  Double_t qlpos = momPos.Dot(momTot)/momTot.Mag();\r
-                  Double_t qlneg = momNeg.Dot(momTot)/momTot.Mag();\r
-                  mcApq = momPos.Perp(momTot);\r
-                  mcApa = 1.-2./(1.+qlpos/qlneg);\r
-                  if(!TMath::AreEqualAbs(mcApq,0,1e-6)) resApq = (fDecayQt - mcApq) / mcApq;\r
-                  if(!TMath::AreEqualAbs(mcApa,0,1e-6)) resApa = (fDecayAlpha - mcApa) / mcApa;\r
-                }\r
-                if(mcmot->GetMother()>0) {\r
-                  AliAODMCParticle *mcfdw = (AliAODMCParticle*) mcArray->At( mcmot->GetMother() );\r
-                  if( TMath::Abs(mcfdw->GetPdgCode())==fdwpdg)\r
-                    feeddown=true;\r
-                } // k0/lda have mother\r
-              } // mother matches k0/lda\r
-            } // both have same mother\r
-      } // match to MCparticles\r
-      if(matched) {\r
-        FillCandidateSpy("RecMth");\r
-        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("D0PD0N"))->Fill( dD0P,dD0N );\r
-        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("XPOSXNEG"))->Fill( xa, xb );\r
-        ((TH1D*)((TList*)fList->FindObject("RecMth"))->FindObject("MCOrigin"))->Fill( rOri );\r
-        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("PTRes"))->Fill( mcPt, resPt );\r
-        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("ETARes"))->Fill( mcEta, resEta );\r
-        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("RAPRes"))->Fill( mcRap, resRap );\r
-        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("RXYRes"))->Fill( mcRxy, resRxy );\r
-        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("DLERes"))->Fill( mcDle, resDle );\r
-        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("APARes"))->Fill( mcApa, resApa );\r
-        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("APQRes"))->Fill( mcApq, resApq );\r
-        LoadTrack(&ieT,iT->Chi2perNDF());\r
-        ieT.GetDZ(pos[0], pos[1], pos[2], tAOD->GetMagneticField(), ip);\r
-        fDaughterImpactParameterXY = ip[0];\r
-        fDaughterImpactParameterZ = ip[1];\r
-        FillTrackSpy("TrkMth");\r
-        LoadTrack(&jeT,jT->Chi2perNDF());\r
-        jeT.GetDZ(pos[0], pos[1], pos[2], tAOD->GetMagneticField(), ip);\r
-        fDaughterImpactParameterXY = ip[0];\r
-        fDaughterImpactParameterZ = ip[1];\r
-        FillTrackSpy("TrkMth");\r
-      }\r
-      if(feeddown) {\r
-        FillCandidateSpy("MthFDW");\r
-        ((TH2D*)((TList*)fList->FindObject("MthFDW"))->FindObject("D0PD0N"))->Fill( dD0P,dD0N );\r
-        ((TH1D*)((TList*)fList->FindObject("MthFDW"))->FindObject("MCOrigin"))->Fill( rOri );\r
-      }\r
-    }\r
-    //===== END OF MCMATCH\r
-  }\r
-  ((TH2D*)((TList*)fList->FindObject("RecAll"))->FindObject("V0SADC"))->Fill( v0all,v0imw );\r
-  return;\r
-}\r
-//=======================================================================\r
-Bool_t AliAnalysisTaskFlowStrange::PassesPIDCuts(AliESDtrack *myTrack, AliPID::EParticleType pid) {\r
-  Bool_t pass=kTRUE;\r
-  if(fPIDResponse) {\r
-    fDaughterNSigmaPID = fPIDResponse->NumberOfSigmasTPC(myTrack,pid);\r
-    if( TMath::Abs(fDaughterNSigmaPID) > fDaughterMaxNSigmaPID )\r
-      pass = kFALSE;\r
-  }\r
-  return pass;\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::ChargeParticles(AliAODEvent *tAOD) {\r
-  //benchmark purposes (for the ultimate measurement for LHC10h see Alex, Francesco)\r
-  if(!tAOD) return;\r
-  // (for the moment) only compatible with SPVZE (no untagging)\r
-  for(int i=0; i!=tAOD->GetNumberOfTracks(); ++i) {\r
-    AliAODTrack *t = tAOD->GetTrack( i );\r
-    if(!t) continue;\r
-    if( !t->TestFilterBit(1024) ) continue;\r
-    fDecayMass=0.0; // using mass as nsigmas control plot\r
-    if(fPIDResponse) { // PID\r
-      switch(fSpecie) { // TPC PID only\r
-      case(kPION):\r
-        fDecayMass = fPIDResponse->NumberOfSigmasTPC(t,AliPID::kPion);\r
-        break;\r
-      case(kKAON):\r
-        fDecayMass = fPIDResponse->NumberOfSigmasTPC(t,AliPID::kKaon);\r
-        break;\r
-      case(kPROTON):\r
-        fDecayMass = fPIDResponse->NumberOfSigmasTPC(t,AliPID::kProton);\r
-        break;\r
-      }\r
-    }\r
-    Bool_t pass = kTRUE;\r
-    if( TMath::Abs(fDecayMass) > 3.0 ) pass=kFALSE;\r
-    if( t->Eta()<-0.8 || t->Eta()>+0.8 ) pass=kFALSE;\r
-    if( t->Pt()<0.2 || t->Pt()>20.0 ) pass=kFALSE;\r
-    if( t->GetTPCsignal()<10.0 ) pass=kFALSE;\r
-    fDecayPt=t->Pt();\r
-    fDecayPhi=t->Phi();\r
-    fDecayEta=t->Eta();\r
-    fDecayID=t->GetID();\r
-\r
-    FillCandidateSpy("RecAll");\r
-    if(!pass) continue;\r
-\r
-    AliESDtrack et( t );\r
-    et.SetTPCClusterMap( t->GetTPCClusterMap() );\r
-    et.SetTPCSharedMap( t->GetTPCSharedMap() );\r
-    et.SetTPCPointsF( t->GetTPCNclsF() );\r
-    Float_t ip[2];\r
-    LoadTrack(&et,t->Chi2perNDF()); \r
-    AliAODVertex *vtx = tAOD->GetPrimaryVertex();\r
-    Double_t pos[3];\r
-    vtx->GetXYZ(pos);\r
-    et.GetDZ(pos[0], pos[1], pos[2], tAOD->GetMagneticField(), ip);\r
-    fDaughterImpactParameterXY = ip[0];\r
-    fDaughterImpactParameterZ = ip[1];\r
-    FillTrackSpy("TrkDau");\r
-    FillCandidateSpy("RecSel");\r
-\r
-    MakeTrack();\r
-  }\r
-  return;\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::Terminate(Option_t *) {\r
-  //terminate\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::MakeTrack() {\r
-  // create track for flow tasks\r
-  if(fCandidates->GetLast()+5>fCandidates->GetSize()) {\r
-    fCandidates->Expand( fCandidates->GetSize()+20 );\r
-  }\r
-  Bool_t overwrite = kTRUE;\r
-  AliFlowCandidateTrack *oTrack = (static_cast<AliFlowCandidateTrack*> (fCandidates->At( fCandidates->GetLast()+1 )));\r
-  if( !oTrack ) { // creates new\r
-    oTrack = new AliFlowCandidateTrack();\r
-    overwrite = kFALSE;\r
-  } else { // overwrites\r
-    oTrack->ClearMe();\r
-  }\r
-  oTrack->SetMass(fDecayMass);\r
-  oTrack->SetPt(fDecayPt);\r
-  oTrack->SetPhi(fDecayPhi);\r
-  oTrack->SetEta(fDecayEta);\r
-  if(fSpecie<10) {\r
-    oTrack->AddDaughter(fDecayIDpos);\r
-    oTrack->AddDaughter(fDecayIDneg);\r
-  } else {\r
-    oTrack->SetID( fDecayID );\r
-  }\r
-  oTrack->SetForPOISelection(kTRUE);\r
-  oTrack->SetForRPSelection(kFALSE);\r
-  if(overwrite) {\r
-    fCandidates->SetLast( fCandidates->GetLast()+1 );\r
-  } else {\r
-    fCandidates->AddLast(oTrack);\r
-  }\r
-  return;\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::AddCandidates() {\r
-  // adds candidates to flow events (untaging if necessary)\r
-  if(fDebug) printf("FlowEventTPC %d tracks | %d RFP | %d POI\n",fTPCevent->NumberOfTracks(),fTPCevent->GetNumberOfRPs(),fTPCevent->GetNumberOfPOIs());\r
-  if(fDebug) printf("FlowEventVZE %d tracks | %d RFP | %d POI\n",fVZEevent->NumberOfTracks(),fVZEevent->GetNumberOfRPs(),fVZEevent->GetNumberOfPOIs());\r
-  if(fDebug) printf("I received %d candidates\n",fCandidates->GetEntriesFast());\r
-  Int_t untagged=0;\r
-  Int_t poi=0;\r
-  for(int iCand=0; iCand!=fCandidates->GetEntriesFast(); ++iCand ) {\r
-    AliFlowCandidateTrack *cand = static_cast<AliFlowCandidateTrack*>(fCandidates->At(iCand));\r
-    if(!cand) continue;\r
-    cand->SetForPOISelection(kTRUE);\r
-    cand->SetForRPSelection(kFALSE);\r
-    poi++;\r
-    if(fDebug) printf(" >Checking at candidate %d with %d daughters: mass %f\n",\r
-                      iCand,cand->GetNDaughters(),cand->Mass());\r
-    if(fSpecie<10) { // DECAYS\r
-      // untagging ===>\r
-      if(fDaughterUnTag) {\r
-       for(int iDau=0; iDau!=cand->GetNDaughters(); ++iDau) {\r
-         if(fDebug) printf("  >Daughter %d with fID %d", iDau, cand->GetIDDaughter(iDau));\r
-         for(int iRPs=0; iRPs!=fTPCevent->NumberOfTracks(); ++iRPs ) {\r
-           AliFlowTrack *iRP = static_cast<AliFlowTrack*>(fTPCevent->GetTrack( iRPs ));\r
-           if(!iRP) continue;\r
-           if(!iRP->InRPSelection()) continue;\r
-           if(cand->GetIDDaughter(iDau) == iRP->GetID()) {\r
-             if(fDebug) printf(" was in RP set");\r
-             ++untagged;\r
-             iRP->SetForRPSelection(kFALSE);\r
-             fTPCevent->SetNumberOfRPs( fTPCevent->GetNumberOfRPs() -1 );\r
-           }\r
-         }\r
-         if(fDebug) printf("\n");\r
-       }\r
-      }\r
-      // <=== untagging \r
-      fTPCevent->InsertTrack( ((AliFlowTrack*) cand) );\r
-    } else {  // CHARGED\r
-      // adding only new tracks and tagging accordingly ===>\r
-      Bool_t found=kFALSE;\r
-      for(int iRPs=0; iRPs!=fTPCevent->NumberOfTracks(); ++iRPs ) {\r
-        AliFlowTrack *iRP = static_cast<AliFlowTrack*>(fTPCevent->GetTrack( iRPs ));\r
-        if(!iRP) continue;\r
-        if(!iRP->InRPSelection()) continue;\r
-        if(cand->GetID() == iRP->GetID()) {\r
-          if(fDebug) printf("  >charged track (%d) was also found in RP set (adding poi tag)\n",cand->GetID());\r
-          iRP->SetForPOISelection(kTRUE);\r
-          found = kTRUE;\r
-        }\r
-      }\r
-      if(!found) // not found adding track\r
-        fTPCevent->InsertTrack( ((AliFlowTrack*) cand) );\r
-    }\r
-    fVZEevent->InsertTrack( ((AliFlowTrack*) cand) );\r
-  } //END OF LOOP\r
-  fTPCevent->SetNumberOfPOIs( poi );\r
-  fVZEevent->SetNumberOfPOIs( poi );\r
-  ((TH1D*)((TList*)fList->FindObject("Event"))->FindObject("POI"))->Fill( poi );\r
-  ((TH1D*)((TList*)fList->FindObject("Event"))->FindObject("UNTAG"))->Fill( untagged );\r
-  if(fDebug) printf("FlowEventTPC %d tracks | %d RFP | %d POI\n",fTPCevent->NumberOfTracks(),fTPCevent->GetNumberOfRPs(),fTPCevent->GetNumberOfPOIs());\r
-  if(fDebug) printf("FlowEventVZE %d tracks | %d RFP | %d POI\n",fVZEevent->NumberOfTracks(),fVZEevent->GetNumberOfRPs(),fVZEevent->GetNumberOfPOIs());\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::PushBackFlowTrack(AliFlowEvent *flowevent, Double_t pt, Double_t phi, Double_t eta, Double_t w, Int_t id) {\r
-  AliFlowTrack rfp;\r
-  rfp.SetPt(pt);\r
-  rfp.SetPhi(phi);\r
-  rfp.SetEta(eta);\r
-  rfp.SetWeight(w);\r
-  rfp.SetForRPSelection(kTRUE);\r
-  rfp.SetForPOISelection(kFALSE);\r
-  rfp.SetID(id);\r
-  flowevent->InsertTrack( &rfp );\r
-}\r
-//=======================================================================\r
-Bool_t AliAnalysisTaskFlowStrange::IsAtTPCEdge(Double_t phi,Double_t pt,Int_t charge,Double_t b) {\r
-  // Origin: Alex Dobrin\r
-  // Implemented by Carlos Perez\r
-  TF1 cutLo("cutLo", "-0.01/x+pi/18.0-0.015", 0, 100);\r
-  TF1 cutHi("cutHi", "0.55/x/x+pi/18.0+0.03", 0, 100);\r
-  Double_t phimod = phi;\r
-  if(b<0) phimod = TMath::TwoPi()-phimod;  //for negatve polarity field\r
-  if(charge<0) phimod = TMath::TwoPi()-phimod; //for negatve charge\r
-  phimod += TMath::Pi()/18.0;\r
-  phimod = fmod(phimod, TMath::Pi()/9.0);\r
-  if( phimod<cutHi.Eval(pt) && phimod>cutLo.Eval(pt) )\r
-    return kTRUE;\r
-\r
-  return kFALSE;\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::MakeQVectors() {\r
-  //computes event plane and updates fPsi2\r
-  //if there is a problem fPsi->-1\r
-  fPsi2=-1;\r
-  Double_t vzeqax, vzeqay, vzeqaw, vzeqbx, vzeqby, vzeqbw;\r
-  Double_t tpcqax, tpcqay, tpcqaw, tpcqbx, tpcqby, tpcqbw;\r
-  //=>loading event\r
-  MakeQVZE(InputEvent(),vzeqax,vzeqay,vzeqaw,vzeqbx,vzeqby,vzeqbw);\r
-  MakeQTPC(InputEvent(),tpcqax,tpcqay,tpcqaw,tpcqbx,tpcqby,tpcqbw);\r
-  //=>computing psi\r
-  //VZERO\r
-  Double_t vqx, vqy;\r
-  vqx=vqy=0;\r
-  Double_t psivzea,psivzeb,psivze,vzew;\r
-  psivzea = ( TMath::Pi()+TMath::ATan2(-vzeqay,-vzeqax) )/2.0;\r
-  psivzeb = ( TMath::Pi()+TMath::ATan2(-vzeqby,-vzeqbx) )/2.0;\r
-  vqx = vzeqax + vzeqbx;\r
-  vqy = vzeqay + vzeqby;\r
-  vzew = vzeqaw + vzeqbw;\r
-  psivze = ( TMath::Pi()+TMath::ATan2(-vqy,-vqx) )/2.0;\r
-  //TPC\r
-  Double_t tqx, tqy;\r
-  tqx=tqy=0;\r
-  Double_t psitpca,psitpcb,psitpc,tpcw;\r
-  psitpca = ( TMath::Pi()+TMath::ATan2(-tpcqay,-tpcqax) )/2.0;\r
-  psitpcb = ( TMath::Pi()+TMath::ATan2(-tpcqby,-tpcqbx) )/2.0;\r
-  tqx = tpcqax + tpcqbx;\r
-  tqy = tpcqay + tpcqby;\r
-  tpcw = tpcqaw + tpcqbw;\r
-  psitpc = ( TMath::Pi()+TMath::ATan2(-tqy,-tqx) )/2.0;\r
-  //=>does the event clear?\r
-  switch(fWhichPsi) {\r
-  case(1): //VZERO\r
-    if( (vzeqaw<2)||(vzeqbw<2) ) return;\r
-    fPsi2 = psivze;\r
-    break;\r
-  case(2): //TPC\r
-    if( (tpcqaw<2)||(tpcqbw<2) ) return;\r
-    fPsi2 = psitpc;\r
-    break;\r
-  }\r
-  //=>great! recording\r
-  ((TH1D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("VZEPSI"))->Fill( psivze );\r
-  ((TH1D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("VZEPSIA"))->Fill( psivzea );\r
-  ((TH1D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("VZEPSIB"))->Fill( psivzeb );\r
-  ((TH1D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("RFPVZE"))->Fill( vzew );\r
-  //------\r
-  ((TH1D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCPSI"))->Fill( psitpc );\r
-  ((TH1D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCPSIA"))->Fill( psitpca );\r
-  ((TH1D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCPSIB"))->Fill( psitpcb );\r
-  ((TH1D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("RFPTPC"))->Fill( tpcw );\r
-  //------\r
-  ((TProfile*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCQ"))->Fill( 1., tpcqay/tpcqaw, tpcqaw );\r
-  ((TProfile*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCQ"))->Fill( 2., tpcqax/tpcqaw, tpcqaw );\r
-  ((TProfile*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCQ"))->Fill( 3., tpcqby/tpcqbw, tpcqbw );\r
-  ((TProfile*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCQ"))->Fill( 4., tpcqbx/tpcqbw, tpcqbw );\r
-  ((TProfile*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCQ"))->Fill( 5., tqy/tpcw, tpcw );\r
-  ((TProfile*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCQ"))->Fill( 6., tqx/tpcw, tpcw );\r
-  //------\r
-  ((TProfile*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("VZEQ"))->Fill( 1., vzeqay/vzeqaw, vzeqaw );\r
-  ((TProfile*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("VZEQ"))->Fill( 2., vzeqax/vzeqaw, vzeqaw );\r
-  ((TProfile*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("VZEQ"))->Fill( 3., vzeqby/vzeqbw, vzeqbw );\r
-  ((TProfile*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("VZEQ"))->Fill( 4., vzeqbx/vzeqbw, vzeqbw );\r
-  ((TProfile*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("VZEQ"))->Fill( 5., vqy/vzew, vzew );\r
-  ((TProfile*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("VZEQ"))->Fill( 6., vqx/vzew, vzew );\r
-\r
-  return;\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::MakeQVZE(AliVEvent *tevent,\r
-                                          Double_t &qxa,Double_t &qya,Double_t &qwa,\r
-                                          Double_t &qxb,Double_t &qyb,Double_t &qwb) {\r
-  //=>cleaning\r
-  if(fUseFP) fVZEevent->ClearFast();\r
-  //=>external weights\r
-  Double_t extW[64];\r
-  for(int i=0;i!=64;++i) extW[i]=1;\r
-  if((!fVZEsave)&&(fVZEResponse)) {\r
-    Double_t minC = fCentPerMin, maxC = fCentPerMax;\r
-    if(fVZEmb) {\r
-      minC = 0;\r
-      maxC = 80;\r
-    }\r
-    Int_t ybinmin = fVZEResponse->GetYaxis()->FindBin(minC+1e-6);\r
-    Int_t ybinmax = fVZEResponse->GetYaxis()->FindBin(maxC-1e-6);\r
-    for(int i=0;i!=64;++i) extW[i] = fVZEResponse->Integral(i+1,i+1,ybinmin,ybinmax)/(maxC-minC);\r
-    //ring-wise normalization\r
-    Double_t ring[8];\r
-    for(int j=0; j!=8; ++j) {\r
-      ring[j]=0;\r
-      for(int i=0;i!=8;++i) ring[j] += extW[j*8+i]/8;\r
-    }\r
-    //disk-wise normalization\r
-    Double_t disk[2];\r
-    int xbinmin, xbinmax;\r
-    xbinmin = 1+8*fVZECa;\r
-    xbinmax = 8+8*fVZECb;\r
-    disk[0] = fVZEResponse->Integral(xbinmin,xbinmax,ybinmin,ybinmax)/(maxC-minC)/(xbinmax-xbinmin+1);\r
-    xbinmin = 33+8*fVZEAa;\r
-    xbinmax = 40+8*fVZEAb;\r
-    disk[1] = fVZEResponse->Integral(xbinmin,xbinmax,ybinmin,ybinmax)/(maxC-minC)/(xbinmax-xbinmin+1);\r
-    //for(int i=0;i!=64;++i) printf("CELL %d -> W = %f ||",i,extW[i]);\r
-\r
-    if(fVZEByDisk) {\r
-      for(int i=0;i!=64;++i) extW[i] = disk[i/32]/extW[i];\r
-    } else {\r
-      for(int i=0;i!=64;++i) extW[i] = ring[i/8]/extW[i];\r
-    }\r
-    //for(int i=0;i!=64;++i) printf(" W = %f \n",extW[i]);\r
-  }\r
-  //=>computing\r
-  qxa=qya=qwa=qxb=qyb=qwb=0;\r
-  Int_t rfp=0;\r
-  Double_t eta, phi, w;\r
-  //v0c -> qa\r
-  for(int id=fVZECa*8;id!=8+fVZECb*8;++id) {\r
-    eta = -3.45+0.5*(id/8);\r
-    phi = TMath::PiOver4()*(0.5+id%8);\r
-    w = tevent->GetVZEROEqMultiplicity(id)*extW[id];\r
-    qxa += w*TMath::Cos(2*phi);\r
-    qya += w*TMath::Sin(2*phi);\r
-    qwa += w;\r
-    ((TH2D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("VZEAllPhiEta"))->Fill( phi, eta, w );\r
-    rfp++;\r
-    if(fUseFP) PushBackFlowTrack(fVZEevent,0,phi,eta,w,0);\r
-  }\r
-  //v0a -> qb\r
-  for(int id=32+fVZEAa*8;id!=40+fVZEAb*8;++id) {\r
-    eta = +4.8-0.6*((id/8)-4);\r
-    phi = TMath::PiOver4()*(0.5+id%8);\r
-    w = tevent->GetVZEROEqMultiplicity(id)*extW[id];\r
-    qxb += w*TMath::Cos(2*phi);\r
-    qyb += w*TMath::Sin(2*phi);\r
-    qwb += w;\r
-    ((TH2D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("VZEAllPhiEta"))->Fill( phi, eta, w );\r
-    rfp++;\r
-    if(fUseFP) PushBackFlowTrack(fVZEevent,0,phi,eta,w,0);\r
-  }\r
-  if(fUseFP) fVZEevent->SetNumberOfRPs(rfp);\r
-  if(fDebug>0&&fUseFP) printf("Inserted tracks in FlowEventVZE %d ==> %.1f\n",fVZEevent->NumberOfTracks(),qwa+qwb);\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::AddTPCRFPSpy(TList *me) {\r
-  TH1D *tH1D;\r
-  tH1D = new TH1D("PT",   "PT",           50,0,5);     me->Add(tH1D);\r
-  tH1D = new TH1D("PHI",  "PHI", 90,0,TMath::TwoPi()); me->Add(tH1D);\r
-  tH1D = new TH1D("ETA",  "ETA",          40,-1,+1);   me->Add(tH1D);\r
-  tH1D = new TH1D("TPCS", "TPC Signal",   100,0,500);  me->Add(tH1D);\r
-  tH1D = new TH1D("IPXY", "IPXY",         100,-2,+2);  me->Add(tH1D);\r
-  tH1D = new TH1D("IPZ",  "IPZ",          100,-2,+2);  me->Add(tH1D);\r
-  // TPC\r
-  tH1D = new TH1D("TPCNCLS", "NCLS", 170,-0.5,+169.5);   me->Add(tH1D);\r
-  tH1D = new TH1D("TPCSHCL", "NSCLS / NCLS", 100,0,1);   me->Add(tH1D);\r
-  tH1D = new TH1D("TPCFICL", "NCLS1I / NCLS",100,0,1);   me->Add(tH1D);\r
-  tH1D = new TH1D("TPCXRNF", "XROW / NFCLS", 100,0,1.5); me->Add(tH1D);\r
-  tH1D = new TH1D("TPCRCHI", "CHI2 / NCLS",  50,0,5);    me->Add(tH1D);\r
-  // ITS\r
-  tH1D = new TH1D("ITSNCLS", "NCLS",   7,-0.5,+6.5); me->Add(tH1D);\r
-  tH1D = new TH1D("ITSRCHI", "CHI2 / NCLS", 50,0,5); me->Add(tH1D);\r
-\r
-}\r
-//=======================================================================\r
-Bool_t AliAnalysisTaskFlowStrange::PassesRFPTPCCuts(AliESDtrack *track, Double_t aodchi2cls, Float_t aodipxy, Float_t aodipz) {\r
-  if(track->GetKinkIndex(0)>0) return kFALSE;\r
-  if( (track->GetStatus()&AliESDtrack::kTPCrefit)==0 ) return kFALSE;\r
-  Double_t pt = track->Pt();\r
-  Double_t phi = track->Phi();\r
-  Double_t eta = track->Eta();\r
-  Double_t tpcs = track->GetTPCsignal();\r
-  Float_t ipxy, ipz;\r
-  track->GetImpactParameters(ipxy,ipz);\r
-  Int_t cls = track->GetTPCclusters(0);\r
-  Double_t xrows, findcls, chi2;\r
-  findcls = track->GetTPCNclsF();\r
-  xrows = track->GetTPCCrossedRows();\r
-  chi2 = track->GetTPCchi2();\r
-  Double_t rchi2 = chi2/cls;\r
-  if(!fReadESD) {\r
-    rchi2 = aodchi2cls;\r
-    ipxy = aodipxy;\r
-    ipz = aodipz;\r
-  }\r
-  Double_t xrnfcls = xrows/findcls;\r
-  Double_t scls, cls1i, itschi2;\r
-  Int_t itscls;\r
-  cls1i = track->GetTPCNclsIter1();\r
-  scls = track->GetTPCnclsS();\r
-  itscls = track->GetITSclusters(0);\r
-  itschi2 = track->GetITSchi2();\r
-  Double_t shcl = scls/cls;\r
-  Double_t ficl = cls1i/cls;\r
-  Double_t itsrchi2 = itscls/itschi2;\r
-  ((TH1D*)((TList*)fList->FindObject("TPCRFPall"))->FindObject("PT"))->Fill( pt );\r
-  ((TH1D*)((TList*)fList->FindObject("TPCRFPall"))->FindObject("PHI"))->Fill( phi );\r
-  ((TH1D*)((TList*)fList->FindObject("TPCRFPall"))->FindObject("ETA"))->Fill( eta );\r
-  ((TH1D*)((TList*)fList->FindObject("TPCRFPall"))->FindObject("TPCS"))->Fill( tpcs );\r
-  ((TH1D*)((TList*)fList->FindObject("TPCRFPall"))->FindObject("IPXY"))->Fill( ipxy );\r
-  ((TH1D*)((TList*)fList->FindObject("TPCRFPall"))->FindObject("IPZ"))->Fill( ipz );\r
-  ((TH1D*)((TList*)fList->FindObject("TPCRFPall"))->FindObject("TPCNCLS"))->Fill( cls );\r
-  ((TH1D*)((TList*)fList->FindObject("TPCRFPall"))->FindObject("TPCSHCL"))->Fill( shcl );\r
-  ((TH1D*)((TList*)fList->FindObject("TPCRFPall"))->FindObject("TPCFICL"))->Fill( ficl );\r
-  ((TH1D*)((TList*)fList->FindObject("TPCRFPall"))->FindObject("TPCXRNF"))->Fill( xrnfcls );\r
-  ((TH1D*)((TList*)fList->FindObject("TPCRFPall"))->FindObject("TPCRCHI"))->Fill( rchi2 );\r
-  ((TH1D*)((TList*)fList->FindObject("TPCRFPall"))->FindObject("ITSNCLS"))->Fill( itscls );\r
-  ((TH1D*)((TList*)fList->FindObject("TPCRFPall"))->FindObject("ITSRCHI"))->Fill( itsrchi2 );\r
-  if(pt<fRFPminPt) return kFALSE; //0.2\r
-  if(pt>fRFPmaxPt) return kFALSE; //5.0\r
-  if(eta<fRFPminEta) return kFALSE; //-0.8\r
-  if(eta>fRFPmaxEta) return kFALSE; //+0.8\r
-  if(tpcs<fRFPTPCsignal) return kFALSE; //10.0\r
-  if( TMath::Sqrt(ipxy*ipxy/fRFPmaxIPxy/fRFPmaxIPxy+ipz*ipz/fRFPmaxIPz/fRFPmaxIPz)>1 ) return kFALSE; //2.4 3.2\r
-  if(cls<fRFPTPCncls) return kFALSE; //70\r
-  ((TH1D*)((TList*)fList->FindObject("TPCRFPsel"))->FindObject("PT"))->Fill( pt );\r
-  ((TH1D*)((TList*)fList->FindObject("TPCRFPsel"))->FindObject("PHI"))->Fill( phi );\r
-  ((TH1D*)((TList*)fList->FindObject("TPCRFPsel"))->FindObject("ETA"))->Fill( eta );\r
-  ((TH1D*)((TList*)fList->FindObject("TPCRFPsel"))->FindObject("TPCS"))->Fill( tpcs );\r
-  ((TH1D*)((TList*)fList->FindObject("TPCRFPsel"))->FindObject("IPXY"))->Fill( ipxy );\r
-  ((TH1D*)((TList*)fList->FindObject("TPCRFPsel"))->FindObject("IPZ"))->Fill( ipz );\r
-  ((TH1D*)((TList*)fList->FindObject("TPCRFPsel"))->FindObject("TPCNCLS"))->Fill( cls );\r
-  ((TH1D*)((TList*)fList->FindObject("TPCRFPsel"))->FindObject("TPCSHCL"))->Fill( shcl );\r
-  ((TH1D*)((TList*)fList->FindObject("TPCRFPsel"))->FindObject("TPCFICL"))->Fill( ficl );\r
-  ((TH1D*)((TList*)fList->FindObject("TPCRFPsel"))->FindObject("TPCXRNF"))->Fill( xrnfcls );\r
-  ((TH1D*)((TList*)fList->FindObject("TPCRFPsel"))->FindObject("TPCRCHI"))->Fill( rchi2 );\r
-  ((TH1D*)((TList*)fList->FindObject("TPCRFPsel"))->FindObject("ITSNCLS"))->Fill( itscls );\r
-  ((TH1D*)((TList*)fList->FindObject("TPCRFPsel"))->FindObject("ITSRCHI"))->Fill( itsrchi2 );\r
-  return kTRUE;\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::MakeQTPC(AliVEvent *tevent,\r
-                                          Double_t &qxa,Double_t &qya,Double_t &qwa,\r
-                                          Double_t &qxb,Double_t &qyb,Double_t &qwb) {\r
-  AliESDEvent *tESD = (AliESDEvent*) (tevent);\r
-  AliAODEvent *tAOD = (AliAODEvent*) (tevent);\r
-  if(fReadESD) {\r
-    if(!tESD) return;\r
-    MakeQTPC(tESD,qxa,qya,qwa,qxb,qyb,qwb);\r
-  } else {\r
-    if(!tAOD) return;\r
-    MakeQTPC(tAOD,qxa,qya,qwa,qxb,qyb,qwb);\r
-  }\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::MakeQTPC(AliAODEvent *tAOD,\r
-                                          Double_t &qxa,Double_t &qya,Double_t &qwa,\r
-                                          Double_t &qxb,Double_t &qyb,Double_t &qwb) {\r
-  //=>cleaning\r
-  if(fUseFP) fTPCevent->ClearFast();\r
-  qxa=qya=qwa=qxb=qyb=qwb=0;\r
-  Int_t rfp=0;\r
-  Double_t eta, phi, w;\r
-  //=>aod stuff\r
-  AliAODVertex *vtx = tAOD->GetPrimaryVertex();\r
-  Double_t pos[3],cov[6];\r
-  vtx->GetXYZ(pos);\r
-  vtx->GetCovarianceMatrix(cov);\r
-  const AliESDVertex vESD(pos,cov,100.,100);\r
-  AliAODTrack *track;\r
-  //=>looping\r
-  Int_t rawN = tAOD->GetNumberOfTracks();\r
-  for(Int_t id=0; id!=rawN; ++id) {\r
-    track = tAOD->GetTrack(id);\r
-    //=>cuts\r
-    if(!track->TestFilterBit(fRFPFilterBit)) continue;\r
-    if( fExcludeTPCEdges )\r
-      if( IsAtTPCEdge( track->Phi(), track->Pt(), track->Charge(), tAOD->GetMagneticField() ) )        continue;\r
-    AliESDtrack etrack( track );\r
-    etrack.SetTPCClusterMap( track->GetTPCClusterMap() );\r
-    etrack.SetTPCSharedMap( track->GetTPCSharedMap() );\r
-    etrack.SetTPCPointsF( track->GetTPCNclsF() );\r
-    Float_t ip[2];\r
-    etrack.GetDZ(pos[0], pos[1], pos[2], tAOD->GetMagneticField(), ip);\r
-    if(!PassesRFPTPCCuts(&etrack,track->Chi2perNDF(),ip[0],ip[1])) continue;\r
-    //=>collecting info\r
-    phi = track->Phi();\r
-    eta = track->Eta();\r
-    w = 1;\r
-    //=>subevents\r
-    if(eta<0) {\r
-      qxa += w*TMath::Cos(2*phi);\r
-      qya += w*TMath::Sin(2*phi);\r
-      qwa += w;\r
-    } else {\r
-      qxb += w*TMath::Cos(2*phi);\r
-      qyb += w*TMath::Sin(2*phi);\r
-      qwb += w;\r
-    }\r
-    ((TH2D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCAllPhiEta"))->Fill( phi, eta, w );\r
-    rfp++;\r
-    if(fUseFP) PushBackFlowTrack(fTPCevent,track->Pt(),phi,eta,w,track->GetID());\r
-  }\r
-  if(fUseFP) fTPCevent->SetNumberOfRPs(rfp);\r
-  if(fDebug) printf("Inserted tracks in FlowEventTPC %d ==> %.1f\n",fTPCevent->NumberOfTracks(),qwa+qwb);\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::MakeQTPC(AliESDEvent *tESD,\r
-                                          Double_t &qxa,Double_t &qya,Double_t &qwa,\r
-                                          Double_t &qxb,Double_t &qyb,Double_t &qwb) {\r
-  //=>cleaning\r
-  if(fUseFP) fTPCevent->ClearFast();\r
-  qxa=qya=qwa=qxb=qyb=qwb=0;\r
-  Int_t rfp=0;\r
-  Double_t eta, phi, w;\r
-  //=>looping\r
-  AliESDtrack *track;\r
-  Int_t rawN = tESD->GetNumberOfTracks();\r
-  for(Int_t id=0; id!=rawN; ++id) {\r
-    track = tESD->GetTrack(id);\r
-    //=>cuts\r
-    if( fExcludeTPCEdges )\r
-      if( IsAtTPCEdge( track->Phi(), track->Pt(), track->Charge(), tESD->GetMagneticField() ) )        continue;\r
-    if(!PassesFilterBit(track)) continue;\r
-    if(!PassesRFPTPCCuts(track)) continue;\r
-    //=>collecting info\r
-    phi = track->Phi();\r
-    eta = track->Eta();\r
-    w = 1;\r
-    //=>subevents\r
-    if(eta<0) {\r
-      qxa += w*TMath::Cos(2*phi);\r
-      qya += w*TMath::Sin(2*phi);\r
-      qwa += w;\r
-    } else {\r
-      qxb += w*TMath::Cos(2*phi);\r
-      qyb += w*TMath::Sin(2*phi);\r
-      qwb += w;\r
-    }\r
-    ((TH2D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCAllPhiEta"))->Fill( phi, eta, w );\r
-    rfp++;\r
-    if(fUseFP) PushBackFlowTrack(fTPCevent,track->Pt(),phi,eta,w,track->GetID());\r
-  }\r
-  if(fUseFP) fTPCevent->SetNumberOfRPs(rfp);\r
-  if(fDebug) printf("Inserted tracks in FlowEventTPC %d ==> %.1f\n",fTPCevent->NumberOfTracks(),qwa+qwb);\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::AddMCParticleSpy(TList *me) {\r
-  TH1D *tH1D;\r
-  TH2D *tH2D;\r
-  tH1D = new TH1D("Pt",   "Pt",   100,0.0,20);  me->Add(tH1D);\r
-  tH1D = new TH1D("Phi",  "Phi",  100,0,TMath::TwoPi()); me->Add(tH1D);\r
-  tH1D = new TH1D("Eta",  "Eta",  100,-1,+1);   me->Add(tH1D);\r
-  tH1D = new TH1D("Rad2", "Rad2", 1000,0,+100); me->Add(tH1D);\r
-  tH2D = new TH2D("Dphi", "phi-MCEP;pt;dphi",100,0,20, 72,0,TMath::Pi()); me->Add(tH2D);\r
-  return;\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::FillMCParticleSpy(TString listName, AliAODMCParticle *p) {\r
-  ((TH1D*)((TList*)fList->FindObject(listName.Data()))->FindObject("Pt" ))->Fill( p->Pt() );\r
-  ((TH1D*)((TList*)fList->FindObject(listName.Data()))->FindObject("Eta" ))->Fill( p->Eta() );\r
-  ((TH1D*)((TList*)fList->FindObject(listName.Data()))->FindObject("Phi" ))->Fill( p->Phi() );\r
-  ((TH1D*)((TList*)fList->FindObject(listName.Data()))->FindObject("Rad2" ))->Fill( TMath::Sqrt( p->Xv()*p->Xv() +\r
-                                                                                                p->Yv()*p->Yv() ) );\r
-  ((TH1D*)((TList*)fList->FindObject(listName.Data()))->FindObject("Dphi" ))->Fill( p->Pt(), GetMCDPHI(p->Phi()) );\r
-  return;\r
-}\r
-//=======================================================================\r
-Double_t AliAnalysisTaskFlowStrange::GetMCDPHI(Double_t phi) {\r
-  Double_t dDPHI = phi - fMCEP;\r
-  if( dDPHI < 0 ) dDPHI += TMath::TwoPi();\r
-  if( dDPHI > TMath::Pi() ) dDPHI = TMath::TwoPi()-dDPHI;\r
-  return dDPHI;\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::FillMCParticleSpy(TString listName, TParticle *p) {\r
-  ((TH1D*)((TList*)fList->FindObject(listName.Data()))->FindObject("Pt" ))->Fill( p->Pt() );\r
-  ((TH1D*)((TList*)fList->FindObject(listName.Data()))->FindObject("Eta" ))->Fill( p->Eta() );\r
-  ((TH1D*)((TList*)fList->FindObject(listName.Data()))->FindObject("Phi" ))->Fill( p->Phi() );\r
-  ((TH1D*)((TList*)fList->FindObject(listName.Data()))->FindObject("Rad2" ))->Fill( TMath::Sqrt( p->Vx()*p->Vx() +\r
-                                                                                                p->Vy()*p->Vy() ) );\r
-  return;\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::AddCandidatesSpy(TList *me) {\r
-  TH2D *tH2D;\r
-  tH2D = new TH2D("PhiEta",  "PhiEta;Phi;Eta", 100,0,TMath::TwoPi(),100,-1,+1); me->Add(tH2D);\r
-  tH2D = new TH2D("PtRAP",   "PtRAP;Pt;Y",          100,0,20,100,-2.0,+2.0);  me->Add(tH2D);\r
-  tH2D = new TH2D("PtDCA",   "PtDCA;Pt;DCA",        100,0,20,100,0,10);       me->Add(tH2D);\r
-  tH2D = new TH2D("PtCTP",   "PtCTP;Pt;CTP",        100,0,20,100,-1,+1);      me->Add(tH2D);\r
-  //tH2D = new TH2D("PtCTP",   "PtCTP;Pt;CTP",        100,0,10,100,0.90,+1);    me->Add(tH2D);\r
-  tH2D = new TH2D("PtD0D0",  "PtD0D0;Pt;D0D0",      100,0,20,100,-5,+5);      me->Add(tH2D);\r
-  tH2D = new TH2D("PtRad2",  "PtRad2;Pt;RadXY",     100,0,20,100,0,+50);      me->Add(tH2D);\r
-  tH2D = new TH2D("PtDL",    "PtDL;Pt;DL",          100,0,20,100,0,+50);      me->Add(tH2D);\r
-  tH2D = new TH2D("PtMASS",  "PtMASS;Pt;MASS", 100,0,20,fMassBins,fMinMass,fMaxMass); me->Add(tH2D);\r
-  tH2D = new TH2D("APPOS",   "APPOS;alphaPOS;QtPOS",100,-2,+2,100,0,0.3);     me->Add(tH2D);\r
-  tH2D = new TH2D("D0PD0N",  "D0PD0N;D0P;D0N",      200,-10,+10,200,-10,+10); me->Add(tH2D);\r
-  tH2D = new TH2D("XPOSXNEG","XPOSXNEG;XPOS;XNEG",  200,-50,+50,200,-50,+50); me->Add(tH2D);\r
-  tH2D = new TH2D("PTDPHIMC","PtDPHIMC;Pt;PHI-MCEP",100,0,20,72,0,TMath::Pi()); me->Add(tH2D);\r
-  return;\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::FillCandidateSpy(TString listName) {\r
-  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PhiEta"))->Fill( fDecayPhi, fDecayEta );\r
-  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PtRAP" ))->Fill( fDecayPt, fDecayRapidity );\r
-  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PtDCA" ))->Fill( fDecayPt, fDecayDCAdaughters );\r
-  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PtCTP" ))->Fill( fDecayPt, fDecayCosinePointingAngleXY );\r
-  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PtD0D0"))->Fill( fDecayPt, fDecayProductIPXY );\r
-  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PtRad2"))->Fill( fDecayPt, fDecayRadXY );\r
-  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PtDL"  ))->Fill( fDecayPt, fDecayDecayLength );\r
-  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PtMASS"))->Fill( fDecayPt, fDecayMass );\r
-  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("APPOS" ))->Fill( fDecayAlpha, fDecayQt );\r
-  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PTDPHIMC" ))->Fill( fDecayPt, GetMCDPHI( fDecayPhi ) );\r
-}\r
-//=======================================================================\r
-Bool_t AliAnalysisTaskFlowStrange::AcceptCandidate() {\r
-  if(fDecayEta<fDecayMinEta) return kFALSE;\r
-  if(fDecayEta>fDecayMaxEta) return kFALSE;\r
-  if(fDecayPt<fDecayMinPt) return kFALSE;\r
-  if(fDecayProductIPXY>fDecayMaxProductIPXY) return kFALSE;\r
-  if(fDecayDCAdaughters>fDecayMaxDCAdaughters) return kFALSE;\r
-  if(fDecayCosinePointingAngleXY<fDecayMinCosinePointingAngleXY) return kFALSE;\r
-  if(fDecayRadXY<fDecayMinRadXY) return kFALSE;\r
-  if(fDecayDecayLength>fDecayMaxDecayLength*2.6842) return kFALSE;\r
-  if(TMath::Abs(fDecayRapidity)>fDecayMaxRapidity) return kFALSE;\r
-  if(fSpecie==0) {\r
-    if(fDecayAPCutPie) {\r
-      if(fDecayQt/TMath::Abs(fDecayAlpha)<fDecayMinQt) return kFALSE;\r
-    } else {\r
-      if(fDecayQt<fDecayMinQt) return kFALSE;\r
-    }\r
-  }\r
-  if(fSpecie==1) if(fDecayAlpha>0) return kFALSE;\r
-  if(fSpecie==2) if(fDecayAlpha<0) return kFALSE;\r
-  return kTRUE;\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::AddTracksSpy(TList *me) {\r
-  TH2D *tH2D;\r
-  tH2D = new TH2D("PHIETA",       "PHIETA;PHI;ETA",               100,0,TMath::TwoPi(),100,-2,2); me->Add(tH2D);\r
-  tH2D = new TH2D("IPXYIPZ",      "IPXYIPZ;IPXY;IPZ",             1000,-20,+20,1000,-20,+20); me->Add(tH2D);\r
-  tH2D = new TH2D("PTTPCNCLS",    "PTTPCNCLS;PT;NCLS",            100,0,20,170,0,170);  me->Add(tH2D);\r
-  tH2D = new TH2D("POSTPCNCLCHI2","POSTPCNCLCHI2;NCLS;CHI2/NCLS", 170,0,170,100,0,8);   me->Add(tH2D);\r
-  tH2D = new TH2D("POSTPCNFCLNXR","POSTPCNFCLNXR;NFCLS;NXR",      170,0,170,170,0,170); me->Add(tH2D);\r
-  tH2D = new TH2D("POSTPCNCLNFCL","POSTPCNCLNFCL;NCLS;NFCLS",     170,0,170,170,0,170); me->Add(tH2D);\r
-  tH2D = new TH2D("POSTPCNCLNSCL","POSTPCNCLNSCL;NCLS;NSCLS",     170,0,170,170,0,170); me->Add(tH2D);\r
-  tH2D = new TH2D("NEGTPCNCLCHI2","NEGTPCNCLCHI2;NCLS;CHI2/NCLS", 170,0,170,100,0,8);   me->Add(tH2D);\r
-  tH2D = new TH2D("NEGTPCNFCLNXR","NEGTPCNFCLNXR;NFCLS;NXR",      170,0,170,170,0,170); me->Add(tH2D);\r
-  tH2D = new TH2D("NEGTPCNCLNFCL","NEGTPCNCLNFCL;NCLS;NFCLS",     170,0,170,170,0,170); me->Add(tH2D);\r
-  tH2D = new TH2D("NEGTPCNCLNSCL","NEGTPCNCLNSCL;NCLS;NSCLS",     170,0,170,170,0,170); me->Add(tH2D);\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::FillTrackSpy(TString listName) {\r
-  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( "PHIETA" ))->Fill( fDaughterPhi, fDaughterEta );\r
-  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( "IPXYIPZ" ))->Fill( fDaughterImpactParameterXY, fDaughterImpactParameterZ );\r
-  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( "PTTPCNCLS" ))->Fill( fDaughterPt, fDaughterNClsTPC );\r
-  TString ch="NEG";\r
-  if(fDaughterCharge>0) ch="POS";\r
-  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( Form("%sTPCNCLCHI2",ch.Data()) ))->Fill( fDaughterNClsTPC, fDaughterChi2PerNClsTPC );\r
-  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( Form("%sTPCNFCLNXR",ch.Data()) ))->Fill( fDaughterNFClsTPC, fDaughterXRows );\r
-  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( Form("%sTPCNCLNFCL",ch.Data()) ))->Fill( fDaughterNClsTPC, fDaughterNFClsTPC );\r
-  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( Form("%sTPCNCLNSCL",ch.Data()) ))->Fill( fDaughterNClsTPC, fDaughterNSClsTPC );\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::LoadTrack(AliESDtrack *myTrack, Double_t aodChi2NDF) {\r
-  fDaughterCharge = myTrack->Charge();\r
-  fDaughterXRows = myTrack->GetTPCCrossedRows();\r
-  fDaughterNFClsTPC = myTrack->GetTPCNclsF();\r
-  fDaughterNSClsTPC = myTrack->GetTPCnclsS();\r
-  fDaughterNClsTPC = myTrack->GetTPCclusters(0);\r
-  if(fReadESD) {\r
-    if(fDaughterNClsTPC>0) fDaughterChi2PerNClsTPC = myTrack->GetTPCchi2()/fDaughterNClsTPC;\r
-  } else {\r
-    fDaughterChi2PerNClsTPC = aodChi2NDF;\r
-  }\r
-  myTrack->GetImpactParameters(fDaughterImpactParameterXY,fDaughterImpactParameterZ);\r
-  fDaughterStatus = myTrack->GetStatus();\r
-  fDaughterPhi = myTrack->Phi();\r
-  fDaughterEta = myTrack->Eta();\r
-  fDaughterPt = myTrack->Pt();\r
-  fDaughterKinkIndex = myTrack->GetKinkIndex(0);\r
-}\r
-//=======================================================================\r
-Bool_t AliAnalysisTaskFlowStrange::AcceptDaughter() {\r
-  if(fDaughterKinkIndex>0) return kFALSE;\r
-  if( (fDaughterStatus&AliESDtrack::kTPCrefit)==0 ) return kFALSE;\r
-  if(fDaughterNFClsTPC<1) return kFALSE;\r
-  if(fDaughterPt<fDaughterMinPt) return kFALSE;\r
-  if(fDaughterEta<fDaughterMinEta) return kFALSE;\r
-  if(fDaughterEta>fDaughterMaxEta) return kFALSE;\r
-  if(fDaughterNClsTPC<fDaughterMinNClsTPC) return kFALSE;\r
-  if(fDaughterXRows<fDaughterMinXRows) return kFALSE;\r
-  if(fDaughterChi2PerNClsTPC>fDaughterMaxChi2PerNClsTPC) return kFALSE;\r
-  if(TMath::Abs(fDaughterImpactParameterXY)<fDaughterMinImpactParameterXY) return kFALSE;\r
-  if(fDaughterXRows<fDaughterMinXRowsOverNClsFTPC*fDaughterNFClsTPC) return kFALSE;\r
-  return kTRUE;\r
-}\r
-//=======================================================================\r
-Double_t AliAnalysisTaskFlowStrange::GetWDist(const AliVVertex* v0, const AliVVertex* v1) {\r
-  // calculate sqrt of weighted distance to other vertex\r
-  if (!v0 || !v1) {\r
-    printf("One of vertices is not valid\n");\r
-    return 0;\r
-  }\r
-  static TMatrixDSym vVb(3);\r
-  double dist = -1;\r
-  double dx = v0->GetX()-v1->GetX();\r
-  double dy = v0->GetY()-v1->GetY();\r
-  double dz = v0->GetZ()-v1->GetZ();\r
-  double cov0[6],cov1[6];\r
-  v0->GetCovarianceMatrix(cov0);\r
-  v1->GetCovarianceMatrix(cov1);\r
-  vVb(0,0) = cov0[0]+cov1[0];\r
-  vVb(1,1) = cov0[2]+cov1[2];\r
-  vVb(2,2) = cov0[5]+cov1[5];\r
-  vVb(1,0) = vVb(0,1) = cov0[1]+cov1[1];\r
-  vVb(0,2) = vVb(1,2) = vVb(2,0) = vVb(2,1) = 0.;\r
-  vVb.InvertFast();\r
-  if (!vVb.IsValid()) {printf("Singular Matrix\n"); return dist;}\r
-  dist = vVb(0,0)*dx*dx + vVb(1,1)*dy*dy + vVb(2,2)*dz*dz\r
-    +    2*vVb(0,1)*dx*dy + 2*vVb(0,2)*dx*dz + 2*vVb(1,2)*dy*dz;\r
-  return dist>0 ? TMath::Sqrt(dist) : -1;\r
-}\r
-//=======================================================================\r
-Bool_t AliAnalysisTaskFlowStrange::plpMV(const AliVEvent *event) {\r
-  // check for multi-vertexer pile-up\r
-  const AliAODEvent *aod = (const AliAODEvent*)event;\r
-  const AliESDEvent *esd = (const AliESDEvent*)event;\r
-  //\r
-  const int    kMinPlpContrib = 5;\r
-  const double kMaxPlpChi2 = 5.0;\r
-  const double kMinWDist = 15;\r
-  //\r
-  if (!aod && !esd) {\r
-    printf("Event is neither of AOD nor ESD\n");\r
-    exit(1);\r
-  }\r
-  //\r
-  const AliVVertex* vtPrm = 0;\r
-  const AliVVertex* vtPlp = 0;\r
-  int nPlp = 0;\r
-  //\r
-  if (aod) {\r
-    if ( !(nPlp=aod->GetNumberOfPileupVerticesTracks()) ) return kFALSE;\r
-    vtPrm = aod->GetPrimaryVertex();\r
-    if (vtPrm == aod->GetPrimaryVertexSPD()) return kTRUE; // there are pile-up vertices but no primary\r
-  }\r
-  else {\r
-    if ( !(nPlp=esd->GetNumberOfPileupVerticesTracks())) return kFALSE;\r
-    vtPrm = esd->GetPrimaryVertexTracks();\r
-    if (((AliESDVertex*)vtPrm)->GetStatus()!=1) return kTRUE; // there are pile-up vertices but no primary\r
-  }\r
-  //int bcPrim = vtPrm->GetBC();\r
-  //\r
-  for (int ipl=0;ipl<nPlp;ipl++) {\r
-    vtPlp = aod ? (const AliVVertex*)aod->GetPileupVertexTracks(ipl) : (const AliVVertex*)esd->GetPileupVertexTracks(ipl);\r
-    //\r
-    if (vtPlp->GetNContributors() < kMinPlpContrib) continue;\r
-    if (vtPlp->GetChi2perNDF() > kMaxPlpChi2) continue;\r
-    //  int bcPlp = vtPlp->GetBC();\r
-    //  if (bcPlp!=AliVTrack::kTOFBCNA && TMath::Abs(bcPlp-bcPrim)>2) return kTRUE; // pile-up from other BC\r
-    //\r
-    double wDst = GetWDist(vtPrm,vtPlp);\r
-    if (wDst<kMinWDist) continue;\r
-    //\r
-    return kTRUE; // pile-up: well separated vertices\r
-  }\r
-  //\r
-  return kFALSE;\r
-  //\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::MakeFilterBits() {\r
-  //FilterBit 1\r
-  fFB1 = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();\r
-  //FilterBit1024\r
-  fFB1024 = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kTRUE,1);\r
-  fFB1024->SetMinNCrossedRowsTPC(120);\r
-  fFB1024->SetMinRatioCrossedRowsOverFindableClustersTPC(0.8);\r
-  fFB1024->SetMaxChi2PerClusterITS(36);\r
-  fFB1024->SetMaxFractionSharedTPCClusters(0.4);\r
-  fFB1024->SetMaxChi2TPCConstrainedGlobal(36);\r
-  fFB1024->SetEtaRange(-0.9,0.9);\r
-  fFB1024->SetPtRange(0.15, 1e10);\r
-}\r
-//=======================================================================\r
-Bool_t AliAnalysisTaskFlowStrange::PassesFilterBit(AliESDtrack *track) {\r
-  Bool_t ret=kFALSE;\r
-  switch(fRFPFilterBit) {\r
-    case(1024):\r
-      ret = fFB1024->AcceptTrack(track);\r
-      break;\r
-    default:\r
-      ret = fFB1->AcceptTrack(track);\r
-  }\r
-  return ret;\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::LoadVZEROResponse() {\r
-  if(fVZEResponse) {\r
-    TString run = fVZEResponse->GetTitle();\r
-    if( run.Atoi() == fRunNumber ) return;\r
-    fVZEResponse = NULL;\r
-  }\r
-  //==>loading\r
-  fVZEResponse = dynamic_cast<TH2D*> (fVZEload->FindObject( Form("%d",fRunNumber) ));\r
-  if(fVZEResponse) {\r
-    printf("New VZE calibration: run %d || %s -> Entries %.0f\n",fRunNumber, fVZEResponse->GetTitle(),fVZEResponse->GetEntries());\r
-  } else {\r
-    printf("VZE calibration: request but not found!!!\n");\r
-  }\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::AddVZEQA() {\r
-  fVZEQA = new TList();\r
-  fVZEQA->SetName( Form("VZEQA%d",fRunNumber) );\r
-  fVZEQA->SetOwner();\r
-  if(fQAlevel>0) {\r
-    TProfile2D *prof = new TProfile2D("LINP","LINP;VZEcell;VZEmult;SPDtrkl", 64,0,64,500,0,700,0,10000); fVZEQA->Add( prof );\r
-    prof = new TProfile2D("MULP","MULP;VZEcell;CENTR;VZEmult", 64,0,64,100,0,100,0,10000); fVZEQA->Add( prof );\r
-    TH3D *tH3D = new TH3D("EQU","EQU;VZEeqmult;VZEmult",100,0,700,100,0,700,64,0,64); fVZEQA->Add( tH3D );\r
-  }\r
-  fList->Add(fVZEQA);\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::SaveVZEROQA() {\r
-  AliAODEvent *event = dynamic_cast<AliAODEvent*> (InputEvent());\r
-  if(!event) return;\r
-  AliVVZERO *vzero = event->GetVZEROData();\r
-  AliAODTracklets *tracklets = event->GetTracklets();\r
-  if(!vzero) return;\r
-  if(!tracklets) return;\r
-  Double_t mult, eqmult;\r
-  Int_t trkl;\r
-  for(int id=0; id!=64; ++id) {\r
-    trkl = tracklets->GetNumberOfTracklets();\r
-    mult = vzero->GetMultiplicity(id);\r
-    eqmult = event->GetVZEROEqMultiplicity(id);\r
-    ((TProfile2D*) fVZEQA->FindObject( "LINP" ))->Fill(id,mult,trkl,1);\r
-    ((TProfile2D*) fVZEQA->FindObject( "MULP" ))->Fill(id,fThisCent,mult,1);\r
-    ((TH3D*) fVZEQA->FindObject("EQU"))->Fill(eqmult,mult,id);\r
-  }\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::AddVZEROResponse() {\r
-  fVZEResponse = NULL;\r
-  AliVEvent *event = InputEvent();\r
-  if(!event) return;\r
-  Int_t thisrun = event->GetRunNumber();\r
-  fVZEResponse = new TH2D( Form("%d",thisrun), Form("%d;cell;CC",thisrun), 64,0,64, 100, 0, 100);\r
-  fList->Add(fVZEResponse);\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::SaveVZEROResponse() {\r
-  if(!fVZEResponse) return;\r
-  AliVEvent *event = InputEvent();\r
-  if(!event) return;\r
-  Double_t w;\r
-  for(int id=0; id!=64; ++id) {\r
-    w = event->GetVZEROEqMultiplicity(id);\r
-    fVZEResponse->Fill(id,fThisCent,w);\r
-  }\r
-}\r
-//=======================================================================\r
-Int_t AliAnalysisTaskFlowStrange::RefMultTPC() {\r
-  AliAODEvent *ev = dynamic_cast<AliAODEvent*> (InputEvent());\r
-  if(!ev) return -1;\r
-  Int_t found = 0;\r
-  for(int i=0; i!=ev->GetNumberOfTracks(); ++i) {\r
-    AliAODTrack *t = ev->GetTrack( i );\r
-    if(!t) continue;\r
-    if( !t->TestFilterBit(1) ) continue;\r
-    if( t->Eta()<-0.8 || t->Eta()>+0.8 ) continue;\r
-    if( t->Pt()<0.2 || t->Pt()>5.0 ) continue;\r
-    if( t->GetTPCNcls()<70 ) continue;\r
-    if( t->GetTPCsignal()<10.0 ) continue;\r
-    if( t->Chi2perNDF()<0.2 ) continue;    \r
-    ++found;\r
-  }\r
-  return found;\r
-}\r
-//=======================================================================\r
-Int_t AliAnalysisTaskFlowStrange::RefMultGlobal() {\r
-  AliAODEvent *ev = dynamic_cast<AliAODEvent*> (InputEvent());\r
-  if(!ev) return -1;\r
-  Int_t found = 0;\r
-  for(int i=0; i!=ev->GetNumberOfTracks(); ++i) {\r
-    AliAODTrack *t = ev->GetTrack( i );\r
-    if(!t) continue;\r
-    if( !t->TestFilterBit(16) ) continue;\r
-    if( t->Eta()<-0.8 || t->Eta()>+0.8 ) continue;\r
-    if( t->Pt()<0.2 || t->Pt()>5.0 ) continue;\r
-    if( t->GetTPCNcls()<70 ) continue;\r
-    if( t->GetTPCsignal()<10.0 ) continue;\r
-    if( t->Chi2perNDF()<0.1 ) continue;    \r
-    Double_t b[3], bcov[3];\r
-    if( !t->PropagateToDCA(ev->GetPrimaryVertex(),ev->GetMagneticField(),100,b,bcov) ) continue;\r
-    if( b[0]>+0.3 || b[0]<-0.3 || b[1]>+0.3 || b[1]<-0.3) continue;\r
-    ++found;\r
-  }\r
-  return found;\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::MakeDHcorr() {\r
-  // Adds DH corr\r
-  for(int iCand=0; iCand!=fCandidates->GetEntriesFast(); ++iCand ) {\r
-    AliFlowCandidateTrack *cand = static_cast<AliFlowCandidateTrack*>(fCandidates->At(iCand));\r
-    if(!cand) continue;\r
-    for(int iRPs=0; iRPs!=fTPCevent->NumberOfTracks(); ++iRPs ) {\r
-      AliFlowTrack *iRP = static_cast<AliFlowTrack*>(fTPCevent->GetTrack( iRPs ));\r
-      if(!iRP) continue;\r
-      if(!iRP->InRPSelection()) continue;\r
-      if(cand->GetID() == iRP->GetID()) continue; //avoid autocorr\r
-      for(int iDau=0; iDau!=cand->GetNDaughters(); ++iDau) //if it is a decay\r
-        if(cand->GetIDDaughter(iDau) == iRP->GetID()) continue;\r
-      //corr\r
-      Double_t dDPHI = iRP->Phi() - cand->Phi();\r
-      Double_t dDETA = iRP->Eta() - cand->Eta();\r
-      Double_t dDPT  = iRP->Pt()  - cand->Pt();\r
-      ((TH3D*)((TList*)fList->FindObject("DHCORR"))->FindObject("DPHI"))->Fill( dDPT, dDPHI, dDETA );\r
-      //end of corr\r
-    }\r
-  }\r
-}\r
-//=======================================================================\r
-void AliAnalysisTaskFlowStrange::ResetContainers() {\r
-  fTPCevent->ClearFast();\r
-  fVZEevent->ClearFast();\r
-}\r
+/*************************************************************************
+* Copyright(c) 1998-2008,ALICE Experiment at CERN,All rights reserved. *
+*                                                                        *
+* Author: The ALICE Off-line Project.                                    *
+* Contributors are mentioned in the code where appropriate.              *
+*                                                                        *
+* Permission to use,copy,modify and distribute this software and its   *
+* documentation strictly for non-commercial purposes is hereby granted   *
+* without fee,provided that the above copyright notice appears in all   *
+* copies and that both the copyright notice and this permission notice   *
+* appear in the supporting documentation. The authors make no claims     *
+* about the suitability of this software for any purpose. It is          *
+* provided "as is" without express or implied warranty.                  *
+**************************************************************************/
+
+/////////////////////////////////////////////////////
+// AliAnalysisTaskFlowStrange:
+// Analysis task to select K0/Lambda candidates for flow analysis.
+// Authors: Cristian Ivan (civan@cern.ch)
+//          Carlos Perez  (cperez@cern.ch)
+//          Pawel Debski  (pdebski@cern.ch)
+//////////////////////////////////////////////////////
+
+#include "TChain.h"
+#include "TList.h"
+#include "TH1D.h"
+#include "TH2D.h"
+#include "TH3D.h"
+#include "TF1.h"
+#include "TProfile.h"
+#include "TProfile2D.h"
+#include "TVector3.h"
+#include "TStopwatch.h"
+#include "TFile.h"
+
+#include "TRandom3.h"
+
+#include "AliAnalysisManager.h"
+#include "AliInputEventHandler.h"
+
+#include "AliVVertex.h"
+#include "AliVVZERO.h"
+#include "AliStack.h"
+#include "AliMCEvent.h"
+
+#include "AliESDEvent.h"
+#include "AliESDtrack.h"
+#include "AliESDVertex.h"
+#include "AliESDv0.h"
+#include "AliESDtrackCuts.h"
+
+#include "AliAODEvent.h"
+#include "AliAODTrack.h"
+#include "AliAODVertex.h"
+#include "AliAODv0.h"
+#include "AliAODTracklets.h"
+#include "AliAODHeader.h"
+
+#include "AliAODMCHeader.h"
+#include "AliAODMCParticle.h"
+#include "TClonesArray.h"
+#include "TDatabasePDG.h"
+#include "TParticlePDG.h"
+
+#include "TMath.h"
+#include "TObjArray.h"
+#include "AliFlowCandidateTrack.h"
+
+#include "AliFlowTrackCuts.h"
+#include "AliFlowEventCuts.h"
+#include "AliFlowEvent.h"
+#include "AliFlowBayesianPID.h"
+#include "AliFlowCommonConstants.h"
+#include "AliFlowVector.h"
+
+#include "AliAnalysisTaskFlowStrange.h"
+
+ClassImp(AliAnalysisTaskFlowStrange)
+
+//=======================================================================
+AliAnalysisTaskFlowStrange::AliAnalysisTaskFlowStrange() :
+  AliAnalysisTaskSE(),
+  fPIDResponse(NULL),
+  fFB1(NULL),
+  fFB1024(NULL),
+  fTPCevent(NULL),
+  fVZEevent(NULL),
+  fCandidates(NULL),
+  fList(NULL),
+  fRunNumber(-1),
+  fDebug(0),
+  fQAlevel(0),
+  fReadESD(kFALSE),
+  fReadMC(kFALSE),
+  fAvoidExec(kFALSE),
+  fSkipSelection(kFALSE),
+  fSkipFlow(kFALSE),
+  fSkipDHcorr(kTRUE),
+  fUseFP(kFALSE),
+  fRunOnpA(kFALSE),
+  fRunOnpp(kFALSE),
+  fExtraEventRejection(kFALSE),
+  fCentMethod("V0MTRK"),
+  fCentPerMin(0),
+  fCentPerMax(100),
+  fThisCent(-1.0),
+  fExcludeTPCEdges(kFALSE),
+  fSpecie(0),
+  fOnline(kFALSE),
+  fHomemade(kFALSE),
+  fWhichPsi(1),
+  fVZEsave(kFALSE),
+  fVZEload(NULL),
+  fVZEResponse(NULL),
+  fVZEmb(kFALSE),
+  fVZEByDisk(kTRUE),
+  fVZECa(0),
+  fVZECb(3),
+  fVZEAa(0),
+  fVZEAb(3),
+  fVZEQA(NULL),
+  fPsi2(0.0),
+  fMCEP(0.0),
+  fMassBins(0),
+  fMinMass(0.0),
+  fMaxMass(0.0),
+  fRFPFilterBit(1),
+  fRFPminPt(0.2),
+  fRFPmaxPt(5.0),
+  fRFPminEta(-0.8),
+  fRFPmaxEta(+0.8),
+  fRFPTPCsignal(10.0),
+  fRFPmaxIPxy(2.4),
+  fRFPmaxIPz(3.2),
+  fRFPTPCncls(70),
+  fDecayMass(0.0),
+  fDecayPhi(0.0),
+  fDecayEta(0.0),
+  fDecayPt(0.0),
+  fDecayDCAdaughters(0.0),
+  fDecayCosinePointingAngleXY(0.0),
+  fDecayRadXY(0.0),
+  fDecayDecayLength(0.0),
+  fDecayQt(0.0),
+  fDecayAlpha(0.0),
+  fDecayRapidity(0.0),
+  fDecayProductIPXY(0.0),
+  fDecayIDneg(-1),
+  fDecayIDpos(-1),
+  fDecayID(-1),
+  fDecayMinEta(0.0),
+  fDecayMaxEta(0.0),
+  fDecayMinPt(0.0),
+  fDecayMaxDCAdaughters(0.0),
+  fDecayMinCosinePointingAngleXY(0.0),
+  fDecayMinQt(0.0),
+  fDecayAPCutPie(kTRUE),
+  fDecayMinRadXY(0.0),
+  fDecayMaxDecayLength(0.0),
+  fDecayMaxProductIPXY(0.0),
+  fDecayMaxRapidity(0.0),
+  fDaughterPhi(0.0),
+  fDaughterEta(0.0),
+  fDaughterPt(0.0),
+  fDaughterNClsTPC(0),
+  fDaughterCharge(0),
+  fDaughterNFClsTPC(0),
+  fDaughterNSClsTPC(0),
+  fDaughterChi2PerNClsTPC(0.0),
+  fDaughterXRows(0.0),
+  fDaughterImpactParameterXY(0.0),
+  fDaughterImpactParameterZ(0.0),
+  fDaughterStatus(0),
+  fDaughterNSigmaPID(0.0),
+  fDaughterKinkIndex(0),
+  fDaughterUnTag(kTRUE),
+  fDaughterMinEta(0.0),
+  fDaughterMaxEta(0.0),
+  fDaughterMinPt(0.0),
+  fDaughterMinNClsTPC(0),
+  fDaughterMinXRows(0),
+  fDaughterMaxChi2PerNClsTPC(0.0),
+  fDaughterMinXRowsOverNClsFTPC(0.0),
+  fDaughterMinImpactParameterXY(0.0),
+  fDaughterMaxNSigmaPID(0.0) {
+  //ctor
+}
+//=======================================================================
+AliAnalysisTaskFlowStrange::AliAnalysisTaskFlowStrange(const char *name) :
+  AliAnalysisTaskSE(name),
+  fPIDResponse(NULL),
+  fFB1(NULL),
+  fFB1024(NULL),
+  fTPCevent(NULL),
+  fVZEevent(NULL),
+  fCandidates(NULL),
+  fList(NULL),
+  fRunNumber(-1),
+  fDebug(0),
+  fQAlevel(0),
+  fReadESD(kFALSE),
+  fReadMC(kFALSE),
+  fAvoidExec(kFALSE),
+  fSkipSelection(kFALSE),
+  fSkipFlow(kFALSE),
+  fSkipDHcorr(kTRUE),
+  fUseFP(kFALSE),
+  fRunOnpA(kFALSE),
+  fRunOnpp(kFALSE),
+  fExtraEventRejection(kFALSE),
+  fCentMethod("V0MTRK"),
+  fCentPerMin(0),
+  fCentPerMax(100),
+  fThisCent(-1.0),
+  fExcludeTPCEdges(kFALSE),
+  fSpecie(0),
+  fOnline(kFALSE),
+  fHomemade(kFALSE),
+  fWhichPsi(1),
+  fVZEsave(kFALSE),
+  fVZEload(NULL),
+  fVZEResponse(NULL),
+  fVZEmb(kFALSE),
+  fVZEByDisk(kTRUE),
+  fVZECa(0),
+  fVZECb(3),
+  fVZEAa(0),
+  fVZEAb(3),
+  fVZEQA(NULL),
+  fPsi2(0.0),
+  fMCEP(0.0),
+  fMassBins(0),
+  fMinMass(0.0),
+  fMaxMass(0.0),
+  fRFPFilterBit(1),
+  fRFPminPt(0.2),
+  fRFPmaxPt(5.0),
+  fRFPminEta(-0.8),
+  fRFPmaxEta(+0.8),
+  fRFPTPCsignal(10.0),
+  fRFPmaxIPxy(2.4),
+  fRFPmaxIPz(3.2),
+  fRFPTPCncls(70),
+  fDecayMass(0.0),
+  fDecayPhi(0.0),
+  fDecayEta(0.0),
+  fDecayPt(0.0),
+  fDecayDCAdaughters(0.0),
+  fDecayCosinePointingAngleXY(0.0),
+  fDecayRadXY(0.0),
+  fDecayDecayLength(0.0),
+  fDecayQt(0.0),
+  fDecayAlpha(0.0),
+  fDecayRapidity(0.0),
+  fDecayProductIPXY(0.0),
+  fDecayIDneg(-1),
+  fDecayIDpos(-1),
+  fDecayID(-1),
+  fDecayMinEta(0.0),
+  fDecayMaxEta(0.0),
+  fDecayMinPt(0.0),
+  fDecayMaxDCAdaughters(0.0),
+  fDecayMinCosinePointingAngleXY(0.0),
+  fDecayMinQt(0.0),
+  fDecayAPCutPie(kTRUE),
+  fDecayMinRadXY(0.0),
+  fDecayMaxDecayLength(0.0),
+  fDecayMaxProductIPXY(0.0),
+  fDecayMaxRapidity(0.0),
+  fDaughterPhi(0.0),
+  fDaughterEta(0.0),
+  fDaughterPt(0.0),
+  fDaughterNClsTPC(0),
+  fDaughterCharge(0),
+  fDaughterNFClsTPC(0),
+  fDaughterNSClsTPC(0),
+  fDaughterChi2PerNClsTPC(0.0),
+  fDaughterXRows(0.0),
+  fDaughterImpactParameterXY(0.0),
+  fDaughterImpactParameterZ(0.0),
+  fDaughterStatus(0),
+  fDaughterNSigmaPID(0.0),
+  fDaughterKinkIndex(0),
+  fDaughterUnTag(kTRUE),
+  fDaughterMinEta(0.0),
+  fDaughterMaxEta(0.0),
+  fDaughterMinPt(0.0),
+  fDaughterMinNClsTPC(0),
+  fDaughterMinXRows(0),
+  fDaughterMaxChi2PerNClsTPC(0.0),
+  fDaughterMinXRowsOverNClsFTPC(0.0),
+  fDaughterMinImpactParameterXY(0.0),
+  fDaughterMaxNSigmaPID(0.0) {
+  //ctor
+  DefineInput( 0,TChain::Class());
+  DefineOutput(1,TList::Class());
+  DefineOutput(2,AliFlowEventSimple::Class()); // TPC object
+  DefineOutput(3,AliFlowEventSimple::Class()); // VZE object
+}
+//=======================================================================
+AliAnalysisTaskFlowStrange::~AliAnalysisTaskFlowStrange() {
+  //dtor
+  if (fCandidates) delete fCandidates;
+  if (fTPCevent)   delete fTPCevent;
+  if (fVZEevent)   delete fVZEevent;
+  if (fList)       delete fList;
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::UserCreateOutputObjects() {
+  //UserCreateOutputObjects
+  fList=new TList();
+  fList->SetOwner();
+  AddQAEvents();
+  AddQACandidates();
+
+  if(fReadESD) MakeFilterBits();
+
+  AliFlowCommonConstants *cc = AliFlowCommonConstants::GetMaster();
+  cc->SetNbinsMult(3000); cc->SetMultMin(0);   cc->SetMultMax(30000);
+  cc->SetNbinsPt(200); cc->SetPtMin(0.0);   cc->SetPtMax(20.0);
+  cc->SetNbinsPhi(100);  cc->SetPhiMin(0.0);  cc->SetPhiMax(TMath::TwoPi());
+  cc->SetNbinsEta(100);  cc->SetEtaMin(-5.0); cc->SetEtaMax(+5.0);
+  cc->SetNbinsQ(100);    cc->SetQMin(0.0);    cc->SetQMax(3.0);
+  cc->SetNbinsMass(fMassBins);
+  cc->SetMassMin(fMinMass);
+  cc->SetMassMax(fMaxMass);
+
+  //loading pid response
+  AliAnalysisManager *man = AliAnalysisManager::GetAnalysisManager();
+  AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
+  fPIDResponse = inputHandler->GetPIDResponse();
+
+  fTPCevent = new AliFlowEvent(100);
+  fVZEevent = new AliFlowEvent(100);
+
+  //array of candidates
+  fCandidates = new TObjArray(100);
+  fCandidates->SetOwner();
+
+  PostData(1,fList);
+  if(fUseFP) { // for connection to the flow package
+    PostData(2,fTPCevent);
+    PostData(3,fVZEevent);
+  }
+
+  gRandom->SetSeed();
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::AddQAEvents() {
+  // function to add event qa
+  TH1D *tH1D;
+  TProfile *tProfile;
+  TList *tQAEvents=new TList();
+  tQAEvents->SetName("Event");
+  tQAEvents->SetOwner();
+  tH1D = new TH1D("Events","Number of Events",6,0,6); tQAEvents->Add(tH1D);
+  tH1D->GetXaxis()->SetBinLabel(1,"exec");
+  tH1D->GetXaxis()->SetBinLabel(2,"userexec");
+  tH1D->GetXaxis()->SetBinLabel(3,"reached");
+  tH1D->GetXaxis()->SetBinLabel(4,"selected");
+  tH1D->GetXaxis()->SetBinLabel(5,"rejectedByLowQw");
+  tH1D->GetXaxis()->SetBinLabel(6,"rejectedByErrorLoadVZEcal");
+  tProfile = new TProfile("Configuration","Configuration",20,0,20); tQAEvents->Add(tProfile);
+  tProfile->Fill( 0.5,fCentPerMin,1); tProfile->GetXaxis()->SetBinLabel( 1,"fCentPerMin");
+  tProfile->Fill( 1.5,fCentPerMax,1); tProfile->GetXaxis()->SetBinLabel( 2,"fCentPerMax");
+  tProfile->Fill( 2.5,fDaughterMinEta,1);               tProfile->GetXaxis()->SetBinLabel( 3,"fDaughterMinEta");
+  tProfile->Fill( 3.5,fDaughterMaxEta,1);               tProfile->GetXaxis()->SetBinLabel( 4,"fDaughterMaxEta");
+  tProfile->Fill( 4.5,fDaughterMinPt,1);                tProfile->GetXaxis()->SetBinLabel( 5,"fDaughterMinPt");
+  tProfile->Fill( 5.5,fDaughterMinNClsTPC,1);           tProfile->GetXaxis()->SetBinLabel( 6,"fDaughterMinNClsTPC");
+  tProfile->Fill( 6.5,fDaughterMaxChi2PerNClsTPC,1);    tProfile->GetXaxis()->SetBinLabel( 7,"fDaughterMaxChi2PerNClsTPC");
+  tProfile->Fill( 7.5,fDaughterMinXRowsOverNClsFTPC,1); tProfile->GetXaxis()->SetBinLabel( 8,"fDaughterMinXRowsOverNClsFTPC");
+  tProfile->Fill( 8.5,fDaughterMinImpactParameterXY,1); tProfile->GetXaxis()->SetBinLabel( 9,"fDaughterMinImpactParameterXY");
+  tProfile->Fill( 9.5,fDaughterMaxNSigmaPID,1);         tProfile->GetXaxis()->SetBinLabel(10,"fDaughterMaxNSigmaPID");
+  tProfile->Fill(10.5,fDecayMaxDCAdaughters,1);          tProfile->GetXaxis()->SetBinLabel(11,"fDecayMaxDCAdaughters");
+  tProfile->Fill(11.5,fDecayMinCosinePointingAngleXY,1); tProfile->GetXaxis()->SetBinLabel(12,"fDecayMinCosinePointingAngleXY");
+  tProfile->Fill(12.5,fDecayMinQt,1);                    tProfile->GetXaxis()->SetBinLabel(13,"fDecayMinQt");
+  tProfile->Fill(13.5,fDecayMinRadXY,1);                 tProfile->GetXaxis()->SetBinLabel(14,"fDecayMinRadXY");
+  tProfile->Fill(14.5,fDecayMaxDecayLength,1);           tProfile->GetXaxis()->SetBinLabel(15,"fDecayMaxDecayLength");
+  tProfile->Fill(15.5,fDecayMaxProductIPXY,1);           tProfile->GetXaxis()->SetBinLabel(16,"fDecayMaxProductIPXY");
+  tProfile->Fill(16.5,fDecayMaxRapidity,1);              tProfile->GetXaxis()->SetBinLabel(17,"fDecayMaxRapidity");
+  tProfile->Fill(17.5,fDecayMinEta,1);                   tProfile->GetXaxis()->SetBinLabel(18,"fDecayMinEta");
+  tProfile->Fill(18.5,fDecayMaxEta,1);                   tProfile->GetXaxis()->SetBinLabel(19,"fDecayMaxEta");
+  tProfile->Fill(19.5,fDecayMinPt,1);                    tProfile->GetXaxis()->SetBinLabel(20,"fDecayMinPt");
+
+  tH1D = new TH1D("POI","POIs;multiplicity",800,0,800);         tQAEvents->Add(tH1D);
+  tH1D = new TH1D("UNTAG","UNTAG;Untagged Daughters",800,0,800);tQAEvents->Add(tH1D);
+  tH1D = new TH1D("RealTime","RealTime;LogT sec",2000,-10,+10); tQAEvents->Add(tH1D);
+  fList->Add(tQAEvents);
+  AddEventSpy();
+  AddMakeQSpy();
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::AddEventSpy() {
+  TH1D *tH1D;
+  TH2D *tH2D;
+  TList *tList=new TList();
+  tList->SetName("EventSpy");
+  tList->SetOwner();
+  if(fQAlevel>0) {
+    tH2D = new TH2D("VTXZ","VTXZ;Global||SPD;SPD",60,-25,+25,60,-25,+25); tList->Add( tH2D );
+    tH2D = new TH2D("CCCC","CCCC;V0M;TRK",60,-10,110,60,-10,110);         tList->Add( tH2D );
+    tH2D = new TH2D("REFM","REFM;TPC;GLOBAL",100,0,3000,100,0,3000);      tList->Add( tH2D );
+    if(fReadMC) {
+      tH1D = new TH1D("MCCC","MCCC;Xsection",100,-10,110); tList->Add( tH1D );
+      tH1D = new TH1D("MCEP","MCEP;MCEP",100,-TMath::TwoPi(),TMath::TwoPi()); tList->Add( tH1D );
+    }
+  }
+  fList->Add(tList);
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::AddMakeQSpy() {
+  if(fSkipFlow) return;
+  TH1D *tH1D;
+  TH2D *tH2D;
+  TProfile *tPF1;
+  TList *tList=new TList();
+  tList->SetName("MakeQSpy");
+  tList->SetOwner();
+  tH1D = new TH1D("RFPTPC","TPC Refrence Multiplicity;multiplicity",3000,0,3000);     tList->Add( tH1D );
+  tH1D = new TH1D("RFPVZE","VZERO Reference Multiplicity;multiplicity",3000,0,30000); tList->Add( tH1D );
+  tH2D = new TH2D("TPCAllPhiEta","TPCall;Phi;Eta",180,0,TMath::TwoPi(),80,-0.9,+0.9); tList->Add( tH2D );
+  tH2D = new TH2D("VZEAllPhiEta","VZEall;Phi;Eta",20,0,TMath::TwoPi(),40,-4.0,+6.0);  tList->Add( tH2D );
+  tH1D = new TH1D("TPCPSI","TPCPSI;PSI",72,0,TMath::Pi()); tList->Add( tH1D );
+  tH1D = new TH1D("TPCPSIA","TPCPSIA;PSIA",72,0,TMath::Pi()); tList->Add( tH1D );
+  tH1D = new TH1D("TPCPSIB","TPCPSIB;PSIB",72,0,TMath::Pi()); tList->Add( tH1D );
+  tH1D = new TH1D("VZEPSI","VZEPSI;PSI",72,0,TMath::Pi()); tList->Add( tH1D );
+  tH1D = new TH1D("VZEPSIA","VZEPSIA;PSIA",72,0,TMath::Pi()); tList->Add( tH1D );
+  tH1D = new TH1D("VZEPSIB","VZEPSIB;PSIB",72,0,TMath::Pi()); tList->Add( tH1D );
+  tPF1 = new TProfile("TPCQ","TPCQ",6,0.5,6.5,"s");
+  tPF1->GetXaxis()->SetBinLabel(1,"Qay"); tPF1->GetXaxis()->SetBinLabel(2,"Qax");
+  tPF1->GetXaxis()->SetBinLabel(3,"Qby"); tPF1->GetXaxis()->SetBinLabel(4,"Qbx");
+  tPF1->GetXaxis()->SetBinLabel(5,"Qy");  tPF1->GetXaxis()->SetBinLabel(6,"Qx");
+  tList->Add( tPF1 );
+  tPF1 = new TProfile("VZEQ","VZEQ",6,0.5,6.5,"s");
+  tPF1->GetXaxis()->SetBinLabel(1,"Qay"); tPF1->GetXaxis()->SetBinLabel(2,"Qax");
+  tPF1->GetXaxis()->SetBinLabel(3,"Qby"); tPF1->GetXaxis()->SetBinLabel(4,"Qbx");
+  tPF1->GetXaxis()->SetBinLabel(5,"Qy");  tPF1->GetXaxis()->SetBinLabel(6,"Qx");
+  tList->Add( tPF1 );
+  
+  fList->Add(tList);
+  if(!fSkipFlow) {
+    tList=new TList(); tList->SetName("TPCRFPall"); tList->SetOwner(); AddTPCRFPSpy(tList); fList->Add(tList);
+    tList=new TList(); tList->SetName("TPCRFPsel"); tList->SetOwner(); AddTPCRFPSpy(tList); fList->Add(tList);
+  }
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::AddQACandidates() {
+  // function to add histogramming for candidates
+  if(fSkipSelection) return;
+
+  TList *tList;
+  TH1D *tH1D;
+  TH2D *tH2D;
+  TH3D *tH3D;
+
+  //reconstruction
+  if(fReadESD) {
+    tList=new TList(); tList->SetName("TrkAll"); tList->SetOwner(); AddTracksSpy(tList); fList->Add(tList);
+    tList=new TList(); tList->SetName("TrkSel"); tList->SetOwner(); AddTracksSpy(tList); fList->Add(tList);
+    tH2D = new TH2D("NPAIR", "NPAIR;NPOS;NNEG",1000,0,5000,1000,0,5000); tList->Add(tH2D);
+    tH2D = new TH2D("PtIPXY","PtIPXY;Pt;IPxy", 100,0,10,200,-10,+10); tList->Add(tH2D);
+  }
+  //candidates
+  tList=new TList(); tList->SetName("RecAll"); tList->SetOwner(); AddCandidatesSpy(tList); fList->Add(tList);
+  tH2D = new TH2D("V0SADC","V0S AFTER DAUGHTER CUTS;V0ALL;V0IMW",100,0,1000,100,0,1000); tList->Add(tH2D);
+  tList=new TList(); tList->SetName("RecSel"); tList->SetOwner(); AddCandidatesSpy(tList); fList->Add(tList);
+  //daughters
+  tList=new TList(); tList->SetName("TrkDau"); tList->SetOwner(); AddTracksSpy(tList); fList->Add(tList);
+  if(!fSkipDHcorr) {
+    //corr
+    tList=new TList(); tList->SetName("DHCORR"); tList->SetOwner(); 
+    tH3D = new TH3D("DPHI","DPHI;dPT;dPHI;dETA", 20, -1, +1, 120, -TMath::TwoPi(), TMath::TwoPi(), 16, -1.6, +1.6 ); tList->Add(tH3D);
+    fList->Add(tList);
+  }
+  if(fQAlevel>1) {
+    // IN-OUT
+    tList=new TList(); tList->SetName("RecAllIP"); tList->SetOwner(); AddCandidatesSpy(tList); fList->Add(tList);
+    tList=new TList(); tList->SetName("RecAllOP"); tList->SetOwner(); AddCandidatesSpy(tList); fList->Add(tList);
+    tList=new TList(); tList->SetName("RecSelIP"); tList->SetOwner(); AddCandidatesSpy(tList); fList->Add(tList);
+    tList=new TList(); tList->SetName("RecSelOP"); tList->SetOwner(); AddCandidatesSpy(tList); fList->Add(tList);
+  }
+  //match
+  if(fReadMC) {
+    tList=new TList(); tList->SetName("RecMth"); tList->SetOwner(); AddCandidatesSpy(tList); fList->Add(tList);
+    tH1D = new TH1D("MCOrigin", "MCOrigin;Rad2",1000,0,100); tList->Add(tH1D);
+    tH2D = new TH2D("PTRes", "PTRes;MCPt;DAT-MC/MC",  100,   0,  20,100,-0.2,+0.2); tList->Add(tH2D);
+    tH2D = new TH2D("ETARes","ETARes;MCETA;DAT-MC/MC", 16,   0, 0.8,100,-0.5,+0.5); tList->Add(tH2D);
+    tH2D = new TH2D("RXYRes","RXYRes;MCRXY;DAT-MC/MC",100,   0,  20,100,-1,1);      tList->Add(tH2D);
+    tH2D = new TH2D("DLERes","DLERes;MCDLE;DAT-MC/MC",100,   0,  20,100,-1,1);      tList->Add(tH2D);
+    tH2D = new TH2D("RAPRes","RAPRes;MCRAP;DAT-MC/MC", 10,   0, 0.5,100,-0.5,+0.5); tList->Add(tH2D);
+    tH2D = new TH2D("APARes","APARes;MCAPA;DAT-MC/MC", 24,-1.2, 1.2,100,-0.5,+0.5); tList->Add(tH2D);
+    tH2D = new TH2D("APQRes","APQRes;MCAPQ;DAT-MC/MC", 25,   0,0.25,100,-0.3,+0.3); tList->Add(tH2D);
+
+    tList=new TList(); tList->SetName("TrkMth"); tList->SetOwner(); AddTracksSpy(tList); fList->Add(tList);
+    tList=new TList(); tList->SetName("MthFDW"); tList->SetOwner(); AddCandidatesSpy(tList); fList->Add(tList);
+    tH1D = new TH1D("MCOrigin", "MCOrigin;Rad2",1000,0,100); tList->Add(tH1D);
+  }
+  //stack
+  if(fReadMC) {
+    tList=new TList(); tList->SetName("GenTru"); tList->SetOwner(); AddCandidatesSpy(tList); fList->Add(tList);
+    tList=new TList(); tList->SetName("MCTK0sGenAcc"); tList->SetOwner(); AddMCParticleSpy(tList); fList->Add(tList);
+    tList=new TList(); tList->SetName("MCTLdaGenAcc"); tList->SetOwner(); AddMCParticleSpy(tList); fList->Add(tList);
+    tList=new TList(); tList->SetName("MCTPhiGenAcc"); tList->SetOwner(); AddMCParticleSpy(tList); fList->Add(tList);
+    tList=new TList(); tList->SetName("MCTXiGenAcc");  tList->SetOwner(); AddMCParticleSpy(tList); fList->Add(tList);
+    tList=new TList(); tList->SetName("MCTK0s"); tList->SetOwner(); AddMCParticleSpy(tList); fList->Add(tList);
+    tList=new TList(); tList->SetName("MCTLda"); tList->SetOwner(); AddMCParticleSpy(tList); fList->Add(tList);
+  }
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::Exec(Option_t* option) {
+  // bypassing ::exec (needed because of AMPT)
+  ((TH1D*)((TList*)fList->FindObject("Event"))->FindObject("Events"))->Fill(0);
+  if(fAvoidExec) {
+    AliAnalysisTaskFlowStrange::UserExec(option);
+  } else {
+    AliAnalysisTaskSE::Exec(option);
+  }
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::UserExec(Option_t *option) {
+  // bridge
+  ((TH1D*)((TList*)fList->FindObject("Event"))->FindObject("Events"))->Fill(1);
+  AliAnalysisTaskFlowStrange::MyUserExec(option);
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::MyNotifyRun() {
+  if(fQAlevel>5 && !fReadESD) AddVZEQA();
+  if(fVZEsave) AddVZEROResponse();
+}
+//=======================================================================
+Bool_t AliAnalysisTaskFlowStrange::CalibrateEvent() {
+  if(fVZEsave) SaveVZEROResponse();
+  if(fQAlevel>5 && !fReadESD) SaveVZEROQA(); // 2BIMPROVED
+  Bool_t okay=kTRUE;
+  if(fVZEload) {
+    LoadVZEROResponse();
+    if(!fVZEResponse) okay = kFALSE;
+  }
+  return okay;
+}
+//=======================================================================
+Bool_t AliAnalysisTaskFlowStrange::AcceptAAEvent(AliESDEvent *tESD) {
+  Double_t acceptEvent=kTRUE;
+  Double_t tTPCVtxZ = tESD->GetPrimaryVertexTPC()->GetZ();
+  if(tESD->GetPrimaryVertexTPC()->GetNContributors()<=0) return kFALSE;
+  Double_t tSPDVtxZ = tESD->GetPrimaryVertexSPD()->GetZ();
+  if(tESD->GetPrimaryVertexSPD()->GetNContributors()<=0) return kFALSE;
+  // EventCuts
+  AliCentrality *cent = tESD->GetCentrality();
+  Double_t cc1, cc2;
+  cc1 = cent->GetCentralityPercentile("V0M");
+  cc2 = cent->GetCentralityPercentile("TRK");
+  TString mycent = fCentMethod;
+  if(fCentMethod.Contains("V0MTRK")) {
+    acceptEvent = TMath::Abs(cc1-cc2)>5.0?kFALSE:acceptEvent; // a la Alex
+    mycent = "V0M";
+  }
+  fThisCent = cent->GetCentralityPercentile( mycent );
+  acceptEvent = (fThisCent<fCentPerMin||fThisCent>fCentPerMax)?kFALSE:acceptEvent;
+  acceptEvent = TMath::Abs(tTPCVtxZ-tSPDVtxZ)>0.5?kFALSE:acceptEvent;
+  acceptEvent = TMath::Abs(tTPCVtxZ)>10.0?kFALSE:acceptEvent;
+  if(fQAlevel>0) ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("VTXZ"))->Fill( tTPCVtxZ, tSPDVtxZ );
+  if(fQAlevel>0) ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("CCCC"))->Fill( cc1, cc2 );
+  // EndOfCuts
+  return acceptEvent;
+}
+//=======================================================================
+Bool_t AliAnalysisTaskFlowStrange::AcceptAAEvent(AliAODEvent *tAOD) {
+  Double_t acceptEvent=kTRUE;
+  //=>Pile-up rejection (hardcoded)
+  Double_t tVtxZ = tAOD->GetPrimaryVertex()->GetZ();
+  if(tAOD->GetPrimaryVertex()->GetNContributors()<=0) return kFALSE;
+  Double_t tSPDVtxZ = tAOD->GetPrimaryVertexSPD()->GetZ();
+  if(tAOD->GetPrimaryVertexSPD()->GetNContributors()<=0) return kFALSE;
+  Int_t tpc = RefMultTPC();
+  Int_t glo = RefMultGlobal();
+  if(fExtraEventRejection) {
+    TString name = tAOD->GetPrimaryVertex()->GetTitle();
+    if( !name.Contains("VertexerTracks") ) return kFALSE;
+    if( ( Float_t(tpc) < -40.3+1.22*glo ) || ( Float_t(tpc)>(32.1+1.59*glo) ) ) return kFALSE;
+  }
+  // EventCuts
+  AliCentrality *cent = tAOD->GetHeader()->GetCentralityP();
+  Double_t cc1, cc2;
+  cc1 = cent->GetCentralityPercentile("V0M");
+  cc2 = cent->GetCentralityPercentile("TRK");
+  TString mycent = fCentMethod;
+  if(fCentMethod.Contains("V0MTRK")) {
+    acceptEvent = TMath::Abs(cc1-cc2)>5.0?kFALSE:acceptEvent;
+    mycent = "V0M";
+  }
+  fThisCent = cent->GetCentralityPercentile( mycent );
+
+  Double_t xsec=0;
+  if(fReadMC) {
+    AliAODMCHeader *mcHeader = dynamic_cast<AliAODMCHeader*>(tAOD->GetList()->FindObject(AliAODMCHeader::StdBranchName()));
+    if (!mcHeader) {
+      return kFALSE;
+    }
+    xsec = mcHeader->GetCrossSection();
+    //fMCEP = mcHeader->GetReactionPlaneAngle();
+    fMCEP = mcHeader->GetReactionPlaneAngle() + (gRandom->Rndm()>0.5)*TMath::Pi();
+  }
+
+  acceptEvent = (fThisCent<fCentPerMin||fThisCent>fCentPerMax)?kFALSE:acceptEvent;
+  acceptEvent = TMath::Abs(tVtxZ-tSPDVtxZ)>0.5?kFALSE:acceptEvent;
+  acceptEvent = TMath::Abs(tVtxZ)>10.0?kFALSE:acceptEvent;
+  if(fQAlevel>0) {
+    ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("VTXZ"))->Fill( tVtxZ, tSPDVtxZ );
+    ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("CCCC"))->Fill( cc1, cc2 );
+    ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("REFM"))->Fill( tpc, glo );
+    if(fReadMC) {
+      ((TH1D*)((TList*)fList->FindObject("EventSpy"))->FindObject("MCCC"))->Fill( xsec );
+      ((TH1D*)((TList*)fList->FindObject("EventSpy"))->FindObject("MCEP"))->Fill( fMCEP );
+    }
+  }
+  // EndOfCuts
+  return acceptEvent;
+}
+//=======================================================================
+Bool_t AliAnalysisTaskFlowStrange::AcceptPPEvent(AliAODEvent *tAOD) {
+  Double_t acceptEvent=kTRUE;
+  Double_t tVtxZ = tAOD->GetPrimaryVertex()->GetZ();
+  if(tAOD->GetPrimaryVertex()->GetNContributors()<=0) return kFALSE;
+  Double_t tSPDVtxZ = tAOD->GetPrimaryVertexSPD()->GetZ();
+  if(tAOD->GetPrimaryVertexSPD()->GetNContributors()<=0) return kFALSE;
+  // EventCuts
+  AliCentrality *cent = tAOD->GetHeader()->GetCentralityP();
+  Double_t cc1, cc2;
+  cc1 = cent->GetCentralityPercentile("V0M");
+  cc2 = cent->GetCentralityPercentile("TRK");
+  fThisCent = GetReferenceMultiplicity();
+  //for pp i use fCentPerXXX to select on multiplicity
+  acceptEvent = (fThisCent<fCentPerMin||fThisCent>fCentPerMax)?kFALSE:acceptEvent;
+  acceptEvent = TMath::Abs(tVtxZ-tSPDVtxZ)>0.5?kFALSE:acceptEvent;
+  acceptEvent = TMath::Abs(tVtxZ)>10.0?kFALSE:acceptEvent;
+  if(fQAlevel>0) ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("VTXZ"))->Fill( tVtxZ, tSPDVtxZ );
+  if(fQAlevel>0) ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("CCCC"))->Fill( cc1, cc2 );
+  // EndOfCuts
+  return acceptEvent;
+}
+//=======================================================================
+Int_t AliAnalysisTaskFlowStrange::GetReferenceMultiplicity() { //toberefined
+  AliAODEvent *tAOD = (AliAODEvent *) InputEvent();
+  if(!tAOD) return -1;
+  AliAODTrack *track;
+  Int_t rawN = tAOD->GetNumberOfTracks();
+  Int_t ref=0;
+  for(Int_t id=0; id!=rawN; ++id) {
+    track = tAOD->GetTrack(id);
+    if(!track->TestFilterBit(fRFPFilterBit)) continue;
+    ++ref;
+  }
+  return ref;
+}
+//=======================================================================
+Bool_t AliAnalysisTaskFlowStrange::AcceptPAEvent(AliAODEvent *tAOD) {
+  //if(aod->GetHeader()->GetEventNumberESDFile() == 0) return; //rejecting first chunk NOT NEEDED ANYMORE
+  Int_t bc2 = tAOD->GetHeader()->GetIRInt2ClosestInteractionMap();
+  if(bc2!=0) return kFALSE;
+  Int_t bc1 = tAOD->GetHeader()->GetIRInt1ClosestInteractionMap();
+  if(bc1!=0) return kFALSE;
+  Short_t isPileup = tAOD->IsPileupFromSPD(5);
+  if(isPileup!=0) return kFALSE;
+  if(tAOD->GetHeader()->GetRefMultiplicityComb08()<0) return kFALSE;
+
+  const AliAODVertex* spdVtx = tAOD->GetPrimaryVertexSPD();
+  if(!spdVtx) return kFALSE;
+  if(spdVtx->GetNContributors()<=0) return kFALSE;
+
+  const AliAODVertex* tpcVtx=NULL;
+  Int_t nVertices = tAOD->GetNumberOfVertices();
+  for(Int_t iVertices = 0; iVertices < nVertices; iVertices++){
+    const AliAODVertex* vertex = tAOD->GetVertex(iVertices);
+    if (vertex->GetType() != AliAODVertex::kMainTPC) continue;
+    tpcVtx = vertex;
+  }
+  if(!tpcVtx) return kFALSE;
+  if(tpcVtx->GetNContributors()<=0) return kFALSE;
+  Double_t tTPCVtxZ = tpcVtx->GetZ();
+  Double_t tSPDVtxZ = spdVtx->GetZ();
+  if (TMath::Abs(tSPDVtxZ - tTPCVtxZ)>2.0) return kFALSE;
+  if(plpMV(tAOD)) return kFALSE;
+
+  Double_t acceptEvent=kTRUE;
+  // EventCuts
+  AliCentrality *cent = tAOD->GetHeader()->GetCentralityP();
+  Double_t cc1, cc2;
+  cc1 = cent->GetCentralityPercentile("V0M");
+  cc2 = cent->GetCentralityPercentile("TRK");
+  if(fCentMethod.Contains("V0MTRK")) fCentMethod = "V0M";
+  fThisCent = cent->GetCentralityPercentile( fCentMethod );
+  acceptEvent = (fThisCent<fCentPerMin||fThisCent>fCentPerMax)?kFALSE:acceptEvent;
+  acceptEvent = TMath::Abs(tTPCVtxZ)>10.0?kFALSE:acceptEvent;
+  // EndOfCuts
+  if(fQAlevel>0) ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("VTXZ"))->Fill( tTPCVtxZ, tSPDVtxZ );
+  if(fQAlevel>0) ((TH2D*)((TList*)fList->FindObject("EventSpy"))->FindObject("CCCC"))->Fill( cc1, cc2 );
+  return acceptEvent;
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::MyUserExec(Option_t *) {
+  // MAIN ROUTINE
+  TStopwatch tTime;
+  tTime.Start();
+  fCandidates->SetLast(-1);
+  AliESDEvent *tESD=dynamic_cast<AliESDEvent*>(InputEvent());
+  AliAODEvent *tAOD=dynamic_cast<AliAODEvent*>(InputEvent());
+  Int_t thisRun = fRunNumber;
+  //=>check event
+  Bool_t acceptEvent=kFALSE;
+  if(fReadESD) {
+    if(!tESD) {ResetContainers(); Publish(); return;}
+    acceptEvent = fRunOnpp?kFALSE:fRunOnpA?kFALSE:AcceptAAEvent(tESD);
+    thisRun = tESD->GetRunNumber();
+  } else {
+    if(!tAOD) {ResetContainers(); Publish(); return;}
+    acceptEvent = fRunOnpp?AcceptPPEvent(tAOD):fRunOnpA?AcceptPAEvent(tAOD):AcceptAAEvent(tAOD);
+    thisRun = tAOD->GetRunNumber();
+  }
+  if(thisRun!=fRunNumber) {
+    fRunNumber = thisRun;
+    MyNotifyRun();
+  }
+  ((TH1D*)((TList*)fList->FindObject("Event"))->FindObject("Events"))->Fill(2);
+  //=>does the event clear?
+  if(!acceptEvent) {ResetContainers(); Publish(); return;}
+  // healthy event incomming
+  if( !CalibrateEvent() ) { // saves/retrieves/qas VZEROCAL
+    ((TH1D*)((TList*)fList->FindObject("Event"))->FindObject("Events"))->Fill(5);
+    ResetContainers(); Publish(); return; // issue retrieving callibration
+  }
+  if(!fSkipFlow) {
+    MakeQVectors();
+    if(fPsi2<-0.1) {
+      ((TH1D*)((TList*)fList->FindObject("Event"))->FindObject("Events"))->Fill(4);
+      ResetContainers(); Publish(); return;
+    }
+  }
+  //=>great, lets do our stuff!
+  ((TH1D*)((TList*)fList->FindObject("Event"))->FindObject("Events"))->Fill(3);
+  //=>load candidates
+  if(!fSkipSelection) {
+    if(fReadESD) {
+      ReadFromESD(tESD);
+    } else {
+      if(fSpecie<10) ReadFromAODv0(tAOD);
+      else ChargeParticles(tAOD);
+    }
+    if(fUseFP) {
+      if(!fSkipDHcorr) MakeDHcorr();
+      AddCandidates();
+    }
+    //=>flow
+    //=>done
+  }
+  tTime.Stop();
+  ((TH1D*)((TList*)fList->FindObject("Event"))->FindObject("RealTime"))->Fill( TMath::Log( tTime.RealTime() ) );
+  Publish();
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::Publish() {
+  PostData(1,fList);
+  if(fUseFP) {
+    PostData(2,fTPCevent);
+    PostData(3,fVZEevent);
+  }
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::ReadFromESD(AliESDEvent *tESD) {
+  AliStack *stack=NULL;
+  if(fReadMC) {
+    AliMCEvent *mcevent=NULL;
+    mcevent = MCEvent();
+    if(mcevent) stack = mcevent->Stack();
+  }
+
+  Int_t num = tESD->GetNumberOfTracks();
+  AliESDtrack *myTrack;
+  Int_t plist[3000], nlist[3000], np=0, nn=0;
+  Double_t pd0[3000], nd0[3000];
+  for (Int_t i=0; i!=num; ++i) {
+    myTrack = (AliESDtrack*) tESD->GetTrack(i);
+    if(!myTrack) continue;
+    LoadTrack(myTrack);
+    FillTrackSpy("TrkAll");
+    if(!AcceptDaughter()) continue;
+    FillTrackSpy("TrkSel");
+    ((TH2D*)((TList*)fList->FindObject("TrkSel"))->FindObject("PtIPXY" ))->Fill( myTrack->Pt(), fDaughterImpactParameterXY );
+    if( myTrack->Charge()>0 ) {
+      pd0[np] = fDaughterImpactParameterXY;
+      plist[np++] = i;
+    } else {
+      nd0[nn] = fDaughterImpactParameterXY;
+      nlist[nn++] = i;
+    }
+  }
+  ((TH1D*)((TList*)fList->FindObject("TrkSel"))->FindObject("NPAIR" ))->Fill( np,nn );
+  const AliESDVertex *vtx = tESD->GetPrimaryVertex();
+  AliESDtrack *pT, *nT;
+  for(int p=0; p!=np; ++p) {
+    pT = (AliESDtrack*) tESD->GetTrack( plist[p] );
+    for(int n=0; n!=nn; ++n) {
+      nT = (AliESDtrack*) tESD->GetTrack( nlist[n] );
+      fDecayProductIPXY = pd0[p]*nd0[n];
+      AliExternalTrackParam pETP(*pT), nETP(*nT);
+      Double_t xa, xb;
+      pETP.GetDCA(&nETP,tESD->GetMagneticField(),xa,xb);
+      fDecayDCAdaughters = pETP.PropagateToDCA(&nETP,tESD->GetMagneticField());
+      AliESDv0 vertex( nETP,nlist[n], pETP,plist[p] );
+      fDecayCosinePointingAngleXY = CosThetaPointXY( &vertex, vtx );
+      fDecayRadXY = DecayLengthXY( &vertex, vtx );
+      fDecayPt = vertex.Pt();
+      fDecayPhi = vertex.Phi();
+      fDecayEta = vertex.Eta();
+      Double_t pmx, pmy, pmz, nmx, nmy, nmz;
+      vertex.GetNPxPyPz(nmx,nmy,nmz);
+      vertex.GetPPxPyPz(pmx,pmy,pmz);
+      TVector3 mom1(pmx,pmy,pmz), mom2(nmx,nmy,nmz), mom(vertex.Px(),vertex.Py(),vertex.Pz());
+      Double_t qlpos = mom1.Dot(mom)/mom.Mag();
+      Double_t qlneg = mom2.Dot(mom)/mom.Mag();
+      fDecayQt = mom1.Perp(mom);
+      fDecayAlpha = (qlpos-qlneg)/(qlpos+qlneg);
+      Double_t mpi = 0.13957018;
+      if(fSpecie==0) {
+        Double_t eppi = TMath::Sqrt( mpi*mpi + pmx*pmx + pmy*pmy + pmz*pmz );
+        Double_t enpi = TMath::Sqrt( mpi*mpi + nmx*nmx + nmy*nmy + nmz*nmz );
+        fDecayMass = TMath::Sqrt( mpi*mpi + mpi*mpi + 2*(eppi*enpi - pmx*nmx - pmy*nmy - pmz*nmz ) );
+        fDecayRapidity = vertex.RapK0Short();
+      } else {
+        Double_t mpr = 0.938272013;
+        Double_t epi, epr;
+        if(fDecayAlpha>0) {
+          epr = TMath::Sqrt( mpr*mpr + pmx*pmx + pmy*pmy + pmz*pmz );
+          epi = TMath::Sqrt( mpi*mpi + nmx*nmx + nmy*nmy + nmz*nmz );
+        } else {
+          epi = TMath::Sqrt( mpi*mpi + pmx*pmx + pmy*pmy + pmz*pmz );
+          epr = TMath::Sqrt( mpr*mpr + nmx*nmx + nmy*nmy + nmz*nmz );
+        }
+        fDecayMass = TMath::Sqrt( mpi*mpi + mpr*mpr + 2*(epi*epr - pmx*nmx - pmy*nmy - pmz*nmz ) );
+        fDecayRapidity = vertex.RapLambda();
+      }
+      Double_t energy = TMath::Sqrt( fDecayMass*fDecayMass + vertex.Px()*vertex.Px() + vertex.Py()*vertex.Py() + vertex.Pz()*vertex.Pz() );
+      Double_t gamma = energy/fDecayMass;
+      fDecayDecayLength = DecayLength( &vertex, vtx )/gamma;
+      Double_t dPHI = fDecayPhi;
+      Double_t dDPHI = dPHI - fPsi2;
+      if( dDPHI < 0 ) dDPHI += TMath::TwoPi();
+      if( dDPHI > TMath::Pi() ) dDPHI = TMath::TwoPi()-dDPHI;
+      if(fQAlevel>1) {
+        if( (dDPHI>TMath::PiOver4()) && (dDPHI<3*TMath::PiOver4()) ) FillCandidateSpy("RecAllOP");
+        else FillCandidateSpy("RecAllIP");
+      }
+      FillCandidateSpy("RecAll");
+      ((TH2D*)((TList*)fList->FindObject("RecAll"))->FindObject("D0PD0N"))->Fill( pd0[p],nd0[n] );
+      ((TH2D*)((TList*)fList->FindObject("RecAll"))->FindObject("XPOSXNEG"))->Fill( xa, xb );
+      if(!AcceptCandidate()) continue;
+      if(fDecayMass<fMinMass) continue;
+      if(fDecayMass>fMaxMass) continue;
+      // PID missing
+      if(fQAlevel>1) {
+        if( (dDPHI>TMath::PiOver4()) && (dDPHI<3*TMath::PiOver4()) ) FillCandidateSpy("RecSelOP");
+        else FillCandidateSpy("RecSelIP");
+      }
+      FillCandidateSpy("RecSel");
+      ((TH2D*)((TList*)fList->FindObject("RecSel"))->FindObject("D0PD0N"))->Fill( pd0[p],nd0[n] );
+      ((TH2D*)((TList*)fList->FindObject("RecSel"))->FindObject("XPOSXNEG"))->Fill( xa, xb );
+
+      fDecayIDneg = nT->GetID();
+      fDecayIDpos = pT->GetID();
+      MakeTrack();
+      LoadTrack(pT); FillTrackSpy("TrkDau");
+      LoadTrack(nT); FillTrackSpy("TrkDau");
+
+      //===== BEGIN OF MCMATCH
+      if(stack) {
+        bool matched = false;
+        Int_t labelpos = pT->GetLabel();
+        Int_t labelneg = nT->GetLabel();
+        Double_t rOri=-1;
+        if( labelpos>0 && labelneg>0 ) {
+          TParticle *mcpos = stack->Particle( labelpos );
+          TParticle *mcneg = stack->Particle( labelneg );
+          Int_t pdgRecPos = mcpos->GetPdgCode();
+          Int_t pdgRecNeg = mcneg->GetPdgCode();
+          if( pdgRecPos==211&&pdgRecNeg==-211 ) if(mcpos->GetMother(0)>0) {
+            if( mcpos->GetMother(0)==mcneg->GetMother(0) ) {
+              TParticle *mcmot = stack->Particle( mcpos->GetMother(0) );
+              rOri = TMath::Sqrt( mcmot->Vx()*mcmot->Vx() + mcmot->Vy()*mcmot->Vy() );
+              if( TMath::Abs(mcmot->GetPdgCode())==310) {
+                if(mcmot->GetNDaughters()==2) matched=true;
+              }
+            }
+          }
+        }
+        if(matched) {
+          FillCandidateSpy("RecMth");
+          ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("D0PD0N"))->Fill( pd0[p],nd0[n] );
+          ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("XPOSXNEG"))->Fill( xa, xb );
+          ((TH1D*)((TList*)fList->FindObject("RecMth"))->FindObject("MCOrigin"))->Fill( rOri );
+          LoadTrack(pT); FillTrackSpy("TrkMth");
+          LoadTrack(nT); FillTrackSpy("TrkMth");
+        }
+      }
+      //===== END OF MCMATCH
+    }
+  }
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::ReadStack(TClonesArray* mcArray) {
+  if(!mcArray) return;
+  AliAODMCParticle *myMCTrack, *iMCDau, *jMCDau;
+  for(int i=0; i!=mcArray->GetEntriesFast(); ++i) {
+    myMCTrack = dynamic_cast<AliAODMCParticle*>(mcArray->At( i ));
+    if(!myMCTrack) continue;
+    int tPDG=310;
+    if(fSpecie>0) tPDG = 3122;
+    if( TMath::Abs(myMCTrack->PdgCode())==tPDG )
+      if( myMCTrack->GetNDaughters() == 2 ) {
+        Int_t iDau = myMCTrack->GetDaughter(0);
+        Int_t jDau = myMCTrack->GetDaughter(1);
+        AliAODMCParticle *posDau=NULL;
+        AliAODMCParticle *negDau=NULL;
+        if(iDau>0&&jDau>0) {
+          iMCDau = dynamic_cast<AliAODMCParticle*>(mcArray->At( iDau ));
+          jMCDau = dynamic_cast<AliAODMCParticle*>(mcArray->At( jDau ));
+          if(iMCDau) {
+            if(iMCDau->Charge()>0) posDau=iMCDau;
+            else negDau=iMCDau;
+          }
+          if(jMCDau) {
+            if(jMCDau->Charge()>0) posDau=jMCDau;
+            else negDau=jMCDau;
+          }
+        } //got two daughters
+        if(posDau&&negDau) {
+          Double_t dx = myMCTrack->Xv() - posDau->Xv();
+          Double_t dy = myMCTrack->Yv() - posDau->Yv();
+          Double_t dz = myMCTrack->Zv() - posDau->Zv();
+          fDecayRadXY = TMath::Sqrt( dx*dx + dy*dy );
+          TVector3 momPos(posDau->Px(),posDau->Py(),posDau->Pz());
+          TVector3 momNeg(negDau->Px(),negDau->Py(),negDau->Pz());
+          TVector3 momTot(myMCTrack->Px(),myMCTrack->Py(),myMCTrack->Pz());
+          Double_t qlpos = momPos.Dot(momTot)/momTot.Mag();
+          Double_t qlneg = momNeg.Dot(momTot)/momTot.Mag();
+          fDecayQt = momPos.Perp(momTot);
+          fDecayAlpha = 1.-2./(1.+qlpos/qlneg);
+          fDecayMass = myMCTrack->GetCalcMass();
+          Double_t energy = myMCTrack->E();
+          Double_t gamma = energy/fDecayMass;
+          fDecayDecayLength = TMath::Sqrt(dx*dx+dy*dy+dz*dz)/gamma;
+          fDecayPt = myMCTrack->Pt();
+          fDecayPhi = myMCTrack->Phi();
+          fDecayEta = myMCTrack->Eta();
+          fDecayRapidity = myMCTrack->Y();
+          fDecayDCAdaughters = 0;
+          fDecayCosinePointingAngleXY = 1;
+          fDecayProductIPXY = -1;
+          if(AcceptCandidate()) FillCandidateSpy("GenTru");
+        }
+      } // k0/lda with two daughters
+    //==== BEGIN TRACK CUTS
+    if(myMCTrack->Eta()<-0.8) continue;
+    if(myMCTrack->Eta()>+0.8) continue;
+    //==== END TRACK CUTS
+    switch( TMath::Abs(myMCTrack->PdgCode()) ) {
+    case (310): //k0s
+      FillMCParticleSpy( "MCTK0s", myMCTrack );
+      if( myMCTrack->IsPrimary() )
+        FillMCParticleSpy( "MCTK0sGenAcc", myMCTrack );
+      break;
+    case (3122): //lda
+      FillMCParticleSpy( "MCTLda", myMCTrack );
+      if( myMCTrack->IsPrimary() )
+        FillMCParticleSpy( "MCTLdaGenAcc", myMCTrack );
+      break;
+    case (333): //phi
+      if( myMCTrack->IsPrimary() )
+        FillMCParticleSpy( "MCTPhiGenAcc", myMCTrack );
+      break;
+    case (3312): //xi
+      if( myMCTrack->IsPrimary() )
+        FillMCParticleSpy( "MCTXiGenAcc", myMCTrack );
+      break;
+    }
+    
+  }
+}
+//=======================================================================
+Double_t AliAnalysisTaskFlowStrange::CosThetaPointXY(AliESDv0 *me, const AliVVertex *vtx) {
+  TVector3 mom( me->Px(), me->Py(), 0 );
+  TVector3 fli( me->Xv()-vtx->GetX(), me->Yv()-vtx->GetY(), 0 );
+  Double_t ctp = mom.Dot(fli) / mom.Mag() / fli.Mag();
+  return ctp;
+}
+//=======================================================================
+Double_t AliAnalysisTaskFlowStrange::CosThetaPointXY(AliAODv0 *me, const AliVVertex *vtx) {
+  TVector3 mom( me->Px(), me->Py(), 0 );
+  TVector3 fli( me->Xv()-vtx->GetX(), me->Yv()-vtx->GetY(), 0 );
+  Double_t ctp = mom.Dot(fli) / mom.Mag() / fli.Mag();
+  return ctp;
+}
+//=======================================================================
+Double_t AliAnalysisTaskFlowStrange::DecayLengthXY(AliESDv0 *me, const AliVVertex *vtx) {
+  Double_t dx = me->Xv()-vtx->GetX();
+  Double_t dy = me->Yv()-vtx->GetY();
+  Double_t dxy = TMath::Sqrt( dx*dx + dy*dy );
+  return dxy;
+}
+//=======================================================================
+Double_t AliAnalysisTaskFlowStrange::DecayLengthXY(AliAODv0 *me, const AliVVertex *vtx) {
+  Double_t dx = me->Xv()-vtx->GetX();
+  Double_t dy = me->Yv()-vtx->GetY();
+  Double_t dxy = TMath::Sqrt( dx*dx + dy*dy );
+  return dxy;
+}
+//=======================================================================
+Double_t AliAnalysisTaskFlowStrange::DecayLength(AliESDv0 *me, const AliVVertex *vtx) {
+  Double_t dx = me->Xv()-vtx->GetX();
+  Double_t dy = me->Yv()-vtx->GetY();
+  Double_t dz = me->Zv()-vtx->GetZ();
+  Double_t dxy = TMath::Sqrt( dx*dx + dy*dy + dz*dz );
+  return dxy;
+}
+//=======================================================================
+Double_t AliAnalysisTaskFlowStrange::DecayLength(AliAODv0 *me, const AliVVertex *vtx) {
+  Double_t dx = me->Xv()-vtx->GetX();
+  Double_t dy = me->Yv()-vtx->GetY();
+  Double_t dz = me->Zv()-vtx->GetZ();
+  Double_t dxy = TMath::Sqrt( dx*dx + dy*dy + dz*dz );
+  return dxy;
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::ReadFromAODv0(AliAODEvent *tAOD) {
+  TClonesArray* mcArray=NULL;
+  if(fReadMC) {
+    mcArray = dynamic_cast<TClonesArray*>(tAOD->FindListObject(AliAODMCParticle::StdBranchName()));
+    ReadStack(mcArray);
+  }
+
+  Int_t nV0s = tAOD->GetNumberOfV0s();
+  AliAODv0 *myV0;
+  Int_t v0all=0, v0imw=0;
+  for (Int_t i=0; i!=nV0s; ++i) {
+    myV0 = (AliAODv0*) tAOD->GetV0(i);
+    if(!myV0) continue;
+    if(!fOnline) if(myV0->GetOnFlyStatus() ) continue;
+    if(fOnline) if(!myV0->GetOnFlyStatus() ) continue;
+    AliAODTrack *iT, *jT;
+    AliAODVertex *vtx = tAOD->GetPrimaryVertex();
+    Double_t pos[3],cov[6];
+    vtx->GetXYZ(pos);
+    vtx->GetCovarianceMatrix(cov);
+    const AliESDVertex vESD(pos,cov,100.,100);
+    // TESTING CHARGE
+    int iPos, iNeg;
+    iT=(AliAODTrack*) myV0->GetDaughter(0);
+    if(iT->Charge()>0) {
+      iPos = 0; iNeg = 1;
+    } else {
+      iPos = 1; iNeg = 0;
+    }
+    // END OF TEST
+
+    iT=(AliAODTrack*) myV0->GetDaughter(iPos); // positive
+    AliESDtrack ieT( iT );
+    ieT.SetTPCClusterMap( iT->GetTPCClusterMap() );
+    ieT.SetTPCSharedMap( iT->GetTPCSharedMap() );
+    ieT.SetTPCPointsF( iT->GetTPCNclsF() );
+    ieT.PropagateToDCA(&vESD, tAOD->GetMagneticField(), 100);
+    LoadTrack(&ieT,iT->Chi2perNDF());
+    Float_t ip[2];
+    ieT.GetDZ(pos[0], pos[1], pos[2], tAOD->GetMagneticField(), ip);
+    fDaughterImpactParameterXY = ip[0];
+    fDaughterImpactParameterZ = ip[1];
+    Double_t dD0P = fDaughterImpactParameterXY; //ieT.GetD(pos[0], pos[1], tAOD->GetMagneticField());
+    if(!AcceptDaughter()) continue;
+
+    jT=(AliAODTrack*) myV0->GetDaughter(iNeg); // negative
+    AliESDtrack jeT( jT );
+    jeT.SetTPCClusterMap( jT->GetTPCClusterMap() );
+    jeT.SetTPCSharedMap( jT->GetTPCSharedMap() );
+    jeT.SetTPCPointsF( jT->GetTPCNclsF() );
+    jeT.PropagateToDCA(&vESD, tAOD->GetMagneticField(), 100);
+    LoadTrack(&jeT,jT->Chi2perNDF());
+    jeT.GetDZ(pos[0], pos[1], pos[2], tAOD->GetMagneticField(), ip);
+    fDaughterImpactParameterXY = ip[0];
+    fDaughterImpactParameterZ = ip[1];
+    Double_t dD0N = fDaughterImpactParameterXY; //jeT.GetD(pos[0], pos[1], tAOD->GetMagneticField());
+    if(!AcceptDaughter()) continue;
+    if( fExcludeTPCEdges ) {
+      if( IsAtTPCEdge(iT->Phi(),iT->Pt(),+1,tAOD->GetMagneticField()) ) continue;
+      if( IsAtTPCEdge(jT->Phi(),jT->Pt(),-1,tAOD->GetMagneticField()) ) continue;
+    }
+    Double_t xa, xb;
+    ieT.GetDCA(&jeT,tAOD->GetMagneticField(),xa,xb);
+    /*
+    // cutting out population close to TPC edges :: strange excess saw in 2010
+    if( fExcludeTPCEdges ) {
+    Double_t phimod = myV0->Phi();
+    int sectors[6] = {5,6,9,10,11,12};
+    for(int ii=0; ii!=6; ++ii)
+    if( (phimod<(sectors[ii]+1)*TMath::Pi()/9.0) && (phimod>sectors[ii]*TMath::Pi()/9.0) )
+    return 0;
+    }
+    */
+    if(fSpecie==0)
+      fDecayRapidity = myV0->RapK0Short();
+    else
+      fDecayRapidity = myV0->RapLambda();
+    fDecayDCAdaughters = myV0->DcaV0Daughters();
+    fDecayCosinePointingAngleXY = CosThetaPointXY( myV0, vtx );
+    fDecayRadXY = DecayLengthXY( myV0, vtx );
+    fDecayPt = myV0->Pt();
+    fDecayPhi = myV0->Phi();
+    fDecayEta = myV0->Eta();
+    fDecayProductIPXY = dD0P*dD0N;
+    fDecayQt = myV0->PtArmV0();
+    fDecayAlpha = myV0->AlphaV0(); // AlphaV0 -> AODRecoDecat::Alpha -> return 1.-2./(1.+QlProng(0)/QlProng(1));
+    if(myV0->ChargeProng(iPos)<0) fDecayAlpha = -fDecayAlpha; // protects for a change in convention
+    fDecayPt = myV0->Pt();
+    fDecayEta = myV0->Eta();
+    if( fSpecie==0 ) {
+      fDecayMass = myV0->MassK0Short();
+    } else {
+      if(fDecayAlpha>0) fDecayMass = myV0->MassLambda();
+      else fDecayMass = myV0->MassAntiLambda();
+    }
+    v0all++;
+    if(fDecayMass<fMinMass) continue;
+    if(fDecayMass>fMaxMass) continue;
+    v0imw++;
+    Double_t energy = TMath::Sqrt( fDecayMass*fDecayMass + myV0->Px()*myV0->Px() + myV0->Py()*myV0->Py() + myV0->Pz()*myV0->Pz() );
+    Double_t gamma = energy/fDecayMass;
+    fDecayDecayLength = DecayLength( myV0, vtx )/gamma;
+    Double_t dPHI = fDecayPhi;
+    Double_t dDPHI = dPHI - fPsi2;
+    if( dDPHI < 0 ) dDPHI += TMath::TwoPi();
+    if( dDPHI > TMath::Pi() ) dDPHI = TMath::TwoPi()-dDPHI;
+    if(fQAlevel>1) {
+      if( (dDPHI>TMath::PiOver4()) && (dDPHI<3*TMath::PiOver4()) ) FillCandidateSpy("RecAllOP");
+      else FillCandidateSpy("RecAllIP");
+    }
+    FillCandidateSpy("RecAll");
+    ((TH2D*)((TList*)fList->FindObject("RecAll"))->FindObject("D0PD0N"))->Fill( dD0P, dD0N );
+    ((TH2D*)((TList*)fList->FindObject("RecAll"))->FindObject("XPOSXNEG"))->Fill( xa, xb );
+    if(!AcceptCandidate()) continue;
+    //PID for lambda::proton
+    if( fSpecie>0 )
+      if(fDecayPt<1.2) {
+        if(fDecayAlpha>0) {
+          if( !PassesPIDCuts(&ieT) ) continue; //positive track
+        } else {
+          if( !PassesPIDCuts(&jeT) ) continue; //negative track
+        }
+      }
+    if(fQAlevel>1) {
+      if( (dDPHI>TMath::PiOver4()) && (dDPHI<3*TMath::PiOver4()) ) FillCandidateSpy("RecSelOP");
+      else FillCandidateSpy("RecSelIP");
+    }
+    FillCandidateSpy("RecSel");
+    ((TH2D*)((TList*)fList->FindObject("RecSel"))->FindObject("D0PD0N"))->Fill( dD0P, dD0N );
+    ((TH2D*)((TList*)fList->FindObject("RecSel"))->FindObject("XPOSXNEG"))->Fill( xa, xb );
+    fDecayIDneg = iT->GetID();
+    fDecayIDpos = jT->GetID();
+    MakeTrack();
+    LoadTrack(&ieT,iT->Chi2perNDF());
+    ieT.GetDZ(pos[0], pos[1], pos[2], tAOD->GetMagneticField(), ip);
+    fDaughterImpactParameterXY = ip[0];
+    fDaughterImpactParameterZ = ip[1];
+    FillTrackSpy("TrkDau");
+    LoadTrack(&jeT,jT->Chi2perNDF()); 
+    jeT.GetDZ(pos[0], pos[1], pos[2], tAOD->GetMagneticField(), ip);
+    fDaughterImpactParameterXY = ip[0];
+    fDaughterImpactParameterZ = ip[1];
+    FillTrackSpy("TrkDau");
+    //===== BEGIN OF MCMATCH                                                                                                                         
+    if(mcArray) {
+      bool matched = false;
+      bool feeddown = false;
+      Int_t labelpos = iT->GetLabel();
+      Int_t labelneg = jT->GetLabel();
+      Double_t rOri=-1;
+      Double_t mcPt=-1, mcEta=-1, mcRap=-1, mcRxy=-1, mcDle=-1, mcApa=-100, mcApq=-1;
+      Double_t resPt=-1, resEta=-1, resRap=-1, resRxy=-1, resDle=-1, resApa=-1, resApq=-1;
+      if( labelpos>0 && labelneg>0 ) {
+        AliAODMCParticle *mcpos = (AliAODMCParticle*) mcArray->At( labelpos );
+        AliAODMCParticle *mcneg = (AliAODMCParticle*) mcArray->At( labelneg );
+        Int_t pdgRecPos = mcpos->GetPdgCode();
+        Int_t pdgRecNeg = mcneg->GetPdgCode();
+        int pospdg=211, negpdg=211;
+        int mompdg=310, fdwpdg=333;
+        if(fSpecie>0) {
+          mompdg=3122;
+          fdwpdg=3312;
+          if(fDecayAlpha>0) {
+            pospdg=2212; negpdg=211;
+          } else {
+            negpdg=2212; pospdg=211;
+          }
+        }
+        if( TMath::Abs(pdgRecPos)==pospdg&&TMath::Abs(pdgRecNeg)==negpdg )
+          if(mcpos->GetMother()>0)
+            if( mcpos->GetMother()==mcneg->GetMother() ) {
+              AliAODMCParticle *mcmot = (AliAODMCParticle*) mcArray->At( mcpos->GetMother() );
+              rOri = TMath::Sqrt( mcmot->Xv()*mcmot->Xv() + mcmot->Yv()*mcmot->Yv() );
+              mcPt = mcmot->Pt();
+              mcEta = TMath::Abs( mcmot->Eta() );
+              mcRap = TMath::Abs( mcmot->Y() );
+              if(!TMath::AreEqualAbs(mcPt,0,1e-6))  resPt = (fDecayPt - mcPt) / mcPt;
+              if(!TMath::AreEqualAbs(mcEta,0,1e-6)) resEta = (fDecayEta - mcEta) / mcEta;
+              if(!TMath::AreEqualAbs(mcRap,0,1e-6)) resRap = (fDecayRapidity - mcRap) / mcRap;
+              if( TMath::Abs(mcmot->GetPdgCode())==mompdg) {
+                if(mcmot->GetNDaughters()==2) {
+                  matched=true;
+                  Double_t dx = mcmot->Xv() - mcpos->Xv();
+                  Double_t dy = mcmot->Yv() - mcpos->Yv();
+                  Double_t dz = mcmot->Zv() - mcpos->Zv();
+                  Double_t mcGamma = mcmot->E() / mcmot->GetCalcMass();
+                  mcRxy = TMath::Sqrt( dx*dx + dy*dy );
+                  mcDle = TMath::Sqrt(dx*dx+dy*dy+dz*dz)/mcGamma;
+                  if(!TMath::AreEqualAbs(mcRxy,0,1e-6)) resRxy = (fDecayRadXY - mcRxy) / mcRxy;
+                  if(!TMath::AreEqualAbs(mcDle,0,1e-6)) resDle = (fDecayDecayLength - mcDle) / mcDle;
+                  TVector3 momPos(mcpos->Px(),mcpos->Py(),mcpos->Pz());
+                  TVector3 momNeg(mcneg->Px(),mcneg->Py(),mcneg->Pz());
+                  TVector3 momTot(mcmot->Px(),mcmot->Py(),mcmot->Pz());
+                  Double_t qlpos = momPos.Dot(momTot)/momTot.Mag();
+                  Double_t qlneg = momNeg.Dot(momTot)/momTot.Mag();
+                  mcApq = momPos.Perp(momTot);
+                  mcApa = 1.-2./(1.+qlpos/qlneg);
+                  if(!TMath::AreEqualAbs(mcApq,0,1e-6)) resApq = (fDecayQt - mcApq) / mcApq;
+                  if(!TMath::AreEqualAbs(mcApa,0,1e-6)) resApa = (fDecayAlpha - mcApa) / mcApa;
+                }
+                if(mcmot->GetMother()>0) {
+                  AliAODMCParticle *mcfdw = (AliAODMCParticle*) mcArray->At( mcmot->GetMother() );
+                  if( TMath::Abs(mcfdw->GetPdgCode())==fdwpdg)
+                    feeddown=true;
+                } // k0/lda have mother
+              } // mother matches k0/lda
+            } // both have same mother
+      } // match to MCparticles
+      if(matched) {
+        FillCandidateSpy("RecMth");
+        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("D0PD0N"))->Fill( dD0P,dD0N );
+        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("XPOSXNEG"))->Fill( xa, xb );
+        ((TH1D*)((TList*)fList->FindObject("RecMth"))->FindObject("MCOrigin"))->Fill( rOri );
+        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("PTRes"))->Fill( mcPt, resPt );
+        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("ETARes"))->Fill( mcEta, resEta );
+        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("RAPRes"))->Fill( mcRap, resRap );
+        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("RXYRes"))->Fill( mcRxy, resRxy );
+        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("DLERes"))->Fill( mcDle, resDle );
+        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("APARes"))->Fill( mcApa, resApa );
+        ((TH2D*)((TList*)fList->FindObject("RecMth"))->FindObject("APQRes"))->Fill( mcApq, resApq );
+        LoadTrack(&ieT,iT->Chi2perNDF());
+        ieT.GetDZ(pos[0], pos[1], pos[2], tAOD->GetMagneticField(), ip);
+        fDaughterImpactParameterXY = ip[0];
+        fDaughterImpactParameterZ = ip[1];
+        FillTrackSpy("TrkMth");
+        LoadTrack(&jeT,jT->Chi2perNDF());
+        jeT.GetDZ(pos[0], pos[1], pos[2], tAOD->GetMagneticField(), ip);
+        fDaughterImpactParameterXY = ip[0];
+        fDaughterImpactParameterZ = ip[1];
+        FillTrackSpy("TrkMth");
+      }
+      if(feeddown) {
+        FillCandidateSpy("MthFDW");
+        ((TH2D*)((TList*)fList->FindObject("MthFDW"))->FindObject("D0PD0N"))->Fill( dD0P,dD0N );
+        ((TH1D*)((TList*)fList->FindObject("MthFDW"))->FindObject("MCOrigin"))->Fill( rOri );
+      }
+    }
+    //===== END OF MCMATCH
+  }
+  ((TH2D*)((TList*)fList->FindObject("RecAll"))->FindObject("V0SADC"))->Fill( v0all,v0imw );
+  return;
+}
+//=======================================================================
+Bool_t AliAnalysisTaskFlowStrange::PassesPIDCuts(AliESDtrack *myTrack, AliPID::EParticleType pid) {
+  Bool_t pass=kTRUE;
+  if(fPIDResponse) {
+    fDaughterNSigmaPID = fPIDResponse->NumberOfSigmasTPC(myTrack,pid);
+    if( TMath::Abs(fDaughterNSigmaPID) > fDaughterMaxNSigmaPID )
+      pass = kFALSE;
+  }
+  return pass;
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::ChargeParticles(AliAODEvent *tAOD) {
+  //benchmark purposes (for the ultimate measurement for LHC10h see Alex, Francesco)
+  if(!tAOD) return;
+  // (for the moment) only compatible with SPVZE (no untagging)
+  for(int i=0; i!=tAOD->GetNumberOfTracks(); ++i) {
+    AliAODTrack *t = tAOD->GetTrack( i );
+    if(!t) continue;
+    if( !t->TestFilterBit(1024) ) continue;
+    fDecayMass=0.0; // using mass as nsigmas control plot
+    if(fPIDResponse) { // PID
+      switch(fSpecie) { // TPC PID only
+      case(kPION):
+        fDecayMass = fPIDResponse->NumberOfSigmasTPC(t,AliPID::kPion);
+        break;
+      case(kKAON):
+        fDecayMass = fPIDResponse->NumberOfSigmasTPC(t,AliPID::kKaon);
+        break;
+      case(kPROTON):
+        fDecayMass = fPIDResponse->NumberOfSigmasTPC(t,AliPID::kProton);
+        break;
+      }
+    }
+    Bool_t pass = kTRUE;
+    if( TMath::Abs(fDecayMass) > 3.0 ) pass=kFALSE;
+    if( t->Eta()<-0.8 || t->Eta()>+0.8 ) pass=kFALSE;
+    if( t->Pt()<0.2 || t->Pt()>20.0 ) pass=kFALSE;
+    if( t->GetTPCsignal()<10.0 ) pass=kFALSE;
+    fDecayPt=t->Pt();
+    fDecayPhi=t->Phi();
+    fDecayEta=t->Eta();
+    fDecayID=t->GetID();
+
+    FillCandidateSpy("RecAll");
+    if(!pass) continue;
+
+    AliESDtrack et( t );
+    et.SetTPCClusterMap( t->GetTPCClusterMap() );
+    et.SetTPCSharedMap( t->GetTPCSharedMap() );
+    et.SetTPCPointsF( t->GetTPCNclsF() );
+    Float_t ip[2];
+    LoadTrack(&et,t->Chi2perNDF()); 
+    AliAODVertex *vtx = tAOD->GetPrimaryVertex();
+    Double_t pos[3];
+    vtx->GetXYZ(pos);
+    et.GetDZ(pos[0], pos[1], pos[2], tAOD->GetMagneticField(), ip);
+    fDaughterImpactParameterXY = ip[0];
+    fDaughterImpactParameterZ = ip[1];
+    FillTrackSpy("TrkDau");
+    FillCandidateSpy("RecSel");
+
+    MakeTrack();
+  }
+  return;
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::Terminate(Option_t *) {
+  //terminate
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::MakeTrack() {
+  // create track for flow tasks
+  if(fCandidates->GetLast()+5>fCandidates->GetSize()) {
+    fCandidates->Expand( fCandidates->GetSize()+20 );
+  }
+  Bool_t overwrite = kTRUE;
+  AliFlowCandidateTrack *oTrack = (static_cast<AliFlowCandidateTrack*> (fCandidates->At( fCandidates->GetLast()+1 )));
+  if( !oTrack ) { // creates new
+    oTrack = new AliFlowCandidateTrack();
+    overwrite = kFALSE;
+  } else { // overwrites
+    oTrack->ClearMe();
+  }
+  oTrack->SetMass(fDecayMass);
+  oTrack->SetPt(fDecayPt);
+  oTrack->SetPhi(fDecayPhi);
+  oTrack->SetEta(fDecayEta);
+  if(fSpecie<10) {
+    oTrack->AddDaughter(fDecayIDpos);
+    oTrack->AddDaughter(fDecayIDneg);
+  } else {
+    oTrack->SetID( fDecayID );
+  }
+  oTrack->SetForPOISelection(kTRUE);
+  oTrack->SetForRPSelection(kFALSE);
+  if(overwrite) {
+    fCandidates->SetLast( fCandidates->GetLast()+1 );
+  } else {
+    fCandidates->AddLast(oTrack);
+  }
+  return;
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::AddCandidates() {
+  // adds candidates to flow events (untaging if necessary)
+  if(fDebug) printf("FlowEventTPC %d tracks | %d RFP | %d POI\n",fTPCevent->NumberOfTracks(),fTPCevent->GetNumberOfRPs(),fTPCevent->GetNumberOfPOIs());
+  if(fDebug) printf("FlowEventVZE %d tracks | %d RFP | %d POI\n",fVZEevent->NumberOfTracks(),fVZEevent->GetNumberOfRPs(),fVZEevent->GetNumberOfPOIs());
+  if(fDebug) printf("I received %d candidates\n",fCandidates->GetEntriesFast());
+  Int_t untagged=0;
+  Int_t poi=0;
+  for(int iCand=0; iCand!=fCandidates->GetEntriesFast(); ++iCand ) {
+    AliFlowCandidateTrack *cand = static_cast<AliFlowCandidateTrack*>(fCandidates->At(iCand));
+    if(!cand) continue;
+    cand->SetForPOISelection(kTRUE);
+    cand->SetForRPSelection(kFALSE);
+    poi++;
+    if(fDebug) printf(" >Checking at candidate %d with %d daughters: mass %f\n",
+                      iCand,cand->GetNDaughters(),cand->Mass());
+    if(fSpecie<10) { // DECAYS
+      // untagging ===>
+      if(fDaughterUnTag) {
+       for(int iDau=0; iDau!=cand->GetNDaughters(); ++iDau) {
+         if(fDebug) printf("  >Daughter %d with fID %d", iDau, cand->GetIDDaughter(iDau));
+         for(int iRPs=0; iRPs!=fTPCevent->NumberOfTracks(); ++iRPs ) {
+           AliFlowTrack *iRP = static_cast<AliFlowTrack*>(fTPCevent->GetTrack( iRPs ));
+           if(!iRP) continue;
+           if(!iRP->InRPSelection()) continue;
+           if(cand->GetIDDaughter(iDau) == iRP->GetID()) {
+             if(fDebug) printf(" was in RP set");
+             ++untagged;
+             iRP->SetForRPSelection(kFALSE);
+             fTPCevent->SetNumberOfRPs( fTPCevent->GetNumberOfRPs() -1 );
+           }
+         }
+         if(fDebug) printf("\n");
+       }
+      }
+      // <=== untagging 
+      fTPCevent->InsertTrack( ((AliFlowTrack*) cand) );
+    } else {  // CHARGED
+      // adding only new tracks and tagging accordingly ===>
+      Bool_t found=kFALSE;
+      for(int iRPs=0; iRPs!=fTPCevent->NumberOfTracks(); ++iRPs ) {
+        AliFlowTrack *iRP = static_cast<AliFlowTrack*>(fTPCevent->GetTrack( iRPs ));
+        if(!iRP) continue;
+        if(!iRP->InRPSelection()) continue;
+        if(cand->GetID() == iRP->GetID()) {
+          if(fDebug) printf("  >charged track (%d) was also found in RP set (adding poi tag)\n",cand->GetID());
+          iRP->SetForPOISelection(kTRUE);
+          found = kTRUE;
+        }
+      }
+      if(!found) // not found adding track
+        fTPCevent->InsertTrack( ((AliFlowTrack*) cand) );
+    }
+    fVZEevent->InsertTrack( ((AliFlowTrack*) cand) );
+  } //END OF LOOP
+  fTPCevent->SetNumberOfPOIs( poi );
+  fVZEevent->SetNumberOfPOIs( poi );
+  ((TH1D*)((TList*)fList->FindObject("Event"))->FindObject("POI"))->Fill( poi );
+  ((TH1D*)((TList*)fList->FindObject("Event"))->FindObject("UNTAG"))->Fill( untagged );
+  if(fDebug) printf("FlowEventTPC %d tracks | %d RFP | %d POI\n",fTPCevent->NumberOfTracks(),fTPCevent->GetNumberOfRPs(),fTPCevent->GetNumberOfPOIs());
+  if(fDebug) printf("FlowEventVZE %d tracks | %d RFP | %d POI\n",fVZEevent->NumberOfTracks(),fVZEevent->GetNumberOfRPs(),fVZEevent->GetNumberOfPOIs());
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::PushBackFlowTrack(AliFlowEvent *flowevent, Double_t pt, Double_t phi, Double_t eta, Double_t w, Int_t id) {
+  AliFlowTrack rfp;
+  rfp.SetPt(pt);
+  rfp.SetPhi(phi);
+  rfp.SetEta(eta);
+  rfp.SetWeight(w);
+  rfp.SetForRPSelection(kTRUE);
+  rfp.SetForPOISelection(kFALSE);
+  rfp.SetID(id);
+  flowevent->InsertTrack( &rfp );
+}
+//=======================================================================
+Bool_t AliAnalysisTaskFlowStrange::IsAtTPCEdge(Double_t phi,Double_t pt,Int_t charge,Double_t b) {
+  // Origin: Alex Dobrin
+  // Implemented by Carlos Perez
+  TF1 cutLo("cutLo", "-0.01/x+pi/18.0-0.015", 0, 100);
+  TF1 cutHi("cutHi", "0.55/x/x+pi/18.0+0.03", 0, 100);
+  Double_t phimod = phi;
+  if(b<0) phimod = TMath::TwoPi()-phimod;  //for negatve polarity field
+  if(charge<0) phimod = TMath::TwoPi()-phimod; //for negatve charge
+  phimod += TMath::Pi()/18.0;
+  phimod = fmod(phimod, TMath::Pi()/9.0);
+  if( phimod<cutHi.Eval(pt) && phimod>cutLo.Eval(pt) )
+    return kTRUE;
+
+  return kFALSE;
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::MakeQVectors() {
+  //computes event plane and updates fPsi2
+  //if there is a problem fPsi->-1
+  fPsi2=-1;
+  Double_t vzeqax, vzeqay, vzeqaw, vzeqbx, vzeqby, vzeqbw;
+  Double_t tpcqax, tpcqay, tpcqaw, tpcqbx, tpcqby, tpcqbw;
+  //=>loading event
+  MakeQVZE(InputEvent(),vzeqax,vzeqay,vzeqaw,vzeqbx,vzeqby,vzeqbw);
+  MakeQTPC(InputEvent(),tpcqax,tpcqay,tpcqaw,tpcqbx,tpcqby,tpcqbw);
+  //=>computing psi
+  //VZERO
+  Double_t vqx, vqy;
+  vqx=vqy=0;
+  Double_t psivzea,psivzeb,psivze,vzew;
+  psivzea = ( TMath::Pi()+TMath::ATan2(-vzeqay,-vzeqax) )/2.0;
+  psivzeb = ( TMath::Pi()+TMath::ATan2(-vzeqby,-vzeqbx) )/2.0;
+  vqx = vzeqax + vzeqbx;
+  vqy = vzeqay + vzeqby;
+  vzew = vzeqaw + vzeqbw;
+  psivze = ( TMath::Pi()+TMath::ATan2(-vqy,-vqx) )/2.0;
+  //TPC
+  Double_t tqx, tqy;
+  tqx=tqy=0;
+  Double_t psitpca,psitpcb,psitpc,tpcw;
+  psitpca = ( TMath::Pi()+TMath::ATan2(-tpcqay,-tpcqax) )/2.0;
+  psitpcb = ( TMath::Pi()+TMath::ATan2(-tpcqby,-tpcqbx) )/2.0;
+  tqx = tpcqax + tpcqbx;
+  tqy = tpcqay + tpcqby;
+  tpcw = tpcqaw + tpcqbw;
+  psitpc = ( TMath::Pi()+TMath::ATan2(-tqy,-tqx) )/2.0;
+  //=>does the event clear?
+  switch(fWhichPsi) {
+  case(1): //VZERO
+    if( (vzeqaw<2)||(vzeqbw<2) ) return;
+    fPsi2 = psivze;
+    break;
+  case(2): //TPC
+    if( (tpcqaw<2)||(tpcqbw<2) ) return;
+    fPsi2 = psitpc;
+    break;
+  }
+  //=>great! recording
+  ((TH1D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("VZEPSI"))->Fill( psivze );
+  ((TH1D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("VZEPSIA"))->Fill( psivzea );
+  ((TH1D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("VZEPSIB"))->Fill( psivzeb );
+  ((TH1D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("RFPVZE"))->Fill( vzew );
+  //------
+  ((TH1D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCPSI"))->Fill( psitpc );
+  ((TH1D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCPSIA"))->Fill( psitpca );
+  ((TH1D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCPSIB"))->Fill( psitpcb );
+  ((TH1D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("RFPTPC"))->Fill( tpcw );
+  //------
+  ((TProfile*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCQ"))->Fill( 1., tpcqay/tpcqaw, tpcqaw );
+  ((TProfile*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCQ"))->Fill( 2., tpcqax/tpcqaw, tpcqaw );
+  ((TProfile*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCQ"))->Fill( 3., tpcqby/tpcqbw, tpcqbw );
+  ((TProfile*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCQ"))->Fill( 4., tpcqbx/tpcqbw, tpcqbw );
+  ((TProfile*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCQ"))->Fill( 5., tqy/tpcw, tpcw );
+  ((TProfile*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCQ"))->Fill( 6., tqx/tpcw, tpcw );
+  //------
+  ((TProfile*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("VZEQ"))->Fill( 1., vzeqay/vzeqaw, vzeqaw );
+  ((TProfile*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("VZEQ"))->Fill( 2., vzeqax/vzeqaw, vzeqaw );
+  ((TProfile*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("VZEQ"))->Fill( 3., vzeqby/vzeqbw, vzeqbw );
+  ((TProfile*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("VZEQ"))->Fill( 4., vzeqbx/vzeqbw, vzeqbw );
+  ((TProfile*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("VZEQ"))->Fill( 5., vqy/vzew, vzew );
+  ((TProfile*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("VZEQ"))->Fill( 6., vqx/vzew, vzew );
+
+  return;
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::MakeQVZE(AliVEvent *tevent,
+                                          Double_t &qxa,Double_t &qya,Double_t &qwa,
+                                          Double_t &qxb,Double_t &qyb,Double_t &qwb) {
+  //=>cleaning
+  if(fUseFP) fVZEevent->ClearFast();
+  //=>external weights
+  Double_t extW[64];
+  for(int i=0;i!=64;++i) extW[i]=1;
+  if((!fVZEsave)&&(fVZEResponse)) {
+    Double_t minC = fCentPerMin, maxC = fCentPerMax;
+    if(fVZEmb) {
+      minC = 0;
+      maxC = 80;
+    }
+    Int_t ybinmin = fVZEResponse->GetYaxis()->FindBin(minC+1e-6);
+    Int_t ybinmax = fVZEResponse->GetYaxis()->FindBin(maxC-1e-6);
+    for(int i=0;i!=64;++i) extW[i] = fVZEResponse->Integral(i+1,i+1,ybinmin,ybinmax)/(maxC-minC);
+    //ring-wise normalization
+    Double_t ring[8];
+    for(int j=0; j!=8; ++j) {
+      ring[j]=0;
+      for(int i=0;i!=8;++i) ring[j] += extW[j*8+i]/8;
+    }
+    //disk-wise normalization
+    Double_t disk[2];
+    int xbinmin, xbinmax;
+    xbinmin = 1+8*fVZECa;
+    xbinmax = 8+8*fVZECb;
+    disk[0] = fVZEResponse->Integral(xbinmin,xbinmax,ybinmin,ybinmax)/(maxC-minC)/(xbinmax-xbinmin+1);
+    xbinmin = 33+8*fVZEAa;
+    xbinmax = 40+8*fVZEAb;
+    disk[1] = fVZEResponse->Integral(xbinmin,xbinmax,ybinmin,ybinmax)/(maxC-minC)/(xbinmax-xbinmin+1);
+    //for(int i=0;i!=64;++i) printf("CELL %d -> W = %f ||",i,extW[i]);
+
+    if(fVZEByDisk) {
+      for(int i=0;i!=64;++i) extW[i] = disk[i/32]/extW[i];
+    } else {
+      for(int i=0;i!=64;++i) extW[i] = ring[i/8]/extW[i];
+    }
+    //for(int i=0;i!=64;++i) printf(" W = %f \n",extW[i]);
+  }
+  //=>computing
+  qxa=qya=qwa=qxb=qyb=qwb=0;
+  Int_t rfp=0;
+  Double_t eta, phi, w;
+  //v0c -> qa
+  for(int id=fVZECa*8;id!=8+fVZECb*8;++id) {
+    eta = -3.45+0.5*(id/8);
+    phi = TMath::PiOver4()*(0.5+id%8);
+    w = tevent->GetVZEROEqMultiplicity(id)*extW[id];
+    qxa += w*TMath::Cos(2*phi);
+    qya += w*TMath::Sin(2*phi);
+    qwa += w;
+    ((TH2D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("VZEAllPhiEta"))->Fill( phi, eta, w );
+    rfp++;
+    if(fUseFP) PushBackFlowTrack(fVZEevent,0,phi,eta,w,0);
+  }
+  //v0a -> qb
+  for(int id=32+fVZEAa*8;id!=40+fVZEAb*8;++id) {
+    eta = +4.8-0.6*((id/8)-4);
+    phi = TMath::PiOver4()*(0.5+id%8);
+    w = tevent->GetVZEROEqMultiplicity(id)*extW[id];
+    qxb += w*TMath::Cos(2*phi);
+    qyb += w*TMath::Sin(2*phi);
+    qwb += w;
+    ((TH2D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("VZEAllPhiEta"))->Fill( phi, eta, w );
+    rfp++;
+    if(fUseFP) PushBackFlowTrack(fVZEevent,0,phi,eta,w,0);
+  }
+  if(fUseFP) fVZEevent->SetNumberOfRPs(rfp);
+  if(fDebug>0&&fUseFP) printf("Inserted tracks in FlowEventVZE %d ==> %.1f\n",fVZEevent->NumberOfTracks(),qwa+qwb);
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::AddTPCRFPSpy(TList *me) {
+  TH1D *tH1D;
+  tH1D = new TH1D("PT",   "PT",           50,0,5);     me->Add(tH1D);
+  tH1D = new TH1D("PHI",  "PHI", 90,0,TMath::TwoPi()); me->Add(tH1D);
+  tH1D = new TH1D("ETA",  "ETA",          40,-1,+1);   me->Add(tH1D);
+  tH1D = new TH1D("TPCS", "TPC Signal",   100,0,500);  me->Add(tH1D);
+  tH1D = new TH1D("IPXY", "IPXY",         100,-2,+2);  me->Add(tH1D);
+  tH1D = new TH1D("IPZ",  "IPZ",          100,-2,+2);  me->Add(tH1D);
+  // TPC
+  tH1D = new TH1D("TPCNCLS", "NCLS", 170,-0.5,+169.5);   me->Add(tH1D);
+  tH1D = new TH1D("TPCSHCL", "NSCLS / NCLS", 100,0,1);   me->Add(tH1D);
+  tH1D = new TH1D("TPCFICL", "NCLS1I / NCLS",100,0,1);   me->Add(tH1D);
+  tH1D = new TH1D("TPCXRNF", "XROW / NFCLS", 100,0,1.5); me->Add(tH1D);
+  tH1D = new TH1D("TPCRCHI", "CHI2 / NCLS",  50,0,5);    me->Add(tH1D);
+  // ITS
+  tH1D = new TH1D("ITSNCLS", "NCLS",   7,-0.5,+6.5); me->Add(tH1D);
+  tH1D = new TH1D("ITSRCHI", "CHI2 / NCLS", 50,0,5); me->Add(tH1D);
+
+}
+//=======================================================================
+Bool_t AliAnalysisTaskFlowStrange::PassesRFPTPCCuts(AliESDtrack *track, Double_t aodchi2cls, Float_t aodipxy, Float_t aodipz) {
+  if(track->GetKinkIndex(0)>0) return kFALSE;
+  if( (track->GetStatus()&AliESDtrack::kTPCrefit)==0 ) return kFALSE;
+  Double_t pt = track->Pt();
+  Double_t phi = track->Phi();
+  Double_t eta = track->Eta();
+  Double_t tpcs = track->GetTPCsignal();
+  Float_t ipxy, ipz;
+  track->GetImpactParameters(ipxy,ipz);
+  Int_t cls = track->GetTPCclusters(0);
+  Double_t xrows, findcls, chi2;
+  findcls = track->GetTPCNclsF();
+  xrows = track->GetTPCCrossedRows();
+  chi2 = track->GetTPCchi2();
+  Double_t rchi2 = chi2/cls;
+  if(!fReadESD) {
+    rchi2 = aodchi2cls;
+    ipxy = aodipxy;
+    ipz = aodipz;
+  }
+  Double_t xrnfcls = xrows/findcls;
+  Double_t scls, cls1i, itschi2;
+  Int_t itscls;
+  cls1i = track->GetTPCNclsIter1();
+  scls = track->GetTPCnclsS();
+  itscls = track->GetITSclusters(0);
+  itschi2 = track->GetITSchi2();
+  Double_t shcl = scls/cls;
+  Double_t ficl = cls1i/cls;
+  Double_t itsrchi2 = itscls/itschi2;
+  ((TH1D*)((TList*)fList->FindObject("TPCRFPall"))->FindObject("PT"))->Fill( pt );
+  ((TH1D*)((TList*)fList->FindObject("TPCRFPall"))->FindObject("PHI"))->Fill( phi );
+  ((TH1D*)((TList*)fList->FindObject("TPCRFPall"))->FindObject("ETA"))->Fill( eta );
+  ((TH1D*)((TList*)fList->FindObject("TPCRFPall"))->FindObject("TPCS"))->Fill( tpcs );
+  ((TH1D*)((TList*)fList->FindObject("TPCRFPall"))->FindObject("IPXY"))->Fill( ipxy );
+  ((TH1D*)((TList*)fList->FindObject("TPCRFPall"))->FindObject("IPZ"))->Fill( ipz );
+  ((TH1D*)((TList*)fList->FindObject("TPCRFPall"))->FindObject("TPCNCLS"))->Fill( cls );
+  ((TH1D*)((TList*)fList->FindObject("TPCRFPall"))->FindObject("TPCSHCL"))->Fill( shcl );
+  ((TH1D*)((TList*)fList->FindObject("TPCRFPall"))->FindObject("TPCFICL"))->Fill( ficl );
+  ((TH1D*)((TList*)fList->FindObject("TPCRFPall"))->FindObject("TPCXRNF"))->Fill( xrnfcls );
+  ((TH1D*)((TList*)fList->FindObject("TPCRFPall"))->FindObject("TPCRCHI"))->Fill( rchi2 );
+  ((TH1D*)((TList*)fList->FindObject("TPCRFPall"))->FindObject("ITSNCLS"))->Fill( itscls );
+  ((TH1D*)((TList*)fList->FindObject("TPCRFPall"))->FindObject("ITSRCHI"))->Fill( itsrchi2 );
+  if(pt<fRFPminPt) return kFALSE; //0.2
+  if(pt>fRFPmaxPt) return kFALSE; //5.0
+  if(eta<fRFPminEta) return kFALSE; //-0.8
+  if(eta>fRFPmaxEta) return kFALSE; //+0.8
+  if(tpcs<fRFPTPCsignal) return kFALSE; //10.0
+  if( TMath::Sqrt(ipxy*ipxy/fRFPmaxIPxy/fRFPmaxIPxy+ipz*ipz/fRFPmaxIPz/fRFPmaxIPz)>1 ) return kFALSE; //2.4 3.2
+  if(cls<fRFPTPCncls) return kFALSE; //70
+  ((TH1D*)((TList*)fList->FindObject("TPCRFPsel"))->FindObject("PT"))->Fill( pt );
+  ((TH1D*)((TList*)fList->FindObject("TPCRFPsel"))->FindObject("PHI"))->Fill( phi );
+  ((TH1D*)((TList*)fList->FindObject("TPCRFPsel"))->FindObject("ETA"))->Fill( eta );
+  ((TH1D*)((TList*)fList->FindObject("TPCRFPsel"))->FindObject("TPCS"))->Fill( tpcs );
+  ((TH1D*)((TList*)fList->FindObject("TPCRFPsel"))->FindObject("IPXY"))->Fill( ipxy );
+  ((TH1D*)((TList*)fList->FindObject("TPCRFPsel"))->FindObject("IPZ"))->Fill( ipz );
+  ((TH1D*)((TList*)fList->FindObject("TPCRFPsel"))->FindObject("TPCNCLS"))->Fill( cls );
+  ((TH1D*)((TList*)fList->FindObject("TPCRFPsel"))->FindObject("TPCSHCL"))->Fill( shcl );
+  ((TH1D*)((TList*)fList->FindObject("TPCRFPsel"))->FindObject("TPCFICL"))->Fill( ficl );
+  ((TH1D*)((TList*)fList->FindObject("TPCRFPsel"))->FindObject("TPCXRNF"))->Fill( xrnfcls );
+  ((TH1D*)((TList*)fList->FindObject("TPCRFPsel"))->FindObject("TPCRCHI"))->Fill( rchi2 );
+  ((TH1D*)((TList*)fList->FindObject("TPCRFPsel"))->FindObject("ITSNCLS"))->Fill( itscls );
+  ((TH1D*)((TList*)fList->FindObject("TPCRFPsel"))->FindObject("ITSRCHI"))->Fill( itsrchi2 );
+  return kTRUE;
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::MakeQTPC(AliVEvent *tevent,
+                                          Double_t &qxa,Double_t &qya,Double_t &qwa,
+                                          Double_t &qxb,Double_t &qyb,Double_t &qwb) {
+  AliESDEvent *tESD = (AliESDEvent*) (tevent);
+  AliAODEvent *tAOD = (AliAODEvent*) (tevent);
+  if(fReadESD) {
+    if(!tESD) return;
+    MakeQTPC(tESD,qxa,qya,qwa,qxb,qyb,qwb);
+  } else {
+    if(!tAOD) return;
+    MakeQTPC(tAOD,qxa,qya,qwa,qxb,qyb,qwb);
+  }
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::MakeQTPC(AliAODEvent *tAOD,
+                                          Double_t &qxa,Double_t &qya,Double_t &qwa,
+                                          Double_t &qxb,Double_t &qyb,Double_t &qwb) {
+  //=>cleaning
+  if(fUseFP) fTPCevent->ClearFast();
+  qxa=qya=qwa=qxb=qyb=qwb=0;
+  Int_t rfp=0;
+  Double_t eta, phi, w;
+  //=>aod stuff
+  AliAODVertex *vtx = tAOD->GetPrimaryVertex();
+  Double_t pos[3],cov[6];
+  vtx->GetXYZ(pos);
+  vtx->GetCovarianceMatrix(cov);
+  const AliESDVertex vESD(pos,cov,100.,100);
+  AliAODTrack *track;
+  //=>looping
+  Int_t rawN = tAOD->GetNumberOfTracks();
+  for(Int_t id=0; id!=rawN; ++id) {
+    track = tAOD->GetTrack(id);
+    //=>cuts
+    if(!track->TestFilterBit(fRFPFilterBit)) continue;
+    if( fExcludeTPCEdges )
+      if( IsAtTPCEdge( track->Phi(), track->Pt(), track->Charge(), tAOD->GetMagneticField() ) )        continue;
+    AliESDtrack etrack( track );
+    etrack.SetTPCClusterMap( track->GetTPCClusterMap() );
+    etrack.SetTPCSharedMap( track->GetTPCSharedMap() );
+    etrack.SetTPCPointsF( track->GetTPCNclsF() );
+    Float_t ip[2];
+    etrack.GetDZ(pos[0], pos[1], pos[2], tAOD->GetMagneticField(), ip);
+    if(!PassesRFPTPCCuts(&etrack,track->Chi2perNDF(),ip[0],ip[1])) continue;
+    //=>collecting info
+    phi = track->Phi();
+    eta = track->Eta();
+    w = 1;
+    //=>subevents
+    if(eta<0) {
+      qxa += w*TMath::Cos(2*phi);
+      qya += w*TMath::Sin(2*phi);
+      qwa += w;
+    } else {
+      qxb += w*TMath::Cos(2*phi);
+      qyb += w*TMath::Sin(2*phi);
+      qwb += w;
+    }
+    ((TH2D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCAllPhiEta"))->Fill( phi, eta, w );
+    rfp++;
+    if(fUseFP) PushBackFlowTrack(fTPCevent,track->Pt(),phi,eta,w,track->GetID());
+  }
+  if(fUseFP) fTPCevent->SetNumberOfRPs(rfp);
+  if(fDebug) printf("Inserted tracks in FlowEventTPC %d ==> %.1f\n",fTPCevent->NumberOfTracks(),qwa+qwb);
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::MakeQTPC(AliESDEvent *tESD,
+                                          Double_t &qxa,Double_t &qya,Double_t &qwa,
+                                          Double_t &qxb,Double_t &qyb,Double_t &qwb) {
+  //=>cleaning
+  if(fUseFP) fTPCevent->ClearFast();
+  qxa=qya=qwa=qxb=qyb=qwb=0;
+  Int_t rfp=0;
+  Double_t eta, phi, w;
+  //=>looping
+  AliESDtrack *track;
+  Int_t rawN = tESD->GetNumberOfTracks();
+  for(Int_t id=0; id!=rawN; ++id) {
+    track = tESD->GetTrack(id);
+    //=>cuts
+    if( fExcludeTPCEdges )
+      if( IsAtTPCEdge( track->Phi(), track->Pt(), track->Charge(), tESD->GetMagneticField() ) )        continue;
+    if(!PassesFilterBit(track)) continue;
+    if(!PassesRFPTPCCuts(track)) continue;
+    //=>collecting info
+    phi = track->Phi();
+    eta = track->Eta();
+    w = 1;
+    //=>subevents
+    if(eta<0) {
+      qxa += w*TMath::Cos(2*phi);
+      qya += w*TMath::Sin(2*phi);
+      qwa += w;
+    } else {
+      qxb += w*TMath::Cos(2*phi);
+      qyb += w*TMath::Sin(2*phi);
+      qwb += w;
+    }
+    ((TH2D*)((TList*)fList->FindObject("MakeQSpy"))->FindObject("TPCAllPhiEta"))->Fill( phi, eta, w );
+    rfp++;
+    if(fUseFP) PushBackFlowTrack(fTPCevent,track->Pt(),phi,eta,w,track->GetID());
+  }
+  if(fUseFP) fTPCevent->SetNumberOfRPs(rfp);
+  if(fDebug) printf("Inserted tracks in FlowEventTPC %d ==> %.1f\n",fTPCevent->NumberOfTracks(),qwa+qwb);
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::AddMCParticleSpy(TList *me) {
+  TH1D *tH1D;
+  TH2D *tH2D;
+  tH1D = new TH1D("Pt",   "Pt",   100,0.0,20);  me->Add(tH1D);
+  tH1D = new TH1D("Phi",  "Phi",  100,0,TMath::TwoPi()); me->Add(tH1D);
+  tH1D = new TH1D("Eta",  "Eta",  100,-1,+1);   me->Add(tH1D);
+  tH1D = new TH1D("Rad2", "Rad2", 1000,0,+100); me->Add(tH1D);
+  tH2D = new TH2D("Dphi", "phi-MCEP;pt;dphi",100,0,20, 72,0,TMath::Pi()); me->Add(tH2D);
+  return;
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::FillMCParticleSpy(TString listName, AliAODMCParticle *p) {
+  ((TH1D*)((TList*)fList->FindObject(listName.Data()))->FindObject("Pt" ))->Fill( p->Pt() );
+  ((TH1D*)((TList*)fList->FindObject(listName.Data()))->FindObject("Eta" ))->Fill( p->Eta() );
+  ((TH1D*)((TList*)fList->FindObject(listName.Data()))->FindObject("Phi" ))->Fill( p->Phi() );
+  ((TH1D*)((TList*)fList->FindObject(listName.Data()))->FindObject("Rad2" ))->Fill( TMath::Sqrt( p->Xv()*p->Xv() +
+                                                                                                p->Yv()*p->Yv() ) );
+  ((TH1D*)((TList*)fList->FindObject(listName.Data()))->FindObject("Dphi" ))->Fill( p->Pt(), GetMCDPHI(p->Phi()) );
+  return;
+}
+//=======================================================================
+Double_t AliAnalysisTaskFlowStrange::GetMCDPHI(Double_t phi) {
+  Double_t dDPHI = phi - fMCEP;
+  if( dDPHI < 0 ) dDPHI += TMath::TwoPi();
+  if( dDPHI > TMath::Pi() ) dDPHI = TMath::TwoPi()-dDPHI;
+  return dDPHI;
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::FillMCParticleSpy(TString listName, TParticle *p) {
+  ((TH1D*)((TList*)fList->FindObject(listName.Data()))->FindObject("Pt" ))->Fill( p->Pt() );
+  ((TH1D*)((TList*)fList->FindObject(listName.Data()))->FindObject("Eta" ))->Fill( p->Eta() );
+  ((TH1D*)((TList*)fList->FindObject(listName.Data()))->FindObject("Phi" ))->Fill( p->Phi() );
+  ((TH1D*)((TList*)fList->FindObject(listName.Data()))->FindObject("Rad2" ))->Fill( TMath::Sqrt( p->Vx()*p->Vx() +
+                                                                                                p->Vy()*p->Vy() ) );
+  return;
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::AddCandidatesSpy(TList *me) {
+  TH2D *tH2D;
+  tH2D = new TH2D("PhiEta",  "PhiEta;Phi;Eta", 100,0,TMath::TwoPi(),100,-1,+1); me->Add(tH2D);
+  tH2D = new TH2D("PtRAP",   "PtRAP;Pt;Y",          100,0,20,100,-2.0,+2.0);  me->Add(tH2D);
+  tH2D = new TH2D("PtDCA",   "PtDCA;Pt;DCA",        100,0,20,100,0,10);       me->Add(tH2D);
+  tH2D = new TH2D("PtCTP",   "PtCTP;Pt;CTP",        100,0,20,100,-1,+1);      me->Add(tH2D);
+  //tH2D = new TH2D("PtCTP",   "PtCTP;Pt;CTP",        100,0,10,100,0.90,+1);    me->Add(tH2D);
+  tH2D = new TH2D("PtD0D0",  "PtD0D0;Pt;D0D0",      100,0,20,100,-5,+5);      me->Add(tH2D);
+  tH2D = new TH2D("PtRad2",  "PtRad2;Pt;RadXY",     100,0,20,100,0,+50);      me->Add(tH2D);
+  tH2D = new TH2D("PtDL",    "PtDL;Pt;DL",          100,0,20,100,0,+50);      me->Add(tH2D);
+  tH2D = new TH2D("PtMASS",  "PtMASS;Pt;MASS", 100,0,20,fMassBins,fMinMass,fMaxMass); me->Add(tH2D);
+  tH2D = new TH2D("APPOS",   "APPOS;alphaPOS;QtPOS",100,-2,+2,100,0,0.3);     me->Add(tH2D);
+  tH2D = new TH2D("D0PD0N",  "D0PD0N;D0P;D0N",      200,-10,+10,200,-10,+10); me->Add(tH2D);
+  tH2D = new TH2D("XPOSXNEG","XPOSXNEG;XPOS;XNEG",  200,-50,+50,200,-50,+50); me->Add(tH2D);
+  tH2D = new TH2D("PTDPHIMC","PtDPHIMC;Pt;PHI-MCEP",100,0,20,72,0,TMath::Pi()); me->Add(tH2D);
+  return;
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::FillCandidateSpy(TString listName) {
+  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PhiEta"))->Fill( fDecayPhi, fDecayEta );
+  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PtRAP" ))->Fill( fDecayPt, fDecayRapidity );
+  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PtDCA" ))->Fill( fDecayPt, fDecayDCAdaughters );
+  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PtCTP" ))->Fill( fDecayPt, fDecayCosinePointingAngleXY );
+  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PtD0D0"))->Fill( fDecayPt, fDecayProductIPXY );
+  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PtRad2"))->Fill( fDecayPt, fDecayRadXY );
+  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PtDL"  ))->Fill( fDecayPt, fDecayDecayLength );
+  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PtMASS"))->Fill( fDecayPt, fDecayMass );
+  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("APPOS" ))->Fill( fDecayAlpha, fDecayQt );
+  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject("PTDPHIMC" ))->Fill( fDecayPt, GetMCDPHI( fDecayPhi ) );
+}
+//=======================================================================
+Bool_t AliAnalysisTaskFlowStrange::AcceptCandidate() {
+  if(fDecayEta<fDecayMinEta) return kFALSE;
+  if(fDecayEta>fDecayMaxEta) return kFALSE;
+  if(fDecayPt<fDecayMinPt) return kFALSE;
+  if(fDecayProductIPXY>fDecayMaxProductIPXY) return kFALSE;
+  if(fDecayDCAdaughters>fDecayMaxDCAdaughters) return kFALSE;
+  if(fDecayCosinePointingAngleXY<fDecayMinCosinePointingAngleXY) return kFALSE;
+  if(fDecayRadXY<fDecayMinRadXY) return kFALSE;
+  if(fDecayDecayLength>fDecayMaxDecayLength*2.6842) return kFALSE;
+  if(TMath::Abs(fDecayRapidity)>fDecayMaxRapidity) return kFALSE;
+  if(fSpecie==0) {
+    if(fDecayAPCutPie) {
+      if(fDecayQt/TMath::Abs(fDecayAlpha)<fDecayMinQt) return kFALSE;
+    } else {
+      if(fDecayQt<fDecayMinQt) return kFALSE;
+    }
+  }
+  if(fSpecie==1) if(fDecayAlpha>0) return kFALSE;
+  if(fSpecie==2) if(fDecayAlpha<0) return kFALSE;
+  return kTRUE;
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::AddTracksSpy(TList *me) {
+  TH2D *tH2D;
+  tH2D = new TH2D("PHIETA",       "PHIETA;PHI;ETA",               100,0,TMath::TwoPi(),100,-2,2); me->Add(tH2D);
+  tH2D = new TH2D("IPXYIPZ",      "IPXYIPZ;IPXY;IPZ",             1000,-20,+20,1000,-20,+20); me->Add(tH2D);
+  tH2D = new TH2D("PTTPCNCLS",    "PTTPCNCLS;PT;NCLS",            100,0,20,170,0,170);  me->Add(tH2D);
+  tH2D = new TH2D("POSTPCNCLCHI2","POSTPCNCLCHI2;NCLS;CHI2/NCLS", 170,0,170,100,0,8);   me->Add(tH2D);
+  tH2D = new TH2D("POSTPCNFCLNXR","POSTPCNFCLNXR;NFCLS;NXR",      170,0,170,170,0,170); me->Add(tH2D);
+  tH2D = new TH2D("POSTPCNCLNFCL","POSTPCNCLNFCL;NCLS;NFCLS",     170,0,170,170,0,170); me->Add(tH2D);
+  tH2D = new TH2D("POSTPCNCLNSCL","POSTPCNCLNSCL;NCLS;NSCLS",     170,0,170,170,0,170); me->Add(tH2D);
+  tH2D = new TH2D("NEGTPCNCLCHI2","NEGTPCNCLCHI2;NCLS;CHI2/NCLS", 170,0,170,100,0,8);   me->Add(tH2D);
+  tH2D = new TH2D("NEGTPCNFCLNXR","NEGTPCNFCLNXR;NFCLS;NXR",      170,0,170,170,0,170); me->Add(tH2D);
+  tH2D = new TH2D("NEGTPCNCLNFCL","NEGTPCNCLNFCL;NCLS;NFCLS",     170,0,170,170,0,170); me->Add(tH2D);
+  tH2D = new TH2D("NEGTPCNCLNSCL","NEGTPCNCLNSCL;NCLS;NSCLS",     170,0,170,170,0,170); me->Add(tH2D);
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::FillTrackSpy(TString listName) {
+  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( "PHIETA" ))->Fill( fDaughterPhi, fDaughterEta );
+  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( "IPXYIPZ" ))->Fill( fDaughterImpactParameterXY, fDaughterImpactParameterZ );
+  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( "PTTPCNCLS" ))->Fill( fDaughterPt, fDaughterNClsTPC );
+  TString ch="NEG";
+  if(fDaughterCharge>0) ch="POS";
+  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( Form("%sTPCNCLCHI2",ch.Data()) ))->Fill( fDaughterNClsTPC, fDaughterChi2PerNClsTPC );
+  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( Form("%sTPCNFCLNXR",ch.Data()) ))->Fill( fDaughterNFClsTPC, fDaughterXRows );
+  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( Form("%sTPCNCLNFCL",ch.Data()) ))->Fill( fDaughterNClsTPC, fDaughterNFClsTPC );
+  ((TH2D*)((TList*)fList->FindObject(listName.Data()))->FindObject( Form("%sTPCNCLNSCL",ch.Data()) ))->Fill( fDaughterNClsTPC, fDaughterNSClsTPC );
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::LoadTrack(AliESDtrack *myTrack, Double_t aodChi2NDF) {
+  fDaughterCharge = myTrack->Charge();
+  fDaughterXRows = myTrack->GetTPCCrossedRows();
+  fDaughterNFClsTPC = myTrack->GetTPCNclsF();
+  fDaughterNSClsTPC = myTrack->GetTPCnclsS();
+  fDaughterNClsTPC = myTrack->GetTPCclusters(0);
+  if(fReadESD) {
+    if(fDaughterNClsTPC>0) fDaughterChi2PerNClsTPC = myTrack->GetTPCchi2()/fDaughterNClsTPC;
+  } else {
+    fDaughterChi2PerNClsTPC = aodChi2NDF;
+  }
+  myTrack->GetImpactParameters(fDaughterImpactParameterXY,fDaughterImpactParameterZ);
+  fDaughterStatus = myTrack->GetStatus();
+  fDaughterPhi = myTrack->Phi();
+  fDaughterEta = myTrack->Eta();
+  fDaughterPt = myTrack->Pt();
+  fDaughterKinkIndex = myTrack->GetKinkIndex(0);
+}
+//=======================================================================
+Bool_t AliAnalysisTaskFlowStrange::AcceptDaughter() {
+  if(fDaughterKinkIndex>0) return kFALSE;
+  if( (fDaughterStatus&AliESDtrack::kTPCrefit)==0 ) return kFALSE;
+  if(fDaughterNFClsTPC<1) return kFALSE;
+  if(fDaughterPt<fDaughterMinPt) return kFALSE;
+  if(fDaughterEta<fDaughterMinEta) return kFALSE;
+  if(fDaughterEta>fDaughterMaxEta) return kFALSE;
+  if(fDaughterNClsTPC<fDaughterMinNClsTPC) return kFALSE;
+  if(fDaughterXRows<fDaughterMinXRows) return kFALSE;
+  if(fDaughterChi2PerNClsTPC>fDaughterMaxChi2PerNClsTPC) return kFALSE;
+  if(TMath::Abs(fDaughterImpactParameterXY)<fDaughterMinImpactParameterXY) return kFALSE;
+  if(fDaughterXRows<fDaughterMinXRowsOverNClsFTPC*fDaughterNFClsTPC) return kFALSE;
+  return kTRUE;
+}
+//=======================================================================
+Double_t AliAnalysisTaskFlowStrange::GetWDist(const AliVVertex* v0, const AliVVertex* v1) {
+  // calculate sqrt of weighted distance to other vertex
+  if (!v0 || !v1) {
+    printf("One of vertices is not valid\n");
+    return 0;
+  }
+  static TMatrixDSym vVb(3);
+  double dist = -1;
+  double dx = v0->GetX()-v1->GetX();
+  double dy = v0->GetY()-v1->GetY();
+  double dz = v0->GetZ()-v1->GetZ();
+  double cov0[6],cov1[6];
+  v0->GetCovarianceMatrix(cov0);
+  v1->GetCovarianceMatrix(cov1);
+  vVb(0,0) = cov0[0]+cov1[0];
+  vVb(1,1) = cov0[2]+cov1[2];
+  vVb(2,2) = cov0[5]+cov1[5];
+  vVb(1,0) = vVb(0,1) = cov0[1]+cov1[1];
+  vVb(0,2) = vVb(1,2) = vVb(2,0) = vVb(2,1) = 0.;
+  vVb.InvertFast();
+  if (!vVb.IsValid()) {printf("Singular Matrix\n"); return dist;}
+  dist = vVb(0,0)*dx*dx + vVb(1,1)*dy*dy + vVb(2,2)*dz*dz
+    +    2*vVb(0,1)*dx*dy + 2*vVb(0,2)*dx*dz + 2*vVb(1,2)*dy*dz;
+  return dist>0 ? TMath::Sqrt(dist) : -1;
+}
+//=======================================================================
+Bool_t AliAnalysisTaskFlowStrange::plpMV(const AliVEvent *event) {
+  // check for multi-vertexer pile-up
+  const AliAODEvent *aod = (const AliAODEvent*)event;
+  const AliESDEvent *esd = (const AliESDEvent*)event;
+  //
+  const int    kMinPlpContrib = 5;
+  const double kMaxPlpChi2 = 5.0;
+  const double kMinWDist = 15;
+  //
+  if (!aod && !esd) {
+    printf("Event is neither of AOD nor ESD\n");
+    exit(1);
+  }
+  //
+  const AliVVertex* vtPrm = 0;
+  const AliVVertex* vtPlp = 0;
+  int nPlp = 0;
+  //
+  if (aod) {
+    if ( !(nPlp=aod->GetNumberOfPileupVerticesTracks()) ) return kFALSE;
+    vtPrm = aod->GetPrimaryVertex();
+    if (vtPrm == aod->GetPrimaryVertexSPD()) return kTRUE; // there are pile-up vertices but no primary
+  }
+  else {
+    if ( !(nPlp=esd->GetNumberOfPileupVerticesTracks())) return kFALSE;
+    vtPrm = esd->GetPrimaryVertexTracks();
+    if (((AliESDVertex*)vtPrm)->GetStatus()!=1) return kTRUE; // there are pile-up vertices but no primary
+  }
+  //int bcPrim = vtPrm->GetBC();
+  //
+  for (int ipl=0;ipl<nPlp;ipl++) {
+    vtPlp = aod ? (const AliVVertex*)aod->GetPileupVertexTracks(ipl) : (const AliVVertex*)esd->GetPileupVertexTracks(ipl);
+    //
+    if (vtPlp->GetNContributors() < kMinPlpContrib) continue;
+    if (vtPlp->GetChi2perNDF() > kMaxPlpChi2) continue;
+    //  int bcPlp = vtPlp->GetBC();
+    //  if (bcPlp!=AliVTrack::kTOFBCNA && TMath::Abs(bcPlp-bcPrim)>2) return kTRUE; // pile-up from other BC
+    //
+    double wDst = GetWDist(vtPrm,vtPlp);
+    if (wDst<kMinWDist) continue;
+    //
+    return kTRUE; // pile-up: well separated vertices
+  }
+  //
+  return kFALSE;
+  //
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::MakeFilterBits() {
+  //FilterBit 1
+  fFB1 = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
+  //FilterBit1024
+  fFB1024 = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kTRUE,1);
+  fFB1024->SetMinNCrossedRowsTPC(120);
+  fFB1024->SetMinRatioCrossedRowsOverFindableClustersTPC(0.8);
+  fFB1024->SetMaxChi2PerClusterITS(36);
+  fFB1024->SetMaxFractionSharedTPCClusters(0.4);
+  fFB1024->SetMaxChi2TPCConstrainedGlobal(36);
+  fFB1024->SetEtaRange(-0.9,0.9);
+  fFB1024->SetPtRange(0.15, 1e10);
+}
+//=======================================================================
+Bool_t AliAnalysisTaskFlowStrange::PassesFilterBit(AliESDtrack *track) {
+  Bool_t ret=kFALSE;
+  switch(fRFPFilterBit) {
+    case(1024):
+      ret = fFB1024->AcceptTrack(track);
+      break;
+    default:
+      ret = fFB1->AcceptTrack(track);
+  }
+  return ret;
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::LoadVZEROResponse() {
+  if(fVZEResponse) {
+    TString run = fVZEResponse->GetTitle();
+    if( run.Atoi() == fRunNumber ) return;
+    fVZEResponse = NULL;
+  }
+  //==>loading
+  fVZEResponse = dynamic_cast<TH2D*> (fVZEload->FindObject( Form("%d",fRunNumber) ));
+  if(fVZEResponse) {
+    printf("New VZE calibration: run %d || %s -> Entries %.0f\n",fRunNumber, fVZEResponse->GetTitle(),fVZEResponse->GetEntries());
+  } else {
+    printf("VZE calibration: request but not found!!!\n");
+  }
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::AddVZEQA() {
+  fVZEQA = new TList();
+  fVZEQA->SetName( Form("VZEQA%d",fRunNumber) );
+  fVZEQA->SetOwner();
+  if(fQAlevel>0) {
+    TProfile2D *prof = new TProfile2D("LINP","LINP;VZEcell;VZEmult;SPDtrkl", 64,0,64,500,0,700,0,10000); fVZEQA->Add( prof );
+    prof = new TProfile2D("MULP","MULP;VZEcell;CENTR;VZEmult", 64,0,64,100,0,100,0,10000); fVZEQA->Add( prof );
+    TH3D *tH3D = new TH3D("EQU","EQU;VZEeqmult;VZEmult",100,0,700,100,0,700,64,0,64); fVZEQA->Add( tH3D );
+  }
+  fList->Add(fVZEQA);
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::SaveVZEROQA() {
+  AliAODEvent *event = dynamic_cast<AliAODEvent*> (InputEvent());
+  if(!event) return;
+  AliVVZERO *vzero = event->GetVZEROData();
+  AliAODTracklets *tracklets = event->GetTracklets();
+  if(!vzero) return;
+  if(!tracklets) return;
+  Double_t mult, eqmult;
+  Int_t trkl;
+  for(int id=0; id!=64; ++id) {
+    trkl = tracklets->GetNumberOfTracklets();
+    mult = vzero->GetMultiplicity(id);
+    eqmult = event->GetVZEROEqMultiplicity(id);
+    ((TProfile2D*) fVZEQA->FindObject( "LINP" ))->Fill(id,mult,trkl,1);
+    ((TProfile2D*) fVZEQA->FindObject( "MULP" ))->Fill(id,fThisCent,mult,1);
+    ((TH3D*) fVZEQA->FindObject("EQU"))->Fill(eqmult,mult,id);
+  }
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::AddVZEROResponse() {
+  fVZEResponse = NULL;
+  AliVEvent *event = InputEvent();
+  if(!event) return;
+  Int_t thisrun = event->GetRunNumber();
+  fVZEResponse = new TH2D( Form("%d",thisrun), Form("%d;cell;CC",thisrun), 64,0,64, 100, 0, 100);
+  fList->Add(fVZEResponse);
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::SaveVZEROResponse() {
+  if(!fVZEResponse) return;
+  AliVEvent *event = InputEvent();
+  if(!event) return;
+  Double_t w;
+  for(int id=0; id!=64; ++id) {
+    w = event->GetVZEROEqMultiplicity(id);
+    fVZEResponse->Fill(id,fThisCent,w);
+  }
+}
+//=======================================================================
+Int_t AliAnalysisTaskFlowStrange::RefMultTPC() {
+  AliAODEvent *ev = dynamic_cast<AliAODEvent*> (InputEvent());
+  if(!ev) return -1;
+  Int_t found = 0;
+  for(int i=0; i!=ev->GetNumberOfTracks(); ++i) {
+    AliAODTrack *t = ev->GetTrack( i );
+    if(!t) continue;
+    if( !t->TestFilterBit(1) ) continue;
+    if( t->Eta()<-0.8 || t->Eta()>+0.8 ) continue;
+    if( t->Pt()<0.2 || t->Pt()>5.0 ) continue;
+    if( t->GetTPCNcls()<70 ) continue;
+    if( t->GetTPCsignal()<10.0 ) continue;
+    if( t->Chi2perNDF()<0.2 ) continue;    
+    ++found;
+  }
+  return found;
+}
+//=======================================================================
+Int_t AliAnalysisTaskFlowStrange::RefMultGlobal() {
+  AliAODEvent *ev = dynamic_cast<AliAODEvent*> (InputEvent());
+  if(!ev) return -1;
+  Int_t found = 0;
+  for(int i=0; i!=ev->GetNumberOfTracks(); ++i) {
+    AliAODTrack *t = ev->GetTrack( i );
+    if(!t) continue;
+    if( !t->TestFilterBit(16) ) continue;
+    if( t->Eta()<-0.8 || t->Eta()>+0.8 ) continue;
+    if( t->Pt()<0.2 || t->Pt()>5.0 ) continue;
+    if( t->GetTPCNcls()<70 ) continue;
+    if( t->GetTPCsignal()<10.0 ) continue;
+    if( t->Chi2perNDF()<0.1 ) continue;    
+    Double_t b[3], bcov[3];
+    if( !t->PropagateToDCA(ev->GetPrimaryVertex(),ev->GetMagneticField(),100,b,bcov) ) continue;
+    if( b[0]>+0.3 || b[0]<-0.3 || b[1]>+0.3 || b[1]<-0.3) continue;
+    ++found;
+  }
+  return found;
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::MakeDHcorr() {
+  // Adds DH corr
+  for(int iCand=0; iCand!=fCandidates->GetEntriesFast(); ++iCand ) {
+    AliFlowCandidateTrack *cand = static_cast<AliFlowCandidateTrack*>(fCandidates->At(iCand));
+    if(!cand) continue;
+    for(int iRPs=0; iRPs!=fTPCevent->NumberOfTracks(); ++iRPs ) {
+      AliFlowTrack *iRP = static_cast<AliFlowTrack*>(fTPCevent->GetTrack( iRPs ));
+      if(!iRP) continue;
+      if(!iRP->InRPSelection()) continue;
+      if(cand->GetID() == iRP->GetID()) continue; //avoid autocorr
+      for(int iDau=0; iDau!=cand->GetNDaughters(); ++iDau) //if it is a decay
+        if(cand->GetIDDaughter(iDau) == iRP->GetID()) continue;
+      //corr
+      Double_t dDPHI = iRP->Phi() - cand->Phi();
+      Double_t dDETA = iRP->Eta() - cand->Eta();
+      Double_t dDPT  = iRP->Pt()  - cand->Pt();
+      ((TH3D*)((TList*)fList->FindObject("DHCORR"))->FindObject("DPHI"))->Fill( dDPT, dDPHI, dDETA );
+      //end of corr
+    }
+  }
+}
+//=======================================================================
+void AliAnalysisTaskFlowStrange::ResetContainers() {
+  fTPCevent->ClearFast();
+  fVZEevent->ClearFast();
+}
index 6f838ab..1540aad 100644 (file)
-/////////////////////////////////////////////////////\r
-// AliAnalysisTaskFlowStrange:\r
-// Analysis task to select K0/Lambda candidates for flow analysis.\r
-// Authors: Cristian Ivan (civan@cern.ch)\r
-//          Carlos Perez (cperez@cern.ch)\r
-//          Pawel Debski (pdebski@cern.ch)\r
-//////////////////////////////////////////////////////\r
-\r
-/* Copyright(c) 1998-1999, ALICExperiment at CERN, All rights reserved. *\r
-* See cxx source for full Copyright notice */\r
-/* $Id: $ */\r
-\r
-#ifndef AliAnalysisTaskFlowStrange_H\r
-#define AliAnalysisTaskFlowStrange_H\r
-\r
-#include "AliAnalysisTaskSE.h"\r
-\r
-class TList;\r
-class TH2D;\r
-class TObjArray;\r
-class TClonesArray;\r
-class AliAODMCParticle;\r
-class AliESDtrackCuts;\r
-class AliFlowEventCuts;\r
-class AliPIDResponse;\r
-class AliESDEvent;\r
-class AliAODEvent;\r
-class AliAODv0;\r
-class AliESDv0;\r
-class AliVVertex;\r
-class AliFlowBayesianPID;\r
-class AliAODVertex;\r
-\r
-class AliAnalysisTaskFlowStrange : public AliAnalysisTaskSE {\r
- public:\r
-  enum Especie {kKZE=0,kLDA=1,kLDABAR=2,kLDAALL=3,kCHARGED=90,kPION=91,kKAON=92,kPROTON=93};\r
-  AliAnalysisTaskFlowStrange();\r
-  AliAnalysisTaskFlowStrange(const Char_t *name);\r
-  virtual ~AliAnalysisTaskFlowStrange();\r
-  virtual void UserCreateOutputObjects();\r
-  virtual void Exec(Option_t*);\r
-  virtual void UserExec(Option_t *);\r
-  virtual void Terminate(Option_t *);\r
-\r
-  void MyUserExec(Option_t *);\r
-  void SetDebug(Int_t val=1) {fDebug = val;}\r
-  void SetQAlevel(Int_t qa) {fQAlevel = qa;}\r
-\r
-  void SetMass(Int_t n, Double_t m, Double_t M) {fMassBins=n;fMinMass=m;fMaxMass=M;}\r
-\r
-  void SetpA() {fRunOnpA = kTRUE;  fRunOnpp = kFALSE;}\r
-  void Setpp() {fRunOnpA = kFALSE; fRunOnpp = kTRUE; }\r
-  void SetK0L0(Int_t specie) {fSpecie=specie;}\r
-  void SetOnline(Bool_t val) {fOnline=val;}\r
-  void SetHomemade(Bool_t val) {fHomemade=val;}\r
-  void SetExcludeTPCEdges(Bool_t value) {fExcludeTPCEdges=value;}\r
-  void SetCentralityRange(TString val, Int_t m, Int_t M) {fCentMethod=val; fCentPerMin=m; fCentPerMax=M;}\r
-  void SetReadESD(Bool_t val) {fReadESD=val;}\r
-  void SetReadMC(Bool_t val) {fReadMC=val;}\r
-  void SetAvoidExec(Bool_t val) {fAvoidExec=val;}\r
-  void SetSkipSelection(Bool_t val) {fSkipSelection=val;}\r
-  void SetSkipFlow(Bool_t val) {fSkipFlow=val;}\r
-  void SetUseFlowPackage(Bool_t val) {fUseFP=val;}\r
-  void SetExtraEventRejection(Bool_t val) {fExtraEventRejection=val;}\r
-\r
-  void SetWhichPsi(Int_t val) {fWhichPsi=val;}\r
-  void SetStoreVZEResponse(Bool_t val) {fVZEsave=val;}\r
-  void LoadVZEResponse(TList *val, Bool_t val2=kFALSE, Bool_t val3=kTRUE) {fVZEload=val;fVZEmb=val2;fVZEByDisk=val3;}\r
-  \r
-  void SetRFPFilterBit(Int_t val) {fRFPFilterBit=val;}\r
-  void SetRFPMinPt(Double_t val) {fRFPminPt=val;}\r
-  void SetRFPMaxPt(Double_t val) {fRFPmaxPt=val;}\r
-  void SetRFPMinEta(Double_t val) {fRFPminEta=val;}\r
-  void SetRFPMaxEta(Double_t val) {fRFPmaxEta=val;}\r
-  void SetRFPTPCSignal(Double_t val) {fRFPTPCsignal=val;}\r
-  void SetRFPMaxIPxy(Double_t val) {fRFPmaxIPxy=val;}\r
-  void SetRFPMaxIPz(Double_t val) {fRFPmaxIPz=val;}\r
-  void SetRFPMinTPCCls(Int_t val) {fRFPTPCncls=val;}\r
-  void SetRFPVZERingRange(Int_t val1, Int_t val2, Int_t val3, Int_t val4)\r
-    {fVZECa=val1;fVZECb=val2;fVZEAa=val3;fVZEAb=val4;}\r
-  void SetDauMinNClsTPC(Int_t val) {fDaughterMinNClsTPC=val;}\r
-  void SetDauMinXRows(Int_t val) {fDaughterMinXRows=val;}\r
-  void SetDauMaxChi2PerNClsTPC(Double_t val) {fDaughterMaxChi2PerNClsTPC=val;}\r
-  void SetDauMinXRowsOverNClsFTPC(Double_t val) {fDaughterMinXRowsOverNClsFTPC=val;}\r
-  void SetDauMinEta(Double_t val) {fDaughterMinEta=val;}\r
-  void SetDauMaxEta(Double_t val) {fDaughterMaxEta=val;}\r
-  void SetDauMinPt(Double_t val) {fDaughterMinPt=val;}\r
-  void SetDauMinImpactParameterXY(Double_t val) {fDaughterMinImpactParameterXY=val;}\r
-  void SetDauMaxNSigmaPID(Double_t val) {fDaughterMaxNSigmaPID=val;}\r
-  void SetDauUnTagProcedure(Bool_t val) {fDaughterUnTag=val;}\r
-\r
-  void SetMaxRapidity(Double_t val) {fDecayMaxRapidity=val;}\r
-  void SetMinEta(Double_t val) {fDecayMinEta=val;}\r
-  void SetMaxEta(Double_t val) {fDecayMaxEta=val;}\r
-  void SetMinPt(Double_t val) {fDecayMinPt=val;}\r
-  void SetMaxDCAdaughters(Double_t val) {fDecayMaxDCAdaughters=val;}\r
-  void SetMinCosinePointingAngleXY(Double_t val) {fDecayMinCosinePointingAngleXY=val;}\r
-  void SetMinQt(Double_t val, Bool_t val2=kTRUE) {fDecayMinQt=val; fDecayAPCutPie=val2;}\r
-  void SetMinRadXY(Double_t val) {fDecayMinRadXY=val;}\r
-  void SetMaxDecayLength(Double_t val) {fDecayMaxDecayLength=val;}\r
-  void SetMaxProductIPXY(Double_t val) {fDecayMaxProductIPXY=val;}\r
-\r
- private:\r
-  AliAnalysisTaskFlowStrange(const AliAnalysisTaskFlowStrange& analysisTask);\r
-  AliAnalysisTaskFlowStrange& operator=(const AliAnalysisTaskFlowStrange& analysisTask);\r
-  void AddQAEvents();\r
-  void AddQACandidates();\r
-\r
-  void MyNotifyRun();\r
-  Bool_t CalibrateEvent();\r
-  void Publish();\r
-  \r
-  void AddEventSpy();\r
-  Bool_t AcceptAAEvent(AliESDEvent *tESD);\r
-  Bool_t AcceptAAEvent(AliAODEvent *tAOD);\r
-  Bool_t AcceptPPEvent(AliAODEvent *tAOD);\r
-  Bool_t AcceptPAEvent(AliAODEvent *tAOD);\r
-  Int_t GetReferenceMultiplicity();\r
-\r
-  void ReadStack(TClonesArray* mcArray);\r
-  void ReadFromESD(AliESDEvent *tESD);\r
-  void ReadFromAODv0(AliAODEvent *tAOD);\r
-\r
-  void ChargeParticles(AliAODEvent *tAOD);\r
-\r
-  void ComputePsi2(AliVEvent *event);\r
-  void AddMakeQSpy();\r
-  void MakeQVZE(AliVEvent *event,Double_t &qxa,Double_t &qya,Double_t &qwa,Double_t &qxb,Double_t &qyb,Double_t &qwb);\r
-  void MakeQTPC(AliVEvent *event,Double_t &qxa,Double_t &qya,Double_t &qwa,Double_t &qxb,Double_t &qyb,Double_t &qwb);\r
-  void MakeQTPC(AliESDEvent *event,Double_t &qxa,Double_t &qya,Double_t &qwa,Double_t &qxb,Double_t &qyb,Double_t &qwb);\r
-  void MakeQTPC(AliAODEvent *event,Double_t &qxa,Double_t &qya,Double_t &qwa,Double_t &qxb,Double_t &qyb,Double_t &qwb);\r
-  void AddTPCRFPSpy(TList *val);\r
-  Bool_t PassesRFPTPCCuts(AliESDtrack *myTrack, Double_t aodChi2NDF=0, Float_t aodipxy=0, Float_t aodipz=0);\r
-  void MakeQVectors();\r
-  void ResetContainers();\r
-\r
-  void MakeDHcorr();\r
-  void AddCandidates();\r
-  void ReadEventPlanesFromAOD(AliAODEvent *tAOD);\r
-\r
-  Double_t GetMCDPHI(Double_t phi);\r
-\r
-  Double_t CosThetaPointXY(AliESDv0 *me, const AliVVertex *vtx);\r
-  Double_t CosThetaPointXY(AliAODv0 *me, const AliVVertex *vtx);\r
-  Double_t DecayLengthXY(AliESDv0 *me, const AliVVertex *vtx);\r
-  Double_t DecayLengthXY(AliAODv0 *me, const AliVVertex *vtx);\r
-  Double_t DecayLength(AliESDv0 *me, const AliVVertex *vtx);\r
-  Double_t DecayLength(AliAODv0 *me, const AliVVertex *vtx);\r
-\r
-  void AddMCParticleSpy(TList *val);\r
-  void FillMCParticleSpy(TString listName, AliAODMCParticle *par);\r
-  void FillMCParticleSpy(TString listName, TParticle *par);\r
-\r
-  void AddCandidatesSpy(TList *val);\r
-  void FillCandidateSpy(TString listName);\r
-\r
-  void AddTracksSpy(TList *val);\r
-  void FillTrackSpy(TString listName);\r
-\r
-  void MakeFilterBits();\r
-  Bool_t PassesFilterBit(AliESDtrack *me);\r
-\r
-  void LoadTrack(AliESDtrack *myTrack, Double_t aodChi2NDF=0);\r
-  Bool_t AcceptDaughter();\r
-  Bool_t AcceptCandidate();\r
-  Bool_t PassesPIDCuts(AliESDtrack *myTrack, AliPID::EParticleType pid=AliPID::kProton);\r
-\r
-  Bool_t IsAtTPCEdge(Double_t phi,Double_t pt,Int_t charge,Double_t b);\r
-\r
-  void MakeTrack();\r
-  void PushBackFlowTrack(AliFlowEvent *event, Double_t pt, Double_t phi, Double_t eta, Double_t we, Int_t id);\r
-\r
-  Double_t GetWDist(const AliVVertex* v0, const AliVVertex* v1);\r
-  Bool_t plpMV(const AliVEvent *event);\r
-\r
-  void LoadVZEROResponse();\r
-  void AddVZEROResponse();\r
-  void SaveVZEROResponse();\r
-  void AddVZEQA();\r
-  void SaveVZEROQA();\r
-\r
-  Int_t RefMultTPC();\r
-  Int_t RefMultGlobal();\r
-\r
-  AliPIDResponse *fPIDResponse; //! PID response object\r
-  AliESDtrackCuts *fFB1;        // filterbit cut equivalent\r
-  AliESDtrackCuts *fFB1024;     // filterbit cut equivalent\r
-  AliFlowEvent   *fTPCevent;    // flow event (needed here due to ev selection)\r
-  AliFlowEvent   *fVZEevent;    // flow event (needed here due to ev selection)\r
-  TObjArray      *fCandidates;  // array of selected candidates\r
-  TList          *fList;        // stores the final list of output histograms\r
-\r
-  Int_t fRunNumber; // current run number\r
-\r
-  Int_t fDebug;   // debug level\r
-  Int_t fQAlevel; // QA plots\r
-\r
-  Bool_t fReadESD;       // move back to ESD\r
-  Bool_t fReadMC;        // read MC files\r
-  Bool_t fAvoidExec;     // avoids Exec\r
-  Bool_t fSkipSelection; // skip decay finder\r
-  Bool_t fSkipFlow;      // skip flow-wise code\r
-  Bool_t fSkipDHcorr;    // skip dhcorr code\r
-  Bool_t fUseFP;         // flow package?\r
-  Bool_t fRunOnpA;       // make task compatible with pA event selection\r
-  Bool_t fRunOnpp;       // make task compatible with pp event selection\r
-  Bool_t fExtraEventRejection; // to reject pile up\r
-  TString  fCentMethod; // CC\r
-  Int_t    fCentPerMin; // CC\r
-  Int_t    fCentPerMax; // CC\r
-  Double_t fThisCent;   // CC\r
-\r
-  Bool_t fExcludeTPCEdges; // exclude TPC edges from single track selection\r
-\r
-  Int_t  fSpecie;   // K0=>0 L0=>1\r
-  Bool_t fOnline;   // change into online v0 finder\r
-  Bool_t fHomemade; // homemade v0 finder\r
-\r
-  Int_t fWhichPsi;  // detector for Psi2\r
-\r
-  Bool_t  fVZEsave; // make vze response\r
-  TList  *fVZEload; // adress to calibration file\r
-  TH2D   *fVZEResponse; // vze response vs centrality class\r
-  Bool_t  fVZEmb;   // integrate response (linearity)\r
-  Bool_t  fVZEByDisk; // normalized by disk\r
-  Int_t   fVZECa;   // start of V0C (ring number 0-3)\r
-  Int_t   fVZECb;   // end of V0C (ring number 0-3)\r
-  Int_t   fVZEAa;   // start of V0A (ring number 0-3)\r
-  Int_t   fVZEAb;   // end of V0A (ring number 0-3)\r
-  TList  *fVZEQA;   // adress to qalist\r
-\r
-  Double_t fPsi2;   // best estimation of Psi2\r
-  Double_t fMCEP;   // stores MC EP (when available)\r
-\r
-  Int_t    fMassBins; // opens\r
-  Double_t fMinMass;  // mass\r
-  Double_t fMaxMass;  // window\r
-\r
-  Int_t fRFPFilterBit;    // RFP TPC\r
-  Double_t fRFPminPt;     // RFP TPC\r
-  Double_t fRFPmaxPt;     // RFP TPC\r
-  Double_t fRFPminEta;    // RFP TPC\r
-  Double_t fRFPmaxEta;    // RFP TPC\r
-  Double_t fRFPTPCsignal; // RFP TPC\r
-  Double_t fRFPmaxIPxy;   // RFP TPC\r
-  Double_t fRFPmaxIPz;    // RFP TPC\r
-  Int_t fRFPTPCncls;      // RFP TPC\r
-\r
-  Double_t fDecayMass;                  // DECAY\r
-  Double_t fDecayPhi;                   // DECAY\r
-  Double_t fDecayEta;                   // DECAY\r
-  Double_t fDecayPt;                    // DECAY\r
-  Double_t fDecayDCAdaughters;          // DECAY\r
-  Double_t fDecayCosinePointingAngleXY; // DECAY\r
-  Double_t fDecayRadXY;                 // DECAY\r
-  Double_t fDecayDecayLength;           // DECAY\r
-  Double_t fDecayQt;                    // DECAY\r
-  Double_t fDecayAlpha;                 // DECAY\r
-  Double_t fDecayRapidity;              // DECAY\r
-  Double_t fDecayProductIPXY;           // DECAY\r
-  Int_t    fDecayIDneg;                 // DECAY\r
-  Int_t    fDecayIDpos;                 // DECAY\r
-  Int_t    fDecayID;                    // DECAY\r
-\r
-  Double_t fDecayMinEta;                   // DECAY CUTS\r
-  Double_t fDecayMaxEta;                   // DECAY CUTS\r
-  Double_t fDecayMinPt;                    // DECAY CUTS\r
-  Double_t fDecayMaxDCAdaughters;          // DECAY CUTS\r
-  Double_t fDecayMinCosinePointingAngleXY; // DECAY CUTS\r
-  Double_t fDecayMinQt;                    // DECAY CUTS\r
-  Bool_t   fDecayAPCutPie;                 // DECAY CUTS\r
-  Double_t fDecayMinRadXY;                 // DECAY CUTS\r
-  Double_t fDecayMaxDecayLength;           // DECAY CUTS\r
-  Double_t fDecayMaxProductIPXY;           // DECAY CUTS\r
-  Double_t fDecayMaxRapidity;              // DECAY CUTS\r
-\r
-  Double_t fDaughterPhi;               // DAUGHTER\r
-  Double_t fDaughterEta;               // DAUGHTER\r
-  Double_t fDaughterPt;                // DAUGHTER\r
-  Int_t    fDaughterNClsTPC;           // DAUGHTER\r
-  Int_t    fDaughterCharge;            // DAUGHTER\r
-  Int_t    fDaughterNFClsTPC;          // DAUGHTER\r
-  Int_t    fDaughterNSClsTPC;          // DAUGHTER\r
-  Double_t fDaughterChi2PerNClsTPC;    // DAUGHTER\r
-  Double_t fDaughterXRows;             // DAUGHTER\r
-  Float_t  fDaughterImpactParameterXY; // DAUGHTER\r
-  Float_t  fDaughterImpactParameterZ;  // DAUGHTER\r
-  UInt_t   fDaughterStatus;            // DAUGHTER\r
-  Double_t fDaughterNSigmaPID;         // DAUGHTER\r
-  Int_t    fDaughterKinkIndex;         // DAUGHTER\r
-\r
-  Bool_t   fDaughterUnTag;             // UNTAG PROCEDURE\r
-\r
-  Double_t fDaughterMinEta;               // DAUGHTER CUTS\r
-  Double_t fDaughterMaxEta;               // DAUGHTER CUTS\r
-  Double_t fDaughterMinPt;                // DAUGHTER CUTS\r
-  Int_t    fDaughterMinNClsTPC;           // DAUGHTER CUTS\r
-  Int_t    fDaughterMinXRows;             // DAUGHTER CUTS\r
-  Double_t fDaughterMaxChi2PerNClsTPC;    // DAUGHTER CUTS\r
-  Double_t fDaughterMinXRowsOverNClsFTPC; // DAUGHTER CUTS\r
-  Double_t fDaughterMinImpactParameterXY; // DAUGHTER CUTS\r
-  Double_t fDaughterMaxNSigmaPID;         // DAUGHTER CUTS\r
-\r
-  ClassDef(AliAnalysisTaskFlowStrange, 5);\r
-};\r
-#endif\r
+/////////////////////////////////////////////////////
+// AliAnalysisTaskFlowStrange:
+// Analysis task to select K0/Lambda candidates for flow analysis.
+// Authors: Cristian Ivan (civan@cern.ch)
+//          Carlos Perez (cperez@cern.ch)
+//          Pawel Debski (pdebski@cern.ch)
+//////////////////////////////////////////////////////
+
+/* Copyright(c) 1998-1999, ALICExperiment at CERN, All rights reserved. *
+* See cxx source for full Copyright notice */
+/* $Id: $ */
+
+#ifndef AliAnalysisTaskFlowStrange_H
+#define AliAnalysisTaskFlowStrange_H
+
+#include "AliAnalysisTaskSE.h"
+
+class TList;
+class TH2D;
+class TObjArray;
+class TClonesArray;
+class AliAODMCParticle;
+class AliESDtrackCuts;
+class AliFlowEventCuts;
+class AliPIDResponse;
+class AliESDEvent;
+class AliAODEvent;
+class AliAODv0;
+class AliESDv0;
+class AliVVertex;
+class AliFlowBayesianPID;
+class AliAODVertex;
+
+class AliAnalysisTaskFlowStrange : public AliAnalysisTaskSE {
+ public:
+  enum Especie {kKZE=0,kLDA=1,kLDABAR=2,kLDAALL=3,kCHARGED=90,kPION=91,kKAON=92,kPROTON=93};
+  AliAnalysisTaskFlowStrange();
+  AliAnalysisTaskFlowStrange(const Char_t *name);
+  virtual ~AliAnalysisTaskFlowStrange();
+  virtual void UserCreateOutputObjects();
+  virtual void Exec(Option_t*);
+  virtual void UserExec(Option_t *);
+  virtual void Terminate(Option_t *);
+
+  void MyUserExec(Option_t *);
+  void SetDebug(Int_t val=1) {fDebug = val;}
+  void SetQAlevel(Int_t qa) {fQAlevel = qa;}
+
+  void SetMass(Int_t n, Double_t m, Double_t M) {fMassBins=n;fMinMass=m;fMaxMass=M;}
+
+  void SetpA() {fRunOnpA = kTRUE;  fRunOnpp = kFALSE;}
+  void Setpp() {fRunOnpA = kFALSE; fRunOnpp = kTRUE; }
+  void SetK0L0(Int_t specie) {fSpecie=specie;}
+  void SetOnline(Bool_t val) {fOnline=val;}
+  void SetHomemade(Bool_t val) {fHomemade=val;}
+  void SetExcludeTPCEdges(Bool_t value) {fExcludeTPCEdges=value;}
+  void SetCentralityRange(TString val, Int_t m, Int_t M) {fCentMethod=val; fCentPerMin=m; fCentPerMax=M;}
+  void SetReadESD(Bool_t val) {fReadESD=val;}
+  void SetReadMC(Bool_t val) {fReadMC=val;}
+  void SetAvoidExec(Bool_t val) {fAvoidExec=val;}
+  void SetSkipSelection(Bool_t val) {fSkipSelection=val;}
+  void SetSkipFlow(Bool_t val) {fSkipFlow=val;}
+  void SetUseFlowPackage(Bool_t val) {fUseFP=val;}
+  void SetExtraEventRejection(Bool_t val) {fExtraEventRejection=val;}
+
+  void SetWhichPsi(Int_t val) {fWhichPsi=val;}
+  void SetStoreVZEResponse(Bool_t val) {fVZEsave=val;}
+  void LoadVZEResponse(TList *val, Bool_t val2=kFALSE, Bool_t val3=kTRUE) {fVZEload=val;fVZEmb=val2;fVZEByDisk=val3;}
+  
+  void SetRFPFilterBit(Int_t val) {fRFPFilterBit=val;}
+  void SetRFPMinPt(Double_t val) {fRFPminPt=val;}
+  void SetRFPMaxPt(Double_t val) {fRFPmaxPt=val;}
+  void SetRFPMinEta(Double_t val) {fRFPminEta=val;}
+  void SetRFPMaxEta(Double_t val) {fRFPmaxEta=val;}
+  void SetRFPTPCSignal(Double_t val) {fRFPTPCsignal=val;}
+  void SetRFPMaxIPxy(Double_t val) {fRFPmaxIPxy=val;}
+  void SetRFPMaxIPz(Double_t val) {fRFPmaxIPz=val;}
+  void SetRFPMinTPCCls(Int_t val) {fRFPTPCncls=val;}
+  void SetRFPVZERingRange(Int_t val1, Int_t val2, Int_t val3, Int_t val4)
+    {fVZECa=val1;fVZECb=val2;fVZEAa=val3;fVZEAb=val4;}
+  void SetDauMinNClsTPC(Int_t val) {fDaughterMinNClsTPC=val;}
+  void SetDauMinXRows(Int_t val) {fDaughterMinXRows=val;}
+  void SetDauMaxChi2PerNClsTPC(Double_t val) {fDaughterMaxChi2PerNClsTPC=val;}
+  void SetDauMinXRowsOverNClsFTPC(Double_t val) {fDaughterMinXRowsOverNClsFTPC=val;}
+  void SetDauMinEta(Double_t val) {fDaughterMinEta=val;}
+  void SetDauMaxEta(Double_t val) {fDaughterMaxEta=val;}
+  void SetDauMinPt(Double_t val) {fDaughterMinPt=val;}
+  void SetDauMinImpactParameterXY(Double_t val) {fDaughterMinImpactParameterXY=val;}
+  void SetDauMaxNSigmaPID(Double_t val) {fDaughterMaxNSigmaPID=val;}
+  void SetDauUnTagProcedure(Bool_t val) {fDaughterUnTag=val;}
+
+  void SetMaxRapidity(Double_t val) {fDecayMaxRapidity=val;}
+  void SetMinEta(Double_t val) {fDecayMinEta=val;}
+  void SetMaxEta(Double_t val) {fDecayMaxEta=val;}
+  void SetMinPt(Double_t val) {fDecayMinPt=val;}
+  void SetMaxDCAdaughters(Double_t val) {fDecayMaxDCAdaughters=val;}
+  void SetMinCosinePointingAngleXY(Double_t val) {fDecayMinCosinePointingAngleXY=val;}
+  void SetMinQt(Double_t val, Bool_t val2=kTRUE) {fDecayMinQt=val; fDecayAPCutPie=val2;}
+  void SetMinRadXY(Double_t val) {fDecayMinRadXY=val;}
+  void SetMaxDecayLength(Double_t val) {fDecayMaxDecayLength=val;}
+  void SetMaxProductIPXY(Double_t val) {fDecayMaxProductIPXY=val;}
+
+ private:
+  AliAnalysisTaskFlowStrange(const AliAnalysisTaskFlowStrange& analysisTask);
+  AliAnalysisTaskFlowStrange& operator=(const AliAnalysisTaskFlowStrange& analysisTask);
+  void AddQAEvents();
+  void AddQACandidates();
+
+  void MyNotifyRun();
+  Bool_t CalibrateEvent();
+  void Publish();
+  
+  void AddEventSpy();
+  Bool_t AcceptAAEvent(AliESDEvent *tESD);
+  Bool_t AcceptAAEvent(AliAODEvent *tAOD);
+  Bool_t AcceptPPEvent(AliAODEvent *tAOD);
+  Bool_t AcceptPAEvent(AliAODEvent *tAOD);
+  Int_t GetReferenceMultiplicity();
+
+  void ReadStack(TClonesArray* mcArray);
+  void ReadFromESD(AliESDEvent *tESD);
+  void ReadFromAODv0(AliAODEvent *tAOD);
+
+  void ChargeParticles(AliAODEvent *tAOD);
+
+  void ComputePsi2(AliVEvent *event);
+  void AddMakeQSpy();
+  void MakeQVZE(AliVEvent *event,Double_t &qxa,Double_t &qya,Double_t &qwa,Double_t &qxb,Double_t &qyb,Double_t &qwb);
+  void MakeQTPC(AliVEvent *event,Double_t &qxa,Double_t &qya,Double_t &qwa,Double_t &qxb,Double_t &qyb,Double_t &qwb);
+  void MakeQTPC(AliESDEvent *event,Double_t &qxa,Double_t &qya,Double_t &qwa,Double_t &qxb,Double_t &qyb,Double_t &qwb);
+  void MakeQTPC(AliAODEvent *event,Double_t &qxa,Double_t &qya,Double_t &qwa,Double_t &qxb,Double_t &qyb,Double_t &qwb);
+  void AddTPCRFPSpy(TList *val);
+  Bool_t PassesRFPTPCCuts(AliESDtrack *myTrack, Double_t aodChi2NDF=0, Float_t aodipxy=0, Float_t aodipz=0);
+  void MakeQVectors();
+  void ResetContainers();
+
+  void MakeDHcorr();
+  void AddCandidates();
+  void ReadEventPlanesFromAOD(AliAODEvent *tAOD);
+
+  Double_t GetMCDPHI(Double_t phi);
+
+  Double_t CosThetaPointXY(AliESDv0 *me, const AliVVertex *vtx);
+  Double_t CosThetaPointXY(AliAODv0 *me, const AliVVertex *vtx);
+  Double_t DecayLengthXY(AliESDv0 *me, const AliVVertex *vtx);
+  Double_t DecayLengthXY(AliAODv0 *me, const AliVVertex *vtx);
+  Double_t DecayLength(AliESDv0 *me, const AliVVertex *vtx);
+  Double_t DecayLength(AliAODv0 *me, const AliVVertex *vtx);
+
+  void AddMCParticleSpy(TList *val);
+  void FillMCParticleSpy(TString listName, AliAODMCParticle *par);
+  void FillMCParticleSpy(TString listName, TParticle *par);
+
+  void AddCandidatesSpy(TList *val);
+  void FillCandidateSpy(TString listName);
+
+  void AddTracksSpy(TList *val);
+  void FillTrackSpy(TString listName);
+
+  void MakeFilterBits();
+  Bool_t PassesFilterBit(AliESDtrack *me);
+
+  void LoadTrack(AliESDtrack *myTrack, Double_t aodChi2NDF=0);
+  Bool_t AcceptDaughter();
+  Bool_t AcceptCandidate();
+  Bool_t PassesPIDCuts(AliESDtrack *myTrack, AliPID::EParticleType pid=AliPID::kProton);
+
+  Bool_t IsAtTPCEdge(Double_t phi,Double_t pt,Int_t charge,Double_t b);
+
+  void MakeTrack();
+  void PushBackFlowTrack(AliFlowEvent *event, Double_t pt, Double_t phi, Double_t eta, Double_t we, Int_t id);
+
+  Double_t GetWDist(const AliVVertex* v0, const AliVVertex* v1);
+  Bool_t plpMV(const AliVEvent *event);
+
+  void LoadVZEROResponse();
+  void AddVZEROResponse();
+  void SaveVZEROResponse();
+  void AddVZEQA();
+  void SaveVZEROQA();
+
+  Int_t RefMultTPC();
+  Int_t RefMultGlobal();
+
+  AliPIDResponse *fPIDResponse; //! PID response object
+  AliESDtrackCuts *fFB1;        // filterbit cut equivalent
+  AliESDtrackCuts *fFB1024;     // filterbit cut equivalent
+  AliFlowEvent   *fTPCevent;    // flow event (needed here due to ev selection)
+  AliFlowEvent   *fVZEevent;    // flow event (needed here due to ev selection)
+  TObjArray      *fCandidates;  // array of selected candidates
+  TList          *fList;        // stores the final list of output histograms
+
+  Int_t fRunNumber; // current run number
+
+  Int_t fDebug;   // debug level
+  Int_t fQAlevel; // QA plots
+
+  Bool_t fReadESD;       // move back to ESD
+  Bool_t fReadMC;        // read MC files
+  Bool_t fAvoidExec;     // avoids Exec
+  Bool_t fSkipSelection; // skip decay finder
+  Bool_t fSkipFlow;      // skip flow-wise code
+  Bool_t fSkipDHcorr;    // skip dhcorr code
+  Bool_t fUseFP;         // flow package?
+  Bool_t fRunOnpA;       // make task compatible with pA event selection
+  Bool_t fRunOnpp;       // make task compatible with pp event selection
+  Bool_t fExtraEventRejection; // to reject pile up
+  TString  fCentMethod; // CC
+  Int_t    fCentPerMin; // CC
+  Int_t    fCentPerMax; // CC
+  Double_t fThisCent;   // CC
+
+  Bool_t fExcludeTPCEdges; // exclude TPC edges from single track selection
+
+  Int_t  fSpecie;   // K0=>0 L0=>1
+  Bool_t fOnline;   // change into online v0 finder
+  Bool_t fHomemade; // homemade v0 finder
+
+  Int_t fWhichPsi;  // detector for Psi2
+
+  Bool_t  fVZEsave; // make vze response
+  TList  *fVZEload; // adress to calibration file
+  TH2D   *fVZEResponse; // vze response vs centrality class
+  Bool_t  fVZEmb;   // integrate response (linearity)
+  Bool_t  fVZEByDisk; // normalized by disk
+  Int_t   fVZECa;   // start of V0C (ring number 0-3)
+  Int_t   fVZECb;   // end of V0C (ring number 0-3)
+  Int_t   fVZEAa;   // start of V0A (ring number 0-3)
+  Int_t   fVZEAb;   // end of V0A (ring number 0-3)
+  TList  *fVZEQA;   // adress to qalist
+
+  Double_t fPsi2;   // best estimation of Psi2
+  Double_t fMCEP;   // stores MC EP (when available)
+
+  Int_t    fMassBins; // opens
+  Double_t fMinMass;  // mass
+  Double_t fMaxMass;  // window
+
+  Int_t fRFPFilterBit;    // RFP TPC
+  Double_t fRFPminPt;     // RFP TPC
+  Double_t fRFPmaxPt;     // RFP TPC
+  Double_t fRFPminEta;    // RFP TPC
+  Double_t fRFPmaxEta;    // RFP TPC
+  Double_t fRFPTPCsignal; // RFP TPC
+  Double_t fRFPmaxIPxy;   // RFP TPC
+  Double_t fRFPmaxIPz;    // RFP TPC
+  Int_t fRFPTPCncls;      // RFP TPC
+
+  Double_t fDecayMass;                  // DECAY
+  Double_t fDecayPhi;                   // DECAY
+  Double_t fDecayEta;                   // DECAY
+  Double_t fDecayPt;                    // DECAY
+  Double_t fDecayDCAdaughters;          // DECAY
+  Double_t fDecayCosinePointingAngleXY; // DECAY
+  Double_t fDecayRadXY;                 // DECAY
+  Double_t fDecayDecayLength;           // DECAY
+  Double_t fDecayQt;                    // DECAY
+  Double_t fDecayAlpha;                 // DECAY
+  Double_t fDecayRapidity;              // DECAY
+  Double_t fDecayProductIPXY;           // DECAY
+  Int_t    fDecayIDneg;                 // DECAY
+  Int_t    fDecayIDpos;                 // DECAY
+  Int_t    fDecayID;                    // DECAY
+
+  Double_t fDecayMinEta;                   // DECAY CUTS
+  Double_t fDecayMaxEta;                   // DECAY CUTS
+  Double_t fDecayMinPt;                    // DECAY CUTS
+  Double_t fDecayMaxDCAdaughters;          // DECAY CUTS
+  Double_t fDecayMinCosinePointingAngleXY; // DECAY CUTS
+  Double_t fDecayMinQt;                    // DECAY CUTS
+  Bool_t   fDecayAPCutPie;                 // DECAY CUTS
+  Double_t fDecayMinRadXY;                 // DECAY CUTS
+  Double_t fDecayMaxDecayLength;           // DECAY CUTS
+  Double_t fDecayMaxProductIPXY;           // DECAY CUTS
+  Double_t fDecayMaxRapidity;              // DECAY CUTS
+
+  Double_t fDaughterPhi;               // DAUGHTER
+  Double_t fDaughterEta;               // DAUGHTER
+  Double_t fDaughterPt;                // DAUGHTER
+  Int_t    fDaughterNClsTPC;           // DAUGHTER
+  Int_t    fDaughterCharge;            // DAUGHTER
+  Int_t    fDaughterNFClsTPC;          // DAUGHTER
+  Int_t    fDaughterNSClsTPC;          // DAUGHTER
+  Double_t fDaughterChi2PerNClsTPC;    // DAUGHTER
+  Double_t fDaughterXRows;             // DAUGHTER
+  Float_t  fDaughterImpactParameterXY; // DAUGHTER
+  Float_t  fDaughterImpactParameterZ;  // DAUGHTER
+  UInt_t   fDaughterStatus;            // DAUGHTER
+  Double_t fDaughterNSigmaPID;         // DAUGHTER
+  Int_t    fDaughterKinkIndex;         // DAUGHTER
+
+  Bool_t   fDaughterUnTag;             // UNTAG PROCEDURE
+
+  Double_t fDaughterMinEta;               // DAUGHTER CUTS
+  Double_t fDaughterMaxEta;               // DAUGHTER CUTS
+  Double_t fDaughterMinPt;                // DAUGHTER CUTS
+  Int_t    fDaughterMinNClsTPC;           // DAUGHTER CUTS
+  Int_t    fDaughterMinXRows;             // DAUGHTER CUTS
+  Double_t fDaughterMaxChi2PerNClsTPC;    // DAUGHTER CUTS
+  Double_t fDaughterMinXRowsOverNClsFTPC; // DAUGHTER CUTS
+  Double_t fDaughterMinImpactParameterXY; // DAUGHTER CUTS
+  Double_t fDaughterMaxNSigmaPID;         // DAUGHTER CUTS
+
+  ClassDef(AliAnalysisTaskFlowStrange, 5);
+};
+#endif
index ecf0d0e..00736d0 100644 (file)
-#ifndef AliAnalysisTaskJetFlowMC_H\r
-#define AliAnalysisTaskJetFlowMC_H\r
-\r
-// root includes\r
-#include "TF1.h"\r
-#include "TH1F.h"\r
-#include "TH2F.h" \r
-#include "TRandom.h"\r
-// aliroot includes\r
-#include "AliAnalysisTaskSE.h"\r
-// forward declarations\r
-class TList;\r
-class TClonesArray;\r
-class TArrayI;\r
-\r
-class AliAnalysisTaskJetFlowMC : public AliAnalysisTaskSE \r
-{\r
-    public:\r
-        // enumerators\r
-        enum detectorType       {kVZEROA, kVZEROC, kVZEROComb};  // detector that was used\r
-        // constructors, destructor\r
-        AliAnalysisTaskJetFlowMC();\r
-        AliAnalysisTaskJetFlowMC(const char *name);\r
-        virtual ~AliAnalysisTaskJetFlowMC();\r
-        // mirror image of PickTrackMaker\r
-        void    UserCreateOutputObjects();\r
-        TH1F*   BookTH1F(const char* name, const char* x, Int_t bins, Double_t min, Double_t max, Int_t c = -1, Bool_t append = kTRUE);\r
-        TH2F*   BookTH2F(const char* name, const char* x, const char* y, Int_t binsx, Double_t minx, Double_t maxx, Int_t binsy, Double_t miny, Double_t maxy, Int_t c = -1, Bool_t append = kTRUE);\r
-\r
-        void    UserExec(Option_t *option);\r
-        void    SetDebugMode(Bool_t d)                          {fDebug = d;}\r
-        void    SetTracksInName(const char *name)               { fTracksInName     = name; }\r
-        void    SetTracksOutName(const char *name)              { fTracksOutName    = name; }\r
-        // additional setters\r
-        void    SetCentralityClasses(TArrayI* c)                { fCentralityClasses = c; }\r
-        void    SetReferenceDetector(detectorType type)         { fDetectorType = type; }\r
-        void    SetDifferentialV2(TF1* v2, Int_t c = 0)         { fFuncDiffV2[c] = v2; }\r
-        void    SetDifferentialV3(TF1* v3, Int_t c = 0)         { fFuncDiffV3[c] = v3; }\r
-        void    SetDifferentialV2(TH1* v2, Int_t c = 0)         { fHistDiffV2[c] = v2; }\r
-        void    SetDifferentialV3(TH1* v3, Int_t c = 0)         { fHistDiffV3[c] = v3; }\r
-        void    SetIntegratedV2(TH1* v2)                        { fHistIntV2 = v2; }\r
-        void    SetIntegratedV3(TH1* v3)                        { fHistIntV3 = v3; }\r
-        void    SetTrackSpectrum(TF1* ts)                       { fTrackSpectrum = ts; }\r
-        void    SetSingleFragmentationJetSpectrum(TF1* js)      { fJetSpectrumSF = js; }\r
-        void    SetNoOfSFJets(Int_t n)                          { fNoOfSFJets = n; }\r
-        // additional methods\r
-        void    V2AfterBurner(Double_t& phi, Double_t& eta, Double_t& pt) const;\r
-        void    V3AfterBurner(Double_t& phi, Double_t& eta, Double_t& pt) const;\r
-        void    InjectSingleFragmentationJetSpectrum(Int_t nacc);\r
-        void    CalculateEventPlane();\r
-        // inlined helper calculations\r
-        Double_t        GetTrackPt()       const                { return fTrackSpectrum->GetRandom();}\r
-        /* inline */    Double_t GetV2(Double_t pt) const { \r
-            return (fFuncDiffV2[fCenBin]) ? fFuncDiffV2[fCenBin]->Eval(pt) :\r
-            fHistDiffV2[fCenBin]->GetBinContent(fHistDiffV2[fCenBin]->GetXaxis()->FindBin(pt));\r
-        }\r
-        /* inline */    Double_t GetV3(Double_t pt) const { \r
-            return (fFuncDiffV3[fCenBin]) ? fFuncDiffV3[fCenBin]->Eval(pt) : \r
-            fHistDiffV3[fCenBin]->GetBinContent(fHistDiffV3[fCenBin]->GetXaxis()->FindBin(pt));\r
-        }\r
-        /* inline */    void GetFlowFluctuation(Double_t& vn) const {\r
-            vn += TMath::Sqrt(2*(vn*.25)*(vn*.25))*TMath::ErfInverse(2*(gRandom->Uniform(0, fFlowFluctuations))-1); \r
-        }\r
-        /* inline */    Double_t PhaseShift(Double_t x) const {  \r
-            while (x>=TMath::TwoPi())x-=TMath::TwoPi();\r
-            while (x<0.)x+=TMath::TwoPi();\r
-        return x; }\r
-        /* inline */    Double_t PhaseShift(Double_t x, Double_t n) const {\r
-            x = PhaseShift(x);\r
-            if(TMath::Nint(n)==2) while (x>TMath::Pi()) x-=TMath::Pi();\r
-            if(TMath::Nint(n)==3) {\r
-                if(x>2.*TMath::TwoPi()/n) x = TMath::TwoPi() - x;\r
-                if(x>TMath::TwoPi()/n) x = TMath::TwoPi()-(x+TMath::TwoPi()/n);\r
-            }\r
-        return x; }\r
-        /* inline */    void SampleVnFromTF1(Double_t &phi) const {\r
-        phi = (fFuncVn) ? fFuncVn->GetRandom(0., TMath::TwoPi()) : 0; }\r
-        /* inline */    void FillHistogramsOriginalData(Double_t& pt, Double_t& eta, Double_t& phi) const {\r
-            fHistOriginalSpectrum[fCenBin]->Fill(pt);    fHistOriginalEtaPhi[fCenBin]->Fill(eta, phi);\r
-            fHistOriginalDeltaPhi[fCenBin]->Fill(PhaseShift(phi-fPsi2, 2));\r
-        }\r
-        /* inline */    void FillHistogramsToyData(Double_t& pt, Double_t& eta, Double_t& phi, Double_t& vn) const {\r
-            fHistToySpectrum[fCenBin]->Fill(pt);         fHistToyEtaPhi[fCenBin]->Fill(eta, phi);\r
-            fHistToyDeltaPhi[fCenBin]->Fill(PhaseShift(phi-fPsi2, 2));  fHistToyVn[fCenBin]->Fill(pt, vn);\r
-        }\r
-        void            Terminate(Option_t* option);\r
-        void            PrintInfo() const;\r
-    protected:\r
-        TString         fTracksOutName;         // name of output track array\r
-        TString         fTracksInName;          // name of input track array\r
-        TClonesArray   *fTracksIn;              //!track array in\r
-        TClonesArray   *fTracksOut;             //!track array out\r
-        Int_t           fCenBin; //! centrality bin\r
-        TArrayI*        fCentralityClasses;     // centrality classes (max 10) \r
-        TF1*            fFuncVn;                //! vn function\r
-        TList*          fOutputList;            // output list\r
-        TF1*            fTrackSpectrum;         // track pt spectrum\r
-        TF1*            fJetSpectrumSF;         // single fragmentation spectrum of jets\r
-        Int_t           fNoOfSFJets;            // number of single fragmentation jets that will be added\r
-        TF1*            fFuncDiffV2[10];        // differential v2 of charged tracks\r
-        TF1*            fFuncDiffV3[10];        // differential v3 of charged tracks\r
-        TH1*            fHistDiffV2[10];        // differential v2 of charged tracks\r
-        TH1*            fHistDiffV3[10];        // differential v3 of charged tracks\r
-        TH1*            fHistIntV2;             // integrated v2 of charged tracks\r
-        TH1*            fHistIntV3;             // integrated v3 of charged tracks\r
-        Float_t         fFlowFluctuations;      // introduce gaussian flow fluctuations of this magnitude\r
-        Int_t           fMaxNumberOfIterations; // max number of iterations for afterburner\r
-        Double_t        fPsi2;                  //! 2nd order event plane orientation\r
-        Double_t        fPsi3;                  //! 3rd order event plane orientation\r
-        Double_t        fPrecisionPhi;          // afterburner precision\r
-        detectorType    fDetectorType;          // type of detector from which the EP is taken\r
-        // output histograms\r
-        TH1F*           fHistOriginalSpectrum[10];      //! original pt spectrum of accepted tracks\r
-        TH2F*           fHistOriginalEtaPhi[10];        //! original eta phi spectrum of accepted tracks\r
-        TH1F*           fHistToySpectrum[10];           //! spectrum of toy (generated) tracks\r
-        TH2F*           fHistToyEtaPhi[10];             //! eta phi spectrum of toy (generated) tracks\r
-        TH1F*           fHistOriginalDeltaPhi[10];      //! original delta phi spectrum\r
-        TH1F*           fHistToyDeltaPhi[10];           //! delta phi spectrum of toy (generated) tracks\r
-        TH2F*           fHistToyVn[10];                 //! generated differential vn values (should equal the differential spectrum)\r
-        TH1F*           fHistSFJetSpectrum;             //! spectrum of generated sf jets\r
-        TH2F*           fHistSFJetEtaPhi;               //! eta phi of generated sf jets\r
-    private:\r
-        AliAnalysisTaskJetFlowMC(const AliAnalysisTaskJetFlowMC&);            // not implemented\r
-        AliAnalysisTaskJetFlowMC &operator=(const AliAnalysisTaskJetFlowMC&); // not implemented\r
-\r
-        ClassDef(AliAnalysisTaskJetFlowMC, 1); // Task to generate toy mc PicoTracks based on real events\r
-};\r
-#endif\r
+#ifndef AliAnalysisTaskJetFlowMC_H
+#define AliAnalysisTaskJetFlowMC_H
+
+// root includes
+#include "TF1.h"
+#include "TH1F.h"
+#include "TH2F.h" 
+#include "TRandom.h"
+// aliroot includes
+#include "AliAnalysisTaskSE.h"
+// forward declarations
+class TList;
+class TClonesArray;
+class TArrayI;
+
+class AliAnalysisTaskJetFlowMC : public AliAnalysisTaskSE 
+{
+    public:
+        // enumerators
+        enum detectorType       {kVZEROA, kVZEROC, kVZEROComb};  // detector that was used
+        // constructors, destructor
+        AliAnalysisTaskJetFlowMC();
+        AliAnalysisTaskJetFlowMC(const char *name);
+        virtual ~AliAnalysisTaskJetFlowMC();
+        // mirror image of PickTrackMaker
+        void    UserCreateOutputObjects();
+        TH1F*   BookTH1F(const char* name, const char* x, Int_t bins, Double_t min, Double_t max, Int_t c = -1, Bool_t append = kTRUE);
+        TH2F*   BookTH2F(const char* name, const char* x, const char* y, Int_t binsx, Double_t minx, Double_t maxx, Int_t binsy, Double_t miny, Double_t maxy, Int_t c = -1, Bool_t append = kTRUE);
+
+        void    UserExec(Option_t *option);
+        void    SetDebugMode(Bool_t d)                          {fDebug = d;}
+        void    SetTracksInName(const char *name)               { fTracksInName     = name; }
+        void    SetTracksOutName(const char *name)              { fTracksOutName    = name; }
+        // additional setters
+        void    SetCentralityClasses(TArrayI* c)                { fCentralityClasses = c; }
+        void    SetReferenceDetector(detectorType type)         { fDetectorType = type; }
+        void    SetDifferentialV2(TF1* v2, Int_t c = 0)         { fFuncDiffV2[c] = v2; }
+        void    SetDifferentialV3(TF1* v3, Int_t c = 0)         { fFuncDiffV3[c] = v3; }
+        void    SetDifferentialV2(TH1* v2, Int_t c = 0)         { fHistDiffV2[c] = v2; }
+        void    SetDifferentialV3(TH1* v3, Int_t c = 0)         { fHistDiffV3[c] = v3; }
+        void    SetIntegratedV2(TH1* v2)                        { fHistIntV2 = v2; }
+        void    SetIntegratedV3(TH1* v3)                        { fHistIntV3 = v3; }
+        void    SetTrackSpectrum(TF1* ts)                       { fTrackSpectrum = ts; }
+        void    SetSingleFragmentationJetSpectrum(TF1* js)      { fJetSpectrumSF = js; }
+        void    SetNoOfSFJets(Int_t n)                          { fNoOfSFJets = n; }
+        // additional methods
+        void    V2AfterBurner(Double_t& phi, Double_t& eta, Double_t& pt) const;
+        void    V3AfterBurner(Double_t& phi, Double_t& eta, Double_t& pt) const;
+        void    InjectSingleFragmentationJetSpectrum(Int_t nacc);
+        void    CalculateEventPlane();
+        // inlined helper calculations
+        Double_t        GetTrackPt()       const                { return fTrackSpectrum->GetRandom();}
+        /* inline */    Double_t GetV2(Double_t pt) const { 
+            return (fFuncDiffV2[fCenBin]) ? fFuncDiffV2[fCenBin]->Eval(pt) :
+            fHistDiffV2[fCenBin]->GetBinContent(fHistDiffV2[fCenBin]->GetXaxis()->FindBin(pt));
+        }
+        /* inline */    Double_t GetV3(Double_t pt) const { 
+            return (fFuncDiffV3[fCenBin]) ? fFuncDiffV3[fCenBin]->Eval(pt) : 
+            fHistDiffV3[fCenBin]->GetBinContent(fHistDiffV3[fCenBin]->GetXaxis()->FindBin(pt));
+        }
+        /* inline */    void GetFlowFluctuation(Double_t& vn) const {
+            vn += TMath::Sqrt(2*(vn*.25)*(vn*.25))*TMath::ErfInverse(2*(gRandom->Uniform(0, fFlowFluctuations))-1); 
+        }
+        /* inline */    Double_t PhaseShift(Double_t x) const {  
+            while (x>=TMath::TwoPi())x-=TMath::TwoPi();
+            while (x<0.)x+=TMath::TwoPi();
+        return x; }
+        /* inline */    Double_t PhaseShift(Double_t x, Double_t n) const {
+            x = PhaseShift(x);
+            if(TMath::Nint(n)==2) while (x>TMath::Pi()) x-=TMath::Pi();
+            if(TMath::Nint(n)==3) {
+                if(x>2.*TMath::TwoPi()/n) x = TMath::TwoPi() - x;
+                if(x>TMath::TwoPi()/n) x = TMath::TwoPi()-(x+TMath::TwoPi()/n);
+            }
+        return x; }
+        /* inline */    void SampleVnFromTF1(Double_t &phi) const {
+        phi = (fFuncVn) ? fFuncVn->GetRandom(0., TMath::TwoPi()) : 0; }
+        /* inline */    void FillHistogramsOriginalData(Double_t& pt, Double_t& eta, Double_t& phi) const {
+            fHistOriginalSpectrum[fCenBin]->Fill(pt);    fHistOriginalEtaPhi[fCenBin]->Fill(eta, phi);
+            fHistOriginalDeltaPhi[fCenBin]->Fill(PhaseShift(phi-fPsi2, 2));
+        }
+        /* inline */    void FillHistogramsToyData(Double_t& pt, Double_t& eta, Double_t& phi, Double_t& vn) const {
+            fHistToySpectrum[fCenBin]->Fill(pt);         fHistToyEtaPhi[fCenBin]->Fill(eta, phi);
+            fHistToyDeltaPhi[fCenBin]->Fill(PhaseShift(phi-fPsi2, 2));  fHistToyVn[fCenBin]->Fill(pt, vn);
+        }
+        void            Terminate(Option_t* option);
+        void            PrintInfo() const;
+    protected:
+        TString         fTracksOutName;         // name of output track array
+        TString         fTracksInName;          // name of input track array
+        TClonesArray   *fTracksIn;              //!track array in
+        TClonesArray   *fTracksOut;             //!track array out
+        Int_t           fCenBin; //! centrality bin
+        TArrayI*        fCentralityClasses;     // centrality classes (max 10) 
+        TF1*            fFuncVn;                //! vn function
+        TList*          fOutputList;            // output list
+        TF1*            fTrackSpectrum;         // track pt spectrum
+        TF1*            fJetSpectrumSF;         // single fragmentation spectrum of jets
+        Int_t           fNoOfSFJets;            // number of single fragmentation jets that will be added
+        TF1*            fFuncDiffV2[10];        // differential v2 of charged tracks
+        TF1*            fFuncDiffV3[10];        // differential v3 of charged tracks
+        TH1*            fHistDiffV2[10];        // differential v2 of charged tracks
+        TH1*            fHistDiffV3[10];        // differential v3 of charged tracks
+        TH1*            fHistIntV2;             // integrated v2 of charged tracks
+        TH1*            fHistIntV3;             // integrated v3 of charged tracks
+        Float_t         fFlowFluctuations;      // introduce gaussian flow fluctuations of this magnitude
+        Int_t           fMaxNumberOfIterations; // max number of iterations for afterburner
+        Double_t        fPsi2;                  //! 2nd order event plane orientation
+        Double_t        fPsi3;                  //! 3rd order event plane orientation
+        Double_t        fPrecisionPhi;          // afterburner precision
+        detectorType    fDetectorType;          // type of detector from which the EP is taken
+        // output histograms
+        TH1F*           fHistOriginalSpectrum[10];      //! original pt spectrum of accepted tracks
+        TH2F*           fHistOriginalEtaPhi[10];        //! original eta phi spectrum of accepted tracks
+        TH1F*           fHistToySpectrum[10];           //! spectrum of toy (generated) tracks
+        TH2F*           fHistToyEtaPhi[10];             //! eta phi spectrum of toy (generated) tracks
+        TH1F*           fHistOriginalDeltaPhi[10];      //! original delta phi spectrum
+        TH1F*           fHistToyDeltaPhi[10];           //! delta phi spectrum of toy (generated) tracks
+        TH2F*           fHistToyVn[10];                 //! generated differential vn values (should equal the differential spectrum)
+        TH1F*           fHistSFJetSpectrum;             //! spectrum of generated sf jets
+        TH2F*           fHistSFJetEtaPhi;               //! eta phi of generated sf jets
+    private:
+        AliAnalysisTaskJetFlowMC(const AliAnalysisTaskJetFlowMC&);            // not implemented
+        AliAnalysisTaskJetFlowMC &operator=(const AliAnalysisTaskJetFlowMC&); // not implemented
+
+        ClassDef(AliAnalysisTaskJetFlowMC, 1); // Task to generate toy mc PicoTracks based on real events
+};
+#endif
index d1d0416..b770584 100644 (file)
-/**************************************************************************\r
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
- *                                                                        *\r
- * Author: The ALICE Off-line Project.                                    *\r
- * Contributors are mentioned in the code where appropriate.              *\r
- *                                                                        *\r
- * Permission to use, copy, modify and distribute this software and its   *\r
- * documentation strictly for non-commercial purposes is hereby granted   *\r
- * without fee, provided that the above copyright notice appears in all   *\r
- * copies and that both the copyright notice and this permission notice   *\r
- * appear in the supporting documentation. The authors make no claims     *\r
- * about the suitability of this software for any purpose. It is          *\r
- * provided "as is" without express or implied warranty.                  *\r
- **************************************************************************/\r
-\r
-/*****************************************************************\r
-  AliFlowEvent: Event container for flow analysis\r
-\r
-  origin:   Mikolaj Krzewicki  (mikolaj.krzewicki@cern.ch)\r
-  mods:     Redmer A. Bertens (rbertens@cern.ch)\r
-*****************************************************************/\r
-\r
-#include "Riostream.h"\r
-#include "TFile.h"\r
-#include "TList.h"\r
-#include "TH1.h"\r
-#include "TH2F.h"\r
-#include "TProfile.h"\r
-#include "AliMCEvent.h"\r
-#include "AliMCParticle.h"\r
-#include "AliCFManager.h"\r
-#include "AliESDtrack.h"\r
-#include "AliESDPmdTrack.h"\r
-#include "AliESDEvent.h"\r
-#include "AliAODEvent.h"\r
-#include "AliOADBContainer.h"\r
-#include "AliGenCocktailEventHeader.h"\r
-#include "AliGenEposEventHeader.h"\r
-#include "AliGenHijingEventHeader.h"\r
-#include "AliGenGeVSimEventHeader.h"\r
-#include "AliCollisionGeometry.h"\r
-#include "AliMultiplicity.h"\r
-#include "AliFlowTrackCuts.h"\r
-#include "AliFlowEventSimple.h"\r
-#include "AliFlowTrack.h"\r
-#include "AliFlowVector.h"\r
-#include "AliFlowEvent.h"\r
-#include "AliLog.h"\r
-\r
-using std::endl;\r
-using std::cout;\r
-ClassImp(AliFlowEvent)\r
-\r
-//-----------------------------------------------------------------------\r
-AliFlowEvent::AliFlowEvent():\r
-  AliFlowEventSimple(), fApplyRecentering(kFALSE), fCachedRun(-1), fCurrentCentrality(-1)\r
-{\r
-    // constructor\r
-    for(Int_t i(0); i < 9; i++) {\r
-        for(Int_t j(0); j < 2; j++) {\r
-            for(Int_t k(0); k < 2; k++) {\r
-                fMeanQ[i][j][k] = 0.; \r
-                fWidthQ[i][j][k] = 0.;  \r
-                fMeanQv3[i][j][k] = 0.; \r
-                fWidthQv3[i][j][k] = 0.;\r
-            }\r
-        }\r
-    }\r
-\r
-  //ctor\r
-  cout << "AliFlowEvent: Default constructor to be used only by root for io" << endl;\r
-}\r
-\r
-//-----------------------------------------------------------------------\r
-AliFlowEvent::AliFlowEvent(Int_t n):\r
-  AliFlowEventSimple(n), fApplyRecentering(kFALSE), fCachedRun(-1), fCurrentCentrality(-1)\r
-{\r
-    // constructor\r
-    for(Int_t i(0); i < 9; i++) {\r
-        for(Int_t j(0); j < 2; j++) {\r
-            for(Int_t k(0); k < 2; k++) {\r
-                fMeanQ[i][j][k] = 0.; \r
-                fWidthQ[i][j][k] = 0.;  \r
-                fMeanQv3[i][j][k] = 0.; \r
-                fWidthQv3[i][j][k] = 0.;\r
-            }\r
-        }\r
-    }\r
-}\r
-\r
-//-----------------------------------------------------------------------\r
-AliFlowEvent::AliFlowEvent(const AliFlowEvent& event):\r
-  AliFlowEventSimple(event), fApplyRecentering(event.fApplyRecentering), fCachedRun(-1), fCurrentCentrality(-1)\r
-{\r
-    // copy constructor \r
-    for(Int_t i(0); i < 9; i++) {\r
-        for(Int_t j(0); j < 2; j++) {\r
-            for(Int_t k(0); k < 2; k++) {\r
-                fMeanQ[i][j][k] = 0.; \r
-                fWidthQ[i][j][k] = 0.;  \r
-                fMeanQv3[i][j][k] = 0.; \r
-                fWidthQv3[i][j][k] = 0.;\r
-            }\r
-        }\r
-    }\r
-}\r
-\r
-//-----------------------------------------------------------------------\r
-AliFlowEvent& AliFlowEvent::operator=(const AliFlowEvent& event)\r
-{\r
-\r
-  //assignment operator\r
-  if (&event==this) return *this;       // check self-assignment\r
-\r
-  fApplyRecentering = event.fApplyRecentering; \r
-  fCachedRun = event.fCachedRun; \r
-  fCurrentCentrality = event.fCurrentCentrality;\r
-  for(Int_t i(0); i < 9; i++) {\r
-      for(Int_t j(0); j < 2; j++) {\r
-          for(Int_t k(0); k < 2; k++) {\r
-              fMeanQ[i][j][k] = event.fMeanQ[i][j][k]; \r
-              fWidthQ[i][j][k] = fWidthQ[i][j][k];  \r
-              fMeanQv3[i][j][k] = fMeanQv3[i][j][k]; \r
-              fWidthQv3[i][j][k] = fWidthQv3[i][j][k];\r
-          }\r
-      }\r
-  }\r
-  AliFlowEventSimple::operator=(event);\r
-  return *this;\r
-}\r
-\r
-//-----------------------------------------------------------------------\r
-AliFlowTrack* AliFlowEvent::GetTrack(Int_t i)\r
-{\r
-  //get track i from collection\r
-  if (i>=fNumberOfTracks) return NULL;\r
-  AliFlowTrack* pTrack = static_cast<AliFlowTrack*>(fTrackCollection->At(i)) ;\r
-  return pTrack;\r
-}\r
-\r
-//-----------------------------------------------------------------------\r
-void AliFlowEvent::SetMCReactionPlaneAngle(const AliMCEvent* mcEvent)\r
-{\r
-  //sets the event plane angle from the proper header in the MC\r
-\r
-  //COCKTAIL with HIJING\r
-  if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"Cocktail Header"))   //returns 0 if matches\r
-  {\r
-    AliGenCocktailEventHeader *headerC = dynamic_cast<AliGenCocktailEventHeader *> (mcEvent-> GenEventHeader());\r
-    if (headerC)\r
-    {\r
-      TList *lhd = headerC->GetHeaders();\r
-      if (lhd)\r
-      {\r
-        AliGenHijingEventHeader *hdh = dynamic_cast<AliGenHijingEventHeader *> (lhd->At(0));\r
-        if (hdh) AliFlowEventSimple::SetMCReactionPlaneAngle( hdh->ReactionPlaneAngle() );\r
-      }\r
-    }\r
-  }\r
-  //THERMINATOR\r
-  else if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"Therminator"))   //returns 0 if matches\r
-  {\r
-    AliGenHijingEventHeader* headerH = dynamic_cast<AliGenHijingEventHeader*>(mcEvent->GenEventHeader());\r
-    if (headerH) AliFlowEventSimple::SetMCReactionPlaneAngle( headerH->ReactionPlaneAngle() );\r
-  }\r
-  //GEVSIM\r
-  else if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"GeVSim header"))   //returns 0 if matches\r
-  {\r
-    AliGenGeVSimEventHeader* headerG = dynamic_cast<AliGenGeVSimEventHeader*>(mcEvent->GenEventHeader());\r
-    if (headerG) AliFlowEventSimple::SetMCReactionPlaneAngle( headerG->GetEventPlane() );\r
-  }\r
-  //HIJING\r
-  else if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"Hijing"))   //returns 0 if matches\r
-  {\r
-    AliGenHijingEventHeader* headerH = dynamic_cast<AliGenHijingEventHeader*>(mcEvent->GenEventHeader());\r
-    if (headerH) AliFlowEventSimple::SetMCReactionPlaneAngle( headerH->ReactionPlaneAngle() );\r
-  }\r
-  //AMPT\r
-  else if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"Ampt"))   //returns 0 if matches\r
-  {\r
-    AliGenHijingEventHeader* headerH = dynamic_cast<AliGenHijingEventHeader*>(mcEvent->GenEventHeader());\r
-    if (headerH) AliFlowEventSimple::SetMCReactionPlaneAngle( headerH->ReactionPlaneAngle() );\r
-  }\r
-  //EPOS\r
-  else if (!strcmp(mcEvent->GenEventHeader()->GetName(),"EPOS"))\r
-  {\r
-    AliGenEposEventHeader* headerE = dynamic_cast<AliGenEposEventHeader*>(mcEvent->GenEventHeader());\r
-    if (headerE) AliFlowEventSimple::SetMCReactionPlaneAngle( headerE->ReactionPlaneAngle() );\r
-  }\r
-  //Hydjet\r
-  else\r
-  {\r
-    AliCollisionGeometry* header = dynamic_cast<AliCollisionGeometry*>(mcEvent->GenEventHeader());\r
-    if (header) AliFlowEventSimple::SetMCReactionPlaneAngle( header->ReactionPlaneAngle() );\r
-  }\r
-}\r
-\r
-//-----------------------------------------------------------------------\r
-AliFlowEvent::AliFlowEvent( const AliMCEvent* anInput,\r
-                            const AliCFManager* rpCFManager,\r
-                            const AliCFManager* poiCFManager):\r
-  AliFlowEventSimple(20), fApplyRecentering(kFALSE), fCachedRun(-1), fCurrentCentrality(-1)\r
-{\r
-    // constructor\r
-    for(Int_t i(0); i < 9; i++) {\r
-        for(Int_t j(0); j < 2; j++) {\r
-            for(Int_t k(0); k < 2; k++) {\r
-                fMeanQ[i][j][k] = 0.; \r
-                fWidthQ[i][j][k] = 0.;  \r
-                fMeanQv3[i][j][k] = 0.; \r
-                fWidthQv3[i][j][k] = 0.;\r
-            }\r
-        }\r
-    }\r
-\r
-  //Fills the event from the MC kinematic information\r
-\r
-  Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;\r
-\r
-  //loop over tracks\r
-  for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)\r
-  {\r
-    //get input particle\r
-    AliMCParticle* pParticle = dynamic_cast<AliMCParticle*>(anInput->GetTrack(itrkN));\r
-    if (!pParticle) continue;\r
-\r
-    //check if pParticle passes the cuts\r
-    Bool_t rpOK = kTRUE;\r
-    Bool_t poiOK = kTRUE;\r
-    if (rpCFManager && poiCFManager)\r
-    {\r
-      rpOK = rpCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pParticle);\r
-      poiOK = poiCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pParticle);\r
-    }\r
-    if (!(rpOK||poiOK)) continue;\r
-\r
-    AliFlowTrack* pTrack = new AliFlowTrack(pParticle);\r
-    pTrack->SetSource(AliFlowTrack::kFromMC);\r
-\r
-    if (rpOK && rpCFManager)\r
-    {\r
-      pTrack->SetForRPSelection(kTRUE);\r
-      fNumberOfRPs++;\r
-    }\r
-    if (poiOK && poiCFManager)\r
-    {\r
-      pTrack->SetForPOISelection(kTRUE);\r
-      fNumberOfPOIs++;\r
-    }\r
-\r
-    AddTrack(pTrack) ;\r
-  }//for all tracks\r
-  SetMCReactionPlaneAngle(anInput);\r
-}\r
-\r
-//-----------------------------------------------------------------------\r
-AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,\r
-                            const AliCFManager* rpCFManager,\r
-                            const AliCFManager* poiCFManager ):\r
-  AliFlowEventSimple(20),  fApplyRecentering(kFALSE), fCachedRun(-1), fCurrentCentrality(-1)\r
-{\r
-    // constructor\r
-    for(Int_t i(0); i < 9; i++) {\r
-        for(Int_t j(0); j < 2; j++) {\r
-            for(Int_t k(0); k < 2; k++) {\r
-                fMeanQ[i][j][k] = 0.; \r
-                fWidthQ[i][j][k] = 0.;  \r
-                fMeanQv3[i][j][k] = 0.; \r
-                fWidthQv3[i][j][k] = 0.;\r
-            }\r
-        }\r
-    }\r
-   \r
-  //Fills the event from the ESD\r
-\r
-  Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;\r
-\r
-  //loop over tracks\r
-  for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)\r
-  {\r
-    AliESDtrack* pParticle = anInput->GetTrack(itrkN);   //get input particle\r
-\r
-    //check if pParticle passes the cuts\r
-    Bool_t rpOK = kTRUE;\r
-    Bool_t poiOK = kTRUE;\r
-    if (rpCFManager && poiCFManager)\r
-    {\r
-      rpOK = ( rpCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&\r
-               rpCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));\r
-      poiOK = ( poiCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&\r
-                poiCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));\r
-    }\r
-    if (!(rpOK || poiOK)) continue;\r
-\r
-    //make new AliFLowTrack\r
-    AliFlowTrack* pTrack = new AliFlowTrack(pParticle);\r
-    pTrack->SetSource(AliFlowTrack::kFromESD);\r
-\r
-    //marking the particles used for int. flow:\r
-    if(rpOK && rpCFManager)\r
-    {\r
-      pTrack->SetForRPSelection(kTRUE);\r
-      fNumberOfRPs++;\r
-    }\r
-    //marking the particles used for diff. flow:\r
-    if(poiOK && poiCFManager)\r
-    {\r
-      pTrack->SetForPOISelection(kTRUE);\r
-      fNumberOfPOIs++;\r
-    }\r
-\r
-    AddTrack(pTrack);\r
-  }//end of while (itrkN < iNumberOfInputTracks)\r
-}\r
-\r
-//-----------------------------------------------------------------------\r
-AliFlowEvent::AliFlowEvent( const AliAODEvent* anInput,\r
-                            const AliCFManager* rpCFManager,\r
-                            const AliCFManager* poiCFManager):\r
-  AliFlowEventSimple(20), fApplyRecentering(kFALSE), fCachedRun(-1), fCurrentCentrality(-1)\r
-{\r
-    // constructor\r
-    for(Int_t i(0); i < 9; i++) {\r
-        for(Int_t j(0); j < 2; j++) {\r
-            for(Int_t k(0); k < 2; k++) {\r
-                fMeanQ[i][j][k] = 0.; \r
-                fWidthQ[i][j][k] = 0.;  \r
-                fMeanQv3[i][j][k] = 0.; \r
-                fWidthQv3[i][j][k] = 0.;\r
-            }\r
-        }\r
-    }\r
-\r
-  //Fills the event from the AOD\r
-  Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;\r
-\r
-  //loop over tracks\r
-  for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)\r
-  {\r
-    AliAODTrack* pParticle = anInput->GetTrack(itrkN);   //get input particle\r
-\r
-    //check if pParticle passes the cuts\r
-    Bool_t rpOK = kTRUE;\r
-    Bool_t poiOK = kTRUE;\r
-    if (rpCFManager && poiCFManager)\r
-    {\r
-      rpOK = ( rpCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&\r
-               rpCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));\r
-      poiOK = ( poiCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&\r
-                poiCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));\r
-    }\r
-    if (!(rpOK || poiOK)) continue;\r
-\r
-    //make new AliFlowTrack\r
-    AliFlowTrack* pTrack = new AliFlowTrack(pParticle);\r
-    pTrack->SetSource(AliFlowTrack::kFromAOD);\r
-\r
-    if (rpOK /* && rpCFManager */ ) // to be fixed - with CF managers uncommented only empty events (NULL in header files)\r
-    {\r
-      pTrack->SetForRPSelection(kTRUE);\r
-      fNumberOfRPs++;\r
-    }\r
-    if (poiOK /* && poiCFManager*/ )\r
-    {\r
-      pTrack->SetForPOISelection(kTRUE);\r
-      fNumberOfPOIs++;\r
-    }\r
-    AddTrack(pTrack);\r
-  }\r
-\r
-  //  if (iSelParticlesRP >= fMinMult && iSelParticlesRP <= fMaxMult)\r
-  //  {\r
-  //    if ( (++fCount % 100) == 0)\r
-  //    {\r
-  //      if (!fMCReactionPlaneAngle == 0) cout<<" MC Reaction Plane Angle = "<<  fMCReactionPlaneAngle << endl;\r
-  //      else cout<<" MC Reaction Plane Angle = unknown "<< endl;\r
-  //      cout<<" iGoodTracks = "<<iGoodTracks<<endl;\r
-  //      cout<<" # of RP selected tracks = "<<iSelParticlesRP<<endl;\r
-  //      cout<<" # of POI selected tracks = "<<iSelParticlesPOI<<endl;\r
-  //      cout << "# " << fCount << " events processed" << endl;\r
-  //    }\r
-  //    return pEvent;\r
-  //  }\r
-  //  else\r
-  //  {\r
-  //    cout<<"Not enough tracks in the FlowEventSimple"<<endl;\r
-  //    return 0;\r
-  //  }\r
-  //}\r
-  //else\r
-  //{\r
-  //  cout<<"Event does not pass multiplicity cuts"<<endl;\r
-  //  return 0;\r
-  //}\r
-\r
-}\r
-\r
-//-----------------------------------------------------------------------\r
-AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,\r
-                            const AliMCEvent* anInputMc,\r
-                            KineSource anOption,\r
-                            const AliCFManager* rpCFManager,\r
-                            const AliCFManager* poiCFManager ):\r
-  AliFlowEventSimple(20), fApplyRecentering(kFALSE), fCachedRun(-1), fCurrentCentrality(-1)\r
-{\r
-    // constructor\r
-    for(Int_t i(0); i < 9; i++) {\r
-        for(Int_t j(0); j < 2; j++) {\r
-            for(Int_t k(0); k < 2; k++) {\r
-                fMeanQ[i][j][k] = 0.; \r
-                fWidthQ[i][j][k] = 0.;  \r
-                fMeanQv3[i][j][k] = 0.; \r
-                fWidthQv3[i][j][k] = 0.;\r
-            }\r
-        }\r
-    }\r
-\r
-  //fills the event with tracks from the ESD and kinematics from the MC info via the track label\r
-  if (anOption==kNoKine)\r
-  {\r
-    AliFatal("WRONG OPTION IN AliFlowEventMaker::FillTracks(AliESDEvent* anInput, AliMCEvent* anInputMc, KineSource anOption)");\r
-    exit(1);\r
-  }\r
-\r
-  Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;\r
-\r
-  Int_t iNumberOfInputTracksMC = anInputMc->GetNumberOfTracks() ;\r
-  if (iNumberOfInputTracksMC==-1)\r
-  {\r
-    AliError("Skipping Event -- No MC information available for this event");\r
-    return;\r
-  }\r
-\r
-  //loop over ESD tracks\r
-  for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)\r
-  {\r
-    AliESDtrack* pParticle = anInput->GetTrack(itrkN);   //get input particle\r
-    //get Label\r
-    Int_t iLabel = pParticle->GetLabel();\r
-    //match to mc particle\r
-    AliMCParticle* pMcParticle = (AliMCParticle*) anInputMc->GetTrack(TMath::Abs(iLabel));\r
-\r
-    //check\r
-    if (TMath::Abs(pParticle->GetLabel())!=pMcParticle->Label())\r
-      AliWarning(Form("pParticle->GetLabel()!=pMcParticle->Label(), %i, %i", pParticle->GetLabel(), pMcParticle->Label()));\r
-\r
-    //check if pParticle passes the cuts\r
-    Bool_t rpOK = kFALSE;\r
-    Bool_t poiOK = kFALSE;\r
-    if (rpCFManager && poiCFManager)\r
-    {\r
-      if(anOption == kESDkine)\r
-      {\r
-        if (rpCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pMcParticle,"mcGenCuts1") &&\r
-            rpCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle))\r
-          rpOK=kTRUE;\r
-        if (poiCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pMcParticle,"mcGenCuts2") &&\r
-            poiCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle))\r
-          poiOK=kTRUE;\r
-      }\r
-      else if (anOption == kMCkine)\r
-      {\r
-        if (rpCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pMcParticle))\r
-          rpOK=kTRUE;\r
-        if (poiCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pMcParticle))\r
-          poiOK=kTRUE;\r
-      }\r
-    }\r
-\r
-    if (!(rpOK || poiOK)) continue;\r
-\r
-    //make new AliFlowTrack\r
-    AliFlowTrack* pTrack = NULL;\r
-    if(anOption == kESDkine)   //take the PID from the MC & the kinematics from the ESD\r
-    {\r
-      pTrack = new AliFlowTrack(pParticle);\r
-    }\r
-    else if (anOption == kMCkine)   //take the PID and kinematics from the MC\r
-    {\r
-      pTrack = new AliFlowTrack(pMcParticle);\r
-    }\r
-\r
-    if (rpOK && rpCFManager)\r
-    {\r
-      fNumberOfRPs++;\r
-      pTrack->SetForRPSelection();\r
-    }\r
-    if (poiOK && poiCFManager) \r
-    { \r
-      fNumberOfPOIs++;\r
-      pTrack->SetForPOISelection();\r
-    }\r
-\r
-    AddTrack(pTrack);\r
-  }\r
-  SetMCReactionPlaneAngle(anInputMc);\r
-}\r
-\r
-//-----------------------------------------------------------------------\r
-AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,\r
-                           const AliMultiplicity* anInputTracklets,\r
-                           const AliCFManager* poiCFManager ):\r
-  AliFlowEventSimple(20), fApplyRecentering(kFALSE), fCachedRun(-1), fCurrentCentrality(-1)\r
-{\r
-    // constructor\r
-    for(Int_t i(0); i < 9; i++) {\r
-        for(Int_t j(0); j < 2; j++) {\r
-            for(Int_t k(0); k < 2; k++) {\r
-                fMeanQ[i][j][k] = 0.; \r
-                fWidthQ[i][j][k] = 0.;  \r
-                fMeanQv3[i][j][k] = 0.; \r
-                fWidthQv3[i][j][k] = 0.;\r
-            }\r
-        }\r
-    }\r
-\r
-\r
-  //Select the particles of interest from the ESD\r
-  Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;\r
-\r
-  //loop over tracks\r
-  for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)\r
-    {\r
-      AliESDtrack* pParticle = anInput->GetTrack(itrkN);   //get input particle\r
-\r
-      //check if pParticle passes the cuts\r
-      Bool_t poiOK = kTRUE;\r
-      if (poiCFManager)\r
-       {\r
-         poiOK = ( poiCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&\r
-                   poiCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));\r
-       }\r
-      if (!poiOK) continue;\r
-      \r
-      //make new AliFLowTrack\r
-      AliFlowTrack* pTrack = new AliFlowTrack(pParticle);\r
-          \r
-      //marking the particles used for the particle of interest (POI) selection:\r
-      if(poiOK && poiCFManager)\r
-       {\r
-          fNumberOfPOIs++;\r
-         pTrack->SetForPOISelection(kTRUE);\r
-         pTrack->SetSource(AliFlowTrack::kFromESD);\r
-       }\r
-\r
-      AddTrack(pTrack);\r
-    }//end of while (itrkN < iNumberOfInputTracks)\r
-\r
-  //Select the reference particles from the SPD tracklets\r
-  anInputTracklets = anInput->GetMultiplicity();\r
-  Int_t multSPD = anInputTracklets->GetNumberOfTracklets();\r
-  \r
-  //loop over tracklets\r
-  for (Int_t itracklet=0; itracklet<multSPD; ++itracklet) {\r
-    Float_t thetaTr= anInputTracklets->GetTheta(itracklet);\r
-    Float_t phiTr= anInputTracklets->GetPhi(itracklet);\r
-    // calculate eta\r
-    Float_t etaTr = -TMath::Log(TMath::Tan(thetaTr/2.));\r
-    \r
-    //make new AliFLowTrackSimple\r
-    AliFlowTrack* pTrack = new AliFlowTrack();\r
-    pTrack->SetPt(0.0);\r
-    pTrack->SetEta(etaTr);\r
-    pTrack->SetPhi(phiTr);\r
-    //marking the particles used for the reference particle (RP) selection:\r
-    fNumberOfRPs++;\r
-    pTrack->SetForRPSelection(kTRUE);\r
-    pTrack->SetSource(AliFlowTrack::kFromTracklet);\r
-\r
-    //Add the track to the flowevent\r
-    AddTrack(pTrack);\r
-  }\r
-\r
-}\r
-\r
-//-----------------------------------------------------------------------\r
-AliFlowEvent::AliFlowEvent( const AliESDEvent* esd,\r
-                           const AliCFManager* poiCFManager,\r
-                            Bool_t hybrid):\r
-  AliFlowEventSimple(20), fApplyRecentering(kFALSE), fCachedRun(-1), fCurrentCentrality(-1)\r
-{\r
-    // constructor\r
-    for(Int_t i(0); i < 9; i++) {\r
-        for(Int_t j(0); j < 2; j++) {\r
-            for(Int_t k(0); k < 2; k++) {\r
-                fMeanQ[i][j][k] = 0.; \r
-                fWidthQ[i][j][k] = 0.;  \r
-                fMeanQv3[i][j][k] = 0.; \r
-                fWidthQv3[i][j][k] = 0.;\r
-            }\r
-        }\r
-    }\r
-\r
-\r
-  //Select the particles of interest from the ESD\r
-  Int_t iNumberOfInputTracks = esd->GetNumberOfTracks() ;\r
-\r
-  //Double_t gPt = 0.0, gP = 0.0;\r
-  Double_t dca[2] = {0.0,0.0}, cov[3] = {0.0,0.0,0.0};  //The impact parameters and their covariance.\r
-//  Double_t dca3D = 0.0;       FIXME unused variable\r
-\r
-  AliESDtrack trackTPC;\r
-\r
-  //loop over tracks\r
-  for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)\r
-    {\r
-\r
-      if (!esd->GetTrack(itrkN)) continue;\r
-\r
-      Bool_t useTPC = kFALSE;\r
-\r
-      AliESDtrack* pParticle = esd->GetTrack(itrkN);   //get input particle\r
-\r
-      //check if pParticle passes the cuts\r
-      Bool_t poiOK = kTRUE;\r
-\r
-      if (poiCFManager)\r
-      {\r
-        poiOK = ( poiCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&\r
-                  poiCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));\r
-      }\r
-\r
-      if (!(poiOK)) continue;\r
-\r
-      AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)pParticle->GetTPCInnerParam();\r
-\r
-      if (tpcTrack)\r
-      {\r
-\r
-//      gPt = tpcTrack->Pt();\r
-//      gP = tpcTrack->P();\r
-\r
-        useTPC = kTRUE;\r
-\r
-        const AliESDVertex *vertexSPD = esd->GetPrimaryVertexSPD();\r
-        const AliESDVertex *vertexTPC = esd->GetPrimaryVertexTPC();\r
-\r
-        if(hybrid)\r
-          tpcTrack->PropagateToDCA(vertexSPD,esd->GetMagneticField(),100.,dca,cov);\r
-        else\r
-          tpcTrack->PropagateToDCA(vertexTPC,esd->GetMagneticField(),100.,dca,cov);\r
-\r
-//        dca3D = TMath::Sqrt(TMath::Power(dca[0],2)+TMath::Power(dca[1],2));   FIXME unused variable\r
-\r
-      }\r
-\r
-      //make new AliFLowTrack\r
-      AliFlowTrack* pTrack = new AliFlowTrack(pParticle);\r
-\r
-      pTrack->SetSource(AliFlowTrack::kFromESD);\r
-\r
-      //marking the particles used for diff. flow:\r
-      if(poiOK && poiCFManager)\r
-      {\r
-        pTrack->SetForPOISelection(kTRUE);\r
-        fNumberOfPOIs++;\r
-      }\r
-\r
-      if(useTPC)\r
-      {\r
-        pTrack->SetForRPSelection(kTRUE);\r
-        fNumberOfRPs++;\r
-      }\r
-\r
-      AddTrack(pTrack);\r
-\r
-    }//end of while (itrkN < iNumberOfInputTracks)\r
-\r
-}\r
-\r
-//-----------------------------------------------------------------------\r
-AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,\r
-                           const TH2F* anInputFMDhist,\r
-                           const AliCFManager* poiCFManager ):\r
-  AliFlowEventSimple(20), fApplyRecentering(kFALSE), fCachedRun(-1), fCurrentCentrality(-1)\r
-{\r
-    // constructor\r
-    for(Int_t i(0); i < 9; i++) {\r
-        for(Int_t j(0); j < 2; j++) {\r
-            for(Int_t k(0); k < 2; k++) {\r
-                fMeanQ[i][j][k] = 0.; \r
-                fWidthQ[i][j][k] = 0.;  \r
-                fMeanQv3[i][j][k] = 0.; \r
-                fWidthQv3[i][j][k] = 0.;\r
-            }\r
-        }\r
-    }\r
-\r
-\r
-  //Select the particles of interest from the ESD\r
-  Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;\r
-\r
-  //loop over tracks\r
-  for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)\r
-    {\r
-      AliESDtrack* pParticle = anInput->GetTrack(itrkN);   //get input particle\r
-\r
-      //check if pParticle passes the cuts\r
-      Bool_t poiOK = kTRUE;\r
-      if (poiCFManager)\r
-       {\r
-         poiOK = ( poiCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&\r
-                   poiCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));\r
-       }\r
-      if (!poiOK) continue;\r
\r
-      //make new AliFLowTrack\r
-      AliFlowTrack* pTrack = new AliFlowTrack(pParticle);\r
-          \r
-      //marking the particles used for the particle of interest (POI) selection:\r
-      if(poiOK && poiCFManager)\r
-       {\r
-          fNumberOfPOIs++; \r
-         pTrack->SetForPOISelection(kTRUE);\r
-         pTrack->SetSource(AliFlowTrack::kFromESD);\r
-       }\r
-\r
-      AddTrack(pTrack);\r
-    }//end of while (itrkN < iNumberOfInputTracks)\r
-\r
-  //Select the reference particles from the FMD hits\r
-  //loop over FMD histogram\r
-  Int_t iBinsEta = anInputFMDhist->GetNbinsX();\r
-  Int_t iBinsPhi = anInputFMDhist->GetNbinsY();\r
-  \r
-  for (Int_t iEta = 1; iEta <= iBinsEta; iEta++){\r
-    Double_t etaFMD = anInputFMDhist->GetXaxis()->GetBinCenter(iEta);\r
-    for (Int_t iPhi = 1; iPhi <= iBinsPhi; iPhi++){\r
-      Double_t phiFMD = anInputFMDhist->GetYaxis()->GetBinCenter(iPhi);\r
-      Double_t weightFMD = anInputFMDhist->GetBinContent(iEta,iPhi);\r
-    \r
-      if (weightFMD > 0.0) { //do not add empty bins\r
-       //make new AliFLowTrackSimple\r
-       AliFlowTrack* pTrack = new AliFlowTrack();\r
-       pTrack->SetPt(0.0);\r
-       pTrack->SetEta(etaFMD);\r
-       pTrack->SetPhi(phiFMD);\r
-       pTrack->SetWeight(weightFMD);\r
-       //marking the particles used for the reference particle (RP) selection:\r
-       pTrack->TagRP();\r
-       fNumberOfRPs++;\r
-       pTrack->SetSource(AliFlowTrack::kFromFMD);\r
-\r
-       //Add the track to the flowevent\r
-       AddTrack(pTrack);\r
-       \r
-      }\r
-    }\r
-  }\r
-\r
-}\r
-\r
-//-----------------------------------------------------------------------\r
-void AliFlowEvent::Fill( AliFlowTrackCuts* rpCuts,\r
-                         AliFlowTrackCuts* poiCuts )\r
-{\r
-  //Fills the event from a vevent: AliESDEvent,AliAODEvent,AliMCEvent\r
-  //the input data needs to be attached to the cuts\r
-  //we have two cases, if we're cutting the same collection of tracks\r
-  //(same param type) then we can have tracks that are both rp and poi\r
-  //in the other case we want to have two exclusive sets of rps and pois\r
-  //e.g. one tracklets, the other PMD or global - USER IS RESPOSIBLE\r
-  //FOR MAKING SURE THEY DONT OVERLAP OR ELSE THE SAME PARTICLE WILL BE\r
-  //TAKEN TWICE\r
-\r
-  ClearFast();\r
-\r
-  if (!rpCuts || !poiCuts) return;\r
-  AliFlowTrackCuts::trackParameterType sourceRP = rpCuts->GetParamType();\r
-  AliFlowTrackCuts::trackParameterType sourcePOI = poiCuts->GetParamType();\r
-  AliFlowTrack* pTrack=NULL;\r
-  \r
-  // if the source for rp's or poi's is the VZERO detector, get the calibration \r
-  // and set the calibration parameters\r
-  if (sourceRP == AliFlowTrackCuts::kV0 || sourceRP == AliFlowTrackCuts::kVZERO) {\r
-      SetVZEROCalibrationForTrackCuts(rpCuts);\r
-//      for now, recentering is only applied if the user specifically asks for it\r
-//      by setting the flag to kTRUE in the ali flow track cuts\r
-      fApplyRecentering = rpCuts->GetApplyRecentering();    \r
-      // note: this flag is used in the overloaded implementation of Get2Qsub()\r
-      // and tells the function to use as Qsub vectors the recentered Q-vectors\r
-      // from the VZERO aodb file\r
-  }\r
-  if (sourcePOI ==AliFlowTrackCuts::kV0 || sourcePOI == AliFlowTrackCuts::kVZERO) {\r
-      // probably no-one will choose vzero tracks as poi's ...\r
-      SetVZEROCalibrationForTrackCuts(poiCuts); \r
-  }\r
-  if (sourceRP==sourcePOI)\r
-  {\r
-    //loop over tracks\r
-    Int_t numberOfInputObject = rpCuts->GetNumberOfInputObjects();\r
-    for (Int_t i=0; i<numberOfInputObject; i++)\r
-    {\r
-      //get input object (particle)\r
-      TObject* particle = rpCuts->GetInputObject(i);\r
-\r
-      Bool_t rp = rpCuts->IsSelected(particle,i);\r
-      Bool_t poi = poiCuts->IsSelected(particle,i);\r
-      \r
-      if (!(rp||poi)) continue;\r
-\r
-      //make new AliFLowTrack\r
-      if (rp)\r
-      {\r
-        pTrack = ReuseTrack(fNumberOfTracks);\r
-        if (!rpCuts->FillFlowTrack(pTrack)) continue;\r
-        pTrack->TagRP(); fNumberOfRPs++;\r
-        if (poi) {pTrack->TagPOI(); fNumberOfPOIs++;}\r
-      }\r
-      else if (poi)\r
-      {\r
-        pTrack = ReuseTrack(fNumberOfTracks);\r
-        if (!poiCuts->FillFlowTrack(pTrack)) continue;\r
-        pTrack->TagPOI(); fNumberOfPOIs++;\r
-      }\r
-      fNumberOfTracks++;\r
-    }//end of while (i < numberOfTracks)\r
-  }\r
-  else if (sourceRP!=sourcePOI)\r
-  {\r
-    //here we have two different sources of particles, so we fill\r
-    //them independently\r
-    //RP\r
-    Int_t numberOfInputObject = rpCuts->GetNumberOfInputObjects();\r
-    for (Int_t i=0; i<numberOfInputObject; i++)\r
-      {\r
-      TObject* particle = rpCuts->GetInputObject(i);\r
-      Bool_t rp = rpCuts->IsSelected(particle,i);\r
-      if (!rp) continue;\r
-      pTrack = ReuseTrack(fNumberOfTracks);\r
-      if (!rpCuts->FillFlowTrack(pTrack)) continue;\r
-      pTrack->TagRP();\r
-      fNumberOfRPs++;\r
-      fNumberOfTracks++;\r
-    }\r
-    //POI\r
-    numberOfInputObject = poiCuts->GetNumberOfInputObjects();\r
-    for (Int_t i=0; i<numberOfInputObject; i++)\r
-    {\r
-      TObject* particle = poiCuts->GetInputObject(i);\r
-      Bool_t poi = poiCuts->IsSelected(particle,i);\r
-      if (!poi) continue;\r
-      pTrack = ReuseTrack(fNumberOfTracks);\r
-      if (!poiCuts->FillFlowTrack(pTrack)) continue;\r
-      pTrack->TagPOI();\r
-      fNumberOfPOIs++;\r
-      fNumberOfTracks++;\r
-    }\r
-  }\r
-}\r
-\r
-//-----------------------------------------------------------------------\r
-void AliFlowEvent::InsertTrack(AliFlowTrack *thisTrack) {\r
-  // adds a flow track at the end of the container\r
-  AliFlowTrack *pTrack = ReuseTrack( fNumberOfTracks++ );\r
-  pTrack->SetPt( thisTrack->Pt() );\r
-  pTrack->SetPhi( thisTrack->Phi() );\r
-  pTrack->SetEta( thisTrack->Eta() );\r
-  pTrack->SetWeight( thisTrack->Weight() );\r
-  pTrack->SetCharge( thisTrack->Charge() );\r
-  pTrack->SetMass( thisTrack->Mass() );\r
-  pTrack->SetForRPSelection( thisTrack->InRPSelection() );\r
-  pTrack->SetForPOISelection( thisTrack->InPOISelection() );\r
-  if(thisTrack->InSubevent(0)) pTrack->SetForSubevent(0);\r
-  if(thisTrack->InSubevent(1)) pTrack->SetForSubevent(1);\r
-  pTrack->SetID( thisTrack->GetID() );\r
-  return;\r
-}\r
-\r
-//-----------------------------------------------------------------------\r
-AliFlowTrack* AliFlowEvent::ReuseTrack(Int_t i)\r
-{\r
-  //try to reuse an existing track, if empty, make new one\r
-  AliFlowTrack* pTrack = static_cast<AliFlowTrack*>(fTrackCollection->At(i));\r
-  if (pTrack)\r
-  {\r
-    pTrack->Clear();\r
-  }\r
-  else \r
-  {\r
-    pTrack = new AliFlowTrack();\r
-    fTrackCollection->AddAtAndExpand(pTrack,i);\r
-  }\r
-  return pTrack;\r
-}\r
-\r
-//-----------------------------------------------------------------------\r
-AliFlowEvent::AliFlowEvent( AliFlowTrackCuts* rpCuts,\r
-                            AliFlowTrackCuts* poiCuts ):\r
-  AliFlowEventSimple(20), fApplyRecentering(kFALSE), fCachedRun(-1), fCurrentCentrality(-1)\r
-{\r
-    // constructor\r
-    for(Int_t i(0); i < 9; i++) {\r
-        for(Int_t j(0); j < 2; j++) {\r
-            for(Int_t k(0); k < 2; k++) {\r
-                fMeanQ[i][j][k] = 0.; \r
-                fWidthQ[i][j][k] = 0.;  \r
-                fMeanQv3[i][j][k] = 0.; \r
-                fWidthQv3[i][j][k] = 0.;\r
-            }\r
-        }\r
-    }\r
-\r
-  //Fills the event from a vevent: AliESDEvent,AliAODEvent,AliMCEvent\r
-  //the input data needs to be attached to the cuts\r
-  //we have two cases, if we're cutting the same collection of tracks\r
-  //(same param type) then we can have tracks that are both rp and poi\r
-  //in the other case we want to have two exclusive sets of rps and pois\r
-  //e.g. one tracklets, the other PMD or global - USER IS RESPOSIBLE\r
-  //FOR MAKING SURE THEY DONT OVERLAP OR ELSE THE SAME PARTICLE WILL BE\r
-  //TAKEN TWICE\r
-\r
-  if (!rpCuts || !poiCuts) return;\r
-  AliFlowTrackCuts::trackParameterType sourceRP = rpCuts->GetParamType();\r
-  AliFlowTrackCuts::trackParameterType sourcePOI = poiCuts->GetParamType();\r
-\r
-  if (sourceRP==sourcePOI)\r
-  {\r
-    //loop over tracks\r
-    Int_t numberOfInputObject = rpCuts->GetNumberOfInputObjects();\r
-    for (Int_t i=0; i<numberOfInputObject; i++)\r
-    {\r
-      //get input object (particle)\r
-      TObject* particle = rpCuts->GetInputObject(i);\r
-\r
-      Bool_t rp = rpCuts->IsSelected(particle,i);\r
-      Bool_t poi = poiCuts->IsSelected(particle,i);\r
-      \r
-      if (!(rp||poi)) continue;\r
-\r
-      //make new AliFLowTrack\r
-      AliFlowTrack* pTrack = NULL;\r
-      if (rp)\r
-      {\r
-        pTrack = rpCuts->MakeFlowTrack();\r
-        if (!pTrack) continue;\r
-        pTrack->TagRP(); fNumberOfRPs++;\r
-        if (poi) {pTrack->TagPOI(); fNumberOfPOIs++;}\r
-      }\r
-      else\r
-      if (poi)\r
-      {\r
-        pTrack = poiCuts->MakeFlowTrack();\r
-        if (!pTrack) continue;\r
-        pTrack->TagPOI(); fNumberOfPOIs++;\r
-      }\r
-      AddTrack(pTrack);\r
-    }//end of while (i < numberOfTracks)\r
-  }\r
-  else if (sourceRP!=sourcePOI)\r
-  {\r
-    //here we have two different sources of particles, so we fill\r
-    //them independently\r
-    AliFlowTrack* pTrack = NULL;\r
-    //RP\r
-    Int_t numberOfInputObject = rpCuts->GetNumberOfInputObjects();\r
-    for (Int_t i=0; i<numberOfInputObject; i++)\r
-    {\r
-      TObject* particle = rpCuts->GetInputObject(i);\r
-      Bool_t rp = rpCuts->IsSelected(particle,i);\r
-      if (!rp) continue;\r
-      pTrack = rpCuts->MakeFlowTrack();\r
-      if (!pTrack) continue;\r
-      pTrack->TagRP(); fNumberOfRPs++;\r
-      AddTrack(pTrack);\r
-    }\r
-    //POI\r
-    numberOfInputObject = poiCuts->GetNumberOfInputObjects();\r
-    for (Int_t i=0; i<numberOfInputObject; i++)\r
-    {\r
-      TObject* particle = poiCuts->GetInputObject(i);\r
-      Bool_t poi = poiCuts->IsSelected(particle,i);\r
-      if (!poi) continue;\r
-      pTrack = poiCuts->MakeFlowTrack();\r
-      if (!pTrack) continue;\r
-      pTrack->TagPOI(); fNumberOfPOIs++;\r
-      AddTrack(pTrack);\r
-    }\r
-  }\r
-}\r
-\r
-//-------------------------------------------------------------------//\r
-//---- Including PMD tracks as RP --------------------------//\r
-\r
-AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,\r
-                           const AliESDPmdTrack *pmdtracks,\r
-                           const AliCFManager* poiCFManager ):\r
-  AliFlowEventSimple(20), fApplyRecentering(kFALSE), fCachedRun(-1), fCurrentCentrality(-1)\r
-{\r
-    // constructor\r
-    for(Int_t i(0); i < 9; i++) {\r
-        for(Int_t j(0); j < 2; j++) {\r
-            for(Int_t k(0); k < 2; k++) {\r
-                fMeanQ[i][j][k] = 0.; \r
-                fWidthQ[i][j][k] = 0.;  \r
-                fMeanQv3[i][j][k] = 0.; \r
-                fWidthQv3[i][j][k] = 0.;\r
-            }\r
-        }\r
-    }\r
-\r
-  Float_t GetPmdEta(Float_t xPos, Float_t yPos, Float_t zPos);\r
-  Float_t GetPmdPhi(Float_t xPos, Float_t yPos);\r
-  //Select the particles of interest from the ESD\r
-  Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;\r
-  \r
-  //loop over tracks\r
-  for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)\r
-    {\r
-      AliESDtrack* pParticle = anInput->GetTrack(itrkN);   //get input particle\r
-      //check if pParticle passes the cuts\r
-      Bool_t poiOK = kTRUE;\r
-      if (poiCFManager)\r
-       {\r
-         poiOK = ( poiCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&\r
-                   poiCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));\r
-       }\r
-      if (!poiOK) continue;\r
-      \r
-      //make new AliFLowTrack\r
-      AliFlowTrack* pTrack = new AliFlowTrack(pParticle);\r
-      \r
-      //marking the particles used for the particle of interest (POI) selection:\r
-      if(poiOK && poiCFManager)\r
-       {\r
-          fNumberOfPOIs++;\r
-         pTrack->SetForPOISelection(kTRUE);\r
-         pTrack->SetSource(AliFlowTrack::kFromESD);\r
-       }\r
-      \r
-      AddTrack(pTrack);\r
-    }//end of while (itrkN < iNumberOfInputTracks)\r
-  \r
-  //Select the reference particles from the PMD tracks\r
-  Int_t npmdcl = anInput->GetNumberOfPmdTracks();\r
-  printf("======There are %d PMD tracks in this event\n-------",npmdcl);\r
-  //loop over clusters \r
-  for(Int_t iclust=0; iclust < npmdcl; iclust++){\r
-    //AliESDPmdTrack *pmdtr = anInput->GetPmdTrack(iclust);\r
-    pmdtracks = anInput->GetPmdTrack(iclust);\r
-    Int_t   det   = pmdtracks->GetDetector();\r
-    //Int_t   smn   = pmdtracks->GetSmn();\r
-    Float_t clsX  = pmdtracks->GetClusterX();\r
-    Float_t clsY  = pmdtracks->GetClusterY();\r
-    Float_t clsZ  = pmdtracks->GetClusterZ();\r
-    Float_t ncell = pmdtracks->GetClusterCells();\r
-    Float_t adc   = pmdtracks->GetClusterADC();\r
-    //Float_t pid   = pmdtracks->GetClusterPID();\r
-    Float_t etacls = GetPmdEta(clsX,clsY,clsZ);\r
-    Float_t phicls = GetPmdPhi(clsX,clsY);\r
-    //make new AliFLowTrackSimple\r
-    AliFlowTrack* pTrack = new AliFlowTrack();\r
-    //if(det == 0){ //selecting preshower plane only\r
-    if(det == 0 && adc > 270 && ncell > 1){ //selecting preshower plane only\r
-      //pTrack->SetPt(adc);//cluster adc\r
-      pTrack->SetPt(0.0);\r
-      pTrack->SetEta(etacls);\r
-      pTrack->SetPhi(phicls);\r
-      //marking the particles used for the reference particle (RP) selection:\r
-      fNumberOfRPs++;\r
-      pTrack->SetForRPSelection(kTRUE);\r
-      pTrack->SetSource(AliFlowTrack::kFromPMD);\r
-      //Add the track to the flowevent\r
-      AddTrack(pTrack);\r
-    }//if det\r
-  }\r
-}\r
-//----------------------------------------------------------------------------//\r
-Float_t GetPmdEta(Float_t xPos, Float_t yPos, Float_t zPos)\r
-{\r
-  Float_t rpxpy, theta, eta;\r
-  rpxpy  = TMath::Sqrt(xPos*xPos + yPos*yPos);\r
-  theta  = TMath::ATan2(rpxpy,zPos);\r
-  eta    = -TMath::Log(TMath::Tan(0.5*theta));\r
-  return eta;\r
-}\r
-//--------------------------------------------------------------------------//\r
-Float_t GetPmdPhi(Float_t xPos, Float_t yPos)\r
-{\r
-  Float_t pybypx, phi = 0., phi1;\r
-  if(xPos==0)\r
-    {\r
-      if(yPos>0) phi = 90.;\r
-      if(yPos<0) phi = 270.;\r
-    }\r
-  if(xPos != 0)\r
-    {\r
-      pybypx = yPos/xPos;\r
-      if(pybypx < 0) pybypx = - pybypx;\r
-      phi1 = TMath::ATan(pybypx)*180./3.14159;\r
-      \r
-      if(xPos > 0 && yPos > 0) phi = phi1;        // 1st Quadrant\r
-      if(xPos < 0 && yPos > 0) phi = 180 - phi1;  // 2nd Quadrant\r
-      if(xPos < 0 && yPos < 0) phi = 180 + phi1;  // 3rd Quadrant\r
-      if(xPos > 0 && yPos < 0) phi = 360 - phi1;  // 4th Quadrant\r
-      \r
-    }\r
-  phi = phi*3.14159/180.;\r
-  return   phi;\r
-}\r
-//---------------------------------------------------------------//\r
-\r
-\r
-void AliFlowEvent::Get2Qsub(AliFlowVector* Qarray, Int_t n, TList *weightsList, Bool_t usePhiWeights, Bool_t usePtWeights, Bool_t useEtaWeights)\r
-{\r
-  // get q vectors for the subevents. if no recentering is necessary, get the guy from the flow event simple\r
-  AliFlowEventSimple::Get2Qsub(Qarray, n, weightsList, usePhiWeights, usePtWeights, useEtaWeights);\r
-  // else get the recentering from the cached info\r
-  if (fApplyRecentering)        // set by Fill()\r
-  {     \r
-    // first retrieve the q-vectors from the AliFlowEventSimple:: routine\r
-    AliFlowVector vA = Qarray[0];\r
-    AliFlowVector vB = Qarray[1];\r
-    // extract the information form the current flow vectors\r
-    Double_t Qxc(vA.X());       // IMPORTANT: user is responsible for the sign of eta\r
-    Double_t Qyc(vA.Y());       // vzeroC has negative pseudorapidity and is taken as subevent A\r
-    Double_t Qxa(vB.X());       // vzeroA has positive pseudorapidity and is taken as subevent B\r
-    Double_t Qya(vB.Y());\r
-    // init some values for the corrections\r
-    \r
-    // values for vector a (VZEROA)\r
-    Double_t Qxamean(0);\r
-    Double_t Qxarms(1);\r
-    Double_t Qyamean(0);\r
-    Double_t Qyarms(1);\r
-    // values for vector b (VZEROC)\r
-    Double_t Qxcmean(0);\r
-    Double_t Qxcrms(1);\r
-    Double_t Qycmean(0);\r
-    Double_t Qycrms(1);        \r
-    \r
-    if( n == 2) {       // second order symmetry\r
-        Qxamean = fMeanQ[fCurrentCentrality][1][0];\r
-        Qxarms  = fWidthQ[fCurrentCentrality][1][0];\r
-        Qyamean = fMeanQ[fCurrentCentrality][1][1];\r
-        Qyarms  = fWidthQ[fCurrentCentrality][1][1];\r
-\r
-        Qxcmean = fMeanQ[fCurrentCentrality][0][0];\r
-        Qxcrms  = fWidthQ[fCurrentCentrality][0][0];\r
-        Qycmean = fMeanQ[fCurrentCentrality][0][1];\r
-        Qycrms  = fWidthQ[fCurrentCentrality][0][1];   \r
-    } else if (n == 3) {        // third order symmetry\r
-        Qxamean = fMeanQv3[fCurrentCentrality][1][0];\r
-        Qxarms  = fWidthQv3[fCurrentCentrality][1][0];\r
-        Qyamean = fMeanQv3[fCurrentCentrality][1][1];\r
-        Qyarms  = fWidthQv3[fCurrentCentrality][1][1];\r
-  \r
-        Qxcmean = fMeanQv3[fCurrentCentrality][0][0];\r
-        Qxcrms  = fWidthQv3[fCurrentCentrality][0][0];\r
-        Qycmean = fMeanQv3[fCurrentCentrality][0][1];\r
-        Qycrms  = fWidthQv3[fCurrentCentrality][0][1]; \r
-    }\r
-    // do the correction    \r
-    Double_t QxaCor = (Qxa - Qxamean)/Qxarms;\r
-    Double_t QyaCor = (Qya - Qyamean)/Qyarms;\r
-    Double_t QxcCor = (Qxc - Qxcmean)/Qxcrms;\r
-    Double_t QycCor = (Qyc - Qycmean)/Qycrms;\r
-    // update the vector\r
-    vA.Set(QxcCor, QycCor);\r
-    vB.Set(QxaCor, QyaCor);\r
-  }\r
-}\r
-//_____________________________________________________________________________\r
-void AliFlowEvent::SetVZEROCalibrationForTrackCuts(AliFlowTrackCuts* cuts) {\r
-    // open calibration info, copied from AliAnalyisTaskVnV0.cxx\r
-    if(!cuts->GetEvent()) return; // coverity. we need to know the event to get the runnumber and centrlaity\r
-    // get the vzero centrality percentile (cc dependent calibration)\r
-    Float_t v0Centr(cuts->GetEvent()->GetCentrality()->GetCentralityPercentile("V0M"));\r
-    if(v0Centr < 5) fCurrentCentrality = 0;\r
-    else if(v0Centr < 10) fCurrentCentrality = 1;\r
-    else if(v0Centr < 20) fCurrentCentrality = 2;\r
-    else if(v0Centr < 30) fCurrentCentrality = 3;\r
-    else if(v0Centr < 40) fCurrentCentrality = 4;\r
-    else if(v0Centr < 50) fCurrentCentrality = 5;\r
-    else if(v0Centr < 60) fCurrentCentrality = 6;\r
-    else if(v0Centr < 70) fCurrentCentrality = 7;\r
-    else fCurrentCentrality = 8;\r
-\r
-    // if this event is from the same run as the previous event\r
-    // we can use the cached calibration values, no need to re-open the \r
-    // aodb file\r
-    Int_t run(cuts->GetEvent()->GetRunNumber());\r
-//    printf ( " > run number is %i \n", run);\r
-    if(fCachedRun == run) {\r
-//        printf(" run number didn't change, using cached values \n");\r
-        return;\r
-    }\r
-    // set the chached run number\r
-    fCachedRun = run;\r
-    \r
-    TString oadbfilename = "$ALICE_ROOT/OADB/PWGCF/VZERO/VZEROcalibEP.root";\r
-    TFile *foadb = TFile::Open(oadbfilename.Data());\r
-\r
-    if(!foadb){\r
-       printf("OADB file %s cannot be opened\n",oadbfilename.Data());\r
-       return;\r
-    }\r
-\r
-    AliOADBContainer *cont = (AliOADBContainer*) foadb->Get("hMultV0BefCorr");\r
-    if(!cont){\r
-       printf("OADB object hMultV0BefCorr is not available in the file\n");\r
-       return; \r
-    }\r
-\r
-    if(!(cont->GetObject(run))){\r
-       printf("OADB object hMultV0BefCorr is not available for run %i (used run 137366)\n",run);\r
-       run = 137366;\r
-    }\r
-    // step 1) get the proper multiplicity weights from the vzero signal\r
-    TProfile* fMultV0 = ((TH2F *) cont->GetObject(run))->ProfileX();\r
-\r
-    TF1 *fpol0 = new TF1("fpol0","pol0"); \r
-    if(cuts->GetV0gainEqualizationPerRing()) {\r
-        // do the calibration per ring\r
-        // start with the vzero c rings (segments 0 through 31)\r
-        fMultV0->Fit(fpol0, "", "", 0, 8);\r
-        (cuts->GetUseVZERORing(0)) ? cuts->SetV0Cpol(0, fpol0->GetParameter(0)) : cuts->SetV0Cpol(0, 0.);\r
-        fMultV0->Fit(fpol0, "", "", 8, 16);\r
-        (cuts->GetUseVZERORing(1)) ? cuts->SetV0Cpol(1, fpol0->GetParameter(0)) : cuts->SetV0Cpol(1, 0.);\r
-        fMultV0->Fit(fpol0, "", "", 16, 24);\r
-        (cuts->GetUseVZERORing(2)) ? cuts->SetV0Cpol(2, fpol0->GetParameter(0)) : cuts->SetV0Cpol(2, 0.);\r
-        fMultV0->Fit(fpol0, "", "", 24, 32);\r
-        (cuts->GetUseVZERORing(3)) ? cuts->SetV0Cpol(3, fpol0->GetParameter(0)) : cuts->SetV0Cpol(3, 0.);\r
-        // same thing for vero A\r
-        fMultV0->Fit(fpol0, "", "", 32, 40);\r
-        (cuts->GetUseVZERORing(4)) ? cuts->SetV0Apol(0, fpol0->GetParameter(0)) : cuts->SetV0Apol(0, 0.);\r
-        fMultV0->Fit(fpol0, "", "", 40, 48);\r
-        (cuts->GetUseVZERORing(5)) ? cuts->SetV0Apol(1, fpol0->GetParameter(0)) : cuts->SetV0Apol(1, 0.);\r
-        fMultV0->Fit(fpol0, "", "", 48, 56);\r
-        (cuts->GetUseVZERORing(6)) ? cuts->SetV0Apol(2, fpol0->GetParameter(0)) : cuts->SetV0Apol(2, 0.);\r
-        fMultV0->Fit(fpol0, "", "", 56, 64);\r
-        (cuts->GetUseVZERORing(7)) ? cuts->SetV0Apol(3, fpol0->GetParameter(0)) : cuts->SetV0Apol(3, 0.);\r
-    } else {\r
-        // do the calibration in one go. the calibration will still be \r
-        // stored per ring, but each ring has the same weight now\r
-       fMultV0->Fit(fpol0,"","",0,31);\r
-       for(Int_t i(0); i < 4; i++) cuts->SetV0Cpol(i, fpol0->GetParameter(0));\r
-       fMultV0->Fit(fpol0,"","",32,64);\r
-       for(Int_t i(0); i < 4; i++) cuts->SetV0Apol(i, fpol0->GetParameter(0));\r
-    }\r
-    // the parameters to weigh the vzero track cuts have been extracted now, \r
-    // so we can pass them to the current track cuts obect\r
-    cuts->SetV0gainEqualisation(fMultV0);       // passed as a TH1\r
-\r
-    // step 2) reweight the q-vectors that will be  called by flow methods which use\r
-    // subevents\r
-    // underlying assumption is that subevent a uses VZEROA\r
-    // and subevent b uses VZEROC\r
-    for(Int_t iside=0;iside<2;iside++){\r
-       for(Int_t icoord=0;icoord<2;icoord++){\r
-           for(Int_t i=0;i  < 9;i++){\r
-               char namecont[100];\r
-               if(iside==0 && icoord==0)\r
-                 snprintf(namecont,100,"hQxc2_%i",i);\r
-               else if(iside==1 && icoord==0)\r
-                 snprintf(namecont,100,"hQxa2_%i",i);\r
-               else if(iside==0 && icoord==1)\r
-                 snprintf(namecont,100,"hQyc2_%i",i);\r
-               else if(iside==1 && icoord==1)\r
-                 snprintf(namecont,100,"hQya2_%i",i);\r
-\r
-               cont = (AliOADBContainer*) foadb->Get(namecont);\r
-               if(!cont){\r
-                   printf("OADB object %s is not available in the file\n",namecont);\r
-                   return;     \r
-               }\r
-       \r
-               if(!(cont->GetObject(run))){\r
-                   printf("OADB object %s is not available for run %i (used run 137366)\n",namecont,run);\r
-                   run = 137366;\r
-               }\r
-\r
-                // after grabbing all the info, set the CORRECTION TERMS to\r
-                // the 2nd and 3rd order qsub-vectors\r
-                // we do this here for all centralities, so that subsequent events\r
-                // can grab the correction from these cached values\r
-                fMeanQ[i][iside][icoord] = ((TH1F *) cont->GetObject(run))->GetMean();\r
-               fWidthQ[i][iside][icoord] = ((TH1F *) cont->GetObject(run))->GetRMS();\r
-\r
-               //for v3\r
-               if(iside==0 && icoord==0)\r
-                 snprintf(namecont,100,"hQxc3_%i",i);\r
-               else if(iside==1 && icoord==0)\r
-                 snprintf(namecont,100,"hQxa3_%i",i);\r
-               else if(iside==0 && icoord==1)\r
-                 snprintf(namecont,100,"hQyc3_%i",i);\r
-               else if(iside==1 && icoord==1)\r
-                 snprintf(namecont,100,"hQya3_%i",i);\r
-\r
-               cont = (AliOADBContainer*) foadb->Get(namecont);\r
-               if(!cont){\r
-                   printf("OADB object %s is not available in the file\n",namecont);\r
-                   return;     \r
-               }\r
-               \r
-               if(!(cont->GetObject(run))){\r
-                   printf("OADB object %s is not available for run %i (used run 137366)\n",namecont,run);\r
-                   run = 137366;\r
-               }\r
-               fMeanQv3[i][iside][icoord] = ((TH1F *) cont->GetObject(run))->GetMean();\r
-               fWidthQv3[i][iside][icoord] = ((TH1F *) cont->GetObject(run))->GetRMS();\r
-\r
-           }\r
-       }\r
-    }\r
-}\r
-//_____________________________________________________________________________\r
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/*****************************************************************
+  AliFlowEvent: Event container for flow analysis
+
+  origin:   Mikolaj Krzewicki  (mikolaj.krzewicki@cern.ch)
+  mods:     Redmer A. Bertens (rbertens@cern.ch)
+*****************************************************************/
+
+#include "Riostream.h"
+#include "TFile.h"
+#include "TList.h"
+#include "TH1.h"
+#include "TH2F.h"
+#include "TProfile.h"
+#include "AliMCEvent.h"
+#include "AliMCParticle.h"
+#include "AliCFManager.h"
+#include "AliESDtrack.h"
+#include "AliESDPmdTrack.h"
+#include "AliESDEvent.h"
+#include "AliAODEvent.h"
+#include "AliOADBContainer.h"
+#include "AliGenCocktailEventHeader.h"
+#include "AliGenEposEventHeader.h"
+#include "AliGenHijingEventHeader.h"
+#include "AliGenGeVSimEventHeader.h"
+#include "AliCollisionGeometry.h"
+#include "AliMultiplicity.h"
+#include "AliFlowTrackCuts.h"
+#include "AliFlowEventSimple.h"
+#include "AliFlowTrack.h"
+#include "AliFlowVector.h"
+#include "AliFlowEvent.h"
+#include "AliLog.h"
+
+using std::endl;
+using std::cout;
+ClassImp(AliFlowEvent)
+
+//-----------------------------------------------------------------------
+AliFlowEvent::AliFlowEvent():
+  AliFlowEventSimple(), fApplyRecentering(kFALSE), fCachedRun(-1), fCurrentCentrality(-1)
+{
+    // constructor
+    for(Int_t i(0); i < 9; i++) {
+        for(Int_t j(0); j < 2; j++) {
+            for(Int_t k(0); k < 2; k++) {
+                fMeanQ[i][j][k] = 0.; 
+                fWidthQ[i][j][k] = 0.;  
+                fMeanQv3[i][j][k] = 0.; 
+                fWidthQv3[i][j][k] = 0.;
+            }
+        }
+    }
+
+  //ctor
+  cout << "AliFlowEvent: Default constructor to be used only by root for io" << endl;
+}
+
+//-----------------------------------------------------------------------
+AliFlowEvent::AliFlowEvent(Int_t n):
+  AliFlowEventSimple(n), fApplyRecentering(kFALSE), fCachedRun(-1), fCurrentCentrality(-1)
+{
+    // constructor
+    for(Int_t i(0); i < 9; i++) {
+        for(Int_t j(0); j < 2; j++) {
+            for(Int_t k(0); k < 2; k++) {
+                fMeanQ[i][j][k] = 0.; 
+                fWidthQ[i][j][k] = 0.;  
+                fMeanQv3[i][j][k] = 0.; 
+                fWidthQv3[i][j][k] = 0.;
+            }
+        }
+    }
+}
+
+//-----------------------------------------------------------------------
+AliFlowEvent::AliFlowEvent(const AliFlowEvent& event):
+  AliFlowEventSimple(event), fApplyRecentering(event.fApplyRecentering), fCachedRun(-1), fCurrentCentrality(-1)
+{
+    // copy constructor 
+    for(Int_t i(0); i < 9; i++) {
+        for(Int_t j(0); j < 2; j++) {
+            for(Int_t k(0); k < 2; k++) {
+                fMeanQ[i][j][k] = 0.; 
+                fWidthQ[i][j][k] = 0.;  
+                fMeanQv3[i][j][k] = 0.; 
+                fWidthQv3[i][j][k] = 0.;
+            }
+        }
+    }
+}
+
+//-----------------------------------------------------------------------
+AliFlowEvent& AliFlowEvent::operator=(const AliFlowEvent& event)
+{
+
+  //assignment operator
+  if (&event==this) return *this;       // check self-assignment
+
+  fApplyRecentering = event.fApplyRecentering; 
+  fCachedRun = event.fCachedRun; 
+  fCurrentCentrality = event.fCurrentCentrality;
+  for(Int_t i(0); i < 9; i++) {
+      for(Int_t j(0); j < 2; j++) {
+          for(Int_t k(0); k < 2; k++) {
+              fMeanQ[i][j][k] = event.fMeanQ[i][j][k]; 
+              fWidthQ[i][j][k] = fWidthQ[i][j][k];  
+              fMeanQv3[i][j][k] = fMeanQv3[i][j][k]; 
+              fWidthQv3[i][j][k] = fWidthQv3[i][j][k];
+          }
+      }
+  }
+  AliFlowEventSimple::operator=(event);
+  return *this;
+}
+
+//-----------------------------------------------------------------------
+AliFlowTrack* AliFlowEvent::GetTrack(Int_t i)
+{
+  //get track i from collection
+  if (i>=fNumberOfTracks) return NULL;
+  AliFlowTrack* pTrack = static_cast<AliFlowTrack*>(fTrackCollection->At(i)) ;
+  return pTrack;
+}
+
+//-----------------------------------------------------------------------
+void AliFlowEvent::SetMCReactionPlaneAngle(const AliMCEvent* mcEvent)
+{
+  //sets the event plane angle from the proper header in the MC
+
+  //COCKTAIL with HIJING
+  if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"Cocktail Header"))   //returns 0 if matches
+  {
+    AliGenCocktailEventHeader *headerC = dynamic_cast<AliGenCocktailEventHeader *> (mcEvent-> GenEventHeader());
+    if (headerC)
+    {
+      TList *lhd = headerC->GetHeaders();
+      if (lhd)
+      {
+        AliGenHijingEventHeader *hdh = dynamic_cast<AliGenHijingEventHeader *> (lhd->At(0));
+        if (hdh) AliFlowEventSimple::SetMCReactionPlaneAngle( hdh->ReactionPlaneAngle() );
+      }
+    }
+  }
+  //THERMINATOR
+  else if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"Therminator"))   //returns 0 if matches
+  {
+    AliGenHijingEventHeader* headerH = dynamic_cast<AliGenHijingEventHeader*>(mcEvent->GenEventHeader());
+    if (headerH) AliFlowEventSimple::SetMCReactionPlaneAngle( headerH->ReactionPlaneAngle() );
+  }
+  //GEVSIM
+  else if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"GeVSim header"))   //returns 0 if matches
+  {
+    AliGenGeVSimEventHeader* headerG = dynamic_cast<AliGenGeVSimEventHeader*>(mcEvent->GenEventHeader());
+    if (headerG) AliFlowEventSimple::SetMCReactionPlaneAngle( headerG->GetEventPlane() );
+  }
+  //HIJING
+  else if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"Hijing"))   //returns 0 if matches
+  {
+    AliGenHijingEventHeader* headerH = dynamic_cast<AliGenHijingEventHeader*>(mcEvent->GenEventHeader());
+    if (headerH) AliFlowEventSimple::SetMCReactionPlaneAngle( headerH->ReactionPlaneAngle() );
+  }
+  //AMPT
+  else if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"Ampt"))   //returns 0 if matches
+  {
+    AliGenHijingEventHeader* headerH = dynamic_cast<AliGenHijingEventHeader*>(mcEvent->GenEventHeader());
+    if (headerH) AliFlowEventSimple::SetMCReactionPlaneAngle( headerH->ReactionPlaneAngle() );
+  }
+  //EPOS
+  else if (!strcmp(mcEvent->GenEventHeader()->GetName(),"EPOS"))
+  {
+    AliGenEposEventHeader* headerE = dynamic_cast<AliGenEposEventHeader*>(mcEvent->GenEventHeader());
+    if (headerE) AliFlowEventSimple::SetMCReactionPlaneAngle( headerE->ReactionPlaneAngle() );
+  }
+  //Hydjet
+  else
+  {
+    AliCollisionGeometry* header = dynamic_cast<AliCollisionGeometry*>(mcEvent->GenEventHeader());
+    if (header) AliFlowEventSimple::SetMCReactionPlaneAngle( header->ReactionPlaneAngle() );
+  }
+}
+
+//-----------------------------------------------------------------------
+AliFlowEvent::AliFlowEvent( const AliMCEvent* anInput,
+                            const AliCFManager* rpCFManager,
+                            const AliCFManager* poiCFManager):
+  AliFlowEventSimple(20), fApplyRecentering(kFALSE), fCachedRun(-1), fCurrentCentrality(-1)
+{
+    // constructor
+    for(Int_t i(0); i < 9; i++) {
+        for(Int_t j(0); j < 2; j++) {
+            for(Int_t k(0); k < 2; k++) {
+                fMeanQ[i][j][k] = 0.; 
+                fWidthQ[i][j][k] = 0.;  
+                fMeanQv3[i][j][k] = 0.; 
+                fWidthQv3[i][j][k] = 0.;
+            }
+        }
+    }
+
+  //Fills the event from the MC kinematic information
+
+  Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
+
+  //loop over tracks
+  for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)
+  {
+    //get input particle
+    AliMCParticle* pParticle = dynamic_cast<AliMCParticle*>(anInput->GetTrack(itrkN));
+    if (!pParticle) continue;
+
+    //check if pParticle passes the cuts
+    Bool_t rpOK = kTRUE;
+    Bool_t poiOK = kTRUE;
+    if (rpCFManager && poiCFManager)
+    {
+      rpOK = rpCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pParticle);
+      poiOK = poiCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pParticle);
+    }
+    if (!(rpOK||poiOK)) continue;
+
+    AliFlowTrack* pTrack = new AliFlowTrack(pParticle);
+    pTrack->SetSource(AliFlowTrack::kFromMC);
+
+    if (rpOK && rpCFManager)
+    {
+      pTrack->SetForRPSelection(kTRUE);
+      fNumberOfRPs++;
+    }
+    if (poiOK && poiCFManager)
+    {
+      pTrack->SetForPOISelection(kTRUE);
+      fNumberOfPOIs++;
+    }
+
+    AddTrack(pTrack) ;
+  }//for all tracks
+  SetMCReactionPlaneAngle(anInput);
+}
+
+//-----------------------------------------------------------------------
+AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
+                            const AliCFManager* rpCFManager,
+                            const AliCFManager* poiCFManager ):
+  AliFlowEventSimple(20),  fApplyRecentering(kFALSE), fCachedRun(-1), fCurrentCentrality(-1)
+{
+    // constructor
+    for(Int_t i(0); i < 9; i++) {
+        for(Int_t j(0); j < 2; j++) {
+            for(Int_t k(0); k < 2; k++) {
+                fMeanQ[i][j][k] = 0.; 
+                fWidthQ[i][j][k] = 0.;  
+                fMeanQv3[i][j][k] = 0.; 
+                fWidthQv3[i][j][k] = 0.;
+            }
+        }
+    }
+   
+  //Fills the event from the ESD
+
+  Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
+
+  //loop over tracks
+  for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)
+  {
+    AliESDtrack* pParticle = anInput->GetTrack(itrkN);   //get input particle
+
+    //check if pParticle passes the cuts
+    Bool_t rpOK = kTRUE;
+    Bool_t poiOK = kTRUE;
+    if (rpCFManager && poiCFManager)
+    {
+      rpOK = ( rpCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&
+               rpCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));
+      poiOK = ( poiCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&
+                poiCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));
+    }
+    if (!(rpOK || poiOK)) continue;
+
+    //make new AliFLowTrack
+    AliFlowTrack* pTrack = new AliFlowTrack(pParticle);
+    pTrack->SetSource(AliFlowTrack::kFromESD);
+
+    //marking the particles used for int. flow:
+    if(rpOK && rpCFManager)
+    {
+      pTrack->SetForRPSelection(kTRUE);
+      fNumberOfRPs++;
+    }
+    //marking the particles used for diff. flow:
+    if(poiOK && poiCFManager)
+    {
+      pTrack->SetForPOISelection(kTRUE);
+      fNumberOfPOIs++;
+    }
+
+    AddTrack(pTrack);
+  }//end of while (itrkN < iNumberOfInputTracks)
+}
+
+//-----------------------------------------------------------------------
+AliFlowEvent::AliFlowEvent( const AliAODEvent* anInput,
+                            const AliCFManager* rpCFManager,
+                            const AliCFManager* poiCFManager):
+  AliFlowEventSimple(20), fApplyRecentering(kFALSE), fCachedRun(-1), fCurrentCentrality(-1)
+{
+    // constructor
+    for(Int_t i(0); i < 9; i++) {
+        for(Int_t j(0); j < 2; j++) {
+            for(Int_t k(0); k < 2; k++) {
+                fMeanQ[i][j][k] = 0.; 
+                fWidthQ[i][j][k] = 0.;  
+                fMeanQv3[i][j][k] = 0.; 
+                fWidthQv3[i][j][k] = 0.;
+            }
+        }
+    }
+
+  //Fills the event from the AOD
+  Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
+
+  //loop over tracks
+  for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)
+  {
+    AliAODTrack* pParticle = anInput->GetTrack(itrkN);   //get input particle
+
+    //check if pParticle passes the cuts
+    Bool_t rpOK = kTRUE;
+    Bool_t poiOK = kTRUE;
+    if (rpCFManager && poiCFManager)
+    {
+      rpOK = ( rpCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&
+               rpCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));
+      poiOK = ( poiCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&
+                poiCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));
+    }
+    if (!(rpOK || poiOK)) continue;
+
+    //make new AliFlowTrack
+    AliFlowTrack* pTrack = new AliFlowTrack(pParticle);
+    pTrack->SetSource(AliFlowTrack::kFromAOD);
+
+    if (rpOK /* && rpCFManager */ ) // to be fixed - with CF managers uncommented only empty events (NULL in header files)
+    {
+      pTrack->SetForRPSelection(kTRUE);
+      fNumberOfRPs++;
+    }
+    if (poiOK /* && poiCFManager*/ )
+    {
+      pTrack->SetForPOISelection(kTRUE);
+      fNumberOfPOIs++;
+    }
+    AddTrack(pTrack);
+  }
+
+  //  if (iSelParticlesRP >= fMinMult && iSelParticlesRP <= fMaxMult)
+  //  {
+  //    if ( (++fCount % 100) == 0)
+  //    {
+  //      if (!fMCReactionPlaneAngle == 0) cout<<" MC Reaction Plane Angle = "<<  fMCReactionPlaneAngle << endl;
+  //      else cout<<" MC Reaction Plane Angle = unknown "<< endl;
+  //      cout<<" iGoodTracks = "<<iGoodTracks<<endl;
+  //      cout<<" # of RP selected tracks = "<<iSelParticlesRP<<endl;
+  //      cout<<" # of POI selected tracks = "<<iSelParticlesPOI<<endl;
+  //      cout << "# " << fCount << " events processed" << endl;
+  //    }
+  //    return pEvent;
+  //  }
+  //  else
+  //  {
+  //    cout<<"Not enough tracks in the FlowEventSimple"<<endl;
+  //    return 0;
+  //  }
+  //}
+  //else
+  //{
+  //  cout<<"Event does not pass multiplicity cuts"<<endl;
+  //  return 0;
+  //}
+
+}
+
+//-----------------------------------------------------------------------
+AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
+                            const AliMCEvent* anInputMc,
+                            KineSource anOption,
+                            const AliCFManager* rpCFManager,
+                            const AliCFManager* poiCFManager ):
+  AliFlowEventSimple(20), fApplyRecentering(kFALSE), fCachedRun(-1), fCurrentCentrality(-1)
+{
+    // constructor
+    for(Int_t i(0); i < 9; i++) {
+        for(Int_t j(0); j < 2; j++) {
+            for(Int_t k(0); k < 2; k++) {
+                fMeanQ[i][j][k] = 0.; 
+                fWidthQ[i][j][k] = 0.;  
+                fMeanQv3[i][j][k] = 0.; 
+                fWidthQv3[i][j][k] = 0.;
+            }
+        }
+    }
+
+  //fills the event with tracks from the ESD and kinematics from the MC info via the track label
+  if (anOption==kNoKine)
+  {
+    AliFatal("WRONG OPTION IN AliFlowEventMaker::FillTracks(AliESDEvent* anInput, AliMCEvent* anInputMc, KineSource anOption)");
+    exit(1);
+  }
+
+  Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
+
+  Int_t iNumberOfInputTracksMC = anInputMc->GetNumberOfTracks() ;
+  if (iNumberOfInputTracksMC==-1)
+  {
+    AliError("Skipping Event -- No MC information available for this event");
+    return;
+  }
+
+  //loop over ESD tracks
+  for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)
+  {
+    AliESDtrack* pParticle = anInput->GetTrack(itrkN);   //get input particle
+    //get Label
+    Int_t iLabel = pParticle->GetLabel();
+    //match to mc particle
+    AliMCParticle* pMcParticle = (AliMCParticle*) anInputMc->GetTrack(TMath::Abs(iLabel));
+
+    //check
+    if (TMath::Abs(pParticle->GetLabel())!=pMcParticle->Label())
+      AliWarning(Form("pParticle->GetLabel()!=pMcParticle->Label(), %i, %i", pParticle->GetLabel(), pMcParticle->Label()));
+
+    //check if pParticle passes the cuts
+    Bool_t rpOK = kFALSE;
+    Bool_t poiOK = kFALSE;
+    if (rpCFManager && poiCFManager)
+    {
+      if(anOption == kESDkine)
+      {
+        if (rpCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pMcParticle,"mcGenCuts1") &&
+            rpCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle))
+          rpOK=kTRUE;
+        if (poiCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pMcParticle,"mcGenCuts2") &&
+            poiCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle))
+          poiOK=kTRUE;
+      }
+      else if (anOption == kMCkine)
+      {
+        if (rpCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pMcParticle))
+          rpOK=kTRUE;
+        if (poiCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pMcParticle))
+          poiOK=kTRUE;
+      }
+    }
+
+    if (!(rpOK || poiOK)) continue;
+
+    //make new AliFlowTrack
+    AliFlowTrack* pTrack = NULL;
+    if(anOption == kESDkine)   //take the PID from the MC & the kinematics from the ESD
+    {
+      pTrack = new AliFlowTrack(pParticle);
+    }
+    else if (anOption == kMCkine)   //take the PID and kinematics from the MC
+    {
+      pTrack = new AliFlowTrack(pMcParticle);
+    }
+
+    if (rpOK && rpCFManager)
+    {
+      fNumberOfRPs++;
+      pTrack->SetForRPSelection();
+    }
+    if (poiOK && poiCFManager) 
+    { 
+      fNumberOfPOIs++;
+      pTrack->SetForPOISelection();
+    }
+
+    AddTrack(pTrack);
+  }
+  SetMCReactionPlaneAngle(anInputMc);
+}
+
+//-----------------------------------------------------------------------
+AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
+                           const AliMultiplicity* anInputTracklets,
+                           const AliCFManager* poiCFManager ):
+  AliFlowEventSimple(20), fApplyRecentering(kFALSE), fCachedRun(-1), fCurrentCentrality(-1)
+{
+    // constructor
+    for(Int_t i(0); i < 9; i++) {
+        for(Int_t j(0); j < 2; j++) {
+            for(Int_t k(0); k < 2; k++) {
+                fMeanQ[i][j][k] = 0.; 
+                fWidthQ[i][j][k] = 0.;  
+                fMeanQv3[i][j][k] = 0.; 
+                fWidthQv3[i][j][k] = 0.;
+            }
+        }
+    }
+
+
+  //Select the particles of interest from the ESD
+  Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
+
+  //loop over tracks
+  for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)
+    {
+      AliESDtrack* pParticle = anInput->GetTrack(itrkN);   //get input particle
+
+      //check if pParticle passes the cuts
+      Bool_t poiOK = kTRUE;
+      if (poiCFManager)
+       {
+         poiOK = ( poiCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&
+                   poiCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));
+       }
+      if (!poiOK) continue;
+      
+      //make new AliFLowTrack
+      AliFlowTrack* pTrack = new AliFlowTrack(pParticle);
+          
+      //marking the particles used for the particle of interest (POI) selection:
+      if(poiOK && poiCFManager)
+       {
+          fNumberOfPOIs++;
+         pTrack->SetForPOISelection(kTRUE);
+         pTrack->SetSource(AliFlowTrack::kFromESD);
+       }
+
+      AddTrack(pTrack);
+    }//end of while (itrkN < iNumberOfInputTracks)
+
+  //Select the reference particles from the SPD tracklets
+  anInputTracklets = anInput->GetMultiplicity();
+  Int_t multSPD = anInputTracklets->GetNumberOfTracklets();
+  
+  //loop over tracklets
+  for (Int_t itracklet=0; itracklet<multSPD; ++itracklet) {
+    Float_t thetaTr= anInputTracklets->GetTheta(itracklet);
+    Float_t phiTr= anInputTracklets->GetPhi(itracklet);
+    // calculate eta
+    Float_t etaTr = -TMath::Log(TMath::Tan(thetaTr/2.));
+    
+    //make new AliFLowTrackSimple
+    AliFlowTrack* pTrack = new AliFlowTrack();
+    pTrack->SetPt(0.0);
+    pTrack->SetEta(etaTr);
+    pTrack->SetPhi(phiTr);
+    //marking the particles used for the reference particle (RP) selection:
+    fNumberOfRPs++;
+    pTrack->SetForRPSelection(kTRUE);
+    pTrack->SetSource(AliFlowTrack::kFromTracklet);
+
+    //Add the track to the flowevent
+    AddTrack(pTrack);
+  }
+
+}
+
+//-----------------------------------------------------------------------
+AliFlowEvent::AliFlowEvent( const AliESDEvent* esd,
+                           const AliCFManager* poiCFManager,
+                            Bool_t hybrid):
+  AliFlowEventSimple(20), fApplyRecentering(kFALSE), fCachedRun(-1), fCurrentCentrality(-1)
+{
+    // constructor
+    for(Int_t i(0); i < 9; i++) {
+        for(Int_t j(0); j < 2; j++) {
+            for(Int_t k(0); k < 2; k++) {
+                fMeanQ[i][j][k] = 0.; 
+                fWidthQ[i][j][k] = 0.;  
+                fMeanQv3[i][j][k] = 0.; 
+                fWidthQv3[i][j][k] = 0.;
+            }
+        }
+    }
+
+
+  //Select the particles of interest from the ESD
+  Int_t iNumberOfInputTracks = esd->GetNumberOfTracks() ;
+
+  //Double_t gPt = 0.0, gP = 0.0;
+  Double_t dca[2] = {0.0,0.0}, cov[3] = {0.0,0.0,0.0};  //The impact parameters and their covariance.
+//  Double_t dca3D = 0.0;       FIXME unused variable
+
+  AliESDtrack trackTPC;
+
+  //loop over tracks
+  for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)
+    {
+
+      if (!esd->GetTrack(itrkN)) continue;
+
+      Bool_t useTPC = kFALSE;
+
+      AliESDtrack* pParticle = esd->GetTrack(itrkN);   //get input particle
+
+      //check if pParticle passes the cuts
+      Bool_t poiOK = kTRUE;
+
+      if (poiCFManager)
+      {
+        poiOK = ( poiCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&
+                  poiCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));
+      }
+
+      if (!(poiOK)) continue;
+
+      AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)pParticle->GetTPCInnerParam();
+
+      if (tpcTrack)
+      {
+
+//      gPt = tpcTrack->Pt();
+//      gP = tpcTrack->P();
+
+        useTPC = kTRUE;
+
+        const AliESDVertex *vertexSPD = esd->GetPrimaryVertexSPD();
+        const AliESDVertex *vertexTPC = esd->GetPrimaryVertexTPC();
+
+        if(hybrid)
+          tpcTrack->PropagateToDCA(vertexSPD,esd->GetMagneticField(),100.,dca,cov);
+        else
+          tpcTrack->PropagateToDCA(vertexTPC,esd->GetMagneticField(),100.,dca,cov);
+
+//        dca3D = TMath::Sqrt(TMath::Power(dca[0],2)+TMath::Power(dca[1],2));   FIXME unused variable
+
+      }
+
+      //make new AliFLowTrack
+      AliFlowTrack* pTrack = new AliFlowTrack(pParticle);
+
+      pTrack->SetSource(AliFlowTrack::kFromESD);
+
+      //marking the particles used for diff. flow:
+      if(poiOK && poiCFManager)
+      {
+        pTrack->SetForPOISelection(kTRUE);
+        fNumberOfPOIs++;
+      }
+
+      if(useTPC)
+      {
+        pTrack->SetForRPSelection(kTRUE);
+        fNumberOfRPs++;
+      }
+
+      AddTrack(pTrack);
+
+    }//end of while (itrkN < iNumberOfInputTracks)
+
+}
+
+//-----------------------------------------------------------------------
+AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
+                           const TH2F* anInputFMDhist,
+                           const AliCFManager* poiCFManager ):
+  AliFlowEventSimple(20), fApplyRecentering(kFALSE), fCachedRun(-1), fCurrentCentrality(-1)
+{
+    // constructor
+    for(Int_t i(0); i < 9; i++) {
+        for(Int_t j(0); j < 2; j++) {
+            for(Int_t k(0); k < 2; k++) {
+                fMeanQ[i][j][k] = 0.; 
+                fWidthQ[i][j][k] = 0.;  
+                fMeanQv3[i][j][k] = 0.; 
+                fWidthQv3[i][j][k] = 0.;
+            }
+        }
+    }
+
+
+  //Select the particles of interest from the ESD
+  Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
+
+  //loop over tracks
+  for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)
+    {
+      AliESDtrack* pParticle = anInput->GetTrack(itrkN);   //get input particle
+
+      //check if pParticle passes the cuts
+      Bool_t poiOK = kTRUE;
+      if (poiCFManager)
+       {
+         poiOK = ( poiCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&
+                   poiCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));
+       }
+      if (!poiOK) continue;
+      //make new AliFLowTrack
+      AliFlowTrack* pTrack = new AliFlowTrack(pParticle);
+          
+      //marking the particles used for the particle of interest (POI) selection:
+      if(poiOK && poiCFManager)
+       {
+          fNumberOfPOIs++; 
+         pTrack->SetForPOISelection(kTRUE);
+         pTrack->SetSource(AliFlowTrack::kFromESD);
+       }
+
+      AddTrack(pTrack);
+    }//end of while (itrkN < iNumberOfInputTracks)
+
+  //Select the reference particles from the FMD hits
+  //loop over FMD histogram
+  Int_t iBinsEta = anInputFMDhist->GetNbinsX();
+  Int_t iBinsPhi = anInputFMDhist->GetNbinsY();
+  
+  for (Int_t iEta = 1; iEta <= iBinsEta; iEta++){
+    Double_t etaFMD = anInputFMDhist->GetXaxis()->GetBinCenter(iEta);
+    for (Int_t iPhi = 1; iPhi <= iBinsPhi; iPhi++){
+      Double_t phiFMD = anInputFMDhist->GetYaxis()->GetBinCenter(iPhi);
+      Double_t weightFMD = anInputFMDhist->GetBinContent(iEta,iPhi);
+    
+      if (weightFMD > 0.0) { //do not add empty bins
+       //make new AliFLowTrackSimple
+       AliFlowTrack* pTrack = new AliFlowTrack();
+       pTrack->SetPt(0.0);
+       pTrack->SetEta(etaFMD);
+       pTrack->SetPhi(phiFMD);
+       pTrack->SetWeight(weightFMD);
+       //marking the particles used for the reference particle (RP) selection:
+       pTrack->TagRP();
+       fNumberOfRPs++;
+       pTrack->SetSource(AliFlowTrack::kFromFMD);
+
+       //Add the track to the flowevent
+       AddTrack(pTrack);
+       
+      }
+    }
+  }
+
+}
+
+//-----------------------------------------------------------------------
+void AliFlowEvent::Fill( AliFlowTrackCuts* rpCuts,
+                         AliFlowTrackCuts* poiCuts )
+{
+  //Fills the event from a vevent: AliESDEvent,AliAODEvent,AliMCEvent
+  //the input data needs to be attached to the cuts
+  //we have two cases, if we're cutting the same collection of tracks
+  //(same param type) then we can have tracks that are both rp and poi
+  //in the other case we want to have two exclusive sets of rps and pois
+  //e.g. one tracklets, the other PMD or global - USER IS RESPOSIBLE
+  //FOR MAKING SURE THEY DONT OVERLAP OR ELSE THE SAME PARTICLE WILL BE
+  //TAKEN TWICE
+
+  ClearFast();
+
+  if (!rpCuts || !poiCuts) return;
+  AliFlowTrackCuts::trackParameterType sourceRP = rpCuts->GetParamType();
+  AliFlowTrackCuts::trackParameterType sourcePOI = poiCuts->GetParamType();
+  AliFlowTrack* pTrack=NULL;
+  
+  // if the source for rp's or poi's is the VZERO detector, get the calibration 
+  // and set the calibration parameters
+  if (sourceRP == AliFlowTrackCuts::kV0 || sourceRP == AliFlowTrackCuts::kVZERO) {
+      SetVZEROCalibrationForTrackCuts(rpCuts);
+//      for now, recentering is only applied if the user specifically asks for it
+//      by setting the flag to kTRUE in the ali flow track cuts
+      fApplyRecentering = rpCuts->GetApplyRecentering();    
+      // note: this flag is used in the overloaded implementation of Get2Qsub()
+      // and tells the function to use as Qsub vectors the recentered Q-vectors
+      // from the VZERO aodb file
+  }
+  if (sourcePOI ==AliFlowTrackCuts::kV0 || sourcePOI == AliFlowTrackCuts::kVZERO) {
+      // probably no-one will choose vzero tracks as poi's ...
+      SetVZEROCalibrationForTrackCuts(poiCuts); 
+  }
+  if (sourceRP==sourcePOI)
+  {
+    //loop over tracks
+    Int_t numberOfInputObject = rpCuts->GetNumberOfInputObjects();
+    for (Int_t i=0; i<numberOfInputObject; i++)
+    {
+      //get input object (particle)
+      TObject* particle = rpCuts->GetInputObject(i);
+
+      Bool_t rp = rpCuts->IsSelected(particle,i);
+      Bool_t poi = poiCuts->IsSelected(particle,i);
+      
+      if (!(rp||poi)) continue;
+
+      //make new AliFLowTrack
+      if (rp)
+      {
+        pTrack = ReuseTrack(fNumberOfTracks);
+        if (!rpCuts->FillFlowTrack(pTrack)) continue;
+        pTrack->TagRP(); fNumberOfRPs++;
+        if (poi) {pTrack->TagPOI(); fNumberOfPOIs++;}
+      }
+      else if (poi)
+      {
+        pTrack = ReuseTrack(fNumberOfTracks);
+        if (!poiCuts->FillFlowTrack(pTrack)) continue;
+        pTrack->TagPOI(); fNumberOfPOIs++;
+      }
+      fNumberOfTracks++;
+    }//end of while (i < numberOfTracks)
+  }
+  else if (sourceRP!=sourcePOI)
+  {
+    //here we have two different sources of particles, so we fill
+    //them independently
+    //RP
+    Int_t numberOfInputObject = rpCuts->GetNumberOfInputObjects();
+    for (Int_t i=0; i<numberOfInputObject; i++)
+      {
+      TObject* particle = rpCuts->GetInputObject(i);
+      Bool_t rp = rpCuts->IsSelected(particle,i);
+      if (!rp) continue;
+      pTrack = ReuseTrack(fNumberOfTracks);
+      if (!rpCuts->FillFlowTrack(pTrack)) continue;
+      pTrack->TagRP();
+      fNumberOfRPs++;
+      fNumberOfTracks++;
+    }
+    //POI
+    numberOfInputObject = poiCuts->GetNumberOfInputObjects();
+    for (Int_t i=0; i<numberOfInputObject; i++)
+    {
+      TObject* particle = poiCuts->GetInputObject(i);
+      Bool_t poi = poiCuts->IsSelected(particle,i);
+      if (!poi) continue;
+      pTrack = ReuseTrack(fNumberOfTracks);
+      if (!poiCuts->FillFlowTrack(pTrack)) continue;
+      pTrack->TagPOI();
+      fNumberOfPOIs++;
+      fNumberOfTracks++;
+    }
+  }
+}
+
+//-----------------------------------------------------------------------
+void AliFlowEvent::InsertTrack(AliFlowTrack *thisTrack) {
+  // adds a flow track at the end of the container
+  AliFlowTrack *pTrack = ReuseTrack( fNumberOfTracks++ );
+  pTrack->SetPt( thisTrack->Pt() );
+  pTrack->SetPhi( thisTrack->Phi() );
+  pTrack->SetEta( thisTrack->Eta() );
+  pTrack->SetWeight( thisTrack->Weight() );
+  pTrack->SetCharge( thisTrack->Charge() );
+  pTrack->SetMass( thisTrack->Mass() );
+  pTrack->SetForRPSelection( thisTrack->InRPSelection() );
+  pTrack->SetForPOISelection( thisTrack->InPOISelection() );
+  if(thisTrack->InSubevent(0)) pTrack->SetForSubevent(0);
+  if(thisTrack->InSubevent(1)) pTrack->SetForSubevent(1);
+  pTrack->SetID( thisTrack->GetID() );
+  return;
+}
+
+//-----------------------------------------------------------------------
+AliFlowTrack* AliFlowEvent::ReuseTrack(Int_t i)
+{
+  //try to reuse an existing track, if empty, make new one
+  AliFlowTrack* pTrack = static_cast<AliFlowTrack*>(fTrackCollection->At(i));
+  if (pTrack)
+  {
+    pTrack->Clear();
+  }
+  else 
+  {
+    pTrack = new AliFlowTrack();
+    fTrackCollection->AddAtAndExpand(pTrack,i);
+  }
+  return pTrack;
+}
+
+//-----------------------------------------------------------------------
+AliFlowEvent::AliFlowEvent( AliFlowTrackCuts* rpCuts,
+                            AliFlowTrackCuts* poiCuts ):
+  AliFlowEventSimple(20), fApplyRecentering(kFALSE), fCachedRun(-1), fCurrentCentrality(-1)
+{
+    // constructor
+    for(Int_t i(0); i < 9; i++) {
+        for(Int_t j(0); j < 2; j++) {
+            for(Int_t k(0); k < 2; k++) {
+                fMeanQ[i][j][k] = 0.; 
+                fWidthQ[i][j][k] = 0.;  
+                fMeanQv3[i][j][k] = 0.; 
+                fWidthQv3[i][j][k] = 0.;
+            }
+        }
+    }
+
+  //Fills the event from a vevent: AliESDEvent,AliAODEvent,AliMCEvent
+  //the input data needs to be attached to the cuts
+  //we have two cases, if we're cutting the same collection of tracks
+  //(same param type) then we can have tracks that are both rp and poi
+  //in the other case we want to have two exclusive sets of rps and pois
+  //e.g. one tracklets, the other PMD or global - USER IS RESPOSIBLE
+  //FOR MAKING SURE THEY DONT OVERLAP OR ELSE THE SAME PARTICLE WILL BE
+  //TAKEN TWICE
+
+  if (!rpCuts || !poiCuts) return;
+  AliFlowTrackCuts::trackParameterType sourceRP = rpCuts->GetParamType();
+  AliFlowTrackCuts::trackParameterType sourcePOI = poiCuts->GetParamType();
+
+  if (sourceRP==sourcePOI)
+  {
+    //loop over tracks
+    Int_t numberOfInputObject = rpCuts->GetNumberOfInputObjects();
+    for (Int_t i=0; i<numberOfInputObject; i++)
+    {
+      //get input object (particle)
+      TObject* particle = rpCuts->GetInputObject(i);
+
+      Bool_t rp = rpCuts->IsSelected(particle,i);
+      Bool_t poi = poiCuts->IsSelected(particle,i);
+      
+      if (!(rp||poi)) continue;
+
+      //make new AliFLowTrack
+      AliFlowTrack* pTrack = NULL;
+      if (rp)
+      {
+        pTrack = rpCuts->MakeFlowTrack();
+        if (!pTrack) continue;
+        pTrack->TagRP(); fNumberOfRPs++;
+        if (poi) {pTrack->TagPOI(); fNumberOfPOIs++;}
+      }
+      else
+      if (poi)
+      {
+        pTrack = poiCuts->MakeFlowTrack();
+        if (!pTrack) continue;
+        pTrack->TagPOI(); fNumberOfPOIs++;
+      }
+      AddTrack(pTrack);
+    }//end of while (i < numberOfTracks)
+  }
+  else if (sourceRP!=sourcePOI)
+  {
+    //here we have two different sources of particles, so we fill
+    //them independently
+    AliFlowTrack* pTrack = NULL;
+    //RP
+    Int_t numberOfInputObject = rpCuts->GetNumberOfInputObjects();
+    for (Int_t i=0; i<numberOfInputObject; i++)
+    {
+      TObject* particle = rpCuts->GetInputObject(i);
+      Bool_t rp = rpCuts->IsSelected(particle,i);
+      if (!rp) continue;
+      pTrack = rpCuts->MakeFlowTrack();
+      if (!pTrack) continue;
+      pTrack->TagRP(); fNumberOfRPs++;
+      AddTrack(pTrack);
+    }
+    //POI
+    numberOfInputObject = poiCuts->GetNumberOfInputObjects();
+    for (Int_t i=0; i<numberOfInputObject; i++)
+    {
+      TObject* particle = poiCuts->GetInputObject(i);
+      Bool_t poi = poiCuts->IsSelected(particle,i);
+      if (!poi) continue;
+      pTrack = poiCuts->MakeFlowTrack();
+      if (!pTrack) continue;
+      pTrack->TagPOI(); fNumberOfPOIs++;
+      AddTrack(pTrack);
+    }
+  }
+}
+
+//-------------------------------------------------------------------//
+//---- Including PMD tracks as RP --------------------------//
+
+AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
+                           const AliESDPmdTrack *pmdtracks,
+                           const AliCFManager* poiCFManager ):
+  AliFlowEventSimple(20), fApplyRecentering(kFALSE), fCachedRun(-1), fCurrentCentrality(-1)
+{
+    // constructor
+    for(Int_t i(0); i < 9; i++) {
+        for(Int_t j(0); j < 2; j++) {
+            for(Int_t k(0); k < 2; k++) {
+                fMeanQ[i][j][k] = 0.; 
+                fWidthQ[i][j][k] = 0.;  
+                fMeanQv3[i][j][k] = 0.; 
+                fWidthQv3[i][j][k] = 0.;
+            }
+        }
+    }
+
+  Float_t GetPmdEta(Float_t xPos, Float_t yPos, Float_t zPos);
+  Float_t GetPmdPhi(Float_t xPos, Float_t yPos);
+  //Select the particles of interest from the ESD
+  Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
+  
+  //loop over tracks
+  for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)
+    {
+      AliESDtrack* pParticle = anInput->GetTrack(itrkN);   //get input particle
+      //check if pParticle passes the cuts
+      Bool_t poiOK = kTRUE;
+      if (poiCFManager)
+       {
+         poiOK = ( poiCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&
+                   poiCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));
+       }
+      if (!poiOK) continue;
+      
+      //make new AliFLowTrack
+      AliFlowTrack* pTrack = new AliFlowTrack(pParticle);
+      
+      //marking the particles used for the particle of interest (POI) selection:
+      if(poiOK && poiCFManager)
+       {
+          fNumberOfPOIs++;
+         pTrack->SetForPOISelection(kTRUE);
+         pTrack->SetSource(AliFlowTrack::kFromESD);
+       }
+      
+      AddTrack(pTrack);
+    }//end of while (itrkN < iNumberOfInputTracks)
+  
+  //Select the reference particles from the PMD tracks
+  Int_t npmdcl = anInput->GetNumberOfPmdTracks();
+  printf("======There are %d PMD tracks in this event\n-------",npmdcl);
+  //loop over clusters 
+  for(Int_t iclust=0; iclust < npmdcl; iclust++){
+    //AliESDPmdTrack *pmdtr = anInput->GetPmdTrack(iclust);
+    pmdtracks = anInput->GetPmdTrack(iclust);
+    Int_t   det   = pmdtracks->GetDetector();
+    //Int_t   smn   = pmdtracks->GetSmn();
+    Float_t clsX  = pmdtracks->GetClusterX();
+    Float_t clsY  = pmdtracks->GetClusterY();
+    Float_t clsZ  = pmdtracks->GetClusterZ();
+    Float_t ncell = pmdtracks->GetClusterCells();
+    Float_t adc   = pmdtracks->GetClusterADC();
+    //Float_t pid   = pmdtracks->GetClusterPID();
+    Float_t etacls = GetPmdEta(clsX,clsY,clsZ);
+    Float_t phicls = GetPmdPhi(clsX,clsY);
+    //make new AliFLowTrackSimple
+    AliFlowTrack* pTrack = new AliFlowTrack();
+    //if(det == 0){ //selecting preshower plane only
+    if(det == 0 && adc > 270 && ncell > 1){ //selecting preshower plane only
+      //pTrack->SetPt(adc);//cluster adc
+      pTrack->SetPt(0.0);
+      pTrack->SetEta(etacls);
+      pTrack->SetPhi(phicls);
+      //marking the particles used for the reference particle (RP) selection:
+      fNumberOfRPs++;
+      pTrack->SetForRPSelection(kTRUE);
+      pTrack->SetSource(AliFlowTrack::kFromPMD);
+      //Add the track to the flowevent
+      AddTrack(pTrack);
+    }//if det
+  }
+}
+//----------------------------------------------------------------------------//
+Float_t GetPmdEta(Float_t xPos, Float_t yPos, Float_t zPos)
+{
+  Float_t rpxpy, theta, eta;
+  rpxpy  = TMath::Sqrt(xPos*xPos + yPos*yPos);
+  theta  = TMath::ATan2(rpxpy,zPos);
+  eta    = -TMath::Log(TMath::Tan(0.5*theta));
+  return eta;
+}
+//--------------------------------------------------------------------------//
+Float_t GetPmdPhi(Float_t xPos, Float_t yPos)
+{
+  Float_t pybypx, phi = 0., phi1;
+  if(xPos==0)
+    {
+      if(yPos>0) phi = 90.;
+      if(yPos<0) phi = 270.;
+    }
+  if(xPos != 0)
+    {
+      pybypx = yPos/xPos;
+      if(pybypx < 0) pybypx = - pybypx;
+      phi1 = TMath::ATan(pybypx)*180./3.14159;
+      
+      if(xPos > 0 && yPos > 0) phi = phi1;        // 1st Quadrant
+      if(xPos < 0 && yPos > 0) phi = 180 - phi1;  // 2nd Quadrant
+      if(xPos < 0 && yPos < 0) phi = 180 + phi1;  // 3rd Quadrant
+      if(xPos > 0 && yPos < 0) phi = 360 - phi1;  // 4th Quadrant
+      
+    }
+  phi = phi*3.14159/180.;
+  return   phi;
+}
+//---------------------------------------------------------------//
+
+
+void AliFlowEvent::Get2Qsub(AliFlowVector* Qarray, Int_t n, TList *weightsList, Bool_t usePhiWeights, Bool_t usePtWeights, Bool_t useEtaWeights)
+{
+  // get q vectors for the subevents. if no recentering is necessary, get the guy from the flow event simple
+  AliFlowEventSimple::Get2Qsub(Qarray, n, weightsList, usePhiWeights, usePtWeights, useEtaWeights);
+  // else get the recentering from the cached info
+  if (fApplyRecentering)        // set by Fill()
+  {     
+    // first retrieve the q-vectors from the AliFlowEventSimple:: routine
+    AliFlowVector vA = Qarray[0];
+    AliFlowVector vB = Qarray[1];
+    // extract the information form the current flow vectors
+    Double_t Qxc(vA.X());       // IMPORTANT: user is responsible for the sign of eta
+    Double_t Qyc(vA.Y());       // vzeroC has negative pseudorapidity and is taken as subevent A
+    Double_t Qxa(vB.X());       // vzeroA has positive pseudorapidity and is taken as subevent B
+    Double_t Qya(vB.Y());
+    // init some values for the corrections
+    
+    // values for vector a (VZEROA)
+    Double_t Qxamean(0);
+    Double_t Qxarms(1);
+    Double_t Qyamean(0);
+    Double_t Qyarms(1);
+    // values for vector b (VZEROC)
+    Double_t Qxcmean(0);
+    Double_t Qxcrms(1);
+    Double_t Qycmean(0);
+    Double_t Qycrms(1);        
+    
+    if( n == 2) {       // second order symmetry
+        Qxamean = fMeanQ[fCurrentCentrality][1][0];
+        Qxarms  = fWidthQ[fCurrentCentrality][1][0];
+        Qyamean = fMeanQ[fCurrentCentrality][1][1];
+        Qyarms  = fWidthQ[fCurrentCentrality][1][1];
+
+        Qxcmean = fMeanQ[fCurrentCentrality][0][0];
+        Qxcrms  = fWidthQ[fCurrentCentrality][0][0];
+        Qycmean = fMeanQ[fCurrentCentrality][0][1];
+        Qycrms  = fWidthQ[fCurrentCentrality][0][1];   
+    } else if (n == 3) {        // third order symmetry
+        Qxamean = fMeanQv3[fCurrentCentrality][1][0];
+        Qxarms  = fWidthQv3[fCurrentCentrality][1][0];
+        Qyamean = fMeanQv3[fCurrentCentrality][1][1];
+        Qyarms  = fWidthQv3[fCurrentCentrality][1][1];
+  
+        Qxcmean = fMeanQv3[fCurrentCentrality][0][0];
+        Qxcrms  = fWidthQv3[fCurrentCentrality][0][0];
+        Qycmean = fMeanQv3[fCurrentCentrality][0][1];
+        Qycrms  = fWidthQv3[fCurrentCentrality][0][1]; 
+    }
+    // do the correction    
+    Double_t QxaCor = (Qxa - Qxamean)/Qxarms;
+    Double_t QyaCor = (Qya - Qyamean)/Qyarms;
+    Double_t QxcCor = (Qxc - Qxcmean)/Qxcrms;
+    Double_t QycCor = (Qyc - Qycmean)/Qycrms;
+    // update the vector
+    vA.Set(QxcCor, QycCor);
+    vB.Set(QxaCor, QyaCor);
+  }
+}
+//_____________________________________________________________________________
+void AliFlowEvent::SetVZEROCalibrationForTrackCuts(AliFlowTrackCuts* cuts) {
+    // open calibration info, copied from AliAnalyisTaskVnV0.cxx
+    if(!cuts->GetEvent()) return; // coverity. we need to know the event to get the runnumber and centrlaity
+    // get the vzero centrality percentile (cc dependent calibration)
+    Float_t v0Centr(cuts->GetEvent()->GetCentrality()->GetCentralityPercentile("V0M"));
+    if(v0Centr < 5) fCurrentCentrality = 0;
+    else if(v0Centr < 10) fCurrentCentrality = 1;
+    else if(v0Centr < 20) fCurrentCentrality = 2;
+    else if(v0Centr < 30) fCurrentCentrality = 3;
+    else if(v0Centr < 40) fCurrentCentrality = 4;
+    else if(v0Centr < 50) fCurrentCentrality = 5;
+    else if(v0Centr < 60) fCurrentCentrality = 6;
+    else if(v0Centr < 70) fCurrentCentrality = 7;
+    else fCurrentCentrality = 8;
+
+    // if this event is from the same run as the previous event
+    // we can use the cached calibration values, no need to re-open the 
+    // aodb file
+    Int_t run(cuts->GetEvent()->GetRunNumber());
+//    printf ( " > run number is %i \n", run);
+    if(fCachedRun == run) {
+//        printf(" run number didn't change, using cached values \n");
+        return;
+    }
+    // set the chached run number
+    fCachedRun = run;
+    
+    TString oadbfilename = "$ALICE_ROOT/OADB/PWGCF/VZERO/VZEROcalibEP.root";
+    TFile *foadb = TFile::Open(oadbfilename.Data());
+
+    if(!foadb){
+       printf("OADB file %s cannot be opened\n",oadbfilename.Data());
+       return;
+    }
+
+    AliOADBContainer *cont = (AliOADBContainer*) foadb->Get("hMultV0BefCorr");
+    if(!cont){
+       printf("OADB object hMultV0BefCorr is not available in the file\n");
+       return; 
+    }
+
+    if(!(cont->GetObject(run))){
+       printf("OADB object hMultV0BefCorr is not available for run %i (used run 137366)\n",run);
+       run = 137366;
+    }
+    // step 1) get the proper multiplicity weights from the vzero signal
+    TProfile* fMultV0 = ((TH2F *) cont->GetObject(run))->ProfileX();
+
+    TF1 *fpol0 = new TF1("fpol0","pol0"); 
+    if(cuts->GetV0gainEqualizationPerRing()) {
+        // do the calibration per ring
+        // start with the vzero c rings (segments 0 through 31)
+        fMultV0->Fit(fpol0, "", "", 0, 8);
+        (cuts->GetUseVZERORing(0)) ? cuts->SetV0Cpol(0, fpol0->GetParameter(0)) : cuts->SetV0Cpol(0, 0.);
+        fMultV0->Fit(fpol0, "", "", 8, 16);
+        (cuts->GetUseVZERORing(1)) ? cuts->SetV0Cpol(1, fpol0->GetParameter(0)) : cuts->SetV0Cpol(1, 0.);
+        fMultV0->Fit(fpol0, "", "", 16, 24);
+        (cuts->GetUseVZERORing(2)) ? cuts->SetV0Cpol(2, fpol0->GetParameter(0)) : cuts->SetV0Cpol(2, 0.);
+        fMultV0->Fit(fpol0, "", "", 24, 32);
+        (cuts->GetUseVZERORing(3)) ? cuts->SetV0Cpol(3, fpol0->GetParameter(0)) : cuts->SetV0Cpol(3, 0.);
+        // same thing for vero A
+        fMultV0->Fit(fpol0, "", "", 32, 40);
+        (cuts->GetUseVZERORing(4)) ? cuts->SetV0Apol(0, fpol0->GetParameter(0)) : cuts->SetV0Apol(0, 0.);
+        fMultV0->Fit(fpol0, "", "", 40, 48);
+        (cuts->GetUseVZERORing(5)) ? cuts->SetV0Apol(1, fpol0->GetParameter(0)) : cuts->SetV0Apol(1, 0.);
+        fMultV0->Fit(fpol0, "", "", 48, 56);
+        (cuts->GetUseVZERORing(6)) ? cuts->SetV0Apol(2, fpol0->GetParameter(0)) : cuts->SetV0Apol(2, 0.);
+        fMultV0->Fit(fpol0, "", "", 56, 64);
+        (cuts->GetUseVZERORing(7)) ? cuts->SetV0Apol(3, fpol0->GetParameter(0)) : cuts->SetV0Apol(3, 0.);
+    } else {
+        // do the calibration in one go. the calibration will still be 
+        // stored per ring, but each ring has the same weight now
+       fMultV0->Fit(fpol0,"","",0,31);
+       for(Int_t i(0); i < 4; i++) cuts->SetV0Cpol(i, fpol0->GetParameter(0));
+       fMultV0->Fit(fpol0,"","",32,64);
+       for(Int_t i(0); i < 4; i++) cuts->SetV0Apol(i, fpol0->GetParameter(0));
+    }
+    // the parameters to weigh the vzero track cuts have been extracted now, 
+    // so we can pass them to the current track cuts obect
+    cuts->SetV0gainEqualisation(fMultV0);       // passed as a TH1
+
+    // step 2) reweight the q-vectors that will be  called by flow methods which use
+    // subevents
+    // underlying assumption is that subevent a uses VZEROA
+    // and subevent b uses VZEROC
+    for(Int_t iside=0;iside<2;iside++){
+       for(Int_t icoord=0;icoord<2;icoord++){
+           for(Int_t i=0;i  < 9;i++){
+               char namecont[100];
+               if(iside==0 && icoord==0)
+                 snprintf(namecont,100,"hQxc2_%i",i);
+               else if(iside==1 && icoord==0)
+                 snprintf(namecont,100,"hQxa2_%i",i);
+               else if(iside==0 && icoord==1)
+                 snprintf(namecont,100,"hQyc2_%i",i);
+               else if(iside==1 && icoord==1)
+                 snprintf(namecont,100,"hQya2_%i",i);
+
+               cont = (AliOADBContainer*) foadb->Get(namecont);
+               if(!cont){
+                   printf("OADB object %s is not available in the file\n",namecont);
+                   return;     
+               }
+       
+               if(!(cont->GetObject(run))){
+                   printf("OADB object %s is not available for run %i (used run 137366)\n",namecont,run);
+                   run = 137366;
+               }
+
+                // after grabbing all the info, set the CORRECTION TERMS to
+                // the 2nd and 3rd order qsub-vectors
+                // we do this here for all centralities, so that subsequent events
+                // can grab the correction from these cached values
+                fMeanQ[i][iside][icoord] = ((TH1F *) cont->GetObject(run))->GetMean();
+               fWidthQ[i][iside][icoord] = ((TH1F *) cont->GetObject(run))->GetRMS();
+
+               //for v3
+               if(iside==0 && icoord==0)
+                 snprintf(namecont,100,"hQxc3_%i",i);
+               else if(iside==1 && icoord==0)
+                 snprintf(namecont,100,"hQxa3_%i",i);
+               else if(iside==0 && icoord==1)
+                 snprintf(namecont,100,"hQyc3_%i",i);
+               else if(iside==1 && icoord==1)
+                 snprintf(namecont,100,"hQya3_%i",i);
+
+               cont = (AliOADBContainer*) foadb->Get(namecont);
+               if(!cont){
+                   printf("OADB object %s is not available in the file\n",namecont);
+                   return;     
+               }
+               
+               if(!(cont->GetObject(run))){
+                   printf("OADB object %s is not available for run %i (used run 137366)\n",namecont,run);
+                   run = 137366;
+               }
+               fMeanQv3[i][iside][icoord] = ((TH1F *) cont->GetObject(run))->GetMean();
+               fWidthQv3[i][iside][icoord] = ((TH1F *) cont->GetObject(run))->GetRMS();
+
+           }
+       }
+    }
+}
+//_____________________________________________________________________________
index f88e6a6..2ae1d5e 100644 (file)
-/////////////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-// AddTask* macro for flow analysis\r
-// Creates a Flow Event task and adds it to the analysis manager.\r
-// Sets the cuts using the correction framework (CORRFW) classes.\r
-// Also creates Flow Analysis tasks and connects them to the output of the flow event task.\r
-//\r
-/////////////////////////////////////////////////////////////////////////////////////////////\r
-\r
-void AddTaskFlowCentralityPIDQC(Int_t centralitysel,\r
-                               Float_t centrMin=10.,\r
-                               Float_t centrMax=20.,\r
-                               TString fileNameBase="output",\r
-                               Bool_t isPID = kTRUE,\r
-                               AliPID::EParticleType particleType=AliPID::kPion,\r
-                               AliFlowTrackCuts::PIDsource sourcePID = AliFlowTrackCuts::kTOFbayesian,\r
-                               Int_t charge=0,\r
-                               Int_t harmonic=2,\r
-                               Bool_t doQA=kFALSE,\r
-                              Float_t etamin=-0.8,\r
-                              Float_t etamax=0.8,       \r
-                               TString uniqueStr="" )\r
-{\r
-  // Define the range for eta subevents (for SP method)\r
-  Double_t minA = -5;\r
-  Double_t maxA = -1.5;\r
-  Double_t minB = 1.5;\r
-  Double_t maxB = 5;\r
-\r
-  // AFTERBURNER\r
-  Bool_t useAfterBurner=kFALSE;\r
-  Double_t v1=0.0;\r
-  Double_t v2=0.0;\r
-  Double_t v3=0.0;\r
-  Double_t v4=0.0;\r
-  Int_t numberOfTrackClones=0; //non-flow\r
-\r
-  // Define a range of the detector to exclude\r
-  Bool_t ExcludeRegion = kFALSE;\r
-  Double_t excludeEtaMin = -0.;\r
-  Double_t excludeEtaMax = 0.;\r
-  Double_t excludePhiMin = 0.;\r
-  Double_t excludePhiMax = 0.;\r
-\r
-  // use physics selection class\r
-  Bool_t  UsePhysicsSelection = kTRUE;\r
-\r