TENDER becomes Tender
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / macros / AddTask_GammaConvV1_pPb3.C
CommitLineData
9b4cb8c1 1void AddTask_GammaConvV1_pPb3( 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",
344100c4 8 TString cutnumberAODBranch = "8000000160084000001500000" // cutnumber for AOD branch
9b4cb8c1 9 ) {
344100c4 10
11 Int_t isHeavyIon = 2;
12
13 // ================= Load Librariers =================================
14 gSystem->Load("libCore.so");
15 gSystem->Load("libTree.so");
16 gSystem->Load("libGeom.so");
17 gSystem->Load("libVMC.so");
18 gSystem->Load("libPhysics.so");
19 gSystem->Load("libMinuit");
20 gSystem->Load("libSTEERBase");
21 gSystem->Load("libESD");
22 gSystem->Load("libAOD");
23 gSystem->Load("libANALYSIS");
24 gSystem->Load("libANALYSISalice");
344100c4 25 gSystem->Load("libCDB.so");
26 gSystem->Load("libSTEER.so");
27 gSystem->Load("libSTEERBase.so");
af472fff 28 gSystem->Load("libTender.so");
29 gSystem->Load("libTenderSupplies.so");
4e1b9acf 30 gSystem->Load("libPWGflowBase.so");
31 gSystem->Load("libPWGflowTasks.so");
32 gSystem->Load("libPWGGAGammaConv.so");
33
344100c4 34 // ================== GetAnalysisManager ===============================
35 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
36 if (!mgr) {
37 Error(Form("AddTask_GammaConvV1_%i",trainConfig), "No analysis manager found.");
38 return ;
39 }
40
41 // ================== GetInputEventHandler =============================
42 AliVEventHandler *inputHandler=mgr->GetInputEventHandler();
43
44 //========= Add PID Reponse to ANALYSIS manager ====
45 if(!(AliPIDResponse*)mgr->GetTask("PIDResponseTask")){
46 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
47 AddTaskPIDResponse(isMC);
48 }
49
50 //========= Set Cutnumber for V0Reader ================================
51 //offline V0Finder
48a2b226 52 TString cutnumberPhoton = "160000084001001500000000";
344100c4 53 TString cutnumberEvent = "8000000";
54 Bool_t doEtaShift = kFALSE;
55 AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
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 fEventCuts->DoEtaShift(doEtaShift);
75 fV0ReaderV1->SetEventCuts(fEventCuts);
76 fEventCuts->SetFillCutHistograms("",kTRUE);
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 if(inputHandler->IsA()==AliAODInputHandler::Class()){
92 // AOD mode
93 cout << "AOD handler: adding " << cutnumberAODBranch.Data() << " as conversion branch" << endl;
94 fV0ReaderV1->SetDeltaAODBranchName(Form("GammaConv_%s_gamma",cutnumberAODBranch.Data()));
95 }
96 fV0ReaderV1->Init();
97
98 AliLog::SetGlobalLogLevel(AliLog::kInfo);
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 // find input container
110 AliAnalysisTaskGammaConvV1 *task=NULL;
111 task= new AliAnalysisTaskGammaConvV1(Form("GammaConvV1_%i",trainConfig));
112 task->SetIsHeavyIon(isHeavyIon);
113 task->SetIsMC(isMC);
114 // Cut Numbers to use in Analysis
115 Int_t numberOfCuts = 4;
116
117 TString *eventCutArray = new TString[numberOfCuts];
118 TString *photonCutArray = new TString[numberOfCuts];
119 TString *mesonCutArray = new TString[numberOfCuts];
120 Bool_t doEtaShiftIndCuts = kFALSE;
121 TString stringShift = "";
122
123 if (trainConfig == 1) {
48a2b226 124 eventCutArray[ 0] = "8000011"; photonCutArray[ 0] = "102000092170008260400000"; mesonCutArray[ 0] = "01621035009000"; // all Photon Qualities //offline V0Finder
125 eventCutArray[ 1] = "8000011"; photonCutArray[ 1] = "102000092170008260420000"; mesonCutArray[ 1] = "01621035009000"; // only photon quality 1 //offline V0Finder
126 eventCutArray[ 2] = "8000011"; photonCutArray[ 2] = "102000092170008260430000"; mesonCutArray[ 2] = "01621035009000"; // only photon quality 2 //offline V0Finder
127 eventCutArray[ 3] = "8000011"; photonCutArray[ 3] = "102000092170008260440000"; mesonCutArray[ 3] = "01621035009000"; // only photon quality 3 //offline V0Finder
344100c4 128 } else if (trainConfig == 2) {
48a2b226 129 eventCutArray[ 0] = "8000012"; photonCutArray[ 0] = "102000092170008260400000"; mesonCutArray[ 0] = "01621035009000"; // all Photon Qualities //offline V0Finder
130 eventCutArray[ 0] = "8000012"; photonCutArray[ 1] = "102000092170008260420000"; mesonCutArray[ 1] = "01621035009000"; // only photon quality 1 //offline V0Finder
131 eventCutArray[ 0] = "8000012"; photonCutArray[ 2] = "102000092170008260430000"; mesonCutArray[ 2] = "01621035009000"; // only photon quality 2 //offline V0Finder
132 eventCutArray[ 0] = "8000012"; photonCutArray[ 3] = "102000092170008260440000"; mesonCutArray[ 3] = "01621035009000"; // only photon quality 3 //offline V0Finder
344100c4 133 } else {
134 Error(Form("GammaConvV1_%i",trainConfig), "wrong trainConfig variable no cuts have been specified for the configuration");
135 return;
9b4cb8c1 136 }
344100c4 137
138 TList *EventCutList = new TList();
9b4cb8c1 139 TList *ConvCutList = new TList();
140 TList *MesonCutList = new TList();
141
142 TList *HeaderList = new TList();
143 if (doWeightingPart==1) {
144 TObjString *Header1 = new TObjString("pi0_1");
145 HeaderList->Add(Header1);
146 }
147 if (doWeightingPart==2){
148 TObjString *Header3 = new TObjString("eta_2");
149 HeaderList->Add(Header3);
150 }
151 if (doWeightingPart==3) {
152 TObjString *Header1 = new TObjString("pi0_1");
153 HeaderList->Add(Header1);
154 TObjString *Header3 = new TObjString("eta_2");
155 HeaderList->Add(Header3);
156 }
157
158
159 Bool_t doWeighting = kFALSE;
160 if (doWeightingPart == 1 || doWeightingPart == 2 || doWeightingPart == 3) doWeighting = kTRUE;
161
344100c4 162 EventCutList->SetOwner(kTRUE);
163 AliConvEventCuts **analysisEventCuts = new AliConvEventCuts*[numberOfCuts];
9b4cb8c1 164 ConvCutList->SetOwner(kTRUE);
165 AliConversionCuts **analysisCuts = new AliConversionCuts*[numberOfCuts];
166 MesonCutList->SetOwner(kTRUE);
167 AliConversionMesonCuts **analysisMesonCuts = new AliConversionMesonCuts*[numberOfCuts];
168
169
170 for(Int_t i = 0; i<numberOfCuts; i++){
171
344100c4 172 analysisEventCuts[i] = new AliConvEventCuts();
9b4cb8c1 173 if ( trainConfig == 1 ){
174 if (doWeighting){
175 if (generatorName.CompareTo("DPMJET")==0){
344100c4 176 analysisEventCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_DPMJET_LHC13b2_efix_pPb_5023GeV_MBV0A", "Eta_DPMJET_LHC13b2_efix_pPb_5023GeV_MBV0A", "","Pi0_Fit_Data_pPb_5023GeV_MBV0A","Eta_Fit_Data_pPb_5023GeV_MBV0A");
9b4cb8c1 177 } else if (generatorName.CompareTo("HIJING")==0){
344100c4 178 analysisEventCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13e7_pPb_5023GeV_MBV0A", "Eta_Hijing_LHC13e7_pPb_5023GeV_MBV0A", "","Pi0_Fit_Data_pPb_5023GeV_MBV0A","Eta_Fit_Data_pPb_5023GeV_MBV0A");
9b4cb8c1 179 }
180 }
181 }
182 if ( trainConfig == 2 ){
183 if (doWeighting){
344100c4 184 analysisEventCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13e7_addSig_pPb_5023GeV_MBV0A", "Eta_Hijing_LHC13e7_addSig_pPb_5023GeV_MBV0A", "","Pi0_Fit_Data_pPb_5023GeV_MBV0A","Eta_Fit_Data_pPb_5023GeV_MBV0A");
9b4cb8c1 185 }
186
187 }
188
344100c4 189 analysisEventCuts[i]->InitializeCutsFromCutString(eventCutArray[i].Data());
9b4cb8c1 190 if (doEtaShiftIndCuts) {
344100c4 191 analysisEventCuts[i]->DoEtaShift(doEtaShiftIndCuts);
192 analysisEventCuts[i]->SetEtaShift(stringShift);
193 }
194 if (trainConfig == 179 || trainConfig == 180) {
195 analysisEventCuts[0]->DoEtaShift(kTRUE);
196 analysisEventCuts[0]->SetEtaShift(-0.215);
9b4cb8c1 197 }
198
344100c4 199 EventCutList->Add(analysisEventCuts[i]);
200 analysisEventCuts[i]->SetFillCutHistograms("",kFALSE);
201
202 analysisCuts[i] = new AliConversionPhotonCuts();
203 analysisCuts[i]->InitializeCutsFromCutString(photonCutArray[i].Data());
204 analysisCuts[i]->SetIsHeavyIon(isHeavyIon);
9b4cb8c1 205 ConvCutList->Add(analysisCuts[i]);
9b4cb8c1 206 analysisCuts[i]->SetFillCutHistograms("",kFALSE);
344100c4 207
9b4cb8c1 208 analysisMesonCuts[i] = new AliConversionMesonCuts();
209 analysisMesonCuts[i]->InitializeCutsFromCutString(mesonCutArray[i].Data());
210 MesonCutList->Add(analysisMesonCuts[i]);
211 analysisMesonCuts[i]->SetFillCutHistograms("");
344100c4 212 analysisEventCuts[i]->SetAcceptedHeader(HeaderList);
9b4cb8c1 213 }
214
344100c4 215 task->SetEventCutList(numberOfCuts,EventCutList);
9b4cb8c1 216 task->SetConversionCutList(numberOfCuts,ConvCutList);
217 task->SetMesonCutList(numberOfCuts,MesonCutList);
218 task->SetMoveParticleAccordingToVertex(kTRUE);
219 task->SetDoMesonAnalysis(kTRUE);
220 task->SetDoMesonQA(enableQAMesonTask); //Attention new switch for Pi0 QA
221 task->SetDoPhotonQA(enableQAPhotonTask); //Attention new switch small for Photon QA
222
223 //connect containers
224 AliAnalysisDataContainer *coutput =
225 mgr->CreateContainer(Form("GammaConvV1_%i",trainConfig), TList::Class(),
226 AliAnalysisManager::kOutputContainer,Form("GammaConvV1_%i.root",trainConfig));
227
228 mgr->AddTask(task);
229 mgr->ConnectInput(task,0,cinput);
230 mgr->ConnectOutput(task,1,coutput);
231
232 return;
233
234}