dNdPt analysis
authorjotwinow <jotwinow@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 17 Nov 2009 11:14:48 +0000 (11:14 +0000)
committerjotwinow <jotwinow@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 17 Nov 2009 11:14:48 +0000 (11:14 +0000)
20 files changed:
PWG0/dNdPt/AlidNdPt.cxx [new file with mode: 0644]
PWG0/dNdPt/AlidNdPt.h [new file with mode: 0644]
PWG0/dNdPt/AlidNdPtAcceptanceCuts.cxx [new file with mode: 0644]
PWG0/dNdPt/AlidNdPtAcceptanceCuts.h [new file with mode: 0644]
PWG0/dNdPt/AlidNdPtAnalysis.cxx [new file with mode: 0644]
PWG0/dNdPt/AlidNdPtAnalysis.h [new file with mode: 0644]
PWG0/dNdPt/AlidNdPtCorrection.cxx [new file with mode: 0644]
PWG0/dNdPt/AlidNdPtCorrection.h [new file with mode: 0644]
PWG0/dNdPt/AlidNdPtCutAnalysis.cxx [new file with mode: 0644]
PWG0/dNdPt/AlidNdPtCutAnalysis.h [new file with mode: 0644]
PWG0/dNdPt/AlidNdPtEventCuts.cxx [new file with mode: 0644]
PWG0/dNdPt/AlidNdPtEventCuts.h [new file with mode: 0644]
PWG0/dNdPt/AlidNdPtHelper.cxx [new file with mode: 0644]
PWG0/dNdPt/AlidNdPtHelper.h [new file with mode: 0644]
PWG0/dNdPt/AlidNdPtTask.cxx [new file with mode: 0644]
PWG0/dNdPt/AlidNdPtTask.h [new file with mode: 0644]
PWG0/dNdPt/macros/CreateStandardCuts.C [new file with mode: 0644]
PWG0/dNdPt/macros/LoadMyLibs.C [new file with mode: 0644]
PWG0/dNdPt/macros/ProofEnableAliRoot.C [new file with mode: 0644]
PWG0/dNdPt/macros/rundNdPt.C [new file with mode: 0644]

diff --git a/PWG0/dNdPt/AlidNdPt.cxx b/PWG0/dNdPt/AlidNdPt.cxx
new file mode 100644 (file)
index 0000000..5b05203
--- /dev/null
@@ -0,0 +1,55 @@
+/**************************************************************************\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
+#include "AliESDtrackCuts.h"  \r
+#include "AlidNdPtEventCuts.h"\r
+#include "AlidNdPtAcceptanceCuts.h"\r
+#include "AlidNdPt.h"\r
+\r
+using namespace std;\r
+\r
+ClassImp(AlidNdPt)\r
+\r
+//_____________________________________________________________________________\r
+AlidNdPt::AlidNdPt(): TNamed()\r
+, fdNdPtEventCuts(0)\r
+, fdNdPtAcceptanceCuts(0)\r
+, fEsdTrackCuts(0)\r
+, fUseMCInfo(kFALSE)\r
+, fAnalysisMode(AlidNdPtHelper::kTPC) \r
+, fTrigger(AlidNdPtHelper::kMB1) \r
+{\r
+  // default constructor\r
+}\r
+\r
+//_____________________________________________________________________________\r
+AlidNdPt::AlidNdPt(Char_t* name, Char_t* title): TNamed(name,title)\r
+, fdNdPtEventCuts(0)\r
+, fdNdPtAcceptanceCuts(0)\r
+, fEsdTrackCuts(0)\r
+, fUseMCInfo(kFALSE)\r
+, fAnalysisMode(AlidNdPtHelper::kTPC) \r
+, fTrigger(AlidNdPtHelper::kMB1) \r
+{\r
+  // constructor\r
+}\r
+\r
+//_____________________________________________________________________________\r
+AlidNdPt::~AlidNdPt(){\r
+  // destructor\r
+  if(fdNdPtEventCuts) delete fdNdPtEventCuts; fdNdPtEventCuts=NULL; \r
+  if(fdNdPtAcceptanceCuts) delete fdNdPtAcceptanceCuts; fdNdPtAcceptanceCuts=NULL;\r
+  if(fEsdTrackCuts) delete fEsdTrackCuts; fEsdTrackCuts=NULL;\r
+}\r
diff --git a/PWG0/dNdPt/AlidNdPt.h b/PWG0/dNdPt/AlidNdPt.h
new file mode 100644 (file)
index 0000000..03c7951
--- /dev/null
@@ -0,0 +1,73 @@
+#ifndef ALIDNDPT_H
+#define ALIDNDPT_H
+
+//------------------------------------------------------------------------------
+// Abstract class for dNdPt analysis. All dNdPt components should derive from it.   
+// 
+// Author: J.Otwinowski 03/11/2008 
+//------------------------------------------------------------------------------
+
+class AliESDEvent; 
+class AliMCEvent; 
+class AliESDtrackCuts; 
+class AlidNdPtEventCuts;
+class AlidNdPtAcceptanceCuts;
+
+#include "TNamed.h"
+#include "TFolder.h"
+#include "AlidNdPtHelper.h"
+
+class AlidNdPt : public TNamed {
+public:
+  AlidNdPt(); 
+  AlidNdPt(Char_t* name, Char_t* title);
+  ~AlidNdPt();
+
+  // Init data members
+  virtual void Init() = 0;
+
+  // Process events
+  virtual void Process(AliESDEvent *const esdEvent=0, AliMCEvent *const mcEvent=0) = 0;
+
+  // Merge output objects (needed by PROOF) 
+  virtual Long64_t Merge(TCollection* list=0) = 0;
+
+  // Analyse output histograms 
+  virtual void Analyse() = 0;
+
+  // Export analysed output objects to folder
+  virtual TFolder *ExportToFolder(TObjArray * array=0) = 0;
+
+  //
+  AlidNdPt(const AlidNdPt&); // not implemented
+  AlidNdPt& operator=(const AlidNdPt&); // not implemented
+
+  //
+  void SetEventCuts(AlidNdPtEventCuts* const cuts) { fdNdPtEventCuts = cuts; }
+  void SetAcceptanceCuts(AlidNdPtAcceptanceCuts* const cuts) { fdNdPtAcceptanceCuts = cuts; }
+  void SetTrackCuts(AliESDtrackCuts* const cuts) { fEsdTrackCuts = cuts; }
+  void SetUseMCInfo(Bool_t info) { fUseMCInfo = info; }
+  void SetAnalysisMode(AlidNdPtHelper::AnalysisMode mode) { fAnalysisMode = mode; }
+  void SetTrigger(AlidNdPtHelper::Trigger trigger) { fTrigger = trigger; }
+
+  AlidNdPtEventCuts* GetEventCuts() const { return fdNdPtEventCuts; }
+  AlidNdPtAcceptanceCuts* GetAcceptanceCuts() const { return fdNdPtAcceptanceCuts; }
+  AliESDtrackCuts* GetTrackCuts() const { return fEsdTrackCuts; }
+  Bool_t IsUseMCInfo() { return fUseMCInfo; }
+  AlidNdPtHelper::AnalysisMode GetAnalysisMode() { return fAnalysisMode; }
+  AlidNdPtHelper::Trigger GetTrigger() { return fTrigger; }
+
+private:
+
+  AlidNdPtEventCuts      *fdNdPtEventCuts;      // event cuts
+  AlidNdPtAcceptanceCuts *fdNdPtAcceptanceCuts; // acceptance cuts
+  AliESDtrackCuts *fEsdTrackCuts;               // esd track cuts
+
+  Bool_t fUseMCInfo;                            // use MC information
+  AlidNdPtHelper::AnalysisMode fAnalysisMode;   // analysis mode TPC only, TPC + ITS
+  AlidNdPtHelper::Trigger fTrigger;             // trigger definition MB1, MB2 ...
+
+  ClassDef(AlidNdPt,1);
+};
+
+#endif
diff --git a/PWG0/dNdPt/AlidNdPtAcceptanceCuts.cxx b/PWG0/dNdPt/AlidNdPtAcceptanceCuts.cxx
new file mode 100644 (file)
index 0000000..c604abe
--- /dev/null
@@ -0,0 +1,149 @@
+/**************************************************************************
+* 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.                  *
+**************************************************************************/
+
+#include <iostream>
+#include <TList.h>
+
+#include "AliLog.h"
+#include "AliESDtrack.h"
+#include "AliExternalTrackParam.h"
+#include "TParticle.h"
+
+#include "AlidNdPtAcceptanceCuts.h"
+
+using namespace std;
+
+ClassImp(AlidNdPtAcceptanceCuts)
+
+//_____________________________________________________________________________
+AlidNdPtAcceptanceCuts::AlidNdPtAcceptanceCuts(const Char_t* name,const Char_t *title) : 
+AliAnalysisCuts(name, title)
+, fMinEta(0)
+, fMaxEta(0)
+, fMinPhi(0)
+, fMaxPhi(0)
+, fMinPt(0)
+, fMaxPt(0)
+, fMaxDCAr(0)
+, fMaxDCAz(0)
+{
+  // default constructor 
+  
+  // init data members with defaults
+  Init();
+}
+
+//_____________________________________________________________________________
+AlidNdPtAcceptanceCuts::~AlidNdPtAcceptanceCuts()  
+{
+  // destructor
+}
+
+//_____________________________________________________________________________
+void AlidNdPtAcceptanceCuts::Init()  
+{
+  // set default values
+  SetEtaRange();
+  SetPhiRange();
+  SetPtRange();
+  SetMaxDCAr();
+  SetMaxDCAz();
+}
+
+//_____________________________________________________________________________
+Bool_t AlidNdPtAcceptanceCuts::AcceptTrack(AliESDtrack *track)
+{
+  // check acceptance cuts for AliESDtrack
+  if(!track) return kFALSE;
+
+  Float_t eta = track->Eta();
+  Float_t phi = track->Phi();
+  Float_t pt = track->Pt();
+
+  if(eta < fMinEta) return kFALSE;
+  if(eta > fMaxEta) return kFALSE;
+  if(phi < fMinPhi) return kFALSE;
+  if(phi > fMaxPhi) return kFALSE;
+  if(pt < fMinPt) return kFALSE;
+  if(pt > fMaxPt) return kFALSE;
+
+return kTRUE;
+}
+
+//_____________________________________________________________________________
+Bool_t AlidNdPtAcceptanceCuts::AcceptTrack(AliExternalTrackParam *track)
+{
+  // check acceptance cuts for AliESDtrack
+  if(!track) return kFALSE;
+
+  Float_t eta = track->Eta();
+  Float_t phi = track->Phi();
+  Float_t pt = track->Pt();
+
+  if(eta < fMinEta) return kFALSE;
+  if(eta > fMaxEta) return kFALSE;
+  if(phi < fMinPhi) return kFALSE;
+  if(phi > fMaxPhi) return kFALSE;
+  if(pt < fMinPt) return kFALSE;
+  if(pt > fMaxPt) return kFALSE;
+
+return kTRUE;
+}
+
+//_____________________________________________________________________________
+Bool_t AlidNdPtAcceptanceCuts::AcceptTrack(TParticle *particle)
+{
+  // check acceptance cuts for TParticle
+  if(!particle) return kFALSE;
+
+  Float_t eta = particle->Eta();
+  Float_t phi = particle->Phi();
+  Float_t pt = particle->Pt();
+
+  if(eta < fMinEta) return kFALSE;
+  if(eta > fMaxEta) return kFALSE;
+  if(phi < fMinPhi) return kFALSE;
+  if(phi > fMaxPhi) return kFALSE;
+  if(pt < fMinPt) return kFALSE;
+  if(pt > fMaxPt) return kFALSE;
+
+return kTRUE;
+}
+
+//_____________________________________________________________________________
+Long64_t AlidNdPtAcceptanceCuts::Merge(TCollection* list) 
+{
+  // Merge list of objects (needed by PROOF)
+  if (!list)
+  return 0;
+
+  if (list->IsEmpty())
+  return 1;
+
+  TIterator* iter = list->MakeIterator();
+  TObject* obj = 0;
+
+  Int_t count=0;
+  while((obj = iter->Next()) != 0) 
+  {
+    AlidNdPtAcceptanceCuts* entry = dynamic_cast<AlidNdPtAcceptanceCuts*>(obj);
+    if (entry == 0)  
+      continue; 
+
+  count++;
+  }
+
+return count;
+}
diff --git a/PWG0/dNdPt/AlidNdPtAcceptanceCuts.h b/PWG0/dNdPt/AlidNdPtAcceptanceCuts.h
new file mode 100644 (file)
index 0000000..1f34f59
--- /dev/null
@@ -0,0 +1,75 @@
+#ifndef ALIDNDPTACCEPTANCECUTS_H\r
+#define ALIDNDPTACCEPTANCECUTS_H\r
+\r
+//------------------------------------------------------------------------------\r
+// Class to keep selection cuts for MC tracks. \r
+// \r
+// Author: J.Otwinowski 03/11/2008 \r
+//------------------------------------------------------------------------------\r
+\r
+class TParticle;\r
+class AliESDtrack;\r
+class AliExternalTrackParam;\r
+\r
+#include "AliAnalysisCuts.h"\r
+\r
+class AlidNdPtAcceptanceCuts : public AliAnalysisCuts\r
+{\r
+public:\r
+  AlidNdPtAcceptanceCuts(const Char_t* name ="AlidNdPtAcceptanceCuts", const Char_t *title ="");\r
+  virtual ~AlidNdPtAcceptanceCuts(); \r
\r
+  // setters \r
+  void SetEtaRange(const Float_t min=0., const Float_t max=1e99)  { fMinEta=min; fMaxEta=max; }\r
+  void SetPhiRange(const Float_t min=0., const Float_t max=1e99)  { fMinPhi=min; fMaxPhi=max;}\r
+  void SetPtRange(const Float_t min=0., const Float_t max=1e99)   { fMinPt=min;  fMaxPt=max;}\r
+\r
+  void SetMaxDCAr(const Float_t max=1e99) { fMaxDCAr=max;}\r
+  void SetMaxDCAz(const Float_t max=1e99) { fMaxDCAz=max;}\r
+\r
+  // getters \r
+  Float_t GetMinEta() const {return fMinEta;}\r
+  Float_t GetMaxEta() const {return fMaxEta;}\r
+  Float_t GetMinPhi() const {return fMinPhi;}\r
+  Float_t GetMaxPhi() const {return fMaxPhi;}\r
+  Float_t GetMinPt() const {return fMinPt;}\r
+  Float_t GetMaxPt() const {return fMaxPt;}\r
+\r
+  Float_t GetMaxDCAr() const {return fMaxDCAr;}\r
+  Float_t GetMaxDCAz() const {return fMaxDCAz;}\r
+\r
+  // cuts init function\r
+  void Init();\r
+\r
+  // check MC tracks\r
+  virtual Bool_t IsSelected(TObject *) {return kTRUE;}\r
+  virtual Bool_t IsSelected(TList *) {return kTRUE;}\r
+\r
+  //\r
+  Bool_t AcceptTrack(AliESDtrack *track);\r
+  Bool_t AcceptTrack(AliExternalTrackParam *track);\r
+  Bool_t AcceptTrack(TParticle *particle);\r
+  \r
+  // Merge output objects (needed by PROOF) \r
+  virtual Long64_t Merge(TCollection* list);\r
+\r
+private:\r
+  Float_t fMinEta; // min pseudorapidity \r
+  Float_t fMaxEta; // max pseudorapidity\r
+  Float_t fMinPhi; // min azimuthal angle (rad)\r
+  Float_t fMaxPhi; // max azimuthal angle (rad)\r
+  Float_t fMinPt;  // min pt\r
+  Float_t fMaxPt;  // max pt\r
+\r
+  // max DCAr and DCAz with respect\r
+  // to nominal vertex position\r
+  Float_t fMaxDCAr; // min DCAr\r
+  Float_t fMaxDCAz; // max DCAz\r
\r
+  AlidNdPtAcceptanceCuts(const AlidNdPtAcceptanceCuts&); // not implemented\r
+  AlidNdPtAcceptanceCuts& operator=(const AlidNdPtAcceptanceCuts&); // not implemented\r
+\r
+  ClassDef(AlidNdPtAcceptanceCuts, 1)\r
+};\r
+\r
+#endif // \r
diff --git a/PWG0/dNdPt/AlidNdPtAnalysis.cxx b/PWG0/dNdPt/AlidNdPtAnalysis.cxx
new file mode 100644 (file)
index 0000000..aa8c79b
--- /dev/null
@@ -0,0 +1,2189 @@
+/**************************************************************************\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
+#include <iostream>\r
+\r
+#include "TFile.h"\r
+#include "TCint.h"\r
+#include "TH1.h"\r
+#include "TH2.h"\r
+//#include "THnSparse.h"\r
+#include "TCanvas.h"\r
+\r
+#include "AliHeader.h"  \r
+#include "AliGenEventHeader.h"  \r
+#include "AliStack.h"  \r
+#include "AliESDEvent.h"  \r
+#include "AliMCEvent.h"  \r
+#include "AliESDtrackCuts.h"  \r
+#include "AliLog.h" \r
+\r
+#include "AlidNdPtEventCuts.h"\r
+#include "AlidNdPtAcceptanceCuts.h"\r
+\r
+#include "AlidNdPtAnalysis.h"\r
+\r
+using namespace std;\r
+\r
+ClassImp(AlidNdPtAnalysis)\r
+\r
+//_____________________________________________________________________________\r
+  AlidNdPtAnalysis::AlidNdPtAnalysis(): AlidNdPt(),\r
+  fAnalysisFolder(0),\r
+  fHistogramsOn(kFALSE),\r
+\r
+  // event multiplicity correlation matrix \r
+  fEventMultCorrelationMatrix(0),\r
+\r
+  // rec. track pt vs true track pt correlation matrix \r
+  fTrackPtCorrelationMatrix(0),\r
+\r
+  // event level correction\r
+  fGenEventMatrix(0),\r
+  fGenSDEventMatrix(0),\r
+  fGenDDEventMatrix(0),\r
+  fGenNDEventMatrix(0),\r
+  fGenNSDEventMatrix(0),\r
+\r
+  fTriggerEventMatrix(0),\r
+  fTriggerSDEventMatrix(0),\r
+  fTriggerDDEventMatrix(0),\r
+  fTriggerNDEventMatrix(0),\r
+  fTriggerNSDEventMatrix(0),\r
+\r
+  fRecEventMatrix(0),\r
+  fRecSDEventMatrix(0),\r
+  fRecDDEventMatrix(0),\r
+  fRecNDEventMatrix(0),\r
+  fRecNSDEventMatrix(0),\r
+\r
+  //\r
+  // track-event level correction \r
+  //\r
+  fGenTrackEventMatrix(0),\r
+  fGenTrackSDEventMatrix(0),\r
+  fGenTrackDDEventMatrix(0),\r
+  fGenTrackNDEventMatrix(0),\r
+  fGenTrackNSDEventMatrix(0),\r
+\r
+  fTriggerTrackEventMatrix(0),\r
+  fTriggerTrackSDEventMatrix(0),\r
+  fTriggerTrackDDEventMatrix(0),\r
+  fTriggerTrackNDEventMatrix(0),\r
+  fTriggerTrackNSDEventMatrix(0),\r
+\r
+  fRecTrackEventMatrix(0),\r
+  fRecTrackSDEventMatrix(0),\r
+  fRecTrackDDEventMatrix(0),\r
+  fRecTrackNDEventMatrix(0),\r
+  fRecTrackNSDEventMatrix(0),\r
+\r
+  // track rec. efficiency correction (fRecPrimTrackMatrix / fGenPrimTrackMatrix)\r
+  fGenPrimTrackMatrix(0),\r
+  fRecPrimTrackMatrix(0),\r
+\r
+  // secondary track contamination correction (fRecSecTrackMatrix / fRecTrackMatrix)\r
+  fRecTrackMatrix(0),\r
+  fRecSecTrackMatrix(0),\r
+\r
+  // multiple rec. track contamination corrections (fRecMultTrackMatrix / fRecTrackMatrix)\r
+  fRecMultTrackMatrix(0),\r
+\r
+  // event control histograms\r
+  fMCEventHist1(0),\r
+  fRecEventHist1(0),\r
+  fRecEventHist2(0),\r
+  fRecMCEventHist1(0),\r
+  fRecMCEventHist2(0),\r
+  fRecMCEventHist3(0),\r
+\r
+  // rec. pt and eta resolution w.r.t MC\r
+  fRecMCTrackHist1(0),\r
+\r
+  //multple reconstructed tracks\r
+  fMCMultRecTrackHist1(0) \r
+{\r
+  // default constructor\r
+  for(Int_t i=0; i<AlidNdPtHelper::kCutSteps; i++) { \r
+    fMCTrackHist1[i]=0;     \r
+    fMCPrimTrackHist1[i]=0;     \r
+    fMCSecTrackHist1[i]=0;     \r
+    fRecTrackHist1[i]=0;     \r
+    fRecTrackMultHist1[i]=0;     \r
+  }\r
+  Init();\r
+}\r
+\r
+//_____________________________________________________________________________\r
+AlidNdPtAnalysis::AlidNdPtAnalysis(Char_t* name, Char_t* title): AlidNdPt(name,title),\r
+  fAnalysisFolder(0),\r
+  fHistogramsOn(kFALSE),\r
+\r
+  // event multiplicity correlation matrix \r
+  fEventMultCorrelationMatrix(0),\r
+\r
+  // rec. track pt vs true track pt correlation matrix \r
+  fTrackPtCorrelationMatrix(0),\r
+\r
+  // event level correction\r
+  fGenEventMatrix(0),\r
+  fGenSDEventMatrix(0),\r
+  fGenDDEventMatrix(0),\r
+  fGenNDEventMatrix(0),\r
+  fGenNSDEventMatrix(0),\r
+\r
+  fTriggerEventMatrix(0),\r
+  fTriggerSDEventMatrix(0),\r
+  fTriggerDDEventMatrix(0),\r
+  fTriggerNDEventMatrix(0),\r
+  fTriggerNSDEventMatrix(0),\r
+\r
+  fRecEventMatrix(0),\r
+  fRecSDEventMatrix(0),\r
+  fRecDDEventMatrix(0),\r
+  fRecNDEventMatrix(0),\r
+  fRecNSDEventMatrix(0),\r
+\r
+  //\r
+  // track-event level correction \r
+  //\r
+  fGenTrackEventMatrix(0),\r
+  fGenTrackSDEventMatrix(0),\r
+  fGenTrackDDEventMatrix(0),\r
+  fGenTrackNDEventMatrix(0),\r
+  fGenTrackNSDEventMatrix(0),\r
+\r
+  fTriggerTrackEventMatrix(0),\r
+  fTriggerTrackSDEventMatrix(0),\r
+  fTriggerTrackDDEventMatrix(0),\r
+  fTriggerTrackNDEventMatrix(0),\r
+  fTriggerTrackNSDEventMatrix(0),\r
+\r
+  fRecTrackEventMatrix(0),\r
+  fRecTrackSDEventMatrix(0),\r
+  fRecTrackDDEventMatrix(0),\r
+  fRecTrackNDEventMatrix(0),\r
+  fRecTrackNSDEventMatrix(0),\r
+\r
+  // track rec. efficiency correction (fRecPrimTrackMatrix / fGenPrimTrackMatrix)\r
+  fGenPrimTrackMatrix(0),\r
+  fRecPrimTrackMatrix(0),\r
+\r
+  // secondary track contamination correction (fRecSecTrackMatrix / fRecTrackMatrix)\r
+  fRecTrackMatrix(0),\r
+  fRecSecTrackMatrix(0),\r
+\r
+  // multiple rec. track contamination corrections (fRecMultTrackMatrix / fRecTrackMatrix)\r
+  fRecMultTrackMatrix(0),\r
+\r
+  // event control histograms\r
+  fMCEventHist1(0),\r
+  fRecEventHist1(0),\r
+  fRecEventHist2(0),\r
+  fRecMCEventHist1(0),\r
+  fRecMCEventHist2(0),\r
+  fRecMCEventHist3(0),\r
\r
+  // rec. pt and eta resolution w.r.t MC\r
+  fRecMCTrackHist1(0),\r
+\r
+  //multple reconstructed tracks\r
+  fMCMultRecTrackHist1(0) \r
+{\r
+  // constructor\r
+  for(Int_t i=0; i<AlidNdPtHelper::kCutSteps; i++) { \r
+    fMCTrackHist1[i]=0;     \r
+    fMCPrimTrackHist1[i]=0;     \r
+    fMCSecTrackHist1[i]=0;     \r
+    fRecTrackHist1[i]=0;     \r
+    fRecTrackMultHist1[i]=0; \r
+  }\r
+\r
+  Init();\r
+}\r
+\r
+//_____________________________________________________________________________\r
+AlidNdPtAnalysis::~AlidNdPtAnalysis() {\r
+  //\r
+  if(fEventMultCorrelationMatrix) delete fEventMultCorrelationMatrix; fEventMultCorrelationMatrix=0;\r
+  //\r
+  if(fTrackPtCorrelationMatrix) delete fTrackPtCorrelationMatrix; fTrackPtCorrelationMatrix=0;\r
+  //\r
+  if(fGenEventMatrix) delete fGenEventMatrix; fGenEventMatrix=0;\r
+  if(fGenSDEventMatrix) delete fGenSDEventMatrix; fGenSDEventMatrix=0;\r
+  if(fGenDDEventMatrix) delete fGenDDEventMatrix; fGenDDEventMatrix=0;\r
+  if(fGenNDEventMatrix) delete fGenNDEventMatrix; fGenNDEventMatrix=0;\r
+  if(fGenNSDEventMatrix) delete fGenNSDEventMatrix; fGenNSDEventMatrix=0;\r
+\r
+  if(fTriggerEventMatrix) delete fTriggerEventMatrix; fTriggerEventMatrix=0;\r
+  if(fTriggerSDEventMatrix) delete fTriggerSDEventMatrix; fTriggerSDEventMatrix=0;\r
+  if(fTriggerDDEventMatrix) delete fTriggerDDEventMatrix; fTriggerDDEventMatrix=0;\r
+  if(fTriggerNDEventMatrix) delete fTriggerNDEventMatrix; fTriggerNDEventMatrix=0;\r
+  if(fTriggerNSDEventMatrix) delete fTriggerNSDEventMatrix; fTriggerNSDEventMatrix=0;\r
+\r
+  if(fRecEventMatrix) delete fRecEventMatrix; fRecEventMatrix=0;\r
+  if(fRecSDEventMatrix) delete fRecSDEventMatrix; fRecSDEventMatrix=0;\r
+  if(fRecDDEventMatrix) delete fRecDDEventMatrix; fRecDDEventMatrix=0;\r
+  if(fRecNDEventMatrix) delete fRecNDEventMatrix; fRecNDEventMatrix=0;\r
+  if(fRecNSDEventMatrix) delete fRecNSDEventMatrix; fRecNSDEventMatrix=0;\r
+\r
+  //\r
+  if(fGenTrackEventMatrix) delete fGenTrackEventMatrix; fGenTrackEventMatrix=0;\r
+  if(fGenTrackSDEventMatrix) delete fGenTrackSDEventMatrix; fGenTrackSDEventMatrix=0;\r
+  if(fGenTrackDDEventMatrix) delete fGenTrackDDEventMatrix; fGenTrackDDEventMatrix=0;\r
+  if(fGenTrackNDEventMatrix) delete fGenTrackNDEventMatrix; fGenTrackNDEventMatrix=0;\r
+  if(fGenTrackNSDEventMatrix) delete fGenTrackNSDEventMatrix; fGenTrackNSDEventMatrix=0;\r
+\r
+  if(fTriggerEventMatrix) delete fTriggerEventMatrix; fTriggerEventMatrix=0;\r
+  if(fTriggerTrackSDEventMatrix) delete fTriggerTrackSDEventMatrix; fTriggerTrackSDEventMatrix=0;\r
+  if(fTriggerTrackDDEventMatrix) delete fTriggerTrackDDEventMatrix; fTriggerTrackDDEventMatrix=0;\r
+  if(fTriggerTrackNDEventMatrix) delete fTriggerTrackNDEventMatrix; fTriggerTrackNDEventMatrix=0;\r
+  if(fTriggerTrackNSDEventMatrix) delete fTriggerTrackNSDEventMatrix; fTriggerTrackNSDEventMatrix=0;\r
+\r
+  if(fRecTrackEventMatrix) delete fRecTrackEventMatrix; fRecTrackEventMatrix=0;\r
+  if(fRecTrackSDEventMatrix) delete fRecTrackSDEventMatrix; fRecTrackSDEventMatrix=0;\r
+  if(fRecTrackDDEventMatrix) delete fRecTrackDDEventMatrix; fRecTrackDDEventMatrix=0;\r
+  if(fRecTrackNDEventMatrix) delete fRecTrackNDEventMatrix; fRecTrackNDEventMatrix=0;\r
+  if(fRecTrackNSDEventMatrix) delete fRecTrackNSDEventMatrix; fRecTrackNSDEventMatrix=0;\r
+\r
+  //\r
+  if(fGenPrimTrackMatrix) delete fGenPrimTrackMatrix; fGenPrimTrackMatrix=0;\r
+  if(fRecPrimTrackMatrix) delete fRecPrimTrackMatrix; fRecPrimTrackMatrix=0;\r
+  //\r
+  if(fRecTrackMatrix) delete fRecTrackMatrix; fRecTrackMatrix=0;\r
+  if(fRecSecTrackMatrix) delete fRecSecTrackMatrix; fRecSecTrackMatrix=0;\r
+  // \r
+  if(fRecMultTrackMatrix) delete fRecMultTrackMatrix; fRecMultTrackMatrix=0;\r
+  //\r
+  // Control histograms\r
+  //\r
+  if(fMCEventHist1) delete fMCEventHist1; fMCEventHist1=0;\r
+  if(fRecEventHist1) delete fRecEventHist1; fRecEventHist1=0;\r
+  if(fRecEventHist2) delete fRecEventHist2; fRecEventHist2=0;\r
+  if(fRecMCEventHist1) delete fRecMCEventHist1; fRecMCEventHist1=0;\r
+  if(fRecMCEventHist2) delete fRecMCEventHist2; fRecMCEventHist2=0;\r
+  if(fRecMCEventHist3) delete fRecMCEventHist3; fRecMCEventHist3=0;\r
+  //\r
+  for(Int_t i=0; i<AlidNdPtHelper::kCutSteps; i++) { \r
+    if(fMCTrackHist1[i]) delete fMCTrackHist1[i]; fMCTrackHist1[i]=0;\r
+    if(fMCPrimTrackHist1[i]) delete fMCPrimTrackHist1[i]; fMCPrimTrackHist1[i]=0;\r
+    if(fMCSecTrackHist1[i]) delete fMCSecTrackHist1[i]; fMCSecTrackHist1[i]=0;\r
+    if(fRecTrackHist1[i]) delete fRecTrackHist1[i]; fRecTrackHist1[i]=0;\r
+    if(fRecTrackMultHist1[i]) delete fRecTrackMultHist1[i]; fRecTrackMultHist1[i]=0;\r
+  }\r
+  if(fRecMCTrackHist1) delete fRecMCTrackHist1; fRecMCTrackHist1=0;\r
+  if(fMCMultRecTrackHist1) delete fMCMultRecTrackHist1; fMCMultRecTrackHist1=0; \r
+  //\r
+  if(fAnalysisFolder) delete fAnalysisFolder; fAnalysisFolder=0;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AlidNdPtAnalysis::Init(){\r
+  //\r
+  // Init histograms\r
+  //\r
+\r
+  const Int_t ptNbins = 56;\r
+  const Int_t etaNbins = 30;\r
+  const Int_t zvNbins = 12;\r
+  //const Int_t multNbins = 22;\r
+\r
+  Double_t binsPt[ptNbins+1] = {0.,0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.2,2.4,2.6,2.8,3.0,3.2,3.4,3.6,3.8,4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0};\r
+  Double_t binsEta[etaNbins+1] = {-1.5,-1.4,-1.3,-1.2,-1.1,-1.0,-0.9,-0.8,-0.7,-0.6,-0.5,-0.4,-0.3,-0.2,-0.1,0.,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5};\r
+  Double_t binsZv[zvNbins+1] = {-30.,-25.,-20.,-15.,-10.,-5.,0.,5.,10.,15.,20.,25.,30.};\r
+  //Double_t binsMult[multNbins+1] = {0.,1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,12.,14.,16.,18.,20.,30.,40.,50.,70.,90.,110.,150.};\r
+\r
+  //Int_t binsTrackMatrix[4]={zvNbins,ptNbins,etaNbins,multNbins};\r
+  Int_t binsTrackMatrix[3]={zvNbins,ptNbins,etaNbins};\r
+  //Int_t binsTrackMatrix[3]={multNbins,ptNbins,etaNbins};\r
+\r
+  //\r
+  // rec. vs MC correlation matrices\r
+  //\r
+  Int_t binsMultTrueEventMatrix[2]={150,150};\r
+  Double_t minMultTrueEventMatrix[2]={-0.5,-0.5}; \r
+  Double_t maxMultTrueEventMatrix[2]={149.5,149.5}; \r
+  fEventMultCorrelationMatrix = new THnSparseF("fEventMultCorrelationMatrix","mult:true_mult",2,binsMultTrueEventMatrix,minMultTrueEventMatrix,maxMultTrueEventMatrix);\r
+  fEventMultCorrelationMatrix->GetAxis(0)->SetTitle("track multiplicity");\r
+  fEventMultCorrelationMatrix->GetAxis(1)->SetTitle("multiplicity");\r
+  fEventMultCorrelationMatrix->Sumw2();\r
+  \r
+  Int_t binsTrackPtCorrelationMatrix[3]={ptNbins,ptNbins,etaNbins};\r
+  fTrackPtCorrelationMatrix = new THnSparseF("fTrackPtCorrelationMatrix","Pt:mcPt:mcEta",3,binsTrackPtCorrelationMatrix);\r
+  fTrackPtCorrelationMatrix->SetBinEdges(0,binsPt);\r
+  fTrackPtCorrelationMatrix->SetBinEdges(1,binsPt);\r
+  fTrackPtCorrelationMatrix->SetBinEdges(2,binsEta);\r
+  fTrackPtCorrelationMatrix->GetAxis(0)->SetTitle("Pt (GeV/c)");\r
+  fTrackPtCorrelationMatrix->GetAxis(1)->SetTitle("mcPt (GeV/c)");\r
+  fTrackPtCorrelationMatrix->GetAxis(2)->SetTitle("mcEta");\r
+  fTrackPtCorrelationMatrix->Sumw2();\r
+\r
+  //\r
+  // Efficiency and contamination correction matrices\r
+  //\r
+  Int_t binsEventMatrix[2]={zvNbins,150};\r
+  Double_t minEventMatrix[2]={-25.,-0.5}; \r
+  Double_t maxEventMatrix[2]={25.,149.5}; \r
+\r
+  fGenEventMatrix = new THnSparseF("fGenEventMatrix","mcZv:mult",2,binsEventMatrix,minEventMatrix,maxEventMatrix);\r
+  fGenEventMatrix->SetBinEdges(0,binsZv);\r
+  fGenEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fGenEventMatrix->GetAxis(1)->SetTitle("multiplicity");\r
+  fGenEventMatrix->Sumw2();\r
+  \r
+  fGenSDEventMatrix = new THnSparseF("fGenSDEventMatrix","mcZv:mult",2,binsEventMatrix,minEventMatrix,maxEventMatrix);\r
+  fGenSDEventMatrix->SetBinEdges(0,binsZv);\r
+  fGenSDEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fGenSDEventMatrix->GetAxis(1)->SetTitle("multiplicity");\r
+  fGenSDEventMatrix->Sumw2();\r
+  \r
+  fGenDDEventMatrix = new THnSparseF("fGenDDEventMatrix","mcZv:mult",2,binsEventMatrix,minEventMatrix,maxEventMatrix);\r
+  fGenDDEventMatrix->SetBinEdges(0,binsZv);\r
+  fGenDDEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fGenDDEventMatrix->GetAxis(1)->SetTitle("multiplicity");\r
+  fGenDDEventMatrix->Sumw2();\r
+  \r
+  fGenNDEventMatrix = new THnSparseF("fGenNDEventMatrix","mcZv:mult",2,binsEventMatrix,minEventMatrix,maxEventMatrix);\r
+  fGenNDEventMatrix->SetBinEdges(0,binsZv);\r
+  fGenNDEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fGenNDEventMatrix->GetAxis(1)->SetTitle("multiplicity");\r
+  fGenNDEventMatrix->Sumw2();\r
+\r
+  fGenNSDEventMatrix = new THnSparseF("fGenNSDEventMatrix","mcZv:mult",2,binsEventMatrix,minEventMatrix,maxEventMatrix);\r
+  fGenNSDEventMatrix->SetBinEdges(0,binsZv);\r
+  fGenNSDEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fGenNSDEventMatrix->GetAxis(1)->SetTitle("multiplicity");\r
+  fGenNSDEventMatrix->Sumw2();\r
+\r
+  //\r
+  fTriggerEventMatrix = new THnSparseF("fTriggerEventMatrix","mcZv:mult",2,binsEventMatrix,minEventMatrix,maxEventMatrix);\r
+  fTriggerEventMatrix->SetBinEdges(0,binsZv);\r
+  fTriggerEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fTriggerEventMatrix->GetAxis(1)->SetTitle("multiplicity");\r
+  fTriggerEventMatrix->Sumw2();\r
+\r
+  fTriggerSDEventMatrix = new THnSparseF("fTriggerSDEventMatrix","mcZv:mult",2,binsEventMatrix,minEventMatrix,maxEventMatrix);\r
+  fTriggerSDEventMatrix->SetBinEdges(0,binsZv);\r
+  fTriggerSDEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fTriggerSDEventMatrix->GetAxis(1)->SetTitle("multiplicity");\r
+  fTriggerSDEventMatrix->Sumw2();\r
+  \r
+  fTriggerDDEventMatrix = new THnSparseF("fTriggerDDEventMatrix","mcZv:mult",2,binsEventMatrix,minEventMatrix,maxEventMatrix);\r
+  fTriggerDDEventMatrix->SetBinEdges(0,binsZv);\r
+  fTriggerDDEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fTriggerDDEventMatrix->GetAxis(1)->SetTitle("multiplicity");\r
+  fTriggerDDEventMatrix->Sumw2();\r
+  \r
+  fTriggerNDEventMatrix = new THnSparseF("fTriggerNDEventMatrix","mcZv:mult",2,binsEventMatrix,minEventMatrix,maxEventMatrix);\r
+  fTriggerNDEventMatrix->SetBinEdges(0,binsZv);\r
+  fTriggerNDEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fTriggerNDEventMatrix->GetAxis(1)->SetTitle("multiplicity");\r
+  fTriggerNDEventMatrix->Sumw2();\r
\r
+  fTriggerNSDEventMatrix = new THnSparseF("fTriggerNSDEventMatrix","mcZv:mult",2,binsEventMatrix,minEventMatrix,maxEventMatrix);\r
+  fTriggerNSDEventMatrix->SetBinEdges(0,binsZv);\r
+  fTriggerNSDEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fTriggerNSDEventMatrix->GetAxis(1)->SetTitle("multiplicity");\r
+  fTriggerNSDEventMatrix->Sumw2();\r
\r
+  //\r
+  fRecEventMatrix = new THnSparseF("fRecEventMatrix","mcZv:mult",2,binsEventMatrix,minEventMatrix,maxEventMatrix);\r
+  fRecEventMatrix->SetBinEdges(0,binsZv);\r
+  fRecEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fRecEventMatrix->GetAxis(1)->SetTitle("multiplicity");\r
+  fRecEventMatrix->Sumw2();\r
+\r
+  fRecSDEventMatrix = new THnSparseF("fRecSDEventMatrix","mcZv:mult",2,binsEventMatrix,minEventMatrix,maxEventMatrix);\r
+  fRecSDEventMatrix->SetBinEdges(0,binsZv);\r
+  fRecSDEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fRecSDEventMatrix->GetAxis(1)->SetTitle("multiplicity");\r
+  fRecSDEventMatrix->Sumw2();\r
+  \r
+  fRecDDEventMatrix = new THnSparseF("fRecDDEventMatrix","mcZv:mult",2,binsEventMatrix,minEventMatrix,maxEventMatrix);\r
+  fRecDDEventMatrix->SetBinEdges(0,binsZv);\r
+  fRecDDEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fRecDDEventMatrix->GetAxis(1)->SetTitle("multiplicity");\r
+  fRecDDEventMatrix->Sumw2();\r
+  \r
+  fRecNDEventMatrix = new THnSparseF("fRecNDEventMatrix","mcZv:mult",2,binsEventMatrix,minEventMatrix,maxEventMatrix);\r
+  fRecNDEventMatrix->SetBinEdges(0,binsZv);\r
+  fRecNDEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fRecNDEventMatrix->GetAxis(1)->SetTitle("multiplicity");\r
+  fRecNDEventMatrix->Sumw2();\r
\r
+  fRecNSDEventMatrix = new THnSparseF("fRecNSDEventMatrix","mcZv:mult",2,binsEventMatrix,minEventMatrix,maxEventMatrix);\r
+  fRecNSDEventMatrix->SetBinEdges(0,binsZv);\r
+  fRecNSDEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fRecNSDEventMatrix->GetAxis(1)->SetTitle("multiplicity");\r
+  fRecNSDEventMatrix->Sumw2();\r
+\r
+  // \r
+  // track to event corrections\r
+  //\r
+\r
+  fGenTrackEventMatrix = new THnSparseF("fGenTrackEventMatrix","mcZv:mcPt:mcEta",3,binsTrackMatrix);\r
+  fGenTrackEventMatrix->SetBinEdges(0,binsZv);\r
+  fGenTrackEventMatrix->SetBinEdges(1,binsPt);\r
+  fGenTrackEventMatrix->SetBinEdges(2,binsEta);\r
+  fGenTrackEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fGenTrackEventMatrix->GetAxis(1)->SetTitle("mcPt (GeV/c)");\r
+  fGenTrackEventMatrix->GetAxis(2)->SetTitle("mcEta");\r
+  fGenTrackEventMatrix->Sumw2();\r
+\r
+  fGenTrackSDEventMatrix = new THnSparseF("fGenTrackSDEventMatrix","mcZv:mcPt:mcEta",3,binsTrackMatrix);\r
+  fGenTrackSDEventMatrix->SetBinEdges(0,binsZv);\r
+  fGenTrackSDEventMatrix->SetBinEdges(1,binsPt);\r
+  fGenTrackSDEventMatrix->SetBinEdges(2,binsEta);\r
+  fGenTrackSDEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fGenTrackSDEventMatrix->GetAxis(1)->SetTitle("mcPt (GeV/c)");\r
+  fGenTrackSDEventMatrix->GetAxis(2)->SetTitle("mcEta");\r
+  fGenTrackSDEventMatrix->Sumw2();\r
+\r
+  fGenTrackDDEventMatrix = new THnSparseF("fGenTrackDDEventMatrix","mcZv:mcPt:mcEta",3,binsTrackMatrix);\r
+  fGenTrackDDEventMatrix->SetBinEdges(0,binsZv);\r
+  fGenTrackDDEventMatrix->SetBinEdges(1,binsPt);\r
+  fGenTrackDDEventMatrix->SetBinEdges(2,binsEta);\r
+  fGenTrackDDEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fGenTrackDDEventMatrix->GetAxis(1)->SetTitle("mcPt (GeV/c)");\r
+  fGenTrackDDEventMatrix->GetAxis(2)->SetTitle("mcEta");\r
+  fGenTrackDDEventMatrix->Sumw2();\r
+\r
+  fGenTrackNDEventMatrix = new THnSparseF("fGenTrackNDEventMatrix","mcZv:mcPt:mcEta",3,binsTrackMatrix);\r
+  fGenTrackNDEventMatrix->SetBinEdges(0,binsZv);\r
+  fGenTrackNDEventMatrix->SetBinEdges(1,binsPt);\r
+  fGenTrackNDEventMatrix->SetBinEdges(2,binsEta);\r
+  fGenTrackNDEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fGenTrackNDEventMatrix->GetAxis(1)->SetTitle("mcPt (GeV/c)");\r
+  fGenTrackNDEventMatrix->GetAxis(2)->SetTitle("mcEta");\r
+  fGenTrackNDEventMatrix->Sumw2();\r
+\r
+  fGenTrackNSDEventMatrix = new THnSparseF("fGenTrackNSDEventMatrix","mcZv:mcPt:mcEta",3,binsTrackMatrix);\r
+  fGenTrackNSDEventMatrix->SetBinEdges(0,binsZv);\r
+  fGenTrackNSDEventMatrix->SetBinEdges(1,binsPt);\r
+  fGenTrackNSDEventMatrix->SetBinEdges(2,binsEta);\r
+  fGenTrackNSDEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fGenTrackNSDEventMatrix->GetAxis(1)->SetTitle("mcPt (GeV/c)");\r
+  fGenTrackNSDEventMatrix->GetAxis(2)->SetTitle("mcEta");\r
+  fGenTrackNSDEventMatrix->Sumw2();\r
+\r
+\r
+  //\r
+  fTriggerTrackEventMatrix = new THnSparseF("fTriggerTrackEventMatrix","mcZv:mcPt:mcEta",3,binsTrackMatrix);\r
+  fTriggerTrackEventMatrix->SetBinEdges(0,binsZv);\r
+  fTriggerTrackEventMatrix->SetBinEdges(1,binsPt);\r
+  fTriggerTrackEventMatrix->SetBinEdges(2,binsEta);\r
+  fTriggerTrackEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fTriggerTrackEventMatrix->GetAxis(1)->SetTitle("mcPt (GeV/c)");\r
+  fTriggerTrackEventMatrix->GetAxis(2)->SetTitle("mcEta");\r
+  fTriggerTrackEventMatrix->Sumw2();\r
+\r
+  fTriggerTrackSDEventMatrix = new THnSparseF("fTriggerTrackSDEventMatrix","mcZv:mcPt:mcEta",3,binsTrackMatrix);\r
+  fTriggerTrackSDEventMatrix->SetBinEdges(0,binsZv);\r
+  fTriggerTrackSDEventMatrix->SetBinEdges(1,binsPt);\r
+  fTriggerTrackSDEventMatrix->SetBinEdges(2,binsEta);\r
+  fTriggerTrackSDEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fTriggerTrackSDEventMatrix->GetAxis(1)->SetTitle("mcPt (GeV/c)");\r
+  fTriggerTrackSDEventMatrix->GetAxis(2)->SetTitle("mcEta");\r
+  fTriggerTrackSDEventMatrix->Sumw2();\r
+\r
+  fTriggerTrackDDEventMatrix = new THnSparseF("fTriggerTrackDDEventMatrix","mcZv:mcPt:mcEta",3,binsTrackMatrix);\r
+  fTriggerTrackDDEventMatrix->SetBinEdges(0,binsZv);\r
+  fTriggerTrackDDEventMatrix->SetBinEdges(1,binsPt);\r
+  fTriggerTrackDDEventMatrix->SetBinEdges(2,binsEta);\r
+  fTriggerTrackDDEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fTriggerTrackDDEventMatrix->GetAxis(1)->SetTitle("mcPt (GeV/c)");\r
+  fTriggerTrackDDEventMatrix->GetAxis(2)->SetTitle("mcEta");\r
+  fTriggerTrackDDEventMatrix->Sumw2();\r
+\r
+  fTriggerTrackNDEventMatrix = new THnSparseF("fTriggerTrackNDEventMatrix","mcZv:mcPt:mcEta",3,binsTrackMatrix);\r
+  fTriggerTrackNDEventMatrix->SetBinEdges(0,binsZv);\r
+  fTriggerTrackNDEventMatrix->SetBinEdges(1,binsPt);\r
+  fTriggerTrackNDEventMatrix->SetBinEdges(2,binsEta);\r
+  fTriggerTrackNDEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fTriggerTrackNDEventMatrix->GetAxis(1)->SetTitle("mcPt (GeV/c)");\r
+  fTriggerTrackNDEventMatrix->GetAxis(2)->SetTitle("mcEta");\r
+  fTriggerTrackNDEventMatrix->Sumw2();\r
+\r
+  fTriggerTrackNSDEventMatrix = new THnSparseF("fTriggerTrackNSDEventMatrix","mcZv:mcPt:mcEta",3,binsTrackMatrix);\r
+  fTriggerTrackNSDEventMatrix->SetBinEdges(0,binsZv);\r
+  fTriggerTrackNSDEventMatrix->SetBinEdges(1,binsPt);\r
+  fTriggerTrackNSDEventMatrix->SetBinEdges(2,binsEta);\r
+  fTriggerTrackNSDEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fTriggerTrackNSDEventMatrix->GetAxis(1)->SetTitle("mcPt (GeV/c)");\r
+  fTriggerTrackNSDEventMatrix->GetAxis(2)->SetTitle("mcEta");\r
+  fTriggerTrackNSDEventMatrix->Sumw2();\r
+\r
+  //\r
+  fRecTrackEventMatrix = new THnSparseF("fRecTrackEventMatrix","mcZv:mcPt:mcEta",3,binsTrackMatrix);\r
+  fRecTrackEventMatrix->SetBinEdges(0,binsZv);\r
+  fRecTrackEventMatrix->SetBinEdges(1,binsPt);\r
+  fRecTrackEventMatrix->SetBinEdges(2,binsEta);\r
+  fRecTrackEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fRecTrackEventMatrix->GetAxis(1)->SetTitle("mcPt (GeV/c)");\r
+  fRecTrackEventMatrix->GetAxis(2)->SetTitle("mcEta");\r
+  fRecTrackEventMatrix->Sumw2();\r
+\r
+  fRecTrackSDEventMatrix = new THnSparseF("fRecTrackSDEventMatrix","mcZv:mcPt:mcEta",3,binsTrackMatrix);\r
+  fRecTrackSDEventMatrix->SetBinEdges(0,binsZv);\r
+  fRecTrackSDEventMatrix->SetBinEdges(1,binsPt);\r
+  fRecTrackSDEventMatrix->SetBinEdges(2,binsEta);\r
+  fRecTrackSDEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fRecTrackSDEventMatrix->GetAxis(1)->SetTitle("mcPt (GeV/c)");\r
+  fRecTrackSDEventMatrix->GetAxis(2)->SetTitle("mcEta");\r
+  fRecTrackSDEventMatrix->Sumw2();\r
+\r
+  fRecTrackDDEventMatrix = new THnSparseF("fRecTrackDDEventMatrix","mcZv:mcPt:mcEta",3,binsTrackMatrix);\r
+  fRecTrackDDEventMatrix->SetBinEdges(0,binsZv);\r
+  fRecTrackDDEventMatrix->SetBinEdges(1,binsPt);\r
+  fRecTrackDDEventMatrix->SetBinEdges(2,binsEta);\r
+  fRecTrackDDEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fRecTrackDDEventMatrix->GetAxis(1)->SetTitle("mcPt (GeV/c)");\r
+  fRecTrackDDEventMatrix->GetAxis(2)->SetTitle("mcEta");\r
+  fRecTrackDDEventMatrix->Sumw2();\r
+\r
+  fRecTrackNDEventMatrix = new THnSparseF("fRecTrackNDEventMatrix","mcZv:mcPt:mcEta",3,binsTrackMatrix);\r
+  fRecTrackNDEventMatrix->SetBinEdges(0,binsZv);\r
+  fRecTrackNDEventMatrix->SetBinEdges(1,binsPt);\r
+  fRecTrackNDEventMatrix->SetBinEdges(2,binsEta);\r
+  fRecTrackNDEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fRecTrackNDEventMatrix->GetAxis(1)->SetTitle("mcPt (GeV/c)");\r
+  fRecTrackNDEventMatrix->GetAxis(2)->SetTitle("mcEta");\r
+  fRecTrackNDEventMatrix->Sumw2();\r
+\r
+  fRecTrackNSDEventMatrix = new THnSparseF("fRecTrackNSDEventMatrix","mcZv:mcPt:mcEta",3,binsTrackMatrix);\r
+  fRecTrackNSDEventMatrix->SetBinEdges(0,binsZv);\r
+  fRecTrackNSDEventMatrix->SetBinEdges(1,binsPt);\r
+  fRecTrackNSDEventMatrix->SetBinEdges(2,binsEta);\r
+  fRecTrackNSDEventMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fRecTrackNSDEventMatrix->GetAxis(1)->SetTitle("mcPt (GeV/c)");\r
+  fRecTrackNSDEventMatrix->GetAxis(2)->SetTitle("mcEta");\r
+  fRecTrackNSDEventMatrix->Sumw2();\r
+\r
+  //\r
+  // tracks correction matrices\r
+  //\r
+  fGenPrimTrackMatrix = new THnSparseF("fGenPrimTrackMatrix","mcZv:mcPt:mcEta",3,binsTrackMatrix);\r
+  fGenPrimTrackMatrix->SetBinEdges(0,binsZv);\r
+  fGenPrimTrackMatrix->SetBinEdges(1,binsPt);\r
+  fGenPrimTrackMatrix->SetBinEdges(2,binsEta);\r
+  fGenPrimTrackMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fGenPrimTrackMatrix->GetAxis(1)->SetTitle("mcPt (GeV/c)");\r
+  fGenPrimTrackMatrix->GetAxis(2)->SetTitle("mcEta");\r
+  fGenPrimTrackMatrix->Sumw2();\r
+\r
+  fRecPrimTrackMatrix = new THnSparseF("fRecPrimTrackMatrix","mcZv:mcPt:mcEta",3,binsTrackMatrix);\r
+  fRecPrimTrackMatrix->SetBinEdges(0,binsZv);\r
+  fRecPrimTrackMatrix->SetBinEdges(1,binsPt);\r
+  fRecPrimTrackMatrix->SetBinEdges(2,binsEta);\r
+  fRecPrimTrackMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fRecPrimTrackMatrix->GetAxis(1)->SetTitle("mcPt (GeV/c)");\r
+  fRecPrimTrackMatrix->GetAxis(2)->SetTitle("mcEta");\r
+  fRecPrimTrackMatrix->Sumw2();\r
+\r
+  //\r
+  fRecTrackMatrix = new THnSparseF("fRecTrackMatrix","mcZv:mcPt:mcEta",3,binsTrackMatrix);\r
+  fRecTrackMatrix->SetBinEdges(0,binsZv);\r
+  fRecTrackMatrix->SetBinEdges(1,binsPt);\r
+  fRecTrackMatrix->SetBinEdges(2,binsEta);\r
+  fRecTrackMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fRecTrackMatrix->GetAxis(1)->SetTitle("Pt (GeV/c)");\r
+  fRecTrackMatrix->GetAxis(2)->SetTitle("Eta");\r
+  fRecTrackMatrix->Sumw2();\r
+\r
+  fRecSecTrackMatrix = new THnSparseF("fRecSecTrackMatrix","mcZv:mcPt:mcEta",3,binsTrackMatrix);\r
+  fRecSecTrackMatrix->SetBinEdges(0,binsZv);\r
+  fRecSecTrackMatrix->SetBinEdges(1,binsPt);\r
+  fRecSecTrackMatrix->SetBinEdges(2,binsEta);\r
+  fRecSecTrackMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fRecSecTrackMatrix->GetAxis(1)->SetTitle("Pt (GeV/c)");\r
+  fRecSecTrackMatrix->GetAxis(2)->SetTitle("Eta");\r
+  fRecSecTrackMatrix->Sumw2();\r
+\r
+  //\r
+  fRecMultTrackMatrix = new THnSparseF("fRecMultTrackMatrix","mcZv:mcPt:mcEta",3,binsTrackMatrix);\r
+  fRecMultTrackMatrix->SetBinEdges(0,binsZv);\r
+  fRecMultTrackMatrix->SetBinEdges(1,binsPt);\r
+  fRecMultTrackMatrix->SetBinEdges(2,binsEta);\r
+  fRecMultTrackMatrix->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fRecMultTrackMatrix->GetAxis(1)->SetTitle("mcPt (GeV/c)");\r
+  fRecMultTrackMatrix->GetAxis(2)->SetTitle("mcEta");\r
+  fRecMultTrackMatrix->Sumw2();\r
+\r
+  //\r
+  // Control analysis histograms\r
+  //\r
+\r
+  Int_t binsMCEventHist1[3]={100,100,140};\r
+  Double_t minMCEventHist1[3]={-0.1,-0.1,-35.}; \r
+  Double_t maxMCEventHist1[3]={0.1,0.1,35.}; \r
+  fMCEventHist1 = new THnSparseF("fMCEventHist1","mcXv:mcYv:mcZv",3,binsMCEventHist1,minMCEventHist1,maxMCEventHist1);\r
+  fMCEventHist1->GetAxis(0)->SetTitle("mcXv (cm)");\r
+  fMCEventHist1->GetAxis(1)->SetTitle("mcYv (cm)");\r
+  fMCEventHist1->GetAxis(2)->SetTitle("mcZv (cm)");\r
+  fMCEventHist1->Sumw2();\r
+\r
+  //\r
+  Int_t binsRecEventHist1[3]={100,100,140};\r
+  Double_t minRecEventHist1[3]={-3.,-3.,-35.}; \r
+  Double_t maxRecEventHist1[3]={3.,3.,35.}; \r
+  \r
+  fRecEventHist1 = new THnSparseF("fRecEventHist1","Xv:Yv:Zv",3,binsRecEventHist1,minRecEventHist1,maxRecEventHist1);\r
+  fRecEventHist1->GetAxis(0)->SetTitle("Xv (cm)");\r
+  fRecEventHist1->GetAxis(1)->SetTitle("Yv (cm)");\r
+  fRecEventHist1->GetAxis(2)->SetTitle("Zv (cm)");\r
+  fRecEventHist1->Sumw2();\r
+\r
+  //\r
+  Int_t binsRecEventHist2[2]={zvNbins,150};\r
+  Double_t minRecEventHist2[2]={-25.,-0.5}; \r
+  Double_t maxRecEventHist2[2]={25.,149.5}; \r
+  \r
+  fRecEventHist2 = new THnSparseF("fRecEventHist2","Zv:multMB",2,binsRecEventHist2,minRecEventHist2,maxRecEventHist2);\r
+  fRecEventHist2->SetBinEdges(0,binsZv);\r
+  fRecEventHist2->GetAxis(0)->SetTitle("Zv (cm)");\r
+  fRecEventHist2->GetAxis(1)->SetTitle("multMB");\r
+  fRecEventHist2->Sumw2();\r
+\r
+  //\r
+  Double_t kFact = 1.0;\r
+  if(GetAnalysisMode() == AlidNdPtHelper::kTPCSPDvtx) kFact = 0.05; \r
+\r
+  Int_t binsRecMCEventHist1[3]={100,100,100};\r
+  Double_t minRecMCEventHist1[3]={-10.0*kFact,-10.0*kFact,-10.0*kFact}; \r
+  Double_t maxRecMCEventHist1[3]={10.0*kFact,10.0*kFact,10.0*kFact}; \r
+   \r
+  fRecMCEventHist1 = new THnSparseF("fRecMCEventHist1","mcXv-Xv:mcYv-Yv:mcZv-Zv",3,binsRecMCEventHist1,minRecMCEventHist1,maxRecMCEventHist1);\r
+  fRecMCEventHist1->GetAxis(0)->SetTitle("mcXv-Xv (cm)");\r
+  fRecMCEventHist1->GetAxis(1)->SetTitle("mcYv-Yv (cm)");\r
+  fRecMCEventHist1->GetAxis(2)->SetTitle("mcZv-Zv (cm)");\r
+  fRecMCEventHist1->Sumw2();\r
+\r
+  //\r
+  Int_t binsRecMCEventHist2[3]={100,100,150};\r
+  Double_t minRecMCEventHist2[3]={-10.0*kFact,-10.0*kFact,0.0}; \r
+  Double_t maxRecMCEventHist2[3]={10.0*kFact,10.0*kFact,149.50}; \r
+\r
+  fRecMCEventHist2 = new THnSparseF("fRecMCEventHist2","mcXv-Xv:mcZv-Zv:Mult",3,binsRecMCEventHist2,minRecMCEventHist2,maxRecMCEventHist2);\r
+  fRecMCEventHist2->GetAxis(0)->SetTitle("mcXv-Xv (cm)");\r
+  fRecMCEventHist2->GetAxis(1)->SetTitle("mcZv-Zv (cm)");\r
+  fRecMCEventHist2->GetAxis(2)->SetTitle("Mult");\r
+  fRecMCEventHist2->Sumw2();\r
+\r
+  Int_t binsRecMCEventHist3[2]={150,5};\r
+  Double_t minRecMCEventHist3[2]={-0.5,0.0}; \r
+  Double_t maxRecMCEventHist3[2]={149.50,5.0}; \r
+  fRecMCEventHist3 = new THnSparseF("fRecMCEventHist3","Mult:EventType (ND, DD, SD)",2,binsRecMCEventHist3,minRecMCEventHist3,maxRecMCEventHist3);\r
+  fRecMCEventHist3->GetAxis(0)->SetTitle("Mult");\r
+  fRecMCEventHist3->GetAxis(1)->SetTitle("EventType");\r
+  fRecMCEventHist3->Sumw2();\r
+\r
+  //\r
+  char name[256];\r
+  char title[256];\r
+  for(Int_t i=0; i<AlidNdPtHelper::kCutSteps; i++) \r
+  {\r
+  // THnSparse track histograms\r
\r
+  Int_t binsMCTrackHist1[3]=  {ptNbins, etaNbins, 90};\r
+  Double_t minMCTrackHist1[3]={0.,-1.,0.}; \r
+  Double_t maxMCTrackHist1[3]={10.,1.,2.*TMath::Pi()}; \r
+  sprintf(name,"fMCTrackHist1_%d",i);\r
+  sprintf(title,"mcPt:mcEta:mcPhi");\r
+  \r
+  fMCTrackHist1[i] = new THnSparseF(name,title,3,binsMCTrackHist1,minMCTrackHist1,maxMCTrackHist1);\r
+  fMCTrackHist1[i]->SetBinEdges(0,binsPt);\r
+  fMCTrackHist1[i]->SetBinEdges(1,binsEta);\r
+  fMCTrackHist1[i]->GetAxis(0)->SetTitle("mcPt (GeV/c)");\r
+  fMCTrackHist1[i]->GetAxis(1)->SetTitle("mcEta");\r
+  fMCTrackHist1[i]->GetAxis(2)->SetTitle("mcPhi (rad)");\r
+  fMCTrackHist1[i]->Sumw2();\r
+\r
+  Int_t binsMCPrimTrackHist2[5]=  {ptNbins,etaNbins,6,20,4000};\r
+  Double_t minMCPrimTrackHist2[5]={0.,-1.,0.,0.,0.}; \r
+  Double_t maxMCPrimTrackHist2[5]={10.,1.,6.,20.,4000.}; \r
+  sprintf(name,"fMCPrimTrackHist1_%d",i);\r
+  sprintf(title,"mcPt:mcEta:pid:mech:mother");\r
+  \r
+  fMCPrimTrackHist1[i] = new THnSparseF(name,title,5,binsMCPrimTrackHist2,minMCPrimTrackHist2,maxMCPrimTrackHist2);\r
+  fMCPrimTrackHist1[i]->SetBinEdges(0,binsPt);\r
+  fMCPrimTrackHist1[i]->SetBinEdges(1,binsEta);\r
+  fMCPrimTrackHist1[i]->GetAxis(0)->SetTitle("mcPt (GeV/c)");\r
+  fMCPrimTrackHist1[i]->GetAxis(1)->SetTitle("mcEta");\r
+  fMCPrimTrackHist1[i]->GetAxis(2)->SetTitle("pid");\r
+  fMCPrimTrackHist1[i]->GetAxis(3)->SetTitle("mech");\r
+  fMCPrimTrackHist1[i]->GetAxis(4)->SetTitle("mother");\r
+  fMCPrimTrackHist1[i]->Sumw2();\r
+\r
+  Int_t binsMCSecTrackHist1[5]=  {ptNbins,etaNbins,6,20,4000};\r
+  Double_t minMCSecTrackHist1[5]={0.,-1.,0.,0.,0.}; \r
+  Double_t maxMCSecTrackHist1[5]={10.,1.,6.,20.,4000.}; \r
+  sprintf(name,"fMCSecTrackHist1_%d",i);\r
+  sprintf(title,"mcPt:mcEta:mcPhi:pid:mech:mother");\r
+  \r
+  fMCSecTrackHist1[i] = new THnSparseF(name,title,5,binsMCSecTrackHist1,minMCSecTrackHist1,maxMCSecTrackHist1);\r
+  fMCSecTrackHist1[i]->SetBinEdges(0,binsPt);\r
+  fMCSecTrackHist1[i]->SetBinEdges(1,binsEta);\r
+  fMCSecTrackHist1[i]->GetAxis(0)->SetTitle("mcPt (GeV/c)");\r
+  fMCSecTrackHist1[i]->GetAxis(1)->SetTitle("mcEta");\r
+  fMCSecTrackHist1[i]->GetAxis(2)->SetTitle("pid");\r
+  fMCSecTrackHist1[i]->GetAxis(3)->SetTitle("mech");\r
+  fMCSecTrackHist1[i]->GetAxis(4)->SetTitle("mother");\r
+  fMCSecTrackHist1[i]->Sumw2();\r
+\r
+  //\r
+\r
+  // \r
+  \r
+  Int_t binsRecTrackHist1[3]={ptNbins,etaNbins,90};\r
+  Double_t minRecTrackHist1[3]={0.,-1.,0.}; \r
+  Double_t maxRecTrackHist1[3]={10.,1.,2.*TMath::Pi()};\r
+  sprintf(name,"fRecTrackHist1_%d",i);\r
+  sprintf(title,"Pt:Eta:Phi");\r
+  fRecTrackHist1[i] = new THnSparseF(name,title,3,binsRecTrackHist1,minRecTrackHist1,maxRecTrackHist1);\r
+  fRecTrackHist1[i]->SetBinEdges(0,binsPt);\r
+  fRecTrackHist1[i]->SetBinEdges(1,binsEta);\r
+  fRecTrackHist1[i]->GetAxis(0)->SetTitle("Pt (GeV/c)");\r
+  fRecTrackHist1[i]->GetAxis(1)->SetTitle("Eta");\r
+  fRecTrackHist1[i]->GetAxis(2)->SetTitle("Phi (rad)");\r
+  fRecTrackHist1[i]->Sumw2();\r
+\r
+  // \r
+  Int_t binsRecTrackMultHist1[2]={ptNbins,150};\r
+  Double_t minRecTrackMultHist1[2]={0.,-0.5}; \r
+  Double_t maxRecTrackMultHist1[2]={10.,149.5};\r
+  sprintf(name,"fRecTrackMultHist_%d",i);\r
+  sprintf(title,"Pt:Mult");\r
+  fRecTrackMultHist1[i] = new THnSparseF(name,title,2,binsRecTrackMultHist1,minRecTrackMultHist1,maxRecTrackMultHist1);\r
+  fRecTrackMultHist1[i]->SetBinEdges(0,binsPt);\r
+  fRecTrackMultHist1[i]->GetAxis(0)->SetTitle("Pt (GeV/c)");\r
+  fRecTrackMultHist1[i]->GetAxis(1)->SetTitle("multiplicity");\r
+  fRecTrackMultHist1[i]->Sumw2();\r
+  }\r
+\r
+  Int_t binsRecMCTrackHist1[4] = {ptNbins,etaNbins,100,100};\r
+  Double_t minRecMCTrackHist1[4]={0.,-1.,-0.5,-0.5}; \r
+  Double_t maxRecMCTrackHist1[4]={20.,1.,0.5,0.5}; \r
+  sprintf(name,"fRecMCTrackHist1");\r
+  sprintf(title,"mcPt:mcEta:(Pt-mcPt)/mcPt:(Eta-mcEta)");\r
+  fRecMCTrackHist1 = new THnSparseF(name,title,4,binsRecMCTrackHist1,minRecMCTrackHist1,maxRecMCTrackHist1);\r
+  fRecMCTrackHist1->SetBinEdges(0,binsPt);\r
+  fRecMCTrackHist1->SetBinEdges(1,binsEta);\r
+  fRecMCTrackHist1->GetAxis(0)->SetTitle("mcPt (GeV/c)");\r
+  fRecMCTrackHist1->GetAxis(1)->SetTitle("mcEta");\r
+  fRecMCTrackHist1->GetAxis(2)->SetTitle("(Pt-mcPt)/mcPt");\r
+  fRecMCTrackHist1->GetAxis(3)->SetTitle("Eta-mcEta");\r
+\r
+  Int_t binsMCMultRecTrackHist1[3] = {ptNbins,etaNbins,6};\r
+  Double_t minMCMultRecTrackHist1[3]={0.,-1.,0.}; \r
+  Double_t maxMCMultRecTrackHist1[3]={20.,1.,6.}; \r
+  sprintf(name,"fMCMultRecTrackHist1");\r
+  sprintf(title,"mcPt:mcEta:pid");\r
+  fMCMultRecTrackHist1 = new THnSparseF(name,title,3,binsMCMultRecTrackHist1,minMCMultRecTrackHist1,maxMCMultRecTrackHist1);\r
+  fMCMultRecTrackHist1->SetBinEdges(0,binsPt);\r
+  fMCMultRecTrackHist1->SetBinEdges(1,binsEta);\r
+  fMCMultRecTrackHist1->GetAxis(0)->SetTitle("mcPt (GeV/c)");\r
+  fMCMultRecTrackHist1->GetAxis(1)->SetTitle("mcEta");\r
+  fMCMultRecTrackHist1->GetAxis(2)->SetTitle("pid");\r
+\r
+  // init folder\r
+  fAnalysisFolder = CreateFolder("folderdNdPt","Analysis dNdPt Folder");\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AlidNdPtAnalysis::Process(AliESDEvent *const esdEvent, AliMCEvent *const mcEvent)\r
+{\r
+  //\r
+  // Process real and/or simulated events\r
+  //\r
+  if(!esdEvent) {\r
+    AliDebug(AliLog::kError, "esdEvent not available");\r
+    return;\r
+  }\r
+  // trigger definition\r
+  Bool_t isEventTriggered = AlidNdPtHelper::IsEventTriggered(esdEvent->GetTriggerMask(), GetTrigger());\r
+  //if(!isEventTriggered) printf("no MB1 trigger ... \n");\r
+  //\r
+\r
+  // cuts\r
+  AlidNdPtEventCuts *evtCuts = GetEventCuts(); \r
+  AlidNdPtAcceptanceCuts *accCuts = GetAcceptanceCuts(); \r
+  AliESDtrackCuts *esdTrackCuts = GetTrackCuts(); \r
+\r
+  if(!evtCuts || !accCuts  || !esdTrackCuts) {\r
+    AliDebug(AliLog::kError, "cuts not available");\r
+    return;\r
+  }\r
+  //if(!evtCuts->IsTriggerRequired()) isEventTriggered = kTRUE;\r
+\r
+  // use MC information\r
+  AliHeader* header = 0;\r
+  AliGenEventHeader* genHeader = 0;\r
+  AliStack* stack = 0;\r
+  TArrayF vtxMC(3);\r
+  AlidNdPtHelper::MCProcessType evtType = AlidNdPtHelper::kInvalidProcess;\r
+\r
+  Int_t multMCTrueTracks = 0;\r
+  if(IsUseMCInfo())\r
+  {\r
+    //\r
+    if(!mcEvent) {\r
+      AliDebug(AliLog::kError, "mcEvent not available");\r
+      return;\r
+    }\r
+    // get MC event header\r
+    header = mcEvent->Header();\r
+    if (!header) {\r
+      AliDebug(AliLog::kError, "Header not available");\r
+      return;\r
+    }\r
+    // MC particle stack\r
+    stack = mcEvent->Stack();\r
+    if (!stack) {\r
+      AliDebug(AliLog::kError, "Stack not available");\r
+      return;\r
+    }\r
+    // get event type (ND=0x1, DD=0x2, SD=0x4)\r
+    evtType = AlidNdPtHelper::GetEventProcessType(header);\r
+    AliDebug(AliLog::kDebug+1, Form("Found process type %d", evtType));\r
+\r
+    // get MC vertex\r
+    genHeader = header->GenEventHeader();\r
+    if (!genHeader) {\r
+      AliDebug(AliLog::kError, "Could not retrieve genHeader from Header");\r
+      return;\r
+    }\r
+    genHeader->PrimaryVertex(vtxMC);\r
+\r
+    Double_t vMCEventHist1[3]={vtxMC[0],vtxMC[1],vtxMC[2]};\r
+    fMCEventHist1->Fill(vMCEventHist1);\r
+\r
+    // multipliticy of all MC primary tracks\r
+    // in Zv, pt and eta ranges)\r
+    multMCTrueTracks = AlidNdPtHelper::GetMCTrueTrackMult(mcEvent,evtCuts,accCuts);\r
+\r
+  } // end bUseMC\r
+\r
+  // get reconstructed vertex  \r
+  const AliESDVertex* vtxESD = 0; \r
+  Bool_t isRecVertex = kFALSE;\r
+  if(evtCuts->IsRecVertexRequired()) \r
+  {\r
+    vtxESD = AlidNdPtHelper::GetVertex(esdEvent, evtCuts,  accCuts, esdTrackCuts, GetAnalysisMode(), kFALSE, kTRUE, kTRUE);\r
+    isRecVertex = AlidNdPtHelper::TestVertex(vtxESD, GetAnalysisMode(), kFALSE); // should be moved to AcceptEvent\r
+  }\r
+  if( IsUseMCInfo() && !evtCuts->IsRecVertexRequired() ) {\r
+    vtxESD = new AliESDVertex(vtxMC[2],10.,genHeader->NProduced(),"smearMC");\r
+    isRecVertex = kTRUE;\r
+  }\r
+  Bool_t isEventOK = evtCuts->AcceptEvent(esdEvent,mcEvent,vtxESD) && isRecVertex; \r
+  //printf("isEventOK %d \n",isEventOK);\r
+\r
+  // MB bias tracks\r
+  Int_t multMBTracks = 0; \r
+  if(GetAnalysisMode() == AlidNdPtHelper::kTPC || GetAnalysisMode() == AlidNdPtHelper::kMCPion ||  \r
+     GetAnalysisMode() == AlidNdPtHelper::kMCKaon ||  GetAnalysisMode() == AlidNdPtHelper::kMCProton || \r
+     GetAnalysisMode() ==AlidNdPtHelper::kPlus || GetAnalysisMode() ==AlidNdPtHelper::kMinus) {  \r
+\r
+     multMBTracks = AlidNdPtHelper::GetTPCMBTrackMult(esdEvent,evtCuts,accCuts,esdTrackCuts);\r
+  } \r
+  else if(GetAnalysisMode() == AlidNdPtHelper::kTPCSPDvtx || GetAnalysisMode() == AlidNdPtHelper::kMCPion || \r
+          GetAnalysisMode() == AlidNdPtHelper::kMCKaon || GetAnalysisMode() == AlidNdPtHelper::kMCProton || \r
+         GetAnalysisMode() ==AlidNdPtHelper::kPlus || GetAnalysisMode() == AlidNdPtHelper::kMinus) {\r
+\r
+           multMBTracks = AlidNdPtHelper::GetSPDMBTrackMult(esdEvent,0.0);\r
+  } \r
+  else {\r
+    AliDebug(AliLog::kError, Form("Found analysis type %s", GetAnalysisMode()));\r
+    return; \r
+  }\r
\r
+  TObjArray *allChargedTracks=0;\r
+  Int_t multAll=0, multAcc=0, multRec=0;\r
+  Int_t *labelsAll=0, *labelsAcc=0, *labelsRec=0;\r
+\r
+  // check event cuts\r
+  if(isEventOK && isEventTriggered)\r
+  {\r
+    // get all charged tracks\r
+    allChargedTracks = AlidNdPtHelper::GetAllChargedTracks(esdEvent,vtxESD,GetAnalysisMode());\r
+    if(!allChargedTracks) return;\r
+\r
+    Int_t entries = allChargedTracks->GetEntries();\r
+    labelsAll = new Int_t[entries];\r
+    labelsAcc = new Int_t[entries];\r
+    labelsRec = new Int_t[entries];\r
+    for(Int_t i=0; i<entries;++i) \r
+    {\r
+      AliESDtrack *track = (AliESDtrack*)allChargedTracks->At(i);\r
+      if(!track) continue;\r
+      if(track->Charge()==0) continue;\r
+        \r
+       FillHistograms(track,stack,AlidNdPtHelper::kAllTracks); \r
+       labelsAll[multAll] = TMath::Abs(track->GetLabel());\r
+       multAll++;\r
+\r
+       if(accCuts->AcceptTrack(track)) {\r
+         FillHistograms(track,stack,AlidNdPtHelper::kAccTracks); \r
+        labelsAcc[multAcc] = TMath::Abs(track->GetLabel());\r
+        multAcc++;\r
+\r
+         if(esdTrackCuts->AcceptTrack(track)) {\r
+           FillHistograms(track,stack,AlidNdPtHelper::kRecTracks); \r
+          labelsRec[multRec] = TMath::Abs(track->GetLabel());\r
+          multRec++;\r
+         }\r
+       }\r
+     } \r
+     // fill track multiplicity histograms\r
+     FillHistograms(allChargedTracks,labelsAll,multAll,labelsAcc,multAcc,labelsRec,multRec);\r
+\r
+     Double_t vRecEventHist1[3] = {vtxESD->GetXv(),vtxESD->GetYv(),vtxESD->GetZv()};\r
+     fRecEventHist1->Fill(vRecEventHist1);\r
+\r
+     Double_t vRecEventHist2[2] = {vtxESD->GetZv(),multMBTracks};\r
+     fRecEventHist2->Fill(vRecEventHist2);\r
+   } \r
+\r
+   //\r
+   // Determine correction matrices\r
+   //\r
+   if(IsUseMCInfo())  \r
+   {\r
+     //\r
+     // multiplicity correlation matrix\r
+     //\r
+     Double_t vMultTrueEventMatrix[2] = {multRec,multMCTrueTracks};\r
+     fEventMultCorrelationMatrix->Fill(vMultTrueEventMatrix);\r
+\r
+     // \r
+     // event level corrections (zv,N_MB)\r
+     //\r
+\r
+     // all inelastic\r
+     Double_t vEventMatrix[2] = {vtxMC[2],multMBTracks};\r
+     fGenEventMatrix->Fill(vEventMatrix); \r
+     if(isEventTriggered) fTriggerEventMatrix->Fill(vEventMatrix);\r
+     if(isEventOK && isEventTriggered) fRecEventMatrix->Fill(vEventMatrix);\r
+\r
+     // single diffractive\r
+     if(evtType == AlidNdPtHelper::kSD) {\r
+       fGenSDEventMatrix->Fill(vEventMatrix); \r
+       if(isEventTriggered) fTriggerSDEventMatrix->Fill(vEventMatrix);\r
+       if(isEventOK && isEventTriggered) fRecSDEventMatrix->Fill(vEventMatrix);\r
+     }\r
+\r
+     // double diffractive\r
+     if(evtType == AlidNdPtHelper::kDD) {\r
+       fGenDDEventMatrix->Fill(vEventMatrix); \r
+       if(isEventTriggered) fTriggerDDEventMatrix->Fill(vEventMatrix);\r
+       if(isEventOK && isEventTriggered)  fRecDDEventMatrix->Fill(vEventMatrix);\r
+     }\r
+\r
+     // non diffractive\r
+     if(evtType == AlidNdPtHelper::kND) {\r
+       fGenNDEventMatrix->Fill(vEventMatrix); \r
+       if(isEventTriggered) fTriggerNDEventMatrix->Fill(vEventMatrix);\r
+       if(isEventOK && isEventTriggered) fRecNDEventMatrix->Fill(vEventMatrix);\r
+     }\r
+\r
+     // non single diffractive\r
+     if(evtType != AlidNdPtHelper::kSD) {\r
+       fGenNSDEventMatrix->Fill(vEventMatrix); \r
+       if(isEventTriggered) fTriggerNSDEventMatrix->Fill(vEventMatrix);\r
+       if(isEventOK && isEventTriggered) fRecNSDEventMatrix->Fill(vEventMatrix);\r
+     }\r
+\r
+     //\r
+     // track-event level corrections (zv,pt,eta)\r
+     //\r
+     Int_t nPart  = stack->GetNtrack();\r
+     for (Int_t iMc = 0; iMc < nPart; ++iMc) \r
+     {\r
+       TParticle* particle = stack->Particle(iMc);\r
+       if (!particle)\r
+       continue;\r
+\r
+       // only charged particles\r
+       Double_t charge = particle->GetPDG()->Charge()/3.;\r
+       if (charge == 0.0)\r
+        continue;\r
+\r
+       // only postive charged \r
+       if(GetAnalysisMode() == AlidNdPtHelper::kPlus && charge < 0.) \r
+        continue;\r
+       \r
+       // only negative charged \r
+       if(GetAnalysisMode() == AlidNdPtHelper::kMinus && charge > 0.) \r
+       continue;\r
+      \r
+       // physical primary\r
+       Bool_t prim = stack->IsPhysicalPrimary(iMc);\r
+       if(!prim) continue;\r
+\r
+       // checked accepted\r
+       if(accCuts->AcceptTrack(particle)) \r
+       {\r
+         Double_t vTrackEventMatrix[3] = {vtxMC[2], particle->Pt(), particle->Eta()}; \r
+         fGenTrackEventMatrix->Fill(vTrackEventMatrix);\r
+\r
+         if(evtType == AlidNdPtHelper::kSD) {\r
+           fGenTrackSDEventMatrix->Fill(vTrackEventMatrix);\r
+        }\r
+         if(evtType == AlidNdPtHelper::kDD) {\r
+           fGenTrackDDEventMatrix->Fill(vTrackEventMatrix);\r
+        }\r
+         if(evtType == AlidNdPtHelper::kND) {\r
+           fGenTrackNDEventMatrix->Fill(vTrackEventMatrix);\r
+        }\r
+         if(evtType != AlidNdPtHelper::kSD) {\r
+           fGenTrackNSDEventMatrix->Fill(vTrackEventMatrix);\r
+        }\r
+\r
+         //\r
+         if(!isEventTriggered) continue;  \r
+\r
+         fTriggerTrackEventMatrix->Fill(vTrackEventMatrix);\r
+         if(evtType == AlidNdPtHelper::kSD) {\r
+           fTriggerTrackSDEventMatrix->Fill(vTrackEventMatrix);\r
+        }\r
+         if(evtType == AlidNdPtHelper::kDD) {\r
+           fTriggerTrackDDEventMatrix->Fill(vTrackEventMatrix);\r
+        }\r
+         if(evtType == AlidNdPtHelper::kND) {\r
+           fTriggerTrackNDEventMatrix->Fill(vTrackEventMatrix);\r
+        }\r
+         if(evtType != AlidNdPtHelper::kSD) {\r
+           fTriggerTrackNSDEventMatrix->Fill(vTrackEventMatrix);\r
+        }\r
+\r
+         //\r
+        if(!isEventOK) continue;  \r
+\r
+         fRecTrackEventMatrix->Fill(vTrackEventMatrix);\r
+         if(evtType == AlidNdPtHelper::kSD) {\r
+           fRecTrackSDEventMatrix->Fill(vTrackEventMatrix);\r
+        }\r
+         if(evtType == AlidNdPtHelper::kDD) {\r
+           fRecTrackDDEventMatrix->Fill(vTrackEventMatrix);\r
+        }\r
+         if(evtType == AlidNdPtHelper::kND) {\r
+           fRecTrackNDEventMatrix->Fill(vTrackEventMatrix);\r
+        }\r
+         if(evtType != AlidNdPtHelper::kSD) {\r
+           fRecTrackNSDEventMatrix->Fill(vTrackEventMatrix);\r
+        }\r
+       }\r
+     }\r
+\r
+     // \r
+     // track-level corrections (zv,pt.eta)\r
+     //\r
+     if(isEventOK && isEventTriggered)\r
+     {\r
+\r
+       // fill MC and rec event control histograms\r
+       if(fHistogramsOn) {\r
+         Double_t vRecMCEventHist1[3] = {vtxMC[0]-vtxESD->GetXv(),vtxMC[1]-vtxESD->GetYv(),vtxMC[2]-vtxESD->GetZv()};\r
+         fRecMCEventHist1->Fill(vRecMCEventHist1);\r
+\r
+         Double_t vRecMCEventHist2[3] = {vtxMC[0]-vtxESD->GetXv(),vtxMC[2]-vtxESD->GetZv(),multMBTracks};\r
+         fRecMCEventHist2->Fill(vRecMCEventHist2);\r
+\r
+         Double_t vRecMCEventHist3[2] = {multRec,evtType};\r
+         fRecMCEventHist3->Fill(vRecMCEventHist3);\r
+       }\r
+\r
+       //\r
+       // MC histograms for track efficiency studies\r
+       //\r
+       Int_t nPart  = stack->GetNtrack();\r
+       for (Int_t iMc = 0; iMc < nPart; ++iMc) \r
+       {\r
+         TParticle* particle = stack->Particle(iMc);\r
+         if (!particle)\r
+         continue;\r
+\r
+         // only charged particles\r
+         Double_t charge = particle->GetPDG()->Charge()/3.;\r
+         if (charge == 0.0)\r
+         continue;\r
+\r
+         // only postive charged \r
+         if(GetAnalysisMode() == AlidNdPtHelper::kPlus && charge < 0.) \r
+        continue;\r
+       \r
+         // only negative charged \r
+         if(GetAnalysisMode() == AlidNdPtHelper::kMinus && charge > 0.) \r
+        continue;\r
+      \r
+         // physical primary\r
+         Bool_t prim = stack->IsPhysicalPrimary(iMc);\r
+\r
+         // check accepted\r
+         if(accCuts->AcceptTrack(particle)) \r
+        {\r
+           Double_t vTrackMatrix[3] = {vtxMC[2],particle->Pt(),particle->Eta()}; \r
+           //if(prim) fGenPrimTrackMatrix->Fill(vTrackMatrix);\r
+           if( AlidNdPtHelper::IsPrimaryParticle(stack, iMc, GetAnalysisMode()) ) fGenPrimTrackMatrix->Fill(vTrackMatrix);\r
+\r
+          // fill control histograms\r
+           if(fHistogramsOn) \r
+            FillHistograms(stack,iMc,AlidNdPtHelper::kAccTracks); \r
+\r
+           // check multiple found tracks\r
+          Int_t mult_count = 0;\r
+           for(Int_t iRec=0; iRec<multRec; ++iRec)\r
+           {\r
+             if(iMc == labelsRec[iRec]) \r
+            {\r
+              mult_count++;\r
+              if(mult_count>1)\r
+              {  \r
+                 fRecMultTrackMatrix->Fill(vTrackMatrix);\r
+\r
+                 // fill control histogram\r
+                 if(fHistogramsOn) {\r
+                   Int_t pid = AlidNdPtHelper::ConvertPdgToPid(particle);\r
+                   Double_t vMCMultRecTrackHist1[3] = {particle->Pt(), particle->Eta(), pid};\r
+                  fMCMultRecTrackHist1->Fill(vMCMultRecTrackHist1);\r
+                }\r
+              }\r
+            }\r
+          }\r
+\r
+           // check reconstructed\r
+           for(Int_t iRec=0; iRec<multRec; ++iRec)\r
+           {\r
+             if(iMc == labelsRec[iRec]) \r
+            {\r
+               fRecTrackMatrix->Fill(vTrackMatrix);\r
+               if( AlidNdPtHelper::IsPrimaryParticle(stack, iMc, GetAnalysisMode()) ) fRecPrimTrackMatrix->Fill(vTrackMatrix);\r
+               if(!prim) fRecSecTrackMatrix->Fill(vTrackMatrix);\r
+\r
+              // fill control histograms\r
+               if(fHistogramsOn) \r
+                 FillHistograms(stack,iMc,AlidNdPtHelper::kRecTracks); \r
+             \r
+               break;\r
+             }\r
+           }\r
+         }\r
+       }\r
+     }\r
+   } // end bUseMC\r
+\r
+  if(allChargedTracks) delete allChargedTracks; allChargedTracks = 0;\r
+  if(labelsAll) delete [] labelsAll; labelsAll = 0;\r
+  if(labelsAcc) delete [] labelsAcc; labelsAcc = 0;\r
+  if(labelsRec) delete [] labelsRec; labelsRec = 0;\r
+\r
+  if(!evtCuts->IsRecVertexRequired() && vtxESD != NULL) delete vtxESD;\r
+\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AlidNdPtAnalysis::FillHistograms(TObjArray *const allChargedTracks,Int_t *const labelsAll,Int_t multAll,Int_t *const labelsAcc,Int_t multAcc,Int_t *const labelsRec,Int_t multRec) {\r
+ // multiplicity  histograms\r
\r
+  if(!allChargedTracks) return;\r
+  if(!labelsAll) return;\r
+  if(!labelsAcc) return;\r
+  if(!labelsRec) return;\r
+\r
+  Int_t entries = allChargedTracks->GetEntries();\r
+  for(Int_t i=0; i<entries; ++i)\r
+  {\r
+     AliESDtrack *track = (AliESDtrack*)allChargedTracks->At(i);\r
+     if(!track) continue;\r
+     if(track->Charge() == 0) continue;\r
+\r
+     Int_t label = TMath::Abs(track->GetLabel());\r
+     for(Int_t iAll=0; iAll<multAll; ++iAll) {\r
+       if(label == labelsAll[iAll]) {\r
+         Double_t v1[2] = {track->Pt(), multAll}; \r
+         fRecTrackMultHist1[AlidNdPtHelper::kAllTracks]->Fill(v1);\r
+       }\r
+     }\r
+     for(Int_t iAcc=0; iAcc<multAcc; ++iAcc) {\r
+       if(label == labelsAcc[iAcc]) {\r
+         Double_t v2[2] = {track->Pt(), multAcc}; \r
+         fRecTrackMultHist1[AlidNdPtHelper::kAccTracks]->Fill(v2);\r
+       }\r
+     }\r
+     for(Int_t iRec=0; iRec<multRec; ++iRec) {\r
+       if(label == labelsRec[iRec]) {\r
+         Double_t v3[2] = {track->Pt(), multRec}; \r
+         fRecTrackMultHist1[AlidNdPtHelper::kRecTracks]->Fill(v3);\r
+       }\r
+     }\r
+  }\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AlidNdPtAnalysis::FillHistograms(AliESDtrack *const esdTrack, AliStack *const stack, AlidNdPtHelper::TrackObject trackObj)\r
+{\r
+  //\r
+  // Fill ESD track and MC histograms \r
+  //\r
+  if(!esdTrack) return;\r
+\r
+  Float_t q = esdTrack->Charge();\r
+  if(q==0) return;\r
+\r
+  Float_t pt = esdTrack->Pt();\r
+  //Float_t qpt = esdTrack->Pt() * q;\r
+  Float_t eta = esdTrack->Eta();\r
+  Float_t phi = esdTrack->Phi();\r
+\r
+  Float_t dca[2], bCov[3];\r
+  esdTrack->GetImpactParameters(dca,bCov);\r
+\r
+\r
+  // fill histograms\r
+  Double_t values[3] = {pt,eta,phi};     \r
+  fRecTrackHist1[trackObj]->Fill(values);\r
\r
+  //\r
+  // Fill rec vs MC information\r
+  //\r
+  if(!stack) return;\r
+\r
+  Int_t label = TMath::Abs(esdTrack->GetLabel()); \r
+  //if(label == 0) return;\r
+\r
+  TParticle* particle = stack->Particle(label);\r
+  if(!particle) return;\r
+\r
+  //Bool_t prim = stack->IsPhysicalPrimary(label);\r
+  //Int_t pid = AlidNdPtHelper::ConvertPdgToPid(particle);\r
+\r
+  Int_t mother_pdg = -1;\r
+  TParticle* mother = 0;\r
+\r
+  //TParticle* prim_mother = AlidNdPtHelper::FindPrimaryMother(stack,label);\r
+  Int_t motherLabel = particle->GetMother(0); \r
+  if(motherLabel>0) mother = stack->Particle(motherLabel);\r
+  if(mother) mother_pdg = TMath::Abs(mother->GetPdgCode()); // take abs for visualisation only\r
+  //Int_t mech = particle->GetUniqueID(); // production mechanism\r
+\r
+  Double_t gq = particle->GetPDG()->Charge()/3.0; // Charge units |e|/3 \r
+  if(gq==0) return;\r
+  Float_t gpt = particle->Pt();\r
+  Float_t geta = particle->Eta();\r
+  //Float_t qgpt = particle->Pt() * gq;\r
+  //Float_t gphi = particle->Phi();\r
+\r
+  Double_t dpt=0;\r
+  if(gpt) dpt = (pt-gpt)/gpt;\r
+  Double_t deta = (eta-geta);\r
\r
+  // fill histograms\r
+  if(trackObj == AlidNdPtHelper::kRecTracks)  \r
+  {\r
+    Double_t vTrackPtCorrelationMatrix[3]={pt,gpt,geta};\r
+    fTrackPtCorrelationMatrix->Fill(vTrackPtCorrelationMatrix);\r
+\r
+    Double_t vRecMCTrackHist1[4]={gpt,geta,dpt,deta};\r
+    fRecMCTrackHist1->Fill(vRecMCTrackHist1);\r
+\r
+  }\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AlidNdPtAnalysis::FillHistograms(AliStack *const stack, Int_t label, AlidNdPtHelper::TrackObject trackObj)\r
+{\r
+  // Fill MC histograms\r
+  if(!stack) return;\r
+\r
+  TParticle* particle = stack->Particle(label);\r
+  if(!particle) return;\r
+\r
+  Int_t mother_pdg = -1;\r
+  TParticle* mother = 0;\r
+\r
+  //TParticle* prim_mother = AlidNdPtHelper::FindPrimaryMother(stack,label);\r
+  Int_t motherLabel = particle->GetMother(0); \r
+  if(motherLabel>0) mother = stack->Particle(motherLabel);\r
+  if(mother) mother_pdg = TMath::Abs(mother->GetPdgCode()); // take abs for visualisation only\r
+  Int_t mech = particle->GetUniqueID(); // production mechanism\r
+\r
+  Double_t gq = particle->GetPDG()->Charge()/3.0; // Charge units |e|/3 \r
+  if(gq == 0) return;\r
+  Float_t gpt = particle->Pt();\r
+  //Float_t qgpt = particle->Pt() * gq;\r
+  Float_t geta = particle->Eta();\r
+  Float_t gphi = particle->Phi();\r
+  //Float_t gpz = particle->Pz();\r
+\r
+  Bool_t prim = stack->IsPhysicalPrimary(label);\r
+  //Float_t vx = particle->Vx(); Float_t vy = particle->Vy(); Float_t vz = particle->Vz();\r
+\r
+  Int_t pid = AlidNdPtHelper::ConvertPdgToPid(particle);\r
+\r
+  //if(prim&&pid==5) printf("pdgcode %d, production mech %d \n",particle->GetPdgCode(),mech);\r
+  //if(!prim) printf("mother_pdg %d, particle %d, production mech %d\n",mother_pdg, particle->GetPdgCode(),mech);\r
+  \r
+  //\r
+  // fill histogram\r
+  //\r
+  Double_t vMCTrackHist1[3] = {gpt,geta,gphi};\r
+  fMCTrackHist1[trackObj]->Fill(vMCTrackHist1);\r
+\r
+  Double_t vMCPrimTrackHist1[5] = {gpt,geta,pid,mech,mother_pdg};\r
+  if(prim) fMCPrimTrackHist1[trackObj]->Fill(vMCPrimTrackHist1);\r
+  else     { \r
+         fMCSecTrackHist1[trackObj]->Fill(vMCPrimTrackHist1);\r
+  }\r
+}\r
+\r
+//_____________________________________________________________________________\r
+Long64_t AlidNdPtAnalysis::Merge(TCollection* list) \r
+{\r
+  // Merge list of objects (needed by PROOF)\r
+\r
+  if (!list)\r
+  return 0;\r
+\r
+  if (list->IsEmpty())\r
+  return 1;\r
+\r
+  TIterator* iter = list->MakeIterator();\r
+  TObject* obj = 0;\r
+\r
+  // collection of generated histograms\r
+\r
+  Int_t count=0;\r
+  while((obj = iter->Next()) != 0) {\r
+    AlidNdPtAnalysis* entry = dynamic_cast<AlidNdPtAnalysis*>(obj);\r
+    if (entry == 0) continue; \r
+\r
+    //\r
+    fEventMultCorrelationMatrix->Add(entry->fEventMultCorrelationMatrix);\r
+    fTrackPtCorrelationMatrix->Add(entry->fTrackPtCorrelationMatrix);\r
+\r
+    //\r
+    fGenEventMatrix->Add(entry->fGenEventMatrix);\r
+    fGenSDEventMatrix->Add(entry->fGenSDEventMatrix);\r
+    fGenDDEventMatrix->Add(entry->fGenDDEventMatrix);\r
+    fGenNDEventMatrix->Add(entry->fGenNDEventMatrix);\r
+    fGenNSDEventMatrix->Add(entry->fGenNSDEventMatrix);\r
+\r
+    fTriggerEventMatrix->Add(entry->fTriggerEventMatrix);\r
+    fTriggerSDEventMatrix->Add(entry->fTriggerSDEventMatrix);\r
+    fTriggerDDEventMatrix->Add(entry->fTriggerDDEventMatrix);\r
+    fTriggerNDEventMatrix->Add(entry->fTriggerNDEventMatrix);\r
+    fTriggerNSDEventMatrix->Add(entry->fTriggerNSDEventMatrix);\r
+\r
+    fRecEventMatrix->Add(entry->fRecEventMatrix);\r
+    fRecSDEventMatrix->Add(entry->fRecSDEventMatrix);\r
+    fRecDDEventMatrix->Add(entry->fRecDDEventMatrix);\r
+    fRecNDEventMatrix->Add(entry->fRecNDEventMatrix);\r
+    fRecNSDEventMatrix->Add(entry->fRecNSDEventMatrix);\r
+\r
+    //\r
+    fGenTrackEventMatrix->Add(entry->fGenTrackEventMatrix);\r
+    fGenTrackSDEventMatrix->Add(entry->fGenTrackSDEventMatrix);\r
+    fGenTrackDDEventMatrix->Add(entry->fGenTrackDDEventMatrix);\r
+    fGenTrackNDEventMatrix->Add(entry->fGenTrackNDEventMatrix);\r
+    fGenTrackNSDEventMatrix->Add(entry->fGenTrackNSDEventMatrix);\r
+\r
+    fTriggerTrackEventMatrix->Add(entry->fTriggerTrackEventMatrix);\r
+    fTriggerTrackSDEventMatrix->Add(entry->fTriggerTrackSDEventMatrix);\r
+    fTriggerTrackDDEventMatrix->Add(entry->fTriggerTrackDDEventMatrix);\r
+    fTriggerTrackNDEventMatrix->Add(entry->fTriggerTrackNDEventMatrix);\r
+    fTriggerTrackNSDEventMatrix->Add(entry->fTriggerTrackNSDEventMatrix);\r
+\r
+    fRecTrackEventMatrix->Add(entry->fRecTrackEventMatrix);\r
+    fRecTrackSDEventMatrix->Add(entry->fRecTrackSDEventMatrix);\r
+    fRecTrackDDEventMatrix->Add(entry->fRecTrackDDEventMatrix);\r
+    fRecTrackNDEventMatrix->Add(entry->fRecTrackNDEventMatrix);\r
+    fRecTrackNSDEventMatrix->Add(entry->fRecTrackNSDEventMatrix);\r
+\r
+    //\r
+    fGenPrimTrackMatrix->Add(entry->fGenPrimTrackMatrix);\r
+    fRecPrimTrackMatrix->Add(entry->fRecPrimTrackMatrix);\r
+    //\r
+    fRecTrackMatrix->Add(entry->fRecTrackMatrix);\r
+    fRecSecTrackMatrix->Add(entry->fRecSecTrackMatrix);\r
+    //\r
+    fRecMultTrackMatrix->Add(entry->fRecMultTrackMatrix);\r
+\r
+    //\r
+    // control analysis histograms\r
+    //\r
+    fMCEventHist1->Add(entry->fMCEventHist1);\r
+    fRecEventHist1->Add(entry->fRecEventHist1);\r
+    fRecEventHist2->Add(entry->fRecEventHist2);\r
+    fRecMCEventHist1->Add(entry->fRecMCEventHist1);\r
+    fRecMCEventHist2->Add(entry->fRecMCEventHist2);\r
+    fRecMCEventHist3->Add(entry->fRecMCEventHist3);\r
+\r
+    for(Int_t i=0; i<AlidNdPtHelper::kCutSteps; i++) {\r
+      fMCTrackHist1[i]->Add(entry->fMCTrackHist1[i]);\r
+\r
+      fMCPrimTrackHist1[i]->Add(entry->fMCPrimTrackHist1[i]);\r
+      fMCSecTrackHist1[i]->Add(entry->fMCSecTrackHist1[i]);\r
+\r
+      fRecTrackHist1[i]->Add(entry->fRecTrackHist1[i]);\r
+      fRecTrackMultHist1[i]->Add(entry->fRecTrackMultHist1[i]);\r
+    }\r
+    fRecMCTrackHist1->Add(entry->fRecMCTrackHist1);\r
+    fMCMultRecTrackHist1->Add(entry->fMCMultRecTrackHist1);\r
+\r
+  count++;\r
+  }\r
+\r
+return count;\r
+}\r
\r
+//_____________________________________________________________________________\r
+void AlidNdPtAnalysis::Analyse() \r
+{\r
+  // Analyse histograms\r
+  //\r
+  TH1::AddDirectory(kFALSE);\r
+  TH1 *h=0, *h1=0, *h2=0, *h2c = 0; \r
+  TH2D *hgen2D=0;\r
+  THnSparse *hs=0; \r
+  TH2 *h2D=0; \r
+  TH1 *h1D=0; \r
+\r
+  char name[256];\r
+  TObjArray *aFolderObj = new TObjArray;\r
+\r
+  //\r
+  // get cuts\r
+  //\r
+  AlidNdPtEventCuts *evtCuts = GetEventCuts(); \r
+  AlidNdPtAcceptanceCuts *accCuts = GetAcceptanceCuts(); \r
+  AliESDtrackCuts *esdTrackCuts = GetTrackCuts(); \r
+\r
+  if(!evtCuts || !accCuts || !esdTrackCuts) {\r
+    Error("AlidNdPtCutAnalysis::Analyse()", "cuts not available");\r
+    return;\r
+  }\r
+\r
+  //\r
+  // set min and max values\r
+  //\r
+  Double_t minZv = evtCuts->GetMinZv();\r
+  Double_t maxZv = evtCuts->GetMaxZv()-0.00001;\r
+  Double_t minPt = accCuts->GetMinPt();\r
+  Double_t maxPt = accCuts->GetMaxPt();\r
+  Double_t minEta = accCuts->GetMinEta();\r
+  Double_t maxEta = accCuts->GetMaxEta()-0.00001;\r
+\r
+  //\r
+  // calculate corrections for empty events\r
+  // with multMB==0 \r
+  //\r
+\r
+  //\r
+  // normalised zv to generate zv for triggered events\r
+  //\r
+  h = fRecEventHist2->Projection(0);\r
+  if( h->Integral() ) h->Scale(1./h->Integral());\r
+  h->SetName("zv_distribution_norm");\r
+  aFolderObj->Add(h);\r
+\r
+  //\r
+  // normalised zv to get trigger/trigger+vertex event differences\r
+  // F(zv) = E_trig(zv,0)/Int(E_trig(zv,0) / Sum(E_trigvtx(zv,n))/Sum(Int(E_trigvtx(zv,n))dzv)\r
+  //\r
+  fTriggerEventMatrix->GetAxis(1)->SetRangeUser(0.,0.);\r
+  h = fTriggerEventMatrix->Projection(0);\r
+  hgen2D = fTriggerEventMatrix->Projection(0,1);\r
+  if(hgen2D->Integral()) h->Scale(1./hgen2D->Integral());\r
+\r
+  h1 = fRecEventMatrix->Projection(0);\r
+  hgen2D = fRecEventMatrix->Projection(0,1);\r
+  if(hgen2D->Integral()) h1->Scale(1./hgen2D->Integral());\r
+\r
+  h->Divide(h1);\r
+  h->SetName("zv_empty_events_norm");\r
+  aFolderObj->Add(h);\r
+  \r
+  fTriggerEventMatrix->GetAxis(1)->SetRange(1,fTriggerEventMatrix->GetAxis(1)->GetNbins());\r
+\r
+  //\r
+  // rec. vs true multiplicity correlation matrix\r
+  //\r
+  hs = (THnSparse*)fEventMultCorrelationMatrix->Clone("event_mult_correlation_matrix");\r
+  aFolderObj->Add(hs);\r
\r
+  //\r
+  // rec. vs true track pt correlation matrix\r
+  //\r
+  hs = (THnSparse*)fTrackPtCorrelationMatrix->Clone("track_pt_correlation_matrix");\r
+  aFolderObj->Add(hs);\r
+\r
+  //\r
+  // trigger efficiency for INEL\r
+  //\r
+  h1D = AlidNdPtHelper::GenerateCorrMatrix(fTriggerEventMatrix->Projection(0),fGenEventMatrix->Projection(0),"zv_trig_INEL_eff_matrix");\r
+  aFolderObj->Add(h1D);\r
+\r
+  //\r
+  // trigger efficiency for NSD\r
+  //\r
+  h1D = AlidNdPtHelper::GenerateCorrMatrix(fTriggerNSDEventMatrix->Projection(0),fGenNSDEventMatrix->Projection(0),"zv_trig_NSD_eff_matrix");\r
+  aFolderObj->Add(h1D);\r
+\r
+  //\r
+  // trigger bias correction (MB to ND)\r
+  //\r
+  hs = AlidNdPtHelper::GenerateCorrMatrix(fGenNDEventMatrix,fTriggerEventMatrix,"zv_mult_trig_MBtoND_corr_matrix");\r
+  aFolderObj->Add(hs);\r
+\r
+  h1D = AlidNdPtHelper::GenerateCorrMatrix(fGenNDEventMatrix->Projection(0),fTriggerEventMatrix->Projection(0),"zv_trig_MBtoND_corr_matrix");\r
+  aFolderObj->Add(h1D);\r
+\r
+  fGenNDEventMatrix->GetAxis(0)->SetRangeUser(minZv,maxZv);\r
+  fTriggerEventMatrix->GetAxis(0)->SetRangeUser(minZv,maxZv);\r
+\r
+  h1D = AlidNdPtHelper::GenerateCorrMatrix(fGenNDEventMatrix->Projection(1),fTriggerEventMatrix->Projection(1),"mult_trig_MBtoND_corr_matrix");\r
+\r
+  aFolderObj->Add(h1D);\r
+  fGenNDEventMatrix->GetAxis(0)->SetRange(1,fGenNDEventMatrix->GetAxis(0)->GetNbins());\r
+  fTriggerEventMatrix->GetAxis(0)->SetRange(1,fTriggerEventMatrix->GetAxis(0)->GetNbins());\r
+\r
+  //\r
+  // trigger bias correction (MB to NSD)\r
+  //\r
+  hs = AlidNdPtHelper::GenerateCorrMatrix(fGenNSDEventMatrix,fTriggerEventMatrix,"zv_mult_trig_MBtoNSD_corr_matrix");\r
+  aFolderObj->Add(hs);\r
+\r
+  h2D = AlidNdPtHelper::GenerateCorrMatrix(fGenNSDEventMatrix->Projection(0,1),fTriggerEventMatrix->Projection(0,1),"zv_mult_trig_MBtoNSD_corr_matrix_2D");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h1D = AlidNdPtHelper::GenerateCorrMatrix(fGenNSDEventMatrix->Projection(0),fTriggerEventMatrix->Projection(0),"zv_trig_MBtoNSD_corr_matrix");\r
+  aFolderObj->Add(h1D);\r
+\r
+  fGenNSDEventMatrix->GetAxis(0)->SetRangeUser(minZv,maxZv);\r
+  fTriggerEventMatrix->GetAxis(0)->SetRangeUser(minZv,maxZv);\r
+\r
+  h1D = AlidNdPtHelper::GenerateCorrMatrix(fGenNSDEventMatrix->Projection(1),fTriggerEventMatrix->Projection(1),"mult_trig_MBtoNSD_corr_matrix");\r
+  aFolderObj->Add(h1D);\r
+\r
+  fGenNSDEventMatrix->GetAxis(0)->SetRange(1,fGenNSDEventMatrix->GetAxis(0)->GetNbins());\r
+  fTriggerEventMatrix->GetAxis(0)->SetRange(1,fTriggerEventMatrix->GetAxis(0)->GetNbins());\r
+\r
+  //\r
+  // trigger bias correction (MB to INEL)\r
+  //\r
+  hs = AlidNdPtHelper::GenerateCorrMatrix(fGenEventMatrix,fTriggerEventMatrix,"zv_mult_trig_MBtoInel_corr_matrix");\r
+  aFolderObj->Add(hs);\r
+\r
+  h1D = AlidNdPtHelper::GenerateCorrMatrix(fGenEventMatrix->Projection(0),fTriggerEventMatrix->Projection(0),"zv_trig_MBtoInel_corr_matrix");\r
+  aFolderObj->Add(h1D);\r
+\r
+  h2D = AlidNdPtHelper::GenerateCorrMatrix(fGenEventMatrix->Projection(0,1),fTriggerEventMatrix->Projection(0,1),"zv_mult_trig_MBtoInel_corr_matrix_2D");\r
+  aFolderObj->Add(h2D);\r
+\r
+  fGenEventMatrix->GetAxis(0)->SetRangeUser(minZv,maxZv);\r
+  fTriggerEventMatrix->GetAxis(0)->SetRangeUser(minZv,maxZv);\r
+\r
+  h1D = AlidNdPtHelper::GenerateCorrMatrix(fGenEventMatrix->Projection(1),fTriggerEventMatrix->Projection(1),"mult_trig_MBtoInel_corr_matrix");\r
+  aFolderObj->Add(h1D);\r
+\r
+  fGenEventMatrix->GetAxis(0)->SetRange(1,fGenEventMatrix->GetAxis(0)->GetNbins());\r
+  fTriggerEventMatrix->GetAxis(0)->SetRange(1,fTriggerEventMatrix->GetAxis(0)->GetNbins());\r
+\r
+  //\r
+  // event vertex reconstruction correction (MB)\r
+  //\r
+  hs = AlidNdPtHelper::GenerateCorrMatrix(fTriggerEventMatrix,fRecEventMatrix,"zv_mult_event_corr_matrix");\r
+  aFolderObj->Add(hs);\r
+\r
+  h2D = AlidNdPtHelper::GenerateCorrMatrix(fTriggerEventMatrix->Projection(0,1),fRecEventMatrix->Projection(0,1),"zv_mult_event_corr_matrix_2D");\r
+  aFolderObj->Add(h2D);\r
+\r
+  fTriggerEventMatrix->GetAxis(0)->SetRangeUser(minZv,maxZv);\r
+  fRecEventMatrix->GetAxis(0)->SetRangeUser(minZv,maxZv);\r
+\r
+  h1D = AlidNdPtHelper::GenerateCorrMatrix(fTriggerEventMatrix->Projection(1),fRecEventMatrix->Projection(1),"mult_event_corr_matrix");\r
+  aFolderObj->Add(h1D);\r
+\r
+  fTriggerEventMatrix->GetAxis(0)->SetRange(1,fTriggerEventMatrix->GetAxis(0)->GetNbins());\r
+  fRecEventMatrix->GetAxis(0)->SetRange(1,fRecEventMatrix->GetAxis(0)->GetNbins());\r
+\r
+  h1D = AlidNdPtHelper::GenerateCorrMatrix(fTriggerEventMatrix->Projection(0),fRecEventMatrix->Projection(0),"zv_event_corr_matrix");\r
+  aFolderObj->Add(h1D);\r
+\r
+  //\r
+  // track-event trigger bias correction (MB to ND)\r
+  //\r
+\r
+  hs = AlidNdPtHelper::GenerateCorrMatrix(fGenTrackNDEventMatrix,fTriggerTrackEventMatrix,"zv_pt_eta_track_trig_MBtoND_corr_matrix");\r
+  aFolderObj->Add(hs);\r
+\r
+  h2D = AlidNdPtHelper::GenerateCorrMatrix(fGenTrackNDEventMatrix->Projection(1,2),fTriggerTrackEventMatrix->Projection(1,2),"eta_pt_track_trig_MBtoND_corr_matrix");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = AlidNdPtHelper::GenerateCorrMatrix(fGenTrackNDEventMatrix->Projection(1,0),fTriggerTrackEventMatrix->Projection(1,0),"pt_zv_track_trig_MBtoND_corr_matrix");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = AlidNdPtHelper::GenerateCorrMatrix(fGenTrackNDEventMatrix->Projection(2,0),fTriggerTrackEventMatrix->Projection(2,0),"zv_eta_track_trig_MBtoND_corr_matrix");\r
+  aFolderObj->Add(h2D);\r
+\r
+  //\r
+  // track-event trigger bias correction (MB to NSD)\r
+  //\r
+  hs = AlidNdPtHelper::GenerateCorrMatrix(fGenTrackNSDEventMatrix,fTriggerTrackEventMatrix,"zv_pt_eta_track_trig_MBtoNSD_corr_matrix");\r
+  aFolderObj->Add(hs);\r
+\r
+  h2D = AlidNdPtHelper::GenerateCorrMatrix(fGenTrackNSDEventMatrix->Projection(1,2),fTriggerTrackEventMatrix->Projection(1,2),"eta_pt_track_trig_MBtoNSD_corr_matrix");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = AlidNdPtHelper::GenerateCorrMatrix(fGenTrackNSDEventMatrix->Projection(1,0),fTriggerTrackEventMatrix->Projection(1,0),"pt_zv_track_trig_MBtoNSD_corr_matrix");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = AlidNdPtHelper::GenerateCorrMatrix(fGenTrackNSDEventMatrix->Projection(2,0),fTriggerTrackEventMatrix->Projection(2,0),"zv_eta_track_trig_MBtoNSD_corr_matrix");\r
+  aFolderObj->Add(h2D);\r
+\r
+\r
+  //\r
+  // track-event trigger bias correction (MB to INEL)\r
+  //\r
+  hs = AlidNdPtHelper::GenerateCorrMatrix(fGenTrackEventMatrix,fTriggerTrackEventMatrix,"zv_pt_eta_track_trig_MBtoInel_corr_matrix");\r
+  aFolderObj->Add(hs);\r
+\r
+  h2D = AlidNdPtHelper::GenerateCorrMatrix(fGenTrackEventMatrix->Projection(1,2),fTriggerTrackEventMatrix->Projection(1,2),"eta_pt_track_trig_MBtoInel_corr_matrix");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = AlidNdPtHelper::GenerateCorrMatrix(fGenTrackEventMatrix->Projection(1,0),fTriggerTrackEventMatrix->Projection(1,0),"pt_zv_track_trig_MBtoInel_corr_matrix");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = AlidNdPtHelper::GenerateCorrMatrix(fGenTrackEventMatrix->Projection(2,0),fTriggerTrackEventMatrix->Projection(2,0),"zv_eta_track_trig_MBtoInel_corr_matrix");\r
+  aFolderObj->Add(h2D);\r
+\r
+  // efficiency\r
+  fTriggerTrackEventMatrix->GetAxis(2)->SetRangeUser(minEta,maxEta);\r
+  fGenTrackEventMatrix->GetAxis(2)->SetRangeUser(minEta,maxEta);\r
+  fTriggerTrackEventMatrix->GetAxis(0)->SetRangeUser(minZv,maxZv);\r
+  fGenTrackEventMatrix->GetAxis(0)->SetRangeUser(minZv,maxZv);\r
+\r
+  h1D = AlidNdPtHelper::GenerateCorrMatrix(fTriggerTrackEventMatrix->Projection(1),fGenTrackEventMatrix->Projection(1),"pt_track_trig_MBtoInel_eff_matrix");\r
+  aFolderObj->Add(h1D);\r
+\r
+  fTriggerTrackEventMatrix->GetAxis(2)->SetRange(1,fTriggerTrackEventMatrix->GetAxis(2)->GetNbins());\r
+  fGenTrackEventMatrix->GetAxis(2)->SetRange(1,fGenTrackEventMatrix->GetAxis(2)->GetNbins());\r
+  fTriggerTrackEventMatrix->GetAxis(0)->SetRange(1,fTriggerTrackEventMatrix->GetAxis(0)->GetNbins());\r
+  fGenTrackEventMatrix->GetAxis(0)->SetRange(1,fGenTrackEventMatrix->GetAxis(0)->GetNbins());\r
+\r
+\r
+  //\r
+  // track-event vertex reconstruction correction (MB)\r
+  //\r
+  hs = AlidNdPtHelper::GenerateCorrMatrix(fTriggerTrackEventMatrix,fRecTrackEventMatrix,"zv_pt_eta_track_event_corr_matrix");\r
+  aFolderObj->Add(hs);\r
+\r
+  h2D = AlidNdPtHelper::GenerateCorrMatrix(fTriggerTrackEventMatrix->Projection(1,2),fRecTrackEventMatrix->Projection(1,2),"eta_pt_track_event_corr_matrix");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = AlidNdPtHelper::GenerateCorrMatrix(fTriggerTrackEventMatrix->Projection(1,0),fRecTrackEventMatrix->Projection(1,0),"pt_zv_track_event_corr_matrix");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = AlidNdPtHelper::GenerateCorrMatrix(fTriggerTrackEventMatrix->Projection(2,0),fRecTrackEventMatrix->Projection(2,0),"zv_eta_track_event_corr_matrix");\r
+  aFolderObj->Add(h2D);\r
+  \r
+  // efficiency\r
+  fTriggerTrackEventMatrix->GetAxis(2)->SetRangeUser(minEta,maxEta);\r
+  fRecTrackEventMatrix->GetAxis(2)->SetRangeUser(minEta,maxEta);\r
+  fTriggerTrackEventMatrix->GetAxis(0)->SetRangeUser(minZv,maxZv);\r
+  fRecTrackEventMatrix->GetAxis(0)->SetRangeUser(minZv,maxZv);\r
+\r
+  h1D = AlidNdPtHelper::GenerateCorrMatrix(fRecTrackEventMatrix->Projection(1),fTriggerTrackEventMatrix->Projection(1),"pt_track_event_eff_matrix");\r
+  aFolderObj->Add(h1D);\r
+\r
+  fTriggerTrackEventMatrix->GetAxis(2)->SetRange(1,fTriggerTrackEventMatrix->GetAxis(2)->GetNbins());\r
+  fRecTrackEventMatrix->GetAxis(2)->SetRange(1,fRecTrackEventMatrix->GetAxis(2)->GetNbins());\r
+  fTriggerTrackEventMatrix->GetAxis(0)->SetRange(1,fTriggerTrackEventMatrix->GetAxis(0)->GetNbins());\r
+  fRecTrackEventMatrix->GetAxis(0)->SetRange(1,fRecTrackEventMatrix->GetAxis(0)->GetNbins());\r
+\r
+  //\r
+  // track rec. efficiency correction\r
+  //\r
+  hs = AlidNdPtHelper::GenerateCorrMatrix(fGenPrimTrackMatrix,fRecPrimTrackMatrix,"zv_pt_eta_track_corr_matrix");\r
+  aFolderObj->Add(hs);\r
+\r
+  h2D = AlidNdPtHelper::GenerateCorrMatrix(fGenPrimTrackMatrix->Projection(1,2),fRecPrimTrackMatrix->Projection(1,2),"eta_pt_track_corr_matrix");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = AlidNdPtHelper::GenerateCorrMatrix(fGenPrimTrackMatrix->Projection(1,0),fRecPrimTrackMatrix->Projection(1,0),"pt_zv_track_corr_matrix");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = AlidNdPtHelper::GenerateCorrMatrix(fGenPrimTrackMatrix->Projection(2,0),fRecPrimTrackMatrix->Projection(2,0),"zv_eta_track_corr_matrix");\r
+  aFolderObj->Add(h2D);\r
+\r
+  fGenPrimTrackMatrix->GetAxis(2)->SetRangeUser(minEta,maxEta);\r
+  fRecPrimTrackMatrix->GetAxis(2)->SetRangeUser(minEta,maxEta);\r
+  fGenPrimTrackMatrix->GetAxis(1)->SetRangeUser(minPt,maxPt);\r
+  fRecPrimTrackMatrix->GetAxis(1)->SetRangeUser(minPt,maxPt);\r
+  \r
+  h1D = AlidNdPtHelper::GenerateCorrMatrix(fGenPrimTrackMatrix->Projection(0),fRecPrimTrackMatrix->Projection(0),"zv_track_corr_matrix");\r
+  aFolderObj->Add(h1D);\r
+\r
+  fGenPrimTrackMatrix->GetAxis(1)->SetRange(1,fGenPrimTrackMatrix->GetAxis(1)->GetNbins());\r
+  fRecPrimTrackMatrix->GetAxis(1)->SetRange(1,fRecPrimTrackMatrix->GetAxis(1)->GetNbins());\r
+  fGenPrimTrackMatrix->GetAxis(0)->SetRangeUser(minZv,maxZv);\r
+  fRecPrimTrackMatrix->GetAxis(0)->SetRangeUser(minZv,maxZv);\r
+\r
+  h1D = AlidNdPtHelper::GenerateCorrMatrix(fGenPrimTrackMatrix->Projection(1),fRecPrimTrackMatrix->Projection(1),"pt_track_corr_matrix");\r
+  aFolderObj->Add(h1D);\r
+\r
+  // efficiency\r
+  h1D = AlidNdPtHelper::GenerateCorrMatrix(fRecPrimTrackMatrix->Projection(1), fGenPrimTrackMatrix->Projection(1),"pt_track_eff_matrix");\r
+  aFolderObj->Add(h1D);\r
+\r
+  fGenPrimTrackMatrix->GetAxis(1)->SetRangeUser(minPt,maxPt);\r
+  fRecPrimTrackMatrix->GetAxis(1)->SetRangeUser(minPt,maxPt);\r
+  fGenPrimTrackMatrix->GetAxis(2)->SetRange(1,fGenPrimTrackMatrix->GetAxis(2)->GetNbins());\r
+  fRecPrimTrackMatrix->GetAxis(2)->SetRange(1,fRecPrimTrackMatrix->GetAxis(2)->GetNbins());\r
+\r
+  h1D = AlidNdPtHelper::GenerateCorrMatrix(fGenPrimTrackMatrix->Projection(2),fRecPrimTrackMatrix->Projection(2),"eta_track_corr_matrix");\r
+  aFolderObj->Add(h1D);\r
+\r
+  fGenPrimTrackMatrix->GetAxis(1)->SetRange(1,fGenPrimTrackMatrix->GetAxis(1)->GetNbins());\r
+  fRecPrimTrackMatrix->GetAxis(1)->SetRange(1,fRecPrimTrackMatrix->GetAxis(1)->GetNbins());\r
+  fGenPrimTrackMatrix->GetAxis(0)->SetRange(1,fGenPrimTrackMatrix->GetAxis(0)->GetNbins());\r
+  fRecPrimTrackMatrix->GetAxis(0)->SetRange(1,fRecPrimTrackMatrix->GetAxis(0)->GetNbins());\r
+\r
+  //\r
+  // secondary track contamination correction\r
+  //\r
+  //hs = AlidNdPtHelper::GenerateContCorrMatrix(fRecSecTrackMatrix,fRecTrackMatrix,"zv_pt_eta_track_cont_matrix");\r
+  hs = AlidNdPtHelper::GenerateCorrMatrix(fRecSecTrackMatrix,fRecTrackMatrix,"zv_pt_eta_track_cont_matrix");\r
+  aFolderObj->Add(hs);\r
+\r
+  h2D = AlidNdPtHelper::GenerateCorrMatrix(fRecSecTrackMatrix->Projection(1,2),fRecTrackMatrix->Projection(1,2),"eta_pt_track_cont_matrix");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = AlidNdPtHelper::GenerateCorrMatrix(fRecSecTrackMatrix->Projection(1,0),fRecTrackMatrix->Projection(1,0),"pt_zv_track_cont_matrix");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = AlidNdPtHelper::GenerateCorrMatrix(fRecSecTrackMatrix->Projection(2,0),fRecTrackMatrix->Projection(2,0),"zv_eta_track_cont_matrix");\r
+  aFolderObj->Add(h2D);\r
+\r
+  fRecSecTrackMatrix->GetAxis(2)->SetRangeUser(minEta,maxEta);\r
+  fRecTrackMatrix->GetAxis(2)->SetRangeUser(minEta,maxEta);\r
+  fRecSecTrackMatrix->GetAxis(1)->SetRangeUser(minPt,maxPt);\r
+  fRecTrackMatrix->GetAxis(1)->SetRangeUser(minPt,maxPt);\r
+  \r
+  h1D = AlidNdPtHelper::GenerateCorrMatrix(fRecSecTrackMatrix->Projection(0),fRecTrackMatrix->Projection(0),"zv_track_cont_matrix");\r
+  aFolderObj->Add(h1D);\r
+\r
+  fRecSecTrackMatrix->GetAxis(1)->SetRange(1,fRecSecTrackMatrix->GetAxis(1)->GetNbins());\r
+  fRecTrackMatrix->GetAxis(1)->SetRange(1,fRecTrackMatrix->GetAxis(1)->GetNbins());\r
+  fRecSecTrackMatrix->GetAxis(0)->SetRangeUser(minZv,maxZv);\r
+  fRecTrackMatrix->GetAxis(0)->SetRangeUser(minZv,maxZv);\r
+\r
+  h1D = AlidNdPtHelper::GenerateCorrMatrix(fRecSecTrackMatrix->Projection(1),fRecTrackMatrix->Projection(1),"pt_track_cont_matrix");\r
+  aFolderObj->Add(h1D);\r
+\r
+  fRecSecTrackMatrix->GetAxis(2)->SetRange(1,fRecSecTrackMatrix->GetAxis(2)->GetNbins());\r
+  fRecTrackMatrix->GetAxis(2)->SetRange(1,fRecTrackMatrix->GetAxis(2)->GetNbins());\r
+\r
+  fRecSecTrackMatrix->GetAxis(1)->SetRangeUser(minPt,maxPt);\r
+  fRecTrackMatrix->GetAxis(1)->SetRangeUser(minPt,maxPt);\r
+\r
+  h1D = AlidNdPtHelper::GenerateCorrMatrix(fRecSecTrackMatrix->Projection(2),fRecTrackMatrix->Projection(2),"eta_track_cont_matrix");\r
+  aFolderObj->Add(h1D);\r
+\r
+  fRecSecTrackMatrix->GetAxis(0)->SetRange(1,fRecSecTrackMatrix->GetAxis(0)->GetNbins());\r
+  fRecTrackMatrix->GetAxis(0)->SetRange(1,fRecTrackMatrix->GetAxis(0)->GetNbins());\r
+  fRecSecTrackMatrix->GetAxis(1)->SetRange(1,fRecSecTrackMatrix->GetAxis(1)->GetNbins());\r
+  fRecTrackMatrix->GetAxis(1)->SetRange(1,fRecTrackMatrix->GetAxis(1)->GetNbins());\r
+\r
+  //\r
+  // multiple track reconstruction correction\r
+  //\r
+  //hs = AlidNdPtHelper::GenerateContCorrMatrix(fRecMultTrackMatrix,fRecTrackMatrix,"zv_pt_eta_mult_track_cont_matrix");\r
+  hs = AlidNdPtHelper::GenerateCorrMatrix(fRecMultTrackMatrix,fRecTrackMatrix,"zv_pt_eta_mult_track_cont_matrix");\r
+  aFolderObj->Add(hs);\r
+\r
+  h2D = AlidNdPtHelper::GenerateCorrMatrix(fRecMultTrackMatrix->Projection(1,2),fRecTrackMatrix->Projection(1,2),"eta_pt_mult_track_cont_matrix");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = AlidNdPtHelper::GenerateCorrMatrix(fRecMultTrackMatrix->Projection(1,0),fRecTrackMatrix->Projection(1,0),"pt_zv_mult_track_cont_matrix");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = AlidNdPtHelper::GenerateCorrMatrix(fRecMultTrackMatrix->Projection(2,0),fRecTrackMatrix->Projection(2,0),"zv_eta_mult_track_cont_matrix");\r
+  aFolderObj->Add(h2D);\r
+\r
+  fRecMultTrackMatrix->GetAxis(2)->SetRangeUser(minEta,maxEta);\r
+  fRecTrackMatrix->GetAxis(2)->SetRangeUser(minEta,maxEta);\r
+  fRecMultTrackMatrix->GetAxis(1)->SetRangeUser(minPt,maxPt);\r
+  fRecTrackMatrix->GetAxis(1)->SetRangeUser(minPt,maxPt);\r
+  \r
+  h1D = AlidNdPtHelper::GenerateCorrMatrix(fRecMultTrackMatrix->Projection(0),fRecTrackMatrix->Projection(0),"zv_mult_track_cont_matrix");\r
+  aFolderObj->Add(h1D);\r
+\r
+  fRecMultTrackMatrix->GetAxis(1)->SetRangeUser(0.,maxPt);\r
+  fRecTrackMatrix->GetAxis(1)->SetRangeUser(0.,maxPt);\r
+  fRecMultTrackMatrix->GetAxis(0)->SetRangeUser(minZv,maxZv);\r
+  fRecTrackMatrix->GetAxis(0)->SetRangeUser(minZv,maxZv);\r
+\r
+  h1D = AlidNdPtHelper::GenerateCorrMatrix(fRecMultTrackMatrix->Projection(1),fRecTrackMatrix->Projection(1),"pt_mult_track_cont_matrix");\r
+  aFolderObj->Add(h1D);\r
+\r
+  fRecMultTrackMatrix->GetAxis(1)->SetRangeUser(minPt,maxPt);\r
+  fRecTrackMatrix->GetAxis(1)->SetRangeUser(minPt,maxPt);\r
+\r
+  fRecMultTrackMatrix->GetAxis(2)->SetRange(1,fRecMultTrackMatrix->GetAxis(2)->GetNbins());\r
+  fRecTrackMatrix->GetAxis(2)->SetRange(1,fRecTrackMatrix->GetAxis(2)->GetNbins());\r
+\r
+  h1D = AlidNdPtHelper::GenerateCorrMatrix(fRecMultTrackMatrix->Projection(2),fRecTrackMatrix->Projection(2),"eta_mult_track_cont_matrix");\r
+  aFolderObj->Add(h1D);\r
+\r
+  fRecMultTrackMatrix->GetAxis(1)->SetRangeUser(0.,maxPt);\r
+  fRecTrackMatrix->GetAxis(1)->SetRangeUser(0.,maxPt);\r
+\r
+  fRecMultTrackMatrix->GetAxis(0)->SetRange(1,fRecMultTrackMatrix->GetAxis(0)->GetNbins());\r
+  fRecTrackMatrix->GetAxis(0)->SetRange(1,fRecTrackMatrix->GetAxis(0)->GetNbins());\r
+\r
+  //\r
+  // Control histograms\r
+  //\r
+  \r
+  if(fHistogramsOn) {\r
+\r
+  // Efficiency electrons, muons, pions, kaons, protons, all\r
+  fMCPrimTrackHist1[1]->GetAxis(2)->SetRange(1,1); \r
+  fMCPrimTrackHist1[2]->GetAxis(2)->SetRange(1,1); \r
+  h1 = fMCPrimTrackHist1[1]->Projection(0);\r
+  h2 = fMCPrimTrackHist1[2]->Projection(0);\r
+  h2c = (TH1D *)h2->Clone();\r
+  h2c->Divide(h1);\r
+  h2c->SetName("eff_pt_electrons");\r
+  aFolderObj->Add(h2c);\r
+\r
+  fMCPrimTrackHist1[1]->GetAxis(2)->SetRange(2,2); \r
+  fMCPrimTrackHist1[2]->GetAxis(2)->SetRange(2,2); \r
+  h1 = fMCPrimTrackHist1[1]->Projection(0);\r
+  h2 = fMCPrimTrackHist1[2]->Projection(0);\r
+  h2c = (TH1D *)h2->Clone();\r
+  h2c->Divide(h1);\r
+  h2c->SetName("eff_pt_muons");\r
+  aFolderObj->Add(h2c);\r
+\r
+  fMCPrimTrackHist1[1]->GetAxis(2)->SetRange(3,3); \r
+  fMCPrimTrackHist1[2]->GetAxis(2)->SetRange(3,3); \r
+  h1 = fMCPrimTrackHist1[1]->Projection(0);\r
+  h2 = fMCPrimTrackHist1[2]->Projection(0);\r
+  h2c = (TH1D *)h2->Clone();\r
+  h2c->Divide(h1);\r
+  h2c->SetName("eff_pt_pions");\r
+  aFolderObj->Add(h2c);\r
+\r
+  fMCPrimTrackHist1[1]->GetAxis(2)->SetRange(4,4); \r
+  fMCPrimTrackHist1[2]->GetAxis(2)->SetRange(4,4); \r
+  h1 = fMCPrimTrackHist1[1]->Projection(0);\r
+  h2 = fMCPrimTrackHist1[2]->Projection(0);\r
+  h2c = (TH1D *)h2->Clone();\r
+  h2c->Divide(h1);\r
+  h2c->SetName("eff_pt_kaons");\r
+  aFolderObj->Add(h2c);\r
+\r
+  fMCPrimTrackHist1[1]->GetAxis(2)->SetRange(5,5); \r
+  fMCPrimTrackHist1[2]->GetAxis(2)->SetRange(5,5); \r
+  h1 = fMCPrimTrackHist1[1]->Projection(0);\r
+  h2 = fMCPrimTrackHist1[2]->Projection(0);\r
+  h2c = (TH1D *)h2->Clone();\r
+  h2c->Divide(h1);\r
+  h2c->SetName("eff_pt_protons");\r
+  aFolderObj->Add(h2c);\r
+\r
+  fMCPrimTrackHist1[1]->GetAxis(2)->SetRange(1,6); \r
+  fMCPrimTrackHist1[2]->GetAxis(2)->SetRange(1,6); \r
+  h1 = fMCPrimTrackHist1[1]->Projection(0);\r
+  h2 = fMCPrimTrackHist1[2]->Projection(0);\r
+  h2c = (TH1D *)h2->Clone();\r
+  h2c->Divide(h1);\r
+  h2c->SetName("eff_pt_all");\r
+  aFolderObj->Add(h2c);\r
+\r
+  //  pt spetra\r
+  // - rec, primaries, secondaries\r
+  // - primaries (pid) \r
+  // - secondaries (pid)\r
+  // - secondaries (mech)\r
+  // - secondaries (mother)\r
+  //\r
+  TH1D *pt_acc = fRecTrackHist1[1]->Projection(0);\r
+  pt_acc->SetName("pt_acc");\r
+  aFolderObj->Add(pt_acc);\r
+\r
+  TH1D *pt_rec = fRecTrackHist1[2]->Projection(0);\r
+  pt_rec->SetName("pt_rec");\r
+  aFolderObj->Add(pt_rec);\r
+\r
+  TH1D *mc_pt_acc_all = fMCTrackHist1[1]->Projection(0);\r
+  mc_pt_acc_all->SetName("mc_pt_acc_all");\r
+  aFolderObj->Add(mc_pt_acc_all);\r
+\r
+  TH1D *mc_pt_acc_prim = fMCPrimTrackHist1[1]->Projection(0);\r
+  mc_pt_acc_prim->SetName("mc_pt_acc_prim");\r
+  aFolderObj->Add(mc_pt_acc_prim);\r
+\r
+  TH1D *mc_pt_rec_all = fMCTrackHist1[2]->Projection(0);\r
+  mc_pt_rec_all->SetName("mc_pt_rec_all");\r
+  aFolderObj->Add(mc_pt_rec_all);\r
+\r
+  TH1D *mc_pt_rec_prim = fMCPrimTrackHist1[2]->Projection(0);\r
+  mc_pt_rec_prim->SetName("mc_pt_rec_prim");\r
+  aFolderObj->Add(mc_pt_rec_prim);\r
+\r
+  TH1D *mc_pt_rec_sec = fMCSecTrackHist1[2]->Projection(0);\r
+  mc_pt_rec_sec->SetName("mc_pt_rec_sec");\r
+  aFolderObj->Add(mc_pt_rec_sec);\r
+\r
+  for(Int_t i = 0; i<6; i++) \r
+  { \r
+    sprintf(name,"mc_pt_rec_prim_pid_%d",i); \r
+    fMCPrimTrackHist1[2]->GetAxis(2)->SetRange(i+1,i+1);\r
+    h = fMCPrimTrackHist1[2]->Projection(0);\r
+    h->SetName(name);\r
+    aFolderObj->Add(h);\r
+\r
+    sprintf(name,"mc_pt_rec_sec_pid_%d",i); \r
+    fMCSecTrackHist1[2]->GetAxis(2)->SetRange(i+1,i+1);\r
+    h = fMCSecTrackHist1[2]->Projection(0);\r
+    h->SetName(name);\r
+    aFolderObj->Add(h);\r
+\r
+    // production mechanisms for given pid\r
+    fMCSecTrackHist1[2]->GetAxis(2)->SetRange(i+1,i+1);\r
+\r
+    for(Int_t j=0; j<20; j++) {\r
+      if(j == 4) {\r
+        // decay\r
+       \r
+        sprintf(name,"mc_pt_rec_sec_pid_%d_decay",i); \r
+        fMCSecTrackHist1[2]->GetAxis(3)->SetRange(j+1,j+1);\r
+        h = fMCSecTrackHist1[2]->Projection(0);\r
+        h->SetName(name);\r
+        aFolderObj->Add(h);\r
+\r
+        sprintf(name,"mc_eta_rec_sec_pid_%d_decay",i); \r
+        fMCSecTrackHist1[2]->GetAxis(3)->SetRange(j+1,j+1);\r
+        h = fMCSecTrackHist1[2]->Projection(1);\r
+        h->SetName(name);\r
+        aFolderObj->Add(h);\r
+\r
+        sprintf(name,"mc_mother_rec_sec_pid_%d_decay",i); \r
+        fMCSecTrackHist1[2]->GetAxis(3)->SetRange(j+1,j+1);\r
+        h = fMCSecTrackHist1[2]->Projection(4);\r
+        h->SetName(name);\r
+        aFolderObj->Add(h);\r
+\r
+      } else if (j == 5) {\r
+       // conversion\r
+\r
+        sprintf(name,"mc_pt_rec_sec_pid_%d_conv",i); \r
+        fMCSecTrackHist1[2]->GetAxis(3)->SetRange(j+1,j+1);\r
+        h = fMCSecTrackHist1[2]->Projection(0);\r
+        h->SetName(name);\r
+        aFolderObj->Add(h);\r
+\r
+        sprintf(name,"mc_eta_rec_sec_pid_%d_conv",i); \r
+        fMCSecTrackHist1[2]->GetAxis(3)->SetRange(j+1,j+1);\r
+        h = fMCSecTrackHist1[2]->Projection(1);\r
+        h->SetName(name);\r
+        aFolderObj->Add(h);\r
+\r
+        sprintf(name,"mc_mother_rec_sec_pid_%d_conv",i); \r
+        fMCSecTrackHist1[2]->GetAxis(3)->SetRange(j+1,j+1);\r
+        h = fMCSecTrackHist1[2]->Projection(4);\r
+        h->SetName(name);\r
+        aFolderObj->Add(h);\r
+\r
+     } else if (j == 13) {\r
+       // mat\r
+       \r
+        sprintf(name,"mc_pt_rec_sec_pid_%d_mat",i); \r
+        fMCSecTrackHist1[2]->GetAxis(3)->SetRange(j+1,j+1);\r
+        h = fMCSecTrackHist1[2]->Projection(0);\r
+        h->SetName(name);\r
+        aFolderObj->Add(h);\r
+\r
+        sprintf(name,"mc_eta_rec_sec_pid_%d_mat",i); \r
+        fMCSecTrackHist1[2]->GetAxis(3)->SetRange(j+1,j+1);\r
+        h = fMCSecTrackHist1[2]->Projection(1);\r
+        h->SetName(name);\r
+        aFolderObj->Add(h);\r
+\r
+        sprintf(name,"mc_eta_mother_rec_sec_pid_%d_mat",i); \r
+        fMCSecTrackHist1[2]->GetAxis(3)->SetRange(j+1,j+1);\r
+        h = fMCSecTrackHist1[2]->Projection(4,1);\r
+        h->SetName(name);\r
+        aFolderObj->Add(h);\r
+\r
+        sprintf(name,"mc_mother_rec_sec_pid_%d_mat",i); \r
+        fMCSecTrackHist1[2]->GetAxis(3)->SetRange(j+1,j+1);\r
+        h = fMCSecTrackHist1[2]->Projection(4);\r
+        h->SetName(name);\r
+        aFolderObj->Add(h);\r
+\r
+        sprintf(name,"mc_pt_mother_rec_sec_pid_%d_mat",i); \r
+        fMCSecTrackHist1[2]->GetAxis(3)->SetRange(j+1,j+1);\r
+        h = fMCSecTrackHist1[2]->Projection(4,0);\r
+        h->SetName(name);\r
+        aFolderObj->Add(h);\r
+\r
+     } else {\r
+       continue;\r
+     }\r
+   }\r
+\r
+  }\r
+  } // end fHistogramOn\r
+\r
+  //\r
+  //  resolution histograms\r
+  //  only for reconstructed tracks\r
+  //\r
+\r
+  TH2F *h2F=0;\r
+  TCanvas * c = new TCanvas("resol","resol");\r
+  c->cd();\r
+\r
+  //\r
+  fRecMCTrackHist1->GetAxis(1)->SetRangeUser(-0.9,0.89); \r
+\r
+  h2F = (TH2F*)fRecMCTrackHist1->Projection(2,0);\r
+  h = AlidNdPtHelper::MakeResol(h2F,1,0,kTRUE,10);\r
+  h->SetXTitle("p_{tmc} (GeV/c)");\r
+  h->SetYTitle("(p_{t}-p_{tmc})/p_{tmc} resolution");\r
+  h->Draw();\r
+  h->SetName("pt_resolution_vs_mcpt");\r
+  aFolderObj->Add(h);\r
+\r
+  h2F = (TH2F*)fRecMCTrackHist1->Projection(2,0);\r
+  h = AlidNdPtHelper::MakeResol(h2F,1,1,kTRUE,10);\r
+  h->SetXTitle("p_{tmc} (GeV/c)");\r
+  h->SetYTitle("(p_{t}-p_{tmc})/p_{tmc} mean");\r
+  h->Draw();\r
+  h->SetName("dpt_mean_vs_mcpt");\r
+  aFolderObj->Add(h);\r
+\r
+  //\r
+  h2F = (TH2F*)fRecMCTrackHist1->Projection(3,0);\r
+  h = AlidNdPtHelper::MakeResol(h2F,1,0,kTRUE,10);\r
+  h->SetXTitle("p_{tmc} (GeV/c)");\r
+  h->SetYTitle("(#eta-#eta_{mc}) resolution");\r
+  h->Draw();\r
+  h->SetName("eta_resolution_vs_mcpt");\r
+  aFolderObj->Add(h);\r
+\r
+  h2F = (TH2F*)fRecMCTrackHist1->Projection(3,0);\r
+  h = AlidNdPtHelper::MakeResol(h2F,1,1,kTRUE,10);\r
+  h->SetXTitle("p_{tmc} (GeV/c)");\r
+  h->SetYTitle("(#eta-mc#eta) mean");\r
+  h->Draw();\r
+  h->SetName("deta_mean_vs_mcpt");\r
+  aFolderObj->Add(h);\r
+  \r
+  // \r
+  fRecMCTrackHist1->GetAxis(1)->SetRange(1,fRecMCTrackHist1->GetAxis(1)->GetNbins()); \r
+  fRecMCTrackHist1->GetAxis(0)->SetRangeUser(minPt,maxPt); \r
+\r
+  h2F = (TH2F*)fRecMCTrackHist1->Projection(2,1);\r
+  h = AlidNdPtHelper::MakeResol(h2F,1,0,kTRUE,10);\r
+  h->SetXTitle("#eta_{mc}");\r
+  h->SetYTitle("(p_{t}-p_{tmc})/p_{tmc} resolution");\r
+  h->Draw();\r
+  h->SetName("pt_resolution_vs_mceta");\r
+  aFolderObj->Add(h);\r
+\r
+  h2F = (TH2F*)fRecMCTrackHist1->Projection(2,1);\r
+  h = AlidNdPtHelper::MakeResol(h2F,1,1,kTRUE,10);\r
+  h->SetXTitle("#eta_{mc}");\r
+  h->SetYTitle("(p_{t}-p_{tmc})/p_{tmc} mean");\r
+  h->Draw();\r
+  h->SetName("dpt_mean_vs_mceta");\r
+  aFolderObj->Add(h);\r
+\r
+  //\r
+  h2F = (TH2F*)fRecMCTrackHist1->Projection(3,1);\r
+  h = AlidNdPtHelper::MakeResol(h2F,1,0,kTRUE,10);\r
+  h->SetXTitle("#eta_{mc}");\r
+  h->SetYTitle("(#eta-#eta_{mc}) resolution");\r
+  h->Draw();\r
+  h->SetName("eta_resolution_vs_mceta");\r
+  aFolderObj->Add(h);\r
+\r
+  h2F = (TH2F*)fRecMCTrackHist1->Projection(3,1);\r
+  h = AlidNdPtHelper::MakeResol(h2F,1,1,kTRUE,10);\r
+  h->SetXTitle("#eta_{mc}");\r
+  h->SetYTitle("(#eta-mc#eta) mean");\r
+  h->Draw();\r
+  h->SetName("deta_mean_vs_mceta");\r
+  aFolderObj->Add(h);\r
+\r
+  fRecMCTrackHist1->GetAxis(0)->SetRange(1,fRecMCTrackHist1->GetAxis(0)->GetNbins()); \r
+\r
\r
+  // export objects to analysis folder\r
+  fAnalysisFolder = ExportToFolder(aFolderObj);\r
+\r
+  // delete only TObjArray\r
+  if(aFolderObj) delete aFolderObj;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+TFolder* AlidNdPtAnalysis::ExportToFolder(TObjArray * array) \r
+{\r
+  // recreate folder avery time and export objects to new one\r
+  //\r
+  AlidNdPtAnalysis * comp=this;\r
+  TFolder *folder = comp->GetAnalysisFolder();\r
+\r
+  TString name, title;\r
+  TFolder *newFolder = 0;\r
+  Int_t i = 0;\r
+  Int_t size = array->GetSize();\r
+\r
+  if(folder) { \r
+     // get name and title from old folder\r
+     name = folder->GetName();  \r
+     title = folder->GetTitle();  \r
+\r
+        // delete old one\r
+     delete folder;\r
+\r
+        // create new one\r
+     newFolder = CreateFolder(name.Data(),title.Data());\r
+     newFolder->SetOwner();\r
+\r
+        // add objects to folder\r
+     while(i < size) {\r
+          newFolder->Add(array->At(i));\r
+          i++;\r
+        }\r
+  }\r
+\r
+return newFolder;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+TFolder* AlidNdPtAnalysis::CreateFolder(TString name,TString title) { \r
+// create folder for analysed histograms\r
+//\r
+TFolder *folder = 0;\r
+  folder = new TFolder(name.Data(),title.Data());\r
+\r
+  return folder;\r
+}\r
diff --git a/PWG0/dNdPt/AlidNdPtAnalysis.h b/PWG0/dNdPt/AlidNdPtAnalysis.h
new file mode 100644 (file)
index 0000000..d19372c
--- /dev/null
@@ -0,0 +1,255 @@
+#ifndef ALIDEDPTANALYSIS_H
+#define ALIDEDPTANALYSIS_H
+
+//------------------------------------------------------------------------------
+// AlidNdPtAnalysis class. 
+// 
+// a. functionality:
+// - fills analysis control histograms
+// - fills generic correction matrices 
+// - generates correction matrices 
+//
+// b. data members:
+// - generic correction matrices
+// - control histograms
+//
+// Author: J.Otwinowski 04/11/2008 
+//------------------------------------------------------------------------------
+
+class TProfile;
+class TFolder;
+class TObjArray;
+class TString;
+
+class AliESDtrackCuts;
+class AliVertexerTracks;
+class AliESD;
+class AliESDfriend;
+class AliESDfriendTrack;
+
+#include "THnSparse.h"
+#include "AlidNdPt.h"
+#include "AlidNdPtHelper.h"
+
+class AlidNdPtAnalysis : public AlidNdPt {
+public :
+  AlidNdPtAnalysis(); 
+  AlidNdPtAnalysis(Char_t* name, Char_t* title);
+  ~AlidNdPtAnalysis();
+
+  // Init data members
+  virtual void Init();
+
+  // Process events
+  virtual void Process(AliESDEvent *const esdEvent=0, AliMCEvent *const mcEvent=0);
+
+  // Merge output objects (needed by PROOF) 
+  virtual Long64_t Merge(TCollection* list);
+
+  // Analyse output histograms 
+  virtual void Analyse();
+
+  // Export objects to folder
+  virtual TFolder *ExportToFolder(TObjArray * array=0);
+
+  // Get analysis folder
+  TFolder* GetAnalysisFolder() {return fAnalysisFolder;}
+
+  // Fill control histograms
+  void SetHistogramsOn(Bool_t histOn=kTRUE) {fHistogramsOn = histOn;}
+  Bool_t IsHistogramsOn() {return fHistogramsOn;}
+
+  // Create folder for analysed histograms
+  TFolder *CreateFolder(TString folder = "folderdNdPtAnalysis",TString title = "Analysed dNdPt histograms");
+
+  // Fill histograms
+  void FillHistograms(AliESDtrack *const esdTrack, AliStack *const stack, AlidNdPtHelper::TrackObject trackObj);
+  void FillHistograms(AliStack *const stack, Int_t label, AlidNdPtHelper::TrackObject trackObj);
+  void FillHistograms(TObjArray *const allChargedTracks,Int_t *const labelsAll,Int_t multAll,Int_t *const labelsAcc,Int_t multAcc,Int_t *const labelsRec,Int_t multRec);
+
+  // Getters
+  THnSparseF *GetEventMultCorrelationMatrix() {return fEventMultCorrelationMatrix;}
+  THnSparseF *GetTrackPtCorrelationMatrix()   {return fTrackPtCorrelationMatrix;}
+
+  //
+  THnSparseF *GetGenEventMatrix() {return fGenEventMatrix;}
+  THnSparseF *GetGenSDEventMatrix() {return fGenSDEventMatrix;}
+  THnSparseF *GetGenDDEventMatrix() {return fGenDDEventMatrix;}
+  THnSparseF *GetGenNDEventMatrix() {return fGenNDEventMatrix;}
+  THnSparseF *GetGenNSDEventMatrix() {return fGenNSDEventMatrix;}
+
+  THnSparseF *GetTriggerEventMatrix() {return fTriggerEventMatrix;}
+  THnSparseF *GetTriggerSDEventMatrix() {return fTriggerSDEventMatrix;}
+  THnSparseF *GetTriggerDDEventMatrix() {return fTriggerDDEventMatrix;}
+  THnSparseF *GetTriggerNDEventMatrix() {return fTriggerNDEventMatrix;}
+  THnSparseF *GetTriggerNSDEventMatrix() {return fTriggerNSDEventMatrix;}
+
+  THnSparseF *GetRecEventMatrix() {return fRecEventMatrix;}
+  THnSparseF *GetRecSDEventMatrix() {return fRecSDEventMatrix;}
+  THnSparseF *GetRecDDEventMatrix() {return fRecDDEventMatrix;}
+  THnSparseF *GetRecNDEventMatrix() {return fRecNDEventMatrix;}
+  THnSparseF *GetRecNSDEventMatrix() {return fRecNSDEventMatrix;}
+
+  // 
+  THnSparseF *GetGenTrackEventMatrix() {return fGenTrackEventMatrix;}
+  THnSparseF *GetGenTrackSDEventMatrix() {return fGenTrackSDEventMatrix;}
+  THnSparseF *GetGenTrackDDEventMatrix() {return fGenTrackDDEventMatrix;}
+  THnSparseF *GetGenTrackNDEventMatrix() {return fGenTrackNDEventMatrix;}
+  THnSparseF *GetGenTrackNSDEventMatrix() {return fGenTrackNSDEventMatrix;}
+
+  THnSparseF *GetTriggerTrackEventMatrix() {return fTriggerTrackEventMatrix;}
+  THnSparseF *GetTriggerTrackSDEventMatrix() {return fTriggerTrackSDEventMatrix;}
+  THnSparseF *GetTriggerTrackDDEventMatrix() {return fTriggerTrackDDEventMatrix;}
+  THnSparseF *GetTriggerTrackNDEventMatrix() {return fTriggerTrackNDEventMatrix;}
+  THnSparseF *GetTriggerTrackNSDEventMatrix() {return fTriggerTrackNSDEventMatrix;}
+
+  THnSparseF *GetRecTrackEventMatrix() {return fRecTrackEventMatrix;}
+  THnSparseF *GetRecTrackSDEventMatrix() {return fRecTrackSDEventMatrix;}
+  THnSparseF *GetRecTrackDDEventMatrix() {return fRecTrackDDEventMatrix;}
+  THnSparseF *GetRecTrackNDEventMatrix() {return fRecTrackNDEventMatrix;}
+  THnSparseF *GetRecTrackNSDEventMatrix() {return fRecTrackNSDEventMatrix;}
+
+  //
+  THnSparseF *GetGenPrimTrackMatrix() {return fGenPrimTrackMatrix;}
+  THnSparseF *GetRecPrimTrackMatrix() {return fRecPrimTrackMatrix;}
+
+  THnSparseF *GetRecTrackMatrix() {return fRecTrackMatrix;}
+  THnSparseF *GetRecSecTrackMatrix() {return fRecSecTrackMatrix;}
+  THnSparseF *GetRecMultTrackMatrix() {return fRecMultTrackMatrix;}
+
+  //
+  // control histograms
+  //
+  THnSparseF *GetMCEventHist1() {return fMCEventHist1;}
+  THnSparseF *GetRecEventHist1() {return fRecEventHist1;}
+  THnSparseF *GetRecEventHist2() {return fRecEventHist2;}
+  THnSparseF *GetRecMCEventHist1() {return fRecMCEventHist1;}
+  THnSparseF *GetRecMCEventHist2() {return fRecMCEventHist2;}
+  THnSparseF *GetRecMCEventHist3() {return fRecMCEventHist3;}
+
+  THnSparseF *GetMCTrackHist1(Int_t i) {return fMCTrackHist1[i];}
+  THnSparseF *GetMCPrimTrackHist1(Int_t i) {return fMCPrimTrackHist1[i];}
+  THnSparseF *GetMCSecTrackHist1(Int_t i) {return fMCSecTrackHist1[i];}
+
+  THnSparseF *GetRecTrackHist1(Int_t i) {return fRecTrackHist1[i];}
+  THnSparseF *GetRecTrackMultHist1(Int_t i) {return fRecTrackMultHist1[i];}
+
+  THnSparseF *GetRecMCTrackHist1() {return fRecMCTrackHist1;}
+  THnSparseF *GetMCMultRecTrackHist1() {return fMCMultRecTrackHist1;}
+
+private:
+
+  // analysis folder 
+  TFolder *fAnalysisFolder; // folder for analysed histograms
+
+  // switch on/off filling of control histograms
+  Bool_t fHistogramsOn; 
+
+  // 
+  // correlation matrices (histograms)
+  //
+
+  // event rec. track vs true track multiplicity correlation matrix 
+  THnSparseF *fEventMultCorrelationMatrix; //-> mult:mult_true_tracks
+
+  // rec. track pt vs true track pt correlation matrix for given eta
+  THnSparseF *fTrackPtCorrelationMatrix; //-> Pt:mcPt:mcEta
+
+  //
+  // event level correction 
+  //
+
+  // all genertated
+  THnSparseF *fGenEventMatrix; //-> mcZv:mult (inelastic)
+  THnSparseF *fGenSDEventMatrix; //-> mcZv:mult (single diffractive)
+  THnSparseF *fGenDDEventMatrix; //-> mcZv:mult (single diffractive)
+  THnSparseF *fGenNDEventMatrix; //-> mcZv:mult (non diffractive)
+  THnSparseF *fGenNSDEventMatrix; //-> mcZv:mult (non single diffractive)
+
+  // trigger bias corrections (fTriggerEventMatrix / fGenEventMatrix)
+  THnSparseF *fTriggerEventMatrix; //-> mcZv:mult
+  THnSparseF *fTriggerSDEventMatrix; //-> mcZv:mult
+  THnSparseF *fTriggerDDEventMatrix; //-> mcZv:mult
+  THnSparseF *fTriggerNDEventMatrix; //-> mcZv:mult
+  THnSparseF *fTriggerNSDEventMatrix; //-> mcZv:mult
+
+  // event vertex rec. eff correction (fRecEventMatrix / fTriggerEventMatrix)
+  THnSparseF *fRecEventMatrix; //-> mcZv:mult 
+  THnSparseF *fRecSDEventMatrix; //-> mcZv:mult
+  THnSparseF *fRecDDEventMatrix; //-> mcZv:mult
+  THnSparseF *fRecNDEventMatrix; //-> mcZv:mult
+  THnSparseF *fRecNSDEventMatrix; //-> mcZv:mult
+
+  //
+  // track-event level correction 
+  //
+
+  THnSparseF *fGenTrackEventMatrix; //-> mcZv:mcPt:mcEta
+  THnSparseF *fGenTrackSDEventMatrix; //-> mcZv:mcPt:mcEta
+  THnSparseF *fGenTrackDDEventMatrix; //-> mcZv:mcPt:mcEta
+  THnSparseF *fGenTrackNDEventMatrix; //-> mcZv:mcPt:mcEta
+  THnSparseF *fGenTrackNSDEventMatrix; //-> mcZv:mcPt:mcEta
+
+  // trigger bias corrections (fTriggerTrackEventMatrix / fGenTrackEventMatrix)
+  THnSparseF *fTriggerTrackEventMatrix; //-> mcZv:mcPt:mcEta
+  THnSparseF *fTriggerTrackSDEventMatrix; //-> mcZv:mcPt:mcEta
+  THnSparseF *fTriggerTrackDDEventMatrix; //-> mcZv:mcPt:mcEta
+  THnSparseF *fTriggerTrackNDEventMatrix; //-> mcZv:mcPt:mcEta
+  THnSparseF *fTriggerTrackNSDEventMatrix; //-> mcZv:mcPt:mcEta
+
+  // event vertex rec. corrections (fRecTrackEventMatrix / fTriggerTrackEventMatrix)
+  THnSparseF *fRecTrackEventMatrix; //-> mcZv:Pt:mcEta
+  THnSparseF *fRecTrackSDEventMatrix; //-> mcZv:Pt:mcEta
+  THnSparseF *fRecTrackDDEventMatrix; //-> mcZv:Pt:mcEta
+  THnSparseF *fRecTrackNDEventMatrix; //-> mcZv:Pt:mcEta
+  THnSparseF *fRecTrackNSDEventMatrix; //-> mcZv:Pt:mcEta
+
+  //
+  // track level correction 
+  //
+
+  // track rec. efficiency correction (fRecPrimTrackMatrix / fGenPrimTrackMatrix)
+  THnSparseF *fGenPrimTrackMatrix; //-> mcZv:mcPt:mcEta
+  THnSparseF *fRecPrimTrackMatrix; //-> mcZv:mcPt:mcEta
+
+  // secondary track contamination correction (fRecSecTrackMatrix / fRecTrackMatrix)
+  THnSparseF *fRecTrackMatrix;    //-> mcZv:mcPt:mcEta
+  THnSparseF *fRecSecTrackMatrix; //-> mcZv:mcPt:mcEta
+
+  // multiple rec. track corrections (fRecMultTrackMatrix / fRecTrackMatrix)
+  THnSparseF *fRecMultTrackMatrix; //-> mcZv:Pt:mcEta
+
+  //
+  // ESD and MC control analysis histograms
+  //
+
+  // THnSparse event histograms
+  THnSparseF *fMCEventHist1;  //-> mcXv:mcYv:mcZv
+  THnSparseF *fRecEventHist1; //-> Xv:Yv:Zv
+  THnSparseF *fRecEventHist2; //-> Zv:multMB
+  THnSparseF *fRecMCEventHist1; //-> Xv-mcXv:Yv-mcYv:Zv-mcZv
+  THnSparseF *fRecMCEventHist2; //-> Xv-mcXv:Zv-mcZv:Mult
+  THnSparseF *fRecMCEventHist3; //-> Mult:EventType (ND, DD, SD)
+
+  // THnSparse track histograms
+  // [0] - after charged track selection, [1] - after acceptance cuts, [2] - after esd track cuts
+
+  THnSparseF *fMCTrackHist1[AlidNdPtHelper::kCutSteps];     //-> mcPt:mcEta:mcPhi
+  THnSparseF *fMCPrimTrackHist1[AlidNdPtHelper::kCutSteps]; //-> mcPt:mcEta:pid:mech:mother
+  THnSparseF *fMCSecTrackHist1[AlidNdPtHelper::kCutSteps];  //-> mcPt:mcEta:pid:mech:mother
+
+  THnSparseF *fRecTrackHist1[AlidNdPtHelper::kCutSteps];     //-> Pt:Eta:Phi
+  THnSparseF *fRecTrackMultHist1[AlidNdPtHelper::kCutSteps]; //-> Pt:Mult
+
+  THnSparseF *fRecMCTrackHist1; //-> mcPt:mcEta:(Pt-mcPt)/mcPt:(Eta-mcEta)
+
+  //multple reconstructed tracks
+  THnSparseF *fMCMultRecTrackHist1; //-> mcPt:mcEta:pid
+
+  AlidNdPtAnalysis(const AlidNdPtAnalysis&); // not implemented
+  AlidNdPtAnalysis& operator=(const AlidNdPtAnalysis&); // not implemented
+
+  ClassDef(AlidNdPtAnalysis,1);
+};
+
+#endif
diff --git a/PWG0/dNdPt/AlidNdPtCorrection.cxx b/PWG0/dNdPt/AlidNdPtCorrection.cxx
new file mode 100644 (file)
index 0000000..761f4b3
--- /dev/null
@@ -0,0 +1,1589 @@
+/**************************************************************************\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
+#include <iostream>\r
+\r
+#include "TFile.h"\r
+#include "TCint.h"\r
+#include "TH1.h"\r
+#include "TH2.h"\r
+\r
+#include "AliHeader.h"  \r
+#include "AliGenEventHeader.h"  \r
+#include "AliStack.h"  \r
+#include "AliESDEvent.h"  \r
+#include "AliMCEvent.h"  \r
+#include "AliESDtrackCuts.h"  \r
+#include "AliLog.h" \r
+\r
+#include "AlidNdPtEventCuts.h"\r
+#include "AlidNdPtAcceptanceCuts.h"\r
+\r
+#include "AlidNdPtCorrection.h"\r
+\r
+using namespace std;\r
+\r
+ClassImp(AlidNdPtCorrection)\r
+\r
+//_____________________________________________________________________________\r
+//AlidNdPtCorrection::AlidNdPtCorrection(): TNamed(),\r
+  AlidNdPtCorrection::AlidNdPtCorrection(): AlidNdPt(),\r
+  fCorrectionFolder(0),\r
+  fMCEventHist1(0),\r
+  fRecEventHist1(0),\r
+  fMCAllEventMultHist1(0),\r
+  fMCAllNDEventMultHist1(0),\r
+  fMCAllNSDEventMultHist1(0),\r
+  fMCTriggerMultHist1(0),\r
+  fMCEventMultHist1(0),\r
+  fMCAllPrimTrackMultHist1(0),\r
+  fMCNDEventAllPrimTrackMultHist1(0),\r
+  fMCNSDEventAllPrimTrackMultHist1(0),\r
+  fMCTriggerPrimTrackMultHist1(0),\r
+  fMCEventPrimTrackMultHist1(0),\r
+  //fPtvsPt(0),\r
+  fEventMultCorrelationMatrix(0),\r
+  fZvNorm(0),\r
+  fZvEmptyEventsNorm(0),\r
+  fCorrTriggerMBtoInelEventMatrix(0),\r
+  fCorrTriggerMBtoNDEventMatrix(0),\r
+  fCorrTriggerMBtoNSDEventMatrix(0),\r
+  fCorrEventMatrix(0),\r
+  fCorrTriggerMBtoInelTrackEventMatrix(0),\r
+  fCorrTriggerMBtoNDTrackEventMatrix(0),\r
+  fCorrTriggerMBtoNSDTrackEventMatrix(0),\r
+  fCorrTrackEventMatrix(0),\r
+  fCorrTrackMatrix(0),\r
+  fContTrackMatrix(0),\r
+  fContMultTrackMatrix(0),\r
+  fCorrMatrixFileName("")\r
+{\r
+  // default constructor\r
+  for(Int_t i=0; i<AlidNdPtHelper::kCutSteps; i++) { \r
+    fRecTrackHist1[i]=0;     \r
+  }\r
+\r
+  for(Int_t i=0; i<8; i++) { \r
+    fCorrRecTrackMultHist1[i] = 0;\r
+  }\r
+\r
+  for(Int_t i=0; i<5; i++) { \r
+    fCorrRecEventHist1[i] = 0;\r
+    fCorrRecEventHist2[i] = 0;\r
+  }\r
+\r
+  Init();\r
+}\r
+\r
+//_____________________________________________________________________________\r
+AlidNdPtCorrection::AlidNdPtCorrection(Char_t* name, Char_t* title, TString corrMatrixFileName): AlidNdPt(name,title),\r
+  fCorrectionFolder(0),\r
+  fMCEventHist1(0),\r
+  fRecEventHist1(0),\r
+  fMCAllEventMultHist1(0),\r
+  fMCAllNDEventMultHist1(0),\r
+  fMCAllNSDEventMultHist1(0),\r
+  fMCTriggerMultHist1(0),\r
+  fMCEventMultHist1(0),\r
+  fMCAllPrimTrackMultHist1(0),\r
+  fMCNDEventAllPrimTrackMultHist1(0),\r
+  fMCNSDEventAllPrimTrackMultHist1(0),\r
+  fMCTriggerPrimTrackMultHist1(0),\r
+  fMCEventPrimTrackMultHist1(0),\r
+  //fPtvsPt(0),\r
+  fEventMultCorrelationMatrix(0),\r
+  fZvNorm(0),\r
+  fZvEmptyEventsNorm(0),\r
+  fCorrTriggerMBtoInelEventMatrix(0),\r
+  fCorrTriggerMBtoNDEventMatrix(0),\r
+  fCorrTriggerMBtoNSDEventMatrix(0),\r
+  fCorrEventMatrix(0),\r
+  fCorrTriggerMBtoInelTrackEventMatrix(0),\r
+  fCorrTriggerMBtoNDTrackEventMatrix(0),\r
+  fCorrTriggerMBtoNSDTrackEventMatrix(0),\r
+  fCorrTrackEventMatrix(0),\r
+  fCorrTrackMatrix(0),\r
+  fContTrackMatrix(0),\r
+  fContMultTrackMatrix(0),\r
+  fCorrMatrixFileName(corrMatrixFileName)\r
+{\r
+  // constructor\r
+  for(Int_t i=0; i<AlidNdPtHelper::kCutSteps; i++) { \r
+    fRecTrackHist1[i]=0;     \r
+  }\r
+\r
+  for(Int_t i=0; i<8; i++) { \r
+    fCorrRecTrackMultHist1[i] = 0;\r
+  }\r
+\r
+  for(Int_t i=0; i<5; i++) { \r
+    fCorrRecEventHist1[i] = 0;\r
+    fCorrRecEventHist2[i] = 0;\r
+  }\r
+\r
+  Init();\r
+}\r
+\r
+//_____________________________________________________________________________\r
+AlidNdPtCorrection::~AlidNdPtCorrection() {\r
+  // \r
+  // destructor\r
+  //\r
+  if(fMCEventHist1) delete fMCEventHist1; fMCEventHist1=0;\r
+  if(fRecEventHist1) delete fRecEventHist1; fRecEventHist1=0;\r
+\r
+  if(fMCAllEventMultHist1) delete fMCAllEventMultHist1; fMCAllEventMultHist1=0;\r
+  if(fMCAllNDEventMultHist1) delete fMCAllNDEventMultHist1; fMCAllNDEventMultHist1=0;\r
+  if(fMCAllNSDEventMultHist1) delete fMCAllNSDEventMultHist1; fMCAllNSDEventMultHist1=0;\r
+  if(fMCTriggerMultHist1) delete fMCTriggerMultHist1; fMCTriggerMultHist1=0;\r
+  if(fMCEventMultHist1) delete fMCEventMultHist1; fMCEventMultHist1=0;\r
+\r
+  if(fMCAllPrimTrackMultHist1) delete fMCAllPrimTrackMultHist1; fMCAllPrimTrackMultHist1=0;\r
+  if(fMCNDEventAllPrimTrackMultHist1) delete fMCNDEventAllPrimTrackMultHist1; fMCNDEventAllPrimTrackMultHist1=0;\r
+  if(fMCNSDEventAllPrimTrackMultHist1) delete fMCNSDEventAllPrimTrackMultHist1; fMCNSDEventAllPrimTrackMultHist1=0;\r
+  if(fMCTriggerPrimTrackMultHist1) delete fMCTriggerPrimTrackMultHist1; fMCTriggerPrimTrackMultHist1=0;\r
+  if(fMCEventPrimTrackMultHist1) delete fMCEventPrimTrackMultHist1; fMCEventPrimTrackMultHist1=0;\r
+\r
+  for(Int_t i=0; i<AlidNdPtHelper::kCutSteps; i++) { \r
+    if(fRecTrackHist1[i]) delete fRecTrackHist1[i]; fRecTrackHist1[i]=0;\r
+  }\r
+\r
+  for(Int_t i=0; i<8; i++) { \r
+    if(fCorrRecTrackMultHist1[i]) delete fCorrRecTrackMultHist1[i]; fCorrRecTrackMultHist1[i]=0;\r
+  }\r
+\r
+  for(Int_t i=0; i<5; i++) { \r
+    if(fCorrRecEventHist1[i]) delete fCorrRecEventHist1[i]; fCorrRecEventHist1[i]=0;\r
+    if(fCorrRecEventHist2[i]) delete fCorrRecEventHist2[i]; fCorrRecEventHist2[i]=0;\r
+  }\r
+\r
+  if(fCorrectionFolder) delete fCorrectionFolder; fCorrectionFolder=0;\r
+  //if(fPtvsPt) delete fPtvsPt; fPtvsPt=0;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AlidNdPtCorrection::Init(){\r
+  //\r
+  // Init histograms\r
+  //\r
+  const Int_t etaNbins = 30; \r
+  const Int_t zvNbins = 12;\r
+\r
+  // UA1 bining\r
+  //const Int_t ptNbins = 52; \r
+  //Double_t binsPt[ptNbins+1] = { 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 1.00, 1.10, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90, 2.00, 2.10, 2.20, 2.30, 2.40, 2.50, 2.60, 2.70, 2.80, 2.90, 3.00, 3.10, 3.20, 3.30, 3.40, 3.50, 3.60, 3.70, 3.80, 3.90, 4.00, 4.20, 4.40, 4.60, 4.80, 5.00, 5.20, 5.40, 5.60, 5.80, 6.00, 7.00, 7.60, 8.80, 9.60 }; \r
+\r
+  const Int_t ptNbins = 56; \r
+  Double_t binsPt[ptNbins+1] = {0.,0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.2,2.4,2.6,2.8,3.0,3.2,3.4,3.6,3.8,4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0};\r
+  Double_t binsEta[etaNbins+1] = {-1.5,-1.4,-1.3,-1.2,-1.1,-1.0,-0.9,-0.8,-0.7,-0.6,-0.5,-0.4,-0.3,-0.2,-0.1,0.,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5};\r
+  Double_t binsZv[zvNbins+1] = {-30.,-25.,-20.,-15.,-10.,-5.,0.,5.,10.,15.,20.,25.,30.};\r
+\r
+  //TProfile *fPtvsPt = new TProfile("fPtvsPt","pt profile",ptNbins,binsPt); \r
+  //fPtvsPt->GetXaxis()->SetTitle("Pt (GeV/c)"); \r
+  //fPtvsPt->GetYaxis()->SetTitle("<Pt> (GeV/c)"); \r
+  //fPtvsPt->Sumw2();\r
+\r
+  //\r
+  Int_t binsMCEventHist1[3]={100,100,140};\r
+  Double_t minMCEventHist1[3]={-0.1,-0.1,-35.}; \r
+  Double_t maxMCEventHist1[3]={0.1,0.1,35.}; \r
+  fMCEventHist1 = new THnSparseF("fMCEventHist1","mcXv:mcYv:mcZv",3,binsMCEventHist1,minMCEventHist1,maxMCEventHist1);\r
+  fMCEventHist1->GetAxis(0)->SetTitle("mcXv (cm)");\r
+  fMCEventHist1->GetAxis(1)->SetTitle("mcYv (cm)");\r
+  fMCEventHist1->GetAxis(2)->SetTitle("mcZv (cm)");\r
+  fMCEventHist1->Sumw2();\r
+\r
+  //\r
+  Int_t binsRecEventHist1[3]={100,100,140};\r
+  Double_t minRecEventHist1[3]={-3.,-3.,-35.}; \r
+  Double_t maxRecEventHist1[3]={3.,3.,35.}; \r
+  fRecEventHist1 = new THnSparseF("fRecEventHist1","Xv:Yv:Zv",3,binsRecEventHist1,minRecEventHist1,maxRecEventHist1);\r
+  fRecEventHist1->GetAxis(0)->SetTitle("Xv (cm)");\r
+  fRecEventHist1->GetAxis(1)->SetTitle("Yv (cm)");\r
+  fRecEventHist1->GetAxis(2)->SetTitle("Zv (cm)");\r
+  fRecEventHist1->Sumw2();\r
+\r
+  //\r
+  char name[256];\r
+  char title[256];\r
+\r
+  Int_t binsMCAllPrimTrackMultHist1[3]={ptNbins,etaNbins,150};\r
+  Double_t minMCAllPrimTrackMultHist1[3]={0.,-1.,-0.5}; \r
+  Double_t maxMCAllPrimTrackMultHist1[3]={20.,1.,149.5}; \r
+  sprintf(name,"fMCAllPrimTrackMultHist1");\r
+  sprintf(title,"mcPt:mcEta:multiplicity");\r
+  \r
+  fMCAllPrimTrackMultHist1 = new THnSparseF(name,title,3,binsMCAllPrimTrackMultHist1,minMCAllPrimTrackMultHist1,maxMCAllPrimTrackMultHist1);\r
+  fMCAllPrimTrackMultHist1->SetBinEdges(0,binsPt);\r
+  fMCAllPrimTrackMultHist1->SetBinEdges(1,binsEta);\r
+  fMCAllPrimTrackMultHist1->GetAxis(0)->SetTitle("mcPt (GeV/c)");\r
+  fMCAllPrimTrackMultHist1->GetAxis(1)->SetTitle("mcEta");\r
+  fMCAllPrimTrackMultHist1->GetAxis(2)->SetTitle("multiplicity");\r
+  fMCAllPrimTrackMultHist1->Sumw2();\r
+\r
+  Int_t binsMCNDEventAllPrimTrackMultHist1[3]={ptNbins,etaNbins,150};\r
+  Double_t minMCNDEventAllPrimTrackMultHist1[3]={0.,-1.,-0.5}; \r
+  Double_t maxMCNDEventAllPrimTrackMultHist1[3]={20.,1.,149.5}; \r
+  sprintf(name,"fMCNDEventAllPrimTrackMultHist1");\r
+  sprintf(title,"mcPt:mcEta:multiplicity");\r
+  \r
+  fMCNDEventAllPrimTrackMultHist1 = new THnSparseF(name,title,3,binsMCNDEventAllPrimTrackMultHist1,minMCNDEventAllPrimTrackMultHist1,maxMCNDEventAllPrimTrackMultHist1);\r
+  fMCNDEventAllPrimTrackMultHist1->SetBinEdges(0,binsPt);\r
+  fMCNDEventAllPrimTrackMultHist1->SetBinEdges(1,binsEta);\r
+  fMCNDEventAllPrimTrackMultHist1->GetAxis(0)->SetTitle("mcPt (GeV/c)");\r
+  fMCNDEventAllPrimTrackMultHist1->GetAxis(1)->SetTitle("mcEta");\r
+  fMCNDEventAllPrimTrackMultHist1->GetAxis(2)->SetTitle("multiplicity");\r
+  fMCNDEventAllPrimTrackMultHist1->Sumw2();\r
+\r
+  Int_t binsMCNSDEventAllPrimTrackMultHist1[3]={ptNbins,etaNbins,150};\r
+  Double_t minMCNSDEventAllPrimTrackMultHist1[3]={0.,-1.,-0.5}; \r
+  Double_t maxMCNSDEventAllPrimTrackMultHist1[3]={20.,1.,140.9}; \r
+  sprintf(name,"fMCNSDEventAllPrimTrackMultHist1");\r
+  sprintf(title,"mcPt:mcEta:multiplicity");\r
+  \r
+  fMCNSDEventAllPrimTrackMultHist1 = new THnSparseF(name,title,3,binsMCNSDEventAllPrimTrackMultHist1,minMCNSDEventAllPrimTrackMultHist1,maxMCNSDEventAllPrimTrackMultHist1);\r
+  fMCNSDEventAllPrimTrackMultHist1->SetBinEdges(0,binsPt);\r
+  fMCNSDEventAllPrimTrackMultHist1->SetBinEdges(1,binsEta);\r
+  fMCNSDEventAllPrimTrackMultHist1->GetAxis(0)->SetTitle("mcPt (GeV/c)");\r
+  fMCNSDEventAllPrimTrackMultHist1->GetAxis(1)->SetTitle("mcEta");\r
+  fMCNSDEventAllPrimTrackMultHist1->GetAxis(2)->SetTitle("multiplicity");\r
+  fMCNSDEventAllPrimTrackMultHist1->Sumw2();\r
+\r
+  Int_t binsMCEventTriggerPrimTrackMultHist1[3]={ptNbins,etaNbins,150};\r
+  Double_t minMCEventTriggerPrimTrackMultHist1[3]={0.,-1.,-0.5}; \r
+  Double_t maxMCEventTriggerPrimTrackMultHist1[3]={20.,1.,149.5}; \r
+  sprintf(name,"fMCTriggerPrimTrackMultHist1");\r
+  sprintf(title,"mcPt:mcEta:multiplicity");\r
+  \r
+  fMCTriggerPrimTrackMultHist1 = new THnSparseF(name,title,3,binsMCEventTriggerPrimTrackMultHist1,minMCEventTriggerPrimTrackMultHist1,maxMCEventTriggerPrimTrackMultHist1);\r
+  fMCTriggerPrimTrackMultHist1->SetBinEdges(0,binsPt);\r
+  fMCTriggerPrimTrackMultHist1->SetBinEdges(1,binsEta);\r
+  fMCTriggerPrimTrackMultHist1->GetAxis(0)->SetTitle("mcPt (GeV/c)");\r
+  fMCTriggerPrimTrackMultHist1->GetAxis(1)->SetTitle("mcEta");\r
+  fMCTriggerPrimTrackMultHist1->GetAxis(2)->SetTitle("multiplicity");\r
+  fMCTriggerPrimTrackMultHist1->Sumw2();\r
+\r
+  Int_t binsMCEventPrimTrackMultHist1[3]={ptNbins,etaNbins,150};\r
+  Double_t minMCEventPrimTrackMultHist1[3]={0.,-1.,-0.5}; \r
+  Double_t maxMCEventPrimTrackMultHist1[3]={20.,1.,149.5}; \r
+  sprintf(name,"fMCEventPrimTrackMultHist1");\r
+  sprintf(title,"mcPt:mcEta:multiplicity");\r
+  \r
+  fMCEventPrimTrackMultHist1 = new THnSparseF(name,title,3,binsMCEventPrimTrackMultHist1,minMCEventPrimTrackMultHist1,maxMCEventPrimTrackMultHist1);\r
+  fMCEventPrimTrackMultHist1->SetBinEdges(0,binsPt);\r
+  fMCEventPrimTrackMultHist1->SetBinEdges(1,binsEta);\r
+  fMCEventPrimTrackMultHist1->GetAxis(0)->SetTitle("mcPt (GeV/c)");\r
+  fMCEventPrimTrackMultHist1->GetAxis(1)->SetTitle("mcEta");\r
+  fMCEventPrimTrackMultHist1->GetAxis(2)->SetTitle("multiplicity");\r
+  fMCEventPrimTrackMultHist1->Sumw2();\r
+\r
+  for(Int_t i=0; i<AlidNdPtHelper::kCutSteps; i++) \r
+  {\r
+    // THnSparse track histograms\r
+    //\r
+    Int_t binsRecTrackHist1[3]={ptNbins,etaNbins,90};\r
+    Double_t minRecTrackHist1[3]={0.,-1.,0.}; \r
+    Double_t maxRecTrackHist1[3]={10.,1.,2.*TMath::Pi()};\r
+    sprintf(name,"fRecTrackHist1_%d",i);\r
+    sprintf(title,"Pt:Eta:Phi");\r
+  \r
+    fRecTrackHist1[i] = new THnSparseF(name,title,3,binsRecTrackHist1,minRecTrackHist1,maxRecTrackHist1);\r
+    fRecTrackHist1[i]->SetBinEdges(0,binsPt);\r
+    fRecTrackHist1[i]->SetBinEdges(1,binsEta);\r
+    fRecTrackHist1[i]->GetAxis(0)->SetTitle("Pt (GeV/c)");\r
+    fRecTrackHist1[i]->GetAxis(1)->SetTitle("Eta");\r
+    fRecTrackHist1[i]->GetAxis(2)->SetTitle("Phi (rad)");\r
+    fRecTrackHist1[i]->Sumw2();\r
+  }\r
+\r
+  Int_t binsCorrRecTrackMultHist1[3]={ptNbins,etaNbins,150};\r
+  Double_t minCorrRecTrackMultHist1[3]={0.,-1.,-0.5}; \r
+  Double_t maxCorrRecTrackMultHist1[3]={20.,1.,149.5};\r
+  for(Int_t i=0; i<8; i++) \r
+  {\r
+    // THnSparse track histograms\r
+    sprintf(name,"fCorrRecTrackMultHist1_%d",i);\r
+    sprintf(title,"Pt:Eta:mult");\r
+    fCorrRecTrackMultHist1[i] = new THnSparseF(name,title,3,binsCorrRecTrackMultHist1,minCorrRecTrackMultHist1,maxCorrRecTrackMultHist1);\r
+    fCorrRecTrackMultHist1[i]->SetBinEdges(0,binsPt);\r
+    fCorrRecTrackMultHist1[i]->SetBinEdges(1,binsEta);\r
+    fCorrRecTrackMultHist1[i]->GetAxis(0)->SetTitle("Pt (GeV/c)");\r
+    fCorrRecTrackMultHist1[i]->GetAxis(1)->SetTitle("Eta");\r
+    fCorrRecTrackMultHist1[i]->GetAxis(2)->SetTitle("multiplicity");\r
+    fCorrRecTrackMultHist1[i]->Sumw2();\r
+  }\r
+\r
+  Int_t binsEventMatrix[2]={zvNbins,150};\r
+  Double_t minEventMatrix[2]={-25.,-0.5};\r
+  Double_t maxEventMatrix[2]={25.,149.5};\r
+\r
+  fMCAllEventMultHist1 = new THnSparseF("fMCAllEventMultHist1","mcZv:mult",2,binsEventMatrix,minEventMatrix,maxEventMatrix);\r
+  fMCAllEventMultHist1->SetBinEdges(0,binsZv);\r
+  fMCAllEventMultHist1->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fMCAllEventMultHist1->GetAxis(1)->SetTitle("multiplicity");\r
+  fMCAllEventMultHist1->Sumw2();\r
+\r
+  fMCAllNDEventMultHist1 = new THnSparseF("fMCAllNDEventMultHist1","mcZv:mult",2,binsEventMatrix,minEventMatrix,maxEventMatrix);\r
+  fMCAllNDEventMultHist1->SetBinEdges(0,binsZv);\r
+  fMCAllNDEventMultHist1->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fMCAllNDEventMultHist1->GetAxis(1)->SetTitle("multiplicity");\r
+  fMCAllNDEventMultHist1->Sumw2();\r
+\r
+  fMCAllNSDEventMultHist1 = new THnSparseF("fMCAllNSDEventMultHist1","mcZv:mult",2,binsEventMatrix,minEventMatrix,maxEventMatrix);\r
+  fMCAllNSDEventMultHist1->SetBinEdges(0,binsZv);\r
+  fMCAllNSDEventMultHist1->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fMCAllNSDEventMultHist1->GetAxis(1)->SetTitle("multiplicity");\r
+  fMCAllNSDEventMultHist1->Sumw2();\r
+\r
+  fMCTriggerMultHist1 = new THnSparseF("fMCTriggerMultHist1","mcZv:mult",2,binsEventMatrix,minEventMatrix,maxEventMatrix);\r
+  fMCTriggerMultHist1->SetBinEdges(0,binsZv);\r
+  fMCTriggerMultHist1->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fMCTriggerMultHist1->GetAxis(1)->SetTitle("multiplicity");\r
+  fMCTriggerMultHist1->Sumw2();\r
+\r
+  fMCEventMultHist1 = new THnSparseF("fMCEventMultHist1","mcZv:mult",2,binsEventMatrix,minEventMatrix,maxEventMatrix);\r
+  fMCEventMultHist1->SetBinEdges(0,binsZv);\r
+  fMCEventMultHist1->GetAxis(0)->SetTitle("mcZv (cm)");\r
+  fMCEventMultHist1->GetAxis(1)->SetTitle("multiplicity");\r
+  fMCEventMultHist1->Sumw2();\r
+\r
+  for(Int_t i=0; i<5; i++) \r
+  {\r
+    // event corrected histograms\r
+    sprintf(name,"fCorrRecEventHist1_%d",i);\r
+    sprintf(title,"mcZv:mult");\r
+    fCorrRecEventHist1[i] = new THnSparseF("fCorrRecEventHist1","mcZv:mult",2,binsEventMatrix,minEventMatrix,maxEventMatrix);\r
+    fCorrRecEventHist1[i]->SetBinEdges(0,binsZv);\r
+    fCorrRecEventHist1[i]->GetAxis(0)->SetTitle("Zv (cm)");\r
+    fCorrRecEventHist1[i]->GetAxis(1)->SetTitle("multiplicity");\r
+    fCorrRecEventHist1[i]->Sumw2();\r
+\r
+    // empty event corrected histograms\r
+    sprintf(name,"fCorrRecEventHist2_%d",i);\r
+    sprintf(title,"mcZv:mult");\r
+    fCorrRecEventHist2[i] = new THnSparseF("fCorrRecEventHist2","mcZv:mult",2,binsEventMatrix,minEventMatrix,maxEventMatrix);\r
+    fCorrRecEventHist2[i]->SetBinEdges(0,binsZv);\r
+    fCorrRecEventHist2[i]->GetAxis(0)->SetTitle("Zv (cm)");\r
+    fCorrRecEventHist2[i]->GetAxis(1)->SetTitle("multiplicity");\r
+    fCorrRecEventHist2[i]->Sumw2();\r
+  }\r
+\r
+  // init output folder\r
+  fCorrectionFolder = CreateFolder("folderdNdPt","Correction dNdPt Folder");\r
+\r
+  // init correction matrices\r
+  TFile *file = (TFile *)TFile::Open(fCorrMatrixFileName.Data()); \r
+  if(!file) { \r
+    AliDebug(AliLog::kError, "file with efficiency matrices not available");\r
+    printf("file with efficiency matrices not available \n");\r
+  } else {\r
+    TFolder *folder = (TFolder *)file->FindObjectAny("folderdNdPt");\r
+    if(!folder) { \r
+      AliDebug(AliLog::kError, "file without folderdNdPt");\r
+      printf("file without folderdNdPt \n");\r
+    } else {\r
+      // rec. event mult vs true multiplicity \r
+      fEventMultCorrelationMatrix = (THnSparseF*)folder->FindObject("event_mult_correlation_matrix");\r
+      if(!fEventMultCorrelationMatrix) {\r
+         Printf("No %s matrix \n", "event_mult_correlation_matrix");\r
+      }\r
+\r
+      //\r
+      // event level corrections (zv,mult_MB)\r
+      //\r
\r
+      // trigger bias correction (MBtoND) \r
+      fCorrTriggerMBtoNDEventMatrix = (THnSparseF*)folder->FindObject("zv_mult_trig_MBtoND_corr_matrix");\r
+      if(!fCorrTriggerMBtoNDEventMatrix) {\r
+         Printf("No %s matrix \n", "zv_mult_trig_MBtoND_corr_matrix");\r
+      }\r
+\r
+      // trigger bias correction (MBtoNSD)\r
+      fCorrTriggerMBtoNSDEventMatrix = (THnSparseF*)folder->FindObject("zv_mult_trig_MBtoNSD_corr_matrix");\r
+      if(!fCorrTriggerMBtoNSDEventMatrix) {\r
+         Printf("No %s matrix \n", "zv_mult_trig_MBtoNSD_corr_matrix");\r
+      }\r
+\r
+      // trigger bias correction (MBtoInel)\r
+      fCorrTriggerMBtoInelEventMatrix = (THnSparseF*)folder->FindObject("zv_mult_trig_MBtoInel_corr_matrix");\r
+      if(!fCorrTriggerMBtoInelEventMatrix) {\r
+         Printf("No %s matrix \n", "zv_mult_trig_MBtoInel_corr_matrix"); \r
+      }\r
+     \r
+      // vertex reconstruction efficiency correction\r
+      fCorrEventMatrix = (THnSparseF*)folder->FindObject("zv_mult_event_corr_matrix");\r
+      if(!fCorrEventMatrix) {\r
+         Printf("No %s matrix \n", "zv_mult_event_corr_matrix");\r
+      }\r
+\r
+      //\r
+      // histogram needed for empty events corrections\r
+      //\r
+      fZvNorm = (TH1D*)folder->FindObject("zv_distribution_norm");\r
+      if(!fZvNorm) {\r
+         Printf("No %s matrix \n", "fZvNorm");\r
+      }\r
+\r
+      fZvEmptyEventsNorm = (TH1D*)folder->FindObject("zv_empty_events_norm");\r
+      if(!fZvEmptyEventsNorm) {\r
+         Printf("No %s matrix \n", "fZvEmptyEventsNorm");\r
+      }\r
+\r
+      //\r
+      // track-event level corrections (zv,pt,eta)\r
+      //\r
+\r
+      // trigger bias correction (MBtoND) \r
+      fCorrTriggerMBtoNDTrackEventMatrix = (THnSparseF*)folder->FindObject("zv_pt_eta_track_trig_MBtoND_corr_matrix");\r
+      if(!fCorrTriggerMBtoNDTrackEventMatrix) {\r
+         Printf("No %s matrix \n", "zv_pt_eta_track_trig_MBtoND_corr_matrix");\r
+      }\r
+\r
+      // trigger bias correction (MBtoNSD)\r
+      fCorrTriggerMBtoNSDTrackEventMatrix = (THnSparseF*)folder->FindObject("zv_pt_eta_track_trig_MBtoNSD_corr_matrix");\r
+      if(!fCorrTriggerMBtoNSDTrackEventMatrix) {\r
+         Printf("No %s matrix \n", "zv_pt_eta_track_trig_MBtoNSD_corr_matrix");\r
+      }\r
+\r
+      // trigger bias correction (MBtoInel) \r
+      fCorrTriggerMBtoInelTrackEventMatrix = (THnSparseF*)folder->FindObject("zv_pt_eta_track_trig_MBtoInel_corr_matrix");\r
+      if(!fCorrTriggerMBtoInelTrackEventMatrix) {\r
+         Printf("No %s matrix \n", "zv_pt_eta_track_trig_MBtoInel_corr_matrix");\r
+      }\r
+    \r
+      // vertex reconstruction efficiency correction (zv,pt,eta)\r
+      fCorrTrackEventMatrix = (THnSparseF*)folder->FindObject("zv_pt_eta_track_event_corr_matrix");\r
+      if(!fCorrTrackEventMatrix) {\r
+         Printf("No %s matrix \n", "zv_pt_eta_track_event_corr_matrix");\r
+      }\r
+\r
+      // track reconstruction efficiency correction (zv,pt,eta)\r
+      fCorrTrackMatrix = (THnSparseF*)folder->FindObject("zv_pt_eta_track_corr_matrix");\r
+      if(!fCorrTrackMatrix) {\r
+         Printf("No %s matrix \n", "zv_pt_eta_track_corr_matrix");\r
+      }\r
+\r
+      // secondary tracks contamination correction (zv,pt,eta)\r
+      fContTrackMatrix = (THnSparseF*)folder->FindObject("zv_pt_eta_track_cont_matrix");\r
+      if(!fContTrackMatrix) {\r
+         Printf("No %s matrix \n", "zv_pt_eta_track_cont_matrix");\r
+      }\r
+\r
+      // multiply reconstructed tracks correction\r
+      fContMultTrackMatrix = (THnSparseF*)folder->FindObject("zv_pt_eta_mult_track_cont_matrix");\r
+      if(!fContMultTrackMatrix) {\r
+         Printf("No %s matrix \n", "zv_pt_eta_mult_track_cont_matrix");\r
+      }\r
+    }\r
+  }\r
+\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AlidNdPtCorrection::Process(AliESDEvent *esdEvent, AliMCEvent *mcEvent)\r
+{\r
+  //\r
+  // Process real and/or simulated events\r
+  //\r
+  if(!esdEvent) {\r
+    AliDebug(AliLog::kError, "esdEvent not available");\r
+    return;\r
+  }\r
+\r
+  // trigger definition\r
+  Bool_t isEventTriggered = AlidNdPtHelper::IsEventTriggered(esdEvent->GetTriggerMask(), GetTrigger());\r
+  //if(!isEventTriggered) printf("no MB1 trigger ... \n");\r
+\r
+  // cuts\r
+  AlidNdPtEventCuts *evtCuts = GetEventCuts(); \r
+  AlidNdPtAcceptanceCuts *accCuts = GetAcceptanceCuts(); \r
+  AliESDtrackCuts *esdTrackCuts = GetTrackCuts(); \r
+\r
+  if(!evtCuts || !accCuts || !esdTrackCuts) {\r
+    AliDebug(AliLog::kError, "cuts not available");\r
+    return;\r
+  }\r
+\r
+  // use MC information\r
+\r
+  AliHeader* header = 0;\r
+  AliGenEventHeader* genHeader = 0;\r
+  AliStack* stack = 0;\r
+  TArrayF vtxMC(3);\r
+  AlidNdPtHelper::MCProcessType evtType = AlidNdPtHelper::kInvalidProcess;\r
+  Int_t multMCTrueTracks = 0;\r
+\r
+  if(IsUseMCInfo())\r
+  {\r
+    if(!mcEvent) {\r
+      AliDebug(AliLog::kError, "mcEvent not available");\r
+      return;\r
+    }\r
+\r
+    // get MC event header\r
+    header = mcEvent->Header();\r
+    if (!header) {\r
+      AliDebug(AliLog::kError, "Header not available");\r
+      return;\r
+    }\r
+    // MC particle stack\r
+    stack = mcEvent->Stack();\r
+    if (!stack) {\r
+      AliDebug(AliLog::kError, "Stack not available");\r
+      return;\r
+    }\r
+\r
+    // get event type (ND=0x1, DD=0x2, SD=0x4)\r
+    evtType = AlidNdPtHelper::GetEventProcessType(header);\r
+    //Printf("evtType %d \n", evtType);\r
+    AliDebug(AliLog::kDebug+1, Form("Found process type %d", evtType));\r
+\r
+    // get MC vertex\r
+    genHeader = header->GenEventHeader();\r
+    if (!genHeader) {\r
+      AliDebug(AliLog::kError, "Could not retrieve genHeader from Header");\r
+      return;\r
+    }\r
+    genHeader->PrimaryVertex(vtxMC);\r
+\r
+    // Fill MC event histogram\r
+    Double_t vMCEventHist1[3]={vtxMC[0],vtxMC[1],vtxMC[2]};\r
+    fMCEventHist1->Fill(vMCEventHist1);\r
+\r
+    // multipliticy of all MC primary tracks\r
+    // in Zvtx, pt and eta ranges\r
+    multMCTrueTracks = AlidNdPtHelper::GetMCTrueTrackMult(mcEvent,evtCuts,accCuts);\r
+\r
+  } // end bUseMC\r
+\r
+  // get reconstructed vertex  \r
+  const AliESDVertex* vtxESD = 0; \r
+  Bool_t isRecVertex = kFALSE;\r
+  if(evtCuts->IsRecVertexRequired()) \r
+  {\r
+    vtxESD = AlidNdPtHelper::GetVertex(esdEvent, evtCuts,  accCuts, esdTrackCuts, GetAnalysisMode(), kFALSE, kTRUE, kTRUE);\r
+    isRecVertex = AlidNdPtHelper::TestVertex(vtxESD, GetAnalysisMode(), kFALSE); // should be moved to AcceptEvent\r
+  }\r
+  if( IsUseMCInfo() &&  !evtCuts->IsRecVertexRequired() ) {\r
+    vtxESD = new AliESDVertex(vtxMC[2],10.,genHeader->NProduced());\r
+    isRecVertex = kTRUE;\r
+  }\r
+  Bool_t isEventOK = evtCuts->AcceptEvent(esdEvent,mcEvent,vtxESD) && isRecVertex; \r
+  //printf("isEventOK %d \n",isEventOK);\r
+\r
+  //\r
+  // get multiplicity of min. bias tracks\r
+  //\r
+  Int_t multMBTracks = 0; \r
+  if(GetAnalysisMode() == AlidNdPtHelper::kTPC || GetAnalysisMode() == AlidNdPtHelper::kMCRec) {  \r
+    multMBTracks = AlidNdPtHelper::GetTPCMBTrackMult(esdEvent,evtCuts,accCuts,esdTrackCuts);\r
+  } \r
+  else if(GetAnalysisMode() == AlidNdPtHelper::kTPCSPDvtx || GetAnalysisMode() == AlidNdPtHelper::kMCRec) {\r
+    multMBTracks = AlidNdPtHelper::GetSPDMBTrackMult(esdEvent,0.0);\r
+  } \r
+  else {\r
+    AliDebug(AliLog::kError, Form("Found analysis type %s", GetAnalysisMode()));\r
+    return; \r
+  }\r
+\r
+  //\r
+  // correct event and track histograms\r
+  //\r
+  TObjArray *allChargedTracks=0;\r
+  Int_t multRec=0, multRecTemp=0;\r
+  Int_t *labelsRec=0;\r
+\r
+  if(isEventOK && isEventTriggered)\r
+  {\r
+    // get all charged tracks\r
+    allChargedTracks = AlidNdPtHelper::GetAllChargedTracks(esdEvent,vtxESD,GetAnalysisMode());\r
+    if(!allChargedTracks) return;\r
+\r
+    Int_t entries = allChargedTracks->GetEntries();\r
+    labelsRec = new Int_t[entries];\r
+\r
+    // calculate mult of reconstructed tracks\r
+    for(Int_t i=0; i<entries;++i) \r
+    {\r
+      AliESDtrack *track = (AliESDtrack*)allChargedTracks->At(i);\r
+      if(!track) continue;\r
+      if(accCuts->AcceptTrack(track)) \r
+      {\r
+        if(esdTrackCuts->AcceptTrack(track)) \r
+       {\r
+         multRecTemp++;\r
+        }\r
+      }\r
+    }  \r
+\r
+    for(Int_t i=0; i<entries;++i) \r
+    {\r
+      AliESDtrack *track = (AliESDtrack*)allChargedTracks->At(i);\r
+      if(!track) continue;\r
+        \r
+      if(accCuts->AcceptTrack(track)) \r
+      {\r
+        if(esdTrackCuts->AcceptTrack(track)) \r
+       {\r
+         // track-level corrections\r
+          if(GetAnalysisMode()==AlidNdPtHelper::kMCRec && IsUseMCInfo()) { \r
+            FillHistograms(track,stack,AlidNdPtHelper::kRecTracks,vtxMC[2],multRecTemp); \r
+         } else {\r
+            FillHistograms(track,stack,AlidNdPtHelper::kRecTracks,vtxESD->GetZv(),multRecTemp); \r
+         }\r
+         labelsRec[multRec] = TMath::Abs(track->GetLabel());\r
+         multRec++;\r
+        }\r
+      }\r
+    }\r
+    // event-level corrections\r
+    if(GetAnalysisMode()==AlidNdPtHelper::kMCRec && IsUseMCInfo()) { \r
+      FillHistograms(AlidNdPtHelper::kRecEvents,vtxMC[2],multMBTracks);\r
+    }\r
+    else {\r
+      FillHistograms(AlidNdPtHelper::kRecEvents,vtxESD->GetZv(),multMBTracks);\r
+    }\r
+\r
+    // control event histograms\r
+    Double_t vRecEventHist1[3] = {vtxESD->GetXv(),vtxESD->GetYv(),vtxESD->GetZv()};\r
+    fRecEventHist1->Fill(vRecEventHist1);\r
+  } \r
+\r
+  // empty events corrections\r
+  // no reconstructed zv\r
+  if(isEventTriggered && multMBTracks==0) {\r
+    if(GetAnalysisMode()==AlidNdPtHelper::kMCRec && IsUseMCInfo()) {\r
+      FillHistograms(AlidNdPtHelper::kTriggeredEvents,vtxMC[2],multMBTracks);\r
+    }\r
+    else {\r
+      Double_t zv = fZvNorm->GetRandom();\r
+      FillHistograms(AlidNdPtHelper::kTriggeredEvents,zv,multMBTracks);\r
+    }\r
+  }\r
+\r
+  if(IsUseMCInfo())  \r
+  {\r
+    // select MC events \r
+    if(evtCuts->AcceptMCEvent(mcEvent))\r
+    {\r
+      //\r
+      // event histograms\r
+      //\r
+      Double_t vMCEventMatrix[2] = {vtxMC[2],multMBTracks};\r
+      fMCAllEventMultHist1->Fill(vMCEventMatrix);\r
+      if(evtType == AlidNdPtHelper::kND) {\r
+        fMCAllNDEventMultHist1->Fill(vMCEventMatrix);\r
+      }\r
+      if(evtType != AlidNdPtHelper::kSD) {\r
+        fMCAllNSDEventMultHist1->Fill(vMCEventMatrix);\r
+      }\r
+      if(isEventTriggered) fMCTriggerMultHist1->Fill(vMCEventMatrix);\r
+      if(isEventTriggered && isEventOK) fMCEventMultHist1->Fill(vMCEventMatrix);\r
+\r
+      //\r
+      // MC histograms for efficiency studies\r
+      //\r
+      Int_t nPart  = stack->GetNtrack();\r
+      for (Int_t iMc = 0; iMc < nPart; ++iMc) \r
+      {\r
+        // print MC stack info\r
+        //AlidNdPtHelper::PrintMCInfo(stack,iMc);\r
+\r
+        TParticle* particle = stack->Particle(iMc);\r
+        if (!particle)\r
+        continue;\r
+\r
+        // only charged particles\r
+        Double_t charge = particle->GetPDG()->Charge()/3.;\r
+        if (charge == 0.0)\r
+          continue;\r
+      \r
+        // physical primary\r
+        Bool_t prim = stack->IsPhysicalPrimary(iMc);\r
+\r
+        // all primaries in acceptance\r
+        if(!accCuts->AcceptTrack(particle)) continue;\r
+        if(!prim) continue;\r
+\r
+        Double_t gpt = particle->Pt();\r
+        Double_t geta = particle->Eta();\r
+\r
+        Double_t valMCAllTrackMultHist1[3] = {gpt,geta,multRec};         \r
+        fMCAllPrimTrackMultHist1->Fill(valMCAllTrackMultHist1);\r
+        if(evtType == AlidNdPtHelper::kND) {\r
+          fMCNDEventAllPrimTrackMultHist1->Fill(valMCAllTrackMultHist1);\r
+        }\r
+        if(evtType != AlidNdPtHelper::kSD) {\r
+          fMCNSDEventAllPrimTrackMultHist1->Fill(valMCAllTrackMultHist1);\r
+        }\r
+        if(isEventTriggered) fMCTriggerPrimTrackMultHist1->Fill(valMCAllTrackMultHist1);\r
+        if(isEventTriggered && isEventOK) fMCEventPrimTrackMultHist1->Fill(valMCAllTrackMultHist1);\r
+      }\r
+    }\r
+  } // end bUseMC\r
+\r
+  if(allChargedTracks) delete allChargedTracks; allChargedTracks = 0;\r
+  if(labelsRec) delete [] labelsRec; labelsRec = 0;\r
+\r
+  if(!evtCuts->IsRecVertexRequired() && vtxESD != NULL) \r
+  delete vtxESD;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AlidNdPtCorrection::FillHistograms(AlidNdPtHelper::EventObject eventObj, Double_t zv, Int_t multMBTracks)\r
+{\r
+  //\r
+  // Fill corrected histograms\r
+  //\r
+\r
+  Double_t vEventMatrix[2] = {zv,multMBTracks};\r
+  //\r
+  // Correct for efficiency \r
+  //\r
+  if(eventObj == AlidNdPtHelper::kRecEvents && multMBTracks>0)  \r
+  {\r
+    Double_t corrToMBF = GetCorrFactZvMult(fCorrEventMatrix,zv,multMBTracks);\r
+    Double_t corrToInelF = GetCorrFactZvMult(fCorrTriggerMBtoInelEventMatrix,zv,multMBTracks);\r
+    Double_t corrToNDF = GetCorrFactZvMult(fCorrTriggerMBtoNDEventMatrix,zv,multMBTracks);\r
+    Double_t corrToNSDF = GetCorrFactZvMult(fCorrTriggerMBtoNSDEventMatrix,zv,multMBTracks);\r
+    //printf("corrToMBF %f, corrToInelF %f, corrToNDF %f corrToNSDF %f \n",corrToMBF,corrToInelF,corrToNDF,corrToNSDF);\r
+\r
+    fCorrRecEventHist1[0]->Fill(vEventMatrix);\r
+    fCorrRecEventHist1[1]->Fill(vEventMatrix,corrToMBF);\r
+    fCorrRecEventHist1[2]->Fill(vEventMatrix,corrToMBF*corrToInelF);\r
+    fCorrRecEventHist1[3]->Fill(vEventMatrix,corrToMBF*corrToNDF);\r
+    fCorrRecEventHist1[4]->Fill(vEventMatrix,corrToMBF*corrToNSDF);\r
+  }\r
+\r
+  if(eventObj==AlidNdPtHelper::kTriggeredEvents && multMBTracks==0) // empty triggered events\r
+  {\r
+    Int_t bin = fZvEmptyEventsNorm->FindBin(zv);\r
+    Double_t Fz = fZvEmptyEventsNorm->GetBinContent(bin);\r
+    Double_t corrToInelF0 = GetCorrFactZvMult(fCorrTriggerMBtoInelEventMatrix,zv,multMBTracks);\r
+    Double_t corrToNDF0 = GetCorrFactZvMult(fCorrTriggerMBtoNDEventMatrix,zv,multMBTracks);\r
+    Double_t corrToNSDF0 = GetCorrFactZvMult(fCorrTriggerMBtoNSDEventMatrix,zv,multMBTracks);\r
+    //printf("Fz %f, corrToInelF0 %f, corrToNDF0 %f, corrToNSDF0 %f \n",Fz,corrToInelF0,corrToNDF0,corrToNSDF0);\r
+\r
+    fCorrRecEventHist2[0]->Fill(vEventMatrix);\r
+    fCorrRecEventHist2[1]->Fill(vEventMatrix,Fz);\r
+    fCorrRecEventHist2[2]->Fill(vEventMatrix,Fz*corrToInelF0);\r
+    fCorrRecEventHist2[3]->Fill(vEventMatrix,Fz*corrToNDF0);\r
+    fCorrRecEventHist2[4]->Fill(vEventMatrix,Fz*corrToNSDF0);\r
+  }\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AlidNdPtCorrection::FillHistograms(AliESDtrack *esdTrack, AliStack *stack, AlidNdPtHelper::TrackObject trackObj, Double_t zv, Int_t mult)\r
+{\r
+  //\r
+  // Fill ESD track and MC histograms \r
+  //\r
+  if(!esdTrack) return;\r
+\r
+  //Float_t q = esdTrack->Charge();\r
+  Float_t pt = esdTrack->Pt();\r
+  Float_t eta = esdTrack->Eta();\r
+  Float_t phi = esdTrack->Phi();\r
+\r
+  if(stack && GetAnalysisMode() == AlidNdPtHelper::kMCRec) \r
+  {\r
+    Int_t label = TMath::Abs(esdTrack->GetLabel());\r
+   \r
+    TParticle* particle = stack->Particle(label);\r
+    if(!particle) return;\r
+   \r
+    Double_t gq = particle->GetPDG()->Charge()/3.0; // Charge units |e|/3\r
+    if(gq==0) return;\r
+    Float_t gpt = particle->Pt();\r
+    Float_t geta = particle->Eta();\r
+    Float_t gphi = particle->Phi();\r
+\r
+    // replace reconstructed values with MC\r
+    pt = gpt;\r
+    eta = geta;\r
+    phi = gphi;\r
+  }\r
+\r
+  //\r
+  // Fill histograms\r
+  //\r
+  Double_t values[3] = {pt,eta,phi};     \r
+  fRecTrackHist1[trackObj]->Fill(values);\r
+\r
+  //\r
+  // Correct for contamination and efficiency \r
+  //\r
+  if(trackObj == AlidNdPtHelper::kRecTracks || GetAnalysisMode() == AlidNdPtHelper::kMCRec)  \r
+  {\r
+    // track level corrections\r
+    Double_t trackEffF = GetCorrFactZvPtEta(fCorrTrackMatrix,zv,pt,eta);\r
+    Double_t trackContF = GetContFactZvPtEta(fContTrackMatrix,zv,pt,eta);\r
+    Double_t multTrackContF = GetContFactZvPtEta(fContMultTrackMatrix,zv,pt,eta);\r
+    //printf("zv %f, pt %f, eta %f \n",zv,pt,eta);\r
+    //printf("trackEffF %f, trackContF %f, multTrackContF %f \n", trackEffF, trackContF, multTrackContF);\r
+   \r
+    // track-event level corrections\r
+    Double_t vertexEffF = GetCorrFactZvPtEta(fCorrTrackEventMatrix,zv,pt,eta);\r
+    Double_t trigMBToInel = GetCorrFactZvPtEta(fCorrTriggerMBtoInelTrackEventMatrix,zv,pt,eta);  \r
+    Double_t trigMBToND = GetCorrFactZvPtEta(fCorrTriggerMBtoNDTrackEventMatrix,zv,pt,eta);\r
+    Double_t trigMBToNSD = GetCorrFactZvPtEta(fCorrTriggerMBtoNSDTrackEventMatrix,zv,pt,eta);\r
+    //printf("vertexEffF %f, trigMBToInel %f, trigMBToNSD %f \n", vertexEffF, trigMBToInel, trigMBToNSD);\r
+\r
+    Double_t valCorrRecTrackMultHist1[3] = {pt,eta,mult};        \r
+    fCorrRecTrackMultHist1[0]->Fill(valCorrRecTrackMultHist1);\r
+    fCorrRecTrackMultHist1[1]->Fill(valCorrRecTrackMultHist1,trackContF);\r
+    fCorrRecTrackMultHist1[2]->Fill(valCorrRecTrackMultHist1,trackContF*trackEffF);\r
+    fCorrRecTrackMultHist1[3]->Fill(valCorrRecTrackMultHist1,trackContF*trackEffF*multTrackContF);\r
+\r
+    fCorrRecTrackMultHist1[4]->Fill(valCorrRecTrackMultHist1,trackContF*trackEffF*multTrackContF*vertexEffF);\r
+    fCorrRecTrackMultHist1[5]->Fill(valCorrRecTrackMultHist1,trackContF*trackEffF*multTrackContF*vertexEffF*trigMBToInel);\r
+    fCorrRecTrackMultHist1[6]->Fill(valCorrRecTrackMultHist1,trackContF*trackEffF*multTrackContF*vertexEffF*trigMBToND);\r
+    fCorrRecTrackMultHist1[7]->Fill(valCorrRecTrackMultHist1,trackContF*trackEffF*multTrackContF*vertexEffF*trigMBToNSD);\r
+\r
+    //\r
+    //Double_t valPtvsPt[2]={pt, pt};    \r
+    //fPtvsPt->Fill(valPtvsPt,trackContF*trackEffF*multTrackContF*vertexEffF*trigMBToNSD);\r
+    //printf("\n histo %p pt %f \n",fPtvsPt,pt);\r
+    //fPtvsPt->Fill(pt,pt,trackContF*trackEffF*multTrackContF*vertexEffF*trigMBToNSD);\r
+  }\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AlidNdPtCorrection::FillHistograms(AliStack *stack, Int_t /*label*/, AlidNdPtHelper::TrackObject /*trackObj*/, Int_t /*mult*/)\r
+{\r
+  // Fill MC histograms\r
+  if(!stack) return;\r
+\r
+  /*\r
+  TParticle* particle = stack->Particle(label);\r
+  if(!particle) return;\r
+\r
+  Int_t mother_pdg = -1;\r
+  TParticle* mother = 0;\r
+\r
+  //TParticle* prim_mother = AlidNdPtHelper::FindPrimaryMother(stack,label);\r
+  Int_t motherLabel = particle->GetMother(0); \r
+  if(motherLabel>0) mother = stack->Particle(motherLabel);\r
+  if(mother) mother_pdg = TMath::Abs(mother->GetPdgCode()); // take abs for visualisation only\r
+  Int_t mech = particle->GetUniqueID(); // production mechanism\r
+\r
+  Double_t gq = particle->GetPDG()->Charge()/3.0; // Charge units |e|/3 \r
+  Float_t gpt = particle->Pt();\r
+  Float_t qgpt = particle->Pt() * gq;\r
+  Float_t geta = particle->Eta();\r
+  Float_t gphi = particle->Phi();\r
+  Float_t gpz = particle->Pz();\r
+\r
+  Bool_t prim = stack->IsPhysicalPrimary(label);\r
+  Float_t vx = particle->Vx(); Float_t vy = particle->Vy(); Float_t vz = particle->Vz();\r
+\r
+  Int_t pid=-1;\r
+  if (TMath::Abs(particle->GetPdgCode()) == kElectron)         { pid = 0; }\r
+    else if (TMath::Abs(particle->GetPdgCode()) == kMuonMinus) { pid = 1; }\r
+    else if (TMath::Abs(particle->GetPdgCode()) == kPiPlus)    { pid = 2; }\r
+    else if (TMath::Abs(particle->GetPdgCode()) == kKPlus)     { pid = 3; }\r
+    else if (TMath::Abs(particle->GetPdgCode()) == kProton)    { pid = 4; }\r
+    else                                                       { pid = 5; }\r
+    */\r
+\r
+  //if(!prim) printf("prim_mother %d, mother %d, particle %d, production mech %d\n",prim_mother->GetPdgCode(),mother->GetPdgCode(), particle->GetPdgCode(),mech);\r
+  \r
+}\r
+\r
+//_____________________________________________________________________________\r
+Double_t AlidNdPtCorrection::GetCorrFactZvPtEta(THnSparse *hist, Double_t zv, Double_t pt, Double_t eta) const {\r
+// return correction factor F(zv,pt,eta)\r
+\r
+ if(!hist) return 1.;\r
+\r
+ //\r
+ TAxis *ax = hist->GetAxis(0);\r
+ TAxis *ay = hist->GetAxis(1);\r
+ TAxis *az = hist->GetAxis(2);\r
+\r
+ Int_t binx = ax->FindBin(zv);\r
+ Int_t biny = ay->FindBin(pt);\r
+ Int_t binz = az->FindBin(eta);\r
+ Int_t dim[3] = {binx,biny,binz};\r
+\r
+ Double_t fact  = hist->GetBinContent(dim);  \r
+\r
+return fact;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+Double_t AlidNdPtCorrection::GetContFactZvPtEta(THnSparse *hist, Double_t zv, Double_t pt, Double_t eta) const {\r
+// return contamination correction factor F(zv,pt,eta)\r
+\r
+ if(!hist) return 1.0;\r
+\r
+ //\r
+ TAxis *ax = hist->GetAxis(0);\r
+ TAxis *ay = hist->GetAxis(1);\r
+ TAxis *az = hist->GetAxis(2);\r
+\r
+ Int_t binx = ax->FindBin(zv);\r
+ Int_t biny = ay->FindBin(pt);\r
+ Int_t binz = az->FindBin(eta);\r
+ Int_t dim[3] = {binx,biny,binz};\r
+\r
+ Double_t fact  = 1.0-hist->GetBinContent(dim);  \r
+ //Double_t fact  = hist->GetBinContent(dim);  \r
+\r
+return fact;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+Double_t AlidNdPtCorrection::GetCorrFactZvMult(THnSparse *hist, Double_t zv, Int_t mult) const {\r
+// return correction factor F(zv,mult)\r
+\r
+ if(!hist) return 1.;\r
+\r
+ TAxis *ax = hist->GetAxis(0);\r
+ TAxis *ay = hist->GetAxis(1);\r
+ Int_t binx = ax->FindBin(zv);\r
+ Int_t biny = ay->FindBin(mult);\r
+ Int_t dim[2] = {binx,biny};\r
+\r
+ Double_t fact  = hist->GetBinContent(dim);  \r
+\r
+\r
+return fact;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+Double_t AlidNdPtCorrection::GetContFactZvMult(THnSparse *hist, Double_t zv, Int_t mult) const {\r
+// return contamination correction factor F(zv,mult)\r
+\r
+ if(!hist) return 1.;\r
+\r
+ TAxis *ax = hist->GetAxis(0);\r
+ TAxis *ay = hist->GetAxis(1);\r
+ Int_t binx = ax->FindBin(zv);\r
+ Int_t biny = ay->FindBin(mult);\r
+ Int_t dim[2] = {binx,biny};\r
+ Double_t fact  = 1.0-hist->GetBinContent(dim);  \r
+\r
+return fact;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+Long64_t AlidNdPtCorrection::Merge(TCollection* list) \r
+{\r
+  // Merge list of objects (needed by PROOF)\r
+\r
+  if (!list)\r
+  return 0;\r
+\r
+  if (list->IsEmpty())\r
+  return 1;\r
+\r
+  TIterator* iter = list->MakeIterator();\r
+  TObject* obj = 0;\r
+\r
+  // collection of generated histograms\r
+\r
+  Int_t count=0;\r
+  while((obj = iter->Next()) != 0) {\r
+    AlidNdPtCorrection* entry = dynamic_cast<AlidNdPtCorrection*>(obj);\r
+    if (entry == 0) continue; \r
+  \r
+    fMCEventHist1->Add(entry->fMCEventHist1);\r
+    fRecEventHist1->Add(entry->fRecEventHist1);\r
+\r
+    fMCAllEventMultHist1->Add(entry->fMCAllEventMultHist1);\r
+    fMCAllNDEventMultHist1->Add(entry->fMCAllNDEventMultHist1);\r
+    fMCAllNSDEventMultHist1->Add(entry->fMCAllNSDEventMultHist1);\r
+    fMCTriggerMultHist1->Add(entry->fMCTriggerMultHist1);\r
+    fMCEventMultHist1->Add(entry->fMCEventMultHist1);\r
+\r
+    fMCAllPrimTrackMultHist1->Add(entry->fMCAllPrimTrackMultHist1);\r
+    fMCNDEventAllPrimTrackMultHist1->Add(entry->fMCNDEventAllPrimTrackMultHist1);\r
+    fMCNSDEventAllPrimTrackMultHist1->Add(entry->fMCNSDEventAllPrimTrackMultHist1);\r
+    fMCTriggerPrimTrackMultHist1->Add(entry->fMCTriggerPrimTrackMultHist1);\r
+    fMCEventPrimTrackMultHist1->Add(entry->fMCEventPrimTrackMultHist1);\r
+\r
+    for(Int_t i=0; i<AlidNdPtHelper::kCutSteps; i++) {\r
+      fRecTrackHist1[i]->Add(entry->fRecTrackHist1[i]);\r
+    }\r
+\r
+    for(Int_t i=0; i<8; i++) {\r
+      fCorrRecTrackMultHist1[i]->Add(entry->fCorrRecTrackMultHist1[i]);\r
+    }\r
+\r
+    for(Int_t i=0; i<5; i++) {\r
+      fCorrRecEventHist1[i]->Add(entry->fCorrRecEventHist1[i]);\r
+      fCorrRecEventHist2[i]->Add(entry->fCorrRecEventHist2[i]);\r
+    }\r
+\r
+    //fPtvsPt->Add(entry->fPtvsPt);\r
+\r
+  count++;\r
+  }\r
+\r
+return count;\r
+}\r
\r
+Int_t AlidNdPtCorrection::GetTrueMult(THnSparse *hist, Int_t mult)\r
+{\r
+ if(!hist) return 0;\r
+ Int_t true_mult = 0;\r
+\r
+ // 0 bins exluded\r
+ TAxis *ax = hist->GetAxis(0);\r
+ TAxis *ay = hist->GetAxis(1);\r
+ ax->SetRange(1,ax->GetNbins());\r
+ ay->SetRange(1,ay->GetNbins());\r
+\r
+ // measured mult\r
+ ax->SetRangeUser((Float_t)mult,(Float_t)mult); \r
+\r
+ // get true multiplicity\r
+ TH1D *h1 = (TH1D *)hist->Projection(1);\r
+ true_mult = (Int_t)h1->GetMean();\r
+\r
+ return true_mult;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AlidNdPtCorrection::Analyse() \r
+{\r
+  // Analyse histograms\r
+  //\r
+  TH1::AddDirectory(kFALSE);\r
+  TH1 *h = 0, *hs=0, *hsc=0; \r
+  TH2 *h2D = 0; \r
+\r
+  TObjArray *aFolderObj = new TObjArray;\r
+\r
+  //\r
+  // get cuts\r
+  //\r
+  AlidNdPtEventCuts *evtCuts = GetEventCuts(); \r
+  AlidNdPtAcceptanceCuts *accCuts = GetAcceptanceCuts(); \r
+  AliESDtrackCuts *esdTrackCuts = GetTrackCuts(); \r
+\r
+  if(!evtCuts || !accCuts || !esdTrackCuts) {\r
+    Error("AlidNdPtCutAnalysis::Analyse()", "cuts not available");\r
+    return;\r
+  }\r
+\r
+  //\r
+  // set min and max values\r
+  //\r
+  Double_t minPt = accCuts->GetMinPt();\r
+  Double_t maxPt = accCuts->GetMaxPt();\r
+  Double_t minEta = accCuts->GetMinEta();\r
+  Double_t maxEta = accCuts->GetMaxEta()-0.00001;\r
+\r
+  //\r
+  // pt profile\r
+  //\r
+  //h2D = fPtvsPt->Projection(1,0);\r
+  //h2D->ProfileX("pt_profile_pt_corrected_NSD");\r
+  //aFolderObj->Add(fPtvsPt);\r
+\r
+  //\r
+  // event level \r
+  //\r
+  h = fCorrRecEventHist1[0]->Projection(1);\r
+  h->SetName("mult_event_not_corrected");\r
+  aFolderObj->Add(h);\r
+\r
+  h = fCorrRecEventHist1[1]->Projection(1);\r
+  h->SetName("mult_event_vertex_corrected");\r
+  aFolderObj->Add(h);\r
+\r
+  h = fCorrRecEventHist1[2]->Projection(1);\r
+  h->SetName("mult_trigger_vertex_corrected");\r
+  aFolderObj->Add(h);\r
+\r
+  h = fCorrRecEventHist1[3]->Projection(1);\r
+  h->SetName("mult_ND_trigger_vertex_corrected");\r
+  aFolderObj->Add(h);\r
+\r
+  h = fCorrRecEventHist1[4]->Projection(1);\r
+  h->SetName("mult_NSD_trigger_vertex_corrected");\r
+  aFolderObj->Add(h);\r
+\r
+  // empty events\r
+  h = fCorrRecEventHist2[0]->Projection(1);\r
+  h->SetName("mult_empty_event_not_corrected");\r
+  aFolderObj->Add(h);\r
+\r
+  h = fCorrRecEventHist2[1]->Projection(1);\r
+  h->SetName("mult_empty_event_vertex_corrected");\r
+  aFolderObj->Add(h);\r
+\r
+  h = fCorrRecEventHist2[2]->Projection(1);\r
+  h->SetName("mult_empty_trigger_vertex_corrected");\r
+  aFolderObj->Add(h);\r
+\r
+  h = fCorrRecEventHist2[3]->Projection(1);\r
+  h->SetName("mult_empty_ND_trigger_vertex_corrected");\r
+  aFolderObj->Add(h);\r
+\r
+  h = fCorrRecEventHist2[4]->Projection(1);\r
+  h->SetName("mult_empty_NSD_trigger_vertex_corrected");\r
+  aFolderObj->Add(h);\r
+\r
+\r
+  // mc \r
+  h = fMCAllEventMultHist1->Projection(1);\r
+  h->SetName("mc_mult_event_acc_prim");\r
+  aFolderObj->Add(h);\r
+\r
+  h = fMCAllNDEventMultHist1->Projection(1);\r
+  h->SetName("mc_mult_ND_event_acc_prim");\r
+  aFolderObj->Add(h);\r
+\r
+  h = fMCAllNSDEventMultHist1->Projection(1);\r
+  h->SetName("mc_mult_NSD_event_acc_prim");\r
+  aFolderObj->Add(h);\r
+\r
+  h = fMCTriggerMultHist1->Projection(1);\r
+  h->SetName("mc_mult_trigger_acc_prim");\r
+  aFolderObj->Add(h);\r
+\r
+  h = fMCEventMultHist1->Projection(1);\r
+  h->SetName("mc_mult_trigger_event_acc_prim");\r
+  aFolderObj->Add(h);\r
+\r
+\r
+  //\r
+  // track level\r
+  //\r
+  \r
+  // limit eta range\r
+  for(Int_t i=0;i<8;i++) { \r
+      fCorrRecTrackMultHist1[i]->GetAxis(0)->SetRangeUser(minPt,maxPt);\r
+      fCorrRecTrackMultHist1[i]->GetAxis(1)->SetRangeUser(minEta,maxEta);\r
+  }\r
+  fMCAllPrimTrackMultHist1->GetAxis(0)->SetRangeUser(minPt,maxPt);\r
+  fMCAllPrimTrackMultHist1->GetAxis(1)->SetRangeUser(minEta,maxEta);\r
+\r
+  fMCNDEventAllPrimTrackMultHist1->GetAxis(0)->SetRangeUser(minPt,maxPt);\r
+  fMCNDEventAllPrimTrackMultHist1->GetAxis(1)->SetRangeUser(minEta,maxEta);\r
+\r
+  fMCNSDEventAllPrimTrackMultHist1->GetAxis(0)->SetRangeUser(minPt,maxPt);\r
+  fMCNSDEventAllPrimTrackMultHist1->GetAxis(1)->SetRangeUser(minEta,maxEta);\r
+\r
+  fMCTriggerPrimTrackMultHist1->GetAxis(0)->SetRangeUser(minPt,maxPt);\r
+  fMCTriggerPrimTrackMultHist1->GetAxis(1)->SetRangeUser(minEta,maxEta);\r
+\r
+  fMCEventPrimTrackMultHist1->GetAxis(0)->SetRangeUser(minPt,maxPt);\r
+  fMCEventPrimTrackMultHist1->GetAxis(1)->SetRangeUser(minEta,maxEta);\r
+  \r
+  //\r
+  h2D = fCorrRecTrackMultHist1[3]->Projection(1,0);\r
+  h2D->SetName("pt_eta_rec_track_mult_eff_cont_corrected");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = fCorrRecTrackMultHist1[4]->Projection(1,0);\r
+  h2D->SetName("pt_eta_rec_event_track_mult_eff_cont_corrected");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = fCorrRecTrackMultHist1[5]->Projection(1,0);\r
+  h2D->SetName("pt_eta_rec_trig_event_track_mult_eff_cont_corrected");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = fCorrRecTrackMultHist1[6]->Projection(1,0);\r
+  h2D->SetName("pt_eta_rec_ND_trig_event_track_mult_eff_cont_corrected");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = fCorrRecTrackMultHist1[7]->Projection(1,0);\r
+  h2D->SetName("pt_eta_rec_NSD_trig_event_track_mult_eff_cont_corrected");\r
+  aFolderObj->Add(h2D);\r
+\r
+\r
+  //\r
+  h2D = fCorrRecTrackMultHist1[3]->Projection(2,0);\r
+  h2D->SetName("pt_mult_rec_track_mult_eff_cont_corrected");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = fCorrRecTrackMultHist1[4]->Projection(2,0);\r
+  h2D->SetName("pt_mult_rec_event_track_mult_eff_cont_corrected");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = fCorrRecTrackMultHist1[5]->Projection(2,0);\r
+  h2D->SetName("pt_mult_rec_trig_event_track_mult_eff_cont_corrected");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = fCorrRecTrackMultHist1[6]->Projection(2,0);\r
+  h2D->SetName("pt_mult_rec_ND_trig_event_track_mult_eff_cont_corrected");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = fCorrRecTrackMultHist1[7]->Projection(2,0);\r
+  h2D->SetName("pt_mult_rec_NSD_trig_event_track_mult_eff_cont_corrected");\r
+  aFolderObj->Add(h2D);\r
+\r
+  // pt axis\r
+\r
+  h = fCorrRecTrackMultHist1[0]->Projection(0);\r
+  h->SetName("pt_rec_track_not_corrected");\r
+  hs = AlidNdPtHelper::ScaleByBinWidth(h);\r
+  hs->SetName("pt_rec_track_not_corrected_s");\r
+  aFolderObj->Add(hs);\r
+\r
+  //\r
+  h = fCorrRecTrackMultHist1[1]->Projection(0);\r
+  h->SetName("pt_rec_track_cont_corrected");\r
+  hs = AlidNdPtHelper::ScaleByBinWidth(h);\r
+  hs->SetName("pt_rec_track_cont_corrected_s");\r
+  aFolderObj->Add(hs);\r
+\r
+  hsc = (TH1D*)hs->Clone("pt_rec_track_cont_corr_fact");\r
+  hsc->Divide((TH1D*)aFolderObj->FindObject("pt_rec_track_not_corrected_s"));\r
+  aFolderObj->Add(hsc);\r
+\r
+  //\r
+  h = fCorrRecTrackMultHist1[2]->Projection(0);\r
+  h->SetName("pt_rec_track_eff_cont_corrected");\r
+  hs = AlidNdPtHelper::ScaleByBinWidth(h);\r
+  hs->SetName("pt_rec_track_eff_cont_corrected_s");\r
+  aFolderObj->Add(hs);\r
+\r
+  hsc = (TH1D*)hs->Clone("pt_rec_track_eff_corr_fact");\r
+  hsc->Divide((TH1D*)aFolderObj->FindObject("pt_rec_track_cont_corrected_s"));\r
+  aFolderObj->Add(hsc);\r
+\r
+  //\r
+  h = fCorrRecTrackMultHist1[3]->Projection(0);\r
+  h->SetName("pt_rec_track_mult_eff_cont_corrected");\r
+  hs = AlidNdPtHelper::ScaleByBinWidth(h);\r
+  hs->SetName("pt_rec_track_mult_eff_cont_corrected_s");\r
+  aFolderObj->Add(hs);\r
+\r
+  hsc = (TH1D*)hs->Clone("pt_rec_track_mult_corr_fact");\r
+  hsc->Divide((TH1D*)aFolderObj->FindObject("pt_rec_track_eff_cont_corrected_s"));\r
+  aFolderObj->Add(hsc);\r
+\r
+  hs = AlidNdPtHelper::ScaleByBinWidth(h);\r
+  hsc = (TH1D*)hs->Clone("pt_rec_track_mult_eff_cont_corr_fact");\r
+  hsc->Divide((TH1D*)aFolderObj->FindObject("pt_rec_track_not_corrected_s"));\r
+  aFolderObj->Add(hsc);\r
+\r
+  hsc = (TH1D*)hs->Clone();\r
+  hsc->SetName("pt_rec_track_mult_eff_cont_corrected_s_norm");\r
+  hsc->Scale(1./(fCorrRecEventHist1[0]->Projection(1)->Integral()));\r
+  aFolderObj->Add(hsc);\r
+\r
+  //\r
+  h = fCorrRecTrackMultHist1[4]->Projection(0);\r
+  h->SetName("pt_rec_event_track_mult_eff_cont_corrected");\r
+  hs = AlidNdPtHelper::ScaleByBinWidth(h);\r
+  hs->SetName("pt_rec_event_track_mult_eff_cont_corrected_s");\r
+  aFolderObj->Add(hs);\r
+\r
+  hsc = (TH1D*)hs->Clone();\r
+  hsc->SetName("pt_rec_event_track_mult_eff_cont_corrected_s_norm");\r
+  hsc->Scale(1./(fCorrRecEventHist1[1]->Projection(1)->Integral()+fCorrRecEventHist2[1]->Projection(1)->Integral()));\r
+  aFolderObj->Add(hsc);\r
+\r
+  //\r
+  h = fCorrRecTrackMultHist1[5]->Projection(0);\r
+  h->SetName("pt_rec_trig_event_track_mult_eff_cont_corrected");\r
+  hs = AlidNdPtHelper::ScaleByBinWidth(h);\r
+  hs->SetName("pt_rec_trig_event_track_mult_eff_cont_corrected_s");\r
+  aFolderObj->Add(hs);\r
+\r
+  hsc = (TH1D*)hs->Clone();\r
+  hsc->SetName("pt_rec_trig_event_track_mult_eff_cont_corrected_s_norm");\r
+  hsc->Scale(1./(fCorrRecEventHist1[2]->Projection(1)->Integral() + fCorrRecEventHist2[2]->Projection(1)->Integral()));\r
+  aFolderObj->Add(hsc);\r
+\r
+  //\r
+  h = fCorrRecTrackMultHist1[6]->Projection(0);\r
+  h->SetName("pt_rec_ND_trig_event_track_mult_eff_cont_corrected");\r
+  hs = AlidNdPtHelper::ScaleByBinWidth(h);\r
+  hs->SetName("pt_rec_ND_trig_event_track_mult_eff_cont_corrected_s");\r
+  aFolderObj->Add(hs);\r
+\r
+  hsc = (TH1D*)hs->Clone();\r
+  hsc->SetName("pt_rec_ND_trig_event_track_mult_eff_cont_corrected_s_norm");\r
+  hsc->Scale(1./(fCorrRecEventHist1[3]->Projection(1)->Integral()+fCorrRecEventHist2[3]->Projection(1)->Integral()));\r
+  aFolderObj->Add(hsc);\r
+\r
+  //\r
+  h = fCorrRecTrackMultHist1[7]->Projection(0);\r
+  h->SetName("pt_rec_NSD_trig_event_track_mult_eff_cont_corrected");\r
+  hs = AlidNdPtHelper::ScaleByBinWidth(h);\r
+  hs->SetName("pt_rec_NSD_trig_event_track_mult_eff_cont_corrected_s");\r
+  aFolderObj->Add(hs);\r
+\r
+  hsc = (TH1D*)hs->Clone();\r
+  hsc->SetName("pt_rec_NSD_trig_event_track_mult_eff_cont_corrected_s_norm");\r
+  hsc->Scale(1./(fCorrRecEventHist1[4]->Projection(1)->Integral()+fCorrRecEventHist2[4]->Projection(1)->Integral()));\r
+  aFolderObj->Add(hsc);\r
+\r
+  // eta axis\r
+  h = fCorrRecTrackMultHist1[0]->Projection(1);\r
+  h->SetName("eta_rec_track_not_corrected");\r
+  aFolderObj->Add(h);\r
+  \r
+  h = fCorrRecTrackMultHist1[1]->Projection(1);\r
+  h->SetName("eta_rec_track_cont_corrected");\r
+  aFolderObj->Add(h);\r
+\r
+  h = fCorrRecTrackMultHist1[2]->Projection(1);\r
+  h->SetName("eta_rec_track_eff_cont_corrected");\r
+  aFolderObj->Add(h);\r
+\r
+  h = fCorrRecTrackMultHist1[3]->Projection(1);\r
+  h->SetName("eta_rec_track_mult_eff_cont_corrected");\r
+  aFolderObj->Add(h);\r
+\r
+  h = fCorrRecTrackMultHist1[4]->Projection(1);\r
+  h->SetName("eta_rec_event_track_mult_eff_cont_corrected");\r
+  aFolderObj->Add(h);\r
+\r
+  h = fCorrRecTrackMultHist1[5]->Projection(1);\r
+  h->SetName("eta_rec_trig_event_track_mult_eff_cont_corrected");\r
+  aFolderObj->Add(h);\r
+\r
+  h = fCorrRecTrackMultHist1[6]->Projection(1);\r
+  h->SetName("eta_rec_ND_trig_event_track_mult_eff_cont_corrected");\r
+  aFolderObj->Add(h);\r
+\r
+  h = fCorrRecTrackMultHist1[7]->Projection(1);\r
+  h->SetName("eta_rec_NSD_trig_event_track_mult_eff_cont_corrected");\r
+  aFolderObj->Add(h);\r
+\r
+\r
+\r
+\r
+  //\r
+  h2D = fMCAllPrimTrackMultHist1->Projection(2,0);\r
+  h2D->SetName("mc_all_pt_mult_acc_prim");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = fMCAllPrimTrackMultHist1->Projection(1,0);\r
+  h2D->SetName("mc_all_eta_pt_acc_prim");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = fMCNDEventAllPrimTrackMultHist1->Projection(2,0);\r
+  h2D->SetName("mc_ND_all_pt_mult_acc_prim");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = fMCNDEventAllPrimTrackMultHist1->Projection(1,0);\r
+  h2D->SetName("mc_ND_all_eta_pt_acc_prim");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = fMCNSDEventAllPrimTrackMultHist1->Projection(2,0);\r
+  h2D->SetName("mc_NSD_all_pt_mult_acc_prim");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = fMCNSDEventAllPrimTrackMultHist1->Projection(1,0);\r
+  h2D->SetName("mc_NSD_all_eta_pt_acc_prim");\r
+  aFolderObj->Add(h2D);\r
+\r
+  //\r
+\r
+  h = fMCAllPrimTrackMultHist1->Projection(0);\r
+  h->SetName("mc_all_pt_acc_prim");\r
+  hs = AlidNdPtHelper::ScaleByBinWidth(h);\r
+  hs->SetName("mc_all_pt_acc_prim_s");\r
+  aFolderObj->Add(hs);\r
+\r
+  hsc = (TH1D*)hs->Clone();\r
+  hsc->SetName("mc_all_pt_acc_prim_s_norm");\r
+  hsc->Scale(1./fMCAllEventMultHist1->Projection(1)->Integral());\r
+  aFolderObj->Add(hsc);\r
+\r
+  h = fMCNDEventAllPrimTrackMultHist1->Projection(0);\r
+  h->SetName("mc_ND_all_pt_acc_prim");\r
+  hs = AlidNdPtHelper::ScaleByBinWidth(h);\r
+  hs->SetName("mc_ND_all_pt_acc_prim_s");\r
+  aFolderObj->Add(hs);\r
+\r
+  hsc = (TH1D*)hs->Clone();\r
+  hsc->SetName("mc_ND_all_pt_acc_prim_s_norm");\r
+  hsc->Scale(1./fMCAllNDEventMultHist1->Projection(1)->Integral());\r
+  aFolderObj->Add(hsc);\r
+\r
+  h = fMCNSDEventAllPrimTrackMultHist1->Projection(0);\r
+  h->SetName("mc_NSD_all_pt_acc_prim");\r
+  hs = AlidNdPtHelper::ScaleByBinWidth(h);\r
+  hs->SetName("mc_NSD_all_pt_acc_prim_s");\r
+  aFolderObj->Add(hs);\r
+\r
+  hsc = (TH1D*)hs->Clone();\r
+  hsc->SetName("mc_NSD_all_pt_acc_prim_s_norm");\r
+  hsc->Scale(1./fMCAllNSDEventMultHist1->Projection(1)->Integral());\r
+  aFolderObj->Add(hsc);\r
+\r
+  h = fMCTriggerPrimTrackMultHist1->Projection(0);\r
+  h->SetName("mc_trigger_all_pt_acc_prim");\r
+  hs = AlidNdPtHelper::ScaleByBinWidth(h);\r
+  hs->SetName("mc_trigger_all_pt_acc_prim_s");\r
+  aFolderObj->Add(hs);\r
+\r
+  hsc = (TH1D*)hs->Clone();\r
+  hsc->SetName("mc_trigger_all_pt_acc_prim_s_norm");\r
+  hsc->Scale(1./fMCTriggerMultHist1->Projection(1)->Integral());\r
+  aFolderObj->Add(hsc);\r
+\r
+  h = fMCEventPrimTrackMultHist1->Projection(0);\r
+  h->SetName("mc_all_pt_acc_trig_event_prim");\r
+  hs = AlidNdPtHelper::ScaleByBinWidth(h);\r
+  hs->SetName("mc_all_pt_acc_trig_event_prim_s");\r
+  aFolderObj->Add(hs);\r
+\r
+  hsc = (TH1D*)hs->Clone();\r
+  hsc->SetName("mc_all_pt_acc_trig_event_prim_s_norm");\r
+  hsc->Scale(1./fMCEventMultHist1->Projection(1)->Integral());\r
+  aFolderObj->Add(hsc);\r
+\r
+  //\r
+\r
+  h = fMCAllPrimTrackMultHist1->Projection(1);\r
+  h->SetName("mc_all_eta_acc_prim");\r
+  aFolderObj->Add(h);\r
+\r
+  h = fMCNDEventAllPrimTrackMultHist1->Projection(1);\r
+  h->SetName("mc_ND_all_eta_acc_prim");\r
+  aFolderObj->Add(h);\r
+\r
+  h = fMCNSDEventAllPrimTrackMultHist1->Projection(1);\r
+  h->SetName("mc_NSD_all_eta_acc_prim");\r
+  aFolderObj->Add(h);\r
+\r
+  h = fMCTriggerPrimTrackMultHist1->Projection(1);\r
+  h->SetName("mc_trigger_all_eta_acc_prim");\r
+  aFolderObj->Add(h);\r
+\r
+  h = fMCEventPrimTrackMultHist1->Projection(1);\r
+  h->SetName("mc_all_eta_acc_trig_event_prim");\r
+  aFolderObj->Add(h);\r
+\r
+  //\r
+  // calculate ratios (rec / mc)\r
+  //\r
+  \r
+  hs = (TH1*)aFolderObj->FindObject("pt_rec_trig_event_track_mult_eff_cont_corrected_s_norm");\r
+  hsc = (TH1D*)hs->Clone("ratio_pt_rec_to_mc_trig_event_track_mult_eff_cont_corrected"); \r
+  hsc->Sumw2();\r
+  hsc->Divide((TH1*)aFolderObj->FindObject("mc_all_pt_acc_prim_s_norm"));\r
+  aFolderObj->Add(hsc);\r
+\r
+  hs = (TH1*)aFolderObj->FindObject("eta_rec_trig_event_track_mult_eff_cont_corrected");\r
+  hsc = (TH1D*)hs->Clone("ratio_eta_rec_to_mc_trig_event_track_mult_eff_cont_corrected"); \r
+  hsc->Sumw2();\r
+  hsc->Divide((TH1*)aFolderObj->FindObject("mc_all_eta_acc_prim"));\r
+  aFolderObj->Add(hsc);\r
+\r
+  //\r
+  hs = (TH1*)aFolderObj->FindObject("pt_rec_ND_trig_event_track_mult_eff_cont_corrected_s_norm");\r
+  hsc = (TH1D*)hs->Clone("ratio_pt_rec_to_mc_ND_trig_event_track_mult_eff_cont_corrected"); \r
+  hsc->Sumw2();\r
+  hsc->Divide((TH1*)aFolderObj->FindObject("mc_ND_all_pt_acc_prim_s_norm"));\r
+  aFolderObj->Add(hsc);\r
+\r
+  hs = (TH1*)aFolderObj->FindObject("eta_rec_ND_trig_event_track_mult_eff_cont_corrected");\r
+  hsc = (TH1D*)hs->Clone("ratio_eta_rec_to_mc_ND_trig_event_track_mult_eff_cont_corrected"); \r
+  hsc->Sumw2();\r
+  hsc->Divide((TH1*)aFolderObj->FindObject("mc_ND_all_eta_acc_prim"));\r
+  aFolderObj->Add(hsc);\r
+\r
+  //\r
+  hs = (TH1*)aFolderObj->FindObject("pt_rec_NSD_trig_event_track_mult_eff_cont_corrected_s_norm");\r
+  hsc = (TH1D*)hs->Clone("ratio_pt_rec_to_mc_NSD_trig_event_track_mult_eff_cont_corrected"); \r
+  hsc->Sumw2();\r
+  hsc->Divide((TH1*)aFolderObj->FindObject("mc_NSD_all_pt_acc_prim_s_norm"));\r
+  aFolderObj->Add(hsc);\r
+\r
+  hs = (TH1*)aFolderObj->FindObject("eta_rec_NSD_trig_event_track_mult_eff_cont_corrected");\r
+  hsc = (TH1D*)hs->Clone("ratio_eta_rec_to_mc_NSD_trig_event_track_mult_eff_cont_corrected"); \r
+  hsc->Sumw2();\r
+  hsc->Divide((TH1*)aFolderObj->FindObject("mc_NSD_all_eta_acc_prim"));\r
+  aFolderObj->Add(hsc);\r
+\r
+  //\r
+  hs = (TH1*)aFolderObj->FindObject("pt_rec_event_track_mult_eff_cont_corrected_s_norm");\r
+  hsc = (TH1D*)hs->Clone("ratio_pt_rec_to_mc_event_track_mult_eff_cont_corrected"); \r
+  hsc->Sumw2();\r
+  hsc->Divide((TH1*)aFolderObj->FindObject("mc_trigger_all_pt_acc_prim_s_norm"));\r
+  aFolderObj->Add(hsc);\r
+\r
+  hs = (TH1*)aFolderObj->FindObject("eta_rec_event_track_mult_eff_cont_corrected");\r
+  hsc = (TH1D*)hs->Clone("ratio_eta_rec_to_mc_event_track_mult_eff_cont_corrected"); \r
+  hsc->Sumw2();\r
+  hsc->Divide((TH1*)aFolderObj->FindObject("mc_trigger_all_eta_acc_prim"));\r
+  aFolderObj->Add(hsc);\r
+\r
+  // track level\r
+  hs = (TH1*)aFolderObj->FindObject("pt_rec_track_mult_eff_cont_corrected_s_norm");\r
+  hsc = (TH1D*)hs->Clone("ratio_pt_rec_to_mc_track_mult_eff_cont_corrected"); \r
+  hsc->Sumw2();\r
+  hsc->Divide((TH1*)aFolderObj->FindObject("mc_all_pt_acc_trig_event_prim_s_norm"));\r
+  aFolderObj->Add(hsc);\r
+\r
+  hs = (TH1*)aFolderObj->FindObject("eta_rec_track_mult_eff_cont_corrected");\r
+  hsc = (TH1D*)hs->Clone("ratio_eta_rec_to_mc_track_mult_eff_cont_corrected"); \r
+  hsc->Sumw2();\r
+  hsc->Divide((TH1*)aFolderObj->FindObject("mc_all_eta_acc_trig_event_prim"));\r
+  aFolderObj->Add(hsc);\r
+\r
+  // export objects to analysis folder\r
+  fCorrectionFolder = ExportToFolder(aFolderObj);\r
+\r
+  // delete only TObjArray\r
+  if(aFolderObj) delete aFolderObj;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+TFolder* AlidNdPtCorrection::ExportToFolder(TObjArray * array) \r
+{\r
+  // recreate folder avery time and export objects to new one\r
+  //\r
+  AlidNdPtCorrection * comp=this;\r
+  TFolder *folder = comp->GetCorrectionFolder();\r
+\r
+  TString name, title;\r
+  TFolder *newFolder = 0;\r
+  Int_t i = 0;\r
+  Int_t size = array->GetSize();\r
+\r
+  if(folder) { \r
+     // get name and title from old folder\r
+     name = folder->GetName();  \r
+     title = folder->GetTitle();  \r
+\r
+        // delete old one\r
+     delete folder;\r
+\r
+        // create new one\r
+     newFolder = CreateFolder(name.Data(),title.Data());\r
+     newFolder->SetOwner();\r
+\r
+        // add objects to folder\r
+     while(i < size) {\r
+          newFolder->Add(array->At(i));\r
+          i++;\r
+        }\r
+  }\r
+\r
+return newFolder;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+TFolder* AlidNdPtCorrection::CreateFolder(TString name,TString title) { \r
+// create folder for analysed histograms\r
+//\r
+TFolder *folder = 0;\r
+  folder = new TFolder(name.Data(),title.Data());\r
+\r
+  return folder;\r
+}\r
diff --git a/PWG0/dNdPt/AlidNdPtCorrection.h b/PWG0/dNdPt/AlidNdPtCorrection.h
new file mode 100644 (file)
index 0000000..85ae0c9
--- /dev/null
@@ -0,0 +1,273 @@
+#ifndef ALIDEDPTCORRECTION_H
+#define ALIDEDPTCORRECTION_H
+
+//------------------------------------------------------------------------------
+// AlidNdPtCorrection class:
+//
+// a. functionality:
+// - applies corrections on dNdPt spectra
+// - fills corrected dNdPt histograms
+// - fills correction control histograms 
+//
+// b. data members:
+// - dNdPt spectra before and after correction procedure
+// - control histograms
+// - correction matrices (must be loaded)
+// 
+// Author: J.Otwinowski 04/11/2008 
+//------------------------------------------------------------------------------
+
+
+class TProfile;
+class TFolder;
+class TObjArray;
+class TString;
+
+class AliESDtrackCuts;
+class AliVertexerTracks;
+class AliESD;
+class AliESDfriend;
+class AliESDfriendTrack;
+
+class AlidNdPtEventCuts;
+class AlidNdPtAcceptanceCuts;
+class AlidNdPtCorrection;
+class AlidNdPt;
+
+#include "THnSparse.h"
+#include "AlidNdPt.h"
+#include "AlidNdPtHelper.h"
+
+class AlidNdPtCorrection : public AlidNdPt {
+public :
+  AlidNdPtCorrection(); 
+  AlidNdPtCorrection(Char_t* name, Char_t* title, TString corrMatrixFileName="ala.root");
+  ~AlidNdPtCorrection();
+
+  // Init data members
+  virtual void Init();
+
+  // Process events
+  virtual void Process(AliESDEvent *const esdEvent=0, AliMCEvent *const mcEvent=0);
+
+  // Merge output objects (needed by PROOF) 
+  virtual Long64_t Merge(TCollection* list);
+
+  // Analyse output histograms 
+  virtual void Analyse();
+
+  // Export objects to folder
+  virtual TFolder *ExportToFolder(TObjArray * array=0);
+
+  // Get analysis folder
+  TFolder* GetCorrectionFolder() {return fCorrectionFolder;}
+
+  // Create folder for analysed histograms
+  TFolder *CreateFolder(TString folder = "folderdNdPtCorrection",TString title = "Analysed dNdPt histograms");
+
+  // Fill histograms
+  void FillHistograms(AliESDtrack *const esdTrack, AliStack *const stack, AlidNdPtHelper::TrackObject trackObj, Double_t zv, Int_t multRec);
+  void FillHistograms(AliStack *const stack, Int_t label, AlidNdPtHelper::TrackObject trackObj, Int_t multRec);
+  void FillHistograms(AlidNdPtHelper::EventObject eventObj, Double_t zv, Int_t multMBRec);
+
+  // Get correction factors
+  Double_t GetCorrFactZvPtEta(THnSparse *const hist=0, Double_t zv =0, Double_t pt=0, Double_t eta=0) const;
+  Double_t GetContFactZvPtEta(THnSparse *const hist=0, Double_t zv =0, Double_t pt=0, Double_t eta=0) const;
+  Double_t GetCorrFactZvMult(THnSparse *const hist=0, Double_t zv =0, Int_t mult=0) const;
+  Double_t GetContFactZvMult(THnSparse *const hist=0, Double_t zv =0, Int_t mult=0) const;
+
+  // Getters
+  THnSparseF *GetMCAllEventMultHist1() {return fMCAllEventMultHist1;}; 
+  THnSparseF *GetMCAllNDEventMultHist1() {return fMCAllNDEventMultHist1;}; 
+  THnSparseF *GetMCAllNSDEventMultHist1() {return fMCAllNSDEventMultHist1;}; 
+  THnSparseF *GetMCTriggerMultHist1() {return fMCTriggerMultHist1;}; 
+  THnSparseF *GetMCEventMultHist1() {return fMCEventMultHist1;}; 
+
+  THnSparseF *GetMCAllPrimTrackMultHist1() {return fMCAllPrimTrackMultHist1;}; 
+  THnSparseF *GetMCNDEventAllPrimTrackMultHist1() {return fMCNDEventAllPrimTrackMultHist1;}; 
+  THnSparseF *GetMCNSDEventAllPrimTrackMultHist1() {return fMCNSDEventAllPrimTrackMultHist1;}; 
+  THnSparseF *GetMCTriggerPrimTrackMultHist1() {return fMCTriggerPrimTrackMultHist1;}; 
+  THnSparseF *GetMCEventPrimTrackMultHist1() {return fMCEventPrimTrackMultHist1;}; 
+
+  THnSparseF *GetCorrRecTrackMultHist1(Int_t i) {return fCorrRecTrackMultHist1[i];}
+  THnSparseF *GetCorrRecEventHist1(Int_t i) {return fCorrRecEventHist1[i];}
+  THnSparseF *GetCorrRecEventHist2(Int_t i) {return fCorrRecEventHist2[i];}
+
+  //THnSparseF *GetPtvsPt() {return fPtvsPt;}
+  //TProfile *GetPtvsPt() {return fPtvsPt;}
+
+  // correlation matrix
+  void SetEventMultCorrelationMatrix(THnSparseF *const matrix=0) {fEventMultCorrelationMatrix = matrix;}
+  THnSparseF *GetEventMultCorrelationMatrix() {return fEventMultCorrelationMatrix;}
+
+  //
+  void SetZvNorm(TH1D *const matrix=0) {fZvNorm = matrix;}
+  TH1D *GetZvNorm() {return fZvNorm;}
+
+  void SetZvEmptyEventsNorm(TH1D *const matrix=0) {fZvEmptyEventsNorm = matrix;}
+  TH1D *GetZvEmptyEventsNorm() {return fZvEmptyEventsNorm;}
+
+  // 
+  void SetCorrEventMatrix(THnSparseF *const matrix=0) {fCorrEventMatrix = matrix;}
+  THnSparseF *GetCorrEventMatrix() {return fCorrEventMatrix;}
+
+  void SetCorrTriggerMBtoInelEventMatrix(THnSparseF *const matrix=0) {fCorrTriggerMBtoInelEventMatrix = matrix;}
+  THnSparseF *GetCorrTriggerMBtoInelEventMatrix() {return fCorrTriggerMBtoInelEventMatrix;}
+
+  void SetCorrTriggerMBtoNDEventMatrix(THnSparseF *const matrix=0) {fCorrTriggerMBtoNDEventMatrix = matrix;}
+  THnSparseF *GetCorrTriggerMBtoNDEventMatrix() {return fCorrTriggerMBtoNDEventMatrix;}
+
+  void SetCorrTriggerMBtoNSDEventMatrix(THnSparseF *const matrix=0) {fCorrTriggerMBtoNSDEventMatrix = matrix;}
+  THnSparseF *GetCorrTriggerMBtoNSDEventMatrix() {return fCorrTriggerMBtoNSDEventMatrix;}
+
+  // 
+  void SetCorrTrackEventMatrix(THnSparseF *const matrix=0) {fCorrTrackEventMatrix = matrix;}
+  THnSparseF *GetCorrTrackEventMatrix() {return fCorrTrackEventMatrix;}
+
+  void SetCorrTriggerMBtoInelTrackEventMatrix(THnSparseF *const matrix=0) {fCorrTriggerMBtoInelTrackEventMatrix = matrix;}
+  THnSparseF *GetCorrTriggerMBtoInelTrackEventMatrix() {return fCorrTriggerMBtoInelTrackEventMatrix;}
+
+  void SetCorrTriggerMBtoNDTrackEventMatrix(THnSparseF *const matrix=0) {fCorrTriggerMBtoNDTrackEventMatrix = matrix;}
+  THnSparseF *GetCorrTriggerMBtoNDTrackEventMatrix() {return fCorrTriggerMBtoNDTrackEventMatrix;}
+
+  void SetCorrTriggerMBtoNSDTrackEventMatrix(THnSparseF *const matrix=0) {fCorrTriggerMBtoNSDTrackEventMatrix = matrix;}
+  THnSparseF *GetCorrTriggerMBtoNSDTrackEventMatrix() {return fCorrTriggerMBtoNSDTrackEventMatrix;}
+
+  void SetCorrTrackMatrix(THnSparseF *const matrix=0) {fCorrTrackMatrix = matrix;}
+  THnSparseF *GetCorrTrackMatrix() {return fCorrTrackMatrix;}
+
+  void SetContTrackMatrix(THnSparseF *const matrix=0) {fContTrackMatrix = matrix;}
+  THnSparseF *GetContTrackMatrix() {return fContTrackMatrix;}
+
+  void SetContMultTrackMatrix(THnSparseF *const matrix=0) {fContMultTrackMatrix = matrix;}
+  THnSparseF *GetContMultTrackMatrix() {return fContMultTrackMatrix;}
+
+  void SetCorrMatrixFileName(TString name="")    { fCorrMatrixFileName = name; }
+
+  Int_t GetTrueMult(THnSparse *const hist=0, Int_t mult=0);
+
+private:
+
+  // analysis folder 
+  TFolder *fCorrectionFolder; // folder for analysed histograms
+
+  //
+  // event histograms
+  //
+  THnSparseF *fMCEventHist1;  //-> mcXv:mcYv:mcZv
+  THnSparseF *fRecEventHist1; //-> Xv:Yv:Zv
+
+  // all MC events
+  THnSparseF *fMCAllEventMultHist1; //-> mcZv:multiplicity
+
+  // all ND MC events
+  THnSparseF *fMCAllNDEventMultHist1; //-> mcZv:multiplicity
+
+  // all NSD MC events
+  THnSparseF *fMCAllNSDEventMultHist1; //-> mcZv:multiplicity
+
+  // MC triggered events
+  THnSparseF *fMCTriggerMultHist1; //-> mcZv:multiplicity
+
+  // MC triggered and event vertex
+  THnSparseF *fMCEventMultHist1; //-> mcZv:multiplicity
+
+  //
+  // track histograms
+  //
+  
+  // all mc primary tracks in acceptance (INEL)
+  THnSparseF *fMCAllPrimTrackMultHist1; //-> mcPt:mcEta:multiplicity
+
+  // all mc primary tracks in acceptance (ND events)
+  THnSparseF *fMCNDEventAllPrimTrackMultHist1; //-> mcPt:mcEta:multiplicity
+
+  // all mc primary tracks in acceptance (NSD events)
+  THnSparseF *fMCNSDEventAllPrimTrackMultHist1; //-> mcPt:mcEta:multiplicity
+
+  //all mc primary tracks in acceptance (triggered events)
+  THnSparseF *fMCTriggerPrimTrackMultHist1; //-> mcPt:mcEta:multiplicity
+
+  //mc primary tracks in acceptance (triggered and event vertex reconstructed)
+  THnSparseF *fMCEventPrimTrackMultHist1; //-> mcPt:mcEta:multiplicity
+
+  // pt vs pt to get proper pt bin (center of gravity)
+  // THnSparseF *fPtvsPt; //-> pt:pt 
+  //TProfile *fPtvsPt; //-> pt profile
+
+  // track histograms 
+  // [0]=all charged tracks, 
+  // [1]=[0]+fiducual volume, 
+  // [2]=[1]+after esd track cuts 
+  THnSparseF *fRecTrackHist1[AlidNdPtHelper::kCutSteps]; //-> Pt:Eta:Phi
+
+  // corrected track histograms 
+  // ([0]-not corrected,
+  // [1]=track cont.,
+  // [2]=[1]+track eff.,
+  // [3]=[2]+multple track,
+  // [4]=[3]+event vertex,
+  // [5]=[4]+trigger MBtoInel,
+  // [6]=[4]+trigger MBtoND, 
+  // [7]=[4]+trigger MBToNSD)
+  THnSparseF *fCorrRecTrackMultHist1[8]; //-> Pt:Eta:mult corrected histograms 
+
+  // corrected event histograms
+  // [0]-not corrected, 
+  // [1]=event vertex, 
+  // [2]=[1]+trigger MBtoInel, 
+  // [3]=[1]+trigger MBtoND, 
+  // [4]=[1]+trigger MBtoNSD 
+  THnSparseF *fCorrRecEventHist1[5]; //-> mcZv:multMB 
+
+  // corrected event histograms (empty events)
+  // [0]=not corrected,
+  // [1]=trigger/trigger+vertex correction,
+  // [2]=[1]+trigger MBtoInel,
+  // [3]=[1]+trigger MBtoND,
+  // [4]=[1]+trigger MBtoNSD
+  THnSparseF *fCorrRecEventHist2[5]; //-> mcZv:multMB
+
+
+  // 
+  // correction matrices (histograms)
+  // must be loaded
+  //
+
+  // event rec. track vs true track multiplicity correlation matrix 
+  THnSparseF *fEventMultCorrelationMatrix; //-> mult:mult_true_tracks
+
+  // histograms needed for empty events corrections
+  TH1D *fZvNorm; //-> normalised reconstructed zv distribution
+  TH1D *fZvEmptyEventsNorm; //-> trigger/trigger+vertex empty event correction
+
+  // trigger bias corrections
+  THnSparseF *fCorrTriggerMBtoInelEventMatrix; //-> mcVz:mcPt:mcEta (fTriggerEventMatrix / fGenEventMatrix)
+  THnSparseF *fCorrTriggerMBtoNDEventMatrix; //-> mcVz:mcPt:mcEta (fTriggerEventMatrix / fGenNDEventMatrix)
+  THnSparseF *fCorrTriggerMBtoNSDEventMatrix; //-> mcVz:mcPt:mcEta (fTriggerEventMatrix / fGenNSDEventMatrix)
+
+  // event vertex corrections
+  THnSparseF *fCorrEventMatrix;  //-> mcVz:mcPt:mcEta   (fRecEventMatrix/fTriggerEventMatrix)
+
+  // track-event trigger bias corrections
+  THnSparseF *fCorrTriggerMBtoInelTrackEventMatrix; //-> mcVz:mcPt:mcEta (fTriggerTrackEventMatrix / fGenTrackEventMatrix)
+  THnSparseF *fCorrTriggerMBtoNDTrackEventMatrix; //-> mcVz:mcPt:mcEta (fTriggerTrackEventMatrix / fGenTrackEventNDMatrix)
+  THnSparseF *fCorrTriggerMBtoNSDTrackEventMatrix; //-> mcVz:mcPt:mcEta (fTriggerTrackEventMatrix / fGenTrackEventNSDMatrix)
+
+  // track-event vertex corrections
+  THnSparseF *fCorrTrackEventMatrix;  //-> mcVz:mcPt:mcEta   (fRecTrackEventMatrix/fTriggerTrackEventMatrix)
+
+  // track-level corrections
+  THnSparseF *fCorrTrackMatrix;  //-> mcVz:mcPt:mcEta (fRecPrimTrackMatrix / fGenPrimTrackMatrix)
+  THnSparseF *fContTrackMatrix;  //-> mcVz:mcPt:mcEta (fRecSecTrackMatrix / fRecTrackMatrix)
+  THnSparseF *fContMultTrackMatrix; //-> mcVz:mcPt:mcEta (fRecMultTrackMatrix / fRecTrackMatrix)
+  
+  TString fCorrMatrixFileName; // file with efficiency correction matrices
+  
+  AlidNdPtCorrection(const AlidNdPtCorrection&); // not implemented
+  AlidNdPtCorrection& operator=(const AlidNdPtCorrection&); // not implemented
+
+  ClassDef(AlidNdPtCorrection,1);
+};
+
+#endif
diff --git a/PWG0/dNdPt/AlidNdPtCutAnalysis.cxx b/PWG0/dNdPt/AlidNdPtCutAnalysis.cxx
new file mode 100644 (file)
index 0000000..b40c27c
--- /dev/null
@@ -0,0 +1,556 @@
+/**************************************************************************\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
+#include <iostream>\r
+\r
+#include "TFile.h"\r
+#include "TCint.h"\r
+#include "TH1.h"\r
+#include "TH2.h"\r
+\r
+#include "AliHeader.h"  \r
+#include "AliGenEventHeader.h"  \r
+#include "AliStack.h"  \r
+#include "AliESDEvent.h"  \r
+#include "AliMCEvent.h"  \r
+#include "AliESDtrackCuts.h"  \r
+#include "AliLog.h" \r
+\r
+#include "AlidNdPtEventCuts.h"\r
+#include "AlidNdPtAcceptanceCuts.h"\r
+\r
+#include "AlidNdPtCutAnalysis.h"\r
+\r
+using namespace std;\r
+\r
+ClassImp(AlidNdPtCutAnalysis)\r
+\r
+//_____________________________________________________________________________\r
+  AlidNdPtCutAnalysis::AlidNdPtCutAnalysis(): AlidNdPt(),\r
+  fAnalysisFolder(0),\r
+  fRecEventHist(0),\r
+  fMCEventHist(0),\r
+  fRecMCEventHist(0),\r
+  fRecMCTrackHist(0)\r
+{\r
+  // default constructor\r
+  Init();\r
+}\r
+\r
+//_____________________________________________________________________________\r
+AlidNdPtCutAnalysis::AlidNdPtCutAnalysis(Char_t* name, Char_t* title): AlidNdPt(name,title),\r
+  fAnalysisFolder(0),\r
+  fRecEventHist(0),\r
+  fMCEventHist(0),\r
+  fRecMCEventHist(0),\r
+  fRecMCTrackHist(0)\r
+{\r
+  // constructor\r
+  Init();\r
+}\r
+\r
+//_____________________________________________________________________________\r
+AlidNdPtCutAnalysis::~AlidNdPtCutAnalysis() {\r
+  // \r
+  if(fRecEventHist) delete fRecEventHist; fRecEventHist=0;\r
+  if(fMCEventHist) delete fMCEventHist; fMCEventHist=0;\r
+  if(fRecMCEventHist) delete fRecMCEventHist; fRecMCEventHist=0;\r
+  if(fRecMCTrackHist) delete fRecMCTrackHist; fRecMCTrackHist=0;\r
+\r
+  if(fAnalysisFolder) delete fAnalysisFolder; fAnalysisFolder=0;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AlidNdPtCutAnalysis::Init(){\r
+  //\r
+  // Init histograms\r
+  //\r
+  const Int_t ptNbins = 56; \r
+  const Double_t ptMin = 0.; \r
+  const Double_t ptMax = 16.; \r
+\r
+  Double_t binsPt[ptNbins+1] = {0.,0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.2,2.4,2.6,2.8,3.0,3.2,3.4,3.6,3.8,4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0};\r
+\r
+  //Xv:Yv:Zv:ResZv:Mult\r
+  Int_t binsRecEventHist[5]={100,100,140,100,150};\r
+  Double_t minRecEventHist[5]={-3.,-3.,-35.,0.,0.}; \r
+  Double_t maxRecEventHist[5]={3.,3.,35.,10.,150.}; \r
+  fRecEventHist = new THnSparseF("fRecEventHist","Xv:Yv:Zv:ResZv:Mult",5,binsRecEventHist,minRecEventHist,maxRecEventHist);\r
+  fRecEventHist->GetAxis(0)->SetTitle("Xv (cm)");\r
+  fRecEventHist->GetAxis(1)->SetTitle("Yv (cm)");\r
+  fRecEventHist->GetAxis(2)->SetTitle("Zv (cm)");\r
+  fRecEventHist->GetAxis(3)->SetTitle("ResZv (cm)");\r
+  fRecEventHist->GetAxis(4)->SetTitle("Mult");\r
+  fRecEventHist->Sumw2();\r
+\r
+  //Xv:Yv:Zv\r
+  Int_t binsMCEventHist[3]={100,100,140};\r
+  Double_t minMCEventHist[3]={-0.1,-0.1,-35.}; \r
+  Double_t maxMCEventHist[3]={0.1,0.1,35.}; \r
+  fMCEventHist = new THnSparseF("fMCEventHist","mcXv:mcYv:mcZv",3,binsMCEventHist,minMCEventHist,maxMCEventHist);\r
+  fMCEventHist->GetAxis(0)->SetTitle("mcXv (cm)");\r
+  fMCEventHist->GetAxis(1)->SetTitle("mcYv (cm)");\r
+  fMCEventHist->GetAxis(2)->SetTitle("mcZv (cm)");\r
+  fMCEventHist->Sumw2();\r
+\r
+  //Xv-mcXv:Yv-mcYv:Zv-mcZv:Mult\r
+  Int_t binsRecMCEventHist[4]={100,100,100,150};\r
+  Double_t minRecMCEventHist[4]={-10.0,-10.0,-10.0,0.}; \r
+  Double_t maxRecMCEventHist[4]={10.0,10.0,10.0,150.}; \r
+  fRecMCEventHist = new THnSparseF("fRecMCEventHist","mcXv-Xv:mcYv-Yv:mcZv-Zv:Mult",4,binsRecMCEventHist,minRecMCEventHist,maxRecMCEventHist);\r
+  fRecMCEventHist->GetAxis(0)->SetTitle("mcXv-Xv (cm)");\r
+  fRecMCEventHist->GetAxis(1)->SetTitle("mcYv-Yv (cm)");\r
+  fRecMCEventHist->GetAxis(2)->SetTitle("mcZv-Zv (cm)");\r
+  fRecMCEventHist->GetAxis(3)->SetTitle("Mult");\r
+  fRecMCEventHist->Sumw2();\r
+\r
+  //\r
+  // THnSparse track histograms\r
+  //\r
+\r
+  //nClust:chi2PerClust:nClust/nFindableClust:DCAy:DCAz:eta:phi:pt:isKink:isPrim\r
+  Int_t binsRecMCTrackHist[10]={160,100,100,100,100,30,90,ptNbins, 2,2};\r
+  Double_t minRecMCTrackHist[10]={0., 0., 0., -10.,-10.,-1.5, 0., ptMin, 0., 0.};\r
+  Double_t maxRecMCTrackHist[10]={160.,10.,1.2, 10.,10.,1.5, 2.*TMath::Pi(), ptMax, 2.,2.};\r
+\r
+  fRecMCTrackHist = new THnSparseF("fRecMCTrackHist","nClust:chi2PerClust:nClust/nFindableClust:DCAy:DCAz:eta:phi:pt:isKink:isPrim",10,binsRecMCTrackHist,minRecMCTrackHist,maxRecMCTrackHist);\r
+  fRecMCTrackHist->SetBinEdges(7,binsPt);\r
+\r
+  fRecMCTrackHist->GetAxis(0)->SetTitle("nClust");\r
+  fRecMCTrackHist->GetAxis(1)->SetTitle("chi2PerClust");\r
+  fRecMCTrackHist->GetAxis(2)->SetTitle("nClust/nFindableClust");\r
+  fRecMCTrackHist->GetAxis(3)->SetTitle("DCAy (cm)");\r
+  fRecMCTrackHist->GetAxis(4)->SetTitle("DCAz (cm)");\r
+  fRecMCTrackHist->GetAxis(5)->SetTitle("#eta");\r
+  fRecMCTrackHist->GetAxis(6)->SetTitle("#phi (rad)");\r
+  fRecMCTrackHist->GetAxis(7)->SetTitle("p_{T} (GeV/c)");\r
+  fRecMCTrackHist->GetAxis(8)->SetTitle("isKink");\r
+  fRecMCTrackHist->GetAxis(9)->SetTitle("isPrim");\r
+  fRecMCTrackHist->Sumw2();\r
+\r
+  // init output folder\r
+  fAnalysisFolder = CreateFolder("folderdNdPt","Analysis dNdPt Folder");\r
+\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AlidNdPtCutAnalysis::Process(AliESDEvent *const esdEvent, AliMCEvent * const mcEvent)\r
+{\r
+  //\r
+  // Process real and/or simulated events\r
+  //\r
+  if(!esdEvent) {\r
+    AliDebug(AliLog::kError, "esdEvent not available");\r
+    return;\r
+  }\r
+\r
+  // trigger definition\r
+  Bool_t isEventTriggered = AlidNdPtHelper::IsEventTriggered(esdEvent->GetTriggerMask(), GetTrigger());\r
+  //if(!isEventTriggered) printf("no MB1 trigger ... \n");\r
+\r
+  // cuts\r
+  AlidNdPtEventCuts *evtCuts = GetEventCuts(); \r
+  AlidNdPtAcceptanceCuts *accCuts = GetAcceptanceCuts(); \r
+  AliESDtrackCuts *esdTrackCuts = GetTrackCuts(); \r
+\r
+  if(!evtCuts || !accCuts || !esdTrackCuts) {\r
+    AliDebug(AliLog::kError, "cuts not available");\r
+    return;\r
+  }\r
+\r
+  // use MC information\r
+  AliHeader* header = 0;\r
+  AliGenEventHeader* genHeader = 0;\r
+  AliStack* stack = 0;\r
+  TArrayF vtxMC(3);\r
+  AlidNdPtHelper::MCProcessType evtType = AlidNdPtHelper::kInvalidProcess;\r
+\r
+  if(IsUseMCInfo())\r
+  {\r
+    if(!mcEvent) {\r
+      AliDebug(AliLog::kError, "mcEvent not available");\r
+      return;\r
+    }\r
+\r
+    // get MC event header\r
+    header = mcEvent->Header();\r
+    if (!header) {\r
+      AliDebug(AliLog::kError, "Header not available");\r
+      return;\r
+    }\r
+\r
+    // MC particle stack\r
+    stack = mcEvent->Stack();\r
+    if (!stack) {\r
+      AliDebug(AliLog::kError, "Stack not available");\r
+      return;\r
+    }\r
+\r
+    // get event type (ND=0x1, DD=0x2, SD=0x4)\r
+    evtType = AlidNdPtHelper::GetEventProcessType(header);\r
+    AliDebug(AliLog::kDebug+1, Form("Found process type %d", evtType));\r
+\r
+    // get MC vertex\r
+    genHeader = header->GenEventHeader();\r
+    if (!genHeader) {\r
+      AliDebug(AliLog::kError, "Could not retrieve genHeader from Header");\r
+      return;\r
+    }\r
+    genHeader->PrimaryVertex(vtxMC);\r
+\r
+    // Fill MC event histogram\r
+    Double_t vMCEventHist[3]={vtxMC[0],vtxMC[1],vtxMC[2]};\r
+    fMCEventHist->Fill(vMCEventHist);\r
+\r
+  } // end bUseMC\r
+\r
+  // get reconstructed vertex  \r
+  const AliESDVertex* vtxESD = AlidNdPtHelper::GetVertex(esdEvent,evtCuts,accCuts,esdTrackCuts,GetAnalysisMode(), kFALSE, kTRUE, kTRUE); // redo TPC vertex & vertex constraints\r
+  if(!vtxESD) return; \r
+\r
+  Bool_t isRecVertex = AlidNdPtHelper::TestVertex(vtxESD, GetAnalysisMode(), kFALSE);  // should be moved to AcceptEvent\r
+  Bool_t isEventOK = evtCuts->AcceptEvent(esdEvent,mcEvent,vtxESD) && isRecVertex;\r
+\r
+  TObjArray *allChargedTracks=0;\r
+  Int_t multAll=0;\r
+\r
+  // check event cuts\r
+  if(isEventOK && isEventTriggered)\r
+  {\r
+    // get all charged tracks\r
+    allChargedTracks = AlidNdPtHelper::GetAllChargedTracks(esdEvent,vtxESD,GetAnalysisMode());\r
+    //allChargedTracks = AlidNdPtHelper::GetAllChargedTracks(esdEvent,GetAnalysisMode());\r
+    if(!allChargedTracks) return;\r
+\r
+    Int_t entries = allChargedTracks->GetEntries();\r
+    for(Int_t i=0; i<entries;++i) \r
+    {\r
+      AliESDtrack *track = (AliESDtrack*)allChargedTracks->At(i);\r
+      if(!track) continue;\r
+\r
+      FillHistograms(track, stack);\r
+      multAll++;\r
+    }\r
+  } \r
+\r
+  Double_t vRecEventHist[5] = {vtxESD->GetXv(),vtxESD->GetYv(),vtxESD->GetZv(),vtxESD->GetZRes(),multAll};\r
+  fRecEventHist->Fill(vRecEventHist);\r
+\r
+  if(IsUseMCInfo()) {\r
+    Double_t vRecMCEventHist[5] = {vtxESD->GetXv()-vtxMC[0],vtxESD->GetYv()-vtxMC[1],vtxESD->GetZv()-vtxMC[2],multAll};\r
+    fRecMCEventHist->Fill(vRecMCEventHist);\r
+  }\r
+\r
+  if(allChargedTracks) delete allChargedTracks; allChargedTracks = 0;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AlidNdPtCutAnalysis::FillHistograms(AliESDtrack *const esdTrack, AliStack *const stack)\r
+{\r
+  //\r
+  // Fill ESD track and MC histograms \r
+  //\r
+  if(!esdTrack) return;\r
+\r
+  //Float_t q = esdTrack->Charge();\r
+  Float_t pt = esdTrack->Pt();\r
+  Float_t eta = esdTrack->Eta();\r
+  Float_t phi = esdTrack->Phi();\r
+  Int_t nClust = esdTrack->GetTPCclusters(0);\r
+  Int_t nFindableClust = esdTrack->GetTPCNclsF();\r
+\r
+  Float_t chi2PerCluster = 0.;\r
+  if(nClust>0.) chi2PerCluster = esdTrack->GetTPCchi2()/Float_t(nClust);\r
+\r
+  Float_t clustPerFindClust = 0.;\r
+  if(nFindableClust>0.) clustPerFindClust = Float_t(nClust)/nFindableClust;\r
+\r
+  Float_t b[2], bCov[3];\r
+  esdTrack->GetImpactParameters(b,bCov);\r
+\r
+  // kink daughter\r
+  Bool_t isKink = kFALSE;\r
+  if(esdTrack->GetKinkIndex(0)>0) isKink=kTRUE;\r
+\r
+  //\r
+  // Fill rec vs MC information\r
+  //\r
+  if(!stack) return;\r
+  Int_t label = TMath::Abs(esdTrack->GetLabel()); \r
+  TParticle* particle = stack->Particle(label);\r
+  if(!particle) return;\r
+  Bool_t isPrim = stack->IsPhysicalPrimary(label);\r
+\r
+  // fill histo\r
+  Double_t vRecMCTrackHist[10] = {nClust,chi2PerCluster,clustPerFindClust,b[0],b[1],eta,phi,pt,isKink,isPrim}; \r
+  fRecMCTrackHist->Fill(vRecMCTrackHist);\r
+}\r
+\r
+//_____________________________________________________________________________\r
+Long64_t AlidNdPtCutAnalysis::Merge(TCollection* list) \r
+{\r
+  // Merge list of objects (needed by PROOF)\r
+\r
+  if (!list)\r
+  return 0;\r
+\r
+  if (list->IsEmpty())\r
+  return 1;\r
+\r
+  TIterator* iter = list->MakeIterator();\r
+  TObject* obj = 0;\r
+\r
+  // collection of generated histograms\r
+  Int_t count=0;\r
+  while((obj = iter->Next()) != 0) {\r
+    AlidNdPtCutAnalysis* entry = dynamic_cast<AlidNdPtCutAnalysis*>(obj);\r
+    if (entry == 0) continue; \r
+  \r
+    // event histo\r
+    fRecEventHist->Add(entry->fRecEventHist);\r
+    fRecMCEventHist->Add(entry->fRecMCEventHist);\r
+    fMCEventHist->Add(entry->fMCEventHist);\r
+\r
+    // track histo\r
+    fRecMCTrackHist->Add(entry->fRecMCTrackHist);\r
+    \r
+  count++;\r
+  }\r
+\r
+return count;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AlidNdPtCutAnalysis::Analyse() \r
+{\r
+  //\r
+  // Analyse histograms\r
+  //\r
+  TH1::AddDirectory(kFALSE);\r
+  TObjArray *aFolderObj = new TObjArray;\r
+  TH1D *h1D = 0; \r
+  TH2D *h2D = 0; \r
+\r
+\r
+  //\r
+  // get cuts\r
+  //\r
+  AlidNdPtEventCuts *evtCuts = GetEventCuts(); \r
+  AlidNdPtAcceptanceCuts *accCuts = GetAcceptanceCuts(); \r
+  AliESDtrackCuts *esdTrackCuts = GetTrackCuts(); \r
+\r
+  if(!evtCuts || !accCuts || !esdTrackCuts) {\r
+    Error("AlidNdPtCutAnalysis::Analyse()", "cuts not available");\r
+    return;\r
+  }\r
+\r
+  //\r
+  // set min and max values\r
+  //\r
+  Double_t minPt = accCuts->GetMinPt();\r
+  Double_t maxPt = accCuts->GetMaxPt();\r
+  Double_t minEta = accCuts->GetMinEta();\r
+  Double_t maxEta = accCuts->GetMaxEta()-0.00001;\r
+\r
+  //\r
+  // Create rec. event histograms\r
+  //\r
+  h2D = (TH2D *)fRecEventHist->Projection(0,1);\r
+  h2D->SetName("rec_xv_vs_yv");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fRecEventHist->Projection(0,2);\r
+  h2D->SetName("rec_xv_vs_zv");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fRecEventHist->Projection(0,2);\r
+  h2D->SetName("rec_resZv_vs_Mult");\r
+  aFolderObj->Add(h2D);\r
+\r
+  //\r
+  // Create mc event histograms\r
+  //\r
+  h2D = (TH2D *)fMCEventHist->Projection(0,1);\r
+  h2D->SetName("mc_xv_vs_yv");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fMCEventHist->Projection(0,2);\r
+  h2D->SetName("mc_xv_vs_zv");\r
+  aFolderObj->Add(h2D);\r
+\r
+  //\r
+  // Create rec-mc event histograms\r
+  //\r
+  h2D = (TH2D *)fRecMCEventHist->Projection(0,3);\r
+  h2D->SetName("rec_mc_deltaXv_vs_mult");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fRecMCEventHist->Projection(1,3);\r
+  h2D->SetName("rec_mc_deltaYv_vs_mult");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fRecMCEventHist->Projection(2,3);\r
+  h2D->SetName("rec_mc_deltaZv_vs_mult");\r
+  aFolderObj->Add(h2D);\r
+\r
+  //\r
+  // Create rec-mc track track histograms \r
+  //\r
+\r
+  // DCA cuts\r
+  fRecMCTrackHist->GetAxis(3)->SetRangeUser(-0.3,0.3);\r
+  fRecMCTrackHist->GetAxis(4)->SetRangeUser(-0.3,0.3);\r
+  fRecMCTrackHist->GetAxis(7)->SetRangeUser(minPt,maxPt);  \r
+\r
+  h2D = (TH2D *)fRecMCTrackHist->Projection(0,5);\r
+  h2D->SetName("nClust_vs_eta");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fRecMCTrackHist->Projection(1,5);\r
+  h2D->SetName("chi2PerClust_vs_eta");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fRecMCTrackHist->Projection(2,5);\r
+  h2D->SetName("ratio_nClust_nFindableClust_vs_eta");\r
+  aFolderObj->Add(h2D);\r
+\r
+  //\r
+  h2D = (TH2D *)fRecMCTrackHist->Projection(0,6);\r
+  h2D->SetName("nClust_vs_phi");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fRecMCTrackHist->Projection(1,6);\r
+  h2D->SetName("chi2PerClust_vs_phi");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fRecMCTrackHist->Projection(2,6);\r
+  h2D->SetName("ratio_nClust_nFindableClust_vs_phi");\r
+  aFolderObj->Add(h2D);\r
+\r
+  //\r
+  fRecMCTrackHist->GetAxis(7)->SetRangeUser(0.0,maxPt);  \r
+\r
+  h2D = (TH2D *)fRecMCTrackHist->Projection(0,7);\r
+  h2D->SetName("nClust_vs_pt");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fRecMCTrackHist->Projection(1,7);\r
+  h2D->SetName("chi2PerClust_vs_pt");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fRecMCTrackHist->Projection(2,7);\r
+  h2D->SetName("ratio_nClust_nFindableClust_vs_pt");\r
+  aFolderObj->Add(h2D);\r
+\r
+  // fiducial volume\r
+  fRecMCTrackHist->GetAxis(5)->SetRangeUser(minEta,maxEta);  \r
+  fRecMCTrackHist->GetAxis(7)->SetRangeUser(minPt,maxPt);  \r
+\r
+  // DCA cuts\r
+  fRecMCTrackHist->GetAxis(3)->SetRangeUser(-0.3,0.3);\r
+  fRecMCTrackHist->GetAxis(4)->SetRangeUser(-0.3,0.3);\r
+\r
+  h2D = (TH2D *)fRecMCTrackHist->Projection(0,1);\r
+  h2D->SetName("nClust_vs_chi2PerClust");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fRecMCTrackHist->Projection(0,2);\r
+  h2D->SetName("nClust_vs_ratio_nClust_nFindableClust");\r
+  aFolderObj->Add(h2D);\r
+\r
+  // DCAy cuts\r
+  fRecMCTrackHist->GetAxis(3)->SetRangeUser(-10.0,10.0);\r
+  fRecMCTrackHist->GetAxis(4)->SetRangeUser(-1.0,1.0);\r
+\r
+  // sec\r
+  fRecMCTrackHist->GetAxis(9)->SetRange(1,1);\r
+  h1D = (TH1D *)fRecMCTrackHist->Projection(3);\r
+  h1D->SetName("dcay_sec");\r
+  aFolderObj->Add(h1D);\r
+\r
+  // prim\r
+  fRecMCTrackHist->GetAxis(9)->SetRange(2,2);\r
+  h1D = (TH1D *)fRecMCTrackHist->Projection(3);\r
+  h1D->SetName("dcay_prim");\r
+  aFolderObj->Add(h1D);\r
+\r
+  // DCAz cuts\r
+  fRecMCTrackHist->GetAxis(3)->SetRangeUser(-1.0,1.0);\r
+  fRecMCTrackHist->GetAxis(4)->SetRangeUser(-10.0,10.0);\r
+\r
+  // sec\r
+  fRecMCTrackHist->GetAxis(9)->SetRange(1,1);\r
+  h1D = (TH1D *)fRecMCTrackHist->Projection(4);\r
+  h1D->SetName("dcaz_sec");\r
+  aFolderObj->Add(h1D);\r
+\r
+  // prim\r
+  fRecMCTrackHist->GetAxis(9)->SetRange(2,2);\r
+  h1D = (TH1D *)fRecMCTrackHist->Projection(4);\r
+  h1D->SetName("dcaz_prim");\r
+  aFolderObj->Add(h1D);\r
+\r
+\r
+  // export objects to analysis folder\r
+  fAnalysisFolder = ExportToFolder(aFolderObj);\r
+\r
+  // delete only TObjArray\r
+  if(aFolderObj) delete aFolderObj;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+TFolder* AlidNdPtCutAnalysis::ExportToFolder(TObjArray * array) \r
+{\r
+  // recreate folder avery time and export objects to new one\r
+  //\r
+  AlidNdPtCutAnalysis * comp=this;\r
+  TFolder *folder = comp->GetAnalysisFolder();\r
+\r
+  TString name, title;\r
+  TFolder *newFolder = 0;\r
+  Int_t i = 0;\r
+  Int_t size = array->GetSize();\r
+\r
+  if(folder) { \r
+     // get name and title from old folder\r
+     name = folder->GetName();  \r
+     title = folder->GetTitle();  \r
+\r
+        // delete old one\r
+     delete folder;\r
+\r
+        // create new one\r
+     newFolder = CreateFolder(name.Data(),title.Data());\r
+     newFolder->SetOwner();\r
+\r
+        // add objects to folder\r
+     while(i < size) {\r
+          newFolder->Add(array->At(i));\r
+          i++;\r
+        }\r
+  }\r
+\r
+return newFolder;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+TFolder* AlidNdPtCutAnalysis::CreateFolder(TString name,TString title) { \r
+// create folder for analysed histograms\r
+//\r
+TFolder *folder = 0;\r
+  folder = new TFolder(name.Data(),title.Data());\r
+\r
+  return folder;\r
+}\r
diff --git a/PWG0/dNdPt/AlidNdPtCutAnalysis.h b/PWG0/dNdPt/AlidNdPtCutAnalysis.h
new file mode 100644 (file)
index 0000000..befa61c
--- /dev/null
@@ -0,0 +1,94 @@
+#ifndef ALIDEDPTCUTANALYSIS_H
+#define ALIDEDPTCUTANALYSIS_H
+
+//------------------------------------------------------------------------------
+// AlidNdPtCutAnalysis class. 
+//
+// a. functionality:
+// - fills generic cut histograms
+// - generates cuts (selection criteria)
+//
+// b. data members:
+// - generic cut histograms
+// - control histograms
+//
+// Author: J.Otwinowski 04/11/2008 
+//------------------------------------------------------------------------------
+
+class TProfile;
+class TFolder;
+class TObjArray;
+class TString;
+
+class AliESDtrackCuts;
+class AliVertexerTracks;
+class AliESD;
+class AliESDfriend;
+class AliESDfriendTrack;
+
+#include "THnSparse.h"
+#include "AlidNdPt.h"
+#include "AlidNdPtHelper.h"
+
+class AlidNdPtCutAnalysis : public AlidNdPt {
+public :
+  AlidNdPtCutAnalysis(); 
+  AlidNdPtCutAnalysis(Char_t* name, Char_t* title);
+  ~AlidNdPtCutAnalysis();
+
+  // Init data members
+  virtual void Init();
+
+  // Process events
+  virtual void Process(AliESDEvent *const esdEvent=0, AliMCEvent *const mcEvent=0);
+
+  // Merge output objects (needed by PROOF) 
+  virtual Long64_t Merge(TCollection* list);
+
+  // Analyse output histograms 
+  virtual void Analyse();
+
+  // Export objects to folder
+  virtual TFolder *ExportToFolder(TObjArray * array=0);
+
+  // Get analysis folder
+  TFolder* GetAnalysisFolder() {return fAnalysisFolder;}
+
+  // Create folder for analysed histograms
+  TFolder *CreateFolder(TString folder = "folderdNdPtAnalysis",TString title = "Analysed dNdPt histograms");
+
+  // Fill histograms
+  void FillHistograms(AliESDtrack *const esdTrack, AliStack *const stack);
+
+  // Getters
+  THnSparseF *GetRecEventHist() {return fRecEventHist;}
+  THnSparseF *GetMCEventHist() {return fMCEventHist;}
+  THnSparseF *GetRecMCEventHist() {return fRecMCEventHist;}
+
+  //
+  THnSparseF *GetRecMCTrackHist() {return fRecMCTrackHist;}
+  
+  private:
+
+  // analysis folder 
+  TFolder *fAnalysisFolder; // folder for analysed histograms
+
+  //
+  // THnSparse event histograms
+  //
+  THnSparseF *fRecEventHist;   //-> Xv:Yv:Zv:ResZv:Mult
+  THnSparseF *fMCEventHist;    //-> mcXv:mcYv:mcZv
+  THnSparseF *fRecMCEventHist; //-> Xv-mcXv:Yv-mcYv:Zv-mcZv:Mult
+
+  //
+  // THnSparse track histograms
+  //
+  THnSparseF *fRecMCTrackHist; //-> nClust:chi2PerClust:nClust/nFindableClust:DCAy:DCAz:eta:phi:pt:isNotKink:isPrim
+
+  AlidNdPtCutAnalysis(const AlidNdPtCutAnalysis&); // not implemented
+  AlidNdPtCutAnalysis& operator=(const AlidNdPtCutAnalysis&); // not implemented
+
+  ClassDef(AlidNdPtCutAnalysis,1);
+};
+
+#endif
diff --git a/PWG0/dNdPt/AlidNdPtEventCuts.cxx b/PWG0/dNdPt/AlidNdPtEventCuts.cxx
new file mode 100644 (file)
index 0000000..548a796
--- /dev/null
@@ -0,0 +1,179 @@
+/**************************************************************************
+* 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.                  *
+**************************************************************************/
+
+#include <iostream>
+#include <TList.h>
+
+#include "AliLog.h"
+#include "AliESDEvent.h"
+#include "AliESDVertex.h"
+#include "AliMCEvent.h"
+#include "AliHeader.h"
+#include "AliGenEventHeader.h"
+
+#include "AlidNdPtHelper.h"
+#include "AlidNdPtEventCuts.h"
+
+using namespace std;
+
+ClassImp(AlidNdPtEventCuts)
+
+//_____________________________________________________________________________
+AlidNdPtEventCuts::AlidNdPtEventCuts(const Char_t* name,const Char_t *title) : 
+AliAnalysisCuts(name, title)
+, fRecVertexRequired(kTRUE)
+, fEventProcessType(AlidNdPtHelper::kInvalidProcess)
+, fMinNContributors(0)
+, fMaxNContributors(0)
+, fMaxR(0)
+, fMinZv(0)
+, fMaxZv(0)
+, fMeanXv(0)
+, fMeanYv(0)
+, fMeanZv(0)
+, fSigmaMeanXv(0)
+, fSigmaMeanYv(0)
+, fSigmaMeanZv(0)
+{
+  // default constructor 
+  
+  // init data members with defaults
+  Init();
+}
+
+//_____________________________________________________________________________
+AlidNdPtEventCuts::~AlidNdPtEventCuts()  
+{
+  // destructor
+}
+
+//_____________________________________________________________________________
+void AlidNdPtEventCuts::Init()  
+{
+  // set default values
+  SetRecVertexRequired();
+  SetEventProcessType();
+  SetNContributorsRange();
+  SetMaxR();
+  SetZvRange();
+  SetMeanXYZv();
+  SetSigmaMeanXYZv();
+}
+
+//_____________________________________________________________________________
+Bool_t AlidNdPtEventCuts::AcceptEvent(AliESDEvent *esdEvent,AliMCEvent *mcEvent, const AliESDVertex *vtx)
+{
+  // Check event selection cuts
+  Bool_t retValue=kTRUE;
+
+  if(!esdEvent) return kFALSE;
+  if(!IsRecVertexRequired()) return kTRUE;
+  if(!vtx) return kFALSE;
+  if(!vtx->GetStatus()) return kFALSE;
+
+  if(mcEvent) {
+   // check MC event conditions
+   AliHeader* header = mcEvent->Header();
+   if(!header) return kFALSE;
+  
+    // select event type (ND-non diffractive, SD-single diffractive, DD-double diffractive)
+    if(fEventProcessType == AlidNdPtHelper::kInvalidProcess) { 
+      retValue=kTRUE;
+    } 
+    else if(fEventProcessType == AlidNdPtHelper::kDiffractiveProcess) {
+      AlidNdPtHelper::MCProcessType processType = AlidNdPtHelper::GetEventProcessType(header);
+      if(processType == AlidNdPtHelper::kND) retValue=kFALSE;
+      else retValue=kTRUE;
+    }
+    else if(fEventProcessType == AlidNdPtHelper::GetEventProcessType(header)) { 
+      retValue=kTRUE;
+    }
+    else 
+      retValue=kFALSE;
+  }
+
+  Float_t R = TMath::Sqrt(vtx->GetXv()*vtx->GetXv()+vtx->GetYv()*vtx->GetYv());
+
+  if(vtx->GetNContributors() < fMinNContributors) return kFALSE; 
+  if(vtx->GetNContributors() > fMaxNContributors) return kFALSE; 
+  if(R > fMaxR) return kFALSE; 
+  if(vtx->GetZv() < fMinZv) return kFALSE; 
+  if(vtx->GetZv() > fMaxZv) return kFALSE; 
+
+return retValue;  
+}
+
+//_____________________________________________________________________________
+Bool_t AlidNdPtEventCuts::AcceptMCEvent(AliMCEvent *mcEvent)
+{
+  // Check event selection cuts
+  if(!mcEvent) return kFALSE;
+
+  Bool_t retValue=kTRUE;
+
+  // check MC event conditions
+  AliHeader* header = mcEvent->Header();
+  if(!header) return kFALSE;
+
+  AliGenEventHeader* genHeader = header->GenEventHeader();
+  if (!genHeader) {
+    AliDebug(AliLog::kError, "Could not retrieve genHeader from Header");
+    return kFALSE;
+  }
+  TArrayF vtxMC(3);
+  genHeader->PrimaryVertex(vtxMC);
+  
+  // select event type (ND-non diffractive, SD-single diffractive, DD-double diffractive)
+  if(fEventProcessType == AlidNdPtHelper::kInvalidProcess) { 
+     retValue=kTRUE;
+  } else {
+     if(fEventProcessType == AlidNdPtHelper::GetEventProcessType(header)) retValue=kTRUE;
+     else retValue=kFALSE;
+  }
+
+  Float_t R = TMath::Sqrt(vtxMC[0]*vtxMC[0]+vtxMC[1]*vtxMC[1]);
+
+  if(R > fMaxR) return kFALSE; 
+  if(vtxMC[2] < fMinZv) return kFALSE; 
+  if(vtxMC[2] > fMaxZv) return kFALSE; 
+
+return retValue;  
+}
+
+//_____________________________________________________________________________
+Long64_t AlidNdPtEventCuts::Merge(TCollection* list) 
+{
+  // Merge list of objects (needed by PROOF)
+  if (!list)
+  return 0;
+
+  if (list->IsEmpty())
+  return 1;
+
+  TIterator* iter = list->MakeIterator();
+  TObject* obj = 0;
+
+  Int_t count=0;
+  while((obj = iter->Next()) != 0) 
+  {
+    AlidNdPtEventCuts* entry = dynamic_cast<AlidNdPtEventCuts*>(obj);
+    if (entry == 0)  
+      continue; 
+
+  count++;
+  }
+
+return count;
+}
diff --git a/PWG0/dNdPt/AlidNdPtEventCuts.h b/PWG0/dNdPt/AlidNdPtEventCuts.h
new file mode 100644 (file)
index 0000000..3650fde
--- /dev/null
@@ -0,0 +1,95 @@
+#ifndef ALIDNDPTEVENTCUTS_H\r
+#define ALIDNDPTEVENTCUTS_H\r
+\r
+//------------------------------------------------------------------------------\r
+// Class to keep event selection cuts for dNdPt analysis. \r
+// \r
+// Author: J.Otwinowski 01/11/2008 \r
+//------------------------------------------------------------------------------\r
+\r
+#include "AliAnalysisCuts.h"\r
+#include "dNdPt/AlidNdPtHelper.h"\r
+\r
+class AliESDEvent;\r
+class AliESDVertex;\r
+class AliMCEvent;\r
+class AliHeader;\r
+class AliGenEventHeader;\r
+\r
+class AlidNdPtEventCuts : public AliAnalysisCuts\r
+{\r
+public:\r
+  AlidNdPtEventCuts(const Char_t* name ="AlidNdPtEventCuts", const Char_t *title ="");\r
+  virtual ~AlidNdPtEventCuts(); \r
\r
+  // setters \r
+  void SetRecVertexRequired(const Bool_t bFlag=kTRUE)  {fRecVertexRequired=bFlag;}\r
+  void SetEventProcessType(AlidNdPtHelper::MCProcessType type=AlidNdPtHelper::kInvalidProcess)  {fEventProcessType=type;}\r
+  void SetNContributorsRange(const Float_t min=0.,const Float_t max=1e99) {fMinNContributors=min; fMaxNContributors=max;}\r
+  void SetMaxR(const Float_t max=1e99) {fMaxR=max;}\r
+  void SetZvRange(const Float_t min=-1e99, const Float_t max=1e99) {fMinZv=min; fMaxZv=max;}\r
+\r
+  void SetMeanXYZv(const Float_t xv=0.0, const Float_t yv=0.0, const Float_t zv=0.0) {\r
+    fMeanXv = xv; fMeanYv = yv; fMeanZv = zv;\r
+  }\r
+\r
+  void SetSigmaMeanXYZv(const Float_t sxv=1.0, const Float_t syv=1.0, const Float_t szv=10.0) {\r
+    fSigmaMeanXv = sxv; fSigmaMeanYv = syv; fSigmaMeanZv = szv;\r
+  }\r
+\r
+  // getters \r
+  Bool_t  IsRecVertexRequired() const {return fRecVertexRequired;}\r
+  Int_t   GetEventProcessType() const {return fEventProcessType;}  \r
+  Float_t GetMinNContributors() const {return fMinNContributors;}\r
+  Float_t GetMaxNContributors() const {return fMaxNContributors;}\r
+  Float_t GetMaxR() const {return fMaxR;}\r
+  Float_t GetMinZv() const {return fMinZv;}\r
+  Float_t GetMaxZv() const {return fMaxZv;}\r
+\r
+  Float_t GetMeanXv() const {return fMeanXv;}\r
+  Float_t GetMeanYv() const {return fMeanYv;}\r
+  Float_t GetMeanZv() const {return fMeanZv;}\r
+\r
+  Float_t GetSigmaMeanXv() const {return fSigmaMeanXv;}\r
+  Float_t GetSigmaMeanYv() const {return fSigmaMeanYv;}\r
+  Float_t GetSigmaMeanZv() const {return fSigmaMeanZv;}\r
\r
+  // cuts init function\r
+  void Init();\r
+\r
+  // check MC tracks\r
+  Bool_t IsSelected(TObject *) {return kTRUE;}\r
+  Bool_t IsSelected(TList *) {return kTRUE;}\r
+\r
+  // accept event\r
+  Bool_t AcceptEvent(AliESDEvent *event=0, AliMCEvent *mcEvent=0, const AliESDVertex *vtx=0);\r
+  Bool_t AcceptMCEvent(AliMCEvent *mcEvent=0);\r
+\r
+  // Merge output objects (needed by PROOF) \r
+  virtual Long64_t Merge(TCollection* list);\r
+\r
+private:\r
+  Bool_t fRecVertexRequired; // reconstructed event vertex required  \r
+  Int_t fEventProcessType;   // select MC event process type (ND, SD, DD)\r
+  Float_t fMinNContributors; // min. number of contributing vertex tracks\r
+  Float_t fMaxNContributors; // max. number of contributing vertex tracks\r
+  Float_t fMaxR;             // max. vertex radii (R = sqrt(Xv^2+Yv^2) \r
+  Float_t fMinZv;            // min. Zv vertex\r
+  Float_t fMaxZv;            // max. Zv vertex\r
+\r
+  // interaction spot constraint\r
+  Float_t fMeanXv; // mean Xv position\r
+  Float_t fMeanYv; // mean Yv position\r
+  Float_t fMeanZv; // mean Zv position\r
+\r
+  Float_t fSigmaMeanXv; // sigma mean Xv position \r
+  Float_t fSigmaMeanYv; // sigma mean Yv position\r
+  Float_t fSigmaMeanZv; // sigma mean Zv position\r
\r
+  AlidNdPtEventCuts(const AlidNdPtEventCuts&); // not implemented\r
+  AlidNdPtEventCuts& operator=(const AlidNdPtEventCuts&); // not implemented\r
+\r
+  ClassDef(AlidNdPtEventCuts, 1)\r
+};\r
+\r
+#endif // ALIDNDPTEVENTCUTS_H\r
diff --git a/PWG0/dNdPt/AlidNdPtHelper.cxx b/PWG0/dNdPt/AlidNdPtHelper.cxx
new file mode 100644 (file)
index 0000000..b7c5782
--- /dev/null
@@ -0,0 +1,1498 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+#include <TROOT.h>
+#include <TParticle.h>
+#include <TParticlePDG.h>
+#include <TH1.h>
+#include <TH2.h>
+#include <TH3.h>
+#include <TCanvas.h>
+#include <TList.h>
+#include <TTree.h>
+#include <TBranch.h>
+#include <TLeaf.h>
+#include <TArrayI.h>
+#include <TF1.h>
+
+#include <AliHeader.h>
+#include <AliStack.h>
+#include <AliLog.h>
+
+#include <AliLog.h>
+#include <AliESD.h>
+#include <AliESDEvent.h>
+#include <AliMCEvent.h>
+#include <AliESDVertex.h>
+#include <AliVertexerTracks.h>
+
+#include <AliGenEventHeader.h>
+#include <AliGenPythiaEventHeader.h>
+#include <AliGenCocktailEventHeader.h>
+#include <AliGenDPMjetEventHeader.h>
+
+#include <AliMathBase.h>
+#include <AliESDtrackCuts.h>
+#include "dNdPt/AlidNdPtEventCuts.h"
+#include "dNdPt/AlidNdPtAcceptanceCuts.h"
+#include "dNdPt/AlidNdPtHelper.h"
+
+//____________________________________________________________________
+ClassImp(AlidNdPtHelper)
+
+Int_t AlidNdPtHelper::fgLastProcessType = -1;
+
+//____________________________________________________________________
+Bool_t AlidNdPtHelper::IsEventTriggered(const AliESD* aEsd, Trigger trigger)
+{
+  // see function with ULong64_t argument
+
+  ULong64_t triggerMask = aEsd->GetTriggerMask();
+  return IsEventTriggered(triggerMask, trigger);
+}
+
+//____________________________________________________________________
+Bool_t AlidNdPtHelper::IsEventTriggered(ULong64_t triggerMask, Trigger trigger)
+{
+  // check if the event was triggered
+  //
+  // this function needs the branch fTriggerMask
+  
+  // definitions from p-p.cfg
+  ULong64_t spdFO = (1 << 14);
+  ULong64_t v0left = (1 << 11);
+  ULong64_t v0right = (1 << 12);
+
+  switch (trigger)
+  {
+    case kMB1:
+    {
+      if (triggerMask & spdFO || ((triggerMask & v0left) || (triggerMask & v0right)))
+        return kTRUE;
+      break;
+    }
+    case kMB2:
+    {
+      if (triggerMask & spdFO && ((triggerMask & v0left) || (triggerMask & v0right)))
+        return kTRUE;
+      break;
+    }
+    case kSPDFASTOR:
+    {
+      if (triggerMask & spdFO)
+        return kTRUE;
+      break;
+    }
+  }
+
+  return kFALSE;
+}
+
+//____________________________________________________________________
+const Bool_t AlidNdPtHelper::TestVertex(const AliESDVertex* vertex, AnalysisMode analysisMode, Bool_t debug)
+{
+  // Checks if a vertex meets the needed quality criteria
+  if(!vertex) return kFALSE;
+
+  Float_t requiredZResolution = -1;
+  if (analysisMode == kSPD || analysisMode == kTPCITS || analysisMode == kTPCSPDvtx)
+  {
+    requiredZResolution = 0.1;
+  }
+  else if (analysisMode == kTPC || analysisMode == kMCRec || 
+           analysisMode == kMCPion || analysisMode == kMCKaon || 
+          analysisMode == kMCProton || analysisMode ==kPlus || analysisMode ==kMinus)
+    requiredZResolution = 10.;
+
+  // check Ncontributors
+  if (vertex->GetNContributors() <= 0) {
+    if (debug){
+      Printf("AlidNdPtHelper::GetVertex: NContributors() <= 0: %d",vertex->GetNContributors());
+      Printf("AlidNdPtHelper::GetVertex: NIndices(): %d",vertex->GetNIndices());
+      vertex->Print();
+    }
+    return kFALSE;
+  }
+
+  // check resolution
+  Double_t zRes = vertex->GetZRes();
+  if (zRes == 0) {
+    Printf("AlidNdPtHelper::GetVertex: UNEXPECTED: resolution is 0.");
+    return kFALSE;
+  }
+
+  if (zRes > requiredZResolution) {
+    if (debug)
+      Printf("AlidNdPtHelper::TestVertex: Resolution too poor %f (required: %f", zRes, requiredZResolution);
+    return kFALSE;
+  }
+
+  return kTRUE;
+}
+
+//____________________________________________________________________
+const AliESDVertex* AlidNdPtHelper::GetVertex(AliESDEvent* aEsd, AlidNdPtEventCuts *evtCuts, AlidNdPtAcceptanceCuts *accCuts, AliESDtrackCuts *trackCuts, AnalysisMode analysisMode, Bool_t debug, Bool_t bRedoTPC, Bool_t bUseMeanVertex)
+{
+  // Get the vertex from the ESD and returns it if the vertex is valid
+  //
+  // Second argument decides which vertex is used (this selects
+  // also the quality criteria that are applied)
+
+  if(!aEsd) 
+  { 
+    ::Error("AlidNdPtHelper::GetVertex()","esd event is NULL");
+    return NULL;  
+  }
+  if(!evtCuts || !accCuts || !trackCuts) 
+  { 
+    ::Error("AlidNdPtHelper::GetVertex()","cuts not available");
+    return NULL;  
+  }
+
+  const AliESDVertex* vertex = 0;
+  AliESDVertex *initVertex = 0;
+  if (analysisMode == kSPD || analysisMode == kTPCITS || analysisMode == kTPCSPDvtx ||  
+      analysisMode == kMCRec || analysisMode == kMCPion || analysisMode == kMCKaon || 
+      analysisMode == kMCProton || analysisMode ==kPlus || analysisMode ==kMinus )
+  {
+    vertex = aEsd->GetPrimaryVertexSPD();
+    if (debug)
+      Printf("AlidNdPtHelper::GetVertex: Returning SPD vertex");
+  }
+  else if (analysisMode == kTPC || analysisMode == kMCRec || 
+           analysisMode == kMCPion || analysisMode == kMCKaon || analysisMode == kMCProton || 
+          analysisMode == kPlus || analysisMode == kMinus)
+  {
+    if(bRedoTPC) {
+
+      Double_t kBz = aEsd->GetMagneticField();
+      AliVertexerTracks vertexer(kBz);
+
+      if(bUseMeanVertex) {
+        Double_t pos[3]={evtCuts->GetMeanXv(),evtCuts->GetMeanYv(),evtCuts->GetMeanZv()};
+        Double_t err[3]={evtCuts->GetSigmaMeanXv(),evtCuts->GetSigmaMeanYv(),evtCuts->GetSigmaMeanZv()};
+        //printf("pos[0] %f, pos[1] %f, pos[2] %f \n", pos[0], pos[1], pos[2]);
+        initVertex = new AliESDVertex(pos,err);
+        vertexer.SetVtxStart(initVertex);
+        vertexer.SetConstraintOn();
+      }
+
+      //vertexer.SetTPCMode(Double_t dcacut=0.1, Double_t dcacutIter0=1.0, Double_t maxd0z0=5.0, Int_t minCls=10, Int_t mintrks=1, Double_t nsigma=3., Double_t mindetfitter=0.1, Double_t maxtgl=1.5, Double_t fidR=3., Double_t fidZ=30., Int_t finderAlgo=1, Int_t finderAlgoIter0=4);
+
+      Double_t maxDCAr = accCuts->GetMaxDCAr();
+      Double_t maxDCAz = accCuts->GetMaxDCAz();
+      Int_t minTPCClust = trackCuts->GetMinNClusterTPC();
+
+      vertexer.SetTPCMode(0.1,1.0,5.0,minTPCClust,1,3.,0.1,2.0,maxDCAr,maxDCAz,1,4);
+
+      // TPC track preselection
+      Int_t ntracks = aEsd->GetNumberOfTracks();
+      TObjArray array(ntracks);
+      UShort_t *id = new UShort_t[ntracks];
+
+      Int_t count=0;
+      for (Int_t i=0;i <ntracks; i++) {
+        AliESDtrack *t = aEsd->GetTrack(i);
+        if (!t) continue;
+        if (t->Charge() == 0) continue;
+        if (!t->GetTPCInnerParam()) continue;
+        if (t->GetTPCNcls()<vertexer.GetMinClusters()) continue;
+        AliExternalTrackParam  *tpcTrack  = new AliExternalTrackParam(*(t->GetTPCInnerParam()));
+       if(tpcTrack) { 
+         array.AddLast(tpcTrack);
+         id[count] = (UShort_t)t->GetID();
+         count++;
+       }
+      } 
+      AliESDVertex *vTPC = vertexer.VertexForSelectedTracks(&array,id, kTRUE, kTRUE, bUseMeanVertex);
+      aEsd->SetPrimaryVertexTPC(vTPC);
+
+      for (Int_t i=0; i<aEsd->GetNumberOfTracks(); i++) {
+       AliESDtrack *t = aEsd->GetTrack(i);
+       t->RelateToVertexTPC(vTPC, kBz, kVeryBig);
+      }
+      
+      delete vTPC;
+      array.Delete();
+      delete [] id; id=NULL;
+
+    }
+    vertex = aEsd->GetPrimaryVertexTPC();
+    if (debug)
+      Printf("AlidNdPtHelper::GetVertex: Returning vertex from tracks");
+    }
+      else
+       Printf("AlidNdPtHelper::GetVertex: ERROR: Invalid second argument %d", analysisMode);
+
+    if (!vertex) {
+     if (debug)
+      Printf("AlidNdPtHelper::GetVertex: No vertex found in ESD");
+      return 0;
+    }
+
+  if (debug)
+  {
+    Printf("AlidNdPtHelper::GetVertex: Returning valid vertex: %s", vertex->GetTitle());
+    vertex->Print();
+  }
+  
+  if(initVertex) delete initVertex; initVertex=NULL;
+  return vertex;
+}
+
+//____________________________________________________________________
+Bool_t AlidNdPtHelper::IsPrimaryParticle(AliStack* stack, Int_t idx, AnalysisMode analysisMode)
+{
+// check primary particles 
+// depending on the analysis mode
+//
+  if(!stack) return kFALSE;
+
+  TParticle* particle = stack->Particle(idx);
+  if (!particle) return  kFALSE;
+
+  // only charged particles
+  Double_t charge = particle->GetPDG()->Charge()/3.;
+  if (charge == 0.0) return kFALSE;
+
+  Int_t pdg = TMath::Abs(particle->GetPdgCode());
+
+  // physical primary
+  Bool_t prim = stack->IsPhysicalPrimary(idx);
+
+  if(analysisMode==kMCPion) {
+    if(prim && pdg==kPiPlus) return kTRUE;
+    else return kFALSE;
+  } 
+
+  if (analysisMode==kMCKaon) {
+    if(prim && pdg==kKPlus) return kTRUE;
+    else return kFALSE;
+  }
+    
+  if (analysisMode==kMCProton) {
+    if(prim && pdg==kProton) return kTRUE;
+    else return kFALSE;
+  }
+
+return prim;
+}
+
+//____________________________________________________________________
+Bool_t AlidNdPtHelper::IsPrimaryCharged(TParticle* aParticle, Int_t aTotalPrimaries, Bool_t adebug)
+{
+  //
+  // this function checks if a particle from the event generator (i.e. among the nPrim particles in the stack)
+  // shall be counted as a primary particle
+  //
+  // This function or a equivalent should be available in some common place of AliRoot
+  //
+  // WARNING: Call this function only for particles that are among the particles from the event generator!
+  // --> stack->Particle(id) with id < stack->GetNprimary()
+
+  // if the particle has a daughter primary, we do not want to count it
+  if (aParticle->GetFirstDaughter() != -1 && aParticle->GetFirstDaughter() < aTotalPrimaries)
+  {
+    if (adebug)
+      printf("Dropping particle because it has a daughter among the primaries.\n");
+    return kFALSE;
+  }
+
+  Int_t pdgCode = TMath::Abs(aParticle->GetPdgCode());
+  
+
+  // skip quarks and gluon
+  if (pdgCode <= 10 || pdgCode == 21)
+  {
+    if (adebug)
+      printf("Dropping particle because it is a quark or gluon.\n");
+    return kFALSE;
+  }
+
+  Int_t status = aParticle->GetStatusCode();
+  // skip non final state particles..
+  if(status!=1){
+    if (adebug)
+      printf("Dropping particle because it is not a final state particle.\n");
+    return kFALSE;
+  }
+
+  if (strcmp(aParticle->GetName(),"XXX") == 0)
+  {
+    Printf("WARNING: There is a particle named XXX (pdg code %d).", pdgCode);
+    return kFALSE;
+  }
+
+  TParticlePDG* pdgPart = aParticle->GetPDG();
+
+  if (strcmp(pdgPart->ParticleClass(),"Unknown") == 0)
+  {
+    Printf("WARNING: There is a particle with an unknown particle class (pdg code %d).", pdgCode);
+    return kFALSE;
+  }
+
+  if (pdgPart->Charge() == 0)
+  {
+    if (adebug)
+      printf("Dropping particle because it is not charged.\n");
+    return kFALSE;
+  }
+
+  return kTRUE;
+}
+
+//____________________________________________________________________
+void AlidNdPtHelper::CreateProjections(TH3* hist, Bool_t save)
+{
+  // create projections of 3d hists to all 2d combinations
+  // the histograms are not returned, just use them from memory or use this to create them in a file
+
+  TH1* proj = hist->Project3D("yx");
+  proj->SetXTitle(hist->GetXaxis()->GetTitle());
+  proj->SetYTitle(hist->GetYaxis()->GetTitle());
+  if (save)
+    proj->Write();
+
+  proj = hist->Project3D("zx");
+  proj->SetXTitle(hist->GetXaxis()->GetTitle());
+  proj->SetYTitle(hist->GetZaxis()->GetTitle());
+  if (save)
+    proj->Write();
+
+  proj = hist->Project3D("zy");
+  proj->SetXTitle(hist->GetYaxis()->GetTitle());
+  proj->SetYTitle(hist->GetZaxis()->GetTitle());
+  if (save)
+    proj->Write();
+}
+
+//____________________________________________________________________
+void AlidNdPtHelper::CreateDividedProjections(TH3* hist, TH3* hist2, const char* axis, Bool_t putErrors, Bool_t save)
+{
+  // create projections of the 3d hists divides them
+  // axis decides to which plane, if axis is 0 to all planes
+  // the histograms are not returned, just use them from memory or use this to create them in a file
+
+  if (axis == 0)
+  {
+    CreateDividedProjections(hist, hist2, "yx", putErrors, save);
+    CreateDividedProjections(hist, hist2, "zx", putErrors, save);
+    CreateDividedProjections(hist, hist2, "zy", putErrors, save);
+
+    return;
+  }
+
+  TH1* proj = hist->Project3D(axis);
+
+  if (strlen(axis) == 2)
+  {
+    proj->SetYTitle(GetAxisTitle(hist, axis[0]));
+    proj->SetXTitle(GetAxisTitle(hist, axis[1]));
+  }
+  else if (strlen(axis) == 1)
+    proj->SetXTitle(GetAxisTitle(hist, axis[0]));
+
+  TH1* proj2 = hist2->Project3D(axis);
+  if (strlen(axis) == 2)
+  {
+    proj2->SetYTitle(GetAxisTitle(hist2, axis[0]));
+    proj2->SetXTitle(GetAxisTitle(hist2, axis[1]));
+  }
+  else if (strlen(axis) == 1)
+    proj2->SetXTitle(GetAxisTitle(hist2, axis[0]));
+
+  TH1* division = dynamic_cast<TH1*> (proj->Clone(Form("%s_div_%s", proj->GetName(), proj2->GetName())));
+  //printf("doing axis: %s, x axis has %d %d bins, min %f %f max %f %f\n", axis, division->GetNbinsX(), proj2->GetNbinsX(), division->GetXaxis()->GetBinLowEdge(1), proj2->GetXaxis()->GetBinLowEdge(1), division->GetXaxis()->GetBinUpEdge(division->GetNbinsX()), proj2->GetXaxis()->GetBinUpEdge(proj2->GetNbinsX()));
+  //printf("doing axis: %s, y axis has %d %d bins, min %f %f max %f %f\n", axis, division->GetNbinsY(), proj2->GetNbinsY(), division->GetYaxis()->GetBinLowEdge(1), proj2->GetYaxis()->GetBinLowEdge(1), division->GetYaxis()->GetBinUpEdge(division->GetNbinsY()), proj2->GetYaxis()->GetBinUpEdge(proj2->GetNbinsY()));
+  division->Divide(proj, proj2, 1, 1, "B");
+  division->SetTitle(Form("%s divided %s", proj->GetTitle(), proj2->GetTitle()));
+
+  if (putErrors)
+  {
+    division->Sumw2();
+    if (division->GetDimension() == 1)
+    {
+      Int_t nBins = division->GetNbinsX();
+      for (Int_t i = 1; i <= nBins; ++i)
+        if (proj2->GetBinContent(i) != 0)
+          division->SetBinError(i, TMath::Sqrt(proj->GetBinContent(i)) / proj2->GetBinContent(i));
+    }
+    else if (division->GetDimension() == 2)
+    {
+      Int_t nBinsX = division->GetNbinsX();
+      Int_t nBinsY = division->GetNbinsY();
+      for (Int_t i = 1; i <= nBinsX; ++i)
+        for (Int_t j = 1; j <= nBinsY; ++j)
+          if (proj2->GetBinContent(i, j) != 0)
+            division->SetBinError(i, j, TMath::Sqrt(proj->GetBinContent(i, j)) / proj2->GetBinContent(i, j));
+    }
+  }
+
+  if (save)
+  {
+    proj->Write();
+    proj2->Write();
+    division->Write();
+  }
+}
+
+//____________________________________________________________________
+const char* AlidNdPtHelper::GetAxisTitle(TH3* hist, const char axis)
+{
+  // returns the title of the axis given in axis (x, y, z)
+
+  if (axis == 'x')
+    return hist->GetXaxis()->GetTitle();
+  else if (axis == 'y')
+    return hist->GetYaxis()->GetTitle();
+  else if (axis == 'z')
+    return hist->GetZaxis()->GetTitle();
+
+  return 0;
+}
+
+
+AlidNdPtHelper::MCProcessType AlidNdPtHelper::GetPythiaEventProcessType(AliGenEventHeader* aHeader, Bool_t adebug) {
+
+  AliGenPythiaEventHeader* pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(aHeader);
+
+  if (!pythiaGenHeader) {
+    printf("AlidNdPtHelper::GetProcessType : Unknown gen Header type). \n");
+    return kInvalidProcess;
+  }
+
+
+  Int_t pythiaType = pythiaGenHeader->ProcessType();
+  fgLastProcessType = pythiaType;
+  MCProcessType globalType = kInvalidProcess;  
+
+
+  if (adebug) {
+    printf("AlidNdPtHelper::GetProcessType : Pythia process type found: %d \n",pythiaType);
+  }
+
+
+  if(pythiaType==92||pythiaType==93){
+    globalType = kSD;
+  }
+  else if(pythiaType==94){
+    globalType = kDD;
+  }
+  //else if(pythiaType != 91){ // also exclude elastic to be sure... CKB??
+  else {
+    globalType = kND;
+  }
+  return globalType;
+}
+
+
+AlidNdPtHelper::MCProcessType AlidNdPtHelper::GetDPMjetEventProcessType(AliGenEventHeader* aHeader, Bool_t adebug) {
+  //
+  // get the process type of the event.
+  //
+
+  // can only read pythia headers, either directly or from cocktalil header
+  AliGenDPMjetEventHeader* dpmJetGenHeader = dynamic_cast<AliGenDPMjetEventHeader*>(aHeader);
+
+  if (!dpmJetGenHeader) {
+    printf("AlidNdPtHelper::GetDPMjetProcessType : Unknown header type (not DPMjet or). \n");
+    return kInvalidProcess;
+  }
+
+  Int_t dpmJetType = dpmJetGenHeader->ProcessType();
+  fgLastProcessType = dpmJetType;
+  MCProcessType globalType = kInvalidProcess;  
+
+
+  if (adebug) {
+    printf("AlidNdPtHelper::GetDPMJetProcessType : DPMJet process type found: %d \n",dpmJetType);
+  }
+
+
+  if(dpmJetType == 1){ // this is explicitly inelastic
+    globalType = kND;
+  }  
+  else if(dpmJetType==5||dpmJetType==6){
+    globalType = kSD;
+  }
+  else if(dpmJetType==7||dpmJetType==4){// DD and double pomeron
+    globalType = kDD;
+  }
+  return globalType;
+}
+
+
+AlidNdPtHelper::MCProcessType AlidNdPtHelper::GetEventProcessType(AliHeader* aHeader, Bool_t adebug) {
+  //
+  // get the process type of the event.
+  //
+
+
+  // Check for simple headers first
+
+  AliGenPythiaEventHeader* pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(aHeader->GenEventHeader());
+  if (pythiaGenHeader) {
+    return GetPythiaEventProcessType(pythiaGenHeader,adebug);
+  }
+
+  AliGenDPMjetEventHeader* dpmJetGenHeader = dynamic_cast<AliGenDPMjetEventHeader*>(aHeader->GenEventHeader());
+  if (dpmJetGenHeader) {
+    return GetDPMjetEventProcessType(dpmJetGenHeader,adebug);
+  }
+  
+
+  // check for cocktail
+
+  AliGenCocktailEventHeader* genCocktailHeader = dynamic_cast<AliGenCocktailEventHeader*>(aHeader->GenEventHeader());
+  if (!genCocktailHeader) {
+    printf("AlidNdPtHelper::GetProcessType : Unknown header type (not Pythia or Cocktail). \n");
+    return kInvalidProcess;
+  }
+
+  TList* headerList = genCocktailHeader->GetHeaders();
+  if (!headerList) {
+    return kInvalidProcess;
+  }
+
+  for (Int_t i=0; i<headerList->GetEntries(); i++) {
+
+    pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(headerList->At(i));
+    if (pythiaGenHeader) {
+      return GetPythiaEventProcessType(pythiaGenHeader,adebug);
+    }
+
+    dpmJetGenHeader = dynamic_cast<AliGenDPMjetEventHeader*>(headerList->At(i));
+    if (dpmJetGenHeader) {
+      return GetDPMjetEventProcessType(dpmJetGenHeader,adebug);
+    }
+  }
+  return kInvalidProcess;
+}
+
+
+
+//____________________________________________________________________
+TParticle* AlidNdPtHelper::FindPrimaryMother(AliStack* stack, Int_t label)
+{
+  //
+  // Finds the first mother among the primary particles of the particle identified by <label>,
+  // i.e. the primary that "caused" this particle
+  //
+
+  Int_t motherLabel = FindPrimaryMotherLabel(stack, label);
+  if (motherLabel < 0)
+    return 0;
+
+  return stack->Particle(motherLabel);
+}
+
+//____________________________________________________________________
+Int_t AlidNdPtHelper::FindPrimaryMotherLabel(AliStack* stack, Int_t label)
+{
+  //
+  // Finds the first mother among the primary particles of the particle identified by <label>,
+  // i.e. the primary that "caused" this particle
+  //
+  // returns its label
+  //
+
+  Int_t nPrim  = stack->GetNprimary();
+
+  while (label >= nPrim)
+  {
+    //printf("Particle %d (pdg %d) is not a primary. Let's check its mother %d\n", label, mother->GetPdgCode(), mother->GetMother(0));
+
+    TParticle* particle = stack->Particle(label);
+    if (!particle)
+    {
+      AliDebugGeneral("FindPrimaryMother", AliLog::kError, Form("UNEXPECTED: particle with label %d not found in stack.", label));
+      return -1;
+    }
+    // find mother
+    if (particle->GetMother(0) < 0)
+    {
+      AliDebugGeneral("FindPrimaryMother", AliLog::kError, Form("UNEXPECTED: Could not find mother of secondary particle %d.", label));
+      return -1;
+    }
+
+    label = particle->GetMother(0);
+  }
+
+  return label;
+}
+
+//____________________________________________________________________
+void AlidNdPtHelper::NormalizeToBinWidth(TH1* hist)
+{
+  //
+  // normalizes a 1-d histogram to its bin width
+  //
+
+  for (Int_t i=1; i<=hist->GetNbinsX(); ++i)
+  {
+    hist->SetBinContent(i, hist->GetBinContent(i) / hist->GetBinWidth(i));
+    hist->SetBinError(i, hist->GetBinError(i) / hist->GetBinWidth(i));
+  }
+}
+
+//____________________________________________________________________
+void AlidNdPtHelper::NormalizeToBinWidth(TH2* hist)
+{
+  //
+  // normalizes a 2-d histogram to its bin width (x width * y width)
+  //
+
+  for (Int_t i=1; i<=hist->GetNbinsX(); ++i)
+    for (Int_t j=1; j<=hist->GetNbinsY(); ++j)
+    {
+      Double_t factor = hist->GetXaxis()->GetBinWidth(i) * hist->GetYaxis()->GetBinWidth(j);
+      hist->SetBinContent(i, j, hist->GetBinContent(i, j) / factor);
+      hist->SetBinError(i, j, hist->GetBinError(i, j) / factor);
+    }
+}
+
+//____________________________________________________________________
+void AlidNdPtHelper::PrintConf(AnalysisMode analysisMode, Trigger trigger)
+{
+  //
+  // Prints the given configuration
+  //
+
+  TString str(">>>> Running with ");
+
+  switch (analysisMode)
+  {
+    case kInvalid: str += "invalid setting"; break;
+    case kSPD : str += "SPD-only"; break;
+    case kTPC : str += "TPC-only"; break;
+    case kTPCITS : str += "Global tracking"; break;
+    case kTPCSPDvtx : str += "TPC tracking + SPD event vertex"; break;
+    case kMCRec : str += "TPC tracking + Replace rec. with MC values"; break;
+    case kMCPion : str += "TPC tracking + only pion MC tracks"; break;
+    case kMCKaon : str += "TPC tracking + only kaon MC tracks"; break;
+    case kMCProton : str += "TPC tracking + only proton MC tracks"; break;
+    case kPlus: str += "TPC tracking + only positive charged tracks"; break;
+    case kMinus : str += "TPC tracking + only negative charge tracks"; break;
+  }
+  str += " and trigger ";
+
+  switch (trigger)
+  {
+    case kMB1 : str += "MB1"; break;
+    case kMB2 : str += "MB2"; break;
+    case kSPDFASTOR : str += "SPD FASTOR"; break;
+  }
+
+  str += " <<<<";
+
+  Printf("%s", str.Data());
+}
+
+//____________________________________________________________________
+Int_t AlidNdPtHelper::ConvertPdgToPid(TParticle *particle) {
+//
+// Convert Abs(pdg) to pid 
+// (0 - e, 1 - muons, 2 - pions, 3 - kaons, 4 - protons, 5 -all rest)
+//
+Int_t pid=-1;
+
+  if (TMath::Abs(particle->GetPdgCode()) == kElectron)         { pid = 0; }
+  else if (TMath::Abs(particle->GetPdgCode()) == kMuonMinus) { pid = 1; }
+  else if (TMath::Abs(particle->GetPdgCode()) == kPiPlus)    { pid = 2; }
+  else if (TMath::Abs(particle->GetPdgCode()) == kKPlus)     { pid = 3; }
+  else if (TMath::Abs(particle->GetPdgCode()) == kProton)    { pid = 4; }
+  else                                                       { pid = 5; }
+
+return pid;
+}
+
+//_____________________________________________________________________________
+TH1F* AlidNdPtHelper::CreateResHisto(TH2F* hRes2, TH1F **phMean, Int_t integ,  Bool_t drawBinFits, Int_t minHistEntries)
+{
+  TVirtualPad* currentPad = gPad;
+  TAxis* axis = hRes2->GetXaxis();
+  Int_t nBins = axis->GetNbins();
+  Bool_t overflowBinFits = kFALSE;
+  TH1F* hRes, *hMean;
+  if (axis->GetXbins()->GetSize()){
+    hRes = new TH1F("hRes", "", nBins, axis->GetXbins()->GetArray());
+    hMean = new TH1F("hMean", "", nBins, axis->GetXbins()->GetArray());
+  }
+  else{
+    hRes = new TH1F("hRes", "", nBins, axis->GetXmin(), axis->GetXmax());
+    hMean = new TH1F("hMean", "", nBins, axis->GetXmin(), axis->GetXmax());
+
+  }
+  hRes->SetStats(false);
+  hRes->SetOption("E");
+  hRes->SetMinimum(0.);
+  //
+  hMean->SetStats(false);
+  hMean->SetOption("E");
+  // create the fit function
+  TF1 * fitFunc = new TF1("G","[0]*exp(-(x-[1])*(x-[1])/(2.*[2]*[2]))",-3,3);
+  
+  fitFunc->SetLineWidth(2);
+  fitFunc->SetFillStyle(0);
+  // create canvas for fits
+  TCanvas* canBinFits = NULL;
+  Int_t nPads = (overflowBinFits) ? nBins+2 : nBins;
+  Int_t nx = Int_t(sqrt(nPads-1.));// + 1;
+  Int_t ny = (nPads-1) / nx + 1;
+  if (drawBinFits) {
+    canBinFits = (TCanvas*)gROOT->FindObject("canBinFits");
+    if (canBinFits) delete canBinFits;
+    canBinFits = new TCanvas("canBinFits", "fits of bins", 200, 100, 500, 700);
+    canBinFits->Divide(nx, ny);
+  }
+
+  // loop over x bins and fit projection
+  Int_t dBin = ((overflowBinFits) ? 1 : 0);
+  for (Int_t bin = 1-dBin; bin <= nBins+dBin; bin++) {
+    if (drawBinFits) canBinFits->cd(bin + dBin);
+    Int_t bin0=TMath::Max(bin-integ,0);
+    Int_t bin1=TMath::Min(bin+integ,nBins);
+    TH1D* hBin = hRes2->ProjectionY("hBin", bin0, bin1);
+    //    
+    if (hBin->GetEntries() > minHistEntries) {
+      fitFunc->SetParameters(hBin->GetMaximum(),hBin->GetMean(),hBin->GetRMS());
+      hBin->Fit(fitFunc,"s");
+      Double_t sigma = TMath::Abs(fitFunc->GetParameter(2));
+
+      if (sigma > 0.){
+       hRes->SetBinContent(bin, TMath::Abs(fitFunc->GetParameter(2)));
+       hMean->SetBinContent(bin, fitFunc->GetParameter(1));    
+      }
+      else{
+       hRes->SetBinContent(bin, 0.);
+       hMean->SetBinContent(bin,0);
+      }
+      hRes->SetBinError(bin, fitFunc->GetParError(2));
+      hMean->SetBinError(bin, fitFunc->GetParError(1));
+      
+      //
+      //
+
+    } else {
+      hRes->SetBinContent(bin, 0.);
+      hRes->SetBinError(bin, 0.);
+      hMean->SetBinContent(bin, 0.);
+      hMean->SetBinError(bin, 0.);
+    }
+    
+
+    if (drawBinFits) {
+      char name[256];
+      if (bin == 0) {
+       sprintf(name, "%s < %.4g", axis->GetTitle(), axis->GetBinUpEdge(bin));
+      } else if (bin == nBins+1) {
+       sprintf(name, "%.4g < %s", axis->GetBinLowEdge(bin), axis->GetTitle());
+      } else {
+       sprintf(name, "%.4g < %s < %.4g", axis->GetBinLowEdge(bin),
+               axis->GetTitle(), axis->GetBinUpEdge(bin));
+      }
+      canBinFits->cd(bin + dBin);
+      hBin->SetTitle(name);
+      hBin->SetStats(kTRUE);
+      hBin->DrawCopy("E");
+      canBinFits->Update();
+      canBinFits->Modified();
+      canBinFits->Update();
+    }
+    
+    delete hBin;
+  }
+
+  delete fitFunc;
+  currentPad->cd();
+  *phMean = hMean;
+  return hRes;
+}
+
+//_____________________________________________________________________________
+TH1F* AlidNdPtHelper::MakeResol(TH2F * his, Int_t integ, Bool_t type, Bool_t drawBins, Int_t minHistEntries){
+// Create resolution histograms
+  
+     TH1F *hisr=0, *hism=0;
+     if (!gPad) new TCanvas;
+         //hisr = AliTreeDraw::CreateResHistoI(his,&hism,integ);
+         hisr = CreateResHisto(his,&hism,integ,drawBins,minHistEntries);
+         if (type) return hism;
+         else return hisr;
+
+return hisr;    
+}
+
+//_____________________________________________________________________________
+AliESDtrack* AlidNdPtHelper::GetTPCOnlyTrack(AliESDEvent* esd, const AliESDVertex *vtx, Int_t iTrack)
+{
+  // creates a TPC only track from the given esd track
+  // the track has to be deleted by the user
+  //
+  // NB. most of the functionality to get a TPC only track from an ESD track is in AliESDtrack, where it should be
+  // there are only missing propagations here that are needed for old data
+  // this function will therefore become obsolete
+  //
+  // adapted from code provided by CKB
+
+  // no vertex
+  if (!vtx) return 0;  
+  if(!vtx->GetStatus()) return 0; 
+
+  AliESDtrack* track = esd->GetTrack(iTrack);
+  if (!track)
+    return 0;
+
+  AliESDtrack *tpcTrack = new AliESDtrack();
+
+  // This should have been done during the reconstruction
+  // fixed by Juri in r26675
+  // but recalculate for older data CKB
+  Float_t p[2],cov[3];
+  track->GetImpactParametersTPC(p,cov);
+  if(p[0]==0&&p[1]==0)
+    //track->RelateToVertexTPC(esd->GetPrimaryVertexTPC(),esd->GetMagneticField(),kVeryBig);
+    track->RelateToVertexTPC(vtx,esd->GetMagneticField(),kVeryBig);
+  // BKC
+
+  // only true if we have a tpc track
+  if (!track->FillTPCOnlyTrack(*tpcTrack))
+  {
+    delete tpcTrack;
+    return 0;
+  }
+
+  // propagate to Vertex
+  // not needed for normal reconstructed ESDs...
+  // Double_t pTPC[2],covTPC[3];
+  //tpcTrack->PropagateToDCA(esd->GetPrimaryVertexTPC(), esd->GetMagneticField(), 10000,  pTPC, covTPC);
+  //tpcTrack->PropagateToDCA(vtx, esd->GetMagneticField(), 10000,  pTPC, covTPC);
+
+  return tpcTrack;
+}
+
+//_____________________________________________________________________________
+TObjArray* AlidNdPtHelper::GetAllChargedTracks(AliESDEvent *esdEvent, const AliESDVertex *vtx, AnalysisMode analysisMode)
+{
+  //
+  // all charged TPC particles 
+  //
+  TObjArray *allTracks = new TObjArray();
+  if(!allTracks) return allTracks;
+
+  AliESDtrack *track=0;
+  for (Int_t iTrack = 0; iTrack < esdEvent->GetNumberOfTracks(); iTrack++) 
+  { 
+    if(analysisMode == AlidNdPtHelper::kTPC || analysisMode == AlidNdPtHelper::kTPCSPDvtx || analysisMode == AlidNdPtHelper::kMCRec || analysisMode == kMCPion || analysisMode == kMCKaon || analysisMode == kMCProton || analysisMode ==kPlus || analysisMode ==kMinus) { 
+      // track must be deleted by the user 
+      track = GetTPCOnlyTrack(esdEvent,vtx,iTrack);
+      //track = AliESDtrackCuts::GetTPCOnlyTrack(esdEvent,iTrack);
+    } else {
+      track=esdEvent->GetTrack(iTrack);
+    }
+    if(!track) continue;
+
+    if(track->Charge()==0) { 
+      if(analysisMode == AlidNdPtHelper::kTPC || analysisMode == AlidNdPtHelper::kTPCSPDvtx ||  analysisMode == AlidNdPtHelper::kMCRec || analysisMode == kMCPion || analysisMode == kMCKaon || analysisMode == kMCProton || analysisMode ==kPlus || analysisMode ==kMinus) {
+        delete track; continue; 
+      } else {
+        continue;
+      } 
+    }
+
+    allTracks->Add(track);
+  }
+  if(analysisMode == AlidNdPtHelper::kTPC || analysisMode == AlidNdPtHelper::kTPCSPDvtx || analysisMode == AlidNdPtHelper::kMCRec || analysisMode == kMCPion || analysisMode == kMCKaon || analysisMode == kMCProton || analysisMode ==kPlus || analysisMode ==kMinus) allTracks->SetOwner(kTRUE);
+
+return allTracks;
+}
+
+//_____________________________________________________________________________
+Int_t AlidNdPtHelper::GetTPCMBTrackMult(AliESDEvent *esdEvent, AlidNdPtEventCuts *evtCuts, AlidNdPtAcceptanceCuts *accCuts, AliESDtrackCuts *trackCuts)
+{
+  //
+  // get MB event track multiplicity
+  //
+  if(!esdEvent) 
+  { 
+    ::Error("AlidNdPtHelper::GetTPCMBTrackMult()","esd event is NULL");
+    return 0;  
+  }
+  if(!evtCuts || !accCuts || !trackCuts) 
+  { 
+    ::Error("AlidNdPtHelper::GetTPCMBTrackMult()","cuts not available");
+    return 0;  
+  }
+
+  //
+  Double_t pos[3]={evtCuts->GetMeanXv(),evtCuts->GetMeanYv(),evtCuts->GetMeanZv()};
+  Double_t err[3]={evtCuts->GetSigmaMeanXv(),evtCuts->GetSigmaMeanYv(),evtCuts->GetSigmaMeanZv()};
+  AliESDVertex vtx0(pos,err);
+
+  //
+  Float_t maxDCAr = accCuts->GetMaxDCAr();
+  Float_t maxDCAz = accCuts->GetMaxDCAz();
+  Float_t minTPCClust = trackCuts->GetMinNClusterTPC();
+  //
+  Int_t ntracks = esdEvent->GetNumberOfTracks();
+  Double_t dca[2],cov[3];
+  Int_t mult=0;
+  for (Int_t i=0;i <ntracks; i++){
+    AliESDtrack *t = esdEvent->GetTrack(i);
+    if (!t) continue;
+    if (t->Charge() == 0) continue;
+    if (!t->GetTPCInnerParam()) continue;
+    if (t->GetTPCNcls()<minTPCClust) continue;
+    //
+    AliExternalTrackParam  *tpcTrack  = new AliExternalTrackParam(*(t->GetTPCInnerParam()));
+    if (!tpcTrack->PropagateToDCA(&vtx0,esdEvent->GetMagneticField(),100.,dca,cov)) 
+    {
+      if(tpcTrack) delete tpcTrack; 
+      continue;
+    }
+    //
+    if (TMath::Abs(dca[0])>maxDCAr || TMath::Abs(dca[1])>maxDCAz) {
+      if(tpcTrack) delete tpcTrack; 
+      continue;
+    }
+
+    mult++;    
+
+    if(tpcTrack) delete tpcTrack; 
+  }
+
+return mult;  
+}
+
+//_____________________________________________________________________________
+Int_t AlidNdPtHelper::GetTPCMBPrimTrackMult(AliESDEvent *esdEvent, AliStack * stack, AlidNdPtEventCuts *evtCuts, AlidNdPtAcceptanceCuts *accCuts, AliESDtrackCuts *trackCuts)
+{
+  //
+  // get MB primary event track multiplicity
+  //
+  if(!esdEvent) 
+  { 
+    ::Error("AlidNdPtHelper::GetTPCMBPrimTrackMult()","esd event is NULL");
+    return 0;  
+  }
+
+  if(!stack) 
+  { 
+    ::Error("AlidNdPtHelper::GetTPCMBPrimTrackMult()","esd event is NULL");
+    return 0;  
+  }
+  if(!evtCuts || !accCuts || !trackCuts) 
+  { 
+    ::Error("AlidNdPtHelper::GetTPCMBPrimTrackMult()","cuts not available");
+    return 0;  
+  }
+
+  //
+  Double_t pos[3]={evtCuts->GetMeanXv(),evtCuts->GetMeanYv(),evtCuts->GetMeanZv()};
+  Double_t err[3]={evtCuts->GetSigmaMeanXv(),evtCuts->GetSigmaMeanYv(),evtCuts->GetSigmaMeanZv()};
+  AliESDVertex vtx0(pos,err);
+
+  //
+  Float_t maxDCAr = accCuts->GetMaxDCAr();
+  Float_t maxDCAz = accCuts->GetMaxDCAz();
+  Float_t minTPCClust = trackCuts->GetMinNClusterTPC();
+
+  //
+  Int_t ntracks = esdEvent->GetNumberOfTracks();
+  Double_t dca[2],cov[3];
+  Int_t mult=0;
+  for (Int_t i=0;i <ntracks; i++){
+    AliESDtrack *t = esdEvent->GetTrack(i);
+    if (!t) continue;
+    if (t->Charge() == 0) continue;
+    if (!t->GetTPCInnerParam()) continue;
+    if (t->GetTPCNcls()<minTPCClust) continue;
+    //
+    AliExternalTrackParam  *tpcTrack  = new AliExternalTrackParam(*(t->GetTPCInnerParam()));
+    if (!tpcTrack->PropagateToDCA(&vtx0,esdEvent->GetMagneticField(),100.,dca,cov)) 
+    {
+      if(tpcTrack) delete tpcTrack; 
+      continue;
+    }
+    //
+    if (TMath::Abs(dca[0])>maxDCAr || TMath::Abs(dca[1])>maxDCAz) {
+      if(tpcTrack) delete tpcTrack; 
+      continue;
+    }
+
+    Int_t label = TMath::Abs(t->GetLabel());
+    TParticle *part = stack->Particle(label);
+    if(!part) { 
+      if(tpcTrack) delete tpcTrack; 
+      continue;
+    }
+    if(!stack->IsPhysicalPrimary(label)) 
+    { 
+      if(tpcTrack) delete tpcTrack; 
+      continue;
+    }
+
+    mult++;    
+
+    if(tpcTrack) delete tpcTrack; 
+  }
+
+return mult;  
+}
+
+
+
+
+
+//_____________________________________________________________________________
+Int_t AlidNdPtHelper::GetMCTrueTrackMult(AliMCEvent *mcEvent, AlidNdPtEventCuts *evtCuts, AlidNdPtAcceptanceCuts *accCuts)
+{
+  //
+  // calculate mc event true track multiplicity
+  //
+  if(!mcEvent) return 0;
+
+  AliStack* stack = 0;
+  Int_t mult = 0;
+
+  // MC particle stack
+  stack = mcEvent->Stack();
+  if (!stack) return 0;
+
+  Bool_t isEventOK = evtCuts->AcceptMCEvent(mcEvent);
+  if(!isEventOK) return 0; 
+
+  Int_t nPart  = stack->GetNtrack();
+  for (Int_t iMc = 0; iMc < nPart; ++iMc) 
+  {
+     TParticle* particle = stack->Particle(iMc);
+     if (!particle)
+     continue;
+
+     // only charged particles
+     Double_t charge = particle->GetPDG()->Charge()/3.;
+     if (charge == 0.0)
+     continue;
+      
+     // physical primary
+     Bool_t prim = stack->IsPhysicalPrimary(iMc);
+     if(!prim) continue;
+
+     // checked accepted
+     if(accCuts->AcceptTrack(particle)) 
+     {
+       mult++;
+     }
+  }
+
+return mult;  
+}
+
+//_______________________________________________________________________
+void  AlidNdPtHelper::PrintMCInfo(AliStack *pStack,Int_t label)
+{
+// print information about particles in the stack
+
+  if(!pStack)return;
+  label = TMath::Abs(label);
+  TParticle *part = pStack->Particle(label);
+  Printf("########################");
+  Printf("%s:%d %d UniqueID %d PDG %d P %3.3f",(char*)__FILE__,__LINE__,label,part->GetUniqueID(),part->GetPdgCode(),part->P());
+  part->Print();
+  TParticle* mother = part;
+  Int_t imo = part->GetFirstMother();
+  Int_t nprim = pStack->GetNprimary();
+
+  while((imo >= nprim)) {
+      mother =  pStack->Particle(imo);
+      Printf("Mother %s:%d Label %d UniqueID %d PDG %d P %3.3f",(char*)__FILE__,__LINE__,imo,mother->GetUniqueID(),mother->GetPdgCode(),mother->P());
+      mother->Print();
+      imo =  mother->GetFirstMother();
+ }
+
+ Printf("########################");
+}
+
+
+//_____________________________________________________________________________
+TH1* AlidNdPtHelper::GetContCorrHisto(TH1 *hist) 
+{
+//
+// get contamination histogram
+//
+ if(!hist) return 0;
+
+ Int_t nbins = hist->GetNbinsX();
+ TH1 *h_cont = (TH1D *)hist->Clone();
+
+ for(Int_t i=0; i<=nbins+1; i++) {
+   Double_t binContent = hist->GetBinContent(i);
+   Double_t binError = hist->GetBinError(i);
+
+   h_cont->SetBinContent(i,1.-binContent);
+   h_cont->SetBinError(i,binError);
+ }
+
+return h_cont;
+}
+
+
+//_____________________________________________________________________________
+TH1* AlidNdPtHelper::ScaleByBinWidth(TH1 *hist) 
+{
+//
+// scale by bin width
+//
+ if(!hist) return 0;
+
+ TH1 *h_scale = (TH1D *)hist->Clone();
+ h_scale->Scale(1.,"width");
+
+return h_scale;
+}
+
+//_____________________________________________________________________________
+TH1* AlidNdPtHelper::CalcRelativeDifference(TH1 *hist1, TH1 *hist2) 
+{
+//
+// calculate rel. difference 
+//
+
+ if(!hist1) return 0;
+ if(!hist2) return 0;
+
+ TH1 *h1_clone = (TH1D *)hist1->Clone();
+ h1_clone->Sumw2();
+
+ // (rec-mc)/mc
+ h1_clone->Add(hist2,-1);
+ h1_clone->Divide(hist2);
+
+return h1_clone;
+}
+
+//_____________________________________________________________________________
+TH1* AlidNdPtHelper::CalcRelativeDifferenceFun(TH1 *hist1, TF1 *fun) 
+{
+//
+// calculate rel. difference\12
+// between histogram and function
+//
+ if(!hist1) return 0;
+ if(!fun) return 0;
+
+ TH1 *h1_clone = (TH1D *)hist1->Clone();
+ h1_clone->Sumw2();
+
+ // 
+ h1_clone->Add(fun,-1);
+ h1_clone->Divide(hist1);
+
+return h1_clone;
+}
+
+//_____________________________________________________________________________
+TH1* AlidNdPtHelper::NormalizeToEvent(TH2 *hist1, TH1 *hist2) 
+{
+// normalise to event for a given multiplicity bin
+// return pt histogram 
+
+ if(!hist1) return 0;
+ if(!hist2) return 0;
+ char name[256];
+
+ Int_t nbinsX = hist1->GetNbinsX();
+ //Int_t nbinsY = hist1->GetNbinsY();
+
+ TH1D *hist_norm = 0;
+ for(Int_t i=0; i<=nbinsX+1; i++) {
+   sprintf(name,"mom_%d",i);
+   TH1D *hist = (TH1D*)hist1->ProjectionY(name,i+1,i+1);
+
+   sprintf(name,"mom_norm");
+   if(i==0) { 
+     hist_norm = (TH1D *)hist->Clone(name);
+     hist_norm->Reset();
+   }
+
+   Double_t nbEvents = hist2->GetBinContent(i);
+   if(!nbEvents) { nbEvents = 1.; };
+
+   hist->Scale(1./nbEvents);
+   hist_norm->Add(hist);
+ }
+
+return hist_norm;
+}
+
+//_____________________________________________________________________________
+THnSparse* AlidNdPtHelper::GenerateCorrMatrix(THnSparse *hist1, THnSparse *hist2, char *name) {
+// generate correction matrix
+if(!hist1 || !hist2) return 0; 
+
+THnSparse *h =(THnSparse*)hist1->Clone(name);;
+h->Divide(hist1,hist2,1,1,"B");
+
+return h;
+}
+
+//_____________________________________________________________________________
+TH2* AlidNdPtHelper::GenerateCorrMatrix(TH2 *hist1, TH2 *hist2, char *name) {
+// generate correction matrix
+if(!hist1 || !hist2) return 0; 
+
+TH2D *h =(TH2D*)hist1->Clone(name);;
+h->Divide(hist1,hist2,1,1,"B");
+
+return h;
+}
+
+//_____________________________________________________________________________
+TH1* AlidNdPtHelper::GenerateCorrMatrix(TH1 *hist1, TH1 *hist2, char *name) {
+// generate correction matrix
+if(!hist1 || !hist2) return 0; 
+
+TH1D *h =(TH1D*)hist1->Clone(name);;
+h->Divide(hist1,hist2,1,1,"B");
+
+return h;
+}
+
+//_____________________________________________________________________________
+THnSparse* AlidNdPtHelper::GenerateContCorrMatrix(THnSparse *hist1, THnSparse *hist2, char *name) {
+// generate contamination correction matrix
+if(!hist1 || !hist2) return 0; 
+
+THnSparse *hist =  GenerateCorrMatrix(hist1, hist2, name);
+if(!hist) return 0;
+
+// only for non ZERO bins!!!!
+
+Int_t* coord = new Int_t[hist->GetNdimensions()];
+memset(coord, 0, sizeof(Int_t) * hist->GetNdimensions());
+
+  for (Long64_t i = 0; i < hist->GetNbins(); ++i) {
+    Double_t v = hist->GetBinContent(i, coord);
+    hist->SetBinContent(coord, 1.0-v);
+    //printf("v %f, hist->GetBinContent(i, coord) %f \n",v,hist->GetBinContent(i, coord));
+    Double_t err = hist->GetBinError(coord);
+    hist->SetBinError(coord, err);
+  }
+
+delete [] coord;
+
+return hist;
+}
+
+//_____________________________________________________________________________
+TH2* AlidNdPtHelper::GenerateContCorrMatrix(TH2 *hist1, TH2 *hist2, char *name) {
+// generate contamination correction matrix
+if(!hist1 || !hist2) return 0; 
+
+TH2 *hist = GenerateCorrMatrix(hist1, hist2, name);
+if(!hist) return 0;
+
+Int_t nBinsX = hist->GetNbinsX();
+Int_t nBinsY = hist->GetNbinsY();
+
+  for (Int_t i = 0; i < nBinsX+1; i++) {
+  for (Int_t j = 0; j < nBinsY+1; j++) {
+     Double_t cont = hist->GetBinContent(i,j);
+     hist->SetBinContent(i,j,1.-cont);
+     Double_t err = hist->GetBinError(i,j);
+     hist->SetBinError(i,j,err);
+  }
+  }
+
+return hist;
+}
+
+//_____________________________________________________________________________
+TH1* AlidNdPtHelper::GenerateContCorrMatrix(TH1 *hist1, TH1 *hist2, char *name) {
+// generate contamination correction matrix
+if(!hist1 || !hist2) return 0; 
+
+TH1 *hist = GenerateCorrMatrix(hist1, hist2, name);
+if(!hist) return 0;
+
+Int_t nBinsX = hist->GetNbinsX();
+
+  for (Int_t i = 0; i < nBinsX+1; i++) {
+     Double_t cont = hist->GetBinContent(i);
+     hist->SetBinContent(i,1.-cont);
+     Double_t err = hist->GetBinError(i);
+     hist->SetBinError(i,err);
+  }
+
+return hist;
+}
+
+//_____________________________________________________________________________
+const AliESDVertex* AlidNdPtHelper::GetTPCVertexZ(AliESDEvent* esdEvent, Float_t sigmaXYcut, Float_t distXYcut, Float_t distZcut, Int_t nclCut, Float_t fraction, Int_t ntracksMin){
+  //
+  // TPC Z vertexer
+  //
+  Double_t vtxpos[3]={0.,0.,0.};
+  Double_t vtxsigma[3]={.2,.2,100.};
+  AliESDVertex vtx0(vtxpos,vtxsigma);
+  //
+  Int_t ntracks = esdEvent->GetNumberOfTracks();
+  TVectorD ztrack(ntracks);
+  //Float_t dcar, dcaz;
+  //Float_t point[2],cov[3];
+  Double_t dca[2],cov[3];
+  Int_t counter=0;
+  for (Int_t i=0;i <ntracks; i++){
+    AliESDtrack *t = esdEvent->GetTrack(i);
+    if (!t) continue;
+    if (!t->GetTPCInnerParam()) continue;
+    if (t->GetTPCNcls()<nclCut) continue;
+    //
+    AliExternalTrackParam  *tpcTrack  = new AliExternalTrackParam(*(t->GetTPCInnerParam()));
+    if (!tpcTrack->PropagateToDCA(&vtx0,esdEvent->GetMagneticField(),100.,dca,cov)) continue;
+
+    //
+    if (TMath::Abs(dca[0])>distXYcut) continue;
+    if (TMath::Sqrt(cov[0])>sigmaXYcut) continue;    
+    if (TMath::Abs(tpcTrack->GetZ())>distZcut) continue;
+
+    /*
+    t->GetImpactParametersTPC(dcar,dcaz);
+    if (TMath::Abs(dcar)>distXYcut) continue;
+    //
+    t->GetImpactParametersTPC(point,cov);
+    if (TMath::Sqrt(cov[0])>sigmaXYcut) continue;    
+    //
+    AliExternalTrackParam  tpcTrack(*(t->GetTPCInnerParam()));
+    if (!tpcTrack.PropagateToDCA(&vtx0,esdEvent->GetMagneticField(), 100)) continue;
+    if (TMath::Abs(tpcTrack.GetZ())>distZcut) continue;
+    */
+    ztrack[counter]=tpcTrack->GetZ();
+    counter++;    
+
+    if(tpcTrack) delete tpcTrack;
+  }
+  //
+  // Find LTM z position
+  //
+  Double_t mean=0, sigma=0;
+  if (counter<ntracksMin) return 0;
+  //
+  Int_t nused = TMath::Nint(counter*fraction);
+  if (nused==counter) nused=counter-1;  
+  if (nused>1){
+    AliMathBase::EvaluateUni(counter, ztrack.GetMatrixArray(), mean,sigma, TMath::Nint(counter*fraction));
+    sigma/=TMath::Sqrt(nused);
+  }else{
+    mean  = TMath::Mean(counter, ztrack.GetMatrixArray());
+    sigma = TMath::RMS(counter, ztrack.GetMatrixArray());
+    sigma/=TMath::Sqrt(counter-1);
+  }
+  vtxpos[2]=mean;
+  vtxsigma[2]=sigma;
+  const AliESDVertex* vertex = new AliESDVertex(vtxpos, vtxsigma);
+  return vertex;
+}
+
+//_____________________________________________________________________________
+Int_t  AlidNdPtHelper::GetSPDMBTrackMult(AliESDEvent* esdEvent, Float_t deltaThetaCut, Float_t deltaPhiCut) 
+{
+  //
+  // SPD track multiplicity
+  //
+
+  // get tracklets
+  const AliMultiplicity* mult = esdEvent->GetMultiplicity();
+  if (!mult)
+     return 0;
+
+  // get multiplicity from SPD tracklets
+  Int_t inputCount = 0; 
+  for (Int_t i=0; i<mult->GetNumberOfTracklets(); ++i)
+  {
+    //printf("%d %f %f %f\n", i, mult->GetTheta(i), mult->GetPhi(i), mult->GetDeltaPhi(i));
+
+     Float_t phi = mult->GetPhi(i);
+     if (phi < 0)
+       phi += TMath::Pi() * 2;
+     Float_t deltaPhi = mult->GetDeltaPhi(i);
+     Float_t deltaTheta = mult->GetDeltaTheta(i);
+
+     if (TMath::Abs(deltaPhi) > 1)
+       printf("WARNING: Very high Delta Phi: %d %f %f %f\n", i, mult->GetTheta(i), mult->GetPhi(i), deltaPhi);
+
+     if (deltaThetaCut > 0. && TMath::Abs(deltaTheta) > deltaThetaCut)
+        continue;
+
+     if (deltaPhiCut > 0. && TMath::Abs(deltaPhi) > deltaPhiCut)
+        continue;
+      
+     ++inputCount;
+  }
+
+return inputCount;
+}
+
+//_____________________________________________________________________________
+Int_t  AlidNdPtHelper::GetSPDMBPrimTrackMult(AliESDEvent* esdEvent, AliStack* stack, Float_t deltaThetaCut, Float_t deltaPhiCut) 
+{
+  //
+  // SPD track multiplicity
+  //
+
+  // get tracklets
+  const AliMultiplicity* mult = esdEvent->GetMultiplicity();
+  if (!mult)
+     return 0;
+
+  // get multiplicity from SPD tracklets
+  Int_t inputCount = 0; 
+  for (Int_t i=0; i<mult->GetNumberOfTracklets(); ++i)
+  {
+    //printf("%d %f %f %f\n", i, mult->GetTheta(i), mult->GetPhi(i), mult->GetDeltaPhi(i));
+
+     Float_t phi = mult->GetPhi(i);
+     if (phi < 0)
+       phi += TMath::Pi() * 2;
+     Float_t deltaPhi = mult->GetDeltaPhi(i);
+     Float_t deltaTheta = mult->GetDeltaTheta(i);
+
+     if (TMath::Abs(deltaPhi) > 1)
+       printf("WARNING: Very high Delta Phi: %d %f %f %f\n", i, mult->GetTheta(i), mult->GetPhi(i), deltaPhi);
+
+     if (deltaThetaCut > 0. && TMath::Abs(deltaTheta) > deltaThetaCut)
+        continue;
+
+     if (deltaPhiCut > 0. && TMath::Abs(deltaPhi) > deltaPhiCut)
+        continue;
+
+
+     if (mult->GetLabel(i, 0) < 0 || mult->GetLabel(i, 0) != mult->GetLabel(i, 1) || 
+         !stack->IsPhysicalPrimary(mult->GetLabel(i, 0)))
+        continue;
+
+      
+     ++inputCount;
+  }
+
+return inputCount;
+}
+
+
diff --git a/PWG0/dNdPt/AlidNdPtHelper.h b/PWG0/dNdPt/AlidNdPtHelper.h
new file mode 100644 (file)
index 0000000..c5e58e3
--- /dev/null
@@ -0,0 +1,123 @@
+/* $Id: AlidNdPtHelper.h 28655 2008-09-10 12:57:42Z jgrosseo $ */
+
+#ifndef ALIDNDPTHELPER_H
+#define ALIDNDPTHELPER_H
+
+//
+// static helper functions
+// origin PWG0 (Jan Fiete, CKB) and extended by Jacek Otwinowski (JO)
+//
+
+#include <TObject.h>
+
+class TParticle;
+class TH1;
+class TH1F;
+class TH2F;
+class TH2;
+class TH3;
+class TF1;
+class TTree;
+class TArrayI;
+
+class AliHeader;
+class AliGenEventHeader;
+class AliStack;
+class AliESD;
+class AliESDEvent;
+class AliESDtrack;
+class AliMCEvent;
+class AliESDVertex;
+class AliESDtrackCuts;
+class AlidNdPtAcceptanceCuts;
+class AlidNdPtEventCuts;
+
+#include "THnSparse.h"
+class AlidNdPtHelper : public TObject
+{
+  public:
+    enum Trigger { kMB1 = 0, kMB2, kSPDFASTOR }; // definition from ALICE-INT-2005-025
+    enum AnalysisMode { kInvalid = -1, kSPD = 0, kTPC, kTPCITS, kTPCSPDvtx, kMCRec, kMCPion, kMCKaon, kMCProton, kPlus, kMinus };
+    // in case we want to use bitmaps...
+    // kDiffractiveProcess is artifficial
+    enum MCProcessType { kInvalidProcess = -1, kND = 0x1, kDD = 0x2, kSD = 0x4, kDiffractiveProcess = 0x9 }; 
+
+    static Bool_t IsEventTriggered(const AliESD* aEsd, Trigger trigger = kMB2);
+    static Bool_t IsEventTriggered(ULong64_t triggerMask, Trigger trigger = kMB2);
+    static const AliESDVertex* GetVertex(AliESDEvent* aEsd, AlidNdPtEventCuts *evtCuts, AlidNdPtAcceptanceCuts *accCuts, AliESDtrackCuts *trackCuts,  AnalysisMode analysisMethod, Bool_t debug = kFALSE,Bool_t bRedoTPC = kFALSE, Bool_t bUseMeanVertex = kFALSE);
+    //static const AliESDVertex* GetVertex(AliESDEvent* aEsd, AnalysisMode analysisMethod, Bool_t debug = kFALSE,Bool_t bRedoTPC = kFALSE, Bool_t bUseMeanVertex = kFALSE);
+
+    static const AliESDVertex* GetTPCVertexZ(AliESDEvent* aEsd, Float_t sigmaXYcut=3., Float_t distXYcut=3., Float_t distZcut=30., Int_t nclCut=50, Float_t fraction=0.8, Int_t ntracksMin=2);
+
+    static const Bool_t TestVertex(const AliESDVertex* vertex, AnalysisMode analysisMode, Bool_t debug = kFALSE);
+
+    static Bool_t IsPrimaryCharged(TParticle* aParticle, Int_t aTotalPrimaries, Bool_t adebug = kFALSE);
+    static Bool_t IsPrimaryParticle(AliStack *stack, Int_t idx, AnalysisMode analysisMode);
+
+    static AlidNdPtHelper::MCProcessType GetEventProcessType(AliHeader* aHeader, Bool_t adebug = kFALSE);
+    static AlidNdPtHelper::MCProcessType GetPythiaEventProcessType(AliGenEventHeader* aHeader, Bool_t adebug = kFALSE);
+    static AlidNdPtHelper::MCProcessType GetDPMjetEventProcessType(AliGenEventHeader* aHeader, Bool_t adebug = kFALSE);
+    static Int_t GetLastProcessType() { return fgLastProcessType; }
+
+    static TParticle* FindPrimaryMother(AliStack* stack, Int_t label);
+    static Int_t FindPrimaryMotherLabel(AliStack* stack, Int_t label);
+
+    static void CreateProjections(TH3* hist, Bool_t save = kFALSE);
+    static void CreateDividedProjections(TH3* hist, TH3* hist2, const char* axis = 0, Bool_t putErrors = kFALSE, Bool_t save = kFALSE);
+    static const char* GetAxisTitle(TH3* hist, const char axis);
+
+    static void NormalizeToBinWidth(TH1* hist);
+    static void NormalizeToBinWidth(TH2* hist);
+
+    static void PrintConf(AnalysisMode analysisMode, Trigger trigger);
+
+    // added by JO
+    static Int_t ConvertPdgToPid(TParticle *particle);
+
+    enum OutputObject { kInvalidObject = -1, kCutAnalysis = 0, kAnalysis, kCorrection, kSystematics };
+    enum TrackObject  { kInvalidTrackObject = -1, kAllTracks = 0, kAccTracks, kRecTracks, kMCTracks };
+    enum EventObject  { kInvalidEventObject = -1, kAllEvents = 0, kTriggeredEvents, kAccEvents, kRecEvents, kMCEvents };
+    enum CutSteps     { kCutSteps = 3 };
+
+    //static TObjArray *GetAllChargedTracks(AliESDEvent *esdEvent, AnalysisMode analysisMode);
+    static TObjArray *GetAllChargedTracks(AliESDEvent *esdEvent, const AliESDVertex *vtx, AnalysisMode analysisMode);
+    static AliESDtrack* GetTPCOnlyTrack(AliESDEvent* esd, const AliESDVertex *vtx, Int_t iTrack);
+
+    static TH1F* MakeResol(TH2F * his, Int_t integ, Bool_t type, Bool_t drawBins, Int_t minHistEntries);
+    static TH1F* CreateResHisto(TH2F* hRes2, TH1F **phMean, Int_t integ,  Bool_t drawBinFits, Int_t minHistEntries);
+
+    static Int_t GetTPCMBTrackMult(AliESDEvent* esdEvent, AlidNdPtEventCuts *evtCuts, AlidNdPtAcceptanceCuts *accCuts, AliESDtrackCuts *trackCuts);
+    static Int_t GetTPCMBPrimTrackMult(AliESDEvent* esdEvent, AliStack * stack,AlidNdPtEventCuts *evtCuts, AlidNdPtAcceptanceCuts *accCuts, AliESDtrackCuts *trackCuts);
+
+    static Int_t GetSPDMBTrackMult(AliESDEvent* esdEvent, Float_t deltaThetaCut =0.025, Float_t deltaPhiCut = 0.08);
+    static Int_t GetSPDMBPrimTrackMult(AliESDEvent* esdEvent, AliStack * stack, Float_t deltaThetaCut =0.025, Float_t deltaPhiCut = 0.08);
+    static Int_t GetMCTrueTrackMult(AliMCEvent *mcEvent, AlidNdPtEventCuts *evtCuts, AlidNdPtAcceptanceCuts *accCuts);
+
+    static void PrintMCInfo(AliStack *pStack, Int_t label);
+
+    static TH1* ScaleByBinWidth(TH1 *hist=0);
+    static TH1* GetContCorrHisto(TH1 *hist=0);
+    static TH1* CalcRelativeDifference(TH1 *hist1=0, TH1 *hist2=0);
+    static TH1* CalcRelativeDifferenceFun(TH1 *hist=0, TF1 *fun=0);
+    static TH1* NormalizeToEvent(TH2 *hist1=0, TH1 *hist2=0);
+
+    static THnSparse* GenerateCorrMatrix(THnSparse *hist1, THnSparse *hist2, char *name);
+    static TH2* GenerateCorrMatrix(TH2 *hist1, TH2 *hist2, char *name);
+    static TH1* GenerateCorrMatrix(TH1 *hist1, TH1 *hist2, char *name);
+
+    static THnSparse* GenerateContCorrMatrix(THnSparse *hist1, THnSparse *hist2, char *name);
+    static TH2* GenerateContCorrMatrix(TH2 *hist1, TH2 *hist2, char *name);
+    static TH1* GenerateContCorrMatrix(TH1 *hist1, TH1 *hist2, char *name);
+
+  protected:
+    static Int_t fgLastProcessType;    // stores the raw value of the last process type extracnted
+    ClassDef(AlidNdPtHelper, 0);
+
+  private:
+    AlidNdPtHelper(const AlidNdPtHelper&);
+    AlidNdPtHelper& operator=(const AlidNdPtHelper&);
+};
+
+#endif
+
diff --git a/PWG0/dNdPt/AlidNdPtTask.cxx b/PWG0/dNdPt/AlidNdPtTask.cxx
new file mode 100644 (file)
index 0000000..c10a1df
--- /dev/null
@@ -0,0 +1,189 @@
+/**************************************************************************\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
+#include "iostream"\r
+\r
+#include "TChain.h"\r
+#include "TTree.h"\r
+#include "TH1F.h"\r
+#include "TCanvas.h"\r
+#include "TList.h"\r
+#include "TFile.h"\r
+\r
+#include "AliAnalysisTask.h"\r
+#include "AliAnalysisManager.h"\r
+#include "AliESDEvent.h"\r
+#include "AliESDInputHandler.h"\r
+#include "AliESDVertex.h"\r
+#include "AliTracker.h"\r
+#include "AliGeomManager.h"\r
+\r
+#include "AliESDtrackCuts.h"\r
+#include "AliMCEventHandler.h"\r
+#include "dNdPt/AlidNdPt.h"\r
+#include "dNdPt/AlidNdPtEventCuts.h"\r
+#include "dNdPt/AlidNdPtAcceptanceCuts.h"\r
+\r
+#include "dNdPt/AlidNdPtTask.h"\r
+\r
+using namespace std;\r
+\r
+ClassImp(AlidNdPtTask)\r
+\r
+//_____________________________________________________________________________\r
+AlidNdPtTask::AlidNdPtTask(const char *name) \r
+  : AliAnalysisTask(name, "dNdPt analysis")\r
+  , fESD(0)\r
+  , fMC(0)\r
+  , fOutput(0)\r
+  , fPitList(0)\r
+  , fCompList(0)\r
+  , fUseMCInfo(kFALSE)\r
+{\r
+  // Constructor\r
+\r
+  // Define input and output slots here\r
+  DefineInput(0, TChain::Class());\r
+  DefineOutput(0, TList::Class());\r
+\r
+  // create the list for comparison objects\r
+  fCompList = new TList;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+AlidNdPtTask::~AlidNdPtTask()\r
+{\r
+  if(fOutput) delete fOutput;  fOutput =0; \r
+}\r
+\r
+//____________________________________________________________________________\r
+Bool_t AlidNdPtTask::Notify()\r
+{\r
+  static Int_t count = 0;\r
+  count++;\r
+  Printf("Processing %d. file", count);\r
+\r
+return kTRUE;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AlidNdPtTask::ConnectInputData(Option_t *) \r
+{\r
+// connect input data \r
+// called once\r
+\r
+  TTree *tree = dynamic_cast<TTree*> (GetInputData(0));\r
+  if (!tree) {\r
+    Printf("ERROR: Could not read chain from input slot 0");\r
+    return;\r
+  }\r
+\r
+  AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());\r
+\r
+  if (!esdH) {\r
+    Printf("ERROR: Could not get ESDInputHandler");\r
+    return;\r
+  } else {\r
+    fESD = esdH->GetEvent();\r
+\r
+    // Enable only the needed branches\r
+    //esdH->SetActiveBranches("AliESDHeader Vertex Tracks");\r
+  }\r
+\r
+  if (fUseMCInfo) {\r
+    AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());\r
+    if (!eventHandler) {\r
+      Printf("ERROR: Could not retrieve MC event handler");\r
+      return;\r
+    } else { \r
+      fMC = eventHandler->MCEvent();\r
+    }\r
+  }\r
+}\r
+\r
+//_____________________________________________________________________________\r
+Bool_t AlidNdPtTask::AddAnalysisObject(AlidNdPt *pObj) \r
+{\r
+  // add analysis object to the list\r
+  if(pObj == 0) {\r
+    Printf("ERROR: Could not add comparison object");\r
+    return kFALSE;\r
+  }\r
+\r
+  // add object to the list\r
+  fCompList->AddLast(pObj);\r
+       \r
+return kTRUE;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AlidNdPtTask::CreateOutputObjects()\r
+{\r
+  // Create histograms\r
+  // Called once\r
+\r
+  OpenFile(0, "RECREATE");\r
+\r
+  //\r
+  // create output list\r
+  //\r
+  fOutput = new TList;\r
+  fOutput->SetOwner();\r
+  fPitList = fOutput->MakeIterator();\r
+\r
+  // add dNdPt analysis objects to the output\r
+  AlidNdPt *pObj=0;\r
+  Int_t count=0;\r
+  TIterator *pitCompList = fCompList->MakeIterator();\r
+  pitCompList->Reset();\r
+  while(( pObj = (AlidNdPt *)pitCompList->Next()) != NULL) {\r
+    fOutput->Add(pObj);\r
+    count++;\r
+  }\r
+  Printf("CreateOutputObjects(): Number of output comparison objects: %d \n", count);\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AlidNdPtTask::Exec(Option_t *) \r
+{\r
+  // Called for each event\r
+  if (!fESD) {\r
+    Printf("ERROR: ESD event not available");\r
+    return;\r
+  }\r
+\r
+  // Process analysis\r
+  AlidNdPt *pObj = 0;\r
+  fPitList->Reset();\r
+  while((pObj = (AlidNdPt *)fPitList->Next()) != NULL) {\r
+    pObj->Process(fESD,fMC);\r
+  }\r
+\r
+  // Post output data.\r
+  PostData(0, fOutput);\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AlidNdPtTask::Terminate(Option_t *) \r
+{\r
+  // Called one at the end \r
+  \r
+  // check output data\r
+  fOutput = dynamic_cast<TList*> (GetOutputData(0));\r
+  if (!fOutput) {\r
+    Printf("ERROR: AlidNdPtTask::Terminate(): Output data not avaiable GetOutputData(0)==0x0 ..." );\r
+    return;\r
+  }\r
+}\r
diff --git a/PWG0/dNdPt/AlidNdPtTask.h b/PWG0/dNdPt/AlidNdPtTask.h
new file mode 100644 (file)
index 0000000..65d1ea5
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef ALIDNDPTTASK_H
+#define ALIDNDPTTASK_H
+
+//------------------------------------------------------------------------------
+// Task for dNdPt analysis.
+// 
+// Author: J.Otwinowski 04/11/2008 
+//------------------------------------------------------------------------------
+
+class AliESDEvent;
+class AliMCEvent;
+class AlidNdPtEventCuts;
+class AlidNdPtAcceptanceCuts;
+class AliESDtrackCuts;
+class AlidNdPt;
+class AlidNdPtAnalysis;
+class AlidNdPtCorrection;
+class AliMagFMaps;
+class TList;
+
+#include "dNdPt/AlidNdPtHelper.h"
+#include "AliAnalysisTask.h"
+
+class AlidNdPtTask : public AliAnalysisTask {
+ public:
+  AlidNdPtTask(const char *name = "AlidNdPtTask");
+  virtual ~AlidNdPtTask();
+  
+  virtual void   ConnectInputData(Option_t *);
+  virtual void   CreateOutputObjects();
+  virtual void   Exec(Option_t *option);
+  virtual void   Terminate(Option_t *);
+  virtual Bool_t Notify();
+
+  Bool_t AddAnalysisObject(AlidNdPt *pObj);
+  void SetUseMCInfo(Bool_t info)           { fUseMCInfo = info; }
+
+ private:
+
+  AliESDEvent *fESD;    //! ESD event
+  AliMCEvent *fMC;      //! MC event
+  TList* fOutput;       //! list send on output slot 0
+  TIterator *fPitList;  //! iterator over the output objetcs  
+  TList *fCompList;     // list of comparison objects
+
+  Bool_t fUseMCInfo;           // use MC information
+
+  AlidNdPtTask(const AlidNdPtTask&); // not implemented
+  AlidNdPtTask& operator=(const AlidNdPtTask&); // not implemented
+  
+  ClassDef(AlidNdPtTask, 1); // example of analysis
+};
+
+#endif
diff --git a/PWG0/dNdPt/macros/CreateStandardCuts.C b/PWG0/dNdPt/macros/CreateStandardCuts.C
new file mode 100644 (file)
index 0000000..abe1928
--- /dev/null
@@ -0,0 +1,1024 @@
+/* $Id: CreateCuts.C,v 1.5 2008/01/11 08:28:52 jgrosseo Exp $ */
+
+// this macro creates the track and event cuts used in this analysis
+
+AliESDtrackCuts* CreateTrackCuts(Int_t cutMode=1, Bool_t fieldOn = kTRUE, Bool_t hists = kTRUE)
+{
+  AliESDtrackCuts* esdTrackCuts = new AliESDtrackCuts("AliESDtrackCuts");
+
+  if (hists)
+    esdTrackCuts->DefineHistograms(1);
+
+  Double_t cov1, cov2, cov3, cov4, cov5;
+  Double_t nSigma;
+  Double_t maxDCAtoVertex, maxDCAtoVertexXY, maxDCAtoVertexZ;
+  Double_t minNClustersTPC;
+  Double_t maxChi2PerClusterTPC;
+  Double_t minPt, maxPt;
+
+  // default cuts for ITS+TPC
+  if (cutMode == 0) 
+  {
+    cov1 = 2;
+    cov2 = 2;
+    cov3 = 0.5;
+    cov4 = 0.5;
+    cov5 = 2;
+    nSigma = 3;
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 3.5;
+
+    esdTrackCuts->SetMaxCovDiagonalElements(cov1, cov2, cov3, cov4, cov5);
+    esdTrackCuts->SetMinNsigmaToVertex(nSigma);
+    esdTrackCuts->SetRequireSigmaToVertex(kTRUE);
+    esdTrackCuts->SetRequireTPCRefit(kTRUE);
+    esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+
+    TString tag("Global tracking");
+  }
+
+  // TPC-only cuts (vertex n sigma cut)
+  if (cutMode == 1) 
+  {
+    // beta cuts (still under investigation)
+    //cov1 = 4;
+    //cov2 = 4;
+    cov1 = 2;
+    cov2 = 2;
+    cov3 = 0.5;
+    cov4 = 0.5;
+    cov5 = 2;
+    nSigma = 4;
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 3.5;
+
+    esdTrackCuts->SetMaxCovDiagonalElements(cov1, cov2, cov3, cov4, cov5);
+    esdTrackCuts->SetMinNsigmaToVertex(nSigma);
+    esdTrackCuts->SetRequireSigmaToVertex(kTRUE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  // TPC-only cuts (vertex maxDCAtoVertex cut)
+  if (cutMode == 2) 
+  {
+    // beta cuts (still under investigation)
+    maxDCAtoVertex = 3.0; // cm
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 3.5;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetMaxDCAToVertex(maxDCAtoVertex);    
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  // TPC-only no vertex cuts
+  if (cutMode == 3) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 3.5;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  // TPC-only no cuts at all 
+  if (cutMode == 4) 
+  {
+
+    // beta cuts (still under investigation)
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kTRUE);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  // TPC-only no kink removal no chi2 
+  if (cutMode == 5) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    //maxChi2PerClusterTPC = 3.5;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kTRUE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    //esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  // TPC-only no kink removal 
+  if (cutMode == 6) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 3.5;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kTRUE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  // TPC-only no kink removal no minNClustersTPC 
+  if (cutMode == 7) 
+  {
+    // beta cuts (still under investigation)
+    //minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 3.5;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kTRUE);
+    //esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+
+    TString tag = "TPC-only tracking";
+  }
+  // TPC-only no kink removal no minNClustersTPC 
+  if (cutMode == 8) 
+  {
+    // beta cuts (still under investigation)
+    //minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 3.5;
+    maxDCAtoVertex = 3.0; // cm
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetMaxDCAToVertex(maxDCAtoVertex);    
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kTRUE);
+    //esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  // TPC-only no kink removal no minNClustersTPC no maxChi2PerClusterTPC
+  if (cutMode == 9) 
+  {
+    // beta cuts (still under investigation)
+    //minNClustersTPC = 50;
+    //maxChi2PerClusterTPC = 3.5;
+    maxDCAtoVertex = 3.0; // cm
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetMaxDCAToVertex(maxDCAtoVertex);    
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kTRUE);
+    //esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    //esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  // TPC-only (loose cuts, absolute DCA cut) 
+  if (cutMode == 10) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 4.0;
+    maxDCAtoVertex = 2.8; // cm
+    minPt=0.15;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kTRUE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertex(maxDCAtoVertex);    
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+
+  // TPC-only (loose cuts, no DCA cut) 
+  if (cutMode == 11) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 4.0;
+    maxDCAtoVertexXY = 1.e10; // cm
+    maxDCAtoVertexZ  = 1.e10; // cm
+    minPt=0.15;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kTRUE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  // TPC-only (standard cuts, no DCA cut) 
+  if (cutMode == 12) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 96;
+    maxChi2PerClusterTPC = 3.5;
+    maxDCAtoVertexXY = 1.e10; // cm
+    maxDCAtoVertexZ  = 1.e10; // cm
+    minPt=0.2;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kTRUE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  // TPC-only (tight cuts, no DCA cut) 
+  if (cutMode == 13) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 120;
+    maxChi2PerClusterTPC = 3.5;
+    maxDCAtoVertexXY = 1.e10; // cm
+    maxDCAtoVertexZ  = 1.e10; // cm
+    minPt=0.3;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kTRUE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  // TPC-only (loose cuts, no pt cut) 
+  if (cutMode == 14) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 4.0;
+    maxDCAtoVertexXY = 1.e10; // cm
+    maxDCAtoVertexZ  = 1.e10; // cm
+    minPt=0.0;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kTRUE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  // TPC-only (standard cuts, no pt cut) 
+  if (cutMode == 15) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 96;
+    maxChi2PerClusterTPC = 3.5;
+    maxDCAtoVertexXY = 1.e10; // cm
+    maxDCAtoVertexZ  = 1.e10; // cm
+    minPt=0.0;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kTRUE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  // TPC-only (tight cuts, no pt cuts) 
+  if (cutMode == 16) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 120;
+    maxChi2PerClusterTPC = 3.5;
+    maxDCAtoVertexXY = 1.e10; // cm
+    maxDCAtoVertexZ  = 1.e10; // cm
+    minPt=0.0;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kTRUE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+  // TPC-only (loose cuts)
+  if (cutMode == 17) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 4.0;
+    //maxDCAtoVertexXY = 2.4; // cm
+    //maxDCAtoVertexZ  = 3.2; // cm
+    maxDCAtoVertexXY = 1.6; // cm
+    maxDCAtoVertexZ  = 2.1; // cm
+    minPt=0.15;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kTRUE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  // TPC-only (standard cuts)
+  if (cutMode == 18) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 96;
+    maxChi2PerClusterTPC = 3.5;
+    //maxDCAtoVertexXY = 2.4; // cm
+    //maxDCAtoVertexZ  = 3.2; // cm
+    maxDCAtoVertexXY = 1.4; // cm
+    maxDCAtoVertexZ  = 1.8; // cm
+    minPt=0.2;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kTRUE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+ // TPC-only (tight cuts)
+  if (cutMode == 19) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 120;
+    maxChi2PerClusterTPC = 3.0;
+    //maxDCAtoVertexXY = 2.4; // cm
+    //maxDCAtoVertexZ  = 3.2; // cm
+    maxDCAtoVertexXY = 1.4; // cm
+    maxDCAtoVertexZ  = 1.8; // cm
+    minPt=0.3;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kTRUE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  // TPC-only (arb. cuts, kink cuts included)
+  if (cutMode == 20) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 1.e10;
+    maxDCAtoVertexXY = 3.0; // cm
+    maxDCAtoVertexZ  = 3.0; // cm
+    minPt=0.0;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  // TPC-only (arb. cuts, kink cuts excluded)
+  if (cutMode == 21) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 1.e10;
+    maxDCAtoVertexXY = 3.0; // cm
+    maxDCAtoVertexZ  = 3.0; // cm
+    minPt=0.0;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kTRUE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  // TPC-only (arb. cuts, kink cuts excluded, no chi2, no DCA)
+  if (cutMode == 22) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 1.e10;
+    maxDCAtoVertexXY = 1.e10; // cm
+    maxDCAtoVertexZ  = 1.e10; // cm
+    minPt=0.15;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kTRUE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  // TPC-only + pt cut + eta cut 
+  if (cutMode == 23) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 4.0;
+    maxDCAtoVertexXY = 2.4; // cm
+    maxDCAtoVertexZ  = 3.2; // cm
+    //minPt=0.15;
+    //maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    //esdTrackCuts->SetPtRange(minPt,maxPt);
+    //esdTrackCuts->SetEtaRange(minEta,maxEta);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  // TPC-only (no pt cut, no eta cut)
+  if (cutMode == 24) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 4.0;
+    maxDCAtoVertexXY = 2.4; // cm
+    maxDCAtoVertexZ  = 3.2; // cm
+    minPt=0.0;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  //
+  // systematic errors DCA cut studies
+  //
+  // TPC-only
+  if (cutMode == 25) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 4.0;
+    maxDCAtoVertexXY = 1.4; // cm
+    maxDCAtoVertexZ  = 2.2; // cm
+    minPt=0.0;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  if (cutMode == 26) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 4.0;
+    maxDCAtoVertexXY = 1.6; // cm
+    maxDCAtoVertexZ  = 2.4; // cm
+    minPt=0.0;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  //
+  // systematic errors cut studies
+  //
+  // TPC-only
+  if (cutMode == 27) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 4.0;
+    maxDCAtoVertexXY = 1.8; // cm
+    maxDCAtoVertexZ  = 2.6; // cm
+    minPt=0.0;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  if (cutMode == 28) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 4.0;
+    maxDCAtoVertexXY = 2.0; // cm
+    maxDCAtoVertexZ  = 2.8; // cm
+    minPt=0.0;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  if (cutMode == 29) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 4.0;
+    maxDCAtoVertexXY = 2.2; // cm
+    maxDCAtoVertexZ  = 3.0; // cm
+    minPt=0.0;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  if (cutMode == 30) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 4.0;
+    maxDCAtoVertexXY = 2.4; // cm
+    maxDCAtoVertexZ  = 3.2; // cm
+    minPt=0.0;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  if (cutMode == 31) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 4.0;
+    maxDCAtoVertexXY = 2.6; // cm
+    maxDCAtoVertexZ  = 3.4; // cm
+    minPt=0.0;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+
+  if (cutMode == 32) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 4.0;
+    maxDCAtoVertexXY = 2.8; // cm
+    maxDCAtoVertexZ  = 3.6; // cm
+    minPt=0.0;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  if (cutMode == 33) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 4.0;
+    maxDCAtoVertexXY = 3.0; // cm
+    maxDCAtoVertexZ  = 3.8; // cm
+    minPt=0.0;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  if (cutMode == 34) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 4.0;
+    maxDCAtoVertexXY = 3.2; // cm
+    maxDCAtoVertexZ  = 4.0; // cm
+    minPt=0.0;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  if (cutMode == 35) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 4.0;
+    maxDCAtoVertexXY = 3.4; // cm
+    maxDCAtoVertexZ  = 4.2; // cm
+    minPt=0.0;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+//
+// cut stability systematics
+//
+
+  if (cutMode == 36) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 70;
+    maxChi2PerClusterTPC = 4.0;
+    maxDCAtoVertexXY = 2.4; // cm
+    maxDCAtoVertexZ  = 3.2; // cm
+    minPt=0.0;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+ if (cutMode == 37) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 90;
+    maxChi2PerClusterTPC = 4.0;
+    maxDCAtoVertexXY = 2.4; // cm
+    maxDCAtoVertexZ  = 3.2; // cm
+    minPt=0.0;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  if (cutMode == 38) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 3.0;
+    maxDCAtoVertexXY = 2.4; // cm
+    maxDCAtoVertexZ  = 3.2; // cm
+    minPt=0.0;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  if (cutMode == 39) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 5.0;
+    maxDCAtoVertexXY = 2.4; // cm
+    maxDCAtoVertexZ  = 3.2; // cm
+    minPt=0.0;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  if (cutMode == 40) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 4.0;
+    maxDCAtoVertexXY = 1.4; // cm
+    maxDCAtoVertexZ  = 2.2; // cm
+    minPt=0.0;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  if (cutMode == 41) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 4.0;
+    maxDCAtoVertexXY = 3.4; // cm
+    maxDCAtoVertexZ  = 4.2; // cm
+    minPt=0.0;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+
+  if (cutMode == 42) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 4.0;
+    maxDCAtoVertexXY = 2.4; // cm
+    maxDCAtoVertexZ  = 3.2; // cm
+    minPt=0.0;
+    maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    //esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kTRUE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    esdTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString tag = "TPC-only tracking";
+  }
+  // test
+  if (cutMode == 43) 
+  {
+    // beta cuts (still under investigation)
+    minNClustersTPC = 50;
+    maxChi2PerClusterTPC = 4.0;
+    //maxDCAtoVertexXY = 2.4; // cm
+    //maxDCAtoVertexZ  = 3.2; // cm
+    //minPt=0.15;
+    //maxPt=1.e10;
+
+    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCuts->SetRequireTPCRefit(kFALSE);
+    esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+    esdTrackCuts->SetMinNClustersTPC(minNClustersTPC);
+    esdTrackCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+    //esdTrackCuts->SetMaxDCAToVertexXY(maxDCAtoVertexXY);
+    //esdTrackCuts->SetMaxDCAToVertexZ(maxDCAtoVertexZ);
+    //esdTrackCuts->SetDCAToVertex2D(kTRUE);
+    //esdTrackCuts->SetPtRange(minPt,maxPt);
+    //esdTrackCuts->SetEtaRange(minEta,maxEta);
+
+    TString tag = "TPC-only tracking";
+  }
+
+
+  // cuts for data without field
+  if (!fieldOn)
+  {
+    cov5 = 1e10;
+    tag += " without field";
+  }
+
+  Printf("Created track cuts for: %s", tag.Data());
+
+  return esdTrackCuts;
+}
diff --git a/PWG0/dNdPt/macros/LoadMyLibs.C b/PWG0/dNdPt/macros/LoadMyLibs.C
new file mode 100644 (file)
index 0000000..d51e00f
--- /dev/null
@@ -0,0 +1,42 @@
+void LoadMyLibs() {
+
+  // Load some ROOT libraries
+  CheckLoadLibrary("libEG");
+  CheckLoadLibrary("libGeom");
+  CheckLoadLibrary("libVMC");
+  CheckLoadLibrary("libTree");
+  CheckLoadLibrary("libGui");
+  CheckLoadLibrary("libMinuit");
+  
+  // Load AliRoot libraries
+  
+  CheckLoadLibrary("libSTEERBase");
+  CheckLoadLibrary("libCDB");
+  CheckLoadLibrary("libRAWDatabase");
+  CheckLoadLibrary("libRAWDatarec");
+  CheckLoadLibrary("libESD");
+  CheckLoadLibrary("libAOD");
+  CheckLoadLibrary("libSTEER");
+  
+  CheckLoadLibrary("libANALYSIS");
+  CheckLoadLibrary("libANALYSISalice");
+  CheckLoadLibrary("libTENDER");
+  CheckLoadLibrary("libTPCbase");
+  CheckLoadLibrary("libTPCsim");
+  CheckLoadLibrary("libTRDbase");
+  CheckLoadLibrary("libTPCrec");
+  CheckLoadLibrary("libTRDrec");
+  CheckLoadLibrary("libITSbase");
+  CheckLoadLibrary("libITSrec");
+  CheckLoadLibrary("libPWG0base");
+  CheckLoadLibrary("libPWG0dep");
+  CheckLoadLibrary("libPWG0selectors");
+  CheckLoadLibrary("libPWG1");
+}
+
+Int_t CheckLoadLibrary(const char* library) {
+  // checks if a library is already loaded, if not loads the library
+  if (strlen(gSystem->GetLibraries(Form("%s.so", library), "", kFALSE)) > 0)
+    return 1;
+  return gSystem->Load(library);
+}
diff --git a/PWG0/dNdPt/macros/ProofEnableAliRoot.C b/PWG0/dNdPt/macros/ProofEnableAliRoot.C
new file mode 100644 (file)
index 0000000..7d519cf
--- /dev/null
@@ -0,0 +1,21 @@
+
+void ProofEnableAliRoot(const char* location = "/usr/local/grid/AliRoot/v4-05-Release")
+{
+  // enables a locally deployed AliRoot in a PROOF cluster
+
+  printf("Load libraries: %s \n",location);
+  gProof->Exec(Form("TString str(gSystem->ExpandPathName(\"%s\")); gSystem->Setenv(\"ALICE_ROOT\", str);", location), kTRUE);
+
+  gProof->AddIncludePath(Form("%s/include", location));
+  gProof->AddIncludePath(Form("%s/TPC", location));
+  gProof->AddIncludePath(Form("%s/PWG0", location));
+  gProof->AddIncludePath(Form("%s/PWG0/dNdPt", location));
+  gProof->AddIncludePath(Form("%s/ANALYSIS", location));
+
+  gProof->AddDynamicPath(Form("%s/lib/tgt_linuxx8664gcc", location));
+
+  // load all libraries
+  gProof->Exec("gROOT->Macro(\"$ALICE_ROOT/PWG0/dNdPt/macros/LoadMyLibs.C\")",kTRUE);
+}
+
diff --git a/PWG0/dNdPt/macros/rundNdPt.C b/PWG0/dNdPt/macros/rundNdPt.C
new file mode 100644 (file)
index 0000000..01f6b49
--- /dev/null
@@ -0,0 +1,145 @@
+void rundNdPt(const char *fileList ="inputList.txt",const char *outFile = "outputFile.root", Int_t NumberOfFiles=10,Int_t fromFile=0, Int_t nEvents=1000, Int_t firstEvent =0, Bool_t bUseMCInfo=kTRUE, Float_t zvWindow=20., Int_t cutMode=9,Float_t etaWindow=0.9, Float_t ptMin=0.15,AlidNdPtHelper::AnalysisMode analysisMode = AlidNdPtHelper::kTPC, AlidNdPtHelper::OutputObject outputObject=AlidNdPtHelper::kCorrection,const char *corrFile = "corrMatricesFile.root",Bool_t bProof=kFALSE)
+{
+  // set Proof
+  if(bProof) { 
+    
+    //cout << "*** START PROOF Lite SESSION ***" << endl;
+    //TProof::Open(""); // 1. Enter your username here
+    
+    TProofMgr * proofmgr = TProof::Mgr("lxialpod2.gsi.de:21001");
+    TProof * proof = proofmgr->CreateSession();
+    proof->SetParameter("PROOF_MaxSlavesPerNode", (Long_t)1000);
+
+    // -- Load AliRoot Libraries
+    gROOT->LoadMacro("ProofEnableAliRoot.C");
+    ProofEnableAliRoot("/u/jacek/alice/AliRoot/trunk");
+  }
+
+  // Swtich off all AliInfo (too much output!!!)
+  AliLog::SetGlobalLogLevel(AliLog::kError);
+
+  // Create analysis manager
+  AliAnalysisManager *mgr = new AliAnalysisManager;
+
+  //
+  // Create event cuts
+  //
+  AlidNdPtEventCuts *evtCuts = new AlidNdPtEventCuts("AlidNdPtEventCuts","Event cuts");
+  evtCuts->SetZvRange(-zvWindow,zvWindow);
+  evtCuts->SetMeanXYZv(0.0,0.0,0.0);
+  evtCuts->SetSigmaMeanXYZv(1.0,1.0,10.0);
+  //evtCuts->SetTriggerRequired(kFALSE);
+
+  // Create geom. acceptance cuts
+  AlidNdPtAcceptanceCuts *accCuts = new AlidNdPtAcceptanceCuts("AlidNdPtAcceptanceCuts","Geom. acceptance cuts");
+  accCuts->SetEtaRange(-etaWindow,etaWindow);
+  accCuts->SetPtRange(ptMin,1.e10);
+  accCuts->SetMaxDCAr(3.0);
+  accCuts->SetMaxDCAz(30.0);
+
+  // Create standard esd track cuts
+  gROOT->LoadMacro("CreateStandardCuts.C");
+  AliESDtrackCuts* esdTrackCuts = CreateTrackCuts(cutMode);
+  if (!esdTrackCuts) {
+    printf("ERROR: esdTrackCuts could not be created\n");
+    return;
+  } else {
+    esdTrackCuts->SetHistogramsOn(kTRUE);
+  }
+
+  //
+  // Create task
+  //
+  AlidNdPtTask *task = new AlidNdPtTask("AlidNdPtTask");
+  if (bUseMCInfo) task->SetUseMCInfo(kTRUE);
+
+  // create cut analysis object
+  if(outputObject==AlidNdPtHelper::kCutAnalysis) 
+  {
+    AlidNdPtCutAnalysis *fdNdPtCutAnalysis = new AlidNdPtCutAnalysis("dNdPtCutAnalysis","dN/dPt Cut Analysis");
+    fdNdPtCutAnalysis->SetEventCuts(evtCuts);
+    fdNdPtCutAnalysis->SetAcceptanceCuts(accCuts);
+    fdNdPtCutAnalysis->SetTrackCuts(esdTrackCuts);
+    fdNdPtCutAnalysis->SetAnalysisMode(analysisMode); 
+    fdNdPtCutAnalysis->SetTrigger(AlidNdPtHelper::kMB1); 
+    if (bUseMCInfo) fdNdPtCutAnalysis->SetUseMCInfo(kTRUE);
+
+    task->AddAnalysisObject( fdNdPtCutAnalysis );
+  }
+
+  // create analysis object
+  if(outputObject==AlidNdPtHelper::kAnalysis) 
+  {
+    AlidNdPtAnalysis *fdNdPtAnalysis = new AlidNdPtAnalysis("dNdPtAnalysis","dN/dPt Analysis");
+    fdNdPtAnalysis->SetEventCuts(evtCuts);
+    fdNdPtAnalysis->SetAcceptanceCuts(accCuts);
+    fdNdPtAnalysis->SetTrackCuts(esdTrackCuts);
+    fdNdPtAnalysis->SetAnalysisMode(analysisMode); 
+    fdNdPtAnalysis->SetTrigger(AlidNdPtHelper::kMB1); 
+    if (bUseMCInfo) fdNdPtAnalysis->SetUseMCInfo(kTRUE);
+
+    fdNdPtAnalysis->SetHistogramsOn(kTRUE);
+    //fdNdPtAnalysis->SetHistogramsOn(kFALSE);
+    task->AddAnalysisObject( fdNdPtAnalysis );
+  }
+
+  // create correction object
+  if(outputObject == AlidNdPtHelper::kCorrection) 
+  {
+    AlidNdPtCorrection *fdNdPtCorrection = new AlidNdPtCorrection("dNdPtCorrection","dN/dPt Correction", corrFile);
+
+    fdNdPtCorrection->SetEventCuts(evtCuts);
+    fdNdPtCorrection->SetAcceptanceCuts(accCuts);
+    fdNdPtCorrection->SetTrackCuts(esdTrackCuts);
+    fdNdPtCorrection->SetAnalysisMode(analysisMode); 
+    fdNdPtCorrection->SetTrigger(AlidNdPtHelper::kMB1); 
+    if (bUseMCInfo) fdNdPtCorrection->SetUseMCInfo(kTRUE);
+
+    task->AddAnalysisObject( fdNdPtCorrection );
+  }
+
+  // Add task
+  mgr->AddTask(task);
+
+  // Add ESD handler
+  AliESDInputHandler* esdH = new AliESDInputHandler;
+  //esdH->SetInactiveBranches("*");
+  mgr->SetInputEventHandler(esdH);
+
+  if(bUseMCInfo) {
+  // Enable MC event handler
+    AliMCEventHandler* handler = new AliMCEventHandler;
+    handler->SetReadTR(kFALSE);
+    //handler->SetReadTR(kTRUE);
+    mgr->SetMCtruthEventHandler(handler);
+  }
+
+  // Create input chain
+  gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C");
+  TChain* chain = CreateESDChain(fileList, NumberOfFiles, fromFile);
+  if(!chain) {
+    printf("ERROR: chain cannot be created\n");
+    return;
+  }
+
+  // Create containers for input
+  //AliAnalysisDataContainer *cinput = mgr->CreateContainer("cchain", TChain::Class(), AliAnalysisManager::kInputContainer);
+  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
+  mgr->ConnectInput(task, 0, cinput);
+
+  // Create containers for output
+  AliAnalysisDataContainer *coutput = mgr->CreateContainer("coutput", TList::Class(), AliAnalysisManager::kOutputContainer, outFile);
+  mgr->ConnectOutput(task, 0, coutput);
+
+  // Enable debug printouts
+  mgr->SetDebugLevel(0);
+
+  if (!mgr->InitAnalysis())
+    return;
+
+  mgr->PrintStatus();
+
+  if(bProof) mgr->StartAnalysis("proof",chain, nEvents, firstEvent);
+  else mgr->StartAnalysis("local",chain,nEvents, firstEvent);
+}
+