TENDER becomes Tender, removing .so
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / macros / AddTask_GammaCalo_pp.C
1 void AddTask_GammaCalo_pp(  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 enableQAClusterTask = 0, // enable additional QA task
5                               TString fileNameInputForWeighting = "MCSpectraInput.root", // path to file for weigting input
6                               TString cutnumberAODBranch = "0000000060084000001500000" // cutnumber for AOD branch
7                                                         ) {
8
9         // ================= Load Librariers =================================
10         gSystem->Load("libCore");  
11         gSystem->Load("libTree");
12         gSystem->Load("libGeom");
13         gSystem->Load("libVMC");
14         gSystem->Load("libPhysics");
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");
22         gSystem->Load("libSTEER");
23         gSystem->Load("libSTEERBase");
24         gSystem->Load("libTender");
25         gSystem->Load("libTenderSupplies");
26         gSystem->Load("libPWGflowBase");
27         gSystem->Load("libPWGflowTasks");
28         gSystem->Load("libPWGGAGammaConv");
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         Printf("here \n");
49         
50         //=========  Set Cutnumber for V0Reader ================================
51         TString cutnumberPhoton = "060000084001001500000000";
52         TString cutnumberEvent = "0000000";
53         Bool_t doEtaShift = kFALSE;
54         AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
55
56         //========= Add V0 Reader to  ANALYSIS manager if not yet existent =====
57         if( !(AliV0ReaderV1*)mgr->GetTask("V0ReaderV1") ){
58                 AliV0ReaderV1 *fV0ReaderV1 = new AliV0ReaderV1("V0ReaderV1");
59                 
60                 fV0ReaderV1->SetUseOwnXYZCalculation(kTRUE);
61                 fV0ReaderV1->SetCreateAODs(kFALSE);// AOD Output
62                 fV0ReaderV1->SetUseAODConversionPhoton(kTRUE);
63
64                 if (!mgr) {
65                         Error("AddTask_V0ReaderV1", "No analysis manager found.");
66                         return;
67                 }
68                 AliConvEventCuts *fEventCuts=NULL;
69                 if(cutnumberEvent!=""){
70                         fEventCuts= new AliConvEventCuts(cutnumberEvent.Data(),cutnumberEvent.Data());
71                         fEventCuts->SetPreSelectionCutFlag(kTRUE);
72                         if(fEventCuts->InitializeCutsFromCutString(cutnumberEvent.Data())){
73                                 fEventCuts->DoEtaShift(doEtaShift);
74                                 fV0ReaderV1->SetEventCuts(fEventCuts);
75                                 fEventCuts->SetFillCutHistograms("",kTRUE);
76                         }
77                 }
78                 // Set AnalysisCut Number
79                 AliConversionPhotonCuts *fCuts=NULL;
80                 if(cutnumberPhoton!=""){
81                         fCuts= new AliConversionPhotonCuts(cutnumberPhoton.Data(),cutnumberPhoton.Data());
82                         fCuts->SetPreSelectionCutFlag(kTRUE);
83                         fCuts->SetIsHeavyIon(isHeavyIon);
84                         if(fCuts->InitializeCutsFromCutString(cutnumberPhoton.Data())){
85                                 fV0ReaderV1->SetConversionCuts(fCuts);
86                                 fCuts->SetFillCutHistograms("",kTRUE);
87                         }
88                 }
89                 if(inputHandler->IsA()==AliAODInputHandler::Class()){
90                 // AOD mode
91                         fV0ReaderV1->SetDeltaAODBranchName(Form("GammaConv_%s_gamma",cutnumberAODBranch.Data()));
92                 }
93                 fV0ReaderV1->Init();
94
95                 AliLog::SetGlobalLogLevel(AliLog::kFatal);
96
97                 //connect input V0Reader
98                 mgr->AddTask(fV0ReaderV1);
99                 mgr->ConnectInput(fV0ReaderV1,0,cinput);
100         }
101
102         //================================================
103         //========= Add task to the ANALYSIS manager =====
104         //================================================
105         AliAnalysisTaskGammaCalo *task=NULL;
106         task= new AliAnalysisTaskGammaCalo(Form("GammaCalo_%i",trainConfig));
107         task->SetIsHeavyIon(isHeavyIon);
108         task->SetIsMC(isMC);
109         // Cut Numbers to use in Analysis
110         Int_t numberOfCuts = 2;
111         if (trainConfig == 2 || trainConfig == 3) numberOfCuts = 5;
112         if (trainConfig == 5) numberOfCuts = 6;
113         if (trainConfig == 31) numberOfCuts = 4;
114         if (trainConfig == 32) numberOfCuts = 1;
115         
116         TString *eventCutArray = new TString[numberOfCuts];
117         TString *clusterCutArray = new TString[numberOfCuts];
118         TString *mesonCutArray = new TString[numberOfCuts];
119
120         // cluster cuts
121         // 0 "ClusterType",  1 "EtaMin", 2 "EtaMax", 3 "PhiMin", 4 "PhiMax", 5 "DistanceToBadChannel", 6 "Timing", 7 "TrackMatching", 8 "ExoticCell",
122         // 9 "MinEnergy", 10 "MinNCells", 11 "MinM02", 12 "MaxM02", 13 "MinM20", 14 "MaxM20", 15 "MaximumDispersion", 16 "NLM"
123         
124         // ************************************* EMCAL cuts ****************************************************
125         // LHC11a
126         if (trainConfig == 1){ // EMCAL clusters 2.76 TeV LHC11a, with SDD (0), kEMC1 (1)
127                 eventCutArray[ 0] = "0000311"; clusterCutArray[0] = "10000040032030000"; mesonCutArray[0] = "01631031000000"; // 400 MeV cluster min energy
128                 eventCutArray[ 1] = "0005111"; clusterCutArray[1] = "10000040032030000"; mesonCutArray[1] = "01631031000000"; // 400 MeV cluster min energy
129         } else if (trainConfig == 2){ //EMCAL minEnergy variation
130                 eventCutArray[ 0] = "0000311"; clusterCutArray[0] = "10000040012030000"; mesonCutArray[0] = "01631031000000"; //0.2 GeV/c
131                 eventCutArray[ 1] = "0000311"; clusterCutArray[1] = "10000040022030000"; mesonCutArray[1] = "01631031000000"; //0.3 GeV/c
132                 eventCutArray[ 2] = "0000311"; clusterCutArray[2] = "10000040032030000"; mesonCutArray[2] = "01631031000000"; //0.4 GeV/c default
133                 eventCutArray[ 3] = "0000311"; clusterCutArray[3] = "10000040042030000"; mesonCutArray[3] = "01631031000000"; //0.5 GeV/c
134                 eventCutArray[ 4] = "0000311"; clusterCutArray[4] = "10000040052030000"; mesonCutArray[4] = "01631031000000"; //0.6 GeV/c
135         } else if (trainConfig == 3){ //EMCAL minNCells variation
136                 eventCutArray[ 0] = "0000311"; clusterCutArray[0] = "10000040031030000"; mesonCutArray[0] = "01631031000000"; //n cells >= 1
137                 eventCutArray[ 1] = "0000311"; clusterCutArray[1] = "10000040033030000"; mesonCutArray[1] = "01631031000000"; //n cells >= 3
138                 eventCutArray[ 2] = "0000311"; clusterCutArray[2] = "10000040032000000"; mesonCutArray[2] = "01631031000000"; //no M02 cut
139                 eventCutArray[ 3] = "0000311"; clusterCutArray[3] = "10031040032030000"; mesonCutArray[3] = "01631031000000"; //only modules with TRD infront
140                 eventCutArray[ 4] = "0000311"; clusterCutArray[4] = "10012040032030000"; mesonCutArray[4] = "01631031000000"; //no modules with TRD infront             
141         // LHC13g       
142         } else if (trainConfig == 5){  // EMCAL clusters, EMCEGA triggers
143                 eventCutArray[ 0] = "0008311"; clusterCutArray[0] = "10000040032030000"; mesonCutArray[0] = "01631031000000"; // EMCEG1, 
144                 eventCutArray[ 1] = "0008511"; clusterCutArray[1] = "10000040032030000"; mesonCutArray[1] = "01631031000000"; // EMCEG2, 
145                 eventCutArray[ 2] = "0009311"; clusterCutArray[2] = "10000040032030000"; mesonCutArray[2] = "01631031000000"; // EMCEJ1, 
146                 eventCutArray[ 3] = "0009511"; clusterCutArray[3] = "10000040032030000"; mesonCutArray[3] = "01631031000000"; // EMCEJ2, 
147                 eventCutArray[ 4] = "0000011"; clusterCutArray[4] = "10000040032030000"; mesonCutArray[4] = "01631031000000"; // INT7
148                 eventCutArray[ 5] = "0005211"; clusterCutArray[5] = "10000040032030000"; mesonCutArray[5] = "01631031000000"; // EMC7
149
150         // ************************************* PHOS cuts ****************************************************
151         } else if (trainConfig == 31) { //PHOS clusters
152                 eventCutArray[ 0] = "0000311"; clusterCutArray[0] = "20000040033200000"; mesonCutArray[0] = "01631031000000"; //pp LHC11a with SDD, PHOS
153                 eventCutArray[ 1] = "0000011"; clusterCutArray[1] = "20000040033200000"; mesonCutArray[1] = "01631031000000"; //pp LHC13g default MB
154                 eventCutArray[ 2] = "0006111"; clusterCutArray[2] = "20000040033200000"; mesonCutArray[2] = "01631031000000"; //pp LHC11a PHI1
155                 eventCutArray[ 3] = "0006211"; clusterCutArray[3] = "20000040033200000"; mesonCutArray[3] = "01631031000000"; //pp LHC11a PHI7
156         } else if (trainConfig == 32){ // Validation PHOS
157                 eventCutArray[ 0] = "0000311"; clusterCutArray[0] = "20000040033200000"; mesonCutArray[0] = "01630031009000";           
158         } else {
159                 Error(Form("GammaCalo_%i",trainConfig), "wrong trainConfig variable no cuts have been specified for the configuration");
160                 return;
161         }
162
163         TList *EventCutList = new TList();
164         TList *ClusterCutList = new TList();
165         TList *MesonCutList = new TList();
166
167
168         EventCutList->SetOwner(kTRUE);
169         AliConvEventCuts **analysisEventCuts = new AliConvEventCuts*[numberOfCuts];
170         ClusterCutList->SetOwner(kTRUE);
171         AliCaloPhotonCuts **analysisClusterCuts = new AliCaloPhotonCuts*[numberOfCuts];
172         MesonCutList->SetOwner(kTRUE);
173         AliConversionMesonCuts **analysisMesonCuts = new AliConversionMesonCuts*[numberOfCuts];
174
175         for(Int_t i = 0; i<numberOfCuts; i++){
176                 analysisEventCuts[i] = new AliConvEventCuts();   
177                 analysisEventCuts[i]->InitializeCutsFromCutString(eventCutArray[i].Data());
178                 EventCutList->Add(analysisEventCuts[i]);
179                 analysisEventCuts[i]->SetFillCutHistograms("",kFALSE);
180                         
181                 analysisClusterCuts[i] = new AliCaloPhotonCuts();
182                 analysisClusterCuts[i]->InitializeCutsFromCutString(clusterCutArray[i].Data());
183                 ClusterCutList->Add(analysisClusterCuts[i]);
184                 analysisClusterCuts[i]->SetFillCutHistograms("");
185                 
186                 analysisMesonCuts[i] = new AliConversionMesonCuts();
187                 analysisMesonCuts[i]->InitializeCutsFromCutString(mesonCutArray[i].Data());
188                 MesonCutList->Add(analysisMesonCuts[i]);
189                 analysisMesonCuts[i]->SetFillCutHistograms("");
190         }
191         task->SetEventCutList(numberOfCuts,EventCutList);
192         task->SetCaloCutList(numberOfCuts,ClusterCutList);
193         task->SetMesonCutList(numberOfCuts,MesonCutList);
194         task->SetDoMesonAnalysis(kTRUE);
195         task->SetDoMesonQA(enableQAMesonTask); //Attention new switch for Pi0 QA
196         task->SetDoClusterQA(enableQAClusterTask);  //Attention new switch small for Cluster QA
197
198         //connect containers
199         AliAnalysisDataContainer *coutput =
200                 mgr->CreateContainer(Form("GammaCalo_%i",trainConfig), TList::Class(),
201                                                         AliAnalysisManager::kOutputContainer,Form("GammaCalo_%i.root",trainConfig));
202
203         mgr->AddTask(task);
204         mgr->ConnectInput(task,0,cinput);
205         mgr->ConnectOutput(task,1,coutput);
206
207         return;
208
209 }