AliPhysics  b5b0183 (b5b0183)
AliAnalysisTaskSEB0toDminuspi.cxx
Go to the documentation of this file.
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  * appeuear 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 // Base class for B0 analysis
19 //
20 //
21 // Cuts arew centralized in AliRDHFCutsDplustoKpipi
22 //
23 
24 #include <TSystem.h>
25 #include <TParticle.h>
26 #include <TH1I.h>
27 #include <TObjArray.h>
28 #include "TROOT.h"
29 #include <TDatabasePDG.h>
30 #include <AliAnalysisDataSlot.h>
31 #include <AliAnalysisDataContainer.h>
32 //#include "AliRDHFCutsDStartoKpipi.h"
34 #include "AliVertex.h"
35 #include "AliVVertex.h"
36 #include "AliESDVertex.h"
37 #include "AliVertexerTracks.h"
38 #include "AliMCEvent.h"
39 #include "AliAnalysisManager.h"
40 #include "AliAODMCHeader.h"
41 #include "AliAODHandler.h"
42 #include "AliLog.h"
43 #include "AliExternalTrackParam.h"
44 #include "AliNeutralTrackParam.h"
45 #include "AliAODVertex.h"
46 #include "AliAODRecoDecay.h"
47 #include "AliAODRecoDecayHF.h"
48 #include "AliAODRecoCascadeHF.h"
51 #include "AliAnalysisVertexingHF.h"
52 #include "AliESDtrack.h"
53 #include "AliAODMCParticle.h"
55 #include "AliAODEvent.h"
57 #include "AliVertexingHFUtils.h"
58 
60 
61 //__________________________________________________________________________
64  fEvents(0),
65  fOutput(0),
66  fOutputBins(0),
67  //fOutputPID(0),
68  fArrayB0(0),
69  //HISTO
70  fCEvents(0),
71  fB0InvMass(0),
72  fDplusInvMass(0),
73  fB0InvMass_PassCut1(0),
74  fB0InvMassMinusD_PassCut1(0),
75  fDplusInvMass_PassCut1(0),
76  fDplusInvMass_DplusMCmatch(0),
77  fDplusInvMass_MCmatch(0),
78  fBInvMass_MCmatch(0),
79  fBInvMass_MCmatch_PassCut1(0),
80  fB0InvMassMinusD_MCmatch_PassCut1(0),
81 
82  fpiPt(0),
83  fpiEta(0),
84  fpiPhi(0),
85  fDplusPt(0),
86  fDplusEta(0),
87  fDplusPhi(0),
88  fDplusPointing(0),
89  fDplusDecayLength(0),
90  fDplusNormalizedDecayLength(0),
91  fDplusSigmaVert(0),
92  fBPt(0),
93  fBEta(0),
94  fBPhi(0),
95  fBPointing(0),
96  fBPointingXY(0),
97  fBDecayLength(0),
98  fBNormalizedDecayLength(0),
99  fDplusd0(0),
100  fpid0(0),
101  fproductd0(0),
102  fpiPt_MCmatch(0),
103  fpiEta_MCmatch(0),
104  fpiPhi_MCmatch(0),
105  fDplusPt_MCmatch(0),
106  fDplusEta_MCmatch(0),
107  fDplusPhi_MCmatch(0),
108  fDplusPointing_MCmatch(0),
109  fDplusDecayLength_MCmatch(0),
110  fDplusNormalizedDecayLength_MCmatch(0),
111  fDplusSigmaVert_MCmatch(0),
112  fBPt_MCmatch(0),
113  fBEta_MCmatch(0),
114  fBPhi_MCmatch(0),
115  fBPointing_MCmatch(0),
116  fBPointingXY_MCmatch(0),
117  fBDecayLength_MCmatch(0),
118  fBNormalizedDecayLength_MCmatch(0),
119  fDplusd0_MCmatch(0),
120  fpid0_MCmatch(0),
121  fproductd0_MCmatch(0),
122 
123 
124  fd0MMExpD(0),
125  fd0MMExpDMCmatch(0),
126  fd0MMExppi(0),
127  fd0MMExppiMCmatch(0),
128  fd0MMExpDDaughters(0),
129  fd0MMExpDDaughters_MCmatch(0),
130  fcosoa(0),
131  fcosoa_MCmatch(0),
132 
133  fBDplusPt(0),
134  fBDplusPt_MCmatch(0),
135  fBpiPt(0),
136  fBpiPt_MCmatch(0),
137 
138 
139  fCounter(0),
140  fCutsDistr(kFALSE),
141  fListCuts(0),
142  fEtaSelection(0),
143  fReadMC(kFALSE),
144  fUseBit(kTRUE),
145  fUseQuarkTagInKine(kTRUE),
146  fRDCutsAnalysis(0),
147  kbins(kTRUE),
148  fInvertedTopomaticCutOnDDaughters(0),
149  fpTD(0),
150  fpTpi(0),
151  fprodd0(999),
152  fcosB(0),
153  fcosBXY(0),
154  fdlB(0),
155  fNdlBXY(0),
156  fTopomaticD(999),
157  fTopomaticpi(999),
158  fcosoaDpi(-999),
159 
160  fDplusMassLowLimit(1.845),
161  fDplusMassUpLimit(1.895),
162  fBMassLowLimit(4.),
163  fBMassUpLimit(7),
164  fBinWidth(0.002)
165 
166 
167 
168 
169  //
170  // Default ctor
171  //
172 
173 {
174 
175  for(Int_t i=0; i<kMaxPtBins; i++){
176  fB0InvMassBin[i]=0;
177  fDplusInvMassBin[i]=0;
178  fB0InvMassBin_MCmatch[i]=0;
179  fB0InvMassBin_MCmatch_PassCut1[i]=0;
180  fDplusInvMassBin_PassCut1[i]=0;
181  fB0InvMassBin_MCmatch_PassCut1[i]=0;
182  fDplusInvMassBin_MCmatch[i]=0;
183  fB0InvMassBin_PassCut1[i]=0;
184  fDplusInvMassBin_PassCut1[i]=0;
185  fB0InvMassBinMinusD_PassCut1[i]=0;
186  fB0InvMassBinMinusD_MCmatch_PassCut1[i]=0;
187 
188  fBDecayLengthBin[i]=0;
189  fBNormalizedDecayLengthBin[i]=0;
190  fBPointingBin[i]=0;
191  fBPointingXYBin[i]=0;
192  fDplusd0Bin[i]=0;
193  fBpTBin[i]=0;
194  fDpluspTBin[i]=0;
195  fproductd0Bin[i]=0;
196  fDplusPointingBin[i]=0;
197  fDplusDecayLengthBin[i]=0;
198  fDplusNormalizedDecayLengthBin[i]=0;
199  fDplusSigmaVertBin[i]=0;
200 
201  fBDecayLengthBin_MCmatch[i]=0;
202  fBNormalizedDecayLengthBin_MCmatch[i]=0;
203  fBPointingBin_MCmatch[i]=0;
204  fBPointingXYBin_MCmatch[i]=0;
205  fDplusd0Bin_MCmatch[i]=0;
206  fBpTBin_MCmatch[i]=0;
207  fDpluspTBin_MCmatch[i]=0;
208  fproductd0Bin_MCmatch[i]=0;
209  fDplusPointingBin_MCmatch[i]=0;
210  fDplusDecayLengthBin_MCmatch[i]=0;
211  fDplusNormalizedDecayLengthBin_MCmatch[i]=0;
212  fDplusSigmaVertBin_MCmatch[i]=0;
213 
214  fd0MMExpDBin[i]=0;
215  fd0MMExpDBin_MCmatch[i]=0;
216  fd0MMExppiBin[i]=0;
217  fd0MMExppiBin_MCmatch[i]=0;
218  fd0MMExpDDaughtersBin[i]=0;
219  fd0MMExpDDaughtersBin_MCmatch[i]=0;
220 
221 
222 
223  fBDplusPtBin[i]=0;
224  fBDplusPtBin_MCmatch[i]=0;
225  fBpiPtBin[i]=0;
226  fBpiPtBin_MCmatch[i]=0;
227 
228 
229 
230  }
231 
232 }
233 //___________________________________________________________________________
235  AliAnalysisTaskSE(name),
236  fEvents(0),
237  fOutput(0),
238  fOutputBins(0),
239  //fOutputPID(0),
240  //fCuts(0),
241  fArrayB0(0),
242  //HISTO
243  fCEvents(0),
244  fB0InvMass(0),
245  fDplusInvMass(0),
246  fB0InvMass_PassCut1(0),
247  fB0InvMassMinusD_PassCut1(0),
248  fDplusInvMass_PassCut1(0),
249  fDplusInvMass_DplusMCmatch(0),
250  fBInvMass_MCmatch(0),
251  fBInvMass_MCmatch_PassCut1(0),
252  fB0InvMassMinusD_MCmatch_PassCut1(0),
253 
254  fpiPt(0),
255  fpiEta(0),
256  fpiPhi(0),
257  fDplusPt(0),
258  fDplusEta(0),
259  fDplusPhi(0),
260  fDplusPointing(0),
261  fDplusDecayLength(0),
262  fDplusNormalizedDecayLength(0),
263  fDplusSigmaVert(0),
264  fBPt(0),
265  fBEta(0),
266  fBPhi(0),
267  fBPointing(0),
268  fBPointingXY(0),
269  fBDecayLength(0),
270  fBNormalizedDecayLength(0),
271  fDplusd0(0),
272  fpid0(0),
273  fproductd0(0),
274  fpiPt_MCmatch(0),
275  fpiEta_MCmatch(0),
276  fpiPhi_MCmatch(0),
277  fDplusPt_MCmatch(0),
278  fDplusEta_MCmatch(0),
279  fDplusPhi_MCmatch(0),
280  fDplusPointing_MCmatch(0),
281  fDplusDecayLength_MCmatch(0),
282  fDplusNormalizedDecayLength_MCmatch(0),
283  fDplusSigmaVert_MCmatch(0),
284  fBPt_MCmatch(0),
285  fBEta_MCmatch(0),
286  fBPhi_MCmatch(0),
287  fBPointing_MCmatch(0),
288  fBPointingXY_MCmatch(0),
289  fBDecayLength_MCmatch(0),
290  fBNormalizedDecayLength_MCmatch(0),
291  fDplusd0_MCmatch(0),
292  fpid0_MCmatch(0),
293  fproductd0_MCmatch(0),
294  fDplusInvMass_MCmatch(0),
295 
296 
297  fd0MMExpD(0),
298  fd0MMExpDMCmatch(0),
299  fd0MMExppi(0),
300  fd0MMExppiMCmatch(0),
301  fd0MMExpDDaughters(0),
302  fd0MMExpDDaughters_MCmatch(0),
303  fcosoa(0),
304  fcosoa_MCmatch(0),
305 
306  fBDplusPt(0),
307  fBDplusPt_MCmatch(0),
308  fBpiPt(0),
309  fBpiPt_MCmatch(0),
310 
311  fCounter(0),
312  fCutsDistr(kFALSE),
313  fListCuts(0),
314  fEtaSelection(0),
315  fReadMC(kFALSE),
316  fUseBit(kTRUE),
317  fUseQuarkTagInKine(kTRUE),
318  fRDCutsAnalysis(dpluscutsana),
319  kbins(kTRUE),
320  fInvertedTopomaticCutOnDDaughters(0),
321  fpTD(0),
322  fpTpi(0),
323  fprodd0(999),
324  fcosB(0),
325  fcosBXY(0),
326  fdlB(0),
327  fNdlBXY(0),
328  fTopomaticD(999),
329  fTopomaticpi(999),
330  fcosoaDpi(-999),
331 
332  fDplusMassLowLimit(1.845),
333  fDplusMassUpLimit(1.895),
334  fBMassLowLimit(4),
335  fBMassUpLimit(7),
336  fBinWidth(0.002)
337 
338 
339 
340 {
341 
342  //standard contructor
343  for(Int_t i=0; i<kMaxPtBins; i++){
344  fB0InvMassBin[i]=0;
345  fDplusInvMassBin[i]=0;
353 
354  fBDecayLengthBin[i]=0;
356  fBPointingBin[i]=0;
357  fBPointingXYBin[i]=0;
358  fDplusd0Bin[i]=0;
359  fBpTBin[i]=0;
360  fDpluspTBin[i]=0;
361  fproductd0Bin[i]=0;
362  fDplusPointingBin[i]=0;
365  fDplusSigmaVertBin[i]=0;
366 
371  fDplusd0Bin_MCmatch[i]=0;
372  fBpTBin_MCmatch[i]=0;
373  fDpluspTBin_MCmatch[i]=0;
379 
380  fd0MMExpDBin[i]=0;
381  fd0MMExpDBin_MCmatch[i]=0;
382  fd0MMExppiBin[i]=0;
386 
387 
388  fBDplusPtBin[i]=0;
390  fBpiPtBin[i]=0;
391  fBpiPtBin_MCmatch[i]=0;
392 
393 
394  }
395  //
396  // Constructor. Initialization of Inputs and Outputs
397  //
398  Info("AliAnalysisTaskSEB0toDminuspi","Calling Constructor");
399 
400  fRDCutsAnalysis=dpluscutsana;
401 
402  DefineOutput(1,TList::Class()); //conters
403  DefineOutput(2,TList::Class()); //All Entries output
404  DefineOutput(3,AliNormalizationCounter::Class()); // normalization
405  DefineOutput(4,AliRDHFCutsDplustoKpipi::Class()); //My private output
406 }
407 //_________________________________________________________________
410  if(uplimit>lowlimit)
411  {
412  Float_t bw=GetBinWidth();
413  fBMassUpLimit=uplimit;
414  fBMassLowLimit= lowlimit;
415  SetBinWidth(bw);
416  }
417 }
418 //________________________________________________________________
420  Float_t width=w;
422  Int_t missingbins=4-nbins%4;
423  nbins=nbins+missingbins;
424  width=(fBMassUpLimit-fBMassLowLimit)/nbins;
425  if(missingbins!=0){
426  printf("AliAnalysisTaskSEDplus::SetBinWidth: W-bin width of %f will produce histograms not rebinnable by 4. New width set to %f\n",w,width);
427  }
428  else{
429  if(fDebug>1) printf("AliAnalysisTaskSEDplus::SetBinWidth: width set to %f\n",width);
430  }
431  fBinWidth=width;
432 }
433 //_________________________________________________________________
436 }
437 //___________________________________________________________________________
439  //
440  // destructor
441  //
442  Info("~AliAnalysisTaskSEB0toDminuspi","Calling Destructor");
443 
444  delete fOutput;
445  delete fOutputBins;
446  //delete fOutputPID;
447  //delete fCuts;
448  delete fListCuts;
449  delete fRDCutsAnalysis;
450  //~fArrayB0();
451  //HISTOs
452  delete fCEvents;
453  delete fB0InvMass;
454  delete fDplusInvMass;
455  delete fB0InvMass_PassCut1;
457  delete fDplusInvMass_PassCut1;
459  delete fDplusInvMass_MCmatch;
460  delete fBInvMass_MCmatch;
463  delete fpiPt;
464  delete fpiEta;
465  delete fpiPhi;
466  delete fDplusPt;
467  delete fDplusEta;
468  delete fDplusPhi;
469  delete fDplusPointing;
470  delete fDplusDecayLength;
472  delete fDplusSigmaVert;
473  delete fBPt;
474  delete fBEta;
475  delete fBPhi;
476  delete fBPointing;
477  delete fBPointingXY;
478  delete fBDecayLength;
480  delete fDplusd0;
481  delete fpid0;
482  delete fproductd0;
483  delete fpiPt_MCmatch;
484  delete fpiEta_MCmatch;
485  delete fpiPhi_MCmatch;
486  delete fDplusPt_MCmatch;
487  delete fDplusEta_MCmatch;
488  delete fDplusPhi_MCmatch;
489  delete fDplusPointing_MCmatch;
492  delete fDplusSigmaVert_MCmatch;
493  delete fBPt_MCmatch;
494  delete fBEta_MCmatch;
495  delete fBPhi_MCmatch;
496  delete fBPointing_MCmatch;
497  delete fBPointingXY_MCmatch;
498  delete fBDecayLength_MCmatch;
500  delete fDplusd0_MCmatch;
501  delete fpid0_MCmatch;
502  delete fproductd0_MCmatch;
503 
504 
505  delete fd0MMExpD;
506  delete fd0MMExpDMCmatch;
507  delete fd0MMExppi;
508  delete fd0MMExppiMCmatch;
509  delete fd0MMExpDDaughters;
511  delete fcosoa;
512  delete fcosoa_MCmatch;
513  delete fBDplusPt;
514  delete fBDplusPt_MCmatch;
515  delete fBpiPt;
516  delete fBpiPt_MCmatch;
517 
518 
519  for(Int_t i=0; i<kMaxPtBins; i++){
520  delete fB0InvMassBin[i];
521  delete fDplusInvMassBin[i];
522  delete fB0InvMassBin_MCmatch[i];
523  delete fDplusInvMassBin_MCmatch[i];
524  delete fB0InvMassBin_PassCut1[i];
526  delete fDplusInvMassBin_PassCut1[i];
529 
530 
531  delete fBDecayLengthBin[i];
532  delete fBNormalizedDecayLengthBin[i];
533  delete fBPointingBin[i];
534  delete fBPointingXYBin[i];
535  delete fDplusd0Bin[i];
536  delete fBpTBin[i];
537  delete fDpluspTBin[i];
538  delete fproductd0Bin[i];
539  delete fDplusPointingBin[i];
540  delete fDplusDecayLengthBin[i];
542  delete fDplusSigmaVertBin[i];
543 
544  delete fBDecayLengthBin_MCmatch[i];
546  delete fBPointingBin_MCmatch[i];
547  delete fBPointingXYBin_MCmatch[i];
548  delete fDplusd0Bin_MCmatch[i];
549  delete fBpTBin_MCmatch[i];
550  delete fDpluspTBin_MCmatch[i];
551  delete fproductd0Bin_MCmatch[i];
552  delete fDplusPointingBin_MCmatch[i];
555  delete fDplusSigmaVertBin_MCmatch[i];
556 
557 
558  delete fd0MMExpDBin[i];
559  delete fd0MMExpDBin_MCmatch[i];
560  delete fd0MMExppiBin[i];
561  delete fd0MMExppiBin_MCmatch[i];
562  delete fd0MMExpDDaughtersBin[i];
564 
565  delete fBDplusPtBin[i];
566  delete fBDplusPtBin_MCmatch[i];
567  delete fBpiPtBin[i];
568  delete fBpiPtBin_MCmatch[i];
569 
570 
571  }
572 }
573 //_________________________________________________
575  //
576  // Initialization
577  //
578 
579  if(fDebug > 1) printf("AnalysisTaskSEB0toDminuspi::Init() \n");
580  fListCuts=new TList();
581  fListCuts->SetOwner();
583  analysis->SetName("AnalysisCuts");
584 
585  fListCuts->Add(analysis);
586 
587  PostData(4,fListCuts);
588 
589 
590  return;
591 }
592 
593 //_________________________________________________
595 {
596  // user exec
597  if (!fInputEvent) {
598  Error("UserExec","NO EVENT FOUND!");
599  return;
600  }
601 
602  fEvents++;
603 
604  TClonesArray *array3Prong = 0;
605 
606  AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(InputEvent());
607 
608  Double_t bz= (Double_t)aodEvent->GetMagneticField();
609 
610  fCEvents->Fill(1);
611 
612  //Extract the Charm3Prong object from the AOD
613 
614  if(!aodEvent && AODEvent() && IsStandardAOD()) {
615  // In case there is an AOD handler writing a standard AOD, use the AOD
616  // event in memory rather than the input (ESD) event.
617  aodEvent = dynamic_cast<AliAODEvent*> (AODEvent());
618  // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
619  // have to taken from the AOD event hold by the AliAODExtension
620  AliAODHandler* aodHandler = (AliAODHandler*)
621  ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
622  if(aodHandler->GetExtensions()) {
623  AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
624  AliAODEvent *aodFromExt = ext->GetAOD();
625  array3Prong=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm3Prong");
626  }
627  } else {
628  array3Prong=(TClonesArray*)aodEvent->GetList()->FindObject("Charm3Prong");
629  }
630 
631 
632  // fix for temporary bug in ESDfilter
633  // the AODs with null vertex pointer didn't pass the PhysSel
634  if(!aodEvent->GetPrimaryVertex() || TMath::Abs(aodEvent->GetMagneticField())<0.001) return;
635  fCEvents->Fill(2);
636 
637 
638  if (array3Prong->GetEntriesFast()==0) return;
639 
640  Bool_t isEvSel=fRDCutsAnalysis->IsEventSelected(aodEvent);
641 
642 
643  TClonesArray *mcArray = 0;
644  AliAODMCHeader *mcHeader=0;
645 
646  if(fReadMC){
647  mcArray = (TClonesArray*)aodEvent->GetList()->FindObject(AliAODMCParticle::StdBranchName());
648  if(!mcArray) {
649  printf("AliAnalysisTaskSEDplus::UserExec: MC particles branch not found!\n");
650  return;
651  }
652  // load MC header
653  mcHeader = (AliAODMCHeader*)aodEvent->GetList()->FindObject(AliAODMCHeader::StdBranchName());
654  if(!mcHeader) {
655  printf("AliAnalysisTaskSEDplus::UserExec: MC header branch not found!\n");
656  return;
657  }
658  }
659 
660  // if(fReadMC && fStepMCAcc)FillMCAcceptanceHistos(arrayMC, mcHeader);
661 
662 
663 
664  if(!isEvSel) return;
666 
667  fCEvents->Fill(3);
668  // counters for efficiencies
669  //Int_t icountReco = 0;
670  Int_t nOS=0;
671 
672  //B0 and D+ prongs needed to MatchToMC and MatchToMCB method
673  Int_t pdgDgDplustoKpipi[3]={321,211,211};
674  Int_t pdgDgB0toDminuspi[2]={411,211};
675 
676  // AOD primary vertex
677  AliAODVertex *primaryVertex = (AliAODVertex*)aodEvent->GetPrimaryVertex();
678  if(!primaryVertex) return;
679  if(primaryVertex->GetNContributors()<1) return;
680 
681  if (!array3Prong){
682  AliInfo("Could not find array of Charm3Prong, skipping the event");
683  return;
684  }
685  else AliDebug(2, Form("Found %d vertices",array3Prong->GetEntriesFast()));
686 
687  Int_t nSelectedAna =0;
688  Int_t nSelectedProd =0;
689 
690  // loop over the D+ candidates and reconstruct the secondary vertex //
691  // //
692  //------------------------------------------------------------------//
693 
694 
695  Double_t xdummy=0.,ydummy=0.,dca,dcaB, e[2];
696  Double_t d0z0B[2],covd0z0B[3],d0B[2],d0errB[2],d0z0[2],covd0z0[3],d0[2],d0err[2];
697 
698  AliAODRecoDecayHF2Prong *B0Dminuspi =0x0;
699 
700  Int_t n3Prong = array3Prong->GetEntriesFast();
701  AliAODRecoDecayHF3Prong *theDminusparticle =0x0;
702  Int_t labDp=-1; //if Dminus is matched with MC
703 
704  Int_t B0evtcount =0;
705 
706  //Loop over the Dplus candidates
707 
708  for (Int_t i3Prong = 0; i3Prong < n3Prong; i3Prong++) {
709  // D+ candidate
710  theDminusparticle = (AliAODRecoDecayHF3Prong*)array3Prong->UncheckedAt(i3Prong);
711  fCEvents->Fill(4);
712 
713  if(fUseBit && !theDminusparticle->HasSelectionBit(AliRDHFCuts::kDplusCuts)){
714  fCEvents->Fill(5);
715  continue;
716  }
717  Int_t passTopolAndPIDCuts=fRDCutsAnalysis->IsSelected(theDminusparticle,AliRDHFCuts::kAll,aodEvent);
718 
720  fCEvents->Fill(6);
721  continue;
722  }
724  fCEvents->Fill(6);
725  continue;
726  }
727 
728 
729  Double_t etaD=theDminusparticle->Eta();
730  Double_t phiD=theDminusparticle->Phi();
731  if(fEtaSelection!=0){
732  if(fEtaSelection==1 && etaD<0) continue;
733  if(fEtaSelection==-1 && etaD>0) continue;
734  }
735 
736 
737 
738  Bool_t unsetvtx=kFALSE;
739  if(!theDminusparticle->GetOwnPrimaryVtx()){
740  theDminusparticle->SetOwnPrimaryVtx(primaryVertex);
741  unsetvtx=kTRUE;
742  }
743 
744  Double_t ptCand = theDminusparticle->Pt();
745 
746  Bool_t recVtx=kFALSE;
747  AliAODVertex *origownvtx=0x0;
749  if(theDminusparticle->GetOwnPrimaryVtx()) origownvtx = new AliAODVertex(*theDminusparticle->GetOwnPrimaryVtx());
750  if(fRDCutsAnalysis->RecalcOwnPrimaryVtx(theDminusparticle,aodEvent)) recVtx=kTRUE;
751  else fRDCutsAnalysis->CleanOwnPrimaryVtx(theDminusparticle,aodEvent,origownvtx);
752  }
753 
754 
755  Bool_t isPrimary=kFALSE;
756  Bool_t isFeeddown=kFALSE;
757  Float_t pdgCode=-2;
758  Float_t trueImpParXY=0.;
759  Double_t ptB=-1.5;
760  Int_t orig=0;
761 
762  if(TMath::Abs(theDminusparticle->Charge())!=1){
763  fCEvents->Fill(7);
764  continue;
765  }
766 
767  if(fReadMC){
768  labDp = theDminusparticle->MatchToMC(411,mcArray,3,pdgDgDplustoKpipi);
769  if(labDp>=0){
770  AliAODMCParticle *partDp = (AliAODMCParticle*)mcArray->At(labDp);
771  if(!partDp)continue;
772  orig=AliVertexingHFUtils::CheckOrigin(mcArray,partDp,fUseQuarkTagInKine);//Prompt = 4, FeedDown = 5
773  pdgCode=TMath::Abs(partDp->GetPdgCode());
774  if(orig==4){
775  isPrimary=kTRUE;
776  isFeeddown=kFALSE;
777  fCEvents->Fill(8);
778  AliAODMCParticle *partMomDp = (AliAODMCParticle*)mcArray->At(partDp->GetMother());
779  }else if(orig==5){
780  isPrimary=kFALSE;
781  isFeeddown=kTRUE;
782  AliAODMCParticle *partMomDp = (AliAODMCParticle*)mcArray->At(partDp->GetMother());
783  if(!partMomDp)continue;
784  fCEvents->Fill(9);
785  // AliAODMCParticle *partGranMomDp = (AliAODMCParticle*)mcArray->At(partMomDp->GetMother());
786  if(TMath::Abs(partMomDp->GetPdgCode())==511 && ((partMomDp->GetLastDaughter()-partMomDp->GetFirstDaughter())==1)){
787  AliAODMCParticle* B0Dau2=0;
788  if(labDp== (partMomDp->GetFirstDaughter()-1)) B0Dau2 = (AliAODMCParticle*)mcArray->At(partMomDp->GetLastDaughter()-1);
789  else if(labDp== (partMomDp->GetLastDaughter()-1)) B0Dau2 = (AliAODMCParticle*)mcArray->At(partMomDp->GetFirstDaughter()-1);
790  if (B0Dau2) {if(TMath::Abs(B0Dau2->GetPdgCode())==211) fCEvents->Fill(10);}
791 
792  }
793  ptB=AliVertexingHFUtils::GetBeautyMotherPt(mcArray,partDp);
794  }else{
795  pdgCode=-3;
796  }
797  }
798  else{
799  pdgCode=-1;
800  }
801  }
802 
803 
804 
805 
806 
807 
808 
809  Double_t invMass=theDminusparticle->InvMassDplus();
810  Double_t rapid=theDminusparticle->YDplus();
811 
812  Bool_t isFidAcc=fRDCutsAnalysis->IsInFiducialAcceptance(ptCand,rapid);
813  if(!isFidAcc){fCEvents->Fill(19);}//continue;}
814 
815 
816 
817 
818 
819 
820  fCEvents->Fill(11);
821 
822 
823  if(recVtx)fRDCutsAnalysis->CleanOwnPrimaryVtx(theDminusparticle,aodEvent,origownvtx);
824 
825  if(unsetvtx) theDminusparticle->UnsetOwnPrimaryVtx();
826 
827 
828 
829  //D particle treated as an external track to create the pairs D-pion
830  AliExternalTrackParam *trackDminus = new AliExternalTrackParam();
831  trackDminus->CopyFromVTrack(theDminusparticle);
832  fDplusInvMass->Fill(theDminusparticle->InvMassDplus());
833  if(labDp>=0)fDplusInvMass_DplusMCmatch->Fill(theDminusparticle->InvMassDplus());
834 
835 
836  // get the ID of the D+ daughters
837  Double_t Id_prong0 = theDminusparticle->GetProngID(0);
838  Double_t Id_prong1 = theDminusparticle->GetProngID(1);
839  Double_t Id_prong2 = theDminusparticle->GetProngID(2);
840 
841  //TObjArray b012;
842 
843 
844 
845  // ----------------------------------------------- ------------------------------------------- //
846  // B0 reconstruction //
847  //---------------------------------------------------------------------------------------------//
848 
849  Int_t iB0count=0;
850  fArrayB0.clear();
851  Int_t arrayMCB0label[50];
852 
853  // select a region around Dplus mass (1.869), ~ 3 sigma of the integrated D invariant mass distribution
854  // if(theDminusparticle->InvMassDplus()<(1.895) && theDminusparticle->InvMassDplus()>(1.845)){
855  if( theDminusparticle->InvMassDplus()>(fDplusMassLowLimit) && theDminusparticle->InvMassDplus()<(fDplusMassUpLimit)){
856 
857  // loop on all the track of the events to be paired with the D
858  for (Int_t i=0; i<aodEvent->GetNumberOfTracks(); i++){
859 
860 
861  AliAODTrack* aodTrack = (AliAODTrack*)aodEvent->GetTrack(i);
862  // remove the Dminus prongs
863  if(aodTrack->GetID() == Id_prong0 ||aodTrack->GetID() == Id_prong1 || aodTrack->GetID() == Id_prong2) continue;
864 
865  fCEvents->Fill(21);
866 
867 
868  if(!(aodTrack->TestFilterMask(BIT(4)))){fCEvents->Fill(20); continue;}
869 
870  // remove very low pt tracks
871  if(aodTrack->Pt()<0.5) continue;
872 
873  //salections on pion tracks
874 
875 
876 
877 
878  if (TMath::Abs(aodTrack->Eta())>0.8)continue; // cut in eta pi
879 
880  //check of the track PID, 3 sigma on TPC and TOF
881  Double_t nSigmaTPCpi=fRDCutsAnalysis->GetPidHF()->GetPidResponse()->NumberOfSigmasTPC(aodTrack,AliPID::kPion);
882  Double_t nSigmaTOFpi=fRDCutsAnalysis->GetPidHF()->GetPidResponse()->NumberOfSigmasTOF(aodTrack,AliPID::kPion);
883  if(nSigmaTPCpi<-3 || nSigmaTPCpi>3 ){fCEvents->Fill(12);
884  continue;}
885  if(nSigmaTOFpi<-3 || nSigmaTOFpi>3){
886  fCEvents->Fill(12);
887  continue;}
888  //remove pair with D and pi with the same charge
889  if(aodTrack->Charge()==theDminusparticle->Charge()){
890  fCEvents->Fill(13);
891  continue;
892  }
893 
894  fCEvents->Fill(14);
895 
896  // reconstruct the new vertex of the 2 prongs
897  AliExternalTrackParam et4;
898  et4.CopyFromVTrack(static_cast<AliAODTrack*>(aodEvent->GetTrack(i)));
899 
900  // here dca, d0 and d0rr
901  trackDminus->PropagateToDCA(primaryVertex,bz,100.,d0z0B,covd0z0B);
902  d0B[0]=d0z0B[0];
903  d0errB[0] = TMath::Sqrt(covd0z0B[0]);
904  et4.PropagateToDCA(primaryVertex,bz,100.,d0z0B,covd0z0B);
905  d0B[1]=d0z0B[0];
906  d0errB[1] = TMath::Sqrt(covd0z0B[0]);
907 
908  dcaB=et4.GetDCA(trackDminus,bz,xdummy,ydummy);
909 
910  TObjArray b012_B;
911  b012_B.Add(trackDminus); b012_B.Add(&et4);
912 
913  // B0 vertex
914  AliAODVertex *vtxNewB0 = RecalculateVertex(primaryVertex,&b012_B,bz);
915  if(!vtxNewB0) {
916  continue;}
917 
918 
919  // fill the momenta of the prongs
920  Double_t pxB[2],pyB[2],pzB[2];
921  pxB[0] = trackDminus-> Px();
922  pyB[0] = trackDminus-> Py();
923  pzB[0] = trackDminus-> Pz();
924  pxB[1] = aodTrack-> Px();
925  pyB[1] = aodTrack-> Py();
926  pzB[1] = aodTrack-> Pz();
927 
928  UShort_t idB[2];
929  //Int_t prongs_ID[2];
930 
931  // make the vertex of the B0
932 
933  idB[0]= 0;
934  idB[1]= aodTrack->GetID();
935 
936  // thid is the D* vertex
937  B0Dminuspi = new AliAODRecoDecayHF2Prong(vtxNewB0,pxB,pyB,pzB,d0B,d0errB,dcaB);
938  if(!B0Dminuspi) continue;
939 
940 
941  //add the daughter tracks to the B vertex
942  B0Dminuspi->GetSecondaryVtx()->AddDaughter(theDminusparticle);
943  B0Dminuspi->GetSecondaryVtx()->AddDaughter(aodTrack);
944  B0Dminuspi->SetPrimaryVtxRef((AliAODVertex*)aodEvent->GetPrimaryVertex());
945  B0Dminuspi->SetProngIDs(2,idB);
946 
947 
948 
949  fCEvents->Fill(15);
950 
951  fArrayB0.resize(iB0count+1);
952  fArrayB0[iB0count]=B0Dminuspi;
953 
954 
955 
956  Int_t isB0 = 0;
957  arrayMCB0label[iB0count]=-1;
958 
959  if(fReadMC){
960 
961  // find associated MC particle for B0 -> pi DminustoKpipi
962  arrayMCB0label[iB0count] = B0Dminuspi->MatchToMCB3Prong(511,411, pdgDgB0toDminuspi, pdgDgDplustoKpipi, mcArray);
963  if(arrayMCB0label[iB0count]>(-1)){
964  isB0 = 1;
965 
966 
967  fCEvents->Fill(16);
968  // fd0MMExpDDaughters_MCmatch->Fill(dd0min);
969 
970  }
971  }
972 
973 
974 
975 
976 
977  nSelectedProd++;
978  nSelectedAna++;
979 
980 
981  iB0count++;
982 
983 
984 
985 
986  }
987 
988 
989 
990  }
991 
992  if(iB0count>0) FillSpectrum(iB0count, arrayMCB0label,bz);
993 
994 
995  fArrayB0.clear();
996 
997  B0evtcount+=iB0count;
998 
999 
1000  }
1001 
1002  fCounter->StoreCandidates(aodEvent,nSelectedProd,kTRUE);
1003  fCounter->StoreCandidates(aodEvent,nSelectedAna,kFALSE);
1004 
1005 
1006  AliDebug(2, Form("Found %i Reco particles that are D+!!",nOS));
1007  AliDebug(2, Form("Found %i Reco particles that are B0!!",B0evtcount));
1008 
1009  PostData(1,fOutput);
1010  PostData(2,fOutputBins);
1011  PostData(3,fCounter);
1012 
1013 }
1014 //________________________________________ terminate ___________________________
1016 {
1017  // The Terminate() function is the last function to be called during
1018  // a query. It always runs on the client, it can be used to present
1019  // the results graphically or save the results to file.
1020 
1021  //Info("Terminate","");
1022  AliAnalysisTaskSE::Terminate();
1023 
1024  fOutput = dynamic_cast<TList*> (GetOutputData(1));
1025  if (!fOutput) {
1026  printf("ERROR: fOutput not available\n");
1027  return;
1028  }
1029 
1030  fCEvents = dynamic_cast<TH1F*>(fOutput->FindObject("fCEvents"));
1031 
1032 
1033 
1034 
1035  return;
1036 }
1037 //___________________________________________________________________________
1039  // output
1040  Info("UserCreateOutputObjects","CreateOutputObjects of task %s\n", GetName());
1041 
1042  //slot #1
1043  //OpenFile(1);
1044  fOutput = new TList();
1045  fOutput->SetOwner();
1046  fOutput->SetName("PtIntegrated");
1047 
1048  fOutputBins = new TList();
1049  fOutputBins->SetOwner();
1050  fOutputBins->SetName("PtBins");
1051 
1052 
1053 
1054  // define histograms
1055  DefineHistograms();
1056 
1057  //Counter for Normalization
1058  fCounter = new AliNormalizationCounter(Form("%s",GetOutputSlot(3)->GetContainer()->GetName()));
1059  fCounter->Init();
1060 
1061 
1062  PostData(1,fOutput);
1063  PostData(2,fOutputBins);
1064 
1065 
1066  return;
1067 }
1068 //___________________________________ hiostograms _______________________________________
1070  // Create histograms
1071 
1072  fCEvents = new TH1F("fCEvents","conter",30,0.5,30.5);
1073  fCEvents->GetXaxis()->SetBinLabel(1,"n Events");
1074  fCEvents->GetXaxis()->SetBinLabel(2,"w primary vtx");
1075  fCEvents->GetXaxis()->SetBinLabel(3,"selected/ w array3prong");
1076  fCEvents->GetXaxis()->SetBinLabel(4,"D+ candidates");
1077  fCEvents->GetXaxis()->SetBinLabel(5,"D+ rejected for DplusCuts");
1078  fCEvents->GetXaxis()->SetBinLabel(6,"D+ rejected for topological + PID selection ");
1079  fCEvents->GetXaxis()->SetBinLabel(7,"D+ rejected for charge");
1080  fCEvents->GetXaxis()->SetBinLabel(8,"MC D+ primary orig=4");
1081  fCEvents->GetXaxis()->SetBinLabel(9,"MC D+ feed-down orig=5");
1082  fCEvents->GetXaxis()->SetBinLabel(10,"MC B->D pi");
1083 
1084  fCEvents->GetXaxis()->SetBinLabel(11,"D+ candidates to be associated with a pion");
1085  fCEvents->GetXaxis()->SetBinLabel(12,"pion cadidate rejected for PID");
1086  fCEvents->GetXaxis()->SetBinLabel(13,"pion candidate rejected because of charge");
1087  fCEvents->GetXaxis()->SetBinLabel(14,"pion candidate passing selections");
1088 
1089  fCEvents->GetXaxis()->SetBinLabel(15,"B0 candidate");
1090  fCEvents->GetXaxis()->SetBinLabel(16,"B0 candidate matched MC");
1091  fCEvents->GetXaxis()->SetBinLabel(17,"B0 passing set cut 1");
1092  fCEvents->GetXaxis()->SetBinLabel(18,"B0 passing set cut 1 matched MC");
1093  fCEvents->GetXaxis()->SetBinLabel(19,"D + not in fiducial accaptance");
1094  fCEvents->GetXaxis()->SetBinLabel(20,"aodtrack rejected for filterbit 4 ");
1095  fCEvents->GetXaxis()->SetBinLabel(21,"pion tracks before cuts");
1096 
1097  fCEvents->SetStats(kTRUE);
1098  fCEvents->GetXaxis()->SetTitle("1");
1099  fCEvents->GetYaxis()->SetTitle("counts");
1100 
1101 
1102 
1104 
1105  fB0InvMass = new TH1F("fB0InvMass", "B0 invariant mass;GeV", nbins, fBMassLowLimit, fBMassUpLimit);
1106  fB0InvMass->Sumw2();
1107  fB0InvMassMinusD_PassCut1 = new TH1F("fB0InvMassMinusD_PassCut1", "B0-D invariant mass;GeV", nbins, fBMassLowLimit-1.869, fBMassUpLimit-1.869);
1108  fB0InvMassMinusD_PassCut1->Sumw2();
1109  fDplusInvMass = new TH1F("fDplusInvMass", "Dplus invariant mass;GeV", 500, 1.75, 1.95 );
1110  fDplusInvMass->Sumw2();
1111  fB0InvMass_PassCut1 = new TH1F("fB0InvMass_PassCut1", "B0 invariant mass with Cut1 implemented;GeV", nbins, fBMassLowLimit, fBMassUpLimit);
1112  fB0InvMass_PassCut1->Sumw2();
1113  fB0InvMassMinusD_MCmatch_PassCut1 = new TH1F("fB0InvMassMinusD_MCmatch_PassCut1", "B0-D invariant mass;GeV", nbins, fBMassLowLimit-1.869, fBMassUpLimit-1.869);
1115  fDplusInvMass_PassCut1 = new TH1F("fDplusInvMass_PassCut1", "D+ invariant mass with Cut1 implemented;GeV", 500, 1.75, 1.95);
1116  fDplusInvMass_PassCut1->Sumw2();
1117  fDplusInvMass_DplusMCmatch = new TH1F("fDplusInvMass_DplusMCmatch", "Dplus invariant mass (Dplus matched);GeV", 500, 1.75, 1.95);
1118  fDplusInvMass_DplusMCmatch->Sumw2();
1119 
1120 
1121 
1122  fpiPt = new TH1F("fpiPt", "Pt of pion (from B0 selected)", 200, 0, 20);
1123  fpiEta = new TH1F("fpiEta", "Eta of pion (from B0 selected)", 200, -1, 1);
1124  fpiPhi = new TH1F("fpiPhi", "Phi of pion (from B0 selected)", 200, 0, 7);
1125  fDplusPt = new TH1F("fDplusPt", "Pt of Dplus (from B0 selected)",100, 0, 50);
1126  fDplusEta = new TH1F("fDplusEta", "Eta of Dplus (from B0 selected)", 200, -1, 1);
1127  fDplusPhi = new TH1F("fDplusPhi", "Phi of Dplus (from B0 selected)", 200, 0, 7);
1128  fDplusPointing = new TH1F("fDplusPointing", "CosPointingAngle of Dplus (from B0 selected)", 200, 0., 1.);
1129  fDplusDecayLength = new TH1F("fDplusDecayLength", "Decay Length of D+ (B0 selected)", 200, 0, 0.5);
1130  fDplusNormalizedDecayLength = new TH1F("fDplusNormalizedDecayLength", "Normalized Decay Length of D+ (B0 selected)", 200, 0, 20);
1131  fDplusSigmaVert = new TH1F("fDplusSigmaVert", "Sigma vertex of D+ (B0 selected)", 200, 0, 0.5);
1132  fBPt = new TH1F("fBPt", "Pt of B0 (B0 selected)", 100, 0, 50);
1133  fBEta = new TH1F("fBEta", "Eta of B0 (B0 selected)", 200, -1, 1);
1134  fBPhi = new TH1F("fBPhi", "Phi of B0 (B0 selected)", 200, 0, 7);
1135  fBPointing = new TH1F("fBPointing", "CosPointingAngle of B0 (B0 selected)", 200, 0., 1.);
1136  fBPointingXY = new TH1F("fBPointingXY", "CosPointingAngleXY of B0 (B0 selected)", 200, 0., 1.);
1137  fBDecayLength = new TH1F("fBDecayLength", "Decay Length of B0 (B0 selected)", 200, 0, 0.5);
1138  fBNormalizedDecayLength = new TH1F("fBNormalizedDecayLength", "Normalized Decay Length of B0 (B0 selected)", 200, 0, 20);
1139  fDplusd0 = new TH1F("fDplusd0", "|d0| Dplus to prim vtx(B0 selected)", 200, 0, 0.25);
1140  fpid0 = new TH1F("fpid0", "|d0| pion to prim vtx(B0 selected)", 200, 0, 0.25);
1141  fproductd0 = new TH1F("fproductd0", "d0 pion x d0 Dplus (B0 selected)", 200, -0.001, 0.001);
1142  fpiPt_MCmatch = new TH1F("fpiPt_MCmatch", "Pt of pion (MCmatched B0)", 200, 0, 20);
1143  fpiEta_MCmatch = new TH1F("fpiEta_MCmatch", "Eta of pion (MCmatched B0)", 200, -1, 1);
1144  fpiPhi_MCmatch = new TH1F("fpiPhi_MCmatch", "Phi of pion (MCmatched B0)", 200, 0, 7);
1145  fDplusPt_MCmatch = new TH1F("fDplusPt_MCmatch", "Pt of Dplus (MCmatched B0)", 100, 0, 50);
1146  fDplusEta_MCmatch = new TH1F("fDplusEta_MCmatch", "Eta of Dplus (MCmatched B0)", 200, -1, 1);
1147  fDplusPhi_MCmatch = new TH1F("fDplusPhi_MCmatch", "Phi of Dplus (MCmatched B0)", 200, 0, 7);
1148  fDplusPointing_MCmatch = new TH1F("fDplusPointing_MCmatch", "CosPointingAngle of Dplus (MCmatched B0)", 200, 0., 1.);
1149  fDplusDecayLength_MCmatch = new TH1F("fDplusDecayLength_MCmatch", "Decay Length of D+ (MCmatched B0)", 200, 0, 0.5);
1150  fDplusNormalizedDecayLength_MCmatch = new TH1F("fDplusNormalizedDecayLength_MCmatch", "Normalized Decay Length of D+ (MCmatched B0)", 200, 0, 20);
1151  fDplusSigmaVert_MCmatch = new TH1F("fDplusSigmaVert_MCmatch", "Sigma vertex of D+ (MC matched B0)", 200, 0, 0.5);
1152  fBPt_MCmatch = new TH1F("fBPt_MCmatch", "Pt of B0 (MCmatched B0)", 100, 0, 50);
1153  fBEta_MCmatch = new TH1F("fBEta_MCmatch", "Eta of B0 (MCmatched B0)", 200, -1, 1);
1154  fBPhi_MCmatch = new TH1F("fBPhi_MCmatch", "Phi of B0 (MCmatched B0)", 200, 0, 7);
1155  fBPointing_MCmatch = new TH1F("fBPointing_MCmatch", "CosPointingAngle of B0 (MCmatched B0)", 200, 0., 1.);
1156  fBPointingXY_MCmatch = new TH1F("fBPointingXY_MCmatch", "CosPointingAngleXY of B0 (MC matched B0)", 200, 0., 1.);
1157  fBDecayLength_MCmatch = new TH1F("fBDecayLength_MCmatch", "Decay Length of B0 (MCmatched B0)", 200, 0, 0.5);
1158  fBNormalizedDecayLength_MCmatch = new TH1F("fBNormalizedDecayLength_MCmatch", "Normalized Decay Length of B0 (MCmatched B0)", 200, 0, 20);
1159  fDplusd0_MCmatch = new TH1F("fDplusd0_MCmatch", "|d0| Dplus to prim vtx(MCmatched B0)", 200, 0, 0.25);
1160  fpid0_MCmatch = new TH1F("fpid0_MCmatch", "|d0| pi to prim vtx(MCmatched B0)", 200, 0, 0.25);
1161  fproductd0_MCmatch = new TH1F("fproductd0_MCmatch", "d0 pion x d0 Dplus (MCmatched B0)", 200, -0.001, 0.001);
1162  fDplusInvMass_MCmatch = new TH1F("fDplusInvMass_MCmatch", "D+ invariant mass (MCmatched B0);GeV", 500, 1.75, 1.95);
1163  fBInvMass_MCmatch = new TH1F("fBInvMass_MCmatch", "B0 invariant mass (MCmatched B0);GeV", nbins, fBMassLowLimit, fBMassUpLimit);
1164  fBInvMass_MCmatch_PassCut1 = new TH1F("fBInvMass_MCmatch_PassCut1", "B0 invariant mass (MCmatched B0);GeV", nbins, fBMassLowLimit, fBMassUpLimit);
1165 
1166  fd0MMExpD = new TH1F("fd0MMExpD", "Topomatic variable for D", 200, -10.0,10.);
1167  fd0MMExpDMCmatch = new TH1F("fd0MMExpDMCmatch", "Topomatic variable for D from B matched to MC", 200, -10,10.);
1168  fd0MMExppi = new TH1F("fd0MMExppi", "Topomatic variable for pi ", 200, -10.0,10.);
1169  fd0MMExppiMCmatch = new TH1F("fd0MMExppiMCmatch", "Topomatic variable for pi from B matched to MC", 200, -10,10.);
1170  fd0MMExpDDaughters = new TH1F("fd0MMExpDDaughters", "Topomatic variable for D daughters", 200, -10.0,10.);
1171  fd0MMExpDDaughters_MCmatch = new TH1F("fd0MMExpDDaughters_MCmatch", "Topomatic variable for D daughters with B matched to MC", 200, -10,10.);
1172 
1173  fcosoa= new TH1F("fcosoa", "cos opening angle", 200, -1.10,1.10);
1174  fcosoa_MCmatch= new TH1F("fcosoa_MCmatch", "cos opening angle MC", 200, -1.10,1.1);
1175 
1176 
1177  fBDplusPt = new TH2F("fBDplusPt", ";B pT;D pT", 100, 0, 50,100,0,50);
1178  fBpiPt = new TH2F("fBpiPt", ";B pT;pi pT", 100, 0, 50,100,0,50);
1179  fBDplusPt_MCmatch = new TH2F("fBDplusPt_MCmatch", " ;B pT;D pT", 100, 0, 50,100,0,50);
1180  fBpiPt_MCmatch = new TH2F("fBpiPt_MCmatch", " ;B pT;pi pT", 100, 0, 50,100,0,50);
1181 
1182 
1183 
1184  fOutput->Add(fCEvents);
1185  fOutput->Add(fB0InvMass);
1186  fOutput->Add(fDplusInvMass);
1190 
1191  fOutput->Add(fpiPt);
1192  fOutput->Add(fpiEta);
1193  fOutput->Add(fpiPhi);
1194  fOutput->Add(fDplusPt);
1195  fOutput->Add(fDplusEta);
1196  fOutput->Add(fDplusPhi);
1197  fOutput->Add(fDplusPointing);
1198  fOutput->Add(fDplusDecayLength);
1200  fOutput->Add(fDplusSigmaVert);
1201  fOutput->Add(fBPt);
1202  fOutput->Add(fBEta);
1203  fOutput->Add(fBPhi);
1204  fOutput->Add(fBPointing);
1205  fOutput->Add(fBPointingXY);
1206  fOutput->Add(fBDecayLength);
1208  fOutput->Add(fDplusd0);
1209  fOutput->Add(fpid0);
1210  fOutput->Add(fproductd0);
1211  fOutput->Add(fd0MMExpD);
1212  fOutput->Add(fd0MMExppi);
1214  fOutput->Add(fBDplusPt);
1215  fOutput->Add(fBpiPt);
1216  fOutput->Add(fcosoa);
1217 
1218 
1219  if(fReadMC){
1221  fOutput->Add(fBInvMass_MCmatch);
1225 
1226  fOutput->Add(fpiPt_MCmatch);
1227  fOutput->Add(fpiEta_MCmatch);
1228  fOutput->Add(fpiPhi_MCmatch);
1229  fOutput->Add(fDplusPt_MCmatch);
1230  fOutput->Add(fDplusEta_MCmatch);
1231  fOutput->Add(fDplusPhi_MCmatch);
1236  fOutput->Add(fBPt_MCmatch);
1237  fOutput->Add(fBEta_MCmatch);
1238  fOutput->Add(fBPhi_MCmatch);
1243  fOutput->Add(fDplusd0_MCmatch);
1244  fOutput->Add(fpid0_MCmatch);
1246  fOutput->Add(fd0MMExpDMCmatch);
1247  fOutput->Add(fd0MMExppiMCmatch);
1249  fOutput->Add(fBDplusPt_MCmatch);
1250  fOutput->Add(fBpiPt_MCmatch);
1251  fOutput->Add(fcosoa_MCmatch);
1252 
1253  }
1254 
1255 
1256 
1257 
1258  TString HistName;
1259  Int_t fNPtBins=fRDCutsAnalysis->GetNPtBins();
1260 
1261 
1262  for(Int_t i=0; i<fNPtBins; i++){
1263  HistName.Form("fB0InvMass_bin%d",i);
1264  fB0InvMassBin[i]= new TH1F(HistName.Data(), HistName.Data(), nbins, fBMassLowLimit, fBMassUpLimit);
1265  fB0InvMassBin[i]->Sumw2();
1266  HistName.Form("fDplusInvMass_bin%d",i);
1267  fDplusInvMassBin[i]= new TH1F(HistName.Data(), HistName.Data(), 500, 1.819, 1.919 );
1268  fDplusInvMassBin[i]->Sumw2();
1269  HistName.Form("fB0InvMass_bin%d_MCmatch",i);
1270  fB0InvMassBin_MCmatch[i]= new TH1F(HistName.Data(), HistName.Data(), nbins, fBMassLowLimit, fBMassUpLimit);
1271  fB0InvMassBin_MCmatch[i]->Sumw2();
1272  HistName.Form("fB0InvMass_bin%d_MCmatch_PassCut1",i);
1273  fB0InvMassBin_MCmatch_PassCut1[i]= new TH1F(HistName.Data(), HistName.Data(), nbins, fBMassLowLimit, fBMassUpLimit);
1274  fB0InvMassBin_MCmatch_PassCut1[i]->Sumw2();
1275 
1276  HistName.Form("fB0InvMassMinusD_bin%d_PassCut1",i);
1277  fB0InvMassBinMinusD_PassCut1[i]= new TH1F(HistName.Data(), HistName.Data(), nbins, fBMassLowLimit-1.869, fBMassUpLimit-1.869);
1278  fB0InvMassBinMinusD_PassCut1[i]->Sumw2();
1279  HistName.Form("fDplusInvMass_bin%d_MCmatch",i);
1280  fDplusInvMassBin_MCmatch[i]= new TH1F(HistName.Data(), HistName.Data(), 500, 1.819, 1.919 );
1281  fDplusInvMassBin_MCmatch[i]->Sumw2();
1282  HistName.Form("fB0InvMass_bin%d_PassCut1",i);
1283  fB0InvMassBin_PassCut1[i]= new TH1F(HistName.Data(), HistName.Data(), nbins, fBMassLowLimit, fBMassUpLimit);
1284  fB0InvMassBin_PassCut1[i]->Sumw2();
1285  HistName.Form("fB0InvMassMinusD_bin%d_MCmatch_PassCut1",i);
1286  fB0InvMassBinMinusD_MCmatch_PassCut1[i]= new TH1F(HistName.Data(), HistName.Data(), nbins, fBMassLowLimit-1.869, fBMassUpLimit-1.869);
1288  HistName.Form("fDplusInvMass_bin%d_PassCut1",i);
1289  fDplusInvMassBin_PassCut1[i]= new TH1F(HistName.Data(), HistName.Data(), 500, 1.819, 1.919 );
1290 
1291 
1292 
1293  HistName.Form("fBDecayLengthBin_bin%d",i);
1294  fBDecayLengthBin[i]= new TH1F(HistName.Data(), HistName.Data(), 200, 0, 0.5);
1295  HistName.Form("fBNormalizedDecayLengthBin_bin%d",i);
1296  fBNormalizedDecayLengthBin[i]= new TH1F(HistName.Data(), HistName.Data(), 200, 0, 20);
1297  HistName.Form("fBPointingBin_bin%d",i);
1298  fBPointingBin[i]= new TH1F(HistName.Data(), HistName.Data(), 200, 0, 1.);
1299  HistName.Form("fBPointingXYBin_bin%d",i);
1300  fBPointingXYBin[i]= new TH1F(HistName.Data(), HistName.Data(), 200, 0, 1.);
1301  HistName.Form("fDplusd0Bin_bin%d",i);
1302  fDplusd0Bin[i]= new TH1F(HistName.Data(), HistName.Data(), 200, 0, 0.25);
1303  HistName.Form("fBpTBin_bin%d",i);
1304  fBpTBin[i]= new TH1F(HistName.Data(), HistName.Data(), 100, 0, 50);
1305  HistName.Form("fDpluspTBin_bin%d",i);
1306  fDpluspTBin[i]= new TH1F(HistName.Data(), HistName.Data(), 100, 0, 50);
1307  HistName.Form("fproductd0Bin_bin%d",i);
1308  fproductd0Bin[i]= new TH1F(HistName.Data(), HistName.Data(), 200, -0.001, 0.001);
1309  HistName.Form("fDplusPointingBin_bin%d",i);
1310  fDplusPointingBin[i]= new TH1F(HistName.Data(), HistName.Data(), 200, 0., 1.);
1311  HistName.Form("fDplusDecayLengthBin_bin%d",i);
1312  fDplusDecayLengthBin[i]= new TH1F(HistName.Data(), HistName.Data(), 200, 0, 0.5);
1313  HistName.Form("fDplusNormalizedDecayLengthBin_bin%d",i);
1314  fDplusNormalizedDecayLengthBin[i]= new TH1F(HistName.Data(), HistName.Data(), 200, 0, 20);
1315  HistName.Form("fDplusSigmaVertBin_bin%d",i);
1316  fDplusSigmaVertBin[i]= new TH1F(HistName.Data(), HistName.Data(), 200, 0, 0.5);
1317 
1318  HistName.Form("fBDecayLengthBin_MCmatch_bin%d",i);
1319  fBDecayLengthBin_MCmatch[i]= new TH1F(HistName.Data(), HistName.Data(), 200, 0, 0.5);
1320  HistName.Form("fBNormalizedDecayLengthBin_MCmatch_bin%d",i);
1321  fBNormalizedDecayLengthBin_MCmatch[i]= new TH1F(HistName.Data(), HistName.Data(), 200, 0, 20);
1322  HistName.Form("fBPointingBin_MCmatch_bin%d",i);
1323  fBPointingBin_MCmatch[i]= new TH1F(HistName.Data(), HistName.Data(), 200, 0, 1.);
1324  HistName.Form("fBPointingXYBin_MCmatch_bin%d",i);
1325  fBPointingXYBin_MCmatch[i]= new TH1F(HistName.Data(), HistName.Data(), 200, 0, 1.);
1326  HistName.Form("fDplusd0Bin_MCmatch_bin%d",i);
1327  fDplusd0Bin_MCmatch[i]= new TH1F(HistName.Data(), HistName.Data(), 200, 0, 0.25);
1328  HistName.Form("fBpTBin_MCmatch_bin%d",i);
1329  fBpTBin_MCmatch[i]= new TH1F(HistName.Data(), HistName.Data(), 100, 0, 50);
1330  HistName.Form("fDpluspTBin_MCmatch_bin%d",i);
1331  fDpluspTBin_MCmatch[i]= new TH1F(HistName.Data(), HistName.Data(), 100, 0, 50);
1332  HistName.Form("fproductd0Bin_MCmatch_bin%d",i);
1333  fproductd0Bin_MCmatch[i]= new TH1F(HistName.Data(), HistName.Data(), 200, -0.001, 0.001);
1334  HistName.Form("fDplusPointingBin_MCmatch_bin%d",i);
1335  fDplusPointingBin_MCmatch[i]= new TH1F(HistName.Data(), HistName.Data(), 200, 0., 1.);
1336  HistName.Form("fDplusDecayLengthBin_MCmatch_bin%d",i);
1337  fDplusDecayLengthBin_MCmatch[i]= new TH1F(HistName.Data(), HistName.Data(), 200, 0, 0.5);
1338  HistName.Form("fDplusNormalizedDecayLengthBin_MCmatch_bin%d",i);
1339  fDplusNormalizedDecayLengthBin_MCmatch[i]= new TH1F(HistName.Data(), HistName.Data(), 200, 0, 20);
1340  HistName.Form("fDplusSigmaVertBin_MCmatch_bin%d",i);
1341  fDplusSigmaVertBin_MCmatch[i]= new TH1F(HistName.Data(), HistName.Data(), 200, 0, 0.5);
1342 
1343  HistName.Form("fd0MMExpD_bin%d",i);
1344  fd0MMExpDBin[i] = new TH1F(HistName.Data(), HistName.Data(), 200, -10.0,10.);
1345  HistName.Form("fd0MMExpD_MCmatch_bin%d",i);
1346  fd0MMExpDBin_MCmatch[i] = new TH1F(HistName.Data(), HistName.Data(), 200, -10.0,10.);
1347  HistName.Form("fd0MMExppi_bin%d",i);
1348  fd0MMExppiBin[i] = new TH1F(HistName.Data(), HistName.Data(), 200, -10.0,10.);
1349  HistName.Form("fd0MMExppi_MCmatch_bin%d",i);
1350  fd0MMExppiBin_MCmatch[i] = new TH1F(HistName.Data(), HistName.Data(), 200, -10.0,10.);
1351  HistName.Form("fd0MMExpDDaughtersBin%d",i);
1352  fd0MMExpDDaughtersBin[i] = new TH1F(HistName.Data(), HistName.Data(), 200, -10.0,10.);
1353  HistName.Form(" fd0MMExpDDaughters_MCmatch_bin%d",i);
1354  fd0MMExpDDaughtersBin_MCmatch[i] = new TH1F(HistName.Data(), HistName.Data(), 200, -10.0,10.);
1355 
1356  HistName.Form("fBDplusPtBin_bin%d",i);
1357  fBDplusPtBin[i]= new TH2F(HistName.Data(), HistName.Data(), 100, 0, 50,100,0,50);
1358  HistName.Form("fBpiPtBin_bin%d",i);
1359  fBpiPtBin[i]= new TH2F(HistName.Data(), HistName.Data(), 100, 0, 50,100,0,50);
1360  HistName.Form("fBDplusPtBin_bin%d_MCmatch",i);
1361  fBDplusPtBin_MCmatch[i]= new TH2F(HistName.Data(), HistName.Data(), 100, 0, 50,100,0,50);
1362  HistName.Form("fBpiPtBin_bin%d_MCmatch",i);
1363  fBpiPtBin_MCmatch[i]= new TH2F(HistName.Data(), HistName.Data(), 100, 0, 50,100,0,50);
1364 
1365 
1366 
1367 
1368  if(kbins){
1369  fOutputBins->Add(fB0InvMassBin[i]);
1371  fOutputBins->Add(fDplusInvMassBin[i]);
1374 
1375 
1376  fOutputBins->Add(fBDecayLengthBin[i]);
1378  fOutputBins->Add(fBPointingBin[i]);
1379  fOutputBins->Add(fBPointingXYBin[i]);
1380  fOutputBins->Add(fDplusd0Bin[i]);
1381  fOutputBins->Add(fBpTBin[i]);
1382  fOutputBins->Add(fDpluspTBin[i]);
1383  fOutputBins->Add(fproductd0Bin[i]);
1384  fOutputBins->Add(fDplusPointingBin[i]);
1388 
1389  fOutputBins->Add(fd0MMExpDBin[i]);
1390  fOutputBins->Add(fd0MMExppiBin[i]);
1392  fOutputBins->Add(fBDplusPtBin[i]);
1393  fOutputBins->Add(fBpiPtBin[i]);
1394  if(fReadMC){
1404  fOutputBins->Add(fBpTBin_MCmatch[i]);
1415  fOutputBins->Add(fBpiPtBin_MCmatch[i]);
1416 
1417 
1418 
1419  }
1420  }
1421  }
1422 
1423 
1424 
1425 
1426 
1427  return;
1428 }
1429 //________________________________________________________________________
1431  //
1432  // Fill histos for B0 spectrum
1433  //
1434  if (nB0 ==0) return;
1435 
1436  //Note: all this B0 candidates are "made" from the same Dplus, that's why fArrayB0[0]
1437  AliAODRecoDecayHF3Prong* Dmeson = (AliAODRecoDecayHF3Prong*)fArrayB0[0]->GetSecondaryVtx()->GetDaughter(0);
1438  UInt_t prongs[2]={411,211};
1439 
1440  Double_t d0MM[3];Double_t dd0min;
1441  for(Int_t i=0; i<3; i++) {
1442  Double_t diffIP, errdiffIP;
1443  Dmeson->Getd0MeasMinusExpProng(i,Bfield,diffIP,errdiffIP);
1444  Double_t normdd0= diffIP/errdiffIP;
1445  d0MM[i]=normdd0;
1446 
1447  if(i==0) dd0min=normdd0;
1448  else if(TMath::Abs(normdd0)<TMath::Abs(dd0min)) dd0min=normdd0;
1449 
1450  }
1451 
1452  //if(TMath::Abs(dd0min)<fInvertedTopomaticCutOnDDaughters)continue;
1453 
1454 
1455 
1456 
1457  Double_t Dmass= Dmeson->InvMassDplus();
1458  Double_t B0InvMass, d01, d02, productd0;
1459 
1460  for (int iB0 =0; iB0<nB0; iB0++){
1461 
1462 
1463 
1464  B0InvMass = fArrayB0[iB0]->InvMass2Prongs(0 , 1 ,prongs[0], prongs[1]);
1465  AliAODTrack* aodTrack = (AliAODTrack*)fArrayB0[iB0]->GetSecondaryVtx()->GetDaughter(1);
1466  d01 = TMath::Abs(fArrayB0[iB0]->Getd0Prong(0));
1467  d02 = TMath::Abs(fArrayB0[iB0]->Getd0Prong(1));
1468  productd0 = fArrayB0[iB0]->Getd0Prong(0) * fArrayB0[iB0]->Getd0Prong(1);
1469 
1470  Double_t diffIPMCD, errdiffIPMCD;
1471  fArrayB0[iB0]->Getd0MeasMinusExpProng(0,Bfield,diffIPMCD,errdiffIPMCD);
1472  Double_t normdd0MCD= diffIPMCD/errdiffIPMCD;
1473 
1474  Double_t diffIPMCpi, errdiffIPMCpi;
1475  fArrayB0[iB0]->Getd0MeasMinusExpProng(1,Bfield,diffIPMCpi,errdiffIPMCpi);
1476  Double_t normdd0MCpi= diffIPMCpi/errdiffIPMCpi;
1477 
1478  Double_t cosoa=(fArrayB0[iB0]->PxProng(0)*fArrayB0[iB0]->PxProng(1)+fArrayB0[iB0]->PyProng(0)*fArrayB0[iB0]->PyProng(1)+fArrayB0[iB0]->PzProng(0)*fArrayB0[iB0]->PzProng(1))/(TMath::Sqrt(fArrayB0[iB0]->P2Prong(0))*TMath::Sqrt(fArrayB0[iB0]->P2Prong(1)));
1479 
1480 
1481  fB0InvMass->Fill(B0InvMass);
1482  if(arrayMClabel[iB0] > (-1)){
1483  fBInvMass_MCmatch->Fill(B0InvMass);}
1484 
1485  if(kbins){
1486  Int_t index = fRDCutsAnalysis->PtBin(fArrayB0[iB0]->Pt());
1487  fB0InvMassBin[index]->Fill(B0InvMass);
1488  fDplusInvMassBin[index]->Fill(Dmeson->InvMassDplus());
1489  if(arrayMClabel[iB0] > (-1)) {
1490  fB0InvMassBin_MCmatch[index]->Fill(B0InvMass);
1491  }
1492  }
1493 
1494 
1495  Bool_t PassCut1=0;
1496  //Cuts array: 0= D pT,1= pi pT, 2= prod d0, 3= cos_point B, 4= cos_pointXY B, 5= decl B, 6=NdlXY B,7= Topomatic D, 8= topmatico pi, 9=cos opening angle
1497 
1498  if(Dmeson->Pt()>fpTD && aodTrack->Pt()>fpTpi &&productd0 < fprodd0 && fArrayB0[iB0]->CosPointingAngle()>fcosB && fArrayB0[iB0]->CosPointingAngleXY()>fcosBXY &&
1499  fArrayB0[iB0]->DecayLength()>fdlB && fArrayB0[iB0]->NormalizedDecayLengthXY()> fNdlBXY && TMath::Abs(normdd0MCpi)<fTopomaticpi && TMath::Abs(normdd0MCD)<fTopomaticD && cosoa>fcosoaDpi && TMath::Abs(dd0min)>fInvertedTopomaticCutOnDDaughters) PassCut1=1;
1500 
1501 
1502 
1503  if(PassCut1){
1504 
1505  fCEvents->Fill(17);
1506  fB0InvMass_PassCut1->Fill(B0InvMass);
1507  fB0InvMassMinusD_PassCut1->Fill(B0InvMass-Dmass);
1508  fDplusInvMass_PassCut1->Fill(Dmeson->InvMassDplus());
1509  //histo for the D+ (ex. if two B are found with the same D it will be counted twice)
1510  fBDplusPt->Fill(fArrayB0[iB0]->Pt(),Dmeson->Pt());
1511  fBpiPt->Fill(fArrayB0[iB0]->Pt(),aodTrack->Pt());
1512  fDplusPt->Fill(Dmeson->Pt());
1513  fDplusEta->Fill(Dmeson->Eta());
1514  fDplusPhi->Fill(Dmeson->Phi());
1515  fDplusPointing->Fill(Dmeson->CosPointingAngle());
1516  fDplusDecayLength->Fill(Dmeson->DecayLength());
1518  fDplusSigmaVert->Fill(Dmeson->GetSigmaVert());
1519  fDplusd0->Fill(d01);
1520 
1521 
1522 
1523  fpiPt->Fill(aodTrack->Pt());
1524  fpiEta->Fill(aodTrack->Eta());
1525  fpiPhi->Fill(aodTrack->Phi());
1526  fBPt->Fill(fArrayB0[iB0]->Pt());
1527  fBEta->Fill(fArrayB0[iB0]->Eta());
1528  fBPhi->Fill(fArrayB0[iB0]->Phi());
1529  fBDecayLength->Fill(fArrayB0[iB0]->DecayLength());
1530  fBNormalizedDecayLength->Fill(fArrayB0[iB0]->NormalizedDecayLengthXY());
1531  fBPointing->Fill(fArrayB0[iB0]->CosPointingAngle());
1532  fBPointingXY->Fill(fArrayB0[iB0]->CosPointingAngleXY());
1533  fpid0->Fill(d02);
1534  fproductd0->Fill(productd0);
1535  fd0MMExpD->Fill(normdd0MCD);
1536  fd0MMExppi->Fill(normdd0MCpi);
1537  fd0MMExpDDaughters->Fill(dd0min);
1538 
1539  fcosoa->Fill(cosoa);
1540 
1541 
1542 
1543  if(arrayMClabel[iB0] > (-1)){
1544 
1545  fCEvents->Fill(18);
1546  fBInvMass_MCmatch_PassCut1->Fill(B0InvMass);
1547  fB0InvMassMinusD_MCmatch_PassCut1->Fill(B0InvMass-Dmass);
1548  fBDplusPt_MCmatch->Fill(fArrayB0[iB0]->Pt(),Dmeson->Pt());
1549  fBpiPt_MCmatch->Fill(fArrayB0[iB0]->Pt(),aodTrack->Pt());
1550 
1551  fpiPt_MCmatch->Fill(aodTrack->Pt());
1552  fpiEta_MCmatch->Fill(aodTrack->Eta());
1553  fpiPhi_MCmatch->Fill(aodTrack->Phi());
1554  fBPt_MCmatch->Fill(fArrayB0[iB0]->Pt());
1555  fBEta_MCmatch->Fill(fArrayB0[iB0]->Eta());
1556  fBPhi_MCmatch->Fill(fArrayB0[iB0]->Phi());
1557  fBDecayLength_MCmatch->Fill(fArrayB0[iB0]->DecayLength());
1558  fBNormalizedDecayLength_MCmatch->Fill(fArrayB0[iB0]->NormalizedDecayLengthXY());
1559  fBPointing_MCmatch->Fill(fArrayB0[iB0]->CosPointingAngle());
1560  fBPointingXY_MCmatch->Fill(fArrayB0[iB0]->CosPointingAngleXY());
1561  fDplusd0_MCmatch->Fill(d01);
1562  fpid0_MCmatch->Fill(d02);
1563  fproductd0_MCmatch->Fill(productd0);
1564  fDplusPt_MCmatch->Fill(Dmeson->Pt());
1565  fDplusEta_MCmatch->Fill(Dmeson->Eta());
1566  fDplusPhi_MCmatch->Fill(Dmeson->Phi());
1567  fDplusPointing_MCmatch->Fill(Dmeson->CosPointingAngle());
1568  fDplusDecayLength_MCmatch->Fill(Dmeson->DecayLength());
1570  fDplusSigmaVert_MCmatch->Fill(Dmeson->GetSigmaVert());
1571  fDplusInvMass_MCmatch->Fill(Dmeson->InvMassDplus());
1572  fd0MMExpDMCmatch->Fill(normdd0MCD);
1573  fd0MMExppiMCmatch->Fill(normdd0MCpi);
1574  fd0MMExpDDaughters_MCmatch->Fill(dd0min);
1575  fcosoa_MCmatch->Fill(cosoa);
1576 
1577  }
1578 
1579 
1580 
1581  if(kbins){
1582  Int_t index = fRDCutsAnalysis->PtBin(fArrayB0[iB0]->Pt());
1583 
1584  fB0InvMassBin_PassCut1[index]->Fill(B0InvMass);
1585  fB0InvMassBinMinusD_PassCut1[index]->Fill(B0InvMass-Dmass);
1586  fDplusInvMassBin_PassCut1[index]->Fill(Dmeson->InvMassDplus());
1587  fBDecayLengthBin[index]->Fill(fArrayB0[iB0]->DecayLength());
1588  fBNormalizedDecayLengthBin[index]->Fill(fArrayB0[iB0]->NormalizedDecayLengthXY());
1589  fBPointingBin[index]->Fill(fArrayB0[iB0]->CosPointingAngle());
1590  fBPointingXYBin[index]->Fill(fArrayB0[iB0]->CosPointingAngleXY());
1591  fDplusd0Bin[index]->Fill(d01);
1592  fBpTBin[index]->Fill(fArrayB0[iB0]->Pt());
1593  fDpluspTBin[index]->Fill(Dmeson->Pt());
1594  fproductd0Bin[index]->Fill(productd0);
1595  fDplusPointingBin[index]->Fill(Dmeson->CosPointingAngle());
1596  fDplusDecayLengthBin[index]->Fill(Dmeson->DecayLength());
1598  fDplusSigmaVertBin[index]->Fill(Dmeson->GetSigmaVert());
1599  fd0MMExpDBin[index]->Fill(normdd0MCD);
1600  fd0MMExppiBin[index]->Fill(normdd0MCpi);
1601  fd0MMExpDDaughtersBin[index]->Fill(dd0min);
1602 
1603 
1604  fBDplusPtBin[index]->Fill(fArrayB0[iB0]->Pt(),Dmeson->Pt());
1605  fBpiPtBin[index]->Fill(fArrayB0[iB0]->Pt(),aodTrack->Pt());
1606 
1607  if(arrayMClabel[iB0] > (-1)){
1608 
1609  fB0InvMassBinMinusD_MCmatch_PassCut1[index]->Fill(B0InvMass-Dmass);
1610  fB0InvMassBin_MCmatch_PassCut1[index]->Fill(B0InvMass);
1611  fDplusInvMassBin_MCmatch[index]->Fill(Dmeson->InvMassDplus());
1612  fBDecayLengthBin_MCmatch[index]->Fill(fArrayB0[iB0]->DecayLength());
1613  fBNormalizedDecayLengthBin_MCmatch[index]->Fill(fArrayB0[iB0]->NormalizedDecayLengthXY());
1614  fBPointingBin_MCmatch[index]->Fill(fArrayB0[iB0]->CosPointingAngle());
1615  fBPointingXYBin_MCmatch[index]->Fill(fArrayB0[iB0]->CosPointingAngleXY());
1616  fDplusd0Bin_MCmatch[index]->Fill(d01);
1617  fBpTBin_MCmatch[index]->Fill(fArrayB0[iB0]->Pt());
1618  fDpluspTBin_MCmatch[index]->Fill(Dmeson->Pt());
1619  fproductd0Bin_MCmatch[index]->Fill(productd0);
1620  fDplusPointingBin_MCmatch[index]->Fill(Dmeson->CosPointingAngle());
1621  fDplusDecayLengthBin_MCmatch[index]->Fill(Dmeson->DecayLength());
1623  fDplusSigmaVertBin_MCmatch[index]->Fill(Dmeson->GetSigmaVert());
1624  fd0MMExpDBin_MCmatch[index]->Fill(normdd0MCD);
1625  fd0MMExppiBin_MCmatch[index]->Fill(normdd0MCpi);
1626  fd0MMExpDDaughtersBin_MCmatch[index]->Fill(dd0min);
1627  fBDplusPtBin_MCmatch[index]->Fill(fArrayB0[iB0]->Pt(),Dmeson->Pt());
1628  fBpiPtBin_MCmatch[index]->Fill(fArrayB0[iB0]->Pt(),aodTrack->Pt());
1629 
1630 
1631  }
1632  }
1633  }
1634  }
1635 
1636 
1637  return;
1638 }
1639 
1640 
1641 //___________________________________________________________________________-
1642 
1643 AliAODVertex* AliAnalysisTaskSEB0toDminuspi::RecalculateVertex(const AliVVertex *primary,TObjArray *tracks,Double_t bField) {
1644  //
1645  // Helper function to recalculate a vertex.
1646  //
1647 
1648  AliESDVertex *vertexESD = 0;
1649  AliAODVertex *vertexAOD = 0;
1650  //Double_t covmatrix[6];
1651  // AliVertexerTracks
1652  AliVertexerTracks *vertexer = new AliVertexerTracks(bField);
1653  vertexer->SetVtxStart((AliESDVertex*)primary);//primary vertex
1654  vertexESD = (AliESDVertex*)vertexer->VertexForSelectedESDTracks(tracks);
1655  delete vertexer; vertexer=NULL;
1656 
1657  if(!vertexESD) return vertexAOD;
1658 
1659 
1660  if(vertexESD->GetNContributors()!=tracks->GetEntriesFast()) {
1661 
1662  delete vertexESD; vertexESD=NULL;
1663  return vertexAOD;
1664  }
1665 
1666  // Double_t pos[3],cov[6],chi2perNDF;
1667  // vertexESD->GetXYZ(pos);
1668  // convert to AliAODVertex
1669  //
1670  Double_t dispersion;
1671  Double_t pos[3],cov[6],chi2perNDF;
1672  for(Int_t a=0;a<3;a++)pos[a]=0.;
1673  for(Int_t b=0;b<6;b++)cov[b]=0.;
1674  chi2perNDF=0;
1675  //
1676  vertexESD->GetXYZ(pos); // position
1677  vertexESD->GetCovMatrix(cov); //covariance matrix
1678 
1679 
1680  Double_t vertRadius2=pos[0]*pos[0]+pos[1]*pos[1];
1681  if(vertRadius2>8.){//(2.82)^2 radius beam pipe
1682  // vertex outside beam pipe, reject candidate to avoid propagation through material
1683  delete vertexESD; vertexESD=NULL;
1684  return vertexAOD;
1685  }
1686 
1687  chi2perNDF = vertexESD->GetChi2toNDF();
1688  dispersion = vertexESD->GetDispersion();
1689  delete vertexESD; vertexESD=NULL;
1690  Int_t nprongs= tracks->GetEntriesFast();
1691  vertexAOD = new AliAODVertex(pos,cov,chi2perNDF,0x0,-1,AliAODVertex::kUndef,nprongs);
1692  return vertexAOD;
1693 
1694 }
1695 
1696 
1697 
1698 //----------------------------------------------------------------------------
TH1F * fDplusSigmaVert
!hist. for D sigma vertex (after cut)
TH1F * fDplusSigmaVertBin_MCmatch[kMaxPtBins]
!hist. for D sigma vertex (after cut) matched to B0 in MC in pT bins
Double_t NormalizedDecayLengthXY() const
TH1F * fBDecayLength_MCmatch
!hist. for B decay length (after cut) matched to B0 in MC
Double_t fTopomaticD
cut to applied on B selection: B norm decay length XY
TH1F * fDplusPhi_MCmatch
!hist. for D phi (after cut) matched to B0 in MC
Double_t fBMassUpLimit
BMassLowLimit for histo.
TH1F * fpid0_MCmatch
!hist. for pion d0 (after cut) matched to B0 in MC
TH1F * fBPhi_MCmatch
!hist. for B phi (after cut) matched to B0 in MC
TH1F * fDplusDecayLength_MCmatch
!hist. for D decay length (after cut) matched to B0 in MC
TH1F * fBpTBin_MCmatch[kMaxPtBins]
!hist. for B pT (after cut) matched to B0 in MC in pT bins
Int_t GetIsSelectedPID() const
Definition: AliRDHFCuts.h:360
TH1F * fBPt
!hist. for B Pt (after cut)
double Double_t
Definition: External.C:58
Double_t fTopomaticpi
cut to applied on B selection: D topomatic
TH1F * fDplusSigmaVert_MCmatch
!hist. for D sigma vertex (after cut) matched to B0 in MC
TH1F * fBInvMass_MCmatch
!hist. for B0 mass matched to B0 in MC
void StoreCandidates(AliVEvent *, Int_t nCand=0, Bool_t flagFilter=kTRUE)
Definition: External.C:236
void Getd0MeasMinusExpProng(Int_t ip, Double_t magf, Double_t &d0diff, Double_t &errd0diff) const
TH2F * fBDplusPt
!hist of B pT vs D pT
TList * fOutputBins
! User output for different pt bins
TH1F * fDplusInvMass_DplusMCmatch
!hist. for D+ mass matched to B0 in MC
TH1F * fDplusd0
!hist. for D d0 (after cut)
TH1F * fBNormalizedDecayLength
!hist. for B norm decay lengthXY (after cut)
Int_t GetIsSelectedCuts() const
Definition: AliRDHFCuts.h:359
Bool_t HasSelectionBit(Int_t i) const
TH1F * fd0MMExpDMCmatch
!hist. for D topomatic (after cut) matched to B0 in MC
TH1F * fDpluspTBin_MCmatch[kMaxPtBins]
!hist. for D pT (after cut) matched to B0 in MC in pT bins
TH1F * fDplusInvMassBin_PassCut1[kMaxPtBins]
!hist. for D mass after cut matched to B0 in MC in pT bins
TH1F * fBDecayLengthBin[kMaxPtBins]
!hist. for B decay length (after cut) in pT bins
TH1F * fDplusNormalizedDecayLengthBin[kMaxPtBins]
!hist. for D norm decay length XY (after cut) in pT bins
Double_t fpTpi
cut to applied on B selection: pT D
TH1F * fpiPt_MCmatch
!hist. for pi Pt (after cut) matched to B0 in MC
TH1F * fcosoa_MCmatch
!hist. for cos opening angle between D and pion (after cut) matched to B0 in MC
TH1F * fBDecayLengthBin_MCmatch[kMaxPtBins]
!hist. for B decay length (after cut) in pT bins
TH1F * fDplusPt
!hist. for D Pt (after cut)
Double_t bz
char Char_t
Definition: External.C:18
void FillSpectrum(Int_t nB0, Int_t *arrayMClabel, Double_t Bfield)
TH1F * fDplusSigmaVertBin[kMaxPtBins]
!hist. for D sigma vertex (after cut) in pT bins
TH1F * fd0MMExpDDaughters
!hist. for D daughters topomatic (after cut)
TH1F * fDplusNormalizedDecayLength
!hist. for D norm decay lengthXY (after cut)
TH1F * fpiPhi_MCmatch
!hist. for pi phi (after cut) matched to B0 in MC
TH2F * fBDplusPtBin_MCmatch[kMaxPtBins]
!hist of B pT vs D pT matched to B0 in MC in pT bins
Float_t fBinWidth
BMassUpLimit for histo.
virtual Bool_t IsInFiducialAcceptance(Double_t pt, Double_t y) const
AliAODVertex * RecalculateVertex(const AliVVertex *old, TObjArray *tracks, Double_t bField)
static Int_t CheckOrigin(TClonesArray *arrayMC, AliAODMCParticle *mcPart, Bool_t searchUpToQuark=kTRUE)
Functions to check the decay tree.
TH1F * fd0MMExpDDaughtersBin[kMaxPtBins]
!hist. for D daughters topomatic (after cut) in pT bins
TH1F * fBpTBin[kMaxPtBins]
!hist. for B pT (after cut) in pT bins
TH1F * fBInvMass_MCmatch_PassCut1
!hist. for B0 mass after cut matched to B0 in MC
TH1F * fDplusDecayLength
!hist. for D decay length (after cut)
TH1F * fd0MMExppi
!hist. for pion topomatic (after cut)
AliAODPidHF * GetPidHF() const
Definition: AliRDHFCuts.h:246
TH1F * fpiPhi
!hist. for pion phi (after cut)
TH1F * fDplusPointingBin[kMaxPtBins]
!hist. for D cos pointing (after cut) in pT bins
Double_t fcosB
cut to applied on B selection: product d0
void SetBMassLimits(Float_t lowlimit, Float_t uplimit)
Double_t fdlB
cut to applied on B selection: B cos pointing XY
TH1F * fBPointing
!hist. for B cos poining (after cut)
TH1F * fB0InvMass_PassCut1
!hist. for B0 mass after cut
TH1F * fB0InvMassBin_MCmatch_PassCut1[kMaxPtBins]
!hist. for B0 mass after cut matched to B0 in MC in pT bins
TH1F * fBEta_MCmatch
!hist. for B eta (after cut) matched to B0 in MC
TH1F * fd0MMExpDDaughtersBin_MCmatch[kMaxPtBins]
!hist. for D daughters topomatic (after cut) matched to B0 in MC in pT bins
Class for cuts on AOD reconstructed D+->Kpipi.
TH1F * fBNormalizedDecayLengthBin[kMaxPtBins]
!hist. for B norm decay length XY (after cut) in pT bins
TH1F * fB0InvMassBin_MCmatch[kMaxPtBins]
!hist. for B0 mass matched to B0 in MC in pT bins
TH1F * fBNormalizedDecayLengthBin_MCmatch[kMaxPtBins]
!hist. for B norm decay length XY (after cut) in pT bins
int Int_t
Definition: External.C:63
TH1F * fDplusEta_MCmatch
!hist. for D eta (after cut) matched to B0 in MC
virtual Int_t IsSelected(TObject *obj, Int_t selectionLevel)
unsigned int UInt_t
Definition: External.C:33
TH1F * fd0MMExpDDaughters_MCmatch
!hist. for D daughters topomatic (after cut) matched to B0 in MC
float Float_t
Definition: External.C:68
TH1F * fDplusPt_MCmatch
!hist. for D pT (after cut) matched to B0 in MC
TH1F * fd0MMExppiBin_MCmatch[kMaxPtBins]
!hist. for pion topomatic (after cut) matched to B0 in MC in pT bins
TH1F * fB0InvMassBin_PassCut1[kMaxPtBins]
!hist. for B0 mass after cut in pT bins
Int_t fEvents
Counter for normalization slot.
TH1F * fpiEta_MCmatch
!hist. for pi eta (after cut) matched to B0 in MC
TH1F * fd0MMExppiMCmatch
!hist. for pion topomatic (after cut) matched to B0 in MC
Double_t fDplusMassUpLimit
DplusMassLowLimit to select D.
AliAODVertex * GetOwnPrimaryVtx() const
Double_t GetSigmaVert(const AliAODEvent *aod=0x0)
TH1F * fproductd0
!hist. for d0 product (after cut)
TH1F * fDplusPointing_MCmatch
!hist. for D cos pointing (after cut) matched to B0 in MC
TH1F * fpiPt
!hist. for pion Pt (after cut)
TH1F * fBPointingXYBin[kMaxPtBins]
!hist. for B cos pointing XY (after cut) in pT bins
TH1F * fDplusInvMassBin[kMaxPtBins]
!hist. for D+ mass in pT bins
TH2F * fBDplusPt_MCmatch
!hist of B pT vs D pT matched to B0 in MC
TH1F * fDplusPhi
!hist. for D phi (after cut)
TH1F * fd0MMExppiBin[kMaxPtBins]
!hist. for pion topomatic (after cut) in pT bins
TH1F * fDplusPointing
!hist. for D cos pointing (after cut)
void SetProngIDs(Int_t nIDs, UShort_t *id)
TH1F * fDplusNormalizedDecayLength_MCmatch
!hist. for D norm dec length XY(after cut) matched to B0 in MC
TH1F * fDpluspTBin[kMaxPtBins]
!hist. for D pT (after cut) in pT bins
TH1F * fB0InvMassBinMinusD_PassCut1[kMaxPtBins]
!hist. for B0minusD mass after cut in MC in pT bins
TH1F * fBPointingBin_MCmatch[kMaxPtBins]
!hist. for B cos pointnig (after cut) matched to B0 in MC in pT bins
UShort_t GetProngID(Int_t ip) const
virtual void Terminate(Option_t *option)
TH1F * fd0MMExpDBin_MCmatch[kMaxPtBins]
!hist. for D topomatic (after cut) matched to B0 in MC in pT bins
TH1F * fDplusDecayLengthBin[kMaxPtBins]
!hist. for D decay length (after cut) in pT bins
TH1F * fBEta
!hist. for B eta (after cut)
AliPIDResponse * GetPidResponse() const
Definition: AliAODPidHF.h:160
TH1F * fDplusInvMassBin_MCmatch[kMaxPtBins]
!hist. for D+ mass matched to B0 in MC in pT bins
std::vector< AliAODRecoDecayHF2Prong * > fArrayB0
Cuts for Analysis.
TH2F * fBpiPtBin[kMaxPtBins]
!hist of B pT vs pion pT in pT bins
TH1F * fd0MMExpDBin[kMaxPtBins]
!hist. for D topomatic (after cut) in pT bins
Double_t fDplusMassLowLimit
flag to activate cuts distr histos
void SetPrimaryVtxRef(TObject *vtx)
primary vertex
TH2F * fBpiPt
!hist of B pT vs pion pT
virtual void UserExec(Option_t *option)
void SetOwnPrimaryVtx(const AliAODVertex *vtx)
TH1F * fDplusd0Bin_MCmatch[kMaxPtBins]
!hist. for D d0 (after cut) matched to B0 in MC in pT bins
Double_t fprodd0
cut to applied on B selection: pT pion
TH1F * fDplusDecayLengthBin_MCmatch[kMaxPtBins]
!hist. for D decay length (after cut) matched to B0 in MC in pT bins
static Double_t GetBeautyMotherPt(TClonesArray *arrayMC, AliAODMCParticle *mcPart)
TH1F * fDplusPointingBin_MCmatch[kMaxPtBins]
!hist. for D pointing (after cut) matched to B0 in MC in pT bins
TH1F * fBNormalizedDecayLength_MCmatch
!hist. for B norm dec length XY (after cut) matched to B0 in MC
TH1F * fB0InvMassMinusD_PassCut1
!hist. for B0minusD mass after cut
Bool_t GetIsPrimaryWithoutDaughters() const
Definition: AliRDHFCuts.h:277
Bool_t IsEventSelected(AliVEvent *event)
void StoreEvent(AliVEvent *, AliRDHFCuts *, Bool_t mc=kFALSE, Int_t multiplicity=-9999, Double_t spherocity=-99.)
TH2F * fBpiPt_MCmatch
!hist of B pT vs pion pT matched to B0 in MC
TH1F * fBPt_MCmatch
!hist. for B pt (after cut) matched to B0 in MC
TH1F * fDplusd0_MCmatch
!hist. for D d0 (after cut) matched to B0 in MC
TH2F * fBpiPtBin_MCmatch[kMaxPtBins]
!hist of B pT vs pion pT matched to B0 in MC in pT bins
TH1F * fDplusNormalizedDecayLengthBin_MCmatch[kMaxPtBins]
!hist. for D norm dec length XY (after cut) matched to B0 in MC in pT bins
TH1F * fpid0
!hist. for pion d0 (after cut)
void CleanOwnPrimaryVtx(AliAODRecoDecayHF *d, AliAODEvent *aod, AliAODVertex *origownvtx) const
Double_t fInvertedTopomaticCutOnDDaughters
width of one bin in B mass output histos
Double_t fBMassLowLimit
DplusMassUpLimit to select D.
TH1F * fBPointing_MCmatch
!hist. for B pointing (after cut) matched to B0 in MC
TH1F * fB0InvMassBinMinusD_MCmatch_PassCut1[kMaxPtBins]
!hist. for B0minusD mass after cut matched to B0 in MC in pT bins
TH1F * fBPointingXY
!hist. for B cos poining XY (after cut)
TH1F * fDplusEta
!hist. for D eta (after cut)
TH1F * fproductd0_MCmatch
!hist. for d0 product (after cut) matched to B0 in MC
TH1F * fBPointingXY_MCmatch
!hist. for B pointing XY (after cut) matched to B0 in MC
TH1F * fproductd0Bin_MCmatch[kMaxPtBins]
!hist. for product d0 (after cut) matched to B0 in MC in pT bins
unsigned short UShort_t
Definition: External.C:28
Bool_t fUseQuarkTagInKine
flag to add histo in pT bins
TH1F * fB0InvMassBin[kMaxPtBins]
!hist. for B0 mass in pT bins
const char Option_t
Definition: External.C:48
Double_t fcosBXY
cut to applied on B selection: B cos pointing
Int_t GetNPtBins() const
Definition: AliRDHFCuts.h:248
TH1F * fDplusInvMass_MCmatch
!hist. for (after cut) matched to B0 in MC
Double_t fcosoaDpi
cut to applied on B selection: pion topomatic
TH2F * fBDplusPtBin[kMaxPtBins]
!hist of B pT vs D pT in pT bins
TH1F * fBPhi
!hist. for B phi (after cut)
Double_t fpTD
only candidates with a minimum topomatic of fUseInvertedTopomaticCutOnDDaughters are considered ...
Double_t fNdlBXY
cut to applied on B selection: B decay length
const Int_t nbins
bool Bool_t
Definition: External.C:53
Double_t CosPointingAngle() const
TH1F * fproductd0Bin[kMaxPtBins]
!hist. for d0 product (after cut) in pT bins
TH1F * fd0MMExpD
!hist. for D topomatic (after cut)
TH1F * fB0InvMassMinusD_MCmatch_PassCut1
!hist. for B0minusD mass after cut matched to B0 in MC
Bool_t RecalcOwnPrimaryVtx(AliAODRecoDecayHF *d, AliAODEvent *aod) const
TH1F * fBPointingBin[kMaxPtBins]
!hist. for B cos pointing (after cut) in pT bins
Int_t PtBin(Double_t pt) const
Double_t DecayLength() const
TH1F * fCEvents
!hist. for No. of events
TH1F * fDplusInvMass_PassCut1
!hist. for D+ mass after cut
TH1F * fcosoa
!hist. for cos opening angle between D and pion (after cut)
TH1F * fDplusd0Bin[kMaxPtBins]
!hist. for D d0 (after cut) in pT bins
Bool_t fReadMC
eta region to accept D+ 0=all, -1 = negative, 1 = positive
TH1F * fBPointingXYBin_MCmatch[kMaxPtBins]
!hist. for B cos pointnig XY (after cut) matched to B0 in MC in pT bins
TH1F * fpiEta
!hist. for pion eta (after cut)
TH1F * fBDecayLength
!hist. for B decay length (after cut)
Int_t MatchToMCB3Prong(Int_t pdgabs, Int_t pdgabs3prong, Int_t *pdgBDg, Int_t *pdgDg3prong, TClonesArray *mcArray) const