.so cleanup: more gSystem->Load()
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / macros / lego_train / old / AddAMRsn.C
CommitLineData
3da8cef7 1#ifndef __CINT__
586747b9 2#include <AliAnalysisManager.h>
3#include <AliLog.h>
3da8cef7 4#endif
586747b9 5
900e06e4 6Bool_t AddAMRsn(TString analysisSource = "proof", TString analysisMode = "test",TString input="aod",TString inputMC="", TString postfix = "",TString idStr="0")
7{
8
43d3541a 9 analysisSource.ToLower(); analysisMode.ToLower();
3248b3db 10
547e2d97 11 if (!RsnLoadMacro("RsnManager.C")) return kFALSE;
900e06e4 12 TList *listRsn = RsnManager();
13
14 Bool_t useMC = !inputMC.CompareTo("mc");
586747b9 15 input.ToLower();
547e2d97 16 Bool_t valid;
17
18 Int_t eventMixinPar = AliAnalysisManager::GetGlobalInt("rsnUseEventMixingPar",valid);
19 Int_t rsnPar = AliAnalysisManager::GetGlobalInt("rsnUseRSNPar",valid);
b63dbf69 20 Int_t rsnParDev = AliAnalysisManager::GetGlobalInt("rsnUseRSNParDev",valid);
547e2d97 21 if (eventMixinPar) rsnPar = 1;
b63dbf69 22 if (rsnPar&&rsnParDev>=0) rsnParDev=1;
3da8cef7 23
547e2d97 24 Int_t pidResponse = AliAnalysisManager::GetGlobalInt("rsnUsePIDResponse",valid);
25 Int_t useRsnIH = AliAnalysisManager::GetGlobalInt("rsnUseRsnInputHandler",valid);
26 Int_t physSel = AliAnalysisManager::GetGlobalInt("rsnUsePhysSel",valid);
3da8cef7 27 Int_t useCentralityTask = AliAnalysisManager::GetGlobalInt("rsnUseCentralityTask",valid);
586747b9 28 Int_t useEventPlaneTask = AliAnalysisManager::GetGlobalInt("rsnUseEventPlaneTask",valid);
29 Int_t usePIDqa = AliAnalysisManager::GetGlobalInt("rsnUsePIDqa",valid);
547e2d97 30 Int_t splitMgrByTask = AliAnalysisManager::GetGlobalInt("rsnSplitMgrByTasks",valid);
31
32 Int_t useMixing = AliAnalysisManager::GetGlobalInt("rsnUseMixing",valid);
33
34 Int_t isRsnMini = AliAnalysisManager::GetGlobalInt("rsnUseMiniPackage",valid);
35 Int_t mixNum = AliAnalysisManager::GetGlobalInt("rsnNumMix",valid);
900e06e4 36
37 // ALICE stuff
38 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
39 if (!mgr) { Printf("Error[AddAMRsn] mgr is null !!!"); return kFALSE; }
40
41 AliAnalysisGrid *analysisPlugin = mgr->GetGridHandler();
42 if (!analysisPlugin) { Printf("Error[AddAMRsn] : analysisPlugin is null !!!"); return kFALSE; }
43
900e06e4 44 TString myAdditionalLibs;
547e2d97 45 if (eventMixinPar) { AliAnalysisAlien::SetupPar("EventMixing"); myAdditionalLibs += " EventMixing.par"; }
b0635849 46 else { gSystem->Load("libEventMixing"); myAdditionalLibs += " libEventMixing.so"; }
900e06e4 47
deb5c67a 48 TString rsnLibName = "PWGLFresonances";
49 if (gSystem->Getenv("ALICE_ROOT")) {
50 TString alirootVersion = gSystem->GetFromPipe("aliroot --version | awk '{print $3}'");
51 if (alirootVersion<"v5-02-19-AN" && alirootVersion.CompareTo("trunk")) rsnLibName = "PWG2resonances";
52 if (rsnPar) { AliAnalysisAlien::SetupPar(rsnLibName.Data()); myAdditionalLibs += Form(" %s.par",rsnLibName.Data()); }
b0635849 53 else { gSystem->Load(Form("lib%s",rsnLibName.Data())); myAdditionalLibs += Form(" lib%s.so",rsnLibName.Data()); }
deb5c67a 54 }
43d3541a 55
b63dbf69 56 if (rsnParDev>=0) {
3da8cef7 57 if (rsnParDev) { AliAnalysisAlien::SetupPar("PWGLFresonancesdev"); myAdditionalLibs += " PWGLFresonancesdev.par"; }
b0635849 58 else { gSystem->Load("libPWGLFresonancesdev"); myAdditionalLibs += " libPWGLFresonancesdev.so"; }
b63dbf69 59 }
900e06e4 60 analysisPlugin->SetAdditionalLibs(myAdditionalLibs.Data());
61
3da8cef7 62 AliMultiInputEventHandler *multiInputHandler = 0;
63 AliInputEventHandler *inputHandler = mgr->GetInputEventHandler();
586747b9 64
3da8cef7 65 TString className = inputHandler->ClassName();
66 if (!className.CompareTo("AliMultiInputEventHandler")) {
586747b9 67 multiInputHandler = (AliMultiInputEventHandler *)inputHandler;
3da8cef7 68 }
69
900e06e4 70 AliRsnInputHandler *rsnIH=0;
71
586747b9 72 if (pidResponse) {
73 if (multiInputHandler) {
74 // add PID Response Handler
75 if (!RsnLoadMacro("AddPIDResponseInputHandler.C")) return kFALSE;
76 AddPIDResponseInputHandler(multiInputHandler,useMC);
77 } else {
78 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
79 AddTaskPIDResponse(useMC);
80 }
900e06e4 81 }
82
3da8cef7 83 if (multiInputHandler && useRsnIH) {
900e06e4 84 // add Rsn input handler (it has to be after ESD,MC,Tender input handler, but before Mixing)
586747b9 85 rsnIH = new AliRsnInputHandler();
900e06e4 86 multiInputHandler->AddInputEventHandler(rsnIH);
87 }
88
547e2d97 89 if (physSel) {
586747b9 90 if (!input.CompareTo("esd")) {
91 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
92 AddTaskPhysicsSelection(useMC);
93 }
900e06e4 94
95 // maybe we can put it in $ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C
3da8cef7 96 if (multiInputHandler) {
97 AliInputEventHandler *ih = multiInputHandler->GetFirstInputEventHandler();
89ccdaab 98 ih->SetEventSelection(multiInputHandler->GetEventSelection());
900e06e4 99 }
100 }
3da8cef7 101
102 if (useCentralityTask) {
103 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
104 AliCentralitySelectionTask *centralityTask = AddTaskCentrality(kFALSE);
105 }
106
586747b9 107 if (useEventPlaneTask) {
108 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskEventplane.C");
109 AliEPSelectionTask *eventPlaneTask = AddTaskEventplane();
110 }
111
112 if (usePIDqa) {
113 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDqa.C");
114 AddTaskPIDqa();
115 }
116
900e06e4 117 // load and run AddTask macro
547e2d97 118 if (!RsnLoadMacro("AddRsnAnalysisTask.C")) return kFALSE;
119 if (!RsnLoadMacro("RsnConfig.C")) return kFALSE;
120 if (!RsnLoadMacro("AddMixingHandler.C")) return kFALSE;
3248b3db 121 if (!analysisSource.CompareTo("grid")) {
43d3541a 122 if (!RsnLoadMacro("RsnGridPlugin.C")) return kFALSE;
89ccdaab 123 RsnGridPlugin(analysisMode);
3248b3db 124 }
900e06e4 125
547e2d97 126 if (splitMgrByTask) {
900e06e4 127 Int_t iTask=0;
128 TList *l=0;
129 TNamed *rsnObj = 0;
130 AliAnalysisTaskSE *task=0;
131 TString rsnName,rsnCutName;
132 TIter next(listRsn);
133 while ((rsnObj = (TNamed *)next())) {
134 l = new TList();
135 Printf("Adding task for RSN:%s CUT:%s ",rsnObj->GetName(),rsnObj->GetTitle());
136 l->Add(new TNamed(*rsnObj));
547e2d97 137 task = AddRsnAnalysisTask(input, useMC, useMixing,rsnIH,l,Form("%s_%d",postfix.Data(),iTask++));
138 if (useMixing) {
900e06e4 139 // add mixing handler (uncomment to turn on Mixnig)
547e2d97 140 AddMixingHandler(multiInputHandler,task, input, useMC,isRsnMini, mixNum,postfix);
900e06e4 141 }
142 }
143 } else {
547e2d97 144 task = AddRsnAnalysisTask(input, useMC, useMixing,rsnIH,listRsn,postfix);
145 if (useMixing) {
900e06e4 146 // add mixing handler (uncomment to turn on Mixnig)
547e2d97 147 AddMixingHandler(multiInputHandler,task, input, useMC,isRsnMini, mixNum,postfix);
900e06e4 148 }
149 }
150
586747b9 151 // mgr->AddClassDebug("AliRsnCutTrackQuality",AliLog::kDebug+3);
152
547e2d97 153 return kTRUE;
154}
155
156Bool_t RsnLoadMacro(TString macro,TString path="") {
900e06e4 157
547e2d97 158 Bool_t valid;
159 TString lego_path = AliAnalysisManager::GetGlobalStr("rsnLegoTrainPath",valid);
160 if (!valid) lego_path = "$ALICE_ROOT/PWG2/RESONANCES/macros/lego_train";
900e06e4 161
547e2d97 162 if (!gSystem->AccessPathName(macro.Data())) {
163 gROOT->LoadMacro(macro.Data());
164 Printf("Macro loaded from %s/%s ...",gSystem->pwd(),macro.Data());
165 return kTRUE;
166 }
900e06e4 167
547e2d97 168 if (!gSystem->AccessPathName(gSystem->ExpandPathName(Form("%s/%s",lego_path.Data(),macro.Data())))) {
169 gROOT->LoadMacro(gSystem->ExpandPathName(Form("%s/%s",lego_path.Data(),macro.Data())));
170 Printf("Macro loaded from %s ...",gSystem->ExpandPathName(Form("%s/%s",lego_path.Data(),macro.Data())));
171 return kTRUE;
172 }
173
174 Printf("Error loading %s",macro.Data());
175
176 return kFALSE;
900e06e4 177}