2 // This is an example steering macro for running RSN analysis task
3 // with the AliEn plugin to launch a multiple analysis.
6 // - runList = list of runs to be processed
7 // - runPath = path containing the runs
8 // - runMode = AliEn plugin run mode
9 // - pluginMacro = macro which loads and initializes the plugin
10 // - addTaskName = name of the macro to add the RSN analysis task
11 // (assumed to have inside it a function named like the file)
12 // - inputSource = name of the file containing all the inputs
13 // ---> to run on a local collection, the collection file
14 // must contain on each line the full path
15 // of one input file and it must have the ".txt" extension
16 // ---> to run on an AliEn collection, the collection file must be an XML
17 // file collection like those built from the "find -x" method in aliensh.
18 // - dataLabel = a label which is used to know what kind of data are being read
19 // (it is propagated to the 'addTask' macro for eventual setting up of something
20 // - outName = name for the file with RSN package outputs (without ROOT extension)
21 // in this case it is fundamental to define the names of all plugin objects
24 // - in case the source is an ESD, and if inputs are a MC production
25 // the MC input handler is created by default
28 // In principle, the user should never modify this macro.
32 const char *runList = "117112-117116-117099-117220-117048-117109-117060-117054-117065",
33 const char *runPath = "/alice/data/2010/LHC10b",
34 const char *runMode = "terminate",
35 const char *pluginMacro = "PluginDataByRun.C",
36 const char *addTaskName = "AddAnalysisTaskRsnTest.C",
37 const char *dataLabel = "7TeV_pass2_data_ESD",
38 const char *outName = "rsnTest"
42 // convert the last argument into a BOOL variable
43 TString strDataLabel(dataLabel);
44 Bool_t isESD = strDataLabel.Contains("ESD");
45 Bool_t isAOD = strDataLabel.Contains("AOD");
46 Bool_t isSim = strDataLabel.Contains("sim");
48 //AliLog::SetGlobalDebugLevel(AliLog::kDebug+2);
50 // load compiled libraries (for aliroot session)
51 gSystem->Load("libANALYSIS.so");
52 gSystem->Load("libANALYSISalice.so");
53 gSystem->Load("libCORRFW.so");
54 gSystem->Load("libPWG2resonances.so");
57 // === PLUGIN CONFIGURATION =====================================================================
61 if (!AliAnalysisGrid::CreateToken()) return;
63 // load and execute plugin configuration macro
64 // pass to the macro, as FIRST argument, the common name
65 // which is used for the output, since it must be equal
66 // to the one defined here for the common output (for merging)
67 TString splugin(pluginMacro);
68 gROOT->LoadMacro(pluginMacro);
69 splugin.ReplaceAll(".C", Form("(\"%s\",\"%s\",\"%s\")", outName, runList, runPath));
70 AliAnalysisAlien *plugin = (AliAnalysisAlien*)gROOT->ProcessLine(splugin);
73 plugin->SetRunMode(runMode);
76 // === ANALYSIS MANAGER CONFIGURATION ===========================================================
79 // create analysis manager
80 AliAnalysisManager *mgr = new AliAnalysisManager("taskRsnTest");
81 mgr->SetGridHandler(plugin);
82 mgr->SetCommonFileName(Form("%s.root", outName));
84 // create input handler
87 AliESDInputHandler *esdHandler = new AliESDInputHandler();
88 mgr->SetInputEventHandler(esdHandler);
89 // if possible, create also MC handler
92 AliMCEventHandler *mcHandler = new AliMCEventHandler();
93 mgr->SetMCtruthEventHandler(mcHandler);
98 AliAODInputHandler *aodHandler = new AliAODInputHandler();
99 mgr->SetInputEventHandler(aodHandler);
103 ::Error("Required an ESD or AOD input data set");
108 // === ANALYSIS TASK CREATION AND INCLUSION =====================================================
111 // add event selection for data
112 gROOT->LoadMacro("$(ALICE_ROOT)/ANALYSIS/macros/AddTaskPhysicsSelection.C");
113 AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(isSim);
116 gROOT->ProcessLine(Form(".x %s(\"%s\")", addTaskName, dataLabel));
118 // initialize and start analysis
119 if (!mgr->InitAnalysis()) return;
121 mgr->StartAnalysis("grid");
124 //_________________________________________________________________________________________________
125 Bool_t LoadPars(const char *parList, const char *path)
128 // Load PAR libraries locally
131 // - parList = list of PARs without extension, separated by ':'
132 // - path = path where PARs are stored
135 // store position of working directory
136 TString ocwd = gSystem->WorkingDirectory();
139 TString pars(parList);
140 TObjArray *array = pars.Tokenize(":");
145 Char_t parName[200], parFile[200];
146 for (Int_t i = 0; i < array->GetEntriesFast(); i++)
148 ostr = (TObjString*) array->At(i);
149 str = ostr->GetString();
150 sprintf(parName, "%s", str.Data());
151 sprintf(parFile, "%s/%s.par", path, str.Data());
153 // check that file exists
154 if (!gSystem->AccessPathName(parFile))
156 // explode tar-ball and enter it
157 gROOT->ProcessLine(Form(".! tar xzf %s", parFile));
158 gSystem->ChangeDirectory(Form("%s", parName));
159 // checks for BUILD.sh and execute it
160 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh"))
162 ::Info("", ">> Building PARs: %s", parName);
163 if (gSystem->Exec("PROOF-INF/BUILD.sh"))
165 ::Error("LoadPars", Form("BUILD.sh error for '%s'", parFile));
166 gSystem->ChangeDirectory(ocwd);
170 // check and execute SETUP.C
171 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C"))
173 ::Info("", ">> Setting up PARs: %s", parName);
174 if (gROOT->Macro("PROOF-INF/SETUP.C"))
176 Error("LoadPars", Form("SETUP.C error for '%s'", parFile));
177 gSystem->ChangeDirectory(ocwd);
184 Error("LoadParsLocal", Form("File '%s' not found", parFile));
189 gSystem->ChangeDirectory(ocwd);