TENDER becomes Tender, removing .so
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / macros / AddTask_GammaConvCalo_PbPb.C
1 void AddTask_GammaConvCalo_PbPb(        Int_t trainConfig = 1,  //change different set of cuts
2                                                                         Bool_t isMC   = kFALSE, //run MC 
3                                                                         Int_t enableQAMesonTask = 0, //enable QA in AliAnalysisTaskGammaConvV1
4                                                                         Int_t enableQAPhotonTask = 0, // enable additional QA task
5                                                                         TString fileNameInputForWeighting = "MCSpectraInput.root", // path to file for weigting input
6                                                                         Int_t headerSelectionInt = 0,  // 1 pi0 header, 2 eta header, 3 both (only for "named" boxes)
7                                                                         TString cutnumberAODBranch = "1000000060084000001500000",
8                                                                         TString periodName = "LHC13d2",  //name of the period for added signals and weighting
9                                     Bool_t doWeighting = kFALSE,  //enable Weighting
10                                     Bool_t enableExtendedMatching = kFALSE //enable or disable extended matching histograms for conversion electrons <-> cluster
11                                                                 ) {
12
13         // ================= Load Librariers =================================
14         gSystem->Load("libCore");  
15         gSystem->Load("libTree");
16         gSystem->Load("libGeom");
17         gSystem->Load("libVMC");
18         gSystem->Load("libPhysics");
19         gSystem->Load("libMinuit");
20         gSystem->Load("libSTEERBase");
21         gSystem->Load("libESD");
22         gSystem->Load("libAOD");
23         gSystem->Load("libANALYSIS");
24         gSystem->Load("libANALYSISalice");  
25         gSystem->Load("libCDB");
26         gSystem->Load("libSTEER");
27         gSystem->Load("libSTEERBase");
28         gSystem->Load("libTender");
29         gSystem->Load("libTenderSupplies");
30         gSystem->Load("libPWGflowBase");
31         gSystem->Load("libPWGflowTasks");
32         gSystem->Load("libPWGGAGammaConv");
33
34         Int_t isHeavyIon = 1;
35         
36         // ================== GetAnalysisManager ===============================
37         AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
38         if (!mgr) {
39                 Error(Form("AddTask_GammaConvV1_%i",trainConfig), "No analysis manager found.");
40                 return ;
41         }
42
43         // ================== GetInputEventHandler =============================
44         AliVEventHandler *inputHandler=mgr->GetInputEventHandler();
45         
46         //========= Add PID Reponse to ANALYSIS manager ====
47         if(!(AliPIDResponse*)mgr->GetTask("PIDResponseTask")){
48                 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
49                 AddTaskPIDResponse(isMC);
50         }
51         
52         //=========  Set Cutnumber for V0Reader ================================
53         TString cutnumberPhoton = "000000084001001500000000";
54         TString cutnumberEvent = "1000000";
55         AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
56
57         //========= Add V0 Reader to  ANALYSIS manager if not yet existent =====
58         if( !(AliV0ReaderV1*)mgr->GetTask("V0ReaderV1") ){
59                 AliV0ReaderV1 *fV0ReaderV1 = new AliV0ReaderV1("V0ReaderV1");
60                 
61                 fV0ReaderV1->SetUseOwnXYZCalculation(kTRUE);
62                 fV0ReaderV1->SetCreateAODs(kFALSE);// AOD Output
63                 fV0ReaderV1->SetUseAODConversionPhoton(kTRUE);
64
65                 if (!mgr) {
66                         Error("AddTask_V0ReaderV1", "No analysis manager found.");
67                         return;
68                 }
69
70                 AliConvEventCuts *fEventCuts=NULL;
71                 if(cutnumberEvent!=""){
72                         fEventCuts= new AliConvEventCuts(cutnumberEvent.Data(),cutnumberEvent.Data());
73                         fEventCuts->SetPreSelectionCutFlag(kTRUE);
74                         if(fEventCuts->InitializeCutsFromCutString(cutnumberEvent.Data())){
75                                 fV0ReaderV1->SetEventCuts(fEventCuts);
76                                 fEventCuts->SetFillCutHistograms("",kTRUE);
77                         }
78                 }
79
80                 
81                 // Set AnalysisCut Number
82                 AliConversionPhotonCuts *fCuts=NULL;
83                 if(cutnumberPhoton!=""){
84                         fCuts= new AliConversionPhotonCuts(cutnumberPhoton.Data(),cutnumberPhoton.Data());
85                         fCuts->SetPreSelectionCutFlag(kTRUE);
86                         fCuts->SetIsHeavyIon(isHeavyIon);
87                         if(fCuts->InitializeCutsFromCutString(cutnumberPhoton.Data())){
88                                 fV0ReaderV1->SetConversionCuts(fCuts);
89                                 fCuts->SetFillCutHistograms("",kTRUE);
90                         }
91                 }
92
93                 if(inputHandler->IsA()==AliAODInputHandler::Class()){
94                 // AOD mode
95                         fV0ReaderV1->SetDeltaAODBranchName(Form("GammaConv_%s_gamma",cutnumberAODBranch.Data()));
96                 }
97                 fV0ReaderV1->Init();
98
99                 AliLog::SetGlobalLogLevel(AliLog::kFatal);
100
101                 //connect input V0Reader
102                 mgr->AddTask(fV0ReaderV1);
103                 mgr->ConnectInput(fV0ReaderV1,0,cinput);
104
105         }
106
107         //================================================
108         //========= Add task to the ANALYSIS manager =====
109         //================================================
110         AliAnalysisTaskGammaConvCalo *task=NULL;
111         task= new AliAnalysisTaskGammaConvCalo(Form("GammaConvCalo_%i",trainConfig));
112         task->SetIsHeavyIon(isHeavyIon);
113         task->SetIsMC(isMC);
114         // Cut Numbers to use in Analysis
115         Int_t numberOfCuts = 5;
116
117         TString *eventCutArray = new TString[numberOfCuts];
118         TString *photonCutArray = new TString[numberOfCuts];
119         TString *clusterCutArray = new TString[numberOfCuts];
120         TString *mesonCutArray = new TString[numberOfCuts];
121   
122         if (trainConfig == 1){ // EMCAL clusters
123                 eventCutArray[ 0] = "6010001"; photonCutArray[ 0] = "002000092970028250400000"; clusterCutArray[0] = "10000040032030000"; mesonCutArray[ 0] = "01631031000000"; // 0-5%
124                 eventCutArray[ 1] = "6120001"; photonCutArray[ 1] = "002000092970028250400000"; clusterCutArray[1] = "10000040032030000"; mesonCutArray[ 1] = "01631031000000"; // 5-10%
125                 eventCutArray[ 2] = "5010001"; photonCutArray[ 2] = "002000092970028250400000"; clusterCutArray[2] = "10000040032030000"; mesonCutArray[ 2] = "01631031000000"; // 0-10%
126                 eventCutArray[ 3] = "5240001"; photonCutArray[ 3] = "002000092970028250400000"; clusterCutArray[3] = "10000040032030000"; mesonCutArray[ 3] = "01631031000000"; // 20-40%
127                 eventCutArray[ 4] = "5250001"; photonCutArray[ 4] = "002000092970028250400000"; clusterCutArray[4] = "10000040032030000"; mesonCutArray[ 4] = "01631031000000"; // 20-50%
128         } else if (trainConfig == 2){ // EMCAL clusters
129                 eventCutArray[ 0] = "6010001"; photonCutArray[ 0] = "002000092970028250400000"; clusterCutArray[0] = "10000040032030000"; mesonCutArray[ 0] = "01631031000000"; // 0-5%
130                 eventCutArray[ 1] = "6120001"; photonCutArray[ 1] = "002000092970028250400000"; clusterCutArray[1] = "10000040032030000"; mesonCutArray[ 1] = "01631031000000"; // 5-10%
131                 eventCutArray[ 2] = "5010001"; photonCutArray[ 2] = "002000092970028250400000"; clusterCutArray[2] = "10000040032030000"; mesonCutArray[ 2] = "01631031000000"; // 0-10%
132                 eventCutArray[ 3] = "5120001"; photonCutArray[ 3] = "002000092970028250400000"; clusterCutArray[3] = "10000040032030000"; mesonCutArray[ 3] = "01631031000000"; // 10-20%
133                 eventCutArray[ 4] = "5240001"; photonCutArray[ 4] = "002000092970028250400000"; clusterCutArray[4] = "10000040032030000"; mesonCutArray[ 4] = "01631031000000"; // 20-40%               
134         } else if (trainConfig == 3){ // EMCAL clusters
135                 eventCutArray[ 0] = "5460001"; photonCutArray[ 0] = "002000092970028250400000"; clusterCutArray[0] = "10000040032030000"; mesonCutArray[ 0] = "01631031000000"; // 40-60%
136                 eventCutArray[ 1] = "5680001"; photonCutArray[ 1] = "002000092970028250400000"; clusterCutArray[1] = "10000040032030000"; mesonCutArray[ 1] = "01631031000000"; // 60-80%
137                 eventCutArray[ 2] = "5260001"; photonCutArray[ 2] = "002000092970028250400000"; clusterCutArray[2] = "10000040032030000"; mesonCutArray[ 2] = "01631031000000"; // 20-60%
138                 eventCutArray[ 3] = "5480001"; photonCutArray[ 3] = "002000092970028250400000"; clusterCutArray[3] = "10000040032030000"; mesonCutArray[ 3] = "01631031000000"; // 40-80%
139                 eventCutArray[ 4] = "5250001"; photonCutArray[ 4] = "002000092970028250400000"; clusterCutArray[4] = "10000040032030000"; mesonCutArray[ 4] = "01631031000000"; // 20-50%                               
140         } else if (trainConfig == 4){ // EMCAL clusters
141                 eventCutArray[ 0] = "6010001"; photonCutArray[ 0] = "002000092970028250400000"; clusterCutArray[0] = "10000043032030000"; mesonCutArray[ 0] = "01631031000000"; // 0-5%
142                 eventCutArray[ 1] = "6120001"; photonCutArray[ 1] = "002000092970028250400000"; clusterCutArray[1] = "10000043032030000"; mesonCutArray[ 1] = "01631031000000"; // 5-10%
143                 eventCutArray[ 2] = "5010001"; photonCutArray[ 2] = "002000092970028250400000"; clusterCutArray[2] = "10000043032030000"; mesonCutArray[ 2] = "01631031000000"; // 0-10%
144                 eventCutArray[ 3] = "5240001"; photonCutArray[ 3] = "002000092970028250400000"; clusterCutArray[3] = "10000043032030000"; mesonCutArray[ 3] = "01631031000000"; // 20-40%
145                 eventCutArray[ 4] = "5250001"; photonCutArray[ 4] = "002000092970028250400000"; clusterCutArray[4] = "10000043032030000"; mesonCutArray[ 4] = "01631031000000"; // 20-50%
146         } else if (trainConfig == 5){ // EMCAL clusters
147                 eventCutArray[ 0] = "6010001"; photonCutArray[ 0] = "002000092970028250400000"; clusterCutArray[0] = "10000043032030000"; mesonCutArray[ 0] = "01631031000000"; // 0-5%
148                 eventCutArray[ 1] = "6120001"; photonCutArray[ 1] = "002000092970028250400000"; clusterCutArray[1] = "10000043032030000"; mesonCutArray[ 1] = "01631031000000"; // 5-10%
149                 eventCutArray[ 2] = "5010001"; photonCutArray[ 2] = "002000092970028250400000"; clusterCutArray[2] = "10000043032030000"; mesonCutArray[ 2] = "01631031000000"; // 0-10%
150                 eventCutArray[ 3] = "5120001"; photonCutArray[ 3] = "002000092970028250400000"; clusterCutArray[3] = "10000043032030000"; mesonCutArray[ 3] = "01631031000000"; // 10-20%
151                 eventCutArray[ 4] = "5240001"; photonCutArray[ 4] = "002000092970028250400000"; clusterCutArray[4] = "10000043032030000"; mesonCutArray[ 4] = "01631031000000"; // 20-40%               
152         } else if (trainConfig == 6){ // EMCAL clusters
153                 eventCutArray[ 0] = "5460001"; photonCutArray[ 0] = "002000092970028250400000"; clusterCutArray[0] = "10000043032030000"; mesonCutArray[ 0] = "01631031000000"; // 40-60%
154                 eventCutArray[ 1] = "5680001"; photonCutArray[ 1] = "002000092970028250400000"; clusterCutArray[1] = "10000043032030000"; mesonCutArray[ 1] = "01631031000000"; // 60-80%
155                 eventCutArray[ 2] = "5260001"; photonCutArray[ 2] = "002000092970028250400000"; clusterCutArray[2] = "10000043032030000"; mesonCutArray[ 2] = "01631031000000"; // 20-60%
156                 eventCutArray[ 3] = "5480001"; photonCutArray[ 3] = "002000092970028250400000"; clusterCutArray[3] = "10000043032030000"; mesonCutArray[ 3] = "01631031000000"; // 40-80%
157                 eventCutArray[ 4] = "5250001"; photonCutArray[ 4] = "002000092970028250400000"; clusterCutArray[4] = "10000043032030000"; mesonCutArray[ 4] = "01631031000000"; // 20-50%                               
158         } else if (trainConfig == 31){ // PHOS clusters
159                 eventCutArray[ 0] = "6010001"; photonCutArray[ 0] = "002000092970028250400000"; clusterCutArray[0] = "20000042033200000"; mesonCutArray[ 0] = "01631031000000"; // 0-5%
160                 eventCutArray[ 1] = "6120001"; photonCutArray[ 1] = "002000092970028250400000"; clusterCutArray[1] = "20000042033200000"; mesonCutArray[ 1] = "01631031000000"; // 5-10%
161                 eventCutArray[ 2] = "5010001"; photonCutArray[ 2] = "002000092970028250400000"; clusterCutArray[2] = "20000042033200000"; mesonCutArray[ 2] = "01631031000000"; // 0-10%
162                 eventCutArray[ 3] = "5240001"; photonCutArray[ 3] = "002000092970028250400000"; clusterCutArray[3] = "20000042033200000"; mesonCutArray[ 3] = "01631031000000"; // 20-40%
163                 eventCutArray[ 4] = "5250001"; photonCutArray[ 4] = "002000092970028250400000"; clusterCutArray[4] = "20000042033200000"; mesonCutArray[ 4] = "01631031000000"; // 20-50%
164         } else if (trainConfig == 32){ // PHOS clusters
165                 eventCutArray[ 0] = "6010001"; photonCutArray[ 0] = "002000092970028250400000"; clusterCutArray[0] = "20000042033200000"; mesonCutArray[ 0] = "01631031000000"; // 0-5%
166                 eventCutArray[ 1] = "6120001"; photonCutArray[ 1] = "002000092970028250400000"; clusterCutArray[1] = "20000042033200000"; mesonCutArray[ 1] = "01631031000000"; // 5-10%
167                 eventCutArray[ 2] = "5010001"; photonCutArray[ 2] = "002000092970028250400000"; clusterCutArray[2] = "20000042033200000"; mesonCutArray[ 2] = "01631031000000"; // 0-10%
168                 eventCutArray[ 3] = "5120001"; photonCutArray[ 3] = "002000092970028250400000"; clusterCutArray[3] = "20000042033200000"; mesonCutArray[ 3] = "01631031000000"; // 10-20%
169                 eventCutArray[ 4] = "5240001"; photonCutArray[ 4] = "002000092970028250400000"; clusterCutArray[4] = "20000042033200000"; mesonCutArray[ 4] = "01631031000000"; // 20-40%               
170         } else if (trainConfig == 33){ // PHOS clusters
171                 eventCutArray[ 0] = "5460001"; photonCutArray[ 0] = "002000092970028250400000"; clusterCutArray[0] = "20000042033200000"; mesonCutArray[ 0] = "01631031000000"; // 40-60%
172                 eventCutArray[ 1] = "5680001"; photonCutArray[ 1] = "002000092970028250400000"; clusterCutArray[1] = "20000042033200000"; mesonCutArray[ 1] = "01631031000000"; // 60-80%
173                 eventCutArray[ 2] = "5260001"; photonCutArray[ 2] = "002000092970028250400000"; clusterCutArray[2] = "20000042033200000"; mesonCutArray[ 2] = "01631031000000"; // 20-60%
174                 eventCutArray[ 3] = "5480001"; photonCutArray[ 3] = "002000092970028250400000"; clusterCutArray[3] = "20000042033200000"; mesonCutArray[ 3] = "01631031000000"; // 40-80%
175                 eventCutArray[ 4] = "5250001"; photonCutArray[ 4] = "002000092970028250400000"; clusterCutArray[4] = "20000042033200000"; mesonCutArray[ 4] = "01631031000000"; // 20-50%                                               
176         } else if (trainConfig == 34){ // PHOS clusters
177                 eventCutArray[ 0] = "6010001"; photonCutArray[ 0] = "002000092970028250400000"; clusterCutArray[0] = "20000043033200000"; mesonCutArray[ 0] = "01631031000000"; // 0-5%
178                 eventCutArray[ 1] = "6120001"; photonCutArray[ 1] = "002000092970028250400000"; clusterCutArray[1] = "20000043033200000"; mesonCutArray[ 1] = "01631031000000"; // 5-10%
179                 eventCutArray[ 2] = "5010001"; photonCutArray[ 2] = "002000092970028250400000"; clusterCutArray[2] = "20000043033200000"; mesonCutArray[ 2] = "01631031000000"; // 0-10%
180                 eventCutArray[ 3] = "5240001"; photonCutArray[ 3] = "002000092970028250400000"; clusterCutArray[3] = "20000043033200000"; mesonCutArray[ 3] = "01631031000000"; // 20-40%
181                 eventCutArray[ 4] = "5250001"; photonCutArray[ 4] = "002000092970028250400000"; clusterCutArray[4] = "20000043033200000"; mesonCutArray[ 4] = "01631031000000"; // 20-50%
182         } else if (trainConfig == 35){ // PHOS clusters
183                 eventCutArray[ 0] = "6010001"; photonCutArray[ 0] = "002000092970028250400000"; clusterCutArray[0] = "20000043033200000"; mesonCutArray[ 0] = "01631031000000"; // 0-5%
184                 eventCutArray[ 1] = "6120001"; photonCutArray[ 1] = "002000092970028250400000"; clusterCutArray[1] = "20000043033200000"; mesonCutArray[ 1] = "01631031000000"; // 5-10%
185                 eventCutArray[ 2] = "5010001"; photonCutArray[ 2] = "002000092970028250400000"; clusterCutArray[2] = "20000043033200000"; mesonCutArray[ 2] = "01631031000000"; // 0-10%
186                 eventCutArray[ 3] = "5120001"; photonCutArray[ 3] = "002000092970028250400000"; clusterCutArray[3] = "20000043033200000"; mesonCutArray[ 3] = "01631031000000"; // 10-20%
187                 eventCutArray[ 4] = "5240001"; photonCutArray[ 4] = "002000092970028250400000"; clusterCutArray[4] = "20000043033200000"; mesonCutArray[ 4] = "01631031000000"; // 20-40%               
188         } else if (trainConfig == 36){ // PHOS clusters
189                 eventCutArray[ 0] = "5460001"; photonCutArray[ 0] = "002000092970028250400000"; clusterCutArray[0] = "20000043033200000"; mesonCutArray[ 0] = "01631031000000"; // 40-60%
190                 eventCutArray[ 1] = "5680001"; photonCutArray[ 1] = "002000092970028250400000"; clusterCutArray[1] = "20000043033200000"; mesonCutArray[ 1] = "01631031000000"; // 60-80%
191                 eventCutArray[ 2] = "5260001"; photonCutArray[ 2] = "002000092970028250400000"; clusterCutArray[2] = "20000043033200000"; mesonCutArray[ 2] = "01631031000000"; // 20-60%
192                 eventCutArray[ 3] = "5480001"; photonCutArray[ 3] = "002000092970028250400000"; clusterCutArray[3] = "20000043033200000"; mesonCutArray[ 3] = "01631031000000"; // 40-80%
193                 eventCutArray[ 4] = "5250001"; photonCutArray[ 4] = "002000092970028250400000"; clusterCutArray[4] = "20000043033200000"; mesonCutArray[ 4] = "01631031000000"; // 20-50%                                                               
194         } else {
195                 Error(Form("GammaConvCalo_%i",trainConfig), "wrong trainConfig variable no cuts have been specified for the configuration");
196                 return;
197         }
198
199         TList *EventCutList = new TList();
200         TList *ConvCutList = new TList();
201         TList *ClusterCutList = new TList();
202         TList *MesonCutList = new TList();
203
204         TList *HeaderList = new TList();
205         if (periodName.CompareTo("LHC13d2")==0){
206                 TObjString *Header1 = new TObjString("pi0_1");
207                 HeaderList->Add(Header1);
208         //    TObjString *Header3 = new TObjString("eta_2");
209         //    HeaderList->Add(Header3);
210
211         } else if (periodName.CompareTo("LHC12a17x_fix")==0){
212                 TObjString *Header1 = new TObjString("PARAM");
213                 HeaderList->Add(Header1);
214         } else if (periodName.CompareTo("LHC14a1a")==0){
215                 if (headerSelectionInt == 1){ 
216                         TObjString *Header1 = new TObjString("pi0_1");
217                         HeaderList->Add(Header1);
218                 } else if (headerSelectionInt == 2){
219                         TObjString *Header1 = new TObjString("eta_2");
220                         HeaderList->Add(Header1);
221                 } else {
222                         TObjString *Header1 = new TObjString("pi0_1");
223                         HeaderList->Add(Header1);
224                         TObjString *Header2 = new TObjString("eta_2");
225                         HeaderList->Add(Header2);
226                 }  
227         } else if (periodName.CompareTo("LHC14a1b")==0 || periodName.CompareTo("LHC14a1c")==0){
228                 TObjString *Header1 = new TObjString("BOX");
229                 HeaderList->Add(Header1);
230         }       
231
232         EventCutList->SetOwner(kTRUE);
233         AliConvEventCuts **analysisEventCuts = new AliConvEventCuts*[numberOfCuts];
234         ConvCutList->SetOwner(kTRUE);
235         AliConversionPhotonCuts **analysisCuts = new AliConversionPhotonCuts*[numberOfCuts];
236         ClusterCutList->SetOwner(kTRUE);
237         AliCaloPhotonCuts **analysisClusterCuts = new AliCaloPhotonCuts*[numberOfCuts];
238         MesonCutList->SetOwner(kTRUE);
239         AliConversionMesonCuts **analysisMesonCuts = new AliConversionMesonCuts*[numberOfCuts];
240
241         for(Int_t i = 0; i<numberOfCuts; i++){
242                 
243                 analysisEventCuts[i] = new AliConvEventCuts();
244 //              if ( trainConfig == 1){
245 //                      if (periodName.CompareTo("LHC14a1a") ==0 || periodName.CompareTo("LHC14a1b") ==0 || periodName.CompareTo("LHC14a1c") ==0 ){
246 //                              if ( i == 0 && doWeighting)  analysisEventCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE,fileNameInputForWeighting, Form("Pi0_Hijing_%s_PbPb_2760GeV_0005TPC",periodName.Data()), Form("Eta_Hijing_%s_PbPb_2760GeV_0005TPC",periodName.Data()), "","Pi0_Fit_Data_PbPb_2760GeV_0005V0M","Eta_Fit_Data_PbPb_2760GeV_0005V0M");
247 //                              if ( i == 1 && doWeighting)  analysisEventCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE,fileNameInputForWeighting, Form("Pi0_Hijing_%s_PbPb_2760GeV_0510TPC",periodName.Data()), Form("Eta_Hijing_%s_PbPb_2760GeV_0510TPC",periodName.Data()), "","Pi0_Fit_Data_PbPb_2760GeV_0510V0M","Eta_Fit_Data_PbPb_2760GeV_0510V0M");
248 //                              if ( i == 2 && doWeighting)  analysisEventCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE,fileNameInputForWeighting, Form("Pi0_Hijing_%s_PbPb_2760GeV_0010TPC",periodName.Data()), Form("Eta_Hijing_%s_PbPb_2760GeV_0010TPC",periodName.Data()), "","Pi0_Fit_Data_PbPb_2760GeV_0010V0M","Eta_Fit_Data_PbPb_2760GeV_0010V0M");
249 //                              if ( i == 3 && doWeighting)  analysisEventCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE,fileNameInputForWeighting, Form("Pi0_Hijing_%s_PbPb_2760GeV_2040TPC",periodName.Data()), Form("Eta_Hijing_%s_PbPb_2760GeV_2040TPC",periodName.Data()), "","Pi0_Fit_Data_PbPb_2760GeV_2040V0M","Eta_Fit_Data_PbPb_2760GeV_2040V0M");
250 //                              if ( i == 4 && doWeighting)  analysisEventCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE,fileNameInputForWeighting, Form("Pi0_Hijing_%s_PbPb_2760GeV_2050TPC",periodName.Data()), Form("Eta_Hijing_%s_PbPb_2760GeV_2050TPC",periodName.Data()), "","Pi0_Fit_Data_PbPb_2760GeV_2050V0M","Eta_Fit_Data_PbPb_2760GeV_2050V0M");
251 //                      }       
252 //              } 
253                 analysisEventCuts[i]->InitializeCutsFromCutString(eventCutArray[i].Data());
254                 if (periodName.CompareTo("LHC14a1b") ==0 || periodName.CompareTo("LHC14a1c") ==0 ){
255                         if (headerSelectionInt == 1) analysisEventCuts[i]->SetAddedSignalPDGCode(111);
256                         if (headerSelectionInt == 2) analysisEventCuts[i]->SetAddedSignalPDGCode(221);
257                 }
258                 EventCutList->Add(analysisEventCuts[i]);
259                 analysisEventCuts[i]->SetFillCutHistograms("",kFALSE);
260
261                 analysisCuts[i] = new AliConversionPhotonCuts();
262                 analysisCuts[i]->InitializeCutsFromCutString(photonCutArray[i].Data());
263                 ConvCutList->Add(analysisCuts[i]);
264                 analysisCuts[i]->SetFillCutHistograms("",kFALSE);
265                                 
266                 analysisClusterCuts[i] = new AliCaloPhotonCuts();
267                 analysisClusterCuts[i]->InitializeCutsFromCutString(clusterCutArray[i].Data());
268                 ClusterCutList->Add(analysisClusterCuts[i]);
269         analysisClusterCuts[i]->SetExtendedMatching(enableExtendedMatching);
270                 analysisClusterCuts[i]->SetFillCutHistograms("");
271
272                 analysisMesonCuts[i] = new AliConversionMesonCuts();
273                 analysisMesonCuts[i]->InitializeCutsFromCutString(mesonCutArray[i].Data());
274                 MesonCutList->Add(analysisMesonCuts[i]);
275                 analysisMesonCuts[i]->SetFillCutHistograms("");
276                 analysisEventCuts[i]->SetAcceptedHeader(HeaderList);
277         
278         }
279
280         task->SetEventCutList(numberOfCuts,EventCutList);
281         task->SetConversionCutList(numberOfCuts,ConvCutList);
282         task->SetCaloCutList(numberOfCuts,ClusterCutList);
283         task->SetMesonCutList(numberOfCuts,MesonCutList);
284         task->SetMoveParticleAccordingToVertex(kTRUE);
285         task->SetDoMesonAnalysis(kTRUE);
286         task->SetDoMesonQA(enableQAMesonTask); //Attention new switch for Pi0 QA
287         task->SetDoPhotonQA(enableQAPhotonTask);  //Attention new switch small for Photon QA
288         task->SetDoClusterQA(1);  //Attention new switch small for Cluster QA
289         
290         //connect containers
291         AliAnalysisDataContainer *coutput =
292                 mgr->CreateContainer(Form("GammaConvCalo_%i",trainConfig), TList::Class(),
293                                                         AliAnalysisManager::kOutputContainer,Form("GammaConvCalo_%i.root",trainConfig));
294
295         mgr->AddTask(task);
296         mgr->ConnectInput(task,0,cinput);
297         mgr->ConnectOutput(task,1,coutput);
298
299         return;
300
301 }