]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/EBYE/Fluctuations/macro/runFluctuationTask.C
Coverity
[u/mrichter/AliRoot.git] / PWG2 / EBYE / Fluctuations / macro / runFluctuationTask.C
1 /****************************************************************
2
3 Lunch the Analysis Task for Fluctuation Study 
4 Author: Satyajit Jena
5 Email:  sjena@cern.ch
6
7 Task : MF, MFT, CF, OF
8 Running in Local = analmode = local, proof, grid 
9
10 *******************************************************************/
11
12
13 TString tasktype = "MF"; //OF, MF, MFT, CF
14
15 //CAF-AAF Related
16 TString dataset      = "/alice/data/LHC10h_000137162_p1_3plus";
17 TString proofCluster = "alice-caf.cern.ch";
18 TString alirootVer   = "VO_ALICE@AliRoot::v4-21-12-AN";
19
20
21 Bool_t UsePar        = kFALSE; // Do you want to use par
22 Bool_t UseTrigger    = kFALSE; // activate trigger seletction
23 Bool_t UseCentrality = kFALSE; // activate centrality slection
24
25
26 void runFluctuationTask(TString analmode = "local")
27 {
28  
29   if(analmode.CompareTo("local") == 0 ) {
30     if(!LoadLibraries(analmode)) {
31       printf("Library Not loaded\n");
32       return;
33     }
34     runLocal("file.txt",1000);
35     
36  }
37   else  if(analmode.CompareTo("proof") == 0) {
38     if(!LoadLibraries(analmode)) return;
39     runproof(dataset);
40  }
41   else printf("load error\n");
42 }
43
44 //___________________________________________________________________________________
45 Bool_t LoadLibraries(TString mode = "local")
46 {
47   
48   if(mode.CompareTo("local") == 0) {
49     gSystem->Load("libSTEERBase.so");
50     gSystem->Load("libVMC.so");
51     gSystem->Load("libESD.so");
52     gSystem->Load("libAOD.so");
53     gSystem->Load("libANALYSIS.so");
54     gSystem->Load("libANALYSISalice.so");
55     //  gSystem->Load("libPWG2ebye.so");
56     gSystem->AddIncludePath("-I$ALICE_ROOT/include");
57     printf("Library is Loaded \n");
58     return kTRUE;
59   }
60   else if(mode.CompareTo("proof") == 0) {
61     gEnv->SetValue("XSec.GSI.DelegProxy","2");
62     TProof *p = TProof::Open(proofCluster.Data());
63     p->ShowPackages();
64     p->EnablePackage(alirootVer.Data());
65     return kTRUE;
66   }
67   else if(mode.CompareTo("proof") == 0) {
68     printf("Satya FIXME \n");
69   }
70   else {
71     printf(" ERROR: Give proper running mode \n");
72     return kFALSE;
73   }
74   
75 }
76
77 //______________________________________________________________________
78 Bool_t LoadIfParAnalysis(TString mode = "local") {
79   // FIXME: For par file upload methods..
80   
81
82
83 }
84
85 //______________________________________________________________________
86 // Running local
87 void runLocal(TString input,int nfile)
88 {
89
90   gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C");
91   TChain* chain = CreateESDChain(input, nfile);
92   
93   AliAnalysisManager *mgr = new AliAnalysisManager("Analysis");
94   AliVEventHandler* esdH = new AliESDInputHandler();
95   mgr->SetInputEventHandler(esdH);
96
97
98   //  gROOT->LoadMacro("AddTaskPhysicsSelection.C");
99   //  gROOT->LoadMacro("AddTaskCentrality.C");
100   
101   //  AliPhysicsSelectionTask* physicsSelTask = AddTaskPhysicsSelection();
102   //  AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
103
104
105   if(!UsePar) gROOT->LoadMacro("../AliEbyEEventBase.cxx++g");  
106   
107   if(tasktype.CompareTo("CF") == 0) {
108     if(!par) {
109       gROOT->LoadMacro("../AliEbyEMultiplicityFluctuationAnalysis.cxx++g"); 
110       gROOT->LoadMacro("../AliEbyEChargeFluctuationAnalysis.cxx++g");  
111     }
112    
113     gROOT->LoadMacro("AddFluctuationTask.C");
114     AddTaskCF();
115   }
116   else if(tasktype.CompareTo("MF") == 0) {
117     if(!UsePar) {
118       gROOT->LoadMacro("../AliEbyEMultiplicityFluctuationAnalysis.cxx++g"); 
119       gROOT->LoadMacro("../AliEbyEMFAnalysisTask.cxx++g"); 
120     }
121     gROOT->LoadMacro("AddFluctuationTask.C");
122     AddTaskMF();
123   }
124   else if(tasktype.CompareTo("OF") == 0) {
125     if(!UsePar) {
126       gROOT->LoadMacro("../AliEbyEFluctuationAnalysis.cxx++g"); 
127       gROOT->LoadMacro("../AliEbyEFluctuationTask.cxx++g"); 
128     }
129     gROOT->LoadMacro("AddFluctuationTask.C");
130     AddTaskF();
131   }
132   else if (tasktype.CompareTo("MFT") == 0) {
133     if(!UsePar) {
134       gROOT->LoadMacro("../AliEbyEMultiplicityFluctuationAnalysis.cxx++g"); 
135       gROOT->LoadMacro("../AliEbyEMFAnalysisTaskT.cxx++g"); 
136     }
137     gROOT->LoadMacro("AddFluctuationTask.C");
138     AddTaskMFT();
139   }
140   else return;
141
142    
143   
144
145   mgr->SetDebugLevel(0);
146   if (!mgr->InitAnalysis()) return;
147   mgr->PrintStatus();
148   mgr->StartAnalysis("local", chain);
149
150
151 }
152
153
154 //________________________________________________________
155 //Running in proof
156
157 void runproof(TString dataset)
158 {
159
160      AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
161      if (!mgr) mgr = new AliAnalysisManager("FirstCheck");
162      
163      AliVEventHandler* esdH = new AliESDInputHandler();
164      mgr->SetInputEventHandler(esdH);
165      
166      if(UseTrigger) {
167        gProof->Load("AddTaskPhysicsSelection.C");
168        AliPhysicsSelectionTask* physicsSelTask = AddTaskPhysicsSelection();
169      }
170
171      if(UseCentrality) {
172        gProof->Load("AddTaskCentrality.C");    
173        AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
174      }
175
176      if(!UsePar) gProof->Load("../AliEbyEEventBase.cxx++g");  
177      
178      if(tasktype.CompareTo("CF") == 0) {
179        if(!UsePar) {
180          gProof->Load("../AliEbyEMultiplicityFluctuationAnalysis.cxx++g"); 
181          gProof->Load("../AliEbyEChargeFluctuationAnalysis.cxx++g"); 
182        } 
183        gProof->Load("AddFluctuationTask.C");
184        AddTaskCF();
185      }
186      else if(tasktype.CompareTo("MF") == 0) {
187        if(!UsePar) {
188          gProof->Load("../AliEbyEMultiplicityFluctuationAnalysis.cxx++g"); 
189          gProof->Load("../AliEbyEMFAnalysisTask.cxx++g"); 
190        }
191        gProof->Load("AddFluctuationTask.C");
192        AddTaskMF();
193      }
194
195      else if(tasktype.CompareTo("OF") == 0) {
196        if(!UsePar) {
197          gProof->Load("../AliEbyEFluctuationAnalysis.cxx++g"); 
198          gProof->Load("../AliEbyEAnalysisTask.cxx++g"); 
199        }
200        gProof->Load("AddFluctuationTask.C");
201        AddTaskF();
202      }
203      
204      else if (tasktype.CompareTo("MFT") == 0) {
205        if(!UsePar) {
206          gProof->Load("../AliEbyEMultiplicityFluctuationAnalysis.cxx++g"); 
207          gProof->Load("../AliEbyEMFAnalysisTaskT.cxx++g"); 
208        }
209        gProof->Load("AddFluctuationTask.C");
210        AddTaskMFT();
211      }
212      else return;
213           
214      mgr->SetDebugLevel(0);
215      if (!mgr->InitAnalysis()) 
216        return;
217      
218      mgr->PrintStatus();
219         
220      mgr->StartAnalysis("proof",dataset.Data());
221   
222 }
223
224
225 //______________________________________________________________________________
226 AliAnalysisGrid* CreateAlienHandler(const char *taskname, const char *gridmode, 
227                                     const char *proofcluster, const char *proofdataset)
228 {
229     AliAnalysisAlien *plugin = new AliAnalysisAlien();
230     // Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
231     plugin->SetRunMode(gridmode);
232
233     // Set versions of used packages
234     plugin->SetAPIVersion("V1.1x");
235     plugin->SetROOTVersion("v5-27-06b");
236     plugin->SetAliROOTVersion("v4-21-08-AN");
237
238     // Declare input data to be processed.
239
240     // Method 1: Create automatically XML collections using alien 'find' command.
241     // Define production directory LFN
242     plugin->SetGridDataDir("/alice/data/2010/LHC10b");
243     // On real reconstructed data:
244     // plugin->SetGridDataDir("/alice/data/2009/LHC09d");
245     // Set data search pattern
246     //plugin->SetDataPattern("*ESDs.root"); // THIS CHOOSES ALL PASSES
247     // Data pattern for reconstructed data
248     plugin->SetDataPattern("*ESDs/pass2/*ESDs.root"); // CHECK LATEST PASS OF DATA SET IN ALIENSH
249     plugin->SetRunPrefix("000");   // real data, comment out for MC
250     // ...then add run numbers to be considered
251     plugin->AddRunNumber(115514);
252     //plugin->SetRunRange(114917,115322);
253     plugin->SetNrunsPerMaster(1);
254     plugin->SetOutputToRunNo();
255     // comment out the next line when using the "terminate" option, unless
256     // you want separate merged files for each run
257     plugin->SetMergeViaJDL();
258
259     // Method 2: Declare existing data files (raw collections, xml collections, root file)
260     // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())
261     // XML collections added via this method can be combined with the first method if
262     // the content is compatible (using or not tags)
263     //   plugin->AddDataFile("tag.xml");
264     //   plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");
265
266     // Define alien work directory where all files will be copied. Relative to alien $HOME.
267     plugin->SetGridWorkingDir(taskname);
268
269     // Declare alien output directory. Relative to working directory.
270     plugin->SetGridOutputDir("out"); // In this case will be $HOME/taskname/out
271
272     // Declare the analysis source files names separated by blancs. To be compiled runtime
273     // using ACLiC on the worker nodes.
274     plugin->SetAnalysisSource("AliAnalysisTaskEx01.cxx");
275
276     // Declare all libraries (other than the default ones for the framework. These will be
277     // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
278     plugin->SetAdditionalLibs("AliAnalysisTaskEx01.h AliAnalysisTaskEx01.cxx");
279
280     // Declare the output file names separated by blancs.
281     // (can be like: file.root or file.root@ALICE::Niham::File)
282     // To only save certain files, use SetDefaultOutputs(kFALSE), and then
283     // SetOutputFiles("list.root other.filename") to choose which files to save
284     plugin->SetDefaultOutputs();
285     //plugin->SetOutputFiles("list.root");
286
287     // Optionally set a name for the generated analysis macro (default MyAnalysis.C)
288     plugin->SetAnalysisMacro(Form("%s.C",taskname));
289
290     // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
291     plugin->SetSplitMaxInputFileNumber(100);
292
293     // Optionally modify the executable name (default analysis.sh)
294     plugin->SetExecutable(Form("%s.sh",taskname));
295
296     // set number of test files to use in "test" mode
297     plugin->SetNtestFiles(10);
298
299     // Optionally resubmit threshold.
300     plugin->SetMasterResubmitThreshold(90);
301
302     // Optionally set time to live (default 30000 sec)
303     plugin->SetTTL(30000);
304
305     // Optionally set input format (default xml-single)
306     plugin->SetInputFormat("xml-single");
307
308     // Optionally modify the name of the generated JDL (default analysis.jdl)
309     plugin->SetJDLName(Form("%s.jdl",taskname));
310
311     // Optionally modify job price (default 1)
312     plugin->SetPrice(1);      
313
314     // Optionally modify split mode (default 'se')    
315     plugin->SetSplitMode("se");
316     
317     //----------------------------------------------------------
318     //---      PROOF MODE SPECIFIC SETTINGS         ------------
319     //---------------------------------------------------------- 
320     // Proof cluster
321     plugin->SetProofCluster(proofcluster);
322     // Dataset to be used   
323     plugin->SetProofDataSet(proofdataset);
324     // May need to reset proof. Supported modes: 0-no reset, 1-soft, 2-hard
325     plugin->SetProofReset(0);
326     // May limit number of workers
327     plugin->SetNproofWorkers(0);
328     // May limit the number of workers per slave
329     plugin->SetNproofWorkersPerSlave(1);   
330     // May use a specific version of root installed in proof
331     plugin->SetRootVersionForProof("current");
332     // May set the aliroot mode. Check http://aaf.cern.ch/node/83 
333     plugin->SetAliRootMode("default"); // Loads AF libs by default
334     // May request ClearPackages (individual ClearPackage not supported)
335     plugin->SetClearPackages(kFALSE);
336     // Plugin test mode works only providing a file containing test file locations, used in "local" mode also
337     plugin->SetFileForTestMode("file1.text"); // file should contain path name to a local directory containg *ESDs.root etc
338     // Request connection to alien upon connection to grid
339     plugin->SetProofConnectGrid(kFALSE);
340
341     return plugin;
342 }
343