Bug fixes (G.E. Bruno)
[u/mrichter/AliRoot.git] / STEER / CreateAODfromESD.C
CommitLineData
e985a35a 1#if !defined(__CINT__) || defined(__MAKECINT__)
e95e4176 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"
e985a35a 9#endif
10
cf22b3fc 11void CreateAODfromESD(const char *inFileName = "AliESDs.root",
d0e7e1bf 12 const char *outFileName = "AliAODs.root",
13 Bool_t bKineFilter = kTRUE)
14{
3dd9f9e3 15
17d9550f 16 gSystem->Load("libTree");
17 gSystem->Load("libGeom");
18 gSystem->Load("libPhysics");
19 gSystem->Load("libVMC");
20 gSystem->Load("libSTEERBase");
21 gSystem->Load("libESD");
22 gSystem->Load("libAOD");
e95e4176 23
17d9550f 24 gSystem->Load("libANALYSIS");
25 gSystem->Load("libANALYSISalice");
35d4b769 26 gSystem->Load("libPWG3muon");
e95e4176 27
35d4b769 28 TChain *chain = new TChain("esdTree");
e95e4176 29 // Steering input chain
30 chain->Add(inFileName);
31 AliAnalysisManager *mgr = new AliAnalysisManager("ESD to AOD", "Analysis Manager");
32
33 // Input
34 AliESDInputHandler* inpHandler = new AliESDInputHandler();
fdce1c9b 35 inpHandler->SetReadTags();
e95e4176 36 mgr->SetInputEventHandler (inpHandler);
e95e4176 37 // Output
38 AliAODHandler* aodHandler = new AliAODHandler();
39 aodHandler->SetOutputFileName(outFileName);
40 mgr->SetOutputEventHandler(aodHandler);
41
d0e7e1bf 42 // MC Truth
43 if(bKineFilter){
44 AliMCEventHandler* mcHandler = new AliMCEventHandler();
45 mgr->SetMCtruthEventHandler(mcHandler);
46 }
47
48
49 // Tasks
50 // Filtering of MC particles (decays conversions etc)
51 // this task is also needed to set the MCEventHandler
52 // to the AODHandler, this will not be needed when
53 // AODHandler goes to ANALYSISalice
54 AliAnalysisTaskMCParticleFilter *kinefilter = new AliAnalysisTaskMCParticleFilter("Particle Filter");
55 if (bKineFilter) mgr->AddTask(kinefilter);
56
35d4b769 57 // Barrel Tracks
e95e4176 58 AliAnalysisTaskESDfilter *filter = new AliAnalysisTaskESDfilter("Filter");
59 mgr->AddTask(filter);
35d4b769 60 // Muons
61 AliAnalysisTaskESDMuonFilter *esdmuonfilter = new AliAnalysisTaskESDMuonFilter("ESD Muon Filter");
62 mgr->AddTask(esdmuonfilter);
e95e4176 63
fdce1c9b 64 // Cuts on primary tracks
215fb466 65 AliESDtrackCuts* esdTrackCutsL = new AliESDtrackCuts("AliESDtrackCuts", "Standard");
66 esdTrackCutsL->SetMinNClustersTPC(50);
67 esdTrackCutsL->SetMaxChi2PerClusterTPC(3.5);
fdce1c9b 68 esdTrackCutsL->SetMaxCovDiagonalElements(2, 2, 0.5, 0.5, 2);
215fb466 69 esdTrackCutsL->SetRequireTPCRefit(kTRUE);
20da34af 70 esdTrackCutsL->SetMaxDCAToVertexXY(3.0);
75bcd466 71 esdTrackCutsL->SetMaxDCAToVertexZ(3.0);
72 esdTrackCutsL->SetDCAToVertex2D(kTRUE);
fdce1c9b 73 esdTrackCutsL->SetRequireSigmaToVertex(kFALSE);
d0e7e1bf 74 esdTrackCutsL->SetAcceptKinkDaughters(kFALSE);
b6594780 75 // ITS stand-alone tracks
76 AliESDtrackCuts* esdTrackCutsITSsa = new AliESDtrackCuts("AliESDtrackCuts", "ITS stand-alone");
77 esdTrackCutsITSsa->SetRequireITSStandAlone(kTRUE);
215fb466 78
79 AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
80 trackFilter->AddCuts(esdTrackCutsL);
b6594780 81 trackFilter->AddCuts(esdTrackCutsITSsa);
215fb466 82
fdce1c9b 83 // Cuts on V0s
84 AliESDv0Cuts* esdV0Cuts = new AliESDv0Cuts("AliESDv0Cuts", "Standard pp");
85 esdV0Cuts->SetMinRadius(0.2);
86 esdV0Cuts->SetMaxRadius(100);
87 esdV0Cuts->SetMinDcaPosToVertex(0.05);
88 esdV0Cuts->SetMinDcaNegToVertex(0.05);
89 esdV0Cuts->SetMaxDcaV0Daughters(0.5);
90 esdV0Cuts->SetMinCosinePointingAngle(0.99);
91 AliAnalysisFilter* v0Filter = new AliAnalysisFilter("v0Filter");
92 v0Filter->AddCuts(esdV0Cuts);
93
94
95//
215fb466 96 filter->SetTrackFilter(trackFilter);
fdce1c9b 97 filter->SetV0Filter(v0Filter);
98
99
100// Create AOD Tags
101 AliAnalysisTaskTagCreator* tagTask = new AliAnalysisTaskTagCreator("AOD Tag Creator");
102 mgr->AddTask(tagTask);
215fb466 103
e95e4176 104 // Pipelining
d0e7e1bf 105 AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
f5fa84ac 106 AliAnalysisDataContainer *coutput1 = mgr->GetCommonOutputContainer();
d0e7e1bf 107
108
fdce1c9b 109 AliAnalysisDataContainer *coutputT
110 = mgr->CreateContainer("cTag", TTree::Class(), AliAnalysisManager::kOutputContainer, "AOD.tag.root");
6518ad6b 111
112 coutput1->SetSpecialOutput();
113 coutputT->SetSpecialOutput();
fdce1c9b 114
d0e7e1bf 115 if(bKineFilter) {
116 mgr->ConnectInput (kinefilter, 0, cinput1 );
117 mgr->ConnectOutput (kinefilter, 0, coutput1 );
118 }
119
e95e4176 120 mgr->ConnectInput (filter, 0, cinput1 );
121 mgr->ConnectOutput(filter, 0, coutput1);
122
35d4b769 123 mgr->ConnectInput (esdmuonfilter, 0, cinput1 );
f5fa84ac 124// mgr->ConnectOutput(esdmuonfilter, 0, coutput1);
35d4b769 125
fdce1c9b 126 mgr->ConnectInput (tagTask, 0, cinput1);
127 mgr->ConnectOutput(tagTask, 1, coutputT);
128
e95e4176 129 //
130 // Run the analysis
131 //
132 mgr->InitAnalysis();
133 mgr->PrintStatus();
134 mgr->StartAnalysis("local", chain);
df9db588 135}
b6594780 136