]>
Commit | Line | Data |
---|---|---|
8931206f | 1 | class AliAnalysisGrid; |
2 | ||
3 | void RunAnalysisAODVertexingHF() | |
4 | { | |
5 | // | |
6 | // Test macro for AliAnalysisTaskSE's for heavy-flavour candidates | |
7 | // It has the structure of a Analysis Train: | |
8 | // - in this macro, change things related to running mode | |
9 | // and input preparation | |
10 | // - add your task using a AddTaskXXX macro | |
11 | // | |
12 | // A.Dainese, andrea.dainese@lnl.infn.it | |
13 | // "grid" mode added by R.Bala, bala@to.infn.it | |
14 | // | |
15 | ||
16 | ||
17 | gSystem->SetIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT -I$ALICE_ROOT/include -I$ALICE_ROOT/ITS -I$ALICE_ROOT/TPC -I$ALICE_ROOT/CONTAINERS -I$ALICE_ROOT/STEER -I$ALICE_ROOT/TRD -I$ALICE_ROOT/macros -I$ALICE_ROOT/ANALYSIS -I$ALICE_ROOT/PWG3 -I$ALICE_ROOT/PWG3/vertexingHF -g"); | |
18 | // | |
19 | TString trainName = "D2H"; | |
20 | TString analysisMode = "grid"; // "local", "grid", or "proof" | |
21 | TString inputMode = "list"; // "list", "xml", or "dataset" | |
22 | Long64_t nentries=123567890,firstentry=0; | |
23 | Bool_t useParFiles=kFALSE; | |
24 | Bool_t useAlienPlugin=kTRUE; | |
25 | TString pluginmode="full"; | |
26 | Bool_t saveProofToAlien=kFALSE; | |
27 | TString proofOutdir = ""; | |
28 | TString loadMacroPath="$ALICE_ROOT/PWG3/vertexingHF/macros/"; | |
29 | //TString loadMacroPath="./"; // this is normally needed for CAF | |
30 | // | |
31 | ||
32 | if(analysisMode=="grid") { | |
33 | // Connect to AliEn | |
34 | TGrid::Connect("alien://"); | |
35 | } else if(analysisMode=="proof") { | |
36 | // Connect to the PROOF cluster | |
37 | if(inputMode!="dataset") {printf("Input mode must be dataset, for proof analysis\n"); return;} | |
38 | gEnv->SetValue("XSec.GSI.DelegProxy","2"); | |
39 | TProof::Open("alicecaf"); | |
40 | //TProof::Reset("alicecaf"); | |
41 | if(saveProofToAlien) { | |
42 | TGrid::Connect("alien://"); | |
43 | if(gGrid) { | |
44 | TString homedir = gGrid->GetHomeDirectory(); | |
45 | TString workdir = homedir + trainName; | |
46 | if(!gGrid->Cd(workdir)) { | |
47 | gGrid->Cd(homedir); | |
48 | if(gGrid->Mkdir(workdir)) { | |
49 | gGrid->Cd(trainName); | |
50 | ::Info("VertexingTrain::Connect()", "Directory %s created", gGrid->Pwd()); | |
51 | } | |
52 | } | |
53 | gGrid->Mkdir("proof_output"); | |
54 | gGrid->Cd("proof_output"); | |
55 | proofOutdir = Form("alien://%s", gGrid->Pwd()); | |
56 | } | |
57 | } | |
58 | } | |
59 | ||
60 | ||
61 | // AliRoot libraries | |
62 | if(analysisMode=="local" || analysisMode=="grid") { | |
63 | TString loadLibraries="LoadLibraries.C"; loadLibraries.Prepend(loadMacroPath.Data()); | |
64 | gROOT->LoadMacro(loadLibraries.Data()); | |
65 | LoadLibraries(useParFiles); | |
66 | } else if (analysisMode=="proof") { | |
67 | gSystem->Load("libTree.so"); | |
68 | gSystem->Load("libGeom.so"); | |
69 | gSystem->Load("libPhysics.so"); | |
70 | gSystem->Load("libVMC.so"); | |
71 | gSystem->Load("libMinuit.so"); | |
72 | // Enable the needed packages | |
73 | //gProof->ClearPackages(); | |
74 | TString parDir="/afs/cern.ch/user/d/dainesea/code/"; | |
75 | TString parFile; | |
76 | if(!useParFiles) { | |
77 | gProof->UploadPackage("AF-v4-17"); | |
78 | gProof->EnablePackage("AF-v4-17"); | |
79 | // --- Enable the PWG3vertexingHF Package | |
80 | parFile="PWG3vertexingHF.par"; parFile.Prepend(parDir.Data()); | |
81 | gProof->UploadPackage(parFile.Data()); | |
82 | gProof->EnablePackage("PWG3vertexingHF"); | |
83 | } else { | |
84 | // --- Enable the STEERBase Package | |
85 | parFile="STEERBase.par"; parFile.Prepend(parDir.Data()); | |
86 | gProof->UploadPackage(parFile.Data()); | |
87 | gProof->EnablePackage("STEERBase"); | |
88 | // --- Enable the ESD Package | |
89 | parFile="ESD.par"; parFile.Prepend(parDir.Data()); | |
90 | gProof->UploadPackage(parFile.Data()); | |
91 | gProof->EnablePackage("ESD"); | |
92 | // --- Enable the AOD Package | |
93 | parFile="AOD.par"; parFile.Prepend(parDir.Data()); | |
94 | gProof->UploadPackage(parFile.Data()); | |
95 | gProof->EnablePackage("AOD"); | |
96 | // --- Enable the ANALYSIS Package | |
97 | parFile="ANALYSIS.par"; parFile.Prepend(parDir.Data()); | |
98 | gProof->UploadPackage(parFile.Data()); | |
99 | gProof->EnablePackage("ANALYSIS"); | |
100 | // --- Enable the ANALYSISalice Package | |
101 | parFile="ANALYSISalice.par"; parFile.Prepend(parDir.Data()); | |
102 | gProof->UploadPackage(parFile.Data()); | |
103 | gProof->EnablePackage("ANALYSISalice"); | |
104 | // --- Enable the CORRFW Package | |
105 | parFile="CORRFW.par"; parFile.Prepend(parDir.Data()); | |
106 | gProof->UploadPackage(parFile.Data()); | |
107 | gProof->EnablePackage("CORRFW"); | |
108 | // --- Enable the PWG3base Package | |
109 | parFile="PWG3base.par"; parFile.Prepend(parDir.Data()); | |
110 | gProof->UploadPackage(parFile.Data()); | |
111 | gProof->EnablePackage("PWG3base"); | |
112 | // --- Enable the PWG3vertexingHF Package | |
113 | parFile="PWG3vertexingHF.par"; parFile.Prepend(parDir.Data()); | |
114 | gProof->UploadPackage(parFile.Data()); | |
115 | gProof->EnablePackage("PWG3vertexingHF"); | |
116 | // --- Enable the PWG3muon Package | |
117 | parFile="PWG3muon.par"; parFile.Prepend(parDir.Data()); | |
118 | gProof->UploadPackage(parFile.Data()); | |
119 | gProof->EnablePackage("PWG3muon"); | |
120 | } | |
121 | gProof->ShowEnabledPackages(); // show a list of enabled packages | |
122 | } | |
123 | ||
124 | ||
125 | // Create Alien plugin, if requested | |
126 | if(useAlienPlugin) { | |
127 | if(analysisMode!="grid") {printf("Analysis mode must be grid, to use alien plugin\n"); return;} | |
128 | AliAnalysisGrid *alienHandler = CreateAlienHandler(pluginmode,useParFiles); | |
129 | if(!alienHandler) return; | |
130 | } | |
131 | ||
132 | ||
133 | //------------------------------------------------------------------- | |
134 | // Prepare input | |
135 | TChain *chainAOD = 0; | |
136 | TString dataset; // for proof | |
137 | ||
138 | if(!useAlienPlugin) { | |
139 | TString makeAODInputChain="MakeAODInputChain.C"; makeAODInputChain.Prepend(loadMacroPath.Data()); | |
140 | if(inputMode=="list") { | |
141 | // Local files | |
142 | gROOT->LoadMacro(makeAODInputChain.Data()); | |
143 | chainAOD = MakeAODInputChain();// with this it reads ./AliAOD.root and ./AliAOD.VertexingHF.root | |
144 | //chainAOD = MakeAODInputChain("alien:///alice/cern.ch/user/r/rbala/newtrain/out_lhc08x/180100/",1,1); | |
145 | printf("ENTRIES %d\n",chainAOD->GetEntries()); | |
146 | } else if(inputMode=="xml") { | |
147 | // xml | |
148 | gROOT->LoadMacro(makeAODInputChain.Data()); | |
149 | chainAOD = MakeAODInputChain("collection_aod.xml","collection_aodHF.xml"); | |
150 | } else if(inputMode=="dataset") { | |
151 | // CAF dataset | |
152 | //gProof->ShowDataSets(); | |
153 | dataset="/ITS/dainesea/AODVertexingHF_LHC08x_180100"; | |
154 | } | |
155 | } | |
156 | ||
157 | // Create the analysis manager | |
158 | AliAnalysisManager *mgr = new AliAnalysisManager("My Manager","My Manager"); | |
159 | mgr->SetDebugLevel(10); | |
160 | // Connect plug-in to the analysis manager | |
161 | if(useAlienPlugin) mgr->SetGridHandler(alienHandler); | |
162 | ||
163 | // Input | |
164 | AliAODInputHandler *inputHandler = new AliAODInputHandler(); | |
165 | inputHandler->AddFriend("./AliAOD.VertexingHF.root"); | |
166 | //inputHandler->AddFriend("deltas/AliAOD.VertexingHF.root"); | |
167 | if(analysisMode=="proof" ) { | |
168 | if(saveProofToAlien) mgr->SetSpecialOutputLocation(proofOutdir); | |
169 | } | |
170 | mgr->SetInputEventHandler(inputHandler); | |
171 | //------------------------------------------------------------------- | |
172 | ||
173 | ||
174 | //------------------------------------------------------------------- | |
175 | // Analysis tasks (wagons of the train) | |
176 | // | |
177 | TString taskName; | |
178 | ||
179 | ////// ADD THE FULL D2H TRAIN | |
180 | taskName="AddD2HTrain.C"; taskName.Prepend(loadMacroPath.Data()); | |
181 | gROOT->LoadMacro(taskName.Data()); | |
182 | Bool_t readMC=kFALSE; | |
183 | AddD2HTrain(readMC);//,1,0,0,0,0,0,0,0,0,0,0); | |
184 | ||
185 | ////// OR ADD INDIVIDUAL TASKS | |
186 | ||
187 | /* | |
188 | taskName="AddTaskCompareHF.C"; taskName.Prepend(loadMacroPath.Data()); | |
189 | gROOT->LoadMacro(taskName.Data()); | |
190 | AliAnalysisTaskSECompareHF *cmpTask = AddTaskCompareHF(); | |
191 | ||
192 | taskName="AddTaskD0Mass.C"; taskName.Prepend(loadMacroPath.Data()); | |
193 | gROOT->LoadMacro(taskName.Data()); | |
194 | AliAnalysisTaskSED0Mass *d0massTask = AddTaskD0Mass(); | |
195 | AliAnalysisTaskSED0Mass *d0massLikeSignTask = AddTaskD0Mass(1); | |
196 | ||
197 | taskName="AddTaskDplus.C"; taskName.Prepend(loadMacroPath.Data()); | |
198 | gROOT->LoadMacro(taskName.Data()); | |
199 | AliAnalysisTaskSEDplus *dplusTask = AddTaskDplus(); | |
200 | ||
201 | taskName="AddTaskDs.C"; taskName.Prepend(loadMacroPath.Data()); | |
202 | gROOT->LoadMacro(taskName.Data()); | |
203 | AliAnalysisTaskSEDs *dsTask = AddTaskDs(); | |
204 | ||
205 | //taskName="AddTaskSelectHF.C"; taskName.Prepend(loadMacroPath.Data()); | |
206 | //gROOT->LoadMacro(taskName.Data()); | |
207 | //AliAnalysisTaskSESelectHF *seleTask = AddTaskSelectHF(); | |
208 | ||
209 | taskName="AddTaskBkgLikeSignD0.C"; taskName.Prepend(loadMacroPath.Data()); | |
210 | gROOT->LoadMacro(taskName.Data()); | |
211 | AliAnalysisTaskSEBkgLikeSignD0 *lsD0Task = AddTaskBkgLikeSignD0(); | |
212 | ||
213 | taskName="AddTaskBkgLikeSignJPSI.C"; taskName.Prepend(loadMacroPath.Data()); | |
214 | gROOT->LoadMacro(taskName.Data()); | |
215 | AliAnalysisTaskSEBkgLikeSignJPSI *lsJPSITask = AddTaskBkgLikeSignJPSI(); | |
216 | ||
217 | //taskName="AddTaskBtoJPSItoEle.C"; taskName.Prepend(loadMacroPath.Data()); | |
218 | //gROOT->LoadMacro(taskName.Data()); | |
219 | //AliAnalysisTaskSEBtoJPSItoEle *jpsiTask = AddTaskBtoJPSItoEle(); | |
220 | ||
221 | taskName="AddTaskCFMultiVarMultiStep.C"; taskName.Prepend(loadMacroPath.Data()); | |
222 | gROOT->LoadMacro(taskName.Data()); | |
223 | AliCFHeavyFlavourTaskMultiVarMultiStep *cfmvmsTask = AddTaskCFMultiVarMultiStep(); | |
224 | ||
225 | taskName="AddTaskCharmFraction.C"; taskName.Prepend(loadMacroPath.Data()); | |
226 | gROOT->LoadMacro(taskName.Data()); | |
227 | Int_t switchMC[5]={1,1,1,1,1}; | |
228 | AliAnalysisTaskSECharmFraction *cFractTask = AddTaskCharmFraction("d0D0",switchMC); | |
229 | ||
230 | // attach a private task (not committed) | |
231 | // (the files MyTask.h MyTask.cxx AddMyTask.C have to be declared in plugin | |
232 | // configuration, see below) | |
233 | ||
234 | if(analysisMode.Data()=="proof") { | |
235 | gProof->LoadMacro("MyTask.cxx++g"); | |
236 | } else { | |
237 | gROOT->LoadMacro("MyTask.cxx++g"); | |
238 | } | |
239 | gROOT->LoadMacro("AddMyTask.C"); | |
240 | MyTask *myTask = AddMyTask(); | |
241 | ||
242 | ||
243 | if(analysisMode.Data()=="proof") { | |
244 | gProof->LoadMacro("AliDStarJets.cxx++g"); | |
245 | } else { | |
246 | gROOT->LoadMacro("AliDStarJets.cxx++g"); | |
247 | } | |
248 | gROOT->LoadMacro("AddTaskDStarJets.C"); | |
249 | AliDStarJets *myTask = AddTaskDStarJets(); | |
250 | */ | |
251 | //------------------------------------------------------------------- | |
252 | ||
253 | // | |
254 | // Run the analysis | |
255 | // | |
256 | if(chainAOD) printf("CHAIN HAS %d ENTRIES\n",(Int_t)chainAOD->GetEntries()); | |
257 | ||
258 | if(!mgr->InitAnalysis()) return; | |
259 | mgr->PrintStatus(); | |
260 | if(analysisMode=="grid" && !useAlienPlugin) analysisMode="local"; | |
261 | if(analysisMode!="proof") { | |
262 | mgr->StartAnalysis(analysisMode.Data(),chainAOD,nentries,firstentry); | |
263 | } else { | |
264 | // proof | |
265 | mgr->StartAnalysis(analysisMode.Data(),dataset.Data(),nentries,firstentry); | |
266 | } | |
267 | ||
268 | return; | |
269 | } | |
270 | //_____________________________________________________________________________ | |
271 | // | |
272 | AliAnalysisGrid* CreateAlienHandler(TString pluginmode="test",Bool_t useParFiles=kFALSE) | |
273 | { | |
274 | // Check if user has a valid token, otherwise make one. This has limitations. | |
275 | // One can always follow the standard procedure of calling alien-token-init then | |
276 | // source /tmp/gclient_env_$UID in the current shell. | |
277 | if (!AliAnalysisGrid::CreateToken()) return NULL; | |
278 | AliAnalysisAlien *plugin = new AliAnalysisAlien(); | |
279 | // Set the run mode (can be "full", "test", "offline", "submit" or "terminate") | |
280 | plugin->SetRunMode(pluginmode.Data()); | |
281 | plugin->SetUser("rbala"); | |
282 | plugin->SetNtestFiles(1); | |
283 | // Set versions of used packages | |
284 | plugin->SetAPIVersion("V1.1x"); | |
285 | plugin->SetROOTVersion("v5-26-00b-6"); | |
286 | plugin->SetAliROOTVersion("v4-19-18-AN"); | |
287 | // Declare input data to be processed. | |
288 | // Method 1: Create automatically XML collections using alien 'find' command. | |
289 | // Define production directory LFN | |
290 | // plugin->SetGridDataDir("/alice/cern.ch/user/r/rbala/data_pass4_good_runCINT1B_8thfeb/"); | |
291 | //plugin->SetGridDataDir("/alice/sim/PDC_09/LHC09a4/AOD3/"); | |
292 | // Set data search pattern | |
293 | plugin->SetGridDataDir("/alice/data/2010/LHC10c"); | |
294 | plugin->SetDataPattern("pass2/*AliAOD.root"); | |
295 | plugin->SetRunPrefix("000"); | |
296 | ||
297 | // ...then add run numbers to be considered | |
298 | plugin->AddRunNumber(119048); | |
299 | plugin->SetMaxMergeFiles(100); | |
300 | plugin->SetNrunsPerMaster(100); | |
301 | plugin->SetNumberOfReplicas(2); | |
302 | // or | |
303 | //plugin->SetRunRange(529000,529007); | |
304 | // Method 2: Declare existing data files (raw collections, xml collections, root file) | |
305 | // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir()) | |
306 | // XML collections added via this method can be combined with the first method if | |
307 | // the content is compatible (using or not tags) | |
308 | //plugin->AddDataFile("/alice/cern.ch/user/r/rbala/newtrain/collection/collection_aod_lhc08w.xml"); | |
309 | // plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root"); | |
310 | // Define alien work directory where all files will be copied. Relative to alien $HOME. | |
311 | plugin->SetGridWorkingDir("myHFanalysis"); | |
312 | // Declare alien output directory. Relative to working directory. | |
313 | plugin->SetGridOutputDir("output"); // In this case will be $HOME/work/output | |
314 | // Declare the analysis source files names separated by blancs. To be compiled runtime | |
315 | // using ACLiC on the worker nodes. | |
316 | //plugin->SetAnalysisSource("AliDStarJets.cxx"); | |
317 | // Declare all libraries (other than the default ones for the framework. These will be | |
318 | // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here. | |
319 | plugin->SetAdditionalLibs("libPWG3vertexingHF.so libPWG3base.so libPWG3muon.so"); | |
320 | // use par files | |
321 | if(useParFiles) { | |
322 | plugin->EnablePackage("STEERBase.par"); | |
323 | plugin->EnablePackage("ESD.par"); | |
324 | plugin->EnablePackage("AOD.par"); | |
325 | plugin->EnablePackage("ANALYSIS.par"); | |
326 | plugin->EnablePackage("ANALYSISalice.par"); | |
327 | plugin->EnablePackage("CORRFW.par"); | |
328 | plugin->EnablePackage("PWG3base.par"); | |
329 | plugin->EnablePackage("PWG3vertexingHF.par"); | |
330 | plugin->EnablePackage("PWG3muon.par"); | |
331 | } | |
332 | plugin->AddIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT -I$ALICE_ROOT/include -I$ALICE_ROOT/ITS -I$ALICE_ROOT/TPC -I$ALICE_ROOT/CONTAINERS -I$ALICE_ROOT/STEER -I$ALICE_ROOT/TRD -I$ALICE_ROOT/macros -I$ALICE_ROOT/ANALYSIS -I$ALICE_ROOT/PWG3 -I$ALICE_ROOT/PWG3/vertexingHF -g"); | |
333 | // Declare the output file names separated by blancs. | |
334 | // (can be like: file.root or file.root@ALICE::Niham::File) | |
335 | plugin->SetDefaultOutputs(kTRUE); | |
336 | //plugin->SetOutputFiles("output.root CmpHF.root CmpHFnt.root D0InvMass.root InvMassDplus.root InvMassDplus_nt1.root InvMassDplus_nt2.root"); | |
337 | // Optionally define the files to be archived. | |
338 | // plugin->SetOutputArchive("log_archive.zip:stdout,stderr@ALICE::NIHAM::File root_archive.zip:*.root@ALICE::NIHAM::File"); | |
339 | // plugin->SetOutputArchive("log_archive.zip:stdout,stderr"); | |
340 | // Optionally set a name for the generated analysis macro (default MyAnalysis.C) | |
341 | plugin->SetAnalysisMacro("AnalysisHF.C"); | |
342 | // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore) | |
343 | plugin->SetSplitMaxInputFileNumber(10); | |
344 | // Optionally set number of failed jobs that will trigger killing waiting sub-jobs. | |
345 | //plugin->SetMaxInitFailed(5); | |
346 | // Optionally resubmit threshold. | |
347 | //plugin->SetMasterResubmitThreshold(90); | |
348 | // Optionally set time to live (default 30000 sec) | |
349 | //plugin->SetTTL(20000); | |
350 | // Optionally set input format (default xml-single) | |
351 | plugin->SetInputFormat("xml-single"); | |
352 | // Optionally modify the name of the generated JDL (default analysis.jdl) | |
353 | plugin->SetJDLName("TaskHF.jdl"); | |
354 | // Optionally modify job price (default 1) | |
355 | //plugin->SetPrice(1); | |
356 | // Optionally modify split mode (default 'se') | |
357 | plugin->SetSplitMode("se"); | |
358 | ||
359 | ||
360 | return plugin; | |
361 | } |