MC changes to evsel for debugging
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / macros / AddTask_GammaConvCalo_PbPb.C
CommitLineData
8bdca7f1 1void 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 ) {
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("libPWGGAGammaConv.so");
25 gSystem->Load("libCDB.so");
26 gSystem->Load("libSTEER.so");
27 gSystem->Load("libSTEERBase.so");
28 gSystem->Load("libTENDER.so");
29 gSystem->Load("libTENDERSupplies.so");
30
31 // ================== GetAnalysisManager ===============================
32 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
33 if (!mgr) {
34 Error(Form("AddTask_GammaConvV1_%i",trainConfig), "No analysis manager found.");
35 return ;
36 }
37
38 // ================== GetInputEventHandler =============================
39 AliVEventHandler *inputHandler=mgr->GetInputEventHandler();
40
41 //========= Add PID Reponse to ANALYSIS manager ====
42 if(!(AliPIDResponse*)mgr->GetTask("PIDResponseTask")){
43 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
44 AddTaskPIDResponse(isMC,1,0,4,0,"",1,1,4);
45 }
46
47 //========= Set Cutnumber for V0Reader ================================
48 TString cutnumber = "1000000000084001001500000000";
49 AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
50
51 //========= Add V0 Reader to ANALYSIS manager if not yet existent =====
52 if( !(AliV0ReaderV1*)mgr->GetTask("V0ReaderV1") ){
53 AliV0ReaderV1 *fV0ReaderV1 = new AliV0ReaderV1("V0ReaderV1");
54
55 fV0ReaderV1->SetUseOwnXYZCalculation(kTRUE);
56 fV0ReaderV1->SetCreateAODs(kFALSE);// AOD Output
57 fV0ReaderV1->SetUseAODConversionPhoton(kTRUE);
58
59 if (!mgr) {
60 Error("AddTask_V0ReaderV1", "No analysis manager found.");
61 return;
62 }
63
64 // Set AnalysisCut Number
65 AliConversionCuts *fCuts=NULL;
66 if(cutnumber!=""){
67 fCuts= new AliConversionCuts(cutnumber.Data(),cutnumber.Data());
68 fCuts->SetPreSelectionCutFlag(kTRUE);
69 if(fCuts->InitializeCutsFromCutString(cutnumber.Data())){
70 fV0ReaderV1->SetConversionCuts(fCuts);
71 fCuts->SetFillCutHistograms("",kTRUE);
72 }
73 }
74 if(inputHandler->IsA()==AliAODInputHandler::Class()){
75 // AOD mode
76 fV0ReaderV1->SetDeltaAODBranchName(Form("GammaConv_%s_gamma",cutnumberAODBranch.Data()));
77 }
78 fV0ReaderV1->Init();
79
80 AliLog::SetGlobalLogLevel(AliLog::kFatal);
81
82 //connect input V0Reader
83 mgr->AddTask(fV0ReaderV1);
84 mgr->ConnectInput(fV0ReaderV1,0,cinput);
85
86 }
87
88 //================================================
89 //========= Add task to the ANALYSIS manager =====
90 //================================================
91 AliAnalysisTaskGammaConvCalo *task=NULL;
92 task= new AliAnalysisTaskGammaConvCalo(Form("GammaConvCalo_%i",trainConfig));
93 task->SetIsHeavyIon(1);
94 task->SetIsMC(isMC);
95 // Cut Numbers to use in Analysis
96 Int_t numberOfCuts = 5;
97
98 TString *cutarray = new TString[numberOfCuts];
99 TString *clustercutarray = new TString[numberOfCuts];
100 TString *mesonCutArray = new TString[numberOfCuts];
101
102 // meson cuts
103 // 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
104
9df9736d 105 if (trainConfig == 1){ // EMCAL clusters
8bdca7f1 106 cutarray[ 0] = "6010001002092970028250400000"; clustercutarray[0] = "10000040022030000"; mesonCutArray[ 0] = "01525065000000"; // 0-5%
107 cutarray[ 1] = "6120001002092970028250400000"; clustercutarray[1] = "10000040022030000"; mesonCutArray[ 1] = "01525065000000"; // 5-10%
108 cutarray[ 2] = "5010001002092970028250400000"; clustercutarray[2] = "10000040022030000"; mesonCutArray[ 2] = "01525065000000"; // 0-10%
109 cutarray[ 3] = "5240001002092970028250400000"; clustercutarray[3] = "10000040022030000"; mesonCutArray[ 3] = "01525065000000"; // 20-40%
110 cutarray[ 4] = "5250001002092970028250400000"; clustercutarray[4] = "10000040022030000"; mesonCutArray[ 4] = "01525065000000"; // 20-50%
9df9736d 111 } else if (trainConfig == 2){ // PHOS clusters
135c1186 112 cutarray[ 0] = "6010001002092970028250400000"; clustercutarray[0] = "20000030022000000"; mesonCutArray[ 0] = "01525065000000"; // 0-5%
113 cutarray[ 1] = "6120001002092970028250400000"; clustercutarray[1] = "20000030022000000"; mesonCutArray[ 1] = "01525065000000"; // 5-10%
114 cutarray[ 2] = "5010001002092970028250400000"; clustercutarray[2] = "20000030022000000"; mesonCutArray[ 2] = "01525065000000"; // 0-10%
115 cutarray[ 3] = "5240001002092970028250400000"; clustercutarray[3] = "20000030022000000"; mesonCutArray[ 3] = "01525065000000"; // 20-40%
116 cutarray[ 4] = "5250001002092970028250400000"; clustercutarray[4] = "20000030022000000"; mesonCutArray[ 4] = "01525065000000"; // 20-50%
9df9736d 117
118
8bdca7f1 119 } else {
120 Error(Form("GammaConvCalo_%i",trainConfig), "wrong trainConfig variable no cuts have been specified for the configuration");
121 return;
122 }
123
124 TList *ConvCutList = new TList();
135c1186 125 TList *ClusterCutList = new TList();
8bdca7f1 126 TList *MesonCutList = new TList();
127
128 TList *HeaderList = new TList();
129 if (periodName.CompareTo("LHC13d2")==0){
130 TObjString *Header1 = new TObjString("pi0_1");
131 HeaderList->Add(Header1);
132 // TObjString *Header3 = new TObjString("eta_2");
133 // HeaderList->Add(Header3);
134
135 } else if (periodName.CompareTo("LHC12a17x_fix")==0){
136 TObjString *Header1 = new TObjString("PARAM");
137 HeaderList->Add(Header1);
138 } else if (periodName.CompareTo("LHC14a1a")==0){
139 if (headerSelectionInt == 1){
140 TObjString *Header1 = new TObjString("pi0_1");
141 HeaderList->Add(Header1);
142 } else if (headerSelectionInt == 2){
143 TObjString *Header1 = new TObjString("eta_2");
144 HeaderList->Add(Header1);
145 } else {
146 TObjString *Header1 = new TObjString("pi0_1");
147 HeaderList->Add(Header1);
148 TObjString *Header2 = new TObjString("eta_2");
149 HeaderList->Add(Header2);
150 }
151 } else if (periodName.CompareTo("LHC14a1b")==0 || periodName.CompareTo("LHC14a1c")==0){
152 TObjString *Header1 = new TObjString("BOX");
153 HeaderList->Add(Header1);
154 }
155
156 ConvCutList->SetOwner(kTRUE);
157 AliConversionCuts **analysisCuts = new AliConversionCuts*[numberOfCuts];
158 ClusterCutList->SetOwner(kTRUE);
159 AliCaloPhotonCuts **analysisClusterCuts = new AliCaloPhotonCuts*[numberOfCuts];
160 MesonCutList->SetOwner(kTRUE);
161 AliConversionMesonCuts **analysisMesonCuts = new AliConversionMesonCuts*[numberOfCuts];
162
163 for(Int_t i = 0; i<numberOfCuts; i++){
164 analysisCuts[i] = new AliConversionCuts();
165
166 if ( trainConfig == 1){
167 if (periodName.CompareTo("LHC14a1a") ==0 || periodName.CompareTo("LHC14a1b") ==0 || periodName.CompareTo("LHC14a1c") ==0 ){
168 if ( i == 0 && doWeighting) analysisCuts[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");
169 if ( i == 1 && doWeighting) analysisCuts[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");
170 if ( i == 2 && doWeighting) analysisCuts[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");
171 if ( i == 3 && doWeighting) analysisCuts[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");
172 if ( i == 4 && doWeighting) analysisCuts[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");
173 }
174 }
175 analysisCuts[i]->InitializeCutsFromCutString(cutarray[i].Data());
176 if (periodName.CompareTo("LHC14a1b") ==0 || periodName.CompareTo("LHC14a1c") ==0 ){
177 if (headerSelectionInt == 1) analysisCuts[i]->SetAddedSignalPDGCode(111);
178 if (headerSelectionInt == 2) analysisCuts[i]->SetAddedSignalPDGCode(221);
179 }
180 ConvCutList->Add(analysisCuts[i]);
181
182 analysisClusterCuts[i] = new AliCaloPhotonCuts();
183 analysisClusterCuts[i]->InitializeCutsFromCutString(clustercutarray[i].Data());
184 ClusterCutList->Add(analysisClusterCuts[i]);
185 analysisClusterCuts[i]->SetFillCutHistograms("");
186
187 analysisCuts[i]->SetFillCutHistograms("",kFALSE);
188 analysisMesonCuts[i] = new AliConversionMesonCuts();
189 analysisMesonCuts[i]->InitializeCutsFromCutString(mesonCutArray[i].Data());
190 MesonCutList->Add(analysisMesonCuts[i]);
191 analysisMesonCuts[i]->SetFillCutHistograms("");
192 analysisCuts[i]->SetAcceptedHeader(HeaderList);
193 }
194
195 task->SetConversionCutList(numberOfCuts,ConvCutList);
196 task->SetCaloCutList(numberOfCuts,ClusterCutList);
197 task->SetMesonCutList(numberOfCuts,MesonCutList);
198 task->SetMoveParticleAccordingToVertex(kTRUE);
199 task->SetDoMesonAnalysis(kTRUE);
200 task->SetDoMesonQA(enableQAMesonTask); //Attention new switch for Pi0 QA
201 task->SetDoPhotonQA(enableQAPhotonTask); //Attention new switch small for Photon QA
202
203 //connect containers
204 AliAnalysisDataContainer *coutput =
205 mgr->CreateContainer(Form("GammaConvCalo_%i",trainConfig), TList::Class(),
206 AliAnalysisManager::kOutputContainer,Form("GammaConvCalo_%i.root",trainConfig));
207
208 mgr->AddTask(task);
209 mgr->ConnectInput(task,0,cinput);
210 mgr->ConnectOutput(task,1,coutput);
211
212 return;
213
214}