]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
First version of the task for the corrections - proton analysis
authorpchrist <pchrist@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 4 Aug 2008 16:19:29 +0000 (16:19 +0000)
committerpchrist <pchrist@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 4 Aug 2008 16:19:29 +0000 (16:19 +0000)
PWG2/AliProtonCorrectionTask.cxx [new file with mode: 0644]
PWG2/AliProtonCorrectionTask.h [new file with mode: 0644]
PWG2/runProtonCorrection.C [new file with mode: 0755]

diff --git a/PWG2/AliProtonCorrectionTask.cxx b/PWG2/AliProtonCorrectionTask.cxx
new file mode 100644 (file)
index 0000000..8a0f664
--- /dev/null
@@ -0,0 +1,328 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+//-----------------------------------------------------------------------
+// Example of task (running locally, on AliEn and CAF),
+// which provides standard way of calculating acceptance and efficiency
+// between different steps of the procedure.
+// The ouptut of the task is a AliCFContainer from which the efficiencies
+// can be calculated
+//-----------------------------------------------------------------------
+// Author : R. Vernet, Consorzio Cometa - Catania (it)
+//-----------------------------------------------------------------------
+
+
+#ifndef ALIPROTONCORRECTIONTASK_CXX
+#define ALIPROTONCORRECTIONTASK_CXX
+
+#include "AliProtonCorrectionTask.h"
+#include "TCanvas.h"
+#include "AliStack.h"
+#include "TParticle.h"
+#include "TH1I.h"
+#include "AliMCEvent.h"
+#include "AliAnalysisManager.h"
+#include "AliESDEvent.h"
+#include "AliAODEvent.h"
+#include "AliCFManager.h"
+#include "AliCFCutBase.h"
+#include "AliCFContainer.h"
+#include "TChain.h"
+#include "AliESDtrack.h"
+#include "AliLog.h"
+//#include "AliTPCtrack.h"
+
+ClassImp(AliProtonCorrectionTask)
+
+//__________________________________________________________________________
+AliProtonCorrectionTask::AliProtonCorrectionTask() :
+  fReadTPCTracks(0),
+  fReadAODData(0),
+  fCFManager(0x0),
+  fQAHistList(0x0),
+  fHistEventsProcessed(0x0)
+{
+  //
+  //Default ctor
+  //
+}
+//___________________________________________________________________________
+AliProtonCorrectionTask::AliProtonCorrectionTask(const Char_t* name) :
+  AliAnalysisTaskSE(name),
+  fReadTPCTracks(0),
+  fReadAODData(0),
+  fCFManager(0x0),
+  fQAHistList(0x0),
+  fHistEventsProcessed(0x0)
+{
+  //
+  // Constructor. Initialization of Inputs and Outputs
+  //
+  Info("AliProtonCorrectionTask","Calling Constructor");
+
+  /*
+    DefineInput(0) and DefineOutput(0)
+    are taken care of by AliAnalysisTaskSE constructor
+  */
+  DefineOutput(1,TH1I::Class());
+  DefineOutput(2,AliCFContainer::Class());
+  DefineOutput(3,TList::Class());
+}
+
+//___________________________________________________________________________
+AliProtonCorrectionTask& AliProtonCorrectionTask::operator=(const AliProtonCorrectionTask& c) 
+{
+  //
+  // Assignment operator
+  //
+  if (this!=&c) {
+    AliAnalysisTaskSE::operator=(c) ;
+    fReadTPCTracks = c.fReadTPCTracks ;
+    fReadAODData = c.fReadAODData ;
+    fCFManager  = c.fCFManager;
+    fQAHistList = c.fQAHistList ;
+    fHistEventsProcessed = c.fHistEventsProcessed;
+  }
+  return *this;
+}
+
+//___________________________________________________________________________
+AliProtonCorrectionTask::AliProtonCorrectionTask(const AliProtonCorrectionTask& c) :
+  AliAnalysisTaskSE(c),
+  fReadTPCTracks(c.fReadTPCTracks),
+  fReadAODData(c.fReadAODData),
+  fCFManager(c.fCFManager),
+  fQAHistList(c.fQAHistList),
+  fHistEventsProcessed(c.fHistEventsProcessed)
+{
+  //
+  // Copy Constructor
+  //
+}
+
+//___________________________________________________________________________
+AliProtonCorrectionTask::~AliProtonCorrectionTask() {
+  //
+  //destructor
+  //
+  Info("~AliProtonCorrectionTask","Calling Destructor");
+  if (fCFManager)           delete fCFManager ;
+  if (fHistEventsProcessed) delete fHistEventsProcessed ;
+  if (fQAHistList) {fQAHistList->Clear(); delete fQAHistList;}
+}
+
+//_________________________________________________
+void AliProtonCorrectionTask::UserExec(Option_t *)
+{
+  //
+  // Main loop function
+  //
+  Info("UserExec","") ;
+
+  AliVEvent*    fEvent = fInputEvent ;
+  AliVParticle* track ;
+  
+  if (!fEvent) {
+    Error("UserExec","NO EVENT FOUND!");
+    return;
+  }
+
+  if (!fMCEvent) Error("UserExec","NO MC INFO FOUND");
+  
+  //pass the MC evt handler to the cuts that need it 
+  fCFManager->SetEventInfo(fMCEvent);
+
+  // MC-event selection
+  Double_t containerInput[2] ;
+        
+  //loop on the 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;
+    
+    containerInput[0] = Rapidity(mcPart->Px(),
+                                mcPart->Py(),
+                                mcPart->Pz());
+    containerInput[1] = (Float_t)mcPart->Pt();
+    //fill the container for Gen-level selection
+    fCFManager->GetParticleContainer()->Fill(containerInput,kStepGenerated);
+
+    //check the Acceptance-level cuts
+    if (!fCFManager->CheckParticleCuts(AliCFManager::kPartAccCuts,mcPart)) continue;
+    //fill the container for Acceptance-level selection
+    fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructible);
+  }    
+
+  //Now go to rec level
+  for (Int_t iTrack = 0; iTrack<fEvent->GetNumberOfTracks(); iTrack++) {
+    
+    track = fEvent->GetTrack(iTrack);
+    
+    if (fReadTPCTracks) {
+      if (fReadAODData) {
+       Error("UserExec","TPC-only tracks are not supported with AOD");
+       return ;
+      }
+      AliESDtrack* esdTrack    = (AliESDtrack*) track;
+      AliESDtrack* esdTrackTPC = new AliESDtrack();
+      if (!esdTrack->FillTPCOnlyTrack(*esdTrackTPC)) {
+       Error("UserExec","Could not retrieve TPC info");
+       continue;
+      }
+      track = esdTrackTPC ;
+    }
+
+    if (!fCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,track)) continue;
+    
+    // is track associated to particle ?
+
+    Int_t label = track->GetLabel();
+
+    if (label<0) continue;
+    AliMCParticle *mcPart  = fMCEvent->GetTrack(label);
+    
+    // check if this track was part of the signal
+    if (!fCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,mcPart)) continue; 
+    
+    //fill the container
+    Double_t mom[3];
+    track->PxPyPz(mom);
+    Double_t pt=TMath::Sqrt(mom[0]*mom[0]+mom[1]*mom[1]);
+    containerInput[0] = Rapidity(track->Px(),
+                                 track->Py(),
+                                 track->Pz());
+    containerInput[1] = track->Pt();
+    fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructed) ;   
+
+    if (!fCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,track)) continue ;
+    fCFManager->GetParticleContainer()->Fill(containerInput,kStepSelected);
+
+    if (fReadTPCTracks) delete track;
+  }
+  
+  fHistEventsProcessed->Fill(0);
+
+  /* PostData(0) is taken care of by AliAnalysisTaskSE */
+  PostData(1,fHistEventsProcessed) ;
+  PostData(2,fCFManager->GetParticleContainer()) ;
+  PostData(3,fQAHistList) ;
+}
+
+
+//___________________________________________________________________________
+void AliProtonCorrectionTask::Terminate(Option_t*)
+{
+  // The Terminate() function is the last function to be called during
+  // a query. It always runs on the client, it can be used to present
+  // the results graphically or save the results to file.
+
+  Info("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 = h00->GetMaximum();
+  Double_t max2 = h10->GetMaximum();
+
+  /*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);
+
+  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);
+
+  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);
+  h00->Draw("p");
+  c->cd(2);
+  h01->Draw("p");
+  c->cd(3);
+  h02->Draw("p");
+  c->cd(4);
+  h03->Draw("p");
+  c->cd(5);
+  h10->Draw("p");
+  c->cd(6);
+  h11->Draw("p");
+  c->cd(7);
+  h12->Draw("p");
+  c->cd(8);
+  h13->Draw("p");
+
+  c->SaveAs("plots.eps");
+}
+
+
+//___________________________________________________________________________
+void AliProtonCorrectionTask::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", GetName());
+
+  //slot #1
+  OpenFile(1);
+  fHistEventsProcessed = new TH1I("fHistEventsProcessed","",1,0,1) ;
+
+//   OpenFile(2);
+//   OpenFile(3);
+}
+
+//___________________________________________________________________________ 
+Double_t AliProtonCorrectionTask::Rapidity(Double_t Px, Double_t Py, Double_t Pz) {
+  //returns the rapidity of the (anti)proton
+  Double_t fMass = 9.38270000000000048e-01;
+
+  Double_t P = TMath::Sqrt(TMath::Power(Px,2) +
+                           TMath::Power(Py,2) +
+                           TMath::Power(Pz,2));
+  Double_t energy = TMath::Sqrt(P*P + fMass*fMass);
+  Double_t y = -999;
+  if(energy != Pz)
+    y = 0.5*TMath::Log((energy + Pz)/(energy - Pz));
+
+  return y;
+}
+
+#endif
diff --git a/PWG2/AliProtonCorrectionTask.h b/PWG2/AliProtonCorrectionTask.h
new file mode 100644 (file)
index 0000000..f860013
--- /dev/null
@@ -0,0 +1,80 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+//-----------------------------------------------------------------------
+// Author : R. Vernet, Consorzio Cometa - Catania (it)
+//-----------------------------------------------------------------------
+
+#ifndef ALIPROTONCORRECTIONTASK_H
+#define ALIPROTONCORRECTIONTASK_H
+
+#include "AliAnalysisTaskSE.h"
+
+class TH1I;
+class TParticle ;
+class TFile ;
+class AliStack ;
+class AliCFManager;
+class AliESDtrack;
+class AliVParticle;
+
+class AliProtonCorrectionTask : public AliAnalysisTaskSE {
+  public:
+
+  enum {
+    kStepGenerated       = 0,
+    kStepReconstructible = 1,
+    kStepReconstructed   = 2,
+    kStepSelected        = 3
+  };
+
+  AliProtonCorrectionTask();
+  AliProtonCorrectionTask(const Char_t* name);
+  AliProtonCorrectionTask& operator= (const AliProtonCorrectionTask& c);
+  AliProtonCorrectionTask(const AliProtonCorrectionTask& c);
+  virtual ~AliProtonCorrectionTask();
+
+  // ANALYSIS FRAMEWORK STUFF to loop on data and fill output objects
+  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() const {return fCFManager;}           // get corr manager
+  void           SetQAList(TList* list) {fQAHistList = list;}
+
+  // Data types
+  Bool_t IsReadTPCTracks() const {return fReadTPCTracks;}
+  Bool_t IsReadAODData()   const {return fReadAODData;}
+  void   SetReadTPCTracks (Bool_t flag=kTRUE) {fReadTPCTracks=flag;}
+  void   SetReadAODData   (Bool_t flag=kTRUE) {fReadAODData=flag;}
+
+ protected:
+  Double_t Rapidity(Double_t px, Double_t py, Double_t pz);
+
+  Bool_t          fReadTPCTracks ; // flag to loop on TPC tracks only
+  Bool_t          fReadAODData ;   // flag for AOD/ESD input files
+  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
+  
+  ClassDef(AliProtonCorrectionTask,1);
+};
+
+#endif
diff --git a/PWG2/runProtonCorrection.C b/PWG2/runProtonCorrection.C
new file mode 100755 (executable)
index 0000000..fbeda07
--- /dev/null
@@ -0,0 +1,214 @@
+Bool_t runProtonCorrection(Int_t stats = 0, const char* dataset = 0x0) {
+  //macro used to extract the correction maps
+  //using the official correction framework of ALICE
+  //for protons and antiprotons
+  //Author: Panos.Christakoglou@cern.ch
+
+  //________________________________________//
+  //Connect to proof  
+  //TProof::Reset("proof://lxb6046.cern.ch");
+  TProof::Open("proof://lxb6046.cern.ch");
+
+  // Enable the STEERBase Package
+  gProof->UploadPackage("STEERBase.par");
+  gProof->EnablePackage("STEERBase");
+  // Enable the ESD Package
+  gProof->UploadPackage("ESD.par");
+  gProof->EnablePackage("ESD");
+  // Enable the AOD Package
+  gProof->UploadPackage("AOD.par");
+  gProof->EnablePackage("AOD");
+  // Enable the Analysis Package
+  gProof->UploadPackage("ANALYSIS.par");
+  gProof->EnablePackage("ANALYSIS");
+  gProof->UploadPackage("ANALYSISalice.par");
+  gProof->EnablePackage("ANALYSISalice");
+  // Enable the CORRFW Package
+  gProof->UploadPackage("CORRFW.par");
+  gProof->EnablePackage("CORRFW");
+
+  gProof->Load("./AliProtonCorrectionTask.cxx+g");
+
+  //________________________________________//
+  //Container definition
+  //Variables of the GRID
+  //For the time being: y-pT
+  //Next step: add Vz
+  //Setting up the container grid...
+  const Double_t ymin  = -1.0;
+  const Double_t ymax  =  1.0;
+  const Double_t ptmin =  0.4;
+  const Double_t ptmax =  3.1;
+  UInt_t iy  = 0;
+  UInt_t ipT = 1;
+  //Setting up the container grid... 
+  UInt_t nstep = 4; //number of selection steps MC 
+  const Int_t nvar = 2; //number of variables on the grid:y-pT
+  const Int_t nbin1 = 8; //bins in y
+  const Int_t nbin2 = 8; //bins in pT 
+  //arrays for the number of bins in each dimension
+  Int_t iBin[nvar];
+  iBin[0]=nbin1;
+  iBin[1]=nbin2;
+  //arrays for lower bounds :
+  Double_t *binLim1=new Double_t[nbin1+1];
+  Double_t *binLim2=new Double_t[nbin2+1];
+  //values for bin lower bounds
+  for(Int_t i=0; i<=nbin1; i++) binLim1[i]=(Double_t)ymin  + (ymax-ymin)  /nbin1*(Double_t)i;
+  for(Int_t i=0; i<=nbin2; i++) binLim2[i]=(Double_t)ptmin + (ptmax-ptmin)/nbin2*(Double_t)i; 
+  //one "container" for MC
+  AliCFContainer* container = new AliCFContainer("container","container for tracks",nstep,nvar,iBin);
+  //setting the bin limits
+  container -> SetBinLimits(iy,binLim1);
+  container -> SetBinLimits(ipT,binLim2);
+
+  //________________________________________//
+  // SET TLIST FOR QA HISTOS
+  TList* qaList = new TList();
+  //Cuts
+  const Int_t    mintrackrefsTPC = 2;
+  const Int_t    mintrackrefsITS = 3;
+  const Int_t    charge  = 1;
+  const Int_t    PDG = 2212; 
+  const Int_t    minclustersTPC = 50;
+  // 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(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);
+  recKineCuts->SetQAOn(qaList);
+
+  AliCFTrackQualityCuts *recQualityCuts = new AliCFTrackQualityCuts("recQualityCuts","rec-level quality cuts");
+  recQualityCuts->SetMinNClusterTPC(minclustersTPC);
+  recQualityCuts->SetRequireITSRefit(kTRUE);
+  recQualityCuts->SetQAOn(qaList);
+
+  AliCFTrackIsPrimaryCuts *recIsPrimaryCuts = new AliCFTrackIsPrimaryCuts("recIsPrimaryCuts","rec-level isPrimary cuts");
+  recIsPrimaryCuts->SetMaxNSigmaToVertex(3);
+  recIsPrimaryCuts->SetQAOn(qaList);
+
+  AliCFTrackCutPid* cutPID = new AliCFTrackCutPid("cutPID","ESD_PID");
+  int n_species = AliPID::kSPECIES;
+  Double_t* prior = new Double_t[n_species];
+  
+  prior[0] = 0.0244519;
+  prior[1] = 0.0143988;
+  prior[2] = 0.805747 ;
+  prior[3] = 0.0928785;
+  prior[4] = 0.0625243;
+  
+  cutPID->SetPriors(prior);
+  cutPID->SetProbabilityCut(0.0);
+  cutPID->SetDetectors("ITS TPC TOF");
+  switch(TMath::Abs(PDG)) {
+  case 11   : cutPID->SetParticleType(AliPID::kElectron, kTRUE); break;
+  case 13   : cutPID->SetParticleType(AliPID::kMuon    , kTRUE); break;
+  case 211  : cutPID->SetParticleType(AliPID::kPion    , kTRUE); break;
+  case 321  : cutPID->SetParticleType(AliPID::kKaon    , kTRUE); break;
+  case 2212 : cutPID->SetParticleType(AliPID::kProton  , kTRUE); break;
+  default   : printf("UNDEFINED PID\n"); break;
+  }
+  cutPID->SetQAOn(qaList);
+
+  //________________________________________// 
+  TObjArray* mcList = new TObjArray(0);
+  mcList->AddLast(mcKineCuts);
+  mcList->AddLast(mcGenCuts);
+
+  printf("CREATE ACCEPTANCE CUTS\n");
+  TObjArray* accList = new TObjArray(0);
+  accList->AddLast(mcAccCuts);
+
+  printf("CREATE RECONSTRUCTION CUTS\n");
+  TObjArray* recList = new TObjArray(0);
+  recList->AddLast(recKineCuts);
+  recList->AddLast(recQualityCuts);
+  recList->AddLast(recIsPrimaryCuts);
+
+  printf("CREATE PID CUTS\n");
+  TObjArray* fPIDCutList = new TObjArray(0);
+  fPIDCutList->AddLast(cutPID);
+
+  //________________________________________// 
+  //CREATE THE INTERFACE TO CORRECTION FRAMEWORK USED IN THE TASK
+  AliCFManager* man = new AliCFManager();
+  man->SetParticleContainer(container);
+  man->SetParticleCutsList(AliCFManager::kPartGenCuts,mcList);
+  man->SetParticleCutsList(AliCFManager::kPartAccCuts,accList);
+  man->SetParticleCutsList(AliCFManager::kPartRecCuts,recList);
+  man->SetParticleCutsList(AliCFManager::kPartSelCuts,fPIDCutList);
+
+  //________________________________________// 
+  //CREATE THE TASK
+  AliProtonCorrectionTask *task = new AliProtonCorrectionTask("AliProtonCorrectionTask");
+  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");
+
+  AliMCEventHandler*  mcHandler = new AliMCEventHandler();
+  AliESDInputHandler* esdHandler = new AliESDInputHandler();
+  mgr->SetMCtruthEventHandler(mcHandler);
+  mgr->SetInputEventHandler(esdHandler);
+
+  //------ input data ------
+  AliAnalysisDataContainer *cinput0  = mgr->CreateContainer("cchain0",TChain::Class(),AliAnalysisManager::kInputContainer);
+
+  // ----- output data -----
+  //slot 0 : default output tree (by default handled by AliAnalysisTaskSE)
+  AliAnalysisDataContainer *coutput0 = mgr->CreateContainer("ctree0", TTree::Class(),AliAnalysisManager::kOutputContainer,"output.root");
+  // 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 *coutput2 = mgr->CreateContainer("ccontainer0", AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,"output.root");
+  // output QA histograms 
+  AliAnalysisDataContainer *coutput3 = mgr->CreateContainer("clist0", TList::Class(),AliAnalysisManager::kOutputContainer,"output.root");
+  
+  mgr->AddTask(task);
+  mgr->ConnectInput(task,0,cinput0);
+  mgr->ConnectOutput(task,0,coutput0);
+  mgr->ConnectOutput(task,1,coutput1);
+  mgr->ConnectOutput(task,2,coutput2);
+  mgr->ConnectOutput(task,3,coutput3);
+
+  //________________________________________// 
+  if (mgr->InitAnalysis()) {
+    if(dataset)
+      mgr->StartAnalysis("proof",dataset,stats);
+    else {
+      // You should get this macro and the txt file from:
+      // http://aliceinfo.cern.ch/Offline/Analysis/CAF/
+      gROOT->LoadMacro("CreateESDChain.C");
+      TChain* chain = 0x0;
+      chain = CreateESDChain("ESD82XX_30K.txt",stats);
+      chain->SetBranchStatus("*Calo*",0);
+
+      mgr->StartAnalysis("proof",chain);
+    }
+  }
+
+  return kTRUE;
+}
+