i)Code cleanup ii)Reading MC info from the same class - To be done: CORRFW interface
authorpchrist <pchrist@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 6 Jul 2008 15:40:44 +0000 (15:40 +0000)
committerpchrist <pchrist@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 6 Jul 2008 15:40:44 +0000 (15:40 +0000)
PWG2/AliAnalysisTaskProtons.cxx
PWG2/AliAnalysisTaskProtons.h
PWG2/SPECTRA/AliProtonAnalysis.cxx
PWG2/SPECTRA/AliProtonAnalysis.h
PWG2/runProtonAnalysis.C

index 56ce065..461dce4 100644 (file)
@@ -13,6 +13,9 @@
 #include "AliESDInputHandler.h"
 #include "AliAODEvent.h"
 #include "AliAODInputHandler.h"
+#include "AliMCEventHandler.h"
+#include "AliMCEvent.h"
+#include "AliStack.h"
 
 #include "AliProtonAnalysis.h"
 #include "AliAnalysisTaskProtons.h"
@@ -24,7 +27,7 @@ ClassImp(AliAnalysisTaskProtons)
 
 //________________________________________________________________________
 AliAnalysisTaskProtons::AliAnalysisTaskProtons() 
-: AliAnalysisTask(), fESD(0), fAOD(0), fAnalysisType("ESD"), 
+: AliAnalysisTask(), fESD(0), fAOD(0), fMC(0),fAnalysisType("ESD"), 
   fList(0), fAnalysis(0), 
   fElectronFunction(0), fMuonFunction(0),
   fPionFunction(0), fKaonFunction(0), fProtonFunction(0),
@@ -34,7 +37,7 @@ AliAnalysisTaskProtons::AliAnalysisTaskProtons()
 
 //________________________________________________________________________
 AliAnalysisTaskProtons::AliAnalysisTaskProtons(const char *name) 
-: AliAnalysisTask(name, ""), fESD(0), fAOD(0), fAnalysisType("ESD"), 
+: AliAnalysisTask(name, ""), fESD(0), fAOD(0), fMC(0), fAnalysisType("ESD"), 
   fList(0), fAnalysis(0), 
   fElectronFunction(0), fMuonFunction(0),
   fPionFunction(0), fKaonFunction(0), fProtonFunction(0),
@@ -60,8 +63,8 @@ void AliAnalysisTaskProtons::ConnectInputData(Option_t *) {
     // Disable all branches and enable only the needed ones
     // The next two lines are different when data produced as AliESDEvent is read
     if(fAnalysisType == "ESD") {
-// In train mode branches can be disabled at the level of ESD handler (M.G.)
-//      tree->SetBranchStatus("*", kFALSE);
+      // In train mode branches can be disabled at the level of ESD handler (M.G.)
+      // tree->SetBranchStatus("*", kFALSE);
       tree->SetBranchStatus("*Tracks.*", kTRUE);
 
       AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
@@ -79,8 +82,16 @@ void AliAnalysisTaskProtons::ConnectInputData(Option_t *) {
       } else
        fAOD = aodH->GetEvent();
     }
+    else if(fAnalysisType == "MC") {
+      AliMCEventHandler* mcH = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
+      if (!mcH) {
+       Printf("ERROR: Could not retrieve MC event handler");
+      }
+      else
+       fMC = mcH->MCEvent();
+    }
     else 
-      Printf("Wrong analysis type: Only ESD and AOD types are allowed!");
+      Printf("Wrong analysis type: Only ESD, AOD and MC types are allowed!");
   }
 }
 
