Cleaning up, and fix filling of one step (Marta)
authorkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 18 Nov 2010 19:24:49 +0000 (19:24 +0000)
committerkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 18 Nov 2010 19:24:49 +0000 (19:24 +0000)
PWG4/JetTasks/AliPWG4HighPtQAMC.cxx
PWG4/JetTasks/AliPWG4HighPtQAMC.h
PWG4/JetTasks/AliPWG4HighPtSpectra.cxx
PWG4/JetTasks/AliPWG4HighPtSpectra.h

index ea6655a..6e7d343 100644 (file)
@@ -59,6 +59,7 @@ AliPWG4HighPtQAMC::AliPWG4HighPtQAMC()
 : AliAnalysisTask("AliPWG4HighPtQAMC", ""), 
   fESD(0), 
   fMC(0),
+  fStack(0),
   fTrackCuts(0), 
   fTrackCutsITS(0),
   fTrackType(0),
@@ -105,6 +106,7 @@ AliPWG4HighPtQAMC::AliPWG4HighPtQAMC(const char *name):
   AliAnalysisTask(name,""), 
   fESD(0),
   fMC(0),
+  fStack(0),
   fTrackCuts(),
   fTrackCutsITS(),
   fTrackType(0),
@@ -175,10 +177,10 @@ void AliPWG4HighPtQAMC::ConnectInputData(Option_t *)
   } 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"));
- }
 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();
 
@@ -354,64 +356,61 @@ void AliPWG4HighPtQAMC::CreateOutputObjects() {
   TH1::AddDirectory(oldStatus); 
 
 }
+
 //________________________________________________________________________
