- fixed MC routines in CaloConv task, added corresponding addtasks
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / macros / AddTask_GammaConvCalo_pPb.C
CommitLineData
8bdca7f1 1void AddTask_GammaConvCalo_pPb( 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",
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
344100c4 30 Int_t isHeavyIon = 2;
31
8bdca7f1 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");
344100c4 45 AddTaskPIDResponse(isMC);
8bdca7f1 46 }
47
48 Printf("here \n");
49
50 //========= Set Cutnumber for V0Reader ================================
344100c4 51 TString cutnumberPhoton = "060084001001500000000";
52 TString cutnumberEvent = "8000000";
53 Bool_t doEtaShift = kFALSE;
8bdca7f1 54 AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
55
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
344100c4 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
8bdca7f1 80 // Set AnalysisCut Number
344100c4 81 AliConversionPhotonCuts *fCuts=NULL;
82 if(cutnumberPhoton!=""){
83 fCuts= new AliConversionPhotonCuts(cutnumberPhoton.Data(),cutnumberPhoton.Data());
8bdca7f1 84 fCuts->SetPreSelectionCutFlag(kTRUE);
344100c4 85 fCuts->SetIsHeavyIon(isHeavyIon);
86 if(fCuts->InitializeCutsFromCutString(cutnumberPhoton.Data())){
8bdca7f1 87 fV0ReaderV1->SetConversionCuts(fCuts);
88 fCuts->SetFillCutHistograms("",kTRUE);
89 }
90 }
91 if(inputHandler->IsA()==AliAODInputHandler::Class()){
92 // AOD mode
93 fV0ReaderV1->SetDeltaAODBranchName(Form("GammaConv_%s_gamma",cutnumberAODBranch.Data()));
94 }
95 fV0ReaderV1->Init();
96
97 AliLog::SetGlobalLogLevel(AliLog::kFatal);
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 AliAnalysisTaskGammaConvCalo *task=NULL;
109 task= new AliAnalysisTaskGammaConvCalo(Form("GammaConvCalo_%i",trainConfig));
344100c4 110 task->SetIsHeavyIon(isHeavyIon);
8bdca7f1 111 task->SetIsMC(isMC);
112 // Cut Numbers to use in Analysis
113 Int_t numberOfCuts = 2;
114
344100c4 115 TString *eventCutArray = new TString[numberOfCuts];
116 TString *photonCutArray = new TString[numberOfCuts];
117 TString *clusterCutArray = new TString[numberOfCuts];
8bdca7f1 118 TString *mesonCutArray = new TString[numberOfCuts];
119
120 // cluster cuts
121 // 0 "ClusterType", 1 "EtaMin", 2 "EtaMax", 3 "PhiMin", 4 "PhiMax", 5 "DistanceToBadChannel", 6 "Timing", 7 "TrackMatching", 8 "ExoticCell",
122 // 9 "MinEnergy", 10 "MinNCells", 11 "MinM02", 12 "MaxM02", 13 "MinM20", 14 "MaxM20", 15 "MaximumDispersion", 16 "NLM"
123
124 if (trainConfig == 1){
344100c4 125 eventCutArray[ 0] = "8000001"; photonCutArray[ 0] = "002092970028250400000"; clusterCutArray[0] = "10000040022030000"; mesonCutArray[0] = "01525065000000"; //standart cut, kINT7 // EMCAL clusters
126 eventCutArray[ 1] = "8005201"; photonCutArray[ 1] = "002092970028250400000"; clusterCutArray[1] = "10000040022030000"; mesonCutArray[1] = "01525065000000"; //standard cut, kEMC7 // EMCAL clusters
9df9736d 127 } else if (trainConfig == 2) {
344100c4 128 eventCutArray[ 0] = "8000001"; photonCutArray[ 0] = "002092970028250400000"; clusterCutArray[0] = "20000030022000000"; mesonCutArray[0] = "01525065000000"; //standart cut, kINT7 // PHOS clusters
129 eventCutArray[ 1] = "8006201"; photonCutArray[ 1] = "002092970028250400000"; clusterCutArray[1] = "20000030022000000"; mesonCutArray[1] = "01525065000000"; //standard cut, kPHI7 // PHOS clusters
8bdca7f1 130 } else {
131 Error(Form("GammaConvCalo_%i",trainConfig), "wrong trainConfig variable no cuts have been specified for the configuration");
132 return;
133 }
134
344100c4 135 TList *EventCutList = new TList();
8bdca7f1 136 TList *ConvCutList = new TList();
137 TList *ClusterCutList = new TList();
138 TList *MesonCutList = new TList();
139
140 TList *HeaderList = new TList();
141 if (doWeightingPart==1) {
142 TObjString *Header1 = new TObjString("pi0_1");
143 HeaderList->Add(Header1);
144 }
145 if (doWeightingPart==2){
146 TObjString *Header3 = new TObjString("eta_2");
147 HeaderList->Add(Header3);
148 }
149 if (doWeightingPart==3) {
150 TObjString *Header1 = new TObjString("pi0_1");
151 HeaderList->Add(Header1);
152 TObjString *Header3 = new TObjString("eta_2");
153 HeaderList->Add(Header3);
154 }
155
344100c4 156 EventCutList->SetOwner(kTRUE);
157 AliConvEventCuts **analysisEventCuts = new AliConvEventCuts*[numberOfCuts];
8bdca7f1 158 ConvCutList->SetOwner(kTRUE);
344100c4 159 AliConversionPhotonCuts **analysisCuts = new AliConversionPhotonCuts*[numberOfCuts];
8bdca7f1 160 ClusterCutList->SetOwner(kTRUE);
161 AliCaloPhotonCuts **analysisClusterCuts = new AliCaloPhotonCuts*[numberOfCuts];
162 MesonCutList->SetOwner(kTRUE);
163 AliConversionMesonCuts **analysisMesonCuts = new AliConversionMesonCuts*[numberOfCuts];
164
165 for(Int_t i = 0; i<numberOfCuts; i++){
344100c4 166 analysisEventCuts[i] = new AliConvEventCuts();
167 analysisEventCuts[i]->InitializeCutsFromCutString(eventCutArray[i].Data());
168 EventCutList->Add(analysisEventCuts[i]);
169 analysisEventCuts[i]->SetFillCutHistograms("",kFALSE);
170
171 analysisCuts[i] = new AliConversionPhotonCuts();
172 analysisCuts[i]->InitializeCutsFromCutString(photonCutArray[i].Data());
173 analysisCuts[i]->SetIsHeavyIon(isHeavyIon);
8bdca7f1 174 ConvCutList->Add(analysisCuts[i]);
175 analysisCuts[i]->SetFillCutHistograms("",kFALSE);
344100c4 176
8bdca7f1 177 analysisClusterCuts[i] = new AliCaloPhotonCuts();
344100c4 178 analysisClusterCuts[i]->InitializeCutsFromCutString(clusterCutArray[i].Data());
8bdca7f1 179 ClusterCutList->Add(analysisClusterCuts[i]);
180 analysisClusterCuts[i]->SetFillCutHistograms("");
181
182 analysisMesonCuts[i] = new AliConversionMesonCuts();
183 analysisMesonCuts[i]->InitializeCutsFromCutString(mesonCutArray[i].Data());
184 MesonCutList->Add(analysisMesonCuts[i]);
185 analysisMesonCuts[i]->SetFillCutHistograms("");
344100c4 186 analysisEventCuts[i]->SetAcceptedHeader(HeaderList);
8bdca7f1 187 }
188
344100c4 189 task->SetEventCutList(numberOfCuts,EventCutList);
8bdca7f1 190 task->SetConversionCutList(numberOfCuts,ConvCutList);
191 task->SetCaloCutList(numberOfCuts,ClusterCutList);
192 task->SetMesonCutList(numberOfCuts,MesonCutList);
193 task->SetMoveParticleAccordingToVertex(kTRUE);
194 task->SetDoMesonAnalysis(kTRUE);
195 task->SetDoMesonQA(enableQAMesonTask); //Attention new switch for Pi0 QA
196 task->SetDoPhotonQA(enableQAPhotonTask); //Attention new switch small for Photon QA
fd94f234 197 task->SetDoClusterQA(1); //Attention new switch small for Cluster QA
8bdca7f1 198
199 //connect containers
200 AliAnalysisDataContainer *coutput =
201 mgr->CreateContainer(Form("GammaConvCalo_%i",trainConfig), TList::Class(),
202 AliAnalysisManager::kOutputContainer,Form("GammaConvCalo_%i.root",trainConfig));
203
204 mgr->AddTask(task);
205 mgr->ConnectInput(task,0,cinput);
206 mgr->ConnectOutput(task,1,coutput);
207
208 return;
209
210}