Restored call to CreateDigitizer (F.Prino)
[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//
19a7d46c 37void runProof
2dab9030 38(
19a7d46c 39 Int_t nRead = 1e5,
2dab9030 40 Int_t nSkip = 0,
41 const char *addMacro = "AddAnalysisTaskRsnTest.C",
42 //const char *inputSource = "/ALICE/pp000900/MC_LHC09d10_104821",
19a7d46c 43// const char *inputSource = "/alice/sim/LHC10a12_104157",
44 const char *inputSource = "/alice/data/LHC10b_000117112_p2",
2dab9030 45 const char *outName = "rsn_proof.root",
46 ERsnData dataType = kRsnESD,
19a7d46c 47 Bool_t isMC = kFALSE,
2dab9030 48 const char *pathStd = "/home/pulvir/ALICE/ALIROOT/head",
19a7d46c 49 const char *pathRsn = "/home/pulvir/ALICE/ALIROOT/head",
50 const char *datalabel = "7TeV_pass2_data_ESD"
2dab9030 51)
52{
19a7d46c 53
2dab9030 54 // connect to PROOF
55 gEnv->SetValue("XSec.GSI.DelegProxy","2");
19a7d46c 56 TProof::Open("skaf.saske.sk");
2dab9030 57 //TProof::Open("pulvir@localhost");
58
19a7d46c 59 // this i will do that AAF will load (needed for TOF)
60 gProof->Exec("gSystem->Load(\"libXMLParser.so\");");
61
62 // needed for tof too
63 gProof->Exec("TGrid::Connect(\"alien:\/\/\");");
64
2dab9030 65 // setup PARs
19a7d46c 66// gProof->ClearPackages();
2dab9030 67
19a7d46c 68 // setup aliroot mode in AAF (for now using SIM mode since ALIROOT mode doesn't load correctly (this is tmp))
69 TList *listAliroot = new TList();
70 listAliroot->Add(new TNamed("ALIROOT_MODE", "SIM"));
71
72 Bool_t usePWG2resonancesPAR = kTRUE;
73 TString alirootVer = "VO_ALICE@AliRoot::v4-20-03-AN-proof";
74
75 if (usePWG2resonancesPAR) {
76 listAliroot->Add(new TNamed("ALIROOT_EXTRA_LIBS", "ANALYSIS:ANALYSISalice:CORRFW"));
77 listAliroot->Add(new TNamed("ALIROOT_EXTRA_INCLUDES", "TOF"));
78 gProof->EnablePackage(alirootVer.Data(),listAliroot);
79 gProof->UploadPackage("PWG2resonances.par");
80 if (gProof->EnablePackage("PWG2resonances")) {
81 Error("runAAF.C","Error in PWG2resonances !!!");
82 return;
83 }
84 }
85 else {
86 listAliroot->Add(new TNamed("ALIROOT_EXTRA_LIBS", "ANALYSIS:ANALYSISalice:CORRFW:PWG2resonances"));
87 listAliroot->Add(new TNamed("ALIROOT_EXTRA_INCLUDES", "PWG2/RESONANCES:TOF"));
88 gProof->EnablePackage(alirootVer.Data(),listAliroot);
89 }
90
2dab9030 91 // create analysis manager and set filename
92 AliAnalysisManager *mgr = new AliAnalysisManager("RsnAnalysis");
93 mgr->SetCommonFileName(outName);
94
95 // create input handler according to data type
96 // if it is ESD and MC is required, add also that
97 AliESDInputHandler *hesd = 0x0;
98 AliAODInputHandler *haod = 0x0;
99 AliMCEventHandler *hmc = 0x0;
100 switch (dataType)
101 {
102 case kRsnESD:
103 hesd = new AliESDInputHandler();
104 mgr->SetInputEventHandler(hesd);
105 if (isMC)
106 {
107 hmc = new AliMCEventHandler();
108 mgr->SetMCtruthEventHandler(hmc);
109 }
110 break;
111 case kRsnAOD:
112 haod = new AliAODInputHandler();
113 mgr->SetInputEventHandler(haod);
114 break;
115 default:
116 ::Error("rsnLocal.C", "Data type not supported");
117 return;
118 }
119
19a7d46c 120// // add event selection for data
121// gROOT->LoadMacro("AddTaskPhysicsSelection.C");
122// AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(isMC);
2dab9030 123
124 // scan list of macros
125 TString macro, taskList(addMacro);
126 TObjArray *list = taskList.Tokenize(" ");
127 TObjString *ostr = 0;
128 TObjArrayIter *next = (TObjArrayIter*)list->MakeIterator();
129 while ( (ostr = (TObjString*)(*next)()) )
130 {
131 // get tokenized string
132 macro = ostr->GetString();
133 Info("rsnLocal.C", "Adding macro: %s", macro.Data());
134 // load the macro and execute it
135 gROOT->LoadMacro(macro.Data());
19a7d46c 136 macro.ReplaceAll(".C",Form("(\"%s\");",datalabel));
2dab9030 137 gROOT->ProcessLine(macro.Data());
138 }
139
140 // initialize analysis and run it
141 mgr->InitAnalysis();
142 mgr->PrintStatus();
143 mgr->StartAnalysis("proof", inputSource, nRead, nSkip);
144}
145
146//_________________________________________________________________________________________________
147Bool_t LoadPars(const char *parList, const char *path = ".")
148{
149//
150// Load PAR libraries in a PROOF environment.
151// ---
152// Arguments:
153// - parList = list of PARs without extension, separated by ':'
154// - path = path where PARs are stored
155//
156
157 // check PROOF initialization
158 if (!gProof) {
159 Error("CleanPars", "gProof object not initialized");
160 return kFALSE;
161 }
162
163 TString str, pars(parList), fileName;
164 TObjArray *array = pars.Tokenize(":");
165 TObjString *ostr;
166
167 for (Int_t i = 0; i < array->GetEntriesFast(); i++)
168 {
169 ostr = (TObjString*) array->At(i);
170 str = ostr->GetString();
171
172 Info("", ">> Creating PAR: %s", str.Data());
173
174 // compose filename with path and extension
175 fileName = path;
176 fileName += '/';
177 fileName.Append(str.Data());
178 fileName.Append(".par");
179
180 // upload package (uses filename)
181 gProof->UploadPackage(fileName.Data());
182
183 // enable package (uses only PAR name)
184 gProof->EnablePackage(str.Data());
185 }
186
187 return kTRUE;
188}
189
190