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