5372ca35a9566a0e7beea0d17cc2eab56acc2283
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / macros / AddTask_PhotonQA.C
1 void AddTask_PhotonQA(  TString V0ReaderEventCutNumber  = "0000000", 
2                                                 TString V0ReaderPhotonCutNumber = "060000084001001500000000", 
3                                                 TString TaskEventCutnumber              = "0000000",
4                                                 TString TaskPhotonCutnumber     = "090000092663743800000000",
5                                                 Bool_t IsMC = kFALSE,
6                                                 Int_t IsHeavyIon = 0,
7                                                 Bool_t kHistograms = kTRUE, 
8                                                 Bool_t kTree = kTRUE,
9                                                 TString V0ReaderCutNumberAODBranch = "0000000060084001001500000", 
10                                                 Bool_t runBasicQAWithStandardOutput = kTRUE,
11                                                 Bool_t doEtaShiftV0Reader = kFALSE 
12                      ){
13         
14         // ================= Load Librariers =================================
15         gSystem->Load("libCore.so");  
16         gSystem->Load("libTree.so");
17         gSystem->Load("libGeom.so");
18         gSystem->Load("libVMC.so");
19         gSystem->Load("libPhysics.so");
20         gSystem->Load("libMinuit");
21         gSystem->Load("libSTEERBase");
22         gSystem->Load("libESD");
23         gSystem->Load("libAOD");
24         gSystem->Load("libANALYSIS");
25         gSystem->Load("libANALYSISalice");  
26         gSystem->Load("libCDB.so");
27         gSystem->Load("libSTEER.so");
28         gSystem->Load("libSTEERBase.so");
29         gSystem->Load("libTENDER.so");
30         gSystem->Load("libTENDERSupplies.so");
31         gSystem->Load("libPWGflowBase.so");
32         gSystem->Load("libPWGflowTasks.so");
33         gSystem->Load("libPWGGAGammaConv.so");
34         
35         // ================== GetAnalysisManager ===============================
36         AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
37         if (!mgr) {
38                 Error(Form("AddTask_GammaConvV1_%i",trainConfig), "No analysis manager found.");
39                 return ;
40         }
41
42         // ================== GetInputEventHandler =============================
43         AliVEventHandler *inputHandler=mgr->GetInputEventHandler();
44         
45         //========= Add PID Reponse to ANALYSIS manager ====
46         if(!(AliPIDResponse*)mgr->GetTask("PIDResponseTask")){
47                 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
48                 AddTaskPIDResponse(isMC);
49         }
50
51         AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
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(V0ReaderEventCutNumber!=""){
66                         fEventCuts= new AliConvEventCuts(V0ReaderEventCutNumber.Data(),V0ReaderEventCutNumber.Data());
67                         fEventCuts->SetPreSelectionCutFlag(kTRUE);
68                         if(fEventCuts->InitializeCutsFromCutString(V0ReaderEventCutNumber.Data())){
69                                 fV0ReaderV1->SetEventCuts(fEventCuts);
70                                 fEventCuts->SetFillCutHistograms("",kTRUE);
71                                 if (IsHeavyIon==2){
72                                         fEventCuts->SelectCollisionCandidates(AliVEvent::kINT7);
73                                         fEventCuts->DoEtaShift(doEtaShiftV0Reader);
74                                 }
75                         }
76                 }
77
78                 // Set AnalysisCut Number
79                 AliConversionPhotonCuts *fCuts=NULL;
80                 if(V0ReaderPhotonCutNumber!=""){
81                         fCuts= new AliConversionPhotonCuts(V0ReaderPhotonCutNumber.Data(),V0ReaderPhotonCutNumber.Data());
82                         fCuts->SetPreSelectionCutFlag(kTRUE);
83                         fCuts->SetIsHeavyIon(IsHeavyIon);
84                         if(fCuts->InitializeCutsFromCutString(V0ReaderPhotonCutNumber.Data())){
85                                 fV0ReaderV1->SetConversionCuts(fCuts);
86                                 fCuts->SetFillCutHistograms("",kTRUE);
87                         }
88                 }
89      
90       
91                 if(inputHandler->IsA()==AliAODInputHandler::Class()){
92                         // AOD mode
93                         fV0ReaderV1->SetDeltaAODBranchName(Form("GammaConv_%s_gamma",V0ReaderCutNumberAODBranch.Data()));
94                 }
95                 fV0ReaderV1->Init();
96
97                 AliLog::SetGlobalLogLevel(AliLog::kInfo);
98
99                 //connect input V0Reader
100                 mgr->AddTask(fV0ReaderV1);
101                 mgr->ConnectInput(fV0ReaderV1,0,cinput);
102
103         } else {
104                 Error("AddTask_V0ReaderV1", "Cannot execute AddTask, V0ReaderV1 already exists.");
105         }   
106
107         AliConvEventCuts *analysisEventCuts = new AliConvEventCuts();
108         analysisEventCuts->InitializeCutsFromCutString(TaskEventCutnumber.Data());
109         analysisEventCuts->SetFillCutHistograms("",kFALSE);
110
111         AliConversionPhotonCuts *analysisCuts = new AliConversionPhotonCuts();
112         analysisCuts->InitializeCutsFromCutString(TaskPhotonCutnumber.Data());
113         analysisCuts->SetFillCutHistograms("",kFALSE);
114         
115         AliAnalysisTaskConversionQA *fQA = new AliAnalysisTaskConversionQA(Form("%s_%s_QA",TaskEventCutnumber.Data(),TaskPhotonCutnumber.Data()));
116         fQA->SetEventCuts(analysisEventCuts,IsHeavyIon);
117         fQA->SetConversionCuts(analysisCuts,IsHeavyIon);
118         fQA->FillType(kTree,kHistograms);
119         fQA->SetIsMC(IsMC);
120         mgr->AddTask(fQA);
121
122         AliAnalysisDataContainer *cinput  = mgr->GetCommonInputContainer();
123         if (runBasicQAWithStandardOutput){
124                 AliAnalysisDataContainer *coutput =
125                         mgr->CreateContainer(Form("GammaConv_V1QA_%s_%s", TaskEventCutnumber.Data(), TaskPhotonCutnumber.Data()), TList::Class(),
126                                 AliAnalysisManager::kOutputContainer, Form("%s:GammaConvV1_QA_%s_%s",AliAnalysisManager::GetCommonFileName(), TaskEventCutnumber.Data(), TaskPhotonCutnumber.Data()));
127                 mgr->ConnectOutput(fQA,  1, coutput);
128         } else {
129                 AliAnalysisDataContainer *coutput =
130                         mgr->CreateContainer(Form("GammaConv_V1QA_%s_%s", TaskEventCutnumber.Data(), TaskPhotonCutnumber.Data()), TList::Class(),
131                                 AliAnalysisManager::kOutputContainer, Form("GammaConvV1_QA_%s_%s.root", TaskEventCutnumber.Data(), TaskPhotonCutnumber.Data()));
132                 mgr->ConnectOutput(fQA,  1, coutput);
133         }
134         mgr->ConnectInput(fQA,0,cinput);
135                 
136
137         //connect containers
138         return;
139 }