-- new class to store track tree
authorjotwinow <jotwinow@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 2 Aug 2011 12:48:08 +0000 (12:48 +0000)
committerjotwinow <jotwinow@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 2 Aug 2011 12:48:08 +0000 (12:48 +0000)
A    PWG0/dNdPt/AlidNdPtTrackDumpTask.h
A    PWG0/dNdPt/AlidNdPtTrackDumpTask.cxx
M    PWG0/PWG0depLinkDef.h
M    PWG0/CMakelibPWG0dep.pkg

-- add possibility to project THnSparses
M    PWG0/dNdPt/AlidNdPt.h
M    PWG0/dNdPt/AlidNdPt.cxx
M    PWG0/dNdPt/AlidNdPtTask.cxx
M    PWG0/dNdPt/AlidNdPtTask.h
M    PWG0/dNdPt/AlidNdPtCutAnalysisPbPb.h
M    PWG0/dNdPt/AlidNdPtCutAnalysisPbPb.cxx

PWG0/CMakelibPWG0dep.pkg
PWG0/PWG0depLinkDef.h
PWG0/dNdPt/AlidNdPt.cxx
PWG0/dNdPt/AlidNdPt.h
PWG0/dNdPt/AlidNdPtCutAnalysisPbPb.cxx
PWG0/dNdPt/AlidNdPtCutAnalysisPbPb.h
PWG0/dNdPt/AlidNdPtTask.cxx
PWG0/dNdPt/AlidNdPtTask.h
PWG0/dNdPt/AlidNdPtTrackDumpTask.cxx [new file with mode: 0644]
PWG0/dNdPt/AlidNdPtTrackDumpTask.h [new file with mode: 0644]

index 70f8ef6..ea4eb68 100644 (file)
@@ -41,6 +41,7 @@ set ( SRCS
     dNdPt/AlidNdPtEfficiency.cxx 
     dNdPt/AliPtResolAnalysis.cxx 
     dNdPt/AliPtResolAnalysisPbPb.cxx 
+    dNdPt/AlidNdPtTrackDumpTask.cxx
     ) 
 
 string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" )
index d6aefa4..b352873 100644 (file)
@@ -19,6 +19,7 @@
 #pragma link C++ class AlidNdPt+;
 #pragma link C++ class AlidNdPtCutAnalysis+;
 #pragma link C++ class AlidNdPtCutAnalysisPbPb+;
+#pragma link C++ class AlidNdPtTrackDumpTask+;
 
 #pragma link C++ class AlidNdPtBackgroundCuts+;
 #pragma link C++ class AlidNdPtEfficiency+;
index dc42473..aa3c036 100644 (file)
@@ -38,6 +38,8 @@ AlidNdPt::AlidNdPt(): TNamed()
 , fParticleMode(AlidNdPtHelper::kAllPart) \r
 , fPhysicsSelection(0)\r
 , fdNdPtBackgroundCuts(0)\r
+, fAnalyseOutput(kFALSE)\r
+, fMergeTHnSparse(kTRUE)\r
 {\r
   // default constructor\r
 }\r
@@ -55,6 +57,8 @@ AlidNdPt::AlidNdPt(Char_t* name, Char_t* title): TNamed(name,title)
 , fParticleMode(AlidNdPtHelper::kAllPart) \r
 , fPhysicsSelection(0)\r
 , fdNdPtBackgroundCuts(0)\r
+, fAnalyseOutput(kFALSE)\r
+, fMergeTHnSparse(kTRUE)\r
 {\r
   // constructor\r
 }\r
@@ -71,6 +75,8 @@ AlidNdPt::AlidNdPt(const AlidNdPt&): TNamed()
 , fParticleMode(AlidNdPtHelper::kAllPart) \r
 , fPhysicsSelection(0)\r
 , fdNdPtBackgroundCuts(0)\r
+, fAnalyseOutput(kFALSE)\r
+, fMergeTHnSparse(kTRUE)\r
 {\r
   // not implemented\r
 }\r
index 239be8b..54ef12c 100644 (file)
@@ -70,6 +70,12 @@ public:
   AlidNdPtBackgroundCuts* GetBackgroundCuts() const             { return fdNdPtBackgroundCuts; }
   Double_t* CreateLogAxis(Int_t nbins, Double_t xmin, Double_t xmax);
 
+  void SetAnalyseOutput(Bool_t analyseoutput)  { fAnalyseOutput = analyseoutput; }
+  Bool_t GetAnalyseOutput() const { return fAnalyseOutput; }
+
+  void SetMergeTHnSparse(Bool_t mergethnsparse)  { fMergeTHnSparse = mergethnsparse; }
+  Bool_t GetMergeTHnSparse() const { return fMergeTHnSparse; }
+
 protected:
    static Double_t* CloneArray(Int_t n, Double_t* source);
 
@@ -91,8 +97,11 @@ private:
 
   AliPhysicsSelection* fPhysicsSelection; // physics trigger selection class
   AlidNdPtBackgroundCuts *fdNdPtBackgroundCuts; // background cuts (cosmics and splitted tracks)
+  
+  Bool_t fAnalyseOutput; // call Analyse() function in the FinishTaskOutput
+  Bool_t fMergeTHnSparse; // merge THnSparse histograms in Merge() function
 
-  ClassDef(AlidNdPt,3);
+  ClassDef(AlidNdPt,4);
 };
 
 #endif
index edd2efa..26ae91c 100644 (file)
 //------------------------------------------------------------------------------\r
 #include "TH1.h"\r
 #include "TH2.h"\r
+#include "TH3.h"\r
+#include "TMatrixD.h"\r
+\r
+#include <TPDGCode.h>\r
 \r
 #include "AliHeader.h"  \r
 #include "AliGenEventHeader.h"  \r
@@ -61,7 +65,8 @@ ClassImp(AlidNdPtCutAnalysisPbPb)
   fMCEventHist(0),\r
   fRecMCEventHist(0),\r
   fRecMCTrackHist(0),\r
