TENDER becomes Tender, removing .so
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / macros / AddTask_GammaCalo_PbPb.C
1 void AddTask_GammaCalo_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 enableQAClusterTask = 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                                                                 ) {
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 = 1;
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         //=========  Set Cutnumber for V0Reader ================================
52         TString cutnumberPhoton = "000000084001001500000000";
53         TString cutnumberEvent = "1000000";
54         AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
55
56         //========= Add V0 Reader to  ANALYSIS manager if not yet existent =====
57         if( !(AliV0ReaderV1*)mgr->GetTask("V0ReaderV1") ){
58                 AliV0ReaderV1 *fV0ReaderV1 = new AliV0ReaderV1("V0ReaderV1");
59                 
60                 fV0ReaderV1->SetUseOwnXYZCalculation(kTRUE);
61                 fV0ReaderV1->SetCreateAODs(kFALSE);// AOD Output
62                 fV0ReaderV1->SetUseAODConversionPhoton(kTRUE);
63
64                 if (!mgr) {
65                         Error("AddTask_V0ReaderV1", "No analysis manager found.");
66                         return;
67                 }
68
69                 AliConvEventCuts *fEventCuts=NULL;
70                 if(cutnumberEvent!=""){
71                         fEventCuts= new AliConvEventCuts(cutnumberEvent.Data(),cutnumberEvent.Data());
72                         fEventCuts->SetPreSelectionCutFlag(kTRUE);
73                         if(fEventCuts->InitializeCutsFromCutString(cutnumberEvent.Data())){
74                                 fV0ReaderV1->SetEventCuts(fEventCuts);
75                                 fEventCuts->SetFillCutHistograms("",kTRUE);
76                         }
77                 }
78
79                 
80                 // Set AnalysisCut Number
81                 AliConversionPhotonCuts *fCuts=NULL;
82                 if(cutnumberPhoton!=""){
83                         fCuts= new AliConversionPhotonCuts(cutnumberPhoton.Data(),cutnumberPhoton.Data());
84                         fCuts->SetPreSelectionCutFlag(kTRUE);
85                         fCuts->SetIsHeavyIon(isHeavyIon);
86                         if(fCuts->InitializeCutsFromCutString(cutnumberPhoton.Data())){
87                                 fV0ReaderV1->SetConversionCuts(fCuts);
88                                 fCuts->SetFillCutHistograms("",kTRUE);
89                         }
90                 }
91
92                 if(inputHandler->IsA()==AliAODInputHandler::Class()){
93                 // AOD mode
94                         fV0ReaderV1->SetDeltaAODBranchName(Form("GammaConv_%s_gamma",cutnumberAODBranch.Data()));
95                 }
96                 fV0ReaderV1->Init();
97
98                 AliLog::SetGlobalLogLevel(AliLog::kFatal);
99
100                 //connect input V0Reader
101                 mgr->AddTask(fV0ReaderV1);
102                 mgr->ConnectInput(fV0ReaderV1,0,cinput);
103
104         }
105
106         //================================================
107         //========= Add task to the ANALYSIS manager =====
108         //================================================
109         AliAnalysisTaskGammaCalo *task=NULL;
110         task= new AliAnalysisTaskGammaCalo(Form("GammaCalo_%i",trainConfig));
111         task->SetIsHeavyIon(isHeavyIon);
112         task->SetIsMC(isMC);
113         // Cut Numbers to use in Analysis
114         Int_t numberOfCuts = 5;
115
116         TString *eventCutArray = new TString[numberOfCuts];
117         TString *clusterCutArray = new TString[numberOfCuts];
118         TString *mesonCutArray = new TString[numberOfCuts];
119
120         // meson cuts
121         // meson type (Dalitz or not), BG scheme, pool depth, rotation degrees, rapidity cut, radius cut, alpha, chi2, shared electrons, reject to close v0, MC smearing, dca, dca, dca
122   
123         if (trainConfig == 1){ // EMCAL clusters
124                 eventCutArray[ 0] = "6010001"; clusterCutArray[0] = "10000040032030000"; mesonCutArray[ 0] = "01631031000000"; // 0-5%
125                 eventCutArray[ 1] = "6120001"; clusterCutArray[1] = "10000040032030000"; mesonCutArray[ 1] = "01631031000000"; // 5-10%
126                 eventCutArray[ 2] = "5010001"; clusterCutArray[2] = "10000040032030000"; mesonCutArray[ 2] = "01631031000000"; // 0-10%
127                 eventCutArray[ 3] = "5240001"; clusterCutArray[3] = "10000040032030000"; mesonCutArray[ 3] = "01631031000000"; // 20-40%
128                 eventCutArray[ 4] = "5250001"; clusterCutArray[4] = "10000040032030000"; mesonCutArray[ 4] = "01631031000000"; // 20-50%
129         } else if (trainConfig == 2){ // EMCAL clusters
130                 eventCutArray[ 0] = "6010001"; clusterCutArray[0] = "10000040032030000"; mesonCutArray[ 0] = "01631031000000"; // 0-5%
131                 eventCutArray[ 1] = "6120001"; clusterCutArray[1] = "10000040032030000"; mesonCutArray[ 1] = "01631031000000"; // 5-10%
132                 eventCutArray[ 2] = "5010001"; clusterCutArray[2] = "10000040032030000"; mesonCutArray[ 2] = "01631031000000"; // 0-10%
133                 eventCutArray[ 3] = "5120001"; clusterCutArray[3] = "10000040032030000"; mesonCutArray[ 3] = "01631031000000"; // 10-20%
134                 eventCutArray[ 4] = "5240001"; clusterCutArray[4] = "10000040032030000"; mesonCutArray[ 4] = "01631031000000"; // 20-40%                
135         } else if (trainConfig == 3){ // EMCAL clusters
136                 eventCutArray[ 0] = "5460001"; clusterCutArray[0] = "10000040032030000"; mesonCutArray[ 0] = "01631031000000"; // 40-60%
137                 eventCutArray[ 1] = "5680001"; clusterCutArray[1] = "10000040032030000"; mesonCutArray[ 1] = "01631031000000"; // 60-80%
138                 eventCutArray[ 2] = "5260001"; clusterCutArray[2] = "10000040032030000"; mesonCutArray[ 2] = "01631031000000"; // 20-60%
139                 eventCutArray[ 3] = "5480001"; clusterCutArray[3] = "10000040032030000"; mesonCutArray[ 3] = "01631031000000"; // 40-80%
140                 eventCutArray[ 4] = "5250001"; clusterCutArray[4] = "10000040032030000"; mesonCutArray[ 4] = "01631031000000"; // 20-50%                                
141         } else if (trainConfig == 31){ // PHOS clusters
142                 eventCutArray[ 0] = "6010001"; clusterCutArray[0] = "20000040033200000"; mesonCutArray[ 0] = "01631031000000"; // 0-5%
143                 eventCutArray[ 1] = "6120001"; clusterCutArray[1] = "20000040033200000"; mesonCutArray[ 1] = "01631031000000"; // 5-10%
144                 eventCutArray[ 2] = "5010001"; clusterCutArray[2] = "20000040033200000"; mesonCutArray[ 2] = "01631031000000"; // 0-10%
145                 eventCutArray[ 3] = "5240001"; clusterCutArray[3] = "20000040033200000"; mesonCutArray[ 3] = "01631031000000"; // 20-40%
146                 eventCutArray[ 4] = "5250001"; clusterCutArray[4] = "20000040033200000"; mesonCutArray[ 4] = "01631031000000"; // 20-50%
147         } else if (trainConfig == 32){ // PHOS clusters
148                 eventCutArray[ 0] = "6010001"; clusterCutArray[0] = "20000040033200000"; mesonCutArray[ 0] = "01631031000000"; // 0-5%
149                 eventCutArray[ 1] = "6120001"; clusterCutArray[1] = "20000040033200000"; mesonCutArray[ 1] = "01631031000000"; // 5-10%
150                 eventCutArray[ 2] = "5010001"; clusterCutArray[2] = "20000040033200000"; mesonCutArray[ 2] = "01631031000000"; // 0-10%
151                 eventCutArray[ 3] = "5120001"; clusterCutArray[3] = "20000040033200000"; mesonCutArray[ 3] = "01631031000000"; // 10-20%
152                 eventCutArray[ 4] = "5240001"; clusterCutArray[4] = "20000040033200000"; mesonCutArray[ 4] = "01631031000000"; // 20-40%                
153         } else if (trainConfig == 33){ // PHOS clusters
154                 eventCutArray[ 0] = "5460001"; clusterCutArray[0] = "20000040033200000"; mesonCutArray[ 0] = "01631031000000"; // 40-60%
155                 eventCutArray[ 1] = "5680001"; clusterCutArray[1] = "20000040033200000"; mesonCutArray[ 1] = "01631031000000"; // 60-80%
156                 eventCutArray[ 2] = "5260001"; clusterCutArray[2] = "20000040033200000"; mesonCutArray[ 2] = "01631031000000"; // 20-60%
157                 eventCutArray[ 3] = "5480001"; clusterCutArray[3] = "20000040033200000"; mesonCutArray[ 3] = "01631031000000"; // 40-80%
158                 eventCutArray[ 4] = "5250001"; clusterCutArray[4] = "20000040033200000"; mesonCutArray[ 4] = "01631031000000"; // 20-50%                                                
159         } else {
160                 Error(Form("GammaConvCalo_%i",trainConfig), "wrong trainConfig variable no cuts have been specified for the configuration");
161                 return;
162         }
163
164         TList *EventCutList = new TList();
165         TList *ConvCutList = new TList();
166         TList *ClusterCutList = new TList();
167         TList *MesonCutList = new TList();
168
169         TList *HeaderList = new TList();
170         if (periodName.CompareTo("LHC13d2")==0){
171                 TObjString *Header1 = new TObjString("pi0_1");
172                 HeaderList->Add(Header1);
173         //    TObjString *Header3 = new TObjString("eta_2");
174         //    HeaderList->Add(Header3);
175
176         } else if (periodName.CompareTo("LHC12a17x_fix")==0){
177                 TObjString *Header1 = new TObjString("PARAM");
178                 HeaderList->Add(Header1);
179         } else if (periodName.CompareTo("LHC14a1a")==0){
180                 if (headerSelectionInt == 1){ 
181                         TObjString *Header1 = new TObjString("pi0_1");
182                         HeaderList->Add(Header1);
183                 } else if (headerSelectionInt == 2){
184                         TObjString *Header1 = new TObjString("eta_2");
185                         HeaderList->Add(Header1);
186                 } else {
187                         TObjString *Header1 = new TObjString("pi0_1");
188                         HeaderList->Add(Header1);
189                         TObjString *Header2 = new TObjString("eta_2");
190                         HeaderList->Add(Header2);
191                 }  
192         } else if (periodName.CompareTo("LHC14a1b")==0 || periodName.CompareTo("LHC14a1c")==0){
193                 TObjString *Header1 = new TObjString("BOX");
194                 HeaderList->Add(Header1);
195         }       
196
197         TList *EventCutList = new TList();
198         TList *ClusterCutList = new TList();
199         TList *MesonCutList = new TList();
200
201
202         EventCutList->SetOwner(kTRUE);
203         AliConvEventCuts **analysisEventCuts = new AliConvEventCuts*[numberOfCuts];
204         ClusterCutList->SetOwner(kTRUE);
205         AliCaloPhotonCuts **analysisClusterCuts = new AliCaloPhotonCuts*[numberOfCuts];
206         MesonCutList->SetOwner(kTRUE);
207         AliConversionMesonCuts **analysisMesonCuts = new AliConversionMesonCuts*[numberOfCuts];
208
209         for(Int_t i = 0; i<numberOfCuts; i++){
210                 analysisEventCuts[i] = new AliConvEventCuts();   
211                 analysisEventCuts[i]->InitializeCutsFromCutString(eventCutArray[i].Data());
212                 EventCutList->Add(analysisEventCuts[i]);
213                 analysisEventCuts[i]->SetFillCutHistograms("",kFALSE);
214                         
215                 analysisClusterCuts[i] = new AliCaloPhotonCuts();
216                 analysisClusterCuts[i]->InitializeCutsFromCutString(clusterCutArray[i].Data());
217                 ClusterCutList->Add(analysisClusterCuts[i]);
218                 analysisClusterCuts[i]->SetFillCutHistograms("");
219                 
220                 analysisMesonCuts[i] = new AliConversionMesonCuts();
221                 analysisMesonCuts[i]->InitializeCutsFromCutString(mesonCutArray[i].Data());
222                 MesonCutList->Add(analysisMesonCuts[i]);
223                 analysisMesonCuts[i]->SetFillCutHistograms("");
224                 analysisEventCuts[i]->SetAcceptedHeader(HeaderList);
225         }
226         task->SetEventCutList(numberOfCuts,EventCutList);
227         task->SetCaloCutList(numberOfCuts,ClusterCutList);
228         task->SetMesonCutList(numberOfCuts,MesonCutList);
229         task->SetDoMesonAnalysis(kTRUE);
230         task->SetDoMesonQA(enableQAMesonTask); //Attention new switch for Pi0 QA
231         task->SetDoClusterQA(enableQAClusterTask);  //Attention new switch small for Cluster QA
232
233         //connect containers
234         AliAnalysisDataContainer *coutput =
235                 mgr->CreateContainer(Form("GammaCalo_%i",trainConfig), TList::Class(),
236                                                         AliAnalysisManager::kOutputContainer,Form("GammaCalo_%i.root",trainConfig));
237
238         mgr->AddTask(task);
239         mgr->ConnectInput(task,0,cinput);
240         mgr->ConnectOutput(task,1,coutput);
241
242         return;
243
244 }