forked from alice-doc/alice-analysis-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runAnalysis.C
110 lines (98 loc) · 4.42 KB
/
runAnalysis.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#if !defined (__CINT__) || defined (__CLING__)
#include "AliAnalysisAlien.h"
#include "AliAnalysisManager.h"
#include "AliAODInputHandler.h"
#include "AliAnalysisTaskMyTask.h"
#endif
void runAnalysis()
{
// set if you want to run the analysis locally (kTRUE), or on grid (kFALSE)
Bool_t local = kTRUE;
// if you run on grid, specify test mode (kTRUE) or full grid model (kFALSE)
Bool_t gridTest = kTRUE;
// since we will compile a class, tell root where to look for headers
#if !defined (__CINT__) || defined (__CLING__)
gInterpreter->ProcessLine(".include $ROOTSYS/include");
gInterpreter->ProcessLine(".include $ALICE_ROOT/include");
#else
gROOT->ProcessLine(".include $ROOTSYS/include");
gROOT->ProcessLine(".include $ALICE_ROOT/include");
#endif
// create the analysis manager
AliAnalysisManager *mgr = new AliAnalysisManager("AnalysisTaskExample");
AliAODInputHandler *aodH = new AliAODInputHandler();
mgr->SetInputEventHandler(aodH);
// compile the class and load the add task macro
// here we have to differentiate between using the just-in-time compiler
// from root6, or the interpreter of root5
#if !defined (__CINT__) || defined (__CLING__)
gInterpreter->LoadMacro("AliAnalysisTaskMyTask.cxx++g");
AliAnalysisTaskMyTask *task = reinterpret_cast<AliAnalysisTaskMyTask*>(gInterpreter->ExecuteMacro("AddMyTask.C"));
#else
gROOT->LoadMacro("AliAnalysisTaskMyTask.cxx++g");
gROOT->LoadMacro("AddMyTask.C");
AliAnalysisTaskMyTask *task = AddMyTask();
#endif
if(!mgr->InitAnalysis()) return;
mgr->SetDebugLevel(2);
mgr->PrintStatus();
mgr->SetUseProgressBar(1, 25);
if(local) {
// if you want to run locally, we need to define some input
TChain* chain = new TChain("aodTree");
// add a few files to the chain (change this so that your local files are added)
chain->Add("AliAOD.root");
// start the analysis locally, reading the events from the tchain
mgr->StartAnalysis("local", chain);
} else {
// if we want to run on grid, we create and configure the plugin
AliAnalysisAlien *alienHandler = new AliAnalysisAlien();
// also specify the include (header) paths on grid
alienHandler->AddIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT -I$ALICE_ROOT/include -I$ALICE_PHYSICS/include");
// make sure your source files get copied to grid
alienHandler->SetAdditionalLibs("AliAnalysisTaskMyTask.cxx AliAnalysisTaskMyTask.h");
alienHandler->SetAnalysisSource("AliAnalysisTaskMyTask.cxx");
// select the aliphysics version. all other packages
// are LOADED AUTOMATICALLY!
alienHandler->SetAliPhysicsVersion("vAN-20160330-2");
// set the Alien API version
alienHandler->SetAPIVersion("V1.1x");
// select the input data
alienHandler->SetGridDataDir("/alice/data/2011/LHC11h_2");
alienHandler->SetDataPattern("*ESDs/pass2/AOD145/*AOD.root");
// MC has no prefix, data has prefix 000
alienHandler->SetRunPrefix("000");
// runnumber
alienHandler->AddRunNumber(167813);
// number of files per subjob
alienHandler->SetSplitMaxInputFileNumber(40);
alienHandler->SetExecutable("myTask.sh");
// specify how many seconds your job may take
alienHandler->SetTTL(10000);
alienHandler->SetJDLName("myTask.jdl");
alienHandler->SetOutputToRunNo(kTRUE);
alienHandler->SetKeepLogs(kTRUE);
// merging: run with kTRUE to merge on grid
// after re-running the jobs in SetRunMode("terminate")
// (see below) mode, set SetMergeViaJDL(kFALSE)
// to collect final results
alienHandler->SetMaxMergeStages(1);
alienHandler->SetMergeViaJDL(kTRUE);
// define the output folders
alienHandler->SetGridWorkingDir("myWorkingDir");
alienHandler->SetGridOutputDir("myOutputDir");
// connect the alien plugin to the manager
mgr->SetGridHandler(alienHandler);
if(gridTest) {
// speficy on how many files you want to run
alienHandler->SetNtestFiles(1);
// and launch the analysis
alienHandler->SetRunMode("test");
mgr->StartAnalysis("grid");
} else {
// else launch the full grid analysis
alienHandler->SetRunMode("full");
mgr->StartAnalysis("grid");
}
}
}