New class for normalization studies (Giacomo)
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / macros / AddTaskD0Mass.C
1 AliAnalysisTaskSED0Mass *AddTaskD0Mass(TString finname="D0toKpiCuts.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="",out6name="",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     //AliNormalizationCounter
54     out6name="normalizationCounter";
55     if(cutOnDistr) out6name+="C"; 
56     if(flagD0D0bar==1)out6name+="D0";
57     if(flagD0D0bar==2)out6name+="D0bar";
58
59     inname="cinputmassD0_0";
60     if(cutOnDistr) inname+="C"; 
61     if(flagD0D0bar==1)inname+="D0";
62     if(flagD0D0bar==2)inname+="D0bar";
63
64   } else {
65     filename+="D0InvMassLikeSign";
66     if(cutOnDistr) filename+="C"; 
67     if(flagD0D0bar==1)filename+="D0";
68     if(flagD0D0bar==2)filename+="D0bar";
69     //list mass
70     out1name="coutputmassLSMass";
71     if(cutOnDistr) out1name+="C"; 
72     if(flagD0D0bar==1)out1name+="D0";
73     if(flagD0D0bar==2)out1name+="D0bar";
74     //list distr
75     out2name="coutputmassLSdistr";
76     if(cutOnDistr) out2name+="C"; 
77     if(flagD0D0bar==1)out2name+="D0";
78     if(flagD0D0bar==2)out2name+="D0bar";
79    //hist entries
80     out3name="nEntriesLS";
81     if(cutOnDistr) out3name+="C"; 
82     if(flagD0D0bar==1)out3name+="D0";
83     if(flagD0D0bar==2)out3name+="D0bar";
84     //list checks
85     out4name="checksLS";
86     if(cutOnDistr) out4name+="C"; 
87     if(flagD0D0bar==1)out4name+="D0";
88     if(flagD0D0bar==2)out4name+="D0bar";
89    //cuts object
90     out5name="cutsLS";
91     if(cutOnDistr) out5name+="C"; 
92     if(flagD0D0bar==1)out5name+="D0";
93     if(flagD0D0bar==2)out5name+="D0bar";
94
95     inname="cinputmassD0_1";
96     if(cutOnDistr) inname+="C"; 
97     if(flagD0D0bar==1)inname+="D0";
98     if(flagD0D0bar==2)inname+="D0bar";
99   }
100
101    //setting my cut values
102
103     //cuts order
104     //       printf("    |M-MD0| [GeV]    < %f\n",fD0toKpiCuts[0]);
105     //     printf("    dca    [cm]  < %f\n",fD0toKpiCuts[1]);
106     //     printf("    cosThetaStar     < %f\n",fD0toKpiCuts[2]);
107     //     printf("    pTK     [GeV/c]    > %f\n",fD0toKpiCuts[3]);
108     //     printf("    pTpi    [GeV/c]    > %f\n",fD0toKpiCuts[4]);
109     //     printf("    |d0K|  [cm]  < %f\n",fD0toKpiCuts[5]);
110     //     printf("    |d0pi| [cm]  < %f\n",fD0toKpiCuts[6]);
111     //     printf("    d0d0  [cm^2] < %f\n",fD0toKpiCuts[7]);
112     //     printf("    cosThetaPoint    > %f\n",fD0toKpiCuts[8]);
113
114
115   TFile* filecuts=new TFile(finname.Data());
116   if(!filecuts->IsOpen()){
117     cout<<"Input file not found: exit"<<endl;
118     return;
119   }
120
121   AliRDHFCutsD0toKpi* RDHFD0toKpi=new AliRDHFCutsD0toKpi();
122   RDHFD0toKpi = (AliRDHFCutsD0toKpi*)filecuts->Get("D0toKpiCuts");
123   RDHFD0toKpi->SetName(Form("D0toKpiCuts%d",flag));
124
125   if(!RDHFD0toKpi){
126     cout<<"Specific AliRDHFCuts not found"<<endl;
127     return;
128   }
129
130   // Aanalysis task    
131   TString taskname="MassAndDistrAnalysis";
132   if (flag==0)taskname.Prepend("D0");
133   else taskname.Prepend("LS");
134   AliAnalysisTaskSED0Mass *massD0Task = new AliAnalysisTaskSED0Mass(taskname.Data(),RDHFD0toKpi);
135   massD0Task->SetDebugLevel(2);
136   massD0Task->SetArray(flag);
137   massD0Task->SetReadMC(readMC);
138   massD0Task->SetCutOnDistr(cutOnDistr);
139   massD0Task->SetUsePid4Distr(kFALSE);
140   massD0Task->SetFillOnlyD0D0bar(flagD0D0bar);
141
142   mgr->AddTask(massD0Task);
143   
144   //
145   // Create containers for input/output
146   AliAnalysisDataContainer *cinputmassD0 = mgr->CreateContainer(inname,TChain::Class(), 
147                                                           AliAnalysisManager::kInputContainer);
148
149   AliAnalysisDataContainer *coutputmassD01 = mgr->CreateContainer(out1name,TList::Class(),AliAnalysisManager::kOutputContainer, filename.Data()); //mass
150   AliAnalysisDataContainer *coutputmassD02 = mgr->CreateContainer(out2name,TList::Class(),AliAnalysisManager::kOutputContainer, filename.Data()); //distr
151   AliAnalysisDataContainer *coutputmassD03 = mgr->CreateContainer(out3name,TH1F::Class(),AliAnalysisManager::kOutputContainer, filename.Data()); //nev
152   AliAnalysisDataContainer *coutputmassD04 = mgr->CreateContainer(out4name,TList::Class(),AliAnalysisManager::kOutputContainer, filename.Data()); //check
153   AliAnalysisDataContainer *coutputmassD05 = mgr->CreateContainer(out5name,AliRDHFCutsD0toKpi::Class(),AliAnalysisManager::kOutputContainer, filename.Data()); //cuts
154   AliAnalysisDataContainer *coutputmassD06 = mgr->CreateContainer(out6name,AliNormalizationCounter::Class(),AliAnalysisManager::kOutputContainer, filename.Data()); //cuts
155   
156   mgr->ConnectInput(massD0Task,0,mgr->GetCommonInputContainer());
157
158   mgr->ConnectOutput(massD0Task,1,coutputmassD01);
159   mgr->ConnectOutput(massD0Task,2,coutputmassD02);
160   mgr->ConnectOutput(massD0Task,3,coutputmassD03);
161   mgr->ConnectOutput(massD0Task,4,coutputmassD04);
162   mgr->ConnectOutput(massD0Task,5,coutputmassD05);
163   mgr->ConnectOutput(massD0Task,6,coutputmassD06);
164
165
166   return massD0Task;
167 }