TENDER becomes Tender
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / macros / AddTask_GammaConvV1_PbPb2.C
1 void AddTask_GammaConvV1_PbPb2(  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                               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("libCDB.so");
23         gSystem->Load("libSTEER.so");
24         gSystem->Load("libSTEERBase.so");
25         gSystem->Load("libTender.so");
26         gSystem->Load("libTenderSupplies.so");
27         gSystem->Load("libPWGflowBase.so");
28         gSystem->Load("libPWGflowTasks.so");
29         gSystem->Load("libPWGGAGammaConv.so");
30                 
31         Int_t isHeavyIon = 1;
32         
33         // ================== GetAnalysisManager ===============================
34         AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
35         if (!mgr) {
36                 Error(Form("AddTask_GammaConvV1_%i",trainConfig), "No analysis manager found.");
37                 return ;
38         }
39
40         // ================== GetInputEventHandler =============================
41         AliVEventHandler *inputHandler=mgr->GetInputEventHandler();
42         
43         //========= Add PID Reponse to ANALYSIS manager ====
44         if(!(AliPIDResponse*)mgr->GetTask("PIDResponseTask")){
45                 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
46                 AddTaskPIDResponse(isMC);
47         }
48         
49         //=========  Set Cutnumber for V0Reader ================================
50         TString cutnumberPhoton = "000000084001001500000000";
51         TString cutnumberEvent = "1000000";
52         AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
53         //========= Add V0 Reader to  ANALYSIS manager if not yet existent =====
54         if( !(AliV0ReaderV1*)mgr->GetTask("V0ReaderV1") ){
55                 AliV0ReaderV1 *fV0ReaderV1 = new AliV0ReaderV1("V0ReaderV1");
56                 
57                 fV0ReaderV1->SetUseOwnXYZCalculation(kTRUE);
58                 fV0ReaderV1->SetCreateAODs(kFALSE);// AOD Output
59                 fV0ReaderV1->SetUseAODConversionPhoton(kTRUE);
60
61                 if (!mgr) {
62                         Error("AddTask_V0ReaderV1", "No analysis manager found.");
63                         return;
64                 }
65
66                 AliConvEventCuts *fEventCuts=NULL;
67                 if(cutnumberEvent!=""){
68                         fEventCuts= new AliConvEventCuts(cutnumberEvent.Data(),cutnumberEvent.Data());
69                         fEventCuts->SetPreSelectionCutFlag(kTRUE);
70                         if(fEventCuts->InitializeCutsFromCutString(cutnumberEvent.Data())){
71                                 fV0ReaderV1->SetEventCuts(fEventCuts);
72                                 fEventCuts->SetFillCutHistograms("",kTRUE);
73                         }
74                 }
75
76                 // Set AnalysisCut Number
77                 AliConversionPhotonCuts *fCuts=NULL;
78                 if(cutnumberPhoton!=""){
79                         fCuts= new AliConversionPhotonCuts(cutnumberPhoton.Data(),cutnumberPhoton.Data());
80                         fCuts->SetPreSelectionCutFlag(kTRUE);
81                         fCuts->SetIsHeavyIon(isHeavyIon);
82                         if(fCuts->InitializeCutsFromCutString(cutnumberPhoton.Data())){
83                                 fV0ReaderV1->SetConversionCuts(fCuts);
84                                 fCuts->SetFillCutHistograms("",kTRUE);
85                         }
86                 }
87                 
88                 if(inputHandler->IsA()==AliAODInputHandler::Class()){
89                 // AOD mode
90                         fV0ReaderV1->SetDeltaAODBranchName(Form("GammaConv_%s_gamma",cutnumberAODBranch.Data()));
91                 }
92                 fV0ReaderV1->Init();
93
94                 AliLog::SetGlobalLogLevel(AliLog::kInfo);
95
96                 //connect input V0Reader
97                 mgr->AddTask(fV0ReaderV1);
98                 mgr->ConnectInput(fV0ReaderV1,0,cinput);
99
100         }
101
102         //================================================
103         //========= Add task to the ANALYSIS manager =====
104         //================================================
105         AliAnalysisTaskGammaConvV1 *task=NULL;
106         task= new AliAnalysisTaskGammaConvV1(Form("GammaConvV1_%i",trainConfig));
107         task->SetIsHeavyIon(isHeavyIon);
108         task->SetIsMC(isMC);
109         // Cut Numbers to use in Analysis
110         Int_t numberOfCuts = 1;
111
112         TString *eventCutArray = new TString[numberOfCuts];
113         TString *photonCutArray = new TString[numberOfCuts];
114         TString *mesonCutArray = new TString[numberOfCuts];
115
116         if (trainConfig == 1){ 
117                 eventCutArray[ 0] = "6010001"; photonCutArray[ 0] = "042000092970023220000000"; mesonCutArray[ 0] = "01522045009000"; 
118         } else if (trainConfig == 2) { 
119                 eventCutArray[ 0] = "6120001"; photonCutArray[ 0] = "042000092970023220000000"; mesonCutArray[ 0] = "01522045009000"; 
120         } else if (trainConfig == 3) { 
121                 eventCutArray[ 0] = "5010001"; photonCutArray[ 0] = "042000092970023220000000"; mesonCutArray[ 0] = "01522045009000"; 
122         } else if (trainConfig == 4) { 
123                 eventCutArray[ 0] = "5020001"; photonCutArray[ 0] = "042000092970023220000000"; mesonCutArray[ 0] = "01522045009000";    
124         } else if (trainConfig == 5) { 
125                 eventCutArray[ 0] = "5120001"; photonCutArray[ 0] = "042000092970023220000000"; mesonCutArray[ 0] = "01522045009000";    
126         } else if (trainConfig == 6) { 
127                 eventCutArray[ 0] = "5240001"; photonCutArray[ 0] = "042000092970023220000000"; mesonCutArray[ 0] = "01522045009000";       
128         } else if (trainConfig == 7) {    
129                 eventCutArray[ 0] = "5460001"; photonCutArray[ 0] = "042000092970023220000000"; mesonCutArray[ 0] = "01522065009000"; 
130         } else if (trainConfig == 8) {    
131                 eventCutArray[ 0] = "5480001"; photonCutArray[ 0] = "042000092970023220000000"; mesonCutArray[ 0] = "01522065009000";    
132         } else if (trainConfig == 9) {    
133                 eventCutArray[ 0] = "5450001"; photonCutArray[ 0] = "042000092970023220000000"; mesonCutArray[ 0] = "01522065009000"; 
134         } else if (trainConfig == 10) { 
135                 eventCutArray[ 0] = "5560001"; photonCutArray[ 0] = "042000092970023220000000"; mesonCutArray[ 0] = "01522065009000";
136         } else if (trainConfig == 11) { 
137                 eventCutArray[ 0] = "5680001"; photonCutArray[ 0] = "042000092970023220000000"; mesonCutArray[ 0] = "01522065009000";    
138         } else if (trainConfig == 12) { 
139                 eventCutArray[ 0] = "5670001"; photonCutArray[ 0] = "042000092970023220000000"; mesonCutArray[ 0] = "01522065009000"; 
140         } else if (trainConfig == 13) { 
141                 eventCutArray[ 0] = "5780001"; photonCutArray[ 0] = "042000092970023220000000"; mesonCutArray[ 0] = "01522065009000"; 
142         } else if (trainConfig == 14) { 
143                 eventCutArray[ 0] = "4690001"; photonCutArray[ 0] = "042000092970023220000000"; mesonCutArray[ 0] = "01522065009000";
144         } else if (trainConfig == 15) { 
145                 eventCutArray[ 0] = "5890001"; photonCutArray[ 0] = "042000092970023220000000"; mesonCutArray[ 0] = "01522065009000";    
146         } else  if (trainConfig == 16){ 
147                 eventCutArray[ 0] = "6010001"; photonCutArray[ 0] = "002000092970028250400000"; mesonCutArray[ 0] = "01525065000000"; 
148         } else if (trainConfig == 17) { 
149                 eventCutArray[ 0] = "6120001"; photonCutArray[ 0] = "002000092970028250400000"; mesonCutArray[ 0] = "01525065000000"; 
150         } else if (trainConfig == 18) { 
151                 eventCutArray[ 0] = "5010001"; photonCutArray[ 0] = "002000092970028250400000"; mesonCutArray[ 0] = "01525065000000"; 
152         } else if (trainConfig == 19) { 
153                 eventCutArray[ 0] = "5020001"; photonCutArray[ 0] = "002000092970028250400000"; mesonCutArray[ 0] = "01525065000000";    
154         } else if (trainConfig == 20) { 
155                 eventCutArray[ 0] = "5120001"; photonCutArray[ 0] = "002000092970028250400000"; mesonCutArray[ 0] = "01525065000000";    
156         } else if (trainConfig == 21) { 
157                 eventCutArray[ 0] = "5240001"; photonCutArray[ 0] = "002000092970028250400000"; mesonCutArray[ 0] = "01525065000000";       
158         } else if (trainConfig == 22) {    
159                 eventCutArray[ 0] = "5460001"; photonCutArray[ 0] = "002000092970028250400000"; mesonCutArray[ 0] = "01525065000000"; 
160         } else if (trainConfig == 23) {    
161                 eventCutArray[ 0] = "5480001"; photonCutArray[ 0] = "002000092970028250400000"; mesonCutArray[ 0] = "01525065000000";    
162         } else if (trainConfig == 24) {    
163                 eventCutArray[ 0] = "5450001"; photonCutArray[ 0] = "002000092970028250400000"; mesonCutArray[ 0] = "01525065000000"; 
164         } else if (trainConfig == 25) { 
165                 eventCutArray[ 0] = "5560001"; photonCutArray[ 0] = "002000092970028250400000"; mesonCutArray[ 0] = "01525065000000";
166         } else if (trainConfig == 26) { 
167                 eventCutArray[ 0] = "5680001"; photonCutArray[ 0] = "002000092970028250400000"; mesonCutArray[ 0] = "01525065000000";    
168         } else if (trainConfig == 27) { 
169                 eventCutArray[ 0] = "5670001"; photonCutArray[ 0] = "002000092970028250400000"; mesonCutArray[ 0] = "01525065000000"; 
170         } else if (trainConfig == 28) { 
171                 eventCutArray[ 0] = "5780001"; photonCutArray[ 0] = "002000092970028250400000"; mesonCutArray[ 0] = "01525065000000"; 
172         } else if (trainConfig == 29) { 
173                 eventCutArray[ 0] = "4690001"; photonCutArray[ 0] = "002000092970028250400000"; mesonCutArray[ 0] = "01525065000000";
174         } else if (trainConfig == 30) { 
175                 eventCutArray[ 0] = "5890001"; photonCutArray[ 0] = "002000092970028250400000"; mesonCutArray[ 0] = "01525065000000";    
176         } else if (trainConfig == 31) { 
177                 eventCutArray[ 0] = "5080001"; photonCutArray[ 0] = "002000092970028250400000"; mesonCutArray[ 0] = "01525065000000";    
178         } else if (trainConfig == 32) { 
179                 eventCutArray[ 0] = "5250001"; photonCutArray[ 0] = "002000092970028250400000"; mesonCutArray[ 0] = "01525065000000";       
180         } else if (trainConfig == 33) { 
181                 eventCutArray[ 0] = "5350001"; photonCutArray[ 0] = "002000092970028250400000"; mesonCutArray[ 0] = "01525065000000";       
182         } else if (trainConfig == 34) { 
183                 eventCutArray[ 0] = "5450001"; photonCutArray[ 0] = "002000092970028250400000"; mesonCutArray[ 0] = "01525065000000";       
184         } else if (trainConfig == 35) { 
185                 eventCutArray[ 0] = "5340001"; photonCutArray[ 0] = "002000092970028250400000"; mesonCutArray[ 0] = "01525065000000";       
186         } else if (trainConfig == 36) { 
187                 eventCutArray[ 0] = "5230001"; photonCutArray[ 0] = "002000092970028250400000"; mesonCutArray[ 0] = "01525065000000";       
188         } else {
189                 Error(Form("GammaConvV1_%i",trainConfig), "wrong trainConfig variable no cuts have been specified for the configuration");
190                 return;
191         }
192
193         TList *EventCutList = new TList();
194         TList *ConvCutList = new TList();
195         TList *MesonCutList = new TList();
196
197         TList *HeaderList = new TList();
198         TObjString *Header1 = new TObjString("BOX");
199         HeaderList->Add(Header1);
200         //    TObjString *Header3 = new TObjString("eta_2");
201         //    HeaderList->Add(Header3);
202         
203         EventCutList->SetOwner(kTRUE);
204         AliConvEventCuts **analysisEventCuts = new AliConvEventCuts*[numberOfCuts];
205         ConvCutList->SetOwner(kTRUE);
206         AliConversionPhotonCuts **analysisCuts = new AliConversionPhotonCuts*[numberOfCuts];
207         MesonCutList->SetOwner(kTRUE);
208         AliConversionMesonCuts **analysisMesonCuts = new AliConversionMesonCuts*[numberOfCuts];
209
210         for(Int_t i = 0; i<numberOfCuts; i++){
211                 analysisEventCuts[i] = new AliConvEventCuts();
212                 analysisEventCuts[i]->InitializeCutsFromCutString(eventCutArray[i].Data());
213                 EventCutList->Add(analysisEventCuts[i]);
214                 analysisEventCuts[i]->SetFillCutHistograms("",kFALSE);
215                 
216                 analysisCuts[i] = new AliConversionPhotonCuts();
217                 analysisCuts[i]->InitializeCutsFromCutString(photonCutArray[i].Data());
218                 ConvCutList->Add(analysisCuts[i]);
219                 analysisCuts[i]->SetFillCutHistograms("",kFALSE);
220
221                 analysisMesonCuts[i] = new AliConversionMesonCuts();
222                 analysisMesonCuts[i]->InitializeCutsFromCutString(mesonCutArray[i].Data());
223                 MesonCutList->Add(analysisMesonCuts[i]);
224                 analysisMesonCuts[i]->SetFillCutHistograms("");
225                 
226                 analysisEventCuts[i]->SetAcceptedHeader(HeaderList);
227         }
228
229         task->SetEventCutList(numberOfCuts,EventCutList);
230         task->SetConversionCutList(numberOfCuts,ConvCutList);
231         task->SetMesonCutList(numberOfCuts,MesonCutList);
232         task->SetMoveParticleAccordingToVertex(kTRUE);
233         task->SetDoMesonAnalysis(kTRUE);
234         task->SetDoMesonQA(enableQAMesonTask); //Attention new switch for Pi0 QA
235         task->SetDoPhotonQA(enableQAPhotonTask);  //Attention new switch small for Photon QA
236
237         //connect containers
238         AliAnalysisDataContainer *coutput =
239                 mgr->CreateContainer(Form("GammaConvV1_%i",trainConfig), TList::Class(),
240                                                         AliAnalysisManager::kOutputContainer,Form("GammaConvV1_%i.root",trainConfig));
241
242         mgr->AddTask(task);
243         mgr->ConnectInput(task,0,cinput);
244         mgr->ConnectOutput(task,1,coutput);
245
246         return;
247
248 }