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 |
17 | TString analysisMode = "grid"; // "local", "grid", or "proof" (not yet)\r |
18 | TString inputMode = "list"; // "list", "xml", or "dataset" (not yet)\r |
19 | Long64_t nentries=1234567890,firstentry=0;\r |
20 | Bool_t useParFiles=kTRUE;\r |
21 | Bool_t useAlienPlugin=kTRUE;\r |
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 |
80 | // --- Enable the PWG3vertexingHF Package\r |
81 | parFile="PWG3vertexingHF.par"; parFile.Prepend(parDir.Data());\r |
82 | gProof->UploadPackage(parFile.Data());\r |
83 | gProof->EnablePackage("PWG3vertexingHF");\r |
84 | }\r |
85 | gProof->ShowEnabledPackages(); // show a list of enabled packages\r |
86 | }\r |
32bb35a1 |
87 | \r |
88 | \r |
1a6db1e0 |
89 | // Create Alien plugin, if requested\r |
90 | if(useAlienPlugin) { \r |
91 | AliAnalysisGrid *alienHandler = CreateAlienHandler(pluginmode,useParFiles); \r |
92 | if(!alienHandler) return;\r |
93 | }\r |
32bb35a1 |
94 | \r |
95 | \r |
96 | //-------------------------------------------------------------------\r |
97 | // Prepare input chain\r |
98 | TChain *chainAOD = 0;\r |
1a6db1e0 |
99 | TString dataset; // for proof\r |
100 | \r |
101 | if(!useAlienPlugin) {\r |
102 | TString makeAODInputChain="MakeAODInputchain.C"; loadLibraries.Prepend(loadMacroPath.Data());\r |
103 | gROOT->LoadMacro(makeAODInputChain.Data());\r |
104 | if(inputMode=="list") {\r |
105 | // Local files\r |
106 | chainAOD = MakeAODInputChain();// with this it reads ./AliAOD.root and ./AliAOD.VertexingHF.root\r |
107 | chainAOD = MakeAODInputChain("alien:///alice/cern.ch/user/r/rbala/newtrain/out_lhc08x/180100/",1,1);\r |
108 | } else if(inputMode=="xml") {\r |
109 | // xml\r |
110 | chainAOD = MakeAODInputChain("collection_aod.xml","collection_aodHF.xml");\r |
111 | } else if(inputMode=="dataset") {\r |
112 | // CAF dataset\r |
113 | //gProof->ShowDataSet();\r |
114 | dataset="/ITS/dainesea/AODVertexingHF_LHC08x_180100_small";\r |
115 | chainAOD = MakeAODInputChainCAF(dataset.Data());\r |
116 | }\r |
32bb35a1 |
117 | }\r |
118 | \r |
119 | // Create the analysis manager\r |
120 | AliAnalysisManager *mgr = new AliAnalysisManager("My Manager","My Manager");\r |
121 | mgr->SetDebugLevel(10);\r |
1a6db1e0 |
122 | // Connect plug-in to the analysis manager\r |
123 | if(useAlienPlugin) mgr->SetGridHandler(alienHandler);\r |
124 | \r |
32bb35a1 |
125 | \r |
126 | // Input\r |
127 | AliAODInputHandler *inputHandler = new AliAODInputHandler();\r |
128 | mgr->SetInputEventHandler(inputHandler);\r |
129 | //-------------------------------------------------------------------\r |
130 | \r |
131 | \r |
132 | //-------------------------------------------------------------------\r |
1a6db1e0 |
133 | // Analysis tasks (wagons of the train) \r |
32bb35a1 |
134 | //\r |
1a6db1e0 |
135 | TString taskName;\r |
136 | \r |
137 | taskName="AddTaskCompareHF.C"; taskName.Prepend(loadMacroPath.Data());\r |
138 | gROOT->LoadMacro(taskName.Data());\r |
32bb35a1 |
139 | AliAnalysisTaskSECompareHF *cmpTask = AddTaskCompareHF();\r |
a9f684f8 |
140 | \r |
1a6db1e0 |
141 | //taskName="AddTaskSelectHF.C"; taskName.Prepend(loadMacroPath.Data());\r |
142 | //gROOT->LoadMacro(taskName.Data());\r |
143 | //AliAnalysisTaskSESelectHF *seleTask = AddTaskSelectHF();\r |
a9f684f8 |
144 | \r |
1a6db1e0 |
145 | //taskName="AddTaskBkgLikeSign.C"; taskName.Prepend(loadMacroPath.Data());\r |
146 | //gROOT->LoadMacro(taskName.Data());\r |
147 | //AliAnalysisTaskSEBkgLikeSignJPSI *lsTask = AddTaskBkgLikeSign();\r |
a9f684f8 |
148 | \r |
1a6db1e0 |
149 | //taskName="AddTaskBtoJPSItoEle.C"; taskName.Prepend(loadMacroPath.Data());\r |
150 | //gROOT->LoadMacro(taskName.Data());\r |
32bb35a1 |
151 | //AliAnalysisTaskSEBtoJPSItoEle *jpsiTask = AddTaskBtoJPSItoEle();\r |
a9f684f8 |
152 | \r |
1a6db1e0 |
153 | //taskName="AddTaskCF.C"; taskName.Prepend(loadMacroPath.Data());\r |
154 | //gROOT->LoadMacro(taskName.Data());\r |
a9f684f8 |
155 | //AliCFHeavyFlavourTask *cfTask = AddTaskCF();\r |
156 | \r |
1a6db1e0 |
157 | //taskName="AddTaskCFMultiVar.C"; taskName.Prepend(loadMacroPath.Data());\r |
158 | //gROOT->LoadMacro(taskName.Data());\r |
32bb35a1 |
159 | //AliCFHeavyFlavourTaskMultiVar *cfmvTask = AddTaskCFMultiVar();\r |
160 | \r |
1a6db1e0 |
161 | //taskName="AddTaskMultiVarMultiStep.C"; taskName.Prepend(loadMacroPath.Data());\r |
162 | //gROOT->LoadMacro(taskName.Data());\r |
163 | //AliCFHeavyFlavourTaskMultiVarMultiStep *cfmvmsTask = AddTaskCFMultiVarMultiStep();\r |
a9f684f8 |
164 | \r |
32bb35a1 |
165 | \r |
166 | //-------------------------------------------------------------------\r |
167 | \r |
168 | //\r |
169 | // Run the analysis\r |
170 | // \r |
1a6db1e0 |
171 | if(chainAOD) printf("CHAIN HAS %d ENTRIES\n",(Int_t)chainAOD->GetEntries());\r |
172 | \r |
173 | if(!mgr->InitAnalysis()) return;\r |
174 | mgr->PrintStatus();\r |
175 | if(analysisMode=="grid" && !useAlienPlugin) analysisMode="local";\r |
176 | mgr->StartAnalysis(analysisMode.Data(),chainAOD,nentries,firstentry);\r |
32bb35a1 |
177 | \r |
178 | return;\r |
179 | }\r |
1a6db1e0 |
180 | //_____________________________________________________________________________\r |
181 | //\r |
182 | AliAnalysisGrid* CreateAlienHandler(TString pluginmode="test",Bool_t useParFiles=kFALSE)\r |
183 | {\r |
184 | // Check if user has a valid token, otherwise make one. This has limitations.\r |
185 | // One can always follow the standard procedure of calling alien-token-init then\r |
186 | // source /tmp/gclient_env_$UID in the current shell.\r |
187 | if (!AliAnalysisGrid::CreateToken()) return NULL;\r |
188 | AliAnalysisAlien *plugin = new AliAnalysisAlien();\r |
189 | // Set the run mode (can be "full", "test", "offline", "submit" or "terminate")\r |
190 | plugin->SetRunMode(pluginmode.Data());\r |
191 | plugin->SetUser("dainesea");\r |
192 | plugin->SetNtestFiles(1);\r |
193 | // Set versions of used packages\r |
194 | plugin->SetAPIVersion("V2.4");\r |
195 | plugin->SetROOTVersion("v5-23-02");\r |
196 | plugin->SetAliROOTVersion("v4-17-00");\r |
197 | // Declare input data to be processed.\r |
198 | // Method 1: Create automatically XML collections using alien 'find' command.\r |
199 | // Define production directory LFN\r |
200 | plugin->SetGridDataDir("/alice/cern.ch/user/r/rbala/newtrain/out_lhc08x/");\r |
201 | // Set data search pattern\r |
202 | plugin->SetDataPattern("AliAOD.root");\r |
203 | plugin->SetFriendChainName("AliAOD.VertexingHF.root");\r |
204 | // ...then add run numbers to be considered\r |
205 | plugin->AddRunNumber(180100);\r |
206 | // Method 2: Declare existing data files (raw collections, xml collections, root file)\r |
207 | // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())\r |
208 | // XML collections added via this method can be combined with the first method if\r |
209 | // the content is compatible (using or not tags)\r |
210 | //plugin->AddDataFile("/alice/cern.ch/user/r/rbala/newtrain/collection/collection_aod_lhc08w.xml");\r |
211 | // plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");\r |
212 | // Define alien work directory where all files will be copied. Relative to alien $HOME.\r |
213 | plugin->SetGridWorkingDir("work");\r |
214 | // Declare alien output directory. Relative to working directory.\r |
215 | plugin->SetGridOutputDir("output"); // In this case will be $HOME/work/output\r |
216 | // Declare the analysis source files names separated by blancs. To be compiled runtime\r |
217 | // using ACLiC on the worker nodes.\r |
218 | //plugin->SetAnalysisSource("$ALICE_ROOT/PWG3/vertexingHF/AliAnalysisTaskSECompareHF.cxx");\r |
219 | // Declare all libraries (other than the default ones for the framework. These will be\r |
220 | // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.\r |
221 | plugin->SetAdditionalLibs("libPWG3vertexingHF.so");\r |
222 | // use par files\r |
223 | if(useParFiles) {\r |
224 | plugin->EnablePackage("STEERBase.par");\r |
225 | plugin->EnablePackage("ESD.par");\r |
226 | plugin->EnablePackage("AOD.par");\r |
227 | plugin->EnablePackage("ANALYSIS.par");\r |
228 | plugin->EnablePackage("ANALYSISalice.par");\r |
229 | plugin->EnablePackage("CORRFW.par");\r |
230 | plugin->EnablePackage("PWG3vertexingHF.par");\r |
231 | }\r |
232 | // Declare the output file names separated by blancs.\r |
233 | // (can be like: file.root or file.root@ALICE::Niham::File)\r |
234 | plugin->SetOutputFiles("CmpHF.root");\r |
235 | // Optionally define the files to be archived.\r |
236 | // plugin->SetOutputArchive("log_archive.zip:stdout,stderr@ALICE::NIHAM::File root_archive.zip:*.root@ALICE::NIHAM::File");\r |
237 | plugin->SetOutputArchive("log_archive.zip:stdout,stderr");\r |
238 | // Optionally set a name for the generated analysis macro (default MyAnalysis.C)\r |
239 | plugin->SetAnalysisMacro("AnalysisHF.C");\r |
240 | // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)\r |
241 | plugin->SetSplitMaxInputFileNumber(5);\r |
242 | // Optionally set number of failed jobs that will trigger killing waiting sub-jobs.\r |
243 | //plugin->SetMaxInitFailed(5);\r |
244 | // Optionally resubmit threshold.\r |
245 | //plugin->SetMasterResubmitThreshold(90);\r |
246 | // Optionally set time to live (default 30000 sec)\r |
247 | //plugin->SetTTL(20000);\r |
248 | // Optionally set input format (default xml-single)\r |
249 | plugin->SetInputFormat("xml-single");\r |
250 | // Optionally modify the name of the generated JDL (default analysis.jdl)\r |
251 | plugin->SetJDLName("TaskHF.jdl");\r |
252 | // Optionally modify job price (default 1)\r |
253 | //plugin->SetPrice(1); \r |
254 | // Optionally modify split mode (default 'se') \r |
255 | plugin->SetSplitMode("se");\r |
256 | // Optionally set the preferred SE \r |
257 | plugin->SetPreferedSE("ALICE::Legnaro::SE");\r |
258 | \r |
259 | return plugin;\r |
260 | }\r |