Separate task for muon tracks added. (R. Arnaldi)
[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     gSystem->Load("libPWG3muon");
25
26     TChain *chain = new TChain("esdTree");
27     // Steering input chain
28     chain->Add(inFileName);
29     AliAnalysisManager *mgr  = new AliAnalysisManager("ESD to AOD", "Analysis Manager");
30
31     // Input
32     AliESDInputHandler* inpHandler = new AliESDInputHandler();
33     mgr->SetInputEventHandler  (inpHandler);
34
35     // Output
36     AliAODHandler* aodHandler   = new AliAODHandler();
37     aodHandler->SetOutputFileName(outFileName);
38     mgr->SetOutputEventHandler(aodHandler);
39
40     // Task
41     // Barrel Tracks
42     AliAnalysisTaskESDfilter *filter = new AliAnalysisTaskESDfilter("Filter");
43     mgr->AddTask(filter);
44     // Muons
45     AliAnalysisTaskESDMuonFilter *esdmuonfilter = new AliAnalysisTaskESDMuonFilter("ESD Muon Filter");
46     mgr->AddTask(esdmuonfilter);
47
48     AliESDtrackCuts* esdTrackCutsL = new AliESDtrackCuts("AliESDtrackCuts", "Standard");
49     esdTrackCutsL->SetMinNClustersTPC(50);
50     esdTrackCutsL->SetMaxChi2PerClusterTPC(3.5);
51     esdTrackCutsL->SetMaxCovDiagonalElements(2,2,0.5,0.5,2);
52     esdTrackCutsL->SetRequireTPCRefit(kTRUE);
53     esdTrackCutsL->SetMinNsigmaToVertex(3);
54     esdTrackCutsL->SetRequireSigmaToVertex(kTRUE);
55     esdTrackCutsL->SetAcceptKingDaughters(kFALSE);
56
57     AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
58     trackFilter->AddCuts(esdTrackCutsL);
59
60     filter->SetTrackFilter(trackFilter);
61
62     // Pipelining
63     AliAnalysisDataContainer *cinput1 = mgr->CreateContainer("cchain", TChain::Class(),
64                                                              AliAnalysisManager::kInputContainer);
65     
66     AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("tree", TTree::Class(),
67                                                               AliAnalysisManager::kOutputContainer,
68                                                               "default");
69   
70
71     mgr->ConnectInput (filter, 0, cinput1 );
72     mgr->ConnectOutput(filter, 0, coutput1);
73
74     mgr->ConnectInput (esdmuonfilter, 0, cinput1 );
75     mgr->ConnectOutput(esdmuonfilter, 0, coutput1);
76
77     //
78     // Run the analysis
79     //
80     mgr->InitAnalysis();
81     mgr->PrintStatus();
82     mgr->StartAnalysis("local", chain);
83 }