Corrected library names and paths to macros
[u/mrichter/AliRoot.git] / STEER / macros / CreateAODfromESD.C
CommitLineData
257e1b2b 1#if !defined( __CINT__) || defined(__MAKECINT__)
aaacb672 2#include <cstring>
e95e4176 3#include <TChain.h>
4#include <TSystem.h>
5#include "AliAnalysisManager.h"
6#include "AliESDInputHandler.h"
7#include "AliAODHandler.h"
8#include "AliAnalysisTaskESDfilter.h"
9#include "AliAnalysisDataContainer.h"
aaacb672 10#include "AliTaskCDBconnect.h"
257e1b2b 11#endif
e985a35a 12
cf22b3fc 13void CreateAODfromESD(const char *inFileName = "AliESDs.root",
368ca218 14 const char *outFileName = "AliAOD.root",
aaacb672 15 const char *cdbLocation = "raw://",
16 const char *grpSpecific = "",
d0e7e1bf 17 Bool_t bKineFilter = kTRUE)
18{
3dd9f9e3 19
35d4b769 20 TChain *chain = new TChain("esdTree");
e95e4176 21 // Steering input chain
22 chain->Add(inFileName);
23 AliAnalysisManager *mgr = new AliAnalysisManager("ESD to AOD", "Analysis Manager");
24
25 // Input
26 AliESDInputHandler* inpHandler = new AliESDInputHandler();
08dccdc4 27 inpHandler->SetReadFriends(kFALSE);
fdce1c9b 28 inpHandler->SetReadTags();
aaacb672 29 inpHandler->NeedField();
e95e4176 30 mgr->SetInputEventHandler (inpHandler);
e95e4176 31 // Output
32 AliAODHandler* aodHandler = new AliAODHandler();
33 aodHandler->SetOutputFileName(outFileName);
34 mgr->SetOutputEventHandler(aodHandler);
35
d0e7e1bf 36 // MC Truth
37 if(bKineFilter){
38 AliMCEventHandler* mcHandler = new AliMCEventHandler();
39 mgr->SetMCtruthEventHandler(mcHandler);
40 }
41
42
43 // Tasks
44 // Filtering of MC particles (decays conversions etc)
45 // this task is also needed to set the MCEventHandler
46 // to the AODHandler, this will not be needed when
47 // AODHandler goes to ANALYSISalice
d0e7e1bf 48
aaacb672 49 // Connect CDB: needed by AliEMCALRecoUtils
50 Int_t run=-1; // Do not use 0, it is the default MC run
51 AliTaskCDBconnect *task= new AliTaskCDBconnect("CDBconnect", cdbLocation, run);
52 if (strlen(grpSpecific)>0) task->SetSpecificStorage("GRP/GRP/Data",grpSpecific);
53 mgr->AddTask(task);
54 AliAnalysisDataContainer *cinput0 = mgr->GetCommonInputContainer();
55 mgr->ConnectInput(task, 0, cinput0);
56
35d4b769 57 // Barrel Tracks
e95e4176 58 AliAnalysisTaskESDfilter *filter = new AliAnalysisTaskESDfilter("Filter");
59 mgr->AddTask(filter);
c3383356 60 AliAnalysisTaskMCParticleFilter *kinefilter = new AliAnalysisTaskMCParticleFilter("Particle Filter");
61 if (bKineFilter) mgr->AddTask(kinefilter);
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