a58f92786c4ca3d98bc8d5f89176da3077b6271a
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / macros / AddTask_PhotonQA.C
1 void AddTask_PhotonQA(  TString V0ReaderEventCutNumber  = "0000000", 
2                                                 TString V0ReaderPhotonCutNumber = "060084001001500000000", 
3                                                 TString TaskEventCutnumber              = "0000000",
4                                                 TString TaskPhotonCutnumber     = "090092663743800000000",
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("libPWGGAGammaConv.so");
27         gSystem->Load("libCDB.so");
28         gSystem->Load("libSTEER.so");
29         gSystem->Load("libSTEERBase.so");
30         gSystem->Load("libTENDER.so");
31         gSystem->Load("libTENDERSupplies.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",V0ReaderCutNumberAODBranch.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         AliAnalysisTaskConversionQA *fQA = new AliAnalysisTaskConversionQA(Form("%s_%s_QA",TaskEventCutnumber.Data(),TaskPhotonCutnumber.Data()));
114         fQA->SetEventCuts(analysisEventCuts,IsHeavyIon);
115         fQA->SetConversionCuts(analysisCuts,IsHeavyIon);
116         fQA->FillType(kTree,kHistograms);
117         fQA->SetIsMC(IsMC);
118         mgr->AddTask(fQA);
119
120         AliAnalysisDataContainer *cinput  = mgr->GetCommonInputContainer();
121         if (runBasicQAWithStandardOutput){
122                 AliAnalysisDataContainer *coutput =
123                         mgr->CreateContainer(Form("GammaConv_V1QA_%s_%s", TaskEventCutnumber.Data(), TaskPhotonCutnumber.Data()), TList::Class(),
124                                 AliAnalysisManager::kOutputContainer, Form("%s:GammaConvV1_QA_%s_%s",AliAnalysisManager::GetCommonFileName(), TaskEventCutnumber.Data(), TaskPhotonCutnumber.Data()));
125                 mgr->ConnectOutput(fQA,  1, coutput);
126         } else {
127                 AliAnalysisDataContainer *coutput =
128                         mgr->CreateContainer(Form("GammaConv_V1QA_%s_%s", TaskEventCutnumber.Data(), TaskPhotonCutnumber.Data()), TList::Class(),
129                                 AliAnalysisManager::kOutputContainer, Form("GammaConvV1_QA_%s_%s.root", TaskEventCutnumber.Data(), TaskPhotonCutnumber.Data()));
130                 mgr->ConnectOutput(fQA,  1, coutput);
131         }
132         mgr->ConnectInput(fQA,0,cinput);
133                 
134
135         //connect containers
136         return;
137 }