AliPhysics  ff07904 (ff07904)
AddTaskD0Mass.C
Go to the documentation of this file.
1 AliAnalysisTaskSED0Mass *AddTaskD0Mass(Int_t flag=0/*0 = D0,1 = LS*/,Bool_t readMC=kFALSE,
2  Bool_t filldistr=kFALSE,Bool_t cutOnDistr=kFALSE,
3  Int_t system=0/*0=pp,1=PbPb*/,Int_t flagD0D0bar=0,
4  Float_t minC=0, Float_t maxC=0,
5  TString finDirname="Loose",
6  TString finname="",TString finObjname="D0toKpiCuts", Bool_t flagAOD049=kFALSE,
7  Bool_t FillMassPt=false, Bool_t FillImpPar=false,
8  Bool_t DrawDetSignal=false, Bool_t PIDCheck=false, Bool_t FillMassY=false, Bool_t FillMCAcc=true,Int_t AODProtection = 1)
9 {
10  //
11  // AddTask for the AliAnalysisTaskSE for D0 candidates
12  // invariant mass histogram and association with MC truth
13  // (using MC info in AOD) and cut variables distributions
14  // C.Bianchin chiara.bianchin@pd.infn.it
15  //
16 
17 
18  // Get the pointer to the existing analysis manager via the static access method.
19  //==============================================================================
20  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
21  if (!mgr) {
22  ::Error("AddTaskD0Distr", "No analysis manager to connect to.");
23  return NULL;
24  }
25 
26  TString filename="",out1name="",out2name="",out3name="",out4name="",out5name="",out6name="",out7name="",out8name="",out9name="", inname="";
27  filename = AliAnalysisManager::GetCommonFileName();
28  filename += ":PWG3_D2H_";
29  if(flag==0){
30  filename+="D0InvMass";
31  if(cutOnDistr) filename+="C";
32  if(flagD0D0bar==1)filename+="D0";
33  if(flagD0D0bar==2)filename+="D0bar";
34  //list mass
35  out1name="coutputmassD0Mass";
36  if(cutOnDistr) out1name+="C";
37  if(flagD0D0bar==1)out1name+="D0";
38  if(flagD0D0bar==2)out1name+="D0bar";
39  //list distr
40  out2name="coutputmassD0distr";
41  if(cutOnDistr) out2name+="C";
42  if(flagD0D0bar==1)out2name+="D0";
43  if(flagD0D0bar==2)out2name+="D0bar";
44  //hist entries
45  out3name="nEntriesD0";
46  if(cutOnDistr) out3name+="C";
47  if(flagD0D0bar==1)out3name+="D0";
48  if(flagD0D0bar==2)out3name+="D0bar";
49  //cuts object
50  out4name="cutsD0";
51  if(cutOnDistr) out4name+="C";
52  if(flagD0D0bar==1)out4name+="D0";
53  if(flagD0D0bar==2)out4name+="D0bar";
54 
55  //AliNormalizationCounter
56  out5name="normalizationCounter";
57  if(cutOnDistr) out5name+="C";
58  if(flagD0D0bar==1)out5name+="D0";
59  if(flagD0D0bar==2)out5name+="D0bar";
60 
61  // mass, pt, imp param distr
62  out6name="coutputmassD0MassPt";
63  if(cutOnDistr) out6name+="C";
64  if(flagD0D0bar==1)out6name+="D0";
65  if(flagD0D0bar==2)out6name+="D0bar";
66 
67  out7name ="coutputVarTree";
68 
69  //detector signal hists
70  out8name="detectorSignals";
71  if(cutOnDistr) out8name+="C";
72  if(flagD0D0bar==1)out8name+="D0";
73  if(flagD0D0bar==2)out8name+="D0bar";
74 
75  // mass, y distr
76  out9name="coutputmassD0MassY";
77  if(cutOnDistr) out9name+="C";
78  if(flagD0D0bar==1)out9name+="D0";
79  if(flagD0D0bar==2)out9name+="D0bar";
80 
81 
82  inname="cinputmassD0_0";
83  if(cutOnDistr) inname+="C";
84  if(flagD0D0bar==1)inname+="D0";
85  if(flagD0D0bar==2)inname+="D0bar";
86 
87  } else {
88  filename+="D0InvMassLikeSign";
89  if(cutOnDistr) filename+="C";
90  if(flagD0D0bar==1)filename+="D0";
91  if(flagD0D0bar==2)filename+="D0bar";
92  //list mass
93  out1name="coutputmassLSMass";
94  if(cutOnDistr) out1name+="C";
95  if(flagD0D0bar==1)out1name+="D0";
96  if(flagD0D0bar==2)out1name+="D0bar";
97  //list distr
98  out2name="coutputmassLSdistr";
99  if(cutOnDistr) out2name+="C";
100  if(flagD0D0bar==1)out2name+="D0";
101  if(flagD0D0bar==2)out2name+="D0bar";
102  //hist entries
103  out3name="nEntriesLS";
104  if(cutOnDistr) out3name+="C";
105  if(flagD0D0bar==1)out3name+="D0";
106  if(flagD0D0bar==2)out3name+="D0bar";
107  //cuts object
108  out4name="cutsLS";
109  if(cutOnDistr) out4name+="C";
110  if(flagD0D0bar==1)out4name+="D0";
111  if(flagD0D0bar==2)out4name+="D0bar";
112 
113  //AliNormalizationCounter
114  out5name="normalizationCounterLS";
115  if(cutOnDistr) out5name+="C";
116  if(flagD0D0bar==1)out5name+="D0";
117  if(flagD0D0bar==2)out5name+="D0bar";
118 
119  // mass, pt, imp param distr
120  out6name="coutputmassD0MassPtLS";
121  if(cutOnDistr) out6name+="C";
122  if(flagD0D0bar==1)out6name+="D0";
123  if(flagD0D0bar==2)out6name+="D0bar";
124 
125  out7name ="coutputVarTreeLS";
126 
127  //detector signal hists
128  out8name="detectorSignalsLS";
129  if(cutOnDistr) out8name+="C";
130  if(flagD0D0bar==1)out8name+="D0";
131  if(flagD0D0bar==2)out8name+="D0bar";
132 
133  // mass, y distr
134  out9name="coutputmassD0MassYLS";
135  if(cutOnDistr) out9name+="C";
136  if(flagD0D0bar==1)out9name+="D0";
137  if(flagD0D0bar==2)out9name+="D0bar";
138 
139 
140  inname="cinputmassD0_1";
141  if(cutOnDistr) inname+="C";
142  if(flagD0D0bar==1)inname+="D0";
143  if(flagD0D0bar==2)inname+="D0bar";
144  }
145  filename += finDirname.Data();
146  out1name += finDirname.Data();
147  out2name += finDirname.Data();
148  out3name += finDirname.Data();
149  out4name += finDirname.Data();
150  out5name += finDirname.Data();
151  out6name += finDirname.Data();
152  out7name += finDirname.Data();
153  out8name += finDirname.Data();
154  out9name += finDirname.Data();
155  inname += finDirname.Data();
156 
157  //setting my cut values
158 
159  //cuts order
160  // printf(" |M-MD0| [GeV] < %f\n",fD0toKpiCuts[0]);
161  // printf(" dca [cm] < %f\n",fD0toKpiCuts[1]);
162  // printf(" cosThetaStar < %f\n",fD0toKpiCuts[2]);
163  // printf(" pTK [GeV/c] > %f\n",fD0toKpiCuts[3]);
164  // printf(" pTpi [GeV/c] > %f\n",fD0toKpiCuts[4]);
165  // printf(" |d0K| [cm] < %f\n",fD0toKpiCuts[5]);
166  // printf(" |d0pi| [cm] < %f\n",fD0toKpiCuts[6]);
167  // printf(" d0d0 [cm^2] < %f\n",fD0toKpiCuts[7]);
168  // printf(" cosThetaPoint > %f\n",fD0toKpiCuts[8]);
169 
170  Bool_t stdcuts=kFALSE;
171  TFile* filecuts;
172  if( finname.EqualTo("") ) {
173  stdcuts=kTRUE;
174  } else {
175  filecuts=TFile::Open(finname.Data());
176  if(!filecuts ||(filecuts&& !filecuts->IsOpen())){
177  ::Fatal("AddTaskD0Mass", "Input file not found : check your cut object");
178  }
179  }
180 
181  AliRDHFCutsD0toKpi* RDHFD0toKpi=new AliRDHFCutsD0toKpi();
182  if(stdcuts) {
183  if(system==0) RDHFD0toKpi->SetStandardCutsPP2010();
184  else {
185  RDHFD0toKpi->SetStandardCutsPbPb2011();
186  if(minC!=0 && maxC!=0) { //if centrality 0 and 0 leave the values in the cut object
187  RDHFD0toKpi->SetMinCentrality(minC);
188  RDHFD0toKpi->SetMaxCentrality(maxC);
189  }
190  if(flagAOD049)RDHFD0toKpi->SetUseAOD049(kTRUE);
192  }
193  }
194  else {
195  RDHFD0toKpi = (AliRDHFCutsD0toKpi*)filecuts->Get(finObjname.Data());
196  if(!RDHFD0toKpi){
197  ::Fatal("AddTaskD0Mass", "Specific AliRDHFCuts not found");
198  return NULL;
199  }
200  if(flagAOD049)RDHFD0toKpi->SetUseAOD049(kTRUE);
201  if(minC!=0 && maxC!=0) { //if centrality 0 and 0 leave the values in the cut object
202  RDHFD0toKpi->SetMinCentrality(minC);
203  RDHFD0toKpi->SetMaxCentrality(maxC);
204  }
205  }
206  // RDHFD0toKpi->SetName(Form("D0toKpiCuts%d",flag));
207 
208  TString centr="";
209  if(minC!=0 && maxC!=0) centr = Form("%.0f%.0f",minC,maxC);
210  else centr = Form("%.0f%.0f",RDHFD0toKpi->GetMinCentrality(),RDHFD0toKpi->GetMaxCentrality());
211  out1name+=centr;
212  out2name+=centr;
213  out3name+=centr;
214  out4name+=centr;
215  out5name+=centr;
216  out6name+=centr;
217  out7name+=centr;
218  out8name+=centr;
219  out9name+=centr;
220  inname+=centr;
221 
222  // Aanalysis task
223  TString taskname="MassAndDistrAnalysis";
224  if (flag==0)taskname.Prepend("D0");
225  else taskname.Prepend("LS");
226  AliAnalysisTaskSED0Mass *massD0Task = new AliAnalysisTaskSED0Mass(taskname.Data(),RDHFD0toKpi);
227  massD0Task->SetDebugLevel(0);
228  massD0Task->SetArray(flag);
229  massD0Task->SetReadMC(readMC);
230  massD0Task->SetCutOnDistr(cutOnDistr);
231  massD0Task->SetUsePid4Distr(kFALSE);
232  massD0Task->SetFillOnlyD0D0bar(flagD0D0bar);
233  massD0Task->SetSystem(system); //0=pp, 1=PbPb
234  massD0Task->SetFillVarHists(filldistr); // default is FALSE if System=PbPb
235 
236  massD0Task->SetAODMismatchProtection(AODProtection);
237 
238  massD0Task->SetFillPtHistos(FillMassPt);
239  massD0Task->SetFillImpactParameterHistos(FillImpPar);
240  massD0Task->SetFillYHistos(FillMassY);
241  massD0Task->SetDrawDetSignal(DrawDetSignal);
242  massD0Task->SetPIDCheck(PIDCheck);
243  massD0Task->SetDoMCAcceptanceHistos(FillMCAcc);
244  // massD0Task->SetRejectSDDClusters(kTRUE);
245 
246  // massD0Task->SetWriteVariableTree(kTRUE);
247 
248  mgr->AddTask(massD0Task);
249 
250  //
251  // Create containers for input/output
252  AliAnalysisDataContainer *cinputmassD0 = mgr->CreateContainer(inname,TChain::Class(),
253  AliAnalysisManager::kInputContainer);
254 
255  AliAnalysisDataContainer *coutputmassD01 = mgr->CreateContainer(out1name,TList::Class(),AliAnalysisManager::kOutputContainer, filename.Data()); //mass
256  AliAnalysisDataContainer *coutputmassD02 = mgr->CreateContainer(out2name,TList::Class(),AliAnalysisManager::kOutputContainer, filename.Data()); //distr
257  AliAnalysisDataContainer *coutputmassD03 = mgr->CreateContainer(out3name,TH1F::Class(),AliAnalysisManager::kOutputContainer, filename.Data()); //nev
258  AliAnalysisDataContainer *coutputmassD04 = mgr->CreateContainer(out4name,AliRDHFCutsD0toKpi::Class(),AliAnalysisManager::kOutputContainer, filename.Data()); //cuts
259  AliAnalysisDataContainer *coutputmassD05 = mgr->CreateContainer(out5name,AliNormalizationCounter::Class(),AliAnalysisManager::kOutputContainer, filename.Data()); //counter
260  AliAnalysisDataContainer *coutputmassD06 = mgr->CreateContainer(out6name,TList::Class(),AliAnalysisManager::kOutputContainer, filename.Data()); //mass vs pt vs impt par
261  AliAnalysisDataContainer *coutputmassD07 = mgr->CreateContainer(out7name,TTree::Class(),AliAnalysisManager::kOutputContainer, filename.Data()); //mass vs pt vs impt par
262  AliAnalysisDataContainer *coutputmassD08 = mgr->CreateContainer(out8name,TList::Class(),AliAnalysisManager::kOutputContainer, filename.Data()); //dedx
263  AliAnalysisDataContainer *coutputmassD09 = mgr->CreateContainer(out9name,TList::Class(),AliAnalysisManager::kOutputContainer, filename.Data()); //mass vs y
264 
265 
266 
267  mgr->ConnectInput(massD0Task,0,mgr->GetCommonInputContainer());
268 
269  mgr->ConnectOutput(massD0Task,1,coutputmassD01);
270  mgr->ConnectOutput(massD0Task,2,coutputmassD02);
271  mgr->ConnectOutput(massD0Task,3,coutputmassD03);
272  mgr->ConnectOutput(massD0Task,4,coutputmassD04);
273  mgr->ConnectOutput(massD0Task,5,coutputmassD05);
274  mgr->ConnectOutput(massD0Task,6,coutputmassD06);
275  mgr->ConnectOutput(massD0Task,7,coutputmassD07);
276  mgr->ConnectOutput(massD0Task,8,coutputmassD08);
277  mgr->ConnectOutput(massD0Task,9,coutputmassD09);
278 
279 
280  return massD0Task;
281 }
Float_t GetMaxCentrality() const
Definition: AliRDHFCuts.h:282
const char * filename
Definition: TestFCM.C:1
void SetUseAOD049(Bool_t flag=kTRUE)
Definition: AliRDHFCuts.h:210
void SetDoMCAcceptanceHistos(Bool_t doMCAcc=kTRUE)
void SetUseCentrality(Int_t flag=1)
void SetAODMismatchProtection(Int_t opt=1)
void SetArray(Int_t type=AliAnalysisTaskSED0Mass::kD0)
virtual void SetStandardCutsPP2010()
void SetFillOnlyD0D0bar(Int_t flagfill)
Float_t GetMinCentrality() const
Definition: AliRDHFCuts.h:281
void SetReadMC(Bool_t readMC=kFALSE)
int Int_t
Definition: External.C:63
void SetMinCentrality(Float_t minCentrality=0.)
Definition: AliRDHFCuts.h:51
float Float_t
Definition: External.C:68
void SetFillImpactParameterHistos(Bool_t flag)
AliAnalysisTaskSED0Mass * AddTaskD0Mass(Int_t flag=0, Bool_t readMC=kFALSE, Bool_t filldistr=kFALSE, Bool_t cutOnDistr=kFALSE, Int_t system=0, Int_t flagD0D0bar=0, Float_t minC=0, Float_t maxC=0, TString finDirname="Loose", TString finname="", TString finObjname="D0toKpiCuts", Bool_t flagAOD049=kFALSE, Bool_t FillMassPt=false, Bool_t FillImpPar=false, Bool_t DrawDetSignal=false, Bool_t PIDCheck=false, Bool_t FillMassY=false, Bool_t FillMCAcc=true, Int_t AODProtection=1)
Definition: AddTaskD0Mass.C:1
void SetDrawDetSignal(Bool_t flag)
void SetMaxCentrality(Float_t maxCentrality=100.)
Definition: AliRDHFCuts.h:52
void SetCutOnDistr(Bool_t cutondistr=kFALSE)
bool Bool_t
Definition: External.C:53
void SetUsePid4Distr(Bool_t usepid=kTRUE)
virtual void SetStandardCutsPbPb2011()