1a6db1e0 |
1 | class AliAnalysisGrid;\r |
2 | \r |
32bb35a1 |
3 | void RunAnalysisAODVertexingHF()\r |
4 | {\r |
5 | //\r |
6 | // Test macro for AliAnalysisTaskSE's for heavy-flavour candidates\r |
7 | // It has the structure of a Analysis Train:\r |
8 | // - in this macro, change things related to running mode\r |
9 | // and input preparation \r |
10 | // - add your task using a AddTaskXXX macro \r |
11 | //\r |
12 | // A.Dainese, andrea.dainese@lnl.infn.it\r |
13 | // "grid" mode added by R.Bala, bala@to.infn.it\r |
14 | //\r |
15 | \r |
1a6db1e0 |
16 | //\r |
aabcfd8f |
17 | TString analysisMode = "local"; // "local", "grid", or "proof" (not yet)\r |
1a6db1e0 |
18 | TString inputMode = "list"; // "list", "xml", or "dataset" (not yet)\r |
19 | Long64_t nentries=1234567890,firstentry=0;\r |
aabcfd8f |
20 | Bool_t useParFiles=kFALSE;\r |
21 | Bool_t useAlienPlugin=kFALSE;\r |
1a6db1e0 |
22 | TString pluginmode="full";\r |
23 | TString loadMacroPath="$ALICE_ROOT/PWG3/vertexingHF/";\r |
24 | //\r |
32bb35a1 |
25 | \r |
1a6db1e0 |
26 | if(analysisMode=="grid") {\r |
27 | // Connect to AliEn\r |
28 | TGrid::Connect("alien://");\r |
29 | } else if(analysisMode=="proof") {\r |
30 | // Connect to the PROOF cluster\r |
31 | printf("PROOF mode not yet functional..\n");\r |
32 | return;\r |
33 | TProof::Open("alicecaf");\r |
34 | //TProof::Reset("alicecaf");\r |
35 | }\r |
32bb35a1 |
36 | \r |
32bb35a1 |
37 | \r |
1a6db1e0 |
38 | // AliRoot libraries\r |
39 | if(analysisMode=="local" || analysisMode=="grid") {\r |
40 | TString loadLibraries="LoadLibraries.C"; loadLibraries.Prepend(loadMacroPath.Data());\r |
41 | gROOT->LoadMacro(loadLibraries.Data());\r |
42 | LoadLibraries(useParFiles);\r |
43 | } else if (analysisMode=="proof") {\r |
44 | gSystem->Load("libTree.so");\r |
45 | gSystem->Load("libGeom.so");\r |
46 | gSystem->Load("libPhysics.so");\r |
47 | gSystem->Load("libVMC.so"); \r |
48 | // Enable the needed packages\r |
49 | //gProof->ClearPackages();\r |
50 | if(!useParFiles) {\r |
51 | gProof->UploadPackage("AF-v4-16");\r |
52 | gProof->EnablePackage("AF-v4-16");\r |
53 | } else {\r |
54 | TString parDir="/afs/cern.ch/user/d/dainesea/code/";\r |
55 | TString parFile;\r |
56 | // --- Enable the STEERBase Package\r |
57 | parFile="STEERBase.par"; parFile.Prepend(parDir.Data());\r |
58 | gProof->UploadPackage(parFile.Data());\r |
59 | gProof->EnablePackage("STEERBase");\r |
60 | // --- Enable the ESD Package\r |
61 | parFile="ESD.par"; parFile.Prepend(parDir.Data());\r |
62 | gProof->UploadPackage(parFile.Data());\r |
63 | gProof->EnablePackage("ESD");\r |
64 | // --- Enable the AOD Package\r |
65 | parFile="AOD.par"; parFile.Prepend(parDir.Data());\r |
66 | gProof->UploadPackage(parFile.Data());\r |
67 | gProof->EnablePackage("AOD");\r |
68 | // --- Enable the ANALYSIS Package\r |
69 | parFile="ANALYSIS.par"; parFile.Prepend(parDir.Data());\r |
70 | gProof->UploadPackage(parFile.Data());\r |
71 | gProof->EnablePackage("ANALYSIS");\r |
72 | // --- Enable the ANALYSISalice Package\r |
73 | parFile="ANALYSISalice.par"; parFile.Prepend(parDir.Data());\r |
74 | gProof->UploadPackage(parFile.Data());\r |
75 | gProof->EnablePackage("ANALYSISalice");\r |
76 | // --- Enable the CORRFW Package\r |
77 | parFile="CORRFW.par"; parFile.Prepend(parDir.Data());\r |
78 | gProof->UploadPackage(parFile.Data());\r |
79 | gProof->EnablePackage("CORRFW");\r |
b093f071 |
80 | // --- Enable the PWG3base Package\r |
81 | parFile="PWG3base.par"; parFile.Prepend(parDir.Data());\r |
82 | gProof->UploadPackage(parFile.Data());\r |
83 | gProof->EnablePackage("PWG3base");\r |
1a6db1e0 |
84 | // --- Enable the PWG3vertexingHF Package\r |
85 | parFile="PWG3vertexingHF.par"; parFile.Prepend(parDir.Data());\r |
86 | gProof->UploadPackage(parFile.Data());\r |
87 | gProof->EnablePackage("PWG3vertexingHF");\r |
b093f071 |
88 | // --- Enable the JETAN Package\r |
89 | parFile="JETAN.par"; parFile.Prepend(parDir.Data());\r |
90 | gProof->UploadPackage(parFile.Data());\r |
91 | gProof->EnablePackage("JETAN");\r |
92 | // --- Enable the PWG3muon Package\r |
93 | parFile="PWG3muon.par"; parFile.Prepend(parDir.Data());\r |
94 | gProof->UploadPackage(parFile.Data());\r |
95 | gProof->EnablePackage("PWG3muon");\r |
96 | // --- Enable the PWG4PartCorrBase Package\r |
97 | parFile="PWG4PartCorrBase.par"; parFile.Prepend(parDir.Data());\r |
98 | gProof->UploadPackage(parFile.Data());\r |
99 | gProof->EnablePackage("PWG4PartCorrBase");\r |
100 | // --- Enable the PWG4PartCorrDep Package\r |
101 | parFile="PWG4PartCorrDep.par"; parFile.Prepend(parDir.Data());\r |
102 | gProof->UploadPackage(parFile.Data());\r |
103 | gProof->EnablePackage("PWG4PartCorrDep");\r |
1a6db1e0 |
104 | }\r |
105 | gProof->ShowEnabledPackages(); // show a list of enabled packages\r |
106 | }\r |
32bb35a1 |
107 | \r |
108 | \r |
1a6db1e0 |
109 | // Create Alien plugin, if requested\r |
110 | if(useAlienPlugin) { \r |
111 | AliAnalysisGrid *alienHandler = CreateAlienHandler(pluginmode,useParFiles); \r |
112 | if(!alienHandler) return;\r |
113 | }\r |
32bb35a1 |
114 | \r |
115 | \r |
116 | //-------------------------------------------------------------------\r |
117 | // Prepare input chain\r |
118 | TChain *chainAOD = 0;\r |
1a6db1e0 |
119 | TString dataset; // for proof\r |
120 | \r |
121 | if(!useAlienPlugin) {\r |
aabcfd8f |
122 | TString makeAODInputChain="MakeAODInputChain.C"; makeAODInputChain.Prepend(loadMacroPath.Data());\r |
1a6db1e0 |
123 | gROOT->LoadMacro(makeAODInputChain.Data());\r |
124 | if(inputMode=="list") {\r |
125 | // Local files\r |
126 | chainAOD = MakeAODInputChain();// with this it reads ./AliAOD.root and ./AliAOD.VertexingHF.root\r |
aabcfd8f |
127 | //chainAOD = MakeAODInputChain("alien:///alice/cern.ch/user/r/rbala/newtrain/out_lhc08x/180100/",1,1);\r |
1a6db1e0 |
128 | } else if(inputMode=="xml") {\r |
129 | // xml\r |
130 | chainAOD = MakeAODInputChain("collection_aod.xml","collection_aodHF.xml");\r |
131 | } else if(inputMode=="dataset") {\r |
132 | // CAF dataset\r |
133 | //gProof->ShowDataSet();\r |
134 | dataset="/ITS/dainesea/AODVertexingHF_LHC08x_180100_small";\r |
135 | chainAOD = MakeAODInputChainCAF(dataset.Data());\r |
136 | }\r |
32bb35a1 |
137 | }\r |
138 | \r |
139 | // Create the analysis manager\r |
140 | AliAnalysisManager *mgr = new AliAnalysisManager("My Manager","My Manager");\r |
141 | mgr->SetDebugLevel(10);\r |
1a6db1e0 |
142 | // Connect plug-in to the analysis manager\r |
143 | if(useAlienPlugin) mgr->SetGridHandler(alienHandler);\r |
144 | \r |
32bb35a1 |
145 | \r |
146 | // Input\r |
147 | AliAODInputHandler *inputHandler = new AliAODInputHandler();\r |
148 | mgr->SetInputEventHandler(inputHandler);\r |
149 | //-------------------------------------------------------------------\r |
150 | \r |
151 | \r |
152 | //-------------------------------------------------------------------\r |
1a6db1e0 |
153 | // Analysis tasks (wagons of the train) \r |
32bb35a1 |
154 | //\r |
1a6db1e0 |
155 | TString taskName;\r |
156 | \r |
157 | taskName="AddTaskCompareHF.C"; taskName.Prepend(loadMacroPath.Data());\r |
158 | gROOT->LoadMacro(taskName.Data());\r |
32bb35a1 |
159 | AliAnalysisTaskSECompareHF *cmpTask = AddTaskCompareHF();\r |
a9f684f8 |
160 | \r |
d486095a |
161 | taskName="AddTaskDplus.C"; taskName.Prepend(loadMacroPath.Data());\r |
162 | gROOT->LoadMacro(taskName.Data());\r |
163 | AliAnalysisTaskSEDplus *dplusTask = AddTaskDplus();\r |
164 | \r |
1a6db1e0 |
165 | //taskName="AddTaskSelectHF.C"; taskName.Prepend(loadMacroPath.Data());\r |
166 | //gROOT->LoadMacro(taskName.Data());\r |
167 | //AliAnalysisTaskSESelectHF *seleTask = AddTaskSelectHF();\r |
a9f684f8 |
168 | \r |
b093f071 |
169 | taskName="AddTaskBkgLikeSign.C"; taskName.Prepend(loadMacroPath.Data());\r |
170 | gROOT->LoadMacro(taskName.Data());\r |
171 | AliAnalysisTaskSEBkgLikeSignJPSI *lsTask = AddTaskBkgLikeSign();\r |
a9f684f8 |
172 | \r |
1a6db1e0 |
173 | //taskName="AddTaskBtoJPSItoEle.C"; taskName.Prepend(loadMacroPath.Data());\r |
174 | //gROOT->LoadMacro(taskName.Data());\r |
32bb35a1 |
175 | //AliAnalysisTaskSEBtoJPSItoEle *jpsiTask = AddTaskBtoJPSItoEle();\r |
a9f684f8 |
176 | \r |
1a6db1e0 |
177 | //taskName="AddTaskCF.C"; taskName.Prepend(loadMacroPath.Data());\r |
178 | //gROOT->LoadMacro(taskName.Data());\r |
a9f684f8 |
179 | //AliCFHeavyFlavourTask *cfTask = AddTaskCF();\r |
180 | \r |
1a6db1e0 |
181 | //taskName="AddTaskCFMultiVar.C"; taskName.Prepend(loadMacroPath.Data());\r |
182 | //gROOT->LoadMacro(taskName.Data());\r |
32bb35a1 |
183 | //AliCFHeavyFlavourTaskMultiVar *cfmvTask = AddTaskCFMultiVar();\r |
184 | \r |
b093f071 |
185 | taskName="AddTaskMultiVarMultiStep.C"; taskName.Prepend(loadMacroPath.Data());\r |
186 | gROOT->LoadMacro(taskName.Data());\r |
187 | AliCFHeavyFlavourTaskMultiVarMultiStep *cfmvmsTask = AddTaskCFMultiVarMultiStep();\r |
a9f684f8 |
188 | \r |
32bb35a1 |
189 | \r |
190 | //-------------------------------------------------------------------\r |
191 | \r |
192 | //\r |
193 | // Run the analysis\r |
194 | // \r |
1a6db1e0 |
195 | if(chainAOD) printf("CHAIN HAS %d ENTRIES\n",(Int_t)chainAOD->GetEntries());\r |
196 | \r |
197 | if(!mgr->InitAnalysis()) return;\r |
198 | mgr->PrintStatus();\r |
199 | if(analysisMode=="grid" && !useAlienPlugin) analysisMode="local";\r |
200 | mgr->StartAnalysis(analysisMode.Data(),chainAOD,nentries,firstentry);\r |
32bb35a1 |
201 | \r |
202 | return;\r |
203 | }\r |
1a6db1e0 |
204 | //_____________________________________________________________________________\r |
205 | //\r |
206 | AliAnalysisGrid* CreateAlienHandler(TString pluginmode="test",Bool_t useParFiles=kFALSE)\r |
207 | {\r |
208 | // Check if user has a valid token, otherwise make one. This has limitations.\r |
209 | // One can always follow the standard procedure of calling alien-token-init then\r |
210 | // source /tmp/gclient_env_$UID in the current shell.\r |
211 | if (!AliAnalysisGrid::CreateToken()) return NULL;\r |
212 | AliAnalysisAlien *plugin = new AliAnalysisAlien();\r |
213 | // Set the run mode (can be "full", "test", "offline", "submit" or "terminate")\r |
214 | plugin->SetRunMode(pluginmode.Data());\r |
215 | plugin->SetUser("dainesea");\r |
216 | plugin->SetNtestFiles(1);\r |
217 | // Set versions of used packages\r |
218 | plugin->SetAPIVersion("V2.4");\r |
219 | plugin->SetROOTVersion("v5-23-02");\r |
220 | plugin->SetAliROOTVersion("v4-17-00");\r |
221 | // Declare input data to be processed.\r |
222 | // Method 1: Create automatically XML collections using alien 'find' command.\r |
223 | // Define production directory LFN\r |
224 | plugin->SetGridDataDir("/alice/cern.ch/user/r/rbala/newtrain/out_lhc08x/");\r |
225 | // Set data search pattern\r |
226 | plugin->SetDataPattern("AliAOD.root");\r |
227 | plugin->SetFriendChainName("AliAOD.VertexingHF.root");\r |
228 | // ...then add run numbers to be considered\r |
229 | plugin->AddRunNumber(180100);\r |
230 | // Method 2: Declare existing data files (raw collections, xml collections, root file)\r |
231 | // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())\r |
232 | // XML collections added via this method can be combined with the first method if\r |
233 | // the content is compatible (using or not tags)\r |
234 | //plugin->AddDataFile("/alice/cern.ch/user/r/rbala/newtrain/collection/collection_aod_lhc08w.xml");\r |
235 | // plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");\r |
236 | // Define alien work directory where all files will be copied. Relative to alien $HOME.\r |
237 | plugin->SetGridWorkingDir("work");\r |
238 | // Declare alien output directory. Relative to working directory.\r |
239 | plugin->SetGridOutputDir("output"); // In this case will be $HOME/work/output\r |
240 | // Declare the analysis source files names separated by blancs. To be compiled runtime\r |
241 | // using ACLiC on the worker nodes.\r |
242 | //plugin->SetAnalysisSource("$ALICE_ROOT/PWG3/vertexingHF/AliAnalysisTaskSECompareHF.cxx");\r |
243 | // Declare all libraries (other than the default ones for the framework. These will be\r |
244 | // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.\r |
245 | plugin->SetAdditionalLibs("libPWG3vertexingHF.so");\r |
246 | // use par files\r |
247 | if(useParFiles) {\r |
248 | plugin->EnablePackage("STEERBase.par");\r |
249 | plugin->EnablePackage("ESD.par");\r |
250 | plugin->EnablePackage("AOD.par");\r |
251 | plugin->EnablePackage("ANALYSIS.par");\r |
252 | plugin->EnablePackage("ANALYSISalice.par");\r |
253 | plugin->EnablePackage("CORRFW.par");\r |
254 | plugin->EnablePackage("PWG3vertexingHF.par");\r |
255 | }\r |
256 | // Declare the output file names separated by blancs.\r |
257 | // (can be like: file.root or file.root@ALICE::Niham::File)\r |
258 | plugin->SetOutputFiles("CmpHF.root");\r |
259 | // Optionally define the files to be archived.\r |
260 | // plugin->SetOutputArchive("log_archive.zip:stdout,stderr@ALICE::NIHAM::File root_archive.zip:*.root@ALICE::NIHAM::File");\r |
261 | plugin->SetOutputArchive("log_archive.zip:stdout,stderr");\r |
262 | // Optionally set a name for the generated analysis macro (default MyAnalysis.C)\r |
263 | plugin->SetAnalysisMacro("AnalysisHF.C");\r |
264 | // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)\r |
265 | plugin->SetSplitMaxInputFileNumber(5);\r |
266 | // Optionally set number of failed jobs that will trigger killing waiting sub-jobs.\r |
267 | //plugin->SetMaxInitFailed(5);\r |
268 | // Optionally resubmit threshold.\r |
269 | //plugin->SetMasterResubmitThreshold(90);\r |
270 | // Optionally set time to live (default 30000 sec)\r |
271 | //plugin->SetTTL(20000);\r |
272 | // Optionally set input format (default xml-single)\r |
273 | plugin->SetInputFormat("xml-single");\r |
274 | // Optionally modify the name of the generated JDL (default analysis.jdl)\r |
275 | plugin->SetJDLName("TaskHF.jdl");\r |
276 | // Optionally modify job price (default 1)\r |
277 | //plugin->SetPrice(1); \r |
278 | // Optionally modify split mode (default 'se') \r |
279 | plugin->SetSplitMode("se");\r |
280 | // Optionally set the preferred SE \r |
281 | plugin->SetPreferedSE("ALICE::Legnaro::SE");\r |
282 | \r |
283 | return plugin;\r |
284 | }\r |