added libraries to AddTask in order to include flow package
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / macros / AddTask_GammaConvCalo_pPb.C
1 void AddTask_GammaConvCalo_pPb(  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 doWeightingPart = 0,  //enable Weighting
7                               TString generatorName = "DPMJET",
8                               TString cutnumberAODBranch = "8000000060084000001500000", // cutnumber for AOD branch
9                               Bool_t enableExtendedMatching = kFALSE //enable or disable extended matching histograms for conversion electrons <-> cluster
10                                                         ) {
11
12         // ================= Load Librariers =================================
13         gSystem->Load("libCore.so");  
14         gSystem->Load("libTree.so");
15         gSystem->Load("libGeom.so");
16         gSystem->Load("libVMC.so");
17         gSystem->Load("libPhysics.so");
18         gSystem->Load("libMinuit");
19         gSystem->Load("libSTEERBase");
20         gSystem->Load("libESD");
21         gSystem->Load("libAOD");
22         gSystem->Load("libANALYSIS");
23         gSystem->Load("libANALYSISalice");  
24         gSystem->Load("libCDB.so");
25         gSystem->Load("libSTEER.so");
26         gSystem->Load("libSTEERBase.so");
27         gSystem->Load("libTENDER.so");
28         gSystem->Load("libTENDERSupplies.so");
29         gSystem->Load("libPWGflowBase.so");
30         gSystem->Load("libPWGflowTasks.so");
31         gSystem->Load("libPWGGAGammaConv.so");
32
33         Int_t isHeavyIon = 2;
34         
35         // ================== GetAnalysisManager ===============================
36         AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
37         if (!mgr) {
38                 Error(Form("AddTask_GammaConvV1_%i",trainConfig), "No analysis manager found.");
39                 return ;
40         }
41
42         // ================== GetInputEventHandler =============================
43         AliVEventHandler *inputHandler=mgr->GetInputEventHandler();
44         
45         //========= Add PID Reponse to ANALYSIS manager ====
46         if(!(AliPIDResponse*)mgr->GetTask("PIDResponseTask")){
47                 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
48                 AddTaskPIDResponse(isMC);
49         }
50         
51         Printf("here \n");
52         
53         //=========  Set Cutnumber for V0Reader ================================
54         TString cutnumberPhoton = "060084001001500000000";
55         TString cutnumberEvent = "8000000";
56         Bool_t doEtaShift = kFALSE;
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                 if(inputHandler->IsA()==AliAODInputHandler::Class()){
95                 // AOD mode
96                         fV0ReaderV1->SetDeltaAODBranchName(Form("GammaConv_%s_gamma",cutnumberAODBranch.Data()));
97                 }
98                 fV0ReaderV1->Init();
99
100                 AliLog::SetGlobalLogLevel(AliLog::kFatal);
101
102                 //connect input V0Reader
103                 mgr->AddTask(fV0ReaderV1);
104                 mgr->ConnectInput(fV0ReaderV1,0,cinput);
105
106         }
107
108         //================================================
109         //========= Add task to the ANALYSIS manager =====
110         //================================================
111         AliAnalysisTaskGammaConvCalo *task=NULL;
112         task= new AliAnalysisTaskGammaConvCalo(Form("GammaConvCalo_%i",trainConfig));
113         task->SetIsHeavyIon(isHeavyIon);
114         task->SetIsMC(isMC);
115         // Cut Numbers to use in Analysis
116         Int_t numberOfCuts = 2;
117         if (trainConfig==3 || trainConfig==5  ){ numberOfCuts =6;}
118         if (trainConfig==6 || trainConfig==7  ){ numberOfCuts =5;}
119         
120         TString *eventCutArray = new TString[numberOfCuts];
121         TString *photonCutArray = new TString[numberOfCuts];
122         TString *clusterCutArray = new TString[numberOfCuts];
123         TString *mesonCutArray = new TString[numberOfCuts];
124
125         // cluster cuts
126         // 0 "ClusterType",  1 "EtaMin", 2 "EtaMax", 3 "PhiMin", 4 "PhiMax", 5 "DistanceToBadChannel", 6 "Timing", 7 "TrackMatching", 8 "ExoticCell",
127         // 9 "MinEnergy", 10 "MinNCells", 11 "MinM02", 12 "MaxM02", 13 "MinM20", 14 "MaxM20", 15 "MaximumDispersion", 16 "NLM"
128         
129         if (trainConfig == 1){ 
130                 eventCutArray[ 0] = "8000001"; photonCutArray[ 0] = "002092970028250400000"; clusterCutArray[0] = "10000041022030000"; mesonCutArray[0] = "01525065000000"; //standart cut, kINT7 // EMCAL clusters
131                 eventCutArray[ 1] = "8005201"; photonCutArray[ 1] = "002092970028250400000"; clusterCutArray[1] = "10000041022030000"; mesonCutArray[1] = "01525065000000"; //standard cut, kEMC7 // EMCAL clusters
132         } else if (trainConfig == 2) {  
133                 eventCutArray[ 0] = "8000001"; photonCutArray[ 0] = "002092970028250400000"; clusterCutArray[0] = "20000031022000000"; mesonCutArray[0] = "01525065000000"; //standart cut, kINT7 // PHOS clusters
134                 eventCutArray[ 1] = "8006201"; photonCutArray[ 1] = "002092970028250400000"; clusterCutArray[1] = "20000031022000000"; mesonCutArray[1] = "01525065000000"; //standard cut, kPHI7       // PHOS clusters        
135         } else if (trainConfig == 3){ 
136                 eventCutArray[ 0] = "8008101"; photonCutArray[ 0] = "002092970028250400000"; clusterCutArray[0] = "10000041022030000"; mesonCutArray[0] = "01525065000000"; //standart cut, kEMCEGA based on INT7 // EMCAL clusters
137                 eventCutArray[ 1] = "8008301"; photonCutArray[ 1] = "002092970028250400000"; clusterCutArray[1] = "10000041022030000"; mesonCutArray[1] = "01525065000000"; //standard cut, kEMCEG1 based on INT7 // EMCAL clusters
138                 eventCutArray[ 2] = "8008501"; photonCutArray[ 2] = "002092970028250400000"; clusterCutArray[2] = "10000041022030000"; mesonCutArray[2] = "01525065000000"; //standard cut, kEMCEG2 based on INT7 // EMCAL clusters
139                 eventCutArray[ 3] = "8009101"; photonCutArray[ 3] = "002092970028250400000"; clusterCutArray[3] = "10000041022030000"; mesonCutArray[3] = "01525065000000"; //standard cut, kEMCEJE based on INT7 // EMCAL clusters
140                 eventCutArray[ 4] = "8009301"; photonCutArray[ 4] = "002092970028250400000"; clusterCutArray[4] = "10000041022030000"; mesonCutArray[4] = "01525065000000"; //standard cut, kEMCEJ1 based on INT7 // EMCAL clusters
141                 eventCutArray[ 5] = "8009501"; photonCutArray[ 5] = "002092970028250400000"; clusterCutArray[5] = "10000041022030000"; mesonCutArray[5] = "01525065000000"; //standard cut, kEMCEG2 based on INT7 // EMCAL clusters
142         } else if (trainConfig == 4){ 
143                 eventCutArray[ 0] = "8000001"; photonCutArray[ 0] = "002092970028250400000"; clusterCutArray[0] = "10000041052030000"; mesonCutArray[0] = "01525065000000"; //standart cut, kINT7 // EMCAL clusters
144                 eventCutArray[ 1] = "8005201"; photonCutArray[ 1] = "002092970028250400000"; clusterCutArray[1] = "10000041052030000"; mesonCutArray[1] = "01525065000000"; //standard cut, kEMC7 // EMCAL clusters     
145         } else if (trainConfig == 5){ 
146                 eventCutArray[ 0] = "8008101"; photonCutArray[ 0] = "002092970028250400000"; clusterCutArray[0] = "10000041052030000"; mesonCutArray[0] = "01525065000000"; //standart cut, kEMCEGA based on INT7 // EMCAL clusters
147                 eventCutArray[ 1] = "8008301"; photonCutArray[ 1] = "002092970028250400000"; clusterCutArray[1] = "10000041052030000"; mesonCutArray[1] = "01525065000000"; //standard cut, kEMCEG1 based on INT7 // EMCAL clusters
148                 eventCutArray[ 2] = "8008501"; photonCutArray[ 2] = "002092970028250400000"; clusterCutArray[2] = "10000041052030000"; mesonCutArray[2] = "01525065000000"; //standard cut, kEMCEG2 based on INT7 // EMCAL clusters
149                 eventCutArray[ 3] = "8009101"; photonCutArray[ 3] = "002092970028250400000"; clusterCutArray[3] = "10000041052030000"; mesonCutArray[3] = "01525065000000"; //standard cut, kEMCEJE based on INT7 // EMCAL clusters
150                 eventCutArray[ 4] = "8009301"; photonCutArray[ 4] = "002092970028250400000"; clusterCutArray[4] = "10000041052030000"; mesonCutArray[4] = "01525065000000"; //standard cut, kEMCEJ1 based on INT7 // EMCAL clusters
151                 eventCutArray[ 5] = "8009501"; photonCutArray[ 5] = "002092970028250400000"; clusterCutArray[5] = "10000041052030000"; mesonCutArray[5] = "01525065000000"; //standard cut, kEMCEG2 based on INT7 // EMCAL clusters             
152         } else if (trainConfig == 6){ //EMCAL
153                 eventCutArray[ 0] = "8000001"; photonCutArray[ 0] = "002092970028250400000"; clusterCutArray[0] = "10000041052030000"; mesonCutArray[0] = "01525065000000"; 
154                 eventCutArray[ 1] = "8000001"; photonCutArray[ 1] = "002092970028250400000"; clusterCutArray[1] = "10000042052030000"; mesonCutArray[1] = "01525065000000"; 
155                 eventCutArray[ 2] = "8000001"; photonCutArray[ 2] = "002092970028250400000"; clusterCutArray[2] = "10000043052030000"; mesonCutArray[2] = "01525065000000"; 
156                 eventCutArray[ 3] = "8000001"; photonCutArray[ 3] = "002092970028250400000"; clusterCutArray[3] = "10000044052030000"; mesonCutArray[3] = "01525065000000"; 
157                 eventCutArray[ 4] = "8000001"; photonCutArray[ 4] = "002092970028250400000"; clusterCutArray[4] = "10000045052030000"; mesonCutArray[4] = "01525065000000"; 
158         } else if (trainConfig == 7) { //PHOS
159                 eventCutArray[ 0] = "8000001"; photonCutArray[ 0] = "002092970028250400000"; clusterCutArray[0] = "20000041053200000"; mesonCutArray[0] = "01525065000000"; 
160                 eventCutArray[ 1] = "8000001"; photonCutArray[ 1] = "002092970028250400000"; clusterCutArray[1] = "20000042053200000"; mesonCutArray[1] = "01525065000000"; 
161                 eventCutArray[ 2] = "8000001"; photonCutArray[ 2] = "002092970028250400000"; clusterCutArray[2] = "20000043053200000"; mesonCutArray[2] = "01525065000000"; 
162                 eventCutArray[ 3] = "8000001"; photonCutArray[ 3] = "002092970028250400000"; clusterCutArray[3] = "20000044053200000"; mesonCutArray[3] = "01525065000000"; 
163                 eventCutArray[ 4] = "8000001"; photonCutArray[ 4] = "002092970028250400000"; clusterCutArray[4] = "20000045053200000"; mesonCutArray[4] = "01525065000000"; 
164         } else {
165                 Error(Form("GammaConvCalo_%i",trainConfig), "wrong trainConfig variable no cuts have been specified for the configuration");
166                 return;
167         }
168
169         TList *EventCutList = new TList();
170         TList *ConvCutList = new TList();
171         TList *ClusterCutList = new TList();
172         TList *MesonCutList = new TList();
173
174         TList *HeaderList = new TList();
175         if (doWeightingPart==1) {
176                 TObjString *Header1 = new TObjString("pi0_1");
177                 HeaderList->Add(Header1);
178         }
179         if (doWeightingPart==2){
180                 TObjString *Header3 = new TObjString("eta_2");
181                 HeaderList->Add(Header3);
182         }
183         if (doWeightingPart==3) {
184                 TObjString *Header1 = new TObjString("pi0_1");
185                 HeaderList->Add(Header1);
186                 TObjString *Header3 = new TObjString("eta_2");
187                 HeaderList->Add(Header3);
188         }
189
190         EventCutList->SetOwner(kTRUE);
191         AliConvEventCuts **analysisEventCuts = new AliConvEventCuts*[numberOfCuts];
192         ConvCutList->SetOwner(kTRUE);
193         AliConversionPhotonCuts **analysisCuts = new AliConversionPhotonCuts*[numberOfCuts];
194         ClusterCutList->SetOwner(kTRUE);
195         AliCaloPhotonCuts **analysisClusterCuts = new AliCaloPhotonCuts*[numberOfCuts];
196         MesonCutList->SetOwner(kTRUE);
197         AliConversionMesonCuts **analysisMesonCuts = new AliConversionMesonCuts*[numberOfCuts];
198
199         for(Int_t i = 0; i<numberOfCuts; i++){
200                 analysisEventCuts[i] = new AliConvEventCuts();   
201                 analysisEventCuts[i]->InitializeCutsFromCutString(eventCutArray[i].Data());
202                 EventCutList->Add(analysisEventCuts[i]);
203                 analysisEventCuts[i]->SetFillCutHistograms("",kFALSE);
204                 
205                 analysisCuts[i] = new AliConversionPhotonCuts();
206                 analysisCuts[i]->InitializeCutsFromCutString(photonCutArray[i].Data());
207                 analysisCuts[i]->SetIsHeavyIon(isHeavyIon);
208                 ConvCutList->Add(analysisCuts[i]);
209                 analysisCuts[i]->SetFillCutHistograms("",kFALSE);
210         
211                 analysisClusterCuts[i] = new AliCaloPhotonCuts();
212                 analysisClusterCuts[i]->InitializeCutsFromCutString(clusterCutArray[i].Data());
213                 ClusterCutList->Add(analysisClusterCuts[i]);
214         analysisClusterCuts[i]->SetExtendedMatching(enableExtendedMatching);
215                 analysisClusterCuts[i]->SetFillCutHistograms("");
216                 
217                 analysisMesonCuts[i] = new AliConversionMesonCuts();
218                 analysisMesonCuts[i]->InitializeCutsFromCutString(mesonCutArray[i].Data());
219                 MesonCutList->Add(analysisMesonCuts[i]);
220                 analysisMesonCuts[i]->SetFillCutHistograms("");
221                 analysisEventCuts[i]->SetAcceptedHeader(HeaderList);
222         }
223
224         task->SetEventCutList(numberOfCuts,EventCutList);
225         task->SetConversionCutList(numberOfCuts,ConvCutList);
226         task->SetCaloCutList(numberOfCuts,ClusterCutList);
227         task->SetMesonCutList(numberOfCuts,MesonCutList);
228         task->SetMoveParticleAccordingToVertex(kTRUE);
229         task->SetDoMesonAnalysis(kTRUE);
230         task->SetDoMesonQA(enableQAMesonTask); //Attention new switch for Pi0 QA
231         task->SetDoPhotonQA(enableQAPhotonTask);  //Attention new switch small for Photon QA
232         task->SetDoClusterQA(1);  //Attention new switch small for Cluster QA
233
234         //connect containers
235         AliAnalysisDataContainer *coutput =
236                 mgr->CreateContainer(Form("GammaConvCalo_%i",trainConfig), TList::Class(),
237                                                         AliAnalysisManager::kOutputContainer,Form("GammaConvCalo_%i.root",trainConfig));
238
239         mgr->AddTask(task);
240         mgr->ConnectInput(task,0,cinput);
241         mgr->ConnectOutput(task,1,coutput);
242
243         return;
244
245 }