Changed AddTasks
[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
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");
29
30 // ================== GetAnalysisManager ===============================
31 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
32 if (!mgr) {
33 Error(Form("AddTask_GammaConvV1_%i",trainConfig), "No analysis manager found.");
34 return ;
35 }
36
37 // ================== GetInputEventHandler =============================
38 AliVEventHandler *inputHandler=mgr->GetInputEventHandler();
39
40 //========= Add PID Reponse to ANALYSIS manager ====
41 if(!(AliPIDResponse*)mgr->GetTask("PIDResponseTask")){
42 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
43 AddTaskPIDResponse(isMC);
44 }
45
46 //========= Set Cutnumber for V0Reader ================================
47 TString cutnumber = "8000000060084001001500000000";
48 Bool_t doEtaShift = kFALSE;
49 AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
50 //========= Add V0 Reader to ANALYSIS manager if not yet existent =====
51 if( !(AliV0ReaderV1*)mgr->GetTask("V0ReaderV1") ){
52 AliV0ReaderV1 *fV0ReaderV1 = new AliV0ReaderV1("V0ReaderV1");
53
54 fV0ReaderV1->SetUseOwnXYZCalculation(kTRUE);
55 fV0ReaderV1->SetCreateAODs(kFALSE);// AOD Output
56 fV0ReaderV1->SetUseAODConversionPhoton(kTRUE);
57
58 if (!mgr) {
59 Error("AddTask_V0ReaderV1", "No analysis manager found.");
60 return;
61 }
62
63 // Set AnalysisCut Number
64 AliConversionCuts *fCuts=NULL;
65 if(cutnumber!=""){
66 fCuts= new AliConversionCuts(cutnumber.Data(),cutnumber.Data());
67 fCuts->SetPreSelectionCutFlag(kTRUE);
68 if(fCuts->InitializeCutsFromCutString(cutnumber.Data())){
69 fCuts->DoEtaShift(doEtaShift);
70 fV0ReaderV1->SetConversionCuts(fCuts);
71 fCuts->SetFillCutHistograms("",kTRUE);
72 }
73 }
74 if(inputHandler->IsA()==AliAODInputHandler::Class()){
75 // AOD mode
76 cout << "AOD handler: adding " << cutnumberAODBranch.Data() << " as conversion branch" << endl;
77 fV0ReaderV1->SetDeltaAODBranchName(Form("GammaConv_%s_gamma",cutnumberAODBranch.Data()));
78 }
79 fV0ReaderV1->Init();
80
81 AliLog::SetGlobalLogLevel(AliLog::kInfo);
82
83 //connect input V0Reader
84 mgr->AddTask(fV0ReaderV1);
85 mgr->ConnectInput(fV0ReaderV1,0,cinput);
86
87 }
88
89 //================================================
90 //========= Add task to the ANALYSIS manager =====
91 //================================================
92 // find input container
93 AliAnalysisTaskGammaConvV1 *task=NULL;
94 task= new AliAnalysisTaskGammaConvV1(Form("GammaConvV1_%i",trainConfig));
95 task->SetIsHeavyIon(2);
96 task->SetIsMC(isMC);
97 // Cut Numbers to use in Analysis
98 Int_t numberOfCuts = 1;
99
100 TString *cutarray = new TString[numberOfCuts];
101 TString *mesonCutArray = new TString[numberOfCuts];
102 Bool_t doEtaShiftIndCuts = kFALSE;
103 TString stringShift = "";
104 if(trainConfig == 1){
105 // Shifting in pPb direction
106 cutarray[ 0] = "8000011002093172003290000000"; mesonCutArray[ 0] = "01621035009000";
107 } else if (trainConfig == 2) {
108 cutarray[ 0] = "8000011002092170008260400000"; mesonCutArray[ 0] = "01621035009000";
109 } else if (trainConfig == 3) {
110 cutarray[ 0] = "8020011002092170008260400000"; mesonCutArray[ 0] = "01621035009000";
111 } else if (trainConfig == 4) {
112 cutarray[ 0] = "8240011002092170008260400000"; mesonCutArray[ 0] = "01621035009000";
113 } else if (trainConfig == 5) {
114 cutarray[ 0] = "8460011002092170008260400000"; mesonCutArray[ 0] = "01621035009000";
115 } else if (trainConfig == 6) {
116 cutarray[ 0] = "8680011002092170008260400000"; mesonCutArray[ 0] = "01621035009000";
117 } else if (trainConfig == 7) {
118 cutarray[ 0] = "8600011002092170008260400000"; mesonCutArray[ 0] = "01621035009000";
119 } else {
120 Error(Form("GammaConvV1_%i",trainConfig), "wrong trainConfig variable no cuts have been specified for the configuration");
121 return;
122 }
123
124 TList *ConvCutList = new TList();
125 TList *MesonCutList = new TList();
126
127 TList *HeaderList = new TList();
128 TObjString *Header1 = new TObjString("pi0_1");
129 HeaderList->Add(Header1);
130 TObjString *Header3 = new TObjString("eta_2");
131 HeaderList->Add(Header3);
132
133 ConvCutList->SetOwner(kTRUE);
134 AliConversionCuts **analysisCuts = new AliConversionCuts*[numberOfCuts];
135 MesonCutList->SetOwner(kTRUE);
136 AliConversionMesonCuts **analysisMesonCuts = new AliConversionMesonCuts*[numberOfCuts];
137
138
139 for(Int_t i = 0; i<numberOfCuts; i++){
140
141 analysisCuts[i] = new AliConversionCuts();
142 analysisCuts[i]->InitializeCutsFromCutString(cutarray[i].Data());
143 if (doEtaShiftIndCuts) {
144 analysisCuts[i]->DoEtaShift(doEtaShiftIndCuts);
145 analysisCuts[i]->SetEtaShift(stringShift);
146 }
147
148 ConvCutList->Add(analysisCuts[i]);
149
150 analysisCuts[i]->SetFillCutHistograms("",kFALSE);
151 analysisMesonCuts[i] = new AliConversionMesonCuts();
152 analysisMesonCuts[i]->InitializeCutsFromCutString(mesonCutArray[i].Data());
153 MesonCutList->Add(analysisMesonCuts[i]);
154 analysisMesonCuts[i]->SetFillCutHistograms("");
155 analysisCuts[i]->SetAcceptedHeader(HeaderList);
156 }
157
158 task->SetConversionCutList(numberOfCuts,ConvCutList);
159 task->SetMesonCutList(numberOfCuts,MesonCutList);
160 task->SetMoveParticleAccordingToVertex(kTRUE);
161 task->SetDoMesonAnalysis(kTRUE);
162 task->SetDoMesonQA(enableQAMesonTask); //Attention new switch for Pi0 QA
163 task->SetDoPhotonQA(enableQAMesonTask); //Attention new switch small for Photon QA
164
165 //connect containers
166 AliAnalysisDataContainer *coutput =
167 mgr->CreateContainer(Form("GammaConvV1_%i",trainConfig), TList::Class(),
168 AliAnalysisManager::kOutputContainer,Form("GammaConvV1_%i.root",trainConfig));
169
170 mgr->AddTask(task);
171 mgr->ConnectInput(task,0,cinput);
172 mgr->ConnectOutput(task,1,coutput);
173
174 return;
175
176}