9e7634bd8a2165f64685941fcf3b35877166b3d6
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / macros / AddTaskD0Mass.C
1 AliAnalysisTaskSED0Mass *AddTaskD0Mass(TString finname="D0toKpiCutsNew.root",Int_t flag=0/*0 = D0,1 = LS*/,Bool_t readMC=kFALSE,Bool_t cutOnDistr=kFALSE,Int_t flagD0D0bar=0)
2 {
3   //
4   // AddTask for the AliAnalysisTaskSE for D0 candidates
5   // invariant mass histogram and association with MC truth 
6   // (using MC info in AOD) and cut variables distributions
7   // C.Bianchin  chiara.bianchin@pd.infn.it
8   //
9
10
11   // Get the pointer to the existing analysis manager via the static access method.
12   //==============================================================================
13   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
14   if (!mgr) {
15     ::Error("AddTaskD0Distr", "No analysis manager to connect to.");
16     return NULL;
17   }   
18
19   TString filename="",out1name="",out2name="",out3name="",out4name="",out5name="",inname="";
20   filename = AliAnalysisManager::GetCommonFileName();
21   filename += ":PWG3_D2H_";
22   if(flag==0){
23     filename+="D0InvMass";
24     if(cutOnDistr) filename+="C"; 
25     if(flagD0D0bar==1)filename+="D0";
26     if(flagD0D0bar==2)filename+="D0bar";
27     //list mass
28     out1name="coutputmassD0Mass";
29     if(cutOnDistr) out1name+="C"; 
30     if(flagD0D0bar==1)out1name+="D0";
31     if(flagD0D0bar==2)out1name+="D0bar";
32     //list distr
33     out2name="coutputmassD0distr";
34     if(cutOnDistr) out2name+="C"; 
35     if(flagD0D0bar==1)out2name+="D0";
36     if(flagD0D0bar==2)out2name+="D0bar";
37    //hist entries
38     out3name="nEntriesD0";
39     if(cutOnDistr) out3name+="C"; 
40     if(flagD0D0bar==1)out3name+="D0";
41     if(flagD0D0bar==2)out3name+="D0bar";
42     //list checks
43     out4name="checksD0";
44     if(cutOnDistr) out4name+="C"; 
45     if(flagD0D0bar==1)out4name+="D0";
46     if(flagD0D0bar==2)out4name+="D0bar";
47    //cuts object
48     out5name="cutsD0";
49     if(cutOnDistr) out5name+="C"; 
50     if(flagD0D0bar==1)out5name+="D0";
51     if(flagD0D0bar==2)out5name+="D0bar";
52
53     inname="cinputmassD0_0";
54     if(cutOnDistr) inname+="C"; 
55     if(flagD0D0bar==1)inname+="D0";
56     if(flagD0D0bar==2)inname+="D0bar";
57
58   } else {
59     filename+="D0InvMassLikeSign";
60     if(cutOnDistr) filename+="C"; 
61     if(flagD0D0bar==1)filename+="D0";
62     if(flagD0D0bar==2)filename+="D0bar";
63     //list mass
64     out1name="coutputmassLSMass";
65     if(cutOnDistr) out1name+="C"; 
66     if(flagD0D0bar==1)out1name+="D0";
67     if(flagD0D0bar==2)out1name+="D0bar";
68     //list distr
69     out2name="coutputmassLSdistr";
70     if(cutOnDistr) out2name+="C"; 
71     if(flagD0D0bar==1)out2name+="D0";
72     if(flagD0D0bar==2)out2name+="D0bar";
73    //hist entries
74     out3name="nEntriesLS";
75     if(cutOnDistr) out3name+="C"; 
76     if(flagD0D0bar==1)out3name+="D0";
77     if(flagD0D0bar==2)out3name+="D0bar";
78     //list checks
79     out4name="checksLS";
80     if(cutOnDistr) out4name+="C"; 
81     if(flagD0D0bar==1)out4name+="D0";
82     if(flagD0D0bar==2)out4name+="D0bar";
83    //cuts object
84     out5name="cutsLS";
85     if(cutOnDistr) out5name+="C"; 
86     if(flagD0D0bar==1)out5name+="D0";
87     if(flagD0D0bar==2)out5name+="D0bar";
88
89     inname="cinputmassD0_1";
90     if(cutOnDistr) inname+="C"; 
91     if(flagD0D0bar==1)inname+="D0";
92     if(flagD0D0bar==2)inname+="D0bar";
93   }
94
95    //setting my cut values
96
97     //cuts order
98     //       printf("    |M-MD0| [GeV]    < %f\n",fD0toKpiCuts[0]);
99     //     printf("    dca    [cm]  < %f\n",fD0toKpiCuts[1]);
100     //     printf("    cosThetaStar     < %f\n",fD0toKpiCuts[2]);
101     //     printf("    pTK     [GeV/c]    > %f\n",fD0toKpiCuts[3]);
102     //     printf("    pTpi    [GeV/c]    > %f\n",fD0toKpiCuts[4]);
103     //     printf("    |d0K|  [cm]  < %f\n",fD0toKpiCuts[5]);
104     //     printf("    |d0pi| [cm]  < %f\n",fD0toKpiCuts[6]);
105     //     printf("    d0d0  [cm^2] < %f\n",fD0toKpiCuts[7]);
106     //     printf("    cosThetaPoint    > %f\n",fD0toKpiCuts[8]);
107
108
109   TFile* filecuts=new TFile(finname.Data());
110   if(!filecuts->IsOpen()){
111     cout<<"Input file not found: exit"<<endl;
112     return;
113   }
114
115   AliRDHFCutsD0toKpi* RDHFD0toKpi=new AliRDHFCutsD0toKpi();
116   RDHFD0toKpi = (AliRDHFCutsD0toKpi*)filecuts->Get("D0toKpiCuts");
117   RDHFD0toKpi->SetName(Form("D0toKpiCuts%d",flag));
118
119   if(!RDHFD0toKpi){
120     cout<<"Specific AliRDHFCuts not found"<<endl;
121     return;
122   }
123
124   // Aanalysis task    
125   TString taskname="MassAndDistrAnalysis";
126   if (flag==0)taskname.Prepend("D0");
127   else taskname.Prepend("LS");
128   AliAnalysisTaskSED0Mass *massD0Task = new AliAnalysisTaskSED0Mass(taskname.Data(),RDHFD0toKpi);
129   massD0Task->SetDebugLevel(2);
130   massD0Task->SetArray(flag);
131   massD0Task->SetReadMC(readMC);
132   massD0Task->SetCutOnDistr(cutOnDistr);
133   massD0Task->SetUsePid4Distr(kFALSE);
134   massD0Task->SetFillOnlyD0D0bar(flagD0D0bar);
135
136   mgr->AddTask(massD0Task);
137   
138   //
139   // Create containers for input/output
140   AliAnalysisDataContainer *cinputmassD0 = mgr->CreateContainer(inname,TChain::Class(), 
141                                                           AliAnalysisManager::kInputContainer);
142
143   AliAnalysisDataContainer *coutputmassD01 = mgr->CreateContainer(out1name,TList::Class(),AliAnalysisManager::kOutputContainer, filename.Data()); //mass
144   AliAnalysisDataContainer *coutputmassD02 = mgr->CreateContainer(out2name,TList::Class(),AliAnalysisManager::kOutputContainer, filename.Data()); //distr
145   AliAnalysisDataContainer *coutputmassD03 = mgr->CreateContainer(out3name,TH1F::Class(),AliAnalysisManager::kOutputContainer, filename.Data()); //nev
146   AliAnalysisDataContainer *coutputmassD04 = mgr->CreateContainer(out4name,TList::Class(),AliAnalysisManager::kOutputContainer, filename.Data()); //check
147   AliAnalysisDataContainer *coutputmassD05 = mgr->CreateContainer(out5name,AliRDHFCutsD0toKpi::Class(),AliAnalysisManager::kOutputContainer, filename.Data()); //cuts
148   
149   mgr->ConnectInput(massD0Task,0,mgr->GetCommonInputContainer());
150
151   mgr->ConnectOutput(massD0Task,1,coutputmassD01);
152   mgr->ConnectOutput(massD0Task,2,coutputmassD02);
153   mgr->ConnectOutput(massD0Task,3,coutputmassD03);
154   mgr->ConnectOutput(massD0Task,4,coutputmassD04);
155   mgr->ConnectOutput(massD0Task,5,coutputmassD05);
156
157
158   return massD0Task;
159 }