-  fCentralityEstimator(0)\r
+  fCentralityEstimator(0),\r
+  fFolderObj(0)\r
 {\r
   // default constructor\r
   Init();\r
@@ -75,7 +80,8 @@ AlidNdPtCutAnalysisPbPb::AlidNdPtCutAnalysisPbPb(Char_t* name, Char_t* title): A
   fMCEventHist(0),\r
   fRecMCEventHist(0),\r
   fRecMCTrackHist(0),\r
-  fCentralityEstimator(0)\r
+  fCentralityEstimator(0),\r
+  fFolderObj(0)\r
 {\r
   // constructor\r
   Init();\r
@@ -91,6 +97,7 @@ AlidNdPtCutAnalysisPbPb::~AlidNdPtCutAnalysisPbPb() {
   if(fRecMCTrackHist) delete fRecMCTrackHist; fRecMCTrackHist=0;\r
 \r
   if(fAnalysisFolder) delete fAnalysisFolder; fAnalysisFolder=0;\r
+  if(fFolderObj) delete fFolderObj; fFolderObj=0;\r
 }\r
 \r
 //_____________________________________________________________________________\r
@@ -107,13 +114,13 @@ void AlidNdPtCutAnalysisPbPb::Init(){
 \r
   // set pt bins\r
   const Int_t ptNbins = 50;\r
-  const Double_t ptMin = 1.e-2, ptMax = 50.;\r
+  const Double_t ptMin = 1.e-2, ptMax = 100.;\r
   Double_t *binsPt = CreateLogAxis(ptNbins,ptMin,ptMax);\r
 \r
   // centrality bins\r
   const Int_t centrNbins = 3;\r
   const Double_t centrMin = 0, centrMax = 1;\r
-  Double_t binsCentr[centrNbins+1] = {0.0, 0.2, 0.5, 1.0};\r
+  Double_t binsCentr[centrNbins+1] = {0.0, 20., 50., 100.};\r
 \r
   // \r
   Int_t binsEventCount[2]={2,2};\r
@@ -129,7 +136,7 @@ void AlidNdPtCutAnalysisPbPb::Init(){
 \r
   Int_t binsRecEventHist[5]={80,80,100,80,150};\r
   Double_t minRecEventHist[5]={-1.*kFact,-1.*kFact,-35.,0.,0.}; \r
-  Double_t maxRecEventHist[5]={1.*kFact,1.*kFact,35.,10.,150.}; \r
+  Double_t maxRecEventHist[5]={1.*kFact,1.*kFact,35.,10.,3000.}; \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
@@ -151,7 +158,7 @@ void AlidNdPtCutAnalysisPbPb::Init(){
   //Xv-mcXv:Yv-mcYv:Zv-mcZv:Mult\r
   Int_t binsRecMCEventHist[4]={100,100,100,150};\r
   Double_t minRecMCEventHist[4]={-1.0*kFact,-1.0*kFact,-1.0*kFact,0.}; \r
-  Double_t maxRecMCEventHist[4]={1.0*kFact,1.0*kFact,1.0*kFact,150.}; \r
+  Double_t maxRecMCEventHist[4]={1.0*kFact,1.0*kFact,1.0*kFact,3000.}; \r
   fRecMCEventHist = new THnSparseF("fRecMCEventHist","Xv-mcXv:Yv-mcYv:Zv-mcZv:Mult",4,binsRecMCEventHist,minRecMCEventHist,maxRecMCEventHist);\r
   fRecMCEventHist->GetAxis(0)->SetTitle("Xv-mcXv (cm)");\r
   fRecMCEventHist->GetAxis(1)->SetTitle("Yv-mcYv (cm)");\r
@@ -164,58 +171,34 @@ void AlidNdPtCutAnalysisPbPb::Init(){
   //\r
   //\r
   //\r
-  //nCrossRows:chi2PerClust:nCrossRows/nFindableClust:fracSharedClust:DCAy:DCAz:eta:phi:pt:hasStrangeMother:isFromMaterial:isPrim:charge:centr\r
-  Int_t binsRecMCTrackHist[14]=  {160, 10, 20, 20, 50,  50,  20,  90,             ptNbins, 2,  2,  2,  3,  centrNbins};\r
-  Double_t minRecMCTrackHist[14]={0.,  0., 0., 0.,-0.5,-0.5,-1.0, 0.,             ptMin,   0., 0., 0.,-1., centrMin};\r
-  Double_t maxRecMCTrackHist[14]={160.,10.,1.,  1., 0.5, 0.5, 1.0, 2.*TMath::Pi(), ptMax,   2., 2., 2., 2., centrMax};\r
+  //nCrossRows:chi2PerClust:chi2PerClustITS:nCrossRows/nFindableClust:fracSharedClust:DCAy:DCAz:eta:phi:pt:hasStrangeMother:isFromConversion:isFromMaterial:isPrim:charge:centr:chi2ToTPCc\r
+  Int_t binsRecMCTrackHist[17]=  {160, 10, 70, 30, 20, 50,  50,  20,  90, ptNbins, 2, 2,  2,  2,  3,               centrNbins,100};\r
+  Double_t minRecMCTrackHist[17]={0.,  0., 0., 0., 0.,-0.5,-2.5,-1.0, 0., ptMin,   0., 0., 0., 0.,-1.,             centrMin,  0.};\r
+  Double_t maxRecMCTrackHist[17]={160.,10.,70.,1.5, 1., 0.5, 2.5, 1.0, 2.*TMath::Pi(), ptMax,  2., 2., 2., 2., 2., centrMax,  100.};\r
 \r
-  fRecMCTrackHist = new THnSparseF("fRecMCTrackHist","nCrossRows:chi2PerClust:nCrossRows/nFindableClust:fracSharedClust:DCAy:DCAz:eta:phi:pt:hasStrangeMother:isFromMaterial:isPrim:charge:centr",14,binsRecMCTrackHist,minRecMCTrackHist,maxRecMCTrackHist);\r
-  fRecMCTrackHist->SetBinEdges(8,binsPt);\r
-  fRecMCTrackHist->SetBinEdges(13,binsCentr);\r
+  fRecMCTrackHist = new THnSparseF("fRecMCTrackHist","nCrossRows:chi2PerClust:chi2PerClustITS:nCrossRows/nFindableClust:fracSharedClust:DCAy:DCAz:eta:phi:pt:hasStrangeMother:isFromConversion:isFromMaterial:isPrim:charge:centr:chi2ToTPCc",17,binsRecMCTrackHist,minRecMCTrackHist,maxRecMCTrackHist);\r
+  fRecMCTrackHist->SetBinEdges(9,binsPt);\r
+  fRecMCTrackHist->SetBinEdges(15,binsCentr);\r
 \r
   fRecMCTrackHist->GetAxis(0)->SetTitle("nCrossRows");\r
   fRecMCTrackHist->GetAxis(1)->SetTitle("chi2PerClust");\r
-  fRecMCTrackHist->GetAxis(2)->SetTitle("nCrossRows/nFindableClust");\r
-  fRecMCTrackHist->GetAxis(3)->SetTitle("fracSharedClust");\r
-  fRecMCTrackHist->GetAxis(4)->SetTitle("DCAy (cm)");\r
-  fRecMCTrackHist->GetAxis(5)->SetTitle("DCAz (cm)");\r
-  fRecMCTrackHist->GetAxis(6)->SetTitle("#eta");\r
-  fRecMCTrackHist->GetAxis(7)->SetTitle("#phi (rad)");\r
-  fRecMCTrackHist->GetAxis(8)->SetTitle("p_{T} (GeV/c)");\r
-  fRecMCTrackHist->GetAxis(9)->SetTitle("hasStrangeMother");\r
-  fRecMCTrackHist->GetAxis(10)->SetTitle("isFromMaterial");\r
-  fRecMCTrackHist->GetAxis(11)->SetTitle("isPrim");\r
-  fRecMCTrackHist->GetAxis(12)->SetTitle("charge");\r
-  fRecMCTrackHist->GetAxis(13)->SetTitle("centrality");\r
+  fRecMCTrackHist->GetAxis(2)->SetTitle("chi2PerClustITS");\r
+  fRecMCTrackHist->GetAxis(3)->SetTitle("nCrossRows/nFindableClust");\r
+  fRecMCTrackHist->GetAxis(4)->SetTitle("fracSharedClust");\r
+  fRecMCTrackHist->GetAxis(5)->SetTitle("DCAy (cm)");\r
+  fRecMCTrackHist->GetAxis(6)->SetTitle("DCAz (cm)");\r
+  fRecMCTrackHist->GetAxis(7)->SetTitle("#eta");\r
+  fRecMCTrackHist->GetAxis(8)->SetTitle("#phi (rad)");\r
+  fRecMCTrackHist->GetAxis(9)->SetTitle("p_{T} (GeV/c)");\r
+  fRecMCTrackHist->GetAxis(10)->SetTitle("hasStrangeMother");\r
+  fRecMCTrackHist->GetAxis(11)->SetTitle("isFromConversion");\r
+  fRecMCTrackHist->GetAxis(12)->SetTitle("isFromMaterial");\r
+  fRecMCTrackHist->GetAxis(13)->SetTitle("isPrim");\r
+  fRecMCTrackHist->GetAxis(14)->SetTitle("charge");\r
+  fRecMCTrackHist->GetAxis(15)->SetTitle("centrality");\r
+  fRecMCTrackHist->GetAxis(16)->SetTitle("chi2ToTPCc");\r
   fRecMCTrackHist->Sumw2();\r
 \r
-\r
-  //nClust:chi2PerClust:nClust/nFindableClust:DCAy:DCAz:eta:phi:pt:hasStrangeMother:isFromMaterial:isPrim:charge:centr\r
-  /*\r
-  Int_t binsRecMCTrackHist[13]={160,20,40,50,50,20,90,ptNbins,2,2,2,3,centrNbins};\r
-  Double_t minRecMCTrackHist[13]={0., 0., 0., -0.5,-0.5,-1.0, 0., ptMin, 0., 0., 0., -1., centrMin};\r
-  Double_t maxRecMCTrackHist[13]={160.,10.,1.2, 0.5,0.5,1.0, 2.*TMath::Pi(), ptMax, 2., 2., 2., 2.,centrMax};\r
-\r
-  fRecMCTrackHist = new THnSparseF("fRecMCTrackHist","nClust:chi2PerClust:nClust/nFindableClust:DCAy:DCAz:eta:phi:pt:hasStrangeMother:isFromMaterial:isPrim:charge",12,binsRecMCTrackHist,minRecMCTrackHist,maxRecMCTrackHist);\r
-  fRecMCTrackHist->SetBinEdges(7,binsPt);\r
-  fRecMCTrackHist->SetBinEdges(12,binsCentr);\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("hasStrangeMother");\r
-  fRecMCTrackHist->GetAxis(9)->SetTitle("isFromMaterial");\r
-  fRecMCTrackHist->GetAxis(10)->SetTitle("isPrim");\r
-  fRecMCTrackHist->GetAxis(11)->SetTitle("charge");\r
-  fRecMCTrackHist->GetAxis(12)->SetTitle("centrality");\r
-  fRecMCTrackHist->Sumw2();\r
-  */\r
-\r
   // init output folder\r
   fAnalysisFolder = CreateFolder("folderdNdPt","Analysis dNdPt Folder");\r
 \r
@@ -352,7 +335,6 @@ void AlidNdPtCutAnalysisPbPb::Process(AliESDEvent *const esdEvent, AliMCEvent *
   Double_t vEventCount[2] = { isEventTriggered, isTrigAndVertex};\r
   fEventCount->Fill(vEventCount);\r
 \r
-\r
   // check event cuts\r
   if(isEventOK && isEventTriggered)\r
   {\r
@@ -367,8 +349,11 @@ void AlidNdPtCutAnalysisPbPb::Process(AliESDEvent *const esdEvent, AliMCEvent *
       if(!track) continue;\r
 \r
       if(!esdTrackCuts->AcceptTrack(track)) continue;\r
-      FillHistograms(track, stack, centralityF);\r
+      if(!accCuts->AcceptTrack(track)) continue;\r
+\r
+      FillHistograms(esdEvent, track, stack, centralityF);\r
       multAll++;\r
+\r
     }\r
 \r
     Double_t vRecEventHist[5] = {vtxESD->GetXv(),vtxESD->GetYv(),vtxESD->GetZv(),vtxESD->GetZRes(),multAll};\r
@@ -385,7 +370,7 @@ void AlidNdPtCutAnalysisPbPb::Process(AliESDEvent *const esdEvent, AliMCEvent *
 }\r
 \r
 //_____________________________________________________________________________\r
-void AlidNdPtCutAnalysisPbPb::FillHistograms(AliESDtrack *const esdTrack, AliStack *const stack, Float_t centralityF) const\r
+void AlidNdPtCutAnalysisPbPb::FillHistograms(AliESDEvent *const esdEvent, AliESDtrack *const esdTrack, AliStack *const stack, Float_t centralityF) const\r
 {\r
   //\r
   // Fill ESD track and MC histograms \r
@@ -411,6 +396,12 @@ void AlidNdPtCutAnalysisPbPb::FillHistograms(AliESDtrack *const esdTrack, AliSta
     chi2PerCluster = esdTrack->GetTPCchi2()/Float_t(nClust);\r
   }\r
 \r
+  Int_t nClustersITS = esdTrack->GetITSclusters(0);\r
+  Float_t chi2PerClusterITS = -1;\r
+  if (nClustersITS!=0) {\r
+      chi2PerClusterITS = esdTrack->GetITSchi2()/Float_t(nClustersITS);\r
+  }\r
+\r
   Float_t clustPerFindClust = 0.;\r
   Int_t nFindableClust = esdTrack->GetTPCNclsF();\r
   if(nFindableClust>0.) clustPerFindClust = Float_t(nClust)/nFindableClust;\r
@@ -444,14 +435,70 @@ void AlidNdPtCutAnalysisPbPb::FillHistograms(AliESDtrack *const esdTrack, AliSta
   //printf("esdTrack->GetKinkIndex(2) %d \n", esdTrack->GetKinkIndex(2));\r
   //printf("kinkIdx %d \n", kinkIdx);\r
 \r
+  Bool_t isOK = kTRUE;\r
+  AliExternalTrackParam * tpcInner = (AliExternalTrackParam *)(esdTrack->GetTPCInnerParam());\r
+  if (!tpcInner) return;\r
+  tpcInner->Rotate(esdTrack->GetAlpha());\r
+  tpcInner->PropagateTo(esdTrack->GetX(),esdEvent->GetMagneticField());\r
+       \r
+  // tpc constrained\r
+  AliExternalTrackParam * tpcInnerC = (AliExternalTrackParam *)(esdTrack->GetTPCInnerParam()->Clone());\r
+  if (!tpcInnerC) return;\r
+  tpcInnerC->Rotate(esdTrack->GetAlpha());\r
+  tpcInnerC->PropagateTo(esdTrack->GetX(),esdEvent->GetMagneticField());\r
+  Double_t dz[2],cov[3];\r
+  AliESDVertex *vtx= (AliESDVertex *)esdEvent->GetPrimaryVertex();\r
+\r
+  if (!tpcInnerC->PropagateToDCA(vtx, esdEvent->GetMagneticField(), 3, dz, cov)) \r
+  { \r
+    if(tpcInnerC) delete tpcInnerC; \r
+    return;\r
+  }\r
+  Double_t covar[6]; vtx->GetCovMatrix(covar);\r
+  Double_t p[2]={tpcInnerC->GetParameter()[0]-dz[0],tpcInnerC->GetParameter()[1]-dz[1]};\r
+  Double_t c[3]={covar[2],0.,covar[5]};\r
+  Double_t chi2C=tpcInnerC->GetPredictedChi2(p,c);\r
+  isOK = tpcInnerC->Update(p,c);\r
+  isOK = tpcInnerC->Rotate(esdTrack->GetAlpha());\r
+  isOK = tpcInnerC->Propagate(esdTrack->GetAlpha(),esdTrack->GetX(),esdEvent->GetMagneticField());\r
+\r
+  if(!isOK || chi2C>kVeryBig) { \r
+     if(tpcInnerC) delete tpcInnerC; \r
+     return;\r
+  }\r
+\r
+  //\r
+  // calculate chi2 between vi and vj vectors\r
+  // with covi and covj covariance matrices\r
+  // chi2ij = (vi-vj)^(T)*(covi+covj)^(-1)*(vi-vj)\r
+  //\r
+  TMatrixD deltaT(5,1);\r
+  TMatrixD delta(1,5);\r
+  TMatrixD covarM(5,5);\r
+\r
+  for (Int_t ipar=0; ipar<5; ipar++) deltaT(ipar,0)=tpcInnerC->GetParameter()[ipar]-esdTrack->GetParameter()[ipar];\r
+  for (Int_t ipar=0; ipar<5; ipar++) delta(0,ipar)=tpcInnerC->GetParameter()[ipar]-esdTrack->GetParameter()[ipar];\r
+\r
+  for (Int_t ipar=0; ipar<5; ipar++) {\r
+  for (Int_t jpar=0; jpar<5; jpar++) {\r
+  Int_t index=esdTrack->GetIndex(ipar,jpar);\r
+    covarM(ipar,jpar)=esdTrack->GetCovariance()[index]+tpcInnerC->GetCovariance()[index];\r
+  }\r
+  }\r
+  TMatrixD covarMInv = covarM.Invert();\r
+  TMatrixD mat2 = covarMInv*deltaT;\r
+  TMatrixD chi2 = delta*mat2; \r
+\r
   //\r
   // Fill rec vs MC information\r
   //\r
   Bool_t isPrim = kTRUE;\r
   Bool_t hasStrangeMother = kFALSE;\r
   Bool_t isFromMaterial = kFALSE;\r
+  Bool_t isFromConversion = kFALSE;\r
 \r
-  if(IsUseMCInfo()) {\r
+  if(IsUseMCInfo()) \r
+  {\r
     if(!stack) return;\r
     Int_t label = TMath::Abs(esdTrack->GetLabel()); \r
     TParticle* particle = stack->Particle(label);\r
@@ -469,22 +516,28 @@ void AlidNdPtCutAnalysisPbPb::FillHistograms(AliESDtrack *const esdTrack, AliSta
     if(mother) motherPdg = TMath::Abs(mother->GetPdgCode()); // take abs for visualisation only \r
     Int_t mech = particle->GetUniqueID(); // production mechanism \r
 \r
-    if( (motherPdg == 3122) || (motherPdg == -3122) || (motherPdg == 310)) // lambda, antilambda, k0s\r
-    {\r
-      if( (mech == 4) || (mech == 5) ) hasStrangeMother = kTRUE;\r
-    } \r
-    else {\r
-      //if(isPrim==0 && mech == 13)   \r
-      //printf("mech %d \n", mech);\r
-      if(!isPrim) isFromMaterial = kTRUE; \r
-    }\r
+     // K+-, lambda, antilambda, K0s decays\r
+     if(!isPrim && mech==4 && \r
+       (TMath::Abs(motherPdg)==kKPlus || TMath::Abs(motherPdg)==kLambda0 || motherPdg==kK0Short))\r
+     {\r
+       hasStrangeMother = kTRUE;\r
+     } \r
+\r
+     if(!isPrim && mech==5 && motherPdg==kGamma) { \r
+       isFromConversion=kTRUE; \r
+     }\r
+\r
+     if(!isPrim && mech==13) { \r
+       isFromMaterial=kTRUE; \r
+     }\r
   }\r
   \r
   // fill histo\r
   Int_t charge = esdTrack->Charge();\r
-  //Double_t vRecMCTrackHist[13] = { nClust,chi2PerCluster,clustPerFindClust,b[0],b[1],eta,phi,pt,hasStrangeMother,isFromMaterial,isPrim,charge, centralityF }; \r
-  Double_t vRecMCTrackHist[14] = { nCrossedRowsTPC, chi2PerCluster, ratioCrossedRowsOverFindableClustersTPC, fracClustersTPCShared , b[0], b[1], eta, phi, pt, hasStrangeMother, isFromMaterial, isPrim, charge, centralityF }; \r
+  Double_t vRecMCTrackHist[17] = { nCrossedRowsTPC, chi2PerCluster, chi2PerClusterITS,ratioCrossedRowsOverFindableClustersTPC, fracClustersTPCShared, b[0], b[1], eta, phi, pt, hasStrangeMother, isFromConversion, isFromMaterial, isPrim, charge, centralityF, chi2(0,0) }; \r
   fRecMCTrackHist->Fill(vRecMCTrackHist);\r
+\r
+  if(tpcInnerC) delete tpcInnerC;\r
 }\r
 \r
 //_____________________________________________________________________________\r
@@ -500,6 +553,8 @@ Long64_t AlidNdPtCutAnalysisPbPb::Merge(TCollection* const list)
 \r
   TIterator* iter = list->MakeIterator();\r
   TObject* obj = 0;\r
+  TObjArray* objArrayList = 0;\r
+  objArrayList = new TObjArray();\r
 \r
   //TList *collPhysSelection = new TList;\r
 \r
@@ -510,24 +565,39 @@ Long64_t AlidNdPtCutAnalysisPbPb::Merge(TCollection* const list)
     if (entry == 0) continue; \r
   \r
     // event histo\r
-    fEventCount->Add(entry->fEventCount);\r
-    fRecEventHist->Add(entry->fRecEventHist);\r
-    fRecMCEventHist->Add(entry->fRecMCEventHist);\r
-    fMCEventHist->Add(entry->fMCEventHist);\r
+    if(GetMergeTHnSparse()) \r
+    {\r
+      fEventCount->Add(entry->fEventCount);\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
+      // track histo\r
+      fRecMCTrackHist->Add(entry->fRecMCTrackHist);\r
+    }\r
 \r
-    // physics selection\r
-    //collPhysSelection->Add(entry->GetPhysicsTriggerSelection());\r
+    if (entry->fFolderObj) { objArrayList->Add(entry->fFolderObj); }\r
     \r
   count++;\r
   }\r
+  if (fFolderObj) { fFolderObj->Merge(objArrayList); } \r
+\r
+  // to signal that track histos were not merged: reset\r
+  if (!GetMergeTHnSparse()) \r
+  { \r
+    // reset content \r
+    // save memory\r
+    fEventCount->Reset();\r
+    fRecEventHist->Reset();\r
+    fRecMCEventHist->Reset();\r
+    fMCEventHist->Reset();\r
 \r
-  //AliPhysicsSelection *trigSelection = GetPhysicsTriggerSelection();\r
-  //trigSelection->Merge(collPhysSelection);\r
+    // track histo\r
+    fRecMCTrackHist->Reset();\r
+  }\r
 \r
-  //if(collPhysSelection) delete collPhysSelection;\r
+  // delete\r
+  if (objArrayList) delete objArrayList;  objArrayList=0;\r
 \r
 return count;\r
 }\r
@@ -544,41 +614,29 @@ void AlidNdPtCutAnalysisPbPb::Analyse()
 \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("AlidNdPtCutAnalysisPbPb::Analyse()", "cuts not available");\r
-    return;\r
-  }\r
-\r
+  TH3D *h3D = 0; \r
+  \r
   //\r
-  // set min and max values\r
+  // make event level projection\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
-  Double_t maxDCAr = accCuts->GetMaxDCAr();\r
+  //THnSparseF *fEventCount; //-> trig, trig + vertex\r
+  //THnSparseF *fRecEventHist;   //-> Xv:Yv:Zv:ResZv:Mult\r
+  //THnSparseF *fMCEventHist;    //-> mcXv:mcYv:mcZv\r
+  //THnSparseF *fRecMCEventHist; //-> Xv-mcXv:Yv-mcYv:Zv-mcZv:Mult\r
 \r
   //\r
   // Event counters\r
   //\r
   h2D = (TH2D*)fEventCount->Projection(0,1);\r
   h2D->SetName("trig_vs_trigANDvertex");\r
+  h2D->SetTitle("trig_vs_trigANDvertex");\r
   aFolderObj->Add(h2D);\r
 \r
   fEventCount->GetAxis(0)->SetRange(2,2); // triggered\r
   h1D = (TH1D*)fEventCount->Projection(1);\r
   h1D->SetTitle("rec. vertex for triggered events");\r
   h1D->SetName("trigANDvertex");\r
+  h1D->SetTitle("trigANDvertex");\r
   aFolderObj->Add(h1D);\r
 \r
   //\r
@@ -586,30 +644,37 @@ void AlidNdPtCutAnalysisPbPb::Analyse()
   //\r
   h1D = (TH1D *)fRecEventHist->Projection(0);\r
   h1D->SetName("rec_xv");\r
+  h1D->SetTitle("rec_xv");\r
   aFolderObj->Add(h1D);\r
 \r
   h1D = (TH1D *)fRecEventHist->Projection(1);\r
   h1D->SetName("rec_yv");\r
+  h1D->SetTitle("rec_yv");\r
   aFolderObj->Add(h1D);\r
 \r
   h1D = (TH1D *)fRecEventHist->Projection(2);\r
   h1D->SetName("rec_zv");\r
+  h1D->SetTitle("rec_zv");\r
   aFolderObj->Add(h1D);\r
 \r
-  h2D = (TH2D *)fRecEventHist->Projection(3,4);\r
-  h2D->SetName("rec_resZv_vs_Mult");\r
-  aFolderObj->Add(h2D);\r
-\r
   h2D = (TH2D *)fRecEventHist->Projection(0,1);\r
   h2D->SetName("rec_xv_vs_yv");\r
+  h2D->SetTitle("rec_xv_vs_yv");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fRecEventHist->Projection(1,2);\r
+  h2D->SetName("rec_yv_vs_zv");\r
+  h2D->SetTitle("rec_yv_vs_zv");\r
   aFolderObj->Add(h2D);\r
 \r
   h2D = (TH2D *)fRecEventHist->Projection(0,2);\r
   h2D->SetName("rec_xv_vs_zv");\r
+  h2D->SetTitle("rec_xv_vs_zv");\r
   aFolderObj->Add(h2D);\r
 \r
   h2D = (TH2D *)fRecEventHist->Projection(3,4);\r
   h2D->SetName("rec_resZv_vs_Mult");\r
+  h2D->SetTitle("rec_resZv_vs_Mult");\r
   aFolderObj->Add(h2D);\r
 \r
   //\r
@@ -620,12 +685,36 @@ void AlidNdPtCutAnalysisPbPb::Analyse()
   //\r
   // Create mc event histograms\r
   //\r
+\r
+  h1D = (TH1D *)fMCEventHist->Projection(0);\r
+  h1D->SetName("mc_xv");\r
+  h1D->SetTitle("mc_xv");\r
+  aFolderObj->Add(h1D);\r
+\r
+  h1D = (TH1D *)fMCEventHist->Projection(1);\r
+  h1D->SetName("mc_yv");\r
+  h1D->SetTitle("mc_yv");\r
+  aFolderObj->Add(h1D);\r
+\r
+  h1D = (TH1D *)fMCEventHist->Projection(2);\r
+  h1D->SetName("mc_zv");\r
+  h1D->SetTitle("mc_zv");\r
+  aFolderObj->Add(h1D);\r
+\r
+\r
   h2D = (TH2D *)fMCEventHist->Projection(0,1);\r
   h2D->SetName("mc_xv_vs_yv");\r
+  h2D->SetTitle("mc_xv_vs_yv");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fMCEventHist->Projection(1,2);\r
+  h2D->SetName("mc_yv_vs_zv");\r
+  h2D->SetTitle("mc_yv_vs_zv");\r
   aFolderObj->Add(h2D);\r
 \r
   h2D = (TH2D *)fMCEventHist->Projection(0,2);\r
   h2D->SetName("mc_xv_vs_zv");\r
+  h2D->SetTitle("mc_xv_vs_zv");\r
   aFolderObj->Add(h2D);\r
 \r
   //\r
@@ -633,138 +722,616 @@ void AlidNdPtCutAnalysisPbPb::Analyse()
   //\r
   h2D = (TH2D *)fRecMCEventHist->Projection(0,3);\r
   h2D->SetName("rec_mc_deltaXv_vs_mult");\r
+  h2D->SetTitle("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
+  h2D->SetTitle("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
+  h2D->SetTitle("rec_mc_deltaZv_vs_mult");\r
   aFolderObj->Add(h2D);\r
 \r
   } // end use MC info \r
 \r
+  //\r
+  // make track level projection\r
+  //\r
+  // THnSparse track histograms\r
+  // nCrossRows:chi2PerClust:chi2PerClustITS:nCrossRows/nFindableClust:fracSharedClust:DCAy:DCAz:eta:phi:pt:hasStrangeMother:isFromConversion:isFromMaterial:isPrim:charge:centr:chi2ToTPCc\r
+  //\r
+\r
+  // only TH3 histograms\r
+  // x : pT : centr\r
+  Double_t minNCrossRows = 120.;\r
+  Double_t maxChi2PerClust = 4.;\r
+  Double_t maxChi2PerClustITS = 36.;\r
+  Double_t minNCrossRowsOverFindable = 0.8;\r
+  Double_t maxFracSharedClust = 0.4;\r
+  Double_t minDCAr = -0.2, maxDCAr = 0.2;\r
+  Double_t minDCAz = -2., maxDCAz = 2.;\r
+  Double_t minEta = -0.8, maxEta = 0.8;\r
+  Double_t maxChi2ToTPCc = 50;\r
+\r
+  // only TH3 histograms\r
+  // x : pT : centr\r
+\r
+  // set all cuts\r
+  fRecMCTrackHist->GetAxis(0)->SetRangeUser(minNCrossRows,160);\r
+  fRecMCTrackHist->GetAxis(1)->SetRangeUser(0.,maxChi2PerClust-0.0001);\r
+  fRecMCTrackHist->GetAxis(2)->SetRangeUser(0.,maxChi2PerClustITS-0.0001);\r
+  fRecMCTrackHist->GetAxis(3)->SetRangeUser(minNCrossRowsOverFindable,1.4999);\r
+  fRecMCTrackHist->GetAxis(4)->SetRangeUser(0.,maxFracSharedClust-0.0001);\r
+  fRecMCTrackHist->GetAxis(5)->SetRangeUser(minDCAr,maxDCAr-0.0001);\r
+  fRecMCTrackHist->GetAxis(6)->SetRangeUser(minDCAz,maxDCAz-0.0001);\r
+  fRecMCTrackHist->GetAxis(7)->SetRangeUser(minEta,maxEta-0.0001);\r
+  fRecMCTrackHist->GetAxis(16)->SetRangeUser(0.,maxChi2ToTPCc-0.0001);\r
+\r
+  // nCrossRows \r
+  fRecMCTrackHist->GetAxis(0)->SetRangeUser(0,160);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(0,9,15);\r
+  h3D->SetName("rec_nCrossRows_pT_centr");\r
+  h3D->SetTitle("rec_nCrossRows_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+\r
+  // Chi2PerClust \r
+  fRecMCTrackHist->GetAxis(0)->SetRangeUser(minNCrossRows,160);\r
+  fRecMCTrackHist->GetAxis(1)->SetRangeUser(0.,10);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(1,9,15);\r
+  h3D->SetName("rec_Chi2PerClust_pT_centr");\r
+  h3D->SetTitle("rec_Chi2PerClust_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+\r
+  // Chi2PerClustITS \r
+  fRecMCTrackHist->GetAxis(1)->SetRangeUser(0.,maxChi2PerClust-0.0001);\r
+  fRecMCTrackHist->GetAxis(2)->SetRangeUser(0.,100);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(2,9,15);\r
+  h3D->SetName("rec_Chi2PerClustITS_pT_centr");\r
+  h3D->SetTitle("rec_Chi2PerClustITS_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+\r
+  // NCrossRowsOverFindable \r
+  fRecMCTrackHist->GetAxis(2)->SetRangeUser(0.,maxChi2PerClustITS-0.0001);\r
+  fRecMCTrackHist->GetAxis(3)->SetRangeUser(0,1.4999);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(3,9,15);\r
+  h3D->SetName("rec_NCrossRowsOverFindable_pT_centr");\r
+  h3D->SetTitle("rec_NCrossRowsOverFindable_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
 \r
+  // FracSharedClust\r
+  fRecMCTrackHist->GetAxis(3)->SetRangeUser(minNCrossRowsOverFindable,1.4999);\r
+  fRecMCTrackHist->GetAxis(4)->SetRangeUser(0.,0.9999);\r
 \r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(4,9,15);\r
+  h3D->SetName("rec_FracSharedClust_pT_centr");\r
+  h3D->SetTitle("rec_FracSharedClust_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+\r
+  // DCAr\r
+  fRecMCTrackHist->GetAxis(4)->SetRangeUser(0.,maxFracSharedClust-0.0001);\r
+  fRecMCTrackHist->GetAxis(5)->SetRangeUser(-10.,9.9999);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(5,9,15);\r
+  h3D->SetName("rec_DCAr_pT_centr");\r
+  h3D->SetTitle("rec_DCAr_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+  // DCAz\r
+  fRecMCTrackHist->GetAxis(5)->SetRangeUser(minDCAr,maxDCAr-0.0001);\r
+  fRecMCTrackHist->GetAxis(6)->SetRangeUser(-10.,9.9999);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(6,9,15);\r
+  h3D->SetName("rec_DCAz_pT_centr");\r
+  h3D->SetTitle("rec_DCAz_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+  // chi2ToTPCc\r
+  fRecMCTrackHist->GetAxis(6)->SetRangeUser(minDCAz,maxDCAz-0.0001);\r
+  fRecMCTrackHist->GetAxis(16)->SetRangeUser(0,100);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(16,9,15);\r
+  h3D->SetName("rec_chi2ToTPCc_pT_centr");\r
+  h3D->SetTitle("rec_chi2ToTPCc_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+\r
+  //\r
+  // MC available\r
+  //\r
+  // nCrossRows:chi2PerClust:chi2PerClustITS:nCrossRows/nFindableClust:fracSharedClust:DCAy:DCAz:eta:phi:pt:hasStrangeMother:isFromConversion:isFromMaterial:isPrim:charge:centr:chi2ToTPCc\r
+  //\r
+\r
+  if(IsUseMCInfo()) {\r
+  //\r
+  // only TH3 histograms \r
+  // x : pT : centr\r
   //\r
-  // Create rec-mc track track histograms \r
+  // comes from week decays\r
   //\r
+  fRecMCTrackHist->GetAxis(10)->SetRange(2,2);\r
 \r
-  // DCA cuts\r
-  fRecMCTrackHist->GetAxis(3)->SetRangeUser(-maxDCAr,maxDCAr);\r
-  fRecMCTrackHist->GetAxis(4)->SetRangeUser(-maxDCAr,maxDCAr);\r
+  // set all cuts\r
+  fRecMCTrackHist->GetAxis(0)->SetRangeUser(minNCrossRows,160);\r
+  fRecMCTrackHist->GetAxis(1)->SetRangeUser(0.,maxChi2PerClust-0.0001);\r
+  fRecMCTrackHist->GetAxis(2)->SetRangeUser(0.,maxChi2PerClustITS-0.0001);\r
+  fRecMCTrackHist->GetAxis(3)->SetRangeUser(minNCrossRowsOverFindable,1.4999);\r
+  fRecMCTrackHist->GetAxis(4)->SetRangeUser(0.,maxFracSharedClust-0.0001);\r
+  fRecMCTrackHist->GetAxis(5)->SetRangeUser(minDCAr,maxDCAr-0.0001);\r
+  fRecMCTrackHist->GetAxis(6)->SetRangeUser(minDCAz,maxDCAz-0.0001);\r
+  fRecMCTrackHist->GetAxis(7)->SetRangeUser(minEta,maxEta-0.0001);\r
+  fRecMCTrackHist->GetAxis(16)->SetRangeUser(0.,maxChi2ToTPCc-0.0001);\r
 \r
-  h2D = (TH2D *)fRecMCTrackHist->Projection(7,5);\r
-  h2D->SetName("pt_vs_eta");\r
-  aFolderObj->Add(h2D);\r
+  // nCrossRows \r
+  fRecMCTrackHist->GetAxis(0)->SetRangeUser(0,160);\r
 \r
-  fRecMCTrackHist->GetAxis(7)->SetRangeUser(minPt,maxPt);  \r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(0,9,15);\r
+  h3D->SetName("rec_sec_strange_nCrossRows_pT_centr");\r
+  h3D->SetTitle("rec_sec_strange_nCrossRows_pT_centr");\r
+  aFolderObj->Add(h3D);\r
 \r
-  h2D = (TH2D *)fRecMCTrackHist->Projection(0,5);\r
-  h2D->SetName("nClust_vs_eta");\r
-  aFolderObj->Add(h2D);\r
+  // Chi2PerClust \r
+  fRecMCTrackHist->GetAxis(0)->SetRangeUser(minNCrossRows,160);\r
+  fRecMCTrackHist->GetAxis(1)->SetRangeUser(0.,10);\r
 \r
-  h2D = (TH2D *)fRecMCTrackHist->Projection(1,5);\r
-  h2D->SetName("chi2PerClust_vs_eta");\r
-  aFolderObj->Add(h2D);\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(1,9,15);\r
+  h3D->SetName("rec_sec_strange_Chi2PerClust_pT_centr");\r
+  h3D->SetTitle("rec_sec_strange_Chi2PerClust_pT_centr");\r
+  aFolderObj->Add(h3D);\r
 \r
-  h2D = (TH2D *)fRecMCTrackHist->Projection(2,5);\r
-  h2D->SetName("ratio_nClust_nFindableClust_vs_eta");\r
-  aFolderObj->Add(h2D);\r
+  // Chi2PerClustITS \r
+  fRecMCTrackHist->GetAxis(1)->SetRangeUser(0.,maxChi2PerClust-0.0001);\r
+  fRecMCTrackHist->GetAxis(2)->SetRangeUser(0.,100);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(2,9,15);\r
+  h3D->SetName("rec_sec_strange_Chi2PerClustITS_pT_centr");\r
+  h3D->SetTitle("rec_sec_strange_Chi2PerClustITS_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+\r
+  // NCrossRowsOverFindable \r
+  fRecMCTrackHist->GetAxis(2)->SetRangeUser(0.,maxChi2PerClustITS-0.0001);\r
+  fRecMCTrackHist->GetAxis(3)->SetRangeUser(0,1.4999);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(3,9,15);\r
+  h3D->SetName("rec_sec_strange_NCrossRowsOverFindable_pT_centr");\r
+  h3D->SetTitle("rec_sec_strange_NCrossRowsOverFindable_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+\r
+  // FracSharedClust\r
+  fRecMCTrackHist->GetAxis(3)->SetRangeUser(minNCrossRowsOverFindable,1.4999);\r
+  fRecMCTrackHist->GetAxis(4)->SetRangeUser(0.,0.9999);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(4,9,15);\r
+  h3D->SetName("rec_sec_strange_FracSharedClust_pT_centr");\r
+  h3D->SetTitle("rec_sec_strange_FracSharedClust_pT_centr");\r
+  aFolderObj->Add(h3D);\r
 \r
-  h2D = (TH2D *)fRecMCTrackHist->Projection(5,6);\r
-  h2D->SetName("eta_vs_phi");\r
-  aFolderObj->Add(h2D);\r
 \r
+  // DCAr\r
+  fRecMCTrackHist->GetAxis(4)->SetRangeUser(0.,maxFracSharedClust-0.0001);\r
+  fRecMCTrackHist->GetAxis(5)->SetRangeUser(-10.,9.9999);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(5,9,15);\r
+  h3D->SetName("rec_sec_strange_DCAr_pT_centr");\r
+  h3D->SetTitle("rec_sec_strange_DCAr_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+\r
+  // DCAz\r
+  fRecMCTrackHist->GetAxis(5)->SetRangeUser(minDCAr,maxDCAr-0.0001);\r
+  fRecMCTrackHist->GetAxis(6)->SetRangeUser(-10.,9.9999);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(6,9,15);\r
+  h3D->SetName("rec_sec_strange_DCAz_pT_centr");\r
+  h3D->SetTitle("rec_sec_strange_DCAz_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+  // chi2ToTPCc\r
+  fRecMCTrackHist->GetAxis(6)->SetRangeUser(minDCAz,maxDCAz-0.0001);\r
+  fRecMCTrackHist->GetAxis(16)->SetRangeUser(0,100);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(16,9,15);\r
+  h3D->SetName("rec_sec_strange_chi2ToTPCc_pT_centr");\r
+  h3D->SetTitle("rec_sec_strange_chi2ToTPCc_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+\r
+  // only TH3 histograms \r
+  // x : pT : centr\r
   //\r
-  fRecMCTrackHist->GetAxis(5)->SetRangeUser(minEta,maxEta);  \r
 \r
-  h2D = (TH2D *)fRecMCTrackHist->Projection(0,6);\r
-  h2D->SetName("nClust_vs_phi");\r
-  aFolderObj->Add(h2D);\r
+  // comes from conversion\r
+  //\r
+  fRecMCTrackHist->GetAxis(10)->SetRange(1,2);\r
+  fRecMCTrackHist->GetAxis(11)->SetRange(2,2);\r
 \r
-  h2D = (TH2D *)fRecMCTrackHist->Projection(1,6);\r
-  h2D->SetName("chi2PerClust_vs_phi");\r
-  aFolderObj->Add(h2D);\r
+  // set all cuts\r
+  fRecMCTrackHist->GetAxis(0)->SetRangeUser(minNCrossRows,160);\r
+  fRecMCTrackHist->GetAxis(1)->SetRangeUser(0.,maxChi2PerClust-0.0001);\r
+  fRecMCTrackHist->GetAxis(2)->SetRangeUser(0.,maxChi2PerClustITS-0.0001);\r
+  fRecMCTrackHist->GetAxis(3)->SetRangeUser(minNCrossRowsOverFindable,1.4999);\r
+  fRecMCTrackHist->GetAxis(4)->SetRangeUser(0.,maxFracSharedClust-0.0001);\r
+  fRecMCTrackHist->GetAxis(5)->SetRangeUser(minDCAr,maxDCAr-0.0001);\r
+  fRecMCTrackHist->GetAxis(6)->SetRangeUser(minDCAz,maxDCAz-0.0001);\r
+  fRecMCTrackHist->GetAxis(7)->SetRangeUser(minEta,maxEta-0.0001);\r
+  fRecMCTrackHist->GetAxis(16)->SetRangeUser(0.,maxChi2ToTPCc-0.0001);\r
 \r
-  h2D = (TH2D *)fRecMCTrackHist->Projection(2,6);\r
-  h2D->SetName("ratio_nClust_nFindableClust_vs_phi");\r
-  aFolderObj->Add(h2D);\r
+  // nCrossRows \r
+  fRecMCTrackHist->GetAxis(0)->SetRangeUser(0,160);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(0,9,15);\r
+  h3D->SetName("rec_sec_conversion_nCrossRows_pT_centr");\r
+  h3D->SetTitle("rec_sec_conversion_nCrossRows_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+  // Chi2PerClust \r
+  fRecMCTrackHist->GetAxis(0)->SetRangeUser(minNCrossRows,160);\r
+  fRecMCTrackHist->GetAxis(1)->SetRangeUser(0.,10);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(1,9,15);\r
+  h3D->SetName("rec_sec_conversion_Chi2PerClust_pT_centr");\r
+  h3D->SetTitle("rec_sec_conversion_Chi2PerClust_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+  // Chi2PerClustITS \r
+  fRecMCTrackHist->GetAxis(1)->SetRangeUser(0.,maxChi2PerClust-0.0001);\r
+  fRecMCTrackHist->GetAxis(2)->SetRangeUser(0.,100);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(2,9,15);\r
+  h3D->SetName("rec_sec_conversion_Chi2PerClustITS_pT_centr");\r
+  h3D->SetTitle("rec_sec_conversion_Chi2PerClustITS_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+\r
+  // NCrossRowsOverFindable \r
+  fRecMCTrackHist->GetAxis(2)->SetRangeUser(0.,maxChi2PerClustITS-0.0001);\r
+  fRecMCTrackHist->GetAxis(3)->SetRangeUser(0,1.4999);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(3,9,15);\r
+  h3D->SetName("rec_sec_conversion_NCrossRowsOverFindable_pT_centr");\r
+  h3D->SetTitle("rec_sec_conversion_NCrossRowsOverFindable_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+\r
+  // FracSharedClust\r
+  fRecMCTrackHist->GetAxis(3)->SetRangeUser(minNCrossRowsOverFindable,1.4999);\r
+  fRecMCTrackHist->GetAxis(4)->SetRangeUser(0.,0.9999);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(4,9,15);\r
+  h3D->SetName("rec_sec_conversion_FracSharedClust_pT_centr");\r
+  h3D->SetTitle("rec_sec_conversion_FracSharedClust_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+\r
+  // DCAr\r
+  fRecMCTrackHist->GetAxis(4)->SetRangeUser(0.,maxFracSharedClust-0.0001);\r
+  fRecMCTrackHist->GetAxis(5)->SetRangeUser(-10.,9.9999);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(5,9,15);\r
+  h3D->SetName("rec_sec_conversion_DCAr_pT_centr");\r
+  h3D->SetTitle("rec_sec_conversion_DCAr_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+\r
+  // DCAz\r
+  fRecMCTrackHist->GetAxis(5)->SetRangeUser(minDCAr,maxDCAr-0.0001);\r
+  fRecMCTrackHist->GetAxis(6)->SetRangeUser(-10.,9.9999);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(6,9,15);\r
+  h3D->SetName("rec_sec_conversion_DCAz_pT_centr");\r
+  h3D->SetTitle("rec_sec_conversion_DCAz_pT_centr");\r
+  aFolderObj->Add(h3D);\r
 \r
+  // chi2ToTPCc\r
+  fRecMCTrackHist->GetAxis(6)->SetRangeUser(minDCAz,maxDCAz-0.0001);\r
+  fRecMCTrackHist->GetAxis(16)->SetRangeUser(0,100);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(16,9,15);\r
+  h3D->SetName("rec_sec_conversion_chi2ToTPCc_pT_centr");\r
+  h3D->SetTitle("rec_sec_conversion_chi2ToTPCc_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+\r
+\r
+\r
+\r
+  // comes from interaction with material\r
   //\r
-  fRecMCTrackHist->GetAxis(7)->SetRangeUser(0.0,maxPt);  \r
+  fRecMCTrackHist->GetAxis(11)->SetRange(1,2);\r
+  fRecMCTrackHist->GetAxis(12)->SetRange(2,2);\r
 \r
-  h2D = (TH2D *)fRecMCTrackHist->Projection(0,7);\r
-  h2D->SetName("nClust_vs_pt");\r
-  aFolderObj->Add(h2D);\r
+  // set all cuts\r
+  fRecMCTrackHist->GetAxis(0)->SetRangeUser(minNCrossRows,160);\r
+  fRecMCTrackHist->GetAxis(1)->SetRangeUser(0.,maxChi2PerClust-0.0001);\r
+  fRecMCTrackHist->GetAxis(2)->SetRangeUser(0.,maxChi2PerClustITS-0.0001);\r
+  fRecMCTrackHist->GetAxis(3)->SetRangeUser(minNCrossRowsOverFindable,1.4999);\r
+  fRecMCTrackHist->GetAxis(4)->SetRangeUser(0.,maxFracSharedClust-0.0001);\r
+  fRecMCTrackHist->GetAxis(5)->SetRangeUser(minDCAr,maxDCAr-0.0001);\r
+  fRecMCTrackHist->GetAxis(6)->SetRangeUser(minDCAz,maxDCAz-0.0001);\r
+  fRecMCTrackHist->GetAxis(7)->SetRangeUser(minEta,maxEta-0.0001);\r
+  fRecMCTrackHist->GetAxis(16)->SetRangeUser(0.,maxChi2ToTPCc-0.0001);\r
 \r
-  h2D = (TH2D *)fRecMCTrackHist->Projection(1,7);\r
-  h2D->SetName("chi2PerClust_vs_pt");\r
-  aFolderObj->Add(h2D);\r
+  // nCrossRows \r
+  fRecMCTrackHist->GetAxis(0)->SetRangeUser(0,160);\r
 \r
-  h2D = (TH2D *)fRecMCTrackHist->Projection(2,7);\r
-  h2D->SetName("ratio_nClust_nFindableClust_vs_pt");\r
-  aFolderObj->Add(h2D);\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(0,9,15);\r
+  h3D->SetName("rec_sec_material_nCrossRows_pT_centr");\r
+  h3D->SetTitle("rec_sec_material_nCrossRows_pT_centr");\r
+  aFolderObj->Add(h3D);\r
 \r
-  h2D = (TH2D *)fRecMCTrackHist->Projection(6,7);\r
-  h2D->SetName("phi_vs_pt");\r
-  aFolderObj->Add(h2D);\r
+  // Chi2PerClust \r
+  fRecMCTrackHist->GetAxis(0)->SetRangeUser(minNCrossRows,160);\r
+  fRecMCTrackHist->GetAxis(1)->SetRangeUser(0.,10);\r
 \r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(1,9,15);\r
+  h3D->SetName("rec_sec_material_Chi2PerClust_pT_centr");\r
+  h3D->SetTitle("rec_sec_material_Chi2PerClust_pT_centr");\r
+  aFolderObj->Add(h3D);\r
 \r
-  // fiducial volume\r
-  fRecMCTrackHist->GetAxis(5)->SetRangeUser(minEta,maxEta);  \r
-  fRecMCTrackHist->GetAxis(7)->SetRangeUser(minPt,maxPt);  \r
+  // Chi2PerClustITS \r
+  fRecMCTrackHist->GetAxis(1)->SetRangeUser(0.,maxChi2PerClust-0.0001);\r
+  fRecMCTrackHist->GetAxis(2)->SetRangeUser(0.,100);\r
 \r
-  // DCA cuts\r
-  fRecMCTrackHist->GetAxis(3)->SetRangeUser(-maxDCAr,maxDCAr);\r
-  fRecMCTrackHist->GetAxis(4)->SetRangeUser(-maxDCAr,maxDCAr);\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(2,9,15);\r
+  h3D->SetName("rec_sec_material_Chi2PerClustITS_pT_centr");\r
+  h3D->SetTitle("rec_sec_material_Chi2PerClustITS_pT_centr");\r
+  aFolderObj->Add(h3D);\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
+  // NCrossRowsOverFindable \r
+  fRecMCTrackHist->GetAxis(2)->SetRangeUser(0.,maxChi2PerClustITS-0.0001);\r
+  fRecMCTrackHist->GetAxis(3)->SetRangeUser(0,1.4999);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(3,9,15);\r
+  h3D->SetName("rec_sec_material_NCrossRowsOverFindable_pT_centr");\r
+  h3D->SetTitle("rec_sec_material_NCrossRowsOverFindable_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
 \r
+  // FracSharedClust\r
+  fRecMCTrackHist->GetAxis(3)->SetRangeUser(minNCrossRowsOverFindable,1.4999);\r
+  fRecMCTrackHist->GetAxis(4)->SetRangeUser(0.,0.9999);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(4,9,15);\r
+  h3D->SetName("rec_sec_material_FracSharedClust_pT_centr");\r
+  h3D->SetTitle("rec_sec_material_FracSharedClust_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+\r
+  // DCAr\r
+  fRecMCTrackHist->GetAxis(4)->SetRangeUser(0.,maxFracSharedClust-0.0001);\r
+  fRecMCTrackHist->GetAxis(5)->SetRangeUser(-10.,9.9999);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(5,9,15);\r
+  h3D->SetName("rec_sec_material_DCAr_pT_centr");\r
+  h3D->SetTitle("rec_sec_material_DCAr_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+\r
+  // DCAz\r
+  fRecMCTrackHist->GetAxis(5)->SetRangeUser(minDCAr,maxDCAr-0.0001);\r
+  fRecMCTrackHist->GetAxis(6)->SetRangeUser(-10.,9.9999);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(6,9,15);\r
+  h3D->SetName("rec_sec_material_DCAz_pT_centr");\r
+  h3D->SetTitle("rec_sec_material_DCAz_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+  // chi2ToTPCc\r
+  fRecMCTrackHist->GetAxis(6)->SetRangeUser(minDCAz,maxDCAz-0.0001);\r
+  fRecMCTrackHist->GetAxis(16)->SetRangeUser(0,100);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(16,9,15);\r
+  h3D->SetName("rec_sec_material_chi2ToTPCc_pT_centr");\r
+  h3D->SetTitle("rec_sec_material_chi2ToTPCc_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+\r
+\r
+  //\r
+  // only TH3 histograms \r
+  // x : pT : centr\r
   //\r
-  // DCAy cuts\r
+  // secondaries defined as AliStack::IsPhysicalPrimary()\r
   //\r
-  fRecMCTrackHist->GetAxis(0)->SetRange(50,160); // nClust/track > 50\r
-  fRecMCTrackHist->GetAxis(1)->SetRangeUser(0.,3.9999); // chi2/cluster < 4.0\r
-  fRecMCTrackHist->GetAxis(3)->SetRange(1,fRecMCTrackHist->GetAxis(3)->GetNbins());\r
-  //fRecMCTrackHist->GetAxis(4)->SetRangeUser(-1.0,1.0);\r
-  fRecMCTrackHist->GetAxis(4)->SetRange(1,fRecMCTrackHist->GetAxis(4)->GetNbins());\r
+  fRecMCTrackHist->GetAxis(12)->SetRange(1,2);\r
+  fRecMCTrackHist->GetAxis(13)->SetRange(1,1);\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
+  // set all cuts\r
+  fRecMCTrackHist->GetAxis(0)->SetRangeUser(minNCrossRows,160);\r
+  fRecMCTrackHist->GetAxis(1)->SetRangeUser(0.,maxChi2PerClust-0.0001);\r
+  fRecMCTrackHist->GetAxis(2)->SetRangeUser(0.,maxChi2PerClustITS-0.0001);\r
+  fRecMCTrackHist->GetAxis(3)->SetRangeUser(minNCrossRowsOverFindable,1.4999);\r
+  fRecMCTrackHist->GetAxis(4)->SetRangeUser(0.,maxFracSharedClust-0.0001);\r
+  fRecMCTrackHist->GetAxis(5)->SetRangeUser(minDCAr,maxDCAr-0.0001);\r
+  fRecMCTrackHist->GetAxis(6)->SetRangeUser(minDCAz,maxDCAz-0.0001);\r
+  fRecMCTrackHist->GetAxis(7)->SetRangeUser(minEta,maxEta-0.0001);\r
+  fRecMCTrackHist->GetAxis(16)->SetRangeUser(0.,maxChi2ToTPCc-0.0001);\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
+  // nCrossRows \r
+  fRecMCTrackHist->GetAxis(0)->SetRangeUser(0,160);\r
 \r
-  // DCAz cuts\r
-  //fRecMCTrackHist->GetAxis(3)->SetRangeUser(-1.0,1.0);\r
-  fRecMCTrackHist->GetAxis(4)->SetRange(1,fRecMCTrackHist->GetAxis(4)->GetNbins());\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(0,9,15);\r
+  h3D->SetName("rec_sec_nCrossRows_pT_centr");\r
+  h3D->SetTitle("rec_sec_nCrossRows_pT_centr");\r
+  aFolderObj->Add(h3D);\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
+  // Chi2PerClust \r
+  fRecMCTrackHist->GetAxis(0)->SetRangeUser(minNCrossRows,160);\r
+  fRecMCTrackHist->GetAxis(1)->SetRangeUser(0.,10);\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
+  h3D = (TH3D *)fRecMCTrackHist->Projection(1,9,15);\r
+  h3D->SetName("rec_sec_Chi2PerClust_pT_centr");\r
+  h3D->SetTitle("rec_sec_Chi2PerClust_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+  // Chi2PerClustITS \r
+  fRecMCTrackHist->GetAxis(1)->SetRangeUser(0.,maxChi2PerClust-0.0001);\r
+  fRecMCTrackHist->GetAxis(2)->SetRangeUser(0.,100);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(2,9,15);\r
+  h3D->SetName("rec_sec_Chi2PerClustITS_pT_centr");\r
+  h3D->SetTitle("rec_sec_Chi2PerClustITS_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+\r
+  // NCrossRowsOverFindable \r
+  fRecMCTrackHist->GetAxis(2)->SetRangeUser(0.,maxChi2PerClustITS-0.0001);\r
+  fRecMCTrackHist->GetAxis(3)->SetRangeUser(0,1.4999);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(3,9,15);\r
+  h3D->SetName("rec_sec_NCrossRowsOverFindable_pT_centr");\r
+  h3D->SetTitle("rec_sec_NCrossRowsOverFindable_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+\r
+  // FracSharedClust\r
+  fRecMCTrackHist->GetAxis(3)->SetRangeUser(minNCrossRowsOverFindable,1.4999);\r
+  fRecMCTrackHist->GetAxis(4)->SetRangeUser(0.,0.9999);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(4,9,15);\r
+  h3D->SetName("rec_sec_FracSharedClust_pT_centr");\r
+  h3D->SetTitle("rec_sec_FracSharedClust_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+\r
+  // DCAr\r
+  fRecMCTrackHist->GetAxis(4)->SetRangeUser(0.,maxFracSharedClust-0.0001);\r
+  fRecMCTrackHist->GetAxis(5)->SetRangeUser(-10.,9.9999);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(5,9,15);\r
+  h3D->SetName("rec_sec_DCAr_pT_centr");\r
+  h3D->SetTitle("rec_sec_DCAr_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+\r
+  // DCAz\r
+  fRecMCTrackHist->GetAxis(5)->SetRangeUser(minDCAr,maxDCAr-0.0001);\r
+  fRecMCTrackHist->GetAxis(6)->SetRangeUser(-10.,9.9999);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(6,9,15);\r
+  h3D->SetName("rec_sec_DCAz_pT_centr");\r
+  h3D->SetTitle("rec_sec_DCAz_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+  // chi2ToTPCc\r
+  fRecMCTrackHist->GetAxis(6)->SetRangeUser(minDCAz,maxDCAz-0.0001);\r
+  fRecMCTrackHist->GetAxis(16)->SetRangeUser(0,100);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(16,9,15);\r
+  h3D->SetName("rec_sec_chi2ToTPCc_pT_centr");\r
+  h3D->SetTitle("rec_sec_chi2ToTPCc_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+  //\r
+  // only TH3 histograms \r
+  // x : pT : centr\r
+  //\r
+  // primaries defined as AliStack::IsPhysicalPrimary()\r
+  //\r
+  fRecMCTrackHist->GetAxis(12)->SetRange(1,2);\r
+  fRecMCTrackHist->GetAxis(13)->SetRange(2,2);\r
+\r
+  // set all cuts\r
+  fRecMCTrackHist->GetAxis(0)->SetRangeUser(minNCrossRows,160);\r
+  fRecMCTrackHist->GetAxis(1)->SetRangeUser(0.,maxChi2PerClust-0.0001);\r
+  fRecMCTrackHist->GetAxis(2)->SetRangeUser(0.,maxChi2PerClustITS-0.0001);\r
+  fRecMCTrackHist->GetAxis(3)->SetRangeUser(minNCrossRowsOverFindable,1.4999);\r
+  fRecMCTrackHist->GetAxis(4)->SetRangeUser(0.,maxFracSharedClust-0.0001);\r
+  fRecMCTrackHist->GetAxis(5)->SetRangeUser(minDCAr,maxDCAr-0.0001);\r
+  fRecMCTrackHist->GetAxis(6)->SetRangeUser(minDCAz,maxDCAz-0.0001);\r
+  fRecMCTrackHist->GetAxis(7)->SetRangeUser(minEta,maxEta-0.0001);\r
+  fRecMCTrackHist->GetAxis(16)->SetRangeUser(0.,maxChi2ToTPCc-0.0001);\r
+\r
+  // nCrossRows \r
+  fRecMCTrackHist->GetAxis(0)->SetRangeUser(0,160);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(0,9,15);\r
+  h3D->SetName("rec_prim_nCrossRows_pT_centr");\r
+  h3D->SetTitle("rec_prim_nCrossRows_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+  // Chi2PerClust \r
+  fRecMCTrackHist->GetAxis(0)->SetRangeUser(minNCrossRows,160);\r
+  fRecMCTrackHist->GetAxis(1)->SetRangeUser(0.,10);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(1,9,15);\r
+  h3D->SetName("rec_prim_Chi2PerClust_pT_centr");\r
+  h3D->SetTitle("rec_prim_Chi2PerClust_pT_centr");\r
+  aFolderObj->Add(h3D);\r
 \r
+  // Chi2PerClustITS \r
+  fRecMCTrackHist->GetAxis(1)->SetRangeUser(0.,maxChi2PerClust-0.0001);\r
+  fRecMCTrackHist->GetAxis(2)->SetRangeUser(0.,100);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(2,9,15);\r
+  h3D->SetName("rec_prim_Chi2PerClustITS_pT_centr");\r
+  h3D->SetTitle("rec_prim_Chi2PerClustITS_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+\r
+  // NCrossRowsOverFindable \r
+  fRecMCTrackHist->GetAxis(2)->SetRangeUser(0.,maxChi2PerClustITS-0.0001);\r
+  fRecMCTrackHist->GetAxis(3)->SetRangeUser(0,1.4999);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(3,9,15);\r
+  h3D->SetName("rec_prim_NCrossRowsOverFindable_pT_centr");\r
+  h3D->SetTitle("rec_prim_NCrossRowsOverFindable_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+\r
+  // FracSharedClust\r
+  fRecMCTrackHist->GetAxis(3)->SetRangeUser(minNCrossRowsOverFindable,1.4999);\r
+  fRecMCTrackHist->GetAxis(4)->SetRangeUser(0.,0.9999);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(4,9,15);\r
+  h3D->SetName("rec_prim_FracSharedClust_pT_centr");\r
+  h3D->SetTitle("rec_prim_FracSharedClust_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+\r
+  // DCAr\r
+  fRecMCTrackHist->GetAxis(4)->SetRangeUser(0.,maxFracSharedClust-0.0001);\r
+  fRecMCTrackHist->GetAxis(5)->SetRangeUser(-10.,9.9999);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(5,9,15);\r
+  h3D->SetName("rec_prim_DCAr_pT_centr");\r
+  h3D->SetTitle("rec_prim_DCAr_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+\r
+  // DCAz\r
+  fRecMCTrackHist->GetAxis(5)->SetRangeUser(minDCAr,maxDCAr-0.0001);\r
+  fRecMCTrackHist->GetAxis(6)->SetRangeUser(-10.,9.9999);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(6,9,15);\r
+  h3D->SetName("rec_prim_DCAz_pT_centr");\r
+  h3D->SetTitle("rec_prim_DCAz_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+  // chi2ToTPCc\r
+  fRecMCTrackHist->GetAxis(6)->SetRangeUser(minDCAz,maxDCAz-0.0001);\r
+  fRecMCTrackHist->GetAxis(16)->SetRangeUser(0,100);\r
+\r
+  h3D = (TH3D *)fRecMCTrackHist->Projection(16,9,15);\r
+  h3D->SetName("rec_prim_chi2ToTPCc_pT_centr");\r
+  h3D->SetTitle("rec_prim_chi2ToTPCc_pT_centr");\r
+  aFolderObj->Add(h3D);\r
+\r
+  }\r
 \r
   // export objects to analysis folder\r
   fAnalysisFolder = ExportToFolder(aFolderObj);\r
@@ -773,8 +1340,31 @@ void AlidNdPtCutAnalysisPbPb::Analyse()
     return;\r
   }\r
 \r
+  // Reset setings\r
+  \r
+  for(Int_t ndim = 0; ndim < fEventCount->GetNdimensions(); ndim++) {\r
+    fEventCount->GetAxis(ndim)->SetRange(1,fEventCount->GetAxis(ndim)->GetNbins());\r
+  }\r
+\r
+  for(Int_t ndim = 0; ndim < fMCEventHist->GetNdimensions(); ndim++) {\r
+    fMCEventHist->GetAxis(ndim)->SetRange(1,fMCEventHist->GetAxis(ndim)->GetNbins());\r
+  }\r
+\r
+  for(Int_t ndim = 0; ndim < fRecMCEventHist->GetNdimensions(); ndim++) {\r
+    fRecMCEventHist->GetAxis(ndim)->SetRange(1,fRecMCEventHist->GetAxis(ndim)->GetNbins());\r
+  }\r
+\r
+  for(Int_t ndim = 0; ndim < fRecMCTrackHist->GetNdimensions(); ndim++) \r
+  {\r
+    fRecMCTrackHist->GetAxis(ndim)->SetRange(1,fRecMCTrackHist->GetAxis(ndim)->GetNbins());\r
+  }\r
+\r
   // delete only TObjArray\r
-  if(aFolderObj) delete aFolderObj;\r
+  //if(aFolderObj) delete aFolderObj;\r
+\r
+  if (fFolderObj) delete fFolderObj;\r
+  fFolderObj = aFolderObj;\r
+  aFolderObj=0;\r
 }\r
 \r
 //_____________________________________________________________________________\r
index 2a02370..80e2a94 100644 (file)
@@ -53,7 +53,7 @@ public :
   TFolder *CreateFolder(TString folder = "folderdNdPtAnalysis",TString title = "Analysed dNdPt histograms");
 
   // Fill histograms
-  void FillHistograms(AliESDtrack *const esdTrack, AliStack *const stack, Float_t centralityF) const;
+  void FillHistograms(AliESDEvent *const esdEvent, AliESDtrack *const esdTrack, AliStack *const stack, Float_t centralityF) const;
 
   // Getters
   THnSparseF *GetEventCount()   const {return fEventCount;}
@@ -85,14 +85,15 @@ private:
   //
   // THnSparse track histograms
   //
-  //THnSparseF *fRecMCTrackHist; //-> nClust:chi2PerClust:nClust/nFindableClust:DCAy:DCAz:eta:phi:pt:hasStrangeMother:isFromMaterial:isPrim:charge:centr
-  THnSparseF *fRecMCTrackHist; //-> nCrossRows:chi2PerClust:nCrossRows/nFindableClust:fracSharedClust:DCAy:DCAz:eta:phi:pt:hasStrangeMother:isFromMaterial:isPrim:charge:centr
+  THnSparseF *fRecMCTrackHist; //-> nCrossRows:chi2PerClust:chi2PerClustITS:nCrossRows/nFindableClust:fracSharedClust:DCAy:DCAz:eta:phi:pt:hasStrangeMother:isFromConversion:isFromMaterial:isPrim:charge:centr:chi2ToTPCc
   TString fCentralityEstimator;     // use centrality can be "VOM" (default), "FMD", "TRK", "TKL", "CL0", "CL1", "V0MvsFMD", "TKLvsV0M", "ZEMvsZDC"
 
+  TObjArray *fFolderObj; // pointer to AnalysisFolder
+
   AlidNdPtCutAnalysisPbPb(const AlidNdPtCutAnalysisPbPb&); // not implemented
   AlidNdPtCutAnalysisPbPb& operator=(const AlidNdPtCutAnalysisPbPb&); // not implemented
 
-  ClassDef(AlidNdPtCutAnalysisPbPb,2);
+  ClassDef(AlidNdPtCutAnalysisPbPb,4);
 };
 
 #endif
index 33a023b..bbf58a8 100644 (file)
@@ -177,6 +177,33 @@ void AlidNdPtTask::UserExec(Option_t *)
 }\r
 \r
 //_____________________________________________________________________________\r
+void AlidNdPtTask::FinishTaskOutput() \r
+{\r
+  //\r
+  // Called one at the end \r
+  // locally on working node\r
+  //\r
+   // check output data\r
+  fOutput = dynamic_cast<TList*> (GetOutputData(1));\r
+  if (!fOutput) {\r
+    Printf("ERROR: AlidNdPtTask::FinishTaskOutput(): Output data not avaiable GetOutputData(1)==0x0 ..." );\r
+    return;\r
+  }\r
+\r
+  AlidNdPt* pObj=0;\r
+  TIterator* itOut = fOutput->MakeIterator();\r
+  itOut->Reset();\r
+  while(( pObj = dynamic_cast<AlidNdPt*>(itOut->Next())) != NULL) {\r
+    if(pObj->GetAnalyseOutput()) { \r
+      pObj->Analyse();\r
+    }\r
+  }\r
+\r
+  // Post output data.\r
+  PostData(1, fOutput);\r
+}\r
+\r
+//_____________________________________________________________________________\r
 void AlidNdPtTask::Terminate(Option_t *) \r
 {\r
   // Called one at the end \r
index 46b1c11..0d62c8c 100644 (file)
@@ -30,7 +30,7 @@ class AlidNdPtTask : public AliAnalysisTaskSE {
   virtual void   UserExec(Option_t *option);
   virtual void   Terminate(Option_t *);
   virtual Bool_t Notify();
-
+  virtual void   FinishTaskOutput();
   Bool_t AddAnalysisObject(AlidNdPt *pObj);
   void SetUseMCInfo(Bool_t info)           { fUseMCInfo = info; }
   
@@ -47,7 +47,7 @@ class AlidNdPtTask : public AliAnalysisTaskSE {
   AlidNdPtTask(const AlidNdPtTask&); // not implemented
   AlidNdPtTask& operator=(const AlidNdPtTask&); // not implemented
   
-  ClassDef(AlidNdPtTask, 3); // example of analysis
+  ClassDef(AlidNdPtTask, 4); // example of analysis
 };
 
 #endif
diff --git a/PWG0/dNdPt/AlidNdPtTrackDumpTask.cxx b/PWG0/dNdPt/AlidNdPtTrackDumpTask.cxx
new file mode 100644 (file)
index 0000000..fbb6fe8
--- /dev/null
@@ -0,0 +1,867 @@
+/**************************************************************************\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 <TPDGCode.h>\r
+\r
+#include "TChain.h"\r
+#include "TTreeStream.h"\r
+#include "TTree.h"\r
+#include "TH1F.h"\r
+#include "TCanvas.h"\r
+#include "TList.h"\r
+#include "TFile.h"\r
+#include "TMatrixD.h"\r
+\r
+#include "AliHeader.h"  \r
+#include "AliGenEventHeader.h"  \r
+#include "AliInputEventHandler.h"  \r
+#include "AliStack.h"  \r
+#include "AliTrackReference.h"  \r
+\r
+#include "AliPhysicsSelection.h"\r
+#include "AliAnalysisTask.h"\r
+#include "AliAnalysisManager.h"\r
+#include "AliESDEvent.h"\r
+#include "AliESDfriend.h"\r
+#include "AliMCEvent.h"\r
+#include "AliESDInputHandler.h"\r
+#include "AliESDVertex.h"\r
+#include "AliTracker.h"\r
+#include "AliGeomManager.h"\r
+\r
+#include "AliCentrality.h"\r
+#include "AliESDVZERO.h"\r
+#include "AliMultiplicity.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/AlidNdPtTrackDumpTask.h"\r
+\r
+using namespace std;\r
+\r
+ClassImp(AlidNdPtTrackDumpTask)\r
+\r
+//_____________________________________________________________________________\r
+AlidNdPtTrackDumpTask::AlidNdPtTrackDumpTask(const char *name) \r
+  : AliAnalysisTaskSE(name)\r
+  , fESD(0)\r
+  , fMC(0)\r
+  , fESDfriend(0)\r
+  , fOutput(0)\r
+  , fPitList(0)\r
+  , fUseMCInfo(kFALSE)\r
+  , fdNdPtEventCuts(0)\r
+  , fdNdPtAcceptanceCuts(0)\r
+  , fdNdPtRecAcceptanceCuts(0)\r
+  , fEsdTrackCuts(0)\r
+  , fTrigger(AliTriggerAnalysis::kMB1) \r
+  , fAnalysisMode(AlidNdPtHelper::kTPC) \r
+  , fOutputSummary(0)\r
+  , fTreeSRedirector(0)\r
+  , fCentralityEstimator(0)\r
+{\r
+  // Constructor\r
+\r
+  // Define input and output slots here\r
+  DefineOutput(0, TTree::Class());\r
+  //DefineOutput(1, TList::Class());\r
+\r
+}\r
+\r
+//_____________________________________________________________________________\r
+AlidNdPtTrackDumpTask::~AlidNdPtTrackDumpTask()\r
+{\r
+  if(fOutput) delete fOutput;  fOutput =0; \r
+  if(fOutputSummary) delete fOutputSummary;  fOutputSummary =0; \r
+  if(fTreeSRedirector) delete fTreeSRedirector;  fTreeSRedirector =0; \r
+\r
+  if(fdNdPtEventCuts) delete fdNdPtEventCuts; fdNdPtEventCuts=NULL; \r
+  if(fdNdPtAcceptanceCuts) delete fdNdPtAcceptanceCuts; fdNdPtAcceptanceCuts=NULL;\r
+  if(fdNdPtRecAcceptanceCuts) delete fdNdPtRecAcceptanceCuts; fdNdPtRecAcceptanceCuts=NULL;  \r
+  if(fEsdTrackCuts) delete fEsdTrackCuts; fEsdTrackCuts=NULL;\r
+}\r
+\r
+//____________________________________________________________________________\r
+Bool_t AlidNdPtTrackDumpTask::Notify()\r
+{\r
+  static Int_t count = 0;\r
+  count++;\r
+  TTree *chain = (TChain*)GetInputData(0);\r
+  if(chain)\r
+  {\r
+    Printf("Processing %d. file: %s", count, chain->GetCurrentFile()->GetName());\r
+  }\r
+\r
+return kTRUE;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AlidNdPtTrackDumpTask::UserCreateOutputObjects()\r
+{\r
+  // Create histograms\r
+  // Called once\r
+  fOutput = new TList;\r
+  fOutput->SetOwner();\r
+\r
+  //\r
+  // create output tree\r
+  //\r
+  fTreeSRedirector = new TTreeSRedirector("dNdPtOutliersAnalysisPbPb.root");\r
+\r
+  PostData(0, fOutputSummary);\r
+  //PostData(1, fOutput);\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AlidNdPtTrackDumpTask::UserExec(Option_t *) \r
+{\r
+  //\r
+  // Called for each event\r
+  //\r
+\r
+  // ESD event\r
+  fESD = (AliESDEvent*) (InputEvent());\r
+  if (!fESD) {\r
+    Printf("ERROR: ESD event not available");\r
+    return;\r
+  }\r
+\r
+  // MC event\r
+  if(fUseMCInfo) {\r
+    fMC = MCEvent();\r
+    if (!fMC) {\r
+      Printf("ERROR: MC event not available");\r
+      return;\r
+    }\r
+  }\r
+\r
+  fESDfriend = static_cast<AliESDfriend*>(fESD->FindListObject("AliESDfriend"));\r
+  if(!fESDfriend) {\r
+    Printf("ERROR: ESD friends not available");\r
+  }\r
+\r
+  //\r
+  Process(fESD,fMC,fESDfriend);\r
+\r
+  // Post output data.\r
+  PostData(0, fOutputSummary);\r
+  //PostData(1, fOutput);\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AlidNdPtTrackDumpTask::Process(AliESDEvent *const esdEvent, AliMCEvent * const mcEvent, AliESDfriend *const esdFriend)\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
+  // get selection 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
+  // trigger selection\r
+  Bool_t isEventTriggered = kTRUE;\r
+  AliPhysicsSelection *physicsSelection = NULL;\r
+  AliTriggerAnalysis* triggerAnalysis = NULL;\r
+\r
+  // \r
+  AliInputEventHandler* inputHandler = (AliInputEventHandler*) AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler();\r
+  if (!inputHandler)\r
+  {\r
+    Printf("ERROR: Could not receive input handler");\r
+    return;\r
+  }\r
+\r
+  if(evtCuts->IsTriggerRequired())  \r
+  {\r
+    // always MB\r
+    isEventTriggered = inputHandler->IsEventSelected() & AliVEvent::kMB;\r
+\r
+    physicsSelection = static_cast<AliPhysicsSelection*> (inputHandler->GetEventSelection());\r
+    if(!physicsSelection) return;\r
+    //SetPhysicsTriggerSelection(physicsSelection);\r
+\r
+    if (isEventTriggered && (GetTrigger() == AliTriggerAnalysis::kV0AND)) {\r
+      // set trigger (V0AND)\r
+      triggerAnalysis = physicsSelection->GetTriggerAnalysis();\r
+      if(!triggerAnalysis) return;\r
+      isEventTriggered = triggerAnalysis->IsOfflineTriggerFired(esdEvent, GetTrigger());\r
+    }\r
+  }\r
+\r
+  // centrality determination\r
+  Float_t centralityF = -1;\r
+  AliCentrality *esdCentrality = esdEvent->GetCentrality();\r
+  centralityF = esdCentrality->GetCentralityPercentile(fCentralityEstimator.Data());\r
+\r
+  // use MC information\r
+  AliHeader* header = 0;\r
+  AliGenEventHeader* genHeader = 0;\r
+  AliStack* stack = 0;\r
+  TArrayF vtxMC(3);\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
+\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
+    // 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
+  const AliESDVertex* vtxESD = 0; \r
+  if(GetAnalysisMode() == AlidNdPtHelper::kTPC) {\r
+        vtxESD = esdEvent->GetPrimaryVertexTPC();\r
+  }\r
+  else if(GetAnalysisMode() == AlidNdPtHelper::kTPCITS) {\r
+     vtxESD = esdEvent->GetPrimaryVertexTracks();\r
+  }\r
+  else {\r
+       return;\r
+  }\r
+\r
+  if(!vtxESD) return;\r
+\r
+  Bool_t isEventOK = evtCuts->AcceptEvent(esdEvent,mcEvent,vtxESD); \r
+  //printf("isEventOK %d, isEventTriggered %d \n",isEventOK, isEventTriggered);\r
+  //printf("GetAnalysisMode() %d \n",GetAnalysisMode());\r
+\r
+  // check event cuts\r
+  if(isEventOK && isEventTriggered)\r
+  {\r
+\r
+    for (Int_t iTrack = 0; iTrack < esdEvent->GetNumberOfTracks(); iTrack++)\r
+    {\r
+      AliESDtrack *track = esdEvent->GetTrack(iTrack);\r
+      if(!track) continue;\r
+      if(track->Charge()==0) continue;\r
+      if(!esdTrackCuts->AcceptTrack(track)) continue;\r
+      if(!accCuts->AcceptTrack(track)) continue;\r
+\r
+      // Dump to the tree \r
+      // vertex\r
+      // TPC constrained tracks\r
+      // InnerParams constrained tracks\r
+      // TPC-ITS tracks\r
+      // ITSout-InnerParams tracks\r
+      // chi2 distance between TPC constrained and TPC-ITS tracks\r
+      // chi2 distance between TPC refitted constrained and TPC-ITS tracks\r
+      // chi2 distance between ITSout and InnerParams tracks\r
+      // MC information\r
+      \r
+      Double_t x[3]; track->GetXYZ(x);\r
+      Double_t b[3]; AliTracker::GetBxByBz(x,b);\r
+      Bool_t isOK = kFALSE;\r
+\r
+      //\r
+      // Constrain TPC-only tracks (TPCinner) to vertex\r
+      //\r
+      AliExternalTrackParam * tpcInner = (AliExternalTrackParam *)(track->GetTPCInnerParam());\r
+      if (!tpcInner) continue;\r
+      // transform to the track reference frame \r
+      isOK = tpcInner->Rotate(track->GetAlpha());\r
+      isOK = tpcInner->PropagateTo(track->GetX(),esdEvent->GetMagneticField());\r
+      if(!isOK) continue;\r
+\r
+      // clone TPCinner has to be deleted\r
+      AliExternalTrackParam * tpcInnerC = (AliExternalTrackParam *)(track->GetTPCInnerParam()->Clone());\r
+      if (!tpcInnerC) continue;\r
\r
+      // constrain TPCinner \r
+      //isOK = ConstrainTPCInner(tpcInnerC,vtxESD,esdEvent->GetMagneticField());\r
+      isOK = ConstrainTPCInner(tpcInnerC,vtxESD,b);\r
+\r
+      // transform to the track reference frame \r
+      isOK = tpcInnerC->Rotate(track->GetAlpha());\r
+      isOK = tpcInnerC->PropagateTo(track->GetX(),esdEvent->GetMagneticField());\r
+\r
+      if(!isOK) {\r
+        if(tpcInnerC) delete tpcInnerC;\r
+       continue;\r
+      }\r
+\r
+\r
+      //\r
+      // Constrain TPC refitted tracks at inner TPC wall (InnerParams) \r
+      // to vertex\r
+      //\r
+      // clone track InnerParams has to be deleted\r
+      AliExternalTrackParam * trackInnerC = (AliExternalTrackParam *)(track->GetInnerParam()->Clone());\r
+      if (!trackInnerC) continue;\r
\r
+      // constrain track InnerParams \r
+      isOK = ConstrainTrackInner(trackInnerC,vtxESD,track->GetMass(),b);\r
+\r
+      // transform to the track reference frame \r
+      isOK = trackInnerC->Rotate(track->GetAlpha());\r
+      isOK = trackInnerC->PropagateTo(track->GetX(),esdEvent->GetMagneticField());\r
+\r
+      if(!isOK) {\r
+        if(trackInnerC) delete trackInnerC;\r
+       continue;\r
+      }\r
+      \r
+      //\r
+      // calculate chi2 between vi and vj vectors\r
+      // with covi and covj covariance matrices\r
+      // chi2ij = (vi-vj)^(T)*(covi+covj)^(-1)*(vi-vj)\r
+      //\r
+      TMatrixD deltaT(5,1), deltaTtrackC(5,1);\r
+      TMatrixD delta(1,5),  deltatrackC(1,5);\r
+      TMatrixD covarM(5,5), covarMtrackC(5,5);\r
+\r
+      for (Int_t ipar=0; ipar<5; ipar++) {\r
+        deltaT(ipar,0)=tpcInnerC->GetParameter()[ipar]-track->GetParameter()[ipar];\r
+       delta(0,ipar)=tpcInnerC->GetParameter()[ipar]-track->GetParameter()[ipar];\r
+\r
+        deltaTtrackC(ipar,0)=trackInnerC->GetParameter()[ipar]-track->GetParameter()[ipar];\r
+       deltatrackC(0,ipar)=trackInnerC->GetParameter()[ipar]-track->GetParameter()[ipar];\r
+\r
+        for (Int_t jpar=0; jpar<5; jpar++) {\r
+         Int_t index=track->GetIndex(ipar,jpar);\r
+         covarM(ipar,jpar)=track->GetCovariance()[index]+tpcInnerC->GetCovariance()[index];\r
+         covarMtrackC(ipar,jpar)=track->GetCovariance()[index]+trackInnerC->GetCovariance()[index];\r
+        }\r
+      }\r
+      // chi2 distance TPC constrained and TPC+ITS\r
+      TMatrixD covarMInv = covarM.Invert();\r
+      TMatrixD mat2 = covarMInv*deltaT;\r
+      TMatrixD chi2 = delta*mat2; \r
+      //chi2.Print();\r
+\r
+      // chi2 distance TPC refitted constrained and TPC+ITS\r
+      TMatrixD covarMInvtrackC = covarMtrackC.Invert();\r
+      TMatrixD mat2trackC = covarMInvtrackC*deltaTtrackC;\r
+      TMatrixD chi2trackC = deltatrackC*mat2trackC; \r
+      //chi2trackC.Print();\r
+\r
+\r
+      //\r
+      // Propagate ITSout to TPC inner wall \r
+      // and calculate chi2 distance to track (InnerParams)\r
+      //\r
+      const Double_t kTPCRadius=85; \r
+      const Double_t kStep=3; \r
+\r
+      // clone track InnerParams has to be deleted\r
+      AliExternalTrackParam *trackInnerC2 = (AliExternalTrackParam *)(track->GetInnerParam()->Clone());\r
+      if (!trackInnerC2) continue;\r
+      if(!AliTracker::PropagateTrackToBxByBz(trackInnerC2,kTPCRadius,track->GetMass(),kStep,kFALSE))\r
+      {\r
+         if(trackInnerC2) delete trackInnerC2;\r
+         continue;\r
+      }\r
+\r
+      AliExternalTrackParam *outerITSc = new AliExternalTrackParam();\r
+      if(!outerITSc) continue;\r
+\r
+      TMatrixD chi2OuterITS(1,1);\r
+      chi2OuterITS(0,0) = 0;\r
+\r
+      if(esdFriend && esdFriend->TestSkipBit()==kFALSE) \r
+      {\r
+        // propagate ITSout to TPC inner wall\r
+        AliESDfriendTrack *friendTrack = esdFriend->GetTrack(iTrack);\r
+\r
+        if(friendTrack) \r
+       {\r
+          if( (outerITSc = (AliExternalTrackParam *)(friendTrack->GetITSOut()->Clone())) ) \r
+         {\r
+           if(AliTracker::PropagateTrackToBxByBz(outerITSc,kTPCRadius,track->GetMass(),kStep,kFALSE))\r
+           {\r
+              // transform ITSout to the track InnerParams reference frame \r
+             isOK = kFALSE;\r
+              isOK = outerITSc->Rotate(trackInnerC2->GetAlpha());\r
+              isOK = outerITSc->PropagateTo(trackInnerC2->GetX(),esdEvent->GetMagneticField());\r
+\r
+              if(!isOK) {\r
+                if(outerITSc) delete outerITSc;\r
+               if(trackInnerC2) delete trackInnerC2;\r
+               continue;\r
+              }\r
+              \r
+             //\r
+              // calculate chi2 between outerITS and innerParams\r
+             // cov without z-coordinate at the moment\r
+             //\r
+              TMatrixD deltaTouterITS(4,1);\r
+              TMatrixD deltaouterITS(1,4);\r
+              TMatrixD covarMouterITS(4,4);\r
+\r
+             Int_t kipar = 0;\r
+             Int_t kjpar = 0;\r
+              for (Int_t ipar=0; ipar<5; ipar++) {\r
+               if(ipar!=1) {\r
+                  deltaTouterITS(kipar,0)=outerITSc->GetParameter()[ipar]-trackInnerC2->GetParameter()[ipar];\r
+                 deltaouterITS(0,kipar)=outerITSc->GetParameter()[ipar]-trackInnerC2->GetParameter()[ipar];\r
+               }\r
+\r
+                kjpar=0;\r
+                for (Int_t jpar=0; jpar<5; jpar++) {\r
+                 Int_t index=outerITSc->GetIndex(ipar,jpar);\r
+                 if(ipar !=1 || jpar!=1) {\r
+                   covarMouterITS(kipar,kjpar)=outerITSc->GetCovariance()[index]+trackInnerC2->GetCovariance()[index];\r
+                 }\r
+                  if(jpar!=1)  kjpar++;\r
+               }\r
+               if(ipar!=1) kipar++;\r
+             }\r
+\r
+              // chi2 distance ITSout and InnerParams\r
+              TMatrixD covarMInvouterITS = covarMouterITS.Invert();\r
+              TMatrixD mat2outerITS = covarMInvouterITS*deltaTouterITS;\r
+              chi2OuterITS = deltaouterITS*mat2outerITS; \r
+              //chi2OuterITS.Print();\r
+           } \r
+          }\r
+        }\r
+      }\r
+\r
+      //\r
+      // MC info\r
+      //\r
+      TParticle *particle=NULL, *particleTPC=NULL, *particleITS=NULL;\r
+      TParticle *particleMother=NULL, *particleMotherTPC=NULL, *particleMotherITS=NULL;\r
+      Int_t mech=-1, mechTPC=-1, mechITS=-1;\r
+      Bool_t isPrim=kFALSE, isPrimTPC=kFALSE, isPrimITS=kFALSE;\r
+      Bool_t isFromStrangess=kFALSE, isFromStrangessTPC=kFALSE, isFromStrangessITS=kFALSE;\r
+      Bool_t isFromConversion=kFALSE, isFromConversionTPC=kFALSE, isFromConversionITS=kFALSE;\r
+      Bool_t isFromMaterial=kFALSE, isFromMaterialTPC=kFALSE, isFromMaterialITS=kFALSE;\r
+\r
+      AliTrackReference *refTPCIn = NULL;\r
+      AliTrackReference *refITS = NULL;\r
+      AliExternalTrackParam *trackInnerC3 = (AliExternalTrackParam *)(track->GetInnerParam()->Clone());\r
+      if(!trackInnerC3) continue;\r
+\r
+      if(IsUseMCInfo()) \r
+      {\r
+        if(!stack) return;\r
+\r
+        //\r
+        // global track\r
+       //\r
+        Int_t label = TMath::Abs(track->GetLabel()); \r
+        particle = stack->Particle(label);\r
+        if(particle && particle->GetPDG() && particle->GetPDG()->Charge()!=0.)\r
+       {\r
+         particleMother = GetMother(particle,stack);\r
+          mech = particle->GetUniqueID();\r
+          isPrim = stack->IsPhysicalPrimary(label);\r
+         isFromStrangess  = IsFromStrangeness(label,stack);\r
+         isFromConversion = IsFromConversion(label,stack);\r
+          isFromMaterial   = IsFromMaterial(label,stack);\r
+       }\r
+\r
+        //\r
+       // TPC track\r
+       //\r
+       Int_t labelTPC = TMath::Abs(track->GetTPCLabel()); \r
+        particleTPC = stack->Particle(labelTPC);\r
+        if(particleTPC && particleTPC->GetPDG() && particleTPC->GetPDG()->Charge()!=0.)\r
+       {\r
+         particleMotherTPC = GetMother(particleTPC,stack);\r
+          mechTPC = particleTPC->GetUniqueID();\r
+          isPrimTPC = stack->IsPhysicalPrimary(labelTPC);\r
+         isFromStrangessTPC  = IsFromStrangeness(labelTPC,stack);\r
+         isFromConversionTPC = IsFromConversion(labelTPC,stack);\r
+          isFromMaterialTPC   = IsFromMaterial(labelTPC,stack);\r
+       }\r
+\r
+        //\r
+        // store first track reference\r
+       // for TPC track\r
+       //\r
+        TParticle *part=0;\r
+        TClonesArray *trefs=0;\r
+        Int_t status = mcEvent->GetParticleAndTR(track->GetTPCLabel(), part, trefs);\r
+\r
+       if(status>0 && part && trefs && part->GetPDG() && part->GetPDG()->Charge()!=0.) \r
+       {\r
+         Int_t nTrackRef = trefs->GetEntries();\r
+         //printf("nTrackRef %d \n",nTrackRef);\r
+\r
+          Int_t countITS = 0;\r
+         for (Int_t iref = 0; iref < nTrackRef; iref++) \r
+          {\r
+            AliTrackReference *ref = (AliTrackReference *)trefs->At(iref);\r
+           //printf("ref %p \n",ref);\r
+           //if(ref) printf("ref->DetectorId() %d \n",ref->DetectorId());\r
+           //printf("AliTrackReference::kTPC  %d \n",AliTrackReference::kTPC);\r
+\r
+\r
+             // Ref. in the middle ITS \r
+            if(ref && ref->DetectorId()==AliTrackReference::kITS)\r
+            {\r
+             if(!refITS && countITS==2) {\r
+               refITS = ref;\r
+               //printf("refITS %p \n",refITS);\r
+             }\r
+             countITS++;\r
+            }\r
+\r
+            // TPC\r
+            if(ref && ref->DetectorId()==AliTrackReference::kTPC)\r
+            {\r
+             if(!refTPCIn) {\r
+               refTPCIn = ref;\r
+               //printf("refTPCIn %p \n",refTPCIn);\r
+               //break;\r
+             }\r
+            }\r
+         }\r
+\r
+          // transform inner params to TrackRef\r
+         // reference frame\r
+          if(refTPCIn && trackInnerC3) \r
+         {\r
+           Double_t kRefPhi = TMath::ATan2(refTPCIn->Y(),refTPCIn->X());\r
+           isOK = kFALSE;\r
+            isOK = trackInnerC3->Rotate(kRefPhi);\r
+            isOK = AliTracker::PropagateTrackToBxByBz(trackInnerC3,refTPCIn->R(),track->GetMass(),kStep,kFALSE);\r
+\r
+            if(!isOK){\r
+             if(trackInnerC3) delete trackInnerC3;\r
+             if(refTPCIn) delete refTPCIn;\r
+            }\r
+         }\r
+        }\r
+\r
+        //\r
+       // ITS track\r
+       //\r
+       Int_t labelITS = TMath::Abs(track->GetITSLabel()); \r
+        particleITS = stack->Particle(labelITS);\r
+        if(particleITS && particleITS->GetPDG() && particleITS->GetPDG()->Charge()!=0.)\r
+       {\r
+         particleMotherITS = GetMother(particleITS,stack);\r
+          mechITS = particleITS->GetUniqueID();\r
+          isPrimITS = stack->IsPhysicalPrimary(labelITS);\r
+         isFromStrangessITS  = IsFromStrangeness(labelITS,stack);\r
+         isFromConversionITS = IsFromConversion(labelITS,stack);\r
+          isFromMaterialITS   = IsFromMaterial(labelITS,stack);\r
+        }\r
+      }\r
+\r
+      //\r
+      Double_t vert[3] = {0}; \r
+      vert[0] = vtxESD->GetXv();\r
+      vert[1] = vtxESD->GetYv();\r
+      vert[2] = vtxESD->GetZv();\r
+      Int_t mult = vtxESD->GetNContributors();\r
+      Double_t bz = esdEvent->GetMagneticField();\r
+      Double_t runNumber = esdEvent->GetRunNumber();\r
+\r
+      //\r
+      if(!fTreeSRedirector) return;\r
+      (*fTreeSRedirector)<<"dNdPtTree"<<\r
+        "runNumber="<<runNumber<<\r
+        "Bz="<<bz<<\r
+        "vertX="<<vert[0]<<\r
+        "vertY="<<vert[1]<<\r
+        "vertZ="<<vert[2]<<\r
+        "mult="<<mult<<\r
+        "esdTrack.="<<track<<\r
+        "extTPCInnerC.="<<tpcInnerC<<\r
+        "extInnerParamC.="<<trackInnerC<<\r
+        "extInnerParam.="<<trackInnerC2<<\r
+        "extOuterITS.="<<outerITSc<<\r
+        "extInnerParamRef.="<<trackInnerC3<<\r
+        "refTPCIn.="<<refTPCIn<<\r
+        "refITS.="<<refITS<<\r
+        "chi2TPCInnerC="<<chi2(0,0)<<\r
+        "chi2InnerC="<<chi2trackC(0,0)<<\r
+        "chi2OuterITS="<<chi2OuterITS(0,0)<<\r
+        "centralityF="<<centralityF<<\r
+        "particle.="<<particle<<\r
+               "particleMother.="<<particleMother<<\r
+        "mech="<<mech<<\r
+        "isPrim="<<isPrim<<\r
+       "isFromStrangess="<<isFromStrangess<<\r
+       "isFromConversion="<<isFromConversion<<\r
+        "isFromMaterial="<<isFromMaterial<<\r
+        "particleTPC.="<<particleTPC<<\r
+               "particleMotherTPC.="<<particleMotherTPC<<\r
+        "mechTPC="<<mechTPC<<\r
+        "isPrimTPC="<<isPrimTPC<<\r
+       "isFromStrangessTPC="<<isFromStrangessTPC<<\r
+       "isFromConversionTPC="<<isFromConversionTPC<<\r
+        "isFromMaterialTPC="<<isFromMaterialTPC<<\r
+        "particleITS.="<<particleITS<<\r
+               "particleMotherITS.="<<particleMotherITS<<\r
+        "mechITS="<<mechITS<<\r
+        "isPrimITS="<<isPrimITS<<\r
+       "isFromStrangessITS="<<isFromStrangessITS<<\r
+       "isFromConversionITS="<<isFromConversionITS<<\r
+        "isFromMaterialITS="<<isFromMaterialITS<<\r
+        "\n";\r
+\r
+       if(tpcInnerC) delete tpcInnerC;\r
+       if(trackInnerC) delete trackInnerC;\r
+       if(trackInnerC2) delete trackInnerC2;\r
+       if(outerITSc) delete outerITSc;\r
+\r
+       if(trackInnerC3) delete trackInnerC3;\r
+    }\r
+  }\r
+\r
+  PostData(0, fOutputSummary);\r
+  //PostData(1, fOutput);\r
+}\r
+\r
+\r
+//_____________________________________________________________________________\r
+Bool_t AlidNdPtTrackDumpTask::ConstrainTPCInner(AliExternalTrackParam *const tpcInnerC, const AliESDVertex* vtx, Double_t b[3])\r
+{\r
+ // Constrain TPC inner params constrained\r
+ //\r
+      if(!tpcInnerC) return kFALSE; \r
+      if(!vtx) return kFALSE;\r
+\r
+      Double_t dz[2],cov[3];\r
+      //AliESDVertex *vtx= (AliESDVertex *)esdEvent->GetPrimaryVertex();\r
+      //if(!tpcInnerC->PropagateToDCA(vtx, esdEvent->GetMagneticField(), 3, dz, cov)) return kFALSE; \r
+      //if(!tpcInnerC->PropagateToDCA(vtx, Bz, 3, dz, cov)) return kFALSE; \r
+      if(!tpcInnerC->PropagateToDCABxByBz(vtx, b, 3, dz, cov)) return kFALSE; \r
+\r
+\r
+      Double_t covar[6]; vtx->GetCovMatrix(covar);\r
+      Double_t p[2]={tpcInnerC->GetParameter()[0]-dz[0],tpcInnerC->GetParameter()[1]-dz[1]};\r
+      Double_t c[3]={covar[2],0.,covar[5]};\r
+      Double_t chi2C=tpcInnerC->GetPredictedChi2(p,c);\r
+      if (chi2C>kVeryBig) return kFALSE; \r
+\r
+      if(!tpcInnerC->Update(p,c)) return kFALSE;\r
+\r
+  return kTRUE;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+Bool_t AlidNdPtTrackDumpTask::ConstrainTrackInner(AliExternalTrackParam *const trackInnerC, const AliESDVertex* vtx, Double_t mass, Double_t b[3])\r
+{\r
+ // Constrain TPC inner params constrained\r
+ //\r
+      if(!trackInnerC) return kFALSE; \r
+      if(!vtx) return kFALSE;\r
+\r
+      const Double_t kRadius  = 2.8; \r
+      const Double_t kMaxStep = 1.0; \r
+\r
+      Double_t dz[2],cov[3];\r
+\r
+      //AliESDVertex *vtx= (AliESDVertex *)esdEvent->GetPrimaryVertex();\r
+      //if(!trackInnerC->PropagateToDCA(vtx, esdEvent->GetMagneticField(), 3, dz, cov)) return kFALSE; \r
+      //if(!trackInnerC->PropagateToDCA(vtx, Bz, 3, dz, cov)) return kFALSE; \r
+\r
+      if(!AliTracker::PropagateTrackToBxByBz(trackInnerC,kRadius,mass,kMaxStep,kFALSE)) return kFALSE;\r
+      if(!trackInnerC->PropagateToDCABxByBz(vtx, b, 3, dz, cov)) return kFALSE; \r
+\r
+      //\r
+      Double_t covar[6]; vtx->GetCovMatrix(covar);\r
+      Double_t p[2]={trackInnerC->GetParameter()[0]-dz[0],trackInnerC->GetParameter()[1]-dz[1]};\r
+      Double_t c[3]={covar[2],0.,covar[5]};\r
+      Double_t chi2C=trackInnerC->GetPredictedChi2(p,c);\r
+      if (chi2C>kVeryBig) return kFALSE; \r
+\r
+      if(!trackInnerC->Update(p,c)) return kFALSE;\r
+\r
+  return kTRUE;\r
+}\r
+\r
+\r
+//_____________________________________________________________________________\r
+TParticle *AlidNdPtTrackDumpTask::GetMother(TParticle *const particle, AliStack *const stack) \r
+{\r
+  if(!particle) return NULL;\r
+  if(!stack) return NULL;\r
+\r
+  Int_t motherLabel = TMath::Abs(particle->GetMother(0));  \r
+  TParticle* mother = NULL; \r
+  mother = stack->Particle(motherLabel); \r
+\r
+return mother;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+Bool_t AlidNdPtTrackDumpTask::IsFromConversion(const Int_t label, AliStack *const stack) \r
+{\r
+  Bool_t isFromConversion = kFALSE;\r
+\r
+  if(stack) {\r
+    TParticle* particle = stack->Particle(label);\r
+\r
+    if(particle && particle->GetPDG() && particle->GetPDG()->Charge()!=0) \r
+    {\r
+       Int_t mech = particle->GetUniqueID(); // production mechanism \r
+       Bool_t isPrim = stack->IsPhysicalPrimary(label);\r
+\r
+       Int_t motherLabel = TMath::Abs(particle->GetMother(0));  \r
+       TParticle* mother = stack->Particle(motherLabel); \r
+       if(mother) {\r
+          Int_t motherPdg = mother->GetPdgCode();\r
+\r
+          if(!isPrim && mech==5 && motherPdg==kGamma) { \r
+            isFromConversion=kTRUE; \r
+          }\r
+       }\r
+    } \r
+  } \r
+\r
+  return isFromConversion;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+Bool_t AlidNdPtTrackDumpTask::IsFromMaterial(const Int_t label, AliStack *const stack) \r
+{\r
+  Bool_t isFromMaterial = kFALSE;\r
+\r
+  if(stack) {\r
+    TParticle* particle = stack->Particle(label);\r
+\r
+    if(particle && particle->GetPDG() && particle->GetPDG()->Charge()!=0) \r
+    {\r
+       Int_t mech = particle->GetUniqueID(); // production mechanism \r
+       Bool_t isPrim = stack->IsPhysicalPrimary(label);\r
+\r
+       Int_t motherLabel = TMath::Abs(particle->GetMother(0));  \r
+       TParticle* mother = stack->Particle(motherLabel); \r
+       if(mother) {\r
+          if(!isPrim && mech==13) { \r
+            isFromMaterial=kTRUE; \r
+          }\r
+       }\r
+     } \r
+  } \r
+\r
+  return isFromMaterial;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+Bool_t AlidNdPtTrackDumpTask::IsFromStrangeness(const Int_t label, AliStack *const stack) \r
+{\r
+  Bool_t isFromStrangeness = kFALSE;\r
+\r
+  if(stack) {\r
+    TParticle* particle = stack->Particle(label);\r
+\r
+    if(particle && particle->GetPDG() && particle->GetPDG()->Charge()!=0) \r
+    {\r
+       Int_t mech = particle->GetUniqueID(); // production mechanism \r
+       Bool_t isPrim = stack->IsPhysicalPrimary(label);\r
+\r
+       Int_t motherLabel = TMath::Abs(particle->GetMother(0));  \r
+       TParticle* mother = stack->Particle(motherLabel); \r
+       if(mother) {\r
+          Int_t motherPdg = mother->GetPdgCode();\r
+\r
+          // K+-, lambda, antilambda, K0s decays\r
+          if(!isPrim && mech==4 && \r
+             (TMath::Abs(motherPdg)==kKPlus || TMath::Abs(motherPdg)==kLambda0 || motherPdg==kK0Short))\r
+          {\r
+            isFromStrangeness = kTRUE;\r
+          } \r
+       }\r
+    } \r
+  } \r
+\r
+  return isFromStrangeness;\r
+}\r
+\r
+\r
+//_____________________________________________________________________________\r
+void AlidNdPtTrackDumpTask::FinishTaskOutput() \r
+{\r
+  //\r
+  // Called one at the end \r
+  // locally on working node\r
+  //\r
+\r
+  // Post output data.\r
+  PostData(1, fOutput);\r
+  //PostData(0, fOutputSummary);\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AlidNdPtTrackDumpTask::Terminate(Option_t *) \r
+{\r
+  // Called one at the end \r
+  \r
+  // check output data\r
+  fOutputSummary = dynamic_cast<TTree*> (GetOutputData(0));\r
+  if(fOutputSummary) delete fOutputSummary; fOutputSummary=0;\r
+  if(fTreeSRedirector)  delete fTreeSRedirector; fTreeSRedirector=0;\r
+\r
+  TChain* chain = new TChain("dNdPtTree");\r
+  if(!chain) return;\r
+  chain->Add("dNdPtOutliersAnalysisPbPb.root");\r
+  TTree *tree = chain->CopyTree("1");\r
+  if (chain) { delete chain; chain=0; }\r
+  if(!tree) return;\r
+  tree->Print();\r
+  fOutputSummary = tree;\r
+\r
+  if (!fOutputSummary) {\r
+    Printf("ERROR: AlidNdPtTrackDumpTask::Terminate(): Output data not avaiable GetOutputData(0)==0x0 ..." );\r
+    return;\r
+  }\r
+  \r
+\r
+\r
+  PostData(0, fOutputSummary);\r
+  //PostData(1, fOutput);\r
+}\r
diff --git a/PWG0/dNdPt/AlidNdPtTrackDumpTask.h b/PWG0/dNdPt/AlidNdPtTrackDumpTask.h
new file mode 100644 (file)
index 0000000..ef0198e
--- /dev/null
@@ -0,0 +1,104 @@
+#ifndef ALIDNDPTTRACKDUMPTASK_H
+#define ALIDNDPTTRACKDUMPTASK_H
+
+//------------------------------------------------------------------------------
+// Task to dump track information 
+// TPC constrained and TP+ITS combined 
+// for outliers analysis.
+// 
+// Author: J.Otwinowski 19/06/2011 
+//------------------------------------------------------------------------------
+
+class AliESDEvent;
+class AliMCEvent;
+class AlidNdPtEventCuts;
+class AlidNdPtAcceptanceCuts;
+class AliESDtrackCuts;
+class AlidNdPt;
+class AlidNdPtAnalysis;
+class AlidNdPtCorrection;
+class AliMagFMaps;
+class AliESDEvent; 
+class AliMCEvent; 
+class TList;
+class TTree;
+class TTreeSRedirector;
+
+#include "AliTriggerAnalysis.h"
+#include "AliAnalysisTaskSE.h"
+#include "dNdPt/AlidNdPtHelper.h"
+
+class AlidNdPtTrackDumpTask : public AliAnalysisTaskSE {
+ public:
+
+
+  AlidNdPtTrackDumpTask(const char *name = "AlidNdPtTrackDumpTask");
+  virtual ~AlidNdPtTrackDumpTask();
+  
+  virtual void   UserCreateOutputObjects();
+  virtual void   UserExec(Option_t *option);
+  virtual void   Terminate(Option_t *);
+  virtual Bool_t Notify();
+  virtual void   FinishTaskOutput();
+  void SetUseMCInfo(Bool_t info)           { fUseMCInfo = info; }
+  Bool_t IsUseMCInfo() const               { return fUseMCInfo; }
+  
+  // Process events
+  virtual void Process(AliESDEvent *const esdEvent=0, AliMCEvent *const mcEvent=0, AliESDfriend *const esdFriend=0);
+
+  void SetEventCuts(AlidNdPtEventCuts* const cuts)              { fdNdPtEventCuts = cuts; }
+  void SetAcceptanceCuts(AlidNdPtAcceptanceCuts* const cuts)    { fdNdPtAcceptanceCuts = cuts; }
+  void SetRecAcceptanceCuts(AlidNdPtAcceptanceCuts* const cuts) { fdNdPtRecAcceptanceCuts = cuts; }
+  void SetTrackCuts(AliESDtrackCuts* const cuts)                { fEsdTrackCuts = cuts; }
+  void SetTrigger(const AliTriggerAnalysis::Trigger trigger)    { fTrigger = trigger; }
+  void SetAnalysisMode(const AlidNdPtHelper::AnalysisMode mode) { fAnalysisMode = mode; }
+
+  AlidNdPtEventCuts* GetEventCuts() const                       { return fdNdPtEventCuts; }
+  AlidNdPtAcceptanceCuts* GetAcceptanceCuts() const             { return fdNdPtAcceptanceCuts; }
+  AlidNdPtAcceptanceCuts* GetRecAcceptanceCuts() const          { return fdNdPtRecAcceptanceCuts; }  
+  AliESDtrackCuts* GetTrackCuts() const                         { return fEsdTrackCuts; }
+  AliTriggerAnalysis::Trigger GetTrigger() const                { return fTrigger; }
+  AlidNdPtHelper::AnalysisMode GetAnalysisMode() const          { return fAnalysisMode; }
+
+  TString GetCentralityEstimator() const {return fCentralityEstimator; }
+  void SetCentralityEstimator(TString centEst="V0M") { fCentralityEstimator = centEst; }
+
+  Bool_t IsFromConversion(const Int_t label, AliStack *const stack);
+  Bool_t IsFromMaterial(const Int_t label, AliStack *const stack);
+  Bool_t IsFromStrangeness(const Int_t label, AliStack *const stack);
+  TParticle *GetMother(TParticle *const particle, AliStack *const stack);
+
+  Bool_t ConstrainTPCInner(AliExternalTrackParam *const tpcInnerC, const AliESDVertex* vtx, Double_t b[3]);
+  Bool_t ConstrainTrackInner(AliExternalTrackParam *const trackInnerC, const AliESDVertex* vtx, Double_t mass, Double_t b[3]);
+
+
+ private:
+
+  AliESDEvent *fESD;    //! ESD event
+  AliMCEvent *fMC;      //! MC event
+  AliESDfriend *fESDfriend; //! ESDfriend event
+  TList* fOutput;       //! list send on output slot 0
+  TIterator *fPitList;  //! iterator over the output objetcs  
+
+  Bool_t fUseMCInfo;        //! use MC information
+
+  AlidNdPtEventCuts      *fdNdPtEventCuts;      //! event cuts
+  AlidNdPtAcceptanceCuts *fdNdPtAcceptanceCuts; //! acceptance cuts  
+  AlidNdPtAcceptanceCuts *fdNdPtRecAcceptanceCuts; //! additional recontruction acceptance cuts (not used for MC truth)
+  AliESDtrackCuts *fEsdTrackCuts;          //! esd track cuts
+  AliTriggerAnalysis::Trigger fTrigger;    //! trigger settings
+  AlidNdPtHelper::AnalysisMode fAnalysisMode;   //! analysis mode TPC only, TPC + ITS
+
+  TTree* fOutputSummary;      //! tree to dump output
+  TTreeSRedirector* fTreeSRedirector;      //! temp tree to dump output
+
+  TString fCentralityEstimator;     //! use centrality can be "VOM" (default), "FMD", "TRK", "TKL", "CL0", "CL1", "V0MvsFMD", "TKLvsV0M", "ZEMvsZDC"
+
+
+  AlidNdPtTrackDumpTask(const AlidNdPtTrackDumpTask&); // not implemented
+  AlidNdPtTrackDumpTask& operator=(const AlidNdPtTrackDumpTask&); // not implemented
+  
+  ClassDef(AlidNdPtTrackDumpTask, 1); // example of analysis
+};
+
+#endif