4f1f9c433617b8252ee31b7442dd202b3acc91c9
[u/mrichter/AliRoot.git] / PWGLF / STRANGENESS / Cascades / macros / runGridCascadePbPb.C
1 /// **** to run the macro: ***********
2 // alien-token-init username
3 // source /tmp/gclient_env_XXX
4 // root -l runGridCascadePbPb.C
5
6 class AliAnalysisGrid;
7
8 void runGridCascadePbPb( Bool_t   useMC               = kTRUE,  // kTRUE if analysing a MC sample 
9                          Bool_t   runperformancetask  = kTRUE,  
10                          Float_t  centrlowlim         = 0.,
11                          Float_t  centruplim          = 90.,
12                          TString  centrest            = "V0M",
13                          Bool_t   kusecleaning        = kTRUE,
14                          Float_t  vtxlim              = 10.,
15                          Int_t minnTPCcls             = 70, 
16                          Bool_t   kextrasel           = kFALSE,
17                          Bool_t   kacccut             = kFALSE,
18                          Bool_t   krelaunchvertexers  = kFALSE,
19                          Float_t  minptondaughtertracks = 0.,
20                          Float_t  etacutondaughtertracks= .5,//9999999.,
21                          TString  anatype             = "AOD",//"ESD",
22                          TString  gridoutputdir       = "LHC10h_AOD086test",
23                          //the following are used for the Cascade task only
24                          TString  datadir             = "/alice/data/2010/LHC10h",///alice/data/2011/LHC11h_2",
25                          TString  datapattern         = "ESDs/pass2/AOD086/*/AliAOD.root", // "ESDs/pass2/*/*ESDs.root" // for data
26                          const char *plugin_mode      = "test") {
27
28   // Load common libraries
29   gSystem->Load("libCore");
30   gSystem->Load("libTree");
31   gSystem->Load("libGeom");
32   gSystem->Load("libVMC");
33   gSystem->Load("libPhysics");
34   gSystem->Load("libMinuit");
35   gSystem->Load("libGui");
36   gSystem->Load("libXMLParser");
37   gSystem->Load("libSTEERBase");
38   gSystem->Load("libESD");
39   gSystem->Load("libCDB");
40   gSystem->Load("libAOD");
41   gSystem->Load("libANALYSIS");
42   gSystem->Load("libANALYSISalice");
43   gSystem->Load("libCORRFW");
44   gSystem->Load("libProof");
45   gSystem->Load("libRAWDatabase");
46   gSystem->Load("libSTEER");
47
48    //__________________________________________________________________________
49   // Use AliRoot includes to compile our task
50   gROOT->ProcessLine(".include $ALICE_ROOT/include");
51   
52   //__________________________________________________________________________
53   // Create and configure the alien handler plugin
54   AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode, runperformancetask, useMC, anatype, gridoutputdir, datadir, datapattern);
55   if (!alienHandler) return;
56  
57   //__________________________________________________________________________
58   // Create the analysis manager
59   AliAnalysisManager *mgr = new AliAnalysisManager("CascadePbPbanalysis");
60   
61   //__________________________________________________________________________
62   // Connect plug-in to the analysis manager
63   mgr->SetGridHandler(alienHandler);
64
65   // Input handlers
66   AliESDInputHandler* esdH = new AliESDInputHandler();
67   AliAODInputHandler* aodH = new AliAODInputHandler();
68   if (anatype=="ESD") mgr->SetInputEventHandler(esdH);
69   else mgr->SetInputEventHandler(aodH);
70   if (runperformancetask&&(anatype=="ESD")) {
71     AliMCEventHandler* mcHandler = new AliMCEventHandler();
72     mgr->SetMCtruthEventHandler(mcHandler);
73   }
74
75   //__________________________________________________________________________
76   // Add tasks
77
78   if (anatype=="ESD") {
79     // Physics selection
80     gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
81     AliPhysicsSelectionTask *physSel = AddTaskPhysicsSelection(useMC);
82     // Centrality selection
83     gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
84     AliCentralitySelectionTask *taskCentr = AddTaskCentrality();
85     if (useMC){
86       taskCentr->SetMCInput();
87       taskCentr->DontUseCleaning();
88     }
89   }
90
91   gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
92   AliAnalysisTaskPIDResponse *pidTask = AddTaskPIDResponse(useMC);
93
94   if (runperformancetask) {
95     gROOT->LoadMacro("./AliAnalysisTaskCheckPerformanceCascadePbPb.cxx++g");//$ALICE_ROOT/PWGLF/STRANGENESS/Cascades/AliAnalysisTaskCheckPerformanceCascadePbPb.cxx++g");
96     gROOT->LoadMacro("./AddTaskCheckPerformanceCascadePbPb.C");//$ALICE_ROOT/PWGLF/STRANGENESS/Cascades/macros/AddTaskCheckPerformanceCascadePbPb.C");
97     AliAnalysisTaskCheckPerformanceCascadePbPb *task = AddTaskCheckPerformanceCascadePbPb(minnTPCcls, centrlowlim, centruplim, centrest, kusecleaning, vtxlim,kextrasel ,kacccut ,krelaunchvertexers,minptondaughtertracks,etacutondaughtertracks);
98
99   } else {
100     gROOT->LoadMacro("./AliAnalysisTaskCheckCascadePbPb.cxx++g");//$ALICE_ROOT/PWGLF/STRANGENESS/Cascades/AliAnalysisTaskCheckCascadePbPb.cxx++g");
101     gROOT->LoadMacro("./AddTaskCheckCascadePbPb.C");//$ALICE_ROOT/PWGLF/STRANGENESS/Cascades/macros/AddTaskCheckCascadePbPb.C");
102     AliAnalysisTaskCheckCascadePbPb *task = AddTaskCheckCascadePbPb(minnTPCcls, centrlowlim, centruplim, centrest, kusecleaning, vtxlim, kextrasel ,krelaunchvertexers,minptondaughtertracks,etacutondaughtertracks);
103
104   }
105
106   //__________________________________________________________________________
107   // Disbale debug printouts
108   mgr->SetDebugLevel(3);
109   AliLog::SetGlobalLogLevel(AliLog::kFatal);
110   AliLog::SetGlobalDebugLevel(0);
111   
112   //__________________________________________________________________________
113   if (!mgr->InitAnalysis()) return;
114   mgr->PrintStatus();
115   // Start analysis in grid.
116   mgr->StartAnalysis("grid");
117 };
118
119 //__________________________________________________________________________
120
121 AliAnalysisGrid* CreateAlienHandler(const char *plugin_mode, Bool_t runperformancetask, Bool_t useMC, TString anatype, TString gridoutputdir, TString datadir, TString datapattern) {
122   //__________________________________________________________________________
123   // Check if user has a valid token, otherwise make one. This has limitations.
124   // One can always follow the standard procedure of calling alien-token-init then
125   //   source /tmp/gclient_env_$UID in the current shell.
126   AliAnalysisAlien *plugin= new AliAnalysisAlien();
127
128   //__________________________________________________________________________
129   // Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
130   plugin->SetRunMode(plugin_mode);
131
132   plugin->SetNtestFiles(1);
133   //__________________________________________________________________________
134   // Set versions of used packages
135   plugin->SetAPIVersion("V1.1x");
136
137   //__________________________________________________________________________
138   // On GRID - current
139   plugin->SetROOTVersion("v5-34-01-1");
140   plugin->SetAliROOTVersion("v5-03-50-AN"); 
141
142   //__________________________________________________________________________
143   // Declare input data to be processed.
144   // Method 1: Create automatically XML collections using alien 'find' command.
145   if (useMC) {
146     //plugin->SetGridDataDir("/alice/sim/LHC11a10a_bis");   // Define production directory
147     //plugin->SetGridDataDir("/alice/sim/LHC11a10b_plus");
148     plugin->SetGridDataDir("/alice/sim/2011/LHC11f5");
149     // Set data search pattern
150     if (anatype == "ESD") plugin->SetDataPattern("*ESDs.root");
151     else plugin->SetDataPattern("AOD090/*AOD.root");  
152     plugin->AddRunNumber(137124);
153
154
155   } else {
156     plugin->SetGridDataDir(datadir.Data());   // Define production directory LFN
157     plugin->SetDataPattern(datapattern.Data());  // Set data search pattern
158     plugin->SetRunPrefix("000");
159     //plugin->SetRunRange(80000,80000); // ...then add run numbers to be considered
160     plugin->AddRunNumber(138534);
161    
162   }
163   // Method 2: Use your input collection 
164   //plugin->AddDataFile("/alice/cern.ch/user/m/mnicassi/139105.xml");
165   //__________________________________________________________________________
166   // Define alien work directory where all files will be copied. Relative to alien $HOME.
167   plugin->SetGridWorkingDir(gridoutputdir.Data());
168   plugin->SetGridOutputDir("output");
169
170   //__________________________________________________________________________
171   if (runperformancetask) plugin->SetAnalysisSource("AliAnalysisTaskCheckPerformanceCascadePbPb.cxx");
172   else plugin->SetAnalysisSource("AliAnalysisTaskCheckCascadePbPb.cxx");
173
174   //__________________________________________________________________________
175   //Enable same others packages
176   //plugin->EnablePackage("PWG3dielectron.par");
177
178   //__________________________________________________________________________
179   // Optionally set a name for the generated analysis macro (default MyAnalysis.C)
180   plugin->SetAnalysisMacro("testmacro.C");
181   //Add all extra files (task.cxx/.h)
182   if (runperformancetask) {
183     plugin->SetAdditionalLibs("AliAnalysisTaskCheckPerformanceCascadePbPb.h AliAnalysisTaskCheckPerformanceCascadePbPb.cxx");
184     // Optionally modify the executable name (default analysis.sh)
185     plugin->SetExecutable("CascadePerformancePbPb.sh");
186   } else {
187     plugin->SetAdditionalLibs("AliAnalysisTaskCheckCascadePbPb.h AliAnalysisTaskCheckCascadePbPb.cxx ");
188     // Optionally modify the executable name (default analysis.sh)
189     plugin->SetExecutable("CascadePbPb.sh");
190
191   }
192   
193   //__________________________________________________________________________
194   // Declare the output file names separated by blancs.
195   // (can be like: file.root or file.root@ALICE::Niham::File)
196   //plugin->SetDefaultOutputs(kFALSE);
197   //if (runperformancetask) plugin->SetOutputFiles("CascadePerformance.root");
198   //else plugin->SetOutputFiles("Cascades.root");
199
200   // Optionally define the files to be archived.
201   //plugin->SetOutputArchive("root_archive.zip:*.root log_archive.zip:stdout,stderr");
202
203   //__________________________________________________________________________
204   // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
205   plugin->SetSplitMaxInputFileNumber(100);
206   // Optionally set number of failed jobs that will trigger killing waiting sub-jobs.
207   plugin->SetMasterResubmitThreshold(90);
208   // Optionally set time to live (default 30000 sec)
209   plugin->SetTTL(30000);
210   // Optionally set input format (default xml-single)
211   plugin->SetInputFormat("xml-single");
212   // Optionally modify the name of the generated JDL (default analysis.jdl)
213   if (runperformancetask) plugin->SetJDLName("TaskCheckPerformanceCascadePbPb.jdl");
214   else plugin->SetJDLName("TaskCheckCascadePbPb.jdl");
215
216   // Optionally modify job price (default 1)
217   plugin->SetPrice(1);
218
219   // Merge via JDL
220   // comment out the next line when using the "terminate" option, unless
221   // you want separate merged files for each run
222 /*  plugin->SetMergeViaJDL(kTRUE);  // run first in full mode, then in terminate
223   plugin->SetOneStageMerging(kFALSE);
224   plugin->SetMaxMergeFiles(50);
225   plugin->SetMaxMergeStages(2);// to define the number of stages
226 */
227   // Optionally set number of runs per master
228 //  plugin->SetNrunsPerMaster(1);
229   //
230   plugin->SetOutputToRunNo();
231   // Optionally modify split mode (default 'se')
232   plugin->SetSplitMode("se");
233   plugin->SetUser("mnicassi");
234   return plugin;
235 }
236