@@ -93,17 +104,23 @@ void AliAnalysisTaskProtons::CreateOutputObjects() {
   fAnalysis = new AliProtonAnalysis();
   fAnalysis->InitHistograms(10,-1.0,1.0,30,0.1,3.1);
   if(fAnalysisType == "ESD") {
+    //Use of TPConly tracks
+    fAnalysis->UseTPCOnly();
+
+    //TPC related cuts
     fAnalysis->SetMinTPCClusters(50);
-    fAnalysis->SetMinITSClusters(1);
     fAnalysis->SetMaxChi2PerTPCCluster(3.5);
     fAnalysis->SetMaxCov11(2.0);
     fAnalysis->SetMaxCov22(2.0);
     fAnalysis->SetMaxCov33(0.5);
     fAnalysis->SetMaxCov44(0.5);
     fAnalysis->SetMaxCov55(2.0);
-    fAnalysis->SetMaxSigmaToVertex(3.);
-    fAnalysis->SetITSRefit();
+    fAnalysis->SetMaxSigmaToVertex(2.5);
     fAnalysis->SetTPCRefit();
+    
+    //ITS related cuts - to be used in the case of the analysis of global tracks
+    //fAnalysis->SetMinITSClusters(5);
+    //fAnalysis->SetITSRefit();
   }
   if(fFunctionUsed)
     fAnalysis->SetPriorProbabilityFunctions(fElectronFunction,
@@ -130,18 +147,34 @@ void AliAnalysisTaskProtons::Exec(Option_t *) {
       return;
     }
   
-    Printf("Proton analysis task: There are %d tracks in this event", fESD->GetNumberOfTracks());
+    Printf("Proton ESD analysis task: There are %d tracks in this event", fESD->GetNumberOfTracks());
     fAnalysis->Analyze(fESD);
-  }
+  }//ESD analysis
+
   else if(fAnalysisType == "AOD") {
     if (!fAOD) {
       Printf("ERROR: fAOD not available");
       return;
     }
     
-    Printf("Proton analysis task: There are %d tracks in this event", fAOD->GetNumberOfTracks());
+    Printf("Proton AOD analysis task: There are %d tracks in this event", fAOD->GetNumberOfTracks());
     fAnalysis->Analyze(fAOD);
-  }
+  }//AOD analysis
+
+  else if(fAnalysisType == "MC") {
+    if (!fMC) {
+      Printf("ERROR: Could not retrieve MC event");
+      return;
+    }
+    
+    AliStack* stack = fMC->Stack();
+    if (!stack) {
+      Printf("ERROR: Could not retrieve the stack");
+      return;
+    }
+    Printf("Proton MC analysis task: There are %d primaries in this event", stack->GetNprimary());
+    fAnalysis->Analyze(stack);
+  }//MC analysis
 
   // Post output data.
   PostData(0, fList);
index e5beab5..050950f 100644 (file)
@@ -8,6 +8,7 @@ class TString;
 class TList;
 class AliESDEvent;
 class AliAODEvent;
+class AliMCEvent;
 class AliProtonAnalysis;
 class TF1;
 
