]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MFT/RunAnalysisTaskMFTExample.C
Disable caching for async prefetching
[u/mrichter/AliRoot.git] / MFT / RunAnalysisTaskMFTExample.C
1 Bool_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 *histogramList = mgr->CreateContainer("list", TList::Class(), AliAnalysisManager::kOutputContainer, "AnalysisMFT_Output.root");
28   
29   // connect input and output
30   mgr->ConnectInput(task,  0, mgr->GetCommonInputContainer());
31   mgr->ConnectOutput(task, 1, histogramList);
32
33   // RUN ANALYSIS
34
35   TStopwatch timer;
36   timer.Start();
37   mgr->InitAnalysis();
38   mgr->PrintStatus();
39   
40   if (!strcmp(runType,"grid")) {
41     printf("Starting MFT analysis on the grid");
42     mgr->StartAnalysis("grid");
43   }
44
45   else if (!strcmp(runType,"local")) {
46     printf("Starting MFT analysis locally");
47     mgr->StartAnalysis("local", GetInputLocalData());
48   }
49
50   else AliError(Form("Specified run type %s is not supported", runType));
51   
52   timer.Stop();
53   timer.Print();
54   return kTRUE;
55
56 }
57
58 //====================================================================================================================================================
59
60 AliAnalysisGrid* CreateAlienHandler() {
61
62   // Set up the analysis plugin in case of a grid analysis
63
64   TString rootVersion = "v5-34-02-1";
65   TString alirootVersion = "v5-04-33-AN";
66
67   AliAnalysisAlien *analysisPlugin = new AliAnalysisAlien();
68   if (!analysisPlugin) { Printf("Error : analysisPlugin is null !!!"); return kFALSE; }
69   analysisPlugin->SetAPIVersion("V1.1x");
70   analysisPlugin->SetROOTVersion(rootVersion.Data());
71   analysisPlugin->SetAliROOTVersion(alirootVersion.Data());
72   analysisPlugin->SetExecutableCommand("aliroot -b -q");
73
74   // Overwrite all generated files, datasets and output results from a previous session
75   analysisPlugin->SetOverwriteMode();
76   // Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
77   analysisPlugin->SetRunMode(runMode);  // VERY IMPORTANT 
78   
79   analysisPlugin->SetAdditionalRootLibs("CORRFW");
80   analysisPlugin->SetAdditionalRootLibs("PWGmuon");
81   
82   // Location of Data and Working dir
83   analysisPlugin->SetGridDataDir("");
84   analysisPlugin->SetDataPattern("");
85   analysisPlugin->SetRunPrefix("");
86   analysisPlugin->SetGridWorkingDir("");
87   
88   // Declare alien output directory. Relative to working directory.
89   analysisPlugin->SetGridOutputDir("output"); // In this case will be $HOME/work/output
90   // Declare the analysis source files names separated by blancs. To be compiled runtime using ACLiC on the worker nodes.
91   analysisPlugin->SetAnalysisSource("AliAnalysisTaskMFTExample.cxx");
92   // Declare all libraries (other than the default ones for the framework. These will be
93   // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
94   analysisPlugin->SetAdditionalLibs("libCORRFW.so libPWGmuon.so AliAnalysisTaskMFTExample.h AliAnalysisTaskMFTExample.cxx");
95   
96   analysisPlugin->AddIncludePath("-I.");
97
98   analysisPlugin->SetOutputToRunNo();
99   
100   // Optionally set a name for the generated analysis macro (default MyAnalysis.C)
101   analysisPlugin->SetAnalysisMacro("MFTAnalysis.C");
102
103   // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
104   analysisPlugin->SetSplitMaxInputFileNumber(100);
105   // Number of runs per master job
106   analysisPlugin->SetNrunsPerMaster(1);
107   
108   // Optionally modify the executable name (default analysis.sh)
109   analysisPlugin->SetExecutable("MFTAnalysis.sh");
110
111   // Optionally set number of failed jobs that will trigger killing waiting sub-jobs.
112   analysisPlugin->SetMaxInitFailed(5);
113   // Optionally resubmit threshold.
114   analysisPlugin->SetMasterResubmitThreshold(90);
115   // Optionally set time to live (default 30000 sec)
116   analysisPlugin->SetTTL(30000);
117   // Optionally set input format (default xml-single)
118   analysisPlugin->SetInputFormat("xml-single");
119   // Optionally modify the name of the generated JDL (default analysis.jdl)
120   analysisPlugin->SetJDLName("MFTAnalysis.jdl");
121   // Optionally modify job price (default 1)
122   analysisPlugin->SetPrice(1);      
123   // Optionally modify split mode (default 'se')    
124   analysisPlugin->SetSplitMode("se");
125   
126   analysisPlugin->SetNtestFiles(5);
127   //   analysisPlugin->SetMergeViaJDL(1);
128   analysisPlugin->SetOverwriteMode(kTRUE);
129   
130   return analysisPlugin;
131
132 }
133
134 //====================================================================================================================================================
135
136 TChain* GetInputLocalData() {
137
138   // Set up the chain of input events in case of a local analysis
139
140   TChain *chain = new TChain("aodTree");
141   chain->Add("./AliAOD.Muons.root");
142
143   return chain;
144
145 }
146
147 //====================================================================================================================================================
148
149 void LoadLibs() {
150
151   gSystem->AddIncludePath("-I$ALICE_ROOT/include ");
152   
153   gSystem->Load("libTree.so")          ;
154   gSystem->Load("libGeom.so")          ;
155   gSystem->Load("libVMC.so")           ;
156   gSystem->Load("libMinuit.so")        ;
157   gSystem->Load("libPhysics.so")       ;
158   gSystem->Load("libSTEERBase.so")     ;
159   gSystem->Load("libESD.so")           ;
160   gSystem->Load("libAOD.so")           ;
161   gSystem->Load("libANALYSIS.so")      ;
162   gSystem->Load("libOADB.so")          ;
163   gSystem->Load("libANALYSISalice.so") ;
164   gSystem->Load("libCORRFW.so")        ;
165   gSystem->Load("libPWGmuon.so")       ;
166
167 }
168
169 //====================================================================================================================================================