Compliance with AliAnalysisTaskSE ; upgraded support for QA.
authorrvernet <rvernet@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 18 May 2008 15:47:56 +0000 (15:47 +0000)
committerrvernet <rvernet@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 18 May 2008 15:47:56 +0000 (15:47 +0000)
CORRFW/test/AliCFRsnTask.C
CORRFW/test/AliCFRsnTask.cxx
CORRFW/test/AliCFRsnTask.h
CORRFW/test/AliCFSingleTrackTask.C
CORRFW/test/AliCFSingleTrackTask.cxx
CORRFW/test/AliCFSingleTrackTask.h
CORRFW/test/AliCFV0Task.C
CORRFW/test/AliCFV0Task.cxx
CORRFW/test/AliCFV0Task.h

index e211eb5..c385641 100644 (file)
@@ -97,7 +97,6 @@ Bool_t AliCFRsnTask(
 
   // Rec-Level kinematic cuts
   AliCFTrackKineCuts *recKineCuts = new AliCFTrackKineCuts("recKineCuts","rec-level kine cuts");
-//   AliCFPairKineCuts *recKineCuts = new AliCFPairKineCuts("recKineCuts","rec-level kine cuts");
   recKineCuts->SetPtRange(ptmin,ptmax);
   recKineCuts->SetRapidityRange(ymin,ymax);
   recKineCuts->SetChargeRec(charge);
@@ -127,14 +126,14 @@ Bool_t AliCFRsnTask(
   cutPID->SetProbabilityCut(0.,0.);
   cutPID->SetDetectors("TPC ITS TOF TRD","TPC ITS TOF TRD");
   switch(PDG) {
-  case  -313  : cutPID->SetParticleType(AliPID::kKaon,kTRUE,AliPID::kPion,kTRUE); break;
-  case   313  : cutPID->SetParticleType(AliPID::kPion,kTRUE,AliPID::kKaon,kTRUE); break;
-  case   333  : cutPID->SetParticleType(AliPID::kKaon,kTRUE,AliPID::kKaon,kTRUE); break;
-  case  3124  : cutPID->SetParticleType(AliPID::kPion,kTRUE,AliPID::kKaon,kTRUE); break;
-  case -3124  : cutPID->SetParticleType(AliPID::kPion,kTRUE,AliPID::kKaon,kTRUE); break;
+  case  -313  : cutPID->SetParticleType(AliPID::kKaon  ,kTRUE,AliPID::kPion  ,kTRUE); break;
+  case   313  : cutPID->SetParticleType(AliPID::kPion  ,kTRUE,AliPID::kKaon  ,kTRUE); break;
+  case   333  : cutPID->SetParticleType(AliPID::kKaon  ,kTRUE,AliPID::kKaon  ,kTRUE); break;
+  case  3124  : cutPID->SetParticleType(AliPID::kKaon  ,kTRUE,AliPID::kProton,kTRUE); break;
+  case -3124  : cutPID->SetParticleType(AliPID::kProton,kTRUE,AliPID::kKaon  ,kTRUE); break;
   default     : printf("UNDEFINED PID\n"); break;
   }
-//   cutPID->SetQAOn(kTRUE);
+  //cutPID->SetQAOn(kTRUE);
 
   Info("AliCFRsnTask","CREATE MC KINE CUTS");
   TObjArray* mcList = new TObjArray(0) ;
@@ -178,25 +177,36 @@ Bool_t AliCFRsnTask(
   // Make the analysis manager
   AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
 
+  if (useGrid) mgr->SetAnalysisType(AliAnalysisManager::kGridAnalysis);
+  else mgr->SetAnalysisType(AliAnalysisManager::kLocalAnalysis);
+
+  AliMCEventHandler* mcHandler = new AliMCEventHandler();
+  AliESDInputHandler* esdHandler = new AliESDInputHandler();
+  mgr->SetMCtruthEventHandler(mcHandler);
+  mgr->SetInputEventHandler(esdHandler);
+
+
   // Create and connect containers for input/output
 
   //input data
   AliAnalysisDataContainer *cinput0  = mgr->CreateContainer("cchain0",TChain::Class(),AliAnalysisManager::kInputContainer);
+
+  //slot 0 : default output tree (by default handled by AliAnalysisTaskSE)
+  AliAnalysisDataContainer *coutput0 = mgr->CreateContainer("ctree0", TTree::Class(),AliAnalysisManager::kOutputContainer,"output_rsn.root");
+
   // output histo (number of events processed)
-  AliAnalysisDataContainer *coutput0 = mgr->CreateContainer("chist0", TH1I::Class(),AliAnalysisManager::kOutputContainer,"output_rsn.root");
+  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("chist0", TH1I::Class(),AliAnalysisManager::kOutputContainer,"output_rsn.root");
   // output Correction Framework Container (for acceptance & efficiency calculations)
-  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("ccontainer0", AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,"output_rsn.root");
-  // output QA histograms 
+  AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("ccontainer0", AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,"output_rsn.root");
+
+  cinput0->SetData(analysisChain);
 
   mgr->AddTask(task);
-  mgr->ConnectInput(task,0,cinput0);
+  mgr->ConnectInput (task,0,cinput0);
   mgr->ConnectOutput(task,0,coutput0);
   mgr->ConnectOutput(task,1,coutput1);
-  cinput0->SetData(analysisChain);
+  mgr->ConnectOutput(task,2,coutput2);
  
-  //NEW INTERFACE TO MC INFORMATION
-  AliMCEventHandler* mcHandler = new AliMCEventHandler();
-  mgr->SetMCtruthEventHandler(mcHandler);
 
   Info("AliCFRsnTask","READY TO RUN");
   //RUN !!!
@@ -218,6 +228,7 @@ void Load(Bool_t useGrid) {
   
   //load the required aliroot libraries
   gSystem->Load("libANALYSIS") ;
+  gSystem->Load("libANALYSISalice") ;
   
   gSystem->SetIncludePath("-I. -I$ALICE_ROOT/include -I$ROOTSYS/include -I$ALICE_ROOT/PWG2/RESONANCES -I$ALICE_ROOT/CORRFW");
 
index a6b51ea..49b100f 100644 (file)
 //-----------------------------------------------------------------------
 
 
-#include <TROOT.h>
-#include <TInterpreter.h>
-
 #include "AliCFRsnTask.h"
 #include "TCanvas.h"
 #include "AliStack.h"
 #include "TParticle.h"
 #include "TH1I.h"
 #include "TChain.h"
-#include "AliMCEventHandler.h"
 #include "AliMCEvent.h"
-#include "AliAnalysisManager.h"
 #include "AliESDEvent.h"
 #include "AliCFManager.h"
 #include "AliCFCutBase.h"
 #include "AliCFContainer.h"
-#include "TChain.h"
 #include "AliESDtrack.h"
 #include "AliLog.h"
 #include "AliRsnDaughter.h"
 #include "AliCFPair.h"
-#include <memory>
+#include "AliRsnParticle.h"
 
 //__________________________________________________________________________
 AliCFRsnTask::AliCFRsnTask() :
+  AliAnalysisTaskSE(),
   fRsnPDG(313),
-  fChain(0x0),
-  fESD(0x0),
   fCFManager(0x0),
   fHistEventsProcessed(0x0)
 {
-  //Defual ctor
+  //
+  //Default ctor
+  //
 }
 //___________________________________________________________________________
 AliCFRsnTask::AliCFRsnTask(const Char_t* name) :
-  AliAnalysisTask(name,"AliCFRsnTask"),
+  AliAnalysisTaskSE(name),
   fRsnPDG(313),
-  fChain(0x0),
-  fESD(0x0),
   fCFManager(0x0),
   fHistEventsProcessed(0x0)
 {
@@ -64,10 +57,13 @@ AliCFRsnTask::AliCFRsnTask(const Char_t* name) :
   // Constructor. Initialization of Inputs and Outputs
   //
   Info("AliCFRsnTask","Calling Constructor");
-  DefineInput (0,TChain::Class());
-  DefineOutput(0,TH1I::Class());
-  DefineOutput(1,AliCFContainer::Class());
-  //   DefineOutput(2,TList::Class());
+  /*
+    DefineInput(0) and DefineOutput(0)
+    are taken care of by AliAnalysisTaskSE constructor
+  */
+  DefineOutput(1,TH1I::Class());
+  DefineOutput(2,AliCFContainer::Class());
+  //   DefineOutput(3,TList::Class());
 }
 
 //___________________________________________________________________________
@@ -77,10 +73,8 @@ AliCFRsnTask& AliCFRsnTask::operator=(const AliCFRsnTask& c)
   // Assignment operator
   //
   if (this!=&c) {
-    AliAnalysisTask::operator=(c) ;
+    AliAnalysisTaskSE::operator=(c) ;
     fRsnPDG     = c.fRsnPDG;
-    fChain      = c.fChain;
-    fESD        = c.fESD;
     fCFManager  = c.fCFManager;
     fHistEventsProcessed = c.fHistEventsProcessed;
   }
@@ -89,10 +83,8 @@ AliCFRsnTask& AliCFRsnTask::operator=(const AliCFRsnTask& c)
 
 //___________________________________________________________________________
 AliCFRsnTask::AliCFRsnTask(const AliCFRsnTask& c) :
-  AliAnalysisTask(c),
+  AliAnalysisTaskSE(c),
   fRsnPDG(c.fRsnPDG),
-  fChain(c.fChain),
-  fESD(c.fESD),
   fCFManager(c.fCFManager),
   fHistEventsProcessed(c.fHistEventsProcessed)
 {
@@ -107,49 +99,36 @@ AliCFRsnTask::~AliCFRsnTask() {
   //destructor
   //
   Info("~AliCFRsnTask","Calling Destructor");
-  if (fChain)               delete fChain ;
-  if (fESD)                 delete fESD ;
   if (fCFManager)           delete fCFManager ;
   if (fHistEventsProcessed) delete fHistEventsProcessed ;
 }
 
-//___________________________________________________________________________
-
-void AliCFRsnTask::Init()
-{
-
-}
 //_________________________________________________
-void AliCFRsnTask::Exec(Option_t *)
+void AliCFRsnTask::UserExec(Option_t *)
 {
   //
   // Main loop function
   //
-  Info("Exec","") ;
-  // Get the mc truth
-  AliMCEventHandler* mcTruth = (AliMCEventHandler*)((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
-
-  if (!mcTruth) Error("Exec","NO MC INFO FOUND... EXITING");
+  Info("UserExec","") ;
 
-  // transform possible old AliESD into AliESDEvent
-
-  if (fESD->GetAliESDOld()) fESD->CopyFromOldESD(); //transition to new ESD format
-
-  //pass the MC evt handler to the cuts that need it 
+  AliESDEvent* fESD = dynamic_cast<AliESDEvent*>(fInputEvent);
+  if (!fESD) {
+    Error("UserExec","NO ESD FOUND!");
+    return;
+  }
 
-  fCFManager->SetEventInfo(mcTruth);
+  if (!fMCEvent) Error("UserExec","NO MC INFO FOUND!");
+  fCFManager->SetEventInfo(fMCEvent);
 
-  // Get the MC event 
-  AliMCEvent* mcEvent = mcTruth->MCEvent();
-  AliStack*   stack   = mcEvent->Stack();
+  AliStack*   stack   = fMCEvent->Stack();
 
   // MC-event selection
   Double_t containerInput[2] ;
         
   //loop on the MC event
-  Info("Exec","Looping on MC event");
+  Info("UserExec","Looping on MC event");
   for (Int_t ipart=0; ipart<stack->GetNprimary(); ipart++) { 
-    AliMCParticle *mcPart  = mcEvent->GetTrack(ipart);
+    AliMCParticle *mcPart  = fMCEvent->GetTrack(ipart);
 
     //check the MC-level cuts
     if (!fCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,mcPart)) continue;
@@ -166,7 +145,7 @@ void AliCFRsnTask::Exec(Option_t *)
 
 
   //Now go to rec level
-  Info("Exec","Looping on ESD event");
+  Info("UserExec","Looping on ESD event");
 
   //SET THE ESD AS EVENT INFO IN RECONSTRUCTION CUTS
   TObjArray* fCutsReco = fCFManager->GetParticleCutsList(AliCFManager::kPartRecCuts);
@@ -180,7 +159,7 @@ void AliCFRsnTask::Exec(Option_t *)
   while ( (cut = (AliCFCutBase*)iter2.Next()) ) {
     cut->SetEvtInfo(fESD);
   }
-  
+
   for (Int_t iTrack1 = 0; iTrack1<fESD->GetNumberOfTracks(); iTrack1++) {
     AliESDtrack* esdTrack1 = fESD->GetTrack(iTrack1);
     //track1 is negative
@@ -195,33 +174,33 @@ void AliCFRsnTask::Exec(Option_t *)
       Int_t esdLabel2 = esdTrack2->GetLabel();
       if (esdLabel2<0) continue;
        
-      // copy ESDtrack data into RsnDaughter (and make Bayesian PID)
-      //if problem with copy constructor, use the following special command to destroy the pointer when exiting scope
-      //std::auto_ptr<AliRsnDaughter> track1(AliRsnDaughter::Adopt(esdTrack1,iTrack1));
-
-      AliRsnDaughter* tmp1=AliRsnDaughter::Adopt(esdTrack1,iTrack1);
-      AliRsnDaughter* tmp2=AliRsnDaughter::Adopt(esdTrack2,iTrack2);
+      AliRsnDaughter* tmp1 = new AliRsnDaughter(esdTrack1);
+      AliRsnDaughter* tmp2 = new AliRsnDaughter(esdTrack2);
       AliRsnDaughter track1(*tmp1);
       AliRsnDaughter track2(*tmp2);
       delete tmp1;
       delete tmp2;
 
       TParticle *part1 = stack->Particle(esdLabel1);
-      track1.SetTruePDG(part1->GetPdgCode());
+      track1.InitParticle(part1);
+      track1.GetParticle()->SetPDG(part1->GetPdgCode());
+
       Int_t mother1 = part1->GetFirstMother();
-      track1.SetMother(mother1);
+      track1.GetParticle()->SetMother(mother1);
       if (mother1 >= 0) {
        TParticle *mum = stack->Particle(mother1);
-       track1.SetMotherPDG(mum->GetPdgCode());
+       track1.GetParticle()->SetMotherPDG(mum->GetPdgCode());
       }
       
       TParticle *part2 = stack->Particle(esdLabel2);
-      track2.SetTruePDG(part2->GetPdgCode());
+      track2.InitParticle(part2);
+      track2.GetParticle()->SetPDG(part2->GetPdgCode());
+
       Int_t mother2 = part2->GetFirstMother();
-      track2.SetMother(mother2);
+      track2.GetParticle()->SetMother(mother2);
       if (mother2 >= 0) {
        TParticle *mum = stack->Particle(mother2);
-       track2.SetMotherPDG(mum->GetPdgCode());
+       track2.GetParticle()->SetMotherPDG(mum->GetPdgCode());
       }
        
       //make a mother resonance from the 2 candidate daughters
@@ -229,19 +208,19 @@ void AliCFRsnTask::Exec(Option_t *)
       AliCFPair pair(esdTrack1,esdTrack2);
 
       //check if true resonance
-      if (rsn.GetMotherPDG() != fRsnPDG) continue;
+      if (rsn.GetParticle()->MotherPDG() != fRsnPDG) continue;
       if (!fCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,&pair)) continue;
 
       //check if associated MC resonance passes the cuts
-      Int_t motherLabel=rsn.GetLabel();
+      Int_t motherLabel=rsn.Label();
       if (motherLabel<0) continue ;
-      AliMCParticle* mcRsn = mcEvent->GetTrack(motherLabel);
+      AliMCParticle* mcRsn = fMCEvent->GetTrack(motherLabel);
       if (!mcRsn) continue;
       if (!fCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,mcRsn)) continue; 
     
       //fill the container
-      containerInput[0] = rsn.GetPt() ;
-      containerInput[1] = GetRapidity(rsn.GetEnergy(),rsn.GetPz());
+      containerInput[0] = rsn.Pt() ;
+      containerInput[1] = GetRapidity(rsn.E(),rsn.Pz());
       fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructed) ;   
 
       if (!fCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,&pair)) continue ;
@@ -250,8 +229,9 @@ void AliCFRsnTask::Exec(Option_t *)
   }
     
   fHistEventsProcessed->Fill(0);
-  PostData(0,fHistEventsProcessed) ;
-  PostData(1,fCFManager->GetParticleContainer()) ;
+  /* PostData(0) is taken care of by AliAnalysisTaskSE */
+  PostData(1,fHistEventsProcessed) ;
+  PostData(2,fCFManager->GetParticleContainer()) ;
   
   //   TList * list = new TList();
   //   fCFManager->AddQAHistosToList(list);
@@ -267,8 +247,6 @@ void AliCFRsnTask::Terminate(Option_t*)
   // the results graphically or save the results to file.
 
   Info("Terminate","");
-  AliAnalysisTask::Terminate();
-
 
   Double_t max1 = fCFManager->GetParticleContainer()->ShowProjection(0,0)->GetMaximum();
   Double_t max2 = fCFManager->GetParticleContainer()->ShowProjection(1,0)->GetMaximum();
@@ -319,27 +297,14 @@ void AliCFRsnTask::Terminate(Option_t*)
 }
 
 //___________________________________________________________________________
-void AliCFRsnTask::ConnectInputData(Option_t *) {
-  //
-  // Initialize branches.
-  //
-  Info("ConnectInputData","ConnectInputData of task %s\n",GetName());
-
-  fChain = (TChain*)GetInputData(0);
-  fChain->SetBranchStatus("*FMD*",0);
-  fChain->SetBranchStatus("*CaloClusters*",0);
-  fESD = new AliESDEvent();
-  fESD->ReadFromTree(fChain);
-}
-
-//___________________________________________________________________________
-void AliCFRsnTask::CreateOutputObjects() {
+void AliCFRsnTask::UserCreateOutputObjects() {
   //HERE ONE CAN CREATE OUTPUT OBJECTS, IN PARTICULAR IF THE OBJECT PARAMETERS DON'T NEED
   //TO BE SET BEFORE THE EXECUTION OF THE TASK
   //
-  Info("CreateOutputObjects","CreateOutputObjects of task %s\n", GetName());
+  Info("UserCreateOutputObjects","CreateOutputObjects of task %s\n", GetName());
 
-  //slot #0
+  //slot #1
+  OpenFile(1);
   fHistEventsProcessed = new TH1I("fHistEventsProcessed","",1,0,1) ;
 }
 
index b6c0393..e817a69 100644 (file)
 #ifndef ALICFRSNTASK_H
 #define ALICFRSNTASK_H
 
-#include "AliAnalysisTask.h"
+#include "AliAnalysisTaskSE.h"
 
 class TH1I;
 class TParticle ;
-class TFile ;
-class AliMCEventHandler;
-class AliESDEvent;
-class AliStack ;
 class AliCFManager;
-class TChain;
-class AliRsnDaughter;
 
-class AliCFRsnTask : public AliAnalysisTask {
+class AliCFRsnTask : public AliAnalysisTaskSE {
   public:
 
   enum {
@@ -49,11 +43,8 @@ class AliCFRsnTask : public AliAnalysisTask {
   virtual ~AliCFRsnTask();
 
   // ANALYSIS FRAMEWORK STUFF to loop on data and fill output objects
-  void     ConnectInputData(Option_t *option="");
-  void     CreateOutputObjects();
-  void     Exec(Option_t *option);
-  void     Init(); //loads the CF manager
-  void     LocalInit() {Init();} //needed for the slaves 
+  void     UserCreateOutputObjects();
+  void     UserExec(Option_t *option);
   void     Terminate(Option_t *);
   
   // CORRECTION FRAMEWORK RELATED FUNCTIONS
@@ -67,8 +58,6 @@ class AliCFRsnTask : public AliAnalysisTask {
  protected:
 
   Int_t           fRsnPDG;       //  PDG code of searched resonance
-  TChain         *fChain      ;  // chained files
-  AliESDEvent    *fESD        ;  // pointer to the ESD event read
   AliCFManager   *fCFManager  ;  // pointer to the CF manager
 
   // Histograms
index 0805f56..41e25ff 100644 (file)
@@ -86,43 +86,45 @@ Bool_t AliCFSingleTrackTask(
   container -> SetBinLimits(iy,binLim2);
 
 
+  // SET TLIST FOR QA HISTOS
+  TList* qaList = new TList();
+
   //CREATE THE  CUTS -----------------------------------------------
-  //Particle-Level cuts:  
 
   // Gen-Level kinematic cuts
   AliCFTrackKineCuts *mcKineCuts = new AliCFTrackKineCuts("mcKineCuts","MC-level kinematic cuts");
   mcKineCuts->SetPtRange(ptmin,ptmax);
   mcKineCuts->SetRapidityRange(ymin,ymax);
   mcKineCuts->SetChargeMC(charge);
-  mcKineCuts->SetQAOn(kTRUE);
+  mcKineCuts->SetQAOn(qaList);
 
+  //Particle-Level cuts:  
   AliCFParticleGenCuts* mcGenCuts = new AliCFParticleGenCuts("mcGenCuts","MC particle generation cuts");
   mcGenCuts->SetRequireIsPrimary();
   mcGenCuts->SetRequirePdgCode(PDG);
+  mcGenCuts->SetQAOn(qaList);
 
   //Acceptance Cuts
   AliCFAcceptanceCuts *mcAccCuts = new AliCFAcceptanceCuts("mcAccCuts","MC acceptance cuts");
   mcAccCuts->SetMinNHitITS(mintrackrefsITS);
   mcAccCuts->SetMinNHitTPC(mintrackrefsTPC);
+  mcAccCuts->SetQAOn(qaList);
 
   // Rec-Level kinematic cuts
   AliCFTrackKineCuts *recKineCuts = new AliCFTrackKineCuts("recKineCuts","rec-level kine cuts");
   recKineCuts->SetPtRange(ptmin,ptmax);
   recKineCuts->SetRapidityRange(ymin,ymax);
   recKineCuts->SetChargeRec(charge);
-  // QA histograms for rec-level kinematic cuts
-  recKineCuts->SetQAOn(kTRUE);
+  recKineCuts->SetQAOn(qaList);
 
   AliCFTrackQualityCuts *recQualityCuts = new AliCFTrackQualityCuts("recQualityCuts","rec-level quality cuts");
   recQualityCuts->SetMinNClusterTPC(minclustersTPC);
   recQualityCuts->SetRequireITSRefit(kTRUE);
-  // QA histograms for rec-level quality cuts
-  recQualityCuts->SetQAOn(kTRUE);
+  recQualityCuts->SetQAOn(qaList);
 
   AliCFTrackIsPrimaryCuts *recIsPrimaryCuts = new AliCFTrackIsPrimaryCuts("recIsPrimaryCuts","rec-level isPrimary cuts");
   recIsPrimaryCuts->SetMaxNSigmaToVertex(3);
-  // QA histograms for rec-level primary-check cuts
-  recIsPrimaryCuts->SetQAOn(kTRUE);
+  recIsPrimaryCuts->SetQAOn(qaList);
 
   AliCFTrackCutPid* cutPID = new AliCFTrackCutPid("cutPID","ESD_PID") ;
   int n_species = AliPID::kSPECIES ;
@@ -145,7 +147,7 @@ Bool_t AliCFSingleTrackTask(
   case 2212 : cutPID->SetParticleType(AliPID::kProton  , kTRUE); break;
   default   : printf("UNDEFINED PID\n"); break;
   }
-  cutPID->SetQAOn(kTRUE);
+  cutPID->SetQAOn(qaList);
 
   printf("CREATE MC KINE CUTS\n");
   TObjArray* mcList = new TObjArray(0) ;
@@ -166,7 +168,6 @@ Bool_t AliCFSingleTrackTask(
   TObjArray* fPIDCutList = new TObjArray(0) ;
   fPIDCutList->AddLast(cutPID);
 
-
   //CREATE THE INTERFACE TO CORRECTION FRAMEWORK USED IN THE TASK
   printf("CREATE INTERFACE AND CUTS\n");
   AliCFManager* man = new AliCFManager() ;
@@ -182,35 +183,49 @@ Bool_t AliCFSingleTrackTask(
   // create the task
   AliCFSingleTrackTask *task = new AliCFSingleTrackTask("AliSingleTrackTask");
   task->SetCFManager(man); //here is set the CF manager
-
+  task->SetQAList(qaList);
 
   //SETUP THE ANALYSIS MANAGER TO READ INPUT CHAIN AND WRITE DESIRED OUTPUTS
   printf("CREATE ANALYSIS MANAGER\n");
   // Make the analysis manager
   AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
 
+  if (useGrid) mgr->SetAnalysisType(AliAnalysisManager::kGridAnalysis);
+  else mgr->SetAnalysisType(AliAnalysisManager::kLocalAnalysis);
+
+  AliMCEventHandler*  mcHandler = new AliMCEventHandler();
+  AliESDInputHandler* esdHandler = new AliESDInputHandler();
+  mgr->SetMCtruthEventHandler(mcHandler);
+  mgr->SetInputEventHandler(esdHandler);
+
   // Create and connect containers for input/output
 
-  //input data
+  //------ input data ------
   AliAnalysisDataContainer *cinput0  = mgr->CreateContainer("cchain0",TChain::Class(),AliAnalysisManager::kInputContainer);
-  // output histo (number of events processed)
-  AliAnalysisDataContainer *coutput0 = mgr->CreateContainer("chist0", TH1I::Class(),AliAnalysisManager::kOutputContainer,"output.root");
+
+  // ----- output data -----
+  
+  //slot 0 : default output tree (by default handled by AliAnalysisTaskSE)
+  AliAnalysisDataContainer *coutput0 = mgr->CreateContainer("ctree0", TTree::Class(),AliAnalysisManager::kOutputContainer,"output.root");
+
+  //now comes user's output objects :
+  
+  // output TH1I for event counting
+  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("chist0", TH1I::Class(),AliAnalysisManager::kOutputContainer,"output.root");
   // output Correction Framework Container (for acceptance & efficiency calculations)
-  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("ccontainer0", AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,"output.root");
+  AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("ccontainer0", AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,"output.root");
   // output QA histograms 
-  AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("clist0", TList::Class(),AliAnalysisManager::kOutputContainer,"output.root");
+  AliAnalysisDataContainer *coutput3 = mgr->CreateContainer("clist0", TList::Class(),AliAnalysisManager::kOutputContainer,"output.root");
+
+  cinput0->SetData(analysisChain);
 
   mgr->AddTask(task);
   mgr->ConnectInput(task,0,cinput0);
   mgr->ConnectOutput(task,0,coutput0);
   mgr->ConnectOutput(task,1,coutput1);
   mgr->ConnectOutput(task,2,coutput2);
-  cinput0->SetData(analysisChain);
+  mgr->ConnectOutput(task,3,coutput3);
  
-  //NEW INTERFACE TO MC INFORMATION
-  AliMCEventHandler* mcHandler = new AliMCEventHandler();
-  mgr->SetMCtruthEventHandler(mcHandler);
-
   printf("READY TO RUN\n");
   //RUN !!!
   if (mgr->InitAnalysis()) {
index 895d12e..d032588 100644 (file)
 
 #ifndef ALICFSINGLETRACKTASK_CXX
 #define ALICFSINGLETRACKTASK_CXX
-#include <TROOT.h>
-#include <TInterpreter.h>
 
 #include "AliCFSingleTrackTask.h"
 #include "TCanvas.h"
 #include "AliStack.h"
 #include "TParticle.h"
 #include "TH1I.h"
-#include "TChain.h"
-#include "AliMCEventHandler.h"
 #include "AliMCEvent.h"
 #include "AliAnalysisManager.h"
 #include "AliESDEvent.h"
 #include "TChain.h"
 #include "AliESDtrack.h"
 #include "AliLog.h"
+
 ClassImp(AliCFSingleTrackTask)
+
 //__________________________________________________________________________
 AliCFSingleTrackTask::AliCFSingleTrackTask() :
-  fChain(0x0),
-  fESD(0x0),
   fCFManager(0x0),
   fQAHistList(0x0),
   fHistEventsProcessed(0x0)
 {
-//Default ctor
+  //
+  //Default ctor
+  //
 }
 //___________________________________________________________________________
 AliCFSingleTrackTask::AliCFSingleTrackTask(const Char_t* name) :
-  AliAnalysisTask(name,"AliCFSingleTrackTask"),
-  fChain(0x0),
-  fESD(0x0),
+  AliAnalysisTaskSE(name),
   fCFManager(0x0),
   fQAHistList(0x0),
   fHistEventsProcessed(0x0)
@@ -69,10 +65,14 @@ AliCFSingleTrackTask::AliCFSingleTrackTask(const Char_t* name) :
   // Constructor. Initialization of Inputs and Outputs
   //
   Info("AliCFSingleTrackTask","Calling Constructor");
-  DefineInput (0,TChain::Class());
-  DefineOutput(0,TH1I::Class());
-  DefineOutput(1,AliCFContainer::Class());
-  DefineOutput(2,TList::Class());
+
+  /*
+    DefineInput(0) and DefineOutput(0)
+    are taken care of by AliAnalysisTaskSE constructor
+  */
+  DefineOutput(1,TH1I::Class());
+  DefineOutput(2,AliCFContainer::Class());
+  DefineOutput(3,TList::Class());
 }
 
 //___________________________________________________________________________
@@ -82,9 +82,7 @@ AliCFSingleTrackTask& AliCFSingleTrackTask::operator=(const AliCFSingleTrackTask
   // Assignment operator
   //
   if (this!=&c) {
-    AliAnalysisTask::operator=(c) ;
-    fChain      = c.fChain;
-    fESD        = c.fESD;
+    AliAnalysisTaskSE::operator=(c) ;
     fCFManager  = c.fCFManager;
     fQAHistList = c.fQAHistList ;
     fHistEventsProcessed = c.fHistEventsProcessed;
@@ -94,9 +92,7 @@ AliCFSingleTrackTask& AliCFSingleTrackTask::operator=(const AliCFSingleTrackTask
 
 //___________________________________________________________________________
 AliCFSingleTrackTask::AliCFSingleTrackTask(const AliCFSingleTrackTask& c) :
-  AliAnalysisTask(c),
-  fChain(c.fChain),
-  fESD(c.fESD),
+  AliAnalysisTaskSE(c),
   fCFManager(c.fCFManager),
   fQAHistList(c.fQAHistList),
   fHistEventsProcessed(c.fHistEventsProcessed)
@@ -112,63 +108,47 @@ AliCFSingleTrackTask::~AliCFSingleTrackTask() {
   //destructor
   //
   Info("~AliCFSingleTrackTask","Calling Destructor");
-  if (fChain)               delete fChain ;
-  if (fESD)                 delete fESD ;
   if (fCFManager)           delete fCFManager ;
   if (fHistEventsProcessed) delete fHistEventsProcessed ;
   if (fQAHistList) {fQAHistList->Clear(); delete fQAHistList;}
 }
 
-//___________________________________________________________________________
-
-void AliCFSingleTrackTask::Init()
-{
-
-}
 //_________________________________________________
-void AliCFSingleTrackTask::Exec(Option_t *)
+void AliCFSingleTrackTask::UserExec(Option_t *)
 {
   //
   // Main loop function
   //
-  Info("Exec","") ;
-  // Get the mc truth
-  AliMCEventHandler* mcTruth = (AliMCEventHandler*)((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
+  Info("UserExec","") ;
 
-  if (!mcTruth) Error("Exec","NO MC INFO FOUND... EXITING\n");
-
-  // transform possible old AliESD into AliESDEvent
+  AliESDEvent* fESD = dynamic_cast<AliESDEvent*>(fInputEvent);
+  if (!fESD) {
+    Error("UserExec","NO ESD FOUND!");
+    return;
+  }
 
-  if (fESD->GetAliESDOld()) fESD->CopyFromOldESD(); //transition to new ESD format
+  if (!fMCEvent) Error("UserExec","NO MC INFO FOUND");
 
   //pass the MC evt handler to the cuts that need it 
-
-  fCFManager->SetEventInfo(mcTruth);
-
-  // Get the MC event 
-  AliMCEvent* mcEvent = mcTruth->MCEvent();
+  fCFManager->SetEventInfo(fMCEvent);
 
   // MC-event selection
   Double_t containerInput[2] ;
         
   //loop on the MC event
-  for (Int_t ipart=0; ipart<mcEvent->GetNumberOfTracks(); ipart++) { 
-    AliMCParticle *mcPart  = mcEvent->GetTrack(ipart);
+  for (Int_t ipart=0; ipart<fMCEvent->GetNumberOfTracks(); ipart++) { 
+    AliMCParticle *mcPart  = fMCEvent->GetTrack(ipart);
 
     //check the MC-level cuts
-    fCFManager->FillQABeforeParticleCuts(AliCFManager::kPartGenCuts,mcPart);  
     if (!fCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,mcPart)) continue;
-    fCFManager->FillQAAfterParticleCuts(AliCFManager::kPartGenCuts,mcPart);  
 
     containerInput[0] = (Float_t)mcPart->Pt();
     containerInput[1] = mcPart->Eta() ;
     //fill the container for Gen-level selection
     fCFManager->GetParticleContainer()->Fill(containerInput,kStepGenerated);
-    
+
     //check the Acceptance-level cuts
-    fCFManager->FillQABeforeParticleCuts(AliCFManager::kPartAccCuts,mcPart);  
     if (!fCFManager->CheckParticleCuts(AliCFManager::kPartAccCuts,mcPart)) continue;
-    fCFManager->FillQAAfterParticleCuts(AliCFManager::kPartAccCuts,mcPart);  
     //fill the container for Acceptance-level selection
     fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructible);
   }    
@@ -178,13 +158,11 @@ void AliCFSingleTrackTask::Exec(Option_t *)
 
     AliESDtrack* track = fESD->GetTrack(iTrack);
     
-    fCFManager->FillQABeforeParticleCuts(AliCFManager::kPartRecCuts,track);  
     if (!fCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,track)) continue;
-    fCFManager->FillQAAfterParticleCuts(AliCFManager::kPartRecCuts,track);
 
     // is track associated to particle ?
     if (track->GetLabel()<0) continue;
-    AliMCParticle *mcPart  = mcEvent->GetTrack(track->GetLabel());
+    AliMCParticle *mcPart  = fMCEvent->GetTrack(track->GetLabel());
     
     // check if this track was part of the signal
     if (!fCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,mcPart)) continue; 
@@ -197,18 +175,16 @@ void AliCFSingleTrackTask::Exec(Option_t *)
     containerInput[1] = track->Eta();
     fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructed) ;   
 
-
-    fCFManager->FillQABeforeParticleCuts(AliCFManager::kPartSelCuts,track);  
     if (!fCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,track)) continue ;
-    fCFManager->FillQAAfterParticleCuts(AliCFManager::kPartSelCuts,track);  
-
     fCFManager->GetParticleContainer()->Fill(containerInput,kStepSelected);
   }
   
   fHistEventsProcessed->Fill(0);
-  PostData(0,fHistEventsProcessed) ;
-  PostData(1,fCFManager->GetParticleContainer()) ;
-  PostData(2,fQAHistList) ;
+
+  /* PostData(0) is taken care of by AliAnalysisTaskSE */
+  PostData(1,fHistEventsProcessed) ;
+  PostData(2,fCFManager->GetParticleContainer()) ;
+  PostData(3,fQAHistList) ;
 }
 
 
@@ -220,88 +196,82 @@ void AliCFSingleTrackTask::Terminate(Option_t*)
   // the results graphically or save the results to file.
 
   Info("Terminate","");
-  AliAnalysisTask::Terminate();
+  AliAnalysisTaskSE::Terminate();
 
   //draw some example plots....
 
-  AliCFContainer *cont= dynamic_cast<AliCFContainer*> (GetOutputData(1));
+  AliCFContainer *cont= dynamic_cast<AliCFContainer*> (GetOutputData(2));
+
+  TH1D* h00 =   cont->ShowProjection(0,0) ;
+  TH1D* h01 =   cont->ShowProjection(0,1) ;
+  TH1D* h02 =   cont->ShowProjection(0,2) ;
+  TH1D* h03 =   cont->ShowProjection(0,3) ;
 
-  Double_t max1 = cont->ShowProjection(0,0)->GetMaximum();
-  Double_t max2 = cont->ShowProjection(1,0)->GetMaximum();
+  TH1D* h10 =   cont->ShowProjection(1,0) ;
+  TH1D* h11 =   cont->ShowProjection(1,1) ;
+  TH1D* h12 =   cont->ShowProjection(1,2) ;
+  TH1D* h13 =   cont->ShowProjection(1,3) ;
 
-  cont->ShowProjection(0,0)->GetYaxis()->SetRangeUser(0,max1*1.2);
-  cont->ShowProjection(0,1)->GetYaxis()->SetRangeUser(0,max1*1.2);
-  cont->ShowProjection(0,2)->GetYaxis()->SetRangeUser(0,max1*1.2);
-  cont->ShowProjection(0,3)->GetYaxis()->SetRangeUser(0,max1*1.2);
+  Double_t max1 = h00->GetMaximum();
+  Double_t max2 = h10->GetMaximum();
 
-  cont->ShowProjection(1,0)->GetYaxis()->SetRangeUser(0,max2*1.2);
-  cont->ShowProjection(1,1)->GetYaxis()->SetRangeUser(0,max2*1.2);
-  cont->ShowProjection(1,2)->GetYaxis()->SetRangeUser(0,max2*1.2);
-  cont->ShowProjection(1,3)->GetYaxis()->SetRangeUser(0,max2*1.2);
+  h00->GetYaxis()->SetRangeUser(0,max1*1.2);
+  h01->GetYaxis()->SetRangeUser(0,max1*1.2);
+  h02->GetYaxis()->SetRangeUser(0,max1*1.2);
+  h03->GetYaxis()->SetRangeUser(0,max1*1.2);
 
-  cont->ShowProjection(0,0)->SetMarkerStyle(23) ;
-  cont->ShowProjection(0,1)->SetMarkerStyle(24) ;
-  cont->ShowProjection(0,2)->SetMarkerStyle(25) ;
-  cont->ShowProjection(0,3)->SetMarkerStyle(26) ;
+  h10->GetYaxis()->SetRangeUser(0,max2*1.2);
+  h11->GetYaxis()->SetRangeUser(0,max2*1.2);
+  h12->GetYaxis()->SetRangeUser(0,max2*1.2);
+  h13->GetYaxis()->SetRangeUser(0,max2*1.2);
 
-  cont->ShowProjection(1,0)->SetMarkerStyle(23) ;
-  cont->ShowProjection(1,1)->SetMarkerStyle(24) ;
-  cont->ShowProjection(1,2)->SetMarkerStyle(25) ;
-  cont->ShowProjection(1,3)->SetMarkerStyle(26) ;
+  h00->SetMarkerStyle(23) ;
+  h01->SetMarkerStyle(24) ;
+  h02->SetMarkerStyle(25) ;
+  h03->SetMarkerStyle(26) ;
+
+  h10->SetMarkerStyle(23) ;
+  h11->SetMarkerStyle(24) ;
+  h12->SetMarkerStyle(25) ;
+  h13->SetMarkerStyle(26) ;
 
   TCanvas * c =new TCanvas("c","",1400,800);
   c->Divide(4,2);
 
   c->cd(1);
-  cont->ShowProjection(0,0)->Draw("p");
+  h00->Draw("p");
   c->cd(2);
-  cont->ShowProjection(0,1)->Draw("p");
+  h01->Draw("p");
   c->cd(3);
-  cont->ShowProjection(0,2)->Draw("p");
+  h02->Draw("p");
   c->cd(4);
-  cont->ShowProjection(0,3)->Draw("p");
+  h03->Draw("p");
   c->cd(5);
-  cont->ShowProjection(1,0)->Draw("p");
+  h10->Draw("p");
   c->cd(6);
-  cont->ShowProjection(1,1)->Draw("p");
+  h11->Draw("p");
   c->cd(7);
-  cont->ShowProjection(1,2)->Draw("p");
+  h12->Draw("p");
   c->cd(8);
-  cont->ShowProjection(1,3)->Draw("p");
+  h13->Draw("p");
 
   c->SaveAs("plots.eps");
-
-  delete fHistEventsProcessed ;
 }
 
-//___________________________________________________________________________
-void AliCFSingleTrackTask::ConnectInputData(Option_t *) {
-  //
-  // Initialize branches.
-  //
-  Info("ConnectInputData","ConnectInputData of task %s\n",GetName());
-
-  fChain = (TChain*)GetInputData(0);
-  fChain->SetBranchStatus("*FMD*",0);
-  fChain->SetBranchStatus("*CaloClusters*",0);
-  fESD = new AliESDEvent();
-  fESD->ReadFromTree(fChain);
-}
 
 //___________________________________________________________________________
-void AliCFSingleTrackTask::CreateOutputObjects() {
+void AliCFSingleTrackTask::UserCreateOutputObjects() {
   //HERE ONE CAN CREATE OUTPUT OBJECTS, IN PARTICULAR IF THE OBJECT PARAMETERS DON'T NEED
   //TO BE SET BEFORE THE EXECUTION OF THE TASK
   //
-  Info("CreateOutputObjects","CreateOutputObjects of task %s\n", GetName());
+  Info("CreateOutputObjects","CreateOutputObjects of task %s", GetName());
 
-  //slot #0
+  //slot #1
+  OpenFile(1);
   fHistEventsProcessed = new TH1I("fHistEventsProcessed","",1,0,1) ;
 
-  //slot #2
-  fQAHistList = new TList();
-  fCFManager->InitQAHistos();
-  fCFManager->AddQAHistosToList(fQAHistList);
+//   OpenFile(2);
+//   OpenFile(3);
 }
 
 #endif
index e666161..ebd6aa3 100644 (file)
 #ifndef ALICFSINGLETRACKTASK_H
 #define ALICFSINGLETRACKTASK_H
 
-#include "AliAnalysisTask.h"
+#include "AliAnalysisTaskSE.h"
 
 class TH1I;
 class TParticle ;
 class TFile ;
-class AliMCEventHandler;
-class AliESDEvent;
 class AliStack ;
 class AliCFManager;
-class TChain;
 class AliESDtrack;
 
-class AliCFSingleTrackTask : public AliAnalysisTask {
+class AliCFSingleTrackTask : public AliAnalysisTaskSE {
   public:
 
   enum {
@@ -49,26 +46,22 @@ class AliCFSingleTrackTask : public AliAnalysisTask {
   virtual ~AliCFSingleTrackTask();
 
   // ANALYSIS FRAMEWORK STUFF to loop on data and fill output objects
-  void     ConnectInputData(Option_t *option="");
-  void     CreateOutputObjects();
-  void     Exec(Option_t *option);
-  void     Init(); //loads the CF manager
-  void     LocalInit() {Init();} //needed for the slaves 
+  void     UserCreateOutputObjects();
+  void     UserExec(Option_t *option);
   void     Terminate(Option_t *);
   
   // CORRECTION FRAMEWORK RELATED FUNCTIONS
   void           SetCFManager(AliCFManager* io) {fCFManager = io;}   // global correction manager
   AliCFManager * GetCFManager()                 {return fCFManager;} // get corr manager
- protected:
+  void           SetQAList(TList* list) {fQAHistList = list;}
 
-  TChain         *fChain      ;  //! chained files
-  AliESDEvent    *fESD        ;  //! pointer to the ESD event read
+ protected:
   AliCFManager   *fCFManager  ;  // pointer to the CF manager
   TList          *fQAHistList ;  // list of QA histograms
 
   // Histograms
   //Number of events
-  TH1I *fHistEventsProcessed; //! simple histo for monitoring the number of events processed
+  TH1I  *fHistEventsProcessed; // simple histo for monitoring the number of events processed
   
   ClassDef(AliCFSingleTrackTask,1);
 };
index 9138a96..eac6970 100644 (file)
@@ -7,7 +7,7 @@ const Double_t phimin =   0 ;
 const Double_t phimax = 360 ;
 const Int_t    mintrackrefsTPC = 2 ;
 const Int_t    mintrackrefsITS = 3 ;
-const Int_t    PDG = 3122; 
+const Int_t    PDG = 310; 
 const Int_t    minclustersTPC = 10 ;
 const Int_t    chargeV0 = 0 ;
 //----------------------------------------------------
@@ -90,7 +90,7 @@ Bool_t AliCFV0Task(
   mcKineCuts->SetChargeMC(0);
 
   AliCFParticleGenCuts* mcGenCuts = new AliCFParticleGenCuts("mcGenCuts","MC particle generation cuts");
-  mcGenCuts->SetRequireIsPrimary();
+  //mcGenCuts->SetRequireIsPrimary(); //problem with some particles...
   mcGenCuts->SetRequirePdgCode(PDG);
 
   //Acceptance Cuts
@@ -102,6 +102,7 @@ Bool_t AliCFV0Task(
   AliCFTrackKineCuts *recKineCuts = new AliCFTrackKineCuts("recKineCuts","V0 rec-level kine cuts");
   recKineCuts->SetPtRange(ptmin,ptmax);
   recKineCuts->SetRapidityRange(ymin,ymax);
+  recKineCuts->SetChargeRec(0);
 
   AliCFPairQualityCuts *recQualityCuts = new AliCFPairQualityCuts("recQualityCuts","V0 rec-level quality cuts");
   recQualityCuts->SetMinNClusterTPC(minclustersTPC,minclustersTPC);
@@ -169,7 +170,7 @@ Bool_t AliCFV0Task(
   // create the task
   AliCFV0Task *task = new AliCFV0Task("AliCFV0Task");
   task->SetCFManager(man); //here is set the CF manager
-  task->SetRebuildV0s(0);
+  task->SetRebuildV0s(kTRUE);
   task->SetV0PDG(PDG);
 
   //SETUP THE ANALYSIS MANAGER TO READ INPUT CHAIN AND WRITE DESIRED OUTPUTS
@@ -177,28 +178,38 @@ Bool_t AliCFV0Task(
   // Make the analysis manager
   AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
 
+  if (useGrid) mgr->SetAnalysisType(AliAnalysisManager::kGridAnalysis);
+  else mgr->SetAnalysisType(AliAnalysisManager::kLocalAnalysis);
+
+  AliMCEventHandler* mcHandler = new AliMCEventHandler();
+  AliESDInputHandler* esdHandler = new AliESDInputHandler();
+  mgr->SetMCtruthEventHandler(mcHandler);
+  mgr->SetInputEventHandler(esdHandler);
+
+
   // Create and connect containers for input/output
 
   //input data
-  AliAnalysisDataContainer *cinput0  = mgr->CreateContainer("cchain0",TChain::Class(),AliAnalysisManager::kInputContainer);
+  AliAnalysisDataContainer *cinput0  = 
+    mgr->CreateContainer("cchain0",TChain::Class(),AliAnalysisManager::kInputContainer);
+  //slot 0 : default output tree (by default handled by AliAnalysisTaskSE)
+  AliAnalysisDataContainer *coutput0 = mgr->CreateContainer("ctree0", TTree::Class(),AliAnalysisManager::kOutputContainer,"outputV0.root");
   // output histo (number of events processed)
-  AliAnalysisDataContainer *coutput0 = mgr->CreateContainer("chist0", TH1I::Class(),AliAnalysisManager::kOutputContainer,"outputV0.root");
+  AliAnalysisDataContainer *coutput1 = 
+    mgr->CreateContainer("chist0", TH1I::Class(),AliAnalysisManager::kOutputContainer,"outputV0.root");
   // output Correction Framework Container (for acceptance & efficiency calculations)
-  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("ccontainer0", AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,"outputV0.root");
-  // output QA histograms 
-//   AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("clist0", TList::Class(),AliAnalysisManager::kOutputContainer,"outputV0.root");
+  AliAnalysisDataContainer *coutput2 = 
+    mgr->CreateContainer("ccontainer0", AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,"outputV0.root");
+
+  cinput0->SetData(analysisChain);
 
   mgr->AddTask(task);
-  mgr->ConnectInput(task,0,cinput0);
+  mgr->ConnectInput (task,0,cinput0 );
   mgr->ConnectOutput(task,0,coutput0);
   mgr->ConnectOutput(task,1,coutput1);
+  mgr->ConnectOutput(task,2,coutput2);
 
-  cinput0->SetData(analysisChain);
  
-  //NEW INTERFACE TO MC INFORMATION
-  AliMCEventHandler* mcHandler = new AliMCEventHandler();
-  mgr->SetMCtruthEventHandler(mcHandler);
-
   Info("AliCFV0Task","READY TO RUN");
   //RUN !!!
   if (mgr->InitAnalysis()) {
@@ -219,6 +230,7 @@ void Load(Bool_t useGrid) {
   
   //load the required aliroot libraries
   gSystem->Load("libANALYSIS") ;
+  gSystem->Load("libANALYSISalice") ;
   
   gSystem->SetIncludePath("-I. -I$ALICE_ROOT/include -I$ROOTSYS/include -I$ALICE_ROOT/PWG2/RESONANCES -I$ALICE_ROOT/CORRFW");
 
index 518d234..6aed01c 100644 (file)
 
 #ifndef ALICFV0TASK_CXX
 #define ALICFV0TASK_CXX
-#include <TROOT.h>
-#include <TInterpreter.h>
 
 #include "AliCFV0Task.h"
 #include "TCanvas.h"
 #include "AliStack.h"
 #include "TParticle.h"
 #include "TH1I.h"
-#include "TChain.h"
-#include "AliMCEventHandler.h"
 #include "AliMCEvent.h"
-#include "AliAnalysisManager.h"
-#include "AliESDEvent.h"
 #include "AliCFManager.h"
-#include "AliCFCutBase.h"
 #include "AliCFContainer.h"
-#include "TChain.h"
 #include "AliESDtrack.h"
 #include "AliLog.h"
 #include "AliESDv0.h"
 #include "AliV0vertexer.h"
 #include "AliCFPair.h"
+#include "AliESDEvent.h"
+#include "TChain.h"
+#include "AliCFParticleGenCuts.h"
 
 //__________________________________________________________________________
 AliCFV0Task::AliCFV0Task() :
+  AliAnalysisTaskSE(),
   fRebuildV0s(0),
   fV0PDG(310),
-  fChain(0x0),
-  fESD(0x0),
   fCFManager(0x0),
   fHistEventsProcessed(0x0)
 {
-//Defual ctor
+  //
+  //Default ctor
+  //
 }
 //___________________________________________________________________________
 AliCFV0Task::AliCFV0Task(const Char_t* name) :
-  AliAnalysisTask(name,"AliCFV0Task"),
+  AliAnalysisTaskSE(name),
   fRebuildV0s(0),
   fV0PDG(310),
-  fChain(0x0),
-  fESD(0x0),
   fCFManager(0x0),
   fHistEventsProcessed(0x0)
 {
@@ -74,10 +68,13 @@ AliCFV0Task::AliCFV0Task(const Char_t* name) :
   // Constructor. Initialization of Inputs and Outputs
   //
   Info("AliCFV0Task","Calling Constructor");
-  DefineInput (0,TChain::Class());
-  DefineOutput(0,TH1I::Class());
-  DefineOutput(1,AliCFContainer::Class());
-//   DefineOutput(2,TList::Class());
+  /*
+    DefineInput(0) and DefineOutput(0)
+    are taken care of by AliAnalysisTaskSE constructor
+  */
+  DefineOutput(1,TH1I::Class());
+  DefineOutput(2,AliCFContainer::Class());
+//   DefineOutput(3,TList::Class());
 }
 
 //___________________________________________________________________________
@@ -87,11 +84,9 @@ AliCFV0Task& AliCFV0Task::operator=(const AliCFV0Task& c)
   // Assignment operator
   //
   if (this!=&c) {
-    AliAnalysisTask::operator=(c) ;
+    AliAnalysisTaskSE::operator=(c) ;
     fRebuildV0s = c.fRebuildV0s;
     fV0PDG      = c.fV0PDG;
-    fChain      = c.fChain;
-    fESD        = c.fESD;
     fCFManager  = c.fCFManager;
     fHistEventsProcessed = c.fHistEventsProcessed;
   }
@@ -100,11 +95,9 @@ AliCFV0Task& AliCFV0Task::operator=(const AliCFV0Task& c)
 
 //___________________________________________________________________________
 AliCFV0Task::AliCFV0Task(const AliCFV0Task& c) :
-  AliAnalysisTask(c),
+  AliAnalysisTaskSE(c),
   fRebuildV0s(c.fRebuildV0s),
   fV0PDG(c.fV0PDG),
-  fChain(c.fChain),
-  fESD(c.fESD),
   fCFManager(c.fCFManager),
   fHistEventsProcessed(c.fHistEventsProcessed)
 {
@@ -119,48 +112,34 @@ AliCFV0Task::~AliCFV0Task() {
   //destructor
   //
   Info("~AliCFV0Task","Calling Destructor");
-  if (fChain)               delete fChain ;
-  if (fESD)                 delete fESD ;
   if (fCFManager)           delete fCFManager ;
   if (fHistEventsProcessed) delete fHistEventsProcessed ;
 }
 
-//___________________________________________________________________________
-
-void AliCFV0Task::Init()
-{
-
-}
 //_________________________________________________
-void AliCFV0Task::Exec(Option_t *)
+void AliCFV0Task::UserExec(Option_t *)
 {
   //
   // Main loop function
   //
-  Info("Exec","") ;
-  // Get the mc truth
-  AliMCEventHandler* mcTruth = (AliMCEventHandler*)((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
-
-  if (!mcTruth) Error("Exec","NO MC INFO FOUND... EXITING");
-
-  // transform possible old AliESD into AliESDEvent
+  Info("UserExec","") ;
 
-  if (fESD->GetAliESDOld()) fESD->CopyFromOldESD(); //transition to new ESD format
-
-  //pass the MC evt handler to the cuts that need it 
-
-  fCFManager->SetEventInfo(mcTruth);
+  AliESDEvent* fESD = dynamic_cast<AliESDEvent*>(fInputEvent);
+  if (!fESD) {
+    Error("UserExec","NO ESD FOUND!");
+    return;
+  }
 
-  // Get the MC event 
-  AliMCEvent* mcEvent = mcTruth->MCEvent();
+  if (!fMCEvent) Error("UserExec","NO MC INFO FOUND!");
+  fCFManager->SetEventInfo(fMCEvent);
 
   // MC-event selection
   Double_t containerInput[2] ;
         
   //loop on the MC event
-  Info("Exec","Looping on MC event");
-  for (Int_t ipart=0; ipart<mcEvent->GetNumberOfTracks(); ipart++) { 
-    AliMCParticle *mcPart  = mcEvent->GetTrack(ipart);
+  Info("UserExec","Looping on MC event");
+  for (Int_t ipart=0; ipart<fMCEvent->GetNumberOfTracks(); ipart++) { 
+    AliMCParticle *mcPart  = fMCEvent->GetTrack(ipart);
 
     //check the MC-level cuts
     if (!fCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,mcPart)) continue;
@@ -177,16 +156,16 @@ void AliCFV0Task::Exec(Option_t *)
 
 
   //Now go to rec level
-  Info("Exec","Looping on ESD event");
+  Info("UserExec","Looping on ESD event");
 
-  if (fRebuildV0s) RebuildV0s() ;
-  printf("There are %d V0s in event\n",fESD->GetNumberOfV0s());
+  if (fRebuildV0s) RebuildV0s(fESD) ;
+  Info("UserExec","There are %d V0s in event",fESD->GetNumberOfV0s());
   for (Int_t iV0 = 0; iV0<fESD->GetNumberOfV0s(); iV0++) {
 
     AliESDv0* esdV0 = fESD->GetV0(iV0);
 
     //check if mother reconstructed V0 can be associated to a MC V0
-    Int_t labMCV0 = IsMcV0(esdV0,fESD,mcEvent->Stack()) ;
+    Int_t labMCV0 = IsMcV0(esdV0) ;
     if (labMCV0 <0) continue;
 
     esdV0->ChangeMassHypothesis(fV0PDG); //important to do that before entering the cut check
@@ -195,9 +174,11 @@ void AliCFV0Task::Exec(Option_t *)
     if (!fCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,&pair)) continue;
 
     //check if associated MC v0 passes the cuts
-    AliMCParticle* mcV0 = mcEvent->GetTrack(labMCV0);
+    AliMCParticle* mcV0 = fMCEvent->GetTrack(labMCV0);
     if (!mcV0) continue;
 
+    Info("UserExec","is v0 primary : %d",AliCFParticleGenCuts::IsPrimary(mcV0,fMCEvent->Stack()));
+
     if (!fCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,mcV0)) continue; 
     
     //fill the container
@@ -215,12 +196,9 @@ void AliCFV0Task::Exec(Option_t *)
   }
   
   fHistEventsProcessed->Fill(0);
-  PostData(0,fHistEventsProcessed) ;
-  PostData(1,fCFManager->GetParticleContainer()) ;
-  
-//   TList * list = new TList();
-//   fCFManager->AddQAHistosToList(list);
-//   PostData(2,list) ;
+  /* PostData(0) is taken care of by AliAnalysisTaskSE */
+  PostData(1,fHistEventsProcessed) ;
+  PostData(2,fCFManager->GetParticleContainer()) ;
 }
 
 
@@ -232,97 +210,98 @@ void AliCFV0Task::Terminate(Option_t*)
   // the results graphically or save the results to file.
 
   Info("Terminate","");
-  AliAnalysisTask::Terminate();
+  AliAnalysisTaskSE::Terminate();
+
+
+  //draw some example plots....
+
+  AliCFContainer *cont= dynamic_cast<AliCFContainer*> (GetOutputData(2));
+
+  TH1D* h00 =   cont->ShowProjection(0,0) ;
+  TH1D* h01 =   cont->ShowProjection(0,1) ;
+  TH1D* h02 =   cont->ShowProjection(0,2) ;
+  TH1D* h03 =   cont->ShowProjection(0,3) ;
 
+  TH1D* h10 =   cont->ShowProjection(1,0) ;
+  TH1D* h11 =   cont->ShowProjection(1,1) ;
+  TH1D* h12 =   cont->ShowProjection(1,2) ;
+  TH1D* h13 =   cont->ShowProjection(1,3) ;
 
-  Double_t max1 = fCFManager->GetParticleContainer()->ShowProjection(0,0)->GetMaximum();
-  Double_t max2 = fCFManager->GetParticleContainer()->ShowProjection(1,0)->GetMaximum();
+  Double_t max1 = h00->GetMaximum();
+  Double_t max2 = h10->GetMaximum();
 
-  fCFManager->GetParticleContainer()->ShowProjection(0,0)->GetYaxis()->SetRangeUser(0,max1*1.2);
-  fCFManager->GetParticleContainer()->ShowProjection(0,1)->GetYaxis()->SetRangeUser(0,max1*1.2);
-  fCFManager->GetParticleContainer()->ShowProjection(0,2)->GetYaxis()->SetRangeUser(0,max1*1.2);
-  fCFManager->GetParticleContainer()->ShowProjection(0,3)->GetYaxis()->SetRangeUser(0,max1*1.2);
+  h00->GetYaxis()->SetRangeUser(0,max1*1.2);
+  h01->GetYaxis()->SetRangeUser(0,max1*1.2);
+  h02->GetYaxis()->SetRangeUser(0,max1*1.2);
+  h03->GetYaxis()->SetRangeUser(0,max1*1.2);
 
-  fCFManager->GetParticleContainer()->ShowProjection(1,0)->GetYaxis()->SetRangeUser(0,max2*1.2);
-  fCFManager->GetParticleContainer()->ShowProjection(1,1)->GetYaxis()->SetRangeUser(0,max2*1.2);
-  fCFManager->GetParticleContainer()->ShowProjection(1,2)->GetYaxis()->SetRangeUser(0,max2*1.2);
-  fCFManager->GetParticleContainer()->ShowProjection(1,3)->GetYaxis()->SetRangeUser(0,max2*1.2);
+  h10->GetYaxis()->SetRangeUser(0,max2*1.2);
+  h11->GetYaxis()->SetRangeUser(0,max2*1.2);
+  h12->GetYaxis()->SetRangeUser(0,max2*1.2);
+  h13->GetYaxis()->SetRangeUser(0,max2*1.2);
 
-  fCFManager->GetParticleContainer()->ShowProjection(0,0)->SetMarkerStyle(23) ;
-  fCFManager->GetParticleContainer()->ShowProjection(0,1)->SetMarkerStyle(24) ;
-  fCFManager->GetParticleContainer()->ShowProjection(0,2)->SetMarkerStyle(25) ;
-  fCFManager->GetParticleContainer()->ShowProjection(0,3)->SetMarkerStyle(26) ;
+  h00->SetMarkerStyle(23) ;
+  h01->SetMarkerStyle(24) ;
+  h02->SetMarkerStyle(25) ;
+  h03->SetMarkerStyle(26) ;
 
-  fCFManager->GetParticleContainer()->ShowProjection(1,0)->SetMarkerStyle(23) ;
-  fCFManager->GetParticleContainer()->ShowProjection(1,1)->SetMarkerStyle(24) ;
-  fCFManager->GetParticleContainer()->ShowProjection(1,2)->SetMarkerStyle(25) ;
-  fCFManager->GetParticleContainer()->ShowProjection(1,3)->SetMarkerStyle(26) ;
+  h10->SetMarkerStyle(23) ;
+  h11->SetMarkerStyle(24) ;
+  h12->SetMarkerStyle(25) ;
+  h13->SetMarkerStyle(26) ;
 
   TCanvas * c =new TCanvas("c","",1400,800);
   c->Divide(4,2);
 
   c->cd(1);
-  fCFManager->GetParticleContainer()->ShowProjection(0,0)->Draw("p");
+  h00->Draw("p");
   c->cd(2);
-  fCFManager->GetParticleContainer()->ShowProjection(0,1)->Draw("p");
+  h01->Draw("p");
   c->cd(3);
-  fCFManager->GetParticleContainer()->ShowProjection(0,2)->Draw("p");
+  h02->Draw("p");
   c->cd(4);
-  fCFManager->GetParticleContainer()->ShowProjection(0,3)->Draw("p");
+  h03->Draw("p");
   c->cd(5);
-  fCFManager->GetParticleContainer()->ShowProjection(1,0)->Draw("p");
+  h10->Draw("p");
   c->cd(6);
-  fCFManager->GetParticleContainer()->ShowProjection(1,1)->Draw("p");
+  h11->Draw("p");
   c->cd(7);
-  fCFManager->GetParticleContainer()->ShowProjection(1,2)->Draw("p");
+  h12->Draw("p");
   c->cd(8);
-  fCFManager->GetParticleContainer()->ShowProjection(1,3)->Draw("p");
+  h13->Draw("p");
 
   c->SaveAs("plots.eps");
-
-  delete fHistEventsProcessed ;
 }
 
 //___________________________________________________________________________
-void AliCFV0Task::ConnectInputData(Option_t *) {
-  //
-  // Initialize branches.
-  //
-  Info("ConnectInputData","ConnectInputData of task %s\n",GetName());
-
-  fChain = (TChain*)GetInputData(0);
-  fChain->SetBranchStatus("*FMD*",0);
-  fChain->SetBranchStatus("*CaloClusters*",0);
-  fESD = new AliESDEvent();
-  fESD->ReadFromTree(fChain);
-}
-
-//___________________________________________________________________________
-void AliCFV0Task::CreateOutputObjects() {
+void AliCFV0Task::UserCreateOutputObjects() {
   //HERE ONE CAN CREATE OUTPUT OBJECTS, IN PARTICULAR IF THE OBJECT PARAMETERS DON'T NEED
   //TO BE SET BEFORE THE EXECUTION OF THE TASK
   //
-  Info("CreateOutputObjects","CreateOutputObjects of task %s\n", GetName());
+  Info("UserCreateOutputObjects","CreateOutputObjects of task %s\n", GetName());
 
-  //slot #0
+  //slot #1
+  OpenFile(1);
   fHistEventsProcessed = new TH1I("fHistEventsProcessed","",1,0,1) ;
 }
 
 //___________________________________________________________________________
-Int_t AliCFV0Task::GetV0Label(UInt_t lab1, UInt_t lab2, AliStack* stack) const {
+Int_t AliCFV0Task::GetV0Label(UInt_t lab1, UInt_t lab2) const {
   //
   // returns the label of the V0, given the labels of the 2 daughter tracks
   // returns -1 if the V0 is fake
   //
   
+  AliStack* stack = fMCEvent->Stack();
   TParticle* part1 = stack->Particle(lab1) ;
   TParticle* part2 = stack->Particle(lab2) ;
   
   Int_t part1MotherLab=part1->GetFirstMother();
   Int_t part2MotherLab=part2->GetFirstMother();
-  
+
   if (part1MotherLab==-1 || part2MotherLab==-1) return -1 ;
   if (part1MotherLab != part2MotherLab )        return -1 ;
+  
   if (stack->Particle(part1MotherLab)->GetPdgCode() != fV0PDG ) return -1 ;
 
   switch (fV0PDG) {
@@ -361,11 +340,14 @@ Double_t AliCFV0Task::GetRapidity(Double_t energy, Double_t pz) {
 } 
 
 //___________________________________________________________________________
-Int_t AliCFV0Task::IsMcV0(AliESDv0* v0, AliESDEvent* esd, AliStack* stack) const {
+Int_t AliCFV0Task::IsMcV0(AliESDv0* v0) const {
+
+  AliESDEvent* fESD = dynamic_cast<AliESDEvent*>(fInputEvent);
+
   Int_t nindex = v0->GetNindex();
   Int_t pindex = v0->GetPindex();
-  AliESDtrack *nTrack = esd->GetTrack(nindex) ;
-  AliESDtrack *pTrack = esd->GetTrack(pindex) ;
+  AliESDtrack *nTrack = fESD->GetTrack(nindex) ;
+  AliESDtrack *pTrack = fESD->GetTrack(pindex) ;
   
   if (!nTrack || !pTrack) return -1 ;
 
@@ -374,23 +356,22 @@ Int_t AliCFV0Task::IsMcV0(AliESDv0* v0, AliESDEvent* esd, AliStack* stack) const
   
   if (nlab <0 || plab <0) return -1 ;
 
-  Int_t v0Label = GetV0Label((UInt_t)nlab,(UInt_t)plab,stack) ;
-  return v0Label ;
+  return GetV0Label((UInt_t)nlab,(UInt_t)plab) ;
 }
 
 
 //___________________________________________________________________________
-void AliCFV0Task::RebuildV0s() {
+void AliCFV0Task::RebuildV0s(AliESDEvent* fESD) {
   
   fESD->ResetV0s();
 
   //These are pp cuts : to change if Pb+Pb !
   Double_t cuts[]={33,  // max. allowed chi2
-                  0.1,// min. allowed negative daughter's impact parameter 
-                  0.1,// min. allowed positive daughter's impact parameter 
-                  0.1,// max. allowed DCA between the daughter tracks
-                  0.999,// max. allowed cosine of V0's pointing angle
-                  0.9,  // min. radius of the fiducial volume
+                  0.01,// min. allowed negative daughter's impact parameter 
+                  0.01,// min. allowed positive daughter's impact parameter 
+                  0.5,// max. allowed DCA between the daughter tracks
+                  0.98,// max. allowed cosine of V0's pointing angle
+                  0.2,  // min. radius of the fiducial volume
                   100.   // max. radius of the fiducial volume
   };
   //   AliV0vertexer* v0Vertexer = new AliV0vertexer(cuts);
index ed01ab0..c96148b 100644 (file)
 #ifndef ALICFV0TASK_H
 #define ALICFV0TASK_H
 
-#include "AliAnalysisTask.h"
+#include "AliAnalysisTaskSE.h"
 
 class TH1I;
 class TParticle ;
 class TFile ;
 class AliMCEventHandler;
-class AliESDEvent;
-class AliStack ;
 class AliCFManager;
-class TChain;
 class AliESDv0;
+class AliESDEvent;
 
-class AliCFV0Task : public AliAnalysisTask {
+class AliCFV0Task : public AliAnalysisTaskSE {
   public:
 
   enum {
@@ -49,11 +47,8 @@ class AliCFV0Task : public AliAnalysisTask {
   virtual ~AliCFV0Task();
 
   // ANALYSIS FRAMEWORK STUFF to loop on data and fill output objects
-  void     ConnectInputData(Option_t *option="");
-  void     CreateOutputObjects();
-  void     Exec(Option_t *option);
-  void     Init(); //loads the CF manager
-  void     LocalInit() {Init();} //needed for the slaves 
+  void     UserCreateOutputObjects();
+  void     UserExec(Option_t *option);
   void     Terminate(Option_t *);
   
   // CORRECTION FRAMEWORK RELATED FUNCTIONS
@@ -62,18 +57,16 @@ class AliCFV0Task : public AliAnalysisTask {
 
   void     SetRebuildV0s(Bool_t flag)       {fRebuildV0s = flag;}       // setter for V0 on-the-fly reconstruction
   void     SetV0PDG(Int_t code)             {fV0PDG = code; }           // defines the PDG code of searched V0's
-  Int_t    IsMcV0(AliESDv0*, AliESDEvent*, AliStack*) const ;           // checks if the AliESDv0 can be associated, returns mother label
-  Int_t    GetV0Label(UInt_t, UInt_t, AliStack*) const ;                // returns label of V0 given 2 daughter labels
+  Int_t    IsMcV0(AliESDv0*) const ;           // checks if the AliESDv0 can be associated, returns mother label
+  Int_t    GetV0Label(UInt_t, UInt_t) const ;                // returns label of V0 given 2 daughter labels
   static   Double_t GetRapidity(Double_t, Double_t) ;  // returns the rapidity of the V0 (assuming PDG code)
 
 
  protected:
-  void          RebuildV0s() ;   // reconstructs V0's on-fly
+  void          RebuildV0s(AliESDEvent*) ;   // reconstructs V0's on-fly
 
   Bool_t          fRebuildV0s;   //  flag for on-the-fly V0 reconstruction
   Int_t           fV0PDG;        //  PDG code of searched V0's
-  TChain         *fChain      ;  // chained files
-  AliESDEvent    *fESD        ;  // pointer to the ESD event read
   AliCFManager   *fCFManager  ;  // pointer to the CF manager
 
   // Histograms