3119de9bd5d9b1afd75f1941580cb87a63109c40
[u/mrichter/AliRoot.git] / PWGHF / vertexingHF / macros / AddTaskLambdac.C
1 AliAnalysisTaskSE *AddTaskLambdac(TString finname,Bool_t storeNtuple,Bool_t readMC,Bool_t MCPid,Bool_t realPid,Bool_t resPid,Bool_t useKF,
2                                   Bool_t fillVarHists=kFALSE, Bool_t priorsHists=kFALSE, Bool_t multiplicityHists=kFALSE, TString postname="")
3 {
4   //==============================================================================                                                      
5   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
6   if (!mgr) {
7     ::Error("AddTaskLambdac", "No analysis manager to connect to.");
8     return NULL;
9   }
10
11
12   Bool_t stdcuts=kFALSE;
13   TFile* filecuts;
14   if( finname.EqualTo("") ) {
15     stdcuts=kTRUE; 
16   } else {
17       filecuts=TFile::Open(finname.Data());
18       if(!filecuts ||(filecuts&& !filecuts->IsOpen())){
19         AliFatal("Input file not found : check your cut object");
20       }
21   }
22   AliRDHFCutsLctopKpi* prodcuts=new AliRDHFCutsLctopKpi();
23   if(stdcuts) prodcuts->SetStandardCutsPP2010();
24   else   prodcuts = (AliRDHFCutsLctopKpi*)filecuts->Get("LctopKpiProdCuts");
25   prodcuts->SetName("LctopKpiProdCuts");
26   prodcuts->SetMinPtCandidate(-1.);
27   prodcuts->SetMaxPtCandidate(10000.);
28
29   AliRDHFCutsLctopKpi *analysiscuts = new AliRDHFCutsLctopKpi();
30   if(stdcuts) analysiscuts->SetStandardCutsPP2010();
31   else analysiscuts = (AliRDHFCutsLctopKpi*)filecuts->Get("LctopKpiAnalysisCuts");
32   analysiscuts->SetName("LctopKpiAnalysisCuts");
33   analysiscuts->SetMinPtCandidate(-1.);
34   analysiscuts->SetMaxPtCandidate(10000.);
35
36   // Aanalysis task                                                                                                                     
37   AliAnalysisTaskSELambdac *lambdacTask = new AliAnalysisTaskSELambdac("LambdacAnalysis",storeNtuple,analysiscuts,prodcuts);
38   lambdacTask->SetReadMC(readMC);
39   if(MCPid) lambdacTask->SetMCPid();
40   if(resPid) lambdacTask->SetResonantPid();
41   if(realPid) lambdacTask->SetRealPid();
42   lambdacTask->SetFillVarHists(fillVarHists);
43   lambdacTask->SetPriorsHists(priorsHists);
44   lambdacTask->SetMultiplicityHists(multiplicityHists);
45   lambdacTask->SetAnalysis(kTRUE);
46
47   lambdacTask->SetDebugLevel(0);
48   if(useKF) {
49     lambdacTask->SetUseKF();
50     Float_t cuts[10]={0.1,0.1,1.5,0.5,0.1,1.5,0.5,0.1,1.5,0.5};
51     lambdacTask->SetCutsKF(cuts);
52   }
53   mgr->AddTask(lambdacTask);
54
55   //
56   // Create containers for input/output
57   TString outputfile = AliAnalysisManager::GetCommonFileName();
58   outputfile += ":PWG3_D2H_InvMassLambdac";
59
60   TString finDirname="pp";
61   TString inname = "cinputLc";
62   TString outname = "coutputLc";
63   TString cutsname = "coutputLcCuts";
64   TString normname = "coutputLcNorm";
65   TString ntuplename = "coutputLc2";
66   TString nev2 = "coutputNev";
67   TString outname2 = "coutputLambdacMC";
68   TString aPrioriname = "coutputAPriori";
69   TString multiplicityname = "coutputMultiplicity";
70   inname += finDirname.Data();
71   outname += finDirname.Data();
72   cutsname += finDirname.Data();
73   normname += finDirname.Data();
74   ntuplename += finDirname.Data();
75   nev2 += finDirname.Data();
76   outname2 += finDirname.Data();
77   aPrioriname += finDirname.Data();
78   multiplicityname += finDirname.Data();
79
80   inname +=  postname.Data();
81   outname +=  postname.Data();
82   cutsname +=  postname.Data();
83   normname += postname.Data();
84   ntuplename +=  postname.Data();
85   nev2 +=  postname.Data();
86   outname2 +=  postname.Data();
87   aPrioriname +=  postname.Data();
88   multiplicityname +=  postname.Data();
89
90
91   AliAnalysisDataContainer *cinputLambdac = mgr->CreateContainer(inname,TChain::Class(),
92                                                                  AliAnalysisManager::kInputContainer);
93   mgr->ConnectInput(lambdacTask,0,mgr->GetCommonInputContainer());
94
95   AliAnalysisDataContainer *coutputLambdacCuts = mgr->CreateContainer(cutsname,TList::Class(),
96                                                                       AliAnalysisManager::kOutputContainer,outputfile.Data());
97   mgr->ConnectOutput(lambdacTask,2,coutputLambdacCuts);
98
99   AliAnalysisDataContainer *coutputLambdac = mgr->CreateContainer(outname,TList::Class(),
100                                                                   AliAnalysisManager::kOutputContainer,outputfile.Data());
101   mgr->ConnectOutput(lambdacTask,1,coutputLambdac);
102
103   AliAnalysisDataContainer *coutputLambdacMC = mgr->CreateContainer(outname2,TList::Class(),
104                                                                     AliAnalysisManager::kOutputContainer,outputfile.Data());
105   mgr->ConnectOutput(lambdacTask,3,coutputLambdacMC);
106
107   AliAnalysisDataContainer *coutputLambdacNev = mgr->CreateContainer(nev2,TH1F::Class(),
108                                                                      AliAnalysisManager::kOutputContainer,outputfile.Data());
109   mgr->ConnectOutput(lambdacTask,4,coutputLambdacNev);
110
111   AliAnalysisDataContainer *coutputAPriori = mgr->CreateContainer(aPrioriname,TList::Class(),
112                                                                   AliAnalysisManager::kOutputContainer,outputfile.Data());
113   mgr->ConnectOutput(lambdacTask,5,coutputAPriori);
114   AliAnalysisDataContainer *coutputMultiplicity = mgr->CreateContainer(multiplicityname,TList::Class(),
115                                                                        AliAnalysisManager::kOutputContainer,outputfile.Data());
116   mgr->ConnectOutput(lambdacTask,6,coutputMultiplicity);
117
118   AliAnalysisDataContainer *coutputLambdacNorm = mgr->CreateContainer(normname,AliNormalizationCounter::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());
119
120  mgr->ConnectOutput(lambdacTask,7,coutputLambdacNorm);
121
122   if (storeNtuple) {
123     AliAnalysisDataContainer *coutputLambdac2 = mgr->CreateContainer(ntuplename,TNtuple::Class(),
124                                                                      AliAnalysisManager::kOutputContainer,"InvMassLambdac_nt1.root");
125     coutputLambdac2->SetSpecialOutput();
126     mgr->ConnectOutput(lambdacTask,7,coutputLambdac2);
127   }
128
129
130   return lambdacTask;
131 }