TENDER becomes Tender
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / macros / AddTask_GammaConvV1_pp2.C
1 void AddTask_GammaConvV1_pp2(  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                               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("libCDB.so");
22         gSystem->Load("libSTEER.so");
23         gSystem->Load("libSTEERBase.so");
24         gSystem->Load("libTender.so");
25         gSystem->Load("libTenderSupplies.so");
26         gSystem->Load("libPWGflowBase.so");
27         gSystem->Load("libPWGflowTasks.so");
28         gSystem->Load("libPWGGAGammaConv.so");
29
30         Int_t isHeavyIon = 0;   
31            
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");
45                 AddTaskPIDResponse(isMC);
46         }
47         
48         //=========  Set Cutnumber for V0Reader ================================
49                 TString cutnumberPhoton = "002000084000002200000000";
50                 TString cutnumberEvent = "0000000"; 
51                 AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
52
53         //========= Add V0 Reader to  ANALYSIS manager if not yet existent =====
54         if( !(AliV0ReaderV1*)mgr->GetTask("V0ReaderV1") ){
55                 AliV0ReaderV1 *fV0ReaderV1 = new AliV0ReaderV1("V0ReaderV1");
56                 
57                 fV0ReaderV1->SetUseOwnXYZCalculation(kTRUE);
58                 fV0ReaderV1->SetCreateAODs(kFALSE);// AOD Output
59                 fV0ReaderV1->SetUseAODConversionPhoton(kTRUE);
60
61                 if (!mgr) {
62                         Error("AddTask_V0ReaderV1", "No analysis manager found.");
63                         return;
64                 }
65
66                 AliConvEventCuts *fEventCuts=NULL;
67                 if(cutnumberEvent!=""){
68                         fEventCuts= new AliConvEventCuts(cutnumberEvent.Data(),cutnumberEvent.Data());
69                         fEventCuts->SetPreSelectionCutFlag(kTRUE);
70                         if(fEventCuts->InitializeCutsFromCutString(cutnumberEvent.Data())){
71                                 fV0ReaderV1->SetEventCuts(fEventCuts);
72                                 fEventCuts->SetFillCutHistograms("",kTRUE);
73                         }
74                 }
75
76                 // Set AnalysisCut Number
77                 AliConversionPhotonCuts *fCuts=NULL;
78                 if(cutnumberPhoton!=""){
79                         fCuts= new AliConversionPhotonCuts(cutnumberPhoton.Data(),cutnumberPhoton.Data());
80                         fCuts->SetPreSelectionCutFlag(kTRUE);
81                         fCuts->SetIsHeavyIon(isHeavyIon);
82                         if(fCuts->InitializeCutsFromCutString(cutnumberPhoton.Data())){
83                                 fV0ReaderV1->SetConversionCuts(fCuts);
84                                 fCuts->SetFillCutHistograms("",kTRUE);
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::kInfo);
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         AliAnalysisTaskGammaConvV1 *task=NULL;
105         task= new AliAnalysisTaskGammaConvV1(Form("GammaConvV1_%i",trainConfig));
106         task->SetIsHeavyIon(isHeavyIon);
107         task->SetIsMC(isMC);
108         // Cut Numbers to use in Analysis
109         Int_t numberOfCuts = 1;
110
111         TString *eventCutArray = new TString[numberOfCuts];
112         TString *photonCutArray = new TString[numberOfCuts];
113         TString *mesonCutArray = new TString[numberOfCuts];
114
115         if (trainConfig == 1){ 
116                 eventCutArray[ 0] = "0000012"; photonCutArray[ 0] = "002000093663003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Pi0 pp 2.76TeV without SDD , only boxes
117         } else if (trainConfig == 2) { 
118                 eventCutArray[ 0] = "0000012"; photonCutArray[ 0] = "002000093663003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Pi0 pp 2.76TeV without SDD, V0AND , only boxes
119         } else if (trainConfig == 3) { 
120                 eventCutArray[ 0] = "0000012"; photonCutArray[ 0] = "002000093260003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Gamma pp 2-76TeV , only boxes
121         } else if (trainConfig == 4) { 
122                 eventCutArray[ 0] = "0000011"; photonCutArray[ 0] = "002000093663003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Pi0 pp 2.76TeV without SDD , only Minbias MC
123         } else if (trainConfig == 5) { 
124                 eventCutArray[ 0] = "0001011"; photonCutArray[ 0] = "002000093663003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Pi0 pp 2.76TeV without SDD, V0AND
125         } else if (trainConfig == 6) { 
126                 eventCutArray[ 0] = "0000011"; photonCutArray[ 0] = "002000093260003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Gamma pp 2-76TeV
127         } else if (trainConfig == 7) {    
128                 eventCutArray[ 0] = "0000311"; photonCutArray[ 0] = "002000093663003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Pi0 pp 2.76TeV with SDD , only Minbias MC
129         } else if (trainConfig == 8) {    
130                 eventCutArray[ 0] = "0001311"; photonCutArray[ 0] = "002000093663003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Pi0 pp 2.76TeV with SDD, V0AND , only Minbias MC
131         } else if (trainConfig == 9) {    
132                 eventCutArray[ 0] = "0000312"; photonCutArray[ 0] = "002000093663003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Pi0 pp 2.76TeV with SDD , only Boxes MC
133         } else if (trainConfig == 10) { 
134                 eventCutArray[ 0] = "0001312"; photonCutArray[ 0] = "002000093663003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Pi0 pp 2.76TeV with SDD, V0AND, only Boxes MC
135         } else if (trainConfig == 11) { 
136                 eventCutArray[ 0] = "0000011"; photonCutArray[ 0] = "002000093663003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Pi0 pp 2.76TeV without SDD , all photon qualities
137         } else if (trainConfig == 12) { 
138                 eventCutArray[ 0] = "0000011"; photonCutArray[ 0] = "007000093663003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Pi0 pp 2.76TeV without SDD , all photon qualities, min R = 35 cm
139         } else if (trainConfig == 13) { 
140                 eventCutArray[ 0] = "0000311"; photonCutArray[ 0] = "002000093663003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Pi0 pp 2.76TeV with SDD , all photon qualities
141         } else if (trainConfig == 14) { 
142                 eventCutArray[ 0] = "0000311"; photonCutArray[ 0] = "007000093663003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Pi0 pp 2.76TeV with SDD , all photon qualities, min R = 35 cm
143         } else if (trainConfig == 15) { 
144                 eventCutArray[ 0] = "0000011"; photonCutArray[ 0] = "002000092970028250400000"; mesonCutArray[0] = "01525065000000"; //standard cut LHC11h pp 2.76TeV 
145         } else if (trainConfig == 16) { 
146                 eventCutArray[ 0] = "0000011"; photonCutArray[ 0] = "002000092570028250400000"; mesonCutArray[0] = "01521065000000"; //standard cut pp 8 TeV            
147         } else {
148                 Error(Form("GammaConvV1_%i",trainConfig), "wrong trainConfig variable no cuts have been specified for the configuration");
149                 return;
150         }
151
152         TList *EventCutList = new TList();
153         TList *ConvCutList = new TList();
154         TList *MesonCutList = new TList();
155
156         TList *HeaderList = new TList();
157         TObjString *Header2 = new TObjString("BOX");
158         HeaderList->Add(Header2);
159
160         EventCutList->SetOwner(kTRUE);
161         AliConvEventCuts **analysisEventCuts = new AliConvEventCuts*[numberOfCuts];
162         ConvCutList->SetOwner(kTRUE);
163         AliConversionPhotonCuts **analysisCuts = new AliConversionPhotonCuts*[numberOfCuts];
164         MesonCutList->SetOwner(kTRUE);
165         AliConversionMesonCuts **analysisMesonCuts = new AliConversionMesonCuts*[numberOfCuts];
166
167
168         for(Int_t i = 0; i<numberOfCuts; i++){
169                 analysisEventCuts[i] = new AliConvEventCuts();
170                 analysisEventCuts[i]->InitializeCutsFromCutString(eventCutArray[i].Data());
171                 EventCutList->Add(analysisEventCuts[i]);
172                 analysisEventCuts[i]->SetFillCutHistograms("",kFALSE);
173                 
174                 analysisCuts[i] = new AliConversionPhotonCuts();
175                 analysisCuts[i]->InitializeCutsFromCutString(photonCutArray[i].Data());
176                 ConvCutList->Add(analysisCuts[i]);
177                 analysisCuts[i]->SetFillCutHistograms("",kFALSE);
178
179                 analysisMesonCuts[i] = new AliConversionMesonCuts();
180                 analysisMesonCuts[i]->InitializeCutsFromCutString(mesonCutArray[i].Data());
181                 MesonCutList->Add(analysisMesonCuts[i]);
182                 analysisMesonCuts[i]->SetFillCutHistograms("");
183                 
184                 analysisEventCuts[i]->SetAcceptedHeader(HeaderList);
185         }
186
187         task->SetEventCutList(numberOfCuts,EventCutList);
188         task->SetConversionCutList(numberOfCuts,ConvCutList);
189         task->SetMesonCutList(numberOfCuts,MesonCutList);
190         task->SetMoveParticleAccordingToVertex(kTRUE);
191         task->SetDoMesonAnalysis(kTRUE);
192         task->SetDoMesonQA(enableQAMesonTask); //Attention new switch for Pi0 QA
193         task->SetDoPhotonQA(enableQAPhotonTask);  //Attention new switch small for Photon QA
194
195         //connect containers
196         AliAnalysisDataContainer *coutput =
197                 mgr->CreateContainer(Form("GammaConvV1_%i",trainConfig), TList::Class(),
198                                                         AliAnalysisManager::kOutputContainer,Form("GammaConvV1_%i.root",trainConfig));
199
200         mgr->AddTask(task);
201         mgr->ConnectInput(task,0,cinput);
202         mgr->ConnectOutput(task,1,coutput);
203
204         return;
205
206 }