ITS stand-alone tracks added to AOD (A. Dainese)
[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 = "AliAODs.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     inpHandler->SetReadTags();
34     mgr->SetInputEventHandler  (inpHandler);
35
36     // Output
37     AliAODHandler* aodHandler   = new AliAODHandler();
38     aodHandler->SetOutputFileName(outFileName);
39     mgr->SetOutputEventHandler(aodHandler);
40
41     // Task
42     // Barrel Tracks
43     AliAnalysisTaskESDfilter *filter = new AliAnalysisTaskESDfilter("Filter");
44     mgr->AddTask(filter);
45     // Muons
46     AliAnalysisTaskESDMuonFilter *esdmuonfilter = new AliAnalysisTaskESDMuonFilter("ESD Muon Filter");
47     mgr->AddTask(esdmuonfilter);
48
49     // Cuts on primary tracks
50     AliESDtrackCuts* esdTrackCutsL = new AliESDtrackCuts("AliESDtrackCuts", "Standard");
51     esdTrackCutsL->SetMinNClustersTPC(50);
52     esdTrackCutsL->SetMaxChi2PerClusterTPC(3.5);
53     esdTrackCutsL->SetMaxCovDiagonalElements(2, 2, 0.5, 0.5, 2);
54     esdTrackCutsL->SetRequireTPCRefit(kTRUE);
55     esdTrackCutsL->SetMaxDCAToVertexXY(3.0);
56     esdTrackCutsL->SetMaxDCAToVertexZ(3.0);
57     esdTrackCutsL->SetDCAToVertex2D(kTRUE);
58     esdTrackCutsL->SetRequireSigmaToVertex(kFALSE);
59     esdTrackCutsL->SetAcceptKingDaughters(kFALSE);
60     // ITS stand-alone tracks
61     AliESDtrackCuts* esdTrackCutsITSsa = new AliESDtrackCuts("AliESDtrackCuts", "ITS stand-alone");
62     esdTrackCutsITSsa->SetRequireITSStandAlone(kTRUE);
63
64     AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
65     trackFilter->AddCuts(esdTrackCutsL);
66     trackFilter->AddCuts(esdTrackCutsITSsa);
67
68     // Cuts on V0s
69     AliESDv0Cuts*   esdV0Cuts = new AliESDv0Cuts("AliESDv0Cuts", "Standard pp");
70     esdV0Cuts->SetMinRadius(0.2);
71     esdV0Cuts->SetMaxRadius(100);
72     esdV0Cuts->SetMinDcaPosToVertex(0.05);
73     esdV0Cuts->SetMinDcaNegToVertex(0.05);
74     esdV0Cuts->SetMaxDcaV0Daughters(0.5);
75     esdV0Cuts->SetMinCosinePointingAngle(0.99);
76     AliAnalysisFilter* v0Filter = new AliAnalysisFilter("v0Filter");
77     v0Filter->AddCuts(esdV0Cuts);
78
79
80 //
81     filter->SetTrackFilter(trackFilter);
82     filter->SetV0Filter(v0Filter);
83
84
85 //  Create AOD Tags
86     AliAnalysisTaskTagCreator* tagTask = new AliAnalysisTaskTagCreator("AOD Tag Creator");
87     mgr->AddTask(tagTask);
88
89     // Pipelining
90     AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();    
91     AliAnalysisDataContainer *coutput1 = mgr->GetCommonOutputContainer();
92     AliAnalysisDataContainer *coutputT
93         = mgr->CreateContainer("cTag",  TTree::Class(), AliAnalysisManager::kOutputContainer, "AOD.tag.root");
94     
95     mgr->ConnectInput (filter, 0, cinput1 );
96     mgr->ConnectOutput(filter, 0, coutput1);
97
98     mgr->ConnectInput (esdmuonfilter, 0, cinput1 );
99 //    mgr->ConnectOutput(esdmuonfilter, 0, coutput1);
100
101     mgr->ConnectInput (tagTask, 0, cinput1);
102     mgr->ConnectOutput(tagTask, 1, coutputT);
103
104     //
105     // Run the analysis
106     //
107     mgr->InitAnalysis();
108     mgr->PrintStatus();
109     mgr->StartAnalysis("local", chain);
110 }
111