Split: fix refs to AddTaskPhysicsSelection.C
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / PiKaPr / TestAOD / runGridBoth.C
CommitLineData
88d02ae4 1
2class AliAnalysisManager;
3class AliAnalysisAlien;
4class AliSpectraBothPID;
3d4d6201 5Int_t mc=-1;
6Int_t aod=-1;
7TString griddatadir="";
8TString datapattern="";
9TString gridworkingdir="";
10TString aliroot="";
11TString root="";
12
13
14void runGridBoth(TString mode="test",TString configfile="config.txt",Int_t day=15,Int_t month=6, Int_t year=2012)
88d02ae4 15{
3d4d6201 16
17
18 ifstream infile(configfile);
19 char buffer[256];
20 while (infile.eof()==false)
21 {
22 buffer[0]='#';
23 while (buffer[0]=='#'&&infile.eof()==false)
24 infile.getline(buffer,256);
25 TString tmpstring(buffer);
26 cout<<buffer<<endl;
27 if(tmpstring.Contains("MC"))
28 {
29 tmpstring.Remove(0,3);
30 cout<<tmpstring<<endl;
31 if (!tmpstring.IsDigit())
32 {
33 cout<<"Wrong format of MC flag in config file "<<endl;
34 return;
35 }
36 mc=tmpstring.Atoi();
37 }
38 else if(tmpstring.Contains("AOD")&&tmpstring.Length()<6)
39 {
40 tmpstring.Remove(0,4);
41 if (!tmpstring.IsDigit())
42 {
43 cout<<"Wrong format of AOD flag in config file "<<endl;
44 return;
45 }
46 aod=tmpstring.Atoi();
47 }
48 else if(tmpstring.Contains("GridDataDir"))
49 {
50 griddatadir=tmpstring.Remove(0,12);
51 }
52 else if(tmpstring.Contains("DataPattern"))
53 {
54 datapattern=tmpstring.Remove(0,12);
55 }
56 else if (tmpstring.Contains("GridWorkingDir"))
57 {
58 gridworkingdir=tmpstring.Remove(0,15);
59 }
60 else if(tmpstring.Contains("root")&&!tmpstring.Contains("aliroot"))
61 {
62 root=tmpstring.Remove(0,5);
63 }
64 else if (tmpstring.Contains("aliroot"))
65 {
66 aliroot=tmpstring.Remove(0,8);
67 }
68
69 else
70 continue;
71
72 }
73
74 if(mc<0||aod<0||griddatadir.Length()<1||root.Length()<1||datapattern.Length()<1||gridworkingdir.Length()<1||aliroot.Length()<1)
75 {
76 cout<<"lack of config info"<<endl;
77 return;
78 }
79cout<<mc<<" "<<aod<<" "<<griddatadir.Data()<<" "<<root.Data()<<" "<<datapattern.Data()<<" "<<gridworkingdir.Data()<<" "<<aliroot.Data()<<endl;
80
81
88d02ae4 82 TString daystring=Form("%d%d%d",year,month,day);
83 //to be used with Aliroot > v5-03-32-AN
84 AliLog::SetGlobalDebugLevel(100);
85 // Load common libraries
86 gEnv->SetValue("XSec.GSI.DelegProxy", "2");
87
88 // Load common libraries
4070f709 89 gSystem->Load("libCore");
90 gSystem->Load("libTree");
91 gSystem->Load("libGeom");
92 gSystem->Load("libVMC");
93 gSystem->Load("libPhysics");
94 gSystem->Load("libMinuit");
95 gSystem->Load("libGui");
96 gSystem->Load("libXMLParser");
97 gSystem->Load("libSTEERBase");
98 gSystem->Load("libESD");
99 gSystem->Load("libCDB");
88d02ae4 100 gSystem->Load("libAOD");
101 gSystem->Load("libANALYSIS");
102 gSystem->Load("libANALYSISalice");
103 gSystem->Load("libCORRFW");
4070f709 104 gSystem->Load("libProof");
105 gSystem->Load("libRAWDatabase");
106 gSystem->Load("libSTEER");
107 gSystem->Load("libTender");
108 gSystem->Load("libTenderSupplies");
109gSystem->Load("libPWGLFspectra");
3d4d6201 110 gROOT->ProcessLine(".include $ALICE_ROOT/include ");
88d02ae4 111 gSystem->SetIncludePath("-I.");
112 gROOT->ProcessLine(".include $ALICE_ROOT/TOF ");
3d4d6201 113
4070f709 114 //gSystem->Load("libPWGLFspectra");
3d4d6201 115 // gROOT->LoadMacro("AliSpectraBothTrackCuts.cxx+g");
88d02ae4 116 // gROOT->LoadMacro("AliSpectraBothEventCuts.cxx+g");
117 // gROOT->LoadMacro("HistogramNames.cxx");
118 // gROOT->LoadMacro("AliSpectraBothHistoManager.cxx+g");
119 // gROOT->LoadMacro("AliSpectraBothPID.cxx+g");
120 // gROOT->LoadMacro("AliAnalysisTaskSpectraBoth.cxx+g");
3d4d6201 121 //__________________________________________________________________________
122 // Use AliRoot includes to compile our task
123 gROOT->ProcessLine(".include $ALICE_ROOT/include ");
124 gSystem->SetIncludePath("-I.");
125 gROOT->ProcessLine(".include $ALICE_ROOT/TOF ");
88d02ae4 126 gROOT->LoadMacro("$ALICE_ROOT/PWGLF/SPECTRA/PiKaPr/TestAOD/AddTaskSpectraBoth.C");
127
128 // Create and configure the alien handler plugin
3d4d6201 129 AliAnalysisGrid *alienHandler = CreateAlienHandler(mode,daystring);
88d02ae4 130 if (!alienHandler) return;
131 // Create the analysis manager
132 AliAnalysisManager *mgr = new AliAnalysisManager("testAnalysis");
133 // Connect plug-in to the analysis manager
134 mgr->SetGridHandler(alienHandler);
135 if(aod)
136 {
137 AliAODInputHandler* aodH = new AliAODInputHandler();
138 mgr->SetInputEventHandler(aodH);
139 }
140 else
141 {
142 AliESDInputHandler* esdH = new AliESDInputHandler();
143 mgr->SetInputEventHandler(esdH);
144 if(mc)
145 {
146 AliMCEventHandler *mch = new AliMCEventHandler();
147 mgr->SetMCtruthEventHandler(mch);
148 }
149 }
150
151 // Add PID task
a65a7e70 152 // Bool_t isMC=kFALSE, Bool_t autoMCesd=kTRUE,
153 // Bool_t tuneOnData=kFALSE, Int_t recoPass=2, Bool_t cachePID=kFALSE, TString detResponse="",
88d02ae4 154//Bool_t useTPCEtaCorrection = kFALSE gROOT->LoadMacro("./AddTaskSpectraBoth.C");
155
156 Double_t Nsigmapid=3.;
157 Double_t pt=5.;
158 Double_t p=5.;
3d4d6201 159 Double_t y=.2;
88d02ae4 160 Double_t ptTofMatch=.6;
161 UInt_t trkbit=1;
3d4d6201 162 UInt_t trkbit2=16;
163
88d02ae4 164 UInt_t trkbitQVector=1;
165 Bool_t UseCentPatchAOD049=kFALSE;
166 Double_t DCA=100000;
3d4d6201 167 UInt_t minNclsTPC=70;
168 UInt_t minNclsTPC2=0;
169 Int_t rebinfactor=1;
88d02ae4 170 Bool_t mcfactor=0;
171 if(mc)
172 mcfactor=1;
173
174 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
88d02ae4 175 AliAnalysisTaskPIDResponse *taskPID=AddTaskPIDResponse(mcfactor,kTRUE,kFALSE,2,kFALSE,"",kTRUE);
0c1898ba 176taskPID->SetUseTPCEtaCorrection(kTRUE);
88d02ae4 177 if(!aod)
178 {
63b6cbd0 179 gROOT->LoadMacro("$ALICE_ROOT/OADB/macros/AddTaskPhysicsSelection.C");
88d02ae4 180 AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection();
181 if(mc)
182 {
183 physSelTask->GetPhysicsSelection()->SetAnalyzeMC();
184 }
185 }
186
187
188 AliAnalysisTaskSpectraBoth* task1=0x0;
3d4d6201 189 AliAnalysisTaskSpectraBoth* task2=0x0;
190 AliAnalysisTaskSpectraBoth* task3=0x0;
191 AliAnalysisTaskSpectraBoth* task4=0x0;
3d4d6201 192
193
194
195 task1=AddTaskSpectraBoth(mcfactor,-1,-1,-1,-1,-0.8,0.8,Nsigmapid,pt,p,-0.5,0.5,ptTofMatch,trkbit,trkbitQVector,UseCentPatchAOD049,DCA,minNclsTPC,rebinfactor,"V0M",2);
196
0c1898ba 197 task2=AddTaskSpectraBoth(mcfactor,-1,-1,-1,-1,-0.8,0.8,Nsigmapid,pt,p,-0.465,0.035,ptTofMatch,trkbit,trkbitQVector,UseCentPatchAOD049,DCA,minNclsTPC,rebinfactor,"V0M",2);
3d4d6201 198
0c1898ba 199 task3=AddTaskSpectraBoth(mcfactor,-1,-1,-1,-1,-0.8,0.8,2.0,pt,p,-0.465,0.035,ptTofMatch,trkbit,trkbitQVector,UseCentPatchAOD049,DCA,minNclsTPC,rebinfactor,"V0M",2);
3d4d6201 200
0c1898ba 201 task4=AddTaskSpectraBoth(mcfactor,-1,-1,-1,-1,-0.8,0.8,Nsigmapid,pt,p,-0.465,0.035,ptTofMatch,trkbit2,trkbitQVector,UseCentPatchAOD049,DCA,minNclsTPC2,rebinfactor,"V0M",2);
3d4d6201 202
3d4d6201 203
3d4d6201 204
205
88d02ae4 206 if(mc)
207 {
3d4d6201 208 task1->SetdotheMCLoopAfterEventCuts(kTRUE);
209 task2->SetdotheMCLoopAfterEventCuts(kTRUE);
210 task3->SetdotheMCLoopAfterEventCuts(kTRUE);
211 task4->SetdotheMCLoopAfterEventCuts(kTRUE);
88d02ae4 212
213
214 }
3d4d6201 215 else
216 {
217 task1->GetEventCuts()->SetTriggerSettings(AliVEvent::kINT7);
218 task2->GetEventCuts()->SetTriggerSettings(AliVEvent::kINT7);
219 task3->GetEventCuts()->SetTriggerSettings(AliVEvent::kINT7);
220 task4->GetEventCuts()->SetTriggerSettings(AliVEvent::kINT7);
3d4d6201 221
222
223}
88d02ae4 224 if(!aod)
225 {
226 AliESDtrackCuts* cuttpc1=AliESDtrackCuts::GetStandardITSTPCTrackCuts2011();
227 task1->SetAliESDtrackCuts(cuttpc1);
3d4d6201 228 AliESDtrackCuts* cuttpc2=AliESDtrackCuts::GetStandardITSTPCTrackCuts2011();
88d02ae4 229
3d4d6201 230 task2->SetAliESDtrackCuts(cuttpc2);
231 }
232
88d02ae4 233 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDqa.C");
234 AddTaskPIDqa();
3d4d6201 235 if(mode.Contains("test"))
88d02ae4 236 mgr->SetDebugLevel(1);
237 //mgr->Init();
238 if (!mgr->InitAnalysis())return;
239 mgr->PrintStatus();
240
241 mgr->StartAnalysis("grid");
242}
243
244
3d4d6201 245AliAnalysisGrid* CreateAlienHandler(TString mode="test",TString daystring)
88d02ae4 246{
247 TString filename="*AliAOD.root";
3d4d6201 248
88d02ae4 249
250 if(!aod)
251 {
252 filename="*AliESDs.root";
88d02ae4 253 }
88d02ae4 254
88d02ae4 255
88d02ae4 256
3d4d6201 257
258 TString jobsettings=griddatadir;
259 jobsettings+=datapattern;
260 if(aod)
261 jobsettings+="AOD";
262 else
263 jobsettings+="ESD";
88d02ae4 264
3d4d6201 265 if(mc)
266 jobsettings+="MC";
267 else
268 jobsettings+="DATA";
269
270
271 jobsettings.ReplaceAll("/","");
88d02ae4 272
3d4d6201 273 jobsettings.ReplaceAll("*","");
274
88d02ae4 275
88d02ae4 276
277 AliAnalysisAlien *plugin = new AliAnalysisAlien();
3d4d6201 278 //plugin->AddIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_ROOT/TOF -I$ALICE_ROOT/PWGLF/SPECTRA/PiKaPr/TestAOD");
af472fff 279 //plugin->SetAdditionalLibs("libSTEERBase.so libESD.so libAOD.so libANALYSISalice.so libPWGLFspectra.so libTender.so libTenderSupplies.so");
88d02ae4 280 //plugin->SetAnalysisSource("AliSpectraBothHistoManager.cxx AliSpectraBothTrackCuts.cxx AliSpectraBothEventCuts.cxx AliSpectraBothPID.cxx AliAnalysisTaskSpectraBoth.cxx");
3d4d6201 281 plugin->AddIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_ROOT/TOF ");
af472fff 282 plugin->SetAdditionalLibs("libTender.so libTenderSupplies.so libPWGLFspectra.so");
3d4d6201 283 // plugin->SetAnalysisSource("AliSpectraBothHistoManager.cxx AliSpectraBothTrackCuts.cxx AliSpectraBothEventCuts.cxx AliSpectraBothPID.cxx AliAnalysisTaskSpectraBoth.cxx");
88d02ae4 284 plugin->SetOverwriteMode();
285 plugin->SetExecutableCommand("aliroot -q -b");
286 plugin->SetRunMode(mode.Data());
287 plugin->SetNtestFiles(1);
288 //Set versions of used packages
289 plugin->SetAPIVersion("V1.1x");
3d4d6201 290 plugin->SetROOTVersion(root.Data());
291 plugin->SetAliROOTVersion(aliroot.Data());
292 // Declare input data to be processed
293 plugin->SetGridDataDir(griddatadir.Data());
88d02ae4 294 plugin->SetDataPattern(Form("%s/%s",datapattern.Data(),filename.Data()));
3d4d6201 295 plugin->SetGridWorkingDir(Form("%s%s",gridworkingdir.Data(),daystring.Data()));
296 plugin->SetAnalysisMacro(Form("%s.C",jobsettings.Data()));
297 plugin->SetExecutable(Form("%s.sh",jobsettings.Data()));
298 plugin->SetJDLName(Form("Task%s.jdl",jobsettings.Data()));
88d02ae4 299
300 if(mc)
301 {
302 plugin->SetRunPrefix("");
303 }
304 else
305 {
306 plugin->SetRunPrefix("000");
307 }
308 FILE* listruns=fopen("runs.txt","r");
309 Int_t irun;
310 while(!feof(listruns))
311 {
312 fscanf(listruns,"%d\n",&irun);
313 plugin->AddRunNumber(irun);
314 }
315 plugin->SetGridOutputDir("output"); // In this case will be $HOME/work/output
316 plugin->SetMaxMergeFiles(25);
317 plugin->SetMergeExcludes("EventStat_temp.root"
318 "event_stat.root");
319 plugin->SetMergeViaJDL(true);
3d4d6201 320 plugin->SetTTL(15*3600);
88d02ae4 321 // Optionally set input format (default xml-single)
322 plugin->SetInputFormat("xml-single");
323 // Optionally modify job price (default 1)
324 plugin->SetPrice(1);
325 // Optionally modify split mode (default 'se')
326 //plugin->SetSplitMaxInputFileNumber();
327 plugin->SetSplitMode("se");
328 return plugin;
329}