new functionality and new class added
[u/mrichter/AliRoot.git] / PWG0 / dNdPt / AlidNdPtCutAnalysis.cxx
index 57e2ab9c23883cb7a84fbd7af67c4064c607c534..20582a531b4a164f67521970bea29107a20ffbe1 100644 (file)
 #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 "AliPhysicsSelection.h"\r
 \r
 #include "AliPWG0Helper.h"\r
@@ -134,10 +136,10 @@ void AlidNdPtCutAnalysis::Init(){
   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","mcXv-Xv:mcYv-Yv:mcZv-Zv:Mult",4,binsRecMCEventHist,minRecMCEventHist,maxRecMCEventHist);\r
-  fRecMCEventHist->GetAxis(0)->SetTitle("mcXv-Xv (cm)");\r
-  fRecMCEventHist->GetAxis(1)->SetTitle("mcYv-Yv (cm)");\r
-  fRecMCEventHist->GetAxis(2)->SetTitle("mcZv-Zv (cm)");\r
+  fRecMCEventHist = 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
@@ -192,16 +194,16 @@ void AlidNdPtCutAnalysis::Process(AliESDEvent *const esdEvent, AliMCEvent * cons
     return;\r
   }\r
 \r
-  // get physics trigger selection \r
-  AliPhysicsSelection *trigSel = GetPhysicsTriggerSelection();\r
-  if(!trigSel) {\r
-    AliDebug(AliLog::kError, "cannot get trigSel");\r
-    return;\r
-  }\r
-\r
   // trigger selection\r
   Bool_t isEventTriggered = kTRUE;\r
-  if(evtCuts->IsTriggerRequired())  {\r
+  if(evtCuts->IsTriggerRequired())  \r
+  {\r
+    AliPhysicsSelection *trigSel = GetPhysicsTriggerSelection();\r
+    if(!trigSel) {\r
+      AliDebug(AliLog::kError, "cannot get trigSel");\r
+      return;\r
+    }\r
+\r
     if(IsUseMCInfo()) { \r
       //static AliTriggerAnalysis* triggerAnalysis = new AliTriggerAnalysis;\r
       //isEventTriggered = triggerAnalysis->IsTriggerFired(esdEvent, GetTrigger());\r
@@ -209,7 +211,6 @@ void AlidNdPtCutAnalysis::Process(AliESDEvent *const esdEvent, AliMCEvent * cons
       isEventTriggered = trigSel->IsCollisionCandidate(esdEvent);\r
     }\r
     else {\r
-      //isEventTriggered = esdEvent->IsTriggerClassFired(GetTriggerClass());\r
       isEventTriggered = trigSel->IsCollisionCandidate(esdEvent);\r
     }\r
   }\r
@@ -265,8 +266,6 @@ void AlidNdPtCutAnalysis::Process(AliESDEvent *const esdEvent, AliMCEvent * cons
   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
-  if(!vtxESD) return; \r
-\r
   Bool_t isRecVertex = AlidNdPtHelper::TestRecVertex(vtxESD, GetAnalysisMode(), kFALSE);\r
   Bool_t isEventOK = evtCuts->AcceptEvent(esdEvent,mcEvent,vtxESD) && isRecVertex;\r
 \r
@@ -282,6 +281,33 @@ void AlidNdPtCutAnalysis::Process(AliESDEvent *const esdEvent, AliMCEvent * cons
   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
@@ -295,28 +321,53 @@ void AlidNdPtCutAnalysis::Process(AliESDEvent *const esdEvent, AliMCEvent * cons
       AliESDtrack *track = (AliESDtrack*)allChargedTracks->At(i);\r
       if(!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 ) \r
+      {\r
+        // Relate TPC-only tracks to SPD vertex\r
+        isOK = track->RelateToVertexTPCBxByBz(esdEvent->GetPrimaryVertexSPD(), 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) \r
       {\r
         //\r
         // update track parameters\r
        //\r
-           AliExternalTrackParam cParam;\r
-          track->RelateToVertexTPC(esdEvent->GetPrimaryVertexSPD(),esdEvent->GetMagneticField(),kVeryBig,&cParam);\r
-          track->Set(cParam.GetX(),cParam.GetAlpha(),cParam.GetParameter(),cParam.GetCovariance());\r
+        AliExternalTrackParam cParam;\r
+        isOK = track->RelateToVertexTPCBxByBz(esdEvent->GetPrimaryVertexSPD(), 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
+    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
+    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
@@ -335,11 +386,13 @@ void AlidNdPtCutAnalysis::FillHistograms(AliESDtrack *const esdTrack, AliStack *
   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->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->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
@@ -388,6 +441,8 @@ Long64_t AlidNdPtCutAnalysis::Merge(TCollection* const list)
   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
@@ -402,10 +457,18 @@ Long64_t AlidNdPtCutAnalysis::Merge(TCollection* const list)
 \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