Adding Tasks to Read AOD for (3He,pi) analysis
[u/mrichter/AliRoot.git] / MFT / RunAnalysisTaskMFTExample.C
CommitLineData
d30a0b7b 1Bool_t RunAnalysisTaskMFTExample(const Char_t *runType="local", // "grid" and "local" types have been tested
2 const Char_t *runMode="full") {
3
4 enum {kGenerated, kReconstructed};
5
6 LoadLibs();
7
8 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
9 if (mgr) delete mgr;
10 mgr = new AliAnalysisManager("AM","Analysis Manager");
11
12 AliAODInputHandler* inputHandler = new AliAODInputHandler();
13 mgr->SetInputEventHandler(inputHandler);
14
15 if (!strcmp(runType,"grid")) mgr->SetGridHandler(CreateAlienHandler());
16
17 gROOT->LoadMacro("AliAnalysisTaskMFTExample.cxx++g");
18 AliAnalysisTaskMFTExample *task = new AliAnalysisTaskMFTExample("AliAnalysisTaskMFTExample");
19
20 // in cm, taken from Fig. 7.4 of the ITS Upgrade TDR, in the hypothesis of ~80 tracks participating to the vtx
21 task -> SetVtxResolutionITS(5.e-4, 5.e-4, 4.e-4);
22 task -> SetVertexMode(kGenerated);
23
24 mgr->AddTask(task);
25
26 // create output container(s)
27 AliAnalysisDataContainer *output1 = mgr->CreateContainer("output1", TH1D::Class(), AliAnalysisManager::kOutputContainer, "AnalysisMFT_Output.root");
28 AliAnalysisDataContainer *output2 = mgr->CreateContainer("output2", TH1D::Class(), AliAnalysisManager::kOutputContainer, "AnalysisMFT_Output.root");
29 AliAnalysisDataContainer *output3 = mgr->CreateContainer("output3", TH1D::Class(), AliAnalysisManager::kOutputContainer, "AnalysisMFT_Output.root");
30 AliAnalysisDataContainer *output4 = mgr->CreateContainer("output4", TH1D::Class(), AliAnalysisManager::kOutputContainer, "AnalysisMFT_Output.root");
31 AliAnalysisDataContainer *output5 = mgr->CreateContainer("output5", TH1D::Class(), AliAnalysisManager::kOutputContainer, "AnalysisMFT_Output.root");
32 AliAnalysisDataContainer *output6 = mgr->CreateContainer("output6", TH1D::Class(), AliAnalysisManager::kOutputContainer, "AnalysisMFT_Output.root");
33 AliAnalysisDataContainer *output7 = mgr->CreateContainer("output7", TH1D::Class(), AliAnalysisManager::kOutputContainer, "AnalysisMFT_Output.root");
34 AliAnalysisDataContainer *output8 = mgr->CreateContainer("output8", TH1D::Class(), AliAnalysisManager::kOutputContainer, "AnalysisMFT_Output.root");
35 AliAnalysisDataContainer *output9 = mgr->CreateContainer("output9", TH1D::Class(), AliAnalysisManager::kOutputContainer, "AnalysisMFT_Output.root");
36
37 // connect input and output
38 mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
39 mgr->ConnectOutput(task, 1, output1);
40 mgr->ConnectOutput(task, 2, output2);
41 mgr->ConnectOutput(task, 3, output3);
42 mgr->ConnectOutput(task, 4, output4);
43 mgr->ConnectOutput(task, 5, output5);
44 mgr->ConnectOutput(task, 6, output6);
45 mgr->ConnectOutput(task, 7, output7);
46 mgr->ConnectOutput(task, 8, output8);
47 mgr->ConnectOutput(task, 9, output9);
48
49 // RUN ANALYSIS
50
51 TStopwatch timer;
52 timer.Start();
53 mgr->InitAnalysis();
54 mgr->PrintStatus();
55
56 if (!strcmp(runType,"grid")) {
57 printf("Starting MFT analysis on the grid");
58 mgr->StartAnalysis("grid");
59 }
60
61 else if (!strcmp(runType,"local")) {
62 printf("Starting MFT analysis locally");
63 mgr->StartAnalysis("local", GetInputLocalData());
64 }
65
66 else AliError(Form("Specified run type %s is not supported", runType));
67
68 timer.Stop();
69 timer.Print();
70 return kTRUE;
71
72}
73
74//====================================================================================================================================================
75
76AliAnalysisGrid* CreateAlienHandler() {
77
78 // Set up the analysis plugin in case of a grid analysis
79
80 TString rootVersion = "v5-34-02-1";
81 TString alirootVersion = "v5-04-33-AN";
82
83 AliAnalysisAlien *analysisPlugin = new AliAnalysisAlien();
84 if (!analysisPlugin) { Printf("Error : analysisPlugin is null !!!"); return kFALSE; }
85 analysisPlugin->SetAPIVersion("V1.1x");
86 analysisPlugin->SetROOTVersion(rootVersion.Data());
87 analysisPlugin->SetAliROOTVersion(alirootVersion.Data());
88 analysisPlugin->SetExecutableCommand("aliroot -b -q");
89
90 // Overwrite all generated files, datasets and output results from a previous session
91 analysisPlugin->SetOverwriteMode();
92 // Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
93 analysisPlugin->SetRunMode(runMode); // VERY IMPORTANT
94
95 analysisPlugin->SetAdditionalRootLibs("CORRFW");
96 analysisPlugin->SetAdditionalRootLibs("PWGmuon");
97
98 // Location of Data and Working dir
99 analysisPlugin->SetGridDataDir("");
100 analysisPlugin->SetDataPattern("");
101 analysisPlugin->SetRunPrefix("");
102 analysisPlugin->SetGridWorkingDir("");
103
104 // Declare alien output directory. Relative to working directory.
105 analysisPlugin->SetGridOutputDir("output"); // In this case will be $HOME/work/output
106 // Declare the analysis source files names separated by blancs. To be compiled runtime using ACLiC on the worker nodes.
107 analysisPlugin->SetAnalysisSource("AliAnalysisTaskMFTExample.cxx");
108 // Declare all libraries (other than the default ones for the framework. These will be
109 // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
110 analysisPlugin->SetAdditionalLibs("libCORRFW.so libPWGmuon.so AliAnalysisTaskMFTExample.h AliAnalysisTaskMFTExample.cxx");
111
112 analysisPlugin->AddIncludePath("-I.");
113
114 analysisPlugin->SetOutputToRunNo();
115
116 // Optionally set a name for the generated analysis macro (default MyAnalysis.C)
117 analysisPlugin->SetAnalysisMacro("MFTAnalysis.C");
118
119 // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
120 analysisPlugin->SetSplitMaxInputFileNumber(100);
121 // Number of runs per master job
122 analysisPlugin->SetNrunsPerMaster(1);
123
124 // Optionally modify the executable name (default analysis.sh)
125 analysisPlugin->SetExecutable("MFTAnalysis.sh");
126
127 // Optionally set number of failed jobs that will trigger killing waiting sub-jobs.
128 analysisPlugin->SetMaxInitFailed(5);
129 // Optionally resubmit threshold.
130 analysisPlugin->SetMasterResubmitThreshold(90);
131 // Optionally set time to live (default 30000 sec)
132 analysisPlugin->SetTTL(30000);
133 // Optionally set input format (default xml-single)
134 analysisPlugin->SetInputFormat("xml-single");
135 // Optionally modify the name of the generated JDL (default analysis.jdl)
136 analysisPlugin->SetJDLName("MFTAnalysis.jdl");
137 // Optionally modify job price (default 1)
138 analysisPlugin->SetPrice(1);
139 // Optionally modify split mode (default 'se')
140 analysisPlugin->SetSplitMode("se");
141
142 analysisPlugin->SetNtestFiles(5);
143 // analysisPlugin->SetMergeViaJDL(1);
144 analysisPlugin->SetOverwriteMode(kTRUE);
145
146 return analysisPlugin;
147
148}
149
150//====================================================================================================================================================
151
152TChain* GetInputLocalData() {
153
154 // Set up the chain of input events in case of a local analysis
155
156 TChain *chain = new TChain("aodTree");
157 chain->Add("./AliAOD.Muons.root");
158
159 return chain;
160
161}
162
163//====================================================================================================================================================
164
165void LoadLibs() {
166
167 gSystem->AddIncludePath("-I$ALICE_ROOT/include ");
168
169 gSystem->Load("libTree.so") ;
170 gSystem->Load("libGeom.so") ;
171 gSystem->Load("libVMC.so") ;
172 gSystem->Load("libMinuit.so") ;
173 gSystem->Load("libPhysics.so") ;
174 gSystem->Load("libSTEERBase.so") ;
175 gSystem->Load("libESD.so") ;
176 gSystem->Load("libAOD.so") ;
177 gSystem->Load("libANALYSIS.so") ;
178 gSystem->Load("libOADB.so") ;
179 gSystem->Load("libANALYSISalice.so") ;
180 gSystem->Load("libCORRFW.so") ;
181 gSystem->Load("libPWGmuon.so") ;
182
183}
184
185//====================================================================================================================================================