@@ -41,9 +42,13 @@ class AliAnalysisTaskProtons : public AliAnalysisTask {
  private:
   AliESDEvent *fESD;    //ESD object
   AliAODEvent *fAOD;    //AOD object
-  TString fAnalysisType;//"ESD" or "AOD"
+  AliMCEvent  *fMC;     //MC object
+  TString fAnalysisType;//"ESD", "AOD" or "MC"
+
   TList  *fList; //TList output object
+
   AliProtonAnalysis *fAnalysis; //analysis object
+
   TF1 *fElectronFunction; //TF1 for e
   TF1 *fMuonFunction; //TF1 for mu
   TF1 *fPionFunction; //TF1 for pi
index a5b138d..5ee8ebd 100644 (file)
@@ -24,6 +24,7 @@
 #include <TF1.h>
 #include <TH2F.h>
 #include <TH1D.h>
+#include <TParticle.h>
 
 #include "AliProtonAnalysis.h"
 
@@ -33,6 +34,8 @@
 #include <AliLog.h>
 #include <AliPID.h>
 
+#include <AliStack.h>
+
 ClassImp(AliProtonAnalysis)
 
 //____________________________________________________________________//
@@ -128,7 +131,7 @@ Bool_t AliProtonAnalysis::ReadFromFile(const char* filename) {
     status = kFALSE;
   }
 
-  TList *list = (TList *)file->Get("clist1");
+  TList *list = (TList *)file->Get("outputList1");
   if(list) {
     cout<<"Retrieving objects from the list "<<list->GetName()<<"..."<<endl; 
     fHistYPtProtons = (TH2F *)list->At(0);
@@ -300,7 +303,7 @@ Double_t AliProtonAnalysis::GetParticleFraction(Int_t i, Double_t p) {
 
 //____________________________________________________________________//
 void AliProtonAnalysis::Analyze(AliESDEvent* fESD) {
-  //Main analysis part
+  //Main analysis part - ESD
   Double_t Pt = 0.0, P = 0.0;
   Int_t nGoodTracks = fESD->GetNumberOfTracks();
   for(Int_t iTracks = 0; iTracks < nGoodTracks; iTracks++) {
@@ -359,7 +362,7 @@ void AliProtonAnalysis::Analyze(AliESDEvent* fESD) {
 
 //____________________________________________________________________//
 void AliProtonAnalysis::Analyze(AliAODEvent* fAOD) {
-  //Main analysis part
+  //Main analysis part - AOD
   Int_t nGoodTracks = fAOD->GetNumberOfTracks();
   for(Int_t iTracks = 0; iTracks < nGoodTracks; iTracks++) {
     AliAODTrack* track = fAOD->GetTrack(iTracks);
@@ -383,6 +386,25 @@ void AliProtonAnalysis::Analyze(AliAODEvent* fAOD) {
 }
 
 //____________________________________________________________________//
+void AliProtonAnalysis::Analyze(AliStack* stack) {
+  //Main analysis part - MC
+  for(Int_t i = 0; i < stack->GetNprimary(); i++) {
+    TParticle *particle = stack->Particle(i);
+    if(particle->Pt() < 0.1) continue;
+    if(TMath::Abs(particle->Eta()) > 1.0) continue;
+    Int_t pdgcode = particle->GetPdgCode();
+    if(pdgcode == 2212) fHistYPtProtons->Fill(Rapidity(particle->Px(),
+                                                      particle->Py(),
+                                                      particle->Pz()),
+                                             particle->Pt());
+    if(pdgcode == -2212) fHistYPtAntiProtons->Fill(Rapidity(particle->Px(),
+                                                           particle->Py(),
+                                                           particle->Pz()),
+                                                  particle->Pt());
+  }//particle loop                                                                  
+}
+
+//____________________________________________________________________//
 Bool_t AliProtonAnalysis::IsAccepted(AliESDtrack* track) {
   // Checks if the track is excluded from the cuts
   Double_t Pt = 0.0, Px = 0.0, Py = 0.0, Pz = 0.0;
index 394f7dd..5609711 100644 (file)
@@ -24,6 +24,7 @@ class AliAODtrack;
 class AliESDEvent;
 class AliESDtrack;
 class AliExternalTrackParam;
+class AliStack;
 
 class AliProtonAnalysis : public TObject {
  public:
@@ -39,6 +40,7 @@ class AliProtonAnalysis : public TObject {
   Bool_t ReadFromFile(const char* filename);
   void Analyze(AliESDEvent* fESD);
   void Analyze(AliAODEvent* fAOD);
+  void Analyze(AliStack* stack);
   
   TH2F *GetProtonYPtHistogram() {return fHistYPtProtons;}
   TH2F *GetAntiProtonYPtHistogram() {return fHistYPtAntiProtons;}
index 7da6b1f..c5b1098 100644 (file)
@@ -5,7 +5,7 @@ void runProtonAnalysis() {
   //runLocal();
   //runInteractive();
   //runBatch();
-  runProof();
+  runProof("/PWG0/COMMON/run30000X_10TeV_0.5T",200000);
 
   timer.Stop();
   timer.Print();
@@ -34,13 +34,19 @@ void runLocal() {
   //____________________________________________________//
   setupPar("AOD");
   gSystem->Load("libAOD.so");
-                                                                
+  
   //_________________________________________________________//
   //_____________Setting up ANALYSIS.par_____________________//
   //_________________________________________________________//
   setupPar("ANALYSIS");
   gSystem->Load("libANALYSIS.so");
 
+  //_________________________________________________________//
+  //___________Setting up ANALYSISalice.par__________________//
+  //_________________________________________________________//
+  setupPar("ANALYSISalice");
+  gSystem->Load("libANALYSISalice.so");
+
   //____________________________________________________________//
   //_____________Setting up PWG2spectra.par_____________________//
   //____________________________________________________________//
@@ -50,8 +56,8 @@ void runLocal() {
   gROOT->LoadMacro("AliAnalysisTaskProtons.cxx++");
 
   //____________________________________________//
-  AliTagAnalysis *TagAna = new AliTagAnalysis("ESD"); 
-  TagAna->ChainLocalTags("/home/pchrist/ALICE/Alien/Tutorial/November2007/Tags");
+  AliTagAnalysis *tagAnalysis = new AliTagAnalysis("ESD"); 
+  tagAnalysis->ChainLocalTags("/home/pchrist/ALICE/Alien/Tutorial/November2007/Tags");
 
   AliRunTagCuts *runCuts = new AliRunTagCuts();
   AliLHCTagCuts *lhcCuts = new AliLHCTagCuts();
@@ -59,7 +65,7 @@ void runLocal() {
   AliEventTagCuts *evCuts = new AliEventTagCuts();
   
   TChain* chain = 0x0;
-  chain = TagAna->QueryTags(runCuts,lhcCuts,detCuts,evCuts);
+  chain = tagAnalysis->QueryTags(runCuts,lhcCuts,detCuts,evCuts);
   chain->SetBranchStatus("*Calo*",0);
 
   //____________________________________________//
@@ -69,27 +75,30 @@ void runLocal() {
   mgr->SetInputEventHandler(esdH);  
   //____________________________________________//
   // 1st Proton task
-  AliAnalysisTaskProtons *task1 = new AliAnalysisTaskProtons("TaskProtons");
-  TFile *f = TFile::Open("PriorProb/PriorProbabilities.root ");
+  AliAnalysisTaskProtons *taskProtons = new AliAnalysisTaskProtons("TaskProtons");
+  /*TFile *f = TFile::Open("PriorProb/PriorProbabilities.root ");
   TF1 *fitElectrons = (TF1 *)f->Get("fitElectrons");
   TF1 *fitMuons = (TF1 *)f->Get("fitMuons");
   TF1 *fitPions = (TF1 *)f->Get("fitPions");
   TF1 *fitKaons = (TF1 *)f->Get("fitKaons");
   TF1 *fitProtons = (TF1 *)f->Get("fitProtons");
-  task1->SetPriorProbabilityFunctions(fitElectrons,
-                                     fitMuons,
-                                     fitPions,
-                                     fitKaons,
-                                     fitProtons);
-  mgr->AddTask(task1);
+  taskProtons->SetPriorProbabilityFunctions(fitElectrons,
+                                           fitMuons,
+                                           fitPions,
+                                           fitKaons,
+                                           fitProtons);*/
+  mgr->AddTask(taskProtons);
+
+  // Create containers for input/output                                                                              
+  AliAnalysisDataContainer *cinput1 = mgr->CreateContainer("dataChain",
+                                                           TChain::Class(),AliAnalysisManager::kInputContainer);
+  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("outputList1",
+                                                            TList::Class(),AliAnalysisManager::kOutputCont
+                                                            "Protons.ESD.root");
 
-  // Create containers for input/output
-  AliAnalysisDataContainer *cinput1 = mgr->CreateContainer("cchain1",TChain::Class(),AliAnalysisManager::kInputContainer);
-  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("clist1", TList::Class(),AliAnalysisManager::kOutputContainer,"Protons.ESD.root");
-  
   //____________________________________________//
-  mgr->ConnectInput(task1,0,cinput1);
-  mgr->ConnectOutput(task1,0,coutput1);
+  mgr->ConnectInput(taskProtons,0,cinput1);
+  mgr->ConnectOutput(taskProtons,0,coutput1);
   if (!mgr->InitAnalysis()) return;
   mgr->PrintStatus();
   mgr->StartAnalysis("local",chain);
@@ -132,6 +141,12 @@ void runInteractive() {
   setupPar("ANALYSIS");
   gSystem->Load("libANALYSIS.so");
 
+  //_________________________________________________________//
+  //___________Setting up ANALYSISalice.par__________________//
+  //_________________________________________________________//
+  setupPar("ANALYSISalice");
+  gSystem->Load("libANALYSISalice.so");
+
   //____________________________________________________________//
   //_____________Setting up PWG2spectra.par_____________________//
   //____________________________________________________________//
@@ -141,7 +156,7 @@ void runInteractive() {
   gROOT->LoadMacro("AliAnalysisTaskProtons.cxx++");
   
   //____________________________________________//
-  AliTagAnalysis *TagAna = new AliTagAnalysis("ESD");
+  AliTagAnalysis *tagAnalysis = new AliTagAnalysis("ESD");
  
   AliRunTagCuts *runCuts = new AliRunTagCuts();
   AliLHCTagCuts *lhcCuts = new AliLHCTagCuts();
@@ -151,9 +166,9 @@ void runInteractive() {
   //grid tags
   TAlienCollection* coll = TAlienCollection::Open("tag.xml");
   TGridResult* TagResult = coll->GetGridResult("",0,0);
-  TagAna->ChainGridTags(TagResult);
+  tagAnalysis->ChainGridTags(TagResult);
   TChain* chain = 0x0;
-  chain = TagAna->QueryTags(runCuts,lhcCuts,detCuts,evCuts);
+  chain = tagAnalysis->QueryTags(runCuts,lhcCuts,detCuts,evCuts);
   chain->SetBranchStatus("*Calo*",0);
 
   //____________________________________________//
@@ -163,27 +178,30 @@ void runInteractive() {
   mgr->SetInputEventHandler(esdH);  
   //____________________________________________//
   // 1st Proton task
-  AliAnalysisTaskProtons *task1 = new AliAnalysisTaskProtons("TaskProtons");
-  TFile *f = TFile::Open("PriorProb/PriorProbabilities.root ");
+  AliAnalysisTaskProtons *taskProtons = new AliAnalysisTaskProtons("TaskProtons");
+  /*TFile *f = TFile::Open("PriorProb/PriorProbabilities.root ");
   TF1 *fitElectrons = (TF1 *)f->Get("fitElectrons");
   TF1 *fitMuons = (TF1 *)f->Get("fitMuons");
   TF1 *fitPions = (TF1 *)f->Get("fitPions");
   TF1 *fitKaons = (TF1 *)f->Get("fitKaons");
   TF1 *fitProtons = (TF1 *)f->Get("fitProtons");
-  task1->SetPriorProbabilityFunctions(fitElectrons,
-                                     fitMuons,
-                                     fitPions,
-                                     fitKaons,
-                                     fitProtons);
-  mgr->AddTask(task1);
-
-  // Create containers for input/output
-  AliAnalysisDataContainer *cinput1 = mgr->CreateContainer("cchain1",TChain::Class(),AliAnalysisManager::kInputContainer);
-  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("clist1", TList::Class(),AliAnalysisManager::kOutputContainer,"Protons.ESD.root");
+  taskProtons->SetPriorProbabilityFunctions(fitElectrons,
+                                           fitMuons,
+                                           fitPions,
+                                           fitKaons,
+                                           fitProtons);*/
+  mgr->AddTask(taskProtons);
+
+  // Create containers for input/output                                                                               
+  AliAnalysisDataContainer *cinput1 = mgr->CreateContainer("dataChain",
+                                                           TChain::Class(),AliAnalysisManager::kInputContainer);
+  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("outputList1",
+                                                            TList::Class(),AliAnalysisManager::kOutputCont
+                                                            "Protons.ESD.root");
   
   //____________________________________________//
-  mgr->ConnectInput(task1,0,cinput1);
-  mgr->ConnectOutput(task1,0,coutput1);
+  mgr->ConnectInput(taskProtons,0,cinput1);
+  mgr->ConnectOutput(taskProtons,0,coutput1);
   if (!mgr->InitAnalysis()) return;
   mgr->PrintStatus();
   mgr->StartAnalysis("local",chain);
@@ -226,6 +244,12 @@ void runBatch() {
   setupPar("ANALYSIS");
   gSystem->Load("libANALYSIS.so");
 
+  //_________________________________________________________//
+  //___________Setting up ANALYSISalice.par__________________//
+  //_________________________________________________________//
+  setupPar("ANALYSISalice");
+  gSystem->Load("libANALYSISalice.so");
+
   //____________________________________________________________//
   //_____________Setting up PWG2spectra.par_____________________//
   //____________________________________________________________//
@@ -238,9 +262,9 @@ void runBatch() {
 
   //____________________________________________//
   //Usage of event tags
-  AliTagAnalysis *analysis = new AliTagAnalysis();
+  AliTagAnalysis *tagAnalysis = new AliTagAnalysis();
   TChain *chain = 0x0;
-  chain = analysis->GetChainFromCollection(collectionfile,"esdTree");
+  chain = tagAnalysis->GetChainFromCollection(collectionfile,"esdTree");
   chain->SetBranchStatus("*Calo*",0);
 
   //____________________________________________//
@@ -250,27 +274,30 @@ void runBatch() {
   mgr->SetInputEventHandler(esdH);  
   //____________________________________________//
   // 1st Proton task
-  AliAnalysisTaskProtons *task1 = new AliAnalysisTaskProtons("TaskProtons");
-  TFile *f = TFile::Open("PriorProb/PriorProbabilities.root ");
+  AliAnalysisTaskProtons *taskProtons = new AliAnalysisTaskProtons("TaskProtons");
+  /*TFile *f = TFile::Open("PriorProb/PriorProbabilities.root ");
   TF1 *fitElectrons = (TF1 *)f->Get("fitElectrons");
   TF1 *fitMuons = (TF1 *)f->Get("fitMuons");
   TF1 *fitPions = (TF1 *)f->Get("fitPions");
   TF1 *fitKaons = (TF1 *)f->Get("fitKaons");
   TF1 *fitProtons = (TF1 *)f->Get("fitProtons");
-  task1->SetPriorProbabilityFunctions(fitElectrons,
-                                     fitMuons,
-                                     fitPions,
-                                     fitKaons,
-                                     fitProtons);
-  mgr->AddTask(task1);
+  taskProtons->SetPriorProbabilityFunctions(fitElectrons,
+                                           fitMuons,
+                                           fitPions,
+                                           fitKaons,
+                                           fitProtons);*/
+  mgr->AddTask(taskProtons);
+
+  // Create containers for input/output                                                                               
+  AliAnalysisDataContainer *cinput1 = mgr->CreateContainer("dataChain",
+                                                           TChain::Class(),AliAnalysisManager::kInputContainer);
+  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("outputList1",
+                                                            TList::Class(),AliAnalysisManager::kOutputCont
+                                                            "Protons.ESD.root");
 
-  // Create containers for input/output
-  AliAnalysisDataContainer *cinput1 = mgr->CreateContainer("cchain1",TChain::Class(),AliAnalysisManager::kInputContainer);
-  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("clist1", TList::Class(),AliAnalysisManager::kOutputContainer,"Protons.ESD.root");
-  
   //____________________________________________//
-  mgr->ConnectInput(task1,0,cinput1);
-  mgr->ConnectOutput(task1,0,coutput1);
+  mgr->ConnectInput(taskProtons,0,cinput1);
+  mgr->ConnectOutput(taskProtons,0,coutput1);
   if (!mgr->InitAnalysis()) return;
   mgr->PrintStatus();
   mgr->StartAnalysis("grid",chain);
@@ -280,7 +307,7 @@ void runBatch() {
 }
 
 //_________________________________________________//
-void runProof() {
+void runProof(const char* dataset = 0x0, Int_t stats = 0) {
   TStopwatch timer;
   timer.Start();
   printf("****** Connect to PROOF *******\n");
@@ -296,49 +323,59 @@ void runProof() {
   gProof->EnablePackage("AOD");
   gProof->UploadPackage("ANALYSIS.par");
   gProof->EnablePackage("ANALYSIS");
+  gProof->UploadPackage("ANALYSISalice.par");
+  gProof->EnablePackage("ANALYSISalice");
   gProof->UploadPackage("PWG2spectra.par");
   gProof->EnablePackage("PWG2spectra");
   
-  // 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",10);
-  chain->SetBranchStatus("*Calo*",0);
-
   gProof->Load("AliAnalysisTaskProtons.cxx++");
 
-    //____________________________________________//
+  //____________________________________________//
   // Make the analysis manager
   AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
   AliVEventHandler* esdH = new AliESDInputHandler;
   mgr->SetInputEventHandler(esdH);  
   //____________________________________________//
   // 1st Proton task
-  AliAnalysisTaskProtons *task1 = new AliAnalysisTaskProtons("TaskProtons");
-  TFile *f = TFile::Open("PriorProb/PriorProbabilities.root ");
+  AliAnalysisTaskProtons *taskProtons = new AliAnalysisTaskProtons("TaskProtons");
+  /*TFile *f = TFile::Open("PriorProb/PriorProbabilities.root ");
   TF1 *fitElectrons = (TF1 *)f->Get("fitElectrons");
   TF1 *fitMuons = (TF1 *)f->Get("fitMuons");
   TF1 *fitPions = (TF1 *)f->Get("fitPions");
   TF1 *fitKaons = (TF1 *)f->Get("fitKaons");
   TF1 *fitProtons = (TF1 *)f->Get("fitProtons");
-  task1->SetPriorProbabilityFunctions(fitElectrons,
-                                     fitMuons,
-                                     fitPions,
-                                     fitKaons,
-                                     fitProtons);
-  mgr->AddTask(task1);
+  taskProtons->SetPriorProbabilityFunctions(fitElectrons,
+                                           fitMuons,
+                                           fitPions,
+                                           fitKaons,
+                                           fitProtons);*/
+  mgr->AddTask(taskProtons);
 
   // Create containers for input/output
-  AliAnalysisDataContainer *cinput1 = mgr->CreateContainer("cchain1",TChain::Class(),AliAnalysisManager::kInputContainer);
-  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("clist1", TList::Class(),AliAnalysisManager::kOutputContainer,"Protons.ESD.root");
+  AliAnalysisDataContainer *cinput1 = mgr->CreateContainer("dataChain",
+                                                          TChain::Class(),AliAnalysisManager::kInputContainer);
+  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("outputList1", 
+                                                           TList::Class(),AliAnalysisManager::kOutputCont
+                                                           "Protons.ESD.root");
   
   //____________________________________________//
-  mgr->ConnectInput(task1,0,cinput1);
-  mgr->ConnectOutput(task1,0,coutput1);
+  mgr->ConnectInput(taskProtons,0,cinput1);
+  mgr->ConnectOutput(taskProtons,0,coutput1);
   if (!mgr->InitAnalysis()) return;
   mgr->PrintStatus();
-  mgr->StartAnalysis("proof",chain);
+
+  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);
+  }
 
   timer.Stop();
   timer.Print();