TENDER becomes Tender
[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");
344100c4 23 gSystem->Load("libCDB.so");
24 gSystem->Load("libSTEER.so");
25 gSystem->Load("libSTEERBase.so");
af472fff 26 gSystem->Load("libTender.so");
27 gSystem->Load("libTenderSupplies.so");
4e1b9acf 28 gSystem->Load("libPWGflowBase.so");
29 gSystem->Load("libPWGflowTasks.so");
30 gSystem->Load("libPWGGAGammaConv.so");
75f195f2 31
344100c4 32 Int_t isHeavyIon = 2;
33
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 ================================
48a2b226 51 TString cutnumberPhoton = "060000084001001500000000";
344100c4 52 TString cutnumberEvent = "8000000";
53 Bool_t doEtaShift = kFALSE;
54 AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
55 //========= Add V0 Reader to ANALYSIS manager if not yet existent =====
56 if( !(AliV0ReaderV1*)mgr->GetTask("V0ReaderV1") ){
57 AliV0ReaderV1 *fV0ReaderV1 = new AliV0ReaderV1("V0ReaderV1");
58
59 fV0ReaderV1->SetUseOwnXYZCalculation(kTRUE);
60 fV0ReaderV1->SetCreateAODs(kFALSE);// AOD Output
61 fV0ReaderV1->SetUseAODConversionPhoton(kTRUE);
62
63 if (!mgr) {
64 Error("AddTask_V0ReaderV1", "No analysis manager found.");
65 return;
66 }
67
68 AliConvEventCuts *fEventCuts=NULL;
69 if(cutnumberEvent!=""){
70 fEventCuts= new AliConvEventCuts(cutnumberEvent.Data(),cutnumberEvent.Data());
71 fEventCuts->SetPreSelectionCutFlag(kTRUE);
72 if(fEventCuts->InitializeCutsFromCutString(cutnumberEvent.Data())){
73 fEventCuts->DoEtaShift(doEtaShift);
74 fV0ReaderV1->SetEventCuts(fEventCuts);
75 fEventCuts->SetFillCutHistograms("",kTRUE);
76 }
77 }
78
79 // Set AnalysisCut Number
80 AliConversionPhotonCuts *fCuts=NULL;
81 if(cutnumberPhoton!=""){
82 fCuts= new AliConversionPhotonCuts(cutnumberPhoton.Data(),cutnumberPhoton.Data());
83 fCuts->SetPreSelectionCutFlag(kTRUE);
84 fCuts->SetIsHeavyIon(isHeavyIon);
85 if(fCuts->InitializeCutsFromCutString(cutnumberPhoton.Data())){
86 fV0ReaderV1->SetConversionCuts(fCuts);
87 fCuts->SetFillCutHistograms("",kTRUE);
88 }
89 }
90 if(inputHandler->IsA()==AliAODInputHandler::Class()){
91 // AOD mode
92 cout << "AOD handler: adding " << cutnumberAODBranch.Data() << " as conversion branch" << endl;
93 fV0ReaderV1->SetDeltaAODBranchName(Form("GammaConv_%s_gamma",cutnumberAODBranch.Data()));
94 }
95 fV0ReaderV1->Init();
96
97 AliLog::SetGlobalLogLevel(AliLog::kInfo);
98
99 //connect input V0Reader
100 mgr->AddTask(fV0ReaderV1);
101 mgr->ConnectInput(fV0ReaderV1,0,cinput);
102
103 }
104
105 //================================================
106 //========= Add task to the ANALYSIS manager =====
107 //================================================
108 // find input container
109 AliAnalysisTaskGammaConvV1 *task=NULL;
110 task= new AliAnalysisTaskGammaConvV1(Form("GammaConvV1_%i",trainConfig));
111 task->SetIsHeavyIon(isHeavyIon);
112 task->SetIsMC(isMC);
113 // Cut Numbers to use in Analysis
114 Int_t numberOfCuts = 1;
115
116 TString *eventCutArray = new TString[numberOfCuts];
117 TString *photonCutArray = new TString[numberOfCuts];
118 TString *mesonCutArray = new TString[numberOfCuts];
119 Bool_t doEtaShiftIndCuts = kFALSE;
120 TString stringShift = "";
121
122 if(trainConfig == 1){
48a2b226 123 eventCutArray[ 0] = "8000011"; photonCutArray[ 0] = "002000093172003290000000"; mesonCutArray[ 0] = "01621035009000";
344100c4 124 } else if (trainConfig == 2) {
48a2b226 125 eventCutArray[ 0] = "8000011"; photonCutArray[ 0] = "002000092170008260400000"; mesonCutArray[ 0] = "01621035009000";
344100c4 126 } else if (trainConfig == 3) {
48a2b226 127 eventCutArray[ 0] = "8020011"; photonCutArray[ 0] = "002000092170008260400000"; mesonCutArray[ 0] = "01621035009000";
344100c4 128 } else if (trainConfig == 4) {
48a2b226 129 eventCutArray[ 0] = "8240011"; photonCutArray[ 0] = "002000092170008260400000"; mesonCutArray[ 0] = "01621035009000";
344100c4 130 } else if (trainConfig == 5) {
48a2b226 131 eventCutArray[ 0] = "8460011"; photonCutArray[ 0] = "002000092170008260400000"; mesonCutArray[ 0] = "01621035009000";
344100c4 132 } else if (trainConfig == 6) {
48a2b226 133 eventCutArray[ 0] = "8680011"; photonCutArray[ 0] = "002000092170008260400000"; mesonCutArray[ 0] = "01621035009000";
344100c4 134 } else if (trainConfig == 7) {
48a2b226 135 eventCutArray[ 0] = "8600011"; photonCutArray[ 0] = "002000092170008260400000"; mesonCutArray[ 0] = "01621035009000";
7ce6ebe2 136 } else if (trainConfig == 8) {
48a2b226 137 eventCutArray[ 0] = "8000011"; photonCutArray[ 0] = "009000092170008260400000"; mesonCutArray[ 0] = "01621035009000"; //RCut 7.5cm
7ce6ebe2 138 } else if (trainConfig == 9) {
48a2b226 139 eventCutArray[ 0] = "8000011"; photonCutArray[ 0] = "005000092170008260400000"; mesonCutArray[ 0] = "01621035009000"; //RCut 10cm
7ce6ebe2 140 } else if (trainConfig == 10) {
48a2b226 141 eventCutArray[ 0] = "8000011"; photonCutArray[ 0] = "008000092170008260400000"; mesonCutArray[ 0] = "01621035009000"; //RCut 12.5cm
7ce6ebe2 142 } else if (trainConfig == 11) {
48a2b226 143 eventCutArray[ 0] = "8000011"; photonCutArray[ 0] = "006000092170008260400000"; mesonCutArray[ 0] = "01621035009000"; //RCut 20cm
7ce6ebe2 144 } else if (trainConfig == 12) {
48a2b226 145 eventCutArray[ 0] = "8000011"; photonCutArray[ 0] = "007000092170008260400000"; mesonCutArray[ 0] = "01621035009000"; //RCut 35cm
344100c4 146 } else {
147 Error(Form("GammaConvV1_%i",trainConfig), "wrong trainConfig variable no cuts have been specified for the configuration");
148 return;
149 }
150
151 TList *EventCutList = new TList();
152 TList *ConvCutList = new TList();
153 TList *MesonCutList = new TList();
154
155 TList *HeaderList = new TList();
156 TObjString *Header1 = new TObjString("pi0_1");
157 HeaderList->Add(Header1);
158 TObjString *Header3 = new TObjString("eta_2");
159 HeaderList->Add(Header3);
160
161 EventCutList->SetOwner(kTRUE);
162 AliConvEventCuts **analysisEventCuts = new AliConvEventCuts*[numberOfCuts];
163 ConvCutList->SetOwner(kTRUE);
164 AliConversionPhotonCuts **analysisCuts = new AliConversionPhotonCuts*[numberOfCuts];
165 MesonCutList->SetOwner(kTRUE);
166 AliConversionMesonCuts **analysisMesonCuts = new AliConversionMesonCuts*[numberOfCuts];
167
168
169 for(Int_t i = 0; i<numberOfCuts; i++){
170 analysisEventCuts[i] = new AliConvEventCuts();
171 analysisEventCuts[i]->InitializeCutsFromCutString(eventCutArray[i].Data());
172 if (doEtaShiftIndCuts) {
173 analysisEventCuts[i]->DoEtaShift(doEtaShiftIndCuts);
174 analysisEventCuts[i]->SetEtaShift(stringShift);
175 }
176 EventCutList->Add(analysisEventCuts[i]);
177 analysisEventCuts[i]->SetFillCutHistograms("",kFALSE);
178
179 analysisCuts[i] = new AliConversionPhotonCuts();
180 analysisCuts[i]->InitializeCutsFromCutString(photonCutArray[i].Data());
181 analysisCuts[i]->SetIsHeavyIon(isHeavyIon);
182 ConvCutList->Add(analysisCuts[i]);
183 analysisCuts[i]->SetFillCutHistograms("",kFALSE);
184
185 analysisMesonCuts[i] = new AliConversionMesonCuts();
186 analysisMesonCuts[i]->InitializeCutsFromCutString(mesonCutArray[i].Data());
187 MesonCutList->Add(analysisMesonCuts[i]);
188 analysisMesonCuts[i]->SetFillCutHistograms("");
189 analysisEventCuts[i]->SetAcceptedHeader(HeaderList);
190 }
191
192 task->SetEventCutList(numberOfCuts,EventCutList);
193 task->SetConversionCutList(numberOfCuts,ConvCutList);
194 task->SetMesonCutList(numberOfCuts,MesonCutList);
195 task->SetMoveParticleAccordingToVertex(kTRUE);
196 task->SetDoMesonAnalysis(kTRUE);
197 task->SetDoMesonQA(enableQAMesonTask); //Attention new switch for Pi0 QA
198 task->SetDoPhotonQA(enableQAPhotonTask); //Attention new switch small for Photon QA
199
200 //connect containers
201 AliAnalysisDataContainer *coutput =
202 mgr->CreateContainer(Form("GammaConvV1_%i",trainConfig), TList::Class(),
203 AliAnalysisManager::kOutputContainer,Form("GammaConvV1_%i.root",trainConfig));
204
205 mgr->AddTask(task);
206 mgr->ConnectInput(task,0,cinput);
207 mgr->ConnectOutput(task,1,coutput);
208
209 return;
75f195f2
FB
210
211}