31aab34bb1d432579fe85871fd2fe41825bbb537
[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("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                 // Set AnalysisCut Number
75                 AliConversionPhotonCuts *fCuts=NULL;
76                 if(cutnumberPhoton!=""){
77                         fCuts= new AliConversionPhotonCuts(cutnumberPhoton.Data(),cutnumberPhoton.Data());
78                         fCuts->SetPreSelectionCutFlag(kTRUE);
79                         fCuts->SetIsHeavyIon(isHeavyIon);
80                         if(fCuts->InitializeCutsFromCutString(cutnumberPhoton.Data())){
81                                 fV0ReaderV1->SetConversionCuts(fCuts);
82                                 fCuts->SetFillCutHistograms("",kTRUE);
83                         }
84                 }
85                 if(inputHandler->IsA()==AliAODInputHandler::Class()){
86                 // AOD mode
87                         fV0ReaderV1->SetDeltaAODBranchName(Form("GammaConv_%s_gamma",cutnumberAODBranch.Data()));
88                 }
89                 fV0ReaderV1->Init();
90
91                 AliLog::SetGlobalLogLevel(AliLog::kInfo);
92
93                 //connect input V0Reader
94                 mgr->AddTask(fV0ReaderV1);
95                 mgr->ConnectInput(fV0ReaderV1,0,cinput);
96
97         }
98
99         //================================================
100         //========= Add task to the ANALYSIS manager =====
101         //================================================
102         AliAnalysisTaskGammaConvV1 *task=NULL;
103         task= new AliAnalysisTaskGammaConvV1(Form("GammaConvV1_%i",trainConfig));
104         task->SetIsHeavyIon(isHeavyIon);
105         task->SetIsMC(isMC);
106         // Cut Numbers to use in Analysis
107         Int_t numberOfCuts = 1;
108
109         TString *eventCutArray = new TString[numberOfCuts];
110         TString *photonCutArray = new TString[numberOfCuts];
111         TString *mesonCutArray = new TString[numberOfCuts];
112
113         if (trainConfig == 1){ 
114                 eventCutArray[ 0] = "0000012"; photonCutArray[ 0] = "002093663003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Pi0 pp 2.76TeV without SDD , only boxes
115         } else if (trainConfig == 2) { 
116                 eventCutArray[ 0] = "0000012"; photonCutArray[ 0] = "002093663003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Pi0 pp 2.76TeV without SDD, V0AND , only boxes
117         } else if (trainConfig == 3) { 
118                 eventCutArray[ 0] = "0000012"; photonCutArray[ 0] = "002093260003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Gamma pp 2-76TeV , only boxes
119         } else if (trainConfig == 4) { 
120                 eventCutArray[ 0] = "0000011"; photonCutArray[ 0] = "002093663003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Pi0 pp 2.76TeV without SDD , only Minbias MC
121         } else if (trainConfig == 5) { 
122                 eventCutArray[ 0] = "0001011"; photonCutArray[ 0] = "002093663003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Pi0 pp 2.76TeV without SDD, V0AND
123         } else if (trainConfig == 6) { 
124                 eventCutArray[ 0] = "0000011"; photonCutArray[ 0] = "002093260003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Gamma pp 2-76TeV
125         } else if (trainConfig == 7) {    
126                 eventCutArray[ 0] = "0002011"; photonCutArray[ 0] = "002093663003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Pi0 pp 2.76TeV with SDD , only Minbias MC
127         } else if (trainConfig == 8) {    
128                 eventCutArray[ 0] = "0003011"; photonCutArray[ 0] = "002093663003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Pi0 pp 2.76TeV with SDD, V0AND , only Minbias MC
129         } else if (trainConfig == 9) {    
130                 eventCutArray[ 0] = "0002012"; photonCutArray[ 0] = "002093663003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Pi0 pp 2.76TeV with SDD , only Boxes MC
131         } else if (trainConfig == 10) { 
132                 eventCutArray[ 0] = "0003012"; photonCutArray[ 0] = "002093663003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Pi0 pp 2.76TeV with SDD, V0AND, only Boxes MC
133         } else if (trainConfig == 11) { 
134                 eventCutArray[ 0] = "0000011"; photonCutArray[ 0] = "002093663003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Pi0 pp 2.76TeV without SDD , all photon qualities
135         } else if (trainConfig == 12) { 
136                 eventCutArray[ 0] = "0000011"; photonCutArray[ 0] = "007093663003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Pi0 pp 2.76TeV without SDD , all photon qualities, min R = 35 cm
137         } else if (trainConfig == 13) { 
138                 eventCutArray[ 0] = "0002011"; photonCutArray[ 0] = "002093663003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Pi0 pp 2.76TeV with SDD , all photon qualities
139         } else if (trainConfig == 14) { 
140                 eventCutArray[ 0] = "0002011"; photonCutArray[ 0] = "007093663003800000000"; mesonCutArray[0] = "01631031009000"; //standard cut Pi0 pp 2.76TeV with SDD , all photon qualities, min R = 35 cm
141         } else if (trainConfig == 15) { 
142                 eventCutArray[ 0] = "0000011"; photonCutArray[ 0] = "002092970028250400000"; mesonCutArray[0] = "01525065000000"; //standard cut LHC11h pp 2.76TeV 
143         } else if (trainConfig == 16) { 
144                 eventCutArray[ 0] = "0000011"; photonCutArray[ 0] = "002092570028250400000"; mesonCutArray[0] = "01521065000000"; //standard cut pp 8 TeV               
145         } else {
146                 Error(Form("GammaConvV1_%i",trainConfig), "wrong trainConfig variable no cuts have been specified for the configuration");
147                 return;
148         }
149
150         TList *EventCutList = new TList();
151         TList *ConvCutList = new TList();
152         TList *MesonCutList = new TList();
153
154         TList *HeaderList = new TList();
155         TObjString *Header2 = new TObjString("BOX");
156         HeaderList->Add(Header2);
157
158         EventCutList->SetOwner(kTRUE);
159         AliConvEventCuts **analysisEventCuts = new AliConvEventCuts*[numberOfCuts];
160         ConvCutList->SetOwner(kTRUE);
161         AliConversionPhotonCuts **analysisCuts = new AliConversionPhotonCuts*[numberOfCuts];
162         MesonCutList->SetOwner(kTRUE);
163         AliConversionMesonCuts **analysisMesonCuts = new AliConversionMesonCuts*[numberOfCuts];
164
165
166         for(Int_t i = 0; i<numberOfCuts; i++){
167                 analysisEventCuts[i] = new AliConvEventCuts();
168                 analysisEventCuts[i]->InitializeCutsFromCutString(eventCutArray[i].Data());
169                 EventCutList->Add(analysisEventCuts[i]);
170                 analysisEventCuts[i]->SetFillCutHistograms("",kFALSE);
171                 
172                 analysisCuts[i] = new AliConversionPhotonCuts();
173                 analysisCuts[i]->InitializeCutsFromCutString(photonCutArray[i].Data());
174                 ConvCutList->Add(analysisCuts[i]);
175                 analysisCuts[i]->SetFillCutHistograms("",kFALSE);
176
177                 analysisMesonCuts[i] = new AliConversionMesonCuts();
178                 analysisMesonCuts[i]->InitializeCutsFromCutString(mesonCutArray[i].Data());
179                 MesonCutList->Add(analysisMesonCuts[i]);
180                 analysisMesonCuts[i]->SetFillCutHistograms("");
181                 
182                 analysisEventCuts[i]->SetAcceptedHeader(HeaderList);
183         }
184
185         task->SetEventCutList(numberOfCuts,EventCutList);
186         task->SetConversionCutList(numberOfCuts,ConvCutList);
187         task->SetMesonCutList(numberOfCuts,MesonCutList);
188         task->SetMoveParticleAccordingToVertex(kTRUE);
189         task->SetDoMesonAnalysis(kTRUE);
190         task->SetDoMesonQA(enableQAMesonTask); //Attention new switch for Pi0 QA
191         task->SetDoPhotonQA(enableQAPhotonTask);  //Attention new switch small for Photon QA
192
193         //connect containers
194         AliAnalysisDataContainer *coutput =
195                 mgr->CreateContainer(Form("GammaConvV1_%i",trainConfig), TList::Class(),
196                                                         AliAnalysisManager::kOutputContainer,Form("GammaConvV1_%i.root",trainConfig));
197
198         mgr->AddTask(task);
199         mgr->ConnectInput(task,0,cinput);
200         mgr->ConnectOutput(task,1,coutput);
201
202         return;
203
204 }