fix minor bug: add task argument was not passed to tak
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / macros / AddTask_GammaConvCalo_pp.C
1 void 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
6                                                                 TString cutnumberAODBranch = "0000000060084001001500000" 
7                                                         ) {
8
9         // ================= Load Librariers =================================
10         gSystem->Load("libCore.so");  
11         gSystem->Load("libTree.so");
12         gSystem->Load("libGeom.so");
13         gSystem->Load("libVMC.so");
14         gSystem->Load("libPhysics.so");
15         gSystem->Load("libMinuit");
16         gSystem->Load("libSTEERBase");
17         gSystem->Load("libESD");
18         gSystem->Load("libAOD");
19         gSystem->Load("libANALYSIS");
20         gSystem->Load("libANALYSISalice");  
21         gSystem->Load("libPWGGAGammaConv.so");
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");
27                 
28         Int_t isHeavyIon = 0;
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 cutnumberPhoton = "002084000002200000000";
48         TString cutnumberEvent = "0000000";
49         AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
50
51         //========= Add V0 Reader to  ANALYSIS manager if not yet existent =====
52         if( !(AliV0ReaderV1*)mgr->GetTask("V0ReaderV1") ){
53                 AliV0ReaderV1 *fV0ReaderV1 = new AliV0ReaderV1("V0ReaderV1");
54                 
55                 fV0ReaderV1->SetUseOwnXYZCalculation(kTRUE);
56                 fV0ReaderV1->SetCreateAODs(kFALSE);// AOD Output
57                 fV0ReaderV1->SetUseAODConversionPhoton(kTRUE);
58
59                 if (!mgr) {
60                         Error("AddTask_V0ReaderV1", "No analysis manager found.");
61                         return;
62                 }
63
64                 AliConvEventCuts *fEventCuts=NULL;
65                 if(cutnumberEvent!=""){
66                         fEventCuts= new AliConvEventCuts(cutnumberEvent.Data(),cutnumberEvent.Data());
67                         fEventCuts->SetPreSelectionCutFlag(kTRUE);
68                         if(fEventCuts->InitializeCutsFromCutString(cutnumberEvent.Data())){
69                                 fV0ReaderV1->SetEventCuts(fEventCuts);
70                                 fEventCuts->SetFillCutHistograms("",kTRUE);
71                         }
72                 }
73
74                 
75                 // Set AnalysisCut Number
76                 AliConversionPhotonCuts *fCuts=NULL;
77                 if(cutnumberPhoton!=""){
78                         fCuts= new AliConversionPhotonCuts(cutnumberPhoton.Data(),cutnumberPhoton.Data());
79                         fCuts->SetPreSelectionCutFlag(kTRUE);
80                         fCuts->SetIsHeavyIon(isHeavyIon);
81                         if(fCuts->InitializeCutsFromCutString(cutnumberPhoton.Data())){
82                                 fV0ReaderV1->SetConversionCuts(fCuts);
83                                 fCuts->SetFillCutHistograms("",kTRUE);
84                         }
85                 }
86
87                 if(inputHandler->IsA()==AliAODInputHandler::Class()){
88                 // AOD mode
89                         fV0ReaderV1->SetDeltaAODBranchName(Form("GammaConv_%s_gamma",cutnumberAODBranch.Data()));
90                 }
91                 fV0ReaderV1->Init();
92
93                 AliLog::SetGlobalLogLevel(AliLog::kFatal);
94
95                 //connect input V0Reader
96                 mgr->AddTask(fV0ReaderV1);
97                 mgr->ConnectInput(fV0ReaderV1,0,cinput);
98
99         }
100
101         //================================================
102         //========= Add task to the ANALYSIS manager =====
103         //================================================
104         AliAnalysisTaskGammaConvCalo *task=NULL;
105         task= new AliAnalysisTaskGammaConvCalo(Form("GammaConvCalo_%i",trainConfig));
106         task->SetIsHeavyIon(0);
107         task->SetIsMC(isMC);
108         // Cut Numbers to use in Analysis
109         Int_t numberOfCuts = 3;
110
111         TString *eventCutArray = new TString[numberOfCuts];
112         TString *photonCutArray = new TString[numberOfCuts];
113         TString *clusterCutArray = new TString[numberOfCuts];
114         TString *mesonCutArray = new TString[numberOfCuts];
115
116         // meson cuts
117         // meson type (Dalitz or not), BG scheme, pool depth, rotation degrees, rapidity cut, radius cut, alpha, chi2, shared electrons, reject to close v0, MC smearing, dca, dca, dca
118         
119         if (trainConfig == 1){ 
120                 eventCutArray[ 0] = "0000001"; photonCutArray[ 0] = "002092970028250400000"; clusterCutArray[0] = "10000040022030000"; mesonCutArray[0] = "01525065000000"; //standard cut LHC11h pp 2.76TeV, kMB // EMCAL clusters
121                 eventCutArray[ 1] = "0005101"; photonCutArray[ 1] = "002092970028250400000"; clusterCutArray[1] = "10000040022030000"; mesonCutArray[1] = "01525065000000"; //standard cut LHC11h pp 2.76TeV, kEMC1 // EMCAL clusters
122                 eventCutArray[ 2] = "0002001"; photonCutArray[ 2] = "002092970028250400000"; clusterCutArray[2] = "10000040022030000"; mesonCutArray[2] = "01525065000000"; //standard cut LHC11h pp 2.76TeV, SDD V0OR // EMCAL clusters
123         } else if (trainConfig == 2){ 
124                 eventCutArray[ 0] = "0000001"; photonCutArray[ 0] = "002092970028250400000"; clusterCutArray[0] = "20000030022000000"; mesonCutArray[0] = "01525065000000"; //standard cut LHC11h pp 2.76TeV, kMB   // PHOS clusters
125                 eventCutArray[ 1] = "0006101"; photonCutArray[ 1] = "002092970028250400000"; clusterCutArray[1] = "20000030022000000"; mesonCutArray[1] = "01525065000000"; //standard cut LHC11h pp 2.76TeV, kPHI1 // PHOS clusters
126                 eventCutArray[ 2] = "0002001"; photonCutArray[ 2] = "002092970028250400000"; clusterCutArray[2] = "20000030022000000"; mesonCutArray[2] = "01525065000000"; //standard cut LHC11h pp 2.76TeV, SDD V0OR //PHOS clusters
127         } else {
128                 Error(Form("GammaConvCalo_%i",trainConfig), "wrong trainConfig variable no cuts have been specified for the configuration");
129                 return;
130         }
131
132         TList *EventCutList = new TList();
133         TList *ConvCutList = new TList();
134         TList *ClusterCutList = new TList();
135         TList *MesonCutList = new TList();
136
137         TList *HeaderList = new TList();
138         TObjString *Header1 = new TObjString("BOX");
139         HeaderList->Add(Header1);
140
141         EventCutList->SetOwner(kTRUE);
142         AliConvEventCuts **analysisEventCuts = new AliConvEventCuts*[numberOfCuts];
143         ConvCutList->SetOwner(kTRUE);
144         AliConversionPhotonCuts **analysisCuts = new AliConversionPhotonCuts*[numberOfCuts];
145         ClusterCutList->SetOwner(kTRUE);
146         AliCaloPhotonCuts **analysisClusterCuts = new AliCaloPhotonCuts*[numberOfCuts];
147         MesonCutList->SetOwner(kTRUE);
148         AliConversionMesonCuts **analysisMesonCuts = new AliConversionMesonCuts*[numberOfCuts];
149
150         for(Int_t i = 0; i<numberOfCuts; i++){
151                 analysisEventCuts[i] = new AliConvEventCuts();
152                 analysisEventCuts[i]->InitializeCutsFromCutString(eventCutArray[i].Data());
153                 EventCutList->Add(analysisEventCuts[i]);
154                 analysisEventCuts[i]->SetFillCutHistograms("",kFALSE);
155
156                 analysisCuts[i] = new AliConversionPhotonCuts();
157                 analysisCuts[i]->InitializeCutsFromCutString(photonCutArray[i].Data());
158                 ConvCutList->Add(analysisCuts[i]);
159                 analysisCuts[i]->SetFillCutHistograms("",kFALSE);
160                 
161                 analysisClusterCuts[i] = new AliCaloPhotonCuts();
162                 analysisClusterCuts[i]->InitializeCutsFromCutString(clusterCutArray[i].Data());
163                 ClusterCutList->Add(analysisClusterCuts[i]);
164                 analysisClusterCuts[i]->SetFillCutHistograms("");
165
166                 analysisMesonCuts[i] = new AliConversionMesonCuts();
167                 analysisMesonCuts[i]->InitializeCutsFromCutString(mesonCutArray[i].Data());
168                 MesonCutList->Add(analysisMesonCuts[i]);
169                 analysisMesonCuts[i]->SetFillCutHistograms("");
170                 analysisEventCuts[i]->SetAcceptedHeader(HeaderList);
171         }
172
173         task->SetEventCutList(numberOfCuts,EventCutList);
174         task->SetConversionCutList(numberOfCuts,ConvCutList);
175         task->SetCaloCutList(numberOfCuts,ClusterCutList);
176         task->SetMesonCutList(numberOfCuts,MesonCutList);
177         task->SetMoveParticleAccordingToVertex(kTRUE);
178         task->SetDoMesonAnalysis(kTRUE);
179         task->SetDoMesonQA(enableQAMesonTask); //Attention new switch for Pi0 QA
180         task->SetDoPhotonQA(enableQAPhotonTask);  //Attention new switch small for Photon QA
181
182         //connect containers
183         AliAnalysisDataContainer *coutput =
184                 mgr->CreateContainer(Form("GammaConvCalo_%i",trainConfig), TList::Class(),
185                                                         AliAnalysisManager::kOutputContainer,Form("GammaConvCalo_%i.root",trainConfig));
186
187         mgr->AddTask(task);
188         mgr->ConnectInput(task,0,cinput);
189         mgr->ConnectOutput(task,1,coutput);
190
191         return;
192
193 }