Code from DongJo and Jan Rak
[u/mrichter/AliRoot.git] / PWGCF / Correlations / macros / jcorran / runGrid.C
CommitLineData
37dde34e 1const Bool_t kMC = kFALSE; //With real data kMC = kFALSE
2const TString kInputData = "AOD";
3const TString kJCORRANInputFormat = "AOD"; // ESD, AODout, AODin
4
5//_____________________________________________________________________
6void runGrid(){
7 // Load Custom Configuration and parameters
8 // override values with parameters
9
10 //==== Load common libraries
11 gSystem->Load("libCore.so");
12 gSystem->Load("libTree.so");
13 gSystem->Load("libGeom.so");
14 gSystem->Load("libVMC.so");
15 gSystem->Load("libXMLIO.so");
16 gSystem->Load("libPhysics.so");
17 gSystem->Load("libSTEERBase");
18 gSystem->Load("libESD");
19 gSystem->Load("libAOD");
20 gSystem->Load("libANALYSIS");
21 gSystem->Load("libANALYSISalice");
22 gSystem->Load("libEMCALUtils");
23 gSystem->Load("libPHOSUtils");
24 gSystem->Load("libPWG4PartCorrBase");
25 gSystem->Load("libPWG4PartCorrDep");
26 gSystem->Load("libPWGCFJCORRAN");
27
28 //==== Load Ours
29// SetupPar("PWG4JCORRAN");
30
31 // Use AliRoot includes to compile our task
32 gROOT->ProcessLine(".include $ALICE_ROOT/include");
33 gROOT->ProcessLine(".include $ALICE_ROOT/EMCAL");
34 gSystem->AddIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_ROOT/EMCAL -I$ALICE_ROOT/ANALYSIS ");
35
36 // Create and configure the alien handler plugin
37 gROOT->LoadMacro("CreateAlienHandler.C");
38 AliAnalysisGrid *alienHandler = CreateAlienHandler();
39 if (!alienHandler) return;
40 // Create the analysis manager
41 AliAnalysisManager *mgr = new AliAnalysisManager("JCHII");
42
43 // Connect plug-in to the analysis manager
44 mgr->SetGridHandler(alienHandler);
45
46 // MC handler
47 if(kMC){
48 AliMCEventHandler* mcHandler = new AliMCEventHandler();
49 mcHandler->SetReadTR(kFALSE);//Do not search TrackRef file
50 mgr->SetMCtruthEventHandler(mcHandler);
51 }
52
53 if(kInputData == "ESD"){
54 // ESD handler
55 AliESDInputHandler *esdHandler = new AliESDInputHandler();
56 mgr->SetInputEventHandler(esdHandler);
57 }
58 if(kInputData == "AOD"){
59 // AOD handler
60 AliAODInputHandler *aodHandler = new AliAODInputHandler();
61 mgr->SetInputEventHandler(aodHandler);
62 }
63
64 //================================================
65 // TASKS
66 //================================================
67
68 //==== PID
69 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
70 AddTaskPIDResponse(kMC);
71 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDqa.C");
72 AddTaskPIDqa();
73
74 //==== Statistics
75 mgr->AddStatisticsTask();
76
77 //==== CENTRALITY
78 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
79 AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
80 //taskCentrality->SetPass(2);
81
82 //==== Physics Selection
83 gROOT->ProcessLine(".L $ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
84 AliPhysicsSelectionTask *physSelTask = AddTaskPhysicsSelection(kMC, kTRUE);
85 physSelTask->SelectCollisionCandidates(AliVEvent::kMB);
86
87 //============================
88 // JCORRANTask
89 //===========================
90 //==== Basic Track Cut
91 AliESDtrackCuts* fEsdTrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
92 //http://aliceinfo.cern.ch/static/aliroot-new/html/roothtml/src/AliESDtrackCuts.cxx.html#DY4BnB
93
94 //==== Additional Track Filter ;
95 gROOT->ProcessLine(".L ./AddESDFilter.C");
96 AliAnalysisFilter *filter = AddESDFilter();
97
98 //==== JCORRAN TASK
99 AliJCORRANTask *jctask = new AliJCORRANTask("PWG4JCORRANTask",kJCORRANInputFormat);
100 jctask->SetESDtrackCuts(fEsdTrackCuts);
101 jctask->SetRealOrMC(kMC);
102 jctask->SetOutputAODName("jcorran.root");
103 jctask->SetDebugLevel(0);
104 jctask->SetESDFilter( filter );
105 jctask->SetRunType("LHC11h");
106 jctask->SetStoreEventPlaneSource(true);
107 jctask->SetStoreTPCTrack(true);
108
109 //==event selection
110 jctask->SelectCollisionCandidates(AliVEvent::kMB | AliVEvent::kHighMult); //Apply offline trigger selection by AliPhysicsSelectionTask
111
112 mgr->AddTask((AliAnalysisTask*) jctask);
113
114 //==== Create containers for input/output
115 AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
116 AliAODHandler* aodoutHandler = new AliAODHandler();
117 aodoutHandler->SetCreateNonStandardAOD();
118 mgr->SetOutputEventHandler(aodoutHandler);
119
120 // Connect input/output
121 AliAnalysisDataContainer *runinfoOutput = mgr->CreateContainer("RunInfo", TList::Class(), AliAnalysisManager::kOutputContainer, "jcorran.root");
122 mgr->ConnectInput(jctask, 0, cinput);
123 mgr->ConnectOutput(jctask, 1, runinfoOutput );
124
125
126 //===============================
127 // START MANAGER
128 //===============================
129
130 // Enable debug printouts
131 mgr->SetDebugLevel(0);
132
133 if (!mgr->InitAnalysis())
134 return;
135
136 mgr->PrintStatus();
137 // Start analysis in grid.
138 printf("********** LD_LIBRARY_PATH *******\n");
139 printf("%s\n", gSystem->Getenv("LD_LIBRARY_PATH"));
140 printf("**********************************\n");
141
142
143// printf("%s\n", gSystem->Getenv("LD_LIBRARY_PATH"));
144
145 mgr->StartAnalysis("grid");
146};
147
148
149
150
151//========================================================================
152// Setup Par Files
153//========================================================================
154void SetupPar(char* pararchivename)
155{
156 //Load par files, create analysis libraries
157 //For testing, if par file already decompressed and modified
158 //classes then do not decompress.
159
160 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
161 TString parpar(Form("%s.par", pararchivename)) ;
162 // create par file if it not exist
163 if ( gSystem->AccessPathName(parpar.Data()) ) {
164 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
165 TString processline(Form(".! make %s", parpar.Data())) ;
166 gROOT->ProcessLine(processline.Data()) ;
167 gSystem->ChangeDirectory(cdir) ;
168 processline = Form(".! mv /tmp/%s .", parpar.Data()) ;
169 gROOT->ProcessLine(processline.Data()) ;
170 }
171 // decompres par file
172 if ( gSystem->AccessPathName(pararchivename) ) {
173 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
174 gROOT->ProcessLine(processline.Data());
175 }
176
177 TString ocwd = gSystem->WorkingDirectory();
178 gSystem->ChangeDirectory(pararchivename);
179
180 // check for BUILD.sh and execute
181 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
182 printf("*******************************\n");
183 printf("*** Building PAR archive ***\n");
184 cout<<pararchivename<<endl;
185 printf("*******************************\n");
186
187 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
188 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
189 return -1;
190 }
191 }
192 // check for SETUP.C and execute
193 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
194 printf("*******************************\n");
195 printf("*** Setup PAR archive ***\n");
196 cout<<pararchivename<<endl;
197 printf("*******************************\n");
198 gROOT->Macro("PROOF-INF/SETUP.C");
199 }
200
201 gSystem->ChangeDirectory(ocwd.Data());
202 printf("Current dir: %s\n", ocwd.Data());
203
204}
205
206
207void LoadConf( TString filename ){
208 ifstream in(filename.Data());
209 TString str;
210 str.ReadFile(in);
211 str.ReplaceAll("\n", "");
212 cout<<str<<endl;
213
214 gROOT->ProcessLine( str.Data() );
215}
216