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