added libraries to AddTask in order to include flow package
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / macros / AddTask_Material.C
1 void AddTask_Material(  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                                                 TString cutnumberAODBranch = "0000000060084001001500000",
8                                                 Bool_t doEtaShiftV0Reader = kFALSE 
9                      ){
10
11         // ================= Load Librariers =================================
12         gSystem->Load("libCore.so");  
13         gSystem->Load("libTree.so");
14         gSystem->Load("libGeom.so");
15         gSystem->Load("libVMC.so");
16         gSystem->Load("libPhysics.so");
17         gSystem->Load("libMinuit");
18         gSystem->Load("libSTEERBase");
19         gSystem->Load("libESD");
20         gSystem->Load("libAOD");
21         gSystem->Load("libANALYSIS");
22         gSystem->Load("libANALYSISalice");  
23         gSystem->Load("libCDB.so");
24         gSystem->Load("libSTEER.so");
25         gSystem->Load("libSTEERBase.so");
26         gSystem->Load("libTENDER.so");
27         gSystem->Load("libTENDERSupplies.so");
28         gSystem->Load("libPWGflowBase.so");
29         gSystem->Load("libPWGflowTasks.so");
30         gSystem->Load("libPWGGAGammaConv.so");
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         AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
48         if( !(AliV0ReaderV1*)mgr->GetTask("V0ReaderV1") ){
49                 AliV0ReaderV1 *fV0ReaderV1 = new AliV0ReaderV1("V0ReaderV1");
50                 
51                 fV0ReaderV1->SetUseOwnXYZCalculation(kTRUE);
52                 fV0ReaderV1->SetCreateAODs(kFALSE);// AOD Output
53                 fV0ReaderV1->SetUseAODConversionPhoton(kTRUE);
54
55                 if (!mgr) {
56                         Error("AddTask_V0ReaderV1", "No analysis manager found.");
57                         return;
58                 }
59
60                 AliConvEventCuts *fEventCuts=NULL;
61                 if(V0ReaderEventCutNumber!=""){
62                         fEventCuts= new AliConvEventCuts(V0ReaderEventCutNumber.Data(),V0ReaderEventCutNumber.Data());
63                         fEventCuts->SetPreSelectionCutFlag(kTRUE);
64                         if(fEventCuts->InitializeCutsFromCutString(V0ReaderEventCutNumber.Data())){
65                                 fV0ReaderV1->SetEventCuts(fEventCuts);
66                                 fEventCuts->SetFillCutHistograms("",kTRUE);
67                                 if (IsHeavyIon==2){
68                                         fEventCuts->SelectCollisionCandidates(AliVEvent::kINT7);
69                                         fEventCuts->DoEtaShift(doEtaShiftV0Reader);
70                                 }
71                         }
72                 }
73
74                 // Set AnalysisCut Number
75                 AliConversionPhotonCuts *fCuts=NULL;
76                 if(V0ReaderPhotonCutNumber!=""){
77                         fCuts= new AliConversionPhotonCuts(V0ReaderPhotonCutNumber.Data(),V0ReaderPhotonCutNumber.Data());
78                         fCuts->SetPreSelectionCutFlag(kTRUE);
79                         fCuts->SetIsHeavyIon(IsHeavyIon);
80                         if(fCuts->InitializeCutsFromCutString(V0ReaderPhotonCutNumber.Data())){
81                                 fV0ReaderV1->SetConversionCuts(fCuts);
82                                 fCuts->SetFillCutHistograms("",kTRUE);
83                         }
84                 }
85                 
86                 
87                 if(inputHandler->IsA()==AliAODInputHandler::Class()){
88                         // AOD mode
89                         fV0ReaderV1->SetDeltaAODBranchName(Form("GammaConv_%s_gamma",cutnumberAODBranch.Data()));
90                 }
91                 fV0ReaderV1->Init();
92
93                 AliLog::SetGlobalLogLevel(AliLog::kInfo);
94
95                 //connect input V0Reader
96                 mgr->AddTask(fV0ReaderV1);
97                 mgr->ConnectInput(fV0ReaderV1,0,cinput);
98
99         } else {
100                 Error("AddTask_V0ReaderV1", "Cannot execute AddTask, V0ReaderV1 already exists.");
101         }   
102
103         AliConvEventCuts *analysisEventCuts = new AliConvEventCuts();
104         analysisEventCuts->InitializeCutsFromCutString(TaskEventCutnumber.Data());
105         analysisEventCuts->SetFillCutHistograms("",kFALSE);
106
107         AliConversionPhotonCuts *analysisCuts = new AliConversionPhotonCuts();
108         analysisCuts->InitializeCutsFromCutString(TaskPhotonCutnumber.Data());
109         analysisCuts->SetFillCutHistograms("",kFALSE);
110         
111         AliAnalysisTaskMaterial *fMaterial= new AliAnalysisTaskMaterial(Form("%s_%s_Material",(analysisEventCuts->GetCutNumber()).Data(),(analysisCuts->GetCutNumber()).Data()));
112         fMaterial->SetEventCuts(analysisEventCuts,IsHeavyIon);
113         fMaterial->SetConversionCuts(analysisCuts,IsHeavyIon);
114         fMaterial->SetIsMC(IsMC);
115         mgr->AddTask(fMaterial);
116         
117         AliAnalysisDataContainer *coutput1 =
118         mgr->CreateContainer(Form("GammaConvMaterial_%s_%s",TaskEventCutnumber.Data(),TaskPhotonCutnumber.Data()), TList::Class(), AliAnalysisManager::kOutputContainer,Form("GammaConv_Material_%s_%s.root",TaskEventCutnumber.Data(),TaskPhotonCutnumber.Data()));
119
120         AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer();
121         mgr->ConnectInput(fMaterial,  0, cinput1 );
122         mgr->ConnectOutput (fMaterial,  1, coutput1);
123         //connect containers
124         return;
125 }