end-of-line normalization
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / ChargedHadrons / dNdPt / AlidNdPtCutAnalysis.cxx
index 9e24cfb..267ca3b 100644 (file)
-/**************************************************************************\r
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
- *                                                                        *\r
- * Author: The ALICE Off-line Project.                                    *\r
- * Contributors are mentioned in the code where appropriate.              *\r
- *                                                                        *\r
- * Permission to use, copy, modify and distribute this software and its   *\r
- * documentation strictly for non-commercial purposes is hereby granted   *\r
- * without fee, provided that the above copyright notice appears in all   *\r
- * copies and that both the copyright notice and this permission notice   *\r
- * appear in the supporting documentation. The authors make no claims     *\r
- * about the suitability of this software for any purpose. It is          *\r
- * provided "as is" without express or implied warranty.                  *\r
- **************************************************************************/\r
-//------------------------------------------------------------------------------\r
-// AlidNdPtCutAnalysis class. \r
-//\r
-// a. functionality:\r
-// - fills generic cut histograms\r
-// - generates cuts (selection criteria)\r
-//\r
-// b. data members:\r
-// - generic cut histograms\r
-// - control histograms\r
-//\r
-// Author: J.Otwinowski 04/11/2008 \r
-//------------------------------------------------------------------------------\r
-#include "TH1.h"\r
-#include "TH2.h"\r
-\r
-#include "AliHeader.h"  \r
-#include "AliGenEventHeader.h"  \r
-#include "AliInputEventHandler.h"  \r
-#include "AliStack.h"  \r
-#include "AliESDEvent.h"  \r
-#include "AliMCEvent.h"  \r
-#include "AliESDtrackCuts.h"  \r
-#include "AliLog.h" \r
-#include "AliTracker.h" \r
-\r
-#include "AlidNdPtEventCuts.h"\r
-#include "AlidNdPtAcceptanceCuts.h"\r
-#include "AlidNdPtBackgroundCuts.h"\r
-#include "AlidNdPtAnalysis.h"\r
-#include "AliPhysicsSelection.h"\r
-\r
-#include "AliPWG0Helper.h"\r
-#include "AlidNdPtHelper.h"\r
-#include "AlidNdPtCutAnalysis.h"\r
-\r
-using namespace std;\r
-\r
-ClassImp(AlidNdPtCutAnalysis)\r
-\r
-//_____________________________________________________________________________\r
-  AlidNdPtCutAnalysis::AlidNdPtCutAnalysis(): AlidNdPt(),\r
-  fAnalysisFolder(0),\r
-  fEventCount(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
-  fEventCount(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(fEventCount) delete fEventCount; fEventCount=0;\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
-  /*\r
-  const Int_t ptNbins = 56; \r
-  const Double_t ptMin = 0.; \r
-  const Double_t ptMax = 16.; \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
-  // set pt bins\r
-  const Int_t ptNbins = 50;\r
-  const Double_t ptMin = 1.e-2, ptMax = 50.;\r
-  Double_t *binsPt = CreateLogAxis(ptNbins,ptMin,ptMax);\r
-\r
-  // \r
-  Int_t binsEventCount[2]={2,2};\r
-  Double_t minEventCount[2]={0,0}; \r
-  Double_t maxEventCount[2]={2,2}; \r
-  fEventCount = new THnSparseF("fEventCount","trig vs trig+vertex",2,binsEventCount,minEventCount,maxEventCount);\r
-  fEventCount->GetAxis(0)->SetTitle("trig");\r
-  fEventCount->GetAxis(1)->SetTitle("trig+vert");\r
-  fEventCount->Sumw2();\r
-\r
-  //Xv:Yv:Zv:ResZv:Mult\r
-  Double_t kFact = 1.0;\r
-\r
-  Int_t binsRecEventHist[5]={80,80,100,80,150};\r
-  Double_t minRecEventHist[5]={-3.*kFact,-3.*kFact,-35.,0.,0.}; \r
-  Double_t maxRecEventHist[5]={3.*kFact,3.*kFact,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]={80,80,100};\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]={-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
-  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
-  fRecMCEventHist->GetAxis(2)->SetTitle("Zv-mcZv (cm)");\r
-  fRecMCEventHist->GetAxis(3)->SetTitle("Mult");\r
-  fRecMCEventHist->Sumw2();\r
-\r
-  //\r
-  // THnSparse track histograms\r
-  //\r
-\r
- //nCrossRows:chi2PerClust:nCrossRows/nFindableClust:fracSharedClust:DCAy:DCAz:eta:phi:pt:hasStrangeMother:isFromMaterial:isPrim:charge\r
-  Int_t binsRecMCTrackHist[13]=  { 160,  10,  20,  20, 50,  50,   20,  90,             ptNbins, 2,  2,  2,  3  };\r
-  Double_t minRecMCTrackHist[13]={ 0.,   0.,  0.,  0., -0.5,-0.5,-1.0, 0.,             ptMin,   0., 0., 0.,-1. };\r
-  Double_t maxRecMCTrackHist[13]={ 160., 10., 1.,  1., 0.5, 0.5,  1.0, 2.*TMath::Pi(), ptMax,   2., 2., 2., 2. };\r
-\r
-  fRecMCTrackHist = new THnSparseF("fRecMCTrackHist","nCrossRows:chi2PerClust:nCrossRows/nFindableClust:fracSharedClust:DCAy:DCAz:eta:phi:pt:hasStrangeMother:isFromMaterial:isPrim:charge",13,binsRecMCTrackHist,minRecMCTrackHist,maxRecMCTrackHist);\r
-  fRecMCTrackHist->SetBinEdges(8,binsPt);\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->Sumw2();\r
-\r
-  //nClust:chi2PerClust:nClust/nFindableClust:DCAy:DCAz:eta:phi:pt:kinkIdx:isPrim:polarity\r
-  /*\r
-  Int_t binsRecMCTrackHist[11]={160,80,80,100,100,90,90,ptNbins, 3, 2, 2};\r
-  Double_t minRecMCTrackHist[11]={0., 0., 0., -1.,-1.,-1.5, 0., ptMin, -1., 0., 0.};\r
-  Double_t maxRecMCTrackHist[11]={160.,10.,1.2, 1.,1.,1.5, 2.*TMath::Pi(), ptMax, 2., 2., 2.};\r
-\r
-  fRecMCTrackHist = new THnSparseF("fRecMCTrackHist","nClust:chi2PerClust:nClust/nFindableClust:DCAy:DCAz:eta:phi:pt:kinkIdx:isPrim:polarity",11,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("kinkIdx"); // 0 - no kink, -1 - kink mother, 1 - kink daugther \r
-  fRecMCTrackHist->GetAxis(9)->SetTitle("isPrim");\r
-  fRecMCTrackHist->GetAxis(10)->SetTitle("polarity");\r
-  fRecMCTrackHist->Sumw2();\r
-  */\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
-  // 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
-\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
-  // use MC information\r
-  AliHeader* header = 0;\r
-  AliGenEventHeader* genHeader = 0;\r
-  AliStack* stack = 0;\r
-  TArrayF vtxMC(3);\r
-  AliPWG0Helper::MCProcessType evtType = AliPWG0Helper::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 = AliPWG0Helper::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
-  Bool_t bRedoTPCVertex = evtCuts->IsRedoTPCVertex();\r
-  Bool_t bUseConstraints = evtCuts->IsUseBeamSpotConstraint();\r
-  const AliESDVertex* vtxESD = AlidNdPtHelper::GetVertex(esdEvent,evtCuts,accCuts,esdTrackCuts,GetAnalysisMode(),kFALSE,bRedoTPCVertex,bUseConstraints); \r
-  Bool_t isRecVertex = AlidNdPtHelper::TestRecVertex(vtxESD, esdEvent->GetPrimaryVertexSPD(), GetAnalysisMode(), kFALSE);\r
-  Bool_t isEventOK = evtCuts->AcceptEvent(esdEvent,mcEvent,vtxESD) && isRecVertex;\r
-\r
-  TObjArray *allChargedTracks=0;\r
-  Int_t multAll=0;\r
-  \r
-  //\r
-  // event counter\r
-  // \r
-  //printf("isEventOK %d, isEventTriggered %d \n",isEventOK,isEventTriggered);\r
-\r
-  Bool_t isTrigAndVertex = isEventTriggered && isEventOK;\r
-  Double_t vEventCount[2] = { isEventTriggered, isTrigAndVertex};\r
-  fEventCount->Fill(vEventCount);\r
-\r
-  //\r
-  // cosmic background and splitted tracks\r
-  //\r
-  if(GetParticleMode() == AlidNdPtHelper::kBackgroundTrack) \r
-  {\r
-    AlidNdPtBackgroundCuts *backCuts = GetBackgroundCuts(); \r
-    if(!backCuts) return;\r
-\r
-    for (Int_t iTrack = 0; iTrack < esdEvent->GetNumberOfTracks(); iTrack++) \r
-    {\r
-      AliESDtrack *track1 = esdEvent->GetTrack(iTrack);\r
-      if(!track1) continue; \r
-      if(track1->Charge()==0) continue; \r
-\r
-      for (Int_t jTrack = iTrack+1; jTrack < esdEvent->GetNumberOfTracks(); jTrack++) \r
-      {\r
-        AliESDtrack *track2 = esdEvent->GetTrack(jTrack);\r
-        if(!track2) continue; \r
-        if(track2->Charge()==0) continue; \r
-\r
-       //printf("track2->Charge() %d\n",track2->Charge());\r
-\r
-        backCuts->IsBackgroundTrack(track1, track2);\r
-      }\r
-    }\r
-  }\r
-\r
-  // check event cuts\r
-  if(isEventOK && isEventTriggered)\r
-  {\r
-    // get all charged tracks\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
-      if(!esdTrackCuts->AcceptTrack(track)) continue;\r
-\r
-      //\r
-      Bool_t isOK = kFALSE;\r
-      Double_t x[3]; track->GetXYZ(x);\r
-      Double_t b[3]; AliTracker::GetBxByBz(x,b);\r
-\r
-      //\r
-      // if TPC-ITS hybrid tracking (kTPCITSHybrid)\r
-      // replace track parameters with TPC-ony track parameters\r
-      //\r
-      if( GetAnalysisMode() == AlidNdPtHelper::kTPCITSHybrid || GetAnalysisMode() == AlidNdPtHelper::kTPCITSHybridTrackSPDvtx || GetAnalysisMode() == AlidNdPtHelper::kTPCITSHybridTrackSPDvtxDCArPt) \r
-      {\r
-        // Relate TPC-only tracks to SPD vertex\r
-        isOK = track->RelateToVertexTPCBxByBz(vtxESD, b, kVeryBig);\r
-        if(!isOK) continue;\r
-\r
-       // replace esd track parameters with TPCinner\r
-        AliExternalTrackParam  *tpcTrack  = new AliExternalTrackParam(*(track->GetTPCInnerParam()));\r
-       if (!tpcTrack) return;\r
-        track->Set(tpcTrack->GetX(),tpcTrack->GetAlpha(),tpcTrack->GetParameter(),tpcTrack->GetCovariance());\r
-\r
-        if(tpcTrack) delete tpcTrack; \r
-      } \r
-\r
-      //\r
-      if (GetAnalysisMode()==AlidNdPtHelper::kTPCSPDvtxUpdate || GetAnalysisMode() == AlidNdPtHelper::kTPCTrackSPDvtxUpdate) \r
-      {\r
-        //\r
-        // update track parameters\r
-       //\r
-        AliExternalTrackParam cParam;\r
-        isOK = track->RelateToVertexTPCBxByBz(vtxESD, b, kVeryBig, &cParam);\r
-       if(!isOK) continue;\r
-\r
-       track->Set(cParam.GetX(),cParam.GetAlpha(),cParam.GetParameter(),cParam.GetCovariance());\r
-      }\r
-\r
-      FillHistograms(track, stack);\r
-      multAll++;\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
-\r
-  if(allChargedTracks) delete allChargedTracks; allChargedTracks = 0;\r
-\r
-}\r
-\r
-//_____________________________________________________________________________\r
-void AlidNdPtCutAnalysis::FillHistograms(AliESDtrack *const esdTrack, AliStack *const stack) const\r
-{\r
-  //\r
-  // Fill ESD track and MC histograms \r
-  //\r
-  if(!esdTrack) return;\r
-  if(esdTrack->Charge() == 0.) return;\r
-\r
-  Float_t pt = esdTrack->Pt();\r
-  Float_t eta = esdTrack->Eta();\r
-  Float_t phi = esdTrack->Phi();\r
-\r
-\r
-  Int_t nClust = 0;\r
-  if(GetAnalysisMode() == AlidNdPtHelper::kTPC) { \r
-    nClust = esdTrack->GetTPCNclsIter1();\r
-  } else {\r
-    nClust = esdTrack->GetTPCclusters(0);\r
-  }\r
-\r
-  Float_t chi2PerCluster = 0.;\r
-  if(GetAnalysisMode() == AlidNdPtHelper::kTPC) { \r
-    if(nClust>0.) chi2PerCluster = esdTrack->GetTPCchi2Iter1()/Float_t(nClust);\r
-  } else {\r
-    chi2PerCluster = esdTrack->GetTPCchi2()/Float_t(nClust);\r
-  }\r
-\r
-  Int_t nFindableClust = esdTrack->GetTPCNclsF();\r
-\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
-  // \r
-  Float_t nCrossedRowsTPC = esdTrack->GetTPCClusterInfo(2,1);\r
-\r
-  Float_t  ratioCrossedRowsOverFindableClustersTPC = 1.0;\r
-  if (esdTrack->GetTPCNclsF()>0) {\r
-     ratioCrossedRowsOverFindableClustersTPC = esdTrack->GetTPCClusterInfo(2,1)/esdTrack->GetTPCNclsF();\r
-  }\r
-\r
-  //\r
-  Int_t nClustersTPCShared = esdTrack->GetTPCnclsS();\r
-  Float_t fracClustersTPCShared = -1.;\r
-  fracClustersTPCShared = Float_t(nClustersTPCShared)/Float_t(nClust);\r
-\r
-\r
-  // kink idx\r
-  Int_t kinkIdx = 0;\r
-  //if(esdTrack->GetKinkIndex(0) > 0.)   isKink  = kTRUE;\r
-  if(esdTrack->GetKinkIndex(0) > 0)      kinkIdx = 1;   // kink daughter\r
-  else if(esdTrack->GetKinkIndex(0) < 0) kinkIdx = -1;  // kink mother\r
-  else kinkIdx = 0; // not kink\r
-\r
-  //printf("esdTrack->GetKinkIndex(0) %d \n", esdTrack->GetKinkIndex(0));\r
-  //printf("esdTrack->GetKinkIndex(1) %d \n", esdTrack->GetKinkIndex(1));\r
-  //printf("esdTrack->GetKinkIndex(2) %d \n", esdTrack->GetKinkIndex(2));\r
-  //printf("kinkIdx %d \n", kinkIdx);\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
-\r
-  if(IsUseMCInfo()) {\r
-    if(!stack) return;\r
-    Int_t label = TMath::Abs(esdTrack->GetLabel()); \r
-    TParticle* particle = stack->Particle(label);\r
-    if(!particle) return;\r
-    if(particle->GetPDG() && particle->GetPDG()->Charge()==0.) return;\r
-    isPrim = stack->IsPhysicalPrimary(label);\r
-\r
-    // check whether has stange mother\r
-    //\r
-    Int_t motherPdg = -1; \r
-    TParticle* mother = 0; \r
-       \r
-    Int_t motherLabel = particle->GetMother(0);  \r
-    if(motherLabel>0) mother = stack->Particle(motherLabel); \r
-    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
-\r
-    //if(isPrim && pt > 1.5 && kinkIdx == -1) printf("nClust  %d \n", nClust);\r
-  }\r
-  \r
-  // fill histo\r
-  Int_t charge = esdTrack->Charge(); \r
-\r
-  //Double_t vRecMCTrackHist[11] = { nClust,chi2PerCluster,clustPerFindClust,b[0],b[1],eta,phi,pt,kinkIdx,isPrim, polarity }; \r
-  //fRecMCTrackHist->Fill(vRecMCTrackHist);\r
-\r
-  Double_t vRecMCTrackHist[13] = { nCrossedRowsTPC, chi2PerCluster, ratioCrossedRowsOverFindableClustersTPC, fracClustersTPCShared , b[0], b[1], eta, phi, pt, hasStrangeMother, isFromMaterial, isPrim, charge }; \r
-  fRecMCTrackHist->Fill(vRecMCTrackHist);\r
-\r
-}\r
-\r
-//_____________________________________________________________________________\r
-Long64_t AlidNdPtCutAnalysis::Merge(TCollection* const 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
-  //TList *collPhysSelection = new TList;\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
-    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
-\r
-    // physics selection\r
-    //collPhysSelection->Add(entry->GetPhysicsTriggerSelection());\r
-    \r
-  count++;\r
-  }\r
-\r
-  //AliPhysicsSelection *trigSelection = GetPhysicsTriggerSelection();\r
-  //trigSelection->Merge(collPhysSelection);\r
-\r
-  //if(collPhysSelection) delete collPhysSelection;\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
-  if(!aFolderObj) return;\r
-\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
-  Double_t maxDCAr = accCuts->GetMaxDCAr();\r
-\r
-  //\r
-  // Event counters\r
-  //\r
-  h2D = (TH2D*)fEventCount->Projection(0,1);\r
-  if(!h2D) return;\r
-  h2D->SetName("trig_vs_trigANDvertex");\r
-  aFolderObj->Add(h2D);\r
-\r
-  fEventCount->GetAxis(0)->SetRange(2,2); // triggered\r
-  h1D = (TH1D*)fEventCount->Projection(1);\r
-  if(!h1D) return;\r
-  h1D->SetTitle("rec. vertex for triggered events");\r
-  h1D->SetName("trigANDvertex");\r
-  aFolderObj->Add(h1D);\r
-\r
-  //\r
-  // Create rec. event histograms\r
-  //\r
-  h1D = (TH1D *)fRecEventHist->Projection(0);\r
-  if(!h1D) return;\r
-  h1D->SetName("rec_xv");\r
-  aFolderObj->Add(h1D);\r
-\r
-  h1D = (TH1D *)fRecEventHist->Projection(1);\r
-  if(!h1D) return;\r
-  h1D->SetName("rec_yv");\r
-  aFolderObj->Add(h1D);\r
-\r
-  h1D = (TH1D *)fRecEventHist->Projection(2);\r
-  if(!h1D) return;\r
-  h1D->SetName("rec_zv");\r
-  aFolderObj->Add(h1D);\r
-\r
-  h2D = (TH2D *)fRecEventHist->Projection(3,4);\r
-  if(!h2D) return;\r
-  h2D->SetName("rec_resZv_vs_Mult");\r
-  aFolderObj->Add(h2D);\r
-\r
-  h2D = (TH2D *)fRecEventHist->Projection(0,1);\r
-  if(!h2D) return;\r
-  h2D->SetName("rec_xv_vs_yv");\r
-  aFolderObj->Add(h2D);\r
-\r
-  h2D = (TH2D *)fRecEventHist->Projection(0,2);\r
-  if(!h2D) return;\r
-  h2D->SetName("rec_xv_vs_zv");\r
-  aFolderObj->Add(h2D);\r
-\r
-  h2D = (TH2D *)fRecEventHist->Projection(3,4);\r
-  if(!h2D) return;\r
-  h2D->SetName("rec_resZv_vs_Mult");\r
-  aFolderObj->Add(h2D);\r
-\r
-  //\r
-  // MC available\r
-  //\r
-  if(IsUseMCInfo()) {\r
-\r
-  //\r
-  // Create mc event histograms\r
-  //\r
-  h2D = (TH2D *)fMCEventHist->Projection(0,1);\r
-  if(!h2D) return;\r
-  h2D->SetName("mc_xv_vs_yv");\r
-  aFolderObj->Add(h2D);\r
-\r
-  h2D = (TH2D *)fMCEventHist->Projection(0,2);\r
-  if(!h2D) return;\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
-  if(!h2D) return;\r
-  h2D->SetName("rec_mc_deltaXv_vs_mult");\r
-  aFolderObj->Add(h2D);\r
-\r
-  h2D = (TH2D *)fRecMCEventHist->Projection(1,3);\r
-  if(!h2D) return;\r
-  h2D->SetName("rec_mc_deltaYv_vs_mult");\r
-  aFolderObj->Add(h2D);\r
-\r
-  h2D = (TH2D *)fRecMCEventHist->Projection(2,3);\r
-  if(!h2D) return;\r
-  h2D->SetName("rec_mc_deltaZv_vs_mult");\r
-  aFolderObj->Add(h2D);\r
-\r
-  } // end use MC info \r
-\r
-\r
-\r
-  //\r
-  // Create rec-mc track track histograms \r
-  //\r
-\r
-  // DCA cuts\r
-  fRecMCTrackHist->GetAxis(3)->SetRangeUser(-maxDCAr,maxDCAr);\r
-  fRecMCTrackHist->GetAxis(4)->SetRangeUser(-maxDCAr,maxDCAr);\r
-\r
-  h2D = (TH2D *)fRecMCTrackHist->Projection(7,5);\r
-  if(!h2D) return;\r
-  h2D->SetName("pt_vs_eta");\r
-  aFolderObj->Add(h2D);\r
-\r
-  fRecMCTrackHist->GetAxis(7)->SetRangeUser(minPt,maxPt);  \r
-\r
-  h2D = (TH2D *)fRecMCTrackHist->Projection(0,5);\r
-  if(!h2D) return;\r
-  h2D->SetName("nClust_vs_eta");\r
-  aFolderObj->Add(h2D);\r
-\r
-  h2D = (TH2D *)fRecMCTrackHist->Projection(1,5);\r
-  if(!h2D) return;\r
-  h2D->SetName("chi2PerClust_vs_eta");\r
-  aFolderObj->Add(h2D);\r
-\r
-  h2D = (TH2D *)fRecMCTrackHist->Projection(2,5);\r
-  if(!h2D) return;\r
-  h2D->SetName("ratio_nClust_nFindableClust_vs_eta");\r
-  aFolderObj->Add(h2D);\r
-\r
-  h2D = (TH2D *)fRecMCTrackHist->Projection(5,6);\r
-  if(!h2D) return;\r
-  h2D->SetName("eta_vs_phi");\r
-  aFolderObj->Add(h2D);\r
-\r
-  //\r
-  fRecMCTrackHist->GetAxis(5)->SetRangeUser(minEta,maxEta);  \r
-\r
-  h2D = (TH2D *)fRecMCTrackHist->Projection(0,6);\r
-  if(!h2D) return;\r
-  h2D->SetName("nClust_vs_phi");\r
-  aFolderObj->Add(h2D);\r
-\r
-  h2D = (TH2D *)fRecMCTrackHist->Projection(1,6);\r
-  if(!h2D) return;\r
-  h2D->SetName("chi2PerClust_vs_phi");\r
-  aFolderObj->Add(h2D);\r
-\r
-  h2D = (TH2D *)fRecMCTrackHist->Projection(2,6);\r
-  if(!h2D) return;\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
-  if(!h2D) return;\r
-  h2D->SetName("nClust_vs_pt");\r
-  aFolderObj->Add(h2D);\r
-\r
-  h2D = (TH2D *)fRecMCTrackHist->Projection(1,7);\r
-  if(!h2D) return;\r
-  h2D->SetName("chi2PerClust_vs_pt");\r
-  aFolderObj->Add(h2D);\r
-\r
-  h2D = (TH2D *)fRecMCTrackHist->Projection(2,7);\r
-  if(!h2D) return;\r
-  h2D->SetName("ratio_nClust_nFindableClust_vs_pt");\r
-  aFolderObj->Add(h2D);\r
-\r
-  h2D = (TH2D *)fRecMCTrackHist->Projection(6,7);\r
-  if(!h2D) return;\r
-  h2D->SetName("phi_vs_pt");\r
-  aFolderObj->Add(h2D);\r
-\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(-maxDCAr,maxDCAr);\r
-  fRecMCTrackHist->GetAxis(4)->SetRangeUser(-maxDCAr,maxDCAr);\r
-\r
-  h2D = (TH2D *)fRecMCTrackHist->Projection(0,1);\r
-  if(!h2D) return;\r
-  h2D->SetName("nClust_vs_chi2PerClust");\r
-  aFolderObj->Add(h2D);\r
-\r
-  h2D = (TH2D *)fRecMCTrackHist->Projection(0,2);\r
-  if(!h2D) return;\r
-  h2D->SetName("nClust_vs_ratio_nClust_nFindableClust");\r
-  aFolderObj->Add(h2D);\r
-\r
-  //\r
-  // DCAy cuts\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
-\r
-  // sec\r
-  fRecMCTrackHist->GetAxis(9)->SetRange(1,1);\r
-  h1D = (TH1D *)fRecMCTrackHist->Projection(3);\r
-  if(!h1D) return;\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
-  if(!h1D) return;\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)->SetRange(1,fRecMCTrackHist->GetAxis(4)->GetNbins());\r
-\r
-  // sec\r
-  fRecMCTrackHist->GetAxis(9)->SetRange(1,1);\r
-  h1D = (TH1D *)fRecMCTrackHist->Projection(4);\r
-  if(!h1D) return;\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
-  if(!h1D) return;\r
-  h1D->SetName("dcaz_prim");\r
-  aFolderObj->Add(h1D);\r
-\r
-\r
-  // export objects to analysis folder\r
-  fAnalysisFolder = ExportToFolder(aFolderObj);\r
-  if(!fAnalysisFolder) {\r
-      if(aFolderObj) delete aFolderObj;\r
-      return;\r
-  }\r
-\r
-  // delete only TObjArray\r
-  if(aFolderObj) delete aFolderObj;\r
-}\r
-\r
-//_____________________________________________________________________________\r
-TFolder* AlidNdPtCutAnalysis::ExportToFolder(TObjArray * const 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
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+//------------------------------------------------------------------------------
+// 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 
+//------------------------------------------------------------------------------
+#include "TH1.h"
+#include "TH2.h"
+
+#include "AliHeader.h"  
+#include "AliGenEventHeader.h"  
+#include "AliInputEventHandler.h"  
+#include "AliStack.h"  
+#include "AliESDEvent.h"  
+#include "AliMCEvent.h"  
+#include "AliESDtrackCuts.h"  
+#include "AliLog.h" 
+#include "AliTracker.h" 
+
+#include "AlidNdPtEventCuts.h"
+#include "AlidNdPtAcceptanceCuts.h"
+#include "AlidNdPtBackgroundCuts.h"
+#include "AlidNdPtAnalysis.h"
+#include "AliPhysicsSelection.h"
+
+#include "AliPWG0Helper.h"
+#include "AlidNdPtHelper.h"
+#include "AlidNdPtCutAnalysis.h"
+
+using namespace std;
+
+ClassImp(AlidNdPtCutAnalysis)
+
+//_____________________________________________________________________________
+  AlidNdPtCutAnalysis::AlidNdPtCutAnalysis(): AlidNdPt(),
+  fAnalysisFolder(0),
+  fEventCount(0),
+  fRecEventHist(0),
+  fMCEventHist(0),
+  fRecMCEventHist(0),
+  fRecMCTrackHist(0)
+{
+  // default constructor
+  Init();
+}
+
+//_____________________________________________________________________________
+AlidNdPtCutAnalysis::AlidNdPtCutAnalysis(Char_t* name, Char_t* title): AlidNdPt(name,title),
+  fAnalysisFolder(0),
+  fEventCount(0),
+  fRecEventHist(0),
+  fMCEventHist(0),
+  fRecMCEventHist(0),
+  fRecMCTrackHist(0)
+{
+  // constructor
+  Init();
+}
+
+//_____________________________________________________________________________
+AlidNdPtCutAnalysis::~AlidNdPtCutAnalysis() {
+  // 
+  if(fEventCount) delete fEventCount; fEventCount=0;
+  if(fRecEventHist) delete fRecEventHist; fRecEventHist=0;
+  if(fMCEventHist) delete fMCEventHist; fMCEventHist=0;
+  if(fRecMCEventHist) delete fRecMCEventHist; fRecMCEventHist=0;
+  if(fRecMCTrackHist) delete fRecMCTrackHist; fRecMCTrackHist=0;
+
+  if(fAnalysisFolder) delete fAnalysisFolder; fAnalysisFolder=0;
+}
+
+//_____________________________________________________________________________
+void AlidNdPtCutAnalysis::Init(){
+  //
+  // Init histograms
+  //
+  /*
+  const Int_t ptNbins = 56; 
+  const Double_t ptMin = 0.; 
+  const Double_t ptMax = 16.; 
+  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};
+  */
+  // set pt bins
+  const Int_t ptNbins = 50;
+  const Double_t ptMin = 1.e-2, ptMax = 50.;
+  Double_t *binsPt = CreateLogAxis(ptNbins,ptMin,ptMax);
+
+  // 
+  Int_t binsEventCount[2]={2,2};
+  Double_t minEventCount[2]={0,0}; 
+  Double_t maxEventCount[2]={2,2}; 
+  fEventCount = new THnSparseF("fEventCount","trig vs trig+vertex",2,binsEventCount,minEventCount,maxEventCount);
+  fEventCount->GetAxis(0)->SetTitle("trig");
+  fEventCount->GetAxis(1)->SetTitle("trig+vert");
+  fEventCount->Sumw2();
+
+  //Xv:Yv:Zv:ResZv:Mult
+  Double_t kFact = 1.0;
+
+  Int_t binsRecEventHist[5]={80,80,100,80,150};
+  Double_t minRecEventHist[5]={-3.*kFact,-3.*kFact,-35.,0.,0.}; 
+  Double_t maxRecEventHist[5]={3.*kFact,3.*kFact,35.,10.,150.}; 
+  fRecEventHist = new THnSparseF("fRecEventHist","Xv:Yv:Zv:ResZv:Mult",5,binsRecEventHist,minRecEventHist,maxRecEventHist);
+  fRecEventHist->GetAxis(0)->SetTitle("Xv (cm)");
+  fRecEventHist->GetAxis(1)->SetTitle("Yv (cm)");
+  fRecEventHist->GetAxis(2)->SetTitle("Zv (cm)");
+  fRecEventHist->GetAxis(3)->SetTitle("ResZv (cm)");
+  fRecEventHist->GetAxis(4)->SetTitle("Mult");
+  fRecEventHist->Sumw2();
+
+  //Xv:Yv:Zv
+  Int_t binsMCEventHist[3]={80,80,100};
+  Double_t minMCEventHist[3]={-0.1,-0.1,-35.}; 
+  Double_t maxMCEventHist[3]={0.1,0.1,35.}; 
+  fMCEventHist = new THnSparseF("fMCEventHist","mcXv:mcYv:mcZv",3,binsMCEventHist,minMCEventHist,maxMCEventHist);
+  fMCEventHist->GetAxis(0)->SetTitle("mcXv (cm)");
+  fMCEventHist->GetAxis(1)->SetTitle("mcYv (cm)");
+  fMCEventHist->GetAxis(2)->SetTitle("mcZv (cm)");
+  fMCEventHist->Sumw2();
+
+  //Xv-mcXv:Yv-mcYv:Zv-mcZv:Mult
+  Int_t binsRecMCEventHist[4]={100,100,100,150};
+  Double_t minRecMCEventHist[4]={-1.0*kFact,-1.0*kFact,-1.0*kFact,0.}; 
+  Double_t maxRecMCEventHist[4]={1.0*kFact,1.0*kFact,1.0*kFact,150.}; 
+  fRecMCEventHist = new THnSparseF("fRecMCEventHist","Xv-mcXv:Yv-mcYv:Zv-mcZv:Mult",4,binsRecMCEventHist,minRecMCEventHist,maxRecMCEventHist);
+  fRecMCEventHist->GetAxis(0)->SetTitle("Xv-mcXv (cm)");
+  fRecMCEventHist->GetAxis(1)->SetTitle("Yv-mcYv (cm)");
+  fRecMCEventHist->GetAxis(2)->SetTitle("Zv-mcZv (cm)");
+  fRecMCEventHist->GetAxis(3)->SetTitle("Mult");
+  fRecMCEventHist->Sumw2();
+
+  //
+  // THnSparse track histograms
+  //
+
+ //nCrossRows:chi2PerClust:nCrossRows/nFindableClust:fracSharedClust:DCAy:DCAz:eta:phi:pt:hasStrangeMother:isFromMaterial:isPrim:charge
+  Int_t binsRecMCTrackHist[13]=  { 160,  10,  20,  20, 50,  50,   20,  90,             ptNbins, 2,  2,  2,  3  };
+  Double_t minRecMCTrackHist[13]={ 0.,   0.,  0.,  0., -0.5,-0.5,-1.0, 0.,             ptMin,   0., 0., 0.,-1. };
+  Double_t maxRecMCTrackHist[13]={ 160., 10., 1.,  1., 0.5, 0.5,  1.0, 2.*TMath::Pi(), ptMax,   2., 2., 2., 2. };
+
+  fRecMCTrackHist = new THnSparseF("fRecMCTrackHist","nCrossRows:chi2PerClust:nCrossRows/nFindableClust:fracSharedClust:DCAy:DCAz:eta:phi:pt:hasStrangeMother:isFromMaterial:isPrim:charge",13,binsRecMCTrackHist,minRecMCTrackHist,maxRecMCTrackHist);
+  fRecMCTrackHist->SetBinEdges(8,binsPt);
+  fRecMCTrackHist->GetAxis(0)->SetTitle("nCrossRows");
+  fRecMCTrackHist->GetAxis(1)->SetTitle("chi2PerClust");
+  fRecMCTrackHist->GetAxis(2)->SetTitle("nCrossRows/nFindableClust");
+  fRecMCTrackHist->GetAxis(3)->SetTitle("fracSharedClust");
+  fRecMCTrackHist->GetAxis(4)->SetTitle("DCAy (cm)");
+  fRecMCTrackHist->GetAxis(5)->SetTitle("DCAz (cm)");
+  fRecMCTrackHist->GetAxis(6)->SetTitle("#eta");
+  fRecMCTrackHist->GetAxis(7)->SetTitle("#phi (rad)");
+  fRecMCTrackHist->GetAxis(8)->SetTitle("p_{T} (GeV/c)");
+  fRecMCTrackHist->GetAxis(9)->SetTitle("hasStrangeMother");
+  fRecMCTrackHist->GetAxis(10)->SetTitle("isFromMaterial");
+  fRecMCTrackHist->GetAxis(11)->SetTitle("isPrim");
+  fRecMCTrackHist->GetAxis(12)->SetTitle("charge");
+  fRecMCTrackHist->Sumw2();
+
+  //nClust:chi2PerClust:nClust/nFindableClust:DCAy:DCAz:eta:phi:pt:kinkIdx:isPrim:polarity
+  /*
+  Int_t binsRecMCTrackHist[11]={160,80,80,100,100,90,90,ptNbins, 3, 2, 2};
+  Double_t minRecMCTrackHist[11]={0., 0., 0., -1.,-1.,-1.5, 0., ptMin, -1., 0., 0.};
+  Double_t maxRecMCTrackHist[11]={160.,10.,1.2, 1.,1.,1.5, 2.*TMath::Pi(), ptMax, 2., 2., 2.};
+
+  fRecMCTrackHist = new THnSparseF("fRecMCTrackHist","nClust:chi2PerClust:nClust/nFindableClust:DCAy:DCAz:eta:phi:pt:kinkIdx:isPrim:polarity",11,binsRecMCTrackHist,minRecMCTrackHist,maxRecMCTrackHist);
+  fRecMCTrackHist->SetBinEdges(7,binsPt);
+
+  fRecMCTrackHist->GetAxis(0)->SetTitle("nClust");
+  fRecMCTrackHist->GetAxis(1)->SetTitle("chi2PerClust");
+  fRecMCTrackHist->GetAxis(2)->SetTitle("nClust/nFindableClust");
+  fRecMCTrackHist->GetAxis(3)->SetTitle("DCAy (cm)");
+  fRecMCTrackHist->GetAxis(4)->SetTitle("DCAz (cm)");
+  fRecMCTrackHist->GetAxis(5)->SetTitle("#eta");
+  fRecMCTrackHist->GetAxis(6)->SetTitle("#phi (rad)");
+  fRecMCTrackHist->GetAxis(7)->SetTitle("p_{T} (GeV/c)");
+  fRecMCTrackHist->GetAxis(8)->SetTitle("kinkIdx"); // 0 - no kink, -1 - kink mother, 1 - kink daugther 
+  fRecMCTrackHist->GetAxis(9)->SetTitle("isPrim");
+  fRecMCTrackHist->GetAxis(10)->SetTitle("polarity");
+  fRecMCTrackHist->Sumw2();
+  */
+
+  // init output folder
+  fAnalysisFolder = CreateFolder("folderdNdPt","Analysis dNdPt Folder");
+
+}
+
+//_____________________________________________________________________________
+void AlidNdPtCutAnalysis::Process(AliESDEvent *const esdEvent, AliMCEvent * const mcEvent)
+{
+  //
+  // Process real and/or simulated events
+  //
+  if(!esdEvent) {
+    AliDebug(AliLog::kError, "esdEvent not available");
+    return;
+  }
+
+  // get selection cuts
+  AlidNdPtEventCuts *evtCuts = GetEventCuts(); 
+  AlidNdPtAcceptanceCuts *accCuts = GetAcceptanceCuts(); 
+  AliESDtrackCuts *esdTrackCuts = GetTrackCuts(); 
+
+  if(!evtCuts || !accCuts  || !esdTrackCuts) {
+    AliDebug(AliLog::kError, "cuts not available");
+    return;
+  }
+
+  // trigger selection
+
+  Bool_t isEventTriggered = kTRUE;
+  AliPhysicsSelection *physicsSelection = NULL;
+  AliTriggerAnalysis* triggerAnalysis = NULL;
+
+  // 
+  AliInputEventHandler* inputHandler = (AliInputEventHandler*) AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler();
+  if (!inputHandler)
+  {
+    Printf("ERROR: Could not receive input handler");
+    return;
+  }
+
+  if(evtCuts->IsTriggerRequired())  
+  {
+    // always MB
+    isEventTriggered = inputHandler->IsEventSelected() & AliVEvent::kMB;
+
+    physicsSelection = static_cast<AliPhysicsSelection*> (inputHandler->GetEventSelection());
+    if(!physicsSelection) return;
+    //SetPhysicsTriggerSelection(physicsSelection);
+
+    if (isEventTriggered && (GetTrigger() == AliTriggerAnalysis::kV0AND)) {
+      // set trigger (V0AND)
+      triggerAnalysis = physicsSelection->GetTriggerAnalysis();
+      if(!triggerAnalysis) return;
+      isEventTriggered = triggerAnalysis->IsOfflineTriggerFired(esdEvent, GetTrigger());
+    }
+  }
+
+  // use MC information
+  AliHeader* header = 0;
+  AliGenEventHeader* genHeader = 0;
+  AliStack* stack = 0;
+  TArrayF vtxMC(3);
+  AliPWG0Helper::MCProcessType evtType = AliPWG0Helper::kInvalidProcess;
+
+  if(IsUseMCInfo())
+  {
+    if(!mcEvent) {
+      AliDebug(AliLog::kError, "mcEvent not available");
+      return;
+    }
+
+    // get MC event header
+    header = mcEvent->Header();
+    if (!header) {
+      AliDebug(AliLog::kError, "Header not available");
+      return;
+    }
+
+    // MC particle stack
+    stack = mcEvent->Stack();
+    if (!stack) {
+      AliDebug(AliLog::kError, "Stack not available");
+      return;
+    }
+
+    // get event type (ND=0x1, DD=0x2, SD=0x4)
+    evtType = AliPWG0Helper::GetEventProcessType(header);
+    AliDebug(AliLog::kDebug+1, Form("Found process type %d", evtType));
+
+    // get MC vertex
+    genHeader = header->GenEventHeader();
+    if (!genHeader) {
+      AliDebug(AliLog::kError, "Could not retrieve genHeader from Header");
+      return;
+    }
+    genHeader->PrimaryVertex(vtxMC);
+
+    // Fill MC event histogram
+    Double_t vMCEventHist[3]={vtxMC[0],vtxMC[1],vtxMC[2]};
+    fMCEventHist->Fill(vMCEventHist);
+
+  } // end bUseMC
+
+  // get reconstructed vertex  
+  Bool_t bRedoTPCVertex = evtCuts->IsRedoTPCVertex();
+  Bool_t bUseConstraints = evtCuts->IsUseBeamSpotConstraint();
+  const AliESDVertex* vtxESD = AlidNdPtHelper::GetVertex(esdEvent,evtCuts,accCuts,esdTrackCuts,GetAnalysisMode(),kFALSE,bRedoTPCVertex,bUseConstraints); 
+  Bool_t isRecVertex = AlidNdPtHelper::TestRecVertex(vtxESD, esdEvent->GetPrimaryVertexSPD(), GetAnalysisMode(), kFALSE);
+  Bool_t isEventOK = evtCuts->AcceptEvent(esdEvent,mcEvent,vtxESD) && isRecVertex;
+
+  TObjArray *allChargedTracks=0;
+  Int_t multAll=0;
+  
+  //
+  // event counter
+  // 
+  //printf("isEventOK %d, isEventTriggered %d \n",isEventOK,isEventTriggered);
+
+  Bool_t isTrigAndVertex = isEventTriggered && isEventOK;
+  Double_t vEventCount[2] = { isEventTriggered, isTrigAndVertex};
+  fEventCount->Fill(vEventCount);
+
+  //
+  // cosmic background and splitted tracks
+  //
+  if(GetParticleMode() == AlidNdPtHelper::kBackgroundTrack) 
+  {
+    AlidNdPtBackgroundCuts *backCuts = GetBackgroundCuts(); 
+    if(!backCuts) return;
+
+    for (Int_t iTrack = 0; iTrack < esdEvent->GetNumberOfTracks(); iTrack++) 
+    {
+      AliESDtrack *track1 = esdEvent->GetTrack(iTrack);
+      if(!track1) continue; 
+      if(track1->Charge()==0) continue; 
+
+      for (Int_t jTrack = iTrack+1; jTrack < esdEvent->GetNumberOfTracks(); jTrack++) 
+      {
+        AliESDtrack *track2 = esdEvent->GetTrack(jTrack);
+        if(!track2) continue; 
+        if(track2->Charge()==0) continue; 
+
+       //printf("track2->Charge() %d\n",track2->Charge());
+
+        backCuts->IsBackgroundTrack(track1, track2);
+      }
+    }
+  }
+
+  // check event cuts
+  if(isEventOK && isEventTriggered)
+  {
+    // get all charged tracks
+    allChargedTracks = AlidNdPtHelper::GetAllChargedTracks(esdEvent,GetAnalysisMode());
+    if(!allChargedTracks) return;
+
+    Int_t entries = allChargedTracks->GetEntries();
+    for(Int_t i=0; i<entries;++i) 
+    {
+      AliESDtrack *track = (AliESDtrack*)allChargedTracks->At(i);
+      if(!track) continue;
+
+      if(!esdTrackCuts->AcceptTrack(track)) continue;
+
+      //
+      Bool_t isOK = kFALSE;
+      Double_t x[3]; track->GetXYZ(x);
+      Double_t b[3]; AliTracker::GetBxByBz(x,b);
+
+      //
+      // if TPC-ITS hybrid tracking (kTPCITSHybrid)
+      // replace track parameters with TPC-ony track parameters
+      //
+      if( GetAnalysisMode() == AlidNdPtHelper::kTPCITSHybrid || GetAnalysisMode() == AlidNdPtHelper::kTPCITSHybridTrackSPDvtx || GetAnalysisMode() == AlidNdPtHelper::kTPCITSHybridTrackSPDvtxDCArPt) 
+      {
+        // Relate TPC-only tracks to SPD vertex
+        isOK = track->RelateToVertexTPCBxByBz(vtxESD, b, kVeryBig);
+        if(!isOK) continue;
+
+       // replace esd track parameters with TPCinner
+        AliExternalTrackParam  *tpcTrack  = new AliExternalTrackParam(*(track->GetTPCInnerParam()));
+       if (!tpcTrack) return;
+        track->Set(tpcTrack->GetX(),tpcTrack->GetAlpha(),tpcTrack->GetParameter(),tpcTrack->GetCovariance());
+
+        if(tpcTrack) delete tpcTrack; 
+      } 
+
+      //
+      if (GetAnalysisMode()==AlidNdPtHelper::kTPCSPDvtxUpdate || GetAnalysisMode() == AlidNdPtHelper::kTPCTrackSPDvtxUpdate) 
+      {
+        //
+        // update track parameters
+       //
+        AliExternalTrackParam cParam;
+        isOK = track->RelateToVertexTPCBxByBz(vtxESD, b, kVeryBig, &cParam);
+       if(!isOK) continue;
+
+       track->Set(cParam.GetX(),cParam.GetAlpha(),cParam.GetParameter(),cParam.GetCovariance());
+      }
+
+      FillHistograms(track, stack);
+      multAll++;
+    }
+
+    Double_t vRecEventHist[5] = {vtxESD->GetXv(),vtxESD->GetYv(),vtxESD->GetZv(),vtxESD->GetZRes(),multAll};
+    fRecEventHist->Fill(vRecEventHist);
+
+    if(IsUseMCInfo()) {
+      Double_t vRecMCEventHist[5] = {vtxESD->GetXv()-vtxMC[0],vtxESD->GetYv()-vtxMC[1],vtxESD->GetZv()-vtxMC[2],multAll};
+      fRecMCEventHist->Fill(vRecMCEventHist);
+    }
+  }
+
+  if(allChargedTracks) delete allChargedTracks; allChargedTracks = 0;
+
+}
+
+//_____________________________________________________________________________
+void AlidNdPtCutAnalysis::FillHistograms(AliESDtrack *const esdTrack, AliStack *const stack) const
+{
+  //
+  // Fill ESD track and MC histograms 
+  //
+  if(!esdTrack) return;
+  if(esdTrack->Charge() == 0.) return;
+
+  Float_t pt = esdTrack->Pt();
+  Float_t eta = esdTrack->Eta();
+  Float_t phi = esdTrack->Phi();
+
+
+  Int_t nClust = 0;
+  if(GetAnalysisMode() == AlidNdPtHelper::kTPC) { 
+    nClust = esdTrack->GetTPCNclsIter1();
+  } else {
+    nClust = esdTrack->GetTPCclusters(0);
+  }
+
+  Float_t chi2PerCluster = 0.;
+  if(GetAnalysisMode() == AlidNdPtHelper::kTPC) { 
+    if(nClust>0.) chi2PerCluster = esdTrack->GetTPCchi2Iter1()/Float_t(nClust);
+  } else {
+    chi2PerCluster = esdTrack->GetTPCchi2()/Float_t(nClust);
+  }
+
+  Int_t nFindableClust = esdTrack->GetTPCNclsF();
+
+  
+  Float_t clustPerFindClust = 0.;
+  if(nFindableClust>0.) clustPerFindClust = Float_t(nClust)/nFindableClust;
+
+  Float_t b[2], bCov[3];
+  esdTrack->GetImpactParameters(b,bCov);
+
+  // 
+  Float_t nCrossedRowsTPC = esdTrack->GetTPCClusterInfo(2,1);
+
+  Float_t  ratioCrossedRowsOverFindableClustersTPC = 1.0;
+  if (esdTrack->GetTPCNclsF()>0) {
+     ratioCrossedRowsOverFindableClustersTPC = esdTrack->GetTPCClusterInfo(2,1)/esdTrack->GetTPCNclsF();
+  }
+
+  //
+  Int_t nClustersTPCShared = esdTrack->GetTPCnclsS();
+  Float_t fracClustersTPCShared = -1.;
+  fracClustersTPCShared = Float_t(nClustersTPCShared)/Float_t(nClust);
+
+
+  // kink idx
+  Int_t kinkIdx = 0;
+  //if(esdTrack->GetKinkIndex(0) > 0.)   isKink  = kTRUE;
+  if(esdTrack->GetKinkIndex(0) > 0)      kinkIdx = 1;   // kink daughter
+  else if(esdTrack->GetKinkIndex(0) < 0) kinkIdx = -1;  // kink mother
+  else kinkIdx = 0; // not kink
+
+  //printf("esdTrack->GetKinkIndex(0) %d \n", esdTrack->GetKinkIndex(0));
+  //printf("esdTrack->GetKinkIndex(1) %d \n", esdTrack->GetKinkIndex(1));
+  //printf("esdTrack->GetKinkIndex(2) %d \n", esdTrack->GetKinkIndex(2));
+  //printf("kinkIdx %d \n", kinkIdx);
+
+  //
+  // Fill rec vs MC information
+  //
+  Bool_t isPrim = kTRUE;
+  Bool_t hasStrangeMother = kFALSE;
+  Bool_t isFromMaterial = kFALSE;
+
+  if(IsUseMCInfo()) {
+    if(!stack) return;
+    Int_t label = TMath::Abs(esdTrack->GetLabel()); 
+    TParticle* particle = stack->Particle(label);
+    if(!particle) return;
+    if(particle->GetPDG() && particle->GetPDG()->Charge()==0.) return;
+    isPrim = stack->IsPhysicalPrimary(label);
+
+    // check whether has stange mother
+    //
+    Int_t motherPdg = -1; 
+    TParticle* mother = 0; 
+       
+    Int_t motherLabel = particle->GetMother(0);  
+    if(motherLabel>0) mother = stack->Particle(motherLabel); 
+    if(mother) motherPdg = TMath::Abs(mother->GetPdgCode()); // take abs for visualisation only 
+    Int_t mech = particle->GetUniqueID(); // production mechanism 
+
+    if( (motherPdg == 3122) || (motherPdg == -3122) || (motherPdg == 310)) // lambda, antilambda, k0s
+    {
+      if( (mech == 4) || (mech == 5) ) hasStrangeMother = kTRUE;
+    } 
+    else {
+      //if(isPrim==0 && mech == 13)   
+      //printf("mech %d \n", mech);
+      if(!isPrim) isFromMaterial = kTRUE; 
+    }
+
+    //if(isPrim && pt > 1.5 && kinkIdx == -1) printf("nClust  %d \n", nClust);
+  }
+  
+  // fill histo
+  Int_t charge = esdTrack->Charge(); 
+
+  //Double_t vRecMCTrackHist[11] = { nClust,chi2PerCluster,clustPerFindClust,b[0],b[1],eta,phi,pt,kinkIdx,isPrim, polarity }; 
+  //fRecMCTrackHist->Fill(vRecMCTrackHist);
+
+  Double_t vRecMCTrackHist[13] = { nCrossedRowsTPC, chi2PerCluster, ratioCrossedRowsOverFindableClustersTPC, fracClustersTPCShared , b[0], b[1], eta, phi, pt, hasStrangeMother, isFromMaterial, isPrim, charge }; 
+  fRecMCTrackHist->Fill(vRecMCTrackHist);
+
+}
+
+//_____________________________________________________________________________
+Long64_t AlidNdPtCutAnalysis::Merge(TCollection* const list) 
+{
+  // Merge list of objects (needed by PROOF)
+
+  if (!list)
+  return 0;
+
+  if (list->IsEmpty())
+  return 1;
+
+  TIterator* iter = list->MakeIterator();
+  TObject* obj = 0;
+
+  //TList *collPhysSelection = new TList;
+
+  // collection of generated histograms
+  Int_t count=0;
+  while((obj = iter->Next()) != 0) {
+    AlidNdPtCutAnalysis* entry = dynamic_cast<AlidNdPtCutAnalysis*>(obj);
+    if (entry == 0) continue; 
+  
+    // event histo
+    fEventCount->Add(entry->fEventCount);
+    fRecEventHist->Add(entry->fRecEventHist);
+    fRecMCEventHist->Add(entry->fRecMCEventHist);
+    fMCEventHist->Add(entry->fMCEventHist);
+
+    // track histo
+    fRecMCTrackHist->Add(entry->fRecMCTrackHist);
+
+    // physics selection
+    //collPhysSelection->Add(entry->GetPhysicsTriggerSelection());
+    
+  count++;
+  }
+
+  //AliPhysicsSelection *trigSelection = GetPhysicsTriggerSelection();
+  //trigSelection->Merge(collPhysSelection);
+
+  //if(collPhysSelection) delete collPhysSelection;
+
+return count;
+}
+
+//_____________________________________________________________________________
+void AlidNdPtCutAnalysis::Analyse() 
+{
+  //
+  // Analyse histograms
+  //
+  TH1::AddDirectory(kFALSE);
+  TObjArray *aFolderObj = new TObjArray;
+  if(!aFolderObj) return;
+
+  TH1D *h1D = 0; 
+  TH2D *h2D = 0; 
+
+
+  //
+  // get cuts
+  //
+  AlidNdPtEventCuts *evtCuts = GetEventCuts(); 
+  AlidNdPtAcceptanceCuts *accCuts = GetAcceptanceCuts(); 
+  AliESDtrackCuts *esdTrackCuts = GetTrackCuts(); 
+
+  if(!evtCuts || !accCuts || !esdTrackCuts) {
+    Error("AlidNdPtCutAnalysis::Analyse()", "cuts not available");
+    return;
+  }
+
+  //
+  // set min and max values
+  //
+  Double_t minPt = accCuts->GetMinPt();
+  Double_t maxPt = accCuts->GetMaxPt();
+  Double_t minEta = accCuts->GetMinEta();
+  Double_t maxEta = accCuts->GetMaxEta()-0.00001;
+
+  Double_t maxDCAr = accCuts->GetMaxDCAr();
+
+  //
+  // Event counters
+  //
+  h2D = (TH2D*)fEventCount->Projection(0,1);
+  if(!h2D) return;
+  h2D->SetName("trig_vs_trigANDvertex");
+  aFolderObj->Add(h2D);
+
+  fEventCount->GetAxis(0)->SetRange(2,2); // triggered
+  h1D = (TH1D*)fEventCount->Projection(1);
+  if(!h1D) return;
+  h1D->SetTitle("rec. vertex for triggered events");
+  h1D->SetName("trigANDvertex");
+  aFolderObj->Add(h1D);
+
+  //
+  // Create rec. event histograms
+  //
+  h1D = (TH1D *)fRecEventHist->Projection(0);
+  if(!h1D) return;
+  h1D->SetName("rec_xv");
+  aFolderObj->Add(h1D);
+
+  h1D = (TH1D *)fRecEventHist->Projection(1);
+  if(!h1D) return;
+  h1D->SetName("rec_yv");
+  aFolderObj->Add(h1D);
+
+  h1D = (TH1D *)fRecEventHist->Projection(2);
+  if(!h1D) return;
+  h1D->SetName("rec_zv");
+  aFolderObj->Add(h1D);
+
+  h2D = (TH2D *)fRecEventHist->Projection(3,4);
+  if(!h2D) return;
+  h2D->SetName("rec_resZv_vs_Mult");
+  aFolderObj->Add(h2D);
+
+  h2D = (TH2D *)fRecEventHist->Projection(0,1);
+  if(!h2D) return;
+  h2D->SetName("rec_xv_vs_yv");
+  aFolderObj->Add(h2D);
+
+  h2D = (TH2D *)fRecEventHist->Projection(0,2);
+  if(!h2D) return;
+  h2D->SetName("rec_xv_vs_zv");
+  aFolderObj->Add(h2D);
+
+  h2D = (TH2D *)fRecEventHist->Projection(3,4);
+  if(!h2D) return;
+  h2D->SetName("rec_resZv_vs_Mult");
+  aFolderObj->Add(h2D);
+
+  //
+  // MC available
+  //
+  if(IsUseMCInfo()) {
+
+  //
+  // Create mc event histograms
+  //
+  h2D = (TH2D *)fMCEventHist->Projection(0,1);
+  if(!h2D) return;
+  h2D->SetName("mc_xv_vs_yv");
+  aFolderObj->Add(h2D);
+
+  h2D = (TH2D *)fMCEventHist->Projection(0,2);
+  if(!h2D) return;
+  h2D->SetName("mc_xv_vs_zv");
+  aFolderObj->Add(h2D);
+
+  //
+  // Create rec-mc event histograms
+  //
+  h2D = (TH2D *)fRecMCEventHist->Projection(0,3);
+  if(!h2D) return;
+  h2D->SetName("rec_mc_deltaXv_vs_mult");
+  aFolderObj->Add(h2D);
+
+  h2D = (TH2D *)fRecMCEventHist->Projection(1,3);
+  if(!h2D) return;
+  h2D->SetName("rec_mc_deltaYv_vs_mult");
+  aFolderObj->Add(h2D);
+
+  h2D = (TH2D *)fRecMCEventHist->Projection(2,3);
+  if(!h2D) return;
+  h2D->SetName("rec_mc_deltaZv_vs_mult");
+  aFolderObj->Add(h2D);
+
+  } // end use MC info 
+
+
+
+  //
+  // Create rec-mc track track histograms 
+  //
+
+  // DCA cuts
+  fRecMCTrackHist->GetAxis(3)->SetRangeUser(-maxDCAr,maxDCAr);
+  fRecMCTrackHist->GetAxis(4)->SetRangeUser(-maxDCAr,maxDCAr);
+
+  h2D = (TH2D *)fRecMCTrackHist->Projection(7,5);
+  if(!h2D) return;
+  h2D->SetName("pt_vs_eta");
+  aFolderObj->Add(h2D);
+
+  fRecMCTrackHist->GetAxis(7)->SetRangeUser(minPt,maxPt);  
+
+  h2D = (TH2D *)fRecMCTrackHist->Projection(0,5);
+  if(!h2D) return;
+  h2D->SetName("nClust_vs_eta");
+  aFolderObj->Add(h2D);
+
+  h2D = (TH2D *)fRecMCTrackHist->Projection(1,5);
+  if(!h2D) return;
+  h2D->SetName("chi2PerClust_vs_eta");
+  aFolderObj->Add(h2D);
+
+  h2D = (TH2D *)fRecMCTrackHist->Projection(2,5);
+  if(!h2D) return;
+  h2D->SetName("ratio_nClust_nFindableClust_vs_eta");
+  aFolderObj->Add(h2D);
+
+  h2D = (TH2D *)fRecMCTrackHist->Projection(5,6);
+  if(!h2D) return;
+  h2D->SetName("eta_vs_phi");
+  aFolderObj->Add(h2D);
+
+  //
+  fRecMCTrackHist->GetAxis(5)->SetRangeUser(minEta,maxEta);  
+
+  h2D = (TH2D *)fRecMCTrackHist->Projection(0,6);
+  if(!h2D) return;
+  h2D->SetName("nClust_vs_phi");
+  aFolderObj->Add(h2D);
+
+  h2D = (TH2D *)fRecMCTrackHist->Projection(1,6);
+  if(!h2D) return;
+  h2D->SetName("chi2PerClust_vs_phi");
+  aFolderObj->Add(h2D);
+
+  h2D = (TH2D *)fRecMCTrackHist->Projection(2,6);
+  if(!h2D) return;
+  h2D->SetName("ratio_nClust_nFindableClust_vs_phi");
+  aFolderObj->Add(h2D);
+
+  //
+  fRecMCTrackHist->GetAxis(7)->SetRangeUser(0.0,maxPt);  
+
+  h2D = (TH2D *)fRecMCTrackHist->Projection(0,7);
+  if(!h2D) return;
+  h2D->SetName("nClust_vs_pt");
+  aFolderObj->Add(h2D);
+
+  h2D = (TH2D *)fRecMCTrackHist->Projection(1,7);
+  if(!h2D) return;
+  h2D->SetName("chi2PerClust_vs_pt");
+  aFolderObj->Add(h2D);
+
+  h2D = (TH2D *)fRecMCTrackHist->Projection(2,7);
+  if(!h2D) return;
+  h2D->SetName("ratio_nClust_nFindableClust_vs_pt");
+  aFolderObj->Add(h2D);
+
+  h2D = (TH2D *)fRecMCTrackHist->Projection(6,7);
+  if(!h2D) return;
+  h2D->SetName("phi_vs_pt");
+  aFolderObj->Add(h2D);
+
+
+  // fiducial volume
+  fRecMCTrackHist->GetAxis(5)->SetRangeUser(minEta,maxEta);  
+  fRecMCTrackHist->GetAxis(7)->SetRangeUser(minPt,maxPt);  
+
+  // DCA cuts
+  fRecMCTrackHist->GetAxis(3)->SetRangeUser(-maxDCAr,maxDCAr);
+  fRecMCTrackHist->GetAxis(4)->SetRangeUser(-maxDCAr,maxDCAr);
+
+  h2D = (TH2D *)fRecMCTrackHist->Projection(0,1);
+  if(!h2D) return;
+  h2D->SetName("nClust_vs_chi2PerClust");
+  aFolderObj->Add(h2D);
+
+  h2D = (TH2D *)fRecMCTrackHist->Projection(0,2);
+  if(!h2D) return;
+  h2D->SetName("nClust_vs_ratio_nClust_nFindableClust");
+  aFolderObj->Add(h2D);
+
+  //
+  // DCAy cuts
+  //
+  fRecMCTrackHist->GetAxis(0)->SetRange(50,160); // nClust/track > 50
+  fRecMCTrackHist->GetAxis(1)->SetRangeUser(0.,3.9999); // chi2/cluster < 4.0
+  fRecMCTrackHist->GetAxis(3)->SetRange(1,fRecMCTrackHist->GetAxis(3)->GetNbins());
+  //fRecMCTrackHist->GetAxis(4)->SetRangeUser(-1.0,1.0);
+  fRecMCTrackHist->GetAxis(4)->SetRange(1,fRecMCTrackHist->GetAxis(4)->GetNbins());
+
+  // sec
+  fRecMCTrackHist->GetAxis(9)->SetRange(1,1);
+  h1D = (TH1D *)fRecMCTrackHist->Projection(3);
+  if(!h1D) return;
+  h1D->SetName("dcay_sec");
+  aFolderObj->Add(h1D);
+
+  // prim
+  fRecMCTrackHist->GetAxis(9)->SetRange(2,2);
+  h1D = (TH1D *)fRecMCTrackHist->Projection(3);
+  if(!h1D) return;
+  h1D->SetName("dcay_prim");
+  aFolderObj->Add(h1D);
+
+  // DCAz cuts
+  //fRecMCTrackHist->GetAxis(3)->SetRangeUser(-1.0,1.0);
+  fRecMCTrackHist->GetAxis(4)->SetRange(1,fRecMCTrackHist->GetAxis(4)->GetNbins());
+
+  // sec
+  fRecMCTrackHist->GetAxis(9)->SetRange(1,1);
+  h1D = (TH1D *)fRecMCTrackHist->Projection(4);
+  if(!h1D) return;
+  h1D->SetName("dcaz_sec");
+  aFolderObj->Add(h1D);
+
+  // prim
+  fRecMCTrackHist->GetAxis(9)->SetRange(2,2);
+  h1D = (TH1D *)fRecMCTrackHist->Projection(4);
+  if(!h1D) return;
+  h1D->SetName("dcaz_prim");
+  aFolderObj->Add(h1D);
+
+
+  // export objects to analysis folder
+  fAnalysisFolder = ExportToFolder(aFolderObj);
+  if(!fAnalysisFolder) {
+      if(aFolderObj) delete aFolderObj;
+      return;
+  }
+
+  // delete only TObjArray
+  if(aFolderObj) delete aFolderObj;
+}
+
+//_____________________________________________________________________________
+TFolder* AlidNdPtCutAnalysis::ExportToFolder(TObjArray * const array) 
+{
+  // recreate folder avery time and export objects to new one
+  //
+  AlidNdPtCutAnalysis * comp=this;
+  TFolder *folder = comp->GetAnalysisFolder();
+
+  TString name, title;
+  TFolder *newFolder = 0;
+  Int_t i = 0;
+  Int_t size = array->GetSize();
+
+  if(folder) { 
+     // get name and title from old folder
+     name = folder->GetName();  
+     title = folder->GetTitle();  
+
+        // delete old one
+     delete folder;
+
+        // create new one
+     newFolder = CreateFolder(name.Data(),title.Data());
+     newFolder->SetOwner();
+
+        // add objects to folder
+     while(i < size) {
+          newFolder->Add(array->At(i));
+          i++;
+        }
+  }
+
+return newFolder;
+}
+
+//_____________________________________________________________________________
+TFolder* AlidNdPtCutAnalysis::CreateFolder(TString name,TString title) { 
+// create folder for analysed histograms
+//
+TFolder *folder = 0;
+  folder = new TFolder(name.Data(),title.Data());
+
+  return folder;
+}