TENDER becomes Tender, removing .so
[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");  
14         gSystem->Load("libTree");
15         gSystem->Load("libGeom");
16         gSystem->Load("libVMC");
17         gSystem->Load("libPhysics");
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");
25         gSystem->Load("libSTEER");
26         gSystem->Load("libSTEERBase");
27         gSystem->Load("libTender");
28         gSystem->Load("libTenderSupplies");
29         gSystem->Load("libPWGflowBase");
30         gSystem->Load("libPWGflowTasks");
31         gSystem->Load("libPWGGAGammaConv");
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 = "060000084001001500000000";
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==10 ){ numberOfCuts =4;}
118         if (trainConfig==2 || trainConfig==4  ){ numberOfCuts =6;}
119         if (trainConfig==5 || trainConfig==6 || trainConfig==7 || trainConfig==8 || trainConfig==32 || trainConfig==33){ numberOfCuts =5;}
120         
121         TString *eventCutArray = new TString[numberOfCuts];
122         TString *photonCutArray = new TString[numberOfCuts];
123         TString *clusterCutArray = new TString[numberOfCuts];
124         TString *mesonCutArray = new TString[numberOfCuts];
125
126         // cluster cuts
127         // 0 "ClusterType",  1 "EtaMin", 2 "EtaMax", 3 "PhiMin", 4 "PhiMax", 5 "DistanceToBadChannel", 6 "Timing", 7 "TrackMatching", 8 "ExoticCell",
128         // 9 "MinEnergy", 10 "MinNCells", 11 "MinM02", 12 "MaxM02", 13 "MinM20", 14 "MaxM20", 15 "MaximumDispersion", 16 "NLM"
129         
130         //************************************************ EMCAL clusters **********************************************************
131         if (trainConfig == 1){ // min energy = 0.3 GeV/c
132                 eventCutArray[ 0] = "8000001"; photonCutArray[ 0] = "002000093270028250400000"; clusterCutArray[0] = "10000042022030000"; mesonCutArray[0] = "01631031000000"; //standart cut, kINT7 
133                 eventCutArray[ 1] = "8005201"; photonCutArray[ 1] = "002000093270028250400000"; clusterCutArray[1] = "10000042022030000"; mesonCutArray[1] = "01631031000000"; //standard cut, kEMC7 
134         } else if (trainConfig == 2){  // min energy = 0.3 GeV/c
135                 eventCutArray[ 0] = "8008101"; photonCutArray[ 0] = "002000093270028250400000"; clusterCutArray[0] = "10000042022030000"; mesonCutArray[0] = "01631031000000"; //standart cut, kEMCEGA based on INT7 
136                 eventCutArray[ 1] = "8008301"; photonCutArray[ 1] = "002000093270028250400000"; clusterCutArray[1] = "10000042022030000"; mesonCutArray[1] = "01631031000000"; //standard cut, kEMCEG1 based on INT7 
137                 eventCutArray[ 2] = "8008501"; photonCutArray[ 2] = "002000093270028250400000"; clusterCutArray[2] = "10000042022030000"; mesonCutArray[2] = "01631031000000"; //standard cut, kEMCEG2 based on INT7 
138                 eventCutArray[ 3] = "8009101"; photonCutArray[ 3] = "002000093270028250400000"; clusterCutArray[3] = "10000042022030000"; mesonCutArray[3] = "01631031000000"; //standard cut, kEMCEJE based on INT7 
139                 eventCutArray[ 4] = "8009301"; photonCutArray[ 4] = "002000093270028250400000"; clusterCutArray[4] = "10000042022030000"; mesonCutArray[4] = "01631031000000"; //standard cut, kEMCEJ1 based on INT7 
140                 eventCutArray[ 5] = "8009501"; photonCutArray[ 5] = "002000093270028250400000"; clusterCutArray[5] = "10000042022030000"; mesonCutArray[5] = "01631031000000"; //standard cut, kEMCEG2 based on INT7 
141         } else if (trainConfig == 3){ // min energy = 0.4 GeV/c
142                 eventCutArray[ 0] = "8000001"; photonCutArray[ 0] = "002000093270028250400000"; clusterCutArray[0] = "10000042032030000"; mesonCutArray[0] = "01631031000000"; //standart cut, kINT7 
143                 eventCutArray[ 1] = "8005201"; photonCutArray[ 1] = "002000093270028250400000"; clusterCutArray[1] = "10000042032030000"; mesonCutArray[1] = "01631031000000"; //standard cut, kEMC7    
144         } else if (trainConfig == 4){ // min energy = 0.4 GeV/c
145                 eventCutArray[ 0] = "8008101"; photonCutArray[ 0] = "002000093270028250400000"; clusterCutArray[0] = "10000042032030000"; mesonCutArray[0] = "01631031000000"; //standart cut, kEMCEGA based on INT7 
146                 eventCutArray[ 1] = "8008301"; photonCutArray[ 1] = "002000093270028250400000"; clusterCutArray[1] = "10000042032030000"; mesonCutArray[1] = "01631031000000"; //standard cut, kEMCEG1 based on INT7 
147                 eventCutArray[ 2] = "8008501"; photonCutArray[ 2] = "002000093270028250400000"; clusterCutArray[2] = "10000042032030000"; mesonCutArray[2] = "01631031000000"; //standard cut, kEMCEG2 based on INT7 
148                 eventCutArray[ 3] = "8009101"; photonCutArray[ 3] = "002000093270028250400000"; clusterCutArray[3] = "10000042032030000"; mesonCutArray[3] = "01631031000000"; //standard cut, kEMCEJE based on INT7 
149                 eventCutArray[ 4] = "8009301"; photonCutArray[ 4] = "002000093270028250400000"; clusterCutArray[4] = "10000042032030000"; mesonCutArray[4] = "01631031000000"; //standard cut, kEMCEJ1 based on INT7 
150                 eventCutArray[ 5] = "8009501"; photonCutArray[ 5] = "002000093270028250400000"; clusterCutArray[5] = "10000042032030000"; mesonCutArray[5] = "01631031000000"; //standard cut, kEMCEG2 based on INT7
151         } else if (trainConfig == 5){ //EMCAL variation of track matching
152                 eventCutArray[ 0] = "8000001"; photonCutArray[ 0] = "002000093270028250400000"; clusterCutArray[0] = "10000041032030000"; mesonCutArray[0] = "01631031000000"; // 
153                 eventCutArray[ 1] = "8000001"; photonCutArray[ 1] = "002000093270028250400000"; clusterCutArray[1] = "10000042032030000"; mesonCutArray[1] = "01631031000000"; 
154                 eventCutArray[ 2] = "8000001"; photonCutArray[ 2] = "002000093270028250400000"; clusterCutArray[2] = "10000043032030000"; mesonCutArray[2] = "01631031000000"; 
155                 eventCutArray[ 3] = "8000001"; photonCutArray[ 3] = "002000093270028250400000"; clusterCutArray[3] = "10000044032030000"; mesonCutArray[3] = "01631031000000"; 
156                 eventCutArray[ 4] = "8000001"; photonCutArray[ 4] = "002000093270028250400000"; clusterCutArray[4] = "10000045032030000"; mesonCutArray[4] = "01631031000000"; 
157         } else if (trainConfig == 6){ //EMCAL added signal
158                 eventCutArray[ 0] = "8000002"; photonCutArray[ 0] = "002000093270028250400000"; clusterCutArray[0] = "10000041032030000"; mesonCutArray[0] = "01631031000000"; 
159                 eventCutArray[ 1] = "8000002"; photonCutArray[ 1] = "002000093270028250400000"; clusterCutArray[1] = "10000042032030000"; mesonCutArray[1] = "01631031000000"; 
160                 eventCutArray[ 2] = "8000002"; photonCutArray[ 2] = "002000093270028250400000"; clusterCutArray[2] = "10000043032030000"; mesonCutArray[2] = "01631031000000"; 
161                 eventCutArray[ 3] = "8000002"; photonCutArray[ 3] = "002000093270028250400000"; clusterCutArray[3] = "10000044032030000"; mesonCutArray[3] = "01631031000000"; 
162                 eventCutArray[ 4] = "8000002"; photonCutArray[ 4] = "002000093270028250400000"; clusterCutArray[4] = "10000045032030000"; mesonCutArray[4] = "01631031000000"; 
163         } else if (trainConfig == 7){ //EMCAL minEnergy variation
164                 eventCutArray[ 0] = "8000001"; photonCutArray[ 0] = "002000093270028250400000"; clusterCutArray[0] = "10000042012030000"; mesonCutArray[0] = "01631031000000"; //0.2 GeV/c
165                 eventCutArray[ 1] = "8000001"; photonCutArray[ 1] = "002000093270028250400000"; clusterCutArray[1] = "10000042022030000"; mesonCutArray[1] = "01631031000000"; //0.3 GeV/c
166                 eventCutArray[ 2] = "8000001"; photonCutArray[ 2] = "002000093270028250400000"; clusterCutArray[2] = "10000042032030000"; mesonCutArray[2] = "01631031000000"; //0.4 GeV/c default
167                 eventCutArray[ 3] = "8000001"; photonCutArray[ 3] = "002000093270028250400000"; clusterCutArray[3] = "10000042042030000"; mesonCutArray[3] = "01631031000000"; //0.5 GeV/c
168                 eventCutArray[ 4] = "8000001"; photonCutArray[ 4] = "002000093270028250400000"; clusterCutArray[4] = "10000042052030000"; mesonCutArray[4] = "01631031000000"; //0.6 GeV/c
169         } else if (trainConfig == 8){ //EMCAL minNCells variation
170                 eventCutArray[ 0] = "8000001"; photonCutArray[ 0] = "002000093270028250400000"; clusterCutArray[0] = "10000042031030000"; mesonCutArray[0] = "01631031000000"; //n cells >= 1
171                 eventCutArray[ 1] = "8000001"; photonCutArray[ 1] = "002000093270028250400000"; clusterCutArray[1] = "10000042033030000"; mesonCutArray[1] = "01631031000000"; //n cells >= 3
172                 eventCutArray[ 2] = "8000001"; photonCutArray[ 2] = "002000093270028250400000"; clusterCutArray[2] = "10000042032000000"; mesonCutArray[2] = "01631031000000"; //no M02 cut
173                 eventCutArray[ 3] = "8000001"; photonCutArray[ 3] = "002000093270028250400000"; clusterCutArray[3] = "10021042032030000"; mesonCutArray[3] = "01631031000000"; //only modules with TRD infront
174                 eventCutArray[ 4] = "8000001"; photonCutArray[ 4] = "002000093270028250400000"; clusterCutArray[4] = "10013042032030000"; mesonCutArray[4] = "01631031000000"; //no modules with TRD infront            
175         } else if (trainConfig == 9){ //PCM restriction in acceptance 
176                 eventCutArray[ 0] = "8000001"; photonCutArray[ 0] = "002022093270028250400000"; clusterCutArray[0] = "10000042032030000"; mesonCutArray[0] = "01631031000000"; // PCM photons pointing to EMCAL loose
177                 eventCutArray[ 1] = "8000001"; photonCutArray[ 1] = "002044093270028250400000"; clusterCutArray[1] = "10000042032030000"; mesonCutArray[1] = "01631031000000"; // PCM photons pointing to EMCAL tight
178         } else if (trainConfig == 10){ 
179                 eventCutArray[ 0] = "8005201"; photonCutArray[ 0] = "002000093270028250400000"; clusterCutArray[0] = "10000042062030000"; mesonCutArray[0] = "01631031000000"; 
180                 eventCutArray[ 1] = "8005201"; photonCutArray[ 1] = "002000093270028250400000"; clusterCutArray[1] = "10000042072030000"; mesonCutArray[1] = "01631031000000"; 
181                 eventCutArray[ 2] = "8005201"; photonCutArray[ 2] = "002000093270028250400000"; clusterCutArray[2] = "10000042082030000"; mesonCutArray[2] = "01631031000000"; 
182                 eventCutArray[ 3] = "8005201"; photonCutArray[ 3] = "002000093270028250400000"; clusterCutArray[3] = "10000042092030000"; mesonCutArray[3] = "01631031000000"; 
183                 
184         //************************************************ PHOS clusters **********************************************************     
185         } else if (trainConfig == 31) { // min energy = 0.3 GeV/c
186                 eventCutArray[ 0] = "8000001"; photonCutArray[ 0] = "002000093270028250400000"; clusterCutArray[0] = "20000042033200000"; mesonCutArray[0] = "01631031000000"; //standart cut, kINT7 
187                 eventCutArray[ 1] = "8006201"; photonCutArray[ 1] = "002000093270028250400000"; clusterCutArray[1] = "20000042033200000"; mesonCutArray[1] = "01631031000000"; //standard cut, kPHI7            
188         } else if (trainConfig == 32) { //PHOS
189                 eventCutArray[ 0] = "8000001"; photonCutArray[ 0] = "002000093270028250400000"; clusterCutArray[0] = "20000041033200000"; mesonCutArray[0] = "01631031000000"; 
190                 eventCutArray[ 1] = "8000001"; photonCutArray[ 1] = "002000093270028250400000"; clusterCutArray[1] = "20000042033200000"; mesonCutArray[1] = "01631031000000"; 
191                 eventCutArray[ 2] = "8000001"; photonCutArray[ 2] = "002000093270028250400000"; clusterCutArray[2] = "20000043033200000"; mesonCutArray[2] = "01631031000000"; 
192                 eventCutArray[ 3] = "8000001"; photonCutArray[ 3] = "002000093270028250400000"; clusterCutArray[3] = "20000044033200000"; mesonCutArray[3] = "01631031000000"; 
193                 eventCutArray[ 4] = "8000001"; photonCutArray[ 4] = "002000093270028250400000"; clusterCutArray[4] = "20000045033200000"; mesonCutArray[4] = "01631031000000"; 
194         } else if (trainConfig == 33) { //PHOS
195                 eventCutArray[ 0] = "8000002"; photonCutArray[ 0] = "002000093270028250400000"; clusterCutArray[0] = "20000041033200000"; mesonCutArray[0] = "01631031000000"; 
196                 eventCutArray[ 1] = "8000002"; photonCutArray[ 1] = "002000093270028250400000"; clusterCutArray[1] = "20000042033200000"; mesonCutArray[1] = "01631031000000"; 
197                 eventCutArray[ 2] = "8000002"; photonCutArray[ 2] = "002000093270028250400000"; clusterCutArray[2] = "20000043033200000"; mesonCutArray[2] = "01631031000000"; 
198                 eventCutArray[ 3] = "8000002"; photonCutArray[ 3] = "002000093270028250400000"; clusterCutArray[3] = "20000044033200000"; mesonCutArray[3] = "01631031000000"; 
199                 eventCutArray[ 4] = "8000002"; photonCutArray[ 4] = "002000093270028250400000"; clusterCutArray[4] = "20000045033200000"; mesonCutArray[4] = "01631031000000"; 
200         } else {
201                 Error(Form("GammaConvCalo_%i",trainConfig), "wrong trainConfig variable no cuts have been specified for the configuration");
202                 return;
203         }
204
205         TList *EventCutList = new TList();
206         TList *ConvCutList = new TList();
207         TList *ClusterCutList = new TList();
208         TList *MesonCutList = new TList();
209
210         TList *HeaderList = new TList();
211         if (doWeightingPart==1) {
212                 TObjString *Header1 = new TObjString("pi0_1");
213                 HeaderList->Add(Header1);
214         }
215         if (doWeightingPart==2){
216                 TObjString *Header3 = new TObjString("eta_2");
217                 HeaderList->Add(Header3);
218         }
219         if (doWeightingPart==3) {
220                 TObjString *Header1 = new TObjString("pi0_1");
221                 HeaderList->Add(Header1);
222                 TObjString *Header3 = new TObjString("eta_2");
223                 HeaderList->Add(Header3);
224         }
225
226         EventCutList->SetOwner(kTRUE);
227         AliConvEventCuts **analysisEventCuts = new AliConvEventCuts*[numberOfCuts];
228         ConvCutList->SetOwner(kTRUE);
229         AliConversionPhotonCuts **analysisCuts = new AliConversionPhotonCuts*[numberOfCuts];
230         ClusterCutList->SetOwner(kTRUE);
231         AliCaloPhotonCuts **analysisClusterCuts = new AliCaloPhotonCuts*[numberOfCuts];
232         MesonCutList->SetOwner(kTRUE);
233         AliConversionMesonCuts **analysisMesonCuts = new AliConversionMesonCuts*[numberOfCuts];
234
235         for(Int_t i = 0; i<numberOfCuts; i++){
236                 analysisEventCuts[i] = new AliConvEventCuts();   
237                 analysisEventCuts[i]->InitializeCutsFromCutString(eventCutArray[i].Data());
238                 EventCutList->Add(analysisEventCuts[i]);
239                 analysisEventCuts[i]->SetFillCutHistograms("",kFALSE);
240                 
241                 analysisCuts[i] = new AliConversionPhotonCuts();
242                 analysisCuts[i]->InitializeCutsFromCutString(photonCutArray[i].Data());
243                 analysisCuts[i]->SetIsHeavyIon(isHeavyIon);
244                 ConvCutList->Add(analysisCuts[i]);
245                 analysisCuts[i]->SetFillCutHistograms("",kFALSE);
246         
247                 analysisClusterCuts[i] = new AliCaloPhotonCuts();
248                 analysisClusterCuts[i]->InitializeCutsFromCutString(clusterCutArray[i].Data());
249                 ClusterCutList->Add(analysisClusterCuts[i]);
250         analysisClusterCuts[i]->SetExtendedMatching(enableExtendedMatching);
251                 analysisClusterCuts[i]->SetFillCutHistograms("");
252                 
253                 analysisMesonCuts[i] = new AliConversionMesonCuts();
254                 analysisMesonCuts[i]->InitializeCutsFromCutString(mesonCutArray[i].Data());
255                 MesonCutList->Add(analysisMesonCuts[i]);
256                 analysisMesonCuts[i]->SetFillCutHistograms("");
257                 analysisEventCuts[i]->SetAcceptedHeader(HeaderList);
258         }
259
260         task->SetEventCutList(numberOfCuts,EventCutList);
261         task->SetConversionCutList(numberOfCuts,ConvCutList);
262         task->SetCaloCutList(numberOfCuts,ClusterCutList);
263         task->SetMesonCutList(numberOfCuts,MesonCutList);
264         task->SetMoveParticleAccordingToVertex(kTRUE);
265         task->SetDoMesonAnalysis(kTRUE);
266         task->SetDoMesonQA(enableQAMesonTask); //Attention new switch for Pi0 QA
267         task->SetDoPhotonQA(enableQAPhotonTask);  //Attention new switch small for Photon QA
268         task->SetDoClusterQA(1);  //Attention new switch small for Cluster QA
269
270         //connect containers
271         AliAnalysisDataContainer *coutput =
272                 mgr->CreateContainer(Form("GammaConvCalo_%i",trainConfig), TList::Class(),
273                                                         AliAnalysisManager::kOutputContainer,Form("GammaConvCalo_%i.root",trainConfig));
274
275         mgr->AddTask(task);
276         mgr->ConnectInput(task,0,cinput);
277         mgr->ConnectOutput(task,1,coutput);
278
279         return;
280
281 }