]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/macros/test/runProof.C
Major upgrade to the package, in order to speed-up the execution and remove some...
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / macros / test / runProof.C
CommitLineData
2dab9030 1//=============================================================================
2//
3// This is an example of steering macro for running RSN analysis task
4// in a PROOF cluster, using a dataset stored there.
5//
6// Usage requirements:
7// -- 1: run with root
8// -- 2: have available the PARs of: STEERBase, ESD, AOD, ANALYSIS
9// ANALYSISalice, CORRFW and PWG2resonances
10//
11//=============================================================================
12
13// enum to define data types
14enum ERsnData
15{
16 kRsnESD, // ESD
17 kRsnAOD // AOD
18};
19
20//_________________________________________________________________________________________________
21//
22// Steering macro.
23// The user must call this one to run the job.
24// ---
25// Arguments:
26// - nRead = how many events to read
27// - nSkip = how many events to skip (starting from first in collection)
28// - inputSource = dataset name
29// - outName = output file name
30// - dataType = kESD or kAOD (see enum above)
31// - isMC = tells if this is a MonteCarlo (otherwise is data)
32// - pathStd = path of {STEERBase|ESD|AOD|ANALYSIS|ANALYSISalice|CORRFW}.par
33// - pathRsn = path of PWG2resonances.par
34//
35// When 'isMC' is true, the MC handler is created by default.
36//
37void rsnProof
38(
39 Int_t nRead = 10,
40 Int_t nSkip = 0,
41 const char *addMacro = "AddAnalysisTaskRsnTest.C",
42 //const char *inputSource = "/ALICE/pp000900/MC_LHC09d10_104821",
43 const char *inputSource = "/COMMON/COMMON/LHC09d10_run10406X",
44 const char *outName = "rsn_proof.root",
45 ERsnData dataType = kRsnESD,
46 Bool_t isMC = kTRUE,
47 const char *pathStd = "/home/pulvir/ALICE/ALIROOT/head",
48 const char *pathRsn = "/home/pulvir/ALICE/ALIROOT/head"
49)
50{
51 // connect to PROOF
52 gEnv->SetValue("XSec.GSI.DelegProxy","2");
53 TProof::Open("pulvir@skaf.saske.sk");
54 //TProof::Open("pulvir@localhost");
55
56 // setup PARs
57 gProof->ClearPackages();
58 LoadPars("STEERBase:ESD:AOD:ANALYSIS:ANALYSISalice:CORRFW", pathStd);
59 LoadPars("PWG2resonances", pathRsn);return;
60
61 // create analysis manager and set filename
62 AliAnalysisManager *mgr = new AliAnalysisManager("RsnAnalysis");
63 mgr->SetCommonFileName(outName);
64
65 // create input handler according to data type
66 // if it is ESD and MC is required, add also that
67 AliESDInputHandler *hesd = 0x0;
68 AliAODInputHandler *haod = 0x0;
69 AliMCEventHandler *hmc = 0x0;
70 switch (dataType)
71 {
72 case kRsnESD:
73 hesd = new AliESDInputHandler();
74 mgr->SetInputEventHandler(hesd);
75 if (isMC)
76 {
77 hmc = new AliMCEventHandler();
78 mgr->SetMCtruthEventHandler(hmc);
79 }
80 break;
81 case kRsnAOD:
82 haod = new AliAODInputHandler();
83 mgr->SetInputEventHandler(haod);
84 break;
85 default:
86 ::Error("rsnLocal.C", "Data type not supported");
87 return;
88 }
89
90 // add event selection for data
91 gROOT->LoadMacro("AddTaskPhysicsSelection.C");
92 AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(isMC);
93
94 // scan list of macros
95 TString macro, taskList(addMacro);
96 TObjArray *list = taskList.Tokenize(" ");
97 TObjString *ostr = 0;
98 TObjArrayIter *next = (TObjArrayIter*)list->MakeIterator();
99 while ( (ostr = (TObjString*)(*next)()) )
100 {
101 // get tokenized string
102 macro = ostr->GetString();
103 Info("rsnLocal.C", "Adding macro: %s", macro.Data());
104 // load the macro and execute it
105 gROOT->LoadMacro(macro.Data());
106 macro.ReplaceAll(".C","();");
107 gROOT->ProcessLine(macro.Data());
108 }
109
110 // initialize analysis and run it
111 mgr->InitAnalysis();
112 mgr->PrintStatus();
113 mgr->StartAnalysis("proof", inputSource, nRead, nSkip);
114}
115
116//_________________________________________________________________________________________________
117Bool_t LoadPars(const char *parList, const char *path = ".")
118{
119//
120// Load PAR libraries in a PROOF environment.
121// ---
122// Arguments:
123// - parList = list of PARs without extension, separated by ':'
124// - path = path where PARs are stored
125//
126
127 // check PROOF initialization
128 if (!gProof) {
129 Error("CleanPars", "gProof object not initialized");
130 return kFALSE;
131 }
132
133 TString str, pars(parList), fileName;
134 TObjArray *array = pars.Tokenize(":");
135 TObjString *ostr;
136
137 for (Int_t i = 0; i < array->GetEntriesFast(); i++)
138 {
139 ostr = (TObjString*) array->At(i);
140 str = ostr->GetString();
141
142 Info("", ">> Creating PAR: %s", str.Data());
143
144 // compose filename with path and extension
145 fileName = path;
146 fileName += '/';
147 fileName.Append(str.Data());
148 fileName.Append(".par");
149
150 // upload package (uses filename)
151 gProof->UploadPackage(fileName.Data());
152
153 // enable package (uses only PAR name)
154 gProof->EnablePackage(str.Data());
155 }
156
157 return kTRUE;
158}
159
160