]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG3/vertexingHF/AliAnalysisTaskSED0Mass.cxx
Little changes (Andrea)
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / AliAnalysisTaskSED0Mass.cxx
CommitLineData
49061176 1/**************************************************************************
2 * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/////////////////////////////////////////////////////////////
17//
18// AliAnalysisTaskSE for D0 candidates invariant mass histogram
a41f6fad 19// and comparison with the MC truth and cut variables distributions.
49061176 20//
21// Authors: A.Dainese, andrea.dainese@lnl.infn.it
feb73eca 22// Chiara Bianchin, chiara.bianchin@pd.infn.it (invariant mass)
23// Carmelo Di Giglio, carmelo.digiglio@ba.infn.it (like sign)
49061176 24/////////////////////////////////////////////////////////////
25
26#include <Riostream.h>
27#include <TClonesArray.h>
28#include <TNtuple.h>
29#include <TList.h>
30#include <TH1F.h>
a41f6fad 31#include <TH2F.h>
32#include <TDatabasePDG.h>
49061176 33
34#include "AliAODEvent.h"
35#include "AliAODVertex.h"
36#include "AliAODTrack.h"
37#include "AliAODMCHeader.h"
38#include "AliAODMCParticle.h"
39#include "AliAODRecoDecayHF2Prong.h"
40#include "AliAODRecoCascadeHF.h"
41#include "AliAnalysisVertexingHF.h"
42#include "AliAnalysisTaskSE.h"
43#include "AliAnalysisTaskSED0Mass.h"
44
45ClassImp(AliAnalysisTaskSED0Mass)
46
47
48//________________________________________________________________________
49AliAnalysisTaskSED0Mass::AliAnalysisTaskSED0Mass():
50AliAnalysisTaskSE(),
a4ae02cd 51fOutputtight(0),
a41f6fad 52fOutputloose(0),
53fDistr(0),
feb73eca 54fNentries(0),
a4ae02cd 55fVHFtight(0),
6ce5994f 56fVHFloose(0),
feb73eca 57fArray(0),
58fLsNormalization(1.)
59
49061176 60{
61 // Default constructor
62}
63
64//________________________________________________________________________
65AliAnalysisTaskSED0Mass::AliAnalysisTaskSED0Mass(const char *name):
66AliAnalysisTaskSE(name),
a4ae02cd 67fOutputtight(0),
68fOutputloose(0),
a41f6fad 69fDistr(0),
feb73eca 70fNentries(0),
a4ae02cd 71fVHFtight(0),
6ce5994f 72fVHFloose(0),
feb73eca 73fArray(0),
74fLsNormalization(1.)
49061176 75{
76 // Default constructor
77
78 // Output slot #1 writes into a TList container
79 DefineOutput(1,TList::Class()); //My private output
a4ae02cd 80 // Output slot #2 writes into a TList container
81 DefineOutput(2,TList::Class()); //My private output
82 // Output slot #3 writes into a TH1F container
83 DefineOutput(3,TH1F::Class()); //My private output
a41f6fad 84 // Output slot #4 writes into a TList container
85 DefineOutput(4,TList::Class()); //My private output
49061176 86}
87
88//________________________________________________________________________
89AliAnalysisTaskSED0Mass::~AliAnalysisTaskSED0Mass()
90{
46c96ce5 91 if (fOutputtight) {
a4ae02cd 92 delete fOutputtight;
93 fOutputtight = 0;
94 }
95 if (fVHFtight) {
96 delete fVHFtight;
97 fVHFtight = 0;
98 }
99 if (fOutputloose) {
100 delete fOutputloose;
101 fOutputloose = 0;
102 }
a41f6fad 103
104 if (fDistr) {
105 delete fDistr;
106 fDistr = 0;
107 }
108
a4ae02cd 109 if (fVHFloose) {
110 delete fVHFloose;
111 fVHFloose = 0;
49061176 112 }
46c96ce5 113 if (fNentries){
114 delete fNentries;
115 fNentries = 0;
116 }
a41f6fad 117
118
49061176 119}
120
121//________________________________________________________________________
122void AliAnalysisTaskSED0Mass::Init()
123{
124 // Initialization
125
126 if(fDebug > 1) printf("AnalysisTaskSED0Mass::Init() \n");
127
128 gROOT->LoadMacro("$ALICE_ROOT/PWG3/vertexingHF/ConfigVertexingHF.C");
129
a4ae02cd 130 // 2 sets of dedidcated cuts -- defined in UserExec
131 fVHFtight = (AliAnalysisVertexingHF*)gROOT->ProcessLine("ConfigVertexingHF()");
132 fVHFloose = (AliAnalysisVertexingHF*)gROOT->ProcessLine("ConfigVertexingHF()");
133
49061176 134 return;
135}
136
137//________________________________________________________________________
138void AliAnalysisTaskSED0Mass::UserCreateOutputObjects()
139{
140
141 // Create the output container
142 //
143 if(fDebug > 1) printf("AnalysisTaskSED0Mass::UserCreateOutputObjects() \n");
144
145 // Several histograms are more conveniently managed in a TList
a4ae02cd 146 fOutputtight = new TList();
147 fOutputtight->SetOwner();
148 fOutputtight->SetName("listtight");
149
150 fOutputloose = new TList();
151 fOutputloose->SetOwner();
152 fOutputloose->SetName("listloose");
49061176 153
a41f6fad 154 fDistr = new TList();
155 fDistr->SetOwner();
156 fDistr->SetName("distributionslist");
157
6ce5994f 158 const Int_t nhist=4;
a4ae02cd 159
a41f6fad 160 TString nameMass=" ", nameSgn=" ", nameBkg=" ", nameRfl=" ", namedistr=" ";
49061176 161
162 for(Int_t i=0;i<nhist;i++){
7646d6da 163 nameMass="histMass_";
49061176 164 nameMass+=i+1;
7646d6da 165 nameSgn="histSgn_";
49061176 166 nameSgn+=i+1;
7646d6da 167 nameBkg="histBkg_";
49061176 168 nameBkg+=i+1;
a4ae02cd 169 nameRfl="histRfl_";
170 nameRfl+=i+1;
7646d6da 171
a41f6fad 172 //histograms of invariant mass distributions
173
46c96ce5 174 TH1F* tmpMt = new TH1F(nameMass.Data(),"D^{0} invariant mass; M [GeV]; Entries",200,1.765,1.965);
175 TH1F *tmpMl=(TH1F*)tmpMt->Clone();
176 tmpMt->Sumw2();
177 tmpMl->Sumw2();
a4ae02cd 178
46c96ce5 179 TH1F* tmpSt = new TH1F(nameSgn.Data(), "D^{0} invariant mass - MC; M [GeV]; Entries",200,1.765,1.965);
180 TH1F *tmpSl=(TH1F*)tmpSt->Clone();
181 tmpSt->Sumw2();
182 tmpSl->Sumw2();
a4ae02cd 183
46c96ce5 184 TH1F* tmpBt = new TH1F(nameBkg.Data(), "Background invariant mass - MC; M [GeV]; Entries",200,1.765,1.965);
185 TH1F *tmpBl=(TH1F*)tmpBt->Clone();
186 tmpBt->Sumw2();
187 tmpBl->Sumw2();
a4ae02cd 188
feb73eca 189 //Reflection: histo filled with D0Mass which pass the cut (also) as D0bar and with D0bar which pass (also) the cut as D0
46c96ce5 190 TH1F* tmpRt = new TH1F(nameRfl.Data(), "Reflected signal invariant mass - MC; M [GeV]; Entries",200,1.765,1.965);
191 TH1F *tmpRl=(TH1F*)tmpRt->Clone();
192 tmpRt->Sumw2();
193 tmpRl->Sumw2();
a4ae02cd 194 // printf("Created histograms %s\t%s\t%s\t%s\n",tmpM->GetName(),tmpS->GetName(),tmpB->GetName(),tmpR->GetName());
195
46c96ce5 196 fOutputtight->Add(tmpMt);
197 fOutputtight->Add(tmpSt);
198 fOutputtight->Add(tmpBt);
199 fOutputtight->Add(tmpRt);
a4ae02cd 200
46c96ce5 201 fOutputloose->Add(tmpMl);
202 fOutputloose->Add(tmpSl);
203 fOutputloose->Add(tmpBl);
204 fOutputloose->Add(tmpRl);
a4ae02cd 205
7646d6da 206 }
a4ae02cd 207
a41f6fad 208 //histograms of cut variable distributions
209 // pT
210 namedistr="hptpiS";
211 TH1F *hptpiS = new TH1F(namedistr.Data(), "P_{T} distribution (pions);p_{T} [GeV/c]",200,0.,8.);
a41f6fad 212
213 namedistr="hptKS";
214 TH1F *hptKS = new TH1F(namedistr.Data(), "P_{T} distribution (kaons);p_{T} [GeV/c]",200,0.,8.);
215
216 namedistr="hptB";
217 TH1F *hptB = new TH1F(namedistr.Data(), "P_{T} distribution;p_{T} [GeV/c]",200,0.,8.);
a41f6fad 218
219 // dca
220 namedistr="hdcaS";
221 TH1F *hdcaS = new TH1F(namedistr.Data(), "DCA distribution;dca [cm]",200,0.,0.1);
222 namedistr="hdcaB";
223 TH1F *hdcaB = new TH1F(namedistr.Data(), "DCA distribution;dca [cm]",200,0.,0.1);
a41f6fad 224
225 // costhetastar
feb73eca 226 namedistr="hcosthetastarS";
a41f6fad 227 TH1F *hcosthetastarS = new TH1F(namedistr.Data(), "cos#theta* distribution;cos#theta*",200,-1.,1.);
feb73eca 228 namedistr="hcosthetastarB";
a41f6fad 229 TH1F *hcosthetastarB = new TH1F(namedistr.Data(), "cos#theta* distribution;cos#theta*",200,-1.,1.);
a41f6fad 230
231 // impact parameter
232 namedistr="hd0piS";
233 TH1F *hd0piS = new TH1F(namedistr.Data(), "Impact parameter distribution (pions);d0(#pi) [cm]",200,-0.1,0.1);
a41f6fad 234
235 namedistr="hd0KS";
236 TH1F *hd0KS = new TH1F(namedistr.Data(), "Impact parameter distribution (kaons);d0(K) [cm]",200,-0.1,0.1);
237 namedistr="hd0B";
238 TH1F *hd0B = new TH1F(namedistr.Data(), "Impact parameter distribution;d0 [cm]",200,-0.1,0.1);
a41f6fad 239
240 namedistr="hd0d0S";
241 TH1F *hd0d0S = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution;d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
242 namedistr="hd0d0B";
243 TH1F *hd0d0B = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution;d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
a41f6fad 244
245 // costhetapoint
246 namedistr="hcosthetapointS";
247 TH1F *hcosthetapointS = new TH1F(namedistr.Data(), "cos#theta_{Point} distribution;cos#theta_{Point}",200,0,1.);
248 namedistr="hcosthetapointB";
249 TH1F *hcosthetapointB = new TH1F(namedistr.Data(), "cos#theta_{Point} distribution;cos#theta_{Point}",200,0,1.);
a41f6fad 250
251 namedistr="hcosthpointd0d0S";
252 TH2F *hcosthpointd0d0S= new TH2F(namedistr.Data(),"Correlation cos#theta_{Point}-d_{0}#timesd_{0};cos#theta_{Point};d_{0}#timesd_{0} [cm^{2}]",200,0,1.,200,-0.001,0.001);
253 namedistr="hcosthpointd0d0B";
254 TH2F *hcosthpointd0d0B= new TH2F(namedistr.Data(),"Correlation cos#theta_{Point}-d_{0}#timesd_{0};cos#theta_{Point};d_{0}#timesd_{0} [cm^{2}]",200,0,1.,200,-0.001,0.001);
255
256 fDistr->Add(hptpiS);
a41f6fad 257 fDistr->Add(hptKS);
258 fDistr->Add(hptB);
a41f6fad 259
260 fDistr->Add(hdcaS);
261 fDistr->Add(hdcaB);
a41f6fad 262
263 fDistr->Add(hd0piS);
a41f6fad 264 fDistr->Add(hd0KS);
265 fDistr->Add(hd0B);
a41f6fad 266
267 fDistr->Add(hd0d0S);
268 fDistr->Add(hd0d0B);
a41f6fad 269
270 fDistr->Add(hcosthetastarS);
271 fDistr->Add(hcosthetastarB);
a41f6fad 272
273 fDistr->Add(hcosthetapointS);
274 fDistr->Add(hcosthetapointB);
a41f6fad 275
276 fDistr->Add(hcosthpointd0d0S);
277 fDistr->Add(hcosthpointd0d0B);
278
279 fNentries=new TH1F("nentriesD0", "Look at the number of entries! it is = to the number of AODs", 2,1.,2.);
a4ae02cd 280
49061176 281 return;
282}
283
284//________________________________________________________________________
285void AliAnalysisTaskSED0Mass::UserExec(Option_t */*option*/)
286{
287 // Execute analysis for current event:
288 // heavy flavor candidates association to MC truth
a4ae02cd 289 //cout<<"I'm in UserExec"<<endl;
49061176 290 AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
feb73eca 291
292 TClonesArray *inputArray=0;
293
294 if(fArray==0){ //D0 candidates
295 // load D0->Kpi candidates
296 //cout<<"D0 candidates"<<endl;
297 inputArray =
298 (TClonesArray*)aod->GetList()->FindObject("D0toKpi");
299 if(!inputArray) {
300 printf("AliAnalysisTaskSECompareHFpt::UserExec: D0toKpi branch not found!\n");
301 return;
302 }
303
304 } else { //LikeSign candidates
305
306 //cout<<"LS candidates"<<endl;
307 // load like sign candidates
308 inputArray =
309 (TClonesArray*)aod->GetList()->FindObject("LikeSign2Prong");
310 if(!inputArray) {
311 printf("AliAnalysisTaskSEBkgLikeSignD0::UserExec: LikeSign2Prong branch not found!\n");
312 return;
313 }
314
49061176 315 }
316
317 // AOD primary vertex
318 AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
319 //vtx1->Print();
feb73eca 320
49061176 321 // load MC particles
322 TClonesArray *mcArray =
323 (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
324 if(!mcArray) {
325 printf("AliAnalysisTaskSED0Mass::UserExec: MC particles branch not found!\n");
326 return;
327 }
328
329 // load MC header
330 AliAODMCHeader *mcHeader =
331 (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
332 if(!mcHeader) {
333 printf("AliAnalysisTaskSED0Mass::UserExec: MC header branch not found!\n");
334 return;
335 }
336
a4ae02cd 337
338 //histogram filled with 1 for every AOD
339 fNentries->Fill(1);
340 PostData(3,fNentries);
feb73eca 341 // loop over candidates
342 Int_t nInD0toKpi = inputArray->GetEntriesFast();
4464ce7e 343 if(fDebug>1) printf("Number of D0->Kpi: %d\n",nInD0toKpi);
49061176 344
345 for (Int_t iD0toKpi = 0; iD0toKpi < nInD0toKpi; iD0toKpi++) {
feb73eca 346 //Int_t nPosPairs=0, nNegPairs=0;
a41f6fad 347 //cout<<"inside the loop"<<endl;
feb73eca 348 AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)inputArray->UncheckedAt(iD0toKpi);
49061176 349 Bool_t unsetvtx=kFALSE;
350 if(!d->GetOwnPrimaryVtx()) {
351 d->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
352 unsetvtx=kTRUE;
353 }
354
46c96ce5 355 //cuts order
a4ae02cd 356// printf(" |M-MD0| [GeV] < %f\n",fD0toKpiCuts[0]);
357// printf(" dca [cm] < %f\n",fD0toKpiCuts[1]);
358// printf(" cosThetaStar < %f\n",fD0toKpiCuts[2]);
359// printf(" pTK [GeV/c] > %f\n",fD0toKpiCuts[3]);
360// printf(" pTpi [GeV/c] > %f\n",fD0toKpiCuts[4]);
361// printf(" |d0K| [cm] < %f\n",fD0toKpiCuts[5]);
362// printf(" |d0pi| [cm] < %f\n",fD0toKpiCuts[6]);
363// printf(" d0d0 [cm^2] < %f\n",fD0toKpiCuts[7]);
364// printf(" cosThetaPoint > %f\n",fD0toKpiCuts[8]);
a41f6fad 365
366 //add distr here
367 UInt_t pdgs[2];
49061176 368
a41f6fad 369 Double_t mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
370 pdgs[0]=211;
371 pdgs[1]=321;
372 Double_t minvD0 = d->InvMassD0();
373 pdgs[1]=211;
374 pdgs[0]=321;
375 Double_t minvD0bar = d->InvMassD0bar();
376 //apply cut on invariant mass on the pair
377 if(TMath::Abs(minvD0-mPDG)<0.03 || TMath::Abs(minvD0bar-mPDG)<0.03){
feb73eca 378 //cout<<"inside mass cut"<<endl;
a41f6fad 379 Int_t pdgDgD0toKpi[2]={321,211};
380 Int_t lab=d->MatchToMC(421,mcArray,2,pdgDgD0toKpi); //return MC particle label if the array corresponds to a D0, -1 if not (cf. AliAODRecoDecay.cxx)
381
a41f6fad 382 if(lab>=0){ //signal
feb73eca 383 if(fArray==1) cout<<"LS signal: ERROR"<<endl;
a41f6fad 384 for (Int_t iprong=0; iprong<2; iprong++){
385 AliAODTrack *prong=(AliAODTrack*)d->GetDaughter(iprong);
386 Int_t labprong=prong->GetLabel();
387
388 //cout<<"prong name = "<<prong->GetName()<<" label = "<<prong->GetLabel()<<endl;
389 AliAODMCParticle *mcprong=0;
390 if(labprong>=0) mcprong= (AliAODMCParticle*)mcArray->At(labprong);
391 Int_t pdgprong=mcprong->GetPdgCode();
392 if(TMath::Abs(pdgprong)==211) {
393 //cout<<"pi"<<endl;
394 ((TH1F*)fDistr->FindObject("hptpiS"))->Fill(d->PtProng(iprong));
395 ((TH1F*)fDistr->FindObject("hd0piS"))->Fill(d->Getd0Prong(iprong));
396 }
397
398 if(TMath::Abs(pdgprong)==321) {
399 //cout<<"kappa"<<endl;
400 ((TH1F*)fDistr->FindObject("hptKS"))->Fill(d->PtProng(iprong));
401 ((TH1F*)fDistr->FindObject("hd0KS"))->Fill(d->Getd0Prong(iprong));
402 }
403 ((TH1F*)fDistr->FindObject("hdcaS"))->Fill(d->GetDCA());
404
405 }
406
407 if (((AliAODMCParticle*)mcArray->At(lab))->GetPdgCode() == 421)
feb73eca 408 ((TH1F*)fDistr->FindObject("hcosthetastarS"))->Fill(d->CosThetaStarD0());
409 else ((TH1F*)fDistr->FindObject("hcosthetastarS"))->Fill(d->CosThetaStarD0bar());
a41f6fad 410
411 ((TH1F*)fDistr->FindObject("hd0d0S"))->Fill(d->Prodd0d0());
412
413 ((TH1F*)fDistr->FindObject("hcosthetapointS"))->Fill(d->CosPointingAngle());
414 ((TH1F*)fDistr->FindObject("hcosthpointd0d0S"))->Fill(d->CosPointingAngle(),d->Prodd0d0());
415
416 //cout<<"ok point"<<endl;
417
feb73eca 418
419 } else{ //Background or LS
a41f6fad 420 //cout<<"is background"<<endl;
feb73eca 421 AliAODTrack *prong=(AliAODTrack*)d->GetDaughter(0);
422 if(!prong) cout<<"No daughter found";
423 else{
424 if(prong->Charge()==1) fTotPosPairs[4]++; else fTotNegPairs[4]++;
425 }
a41f6fad 426 ((TH1F*)fDistr->FindObject("hptB"))->Fill(d->PtProng(0));
427 //cout<<"ptok"<<endl;
428 ((TH1F*)fDistr->FindObject("hd0B"))->Fill(d->Getd0Prong(0));
429 //cout<<"d0ok"<<endl;
430 ((TH1F*)fDistr->FindObject("hdcaB"))->Fill(d->GetDCA());
431 //cout<<"dcaok"<<endl;
feb73eca 432 ((TH1F*)fDistr->FindObject("hcosthetastarB"))->Fill(d->CosThetaStarD0());
433 ((TH1F*)fDistr->FindObject("hcosthetastarB"))->Fill(d->CosThetaStarD0bar());
a41f6fad 434 ((TH1F*)fDistr->FindObject("hd0d0B"))->Fill(d->Prodd0d0());
435 //cout<<"d0d0ok"<<endl;
436 ((TH1F*)fDistr->FindObject("hcosthetapointB"))->Fill(d->CosPointingAngle());
437 ((TH1F*)fDistr->FindObject("hcosthpointd0d0B"))->Fill(d->CosPointingAngle(),d->Prodd0d0());
438
439 //cout<<"pointok"<<endl;
440
441 }
442
443 } //inv mass cut
444
445
49061176 446 Double_t pt = d->Pt();
a41f6fad 447
49061176 448 Int_t ptbin=0;
449
450 //cout<<"P_t = "<<pt<<endl;
451 if (pt>0. && pt<=1.) {
a4ae02cd 452 ptbin=1;
6ce5994f 453 fVHFtight->SetD0toKpiCuts(0.7,0.04,0.8,0.5,0.5,0.05,0.05,-0.0003,0.7);
454 fVHFloose->SetD0toKpiCuts(0.7,0.04,0.8,0.5,0.5,0.05,0.05,-0.00025,0.7);
455// fVHFtight->SetD0toKpiCuts(0.7,0.04,0.8,0.5,0.5,0.05,0.05,-0.0002,0.7);
456// fVHFloose->SetD0toKpiCuts(0.7,0.04,0.8,0.5,0.5,1,1,-0.00015,0.5);
49061176 457 //printf("I'm in the bin %d\n",ptbin);
a4ae02cd 458
49061176 459 }
46c96ce5 460
461 if(pt>1. && pt<=3.) {
462 ptbin=2;
463 fVHFtight->SetD0toKpiCuts(0.7,0.02,0.8,0.7,0.7,0.05,0.05,-0.0003,0.9);
464 fVHFloose->SetD0toKpiCuts(0.7,0.02,0.8,0.7,0.7,1,1,-0.00025,0.8);
465 //printf("I'm in the bin %d\n",ptbin);
466 }
467
468 if(pt>3. && pt<=5.){
49061176 469 ptbin=3;
6ce5994f 470 fVHFtight->SetD0toKpiCuts(0.7,0.015,0.8,0.7,0.7,0.05,0.05,-0.0002,0.9);
471 fVHFloose->SetD0toKpiCuts(0.7,0.02,0.8,0.7,0.7,0.05,0.05,-0.00015,0.8);
49061176 472 //printf("I'm in the bin %d\n",ptbin);
49061176 473 }
46c96ce5 474 if(pt>5.){
475 ptbin=4;
476 fVHFtight->SetD0toKpiCuts(0.7,0.015,0.8,0.7,0.7,0.05,0.05,-0.0002,0.95);
477 fVHFloose->SetD0toKpiCuts(0.7,0.02,0.8,0.7,0.7,0.05,0.05,-0.00015,0.9);
478 }//if(pt>5)
479
a4ae02cd 480 //printf("I'm in the bin %d\n",ptbin);
481 //old
482 //fVHF->SetD0toKpiCuts(0.7,0.03,0.8,0.06,0.06,0.05,0.05,-0.0002,0.6); //2.p-p vertex reconstructed
483
a4ae02cd 484 FillHists(ptbin,d,mcArray,fVHFtight,fOutputtight);
485 FillHists(ptbin,d,mcArray,fVHFloose,fOutputloose);
49061176 486 if(unsetvtx) d->UnsetOwnPrimaryVtx();
49061176 487 }
46c96ce5 488
49061176 489
490
491
492 // Post the data
a4ae02cd 493 PostData(1,fOutputtight);
494 PostData(2,fOutputloose);
a41f6fad 495 PostData(4,fDistr);
49061176 496 return;
497}
498//____________________________________________________________________________*
a4ae02cd 499void AliAnalysisTaskSED0Mass::FillHists(Int_t ptbin, AliAODRecoDecayHF2Prong *part, TClonesArray *arrMC, AliAnalysisVertexingHF *vhf, TList *listout){
49061176 500 //
501 // function used in UserExec:
502 //
503 Int_t okD0=0,okD0bar=0;
feb73eca 504 //cout<<"inside FillHist"<<endl;
a4ae02cd 505 if(part->SelectD0(vhf->GetD0toKpiCuts(),okD0,okD0bar)) {//selected
49061176 506 Double_t invmassD0 = part->InvMassD0(), invmassD0bar = part->InvMassD0bar();
507 //printf("SELECTED\n");
feb73eca 508
509 AliAODTrack *prong=(AliAODTrack*)part->GetDaughter(0);
510 if(!prong) cout<<"No daughter found";
511 else{
512 if(prong->Charge()==1) fTotPosPairs[ptbin-1]++; else fTotNegPairs[ptbin-1]++;
513 }
514
515 TString fillthis="";
c8112d2f 516 Int_t pdgDgD0toKpi[2]={321,211};
517 Int_t labD0 = part->MatchToMC(421,arrMC,2,pdgDgD0toKpi); //return MC particle label if the array corresponds to a D0, -1 if not (cf. AliAODRecoDecay.cxx)
a41f6fad 518
a4ae02cd 519 if (okD0==1) {
520 fillthis="histMass_";
7646d6da 521 fillthis+=ptbin;
522 //cout<<"Filling "<<fillthis<<endl;
523
49061176 524 //printf("Fill mass with D0");
a4ae02cd 525 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
feb73eca 526
a4ae02cd 527 if(labD0>=0) {
feb73eca 528 if(fArray==1) cout<<"LS signal ERROR"<<endl;
529
a4ae02cd 530 AliAODMCParticle *partD0 = (AliAODMCParticle*)arrMC->At(labD0);
531 Int_t pdgD0 = partD0->GetPdgCode();
532 //cout<<"pdg = "<<pdgD0<<endl;
a4ae02cd 533 if (pdgD0==421){ //D0
534 //cout<<"Fill S with D0"<<endl;
46c96ce5 535 fillthis="histSgn_";
536 fillthis+=ptbin;
a4ae02cd 537 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
538
539 } else{ //it was a D0bar
46c96ce5 540 fillthis="histRfl_";
541 fillthis+=ptbin;
542 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
a4ae02cd 543 }
544 } else {//background
545 fillthis="histBkg_";
546 fillthis+=ptbin;
547 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
548 }
feb73eca 549
49061176 550 }
551 if (okD0bar==1) {
a4ae02cd 552 fillthis="histMass_";
553 fillthis+=ptbin;
49061176 554 //printf("Fill mass with D0bar");
a4ae02cd 555 ((TH1F*)listout->FindObject(fillthis))->Fill(invmassD0bar);
feb73eca 556
a4ae02cd 557 if(labD0>=0) {
feb73eca 558 if(fArray==1) cout<<"LS signal ERROR"<<endl;
a4ae02cd 559 AliAODMCParticle *partD0 = (AliAODMCParticle*)arrMC->At(labD0);
560 Int_t pdgD0 = partD0->GetPdgCode();
561 //cout<<" pdg = "<<pdgD0<<endl;
562 if (pdgD0==-421){ //D0bar
563 fillthis="histSgn_";
564 fillthis+=ptbin;
565 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
566
567 } else{
46c96ce5 568 fillthis="histRfl_";
569 fillthis+=ptbin;
570 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
a4ae02cd 571 }
feb73eca 572 } else {//background or LS
a4ae02cd 573 fillthis="histBkg_";
574 fillthis+=ptbin;
575 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
576 }
577 }
578
579
49061176 580 } //else cout<<"NOT SELECTED"<<endl;
581
582}
583//________________________________________________________________________
584void AliAnalysisTaskSED0Mass::Terminate(Option_t */*option*/)
585{
586 // Terminate analysis
587 //
588 if(fDebug > 1) printf("AnalysisTaskSED0Mass: Terminate() \n");
589
a4ae02cd 590 fOutputtight = dynamic_cast<TList*> (GetOutputData(1));
591 if (!fOutputtight) {
a41f6fad 592 printf("ERROR: fOutputthight not available\n");
a4ae02cd 593 return;
594 }
595 fOutputloose = dynamic_cast<TList*> (GetOutputData(2));
596 if (!fOutputloose) {
a41f6fad 597 printf("ERROR: fOutputloose not available\n");
598 return;
599 }
600 fDistr = dynamic_cast<TList*> (GetOutputData(3));
601 if (!fDistr) {
602 printf("ERROR: fDistr not available\n");
49061176 603 return;
604 }
605
feb73eca 606 if(fArray==1){
607 for(Int_t ipt=0;ipt<4;ipt++){
608 fLsNormalization = 2.*TMath::Sqrt(fTotPosPairs[ipt]*fTotNegPairs[ipt]);
609
610
611 if(fLsNormalization>0) {
612
613 TString massName="histMass_";
614 massName+=ipt+1;
615 ((TH1F*)fOutputtight->FindObject(massName))->Scale((1/fLsNormalization)*((TH1F*)fOutputtight->FindObject(massName))->GetEntries());
616 ((TH1F*)fOutputloose->FindObject(massName))->Scale((1/fLsNormalization)*((TH1F*)fOutputloose->FindObject(massName))->GetEntries());
617 }
618 }
619
620 fLsNormalization = 2.*TMath::Sqrt(fTotPosPairs[4]*fTotNegPairs[4]);
621
622 if(fLsNormalization>0) {
623
624 TString nameDistr="hptB";
625 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
626 nameDistr="hdcaB";
627 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
628 nameDistr="hcosthetastarB";
629 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
630 nameDistr="hd0B";
631 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
632 nameDistr="hd0d0B";
633 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
634 nameDistr="hcosthetapointB";
635 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
636 nameDistr="hcosthpointd0d0B";
637 ((TH2F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH2F*)fDistr->FindObject(nameDistr))->GetEntries());
638
639 }
640 }
6ce5994f 641
49061176 642 return;
643}
644