TENDER becomes Tender
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / macros / AddTask_Resolution.C
1 void AddTask_Resolution(        TString V0ReaderEventCutNumber  = "8000000",
2                                                         TString V0ReaderPhotonCutNumber = "060000084001001500000000",
3                                                         TString TaskEventCutnumber              = "8000011",
4                                                         TString TaskPhotonCutnumber     = "092000092170008260400000",
5                                                         Bool_t IsMC = kTRUE, 
6                                                         Int_t IsHeavyIon = 0, 
7                                                         TString cutnumberAODBranch = "0000000060084001001500000",
8                                                         Bool_t doEtaShiftV0Reader = kFALSE 
9                        ){
10         
11         //get the current analysis manager
12         // ================= Load Librariers =================================
13         gSystem->Load("libCore.so");  
14         gSystem->Load("libTree.so");
15         gSystem->Load("libGeom.so");
16         gSystem->Load("libVMC.so");
17         gSystem->Load("libPhysics.so");
18         gSystem->Load("libMinuit");
19         gSystem->Load("libSTEERBase");
20         gSystem->Load("libESD");
21         gSystem->Load("libAOD");
22         gSystem->Load("libANALYSIS");
23         gSystem->Load("libANALYSISalice");  
24         gSystem->Load("libCDB.so");
25         gSystem->Load("libSTEER.so");
26         gSystem->Load("libSTEERBase.so");
27         gSystem->Load("libTender.so");
28         gSystem->Load("libTenderSupplies.so");
29         gSystem->Load("libPWGflowBase.so");
30         gSystem->Load("libPWGflowTasks.so");
31         gSystem->Load("libPWGGAGammaConv.so");
32         
33         // ================== GetAnalysisManager ===============================
34         AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
35         if (!mgr) {
36                 Error(Form("AddTask_GammaConvV1_%i",trainConfig), "No analysis manager found.");
37                 return ;
38         }
39
40         // ================== GetInputEventHandler =============================
41         AliVEventHandler *inputHandler=mgr->GetInputEventHandler();
42         
43         //========= Add PID Reponse to ANALYSIS manager ====
44         if(!(AliPIDResponse*)mgr->GetTask("PIDResponseTask")){
45                 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
46                 AddTaskPIDResponse(isMC);
47         }
48
49         AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
50         if( !(AliV0ReaderV1*)mgr->GetTask("V0ReaderV1") ){
51                 AliV0ReaderV1 *fV0ReaderV1 = new AliV0ReaderV1("V0ReaderV1");
52                 
53                 fV0ReaderV1->SetUseOwnXYZCalculation(kTRUE);
54                 fV0ReaderV1->SetCreateAODs(kFALSE);// AOD Output
55                 fV0ReaderV1->SetUseAODConversionPhoton(kTRUE);
56
57                 if (!mgr) {
58                         Error("AddTask_V0ReaderV1", "No analysis manager found.");
59                         return;
60                 }
61
62                 AliConvEventCuts *fEventCuts=NULL;
63                 if(V0ReaderEventCutNumber!=""){
64                         fEventCuts= new AliConvEventCuts(V0ReaderEventCutNumber.Data(),V0ReaderEventCutNumber.Data());
65                         fEventCuts->SetPreSelectionCutFlag(kTRUE);
66                         if(fEventCuts->InitializeCutsFromCutString(V0ReaderEventCutNumber.Data())){
67                                 fV0ReaderV1->SetEventCuts(fEventCuts);
68                                 fEventCuts->SetFillCutHistograms("",kTRUE);
69                                 if (IsHeavyIon==2){
70                                         fEventCuts->SelectCollisionCandidates(AliVEvent::kINT7);
71                                         fEventCuts->DoEtaShift(doEtaShiftV0Reader);
72                                 }
73                         }
74                 }
75
76                 // Set AnalysisCut Number
77                 AliConversionPhotonCuts *fCuts=NULL;
78                 if(V0ReaderPhotonCutNumber!=""){
79                         fCuts= new AliConversionPhotonCuts(V0ReaderPhotonCutNumber.Data(),V0ReaderPhotonCutNumber.Data());
80                         fCuts->SetPreSelectionCutFlag(kTRUE);
81                         fCuts->SetIsHeavyIon(IsHeavyIon);
82                         if(fCuts->InitializeCutsFromCutString(V0ReaderPhotonCutNumber.Data())){
83                                 fV0ReaderV1->SetConversionCuts(fCuts);
84                                 fCuts->SetFillCutHistograms("",kTRUE);
85                         }
86                 }
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::kInfo);
96
97                 //connect input V0Reader
98                 mgr->AddTask(fV0ReaderV1);
99                 mgr->ConnectInput(fV0ReaderV1,0,cinput);
100
101         } else {
102                 Error("AddTask_V0ReaderV1", "Cannot execute AddTask, V0ReaderV1 already exists.");
103         }   
104
105         AliConvEventCuts *analysisEventCuts = new AliConvEventCuts();
106         analysisEventCuts->InitializeCutsFromCutString(TaskEventCutnumber.Data());
107         analysisEventCuts->SetFillCutHistograms("",kFALSE);
108
109         AliConversionPhotonCuts *analysisCuts = new AliConversionPhotonCuts();
110         analysisCuts->InitializeCutsFromCutString(TaskPhotonCutnumber.Data());
111         analysisCuts->SetFillCutHistograms("",kFALSE);
112
113         AliAnalysisTaskResolution *fResolution= new AliAnalysisTaskResolution(Form("%s_%s_Resolution",(analysisEventCuts->GetCutNumber()).Data(), (analysisCuts->GetCutNumber()).Data()));
114         fResolution->SetEventCuts(analysisEventCuts,IsHeavyIon);        
115         fResolution->SetConversionCuts(analysisCuts,IsHeavyIon);
116         fResolution->SetIsMC(IsMC);
117         mgr->AddTask(fResolution);
118         
119         AliAnalysisDataContainer *coutput1 =
120         mgr->CreateContainer(Form("GammaConvResolution_%s_%s", TaskEventCutnumber.Data(), TaskPhotonCutnumber.Data()), TList::Class(),
121                                                 AliAnalysisManager::kOutputContainer, Form("GammaConv_Resolution_%s_%s.root", TaskEventCutnumber.Data(), TaskPhotonCutnumber.Data()));
122
123         AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer();
124         mgr->ConnectInput(fResolution,  0, cinput1 );
125         mgr->ConnectOutput (fResolution,  1, coutput1);
126    //connect containers
127         return;
128 }
129