Bugfixes for empty histograms and added comparison to TPC only Tracks (Marta)
authorkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 23 Sep 2010 14:27:09 +0000 (14:27 +0000)
committerkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 23 Sep 2010 14:27:09 +0000 (14:27 +0000)
PWG4/JetTasks/AliPWG4HighPtQAMC.cxx
PWG4/JetTasks/AliPWG4HighPtQAMC.h
PWG4/JetTasks/AliPWG4HighPtQATPConly.cxx
PWG4/JetTasks/AliPWG4HighPtQATPConly.h
PWG4/macros/AddTaskPWG4HighPtQAMC.C
PWG4/macros/AnalysisTrainPWG4Jets.C

index 4bbb7a1..c5af048 100644 (file)
@@ -51,6 +51,7 @@ AliPWG4HighPtQAMC::AliPWG4HighPtQAMC(): AliAnalysisTask("AliPWG4HighPtQAMC", "")
   fMC(0),
   fTrackCuts(0), 
   fTrackCutsITS(0),
+  fTrackType(0),
   fPtMax(100.),
   fNEventAll(0),
   fNEventSel(0),
@@ -90,6 +91,7 @@ AliPWG4HighPtQAMC::AliPWG4HighPtQAMC(const char *name):
   fMC(0),
   fTrackCuts(),
   fTrackCutsITS(),
+  fTrackType(0),
   fPtMax(100.),
   fNEventAll(0),
   fNEventSel(0),
