TENDER becomes Tender
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / macros / AddTask_GammaConvNeutralMesonPiPlPiMiPiZero_pp.C
CommitLineData
b5d519c0 1void AddTask_GammaConvNeutralMesonPiPlPiMiPiZero_pp(
2 Int_t trainConfig = 1,
3 Bool_t isMC = kFALSE, // run MC
4 Bool_t enableQAMesonTask = kTRUE, // enable QA in AliAnalysisTaskNeutralMesonToPiPlPiMiPiZero
5 TString fileNameInputForWeighting = "MCSpectraInput.root", // path to file for weigting input
6 Bool_t doWeighting = kFALSE, // enable Weighting
7 TString generatorName = "Pythia",
8 TString cutnumberAODBranch = "0000000060084001001500000"
9 ) {
10
11 // ================= Load Librariers =================================
12 gSystem->Load("libCore.so");
13 gSystem->Load("libTree.so");
14 gSystem->Load("libGeom.so");
15 gSystem->Load("libVMC.so");
16 gSystem->Load("libPhysics.so");
17 gSystem->Load("libMinuit");
18 gSystem->Load("libSTEERBase");
19 gSystem->Load("libESD");
20 gSystem->Load("libAOD");
21 gSystem->Load("libANALYSIS");
22 gSystem->Load("libANALYSISalice");
b5d519c0 23 gSystem->Load("libCDB.so");
24 gSystem->Load("libSTEER.so");
25 gSystem->Load("libSTEERBase.so");
af472fff 26 gSystem->Load("libTender.so");
27 gSystem->Load("libTenderSupplies.so");
4e1b9acf 28 gSystem->Load("libPWGflowBase.so");
29 gSystem->Load("libPWGflowTasks.so");
30 gSystem->Load("libPWGGAGammaConv.so");
b5d519c0 31
32 Int_t isHeavyIon = 2;
33
34 // ================== GetAnalysisManager ===============================
35 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
36 if (!mgr) {
37 Error(Form("AddTask_GammaConvNeutralMesonPiPlPiMiPiZero_pPb_%i",trainConfig), "No analysis manager found.");
38 return ;
39 }
40
41 // ================== GetInputEventHandler =============================
42 AliVEventHandler *inputHandler=mgr->GetInputEventHandler();
43
44 //========= Add PID Reponse to ANALYSIS manager ====
45 if(!(AliPIDResponse*)mgr->GetTask("PIDResponseTask")){
46 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
47 AddTaskPIDResponse(isMC);
48 }
49
50 //========= Set Cutnumber for V0Reader ================================
3013611f 51 TString cutnumberPhoton = "060000084001001500000000";
b5d519c0 52 TString cutnumberEvent = "0000000";
53 TString PionCuts = "000000200"; //Electron Cuts
54
55 Bool_t doEtaShift = kFALSE;
56
57 AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
58
59 //========= Add V0 Reader to ANALYSIS manager if not yet existent =====
60 if( !(AliV0ReaderV1*)mgr->GetTask("V0ReaderV1") ){
61 AliV0ReaderV1 *fV0ReaderV1 = new AliV0ReaderV1("V0ReaderV1");
62
63 fV0ReaderV1->SetUseOwnXYZCalculation(kTRUE);
64 fV0ReaderV1->SetCreateAODs(kFALSE);// AOD Output
65 fV0ReaderV1->SetUseAODConversionPhoton(kTRUE);
66
67 if (!mgr) {
68 Error("AddTask_V0ReaderV1", "No analysis manager found.");
69 return;
70 }
71
72 AliConvEventCuts *fEventCuts=NULL;
73 if(cutnumberEvent!=""){
74 fEventCuts= new AliConvEventCuts(cutnumberEvent.Data(),cutnumberEvent.Data());
75 fEventCuts->SetPreSelectionCutFlag(kTRUE);
76 if(fEventCuts->InitializeCutsFromCutString(cutnumberEvent.Data())){
77 fEventCuts->DoEtaShift(doEtaShift);
78 fV0ReaderV1->SetEventCuts(fEventCuts);
79 fEventCuts->SetFillCutHistograms("",kTRUE);
80 }
81 }
82
83 // Set AnalysisCut Number
84 AliConversionPhotonCuts *fCuts=NULL;
85 if(cutnumberPhoton!=""){
86 fCuts= new AliConversionPhotonCuts(cutnumberPhoton.Data(),cutnumberPhoton.Data());
87 fCuts->SetPreSelectionCutFlag(kTRUE);
88 fCuts->SetIsHeavyIon(isHeavyIon);
89 if(fCuts->InitializeCutsFromCutString(cutnumberPhoton.Data())){
90 fV0ReaderV1->SetConversionCuts(fCuts);
91 fCuts->SetFillCutHistograms("",kTRUE);
92 }
93 }
94
95 if(inputHandler->IsA()==AliAODInputHandler::Class()){
96 // AOD mode
97 fV0ReaderV1->SetDeltaAODBranchName(Form("GammaConv_%s_gamma",cutnumberAODBranch.Data()));
98 }
99 fV0ReaderV1->Init();
100
101 AliLog::SetGlobalLogLevel(AliLog::kInfo);
102
103 //connect input V0Reader
104 mgr->AddTask(fV0ReaderV1);
105 mgr->ConnectInput(fV0ReaderV1,0,cinput);
106 }
107
108 //================================================
109 //========= Add Electron Selector ================
110
111
112 if( !(AliPrimaryPionSelector*)mgr->GetTask("PionSelector") ){
113
114 AliPrimaryPionSelector *fPionSelector = new AliPrimaryPionSelector("PionSelector");
115 // Set AnalysisCut Number
116
117 AliPrimaryPionCuts *fPionCuts=0;
118 if( PionCuts!=""){
119 fPionCuts= new AliPrimaryPionCuts(PionCuts.Data(),PionCuts.Data());
120 if(fPionCuts->InitializeCutsFromCutString(PionCuts.Data())){
121 fPionSelector->SetPrimaryPionCuts(fPionCuts);
122 fPionCuts->SetFillCutHistograms("",kTRUE);
123
124 }
125 }
126
127 fPionSelector->Init();
128 mgr->AddTask(fPionSelector);
129
130 AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
131
132 //connect input V0Reader
133 mgr->ConnectInput (fPionSelector,0,cinput1);
134
135 }
136
137
138
139 AliAnalysisTaskNeutralMesonToPiPlPiMiPiZero *task=NULL;
140
141 task= new AliAnalysisTaskNeutralMesonToPiPlPiMiPiZero(Form("GammaConvNeutralMesonPiPlPiMiPiZero_%i",trainConfig));
142
143 task->SetIsHeavyIon(2);
144 task->SetIsMC(isMC);
145
146 // Cut Numbers to use in Analysis
147 Int_t numberOfCuts = 1;
148
149 TString *eventCutArray = new TString[numberOfCuts];
150 TString *ConvCutarray = new TString[numberOfCuts];
151 TString *PionCutarray = new TString[numberOfCuts];
152 TString *NeutralPionCutarray = new TString[numberOfCuts];
153 TString *MesonCutarray = new TString[numberOfCuts];
154
155 Bool_t doEtaShiftIndCuts = kFALSE;
156 TString stringShift = "";
157
158 // Shifting in pPb direction
159
160 doEtaShiftIndCuts = kTRUE;
161 stringShift = "pPb";
162
163 if( trainConfig == 1 ) {
3013611f 164 eventCutArray[ 0] = "0000010"; ConvCutarray[0] = "002000091170008260400000"; PionCutarray[0] = "000000400"; NeutralPionCutarray[0] = "01035030000000"; MesonCutarray[0] = "01035030000000";
b5d519c0 165 } else if( trainConfig == 2 ) {
3013611f 166 eventCutArray[ 0] = "0000010"; ConvCutarray[0] = "002000091170008260400000"; PionCutarray[0] = "002000700"; NeutralPionCutarray[0] = "01035030000000"; MesonCutarray[0] = "01035030000000";
b5d519c0 167 } else if( trainConfig == 3 ) {
3013611f 168 eventCutArray[ 0] = "0000010"; ConvCutarray[0] = "002000091170008260400000"; PionCutarray[0] = "002003700"; NeutralPionCutarray[0] = "01035030000000"; MesonCutarray[0] = "01035030000000";
b5d519c0 169 } else if( trainConfig == 4 ) {
3013611f 170 eventCutArray[ 0] = "0000010"; ConvCutarray[0] = "002000091170008260400000"; PionCutarray[0] = "002006700"; NeutralPionCutarray[0] = "01035030000000"; MesonCutarray[0] = "01035030000000";
b5d519c0 171 } else if( trainConfig == 5 ) {
3013611f 172 eventCutArray[ 0] = "0000010"; ConvCutarray[0] = "002000091170008260400000"; PionCutarray[0] = "002006700"; NeutralPionCutarray[0] = "01035031000000"; MesonCutarray[0] = "01035030000000";
b5d519c0 173 } else if( trainConfig == 6 ) {
3013611f 174 eventCutArray[ 0] = "0000010"; ConvCutarray[0] = "002000091170008260400000"; PionCutarray[0] = "002006700"; NeutralPionCutarray[0] = "01035032000000"; MesonCutarray[0] = "01035030000000";
b5d519c0 175 } else if( trainConfig == 7 ) {
3013611f 176 eventCutArray[ 0] = "0000010"; ConvCutarray[0] = "002000091170008260400000"; PionCutarray[0] = "002006700"; NeutralPionCutarray[0] = "01035033000000"; MesonCutarray[0] = "01035030000000";
b5d519c0 177 } else if( trainConfig == 8 ) {
3013611f 178 eventCutArray[ 0] = "0000010"; ConvCutarray[0] = "002000091170008260400000"; PionCutarray[0] = "002003700"; NeutralPionCutarray[0] = "01035033000000"; MesonCutarray[0] = "01035030000000";
b5d519c0 179 }
180
181 TList *EventCutList = new TList();
182 TList *ConvCutList = new TList();
183 TList *NeutralPionCutList = new TList();
184 TList *MesonCutList = new TList();
185 TList *PionCutList = new TList();
186
187 TList *HeaderList = new TList();
188 TObjString *Header1 = new TObjString("pi0_1");
189 HeaderList->Add(Header1);
190 TObjString *Header3 = new TObjString("eta_2");
191 HeaderList->Add(Header3);
192
193 EventCutList->SetOwner(kTRUE);
194 AliConvEventCuts **analysisEventCuts = new AliConvEventCuts*[numberOfCuts];
195 ConvCutList->SetOwner(kTRUE);
196 AliConversionPhotonCuts **analysisCuts = new AliConversionPhotonCuts*[numberOfCuts];
197 NeutralPionCutList->SetOwner(kTRUE);
198 AliConversionMesonCuts **analysisNeutralPionCuts = new AliConversionMesonCuts*[numberOfCuts];
199 MesonCutList->SetOwner(kTRUE);
200 AliConversionMesonCuts **analysisMesonCuts = new AliConversionMesonCuts*[numberOfCuts];
201 PionCutList->SetOwner(kTRUE);
202 AliPrimaryPionCuts **analysisPionCuts = new AliPrimaryPionCuts*[numberOfCuts];
203
204 for(Int_t i = 0; i<numberOfCuts; i++){
205 analysisEventCuts[i] = new AliConvEventCuts();
206 analysisEventCuts[i]->InitializeCutsFromCutString(eventCutArray[i].Data());
207 EventCutList->Add(analysisEventCuts[i]);
208 analysisEventCuts[i]->SetFillCutHistograms("",kFALSE);
209
210 analysisCuts[i] = new AliConversionPhotonCuts();
211 if( ! analysisCuts[i]->InitializeCutsFromCutString(ConvCutarray[i].Data()) ) {
212 cout<<"ERROR: analysisCuts [" <<i<<"]"<<endl;
213 return 0;
214 } else {
215 ConvCutList->Add(analysisCuts[i]);
216 analysisCuts[i]->SetFillCutHistograms("",kFALSE);
217
218 }
219
220 analysisNeutralPionCuts[i] = new AliConversionMesonCuts();
221 if( ! analysisNeutralPionCuts[i]->InitializeCutsFromCutString(NeutralPionCutarray[i].Data()) ) {
222 cout<<"ERROR: analysisMesonCuts [ " <<i<<" ] "<<endl;
223 return 0;
224 } else {
225 NeutralPionCutList->Add(analysisNeutralPionCuts[i]);
226 analysisNeutralPionCuts[i]->SetFillCutHistograms("");
227 }
228
229 analysisMesonCuts[i] = new AliConversionMesonCuts();
230 if( ! analysisMesonCuts[i]->InitializeCutsFromCutString(MesonCutarray[i].Data()) ) {
231 cout<<"ERROR: analysisMesonCuts [ " <<i<<" ] "<<endl;
232 return 0;
233 } else {
234 MesonCutList->Add(analysisMesonCuts[i]);
235 analysisMesonCuts[i]->SetFillCutHistograms("");
236 }
237 analysisEventCuts[i]->SetAcceptedHeader(HeaderList);
238
239 TString cutName( Form("%s_%s_%s_%s_%s",eventCutArray[i].Data(), ConvCutarray[i].Data(),PionCutarray[i].Data(),NeutralPionCutarray[i].Data(), MesonCutarray[i].Data() ) );
240 analysisPionCuts[i] = new AliPrimaryPionCuts();
241 if( !analysisPionCuts[i]->InitializeCutsFromCutString(PionCutarray[i].Data())) {
242 cout<< "ERROR: analysisPionCuts [ " <<i<<" ] "<<endl;
243 return 0;
244 } else {
245 PionCutList->Add(analysisPionCuts[i]);
246 analysisPionCuts[i]->SetFillCutHistograms("",kFALSE,cutName);
247 }
248 }
249
250 task->SetEventCutList(numberOfCuts,EventCutList);
251 task->SetConversionCutList(numberOfCuts,ConvCutList);
252 task->SetNeutralPionCutList(NeutralPionCutList);
253 task->SetMesonCutList(MesonCutList);
254 task->SetPionCutList(PionCutList);
255
256 task->SetMoveParticleAccordingToVertex(kTRUE);
257
258 if(enableQAMesonTask) task->SetDoMesonQA(kTRUE);
259
260 //connect containers
261 AliAnalysisDataContainer *coutput =
262 mgr->CreateContainer(Form("GammaConvNeutralMesonPiPlPiMiPiZero_%i",trainConfig), TList::Class(),
263 AliAnalysisManager::kOutputContainer,Form("GammaConvNeutralMesonPiPlPiMiPiZero_%i.root",trainConfig));
264
265 mgr->AddTask(task);
266 mgr->ConnectInput(task,0,cinput);
267 mgr->ConnectOutput(task,1,coutput);
268
269 return;
270
271}