cut analysis for PbPb
authorjotwinow <jotwinow@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 11 Nov 2010 17:42:42 +0000 (17:42 +0000)
committerjotwinow <jotwinow@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 11 Nov 2010 17:42:42 +0000 (17:42 +0000)
PWG0/dNdPt/AlidNdPtCutAnalysisPbPb.cxx [new file with mode: 0644]
PWG0/dNdPt/AlidNdPtCutAnalysisPbPb.h [new file with mode: 0644]

diff --git a/PWG0/dNdPt/AlidNdPtCutAnalysisPbPb.cxx b/PWG0/dNdPt/AlidNdPtCutAnalysisPbPb.cxx
new file mode 100644 (file)
index 0000000..4521028
--- /dev/null
@@ -0,0 +1,727 @@
+/**************************************************************************\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
+// AlidNdPtCutAnalysisPbPb 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 "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 "AlidNdPtCutAnalysisPbPb.h"\r
+\r
+using namespace std;\r
+\r
+ClassImp(AlidNdPtCutAnalysisPbPb)\r
+\r
+//_____________________________________________________________________________\r
+  AlidNdPtCutAnalysisPbPb::AlidNdPtCutAnalysisPbPb(): 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
+AlidNdPtCutAnalysisPbPb::AlidNdPtCutAnalysisPbPb(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
+AlidNdPtCutAnalysisPbPb::~AlidNdPtCutAnalysisPbPb() {\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 AlidNdPtCutAnalysisPbPb::Init(){\r
+  //\r
+  // Init histograms\r
+  //\r
+  const Int_t ptNbins = 56; \r
+  const Double_t ptMin = 0.; \r
+  const Double_t ptMax = 16.; \r
+\r
+  Double_t binsPt[ptNbins+1] = {0.,0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.2,2.4,2.6,2.8,3.0,3.2,3.4,3.6,3.8,4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0};\r
+\r
+  // \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
+  //nClust:chi2PerClust:nClust/nFindableClust:DCAy:DCAz:eta:phi:pt:kinkIdx:isPrim:polarity\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
+  // init output folder\r
+  fAnalysisFolder = CreateFolder("folderdNdPt","Analysis dNdPt Folder");\r
+\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AlidNdPtCutAnalysisPbPb::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
+  Bool_t isEventTriggered = kTRUE;\r
+  AliPhysicsSelection *trigSel = NULL;\r
+  AliTriggerAnalysis *trigAna = NULL; // needed for andV0\r
+\r
+  if(evtCuts->IsTriggerRequired())  \r
+  {\r
+    //\r
+    trigSel = GetPhysicsTriggerSelection();\r
+    if(!trigSel) {\r
+      printf("cannot get trigSel \n");\r
+      return;\r
+    }\r
+\r
+    //\r
+    if(IsUseMCInfo()) \r
+    { \r
+      trigSel->SetAnalyzeMC();\r
+\r
+      \r
+        isEventTriggered = trigSel->IsCollisionCandidate(esdEvent);\r
+       \r
+        if(GetTrigger() == AliTriggerAnalysis::kV0AND) \r
+       {\r
+          trigAna = trigSel->GetTriggerAnalysis();\r
+          if(!trigAna) \r
+            return;\r
+\r
+          isEventTriggered = trigAna->IsOfflineTriggerFired(esdEvent, GetTrigger());\r
+        }//if(GetTrigger() == AliTriggerAnalysis::kV0AND)\r
+     }//if(IsUseMCInfo())\r
+  }//if(evtCuts->IsTriggerRequired())\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
+    Double_t vMCEventHist[3]={vtxMC[0],vtxMC[1],vtxMC[2]};\r
+    fMCEventHist->Fill(vMCEventHist);\r
+\r
+    // multipliticy of all MC primary tracks\r
+    // in Zv, pt and eta ranges)\r
+    multMCTrueTracks = AlidNdPtHelper::GetMCTrueTrackMult(mcEvent,evtCuts,accCuts);\r
+\r
+  } // end bUseMC\r
+\r
+  // get reconstructed vertex  \r
+  const AliESDVertex* vtxESD = 0; \r
+  Bool_t isRecVertex = kTRUE;\r
+  if(evtCuts->IsRecVertexRequired()) \r
+  {\r
+//    Bool_t bRedoTPCVertex = evtCuts->IsRedoTPCVertex();\r
+    //Bool_t bUseConstraints = evtCuts->IsUseBeamSpotConstraint();\r
+    //vtxESD = AlidNdPtHelper::GetVertex(esdEvent,evtCuts,accCuts,esdTrackCuts,GetAnalysisMode(),kFALSE,bRedoTPCVertex,bUseConstraints); \r
+    //isRecVertex = AlidNdPtHelper::TestRecVertex(vtxESD, esdEvent->GetPrimaryVertexSPD(), GetAnalysisMode(), kFALSE);\r
+    if(GetAnalysisMode() == AlidNdPtHelper::kTPC) {\r
+      vtxESD = esdEvent->GetPrimaryVertexTPC();\r
+      //isRecVertex = AlidNdPtHelper::TestRecVertex(vtxESD, esdEvent->GetPrimaryVertexSPD(), GetAnalysisMode(), kFALSE);\r
+    }\r
+  }\r
+\r
+  Bool_t isEventOK = evtCuts->AcceptEvent(esdEvent,mcEvent,vtxESD) && isRecVertex; \r
+  //printf("isEventOK %d, isEventTriggered %d \n",isEventOK, isEventTriggered);\r
+  //printf("GetAnalysisMode() %d \n",GetAnalysisMode());\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
+  // 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
+      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 AlidNdPtCutAnalysisPbPb::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
+  //Int_t nClust = esdTrack->GetTPCclusters(0);\r
+  Int_t nClust = esdTrack->GetTPCNclsIter1();\r
+  Int_t nFindableClust = esdTrack->GetTPCNclsF();\r
+\r
+  Float_t chi2PerCluster = 0.;\r
+  //if(nClust>0.) chi2PerCluster = esdTrack->GetTPCchi2()/Float_t(nClust);\r
+  if(nClust>0.) chi2PerCluster = esdTrack->GetTPCchi2Iter1()/Float_t(nClust);\r
+\r
+  Float_t clustPerFindClust = 0.;\r
+  if(nFindableClust>0.) clustPerFindClust = Float_t(nClust)/nFindableClust;\r
+\r
+  Float_t b[2], bCov[3];\r
+  esdTrack->GetImpactParameters(b,bCov);\r
+\r
+  // kink 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
+\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
+    //if(isPrim && pt > 1.5 && kinkIdx == -1) printf("nClust  %d \n", nClust);\r
+  }\r
+  \r
+  // fill histo\r
+  Int_t polarity = -2;\r
+  if (esdTrack->Charge() < 0.) polarity = 0; \r
+  else polarity = 1; \r
+  Double_t vRecMCTrackHist[11] = { nClust,chi2PerCluster,clustPerFindClust,b[0],b[1],eta,phi,pt,kinkIdx,isPrim, polarity }; \r
+  fRecMCTrackHist->Fill(vRecMCTrackHist);\r
+}\r
+\r
+//_____________________________________________________________________________\r
+Long64_t AlidNdPtCutAnalysisPbPb::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
+    AlidNdPtCutAnalysisPbPb* entry = dynamic_cast<AlidNdPtCutAnalysisPbPb*>(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 AlidNdPtCutAnalysisPbPb::Analyse() \r
+{\r
+  //\r
+  // Analyse histograms\r
+  //\r
+  TH1::AddDirectory(kFALSE);\r
+  TObjArray *aFolderObj = new TObjArray;\r
+  TH1D *h1D = 0; \r
+  TH2D *h2D = 0; \r
+\r
+\r
+  //\r
+  // get cuts\r
+  //\r
+  AlidNdPtEventCuts *evtCuts = GetEventCuts(); \r
+  AlidNdPtAcceptanceCuts *accCuts = GetAcceptanceCuts(); \r
+  AliESDtrackCuts *esdTrackCuts = GetTrackCuts(); \r
+\r
+  if(!evtCuts || !accCuts || !esdTrackCuts) {\r
+    Error("AlidNdPtCutAnalysisPbPb::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
+  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
+  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
+  h1D->SetName("rec_xv");\r
+  aFolderObj->Add(h1D);\r
+\r
+  h1D = (TH1D *)fRecEventHist->Projection(1);\r
+  h1D->SetName("rec_yv");\r
+  aFolderObj->Add(h1D);\r
+\r
+  h1D = (TH1D *)fRecEventHist->Projection(2);\r
+  h1D->SetName("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
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fRecEventHist->Projection(0,2);\r
+  h2D->SetName("rec_xv_vs_zv");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fRecEventHist->Projection(3,4);\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
+  h2D->SetName("mc_xv_vs_yv");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fMCEventHist->Projection(0,2);\r
+  h2D->SetName("mc_xv_vs_zv");\r
+  aFolderObj->Add(h2D);\r
+\r
+  //\r
+  // Create rec-mc event histograms\r
+  //\r
+  h2D = (TH2D *)fRecMCEventHist->Projection(0,3);\r
+  h2D->SetName("rec_mc_deltaXv_vs_mult");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fRecMCEventHist->Projection(1,3);\r
+  h2D->SetName("rec_mc_deltaYv_vs_mult");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fRecMCEventHist->Projection(2,3);\r
+  h2D->SetName("rec_mc_deltaZv_vs_mult");\r
+  aFolderObj->Add(h2D);\r
+\r
+  } // 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
+  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
+  h2D->SetName("nClust_vs_eta");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fRecMCTrackHist->Projection(1,5);\r
+  h2D->SetName("chi2PerClust_vs_eta");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fRecMCTrackHist->Projection(2,5);\r
+  h2D->SetName("ratio_nClust_nFindableClust_vs_eta");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fRecMCTrackHist->Projection(5,6);\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
+  h2D->SetName("nClust_vs_phi");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fRecMCTrackHist->Projection(1,6);\r
+  h2D->SetName("chi2PerClust_vs_phi");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fRecMCTrackHist->Projection(2,6);\r
+  h2D->SetName("ratio_nClust_nFindableClust_vs_phi");\r
+  aFolderObj->Add(h2D);\r
+\r
+  //\r
+  fRecMCTrackHist->GetAxis(7)->SetRangeUser(0.0,maxPt);  \r
+\r
+  h2D = (TH2D *)fRecMCTrackHist->Projection(0,7);\r
+  h2D->SetName("nClust_vs_pt");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fRecMCTrackHist->Projection(1,7);\r
+  h2D->SetName("chi2PerClust_vs_pt");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fRecMCTrackHist->Projection(2,7);\r
+  h2D->SetName("ratio_nClust_nFindableClust_vs_pt");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fRecMCTrackHist->Projection(6,7);\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
+  h2D->SetName("nClust_vs_chi2PerClust");\r
+  aFolderObj->Add(h2D);\r
+\r
+  h2D = (TH2D *)fRecMCTrackHist->Projection(0,2);\r
+  h2D->SetName("nClust_vs_ratio_nClust_nFindableClust");\r
+  aFolderObj->Add(h2D);\r
+\r
+  //\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
+  h1D->SetName("dcay_sec");\r
+  aFolderObj->Add(h1D);\r
+\r
+  // prim\r
+  fRecMCTrackHist->GetAxis(9)->SetRange(2,2);\r
+  h1D = (TH1D *)fRecMCTrackHist->Projection(3);\r
+  h1D->SetName("dcay_prim");\r
+  aFolderObj->Add(h1D);\r
+\r
+  // DCAz cuts\r
+  //fRecMCTrackHist->GetAxis(3)->SetRangeUser(-1.0,1.0);\r
+  fRecMCTrackHist->GetAxis(4)->SetRange(1,fRecMCTrackHist->GetAxis(4)->GetNbins());\r
+\r
+  // sec\r
+  fRecMCTrackHist->GetAxis(9)->SetRange(1,1);\r
+  h1D = (TH1D *)fRecMCTrackHist->Projection(4);\r
+  h1D->SetName("dcaz_sec");\r
+  aFolderObj->Add(h1D);\r
+\r
+  // prim\r
+  fRecMCTrackHist->GetAxis(9)->SetRange(2,2);\r
+  h1D = (TH1D *)fRecMCTrackHist->Projection(4);\r
+  h1D->SetName("dcaz_prim");\r
+  aFolderObj->Add(h1D);\r
+\r
+\r
+  // export objects to analysis folder\r
+  fAnalysisFolder = ExportToFolder(aFolderObj);\r
+\r
+  // delete only TObjArray\r
+  if(aFolderObj) delete aFolderObj;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+TFolder* AlidNdPtCutAnalysisPbPb::ExportToFolder(TObjArray * const array) \r
+{\r
+  // recreate folder avery time and export objects to new one\r
+  //\r
+  AlidNdPtCutAnalysisPbPb * 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* AlidNdPtCutAnalysisPbPb::CreateFolder(TString name,TString title) { \r
+// create folder for analysed histograms\r
+//\r
+TFolder *folder = 0;\r
+  folder = new TFolder(name.Data(),title.Data());\r
+\r
+  return folder;\r
+}\r
diff --git a/PWG0/dNdPt/AlidNdPtCutAnalysisPbPb.h b/PWG0/dNdPt/AlidNdPtCutAnalysisPbPb.h
new file mode 100644 (file)
index 0000000..9e3506f
--- /dev/null
@@ -0,0 +1,92 @@
+#ifndef ALIDNDPTCUTANALYSISPBPB_H
+#define ALIDNDPTCUTANALYSISPBPB_H
+
+//------------------------------------------------------------------------------
+// AlidNdPtCutAnalysisPbPb class to determine 
+// cuts to be used for dNdPt analysis. 
+//
+// Author: J.Otwinowski 12/11/2010 
+//------------------------------------------------------------------------------
+
+class iostream;
+class TFile;
+class TCint;
+class TProfile;
+class TFolder;
+class TObjArray;
+class TString;
+class THnSparse;
+
+class AliESDtrackCuts;
+class AliVertexerTracks;
+class AliESD;
+class AliESDfriend;
+class AliESDfriendTrack;
+
+#include "AlidNdPt.h"
+
+class AlidNdPtCutAnalysisPbPb : public AlidNdPt {
+public :
+  AlidNdPtCutAnalysisPbPb(); 
+  AlidNdPtCutAnalysisPbPb(Char_t* name, Char_t* title);
+  ~AlidNdPtCutAnalysisPbPb();
+
+  // Init data members
+  virtual void Init();
+
+  // Process events
+  virtual void Process(AliESDEvent *const esdEvent=0, AliMCEvent *const mcEvent=0);
+
+  // Merge output objects (needed by PROOF) 
+  virtual Long64_t Merge(TCollection* const list);
+
+  // Analyse output histograms 
+  virtual void Analyse();
+
+  // Export objects to folder
+  virtual TFolder *ExportToFolder(TObjArray * const array=0);
+
+  // Get analysis folder
+  TFolder* GetAnalysisFolder() const {return fAnalysisFolder;}
+
+  // Create folder for analysed histograms
+  TFolder *CreateFolder(TString folder = "folderdNdPtAnalysis",TString title = "Analysed dNdPt histograms");
+
+  // Fill histograms
+  void FillHistograms(AliESDtrack *const esdTrack, AliStack *const stack) const;
+
+  // Getters
+  THnSparseF *GetEventCount()   const {return fEventCount;}
+  THnSparseF *GetRecEventHist() const   {return fRecEventHist;}
+  THnSparseF *GetMCEventHist()  const   {return fMCEventHist;}
+  THnSparseF *GetRecMCEventHist() const {return fRecMCEventHist;}
+
+  //
+  THnSparseF *GetRecMCTrackHist() const {return fRecMCTrackHist;}
+  
+private:
+
+  // analysis folder 
+  TFolder *fAnalysisFolder; // folder for analysed histograms
+
+  //
+  // THnSparse event histograms
+  //
+  THnSparseF *fEventCount; //-> trig, trig + vertex
+
+  THnSparseF *fRecEventHist;   //-> Xv:Yv:Zv:ResZv:Mult
+  THnSparseF *fMCEventHist;    //-> mcXv:mcYv:mcZv
+  THnSparseF *fRecMCEventHist; //-> Xv-mcXv:Yv-mcYv:Zv-mcZv:Mult
+
+  //
+  // THnSparse track histograms
+  //
+  THnSparseF *fRecMCTrackHist; //-> nClust:chi2PerClust:nClust/nFindableClust:DCAy:DCAz:eta:phi:pt:kinkIdx:isPrim:polarity
+
+  AlidNdPtCutAnalysisPbPb(const AlidNdPtCutAnalysisPbPb&); // not implemented
+  AlidNdPtCutAnalysisPbPb& operator=(const AlidNdPtCutAnalysisPbPb&); // not implemented
+
+  ClassDef(AlidNdPtCutAnalysisPbPb,1);
+};
+
+#endif