@@ -391,33 +393,63 @@ void AliPWG4HighPtQAMC::Exec(Option_t *) {
 
   int nMCtracks = stack->GetNtrack();
 
+  Float_t pt      = 0.;
+  Float_t ptMC    = 0.;
+  Float_t phi     = 0.;
+  Float_t dca2D   = 0.;
+  Float_t dcaZ    = 0.;
+  Int_t nPointITS = 0;
+  Float_t chi2C   = 0.;
+  Float_t nSigmaToVertex    = 0.;
+  Float_t relUncertainty1Pt = 0.;
+
   for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
     
-    AliESDtrack *track = fESD->GetTrack(iTrack);
+    AliESDtrack *track;
+    AliESDtrack *esdtrack = fESD->GetTrack(iTrack);
+    if(!esdtrack) continue;
+    AliExternalTrackParam *trackTPC = (AliExternalTrackParam *)esdtrack->GetTPCInnerParam();
+
+    if(fTrackType==1)
+      track = AliESDtrackCuts::GetTPCOnlyTrack(fESD,esdtrack->GetID());
+    else
+      track = esdtrack;
+
+    
     if(!track) continue;
+
     Int_t label = TMath::Abs(track->GetLabel());
     if(label>=nMCtracks)continue;
     TParticle *particle = stack->Particle(label) ;
     if(!particle) continue;
 
-    Float_t pt = track->Pt();
-    Float_t ptMC = particle->Pt();
-    Float_t phi = track->Phi();
-    Float_t dca2D, dcaZ;
-    track->GetImpactParameters(dca2D,dcaZ);
+    ptMC = particle->Pt();
+
+    if(fTrackType==0) {       //Global
+      pt  = track->Pt();
+      phi = track->Phi();
+      track->GetImpactParameters(dca2D,dcaZ);
+    }
+    else if(fTrackType==1) {  //TPConly
+      pt  = trackTPC->Pt();
+      phi = trackTPC->Phi();
+      track->GetImpactParametersTPC(dca2D,dcaZ);
+    }
+    else {continue;}
+
+    
     UChar_t itsMap = track->GetITSClusterMap();
-    Int_t nPointITS = 0;
     for (Int_t i=0; i < 6; i++) {
       if (itsMap & (1 << i))
        nPointITS ++;
     }
-    Float_t nSigmaToVertex = fTrackCuts->GetSigmaToVertex(track);// Calculates the number of sigma to the vertex for a track.
-    Float_t chi2C = track->GetConstrainedChi2();
-    Float_t relUncertainty1Pt = TMath::Sqrt(track->GetSigma1Pt2())*pt;
-
+    nSigmaToVertex = fTrackCuts->GetSigmaToVertex(track);// Calculates the number of sigma to the vertex for a track.
+    chi2C = track->GetConstrainedChi2();
+    relUncertainty1Pt = TMath::Sqrt(track->GetSigma1Pt2())*pt;
+    
     fPtAll->Fill(pt);
     fPtAllMC->Fill(ptMC);
-    
+
     if (fTrackCuts->AcceptTrack(track)) {
 
       fPtSel->Fill(pt);
@@ -435,8 +467,9 @@ void AliPWG4HighPtQAMC::Exec(Option_t *) {
     }//fTrackCuts selection
     
     
+    
     //ITSrefit selection
-    if (fTrackCutsITS->AcceptTrack(track)) {
+    if (fTrackCutsITS->AcceptTrack(track) && fTrackType==0) {
       
       fPtSelITS->Fill(pt);
       fPtSelMCITS->Fill(ptMC);
@@ -450,7 +483,7 @@ void AliPWG4HighPtQAMC::Exec(Option_t *) {
       fPtITSminPtMCvsPtITSChi2C->Fill(ptMC,(1./pt-1./ptMC)/(1./ptMC),chi2C);
       fPtITSminPtMCvsPtITSRel1PtUncertainty->Fill(ptMC,(1./pt-1./ptMC)/(1./ptMC),relUncertainty1Pt);
     }//fTrackCutsITS loop
-      
+    
   }//ESD track loop
    
   // Post output data
index 8f49fd4..7defa80 100644 (file)
@@ -46,6 +46,7 @@ class AliPWG4HighPtQAMC: public AliAnalysisTask {
   void SetCuts(AliESDtrackCuts* trackCuts) {fTrackCuts = trackCuts;}
   void SetCutsITS(AliESDtrackCuts* trackCutsITS) {fTrackCutsITS = trackCutsITS;}
 
+  void SetTrackType(Int_t trackType) {fTrackType = trackType;}
   void SetPtMax(Float_t ptmax) {fPtMax = ptmax;}
   Float_t GetPtMax()           {return fPtMax;}
 
@@ -62,6 +63,8 @@ class AliPWG4HighPtQAMC: public AliAnalysisTask {
   AliESDtrackCuts *fTrackCuts;    // TrackCuts for global reconstructed vs MC comparison
   AliESDtrackCuts *fTrackCutsITS; // TrackCuts including ITSrefit
 
+  Int_t fTrackType;               // 0: global track; 1:TPConly track
+
   Float_t fPtMax;                 // Maximum pT for histograms
 
   
index 07e880c..0ab2b87 100644 (file)
 #include "AliLog.h"
 //#include "AliAnalysisHelperJetTasks.h"
 
-#include "AliStack.h"
-#include "TParticle.h"
 #include "TH1I.h"
-#include "AliMCEvent.h"
-#include "AliMCEventHandler.h"
 
 using namespace std; //required for resolving the 'cout' symbol
 
@@ -61,7 +57,6 @@ ClassImp(AliPWG4HighPtQATPConly)
 AliPWG4HighPtQATPConly::AliPWG4HighPtQATPConly(): AliAnalysisTask("AliPWG4HighPtQATPConly", ""), 
   fESD(0), 
   fESDfriend(0), 
-  fMC(0),
   fCutType(1),
   fTrackCuts(0), 
   fTrackCutsITS(0),
@@ -152,7 +147,6 @@ AliPWG4HighPtQATPConly::AliPWG4HighPtQATPConly(const char *name):
   AliAnalysisTask(name, ""), 
   fESD(0),
   fESDfriend(0), 
-  fMC(0),
   fCutType(1),  
   fTrackCuts(),
   fTrackCutsITS(),
@@ -280,14 +274,7 @@ void AliPWG4HighPtQATPConly::ConnectInputData(Option_t *)
     return;
   } else
     fESD = esdH->GetEvent();
-  
- AliMCEventHandler *eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
- if (!eventHandler) {
-    AliDebug(2,Form( "ERROR: Could not retrieve MC event handler \n"));
-  }
-  else
-    fMC = eventHandler->MCEvent();
-
   fESDfriend = esdH->GetESDfriend();
 
 }
@@ -853,24 +840,6 @@ void AliPWG4HighPtQATPConly::Exec(Option_t *) {
     return;
   }
 
-  AliStack* stack = 0x0;
-  
-  if(fMC) {
-    AliDebug(2,Form("MC particles: %d", fMC->GetNumberOfTracks()));
-    
-    stack = fMC->Stack();                //Particles Stack
-    
-    AliDebug(2,Form("MC particles stack: %d", stack->GetNtrack()));
-  }
-  else {
-      AliDebug(2,Form("ERROR: Could not retrieve MC event"));
-      PostData(0, fHistList);
-      PostData(1, fHistListTPC);
-      PostData(2, fHistListITS);
-      return;
-    }
-      
-
   const AliESDVertex *vtx = fESD->GetPrimaryVertexTracks();
   // Need vertex cut
   TString vtxName(vtx->GetName());
index 1a72d27..d0c91f0 100644 (file)
@@ -30,7 +30,6 @@ class TList;
 class AliESDEvent;
 class AliESDfriend;
 class AliESDfriendTrack;
-class AliMCEvent;
 class AliVEvent;
 class AliESDtrackCuts;
 class AliESDtrack;
@@ -66,7 +65,6 @@ class AliPWG4HighPtQATPConly: public AliAnalysisTask {
 
   AliESDEvent *fESD;              //! ESD object
   AliESDfriend *fESDfriend;       //! ESD friend object
-  AliMCEvent *fMC;                //! MC event object
   Int_t fCutType;                 // Cut Type set in AddTask*
   AliESDtrackCuts *fTrackCuts;    // TrackCuts for global vs TPConly comparison
   AliESDtrackCuts *fTrackCutsITS; // TrackCuts including ITSrefit
index 7aabf90..a7346be 100644 (file)
@@ -1,6 +1,7 @@
+
 //DEFINITION OF A FEW CONSTANTS
 
-AliPWG4HighPtQAMC* AddTaskPWG4HighPtQAMC(char *prodType = "LHC10e14")
+AliPWG4HighPtQAMC* AddTaskPWG4HighPtQAMC(char *prodType = "LHC10e14", int trackType = 0)
 {
   // Creates HighPtQAMC analysis task and adds it to the analysis manager.
   
@@ -29,7 +30,10 @@ AliPWG4HighPtQAMC* AddTaskPWG4HighPtQAMC(char *prodType = "LHC10e14")
   //Use AliESDtrackCuts
   AliESDtrackCuts *trackCuts = new AliESDtrackCuts("AliESDtrackCuts","Standard Cuts");
   //Standard Cuts
-  trackCuts=trackCuts->GetStandardITSTPCTrackCuts2009(kTRUE);//Primary Track Selection
+  //Set track cuts for global tracks
+  if(trackType==0) trackCuts = trackCuts->GetStandardITSTPCTrackCuts2009(kTRUE);//Primary Track Selection
+  //Set track cuts for TPConly tracks
+  if(trackType==1) trackCuts = trackCuts->GetStandardTPCOnlyTrackCuts(); 
   trackCuts->SetEtaRange(-0.9,0.9);
   trackCuts->SetPtRange(0.15, 1e10);
   trackCuts->SetRequireITSRefit(kFALSE);
@@ -42,9 +46,10 @@ AliPWG4HighPtQAMC* AddTaskPWG4HighPtQAMC(char *prodType = "LHC10e14")
   trackCutsITS->SetRequireITSRefit(kTRUE);
 
   //Create the task
-  AliPWG4HighPtQAMC *taskPWG4QAMC = new AliPWG4HighPtQAMC("AliPWG4HighPtQAMC");
+  AliPWG4HighPtQAMC *taskPWG4QAMC = new AliPWG4HighPtQAMC(Form("AliPWG4HighPtQAMC%d",trackType));
   taskPWG4QAMC->SetCuts(trackCuts);
   taskPWG4QAMC->SetCutsITS(trackCutsITS);
+  taskPWG4QAMC->SetTrackType(trackType);
   if(!strcmp(prodType, "LHC10e14")  || !strcmp(prodType, "PbPb")) taskPWG4QAMC->SetPtMax(500.);
   else taskPWG4QAMC->SetPtMax(100.);
  
@@ -56,10 +61,10 @@ AliPWG4HighPtQAMC* AddTaskPWG4HighPtQAMC(char *prodType = "LHC10e14")
   //  AliAnalysisDataContainer *cinput0  = mgr->GetCommonInputContainer();
   printf("Create output containers \n");
   TString outputfile = AliAnalysisManager::GetCommonFileName();
-  outputfile += ":PWG4_HighPtQAMC"; 
-  //char *outputfile = "outputAliPWG4HighPtQAMCTestTrain.root";
-  AliAnalysisDataContainer *cout_hist0 = mgr->CreateContainer("qa_histsMC", TList::Class(), AliAnalysisManager::kOutputContainer,outputfile);
-  AliAnalysisDataContainer *cout_hist2 = mgr->CreateContainer("qa_histsMCITS", TList::Class(), AliAnalysisManager::kOutputContainer,outputfile);  
+  outputfile += Form(":PWG4_HighPtQAMC%d",trackType);
+  
+  AliAnalysisDataContainer *cout_hist0 = mgr->CreateContainer(Form("qa_histsMC%d",trackType), TList::Class(), AliAnalysisManager::kOutputContainer,outputfile);
+  AliAnalysisDataContainer *cout_hist2 = mgr->CreateContainer(Form("qa_histsMCITS%d",trackType), TList::Class(), AliAnalysisManager::kOutputContainer,outputfile);  
 
   mgr->AddTask(taskPWG4QAMC);
   mgr->ConnectInput(taskPWG4QAMC,0,mgr->GetCommonInputContainer());
index 1035dc9..7044d52 100644 (file)
@@ -596,7 +596,8 @@ void AnalysisTrainPWG4Jets(const char *analysis_mode="local",
    }
    if(iPWG4PtQAMC){
      gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4HighPtQAMC.C");
-     AliPWG4HighPtQAMC *taskQAMC = AddTaskPWG4HighPtQAMC(kGridDataSet.Data());
+     AliPWG4HighPtQAMC *taskQAMC = AddTaskPWG4HighPtQAMC(kGridDataSet.Data(),0);
+     if(kUseMC)taskQAMC = AddTaskPWG4HighPtQAMC(kGridDataSet.Data());
      if (!taskQAMC) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskQAMC cannot run for this train conditions - EXCLUDED");
    }