TENDER becomes Tender, removing .so
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / macros / AddTask_GammaConvEtaPiPlPiMiGamma_pPb.C
1 void AddTask_GammaConvEtaPiPlPiMiGamma_pPb(    
2                                                                                 Int_t trainConfig = 1,
3                                                                                 Bool_t isMC       = kFALSE, //run MC 
4                                                                                 Bool_t enableQAMesonTask = kTRUE, //enable QA in AliAnalysisTaskEtaToPiPlPiMiGamma
5                                                                                 TString fileNameInputForWeighting = "MCSpectraInput.root", // path to file for weigting input
6                                                                                 Bool_t doWeighting = kFALSE,  //enable Weighting
7                                                                                 TString generatorName = "HIJING",                               
8                                                                                 TString cutnumberAODBranch = "0000000060084001001500000"
9                                                                                 ) {
10
11         // ================= Load Librariers =================================
12         gSystem->Load("libCore");  
13         gSystem->Load("libTree");
14         gSystem->Load("libGeom");
15         gSystem->Load("libVMC");
16         gSystem->Load("libPhysics");
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("libCDB");
24         gSystem->Load("libSTEER");
25         gSystem->Load("libSTEERBase");
26         gSystem->Load("libTender");
27         gSystem->Load("libTenderSupplies");
28         gSystem->Load("libPWGflowBase");
29         gSystem->Load("libPWGflowTasks");
30         gSystem->Load("libPWGGAGammaConv");
31
32         Int_t isHeavyIon = 2;
33         
34         // ================== GetAnalysisManager ===============================
35         AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
36         if (!mgr) {
37                 Error(Form("AddTask_GammaConvEtaPiPlPiMiGamma_pPb_%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 ================================
51         TString cutnumberPhoton = "060000084001001500000000";
52         TString cutnumberEvent = "8000000";
53         TString PionCuts      = "000000200";            //Electron Cuts
54                 
55         Bool_t doEtaShift = kFALSE;
56
57         AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
58         
59         //========= Add V0 Reader to  ANALYSIS manager if not yet existent =====
60         if( !(AliV0ReaderV1*)mgr->GetTask("V0ReaderV1") ){
61                 AliV0ReaderV1 *fV0ReaderV1 = new AliV0ReaderV1("V0ReaderV1");
62                 
63                 fV0ReaderV1->SetUseOwnXYZCalculation(kTRUE);
64                 fV0ReaderV1->SetCreateAODs(kFALSE);// AOD Output
65                 fV0ReaderV1->SetUseAODConversionPhoton(kTRUE);
66                 
67                 if (!mgr) {
68                         Error("AddTask_V0ReaderV1", "No analysis manager found.");
69                         return;
70                 }
71
72                 AliConvEventCuts *fEventCuts=NULL;
73                 if(cutnumberEvent!=""){
74                         fEventCuts= new AliConvEventCuts(cutnumberEvent.Data(),cutnumberEvent.Data());
75                         fEventCuts->SetPreSelectionCutFlag(kTRUE);
76                         if(fEventCuts->InitializeCutsFromCutString(cutnumberEvent.Data())){
77                                 fEventCuts->DoEtaShift(doEtaShift);
78                                 fV0ReaderV1->SetEventCuts(fEventCuts);
79                                 fEventCuts->SetFillCutHistograms("",kTRUE);
80                         }
81                 }
82
83                 // Set AnalysisCut Number
84                 AliConversionPhotonCuts *fCuts=NULL;
85                 if(cutnumberPhoton!=""){
86                         fCuts= new AliConversionPhotonCuts(cutnumberPhoton.Data(),cutnumberPhoton.Data());
87                         fCuts->SetPreSelectionCutFlag(kTRUE);
88                         fCuts->SetIsHeavyIon(isHeavyIon);
89                         if(fCuts->InitializeCutsFromCutString(cutnumberPhoton.Data())){
90                                 fV0ReaderV1->SetConversionCuts(fCuts);
91                                 fCuts->SetFillCutHistograms("",kTRUE);
92                         }
93                 }
94
95                 if(inputHandler->IsA()==AliAODInputHandler::Class()){
96                 // AOD mode
97                         fV0ReaderV1->SetDeltaAODBranchName(Form("GammaConv_%s_gamma",cutnumberAODBranch.Data()));
98                 }
99                 fV0ReaderV1->Init();
100
101                 AliLog::SetGlobalLogLevel(AliLog::kInfo);
102
103                 //connect input V0Reader
104                 mgr->AddTask(fV0ReaderV1);
105                 mgr->ConnectInput(fV0ReaderV1,0,cinput);
106         }
107
108         //================================================
109         //========= Add Electron Selector ================
110
111
112         if( !(AliPrimaryPionSelector*)mgr->GetTask("PionSelector") ){
113
114                 AliPrimaryPionSelector *fPionSelector = new AliPrimaryPionSelector("PionSelector");
115                 // Set AnalysisCut Number
116
117                 AliPrimaryPionCuts *fPionCuts=0;
118                 if( PionCuts!=""){
119                         fPionCuts= new AliPrimaryPionCuts(PionCuts.Data(),PionCuts.Data());
120                         if(fPionCuts->InitializeCutsFromCutString(PionCuts.Data())){
121                                 fPionSelector->SetPrimaryPionCuts(fPionCuts);
122                                 fPionCuts->SetFillCutHistograms("",kTRUE);
123
124                         }
125                 }
126
127                 fPionSelector->Init();
128                 mgr->AddTask(fPionSelector);
129                 
130                 AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer();
131
132                 //connect input V0Reader
133                 mgr->ConnectInput (fPionSelector,0,cinput1);
134
135         }
136
137         
138         
139         AliAnalysisTaskEtaToPiPlPiMiGamma *task=NULL;
140
141         task= new AliAnalysisTaskEtaToPiPlPiMiGamma(Form("GammaConvEtaPiPlPiMiGamma_%i",trainConfig));
142
143         task->SetIsHeavyIon(2);
144         task->SetIsMC(isMC);
145
146         // Cut Numbers to use in Analysis
147         Int_t numberOfCuts = 1;
148
149         TString *eventCutArray = new TString[numberOfCuts];
150         TString *ConvCutarray    = new TString[numberOfCuts];
151         TString *PionCutarray    = new TString[numberOfCuts];
152         TString *MesonCutarray   = new TString[numberOfCuts];
153
154         Bool_t doEtaShiftIndCuts = kFALSE;
155         TString stringShift = "";
156
157         // Shifting in pPb direction
158
159         doEtaShiftIndCuts = kTRUE;
160         stringShift = "pPb";
161
162         if( trainConfig == 1 ) {
163                 eventCutArray[ 0] = "8000011"; ConvCutarray[0] = "002000091170008260400000"; PionCutarray[0] = "000000400"; MesonCutarray[0] = "01035035000000"; //standard cut Pi0 PbPb 00-100                 
164         } else if( trainConfig == 1 ) {
165                 eventCutArray[ 0] = "8000011"; ConvCutarray[0] = "002000091170008260400000"; PionCutarray[0] = "000000403"; MesonCutarray[0] = "01035035000000"; //standard cut Pi0 PbPb 00-100                 
166         } else if( trainConfig == 1 ) {
167                 eventCutArray[ 0] = "8000011"; ConvCutarray[0] = "002000091170008260400000"; PionCutarray[0] = "000000404"; MesonCutarray[0] = "01035035000000"; //standard cut Pi0 PbPb 00-100                 
168         } else if( trainConfig == 1 ) {
169                 eventCutArray[ 0] = "8000011"; ConvCutarray[0] = "002000091170008260400000"; PionCutarray[0] = "000000405"; MesonCutarray[0] = "01035035000000"; //standard cut Pi0 PbPb 00-100                 
170         }
171         
172         TList *EventCutList = new TList();
173         TList *ConvCutList  = new TList();
174         TList *MesonCutList = new TList();
175         TList *PionCutList  = new TList();
176
177         TList *HeaderList = new TList();
178         TObjString *Header1 = new TObjString("pi0_1");
179         HeaderList->Add(Header1);
180         TObjString *Header3 = new TObjString("eta_2");
181         HeaderList->Add(Header3);
182         
183         EventCutList->SetOwner(kTRUE);
184         AliConvEventCuts **analysisEventCuts = new AliConvEventCuts*[numberOfCuts];
185         ConvCutList->SetOwner(kTRUE);
186         AliConversionPhotonCuts **analysisCuts = new AliConversionPhotonCuts*[numberOfCuts];
187         MesonCutList->SetOwner(kTRUE);
188         AliConversionMesonCuts **analysisMesonCuts   = new AliConversionMesonCuts*[numberOfCuts];
189         PionCutList->SetOwner(kTRUE);
190         AliPrimaryPionCuts **analysisPionCuts     = new AliPrimaryPionCuts*[numberOfCuts];
191
192         for(Int_t i = 0; i<numberOfCuts; i++){
193                 analysisEventCuts[i] = new AliConvEventCuts();   
194                 analysisEventCuts[i]->InitializeCutsFromCutString(eventCutArray[i].Data());
195                 EventCutList->Add(analysisEventCuts[i]);
196                 analysisEventCuts[i]->SetFillCutHistograms("",kFALSE);
197
198                 analysisCuts[i] = new AliConversionPhotonCuts();
199                 if( ! analysisCuts[i]->InitializeCutsFromCutString(ConvCutarray[i].Data()) ) {
200                                 cout<<"ERROR: analysisCuts [" <<i<<"]"<<endl;
201                                 return 0;
202                 } else {                                
203                         ConvCutList->Add(analysisCuts[i]);
204                         analysisCuts[i]->SetFillCutHistograms("",kFALSE);
205                         
206                 }
207
208                 analysisMesonCuts[i] = new AliConversionMesonCuts();
209                 
210                 if( ! analysisMesonCuts[i]->InitializeCutsFromCutString(MesonCutarray[i].Data()) ) {
211                         cout<<"ERROR: analysisMesonCuts [ " <<i<<" ] "<<endl;
212                         return 0;
213                 } else {
214                         MesonCutList->Add(analysisMesonCuts[i]);
215                         analysisMesonCuts[i]->SetFillCutHistograms("");
216                 }
217                 analysisEventCuts[i]->SetAcceptedHeader(HeaderList);
218                 
219                 TString cutName( Form("%s_%s_%s_%s",eventCutArray[i].Data(), ConvCutarray[i].Data(),PionCutarray[i].Data(),MesonCutarray[i].Data() ) );
220                 analysisPionCuts[i] = new AliPrimaryPionCuts();
221                 if( !analysisPionCuts[i]->InitializeCutsFromCutString(PionCutarray[i].Data())) {
222                         cout<< "ERROR:  analysisPionCuts [ " <<i<<" ] "<<endl;
223                         return 0;
224                 } else { 
225                         PionCutList->Add(analysisPionCuts[i]);
226                         analysisPionCuts[i]->SetFillCutHistograms("",kFALSE,cutName); 
227                 }
228                 
229
230         }
231
232         task->SetEventCutList(numberOfCuts,EventCutList);
233         task->SetConversionCutList(numberOfCuts,ConvCutList);
234         task->SetMesonCutList(MesonCutList);
235         task->SetPionCutList(PionCutList);
236
237         task->SetMoveParticleAccordingToVertex(kTRUE);
238
239         if(enableQAMesonTask) task->SetDoMesonQA(kTRUE);
240
241         //connect containers
242         AliAnalysisDataContainer *coutput =
243         mgr->CreateContainer(Form("GammaConvEtaPiPlPiMiGamma_%i",trainConfig), TList::Class(),
244                                                         AliAnalysisManager::kOutputContainer,Form("GammaConvEtaPiPlPiMiGamma_%i.root",trainConfig));
245
246         mgr->AddTask(task);
247         mgr->ConnectInput(task,0,cinput);
248         mgr->ConnectOutput(task,1,coutput);
249
250         return;
251
252 }