modified PhotonQA task + AddTask PbPb
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / macros / AddTask_GammaConvV1_PbPb.C
1 void AddTask_GammaConvV1_PbPb(  Int_t trainConfig = 1,  //change different set of cuts
2                               Bool_t isMC   = kFALSE, //run MC 
3                               Bool_t enableQAMesonTask = kFALSE, //enable QA in AliAnalysisTaskGammaConvV1
4                               Bool_t enableQAPhotonTask = kFALSE, // enable additional QA task
5                               TString fileNameInputForWeighting = "MCSpectraInput.root", // path to file for weigting input
6                               Bool_t doWeighting = kFALSE,  //enable Weighting
7                               TString cutnumberAODBranch = "1000000060084000001500000" 
8                            ) {
9
10    // ================= Load Librariers =================================
11    gSystem->Load("libCore.so");  
12    gSystem->Load("libTree.so");
13    gSystem->Load("libGeom.so");
14    gSystem->Load("libVMC.so");
15    gSystem->Load("libPhysics.so");
16    gSystem->Load("libMinuit");
17    gSystem->Load("libSTEERBase");
18    gSystem->Load("libESD");
19    gSystem->Load("libAOD");
20    gSystem->Load("libANALYSIS");
21    gSystem->Load("libANALYSISalice");  
22    gSystem->Load("libPWGGAGammaConv.so");
23    gSystem->Load("libCDB.so");
24    gSystem->Load("libSTEER.so");
25    gSystem->Load("libSTEERBase.so");
26    gSystem->Load("libTENDER.so");
27    gSystem->Load("libTENDERSupplies.so");
28       
29    // ================== GetAnalysisManager ===============================
30    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
31    if (!mgr) {
32       Error(Form("AddTask_GammaConvV1_%i",trainConfig), "No analysis manager found.");
33       return ;
34    }
35
36    // ================== GetInputEventHandler =============================
37    AliVEventHandler *inputHandler=mgr->GetInputEventHandler();
38    
39    //========= Add PID Reponse to ANALYSIS manager ====
40    if(!(AliPIDResponse*)mgr->GetTask("PIDResponseTask")){
41       gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
42       AddTaskPIDResponse(isMC);
43    }
44    
45    //=========  Set Cutnumber for V0Reader ================================
46    TString cutnumber = "100000000008400100150000000"; 
47    AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
48    //========= Add V0 Reader to  ANALYSIS manager if not yet existent =====
49    if( !(AliV0ReaderV1*)mgr->GetTask("V0ReaderV1") ){
50       AliV0ReaderV1 *fV0ReaderV1 = new AliV0ReaderV1("V0ReaderV1");
51       
52       fV0ReaderV1->SetUseOwnXYZCalculation(kTRUE);
53       fV0ReaderV1->SetCreateAODs(kFALSE);// AOD Output
54       fV0ReaderV1->SetUseAODConversionPhoton(kTRUE);
55
56       if (!mgr) {
57          Error("AddTask_V0ReaderV1", "No analysis manager found.");
58          return;
59       }
60
61       // Set AnalysisCut Number
62       AliConversionCuts *fCuts=NULL;
63       if(cutnumber!=""){
64          fCuts= new AliConversionCuts(cutnumber.Data(),cutnumber.Data());
65          fCuts->SetPreSelectionCutFlag(kTRUE);
66          if(fCuts->InitializeCutsFromCutString(cutnumber.Data())){
67             fV0ReaderV1->SetConversionCuts(fCuts);
68             fCuts->SetFillCutHistograms("",kTRUE);
69          }
70       }
71       
72       if(inputHandler->IsA()==AliAODInputHandler::Class()){
73       // AOD mode
74          fV0ReaderV1->SetDeltaAODBranchName(Form("GammaConv_%s_gamma",cutnumberAODBranch.Data()));
75       }
76       fV0ReaderV1->Init();
77
78       AliLog::SetGlobalLogLevel(AliLog::kInfo);
79
80       //connect input V0Reader
81       mgr->AddTask(fV0ReaderV1);
82       mgr->ConnectInput(fV0ReaderV1,0,cinput);
83
84    }
85
86    //================================================
87    //========= Add task to the ANALYSIS manager =====
88    //================================================
89    AliAnalysisTaskGammaConvV1 *task=NULL;
90    task= new AliAnalysisTaskGammaConvV1(Form("GammaConvV1_%i",trainConfig));
91    task->SetIsHeavyIon(1);
92    task->SetIsMC(isMC);
93    // Cut Numbers to use in Analysis
94    Int_t numberOfCuts = 5;
95
96    TString *cutarray = new TString[numberOfCuts];
97    TString *mesonCutArray = new TString[numberOfCuts];
98
99    if (trainConfig == 1){ // Standard cuts
100       cutarray[ 0] = "601000104209297002322000000"; mesonCutArray[ 0] = "01522045009000"; // 0-5%
101       cutarray[ 1] = "612000104209297002322000000"; mesonCutArray[ 1] = "01522045009000"; // 5-10%
102       cutarray[ 2] = "501000104209297002322000000"; mesonCutArray[ 2] = "01522045009000"; // 0-10%
103       cutarray[ 3] = "512000104209297002322000000"; mesonCutArray[ 3] = "01522045009000"; // 10-20%
104       cutarray[ 4] = "502000104209297002322000000"; mesonCutArray[ 4] = "01522045009000"; // 0-20%
105    } else if (trainConfig == 2) { // Standard cuts
106       cutarray[ 0] = "524000104209297002322000000"; mesonCutArray[ 0] = "01522045009000"; // 20-40%
107       cutarray[ 1] = "546000104209297002322000000"; mesonCutArray[ 1] = "01522065009000"; // 40-60%
108       cutarray[ 2] = "568000104209297002322000000"; mesonCutArray[ 2] = "01522065009000"; // 60-80%
109       cutarray[ 3] = "548000104209297002322000000"; mesonCutArray[ 3] = "01522065009000"; // 40-80%
110       cutarray[ 4] = "549000104209297002322000000"; mesonCutArray[ 4] = "01522065009000"; // 40-90%
111    } else if (trainConfig == 3) { // Standard cuts only added signals
112       cutarray[ 0] = "601000204209297002322000000"; mesonCutArray[ 0] = "01522045009000"; // 0-5%
113       cutarray[ 1] = "612000204209297002322000000"; mesonCutArray[ 1] = "01522045009000"; // 5-10%
114       cutarray[ 2] = "501000204209297002322000000"; mesonCutArray[ 2] = "01522045009000"; // 0-10%
115       cutarray[ 3] = "512000204209297002322000000"; mesonCutArray[ 3] = "01522045009000"; // 10-20%
116       cutarray[ 4] = "502000204209297002322000000"; mesonCutArray[ 4] = "01522045009000"; // 0-20%
117    } else if (trainConfig == 4) { // Standard cuts only added signals
118       cutarray[ 0] = "524000204209297002322000000"; mesonCutArray[ 0] = "01522045009000"; // 20-40%
119       cutarray[ 1] = "546000204209297002322000000"; mesonCutArray[ 1] = "01522065009000"; // 40-60%
120       cutarray[ 2] = "568000204209297002322000000"; mesonCutArray[ 2] = "01522065009000"; // 60-80%
121       cutarray[ 3] = "548000204209297002322000000"; mesonCutArray[ 3] = "01522065009000"; // 20-40% 
122       cutarray[ 4] = "549000204209297002322000000"; mesonCutArray[ 4] = "01522065009000"; // 40-90%
123    } else if (trainConfig == 5){ // R-minCut 7.5 cm
124       cutarray[ 0] = "601000104909297002322000000"; mesonCutArray[ 0] = "01522045009000"; // 0-5%
125       cutarray[ 1] = "612000104909297002322000000"; mesonCutArray[ 1] = "01522045009000"; // 5-10%
126       cutarray[ 2] = "501000104909297002322000000"; mesonCutArray[ 2] = "01522045009000"; // 0-10%
127       cutarray[ 3] = "512000104909297002322000000"; mesonCutArray[ 3] = "01522045009000"; // 10-20%
128       cutarray[ 4] = "502000104909297002322000000"; mesonCutArray[ 4] = "01522045009000"; // 0-20%
129    } else if (trainConfig == 6) { // R-minCut 7.5 cm
130       cutarray[ 0] = "524000104909297002322000000"; mesonCutArray[ 0] = "01522045009000"; // 20-40%
131       cutarray[ 1] = "546000104909297002322000000"; mesonCutArray[ 1] = "01522065009000"; // 40-60%
132       cutarray[ 2] = "568000104909297002322000000"; mesonCutArray[ 2] = "01522065009000"; // 60-80%
133       cutarray[ 3] = "548000104909297002322000000"; mesonCutArray[ 3] = "01522065009000"; // 40-80%
134       cutarray[ 4] = "549000104909297002322000000"; mesonCutArray[ 4] = "01522065009000"; // 40-90%
135    } else if (trainConfig == 7) {// R-minCut 7.5 cm
136       cutarray[ 0] = "601000204909297002322000000"; mesonCutArray[ 0] = "01522045009000"; // 0-5%
137       cutarray[ 1] = "612000204909297002322000000"; mesonCutArray[ 1] = "01522045009000"; // 5-10%
138       cutarray[ 2] = "501000204909297002322000000"; mesonCutArray[ 2] = "01522045009000"; // 0-10%
139       cutarray[ 3] = "512000204909297002322000000"; mesonCutArray[ 3] = "01522045009000"; // 10-20%
140       cutarray[ 4] = "502000204909297002322000000"; mesonCutArray[ 4] = "01522045009000"; // 0-20%
141    } else if (trainConfig == 8) { // R-minCut 7.5 cm
142       cutarray[ 0] = "524000204009297002322000000"; mesonCutArray[ 0] = "01522045009000"; // 20-40%
143       cutarray[ 1] = "546000204909297002322000000"; mesonCutArray[ 1] = "01522065009000"; // 40-60%
144       cutarray[ 2] = "568000204909297002322000000"; mesonCutArray[ 2] = "01522065009000"; // 60-80%
145       cutarray[ 3] = "548000204909297002322000000"; mesonCutArray[ 3] = "01522065009000"; // 20-40% 
146       cutarray[ 4] = "549000204909297002322000000"; mesonCutArray[ 4] = "01522065009000"; // 40-90%   
147    } else if (trainConfig == 9){ // R-minCut 12.5 cm
148       cutarray[ 0] = "601000104809297002322000000"; mesonCutArray[ 0] = "01522045009000"; // 0-5%
149       cutarray[ 1] = "612000104809297002322000000"; mesonCutArray[ 1] = "01522045009000"; // 5-10%
150       cutarray[ 2] = "501000104809297002322000000"; mesonCutArray[ 2] = "01522045009000"; // 0-10%
151       cutarray[ 3] = "512000104809297002322000000"; mesonCutArray[ 3] = "01522045009000"; // 10-20%
152       cutarray[ 4] = "502000104809297002322000000"; mesonCutArray[ 4] = "01522045009000"; // 0-20%
153    } else if (trainConfig == 10) { // R-minCut 12.5 cm
154       cutarray[ 0] = "524000104809297002322000000"; mesonCutArray[ 0] = "01522045009000"; // 20-40%
155       cutarray[ 1] = "546000104809297002322000000"; mesonCutArray[ 1] = "01522065009000"; // 40-60%
156       cutarray[ 2] = "568000104809297002322000000"; mesonCutArray[ 2] = "01522065009000"; // 60-80%
157       cutarray[ 3] = "548000104809297002322000000"; mesonCutArray[ 3] = "01522065009000"; // 40-80%
158       cutarray[ 4] = "549000104809297002322000000"; mesonCutArray[ 4] = "01522065009000"; // 40-90%
159    } else if (trainConfig == 11) {// R-minCut 12.5 cm
160       cutarray[ 0] = "601000204809297002322000000"; mesonCutArray[ 0] = "01522045009000"; // 0-5%
161       cutarray[ 1] = "612000204809297002322000000"; mesonCutArray[ 1] = "01522045009000"; // 5-10%
162       cutarray[ 2] = "501000204809297002322000000"; mesonCutArray[ 2] = "01522045009000"; // 0-10%
163       cutarray[ 3] = "512000204809297002322000000"; mesonCutArray[ 3] = "01522045009000"; // 10-20%
164       cutarray[ 4] = "502000204809297002322000000"; mesonCutArray[ 4] = "01522045009000"; // 0-20%
165    } else if (trainConfig == 12) { // R-minCut 12.5 cm
166       cutarray[ 0] = "524000204009297002322000000"; mesonCutArray[ 0] = "01522045009000"; // 20-40%
167       cutarray[ 1] = "546000204809297002322000000"; mesonCutArray[ 1] = "01522065009000"; // 40-60%
168       cutarray[ 2] = "568000204809297002322000000"; mesonCutArray[ 2] = "01522065009000"; // 60-80%
169       cutarray[ 3] = "548000204809297002322000000"; mesonCutArray[ 3] = "01522065009000"; // 20-40% 
170       cutarray[ 4] = "549000204809297002322000000"; mesonCutArray[ 4] = "01522065009000"; // 40-90%      
171    } else  if (trainConfig == 13){ // eta 0.65 (new standard), y = 0.6 (new Standard)
172       cutarray[ 0] = "601000103209297002322000000"; mesonCutArray[ 0] = "01523045009000"; // 0-5%
173       cutarray[ 1] = "612000103209297002322000000"; mesonCutArray[ 1] = "01523045009000"; // 5-10%
174       cutarray[ 2] = "501000103209297002322000000"; mesonCutArray[ 2] = "01523045009000"; // 0-10%
175       cutarray[ 3] = "512000103209297002322000000"; mesonCutArray[ 3] = "01523045009000"; // 10-20%
176       cutarray[ 4] = "502000103209297002322000000"; mesonCutArray[ 4] = "01523045009000"; // 0-20%
177    } else if (trainConfig == 14) {  // eta 0.65 (new standard), y = 0.6 (new Standard)
178       cutarray[ 0] = "524000103209297002322000000"; mesonCutArray[ 0] = "01523045009000"; // 20-40%
179       cutarray[ 1] = "546000103209297002322000000"; mesonCutArray[ 1] = "01523065009000"; // 40-60%
180       cutarray[ 2] = "568000103209297002322000000"; mesonCutArray[ 2] = "01523065009000"; // 60-80%
181       cutarray[ 3] = "548000103209297002322000000"; mesonCutArray[ 3] = "01523065009000"; // 40-80%
182       cutarray[ 4] = "549000103209297002322000000"; mesonCutArray[ 4] = "01523065009000"; // 40-90%
183    } else if (trainConfig == 15) { // eta 0.65 (new standard), y = 0.6 (new Standard) cuts only added signals
184       cutarray[ 0] = "601000203209297002322000000"; mesonCutArray[ 0] = "01523045009000"; // 0-5%
185       cutarray[ 1] = "612000203209297002322000000"; mesonCutArray[ 1] = "01523045009000"; // 5-10%
186       cutarray[ 2] = "501000203209297002322000000"; mesonCutArray[ 2] = "01523045009000"; // 0-10%
187       cutarray[ 3] = "512000203209297002322000000"; mesonCutArray[ 3] = "01523045009000"; // 10-20%
188       cutarray[ 4] = "502000203209297002322000000"; mesonCutArray[ 4] = "01523045009000"; // 0-20%
189    } else if (trainConfig == 16) { // eta 0.65 (new standard), y = 0.6 (new Standard) cuts only added signals
190       cutarray[ 0] = "524000203209297002322000000"; mesonCutArray[ 0] = "01523045009000"; // 20-40%
191       cutarray[ 1] = "546000203209297002322000000"; mesonCutArray[ 1] = "01523065009000"; // 40-60%
192       cutarray[ 2] = "568000203209297002322000000"; mesonCutArray[ 2] = "01523065009000"; // 60-80%
193       cutarray[ 3] = "548000203209297002322000000"; mesonCutArray[ 3] = "01523065009000"; // 20-40% 
194       cutarray[ 4] = "549000203209297002322000000"; mesonCutArray[ 4] = "01523065009000"; // 40-90%
195    } else  if (trainConfig == 17){ // eta 0.6, y = 0.6 (new Standard)
196       cutarray[ 0] = "601000101209297002322000000"; mesonCutArray[ 0] = "01523045009000"; // 0-5%
197       cutarray[ 1] = "612000101209297002322000000"; mesonCutArray[ 1] = "01523045009000"; // 5-10%
198       cutarray[ 2] = "501000101209297002322000000"; mesonCutArray[ 2] = "01523045009000"; // 0-10%
199       cutarray[ 3] = "512000101209297002322000000"; mesonCutArray[ 3] = "01523045009000"; // 10-20%
200       cutarray[ 4] = "502000101209297002322000000"; mesonCutArray[ 4] = "01523045009000"; // 0-20%
201    } else if (trainConfig == 18) {  // eta 0.6, y = 0.6 (new Standard)
202       cutarray[ 0] = "524000101209297002322000000"; mesonCutArray[ 0] = "01523045009000"; // 20-40%
203       cutarray[ 1] = "546000101209297002322000000"; mesonCutArray[ 1] = "01523065009000"; // 40-60%
204       cutarray[ 2] = "568000101209297002322000000"; mesonCutArray[ 2] = "01523065009000"; // 60-80%
205       cutarray[ 3] = "548000101209297002322000000"; mesonCutArray[ 3] = "01523065009000"; // 40-80%
206       cutarray[ 4] = "549000101209297002322000000"; mesonCutArray[ 4] = "01523065009000"; // 40-90%
207    } else if (trainConfig == 19) { // eta 0.6, y = 0.6 (new Standard) cuts only added signals
208       cutarray[ 0] = "601000201209297002322000000"; mesonCutArray[ 0] = "01523045009000"; // 0-5%
209       cutarray[ 1] = "612000201209297002322000000"; mesonCutArray[ 1] = "01523045009000"; // 5-10%
210       cutarray[ 2] = "501000201209297002322000000"; mesonCutArray[ 2] = "01523045009000"; // 0-10%
211       cutarray[ 3] = "512000201209297002322000000"; mesonCutArray[ 3] = "01523045009000"; // 10-20%
212       cutarray[ 4] = "502000201209297002322000000"; mesonCutArray[ 4] = "01523045009000"; // 0-20%
213    } else if (trainConfig == 20) { // eta 0.6, y = 0.6 (new Standard) cuts only added signals
214       cutarray[ 0] = "524000201209297002322000000"; mesonCutArray[ 0] = "01523045009000"; // 20-40%
215       cutarray[ 1] = "546000201209297002322000000"; mesonCutArray[ 1] = "01523065009000"; // 40-60%
216       cutarray[ 2] = "568000201209297002322000000"; mesonCutArray[ 2] = "01523065009000"; // 60-80%
217       cutarray[ 3] = "548000201209297002322000000"; mesonCutArray[ 3] = "01523065009000"; // 20-40% 
218       cutarray[ 4] = "549000201209297002322000000"; mesonCutArray[ 4] = "01523065009000"; // 40-90%
219    } else  if (trainConfig == 21){ // eta 0.7, y = 0.6 (new Standard)
220       cutarray[ 0] = "601000107209297002322000000"; mesonCutArray[ 0] = "01523045009000"; // 0-5%
221       cutarray[ 1] = "612000107209297002322000000"; mesonCutArray[ 1] = "01523045009000"; // 5-10%
222       cutarray[ 2] = "501000107209297002322000000"; mesonCutArray[ 2] = "01523045009000"; // 0-10%
223       cutarray[ 3] = "512000107209297002322000000"; mesonCutArray[ 3] = "01523045009000"; // 10-20%
224       cutarray[ 4] = "502000107209297002322000000"; mesonCutArray[ 4] = "01523045009000"; // 0-20%
225    } else if (trainConfig == 22) {  // eta 0.7, y = 0.6 (new Standard)
226       cutarray[ 0] = "524000107209297002322000000"; mesonCutArray[ 0] = "01523045009000"; // 20-40%
227       cutarray[ 1] = "546000107209297002322000000"; mesonCutArray[ 1] = "01523065009000"; // 40-60%
228       cutarray[ 2] = "568000107209297002322000000"; mesonCutArray[ 2] = "01523065009000"; // 60-80%
229       cutarray[ 3] = "548000107209297002322000000"; mesonCutArray[ 3] = "01523065009000"; // 40-80%
230       cutarray[ 4] = "549000107209297002322000000"; mesonCutArray[ 4] = "01523065009000"; // 40-90%
231    } else if (trainConfig == 23) { // eta 0.7, y = 0.6 (new Standard) cuts only added signals
232       cutarray[ 0] = "601000207209297002322000000"; mesonCutArray[ 0] = "01523045009000"; // 0-5%
233       cutarray[ 1] = "612000207209297002322000000"; mesonCutArray[ 1] = "01523045009000"; // 5-10%
234       cutarray[ 2] = "501000207209297002322000000"; mesonCutArray[ 2] = "01523045009000"; // 0-10%
235       cutarray[ 3] = "512000207209297002322000000"; mesonCutArray[ 3] = "01523045009000"; // 10-20%
236       cutarray[ 4] = "502000207209297002322000000"; mesonCutArray[ 4] = "01523045009000"; // 0-20%
237    } else if (trainConfig == 24) { // eta 0.7, y = 0.6 (new Standard) cuts only added signals
238       cutarray[ 0] = "524000207209297002322000000"; mesonCutArray[ 0] = "01523045009000"; // 20-40%
239       cutarray[ 1] = "546000207209297002322000000"; mesonCutArray[ 1] = "01523065009000"; // 40-60%
240       cutarray[ 2] = "568000207209297002322000000"; mesonCutArray[ 2] = "01523065009000"; // 60-80%
241       cutarray[ 3] = "548000207209297002322000000"; mesonCutArray[ 3] = "01523065009000"; // 20-40% 
242       cutarray[ 4] = "549000207209297002322000000"; mesonCutArray[ 4] = "01523065009000"; // 40-90%
243    } else  if (trainConfig == 25){ // eta 0.5, y = 0.6 (new Standard)
244       cutarray[ 0] = "601000105209297002322000000"; mesonCutArray[ 0] = "01523045009000"; // 0-5%
245       cutarray[ 1] = "612000105209297002322000000"; mesonCutArray[ 1] = "01523045009000"; // 5-10%
246       cutarray[ 2] = "501000105209297002322000000"; mesonCutArray[ 2] = "01523045009000"; // 0-10%
247       cutarray[ 3] = "512000105209297002322000000"; mesonCutArray[ 3] = "01523045009000"; // 10-20%
248       cutarray[ 4] = "502000105209297002322000000"; mesonCutArray[ 4] = "01523045009000"; // 0-20%
249    } else if (trainConfig == 26) {  // eta 0.5, y = 0.6 (new Standard)
250       cutarray[ 0] = "524000105209297002322000000"; mesonCutArray[ 0] = "01523045009000"; // 20-40%
251       cutarray[ 1] = "546000105209297002322000000"; mesonCutArray[ 1] = "01523065009000"; // 40-60%
252       cutarray[ 2] = "568000105209297002322000000"; mesonCutArray[ 2] = "01523065009000"; // 60-80%
253       cutarray[ 3] = "548000105209297002322000000"; mesonCutArray[ 3] = "01523065009000"; // 40-80%
254       cutarray[ 4] = "549000105209297002322000000"; mesonCutArray[ 4] = "01523065009000"; // 40-90%
255    } else if (trainConfig == 27) { // eta 0.5, y = 0.6 (new Standard) cuts only added signals
256       cutarray[ 0] = "601000205209297002322000000"; mesonCutArray[ 0] = "01523045009000"; // 0-5%
257       cutarray[ 1] = "612000205209297002322000000"; mesonCutArray[ 1] = "01523045009000"; // 5-10%
258       cutarray[ 2] = "501000205209297002322000000"; mesonCutArray[ 2] = "01523045009000"; // 0-10%
259       cutarray[ 3] = "512000205209297002322000000"; mesonCutArray[ 3] = "01523045009000"; // 10-20%
260       cutarray[ 4] = "502000205209297002322000000"; mesonCutArray[ 4] = "01523045009000"; // 0-20%
261    } else if (trainConfig == 28) { // eta 0.5, y = 0.6 (new Standard) cuts only added signals
262       cutarray[ 0] = "524000205209297002322000000"; mesonCutArray[ 0] = "01523045009000"; // 20-40%
263       cutarray[ 1] = "546000205209297002322000000"; mesonCutArray[ 1] = "01523065009000"; // 40-60%
264       cutarray[ 2] = "568000205209297002322000000"; mesonCutArray[ 2] = "01523065009000"; // 60-80%
265       cutarray[ 3] = "548000205209297002322000000"; mesonCutArray[ 3] = "01523065009000"; // 20-40% 
266       cutarray[ 4] = "549000205209297002322000000"; mesonCutArray[ 4] = "01523065009000"; // 40-90%
267    } else  if (trainConfig == 29){ // eta 0.65 (new standard), y = 0.6 (new Standard) pt dependent alpha
268       cutarray[ 0] = "601000103209297002322000000"; mesonCutArray[ 0] = "01523015009000"; // 0-5%
269       cutarray[ 1] = "612000103209297002322000000"; mesonCutArray[ 1] = "01523015009000"; // 5-10%
270       cutarray[ 2] = "501000103209297002322000000"; mesonCutArray[ 2] = "01523015009000"; // 0-10%
271       cutarray[ 3] = "512000103209297002322000000"; mesonCutArray[ 3] = "01523015009000"; // 10-20%
272       cutarray[ 4] = "502000103209297002322000000"; mesonCutArray[ 4] = "01523015009000"; // 0-20%
273    } else if (trainConfig == 30) {  // eta 0.65 (new standard), y = 0.6 (new Standard) pt dependent alpha
274       cutarray[ 0] = "524000103209297002322000000"; mesonCutArray[ 0] = "01523015009000"; // 20-40%
275       cutarray[ 1] = "546000103209297002322000000"; mesonCutArray[ 1] = "01523025009000"; // 40-60%
276       cutarray[ 2] = "568000103209297002322000000"; mesonCutArray[ 2] = "01523025009000"; // 60-80%
277       cutarray[ 3] = "548000103209297002322000000"; mesonCutArray[ 3] = "01523025009000"; // 40-80%
278       cutarray[ 4] = "549000103209297002322000000"; mesonCutArray[ 4] = "01523025009000"; // 40-90%
279    } else if (trainConfig == 31) { // eta 0.65 (new standard), y = 0.6 (new Standard) cuts only added signals, pt dependent alpha
280       cutarray[ 0] = "601000203209297002322000000"; mesonCutArray[ 0] = "01523015009000"; // 0-5%
281       cutarray[ 1] = "612000203209297002322000000"; mesonCutArray[ 1] = "01523015009000"; // 5-10%
282       cutarray[ 2] = "501000203209297002322000000"; mesonCutArray[ 2] = "01523015009000"; // 0-10%
283       cutarray[ 3] = "512000203209297002322000000"; mesonCutArray[ 3] = "01523015009000"; // 10-20%
284       cutarray[ 4] = "502000203209297002322000000"; mesonCutArray[ 4] = "01523015009000"; // 0-20%
285    } else if (trainConfig == 32) { // eta 0.65 (new standard), y = 0.6 (new Standard) cuts only added signals, pt dependent alpha
286       cutarray[ 0] = "524000203209297002322000000"; mesonCutArray[ 0] = "01523015009000"; // 20-40%
287       cutarray[ 1] = "546000203209297002322000000"; mesonCutArray[ 1] = "01523025009000"; // 40-60%
288       cutarray[ 2] = "568000203209297002322000000"; mesonCutArray[ 2] = "01523025009000"; // 60-80%
289       cutarray[ 3] = "548000203209297002322000000"; mesonCutArray[ 3] = "01523025009000"; // 20-40% 
290       cutarray[ 4] = "549000203209297002322000000"; mesonCutArray[ 4] = "01523025009000"; // 40-90%
291    } else {
292       Error(Form("GammaConvV1_%i",trainConfig), "wrong trainConfig variable no cuts have been specified for the configuration");
293       return;
294    }
295
296    TList *ConvCutList = new TList();
297    TList *MesonCutList = new TList();
298
299    TList *HeaderList = new TList();
300    TObjString *Header1 = new TObjString("pi0_1");
301    HeaderList->Add(Header1);
302 //    TObjString *Header3 = new TObjString("eta_2");
303 //    HeaderList->Add(Header3);
304    
305    ConvCutList->SetOwner(kTRUE);
306    AliConversionCuts **analysisCuts = new AliConversionCuts*[numberOfCuts];
307    MesonCutList->SetOwner(kTRUE);
308    AliConversionMesonCuts **analysisMesonCuts = new AliConversionMesonCuts*[numberOfCuts];
309
310    for(Int_t i = 0; i<numberOfCuts; i++){
311       analysisCuts[i] = new AliConversionCuts();
312       if (trainConfig == 1 ||trainConfig == 5 || trainConfig == 9 || trainConfig == 13 || trainConfig == 17 || trainConfig == 21 || trainConfig == 25 || trainConfig == 29 || trainConfig == 33 || trainConfig == 37 || trainConfig == 41 ){
313          if (i == 0 && doWeighting)  analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kFALSE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13d2_PbPb_2760GeV_0005TPC", "", "","Pi0_Fit_Data_PbPb_2760GeV_0005V0M");
314          if (i == 1 && doWeighting)  analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kFALSE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13d2_PbPb_2760GeV_0510TPC", "", "","Pi0_Fit_Data_PbPb_2760GeV_0510V0M");
315          if (i == 2 && doWeighting)  analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kFALSE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13d2_PbPb_2760GeV_0010TPC", "", "","Pi0_Fit_Data_PbPb_2760GeV_0010V0M");
316          if (i == 3 && doWeighting)  analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kFALSE, kFALSE,fileNameInputForWeighting, "Pi0_Hijing_LHC13d2_PbPb_2760GeV_1020TPC", "", "","Pi0_Fit_Data_PbPb_2760GeV_1020V0M");
317          if (i == 4 && doWeighting)  analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kFALSE, kFALSE,fileNameInputForWeighting, "Pi0_Hijing_LHC13d2_PbPb_2760GeV_0020TPC", "", "","Pi0_Fit_Data_PbPb_2760GeV_0020V0M");
318       } else if (trainConfig == 2 ||trainConfig == 6 || trainConfig == 10 || trainConfig == 14 || trainConfig == 18 || trainConfig == 22 || trainConfig == 26 || trainConfig == 30 || trainConfig == 34 || trainConfig == 38 || trainConfig == 42 ){ 
319         if (i == 0 && doWeighting)  analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kFALSE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13d2_PbPb_2760GeV_2040TPC", "", "","Pi0_Fit_Data_PbPb_2760GeV_2040V0M");
320         if (i == 1 && doWeighting) analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kFALSE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13d2_PbPb_2760GeV_4060TPC", "", "","Pi0_Fit_Data_PbPb_2760GeV_4060V0M");
321         if (i == 2 && doWeighting) analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kFALSE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13d2_PbPb_2760GeV_6080TPC", "", "","Pi0_Fit_Data_PbPb_2760GeV_6080V0M");
322         if (i == 3 && doWeighting)  analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kFALSE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13d2_PbPb_2760GeV_4080TPC", "", "","Pi0_Fit_Data_PbPb_2760GeV_4080V0M");
323       } else if (trainConfig == 3 ||trainConfig == 7 || trainConfig == 11 || trainConfig == 15 || trainConfig == 19 || trainConfig == 23 || trainConfig == 27 || trainConfig == 31 || trainConfig == 35 || trainConfig == 39 || trainConfig == 43 ){
324          if (i == 0 && doWeighting)  analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kFALSE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13d2_addSig_PbPb_2760GeV_0005TPC", "", "","Pi0_Fit_Data_PbPb_2760GeV_0005V0M");
325          if (i == 1 && doWeighting)  analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kFALSE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13d2_addSig_PbPb_2760GeV_0510TPC", "", "","Pi0_Fit_Data_PbPb_2760GeV_0510V0M");
326          if (i == 2 && doWeighting)  analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kFALSE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13d2_addSig_PbPb_2760GeV_0010TPC", "", "","Pi0_Fit_Data_PbPb_2760GeV_0010V0M");
327          if (i == 3 && doWeighting)  analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kFALSE, kFALSE,fileNameInputForWeighting, "Pi0_Hijing_LHC13d2_addSig_PbPb_2760GeV_1020TPC", "", "","Pi0_Fit_Data_PbPb_2760GeV_1020V0M");
328           if (i == 0 && doWeighting)  analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kFALSE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13d2_addSig_PbPb_2760GeV_0020TPC", "", "","Pi0_Fit_Data_PbPb_2760GeV_0020V0M");
329       } else if (trainConfig == 4 ||trainConfig == 8 || trainConfig == 12 || trainConfig == 16 || trainConfig == 20 || trainConfig == 24 || trainConfig == 28 || trainConfig == 32 || trainConfig == 36 || trainConfig == 40 || trainConfig == 44 ){ 
330         if (i == 0 && doWeighting)  analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kFALSE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13d2_addSig_PbPb_2760GeV_2040TPC", "", "","Pi0_Fit_Data_PbPb_2760GeV_2040V0M");
331         if (i == 1 && doWeighting)  analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kFALSE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13d2_addSig_PbPb_2760GeV_4060TPC", "", "","Pi0_Fit_Data_PbPb_2760GeV_4060V0M");
332         if (i == 2  && doWeighting) analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kFALSE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13d2_addSig_PbPb_2760GeV_6080TPC", "", "","Pi0_Fit_Data_PbPb_2760GeV_6080V0M");
333         if (i == 3 && doWeighting)  analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kFALSE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13d2_addSig_PbPb_2760GeV_4080TPC", "", "","Pi0_Fit_Data_PbPb_2760GeV_4080V0M");
334       }
335 //      if (trainConfig == 45 ||trainConfig == 47 || trainConfig == 49 || trainConfig == 51 || trainConfig == 53 || trainConfig == 55  ){
336 //          if ((i == 0 || i == 1 || i == 2)&& doWeighting)  analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kFALSE, kFALSE,fileNameInputForWeighting, "Pi0_Hijing_LHC13d2_PbPb_2760GeV_0020TPC", "", "","Pi0_Fit_Data_PbPb_2760GeV_0020V0M");
337 //          if ((i == 3 || i == 4 )&& doWeighting)  analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kFALSE, kFALSE,fileNameInputForWeighting, "Pi0_Hijing_LHC13d2_PbPb_2760GeV_4080TPC", "", "","Pi0_Fit_Data_PbPb_2760GeV_4080V0M");
338 //      }
339 //      if (trainConfig == 46 ||trainConfig == 48 || trainConfig == 50 || trainConfig == 52 || trainConfig == 54 || trainConfig == 56  ){
340 //          if ((i == 0 || i == 1 || i == 2)&& doWeighting)  analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kFALSE, kFALSE,fileNameInputForWeighting, "Pi0_Hijing_LHC13d2_addSig_PbPb_2760GeV_0020TPC", "", "","Pi0_Fit_Data_PbPb_2760GeV_0020V0M");
341 //          if ((i == 3 || i == 4 )&& doWeighting)  analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kFALSE, kFALSE,fileNameInputForWeighting, "Pi0_Hijing_LHC13d2_addSig_PbPb_2760GeV_4080TPC", "", "","Pi0_Fit_Data_PbPb_2760GeV_4080V0M");
342 //      }
343 //      if (trainConfig == 57  ){
344 //          if (doWeighting)  analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kFALSE, kFALSE,fileNameInputForWeighting, "Pi0_Hijing_LHC13d2_PbPb_2760GeV_4080TPC", "", "","Pi0_Fit_Data_PbPb_2760GeV_4080V0M");
345 //      }
346 //      if (trainConfig == 58){
347 //          if (doWeighting)  analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kFALSE, kFALSE,fileNameInputForWeighting, "Pi0_Hijing_LHC13d2_addSig_PbPb_2760GeV_4080TPC", "", "","Pi0_Fit_Data_PbPb_2760GeV_4080V0M");
348 //      }
349       analysisCuts[i]->InitializeCutsFromCutString(cutarray[i].Data());
350       ConvCutList->Add(analysisCuts[i]);
351
352       analysisCuts[i]->SetFillCutHistograms("",kFALSE);
353       analysisMesonCuts[i] = new AliConversionMesonCuts();
354       analysisMesonCuts[i]->InitializeCutsFromCutString(mesonCutArray[i].Data());
355       MesonCutList->Add(analysisMesonCuts[i]);
356       analysisMesonCuts[i]->SetFillCutHistograms("");
357       analysisCuts[i]->SetAcceptedHeader(HeaderList);
358    }
359
360    task->SetConversionCutList(numberOfCuts,ConvCutList);
361    task->SetMesonCutList(numberOfCuts,MesonCutList);
362    task->SetMoveParticleAccordingToVertex(kTRUE);
363    task->SetDoMesonAnalysis(kTRUE);
364    if (enableQAMesonTask) task->SetDoMesonQA(kTRUE); //Attention new switch for Pi0 QA
365    if (enableQAPhotonTask) task->SetDoPhotonQA(kTRUE);  //Attention new switch small for Photon QA
366
367    //connect containers
368    AliAnalysisDataContainer *coutput =
369       mgr->CreateContainer(Form("GammaConvV1_%i",trainConfig), TList::Class(),
370                            AliAnalysisManager::kOutputContainer,Form("GammaConvV1_%i.root",trainConfig));
371
372    mgr->AddTask(task);
373    mgr->ConnectInput(task,0,cinput);
374    mgr->ConnectOutput(task,1,coutput);
375
376    return;
377
378 }