Standard quality cuts added.
[u/mrichter/AliRoot.git] / STEER / CreateAODfromESD.C
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include <TChain.h>
3 #include <TSystem.h>
4 #include "AliAnalysisManager.h"
5 #include "AliESDInputHandler.h"
6 #include "AliAODHandler.h"
7 #include "AliAnalysisTaskESDfilter.h"
8 #include "AliAnalysisDataContainer.h"
9 #endif
10
11 void CreateAODfromESD(const char *inFileName = "AliESDs.root",
12                       const char *outFileName = "AliAOD.root") {
13   
14     gSystem->Load("libTree");
15     gSystem->Load("libGeom");
16     gSystem->Load("libPhysics");
17     gSystem->Load("libVMC");
18     gSystem->Load("libSTEERBase");
19     gSystem->Load("libESD");
20     gSystem->Load("libAOD");
21     
22     gSystem->Load("libANALYSIS");
23     gSystem->Load("libANALYSISalice");
24     TChain *chain = new TChain("esdTree");
25
26     // Steering input chain
27     chain->Add(inFileName);
28     AliAnalysisManager *mgr  = new AliAnalysisManager("ESD to AOD", "Analysis Manager");
29
30     // Input
31     AliESDInputHandler* inpHandler = new AliESDInputHandler();
32     mgr->SetInputEventHandler  (inpHandler);
33
34     // Output
35     AliAODHandler* aodHandler   = new AliAODHandler();
36     aodHandler->SetOutputFileName(outFileName);
37     mgr->SetOutputEventHandler(aodHandler);
38
39     // Task
40     AliAnalysisTaskESDfilter *filter = new AliAnalysisTaskESDfilter("Filter");
41     mgr->AddTask(filter);
42
43     AliESDtrackCuts* esdTrackCutsL = new AliESDtrackCuts("AliESDtrackCuts", "Standard");
44     esdTrackCutsL->SetMinNClustersTPC(50);
45     esdTrackCutsL->SetMaxChi2PerClusterTPC(3.5);
46     esdTrackCutsL->SetMaxCovDiagonalElements(2,2,0.5,0.5,2);
47     esdTrackCutsL->SetRequireTPCRefit(kTRUE);
48     esdTrackCutsL->SetMinNsigmaToVertex(3);
49     esdTrackCutsL->SetRequireSigmaToVertex(kTRUE);
50     esdTrackCutsL->SetAcceptKingDaughters(kFALSE);
51
52     AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
53     trackFilter->AddCuts(esdTrackCutsL);
54
55     filter->SetTrackFilter(trackFilter);
56
57     // Pipelining
58     AliAnalysisDataContainer *cinput1 = mgr->CreateContainer("cchain", TChain::Class(),
59                                                              AliAnalysisManager::kInputContainer);
60     
61     AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("tree", TTree::Class(),
62                                                               AliAnalysisManager::kOutputContainer,
63                                                               "default");
64   
65
66     mgr->ConnectInput (filter, 0, cinput1 );
67     mgr->ConnectOutput(filter, 0, coutput1);
68
69     //
70     // Run the analysis
71     //
72     mgr->InitAnalysis();
73     mgr->PrintStatus();
74     mgr->StartAnalysis("local", chain);
75 }