ATO-80
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / macros / AddTask_GammaConvV1_pPb2.C
CommitLineData
75f195f2
FB
1void AddTask_GammaConvV1_pPb2( 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 Bool_t doWeighting = kFALSE, //enable Weighting
7 TString generatorName = "DPMJET",
8 TString cutnumberAODBranch = "8000000060084000001500000" // cutnumber for AOD branch
9 ) {
10
344100c4 11 // ================= Load Librariers =================================
12 gSystem->Load("libCore.so");
13 gSystem->Load("libTree.so");
14 gSystem->Load("libGeom.so");
15 gSystem->Load("libVMC.so");
16 gSystem->Load("libPhysics.so");
17 gSystem->Load("libMinuit");
18 gSystem->Load("libSTEERBase");
19 gSystem->Load("libESD");
20 gSystem->Load("libAOD");
21 gSystem->Load("libANALYSIS");
22 gSystem->Load("libANALYSISalice");
23 gSystem->Load("libPWGGAGammaConv.so");
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");
75f195f2 29
344100c4 30 Int_t isHeavyIon = 2;
31
32 // ================== GetAnalysisManager ===============================
33 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
34 if (!mgr) {
35 Error(Form("AddTask_GammaConvV1_%i",trainConfig), "No analysis manager found.");
36 return ;
37 }
38
39 // ================== GetInputEventHandler =============================
40 AliVEventHandler *inputHandler=mgr->GetInputEventHandler();
41
42 //========= Add PID Reponse to ANALYSIS manager ====
43 if(!(AliPIDResponse*)mgr->GetTask("PIDResponseTask")){
44 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
45 AddTaskPIDResponse(isMC);
46 }
47
48 //========= Set Cutnumber for V0Reader ================================
49 TString cutnumberPhoton = "060084001001500000000";
50 TString cutnumberEvent = "8000000";
51 Bool_t doEtaShift = kFALSE;
52 AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
53 //========= Add V0 Reader to ANALYSIS manager if not yet existent =====
54 if( !(AliV0ReaderV1*)mgr->GetTask("V0ReaderV1") ){
55 AliV0ReaderV1 *fV0ReaderV1 = new AliV0ReaderV1("V0ReaderV1");
56
57 fV0ReaderV1->SetUseOwnXYZCalculation(kTRUE);
58 fV0ReaderV1->SetCreateAODs(kFALSE);// AOD Output
59 fV0ReaderV1->SetUseAODConversionPhoton(kTRUE);
60
61 if (!mgr) {
62 Error("AddTask_V0ReaderV1", "No analysis manager found.");
63 return;
64 }
65
66 AliConvEventCuts *fEventCuts=NULL;
67 if(cutnumberEvent!=""){
68 fEventCuts= new AliConvEventCuts(cutnumberEvent.Data(),cutnumberEvent.Data());
69 fEventCuts->SetPreSelectionCutFlag(kTRUE);
70 if(fEventCuts->InitializeCutsFromCutString(cutnumberEvent.Data())){
71 fEventCuts->DoEtaShift(doEtaShift);
72 fV0ReaderV1->SetEventCuts(fEventCuts);
73 fEventCuts->SetFillCutHistograms("",kTRUE);
74 }
75 }
76
77 // Set AnalysisCut Number
78 AliConversionPhotonCuts *fCuts=NULL;
79 if(cutnumberPhoton!=""){
80 fCuts= new AliConversionPhotonCuts(cutnumberPhoton.Data(),cutnumberPhoton.Data());
81 fCuts->SetPreSelectionCutFlag(kTRUE);
82 fCuts->SetIsHeavyIon(isHeavyIon);
83 if(fCuts->InitializeCutsFromCutString(cutnumberPhoton.Data())){
84 fV0ReaderV1->SetConversionCuts(fCuts);
85 fCuts->SetFillCutHistograms("",kTRUE);
86 }
87 }
88 if(inputHandler->IsA()==AliAODInputHandler::Class()){
89 // AOD mode
90 cout << "AOD handler: adding " << cutnumberAODBranch.Data() << " as conversion branch" << endl;
91 fV0ReaderV1->SetDeltaAODBranchName(Form("GammaConv_%s_gamma",cutnumberAODBranch.Data()));
92 }
93 fV0ReaderV1->Init();
94
95 AliLog::SetGlobalLogLevel(AliLog::kInfo);
96
97 //connect input V0Reader
98 mgr->AddTask(fV0ReaderV1);
99 mgr->ConnectInput(fV0ReaderV1,0,cinput);
100
101 }
102
103 //================================================
104 //========= Add task to the ANALYSIS manager =====
105 //================================================
106 // find input container
107 AliAnalysisTaskGammaConvV1 *task=NULL;
108 task= new AliAnalysisTaskGammaConvV1(Form("GammaConvV1_%i",trainConfig));
109 task->SetIsHeavyIon(isHeavyIon);
110 task->SetIsMC(isMC);
111 // Cut Numbers to use in Analysis
112 Int_t numberOfCuts = 1;
113
114 TString *eventCutArray = new TString[numberOfCuts];
115 TString *photonCutArray = new TString[numberOfCuts];
116 TString *mesonCutArray = new TString[numberOfCuts];
117 Bool_t doEtaShiftIndCuts = kFALSE;
118 TString stringShift = "";
119
120 if(trainConfig == 1){
121 eventCutArray[ 0] = "8000011"; photonCutArray[ 0] = "002093172003290000000"; mesonCutArray[ 0] = "01621035009000";
122 } else if (trainConfig == 2) {
123 eventCutArray[ 0] = "8000011"; photonCutArray[ 0] = "002092170008260400000"; mesonCutArray[ 0] = "01621035009000";
124 } else if (trainConfig == 3) {
125 eventCutArray[ 0] = "8020011"; photonCutArray[ 0] = "002092170008260400000"; mesonCutArray[ 0] = "01621035009000";
126 } else if (trainConfig == 4) {
127 eventCutArray[ 0] = "8240011"; photonCutArray[ 0] = "002092170008260400000"; mesonCutArray[ 0] = "01621035009000";
128 } else if (trainConfig == 5) {
129 eventCutArray[ 0] = "8460011"; photonCutArray[ 0] = "002092170008260400000"; mesonCutArray[ 0] = "01621035009000";
130 } else if (trainConfig == 6) {
131 eventCutArray[ 0] = "8680011"; photonCutArray[ 0] = "002092170008260400000"; mesonCutArray[ 0] = "01621035009000";
132 } else if (trainConfig == 7) {
133 eventCutArray[ 0] = "8600011"; photonCutArray[ 0] = "002092170008260400000"; mesonCutArray[ 0] = "01621035009000";
134 } else {
135 Error(Form("GammaConvV1_%i",trainConfig), "wrong trainConfig variable no cuts have been specified for the configuration");
136 return;
137 }
138
139 TList *EventCutList = new TList();
140 TList *ConvCutList = new TList();
141 TList *MesonCutList = new TList();
142
143 TList *HeaderList = new TList();
144 TObjString *Header1 = new TObjString("pi0_1");
145 HeaderList->Add(Header1);
146 TObjString *Header3 = new TObjString("eta_2");
147 HeaderList->Add(Header3);
148
149 EventCutList->SetOwner(kTRUE);
150 AliConvEventCuts **analysisEventCuts = new AliConvEventCuts*[numberOfCuts];
151 ConvCutList->SetOwner(kTRUE);
152 AliConversionPhotonCuts **analysisCuts = new AliConversionPhotonCuts*[numberOfCuts];
153 MesonCutList->SetOwner(kTRUE);
154 AliConversionMesonCuts **analysisMesonCuts = new AliConversionMesonCuts*[numberOfCuts];
155
156
157 for(Int_t i = 0; i<numberOfCuts; i++){
158 analysisEventCuts[i] = new AliConvEventCuts();
159 analysisEventCuts[i]->InitializeCutsFromCutString(eventCutArray[i].Data());
160 if (doEtaShiftIndCuts) {
161 analysisEventCuts[i]->DoEtaShift(doEtaShiftIndCuts);
162 analysisEventCuts[i]->SetEtaShift(stringShift);
163 }
164 EventCutList->Add(analysisEventCuts[i]);
165 analysisEventCuts[i]->SetFillCutHistograms("",kFALSE);
166
167 analysisCuts[i] = new AliConversionPhotonCuts();
168 analysisCuts[i]->InitializeCutsFromCutString(photonCutArray[i].Data());
169 analysisCuts[i]->SetIsHeavyIon(isHeavyIon);
170 ConvCutList->Add(analysisCuts[i]);
171 analysisCuts[i]->SetFillCutHistograms("",kFALSE);
172
173 analysisMesonCuts[i] = new AliConversionMesonCuts();
174 analysisMesonCuts[i]->InitializeCutsFromCutString(mesonCutArray[i].Data());
175 MesonCutList->Add(analysisMesonCuts[i]);
176 analysisMesonCuts[i]->SetFillCutHistograms("");
177 analysisEventCuts[i]->SetAcceptedHeader(HeaderList);
178 }
179
180 task->SetEventCutList(numberOfCuts,EventCutList);
181 task->SetConversionCutList(numberOfCuts,ConvCutList);
182 task->SetMesonCutList(numberOfCuts,MesonCutList);
183 task->SetMoveParticleAccordingToVertex(kTRUE);
184 task->SetDoMesonAnalysis(kTRUE);
185 task->SetDoMesonQA(enableQAMesonTask); //Attention new switch for Pi0 QA
186 task->SetDoPhotonQA(enableQAPhotonTask); //Attention new switch small for Photon QA
187
188 //connect containers
189 AliAnalysisDataContainer *coutput =
190 mgr->CreateContainer(Form("GammaConvV1_%i",trainConfig), TList::Class(),
191 AliAnalysisManager::kOutputContainer,Form("GammaConvV1_%i.root",trainConfig));
192
193 mgr->AddTask(task);
194 mgr->ConnectInput(task,0,cinput);
195 mgr->ConnectOutput(task,1,coutput);
196
197 return;
75f195f2
FB
198
199}