-void AliPWG4HighPtQAMC::Exec(Option_t *) {  
-  // Main loop
-  // Called for each event
-  AliDebug(2,Form(">> AliPWG4HighPtQATPConly::Exec \n"));  
-  // All events without selection
-  fNEventAll->Fill(0.);
+Bool_t AliPWG4HighPtQAMC::SelectEvent() {
+  //
+  // Decide if event should be selected for analysis
+  //
 
+  // Checks following requirements:
+  // - fESD available
+  // - trigger info from AliPhysicsSelection
+  // - MCevent available
+  // - number of reconstructed tracks > 1
+  // - primary vertex reconstructed
+  // - z-vertex < 10 cm
+
+  Bool_t selectEvent = kTRUE;
+
+  //fESD object available?
   if (!fESD) {
     AliDebug(2,Form("ERROR: fInputEvent not available\n"));
     fNEventReject->Fill("noESD",1);
-    PostData(0, fHistList);
-    PostData(1, fHistListITS);
-    return;
+    selectEvent = kFALSE;
+    return selectEvent;
   }
 
+  //Trigger
   UInt_t isSelected = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
   if(!(isSelected&AliVEvent::kMB)) { //Select collison candidates
     AliDebug(2,Form(" Trigger Selection: event REJECTED ... "));
     fNEventReject->Fill("Trigger",1);
-    // Post output data
-    PostData(0, fHistList);
-    PostData(1, fHistListITS);
-    return;
+    selectEvent = kFALSE;
+    return selectEvent;
   }
-  
-  AliStack* stack = 0x0;
-  
+
+  //MCEvent available?
+  //if yes: get stack
   if(fMC) {
     AliDebug(2,Form("MC particles: %d", fMC->GetNumberOfTracks()));
-    stack = fMC->Stack();                //Particles Stack
-    AliDebug(2,Form("MC particles stack: %d", stack->GetNtrack()));
+    fStack = fMC->Stack();                //Particles Stack
+    AliDebug(2,Form("MC particles stack: %d", fStack->GetNtrack()));
   } else {
     AliDebug(2,Form("ERROR: Could not retrieve MC eventHandler"));
     fNEventReject->Fill("noMCEvent",1);
-    PostData(0, fHistList);
-    PostData(1, fHistListITS);
-    return;
+    selectEvent = kFALSE;
+    return selectEvent;
   }
 
-  //___ get MC information __________________________________________________________________
-
-  Double_t ptHard = 0.;
-  Double_t nTrials = 1; // trials for MC trigger weight for real data
-  
-  if(fMC){
-    AliGenPythiaEventHeader*  pythiaGenHeader = GetPythiaEventHeader(fMC);
-     if(pythiaGenHeader){
-       nTrials = pythiaGenHeader->Trials();
-       ptHard  = pythiaGenHeader->GetPtHard();
-       
-       fh1PtHard->Fill(ptHard);
-       fh1PtHardTrials->Fill(ptHard,nTrials);
-       
-       fh1Trials->Fill("#sum{ntrials}",fAvgTrials);
-     }
+  //Check if number of reconstructed tracks is larger than 1
+  if(!fESD->GetNumberOfTracks() || fESD->GetNumberOfTracks()<2)  {
+    fNEventReject->Fill("NTracks<2",1);
+    selectEvent = kFALSE;
+    return selectEvent;
   }
 
+  //Check if vertex is reconstructed
   const AliESDVertex *vtx = fESD->GetPrimaryVertex();
   // Need vertex cut
   TString vtxName(vtx->GetName());
@@ -421,39 +420,66 @@ void AliPWG4HighPtQAMC::Exec(Option_t *) {
     if(vtx->GetNContributors()<2) {
       vtx = 0x0;
       fNEventReject->Fill("noVTX",1);
-      // Post output data
-      PostData(0, fHistList);
-      PostData(1, fHistListITS);
-      return;
+      selectEvent = kFALSE;
+      return selectEvent;
     }
   }
 
+  //Check if z-vertex < 10 cm
   double primVtx[3];
   vtx->GetXYZ(primVtx);
   if(TMath::Sqrt(primVtx[0]*primVtx[0] + primVtx[1]*primVtx[1])>1. || TMath::Abs(primVtx[2]>10.)){
     fNEventReject->Fill("ZVTX>10",1);
-    // Post output data
-    PostData(0, fHistList);
-    PostData(1, fHistListITS);
-    return;
+    selectEvent = kFALSE;
+    return selectEvent;
   }
   
   AliDebug(2,Form("Vertex title %s, status %d, nCont %d\n",vtx->GetTitle(), vtx->GetStatus(), vtx->GetNContributors()));
 
-  if(!fESD->GetNumberOfTracks() || fESD->GetNumberOfTracks()<2)  {
+  return selectEvent;
+
+}
+
+//________________________________________________________________________
+void AliPWG4HighPtQAMC::Exec(Option_t *) {  
+  // Main loop
+  // Called for each event
+  AliDebug(2,Form(">> AliPWG4HighPtQATPConly::Exec \n"));  
+  // All events without selection
+  fNEventAll->Fill(0.);
+
+  if(!SelectEvent()) {
+    // Post output data
     fNEventReject->Fill("NTracks<2",1);
     PostData(0, fHistList);
     PostData(1, fHistListITS);
     return;
   }
 
+  // ---- Get MC Header information (for MC productions in pThard bins) ----
+  Double_t ptHard = 0.;
+  Double_t nTrials = 1; // trials for MC trigger weight for real data
+  
+  if(fMC){
+    AliGenPythiaEventHeader*  pythiaGenHeader = GetPythiaEventHeader(fMC);
+     if(pythiaGenHeader){
+       nTrials = pythiaGenHeader->Trials();
+       ptHard  = pythiaGenHeader->GetPtHard();
+       
+       fh1PtHard->Fill(ptHard);
+       fh1PtHardTrials->Fill(ptHard,nTrials);
+       
+       fh1Trials->Fill("#sum{ntrials}",fAvgTrials);
+     }
+  }
+
   //Need to keep track of selected events
   fNEventSel->Fill(0.);
 
   Int_t nTracks = fESD->GetNumberOfTracks();
   AliDebug(2,Form("nTracks ESD%d", nTracks));
 
-  int nMCtracks = stack->GetNtrack();
+  int nMCtracks = fStack->GetNtrack();
 
   Float_t pt      = 0.;
   Float_t ptMC    = 0.;
@@ -482,7 +508,7 @@ void AliPWG4HighPtQAMC::Exec(Option_t *) {
 
     Int_t label = TMath::Abs(track->GetLabel());
     if(label>=nMCtracks)continue;
-    TParticle *particle = stack->Particle(label) ;
+    TParticle *particle = fStack->Particle(label) ;
     if(!particle) continue;
 
     ptMC = particle->Pt();
index ad7a5b7..783ab5f 100644 (file)
@@ -31,6 +31,7 @@ class TList;
 class AliESDEvent;
 class AliESDtrackCuts;
 class AliMCEvent;
+class AliStack;
 class AliGenPythiaEventHeader;
 //class AliAnalysisHelperJetTasks;
 
@@ -47,6 +48,8 @@ class AliPWG4HighPtQAMC: public AliAnalysisTask {
   virtual void   Terminate(Option_t *);
   virtual Bool_t Notify(); //Copied from AliAnalysisTaskJetSpectrum2
 
+  Bool_t SelectEvent();    //decides if event is used for analysis
+
   void SetCuts(AliESDtrackCuts* trackCuts) {fTrackCuts = trackCuts;}
   void SetCutsITS(AliESDtrackCuts* trackCutsITS) {fTrackCutsITS = trackCutsITS;}
 
@@ -65,7 +68,8 @@ class AliPWG4HighPtQAMC: public AliAnalysisTask {
 
   AliESDEvent *fESD;              //! ESD object
   AliMCEvent  *fMC;               //! MC event object
+  AliStack    *fStack;            //! stack object
+
   AliESDtrackCuts *fTrackCuts;    // TrackCuts for global reconstructed vs MC comparison
   AliESDtrackCuts *fTrackCutsITS; // TrackCuts including ITSrefit
 
index d5aa4bc..c68ab29 100644 (file)
@@ -68,9 +68,11 @@ AliPWG4HighPtSpectra::AliPWG4HighPtSpectra() : AliAnalysisTask("AliPWG4HighPtSpe
   fReadAODData(0),
   fCFManagerPos(0x0),
   fCFManagerNeg(0x0),
-  fESD(0),
-  fTrackCuts(0),
-  fTrackCutsTPConly(0),
+  fESD(0x0),
+  fMC(0x0),
+  fStack(0x0),
+  fTrackCuts(0x0),
+  fTrackCutsTPConly(0x0),
   fAvgTrials(1),
   fHistList(0),
   fNEventAll(0),
@@ -91,9 +93,11 @@ AliPWG4HighPtSpectra::AliPWG4HighPtSpectra(const Char_t* name) :
   fReadAODData(0),
   fCFManagerPos(0x0),
   fCFManagerNeg(0x0),
-  fESD(0),
-  fTrackCuts(),
-  fTrackCutsTPConly(0),
+  fESD(0x0),
+  fMC(0x0),
+  fStack(0x0),
+  fTrackCuts(0x0),
+  fTrackCutsTPConly(0x0),
   fAvgTrials(1),
   fHistList(0),
   fNEventAll(0),
@@ -139,95 +143,68 @@ void AliPWG4HighPtSpectra::ConnectInputData(Option_t *)
 
   TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
   if (!tree) {
-    AliDebug(2,Form("ERROR: Could not read chain from input slot 0"));
-  } else {
-    
-    AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
-    
-    if (!esdH) {
-      AliDebug(2,Form("ERROR: Could not get ESDInputHandler"));
-    } else {
-      fESD = esdH->GetEvent();
-    }
+    AliDebug(2,Form( "ERROR: Could not read chain from input slot 0 \n"));
+    return;
   }
+
+  AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
+
+  if (!esdH) {
+    AliDebug(2,Form("ERROR: Could not get ESDInputHandler"));
+    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();
+
 }
-//_________________________________________________
-void AliPWG4HighPtSpectra::Exec(Option_t *)
-{
+
+//________________________________________________________________________
+Bool_t AliPWG4HighPtSpectra::SelectEvent() {
   //
-  // Main loop function
+  // Decide if event should be selected for analysis
   //
-  AliDebug(2,Form(">> AliPWG4HighPtSpectra::Exec \n"));  
 
-  // All events without selection
-  fNEventAll->Fill(0.);
+  // Checks following requirements:
+  // - fESD available
+  // - trigger info from AliPhysicsSelection
+  // - number of reconstructed tracks > 1
+  // - primary vertex reconstructed
+  // - z-vertex < 10 cm
+
+  Bool_t selectEvent = kTRUE;
 
+  //fESD object available?
   if (!fESD) {
-    AliDebug(2,Form("ERROR: fESD not available"));
+    AliDebug(2,Form("ERROR: fInputEvent not available\n"));
     fNEventReject->Fill("noESD",1);
-    PostData(0,fHistList);
-    PostData(1,fCFManagerPos->GetParticleContainer());
-    PostData(2,fCFManagerNeg->GetParticleContainer());
-    return;
+    selectEvent = kFALSE;
+    return selectEvent;
   }
 
+  //Trigger
   UInt_t isSelected = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
   if(!(isSelected&AliVEvent::kMB)) { //Select collison candidates
     AliDebug(2,Form(" Trigger Selection: event REJECTED ... "));
     fNEventReject->Fill("Trigger",1);
-    PostData(0,fHistList);
-    PostData(1,fCFManagerPos->GetParticleContainer());
-    PostData(2,fCFManagerNeg->GetParticleContainer());
-    return;
+    selectEvent = kFALSE;
+    return selectEvent;
   }
 
-  // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler
-  // This handler can return the current MC event
-  
-  AliMCEventHandler *eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
-  
-  AliStack* stack = 0x0;
-  AliMCEvent* mcEvent = 0x0;
-  
-  if(eventHandler) {
-    mcEvent = eventHandler->MCEvent();
-    if (!mcEvent) {
-      AliDebug(2,Form("ERROR: Could not retrieve MC event"));
-      fNEventReject->Fill("noMCEvent",1);
-      PostData(0,fHistList);
-      PostData(1,fCFManagerPos->GetParticleContainer());
-      PostData(2,fCFManagerNeg->GetParticleContainer());
-      return;
-    }
-    
-    AliDebug(2,Form("MC particles: %d", mcEvent->GetNumberOfTracks()));
-    
-    stack = mcEvent->Stack();                //Particles Stack
-    
-    AliDebug(2,Form("MC particles stack: %d", stack->GetNtrack()));
+  //Check if number of reconstructed tracks is larger than 1
+  if(!fESD->GetNumberOfTracks() || fESD->GetNumberOfTracks()<2)  {
+    fNEventReject->Fill("NTracks<2",1);
+    selectEvent = kFALSE;
+    return selectEvent;
   }
 
-  //___ get MC information __________________________________________________________________
-
-  Double_t ptHard = 0.;
-  Double_t nTrials = 1; // trials for MC trigger weight for real data
-  
-  if(mcEvent){
-    AliGenPythiaEventHeader*  pythiaGenHeader = GetPythiaEventHeader(mcEvent);
-     if(pythiaGenHeader){
-       nTrials = pythiaGenHeader->Trials();
-       ptHard  = pythiaGenHeader->GetPtHard();
-       
-       fh1PtHard->Fill(ptHard);
-       fh1PtHardTrials->Fill(ptHard,nTrials);
-       
-       fh1Trials->Fill("#sum{ntrials}",fAvgTrials);
-     }
-  }
-  
+  //Check if vertex is reconstructed
   const AliESDVertex *vtx = fESD->GetPrimaryVertex();
-  AliDebug(2,Form("Vertex title %s, status %d, nCont %d\n",vtx->GetTitle(), vtx->GetStatus(), vtx->GetNContributors()));
   // Need vertex cut
   TString vtxName(vtx->GetName());
   if(vtx->GetNContributors() < 2 || (vtxName.Contains("TPCVertex")) ) {
@@ -236,25 +213,38 @@ void AliPWG4HighPtSpectra::Exec(Option_t *)
     if(vtx->GetNContributors()<2) {
       vtx = 0x0;
       fNEventReject->Fill("noVTX",1);
-      // Post output data
-      PostData(0,fHistList);
-      PostData(1,fCFManagerPos->GetParticleContainer());
-      PostData(2,fCFManagerNeg->GetParticleContainer());
-      return;
+      selectEvent = kFALSE;
+      return selectEvent;
     }
   }
-  
+
+  //Check if z-vertex < 10 cm
   double primVtx[3];
   vtx->GetXYZ(primVtx);
   if(TMath::Sqrt(primVtx[0]*primVtx[0] + primVtx[1]*primVtx[1])>1. || TMath::Abs(primVtx[2]>10.)){
     fNEventReject->Fill("ZVTX>10",1);
-    PostData(0,fHistList);
-    PostData(1,fCFManagerPos->GetParticleContainer());
-    PostData(2,fCFManagerNeg->GetParticleContainer());
-    return;
+    selectEvent = kFALSE;
+    return selectEvent;
   }
   
-  if(!fESD->GetNumberOfTracks() || fESD->GetNumberOfTracks()<2){ 
+  AliDebug(2,Form("Vertex title %s, status %d, nCont %d\n",vtx->GetTitle(), vtx->GetStatus(), vtx->GetNContributors()));
+
+  return selectEvent;
+
+}
+
+//_________________________________________________
+void AliPWG4HighPtSpectra::Exec(Option_t *)
+{
+  //
+  // Main loop function
+  //
+  AliDebug(2,Form(">> AliPWG4HighPtSpectra::Exec \n"));  
+
+  // All events without selection
+  fNEventAll->Fill(0.);
+
+  if(!SelectEvent()) {
     fNEventReject->Fill("NTracks<2",1);
     // Post output data
     PostData(0,fHistList);
@@ -262,6 +252,32 @@ void AliPWG4HighPtSpectra::Exec(Option_t *)
     PostData(2,fCFManagerNeg->GetParticleContainer());
     return;
   }
+
+  //MCEvent available? 
+  //if yes: get stack
+  if(fMC) {
+    AliDebug(2,Form("MC particles: %d", fMC->GetNumberOfTracks()));
+    fStack = fMC->Stack();                //Particles Stack
+    AliDebug(2,Form("MC particles stack: %d", fStack->GetNtrack()));
+  }
+
+  // ---- Get MC Header information (for MC productions in pThard bins) ----
+  Double_t ptHard = 0.;
+  Double_t nTrials = 1; // trials for MC trigger weight for real data
+  
+  if(fMC){
+    AliGenPythiaEventHeader*  pythiaGenHeader = GetPythiaEventHeader(fMC);
+     if(pythiaGenHeader){
+       nTrials = pythiaGenHeader->Trials();
+       ptHard  = pythiaGenHeader->GetPtHard();
+       
+       fh1PtHard->Fill(ptHard);
+       fh1PtHardTrials->Fill(ptHard,nTrials);
+       
+       fh1Trials->Fill("#sum{ntrials}",fAvgTrials);
+     }
+  }
+  
   Int_t nTracks = fESD->GetNumberOfTracks();
   AliDebug(2,Form("nTracks %d", nTracks));
 
@@ -310,9 +326,9 @@ void AliPWG4HighPtSpectra::Exec(Option_t *)
          if(trackTPC->GetSign()<0.) fCFManagerNeg->GetParticleContainer()->Fill(containerInputTPConly,kStepReconstructedTPCOnly);
 
          //Only fill the MC containers if MC information is available
-         if(eventHandler) {
+         if(fMC) {
            Int_t label = TMath::Abs(track->GetLabel());
-           TParticle *particle = stack->Particle(label) ;
+           TParticle *particle = fStack->Particle(label) ;
            if(!particle) continue;
            
            containerInputTPConlyMC[0] = particle->Pt();      
@@ -320,12 +336,12 @@ void AliPWG4HighPtSpectra::Exec(Option_t *)
            containerInputTPConlyMC[2] = particle->Eta();  
            
            //Container with primaries
-           if(stack->IsPhysicalPrimary(label)) {
+           if(fStack->IsPhysicalPrimary(label)) {
              if(particle->GetPDG()->Charge()>0.) {
-               fCFManagerPos->GetParticleContainer()->Fill(containerInputMC,kStepReconstructedTPCOnlyMC);
+               fCFManagerPos->GetParticleContainer()->Fill(containerInputTPConlyMC,kStepReconstructedTPCOnlyMC);
              }
              if(particle->GetPDG()->Charge()<0.) {
-               fCFManagerNeg->GetParticleContainer()->Fill(containerInputMC,kStepReconstructedTPCOnlyMC);
+               fCFManagerNeg->GetParticleContainer()->Fill(containerInputTPConlyMC,kStepReconstructedTPCOnlyMC);
              }
            }
          }
@@ -339,9 +355,9 @@ void AliPWG4HighPtSpectra::Exec(Option_t *)
 
        
        //Only fill the MC containers if MC information is available
-       if(eventHandler) {
+       if(fMC) {
          Int_t label = TMath::Abs(track->GetLabel());
-         TParticle *particle = stack->Particle(label) ;
+         TParticle *particle = fStack->Particle(label) ;
          if(!particle) continue;
 
          containerInputRecMC[0] = particle->Pt();      
@@ -349,7 +365,7 @@ void AliPWG4HighPtSpectra::Exec(Option_t *)
          containerInputRecMC[2] = particle->Eta();  
 
          //Container with primaries
-         if(stack->IsPhysicalPrimary(label)) {
+         if(fStack->IsPhysicalPrimary(label)) {
            if(particle->GetPDG()->Charge()>0.) {
              fCFManagerPos->GetParticleContainer()->Fill(containerInputRecMC,kStepReconstructedMC);
            }
@@ -359,7 +375,7 @@ void AliPWG4HighPtSpectra::Exec(Option_t *)
          }
 
          //Container with secondaries
-         if (!stack->IsPhysicalPrimary(label) ) {
+         if (!fStack->IsPhysicalPrimary(label) ) {
            if(particle->GetPDG()->Charge()>0.) {
              fCFManagerPos->GetParticleContainer()->Fill(containerInputRec,kStepSecondaries);
            }
@@ -376,21 +392,20 @@ void AliPWG4HighPtSpectra::Exec(Option_t *)
   
 
   //Fill MC containters if particles are findable
-  if(eventHandler) {
-    for(int iPart = 1; iPart<(mcEvent->GetNumberOfPrimaries()); iPart++)//stack->GetNprimary();
-      {
-       AliMCParticle *mcPart  = (AliMCParticle*)mcEvent->GetTrack(iPart);
-       if(!mcPart) continue;
-       //fill the container
-       containerInputMC[0] = mcPart->Pt();
-       containerInputMC[1] = mcPart->Phi();      
-       containerInputMC[2] = mcPart->Eta();  
-
-       if(stack->IsPhysicalPrimary(iPart)) {
-         if(mcPart->Charge()>0. && fCFManagerPos->CheckParticleCuts(kStepMCAcceptance,mcPart)) fCFManagerPos->GetParticleContainer()->Fill(containerInputMC,kStepMCAcceptance);
-         if(mcPart->Charge()<0. && fCFManagerNeg->CheckParticleCuts(kStepMCAcceptance,mcPart)) fCFManagerNeg->GetParticleContainer()->Fill(containerInputMC,kStepMCAcceptance);
-       }
+  if(fMC) {
+    for(int iPart = 1; iPart<(fMC->GetNumberOfPrimaries()); iPart++) {
+      AliMCParticle *mcPart  = (AliMCParticle*)fMC->GetTrack(iPart);
+      if(!mcPart) continue;
+      //fill the container
+      containerInputMC[0] = mcPart->Pt();
+      containerInputMC[1] = mcPart->Phi();      
+      containerInputMC[2] = mcPart->Eta();  
+      
+      if(fStack->IsPhysicalPrimary(iPart)) {
+       if(mcPart->Charge()>0. && fCFManagerPos->CheckParticleCuts(kStepMCAcceptance,mcPart)) fCFManagerPos->GetParticleContainer()->Fill(containerInputMC,kStepMCAcceptance);
+       if(mcPart->Charge()<0. && fCFManagerNeg->CheckParticleCuts(kStepMCAcceptance,mcPart)) fCFManagerNeg->GetParticleContainer()->Fill(containerInputMC,kStepMCAcceptance);
       }
+    }
   }
   
   PostData(0,fHistList);
index b99dc2f..1aa42e2 100644 (file)
@@ -34,6 +34,7 @@ class TList;
 class AliESDtrackCuts;
 class AliESDEvent;
 class AliMCEvent;
+class AliStack;
 class AliGenPythiaEventHeader;
 
 class AliPWG4HighPtSpectra : public AliAnalysisTask {
@@ -62,6 +63,8 @@ class AliPWG4HighPtSpectra : public AliAnalysisTask {
   virtual void   Terminate(Option_t *);
   virtual Bool_t Notify(); //Copied from AliAnalysisTaskJetSpectrum2
 
+  Bool_t SelectEvent();    //decides if event is used for analysis
+
   // CORRECTION FRAMEWORK RELATED FUNCTIONS
   void     SetCFManagerPos(const AliCFManager* io1) {fCFManagerPos = io1;}   // global correction manager 
   const AliCFManager * GetCFManagerPos() const {return fCFManagerPos;}           // get corr manager 
@@ -84,7 +87,10 @@ class AliPWG4HighPtSpectra : public AliAnalysisTask {
   const AliCFManager  *fCFManagerPos    ;  // pointer to the CF manager for positive charged particles
   const AliCFManager  *fCFManagerNeg    ;  // pointer to the CF manager for negative charged particles
  
-  AliESDEvent *fESD;                     //! ESD object
+  AliESDEvent *fESD;      //! ESD object
+  AliMCEvent  *fMC;       //! MC event object
+  AliStack    *fStack;    //! stack object
+
   //AliESDtrackCuts options. Must be setted in AddTaskPWG4HighPTSpectra.C. They correspond with different steps in container.
   AliESDtrackCuts *fTrackCuts;           // trackCuts applied to global tracks
   AliESDtrackCuts *fTrackCutsTPConly;    // trackCuts applied to TPConly tracks