- changed cut selections for all calo related tasks, changed definition of cuts for...
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / macros / AddTask_GammaConvCalo_pp.C
CommitLineData
8bdca7f1 1void AddTask_GammaConvCalo_pp( Int_t trainConfig = 1, //change different set of cuts
2 Bool_t isMC = kFALSE, //run MC
3 Int_t enableQAMesonTask = 1, //enable QA in AliAnalysisTaskGammaConvV1
4 Int_t enableQAPhotonTask = 1, // enable additional QA task
5 TString fileNameInputForWeighting = "MCSpectraInput.root", // path to file for weigting input
4e8dcc76 6 TString cutnumberAODBranch = "0000000060084001001500000",
7 Bool_t enableExtendedMatching = kFALSE //enable or disable extended matching histograms for conversion electrons <-> cluster
8bdca7f1 8 ) {
9
10 // ================= Load Librariers =================================
11 gSystem->Load("libCore.so");
12 gSystem->Load("libTree.so");
13 gSystem->Load("libGeom.so");
14 gSystem->Load("libVMC.so");
15 gSystem->Load("libPhysics.so");
16 gSystem->Load("libMinuit");
17 gSystem->Load("libSTEERBase");
18 gSystem->Load("libESD");
19 gSystem->Load("libAOD");
20 gSystem->Load("libANALYSIS");
21 gSystem->Load("libANALYSISalice");
8bdca7f1 22 gSystem->Load("libCDB.so");
23 gSystem->Load("libSTEER.so");
24 gSystem->Load("libSTEERBase.so");
25 gSystem->Load("libTENDER.so");
26 gSystem->Load("libTENDERSupplies.so");
4e1b9acf 27 gSystem->Load("libPWGflowBase.so");
28 gSystem->Load("libPWGflowTasks.so");
29 gSystem->Load("libPWGGAGammaConv.so");
30
344100c4 31 Int_t isHeavyIon = 0;
32
8bdca7f1 33 // ================== GetAnalysisManager ===============================
34 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
35 if (!mgr) {
36 Error(Form("AddTask_GammaConvV1_%i",trainConfig), "No analysis manager found.");
37 return ;
38 }
39
40 // ================== GetInputEventHandler =============================
41 AliVEventHandler *inputHandler=mgr->GetInputEventHandler();
42
43 //========= Add PID Reponse to ANALYSIS manager ====
44 if(!(AliPIDResponse*)mgr->GetTask("PIDResponseTask")){
45 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
344100c4 46 AddTaskPIDResponse(isMC);
8bdca7f1 47 }
48
ed8bc1ca 49 Printf("here \n");
50
8bdca7f1 51 //========= Set Cutnumber for V0Reader ================================
ed8bc1ca 52 TString cutnumberPhoton = "060084001001500000000";
344100c4 53 TString cutnumberEvent = "0000000";
ed8bc1ca 54 Bool_t doEtaShift = kFALSE;
8bdca7f1 55 AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
56
57 //========= Add V0 Reader to ANALYSIS manager if not yet existent =====
58 if( !(AliV0ReaderV1*)mgr->GetTask("V0ReaderV1") ){
59 AliV0ReaderV1 *fV0ReaderV1 = new AliV0ReaderV1("V0ReaderV1");
60
61 fV0ReaderV1->SetUseOwnXYZCalculation(kTRUE);
62 fV0ReaderV1->SetCreateAODs(kFALSE);// AOD Output
63 fV0ReaderV1->SetUseAODConversionPhoton(kTRUE);
64
65 if (!mgr) {
66 Error("AddTask_V0ReaderV1", "No analysis manager found.");
67 return;
68 }
69
344100c4 70 AliConvEventCuts *fEventCuts=NULL;
71 if(cutnumberEvent!=""){
72 fEventCuts= new AliConvEventCuts(cutnumberEvent.Data(),cutnumberEvent.Data());
73 fEventCuts->SetPreSelectionCutFlag(kTRUE);
74 if(fEventCuts->InitializeCutsFromCutString(cutnumberEvent.Data())){
ed8bc1ca 75 fEventCuts->DoEtaShift(doEtaShift);
344100c4 76 fV0ReaderV1->SetEventCuts(fEventCuts);
77 fEventCuts->SetFillCutHistograms("",kTRUE);
78 }
79 }
80
8bdca7f1 81 // Set AnalysisCut Number
344100c4 82 AliConversionPhotonCuts *fCuts=NULL;
83 if(cutnumberPhoton!=""){
84 fCuts= new AliConversionPhotonCuts(cutnumberPhoton.Data(),cutnumberPhoton.Data());
8bdca7f1 85 fCuts->SetPreSelectionCutFlag(kTRUE);
344100c4 86 fCuts->SetIsHeavyIon(isHeavyIon);
87 if(fCuts->InitializeCutsFromCutString(cutnumberPhoton.Data())){
8bdca7f1 88 fV0ReaderV1->SetConversionCuts(fCuts);
89 fCuts->SetFillCutHistograms("",kTRUE);
90 }
91 }
92 if(inputHandler->IsA()==AliAODInputHandler::Class()){
93 // AOD mode
94 fV0ReaderV1->SetDeltaAODBranchName(Form("GammaConv_%s_gamma",cutnumberAODBranch.Data()));
95 }
96 fV0ReaderV1->Init();
97
98 AliLog::SetGlobalLogLevel(AliLog::kFatal);
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 AliAnalysisTaskGammaConvCalo *task=NULL;
110 task= new AliAnalysisTaskGammaConvCalo(Form("GammaConvCalo_%i",trainConfig));
ed8bc1ca 111 task->SetIsHeavyIon(isHeavyIon);
8bdca7f1 112 task->SetIsMC(isMC);
113 // Cut Numbers to use in Analysis
0e006b2c 114 Int_t numberOfCuts = 2;
115 if (trainConfig==2 || trainConfig==3 || trainConfig==4 ){ numberOfCuts =5;}
116 if (trainConfig==5 || trainConfig==31 || trainConfig==32 ){ numberOfCuts =6;}
117
344100c4 118 TString *eventCutArray = new TString[numberOfCuts];
119 TString *photonCutArray = new TString[numberOfCuts];
120 TString *clusterCutArray = new TString[numberOfCuts];
8bdca7f1 121 TString *mesonCutArray = new TString[numberOfCuts];
122
ed8bc1ca 123 // cluster cuts
124 // 0 "ClusterType", 1 "EtaMin", 2 "EtaMax", 3 "PhiMin", 4 "PhiMax", 5 "DistanceToBadChannel", 6 "Timing", 7 "TrackMatching", 8 "ExoticCell",
125 // 9 "MinEnergy", 10 "MinNCells", 11 "MinM02", 12 "MaxM02", 13 "MinM20", 14 "MaxM20", 15 "MaximumDispersion", 16 "NLM"
0e006b2c 126
127 // ************************************* EMCAL cuts ****************************************************
128 // LHC11a
129 if (trainConfig == 1){ // EMCAL clusters 2.76 TeV LHC11a, with SDD (0), kEMC1 (1)
130 eventCutArray[ 0] = "0000311"; photonCutArray[ 0] = "002093663003800000000"; clusterCutArray[0] = "10000042032030000"; mesonCutArray[0] = "01631031009000"; // 400 MeV cluster min energy
131 eventCutArray[ 1] = "0005111"; photonCutArray[ 1] = "002093663003800000000"; clusterCutArray[1] = "10000042032030000"; mesonCutArray[1] = "01631031009000"; // 400 MeV cluster min energy
132 } else if (trainConfig == 2){ //EMCAL minEnergy variation
133 eventCutArray[ 0] = "0000311"; photonCutArray[ 0] = "002093663003800000000"; clusterCutArray[0] = "10000042012030000"; mesonCutArray[0] = "01525065000000"; //0.2 GeV/c
134 eventCutArray[ 1] = "0000311"; photonCutArray[ 1] = "002093663003800000000"; clusterCutArray[1] = "10000042022030000"; mesonCutArray[1] = "01525065000000"; //0.3 GeV/c
135 eventCutArray[ 2] = "0000311"; photonCutArray[ 2] = "002093663003800000000"; clusterCutArray[2] = "10000042032030000"; mesonCutArray[2] = "01525065000000"; //0.4 GeV/c default
136 eventCutArray[ 3] = "0000311"; photonCutArray[ 3] = "002093663003800000000"; clusterCutArray[3] = "10000042042030000"; mesonCutArray[3] = "01525065000000"; //0.5 GeV/c
137 eventCutArray[ 4] = "0000311"; photonCutArray[ 4] = "002093663003800000000"; clusterCutArray[4] = "10000042052030000"; mesonCutArray[4] = "01525065000000"; //0.6 GeV/c
138 } else if (trainConfig == 3){ //EMCAL minNCells variation
139 eventCutArray[ 0] = "0000311"; photonCutArray[ 0] = "002093663003800000000"; clusterCutArray[0] = "10000042031030000"; mesonCutArray[0] = "01525065000000"; //n cells >= 1
140 eventCutArray[ 1] = "0000311"; photonCutArray[ 1] = "002093663003800000000"; clusterCutArray[1] = "10000042033030000"; mesonCutArray[1] = "01525065000000"; //n cells >= 3
141 eventCutArray[ 2] = "0000311"; photonCutArray[ 2] = "002093663003800000000"; clusterCutArray[2] = "10000042032000000"; mesonCutArray[2] = "01525065000000"; //no M02 cut
142 eventCutArray[ 3] = "0000311"; photonCutArray[ 3] = "002093663003800000000"; clusterCutArray[3] = "10031042032030000"; mesonCutArray[3] = "01525065000000"; //only modules with TRD infront
143 eventCutArray[ 4] = "0000311"; photonCutArray[ 4] = "002093663003800000000"; clusterCutArray[4] = "10012042032030000"; mesonCutArray[4] = "01525065000000"; //no modules with TRD infront
144 } else if (trainConfig == 4){ // EMCAL track matching variations
145 eventCutArray[ 0] = "0000311"; photonCutArray[ 0] = "002093663003800000000"; clusterCutArray[0] = "10000041032030000"; mesonCutArray[0] = "01631031009000"; //
146 eventCutArray[ 1] = "0000311"; photonCutArray[ 1] = "002093663003800000000"; clusterCutArray[1] = "10000042032030000"; mesonCutArray[1] = "01631031009000"; //
147 eventCutArray[ 2] = "0000311"; photonCutArray[ 2] = "002093663003800000000"; clusterCutArray[2] = "10000043032030000"; mesonCutArray[2] = "01631031009000"; //
148 eventCutArray[ 3] = "0000311"; photonCutArray[ 3] = "002093663003800000000"; clusterCutArray[3] = "10000044032030000"; mesonCutArray[3] = "01631031009000"; //
149 eventCutArray[ 4] = "0000311"; photonCutArray[ 4] = "002093663003800000000"; clusterCutArray[4] = "10000045032030000"; mesonCutArray[4] = "01631031009000"; //
150 // LHC13g
ed8bc1ca 151 } else if (trainConfig == 5){ // EMCAL clusters, EMCEGA triggers, track matching 0.035
0e006b2c 152 eventCutArray[ 0] = "0008311"; photonCutArray[ 0] = "002093663003800000000"; clusterCutArray[0] = "10000042032030000"; mesonCutArray[0] = "01631031009000"; // EMCEG1,
153 eventCutArray[ 1] = "0008511"; photonCutArray[ 1] = "002093663003800000000"; clusterCutArray[1] = "10000042032030000"; mesonCutArray[1] = "01631031009000"; // EMCEG2,
154 eventCutArray[ 2] = "0009311"; photonCutArray[ 2] = "002093663003800000000"; clusterCutArray[2] = "10000042032030000"; mesonCutArray[2] = "01631031009000"; // EMCEJ1,
155 eventCutArray[ 3] = "0009511"; photonCutArray[ 3] = "002093663003800000000"; clusterCutArray[3] = "10000042032030000"; mesonCutArray[3] = "01631031009000"; // EMCEJ2,
156 eventCutArray[ 4] = "0000011"; photonCutArray[ 4] = "002093663003800000000"; clusterCutArray[4] = "10000042032030000"; mesonCutArray[4] = "01631031009000"; // INT7
157 eventCutArray[ 5] = "0005211"; photonCutArray[ 5] = "002093663003800000000"; clusterCutArray[5] = "10000042032030000"; mesonCutArray[5] = "01631031009000"; // EMC7
158
159 // ************************************* PHOS cuts ****************************************************
160 // LHC11a
161 } else if (trainConfig == 31) { //PHOS clusters
162 eventCutArray[ 0] = "0000311"; photonCutArray[ 0] = "002093663003800000000"; clusterCutArray[0] = "20000041033200000"; mesonCutArray[0] = "01631031009000";
163 eventCutArray[ 1] = "0000311"; photonCutArray[ 1] = "002093663003800000000"; clusterCutArray[1] = "20000042033200000"; mesonCutArray[1] = "01631031009000";
164 eventCutArray[ 2] = "0000311"; photonCutArray[ 2] = "002093663003800000000"; clusterCutArray[2] = "20000043033200000"; mesonCutArray[2] = "01631031009000";
165 eventCutArray[ 3] = "0006111"; photonCutArray[ 3] = "002093663003800000000"; clusterCutArray[3] = "20000041033200000"; mesonCutArray[3] = "01631031009000";
166 eventCutArray[ 4] = "0006111"; photonCutArray[ 4] = "002093663003800000000"; clusterCutArray[4] = "20000042033200000"; mesonCutArray[4] = "01631031009000";
167 eventCutArray[ 5] = "0006111"; photonCutArray[ 5] = "002093663003800000000"; clusterCutArray[5] = "20000043033200000"; mesonCutArray[5] = "01631031009000";
168 // LHC13g & LHC12x
169 } else if (trainConfig == 32) { //PHOS clusters
170 eventCutArray[ 0] = "0000011"; photonCutArray[ 0] = "002093663003800000000"; clusterCutArray[0] = "20000041033200000"; mesonCutArray[0] = "01631031009000";
171 eventCutArray[ 1] = "0000011"; photonCutArray[ 1] = "002093663003800000000"; clusterCutArray[1] = "20000042033200000"; mesonCutArray[1] = "01631031009000";
172 eventCutArray[ 2] = "0000011"; photonCutArray[ 2] = "002093663003800000000"; clusterCutArray[2] = "20000043033200000"; mesonCutArray[2] = "01631031009000";
173 eventCutArray[ 3] = "0006211"; photonCutArray[ 3] = "002093663003800000000"; clusterCutArray[3] = "20000041033200000"; mesonCutArray[3] = "01631031009000";
174 eventCutArray[ 4] = "0006211"; photonCutArray[ 4] = "002093663003800000000"; clusterCutArray[4] = "20000042033200000"; mesonCutArray[4] = "01631031009000";
175 eventCutArray[ 5] = "0006211"; photonCutArray[ 5] = "002093663003800000000"; clusterCutArray[5] = "20000043033200000"; mesonCutArray[5] = "01631031009000";
8bdca7f1 176 } else {
177 Error(Form("GammaConvCalo_%i",trainConfig), "wrong trainConfig variable no cuts have been specified for the configuration");
178 return;
179 }
180
344100c4 181 TList *EventCutList = new TList();
8bdca7f1 182 TList *ConvCutList = new TList();
135c1186 183 TList *ClusterCutList = new TList();
8bdca7f1 184 TList *MesonCutList = new TList();
185
ed8bc1ca 186// TList *HeaderList = new TList();
187// if (doWeightingPart==1) {
188// TObjString *Header1 = new TObjString("pi0_1");
189// HeaderList->Add(Header1);
190// }
191// if (doWeightingPart==2){
192// TObjString *Header3 = new TObjString("eta_2");
193// HeaderList->Add(Header3);
194// }
195// if (doWeightingPart==3) {
196// TObjString *Header1 = new TObjString("pi0_1");
197// HeaderList->Add(Header1);
198// TObjString *Header3 = new TObjString("eta_2");
199// HeaderList->Add(Header3);
200// }
8bdca7f1 201
344100c4 202 EventCutList->SetOwner(kTRUE);
203 AliConvEventCuts **analysisEventCuts = new AliConvEventCuts*[numberOfCuts];
8bdca7f1 204 ConvCutList->SetOwner(kTRUE);
344100c4 205 AliConversionPhotonCuts **analysisCuts = new AliConversionPhotonCuts*[numberOfCuts];
8bdca7f1 206 ClusterCutList->SetOwner(kTRUE);
207 AliCaloPhotonCuts **analysisClusterCuts = new AliCaloPhotonCuts*[numberOfCuts];
208 MesonCutList->SetOwner(kTRUE);
209 AliConversionMesonCuts **analysisMesonCuts = new AliConversionMesonCuts*[numberOfCuts];
210
211 for(Int_t i = 0; i<numberOfCuts; i++){
ed8bc1ca 212 analysisEventCuts[i] = new AliConvEventCuts();
344100c4 213 analysisEventCuts[i]->InitializeCutsFromCutString(eventCutArray[i].Data());
214 EventCutList->Add(analysisEventCuts[i]);
215 analysisEventCuts[i]->SetFillCutHistograms("",kFALSE);
ed8bc1ca 216
344100c4 217 analysisCuts[i] = new AliConversionPhotonCuts();
218 analysisCuts[i]->InitializeCutsFromCutString(photonCutArray[i].Data());
ed8bc1ca 219 analysisCuts[i]->SetIsHeavyIon(isHeavyIon);
8bdca7f1 220 ConvCutList->Add(analysisCuts[i]);
221 analysisCuts[i]->SetFillCutHistograms("",kFALSE);
ed8bc1ca 222
8bdca7f1 223 analysisClusterCuts[i] = new AliCaloPhotonCuts();
344100c4 224 analysisClusterCuts[i]->InitializeCutsFromCutString(clusterCutArray[i].Data());
8bdca7f1 225 ClusterCutList->Add(analysisClusterCuts[i]);
4e8dcc76 226 analysisClusterCuts[i]->SetExtendedMatching(enableExtendedMatching);
8bdca7f1 227 analysisClusterCuts[i]->SetFillCutHistograms("");
ed8bc1ca 228
8bdca7f1 229 analysisMesonCuts[i] = new AliConversionMesonCuts();
230 analysisMesonCuts[i]->InitializeCutsFromCutString(mesonCutArray[i].Data());
231 MesonCutList->Add(analysisMesonCuts[i]);
232 analysisMesonCuts[i]->SetFillCutHistograms("");
ed8bc1ca 233// analysisEventCuts[i]->SetAcceptedHeader(HeaderList);
8bdca7f1 234 }
235
344100c4 236 task->SetEventCutList(numberOfCuts,EventCutList);
8bdca7f1 237 task->SetConversionCutList(numberOfCuts,ConvCutList);
238 task->SetCaloCutList(numberOfCuts,ClusterCutList);
239 task->SetMesonCutList(numberOfCuts,MesonCutList);
240 task->SetMoveParticleAccordingToVertex(kTRUE);
241 task->SetDoMesonAnalysis(kTRUE);
242 task->SetDoMesonQA(enableQAMesonTask); //Attention new switch for Pi0 QA
243 task->SetDoPhotonQA(enableQAPhotonTask); //Attention new switch small for Photon QA
fd94f234 244 task->SetDoClusterQA(1); //Attention new switch small for Cluster QA
ed8bc1ca 245
8bdca7f1 246 //connect containers
247 AliAnalysisDataContainer *coutput =
248 mgr->CreateContainer(Form("GammaConvCalo_%i",trainConfig), TList::Class(),
249 AliAnalysisManager::kOutputContainer,Form("GammaConvCalo_%i.root",trainConfig));
250
251 mgr->AddTask(task);
252 mgr->ConnectInput(task,0,cinput);
253 mgr->ConnectOutput(task,1,coutput);
254
255 return;
256
257}