AliPhysics  a6017e1 (a6017e1)
AliAnalysisTaskSEBPlustoD0Pi.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 /* $Id$ */
17 
18 //
19 //
20 // Base class for (BPlus -> D0 pi-> K pi pi) Analysis
21 //
22 //
23 // Cuts are centralized in AliRDHFCutsBPlustoD0Pi
24 // Like sign + track rotation backgrounds are imlemented in the macro
25 //
26 //-----------------------------------------------------------------------
27 //
28 // Author Lennart van Doremalen
29 // Utrecht University - l.v.r.vandoremalen@uu.nl
30 //
31 //-----------------------------------------------------------------------
32 
33 #include <TSystem.h>
34 #include <TChain.h>
35 #include <TParticle.h>
36 #include <TH1I.h>
37 #include "TROOT.h"
38 #include <TDatabasePDG.h>
39 #include <AliAnalysisDataSlot.h>
40 #include <AliAnalysisDataContainer.h>
41 #include "AliRDHFCutsBPlustoD0Pi.h"
42 #include "AliStack.h"
43 #include "AliMCEvent.h"
44 #include "AliAnalysisManager.h"
45 #include "AliAODMCHeader.h"
46 #include "AliAODHandler.h"
47 #include "AliLog.h"
48 #include "AliVertex.h"
49 #include "AliVVertex.h"
50 #include "AliESDVertex.h"
51 #include "AliAODVertex.h"
52 #include "AliVertexerTracks.h"
53 #include "AliExternalTrackParam.h"
54 #include "AliNeutralTrackParam.h"
55 #include "AliAODRecoDecay.h"
56 #include "AliAODRecoDecayHF.h"
59 #include "AliAnalysisVertexingHF.h"
60 #include "AliVertexingHFUtils.h"
61 #include "AliESDtrack.h"
62 #include "AliAODMCParticle.h"
63 #include "AliAODEvent.h"
65 #include "AliAODInputHandler.h"
66 #include <vector>
67 #include <TMatrix.h>
68 #include <TVector3.h>
69 #include <TArrayI.h>
70 #include <bitset>
71 #include <TH3F.h>
72 
73 // #include "TObjectTable.h"
74 
78 
79 //__________________________________________________________________________
82  fEvents(0),
83  fUseMCInfo(kFALSE),
84  fShowMask(0),
85  fShowRejection(0),
86  fQuickSignalAnalysis(0),
87  fGetCutInfo(0),
88  fHistMassWindow(0.125),
89  fDegreePerRotation(0),
90  fNumberOfRotations(0),
91  fCheckBackground(0),
92  fPerformCutOptimization(0),
93  fOutput(0),
94  fListCuts(0),
95  fOutputBPlusMC(0),
96  fOutputD0FirstDaughter(0),
97  fOutputD0SecondDaughter(0),
98  fOutputBPlusPion(0),
99  fOutputD0(0),
100  fOutputBPlus(0),
101  fOutputD0_D0Pt(0),
102  fCuts(0),
103  fCEvents(0),
104  fBPlusPionTracks(0x0),
105  fD0Tracks(0x0),
106  fnPtBins(0),
107  fnPtBinLimits(0),
108  fPtBinLimits(0x0),
109  fnPtBinsD0forD0ptbin(0),
110  fnPtBinsD0forD0ptbinLimits(0),
111  fPtBinLimitsD0forD0ptbin(0x0),
112  fCutVariableValueArray(),
113  fDaughterHistogramArray(),
114  fDaughterHistogramArray2D(),
115  fDaughterHistogramArrayExtra(),
116  fMotherHistogramArray(),
117  fMotherHistogramArray2D(),
118  fMotherHistogramArrayExtra()
119 {
120  //
122  //
123 
124 }
125 //___________________________________________________________________________
127  AliAnalysisTaskSE(name),
128  fEvents(0),
129  fUseMCInfo(kFALSE),
130  fShowMask(0),
131  fShowRejection(0),
133  fGetCutInfo(0),
134  fHistMassWindow(0.125),
137  fCheckBackground(0),
139  fOutput(0),
140  fListCuts(0),
141  fOutputBPlusMC(0),
144  fOutputBPlusPion(0),
145  fOutputD0(0),
146  fOutputBPlus(0),
147  fOutputD0_D0Pt(0),
148  fCuts(0),
149  fCEvents(0),
150  fBPlusPionTracks(0x0),
151  fD0Tracks(0x0),
152  fnPtBins(0),
153  fnPtBinLimits(0),
154  fPtBinLimits(0x0),
165 {
166  //
168  //
169 
170  Info("AliAnalysisTaskSEBPlustoD0Pi", "Calling Constructor");
171 
172  fCuts = cuts;
173 
174  DefineInput(0, TChain::Class());
175  DefineOutput(1, TList::Class()); //conters
176  DefineOutput(2, TList::Class()); //My private output
177  DefineOutput(3, TList::Class()); // D0 pion output
178  DefineOutput(4, TList::Class()); // D0 kaon output
179  DefineOutput(5, TList::Class()); // BPlus pion output
180  DefineOutput(6, TList::Class()); // D0 output
181  DefineOutput(7, TList::Class()); // BPlus output
182  DefineOutput(8, TList::Class()); // BPlus output
183  DefineOutput(9, TList::Class()); // BPlusMC output
184 }
185 
186 //___________________________________________________________________________
188  //
190  //
191  Info("~AliAnalysisTaskSEBPlustoD0Pi", "Calling Destructor");
192 
193  delete fOutput;
194  delete fOutputD0FirstDaughter;
196  delete fOutputBPlusPion;
197  delete fOutputD0;
198  delete fOutputBPlus;
199  delete fOutputD0_D0Pt;
200  delete fOutputBPlusMC;
201  delete fCuts;
202  delete fCEvents;
203  delete fD0Tracks;
204  delete fBPlusPionTracks;
205  delete fListCuts;
206  delete fPtBinLimits;
208  for (Int_t i = 0; i < 4; i++) {
209  for (Int_t j = 0; j < 6; j++) {
210  for (Int_t k = 0; k < 15; k++) {
211  delete fDaughterHistogramArray[i][j][k]; fDaughterHistogramArray[i][j][k] = nullptr;
212  }
213  }
214  }
215  for (Int_t i = 0; i < 4; i++) {
216  for (Int_t j = 0; j < 6; j++) {
217  delete fDaughterHistogramArray2D[i][j]; fDaughterHistogramArray2D[i][j] = nullptr;
218  }
219  }
220  for (Int_t i = 0; i < 4; i++) {
221  for (Int_t j = 0; j < 6; j++) {
222  delete fDaughterHistogramArrayExtra[i][j]; fDaughterHistogramArrayExtra[i][j] = nullptr;
223  }
224  }
225  for (Int_t i = 0; i < 6; i++) {
226  for (Int_t j = 0; j < 99; j++) {
227  for (Int_t k = 0; k < 60; k++) {
228  delete fMotherHistogramArray[i][j][k]; fMotherHistogramArray[i][j][k] = nullptr;
229  }
230  }
231  }
232  for (Int_t i = 0; i < 6; i++) {
233  for (Int_t j = 0; j < 99; j++) {
234  for (Int_t k = 0; k < 60; k++) {
235  delete fMotherHistogramArray2D[i][j][k]; fMotherHistogramArray2D[i][j][k] = nullptr;
236  }
237  }
238  }
239  for (Int_t i = 0; i < 7; i++) {
240  for (Int_t j = 0; j < 10; j++) {
241  delete fMotherHistogramArrayExtra[i][j]; fMotherHistogramArrayExtra[i][j] = nullptr;
242  }
243  }
244 }
245 //_________________________________________________
247  //
249  //
250 
251  if (fDebug > 1) printf("AliAnalysisTaskSEBPlustoD0Pi::Init() \n");
252 
253  return;
254 }
255 //_________________________________________________
257 
258  //==================================================================================
259  // USER EXECUTION FUNCTION - start
260  //==================================================================================
261  //
262  // This is the main function that has to be altered to do heavy flavour analysis.
263  //
264  //==================================================================================
265 
266  if (!fInputEvent) {
267  Error("UserExec", "NO EVENT FOUND!");
268  return;
269  }
270 
271  if (fEvents % 50 == 0) {
272  std::cout << "\r" << "Analysing event number: " << fEvents << std::endl;
273  }
274 
275  fEvents++;
276 
277  // Show trigger mask
278  if (fShowMask)
279  {
280  std::bitset<32> maskEV(((AliAODInputHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected());
281  std::cout << "Event mask: " << maskEV << std::endl;
282  std::cout << "Trigger mask: " << std::bitset<32>(fCuts->GetTriggerMask()) << std::endl;
283  }
284 
285 
286  //==================================================================================
287  // EVENT INITIALIZATION - start
288  //==================================================================================
289 
290 
291  AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(fInputEvent);
292  TClonesArray * D0TracksFromFriendFile = 0;
293  fCEvents->Fill(1);
294 
295  if (!aodEvent && AODEvent() && IsStandardAOD()) {
296  // In case there is an AOD handler writing a standard AOD, use the AOD
297  // event in memory rather than the input (ESD) event.
298  aodEvent = dynamic_cast<AliAODEvent*> (AODEvent());
299  // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
300  // have to taken from the AOD event hold by the AliAODExtension
301  AliAODHandler* aodHandler = (AliAODHandler*)((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
302  if (aodHandler->GetExtensions()) {
303  AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
304  AliAODEvent *aodFromExt = ext->GetAOD();
305  D0TracksFromFriendFile = (TClonesArray*)aodFromExt->GetList()->FindObject("D0toKpi");
306  }
307  } else {
308  D0TracksFromFriendFile = (TClonesArray*)aodEvent->GetList()->FindObject("D0toKpi");
309  }
310 
311  // fix for temporary bug in ESDfilter
312  // the AODs with null vertex pointer didn't pass the PhysSel
313  if (!aodEvent->GetPrimaryVertex() || TMath::Abs(aodEvent->GetMagneticField()) < 0.001) return;
314  fCEvents->Fill(2);
315 
316  // trigger class for PbPb C0SMH-B-NOPF-ALLNOTRD
317  TString trigclass = aodEvent->GetFiredTriggerClasses();
318  if (trigclass.Contains("C0SMH-B-NOPF-ALLNOTRD") || trigclass.Contains("C0SMH-B-NOPF-ALL")) fCEvents->Fill(5);
319 
320  if (!fCuts->IsEventSelected(aodEvent))
321  {
322  if (fShowRejection) std::cout << "Event rejected by code: " << fCuts->GetWhyRejection() << std::endl;
323  if (fCuts->GetWhyRejection() == 6) // rejected for Z vertex
324  {
325  fCEvents->Fill(6);
326  return;
327  }
328  }
329 
330  Bool_t isEvSel = fCuts->IsEventSelected(aodEvent);
331  if (!isEvSel) return;
332  fCEvents->Fill(3);
333 
334  //get the magnetic field
335  Double_t bz = (Double_t)aodEvent->GetMagneticField();
336 
337  // AOD primary vertex
338  AliAODVertex *primaryVertex = (AliAODVertex*)aodEvent->GetPrimaryVertex();
339  if (!primaryVertex) return;
340  if (primaryVertex->GetNContributors() < 1) return;
341  fCEvents->Fill(4);
342 
343  if (!D0TracksFromFriendFile)
344  {
345  AliInfo("Could not find array of HF vertices, skipping the event");
346  return;
347  }
348  else AliDebug(2, Form("Found %d vertices", D0TracksFromFriendFile->GetEntriesFast()));
349 
350  AliAODMCHeader *mcHeader = 0;
351  if (fUseMCInfo)
352  {
353  mcHeader = (AliAODMCHeader*)aodEvent->GetList()->FindObject(AliAODMCHeader::StdBranchName());
354  if (!mcHeader) {
355  printf(" MC header branch not found!\n");
356  return;
357  }
358  }
359 
360 
361  //==================================================================================
362  // EVENT INITIALIZATION - end
363  //==================================================================================
364  // BPlus LOSS BY CUTS TRACKER - start
365  //==================================================================================
366 
367  TClonesArray *mcTrackArray = nullptr;
368  if (fUseMCInfo) mcTrackArray = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(AliAODMCParticle::StdBranchName()));
369  if (fUseMCInfo && !mcTrackArray) return;
370 
371  //Here we create an array and vectors that we use to look how many BPluss can be reconstructed after each cut
372  TMatrix * BPlustoD0PiLabelMatrix = new TMatrix(0, 5);
373 
374  //we fill the array with all BPlus->D0Pi tracks
375  if (fUseMCInfo) {
376  BPlustoD0PiSignalTracksInMC(mcTrackArray, aodEvent, BPlustoD0PiLabelMatrix, fOutputBPlusMC);
377  }
378 
379  //==================================================================================
380  // BPlus LOSS BY CUTS TRACKER - end
381  //==================================================================================
382  // PARTICLE SELECTION LOOP - start
383  //==================================================================================
384  //
385  // Here we select and reconstruct the particles for the BPlus->D*Pion decay.
386  //
387  //==================================================================================
388 
389 
390  BPlusPionSelection(aodEvent, primaryVertex, bz, mcTrackArray, BPlustoD0PiLabelMatrix, mcHeader);
391  D0Selection(aodEvent, primaryVertex, bz, mcTrackArray, BPlustoD0PiLabelMatrix, D0TracksFromFriendFile, mcHeader);
392  BPlusSelection(aodEvent, primaryVertex, bz, mcTrackArray, BPlustoD0PiLabelMatrix, D0TracksFromFriendFile, mcHeader);
393 
394  // Clear arrays and memory management:
395  fD0Tracks->erase(fD0Tracks->begin(), fD0Tracks->end());
396  fBPlusPionTracks->erase(fBPlusPionTracks->begin(), fBPlusPionTracks->end());
397 
398  delete BPlustoD0PiLabelMatrix; BPlustoD0PiLabelMatrix = NULL;
399 
400  //==================================================================================
401  // PARTICLE SELECTION LOOP - end
402  //==================================================================================
403 
404  PostData(1, fOutput);
405  PostData(3, fOutputD0FirstDaughter);
406  PostData(4, fOutputD0SecondDaughter);
407  PostData(5, fOutputBPlusPion);
408  PostData(6, fOutputD0);
409  PostData(7, fOutputBPlus);
410  PostData(8, fOutputD0_D0Pt);
411  PostData(9, fOutputBPlusMC);
412 
413 
414  //==================================================================================
415  // USER EXECUTION FUNCTION - end
416  //==================================================================================
417 
418 }
419 //___________________________________ terminate ___________________________
424 
425  //Info("Terminate","");
426  AliAnalysisTaskSE::Terminate();
427 
428  fOutput = dynamic_cast<TList*> (GetOutputData(1));
429  if (!fOutput) {
430  printf("ERROR: fOutput not available\n");
431  return;
432  }
433 
434  fCEvents = dynamic_cast<TH1F*>(fOutput->FindObject("fCEvents"));
435 
436  fListCuts = dynamic_cast<TList*> (GetOutputData(2));
437  if (!fListCuts) {
438  printf("ERROR: fListCuts not available\n");
439  return;
440  }
441  fOutputD0FirstDaughter = dynamic_cast<TList*> (GetOutputData(3));
442  if (!fOutputD0FirstDaughter) {
443  printf("ERROR: fOutputD0FirstDaughter not available\n");
444  return;
445  }
446  fOutputD0SecondDaughter = dynamic_cast<TList*> (GetOutputData(4));
448  printf("ERROR: fOutputD0SecondDaughter not available\n");
449  return;
450  }
451  fOutputBPlusPion = dynamic_cast<TList*> (GetOutputData(5));
452  if (!fOutputBPlusPion) {
453  printf("ERROR: fOutputBPlusPion not available\n");
454  return;
455  }
456  fOutputD0 = dynamic_cast<TList*> (GetOutputData(6));
457  if (!fOutputD0) {
458  printf("ERROR: fOutputD0 not available\n");
459  return;
460  }
461  fOutputBPlus = dynamic_cast<TList*> (GetOutputData(7));
462  if (!fOutputBPlus) {
463  printf("ERROR: fOutputBPlus not available\n");
464  return;
465  }
466  fOutputD0_D0Pt = dynamic_cast<TList*> (GetOutputData(8));
467  if (!fOutputD0_D0Pt) {
468  printf("ERROR: fOutputD0_D0Pt not available\n");
469  return;
470  }
471  fOutputBPlusMC = dynamic_cast<TList*> (GetOutputData(9));
472  if (!fOutputBPlusMC) {
473  printf("ERROR: fOutputBPlusMC not available\n");
474  return;
475  }
476  return;
477 }
478 
479 //___________________________________________________________________________
482  Info("UserCreateOutputObjects", "CreateOutputObjects of task %s\n", GetName());
483 
484  //slot #1
485  //OpenFile(1);
486  fOutput = new TList();
487  fOutput->SetOwner();
488  fOutput->SetName("chist0");
489 
491  fOutputD0FirstDaughter->SetOwner();
492  fOutputD0FirstDaughter->SetName("listD0Pion");
493 
495  fOutputD0SecondDaughter->SetOwner();
496  fOutputD0SecondDaughter->SetName("listD0Kaon");
497 
498  fOutputBPlusPion = new TList();
499  fOutputBPlusPion->SetOwner();
500  fOutputBPlusPion->SetName("listBPlusPion");
501 
502  fOutputD0 = new TList();
503  fOutputD0->SetOwner();
504  fOutputD0->SetName("listD0");
505 
506  fOutputBPlus = new TList();
507  fOutputBPlus->SetOwner();
508  fOutputBPlus->SetName("listBPlus");
509 
510  fOutputD0_D0Pt = new TList();
511  fOutputD0_D0Pt->SetOwner();
512  fOutputD0_D0Pt->SetName("listD0_D0Pt");
513 
514  fOutputBPlusMC = new TList();
515  fOutputBPlusMC->SetOwner();
516  fOutputBPlusMC->SetName("listBPlusMC");
517 
518  // we prepare vectors that will save the positions of the daughter tracks in the track list during the reconstruction
519  fBPlusPionTracks = new std::vector<Int_t>;
520  fD0Tracks = new std::vector<Int_t>;
521 
522  // we get information on the pt bins
524  fnPtBinLimits = fnPtBins + 1;
526 
530 
531 
532  std::cout << "Nr. of BPlus meson bins: " << fCuts->GetNPtBins() << " limits: " << std::endl;
533  for (int i = 0; i < fnPtBinLimits; ++i)
534  {
535  std::cout << fPtBinLimits[i] << " " << std::endl;
536  }
537  std::cout << std::endl;
538  std::cout << "Nr. of D0 meson bins: " << fCuts->GetNPtBinsD0forD0ptbin() << " limits: " << std::endl;
539  for (int i = 0; i < fnPtBinsD0forD0ptbinLimits; ++i)
540  {
541  std::cout << fPtBinLimitsD0forD0ptbin[i] << " " << std::endl;
542  }
543  std::cout << std::endl;
544 
545 
546  fListCuts = new TList();
547  fListCuts->SetOwner();
548  fListCuts->SetName("Cuts");
550  // Post the data
551  fListCuts->Add(copyfCuts);
552 
553  // define histograms
555 
556  PostData(1, fOutput);
557  PostData(2, fListCuts);
558  PostData(3, fOutputD0FirstDaughter);
559  PostData(4, fOutputD0SecondDaughter);
560  PostData(5, fOutputBPlusPion);
561  PostData(6, fOutputD0);
562  PostData(7, fOutputBPlus);
563  PostData(8, fOutputD0_D0Pt);
564  PostData(9, fOutputBPlusMC);
565 
566  return;
567 }
568 //___________________________________ histograms _______________________________________
571 
572 
573  fCEvents = new TH1F("fCEvents", "conter", 13, 0, 13);
574  fCEvents->SetStats(kTRUE);
575  fCEvents->GetXaxis()->SetTitle("1");
576  fCEvents->GetYaxis()->SetTitle("counts");
577  fCEvents->GetXaxis()->SetBinLabel(2, "no. of events");
578  fCEvents->GetXaxis()->SetBinLabel(3, "good prim vtx and B field");
579  fCEvents->GetXaxis()->SetBinLabel(4, "no event selected");
580  fCEvents->GetXaxis()->SetBinLabel(5, "no vtx contributors");
581  fCEvents->GetXaxis()->SetBinLabel(6, "trigger for PbPb");
582  fCEvents->GetXaxis()->SetBinLabel(7, "no z vtx");
583  fCEvents->GetXaxis()->SetBinLabel(8, "...");
584  fCEvents->GetXaxis()->SetBinLabel(12, "no. of D0 fail to be rec");
585  fOutput->Add(fCEvents);
586 
587  //====================================================
588 
589  TString name_mc_BPlus_pt = "mc_BPlus_pt";
590  TH1F* hist_mc_BPlus_pt = new TH1F(name_mc_BPlus_pt.Data(), "Pt monte carlo BPlus in BPlus->D*#pi; p_{T} [GeV/c]; Entries", 400, 0, 20);
591  hist_mc_BPlus_pt->Sumw2();
592  hist_mc_BPlus_pt->SetLineColor(6);
593  hist_mc_BPlus_pt->SetMarkerStyle(20);
594  hist_mc_BPlus_pt->SetMarkerSize(0.6);
595  hist_mc_BPlus_pt->SetMarkerColor(6);
596  TH1F* histogram_mc_BPlus_pt = (TH1F*)hist_mc_BPlus_pt->Clone();
597  fOutputBPlusMC->Add(histogram_mc_BPlus_pt);
598 
599  TString name_mc_BPlus_pion_pt = "mc_BPlus_pion_pt";
600  TH1F* hist_mc_BPlus_pion_pt = new TH1F(name_mc_BPlus_pion_pt.Data(), "Pt monte carlo pion of BPlus in BPlus->D*#pi; p_{T} [GeV/c]; Entries", 400, 0, 20);
601  hist_mc_BPlus_pion_pt->Sumw2();
602  hist_mc_BPlus_pion_pt->SetLineColor(6);
603  hist_mc_BPlus_pion_pt->SetMarkerStyle(20);
604  hist_mc_BPlus_pion_pt->SetMarkerSize(0.6);
605  hist_mc_BPlus_pion_pt->SetMarkerColor(6);
606  TH1F* histogram_mc_BPlus_pion_pt = (TH1F*)hist_mc_BPlus_pion_pt->Clone();
607  fOutputBPlusMC->Add(histogram_mc_BPlus_pion_pt);
608 
609  TString name_mc_D0_pt = "mc_D0_pt";
610  TH1F* hist_mc_D0_pt = new TH1F(name_mc_D0_pt.Data(), "Pt monte carlo D0 in BPlus->D*#pi; p_{T} [GeV/c]; Entries", 400, 0, 20);
611  hist_mc_D0_pt->Sumw2();
612  hist_mc_D0_pt->SetLineColor(6);
613  hist_mc_D0_pt->SetMarkerStyle(20);
614  hist_mc_D0_pt->SetMarkerSize(0.6);
615  hist_mc_D0_pt->SetMarkerColor(6);
616  TH1F* histogram_mc_D0_pt = (TH1F*)hist_mc_D0_pt->Clone();
617  fOutputBPlusMC->Add(histogram_mc_D0_pt);
618 
619  TString name_mc_D0_pion_pt = "mc_D0_pion_pt";
620  TH1F* hist_mc_D0_pion_pt = new TH1F(name_mc_D0_pion_pt.Data(), "Pt monte carlo pion of D0 in BPlus->D*#pi; p_{T} [GeV/c]; Entries", 400, 0, 20);
621  hist_mc_D0_pion_pt->Sumw2();
622  hist_mc_D0_pion_pt->SetLineColor(6);
623  hist_mc_D0_pion_pt->SetMarkerStyle(20);
624  hist_mc_D0_pion_pt->SetMarkerSize(0.6);
625  hist_mc_D0_pion_pt->SetMarkerColor(6);
626  TH1F* histogram_mc_D0_pion_pt = (TH1F*)hist_mc_D0_pion_pt->Clone();
627  fOutputBPlusMC->Add(histogram_mc_D0_pion_pt);
628 
629  TString name_mc_D0_kaon_pt = "mc_D0_kaon_pt";
630  TH1F* hist_mc_D0_kaon_pt = new TH1F(name_mc_D0_kaon_pt.Data(), "Pt monte carlo kaon of D0 in BPlus->D*#pi; p_{T} [GeV/c]; Entries", 400, 0, 20);
631  hist_mc_D0_kaon_pt->Sumw2();
632  hist_mc_D0_kaon_pt->SetLineColor(6);
633  hist_mc_D0_kaon_pt->SetMarkerStyle(20);
634  hist_mc_D0_kaon_pt->SetMarkerSize(0.6);
635  hist_mc_D0_kaon_pt->SetMarkerColor(6);
636  TH1F* histogram_mc_D0_kaon_pt = (TH1F*)hist_mc_D0_kaon_pt->Clone();
637  fOutputBPlusMC->Add(histogram_mc_D0_kaon_pt);
638 
639  TString name_mc_BPlus_rapidity_true = "mc_BPlus_rapidity_true";
640  TH1F* hist_mc_BPlus_rapidity_true = new TH1F(name_mc_BPlus_rapidity_true.Data(), "rapidity_true monte carlo BPlus in BPlus->D*#pi; Y; Entries", 5000, -20, 20);
641  hist_mc_BPlus_rapidity_true->Sumw2();
642  hist_mc_BPlus_rapidity_true->SetLineColor(6);
643  hist_mc_BPlus_rapidity_true->SetMarkerStyle(20);
644  hist_mc_BPlus_rapidity_true->SetMarkerSize(0.6);
645  hist_mc_BPlus_rapidity_true->SetMarkerColor(6);
646  TH1F* histogram_mc_BPlus_rapidity_true = (TH1F*)hist_mc_BPlus_rapidity_true->Clone();
647  fOutputBPlusMC->Add(histogram_mc_BPlus_rapidity_true);
648 
649  TString name_mc_BPlus_pion_rapidity_true = "mc_BPlus_pion_rapidity_true";
650  TH1F* hist_mc_BPlus_pion_rapidity_true = new TH1F(name_mc_BPlus_pion_rapidity_true.Data(), "rapidity_true monte carlo pion of BPlus in BPlus->D*#pi; Y; Entries", 5000, -20, 20);
651  hist_mc_BPlus_pion_rapidity_true->Sumw2();
652  hist_mc_BPlus_pion_rapidity_true->SetLineColor(6);
653  hist_mc_BPlus_pion_rapidity_true->SetMarkerStyle(20);
654  hist_mc_BPlus_pion_rapidity_true->SetMarkerSize(0.6);
655  hist_mc_BPlus_pion_rapidity_true->SetMarkerColor(6);
656  TH1F* histogram_mc_BPlus_pion_rapidity_true = (TH1F*)hist_mc_BPlus_pion_rapidity_true->Clone();
657  fOutputBPlusMC->Add(histogram_mc_BPlus_pion_rapidity_true);
658 
659  TString name_mc_D0_rapidity_true = "mc_D0_rapidity_true";
660  TH1F* hist_mc_D0_rapidity_true = new TH1F(name_mc_D0_rapidity_true.Data(), "rapidity_true monte carlo D0 in BPlus->D*#pi; Y; Entries", 5000, -20, 20);
661  hist_mc_D0_rapidity_true->Sumw2();
662  hist_mc_D0_rapidity_true->SetLineColor(6);
663  hist_mc_D0_rapidity_true->SetMarkerStyle(20);
664  hist_mc_D0_rapidity_true->SetMarkerSize(0.6);
665  hist_mc_D0_rapidity_true->SetMarkerColor(6);
666  TH1F* histogram_mc_D0_rapidity_true = (TH1F*)hist_mc_D0_rapidity_true->Clone();
667  fOutputBPlusMC->Add(histogram_mc_D0_rapidity_true);
668 
669  TString name_mc_D0_pion_rapidity_true = "mc_D0_pion_rapidity_true";
670  TH1F* hist_mc_D0_pion_rapidity_true = new TH1F(name_mc_D0_pion_rapidity_true.Data(), "rapidity_true monte carlo pion of D0 in BPlus->D*#pi; Y; Entries", 5000, -20, 20);
671  hist_mc_D0_pion_rapidity_true->Sumw2();
672  hist_mc_D0_pion_rapidity_true->SetLineColor(6);
673  hist_mc_D0_pion_rapidity_true->SetMarkerStyle(20);
674  hist_mc_D0_pion_rapidity_true->SetMarkerSize(0.6);
675  hist_mc_D0_pion_rapidity_true->SetMarkerColor(6);
676  TH1F* histogram_mc_D0_pion_rapidity_true = (TH1F*)hist_mc_D0_pion_rapidity_true->Clone();
677  fOutputBPlusMC->Add(histogram_mc_D0_pion_rapidity_true);
678 
679  TString name_mc_D0_kaon_rapidity_true = "mc_D0_kaon_rapidity_true";
680  TH1F* hist_mc_D0_kaon_rapidity_true = new TH1F(name_mc_D0_kaon_rapidity_true.Data(), "rapidity_true monte carlo kaon of D0 in BPlus->D*#pi; Y; Entries", 5000, -20, 20);
681  hist_mc_D0_kaon_rapidity_true->Sumw2();
682  hist_mc_D0_kaon_rapidity_true->SetLineColor(6);
683  hist_mc_D0_kaon_rapidity_true->SetMarkerStyle(20);
684  hist_mc_D0_kaon_rapidity_true->SetMarkerSize(0.6);
685  hist_mc_D0_kaon_rapidity_true->SetMarkerColor(6);
686  TH1F* histogram_mc_D0_kaon_rapidity_true = (TH1F*)hist_mc_D0_kaon_rapidity_true->Clone();
687  fOutputBPlusMC->Add(histogram_mc_D0_kaon_rapidity_true);
688 
689  TString name_mc_BPlus_pseudorapidity_true = "mc_BPlus_pseudorapidity_true";
690  TH1F* hist_mc_BPlus_pseudorapidity_true = new TH1F(name_mc_BPlus_pseudorapidity_true.Data(), "pseudorapidity_true monte carlo BPlus in BPlus->D*#pi; #eta; Entries", 5000, -20, 20);
691  hist_mc_BPlus_pseudorapidity_true->Sumw2();
692  hist_mc_BPlus_pseudorapidity_true->SetLineColor(6);
693  hist_mc_BPlus_pseudorapidity_true->SetMarkerStyle(20);
694  hist_mc_BPlus_pseudorapidity_true->SetMarkerSize(0.6);
695  hist_mc_BPlus_pseudorapidity_true->SetMarkerColor(6);
696  TH1F* histogram_mc_BPlus_pseudorapidity_true = (TH1F*)hist_mc_BPlus_pseudorapidity_true->Clone();
697  fOutputBPlusMC->Add(histogram_mc_BPlus_pseudorapidity_true);
698 
699  TString name_mc_BPlus_pion_pseudorapidity_true = "mc_BPlus_pion_pseudorapidity_true";
700  TH1F* hist_mc_BPlus_pion_pseudorapidity_true = new TH1F(name_mc_BPlus_pion_pseudorapidity_true.Data(), "pseudorapidity_true monte carlo pion of BPlus in BPlus->D*#pi; #eta; Entries", 5000, -20, 20);
701  hist_mc_BPlus_pion_pseudorapidity_true->Sumw2();
702  hist_mc_BPlus_pion_pseudorapidity_true->SetLineColor(6);
703  hist_mc_BPlus_pion_pseudorapidity_true->SetMarkerStyle(20);
704  hist_mc_BPlus_pion_pseudorapidity_true->SetMarkerSize(0.6);
705  hist_mc_BPlus_pion_pseudorapidity_true->SetMarkerColor(6);
706  TH1F* histogram_mc_BPlus_pion_pseudorapidity_true = (TH1F*)hist_mc_BPlus_pion_pseudorapidity_true->Clone();
707  fOutputBPlusMC->Add(histogram_mc_BPlus_pion_pseudorapidity_true);
708 
709  TString name_mc_D0_pseudorapidity_true = "mc_D0_pseudorapidity_true";
710  TH1F* hist_mc_D0_pseudorapidity_true = new TH1F(name_mc_D0_pseudorapidity_true.Data(), "pseudorapidity_true monte carlo D0 in BPlus->D*#pi; #eta; Entries", 5000, -20, 20);
711  hist_mc_D0_pseudorapidity_true->Sumw2();
712  hist_mc_D0_pseudorapidity_true->SetLineColor(6);
713  hist_mc_D0_pseudorapidity_true->SetMarkerStyle(20);
714  hist_mc_D0_pseudorapidity_true->SetMarkerSize(0.6);
715  hist_mc_D0_pseudorapidity_true->SetMarkerColor(6);
716  TH1F* histogram_mc_D0_pseudorapidity_true = (TH1F*)hist_mc_D0_pseudorapidity_true->Clone();
717  fOutputBPlusMC->Add(histogram_mc_D0_pseudorapidity_true);
718 
719  TString name_mc_D0_pion_pseudorapidity_true = "mc_D0_pion_pseudorapidity_true";
720  TH1F* hist_mc_D0_pion_pseudorapidity_true = new TH1F(name_mc_D0_pion_pseudorapidity_true.Data(), "pseudorapidity_true monte carlo pion of D0 in BPlus->D*#pi; #eta; Entries", 5000, -20, 20);
721  hist_mc_D0_pion_pseudorapidity_true->Sumw2();
722  hist_mc_D0_pion_pseudorapidity_true->SetLineColor(6);
723  hist_mc_D0_pion_pseudorapidity_true->SetMarkerStyle(20);
724  hist_mc_D0_pion_pseudorapidity_true->SetMarkerSize(0.6);
725  hist_mc_D0_pion_pseudorapidity_true->SetMarkerColor(6);
726  TH1F* histogram_mc_D0_pion_pseudorapidity_true = (TH1F*)hist_mc_D0_pion_pseudorapidity_true->Clone();
727  fOutputBPlusMC->Add(histogram_mc_D0_pion_pseudorapidity_true);
728 
729  TString name_mc_D0_kaon_pseudorapidity_true = "mc_D0_kaon_pseudorapidity_true";
730  TH1F* hist_mc_D0_kaon_pseudorapidity_true = new TH1F(name_mc_D0_kaon_pseudorapidity_true.Data(), "pseudorapidity_true monte carlo kaon of D0 in BPlus->D*#pi; #eta; Entries", 5000, -20, 20);
731  hist_mc_D0_kaon_pseudorapidity_true->Sumw2();
732  hist_mc_D0_kaon_pseudorapidity_true->SetLineColor(6);
733  hist_mc_D0_kaon_pseudorapidity_true->SetMarkerStyle(20);
734  hist_mc_D0_kaon_pseudorapidity_true->SetMarkerSize(0.6);
735  hist_mc_D0_kaon_pseudorapidity_true->SetMarkerColor(6);
736  TH1F* histogram_mc_D0_kaon_pseudorapidity_true = (TH1F*)hist_mc_D0_kaon_pseudorapidity_true->Clone();
737  fOutputBPlusMC->Add(histogram_mc_D0_kaon_pseudorapidity_true);
738 
740  {
743  Int_t nCutOptimizationBins = TMath::Power(nCuts,nVariables);
744 
745  for (Int_t k = 0; k < fnPtBins; ++k)
746  {
747  TString ptBinMother = "";
748  ptBinMother += "_ptbin_";
749  ptBinMother += fPtBinLimits[k];
750  ptBinMother += "_to_";
751  ptBinMother += fPtBinLimits[k+1];
752 
753  TString name_cut_optimization_signal = "cut_optimization_signal";
754  name_cut_optimization_signal += ptBinMother;
755  TH1F* hist_cut_optimization_signal = new TH1F(name_cut_optimization_signal.Data(), "Total signal for different cuts; Cut number; Entries", nCutOptimizationBins, 0, nCutOptimizationBins);
756  hist_cut_optimization_signal->Sumw2();
757  hist_cut_optimization_signal->SetLineColor(6);
758  hist_cut_optimization_signal->SetMarkerStyle(20);
759  hist_cut_optimization_signal->SetMarkerSize(0.6);
760  hist_cut_optimization_signal->SetMarkerColor(6);
761  TH1F* histogram_cut_optimization_signal = (TH1F*)hist_cut_optimization_signal->Clone();
762  fOutputBPlusMC->Add(histogram_cut_optimization_signal);
763 
764  TString name_cut_optimization_background = "cut_optimization_background";
765  name_cut_optimization_background += ptBinMother;
766  TH1F* hist_cut_optimization_background = new TH1F(name_cut_optimization_background.Data(), "Total background for different cuts; Cut number; Entries", nCutOptimizationBins, 0, nCutOptimizationBins);
767  hist_cut_optimization_background->Sumw2();
768  hist_cut_optimization_background->SetLineColor(6);
769  hist_cut_optimization_background->SetMarkerStyle(20);
770  hist_cut_optimization_background->SetMarkerSize(0.6);
771  hist_cut_optimization_background->SetMarkerColor(6);
772  TH1F* histogram_cut_optimization_background = (TH1F*)hist_cut_optimization_background->Clone();
773  fOutputBPlusMC->Add(histogram_cut_optimization_background);
774  }
775  }
776 
777 
778  //==================================================
779 
780  TString name_BPluss_in_analysis = "BPlus_in_analysis";
781  TH1F* hist_BPluss_in_analysis = new TH1F(name_BPluss_in_analysis.Data(), "Number of BPluss to kpipipi in the Analysis; Entries", 10, 0, 10);
782  hist_BPluss_in_analysis->Sumw2();
783  hist_BPluss_in_analysis->SetLineColor(6);
784  hist_BPluss_in_analysis->SetMarkerStyle(20);
785  hist_BPluss_in_analysis->SetMarkerSize(0.6);
786  hist_BPluss_in_analysis->SetMarkerColor(6);
787  hist_BPluss_in_analysis->SetStats(kTRUE);
788  hist_BPluss_in_analysis->GetXaxis()->SetBinLabel(1, "no. of BPlus");
789  hist_BPluss_in_analysis->GetXaxis()->SetBinLabel(2, "no. of BPlus to kpipi");
790  hist_BPluss_in_analysis->GetXaxis()->SetBinLabel(3, "no. with all tracks in event");
791  hist_BPluss_in_analysis->GetXaxis()->SetBinLabel(4, "no. ...");
792  hist_BPluss_in_analysis->GetXaxis()->SetBinLabel(5, "no. ...");
793  hist_BPluss_in_analysis->GetXaxis()->SetBinLabel(6, "no. ...");
794  hist_BPluss_in_analysis->GetXaxis()->SetBinLabel(7, "no. ...");
795  hist_BPluss_in_analysis->GetXaxis()->SetBinLabel(8, "no. ...");
796  TH1F* hist_BPluss_in_analysis_mc = (TH1F*)hist_BPluss_in_analysis->Clone();
797  fOutputBPlusMC->Add(hist_BPluss_in_analysis_mc);
798 
799  TString name_BPlus_per_bin = "BPlus_per_bin";
800  TH1F* hist_BPlus_per_bin = new TH1F(name_BPlus_per_bin.Data(), "Number of BPlus to kpipi in the Analysis per bin; Entries", fnPtBins, 0, fnPtBins);
801  for (Int_t i = 0; i < fnPtBins; ++i)
802  {
803  TString bin_name = "";
804  bin_name += fPtBinLimits[i];
805  bin_name += "-";
806  bin_name += fPtBinLimits[i + 1];
807  hist_BPlus_per_bin->GetXaxis()->SetBinLabel(i + 1, bin_name);
808  }
809  TH1F* hist_BPlus_per_bin_mc = (TH1F*)hist_BPlus_per_bin->Clone();
810  fOutputBPlusMC->Add(hist_BPlus_per_bin_mc);
811 
812  TString name_BPlus_per_bin_in_Acc = "BPlus_per_bin_in_Acc";
813  TH1F* hist_BPlus_per_bin_in_Acc = new TH1F(name_BPlus_per_bin_in_Acc.Data(), "Number of BPlus to kpipi in the Analysis per bin with all daughters in acceptance; Entries", fnPtBins, 0, fnPtBins);
814  for (Int_t i = 0; i < fnPtBins; ++i)
815  {
816  TString bin_name = "";
817  bin_name += fPtBinLimits[i];
818  bin_name += "-";
819  bin_name += fPtBinLimits[i + 1];
820  hist_BPlus_per_bin_in_Acc->GetXaxis()->SetBinLabel(i + 1, bin_name);
821  }
822  TH1F* hist_BPlus_per_bin_in_Acc_mc = (TH1F*)hist_BPlus_per_bin_in_Acc->Clone();
823  fOutputBPlusMC->Add(hist_BPlus_per_bin_in_Acc_mc);
824 
825  //======================================================================================================================================================
826 
827  //we make the histograms for the Pions and Kaon
828  for (Int_t i = 0; i < 3; i++) {
829 
830  TString add_name = "";
831  TList * listout;
832  if (i == 0) listout = fOutputD0FirstDaughter;
833  if (i == 1) listout = fOutputD0SecondDaughter;
834  if (i == 2) listout = fOutputBPlusPion;
835 
836  for (Int_t j = 0; j < 6; j++) {
837  if (j == 0) add_name = "";
838  if (j == 1) add_name = "Signal";
839  if (j == 2) add_name = "Cut";
840  if (j == 3) add_name = "SignalCut";
841  if (j == 4) add_name = "Result";
842  if (j == 5) add_name = "SignalResult";
843 
844  TString name_Histogram = "";
845  TString discription_Histogram = "";
846  Int_t numberOfBins = 0;
847  Double_t lowerBound = 0.0;
848  Double_t upperBound = 0.0;
849 
850  for (Int_t k = 0; k < 10; ++k)
851  {
852  if (k == 0) {name_Histogram = "ptTrack"; discription_Histogram = "pt track; p_{T} [GeV/c]; Entries"; numberOfBins = 600; lowerBound = 0; upperBound = 30;}
853  if (k == 1) {name_Histogram = "momentumTrack"; discription_Histogram = "momentum track; p [GeV/c]; Entries"; numberOfBins = 600; lowerBound = 0; upperBound = 30;}
854  if (k == 2) {name_Histogram = "numberOfITS"; discription_Histogram = "Number of ITS clusters track; [#]; Entries"; numberOfBins = 10; lowerBound = -0.5; upperBound = 9.5;}
855  if (k == 3) {name_Histogram = "numberOfTPC"; discription_Histogram = "Number of TPC clusters track; [#]; Entries"; numberOfBins = 601; lowerBound = -0.5; upperBound = 600.5;}
856  if (k == 4) {name_Histogram = "pointsOnITS"; discription_Histogram = "Number of ITS clusters track per layer; [#]; Entries"; numberOfBins = 10; lowerBound = -0.5; upperBound = 9.5;}
857  if (k == 5) {name_Histogram = "nSigmaTPC"; discription_Histogram = "n sigma TPC for track PID; sigma; Entries"; numberOfBins = 500; lowerBound = -5; upperBound = 5;}
858  if (k == 6) {name_Histogram = "nSigmaTOF"; discription_Histogram = "n sigma TOF for track PID; sigma; Entries"; numberOfBins = 500; lowerBound = -5; upperBound = 5;}
859  if (k == 7) {name_Histogram = "nSigmaTPCandTOF"; discription_Histogram = "n sigma TPC and TOF for track PID; a.u.; Entries"; numberOfBins = 1000; lowerBound = 0; upperBound = 10;}
860  if (k == 8) {name_Histogram = "impactParameter"; discription_Histogram = "Impact Parameter track; [cm]; Entries"; numberOfBins = 2000; lowerBound = 0; upperBound = 0.5;}
861  if (k == 9) {name_Histogram = "EtaTrack"; discription_Histogram = "Eta Track; Entries"; numberOfBins = 1000; lowerBound = -3; upperBound = 3;}
862 
863  name_Histogram += add_name;
864  TH1F* histogram = new TH1F(name_Histogram.Data(), discription_Histogram.Data(), numberOfBins, lowerBound, upperBound);
865  histogram->Sumw2();
866  if (j % 2 == 0) histogram->SetLineColor(6);
867  if (j % 2 == 1) histogram->SetLineColor(4);
868  histogram->SetMarkerStyle(20);
869  histogram->SetMarkerSize(0.6);
870  if (j % 2 == 0) histogram->SetMarkerColor(6);
871  if (j % 2 == 1) histogram->SetMarkerColor(4);
872  TH1F* histogram_Clone = (TH1F*)histogram->Clone();
873  listout->Add(histogram_Clone);
874  fDaughterHistogramArray[i][j][k] = histogram_Clone;
875  }
876 
877  TString numberofparticlesperevent = "numberofparticlesperevent";
878  numberofparticlesperevent += add_name;
879  TH1F* hist_numberofparticlesperevent = new TH1F(numberofparticlesperevent.Data(), "Number of particles per event; number of particles in one event; Entries", 100, 0, 100);
880  hist_numberofparticlesperevent->Sumw2();
881  hist_numberofparticlesperevent->SetLineColor(6);
882  hist_numberofparticlesperevent->SetMarkerStyle(20);
883  hist_numberofparticlesperevent->SetMarkerSize(0.6);
884  hist_numberofparticlesperevent->SetMarkerColor(6);
885  TH1F* histogram_numberofparticlesperevent = (TH1F*)hist_numberofparticlesperevent->Clone();
886  listout->Add(histogram_numberofparticlesperevent);
887  fDaughterHistogramArray[i][j][10] = histogram_numberofparticlesperevent;
888  }
889 
890  TH1F * effectOfCuts = new TH1F("effectOfCuts", "Removal counter", 18, 0, 18);
891  effectOfCuts->SetStats(kTRUE);
892  effectOfCuts->GetXaxis()->SetTitle("Cut number");
893  effectOfCuts->GetYaxis()->SetTitle("Particles cut");
894  effectOfCuts->GetXaxis()->SetBinLabel(1, "total");
895  effectOfCuts->GetXaxis()->SetBinLabel(2, "1");
896  effectOfCuts->GetXaxis()->SetBinLabel(3, "2");
897  effectOfCuts->GetXaxis()->SetBinLabel(4, "3");
898  effectOfCuts->GetXaxis()->SetBinLabel(5, "4");
899  effectOfCuts->GetXaxis()->SetBinLabel(6, "5");
900  effectOfCuts->GetXaxis()->SetBinLabel(7, "6");
901  effectOfCuts->GetXaxis()->SetBinLabel(8, "7");
902  effectOfCuts->GetXaxis()->SetBinLabel(9, "8");
903  effectOfCuts->GetXaxis()->SetBinLabel(10, "9");
904  effectOfCuts->GetXaxis()->SetBinLabel(11, "10");
905  effectOfCuts->GetXaxis()->SetBinLabel(12, "11");
906  effectOfCuts->GetXaxis()->SetBinLabel(13, "12");
907  effectOfCuts->GetXaxis()->SetBinLabel(14, "13");
908  effectOfCuts->GetXaxis()->SetBinLabel(15, "14");
909  effectOfCuts->GetXaxis()->SetBinLabel(16, "15");
910  effectOfCuts->GetXaxis()->SetBinLabel(17, "16");
911  effectOfCuts->GetXaxis()->SetBinLabel(18, "17");
912  listout->Add(effectOfCuts);
913  fDaughterHistogramArrayExtra[i][0] = effectOfCuts;
914 
915  TH1F * effectOfCutsMC = new TH1F("effectOfCutsMC", "Removal counter", 18, 0, 18);
916  effectOfCutsMC->SetStats(kTRUE);
917  effectOfCutsMC->GetXaxis()->SetTitle("Cut number");
918  effectOfCutsMC->GetYaxis()->SetTitle("Particles cut");
919  effectOfCutsMC->GetXaxis()->SetBinLabel(1, "total");
920  effectOfCutsMC->GetXaxis()->SetBinLabel(2, "1");
921  effectOfCutsMC->GetXaxis()->SetBinLabel(3, "2");
922  effectOfCutsMC->GetXaxis()->SetBinLabel(4, "3");
923  effectOfCutsMC->GetXaxis()->SetBinLabel(5, "4");
924  effectOfCutsMC->GetXaxis()->SetBinLabel(6, "5");
925  effectOfCutsMC->GetXaxis()->SetBinLabel(7, "6");
926  effectOfCutsMC->GetXaxis()->SetBinLabel(8, "7");
927  effectOfCutsMC->GetXaxis()->SetBinLabel(9, "8");
928  effectOfCutsMC->GetXaxis()->SetBinLabel(10, "9");
929  effectOfCutsMC->GetXaxis()->SetBinLabel(11, "10");
930  effectOfCutsMC->GetXaxis()->SetBinLabel(12, "11");
931  effectOfCutsMC->GetXaxis()->SetBinLabel(13, "12");
932  effectOfCutsMC->GetXaxis()->SetBinLabel(14, "13");
933  effectOfCutsMC->GetXaxis()->SetBinLabel(15, "14");
934  effectOfCutsMC->GetXaxis()->SetBinLabel(16, "15");
935  effectOfCutsMC->GetXaxis()->SetBinLabel(17, "16");
936  effectOfCutsMC->GetXaxis()->SetBinLabel(18, "17");
937  listout->Add(effectOfCutsMC);
938  fDaughterHistogramArrayExtra[i][1] = effectOfCutsMC;
939 
940  TString name_particle_pdg = "particle_pdg";
941  TH1F* hist_particle_pdg = new TH1F(name_particle_pdg.Data(), "Pdg code particle; pdg code; Entries", 2000, -0.5, 1999.5);
942  hist_particle_pdg->Sumw2();
943  hist_particle_pdg->SetLineColor(6);
944  hist_particle_pdg->SetMarkerStyle(20);
945  hist_particle_pdg->SetMarkerSize(0.6);
946  hist_particle_pdg->SetMarkerColor(6);
947  TH1F* histogram_particle_pdg = (TH1F*)hist_particle_pdg->Clone();
948  listout->Add(histogram_particle_pdg);
949  fDaughterHistogramArrayExtra[i][2] = histogram_particle_pdg;
950 
951  TString name_particle_mother_pdg = "particle_mother_pdg";
952  TH1F* hist_particle_mother_pdg = new TH1F(name_particle_mother_pdg.Data(), "Pdg code particle mother; pdg code; Entries", 2000, -0.5, 1999.5);
953  hist_particle_mother_pdg->Sumw2();
954  hist_particle_mother_pdg->SetLineColor(6);
955  hist_particle_mother_pdg->SetMarkerStyle(20);
956  hist_particle_mother_pdg->SetMarkerSize(0.6);
957  hist_particle_mother_pdg->SetMarkerColor(6);
958  TH1F* histogram_particle_mother_pdg = (TH1F*)hist_particle_mother_pdg->Clone();
959  listout->Add(histogram_particle_mother_pdg);
960  fDaughterHistogramArrayExtra[i][3] = histogram_particle_mother_pdg;
961 
962  TString name_ptBPlus_vs_ptTrack = "ptBPlus_vs_ptTrackBackground";
963  TH2F* hist_ptBPlus_vs_ptTrack = new TH2F(name_ptBPlus_vs_ptTrack.Data(), "Pt BPlus vs Pt ; p_{T} BPlus [GeV/c]; p_{T} track [GeV/c]", 100, 0, 30, 100, 0, 30);
964  hist_ptBPlus_vs_ptTrack->Sumw2();
965  hist_ptBPlus_vs_ptTrack->SetLineColor(6);
966  hist_ptBPlus_vs_ptTrack->SetMarkerStyle(20);
967  hist_ptBPlus_vs_ptTrack->SetMarkerSize(0.6);
968  hist_ptBPlus_vs_ptTrack->SetMarkerColor(6);
969  TH2F* histogram_ptBPlus_vs_ptTrack = (TH2F*)hist_ptBPlus_vs_ptTrack->Clone();
970  listout->Add(histogram_ptBPlus_vs_ptTrack);
971  fDaughterHistogramArray2D[i][4] = histogram_ptBPlus_vs_ptTrack;
972 
973  TString name_ptBPlus_vs_ptTrackSignal = "ptBPlus_vs_ptTrackSignal";
974  TH2F* hist_ptBPlus_vs_ptTrackSignal = new TH2F(name_ptBPlus_vs_ptTrackSignal.Data(), "Pt BPlus vs Pt ; p_{T} BPlus [GeV/c]; p_{T} track [GeV/c]", 100, 0, 30, 100, 0, 30);
975  hist_ptBPlus_vs_ptTrackSignal->Sumw2();
976  hist_ptBPlus_vs_ptTrackSignal->SetLineColor(4);
977  hist_ptBPlus_vs_ptTrackSignal->SetMarkerStyle(20);
978  hist_ptBPlus_vs_ptTrackSignal->SetMarkerSize(0.6);
979  hist_ptBPlus_vs_ptTrackSignal->SetMarkerColor(6);
980  TH2F* histogram_ptBPlus_vs_ptTrackSignal = (TH2F*)hist_ptBPlus_vs_ptTrackSignal->Clone();
981  listout->Add(histogram_ptBPlus_vs_ptTrackSignal);
982  fDaughterHistogramArray2D[i][5] = histogram_ptBPlus_vs_ptTrackSignal;
983  }
984 
985  //we make the histograms for the reconstructed particles
986  for (Int_t i = 0; i < 3; i++) {
987 
988  TString add_name = "";
989  TList * listout;
990  Int_t nHistogramSets = 0;
991  if (i == 0) {listout = fOutputD0; nHistogramSets = 6 + 2 * fnPtBins;}
992  if (i == 1) {listout = fOutputBPlus; nHistogramSets = 6 + 2 * fnPtBins;}
993  if (i == 2) {listout = fOutputD0_D0Pt; nHistogramSets = 2 * fnPtBinsD0forD0ptbin;}
994 
995 
996  for (Int_t j = 0; j < nHistogramSets; j++) {
997  if (i < 2)
998  {
999  if (j == 0) add_name = "";
1000  if (j == 1) add_name = "Signal";
1001  if (j == 2) add_name = "Cut";
1002  if (j == 3) add_name = "SignalCut";
1003  if (j == 4) add_name = "Result";
1004  if (j == 5) add_name = "SignalResult";
1005  if (j % 2 == 0 && j > 5) {add_name = "_ptbin_"; add_name += fPtBinLimits[(j - 6) / 2]; add_name += "_to_"; add_name += fPtBinLimits[(j - 6) / 2 + 1];}
1006  if (j % 2 == 1 && j > 5) {add_name = "Signal_ptbin_"; add_name += fPtBinLimits[(j - 7) / 2]; add_name += "_to_"; add_name += fPtBinLimits[(j - 7) / 2 + 1];}
1007  }
1008  if (i == 2)
1009  {
1010  if (j % 2 == 0) {add_name = "_ptbin_"; add_name += fPtBinLimitsD0forD0ptbin[j / 2]; add_name += "_to_"; add_name += fPtBinLimitsD0forD0ptbin[1 + j / 2];}
1011  if (j % 2 == 1) {add_name = "Signal_ptbin_"; add_name += fPtBinLimitsD0forD0ptbin[(j - 1) / 2]; add_name += "_to_"; add_name += fPtBinLimitsD0forD0ptbin[1 + (j - 1) / 2];}
1012  }
1013 
1014 
1015  TString name_Histogram = "";
1016  TString discription_Histogram = "";
1017  Int_t numberOfBins = 0;
1018  Double_t lowerBound = 0.0;
1019  Double_t upperBound = 0.0;
1020  Int_t numberOfBinsTwo = 0;
1021  Double_t lowerBoundTwo = 0.0;
1022  Double_t upperBoundTwo = 0.0;
1023 
1024  for (Int_t k = 0; k < 45; ++k)
1025  {
1026  if (k == 0) {name_Histogram = "ptMother"; discription_Histogram = "pt mother; p_{T} [GeV/c]; Entries"; numberOfBins = 300; lowerBound = 0; upperBound = 30;}
1027  if (k == 1) {name_Histogram = "ptFirstDaughter"; discription_Histogram = "pt first daughter; p_{T} [GeV/c]; Entries"; numberOfBins = 300; lowerBound = 0; upperBound = 30;}
1028  if (k == 2) {name_Histogram = "ptSecondDaughter"; discription_Histogram = "pt second daughter; p_{T} [GeV/c]; Entries"; numberOfBins = 300; lowerBound = 0; upperBound = 30;}
1029  if (k == 3) {name_Histogram = "etaMother"; discription_Histogram = "eta mother; #eta; Entries"; numberOfBins = 100; lowerBound = -2; upperBound = 2;}
1030  if (k == 4) {name_Histogram = "phiMother"; discription_Histogram = "phi mother; #phi; Entries"; numberOfBins = 25; lowerBound = 0; upperBound = 2 * TMath::Pi();}
1031  if (k == 5) {name_Histogram = "d0Mother"; discription_Histogram = "d0 mother; [cm]; Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 1.0;}
1032  if (k == 6) {name_Histogram = "d0FirstDaughter"; discription_Histogram = "d0 first daughter; [cm]; Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 1;}
1033 
1034  if (k == 7) {name_Histogram = "d0SecondDaughter"; discription_Histogram = "d0 second daughter; [cm]; Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 1;}
1035 
1036  if (k == 8) {name_Histogram = "pointingAngleMother"; discription_Histogram = "pointing angle; [Cos(#theta)]; Entries"; numberOfBins = 100; lowerBound = -1; upperBound = 1;}
1037  if (k == 9) {name_Histogram = "impactProduct"; discription_Histogram = "impact product; [cm^{2}]; Entries"; numberOfBins = 500; lowerBound = -0.01; upperBound = 0.01;}
1038  if (k == 10) {name_Histogram = "impactProductXY"; discription_Histogram = "impact product XY; [cm^{2}]; Entries"; numberOfBins = 200; lowerBound = 0; upperBound = 0.5;}
1039  if (k == 11) {name_Histogram = "invariantMassMother"; discription_Histogram = "mass mother candidate; m [GeV/c^{2}]; Entries"; numberOfBins = 10000; lowerBound = 0; upperBound = 10;}
1040  if (k == 12) {name_Histogram = "deltaMassMother"; discription_Histogram = "mass mother candidate; m [GeV/c^{2}]; Entries"; numberOfBins = 10000; lowerBound = 0; upperBound = 10;}
1041  if (k == 13) {name_Histogram = "dcaMother"; discription_Histogram = "dca mother; distance [cm]; Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 0.25;}
1042  if (k == 14) {name_Histogram = "vertexDistance"; discription_Histogram = "vertex distance between mother and primary vertex; distance [cm]; Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 1;}
1043  if (k == 15) {name_Histogram = "normDecayLength"; discription_Histogram = "Normalized decay length w.r.t primary vertex; [cm]; Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 50;}
1044  if (k == 16) {name_Histogram = "pseudoProperDecayTime"; discription_Histogram = "Pseudo Proper Decay Time w.r.t primary vertex; [a.u.]; Entries"; numberOfBins = 1000; lowerBound = -10; upperBound = 10;}
1045  if (k == 17) {name_Histogram = "DecayTime"; discription_Histogram = "Decay Time w.r.t primary vertex; [a.u.]; Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 0.00000001;}
1046  if (k == 18) {name_Histogram = "normDecayTime"; discription_Histogram = "Normalized Decay Time w.r.t primary vertex; [a.u.]; Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 0.0000001;}
1047  if (k == 19) {name_Histogram = "angleMotherFirstDaughter"; discription_Histogram = "flight angle mother and first daughter; [Cos(#phi)]; Entries"; numberOfBins = 100; lowerBound = -1; upperBound = 1;}
1048  if (k == 20) {name_Histogram = "angleMotherSecondDaughter"; discription_Histogram = "flight angle mother and second daughter; [Cos(#phi)]; Entries"; numberOfBins = 100; lowerBound = 0.5; upperBound = 1;}
1049  if (k == 21) {name_Histogram = "angleBetweenBothDaughters"; discription_Histogram = "angle between both daughters; [Cos(#phi)]; Entries"; numberOfBins = 100; lowerBound = -1; upperBound = 1;}
1050  if (k == 22) {name_Histogram = "cosThetaStar"; discription_Histogram = "cosThetaStar; [Cos(#theta*)]; Entries"; numberOfBins = 200; lowerBound = -2; upperBound = 2;}
1051  if (k == 23) {name_Histogram = "vertexX"; discription_Histogram = "Vertex position; [cm]; Entries"; numberOfBins = 500; lowerBound = -5; upperBound = 5;}
1052  if (k == 24) {name_Histogram = "vertexY"; discription_Histogram = "Vertex position; [cm]; Entries"; numberOfBins = 500; lowerBound = -5; upperBound = 5;}
1053  if (k == 25) {name_Histogram = "vertexZ"; discription_Histogram = "Vertex position; [cm]; Entries"; numberOfBins = 500; lowerBound = -20; upperBound = 20;}
1054 
1055 
1056  if (k == 26) {
1057  if (i == 0) {name_Histogram = "pointingAngleToBPlus"; discription_Histogram = "Pointing angle w.r.t. BPlus decay vertex; [Cos(#theta)]; Entries"; numberOfBins = 200; lowerBound = -1; upperBound = 1;}
1058  else continue;
1059  }
1060  if (k == 27) {
1061  if (i == 0) {name_Histogram = "d0MotherToBPlus"; discription_Histogram = "d0 Mother w.r.t. BPlus decay vertex; [cm]; Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 1;}
1062  else continue;
1063  }
1064  if (k == 28) {
1065  if (i == 0) {name_Histogram = "d0FirstDaughterToBPlus"; discription_Histogram = "d0 first daughter w.r.t. BPlus decay vertex; [cm]; Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 1;}
1066  else continue;
1067  }
1068  if (k == 29) {
1069  if (i == 0) {name_Histogram = "d0SecondDaughterToBPlus"; discription_Histogram = "d0 second daughter w.r.t. BPlus decay vertex; [cm]; Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 1;}
1070  else continue;
1071  }
1072  if (k == 30) {
1073  if (i == 0) {name_Histogram = "impactProductToBPlus"; discription_Histogram = "impact product w.r.t. BPlus decay vertex; [cm]; Entries"; numberOfBins = 400; lowerBound = -0.02; upperBound = 0.02;}
1074  else continue;
1075  }
1076  if (k == 31) {
1077  if (i == 0) {name_Histogram = "impactProductXYToBPlus"; discription_Histogram = "impact product XY w.r.t. BPlus decay vertex; [cm^{2}]; Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 0.5;}
1078  else continue;
1079  }
1080  if (k == 32) {
1081  if (i == 0) {name_Histogram = "normDecayLengthToBPlus"; discription_Histogram = "Normalized decay length w.r.t. BPlus decay vertex; [cm]; Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 50;}
1082  else continue;
1083  }
1084  if (k == 33) {
1085  if (i == 0) {name_Histogram = "pseudoProperDecayTimeToBPlus"; discription_Histogram = "Pseudo Proper Decay Time w.r.t BPlus vertex; [a.u.]; Entries"; numberOfBins = 1000; lowerBound = -1; upperBound = 1;}
1086  else continue;
1087  }
1088  if (k == 34) {
1089  if (i == 0) {name_Histogram = "DecayTimeToBPlus"; discription_Histogram = "Decay Time w.r.t BPlus vertex; [a.u.]; Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 0.00000001;}
1090  else continue;
1091  }
1092  if (k == 35) {
1093  if (i == 0) {name_Histogram = "normDecayTimeToBPlus"; discription_Histogram = "Normalized Decay Time w.r.t BPlus vertex; [a.u.]; Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 0.00000001;}
1094  else continue;
1095  }
1096 
1097  if (k == 36) {name_Histogram = "topomaticFirstDaughter"; discription_Histogram = "topomatic d0 first daughter; [cm]; Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 20;}
1098  if (k == 37) {name_Histogram = "topomaticSecondDaughter"; discription_Histogram = "topomatic d0 second daughter; [cm]; Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 20;}
1099  if (k == 38) {name_Histogram = "topomaticMax"; discription_Histogram = "Max topomatic; [cm]; Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 20;}
1100  if (k == 39) {name_Histogram = "topomaticMin"; discription_Histogram = "Min topomatic; [cm]; Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 20;}
1101  if (k == 40) {name_Histogram = "pointingAngleMotherXY"; discription_Histogram = "pointing angle XY; [Cos(#theta)]; Entries"; numberOfBins = 1000; lowerBound = -1; upperBound = 1;}
1102  if (k == 41) {name_Histogram = "vertexDistanceXY"; discription_Histogram = "vertex distance between mother and primary vertex XY; distance [cm]; Entries"; numberOfBins = 1000; lowerBound = 0; upperBound = 10;}
1103  if (k == 42) {name_Histogram = "normDecayLengthXY"; discription_Histogram = "Normalized decay length w.r.t primary vertex XY; [cm]; Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 50;}
1104  if (k == 43) {name_Histogram = "vertexChi2"; discription_Histogram = "#Chi^{2} Vertex; [#Chi^{2}]; Entries"; numberOfBins = 1000; lowerBound = 0; upperBound = 50;}
1105  if (k == 44) {name_Histogram = "vertexChi2NDF"; discription_Histogram = "#Chi^{2} per NDF Vertex; [#Chi^{2}/NDF]; Entries"; numberOfBins = 1000; lowerBound = 0; upperBound = 50;}
1106 
1107  name_Histogram += add_name;
1108  TH1F* histogram = new TH1F(name_Histogram.Data(), discription_Histogram.Data(), numberOfBins, lowerBound, upperBound);
1109  histogram->Sumw2();
1110  if (j % 2 == 0) histogram->SetLineColor(6);
1111  if (j % 2 == 1) histogram->SetLineColor(4);
1112  histogram->SetMarkerStyle(20);
1113  histogram->SetMarkerSize(0.6);
1114  if (j % 2 == 0) histogram->SetMarkerColor(6);
1115  if (j % 2 == 1) histogram->SetMarkerColor(4);
1116  TH1F* histogram_Clone = (TH1F*)histogram->Clone();
1117  listout->Add(histogram_Clone);
1118  fMotherHistogramArray[i][j][k] = histogram_Clone;
1119  }
1120 
1121 
1122  name_Histogram = "";
1123  discription_Histogram = "";
1124  numberOfBins = 0;
1125  lowerBound = 0.0;
1126  upperBound = 0.0;
1127  numberOfBinsTwo = 0;
1128  lowerBoundTwo = 0.0;
1129  upperBoundTwo = 0.0;
1130 
1131  //we make the 2D histograms for the reconstructed particles
1132  Int_t nFirst = 0;
1133  Int_t nSecond = 1;
1134  Int_t nVariables = 10;
1135  Int_t nHistograms = nVariables * (nVariables - 1) / 2;
1136 
1137  TList * list2D = new TList();
1138  list2D->SetOwner();
1139  TString name2D = "2D_Histograms";
1140  name2D += add_name;
1141  list2D->SetName(name2D);
1142  listout->Add(list2D);
1143 
1144  for (Int_t k = 0; k < nHistograms; ++k)
1145  {
1146  numberOfBins = 50; numberOfBinsTwo = 50;
1147  if (nFirst == 0) {name_Histogram = "d0FirstDaughter"; discription_Histogram = "d0 first daughter [cm];"; lowerBound = 0; upperBound = 1;}
1148  if (nFirst == 1) {name_Histogram = "d0SecondDaughter"; discription_Histogram = "d0 second daughter [cm];"; lowerBound = 0; upperBound = 1;}
1149  if (nFirst == 2) {name_Histogram = "d0Mother"; discription_Histogram = "d0 mother [cm];"; lowerBound = 0; upperBound = 1;}
1150  if (nFirst == 3) {name_Histogram = "pointingAngleMother"; discription_Histogram = "pointing angle [Cos(#theta)];"; lowerBound = -1; upperBound = 1;}
1151  if (nFirst == 4) {name_Histogram = "impactProduct"; discription_Histogram = "impact product [cm^{2}];"; lowerBound = -0.01; upperBound = 0.01;}
1152  if (nFirst == 5) {name_Histogram = "impactProductXY"; discription_Histogram = "impact product XY [cm^{2}];"; lowerBound = 0; upperBound = 0.5;}
1153  if (nFirst == 6) {name_Histogram = "vertexDistance"; discription_Histogram = "vertex distance between mother and primary vertex [cm];"; lowerBound = 0; upperBound = 1;}
1154  if (nFirst == 7) {name_Histogram = "normDecayLength"; discription_Histogram = "Normalized decay length w.r.t primary vertex [cm];"; lowerBound = 0; upperBound = 50;}
1155  if (nFirst == 8) {name_Histogram = "pointingAngleMotherXY"; discription_Histogram = "pointing angle XY [Cos(#theta)];"; lowerBound = -1; upperBound = 1;}
1156  if (nFirst == 9) {name_Histogram = "vertexDistanceXY"; discription_Histogram = "vertex distance between mother and primary vertex XY [cm];"; lowerBound = 0; upperBound = 1;}
1157  if (nFirst == 10) {name_Histogram = "normDecayLengthXY"; discription_Histogram = "Normalized decay length w.r.t primary vertex XY [cm];"; lowerBound = 0; upperBound = 50;}
1158 
1159  if (nSecond == 0) {name_Histogram += "d0FirstDaughter"; discription_Histogram += "d0 first daughter [cm];"; lowerBoundTwo = 0; upperBoundTwo = 1;}
1160  if (nSecond == 1) {name_Histogram += "d0SecondDaughter"; discription_Histogram += "d0 second daughter [cm];"; lowerBoundTwo = 0; upperBoundTwo = 1;}
1161  if (nSecond == 2) {name_Histogram += "d0Mother"; discription_Histogram += "d0 mother [cm];"; lowerBoundTwo = 0; upperBoundTwo = 1;}
1162  if (nSecond == 3) {name_Histogram += "pointingAngleMother"; discription_Histogram += "pointing angle [Cos(#theta)];"; lowerBoundTwo = -1; upperBoundTwo = 1;}
1163  if (nSecond == 4) {name_Histogram += "impactProduct"; discription_Histogram += "impact product [cm^{2}];"; lowerBoundTwo = -0.01; upperBoundTwo = 0.01;}
1164  if (nSecond == 5) {name_Histogram += "impactProductXY"; discription_Histogram += "impact product XY [cm^{2}];"; lowerBoundTwo = 0; upperBoundTwo = 0.5;}
1165  if (nSecond == 6) {name_Histogram += "vertexDistance"; discription_Histogram += "vertex distance between mother and primary vertex [cm];"; lowerBoundTwo = 0; upperBoundTwo = 1;}
1166  if (nSecond == 7) {name_Histogram += "normDecayLength"; discription_Histogram += "Normalized decay length w.r.t primary vertex [cm];"; lowerBoundTwo = 0; upperBoundTwo = 50;}
1167  if (nSecond == 8) {name_Histogram += "_pointingAngleMotherXY"; discription_Histogram += "pointing angle XY [Cos(#theta)];"; lowerBoundTwo = -1; upperBoundTwo = 1;}
1168  if (nSecond == 9) {name_Histogram += "_vertexDistanceXY"; discription_Histogram += "vertex distance between mother and primary vertex XY [cm];"; lowerBoundTwo = 0; upperBoundTwo = 1;}
1169  if (nSecond == 10) {name_Histogram += "_normDecayLengthXY"; discription_Histogram += "Normalized decay length w.r.t primary vertex XY [cm];"; lowerBoundTwo = 0; upperBoundTwo = 50;}
1170 
1171  name_Histogram += add_name;
1172  TH2F* histogram = new TH2F(name_Histogram.Data(), discription_Histogram.Data(), numberOfBins, lowerBound, upperBound, numberOfBinsTwo, lowerBoundTwo, upperBoundTwo);
1173  histogram->Sumw2();
1174  if (j % 2 == 0) histogram->SetLineColor(6);
1175  if (j % 2 == 1) histogram->SetLineColor(4);
1176  histogram->SetMarkerStyle(20);
1177  histogram->SetMarkerSize(0.6);
1178  histogram->SetMarkerColor(6);
1179  TH2F* histogram_Clone = (TH2F*)histogram->Clone();
1180  list2D->Add(histogram_Clone);
1181  fMotherHistogramArray2D[i][j][k] = histogram_Clone;
1182 
1183  nSecond++;
1184  if (nSecond > nVariables)
1185  {
1186  nFirst++;
1187  nSecond = nFirst + 1;
1188  }
1189  }
1190  }
1191 
1192  TH1F * effectOfCuts = new TH1F("effectOfCuts", "Removal counter", 100, 0, 100);
1193  effectOfCuts->SetStats(kTRUE);
1194  effectOfCuts->GetXaxis()->SetTitle("Cut number");
1195  effectOfCuts->GetYaxis()->SetTitle("Particles cut");
1196  effectOfCuts->GetXaxis()->SetBinLabel(1, "total");
1197  for (Int_t i = 1; i < 100; ++i)
1198  {
1199  TString integerText = "";
1200  integerText += i;
1201  effectOfCuts->GetXaxis()->SetBinLabel(i + 1, integerText);
1202  }
1203  listout->Add(effectOfCuts);
1204  fMotherHistogramArrayExtra[i][0] = effectOfCuts;
1205 
1206  TH1F * effectOfCutsSignal = new TH1F("effectOfCutsSignal", "Removal counter", 100, 0, 100);
1207  effectOfCutsSignal->SetStats(kTRUE);
1208  effectOfCutsSignal->GetXaxis()->SetTitle("Cut number");
1209  effectOfCutsSignal->GetYaxis()->SetTitle("Particles cut");
1210  effectOfCutsSignal->GetXaxis()->SetBinLabel(1, "total");
1211  for (Int_t i = 1; i < 100; ++i)
1212  {
1213  TString integerText = "";
1214  integerText += i;
1215  effectOfCutsSignal->GetXaxis()->SetBinLabel(i + 1, integerText);
1216  }
1217  listout->Add(effectOfCutsSignal);
1218  fMotherHistogramArrayExtra[i][1] = effectOfCutsSignal;
1219 
1220  TString name_particle_pdg = "particle_pdg";
1221  TH1F* hist_particle_pdg = new TH1F(name_particle_pdg.Data(), "Pdg code particle; pdg code; Entries", 2000, -0.5, 1999.5);
1222  hist_particle_pdg->Sumw2();
1223  hist_particle_pdg->SetLineColor(6);
1224  hist_particle_pdg->SetMarkerStyle(20);
1225  hist_particle_pdg->SetMarkerSize(0.6);
1226  hist_particle_pdg->SetMarkerColor(6);
1227  TH1F* histogram_particle_pdg = (TH1F*)hist_particle_pdg->Clone();
1228  listout->Add(histogram_particle_pdg);
1229  fMotherHistogramArrayExtra[i][2] = histogram_particle_pdg;
1230 
1231  TString name_particle_mother_pdg = "particle_mother_pdg";
1232  TH1F* hist_particle_mother_pdg = new TH1F(name_particle_mother_pdg.Data(), "Pdg code particle mother; pdg code; Entries", 2000, -0.5, 1999.5);
1233  hist_particle_mother_pdg->Sumw2();
1234  hist_particle_mother_pdg->SetLineColor(6);
1235  hist_particle_mother_pdg->SetMarkerStyle(20);
1236  hist_particle_mother_pdg->SetMarkerSize(0.6);
1237  hist_particle_mother_pdg->SetMarkerColor(6);
1238  TH1F* histogram_particle_mother_pdg = (TH1F*)hist_particle_mother_pdg->Clone();
1239  listout->Add(histogram_particle_mother_pdg);
1240  fMotherHistogramArrayExtra[i][3] = histogram_particle_mother_pdg;
1241 
1242  TString name_distance_vertex_from_real = "distance_vertex_from_real";
1243  TH1F* hist_distance_vertex_from_real = new TH1F(name_distance_vertex_from_real.Data(), "Distance reconstructed vertex from real vertex; distance [cm]; Entries", 500, 0, 0.5);
1244  hist_distance_vertex_from_real->Sumw2();
1245  hist_distance_vertex_from_real->SetLineColor(6);
1246  hist_distance_vertex_from_real->SetMarkerStyle(20);
1247  hist_distance_vertex_from_real->SetMarkerSize(0.6);
1248  hist_distance_vertex_from_real->SetMarkerColor(6);
1249  TH1F* histogram_distance_vertex_from_real = (TH1F*)hist_distance_vertex_from_real->Clone();
1250  listout->Add(histogram_distance_vertex_from_real);
1251  fMotherHistogramArrayExtra[i][4] = histogram_distance_vertex_from_real;
1252 
1253  TString name_distance_vertex_from_real_new = "distance_vertex_from_real_new";
1254  TH1F* hist_distance_vertex_from_real_new = new TH1F(name_distance_vertex_from_real_new.Data(), "Distance reconstructed vertex from real vertex; distance [cm]; Entries", 500, 0, 0.5);
1255  hist_distance_vertex_from_real_new->Sumw2();
1256  hist_distance_vertex_from_real_new->SetLineColor(6);
1257  hist_distance_vertex_from_real_new->SetMarkerStyle(20);
1258  hist_distance_vertex_from_real_new->SetMarkerSize(0.6);
1259  hist_distance_vertex_from_real_new->SetMarkerColor(6);
1260  TH1F* histogram_distance_vertex_from_real_new = (TH1F*)hist_distance_vertex_from_real_new->Clone();
1261  listout->Add(histogram_distance_vertex_from_real_new);
1262  fMotherHistogramArrayExtra[i][5] = histogram_distance_vertex_from_real_new;
1263 
1264  TString name_momentum_resolution = "momentum_resolution";
1265  TH1F* hist_momentum_resolution = new TH1F(name_momentum_resolution.Data(), "Momentum resolution; difference between real and reconstructed momentum [GeV/c]; Entries", 1000, 0, 1);
1266  hist_momentum_resolution->Sumw2();
1267  hist_momentum_resolution->SetLineColor(6);
1268  hist_momentum_resolution->SetMarkerStyle(20);
1269  hist_momentum_resolution->SetMarkerSize(0.6);
1270  hist_momentum_resolution->SetMarkerColor(6);
1271  TH1F* histogram_momentum_resolution = (TH1F*)hist_momentum_resolution->Clone();
1272  listout->Add(histogram_momentum_resolution);
1273  fMotherHistogramArrayExtra[i][6] = histogram_momentum_resolution;
1274  }
1275 
1276  //we make the histograms for the same sign method histograms and the pt bins
1277  for (Int_t k = 0; k < fnPtBins + 3; ++k) {
1278  TString ptBinMother = "";
1279  if (k == 0) ptBinMother = "";
1280  if (k == 1) ptBinMother = "_ptbin_6_to_inf";
1281  if (k == 2) ptBinMother = "_ptbin_3_to_inf";
1282  if (k > 2) {ptBinMother += "_ptbin_"; ptBinMother += fPtBinLimits[k - 3]; ptBinMother += "_to_"; ptBinMother += fPtBinLimits[k - 2];}
1283 
1284  for (Int_t i = 0; i < 8; ++i) {
1285  TString signName = "";
1286  if (i == 0) signName = "";
1287  if (i == 1) signName = "_SameSign";
1288  if (i == 2) signName = "_SignSum";
1289  if (i == 3) signName = "_HIJING_Background";
1290  if (i == 4) signName = "_HIJING_Signal";
1291  if (i == 5) signName = "_Background_rotation";
1292  if (i == 6) signName = "_HIJING_Background_rotation";
1293  if (i == 7) signName = "_correlated511";
1294  TString name_invariantMassMother = "invariantMassBPlus";
1295  name_invariantMassMother += ptBinMother + signName;
1296  TH1F* hist_invariantMassMother = new TH1F(name_invariantMassMother.Data(), "mass mother candidate; m [GeV/c^2]; Entries", 2000, 0, 20);
1297  hist_invariantMassMother->Sumw2();
1298  hist_invariantMassMother->SetLineColor(6);
1299  hist_invariantMassMother->SetMarkerStyle(20);
1300  hist_invariantMassMother->SetMarkerSize(0.6);
1301  hist_invariantMassMother->SetMarkerColor(6);
1302  TH1F* histogram_invariantMassMother = (TH1F*)hist_invariantMassMother->Clone();
1303  fOutputBPlusMC->Add(histogram_invariantMassMother);
1304 
1305  TString name_deltainvariantMassMother = "deltainvariantMassBPlus";
1306  name_deltainvariantMassMother += ptBinMother + signName;
1307  TH1F* hist_deltainvariantMassMother = new TH1F(name_deltainvariantMassMother.Data(), "delta mass mother candidate; m [GeV/c^2]; Entries", 2000, 0, 20);
1308  hist_deltainvariantMassMother->Sumw2();
1309  hist_deltainvariantMassMother->SetLineColor(6);
1310  hist_deltainvariantMassMother->SetMarkerStyle(20);
1311  hist_deltainvariantMassMother->SetMarkerSize(0.6);
1312  hist_deltainvariantMassMother->SetMarkerColor(6);
1313  TH1F* histogram_deltainvariantMassMother = (TH1F*)hist_deltainvariantMassMother->Clone();
1314  fOutputBPlusMC->Add(histogram_deltainvariantMassMother);
1315  }
1316  }
1317 
1318 
1319  TString name_cutEffectBackground = "cutEffectBackground";
1320  TH2I* hist_cutEffectBackground = new TH2I(name_cutEffectBackground.Data(), "Effect of Cuts on background; cut number; cut number", 99, 0, 99, 99, 0, 99);
1321  for (int i = 0; i < 99; ++i)
1322  {
1323  TString integerText = "";
1324  integerText += i;
1325  hist_cutEffectBackground->GetXaxis()->SetBinLabel(i + 1, integerText);
1326  hist_cutEffectBackground->GetYaxis()->SetBinLabel(i + 1, integerText);
1327  }
1328  TH2I* histogram_cutEffectBackground = (TH2I*)hist_cutEffectBackground->Clone();
1329  fOutputBPlusMC->Add(histogram_cutEffectBackground);
1330 
1331  TString name_cutEffectSignal = "cutEffectSignal";
1332  TH2I* hist_cutEffectSignal = new TH2I(name_cutEffectSignal.Data(), "Effect of Cuts on Signal; cut number; cut number", 99, 0, 99, 99, 0, 99);
1333  for (Int_t i = 0; i < 99; ++i)
1334  {
1335  TString integerText = "";
1336  integerText += i;
1337  hist_cutEffectSignal->GetXaxis()->SetBinLabel(i + 1, integerText);
1338  hist_cutEffectSignal->GetYaxis()->SetBinLabel(i + 1, integerText);
1339  }
1340  TH2I* histogram_cutEffectSignal = (TH2I*)hist_cutEffectSignal->Clone();
1341  fOutputBPlusMC->Add(histogram_cutEffectSignal);
1342 
1343  TString name_cutEffectUniqueBackground = "cutEffectUniqueBackground";
1344  TH1I* hist_cutEffectUniqueBackground = new TH1I(name_cutEffectUniqueBackground.Data(), "Effect of Cuts on Signal; cut number; cut number", 99, 0, 99);
1345  for (Int_t i = 0; i < 99; ++i)
1346  {
1347  TString integerText = "";
1348  integerText += i;
1349  hist_cutEffectUniqueBackground->GetXaxis()->SetBinLabel(i + 1, integerText);
1350  }
1351  TH1I* histogram_cutEffectUniqueBackground = (TH1I*)hist_cutEffectUniqueBackground->Clone();
1352  fOutputBPlusMC->Add(histogram_cutEffectUniqueBackground);
1353 
1354  TString name_cutEffectUniqueSignal = "cutEffectUniqueSignal";
1355  TH1I* hist_cutEffectUniqueSignal = new TH1I(name_cutEffectUniqueSignal.Data(), "Effect of Cuts on Signal; cut number; cut number", 99, 0, 99);
1356  for (Int_t i = 0; i < 99; ++i)
1357  {
1358  TString integerText = "";
1359  integerText += i;
1360  hist_cutEffectUniqueSignal->GetXaxis()->SetBinLabel(i + 1, integerText);
1361  }
1362  TH1I* histogram_cutEffectUniqueSignal = (TH1I*)hist_cutEffectUniqueSignal->Clone();
1363  fOutputBPlusMC->Add(histogram_cutEffectUniqueSignal);
1364 
1365  TString name_totalITSBackground = "totalITSBackground";
1366  TH1F* hist_totalITSBackground = new TH1F(name_totalITSBackground.Data(), "Total nr. of ITS hits for the daughters; number [#]; Entries", 30, 0, 30);
1367  hist_totalITSBackground->Sumw2();
1368  hist_totalITSBackground->SetLineColor(6);
1369  hist_totalITSBackground->SetMarkerStyle(20);
1370  hist_totalITSBackground->SetMarkerSize(0.6);
1371  hist_totalITSBackground->SetMarkerColor(6);
1372  TH1F* histogram_totalITSBackground = (TH1F*)hist_totalITSBackground->Clone();
1373  fOutputBPlusMC->Add(histogram_totalITSBackground);
1374 
1375  TString name_totalITSSignal = "totalITSSignal";
1376  TH1F* hist_totalITSSignal = new TH1F(name_totalITSSignal.Data(), "Total nr. of ITS hits for the daughters; number [#]; Entries", 30, 0, 30);
1377  hist_totalITSSignal->Sumw2();
1378  hist_totalITSSignal->SetLineColor(6);
1379  hist_totalITSSignal->SetMarkerStyle(20);
1380  hist_totalITSSignal->SetMarkerSize(0.6);
1381  hist_totalITSSignal->SetMarkerColor(6);
1382  TH1F* histogram_totalITSSignal = (TH1F*)hist_totalITSSignal->Clone();
1383  fOutputBPlusMC->Add(histogram_totalITSSignal);
1384 
1385  TString name_totalTPCBackground = "totalTPCBackground";
1386  TH1F* hist_totalTPCBackground = new TH1F(name_totalTPCBackground.Data(), "Total nr. of TPC hits for the daughters; number [#]; Entries", 1000, 0, 1000);
1387  hist_totalTPCBackground->Sumw2();
1388  hist_totalTPCBackground->SetLineColor(6);
1389  hist_totalTPCBackground->SetMarkerStyle(20);
1390  hist_totalTPCBackground->SetMarkerSize(0.6);
1391  hist_totalTPCBackground->SetMarkerColor(6);
1392  TH1F* histogram_totalTPCBackground = (TH1F*)hist_totalTPCBackground->Clone();
1393  fOutputBPlusMC->Add(histogram_totalTPCBackground);
1394 
1395  TString name_totalTPCSignal = "totalTPCSignal";
1396  TH1F* hist_totalTPCSignal = new TH1F(name_totalTPCSignal.Data(), "Total nr. of TPC hits for the daughters; number [#]; Entries", 1000, 0, 1000);
1397  hist_totalTPCSignal->Sumw2();
1398  hist_totalTPCSignal->SetLineColor(6);
1399  hist_totalTPCSignal->SetMarkerStyle(20);
1400  hist_totalTPCSignal->SetMarkerSize(0.6);
1401  hist_totalTPCSignal->SetMarkerColor(6);
1402  TH1F* histogram_totalTPCSignal = (TH1F*)hist_totalTPCSignal->Clone();
1403  fOutputBPlusMC->Add(histogram_totalTPCSignal);
1404 
1405  TString name_totalSigmaPIDBackground = "totalSigmaPIDBackground";
1406  TH1F* hist_totalSigmaPIDBackground = new TH1F(name_totalSigmaPIDBackground.Data(), "Total sigma of TPC and TOF PID for the daughters; number [#]; Entries", 1000, 0, 100);
1407  hist_totalSigmaPIDBackground->Sumw2();
1408  hist_totalSigmaPIDBackground->SetLineColor(6);
1409  hist_totalSigmaPIDBackground->SetMarkerStyle(20);
1410  hist_totalSigmaPIDBackground->SetMarkerSize(0.6);
1411  hist_totalSigmaPIDBackground->SetMarkerColor(6);
1412  TH1F* histogram_totalSigmaPIDBackground = (TH1F*)hist_totalSigmaPIDBackground->Clone();
1413  fOutputBPlusMC->Add(histogram_totalSigmaPIDBackground);
1414 
1415  TString name_totalSigmaPIDSignal = "totalSigmaPIDSignal";
1416  TH1F* hist_totalSigmaPIDSignal = new TH1F(name_totalSigmaPIDSignal.Data(), "Total sigma of TPC and TOF PID for the daughters; number [#]; Entries", 1000, 0, 100);
1417  hist_totalSigmaPIDSignal->Sumw2();
1418  hist_totalSigmaPIDSignal->SetLineColor(6);
1419  hist_totalSigmaPIDSignal->SetMarkerStyle(20);
1420  hist_totalSigmaPIDSignal->SetMarkerSize(0.6);
1421  hist_totalSigmaPIDSignal->SetMarkerColor(6);
1422  TH1F* histogram_totalSigmaPIDSignal = (TH1F*)hist_totalSigmaPIDSignal->Clone();
1423  fOutputBPlusMC->Add(histogram_totalSigmaPIDSignal);
1424 
1425  TString name_BPlusLabelNumber = "BPlusLabelNumber";
1426  TH1I* hist_BPlusLabelNumber = new TH1I(name_BPlusLabelNumber.Data(), "Number of BPlus mesons with same label; numer with same label; entries", 50, 0, 50);
1427  for (Int_t i = 0; i < 50; ++i)
1428  {
1429  TString integerText = "";
1430  integerText += i;
1431  hist_BPlusLabelNumber->GetXaxis()->SetBinLabel(i + 1, integerText);
1432  }
1433  TH1I* histogram_BPlusLabelNumber = (TH1I*)hist_BPlusLabelNumber->Clone();
1434  fOutputBPlusMC->Add(histogram_BPlusLabelNumber);
1435 
1436 
1437  TString name_particle_pdgBPlusPion = "particle_pdgBPlusPion";
1438  TH1F* hist_particle_pdgBPlusPion = new TH1F(name_particle_pdgBPlusPion.Data(), "Pdg code particle; pdg code; Entries", 5000, -0.5, 4999.5);
1439  hist_particle_pdgBPlusPion->Sumw2();
1440  hist_particle_pdgBPlusPion->SetLineColor(6);
1441  hist_particle_pdgBPlusPion->SetMarkerStyle(20);
1442  hist_particle_pdgBPlusPion->SetMarkerSize(0.6);
1443  hist_particle_pdgBPlusPion->SetMarkerColor(6);
1444  TH1F* histogram_particle_pdgBPlusPion = (TH1F*)hist_particle_pdgBPlusPion->Clone();
1445  fOutputBPlusMC->Add(histogram_particle_pdgBPlusPion);
1446 
1447  TString name_particle_pdgD0First = "particle_pdgD0First";
1448  TH1F* hist_particle_pdgD0First = new TH1F(name_particle_pdgD0First.Data(), "Pdg code particle; pdg code; Entries", 5000, -0.5, 4999.5);
1449  hist_particle_pdgD0First->Sumw2();
1450  hist_particle_pdgD0First->SetLineColor(6);
1451  hist_particle_pdgD0First->SetMarkerStyle(20);
1452  hist_particle_pdgD0First->SetMarkerSize(0.6);
1453  hist_particle_pdgD0First->SetMarkerColor(6);
1454  TH1F* histogram_particle_pdgD0First = (TH1F*)hist_particle_pdgD0First->Clone();
1455  fOutputBPlusMC->Add(histogram_particle_pdgD0First);
1456 
1457  TString name_particle_pdgD0Second = "particle_pdgD0Second";
1458  TH1F* hist_particle_pdgD0Second = new TH1F(name_particle_pdgD0Second.Data(), "Pdg code particle; pdg code; Entries", 5000, -0.5, 4999.5);
1459  hist_particle_pdgD0Second->Sumw2();
1460  hist_particle_pdgD0Second->SetLineColor(6);
1461  hist_particle_pdgD0Second->SetMarkerStyle(20);
1462  hist_particle_pdgD0Second->SetMarkerSize(0.6);
1463  hist_particle_pdgD0Second->SetMarkerColor(6);
1464  TH1F* histogram_particle_pdgD0Second = (TH1F*)hist_particle_pdgD0Second->Clone();
1465  fOutputBPlusMC->Add(histogram_particle_pdgD0Second);
1466 
1467  TString name_particle_pdgAll = "particle_pdgAll";
1468  TH1F* hist_particle_pdgAll = new TH1F(name_particle_pdgAll.Data(), "Pdg code particle; pdg code; Entries", 5000, -0.5, 4999.5);
1469  hist_particle_pdgAll->Sumw2();
1470  hist_particle_pdgAll->SetLineColor(6);
1471  hist_particle_pdgAll->SetMarkerStyle(20);
1472  hist_particle_pdgAll->SetMarkerSize(0.6);
1473  hist_particle_pdgAll->SetMarkerColor(6);
1474  TH1F* histogram_particle_pdgAll = (TH1F*)hist_particle_pdgAll->Clone();
1475  fOutputBPlusMC->Add(histogram_particle_pdgAll);
1476 
1477  TString name_particle_pdgAllSecond = "particle_pdgAllSecond";
1478  TH1F* hist_particle_pdgAllSecond = new TH1F(name_particle_pdgAllSecond.Data(), "Pdg code particle; pdg code; Entries", 5000, -0.5, 4999.5);
1479  hist_particle_pdgAllSecond->Sumw2();
1480  hist_particle_pdgAllSecond->SetLineColor(6);
1481  hist_particle_pdgAllSecond->SetMarkerStyle(20);
1482  hist_particle_pdgAllSecond->SetMarkerSize(0.6);
1483  hist_particle_pdgAllSecond->SetMarkerColor(6);
1484  TH1F* histogram_particle_pdgAllSecond = (TH1F*)hist_particle_pdgAllSecond->Clone();
1485  fOutputBPlusMC->Add(histogram_particle_pdgAllSecond);
1486 
1487  TString name_particle_pdgAllInvMass = "particle_pdgAllInvMass";
1488  TH2F* hist_particle_pdgAllInvMass = new TH2F(name_particle_pdgAllInvMass.Data(), "Pdg code particle; pdg code; BPlus Inv. Mass", 5000, -0.5, 4999.5, 500, 4.0, 6.0);
1489  hist_particle_pdgAllInvMass->Sumw2();
1490  hist_particle_pdgAllInvMass->SetLineColor(6);
1491  hist_particle_pdgAllInvMass->SetMarkerStyle(20);
1492  hist_particle_pdgAllInvMass->SetMarkerSize(0.6);
1493  hist_particle_pdgAllInvMass->SetMarkerColor(6);
1494  TH2F* histogram_particle_pdgAllInvMass = (TH2F*)hist_particle_pdgAllInvMass->Clone();
1495  fOutputBPlusMC->Add(histogram_particle_pdgAllInvMass);
1496 
1497  TString name_particle_pdgAllSecondInvMass = "particle_pdgAllSecondInvMass";
1498  TH2F* hist_particle_pdgAllSecondInvMass = new TH2F(name_particle_pdgAllSecondInvMass.Data(), "Pdg code particle; pdg code; BPlus Inv. Mass", 5000, -0.5, 4999.5, 500, 4.0, 6.0);
1499  hist_particle_pdgAllSecondInvMass->Sumw2();
1500  hist_particle_pdgAllSecondInvMass->SetLineColor(6);
1501  hist_particle_pdgAllSecondInvMass->SetMarkerStyle(20);
1502  hist_particle_pdgAllSecondInvMass->SetMarkerSize(0.6);
1503  hist_particle_pdgAllSecondInvMass->SetMarkerColor(6);
1504  TH2F* histogram_particle_pdgAllSecondInvMass = (TH2F*)hist_particle_pdgAllSecondInvMass->Clone();
1505  fOutputBPlusMC->Add(histogram_particle_pdgAllSecondInvMass);
1506 
1507  TString name_particle_daughterPdgOneStep511 = "particle_daughterPdgOneStep511";
1508  TH2F* hist_particle_daughterPdgOneStep511 = new TH2F(name_particle_daughterPdgOneStep511.Data(), "Pdg daughters; n daughter; Pdg daughter", 50, -0.5, 49.5, 5000, -0.5, 4999.5);
1509  hist_particle_daughterPdgOneStep511->Sumw2();
1510  hist_particle_daughterPdgOneStep511->SetLineColor(6);
1511  hist_particle_daughterPdgOneStep511->SetMarkerStyle(20);
1512  hist_particle_daughterPdgOneStep511->SetMarkerSize(0.6);
1513  hist_particle_daughterPdgOneStep511->SetMarkerColor(6);
1514  TH2F* histogram_particle_daughterPdgOneStep511 = (TH2F*)hist_particle_daughterPdgOneStep511->Clone();
1515  fOutputBPlusMC->Add(histogram_particle_daughterPdgOneStep511);
1516 
1517  TString name_particle_daughterPdgOneStep521 = "particle_daughterPdgOneStep521";
1518  TH2F* hist_particle_daughterPdgOneStep521 = new TH2F(name_particle_daughterPdgOneStep521.Data(), "Pdg daughters; n daughter; Pdg daughter", 50, -0.5, 49.5, 5000, -0.5, 4999.5);
1519  hist_particle_daughterPdgOneStep521->Sumw2();
1520  hist_particle_daughterPdgOneStep521->SetLineColor(6);
1521  hist_particle_daughterPdgOneStep521->SetMarkerStyle(20);
1522  hist_particle_daughterPdgOneStep521->SetMarkerSize(0.6);
1523  hist_particle_daughterPdgOneStep521->SetMarkerColor(6);
1524  TH2F* histogram_particle_daughterPdgOneStep521 = (TH2F*)hist_particle_daughterPdgOneStep521->Clone();
1525  fOutputBPlusMC->Add(histogram_particle_daughterPdgOneStep521);
1526 
1527  TString name_particle_daughterPdgTwoStep511 = "particle_daughterPdgTwoStep511";
1528  TH2F* hist_particle_daughterPdgTwoStep511 = new TH2F(name_particle_daughterPdgTwoStep511.Data(), "Pdg daughters; n daughter; Pdg daughter", 50, -0.5, 49.5, 5000, -0.5, 4999.5);
1529  hist_particle_daughterPdgTwoStep511->Sumw2();
1530  hist_particle_daughterPdgTwoStep511->SetLineColor(6);
1531  hist_particle_daughterPdgTwoStep511->SetMarkerStyle(20);
1532  hist_particle_daughterPdgTwoStep511->SetMarkerSize(0.6);
1533  hist_particle_daughterPdgTwoStep511->SetMarkerColor(6);
1534  TH2F* histogram_particle_daughterPdgTwoStep511 = (TH2F*)hist_particle_daughterPdgTwoStep511->Clone();
1535  fOutputBPlusMC->Add(histogram_particle_daughterPdgTwoStep511);
1536 
1537  TString name_particle_daughterPdgTwoStep521 = "particle_daughterPdgTwoStep521";
1538  TH2F* hist_particle_daughterPdgTwoStep521 = new TH2F(name_particle_daughterPdgTwoStep521.Data(), "Pdg daughters; n daughter; Pdg daughter", 50, -0.5, 49.5, 5000, -0.5, 4999.5);
1539  hist_particle_daughterPdgTwoStep521->Sumw2();
1540  hist_particle_daughterPdgTwoStep521->SetLineColor(6);
1541  hist_particle_daughterPdgTwoStep521->SetMarkerStyle(20);
1542  hist_particle_daughterPdgTwoStep521->SetMarkerSize(0.6);
1543  hist_particle_daughterPdgTwoStep521->SetMarkerColor(6);
1544  TH2F* histogram_particle_daughterPdgTwoStep521 = (TH2F*)hist_particle_daughterPdgTwoStep521->Clone();
1545  fOutputBPlusMC->Add(histogram_particle_daughterPdgTwoStep521);
1546 
1547  for (int i = 0; i < 3; ++i)
1548  {
1549  TString name_Histogram;
1550  TString discription_Histogram;
1551  if (i == 0) {name_Histogram = "invmassD0PionBPlusPion"; discription_Histogram = "Invariant mass D0 Pion and BPlus Pion; inv. mass [GeV/c^{2}]; Entries";}
1552  if (i == 1) {name_Histogram = "invmassD0KaonBPlusPion"; discription_Histogram = "Invariant mass D0 Kaon and BPlus Pion; inv. mass [GeV/c^{2}]; Entries";}
1553  if (i == 2) {name_Histogram = "invmassD0PionD0KaonBPlusPion"; discription_Histogram = "Invariant mass D0 Pion, D0 Kaon, and BPlus Pion; inv. mass [GeV/c^{2}]; Entries";}
1554 
1555  for (int j = 0; j < 2; ++j)
1556  {
1557  TString add_name = "";
1558  if (j == 1) add_name = "_MC";
1559  name_Histogram += add_name;
1560  TH1F* histogram = new TH1F(name_Histogram.Data(), discription_Histogram.Data(), 1000, 0, 30);
1561  histogram->Sumw2();
1562  if (j % 2 == 0) histogram->SetLineColor(6);
1563  if (j % 2 == 1) histogram->SetLineColor(4);
1564  histogram->SetMarkerStyle(20);
1565  histogram->SetMarkerSize(0.6);
1566  if (j % 2 == 0) histogram->SetMarkerColor(6);
1567  if (j % 2 == 1) histogram->SetMarkerColor(4);
1568  TH1F* histogram_Clone = (TH1F*)histogram->Clone();
1569  fOutputBPlusMC->Add(histogram_Clone);
1570  }
1571  }
1572 
1573 
1574 
1575  return;
1576 }
1577 //-------------------------------------------------------------------------------------
1578 AliAODVertex* AliAnalysisTaskSEBPlustoD0Pi::RecalculateVertex(const AliVVertex *primary, TObjArray *tracks, Double_t bField, Double_t dispersion) {
1579  //
1580  // Helper function to recalculate a vertex.
1581  //
1582 
1583  AliESDVertex *vertexESD = 0;
1584  AliAODVertex *vertexAOD = 0;
1585 
1586  AliVertexerTracks vertexer;
1587  vertexer.SetFieldkG(bField);
1588 
1589  vertexer.SetVtxStart((AliESDVertex*)primary); //primary vertex
1590  vertexESD = (AliESDVertex*)vertexer.VertexForSelectedESDTracks(tracks);
1591 
1592  // delete vertexer; vertexer=NULL;
1593 
1594  if (!vertexESD) return vertexAOD;
1595 
1596 
1597  if (vertexESD->GetNContributors() != tracks->GetEntriesFast())
1598  {
1599  delete vertexESD; vertexESD = nullptr;
1600  return vertexAOD;
1601  }
1602 
1603  // convert to AliAODVertex
1604  Double_t pos[3], cov[6], chi2perNDF;
1605  for (Int_t a = 0; a < 3; a++)pos[a] = 0.;
1606  for (Int_t b = 0; b < 6; b++)cov[b] = 0.;
1607  chi2perNDF = 0;
1608 
1609  vertexESD->GetXYZ(pos); // position
1610  vertexESD->GetCovMatrix(cov); //covariance matrix
1611 
1612 
1613  Double_t vertRadius2 = pos[0] * pos[0] + pos[1] * pos[1];
1614  if (vertRadius2 > 8.) //(2.82)^2 radius beam pipe
1615  {
1616  delete vertexESD; vertexESD = nullptr;
1617  return vertexAOD;
1618  }
1619 
1620  chi2perNDF = vertexESD->GetChi2toNDF();
1621  dispersion = vertexESD->GetDispersion();
1622  delete vertexESD; vertexESD = nullptr;
1623  Int_t nprongs = 2; //tracks->GetEntriesFast();
1624  vertexAOD = new AliAODVertex(pos, cov, chi2perNDF, 0x0, -1, AliAODVertex::kUndef, nprongs);
1625 
1626  return vertexAOD;
1627 }
1628 //-------------------------------------------------------------------------------------
1629 void AliAnalysisTaskSEBPlustoD0Pi::BPlustoD0PiSignalTracksInMC(TClonesArray * mcTrackArray, AliAODEvent* aodevent, TMatrix * BPlustoD0PiLabelMatrix, TList *listout) {
1630 
1631  TMatrix &particleMatrix = *BPlustoD0PiLabelMatrix;
1632  for (Int_t i = 0; i < mcTrackArray->GetEntriesFast(); i++) {
1633 
1634  Int_t mcLabelPionBPlus = 0;
1635  Int_t mcLabelPionD0 = 0;
1636  Int_t mcLabelKaon = 0;
1637  Int_t mcLabelD0 = 0;
1638  Int_t mcLabelBPlus = 0;
1639 
1640  Double_t ptMC[5] = {0.0};
1641  Double_t yMC[5] = {0.0};
1642  Double_t pseudoYMC[5] = {0.0};
1643 
1644  Bool_t mcPionBPlusPresent = kFALSE;
1645  Bool_t mcPionD0Present = kFALSE;
1646  Bool_t mcKaonPresent = kFALSE;
1647 
1648 
1649  AliAODMCParticle *mcTrackParticle = dynamic_cast< AliAODMCParticle*>(mcTrackArray->At(i));
1650  if (!mcTrackParticle) {std::cout << "no particle" << std::endl; continue;}
1651  Int_t pdgCodeMC = TMath::Abs(mcTrackParticle->GetPdgCode());
1652 
1653  if (pdgCodeMC == 521)
1654  { //if the track is a BPlus we look at its daughters
1655 
1656  mcLabelBPlus = i;
1657  Int_t nDaughterBPlus = mcTrackParticle->GetNDaughters();
1658  ptMC[0] = mcTrackParticle->Pt();
1659  yMC[0] = mcTrackParticle->Y();
1660  pseudoYMC[0] = mcTrackParticle->Eta();
1661 
1662  TString fillthis = "BPlus_in_analysis";
1663  ((TH1F*)(listout->FindObject(fillthis)))->Fill(0);
1664 
1665  if (nDaughterBPlus == 2)
1666  {
1667  for (Int_t iDaughterBPlus = 0; iDaughterBPlus < 2; iDaughterBPlus++)
1668  {
1669  AliAODMCParticle* daughterBPlus = (AliAODMCParticle*)mcTrackArray->At(mcTrackParticle->GetDaughter(iDaughterBPlus));
1670  if (!daughterBPlus) break;
1671  Int_t pdgCodeDaughterBPlus = TMath::Abs(daughterBPlus->GetPdgCode());
1672 
1673  if (pdgCodeDaughterBPlus == 211) //if the track is a pion we save its monte carlo label
1674  {
1675  mcLabelPionBPlus = mcTrackParticle->GetDaughter(iDaughterBPlus);
1676  mcPionBPlusPresent = kTRUE;
1677  ptMC[1] = daughterBPlus->Pt();
1678  yMC[1] = daughterBPlus->Y();
1679  pseudoYMC[1] = daughterBPlus->Eta();
1680  } else if (pdgCodeDaughterBPlus == 421) //if the track is a D0 we look at its daughters
1681  {
1682  mcLabelD0 = mcTrackParticle->GetDaughter(iDaughterBPlus);
1683  Int_t nDaughterD0 = daughterBPlus->GetNDaughters();
1684  ptMC[2] = daughterBPlus->Pt();
1685  yMC[2] = daughterBPlus->Y();
1686  pseudoYMC[2] = daughterBPlus->Eta();
1687 
1688  if (nDaughterD0 == 2)
1689  {
1690  for (Int_t iDaughterD0 = 0; iDaughterD0 < 2; iDaughterD0++)
1691  {
1692  AliAODMCParticle* daughterD0 = (AliAODMCParticle*)mcTrackArray->At(daughterBPlus->GetDaughter(iDaughterD0));
1693  if (!daughterD0) break;
1694  Int_t pdgCodeDaughterD0 = TMath::Abs(daughterD0->GetPdgCode());
1695  if (pdgCodeDaughterD0 == 211) //if the track is a pion we save its monte carlo label
1696  {
1697  mcLabelPionD0 = daughterBPlus->GetDaughter(iDaughterD0);
1698  ptMC[3] = daughterD0->Pt();
1699  yMC[3] = daughterD0->Y();
1700  pseudoYMC[3] = daughterD0->Eta();
1701  mcPionD0Present = kTRUE;
1702  } else if (pdgCodeDaughterD0 == 321) //if the track is a kaon we save its monte carlo label
1703  {
1704  mcLabelKaon = daughterBPlus->GetLabel();
1705  mcKaonPresent = kTRUE;
1706  ptMC[4] = daughterD0->Pt();
1707  yMC[4] = daughterD0->Y();
1708  pseudoYMC[4] = daughterD0->Eta();
1709  } else break;
1710  }
1711  }
1712  } else break;
1713  }
1714  }
1715  }
1716  if (mcPionBPlusPresent && mcPionD0Present && mcKaonPresent) {
1717 
1718  TString fillthis = "BPlus_in_analysis";
1719  ((TH1F*)(listout->FindObject(fillthis)))->Fill(1);
1720 
1721  fillthis = "BPlus_per_bin";
1722  for (Int_t j = 0; j < fnPtBins; ++j)
1723  {
1724  if (fPtBinLimits[j] < ptMC[0] && ptMC[0] < fPtBinLimits[j + 1]) {((TH1F*)(listout->FindObject(fillthis)))->Fill(j); break;}
1725  }
1726 
1727 
1728  fillthis = "mc_BPlus_pt";
1729  ((TH1F*)(listout->FindObject(fillthis)))->Fill(ptMC[0]);
1730  fillthis = "mc_BPlus_pion_pt";
1731  ((TH1F*)(listout->FindObject(fillthis)))->Fill(ptMC[1]);
1732  fillthis = "mc_D0_pt";
1733  ((TH1F*)(listout->FindObject(fillthis)))->Fill(ptMC[2]);
1734  fillthis = "mc_D0_pion_pt";
1735  ((TH1F*)(listout->FindObject(fillthis)))->Fill(ptMC[3]);
1736  fillthis = "mc_D0_kaon_pt";
1737  ((TH1F*)(listout->FindObject(fillthis)))->Fill(ptMC[4]);
1738 
1739  fillthis = "mc_BPlus_rapidity_true";
1740  ((TH1F*)(listout->FindObject(fillthis)))->Fill(yMC[0]);
1741  fillthis = "mc_BPlus_pion_rapidity_true";
1742  ((TH1F*)(listout->FindObject(fillthis)))->Fill(yMC[1]);
1743  fillthis = "mc_D0_rapidity_true";
1744  ((TH1F*)(listout->FindObject(fillthis)))->Fill(yMC[2]);
1745  fillthis = "mc_D0_pion_rapidity_true";
1746  ((TH1F*)(listout->FindObject(fillthis)))->Fill(yMC[3]);
1747  fillthis = "mc_D0_kaon_rapidity_true";
1748  ((TH1F*)(listout->FindObject(fillthis)))->Fill(yMC[4]);
1749 
1750  fillthis = "mc_BPlus_pseudorapidity_true";
1751  ((TH1F*)(listout->FindObject(fillthis)))->Fill(pseudoYMC[0]);
1752  fillthis = "mc_BPlus_pion_pseudorapidity_true";
1753  ((TH1F*)(listout->FindObject(fillthis)))->Fill(pseudoYMC[1]);
1754  fillthis = "mc_D0_pseudorapidity_true";
1755  ((TH1F*)(listout->FindObject(fillthis)))->Fill(pseudoYMC[2]);
1756  fillthis = "mc_D0_pion_pseudorapidity_true";
1757  ((TH1F*)(listout->FindObject(fillthis)))->Fill(pseudoYMC[3]);
1758  fillthis = "mc_D0_kaon_pseudorapidity_true";
1759  ((TH1F*)(listout->FindObject(fillthis)))->Fill(pseudoYMC[4]);
1760 
1761  // We check if the tracks are in acceptance
1762  if (ptMC[1] < 0.1 || TMath::Abs(pseudoYMC[1]) > 0.8 ) continue;
1763  if (ptMC[3] < 0.1 || TMath::Abs(pseudoYMC[3]) > 0.8 ) continue;
1764  if (ptMC[4] < 0.1 || TMath::Abs(pseudoYMC[4]) > 0.8 ) continue;
1765 
1766  // We check if the BPlus is in the fiducial region
1767  if (TMath::Abs(yMC[0]) > 0.8) continue;
1768 
1769  Int_t rows = BPlustoD0PiLabelMatrix->GetNrows();
1770 
1771  BPlustoD0PiLabelMatrix->ResizeTo(rows + 1, 5);
1772  particleMatrix(rows, 0) = mcLabelPionBPlus;
1773  particleMatrix(rows, 1) = mcLabelPionD0;
1774  particleMatrix(rows, 2) = mcLabelKaon;
1775  particleMatrix(rows, 3) = mcLabelD0;
1776  particleMatrix(rows, 4) = mcLabelBPlus;
1777 
1778  fillthis = "BPlus_in_analysis";
1779  ((TH1F*)(listout->FindObject(fillthis)))->Fill(2);
1780 
1781 
1782  fillthis = "BPlus_per_bin_in_Acc";
1783  for (Int_t j = 0; j < fnPtBins; ++j)
1784  {
1785  if (fPtBinLimits[j] < ptMC[0] && ptMC[0] < fPtBinLimits[j + 1]) {((TH1F*)(listout->FindObject(fillthis)))->Fill(j); break;}
1786  }
1787  }
1788  }
1789 
1790 
1791  return;
1792 }
1793 //-------------------------------------------------------------------------------------
1794 Bool_t AliAnalysisTaskSEBPlustoD0Pi::D0FirstDaughterSelection(AliAODTrack* aodTrack, AliAODVertex *primaryVertex, Double_t bz, TClonesArray * mcTrackArray, TMatrix * BPlustoD0PiLabelMatrix, AliAODMCHeader * header) {
1795 
1796  // we select the D0 pion and save its information
1797  if (!aodTrack) AliFatal("Not a standard AOD");
1798 
1799  //quick quality cut
1800  if (aodTrack->GetITSNcls() < 1) return kFALSE;
1801  if (aodTrack->GetTPCNcls() < 1) return kFALSE;
1802  if (aodTrack->GetStatus()&AliESDtrack::kITSpureSA) return kFALSE;
1803  if (!(aodTrack->GetStatus()&AliESDtrack::kITSin)) return kFALSE;
1804  if (aodTrack->GetID() < 0) return kFALSE;
1805  Double_t covtest[21];
1806  if (!aodTrack->GetCovarianceXYZPxPyPz(covtest)) return kFALSE;
1807 
1808  Int_t mcLabelParticle = -1;
1809  mcLabelParticle = aodTrack->GetLabel();
1810 
1811  // we fill histograms with information of the track
1812  Double_t pt_track = aodTrack->Pt();
1813  Double_t momentum_track = aodTrack->P();
1814  Int_t numberOfITS = aodTrack->GetITSNcls();
1815  Int_t numberOfTPC = aodTrack->GetTPCNcls();
1816 
1817  AliExternalTrackParam particleTrack;
1818  particleTrack.CopyFromVTrack(aodTrack);
1819  Double_t d0[2], covd0[3];
1820  particleTrack.PropagateToDCA(primaryVertex, bz, 100., d0, covd0);
1821 
1822  //we check if the particle is a signal track, we look at both daughter options therefore the signal will be too high in the D0 daughter signal histograms
1823  Bool_t isDesiredCandidate = kFALSE;
1824  if (fUseMCInfo) {
1825  TMatrix &particleMatrix = *BPlustoD0PiLabelMatrix;
1826  for (Int_t k = 0; k < BPlustoD0PiLabelMatrix->GetNrows(); ++k) {
1827  if (mcLabelParticle == (Int_t)particleMatrix(k, 1) || mcLabelParticle == (Int_t)particleMatrix(k, 2)) {
1828  isDesiredCandidate = kTRUE;
1829  break;
1830  }
1831  }
1832  }
1833 
1834  if (fUseMCInfo) {
1835  if (IsTrackInjected(aodTrack, header, mcTrackArray) && !isDesiredCandidate && fQuickSignalAnalysis == 2) return kFALSE;
1836  }
1837 
1838  Int_t daughterType = 0;
1839 
1840 
1841  Int_t histType = 0;
1842  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
1843  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
1844  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
1845  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
1846 
1847  for (Int_t j = 0; j < 10; ++j)
1848  {
1849  if (aodTrack->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
1850 
1851  }
1852  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0[0]);
1853 
1854  if (isDesiredCandidate)
1855  {
1856  histType = 1;
1857  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
1858  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
1859  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
1860  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
1861 
1862  for (Int_t j = 0; j < 10; ++j)
1863  {
1864  if (aodTrack->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
1865 
1866  }
1867  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0[0]);
1868  }
1869 
1870  //we apply a number of cuts on the particle
1871  Bool_t bCut = kFALSE;
1872 
1873  //We do not apply a PID cut at this stage since we don't know if we are dealing with a kaon or a pion
1874 
1875  if (aodTrack->GetITSNcls() < fCuts->GetMinITSNclsD0FirstDaughter()) {
1876  if (isDesiredCandidate) {
1877  ((TH1F*)fDaughterHistogramArrayExtra[0][1])->Fill(3);
1878  } else ((TH1F*)fDaughterHistogramArrayExtra[0][0])->Fill(3);
1879  bCut = kTRUE;
1880  }
1881 
1882  if (aodTrack->GetTPCNcls() < fCuts->GetMinTPCNclsD0FirstDaughter()) {
1883  if (isDesiredCandidate) {
1884  ((TH1F*)fDaughterHistogramArrayExtra[0][1])->Fill(4);
1885  } else ((TH1F*)fDaughterHistogramArrayExtra[0][0])->Fill(4);
1886  bCut = kTRUE;
1887  }
1888 
1889  if (fCuts->UseITSRefitD0FirstDaughter() == kTRUE) {
1890  if (!(aodTrack->GetStatus()&AliESDtrack::kITSrefit)) {
1891  if (isDesiredCandidate) {
1892  ((TH1F*)fDaughterHistogramArrayExtra[0][1])->Fill(5);
1893  } else ((TH1F*)fDaughterHistogramArrayExtra[0][0])->Fill(5);
1894  bCut = kTRUE;
1895  }
1896  }
1897 
1898  if (fCuts->UseTPCRefitD0FirstDaughter() == kTRUE) {
1899  if ((!(aodTrack->GetStatus()&AliESDtrack::kTPCrefit))) {
1900  if (isDesiredCandidate) {
1901  ((TH1F*)fDaughterHistogramArrayExtra[0][1])->Fill(6);
1902  } else ((TH1F*)fDaughterHistogramArrayExtra[0][0])->Fill(6);
1903  bCut = kTRUE;
1904  }
1905  }
1906 
1907  if (fCuts->UseFilterBitD0FirstDaughter() == kTRUE) {
1908  if (!(aodTrack->TestFilterMask(BIT(fCuts->GetFilterBitD0FirstDaughter())))) {
1909  if (isDesiredCandidate) {
1910  ((TH1F*)fDaughterHistogramArrayExtra[0][1])->Fill(7);
1911  } else ((TH1F*)fDaughterHistogramArrayExtra[0][0])->Fill(7);
1912  bCut = kTRUE;
1913  }
1914  }
1915 
1916  if (aodTrack->Pt() < fCuts->GetMinPtD0FirstDaughter()) {
1917  if (isDesiredCandidate) {
1918  ((TH1F*)fDaughterHistogramArrayExtra[0][1])->Fill(8);
1919  } else ((TH1F*)fDaughterHistogramArrayExtra[0][0])->Fill(8);
1920  bCut = kTRUE;
1921  }
1922 
1923  if (TMath::Abs(d0[0]) < fCuts->GetMind0D0FirstDaughter()) {
1924  if (isDesiredCandidate) {
1925  ((TH1F*)fDaughterHistogramArrayExtra[0][1])->Fill(12);
1926  } else ((TH1F*)fDaughterHistogramArrayExtra[0][0])->Fill(12);
1927  bCut = kTRUE;
1928  }
1929 
1930  if (TMath::Abs(aodTrack->Eta()) > fCuts->GetMaxAbsEtaD0FirstDaughter()) {
1931  if (isDesiredCandidate) {
1932  ((TH1F*)fDaughterHistogramArrayExtra[0][1])->Fill(9);
1933  } else ((TH1F*)fDaughterHistogramArrayExtra[0][0])->Fill(9);
1934  bCut = kTRUE;
1935  }
1936 
1937  Bool_t bHardSelectionArrayITS[7] = {kFALSE};
1938  fCuts->GetHardSelectionArrayITSD0FirstDaughter(bHardSelectionArrayITS);
1939  Bool_t bSoftSelectionArrayITS[7] = {kFALSE};
1940  fCuts->GetSoftSelectionArrayITSD0FirstDaughter(bSoftSelectionArrayITS);
1941 
1942  Bool_t bHardITSPass = kTRUE;
1943  for (Int_t j = 0; j < 7; ++j)
1944  {
1945  if (bHardSelectionArrayITS[j])
1946  {
1947  if (!aodTrack->HasPointOnITSLayer(j)) bHardITSPass = kFALSE;
1948  }
1949  }
1950 
1951  Int_t nCounterSoftSelection = 0;
1952  Bool_t bSoftITSPass = kTRUE;
1953  for (Int_t j = 0; j < 7; ++j)
1954  {
1955  if (bSoftSelectionArrayITS[j])
1956  {
1957  if (aodTrack->HasPointOnITSLayer(j)) nCounterSoftSelection++;
1958  }
1959  }
1960  if (nCounterSoftSelection < fCuts->GetNSoftITSCutD0FirstDaughter()) bSoftITSPass = kFALSE;
1961 
1962  if (!bHardITSPass) {
1963  if (isDesiredCandidate) {
1964  ((TH1F*)fDaughterHistogramArrayExtra[0][1])->Fill(10);
1965  } else ((TH1F*)fDaughterHistogramArrayExtra[0][0])->Fill(10);
1966  bCut = kTRUE;
1967  }
1968 
1969  if (!bSoftITSPass) {
1970  if (isDesiredCandidate) {
1971  ((TH1F*)fDaughterHistogramArrayExtra[0][1])->Fill(11);
1972  } else ((TH1F*)fDaughterHistogramArrayExtra[0][0])->Fill(11);
1973  bCut = kTRUE;
1974  }
1975 
1976  if (!isDesiredCandidate && fQuickSignalAnalysis == 1) bCut = kTRUE;
1977 
1978  if (bCut) {
1979  if (isDesiredCandidate) {
1980  ((TH1F*)fDaughterHistogramArrayExtra[0][1])->Fill(0);
1981  } else ((TH1F*)fDaughterHistogramArrayExtra[0][0])->Fill(0);
1982  return kFALSE;
1983  }
1984 
1985  //we fill histograms with track information of the tracks that pass the cuts
1986  histType = 2;
1987  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
1988  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
1989  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
1990  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
1991 
1992  for (Int_t j = 0; j < 10; ++j)
1993  {
1994  if (aodTrack->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
1995 
1996  }
1997  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0[0]);
1998 
1999  if (isDesiredCandidate)
2000  {
2001  histType = 3;
2002  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
2003  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
2004  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
2005  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
2006 
2007  for (Int_t j = 0; j < 10; ++j)
2008  {
2009  if (aodTrack->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
2010 
2011  }
2012  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0[0]);
2013  }
2014 
2015  return kTRUE;
2016 }
2017 //-------------------------------------------------------------------------------------
2018 Bool_t AliAnalysisTaskSEBPlustoD0Pi::D0SecondDaughterSelection(AliAODTrack* aodTrack, AliAODVertex *primaryVertex, Double_t bz, TClonesArray * mcTrackArray, TMatrix * BPlustoD0PiLabelMatrix, AliAODMCHeader * header) {
2019 
2020  // we select the D0 pion and save its information
2021  if (!aodTrack) AliFatal("Not a standard AOD");
2022 
2023  //quick quality cut
2024  if (aodTrack->GetITSNcls() < 1) return kFALSE;
2025  if (aodTrack->GetTPCNcls() < 1) return kFALSE;
2026  if (aodTrack->GetStatus()&AliESDtrack::kITSpureSA) return kFALSE;
2027  if (!(aodTrack->GetStatus()&AliESDtrack::kITSin)) return kFALSE;
2028  if (aodTrack->GetID() < 0) return kFALSE;
2029  Double_t covtest[21];
2030  if (!aodTrack->GetCovarianceXYZPxPyPz(covtest)) return kFALSE;
2031 
2032  Int_t mcLabelParticle = -1;
2033  mcLabelParticle = aodTrack->GetLabel();
2034 
2035  // we fill histograms with information of the track
2036  Double_t pt_track = aodTrack->Pt();
2037  Double_t momentum_track = aodTrack->P();
2038  Int_t numberOfITS = aodTrack->GetITSNcls();
2039  Int_t numberOfTPC = aodTrack->GetTPCNcls();
2040 
2041  AliExternalTrackParam particleTrack;
2042  particleTrack.CopyFromVTrack(aodTrack);
2043  Double_t d0[2], covd0[3];
2044  particleTrack.PropagateToDCA(primaryVertex, bz, 100., d0, covd0);
2045 
2046  //we check if the particle is a signal track, we look at both daughter options therefore the signal will be too high in the D0 daughter signal histograms
2047  Bool_t isDesiredCandidate = kFALSE;
2048  if (fUseMCInfo) {
2049  TMatrix &particleMatrix = *BPlustoD0PiLabelMatrix;
2050  for (Int_t k = 0; k < BPlustoD0PiLabelMatrix->GetNrows(); ++k) {
2051  if (mcLabelParticle == (Int_t)particleMatrix(k, 1) || mcLabelParticle == (Int_t)particleMatrix(k, 2)) {
2052  isDesiredCandidate = kTRUE;
2053  break;
2054  }
2055  }
2056  }
2057 
2058  if (fUseMCInfo) {
2059  if (IsTrackInjected(aodTrack, header, mcTrackArray) && !isDesiredCandidate && fQuickSignalAnalysis == 2) return kFALSE;
2060  }
2061 
2062  Int_t daughterType = 1;
2063 
2064 
2065  Int_t histType = 0;
2066  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
2067  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
2068  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
2069  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
2070 
2071  for (Int_t j = 0; j < 10; ++j)
2072  {
2073  if (aodTrack->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
2074 
2075  }
2076  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0[0]);
2077 
2078  if (isDesiredCandidate)
2079  {
2080  histType = 1;
2081  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
2082  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
2083  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
2084  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
2085 
2086  for (Int_t j = 0; j < 10; ++j)
2087  {
2088  if (aodTrack->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
2089  }
2090  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0[0]);
2091  }
2092 
2093  //we apply a number of cuts on the particle
2094  Bool_t bCut = kFALSE;
2095 
2096  //We do not apply a PID cut at this stage since we don't know if we are dealing with a kaon or a pion
2097 
2098  if (aodTrack->GetITSNcls() < fCuts->GetMinITSNclsD0SecondDaughter()) {
2099  if (isDesiredCandidate) {
2100  ((TH1F*)fDaughterHistogramArrayExtra[1][1])->Fill(3);
2101  } else ((TH1F*)fDaughterHistogramArrayExtra[1][0])->Fill(3);
2102  bCut = kTRUE;
2103  }
2104 
2105  if (aodTrack->GetTPCNcls() < fCuts->GetMinTPCNclsD0SecondDaughter()) {
2106  if (isDesiredCandidate) {
2107  ((TH1F*)fDaughterHistogramArrayExtra[1][1])->Fill(4);
2108  } else ((TH1F*)fDaughterHistogramArrayExtra[1][0])->Fill(4);
2109  bCut = kTRUE;
2110  }
2111 
2112  if (fCuts->UseITSRefitD0SecondDaughter() == kTRUE) {
2113  if (!(aodTrack->GetStatus()&AliESDtrack::kITSrefit)) {
2114  if (isDesiredCandidate) {
2115  ((TH1F*)fDaughterHistogramArrayExtra[1][1])->Fill(5);
2116  } else ((TH1F*)fDaughterHistogramArrayExtra[1][0])->Fill(5);
2117  bCut = kTRUE;
2118  }
2119  }
2120 
2121  if (fCuts->UseTPCRefitD0SecondDaughter() == kTRUE) {
2122  if ((!(aodTrack->GetStatus()&AliESDtrack::kTPCrefit))) {
2123  if (isDesiredCandidate) {
2124  ((TH1F*)fDaughterHistogramArrayExtra[1][1])->Fill(6);
2125  } else ((TH1F*)fDaughterHistogramArrayExtra[1][0])->Fill(6);
2126  bCut = kTRUE;
2127  }
2128  }
2129 
2130  if (fCuts->UseFilterBitD0SecondDaughter() == kTRUE) {
2131  if (!(aodTrack->TestFilterMask(BIT(fCuts->GetFilterBitD0SecondDaughter())))) {
2132  if (isDesiredCandidate) {
2133  ((TH1F*)fDaughterHistogramArrayExtra[1][1])->Fill(7);
2134  } else ((TH1F*)fDaughterHistogramArrayExtra[1][0])->Fill(7);
2135  bCut = kTRUE;
2136  }
2137  }
2138 
2139  if (aodTrack->Pt() < fCuts->GetMinPtD0SecondDaughter()) {
2140  if (isDesiredCandidate) {
2141  ((TH1F*)fDaughterHistogramArrayExtra[1][1])->Fill(8);
2142  } else ((TH1F*)fDaughterHistogramArrayExtra[1][0])->Fill(8);
2143  bCut = kTRUE;
2144  }
2145 
2146  if (TMath::Abs(d0[0]) < fCuts->GetMind0D0SecondDaughter()) {
2147  if (isDesiredCandidate) {
2148  ((TH1F*)fDaughterHistogramArrayExtra[1][1])->Fill(12);
2149  } else ((TH1F*)fDaughterHistogramArrayExtra[1][0])->Fill(12);
2150  bCut = kTRUE;
2151  }
2152 
2153  if (TMath::Abs(aodTrack->Eta()) > fCuts->GetMaxAbsEtaD0SecondDaughter()) {
2154  if (isDesiredCandidate) {
2155  ((TH1F*)fDaughterHistogramArrayExtra[1][1])->Fill(9);
2156  } else ((TH1F*)fDaughterHistogramArrayExtra[1][0])->Fill(9);
2157  bCut = kTRUE;
2158  }
2159 
2160  Bool_t bHardSelectionArrayITS[7] = {kFALSE};
2161  fCuts->GetHardSelectionArrayITSD0SecondDaughter(bHardSelectionArrayITS);
2162  Bool_t bSoftSelectionArrayITS[7] = {kFALSE};
2163  fCuts->GetSoftSelectionArrayITSD0SecondDaughter(bSoftSelectionArrayITS);
2164 
2165  Bool_t bHardITSPass = kTRUE;
2166  for (Int_t j = 0; j < 7; ++j)
2167  {
2168  if (bHardSelectionArrayITS[j])
2169  {
2170  if (!aodTrack->HasPointOnITSLayer(j)) bHardITSPass = kFALSE;
2171  }
2172  }
2173 
2174  Int_t nCounterSoftSelection = 0;
2175  Bool_t bSoftITSPass = kTRUE;
2176  for (Int_t j = 0; j < 7; ++j)
2177  {
2178  if (bSoftSelectionArrayITS[j])
2179  {
2180  if (aodTrack->HasPointOnITSLayer(j)) nCounterSoftSelection++;
2181  }
2182  }
2183  if (nCounterSoftSelection < fCuts->GetNSoftITSCutD0SecondDaughter()) bSoftITSPass = kFALSE;
2184 
2185  if (!bHardITSPass) {
2186  if (isDesiredCandidate) {
2187  ((TH1F*)fDaughterHistogramArrayExtra[1][1])->Fill(10);
2188  } else ((TH1F*)fDaughterHistogramArrayExtra[1][0])->Fill(10);
2189  bCut = kTRUE;
2190  }
2191 
2192  if (!bSoftITSPass) {
2193  if (isDesiredCandidate) {
2194  ((TH1F*)fDaughterHistogramArrayExtra[1][1])->Fill(11);
2195  } else ((TH1F*)fDaughterHistogramArrayExtra[1][0])->Fill(11);
2196  bCut = kTRUE;
2197  }
2198 
2199  if (!isDesiredCandidate && fQuickSignalAnalysis == 1) bCut = kTRUE;
2200 
2201  if (bCut) {
2202  if (isDesiredCandidate) {
2203  ((TH1F*)fDaughterHistogramArrayExtra[1][1])->Fill(0);
2204  } else ((TH1F*)fDaughterHistogramArrayExtra[1][0])->Fill(0);
2205  return kFALSE;
2206  }
2207 
2208  //we fill histograms with track information of the tracks that pass the cuts
2209  histType = 2;
2210  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
2211  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
2212  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
2213  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
2214 
2215  for (Int_t j = 0; j < 10; ++j)
2216  {
2217  if (aodTrack->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
2218 
2219  }
2220  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0[0]);
2221 
2222  if (isDesiredCandidate)
2223  {
2224  histType = 3;
2225  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
2226  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
2227  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
2228  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
2229 
2230  for (Int_t j = 0; j < 10; ++j)
2231  {
2232  if (aodTrack->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
2233 
2234  }
2235  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0[0]);
2236  }
2237 
2238  return kTRUE;
2239 }
2240 //-------------------------------------------------------------------------------------
2241 void AliAnalysisTaskSEBPlustoD0Pi::BPlusPionSelection(AliAODEvent* aodEvent, AliAODVertex *primaryVertex, Double_t bz, TClonesArray * mcTrackArray, TMatrix * BPlustoD0PiLabelMatrix, AliAODMCHeader * header) {
2242 
2243  //we keep track of the number of particles we could use and how many we actually use after cuts
2244  Int_t numberofparticles = 0;
2245  Int_t numberofparticlesused = 0;
2246 
2247  TString fillthis = "";
2248 
2249  //we loop over all tracks in the event
2250  for (Int_t i = 0; i < aodEvent->GetNumberOfTracks(); i++) {
2251  AliAODTrack* aodTrack = dynamic_cast<AliAODTrack*>(aodEvent->GetTrack(i));
2252  if (!aodTrack) AliFatal("Not a standard AOD");
2253 
2254  //quick quality cut
2255  if (aodTrack->GetITSNcls() < 1) continue;
2256  if (aodTrack->GetTPCNcls() < 1) continue;
2257  if (aodTrack->GetStatus()&AliESDtrack::kITSpureSA) continue;
2258  if (!(aodTrack->GetStatus()&AliESDtrack::kITSin)) continue;
2259  if (aodTrack->GetID() < 0) continue;
2260  Double_t covtest[21];
2261  if (!aodTrack->GetCovarianceXYZPxPyPz(covtest)) continue;
2262 
2263  Double_t pos[3],cov[6];
2264  primaryVertex->GetXYZ(pos);
2265  primaryVertex->GetCovarianceMatrix(cov);
2266  const AliESDVertex vESD(pos,cov,100.,100);
2267  if(!fCuts->IsDaughterSelected(aodTrack,&vESD,fCuts->GetTrackCuts(),aodEvent)) continue;
2268 
2269  Int_t mcLabelParticle = -1;
2270  mcLabelParticle = aodTrack->GetLabel();
2271 
2272  numberofparticles++;
2273 
2274  // we fill histograms with information of the track
2275  Double_t pt_track = aodTrack->Pt();
2276  Double_t momentum_track = aodTrack->P();
2277  Int_t numberOfITS = aodTrack->GetITSNcls();
2278  Int_t numberOfTPC = aodTrack->GetTPCNcls();
2279  Double_t nSigmaTPC = 0;
2280  Double_t nSigmaTOF = 0;
2281  Int_t pionPIDnumber = 2;
2282  Int_t TPCok = 0;
2283  Int_t TOFok = 0;
2284 
2285  AliAODPidHF* trackPIDHF = (AliAODPidHF*)fCuts->GetPidHF();
2286  TPCok = trackPIDHF->GetnSigmaTPC(aodTrack, pionPIDnumber, nSigmaTPC);
2287  TOFok = trackPIDHF->GetnSigmaTOF(aodTrack, pionPIDnumber, nSigmaTOF);
2288 
2289  AliExternalTrackParam particleTrack;
2290  particleTrack.CopyFromVTrack(aodTrack);
2291  Double_t d0[2], covd0[3];
2292  particleTrack.PropagateToDCA(primaryVertex, bz, 100., d0, covd0);
2293 
2294 
2295  //we check if the particle is a signal track
2296  Bool_t isDesiredCandidate = kFALSE;
2297  if (fUseMCInfo) {
2298  TMatrix &particleMatrix = *BPlustoD0PiLabelMatrix;
2299  for (Int_t k = 0; k < BPlustoD0PiLabelMatrix->GetNrows(); ++k) {
2300  if (mcLabelParticle == (Int_t)particleMatrix(k, 0)) {
2301  isDesiredCandidate = kTRUE;
2302  break;
2303  }
2304  }
2305  }
2306 
2307  if (fUseMCInfo) {
2308  if (IsTrackInjected(aodTrack, header, mcTrackArray) && !isDesiredCandidate && fQuickSignalAnalysis == 2) continue;
2309  }
2310 
2311  Int_t daughterType = 2;
2312 
2313  Int_t histType = 0;
2314  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
2315  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
2316  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
2317  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
2318 
2319  for (Int_t j = 0; j < 10; ++j)
2320  {
2321  if (aodTrack->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
2322 
2323  }
2324 
2325  if (TPCok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(nSigmaTPC);
2326  if (TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][5])->Fill(nSigmaTOF);
2327  if (TPCok != -1 && TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][6])->Fill(sqrt(nSigmaTPC * nSigmaTPC + nSigmaTOF * nSigmaTOF));
2328  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0[0]);
2329 
2330  if (isDesiredCandidate)
2331  {
2332  histType = 1;
2333  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
2334  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
2335  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
2336  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
2337 
2338  for (Int_t j = 0; j < 10; ++j)
2339  {
2340  if (aodTrack->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
2341 
2342  }
2343 
2344  if (TPCok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(nSigmaTPC);
2345  if (TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][5])->Fill(nSigmaTOF);
2346  if (TPCok != -1 && TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][6])->Fill(sqrt(nSigmaTPC * nSigmaTPC + nSigmaTOF * nSigmaTOF));
2347  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0[0]);
2348  }
2349 
2350 
2351  //we apply a number of cuts on the particle
2352  Bool_t bCut = kFALSE;
2353 
2354 
2355  //we apply a PID cut, 2 is used to indicate we look for a pion
2356  if (!(fCuts->SelectPID(aodTrack, 2))) {
2357  if (isDesiredCandidate) {
2358  ((TH1F*)fDaughterHistogramArrayExtra[2][1])->Fill(2);
2359  } else ((TH1F*)fDaughterHistogramArrayExtra[2][0])->Fill(2);
2360  bCut = kTRUE;
2361  }
2362 
2363  if (aodTrack->GetITSNcls() < fCuts->GetMinITSNclsBPlusPion()) {
2364  if (isDesiredCandidate) {
2365  ((TH1F*)fDaughterHistogramArrayExtra[2][1])->Fill(3);
2366  } else ((TH1F*)fDaughterHistogramArrayExtra[2][0])->Fill(3);
2367  bCut = kTRUE;
2368  }
2369 
2370  if (aodTrack->GetTPCNcls() < fCuts->GetMinTPCNclsBPlusPion()) {
2371  if (isDesiredCandidate) {
2372  ((TH1F*)fDaughterHistogramArrayExtra[2][1])->Fill(4);
2373  } else ((TH1F*)fDaughterHistogramArrayExtra[2][0])->Fill(4);
2374  bCut = kTRUE;
2375  }
2376 
2377  if (fCuts->UseITSRefitBPlusPion() == kTRUE) {
2378  if (!(aodTrack->GetStatus()&AliESDtrack::kITSrefit)) {
2379  if (isDesiredCandidate) {
2380  ((TH1F*)fDaughterHistogramArrayExtra[2][1])->Fill(5);
2381  } else ((TH1F*)fDaughterHistogramArrayExtra[2][0])->Fill(5);
2382  bCut = kTRUE;
2383  }
2384  }
2385 
2386  if (fCuts->UseTPCRefitBPlusPion() == kTRUE) {
2387  if ((!(aodTrack->GetStatus()&AliESDtrack::kTPCrefit))) {
2388  if (isDesiredCandidate) {
2389  ((TH1F*)fDaughterHistogramArrayExtra[2][1])->Fill(6);
2390  } else ((TH1F*)fDaughterHistogramArrayExtra[2][0])->Fill(6);
2391  bCut = kTRUE;
2392  }
2393  }
2394 
2395  if (fCuts->UseFilterBitBPlusPion() == kTRUE) {
2396  if (!(aodTrack->TestFilterMask(BIT(fCuts->GetFilterBitBPlusPion())))) {
2397  if (isDesiredCandidate) {
2398  ((TH1F*)fDaughterHistogramArrayExtra[2][1])->Fill(7);
2399  } else ((TH1F*)fDaughterHistogramArrayExtra[2][0])->Fill(7);
2400  bCut = kTRUE;
2401  }
2402  }
2403 
2404 
2405  if (aodTrack->Pt() < fCuts->GetMinPtBPlusPion()) {
2406  if (isDesiredCandidate) {
2407  ((TH1F*)fDaughterHistogramArrayExtra[2][1])->Fill(8);
2408  } else ((TH1F*)fDaughterHistogramArrayExtra[2][0])->Fill(8);
2409  bCut = kTRUE;
2410  }
2411 
2412 
2413  if (TMath::Abs(d0[0]) < fCuts->GetMind0BPlusPion()) {
2414  if (isDesiredCandidate) {
2415  ((TH1F*)fDaughterHistogramArrayExtra[2][1])->Fill(12);
2416  } else ((TH1F*)fDaughterHistogramArrayExtra[2][0])->Fill(12);
2417  bCut = kTRUE;
2418  }
2419 
2420  if (TMath::Abs(aodTrack->Eta()) > fCuts->GetMaxAbsEtaBPlusPion()) {
2421  if (isDesiredCandidate) {
2422  ((TH1F*)fDaughterHistogramArrayExtra[2][1])->Fill(9);
2423  } else ((TH1F*)fDaughterHistogramArrayExtra[2][0])->Fill(9);
2424  bCut = kTRUE;
2425  }
2426 
2427  Bool_t bHardSelectionArrayITS[7] = {kFALSE};
2428  fCuts->GetHardSelectionArrayITSBPlusPion(bHardSelectionArrayITS);
2429  Bool_t bSoftSelectionArrayITS[7] = {kFALSE};
2430  fCuts->GetSoftSelectionArrayITSBPlusPion(bSoftSelectionArrayITS);
2431 
2432  Bool_t bHardITSPass = kTRUE;
2433  for (Int_t j = 0; j < 7; ++j)
2434  {
2435  if (bHardSelectionArrayITS[j])
2436  {
2437  if (!aodTrack->HasPointOnITSLayer(j)) bHardITSPass = kFALSE;
2438  }
2439  }
2440 
2441  Int_t nCounterSoftSelection = 0;
2442  Bool_t bSoftITSPass = kTRUE;
2443  for (Int_t j = 0; j < 7; ++j)
2444  {
2445  if (bSoftSelectionArrayITS[j])
2446  {
2447  if (aodTrack->HasPointOnITSLayer(j)) nCounterSoftSelection++;
2448  }
2449  }
2450  if (nCounterSoftSelection < fCuts->GetNSoftITSCutBPlusPion()) bSoftITSPass = kFALSE;
2451 
2452  if (!bHardITSPass) {
2453  if (isDesiredCandidate) {
2454  ((TH1F*)fDaughterHistogramArrayExtra[2][1])->Fill(10);
2455  } else ((TH1F*)fDaughterHistogramArrayExtra[2][0])->Fill(10);
2456  bCut = kTRUE;
2457  }
2458 
2459  if (!bSoftITSPass) {
2460  if (isDesiredCandidate) {
2461  ((TH1F*)fDaughterHistogramArrayExtra[2][1])->Fill(11);
2462  } else ((TH1F*)fDaughterHistogramArrayExtra[2][0])->Fill(11);
2463  bCut = kTRUE;
2464  }
2465 
2466 
2467  if (!isDesiredCandidate && fQuickSignalAnalysis == 1) bCut = kTRUE;
2468 
2469  if (bCut) {
2470  if (isDesiredCandidate) {
2471  ((TH1F*)fDaughterHistogramArrayExtra[2][1])->Fill(0);
2472  } else ((TH1F*)fDaughterHistogramArrayExtra[2][0])->Fill(0);
2473  continue;
2474  }
2475 
2476  //we fill histograms with track information of the tracks that pass the cuts
2477  histType = 2;
2478  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
2479  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
2480  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
2481  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
2482 
2483  for (Int_t j = 0; j < 10; ++j)
2484  {
2485  if (aodTrack->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
2486 
2487  }
2488 
2489  if (TPCok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(nSigmaTPC);
2490  if (TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][5])->Fill(nSigmaTOF);
2491  if (TPCok != -1 && TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][6])->Fill(sqrt(nSigmaTPC * nSigmaTPC + nSigmaTOF * nSigmaTOF));
2492  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0[0]);
2493 
2494  if (isDesiredCandidate)
2495  {
2496  histType = 3;
2497  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
2498  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
2499  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
2500  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
2501 
2502  for (Int_t j = 0; j < 10; ++j)
2503  {
2504  if (aodTrack->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
2505 
2506  }
2507 
2508  if (TPCok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(nSigmaTPC);
2509  if (TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][5])->Fill(nSigmaTOF);
2510  if (TPCok != -1 && TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][6])->Fill(sqrt(nSigmaTPC * nSigmaTPC + nSigmaTOF * nSigmaTOF));
2511  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0[0]);
2512  }
2513 
2514  fBPlusPionTracks->push_back(i);
2515  numberofparticlesused++;
2516  }
2517 
2518  // cout << "BPlus pions used: " << numberofparticlesused << endl;
2519 
2520  ((TH1F*)fDaughterHistogramArray[2][0][10])->Fill(numberofparticles);
2521  ((TH1F*)fDaughterHistogramArray[2][1][10])->Fill(numberofparticlesused);
2522  return;
2523 }
2524 //-------------------------------------------------------------------------------------
2525 void AliAnalysisTaskSEBPlustoD0Pi::D0Selection(AliAODEvent* aodEvent, AliAODVertex *primaryVertex, Double_t bz, TClonesArray * mcTrackArray, TMatrix * BPlustoD0PiLabelMatrix, TClonesArray * D0TracksFromFriendFile, AliAODMCHeader * header) {
2526 
2527  TString fillthis = "";
2528 
2530 
2531  //next we loop over all the D0 candidates
2532  for (Int_t j = 0; j < D0TracksFromFriendFile->GetEntriesFast(); j++)
2533  {
2534 
2535  //we get the track of the D0
2536  AliAODRecoDecayHF2Prong * trackD0 = (AliAODRecoDecayHF2Prong*)(D0TracksFromFriendFile->At(j));
2537  if (!trackD0) {std::cout << "found none" << std::endl; continue;}
2538  if (trackD0 == nullptr) {std::cout << "found nullptr" << std::endl; continue;}
2539 
2540  if (!(vHF->FillRecoCand(aodEvent, trackD0))) //Fill the data members of the candidate only if they are empty.
2541  {
2542  fCEvents->Fill(12); //monitor how often this fails
2543  continue;
2544  }
2545 
2546  AliAODTrack * trackFirstDaughter = (AliAODTrack*)(trackD0->GetDaughter(0));
2547  AliAODTrack * trackSecondDaughter = (AliAODTrack*)(trackD0->GetDaughter(1));
2548  if (!D0FirstDaughterSelection(trackFirstDaughter, primaryVertex, bz, mcTrackArray, BPlustoD0PiLabelMatrix, header)) continue;
2549  if (!D0SecondDaughterSelection(trackSecondDaughter, primaryVertex, bz, mcTrackArray, BPlustoD0PiLabelMatrix, header)) continue;
2550 
2551 
2552  AliAODVertex *vertexMother = (AliAODVertex*)trackD0->GetSecondaryVtx();
2553 
2554  //we check if the track is a desired candidate
2555  Int_t pdgCodeMother = -1;
2556  Bool_t isDesiredCandidate = kFALSE;
2557  Int_t motherType, histType;
2558  motherType = 0;
2559  Int_t mcLabelD0 = -1;
2560 
2561  if (fUseMCInfo)
2562  {
2563  mcLabelD0 = MatchCandidateToMonteCarlo(421, trackD0, mcTrackArray, BPlustoD0PiLabelMatrix);
2564 
2565  if (mcLabelD0 >= 0)
2566  {
2567  isDesiredCandidate = kTRUE;
2568 
2569  Int_t mcLabelFirstTrack = -1;
2570  mcLabelFirstTrack = trackFirstDaughter->GetLabel();
2571 
2572  if (mcLabelFirstTrack >= 0)
2573  {
2574  AliAODMCParticle *mcParticleFirstTrack = (AliAODMCParticle*)mcTrackArray->At(mcLabelFirstTrack);
2575  AliAODMCParticle *mcMotherParticle = (AliAODMCParticle*)mcTrackArray->At(mcLabelD0);
2576 
2577  if (mcParticleFirstTrack && mcMotherParticle)
2578  {
2579  pdgCodeMother = mcMotherParticle->GetPdgCode();
2580 
2581  Double_t vertex_distance = TMath::Sqrt((vertexMother->GetX() - mcParticleFirstTrack->Xv()) * (vertexMother->GetX() - mcParticleFirstTrack->Xv()) + (vertexMother->GetY() - mcParticleFirstTrack->Yv()) * (vertexMother->GetY() - mcParticleFirstTrack->Yv()) + (vertexMother->GetZ() - mcParticleFirstTrack->Zv()) * (vertexMother->GetZ() - mcParticleFirstTrack->Zv()));
2582  ((TH1F*)fMotherHistogramArrayExtra[motherType][4])->Fill(vertex_distance);
2583 
2584  Double_t momentum_resolution = TMath::Sqrt((trackD0->Px() - mcMotherParticle->Px()) * (trackD0->Px() - mcMotherParticle->Px()) + (trackD0->Py() - mcMotherParticle->Py()) * (trackD0->Py() - mcMotherParticle->Py()) + (trackD0->Pz() - mcMotherParticle->Pz()) * (trackD0->Pz() - mcMotherParticle->Pz()));
2585  ((TH1F*)fMotherHistogramArrayExtra[motherType][6])->Fill(momentum_resolution);
2586  }
2587  }
2588  }
2589  }
2590 
2591  // We fill the histograms
2592  histType = 0;
2593  FillD0Histograms(trackD0, primaryVertex, bz, motherType, histType);
2594  if (isDesiredCandidate && fUseMCInfo) {
2595  histType = 1;
2596  FillD0Histograms(trackD0, primaryVertex, bz, motherType, histType, pdgCodeMother);
2597  }
2598 
2599  // Here we apply cuts on the particle
2600  Bool_t cutMother = kFALSE;
2601 
2602  Bool_t bCutArray[29] = {0};
2603  Int_t cutReturnValue = fCuts->IsD0forD0ptbinSelected(trackD0, 0, aodEvent, bCutArray);
2604  if (cutReturnValue == -1) cutMother = kTRUE;
2605  if (cutReturnValue == 0) cutMother = kTRUE;
2606 
2607 
2608  if (fGetCutInfo == kTRUE)
2609  {
2610  for (Int_t k = 0; k < 29; ++k)
2611  {
2612  if (bCutArray[k] == kTRUE) {
2613  if (isDesiredCandidate) {
2614  ((TH1F*)fMotherHistogramArrayExtra[motherType][1])->Fill(k + 1);
2615  } else ((TH1F*)fMotherHistogramArrayExtra[motherType][0])->Fill(k + 1);
2616  cutMother = kTRUE;
2617  }
2618  }
2619  }
2620 
2621  if (!fCuts->AreDaughtersSelected(trackD0, aodEvent)) cutMother = kTRUE;
2622 
2623  if (!isDesiredCandidate && fQuickSignalAnalysis == 1) cutMother = kTRUE;
2624 
2625  if (cutMother) {
2626  if (isDesiredCandidate) {
2627  ((TH1F*)fMotherHistogramArrayExtra[motherType][1])->Fill(0);
2628  } else ((TH1F*)fMotherHistogramArrayExtra[motherType][0])->Fill(0);
2629  // delete vertexMother; vertexMother = nullptr;
2630  // delete trackD0; trackD0 = nullptr;
2631  continue;
2632  }
2633 
2634  // We fill the cut histograms
2635  histType = 2;
2636  FillD0Histograms(trackD0, primaryVertex, bz, motherType, histType);
2637  if (isDesiredCandidate && fUseMCInfo) {
2638  histType = 3;
2639  FillD0Histograms(trackD0, primaryVertex, bz, motherType, histType, pdgCodeMother);
2640  }
2641 
2642  //we save the location of the D0 candidate
2643  fD0Tracks->push_back(j);
2644  }
2645 
2646  delete vHF; vHF = nullptr;
2647  return;
2648 }
2649 //-------------------------------------------------------------------------------------
2650 void AliAnalysisTaskSEBPlustoD0Pi::BPlusSelection(AliAODEvent* aodEvent, AliAODVertex *primaryVertex, Double_t bz, TClonesArray * mcTrackArray, TMatrix * BPlustoD0PiLabelMatrix, TClonesArray * D0TracksFromFriendFile, AliAODMCHeader * header) {
2651 
2652  TString fillthis = "";
2653 
2654  //we loop over all the D0 candidates
2655  for (Int_t j = 0; j < (Int_t)fD0Tracks->size(); j++)
2656  {
2657 
2658  //Save current Object count
2659  Int_t ObjectNumber = TProcessID::GetObjectCount();
2660 
2661  //we get the track of the D0
2662  AliAODRecoDecayHF2Prong * trackD0 = (AliAODRecoDecayHF2Prong*)(D0TracksFromFriendFile->At(fD0Tracks->at(j)));
2663  if (!trackD0) {std::cout << "found none" << std::endl; continue;}
2664  if (trackD0 == nullptr) {std::cout << "found nullptr" << std::endl; continue;}
2665 
2666  //we loop over all the BPlus pion candidates
2667  for (Int_t i = 0; i < (Int_t)fBPlusPionTracks->size(); i++)
2668  {
2669 
2670  //we get the track of the BPlus daughter
2671  AliAODTrack * trackBPlusPion = dynamic_cast<AliAODTrack*>(aodEvent->GetTrack(fBPlusPionTracks->at(i)));
2672  if (!trackBPlusPion) continue;
2673 
2674  //we check if the IDs of the tracks are different
2675  AliAODTrack* twoProngdaughter0 = (AliAODTrack*)trackD0->GetDaughter(0);
2676  AliAODTrack* twoProngdaughter1 = (AliAODTrack*)trackD0->GetDaughter(1);
2677  UShort_t idProng0 = twoProngdaughter0->GetID();
2678  UShort_t idProng1 = twoProngdaughter1->GetID();
2679 
2680  if (trackBPlusPion->GetID() == idProng0 || trackBPlusPion->GetID() == idProng1) continue;
2681 
2682  UInt_t prongsD0[2];
2683  prongsD0[0] = 211;
2684  prongsD0[1] = 321;
2685 
2686 
2687  UInt_t prongsD02[2];
2688  prongsD02[1] = 211;
2689  prongsD02[0] = 321;
2690 
2691  // D0 window - invariant mass cut
2692  Double_t invariantMassD0 = trackD0->InvMass(2, prongsD0);
2693  Double_t invariantMassD02 = trackD0->InvMass(2, prongsD02);
2694 
2695  Double_t pdgMassD0 = TDatabasePDG::Instance()->GetParticle(421)->Mass();
2696  Double_t massWindowD0 = 0.06; //GeV/c^2 //-----------------------------------------fcuts get mass window --------------------------------------------------------------------------
2697  Int_t pdgD0 = 421;
2698 
2699  //we check if the pions have the opposite charge
2700  Bool_t bWrongSign = kFALSE;
2701  if (trackBPlusPion->Charge() == -1)
2702  {
2703  if ((fCuts->SelectPID(((AliAODTrack*)trackD0->GetDaughter(0)), 2)) && (fCuts->SelectPID(((AliAODTrack*)trackD0->GetDaughter(1)), 3))) bWrongSign = kFALSE;
2704  else if ((fCuts->SelectPID(((AliAODTrack*)trackD0->GetDaughter(0)), 3)) && (fCuts->SelectPID(((AliAODTrack*)trackD0->GetDaughter(1)), 2))) bWrongSign = kTRUE;
2705  else continue;
2706  if (TMath::Abs(invariantMassD0 - pdgMassD0) > massWindowD0) continue;
2707 
2708  } else if (trackBPlusPion->Charge() == 1) {
2709  pdgD0 = -421;
2710  if ((fCuts->SelectPID(((AliAODTrack*)trackD0->GetDaughter(0)), 3)) && (fCuts->SelectPID(((AliAODTrack*)trackD0->GetDaughter(1)), 2))) bWrongSign = kFALSE;
2711  else if ((fCuts->SelectPID(((AliAODTrack*)trackD0->GetDaughter(0)), 2)) && (fCuts->SelectPID(((AliAODTrack*)trackD0->GetDaughter(1)), 3))) bWrongSign = kTRUE;
2712  else continue;
2713  if (TMath::Abs(invariantMassD02 - pdgMassD0) > massWindowD0) continue;
2714  }
2715 
2716  //location BPlus pion rotation around PV
2717  for (Int_t iRot = 0; iRot < 1; ++iRot)
2718  {
2719  //we create a copy of the track that we will rotate
2720  AliAODTrack * trackBPlusPionRotated = new AliAODTrack(*trackBPlusPion);
2721 
2722  //for iRot == 0, we use the original unrotated track. For iRot > 0 we rotate the track and set the label to -1
2723  if (iRot != 0)
2724  {
2725  //should still check if track is already at PV
2726  Double_t dPhiRotated = trackBPlusPionRotated->Phi() + TMath::Pi() - (TMath::Pi() * fDegreePerRotation * fNumberOfRotations / (180.0 * 2.0)) + (TMath::Pi() * fDegreePerRotation * iRot / 180.0);
2727  trackBPlusPionRotated->SetPhi(dPhiRotated);
2728  }
2729 
2730 
2731  //we use the BPlus pion and D0 tracks to reconstruct the vertex for the BPlus
2732  AliExternalTrackParam firstTrack;
2733  firstTrack.CopyFromVTrack(trackBPlusPionRotated);
2734  AliExternalTrackParam secondTrack;
2735  secondTrack.CopyFromVTrack(trackD0);
2736 
2737  UInt_t prongs[2];
2738  prongs[1] = 421;
2739  prongs[0] = 211;
2740 
2741  // we calculate the vertex of the mother candidate
2742  TObjArray daughterTracks;
2743 
2744  daughterTracks.Add(&firstTrack);
2745  daughterTracks.Add(&secondTrack);
2746  Double_t dispersion = 0;
2747  AliAODVertex *vertexMother = RecalculateVertex(primaryVertex, &daughterTracks, bz, dispersion);
2748  if (!vertexMother)
2749  {
2750  delete vertexMother; vertexMother = nullptr;
2751  delete trackBPlusPionRotated; trackBPlusPionRotated = nullptr;
2752  continue;
2753  }
2754 
2755 
2756  //use the new vertex to create the BPlus candidate
2757  Double_t xdummy = 0., ydummy = 0., dca;
2758  Double_t d0z0[2], covd0z0[3], d0[2], d0err[2];
2759 
2760 
2761  firstTrack.PropagateToDCA(vertexMother, bz, 100., d0z0, covd0z0);
2762  secondTrack.PropagateToDCA(vertexMother, bz, 100., d0z0, covd0z0);
2763 
2764  //we reconstruct the mother decay prong
2765  Double_t px[2], py[2], pz[2];
2766  px[0] = firstTrack.Px();
2767  py[0] = firstTrack.Py();
2768  pz[0] = firstTrack.Pz();
2769  px[1] = secondTrack.Px();
2770  py[1] = secondTrack.Py();
2771  pz[1] = secondTrack.Pz();
2772 
2773  UShort_t id[2];
2774  id[0] = firstTrack.GetID();
2775  id[1] = secondTrack.GetID();
2776 
2777  firstTrack.PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
2778  d0[0] = d0z0[0];
2779  d0err[0] = TMath::Sqrt(covd0z0[0]);
2780  secondTrack.PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
2781  d0[1] = d0z0[0];
2782  d0err[1] = TMath::Sqrt(covd0z0[0]);
2783 
2784 
2785  dca = secondTrack.GetDCA(&firstTrack, bz, xdummy, ydummy);
2786 
2787 
2788  Short_t chargeMother = trackD0->Charge() + trackBPlusPionRotated->Charge();
2789  // cout << " charge: " << chargeMother << endl;
2790  AliAODRecoDecayHF2Prong trackBPlus(vertexMother, px, py, pz, d0, d0err, dca);
2791 
2792  trackBPlus.SetCharge(chargeMother);
2793  trackBPlus.GetSecondaryVtx()->AddDaughter(trackBPlusPionRotated);
2794  trackBPlus.GetSecondaryVtx()->AddDaughter(trackD0);
2795  trackBPlus.SetPrimaryVtxRef((AliAODVertex*)aodEvent->GetPrimaryVertex());
2796  trackBPlus.SetProngIDs(2, id);
2797 
2798  // Fiducial cut
2799  if (TMath::Abs(trackBPlus.Y(521)) > 0.8) {
2800  delete vertexMother; vertexMother = nullptr;
2801  delete trackBPlusPionRotated; trackBPlusPionRotated = nullptr;
2802  continue;
2803  }
2804 
2805  // We check if the signal is injected, optionally we can reject injected signals
2806  Bool_t fCheckInjected = kTRUE; //temp
2807  Bool_t fRemoveInjected = kFALSE; //temp
2808  Bool_t bIsInjected = kFALSE;
2809  if (fUseMCInfo) {
2810  if (fCheckInjected) bIsInjected = IsCandidateInjected(&trackBPlus, header, mcTrackArray);
2811  if (fCheckInjected && fRemoveInjected && bIsInjected) {
2812  delete vertexMother; vertexMother = nullptr;
2813  delete trackBPlusPionRotated; trackBPlusPionRotated = nullptr;
2814  continue;
2815  }
2816  }
2817 
2818  // We check if the BPlus candidate is a true signal in Monte Carlo
2819  Bool_t isDesiredCandidate = kFALSE;
2820  Int_t mcLabelBPlus = -1;
2821  fillthis = "";
2822  Int_t motherType, histType;
2823  motherType = 1;
2824 
2825  if (fUseMCInfo)
2826  {
2827  mcLabelBPlus = MatchCandidateToMonteCarlo(521, &trackBPlus, mcTrackArray, BPlustoD0PiLabelMatrix);
2828  if (mcLabelBPlus >= 0 && trackBPlusPionRotated->GetLabel() >= 0 && iRot == 0)
2829  {
2830  isDesiredCandidate = kTRUE;
2831  }
2832  }
2833 
2834  histType = 0;
2835 
2836  if (isDesiredCandidate)
2837  {
2838  AliAODMCParticle *mcTrackBPlusPion = (AliAODMCParticle*)mcTrackArray->At(trackBPlusPion->GetLabel());
2839  AliAODMCParticle *mcTrackBPlus = (AliAODMCParticle*)mcTrackArray->At(mcLabelBPlus);
2840 
2841  Double_t vertex_distance = TMath::Sqrt((primaryVertex->GetX() - mcTrackBPlusPion->Xv()) * (primaryVertex->GetX() - mcTrackBPlus->Xv()) + (primaryVertex->GetY() - mcTrackBPlus->Yv()) * (primaryVertex->GetY() - mcTrackBPlus->Yv()) + (primaryVertex->GetZ() - mcTrackBPlus->Zv()) * (primaryVertex->GetZ() - mcTrackBPlus->Zv()));
2842  ((TH1F*)fMotherHistogramArrayExtra[motherType][4])->Fill(vertex_distance);
2843 
2844  Double_t momentum_resolution = TMath::Sqrt((trackBPlus.Px() - mcTrackBPlus->Px()) * (trackBPlus.Px() - mcTrackBPlus->Px()) + (trackBPlus.Py() - mcTrackBPlus->Py()) * (trackBPlus.Py() - mcTrackBPlus->Py()) + (trackBPlus.Pz() - mcTrackBPlus->Pz()) * (trackBPlus.Pz() - mcTrackBPlus->Pz()));
2845  ((TH1F*)fMotherHistogramArrayExtra[motherType][6])->Fill(momentum_resolution);
2846  }
2847 
2848 
2849  if (!bWrongSign)
2850  {
2851  // We fill the histograms
2852  histType = 0;
2853  FillBPlusHistograms(&trackBPlus, primaryVertex, bz, motherType, histType);
2854 
2855  if (isDesiredCandidate)
2856  {
2857  histType = 1;
2858  FillBPlusHistograms(&trackBPlus, primaryVertex, bz, motherType, histType);
2859  }
2860  }
2861 
2862 
2863  // We apply cuts
2864  Bool_t cutMother = kFALSE;
2865 
2866  Bool_t bCutArray[68] = {0};
2867  Int_t numberOfCuts = 68;
2868  Int_t cutReturnValue = fCuts->IsSelected(&trackBPlus, 0, aodEvent, bCutArray);
2869  if (cutReturnValue == -1) cutMother = kTRUE;
2870  if (cutReturnValue == 0) cutMother = kTRUE;
2871 
2872 
2873  // We save information about the cuts
2874  TString histName = "";
2875  Double_t invariantMassMother = trackBPlus.InvMass(2, prongs);
2876  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(521)->Mass();
2877  Double_t massWindow = fHistMassWindow; //GeV/c^2
2878  if (fGetCutInfo == kTRUE)
2879  {
2880  for (Int_t n = 0; n < 68; ++n)
2881  {
2882  if (bCutArray[n] == kTRUE) {
2883  if (isDesiredCandidate) {
2884  ((TH1F*)fMotherHistogramArrayExtra[motherType][1])->Fill(n + 1);
2885  } else ((TH1F*)fMotherHistogramArrayExtra[motherType][0])->Fill(n + 1);
2886  cutMother = kTRUE;
2887  }
2888  }
2889 
2890  if (TMath::Abs(invariantMassMother - pdgMassMother) < massWindow) {
2891  for (Int_t l = 0; l < numberOfCuts; ++l) //total
2892  {
2893  if (bCutArray[l] == kFALSE) continue;
2894  for (Int_t j = 0; j < numberOfCuts; ++j)
2895  {
2896  if (bCutArray[j] == kFALSE) continue;
2897  if (isDesiredCandidate == kFALSE) histName = "cutEffectBackground";
2898  if (isDesiredCandidate == kTRUE) histName = "cutEffectSignal";
2899  ((TH2I*)(fOutputBPlusMC->FindObject(histName)))->Fill(l, j);
2900  }
2901  }
2902 
2903  for (Int_t l = 0; l < numberOfCuts; ++l) //unique
2904  {
2905  if (bCutArray[l] == kFALSE) continue;
2906  Bool_t bFill = kTRUE;
2907  for (Int_t j = 0; j < numberOfCuts; ++j)
2908  {
2909  if (l == j) continue;
2910  if (bCutArray[j] == kTRUE)
2911  {
2912  bFill = kFALSE;
2913  break;
2914  }
2915 
2916  }
2917  if (bFill == kTRUE)
2918  {
2919  if (isDesiredCandidate == kFALSE) histName = "cutEffectUniqueBackground";
2920  if (isDesiredCandidate == kTRUE) histName = "cutEffectUniqueSignal";
2921  ((TH1I*)(fOutputBPlusMC->FindObject(histName)))->Fill(l);
2922  }
2923  }
2924  }
2925  }
2926 
2927 
2928  if (!isDesiredCandidate && fQuickSignalAnalysis == 1) cutMother = kTRUE;
2929 
2930  if (cutMother)
2931  {
2932  if (isDesiredCandidate)
2933  {
2934  ((TH1F*)fMotherHistogramArrayExtra[motherType][1])->Fill(0);
2935  } else ((TH1F*)fMotherHistogramArrayExtra[motherType][0])->Fill(0);
2936  delete vertexMother; vertexMother = nullptr;
2937  delete trackBPlusPionRotated; trackBPlusPionRotated = nullptr;
2938  continue;
2939  }
2940 
2941 
2942  // isDesiredCandidate = kFALSE;
2943 
2944  // if (4.9 < invariantMassMother && invariantMassMother < 5.2)
2945  // {
2946  // if(!bWrongSign)
2947  // {
2948  // Int_t mcLabelBPlusPion = trackBPlusPion->GetLabel();
2949  // Int_t mcLabelD0first = ((AliAODTrack*)trackD0->GetDaughter(0))->GetLabel();
2950  // Int_t mcLabelD0second = ((AliAODTrack*)trackD0->GetDaughter(1))->GetLabel();
2951 
2952  // AliAODMCParticle * mcBPlusPion = (AliAODMCParticle*)mcTrackArray->At(mcLabelBPlusPion);
2953  // AliAODMCParticle * mcD0first = (AliAODMCParticle*)mcTrackArray->At(mcLabelD0first);
2954  // AliAODMCParticle * mcD0second = (AliAODMCParticle*)mcTrackArray->At(mcLabelD0second);
2955 
2956  // if(mcBPlusPion)
2957  // {
2958  // while(mcBPlusPion->GetMother() >= 0)
2959  // {
2960  // mcBPlusPion = (AliAODMCParticle*)mcTrackArray->At(mcBPlusPion->GetMother());
2961  // fillthis="particle_pdgBPlusPion";
2962  // ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(TMath::Abs(mcBPlusPion->GetPdgCode()));
2963  // }
2964  // }
2965 
2966  // if(mcD0first)
2967  // {
2968  // while(mcD0first->GetMother() >= 0)
2969  // {
2970  // mcD0first = (AliAODMCParticle*)mcTrackArray->At(mcD0first->GetMother());
2971  // fillthis="particle_pdgD0First";
2972  // ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(TMath::Abs(mcD0first->GetPdgCode()));
2973  // }
2974  // }
2975 
2976  // if(mcD0second)
2977  // {
2978  // while(mcD0second->GetMother() >= 0)
2979  // {
2980  // mcD0second = (AliAODMCParticle*)mcTrackArray->At(mcD0second->GetMother());
2981  // fillthis="particle_pdgD0Second";
2982  // ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(TMath::Abs(mcD0second->GetPdgCode()));
2983  // }
2984  // }
2985 
2986  // mcBPlusPion = (AliAODMCParticle*)mcTrackArray->At(mcLabelBPlusPion);
2987  // mcD0first = (AliAODMCParticle*)mcTrackArray->At(mcLabelD0first);
2988  // mcD0second = (AliAODMCParticle*)mcTrackArray->At(mcLabelD0second);
2989 
2990  // if(mcBPlusPion && mcD0first && mcD0second)
2991  // {
2992  // if(mcD0first->GetMother() == mcD0second->GetMother() && mcD0first->GetMother() >= 0)
2993  // {
2994  // AliAODMCParticle * D0Mother = (AliAODMCParticle*)mcTrackArray->At(mcD0first->GetMother());
2995  // if(D0Mother->GetMother() == mcBPlusPion->GetMother() && D0Mother->GetMother() >= 0)
2996  // {
2997  // AliAODMCParticle * finalMother = (AliAODMCParticle*)mcTrackArray->At(D0Mother->GetMother());
2998  // fillthis="particle_pdgAll";
2999  // ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(TMath::Abs(finalMother->GetPdgCode()));
3000  // fillthis="particle_pdgAllInvMass";
3001  // ((TH2F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(TMath::Abs(finalMother->GetPdgCode()),invariantMassMother);
3002  // if(finalMother->GetPdgCode()==511)
3003  // {
3004  // // isDesiredCandidate = kTRUE;
3005  // for (Int_t iDaughter = 0; iDaughter < finalMother->GetNDaughters(); ++iDaughter) //will work up to ten daughters
3006  // {
3007  // AliAODMCParticle* daughterfinalMother = (AliAODMCParticle*)mcTrackArray->At(finalMother->GetDaughter(0)+iDaughter);
3008  // fillthis="particle_daughterPdgOneStep511";
3009  // ((TH2F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(iDaughter,TMath::Abs(daughterfinalMother->GetPdgCode()));
3010  // }
3011  // for (Int_t iDaughter = 0; iDaughter < D0Mother->GetNDaughters(); ++iDaughter) //will work up to ten daughters
3012  // {
3013  // AliAODMCParticle* daughterD0Mother = (AliAODMCParticle*)mcTrackArray->At(D0Mother->GetDaughter(0)+iDaughter);
3014  // fillthis="particle_daughterPdgOneStep511";
3015  // ((TH2F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(iDaughter+10,TMath::Abs(daughterD0Mother->GetPdgCode()));
3016  // }
3017  // }
3018  // if(finalMother->GetPdgCode()==521)
3019  // {
3020  // // isDesiredCandidate = kTRUE;
3021  // for (Int_t iDaughter = 0; iDaughter < finalMother->GetNDaughters(); ++iDaughter) //will work up to ten daughters
3022  // {
3023  // AliAODMCParticle* daughterfinalMother = (AliAODMCParticle*)mcTrackArray->At(finalMother->GetDaughter(0)+iDaughter);
3024  // fillthis="particle_daughterPdgOneStep521";
3025  // ((TH2F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(iDaughter,TMath::Abs(daughterfinalMother->GetPdgCode()));
3026  // }
3027  // for (Int_t iDaughter = 0; iDaughter < D0Mother->GetNDaughters(); ++iDaughter) //will work up to ten daughters
3028  // {
3029  // AliAODMCParticle* daughterD0Mother = (AliAODMCParticle*)mcTrackArray->At(D0Mother->GetDaughter(0)+iDaughter);
3030  // fillthis="particle_daughterPdgOneStep521";
3031  // ((TH2F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(iDaughter+10,TMath::Abs(daughterD0Mother->GetPdgCode()));
3032  // }
3033  // }
3034  // }
3035  // }
3036 
3037  // if(mcD0first->GetMother() == mcD0second->GetMother() && mcD0first->GetMother() >= 0)
3038  // {
3039  // AliAODMCParticle * D0Mother = (AliAODMCParticle*)mcTrackArray->At(mcD0first->GetMother());
3040  // AliAODMCParticle * D0GrandMother = (AliAODMCParticle*)mcTrackArray->At(D0Mother->GetMother());
3041  // if(D0GrandMother->GetMother() == mcBPlusPion->GetMother() && D0GrandMother->GetMother() >= 0)
3042  // {
3043  // AliAODMCParticle * finalMother = (AliAODMCParticle*)mcTrackArray->At(D0GrandMother->GetMother());
3044  // fillthis="particle_pdgAllSecond";
3045  // ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(TMath::Abs(finalMother->GetPdgCode()));
3046  // fillthis="particle_pdgAllSecondInvMass";
3047  // ((TH2F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(TMath::Abs(finalMother->GetPdgCode()),invariantMassMother);
3048  // if(finalMother->GetPdgCode()==511)
3049  // {
3050  // // isDesiredCandidate = kTRUE;
3051  // for (Int_t iDaughter = 0; iDaughter < finalMother->GetNDaughters(); ++iDaughter) //will work up to ten daughters
3052  // {
3053  // AliAODMCParticle* daughterfinalMother = (AliAODMCParticle*)mcTrackArray->At(finalMother->GetDaughter(0)+iDaughter);
3054  // fillthis="particle_daughterPdgTwoStep511";
3055  // ((TH2F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(iDaughter,TMath::Abs(daughterfinalMother->GetPdgCode()));
3056  // }
3057  // for (Int_t iDaughter = 0; iDaughter < D0GrandMother->GetNDaughters(); ++iDaughter) //will work up to ten daughters
3058  // {
3059  // AliAODMCParticle* daughterD0GrandMother = (AliAODMCParticle*)mcTrackArray->At(D0GrandMother->GetDaughter(0)+iDaughter);
3060  // fillthis="particle_daughterPdgTwoStep511";
3061  // ((TH2F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(iDaughter+10,TMath::Abs(daughterD0GrandMother->GetPdgCode()));
3062  // }
3063  // for (Int_t iDaughter = 0; iDaughter < D0Mother->GetNDaughters(); ++iDaughter) //will work up to ten daughters
3064  // {
3065  // AliAODMCParticle* daughterD0Mother = (AliAODMCParticle*)mcTrackArray->At(D0Mother->GetDaughter(0)+iDaughter);
3066  // fillthis="particle_daughterPdgTwoStep511";
3067  // ((TH2F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(iDaughter+20,TMath::Abs(daughterD0Mother->GetPdgCode()));
3068  // }
3069  // }
3070  // if(finalMother->GetPdgCode()==521)
3071  // {
3072  // // isDesiredCandidate = kTRUE;
3073  // for (Int_t iDaughter = 0; iDaughter < finalMother->GetNDaughters(); ++iDaughter) //will work up to ten daughters
3074  // {
3075  // AliAODMCParticle* daughterfinalMother = (AliAODMCParticle*)mcTrackArray->At(finalMother->GetDaughter(0)+iDaughter);
3076  // fillthis="particle_daughterPdgTwoStep521";
3077  // ((TH2F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(iDaughter,TMath::Abs(daughterfinalMother->GetPdgCode()));
3078  // }
3079  // for (Int_t iDaughter = 0; iDaughter < D0GrandMother->GetNDaughters(); ++iDaughter) //will work up to ten daughters
3080  // {
3081  // AliAODMCParticle* daughterD0GrandMother = (AliAODMCParticle*)mcTrackArray->At(D0GrandMother->GetDaughter(0)+iDaughter);
3082  // fillthis="particle_daughterPdgTwoStep521";
3083  // ((TH2F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(iDaughter+10,TMath::Abs(daughterD0GrandMother->GetPdgCode()));
3084  // }
3085  // for (Int_t iDaughter = 0; iDaughter < D0Mother->GetNDaughters(); ++iDaughter) //will work up to ten daughters
3086  // {
3087  // AliAODMCParticle* daughterD0Mother = (AliAODMCParticle*)mcTrackArray->At(D0Mother->GetDaughter(0)+iDaughter);
3088  // fillthis="particle_daughterPdgTwoStep521";
3089  // ((TH2F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(iDaughter+20,TMath::Abs(daughterD0Mother->GetPdgCode()));
3090  // }
3091  // }
3092  // }
3093  // }
3094  // }
3095 
3096  // }
3097  // }
3098 
3099 
3100  if (!bWrongSign)
3101  {
3102  histType = 2;
3103  FillBPlusHistograms(&trackBPlus, primaryVertex, bz, motherType, histType);
3104  if (fUseMCInfo && isDesiredCandidate)
3105  {
3106  //fill mc histograms
3107  histType = 3;
3108  FillBPlusHistograms(&trackBPlus, primaryVertex, bz, motherType, histType);
3109  }
3110  }
3111 
3112 
3113  // pdgMassMother=TDatabasePDG::Instance()->GetParticle(521)->Mass();
3114  // Double_t massWindow =fHistMassWindow; //GeV/c^2
3115  if (TMath::Abs(invariantMassMother - pdgMassMother) < massWindow)
3116  {
3117  if (!bWrongSign)
3118  {
3119  FillFinalTrackHistograms(&trackBPlus, primaryVertex, bz, isDesiredCandidate, mcTrackArray);
3120  if (!isDesiredCandidate)
3121  {
3122  motherType = 0; histType = 4; FillD0Histograms(trackD0, primaryVertex, bz, motherType, histType, pdgD0);
3123  motherType = 1; histType = 4; FillBPlusHistograms(&trackBPlus, primaryVertex, bz, motherType, histType);
3124  }
3125  if (isDesiredCandidate)
3126  {
3127  motherType = 0; histType = 5; FillD0Histograms(trackD0, primaryVertex, bz, motherType, histType, pdgD0);
3128  motherType = 1; histType = 5; FillBPlusHistograms(&trackBPlus, primaryVertex, bz, motherType, histType);
3129  }
3130  }
3131  }
3132 
3133 
3134  // Here we fill the histograms per pt bin and apply the same sign method
3135  TString ptBinMother = "";
3136  Int_t ptBin = fCuts->PtBin(trackBPlus.Pt());
3137  ptBinMother += "_ptbin_"; ptBinMother += fPtBinLimits[ptBin]; ptBinMother += "_to_"; ptBinMother += fPtBinLimits[ptBin + 1];
3138  histType = 6 + 2 * ptBin;
3139 
3140  Int_t d0PtBin = fCuts->PtBinD0forD0ptbin(trackD0->Pt());
3141  Int_t histTypeD0 = 2 * d0PtBin;
3142 
3143 
3144  if (TMath::Abs(invariantMassMother - pdgMassMother) < massWindow)
3145  {
3146  if (!bWrongSign && histType > 5)
3147  {
3148  if (!isDesiredCandidate)
3149  {
3150  motherType = 0; FillD0Histograms(trackD0, primaryVertex, bz, motherType, histType, pdgD0);
3151  motherType = 1; FillBPlusHistograms(&trackBPlus, primaryVertex, bz, motherType, histType);
3152  motherType = 2; FillD0Histograms(trackD0, primaryVertex, bz, motherType, histTypeD0, pdgD0);
3153  }
3154 
3155  if (isDesiredCandidate)
3156  {
3157  histType += 1;
3158  motherType = 0; FillD0Histograms(trackD0, primaryVertex, bz, motherType, histType, pdgD0);
3159  motherType = 1; FillBPlusHistograms(&trackBPlus, primaryVertex, bz, motherType, histType);
3160  motherType = 2; FillD0Histograms(trackD0, primaryVertex, bz, motherType, histTypeD0 + 1, pdgD0);
3161  }
3162  }
3163  }
3164 
3165  // after the (loose) cut on candidates we can get data for cut optimization
3166  if (!bWrongSign && fPerformCutOptimization)
3167  {
3168  Double_t massWindowForCutOptimization = 3 * fCuts->GetSigmaForCutOptimization(ptBin);
3169  if(TMath::Abs(invariantMassMother - pdgMassMother) < massWindowForCutOptimization)
3170  {
3171  Int_t nStartVariable = 0;
3172  Int_t nStartFillNumber = 0;
3174  Int_t nCuts = fCuts->GetnCutsForOptimization();
3175  CutOptimizationVariableValues(&trackBPlus, aodEvent);
3176  CutOptimizationLoop(nStartVariable, nVariables, nCuts, ptBin, nStartFillNumber, isDesiredCandidate);
3177  }
3178  }
3179 
3180 
3181  Double_t invmassDelta = DeltaInvMassBPlusKpipi(&trackBPlus);
3182  if (bWrongSign && iRot == 0)
3183  {
3184  fillthis = "invariantMassBPlus";
3185  fillthis += "_SameSign";
3186  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3187  fillthis = "invariantMassBPlus";
3188  fillthis += ptBinMother + "_SameSign";
3189  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3190  fillthis = "invariantMassBPlus";
3191  fillthis += "_SignSum";
3192  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother, -1);
3193  fillthis = "invariantMassBPlus";
3194  fillthis += ptBinMother + "_SignSum";
3195  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother, -1);
3196  }
3197  if (!bWrongSign)
3198  {
3199  if (iRot == 0)
3200  {
3201  fillthis = "invariantMassBPlus";
3202  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3203  fillthis = "invariantMassBPlus";
3204  fillthis += ptBinMother;
3205  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3206  fillthis = "invariantMassBPlus";
3207  fillthis += "_SignSum";
3208  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother, 1);
3209  fillthis = "invariantMassBPlus";
3210  fillthis += ptBinMother + "_SignSum";
3211  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother, 1);
3212 
3213  // fillthis = "invariantMassBPlusSignal_BA";
3214  // if(isDesiredCandidate) ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3215 
3216  // fillthis = "invariantMassBPlusCorrelated_BA";
3217  // if(bIsCorrelatedBackground) ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3218 
3219  // fillthis = "invariantMassBPlusBackground_BA";
3220  // if(!isDesiredCandidate && !bIsCorrelatedBackground) ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3221 
3222  // if(bIsCorrelatedBackground511)
3223  // {
3224  // fillthis="invariantMassBPlus_correlated511";
3225  // ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3226  // fillthis="invariantMassBPlus";
3227  // fillthis += ptBinMother + "_correlated511";
3228  // ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3229  // }
3230 
3231  if (!isDesiredCandidate && !bIsInjected)
3232  {
3233  TString signName = "_HIJING_Background";
3234  fillthis = "invariantMassBPlus";
3235  fillthis += signName;
3236  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3237  fillthis = "invariantMassBPlus";
3238  fillthis += ptBinMother + signName;
3239  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3240  }
3241  if (isDesiredCandidate && !bIsInjected)
3242  {
3243  TString signName = "_HIJING_Signal";
3244  fillthis = "invariantMassBPlus";
3245  fillthis += signName;
3246  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3247  fillthis = "invariantMassBPlus";
3248  fillthis += ptBinMother + signName;
3249  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3250  }
3251  }
3252  else
3253  {
3254  TString signName = "_Background_rotation";
3255  fillthis = "invariantMassBPlus";
3256  fillthis += signName;
3257  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3258  fillthis = "invariantMassBPlus";
3259  fillthis += ptBinMother + signName;
3260  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3261  if (!isDesiredCandidate && !bIsInjected)
3262  {
3263  signName = "_HIJING_Background_rotation";
3264  fillthis = "invariantMassBPlus";
3265  fillthis += signName;
3266  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3267  fillthis = "invariantMassBPlus";
3268  fillthis += ptBinMother + signName;
3269  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3270  }
3271  }
3272  }
3273 
3274  if (trackBPlus.Pt() > 6.0)
3275  {
3276  TString broadptBinMother = "_ptbin_6_to_inf";
3277  if (bWrongSign && iRot == 0)
3278  {
3279  fillthis = "invariantMassBPlus";
3280  fillthis += broadptBinMother + "_SameSign";
3281  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3282  fillthis = "invariantMassBPlus";
3283  fillthis += broadptBinMother + "_SignSum";
3284  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother, -1);
3285  }
3286  if (!bWrongSign)
3287  {
3288  if (iRot == 0)
3289  {
3290  fillthis = "invariantMassBPlus";
3291  fillthis += broadptBinMother;
3292  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3293  fillthis = "invariantMassBPlus";
3294  fillthis += broadptBinMother + "_SignSum";
3295  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother, 1);
3296  if (!isDesiredCandidate && !bIsInjected)
3297  {
3298  TString signName = "_HIJING_Background";
3299  fillthis = "invariantMassBPlus";
3300  fillthis += broadptBinMother + signName;
3301  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3302  }
3303  if (isDesiredCandidate && !bIsInjected)
3304  {
3305  TString signName = "_HIJING_Signal";
3306  fillthis = "invariantMassBPlus";
3307  fillthis += broadptBinMother + signName;
3308  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3309  }
3310  }
3311  else
3312  {
3313  TString signName = "_Background_rotation";
3314  fillthis = "invariantMassBPlus";
3315  fillthis += broadptBinMother + signName;
3316  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3317  if (!isDesiredCandidate && !bIsInjected)
3318  {
3319  signName = "_HIJING_Background_rotation";
3320  fillthis = "invariantMassBPlus";
3321  fillthis += broadptBinMother + signName;
3322  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3323  }
3324  }
3325  }
3326  }
3327 
3328  if (trackBPlus.Pt() > 3.0)
3329  {
3330  TString broadptBinMother = "_ptbin_3_to_inf";
3331  if (bWrongSign && iRot == 0)
3332  {
3333  fillthis = "invariantMassBPlus";
3334  fillthis += broadptBinMother + "_SameSign";
3335  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3336  fillthis = "invariantMassBPlus";
3337  fillthis += broadptBinMother + "_SignSum";
3338  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother, -1);
3339  }
3340  if (!bWrongSign)
3341  {
3342  if (iRot == 0)
3343  {
3344  fillthis = "invariantMassBPlus";
3345  fillthis += broadptBinMother;
3346  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3347  fillthis = "invariantMassBPlus";
3348  fillthis += broadptBinMother + "_SignSum";
3349  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother, 1);
3350  if (!isDesiredCandidate && !bIsInjected)
3351  {
3352  TString signName = "_HIJING_Background";
3353  fillthis = "invariantMassBPlus";
3354  fillthis += broadptBinMother + signName;
3355  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3356  }
3357  if (isDesiredCandidate && !bIsInjected)
3358  {
3359  TString signName = "_HIJING_Signal";
3360  fillthis = "invariantMassBPlus";
3361  fillthis += broadptBinMother + signName;
3362  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3363  }
3364  }
3365  else
3366  {
3367  TString signName = "_Background_rotation";
3368  fillthis = "invariantMassBPlus";
3369  fillthis += broadptBinMother + signName;
3370  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3371  if (!isDesiredCandidate && !bIsInjected)
3372  {
3373  signName = "_HIJING_Background_rotation";
3374  fillthis = "invariantMassBPlus";
3375  fillthis += broadptBinMother + signName;
3376  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invariantMassMother);
3377  }
3378  }
3379  }
3380  }
3381 
3382 
3383  //deltamass
3384  if (bWrongSign && iRot == 0)
3385  {
3386  fillthis = "deltainvariantMassBPlus";
3387  fillthis += "_SameSign";
3388  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta);
3389  fillthis = "deltainvariantMassBPlus";
3390  fillthis += ptBinMother + "_SameSign";
3391  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta);
3392  fillthis = "deltainvariantMassBPlus";
3393  fillthis += "_SignSum";
3394  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta, -1);
3395  fillthis = "deltainvariantMassBPlus";
3396  fillthis += ptBinMother + "_SignSum";
3397  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta, -1);
3398  }
3399  if (!bWrongSign)
3400  {
3401  if (iRot == 0)
3402  {
3403  fillthis = "deltainvariantMassBPlus";
3404  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta);
3405  fillthis = "deltainvariantMassBPlus";
3406  fillthis += ptBinMother;
3407  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta);
3408  fillthis = "deltainvariantMassBPlus";
3409  fillthis += "_SignSum";
3410  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta, 1);
3411  fillthis = "deltainvariantMassBPlus";
3412  fillthis += ptBinMother + "_SignSum";
3413  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta, 1);
3414 
3415  // if(bIsCorrelatedBackground511)
3416  // {
3417  // fillthis="deltainvariantMassBPlus_correlated511";
3418  // ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta);
3419  // fillthis="deltainvariantMassBPlus";
3420  // fillthis += ptBinMother + "_correlated511" ;
3421  // ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta);
3422  // }
3423 
3424  if (!isDesiredCandidate && !bIsInjected)
3425  {
3426  TString signName = "_HIJING_Background";
3427  fillthis = "deltainvariantMassBPlus";
3428  fillthis += signName;
3429  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta);
3430  fillthis = "deltainvariantMassBPlus";
3431  fillthis += ptBinMother + signName;
3432  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta);
3433  }
3434  if (isDesiredCandidate && !bIsInjected)
3435  {
3436  TString signName = "_HIJING_Signal";
3437  fillthis = "deltainvariantMassBPlus";
3438  fillthis += signName;
3439  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta);
3440  fillthis = "deltainvariantMassBPlus";
3441  fillthis += ptBinMother + signName;
3442  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta);
3443  }
3444  }
3445  else
3446  {
3447  TString signName = "_Background_rotation";
3448  fillthis = "deltainvariantMassBPlus";
3449  fillthis += signName;
3450  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta);
3451  fillthis = "deltainvariantMassBPlus";
3452  fillthis += ptBinMother + signName;
3453  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta);
3454  if (!isDesiredCandidate && !bIsInjected)
3455  {
3456  signName = "_HIJING_Background_rotation";
3457  fillthis = "deltainvariantMassBPlus";
3458  fillthis += signName;
3459  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta);
3460  fillthis = "deltainvariantMassBPlus";
3461  fillthis += ptBinMother + signName;
3462  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta);
3463  }
3464  }
3465  }
3466 
3467  if (trackBPlus.Pt() > 6.0)
3468  {
3469  TString broadptBinMother = "_ptbin_6_to_inf";
3470  if (bWrongSign && iRot == 0)
3471  {
3472  fillthis = "deltainvariantMassBPlus";
3473  fillthis += broadptBinMother + "_SameSign";
3474  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta);
3475  fillthis = "deltainvariantMassBPlus";
3476  fillthis += broadptBinMother + "_SignSum";
3477  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta, -1);
3478  }
3479  if (!bWrongSign)
3480  {
3481  if (iRot == 0)
3482  {
3483  fillthis = "deltainvariantMassBPlus";
3484  fillthis += broadptBinMother;
3485  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta);
3486  fillthis = "deltainvariantMassBPlus";
3487  fillthis += broadptBinMother + "_SignSum";
3488  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta, 1);
3489  if (!isDesiredCandidate && !bIsInjected)
3490  {
3491  TString signName = "_HIJING_Background";
3492  fillthis = "deltainvariantMassBPlus";
3493  fillthis += broadptBinMother + signName;
3494  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta);
3495  }
3496  if (isDesiredCandidate && !bIsInjected)
3497  {
3498  TString signName = "_HIJING_Signal";
3499  fillthis = "deltainvariantMassBPlus";
3500  fillthis += broadptBinMother + signName;
3501  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta);
3502  }
3503  }
3504  else
3505  {
3506  TString signName = "_Background_rotation";
3507  fillthis = "deltainvariantMassBPlus";
3508  fillthis += broadptBinMother + signName;
3509  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta);
3510  if (!isDesiredCandidate && !bIsInjected)
3511  {
3512  signName = "_HIJING_Background_rotation";
3513  fillthis = "deltainvariantMassBPlus";
3514  fillthis += broadptBinMother + signName;
3515  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta);
3516  }
3517  }
3518  }
3519  }
3520 
3521  if (trackBPlus.Pt() > 3.0)
3522  {
3523  TString broadptBinMother = "_ptbin_3_to_inf";
3524  if (bWrongSign && iRot == 0)
3525  {
3526  fillthis = "deltainvariantMassBPlus";
3527  fillthis += broadptBinMother + "_SameSign";
3528  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta);
3529  fillthis = "deltainvariantMassBPlus";
3530  fillthis += broadptBinMother + "_SignSum";
3531  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta, -1);
3532  }
3533  if (!bWrongSign)
3534  {
3535  if (iRot == 0)
3536  {
3537  fillthis = "deltainvariantMassBPlus";
3538  fillthis += broadptBinMother;
3539  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta);
3540  fillthis = "deltainvariantMassBPlus";
3541  fillthis += broadptBinMother + "_SignSum";
3542  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta, 1);
3543  if (!isDesiredCandidate && !bIsInjected)
3544  {
3545  TString signName = "_HIJING_Background";
3546  fillthis = "deltainvariantMassBPlus";
3547  fillthis += broadptBinMother + signName;
3548  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta);
3549  }
3550  if (isDesiredCandidate && !bIsInjected)
3551  {
3552  TString signName = "_HIJING_Signal";
3553  fillthis = "deltainvariantMassBPlus";
3554  fillthis += broadptBinMother + signName;
3555  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta);
3556  }
3557  }
3558  else
3559  {
3560  TString signName = "_Background_rotation";
3561  fillthis = "deltainvariantMassBPlus";
3562  fillthis += broadptBinMother + signName;
3563  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta);
3564  if (!isDesiredCandidate && !bIsInjected)
3565  {
3566  signName = "_HIJING_Background_rotation";
3567  fillthis = "deltainvariantMassBPlus";
3568  fillthis += broadptBinMother + signName;
3569  ((TH1F*)(fOutputBPlusMC->FindObject(fillthis)))->Fill(invmassDelta);
3570  }
3571  }
3572  }
3573  }
3574 
3575  //we save the mother to a TClonesArray
3576  //if(!bWrongSign) new ((*fBPlusTracks)[iClonesArray++]) AliAODRecoDecayHF2Prong(*trackBPlus);
3577  delete vertexMother; vertexMother = NULL;
3578  delete trackBPlusPionRotated; trackBPlusPionRotated = nullptr;
3579  }
3580  }
3581 
3582  //Restore Object count
3583  //To save space in the table keeping track of all referenced objects,
3584  //we reset the object count to what it was at the beginning of the loop.
3585  TProcessID::SetObjectCount(ObjectNumber);
3586  }
3587  return;
3588 }
3589 //-------------------------------------------------------------------------------------
3590 void AliAnalysisTaskSEBPlustoD0Pi::FillFinalTrackHistograms(AliAODRecoDecayHF2Prong * selectedBPlus, AliAODVertex *primaryVertex, Double_t bz, Bool_t isDesiredCandidate, TClonesArray * mcTrackArray) {
3591 
3592  //In this function we fill histograms with the properties of all the daughters of our selected signal candidate
3593 
3594  AliAODTrack* selectedBPlusPion = (AliAODTrack*)selectedBPlus->GetDaughter(0);
3595  AliAODRecoDecayHF2Prong* selectedD0 = (AliAODRecoDecayHF2Prong*)selectedBPlus->GetDaughter(1);
3596 
3597  AliAODTrack* selectedD0Pion;
3598  AliAODTrack* selectedD0Kaon;
3599 
3600  if (selectedBPlus->Charge() == 1) selectedD0Pion = (AliAODTrack*)selectedD0->GetDaughter(0);
3601  if (selectedBPlus->Charge() == -1) selectedD0Pion = (AliAODTrack*)selectedD0->GetDaughter(1);
3602 
3603  if (selectedBPlus->Charge() == 1) selectedD0Kaon = (AliAODTrack*)selectedD0->GetDaughter(1);
3604  if (selectedBPlus->Charge() == -1) selectedD0Kaon = (AliAODTrack*)selectedD0->GetDaughter(0);
3605 
3606  Double_t d0BPluspion = TMath::Abs(selectedBPlus->Getd0Prong(0));
3607  Double_t d0D0pion = 0;
3608  Double_t d0D0kaon = 0;
3609 
3610  if (selectedBPlus->Charge() == 1) d0D0pion = selectedD0->Getd0Prong(0);
3611  if (selectedBPlus->Charge() == -1) d0D0pion = selectedD0->Getd0Prong(1);
3612 
3613  if (selectedBPlus->Charge() == 1) d0D0kaon = selectedD0->Getd0Prong(1);
3614  if (selectedBPlus->Charge() == -1) d0D0kaon = selectedD0->Getd0Prong(0);
3615 
3616  Double_t pt_track = 0;
3617  Double_t momentum_track = 0;
3618  Int_t numberOfITS = 0;
3619  Int_t numberOfTPC = 0;
3620  Int_t daughterType, histType;
3621  Int_t totalNumberOfITS = 0;
3622  Int_t totalNumberOfTPC = 0;
3623  Double_t nSigmaTPC = 0;
3624  Double_t nSigmaTOF = 0;
3625  Double_t nSigmaTPCtotal = 0;
3626  Double_t nSigmaTOFtotal = 0;
3627  Int_t pionPIDnumber = 2;
3628  Int_t kaonPIDnumber = 3;
3629  Int_t TPCok = 0;
3630  Int_t TOFok = 0;
3631 
3632  AliAODPidHF* trackPIDHF = (AliAODPidHF*)fCuts->GetPidHF();
3633 
3634  //fill the D0 pion info
3635  pt_track = selectedD0Pion->Pt();
3636  momentum_track = selectedD0Pion->P();
3637  numberOfITS = selectedD0Pion->GetITSNcls();
3638  numberOfTPC = selectedD0Pion->GetTPCNcls();
3639  totalNumberOfITS += numberOfITS;
3640  totalNumberOfTPC += numberOfTPC;
3641  TPCok = trackPIDHF->GetnSigmaTPC(selectedD0Pion, pionPIDnumber, nSigmaTPC);
3642  TOFok = trackPIDHF->GetnSigmaTOF(selectedD0Pion, pionPIDnumber, nSigmaTOF);
3643  if (TPCok != -1) nSigmaTPCtotal += nSigmaTPC * nSigmaTPC;
3644  if (TOFok != -1) nSigmaTOFtotal += nSigmaTOF * nSigmaTOF;
3645 
3646  Double_t ptBPlus = selectedBPlus->Pt();
3647 
3648  daughterType = 0;
3649  histType = 4;
3650  if (!isDesiredCandidate)
3651  {
3652  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
3653  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
3654  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
3655  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
3656 
3657  for (Int_t j = 0; j < 10; ++j)
3658  {
3659  if (selectedD0Pion->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
3660 
3661  }
3662 
3663  if (TPCok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(nSigmaTPC);
3664  if (TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][5])->Fill(nSigmaTOF);
3665  if (TPCok != -1 && TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][6])->Fill(sqrt(nSigmaTPC * nSigmaTPC + nSigmaTOF * nSigmaTOF));
3666  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0D0pion);
3667  ((TH1F*)fDaughterHistogramArray[daughterType][histType][9])->Fill(selectedD0Pion->Eta());
3668  ((TH2F*)fDaughterHistogramArray2D[daughterType][4])->Fill(ptBPlus, pt_track);
3669  }
3670 
3671  if (isDesiredCandidate)
3672  {
3673  histType = 5;
3674  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
3675  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
3676  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
3677  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
3678 
3679  for (Int_t j = 0; j < 10; ++j)
3680  {
3681  if (selectedD0Pion->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
3682 
3683  }
3684 
3685  if (TPCok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(nSigmaTPC);
3686  if (TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][5])->Fill(nSigmaTOF);
3687  if (TPCok != -1 && TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][6])->Fill(sqrt(nSigmaTPC * nSigmaTPC + nSigmaTOF * nSigmaTOF));
3688  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0D0pion);
3689  ((TH1F*)fDaughterHistogramArray[daughterType][histType][9])->Fill(selectedD0Pion->Eta());
3690  ((TH2F*)fDaughterHistogramArray2D[daughterType][5])->Fill(ptBPlus, pt_track);
3691  }
3692 
3693  //we save the pdgcode of the used particle and its mother to check PID efficiency
3694  if (fUseMCInfo)
3695  {
3696  Float_t pdgCodeParticle = -1;
3697  Float_t pdgCodeParticleMother = -1;
3698  Int_t mcLabelParticle = -1;
3699  Int_t mcLabelParticleMother = -1;
3700  mcLabelParticle = selectedD0Pion->GetLabel();
3701 
3702  if (mcLabelParticle >= 0) {
3703 
3704  AliAODMCParticle *mcTrackParticle = (AliAODMCParticle*)mcTrackArray->At(mcLabelParticle);
3705  pdgCodeParticle = TMath::Abs(mcTrackParticle->GetPdgCode());
3706  ((TH1F*)fDaughterHistogramArrayExtra[0][2])->Fill(pdgCodeParticle);
3707  mcLabelParticleMother = mcTrackParticle->GetMother();
3708 
3709  if (mcLabelParticleMother >= 0) {
3710  AliAODMCParticle *mcTrackParticleMother = (AliAODMCParticle*)mcTrackArray->At(mcLabelParticleMother);
3711  pdgCodeParticleMother = TMath::Abs(mcTrackParticleMother->GetPdgCode());
3712  ((TH1F*)fDaughterHistogramArrayExtra[0][3])->Fill(pdgCodeParticleMother);
3713  }
3714  }
3715  }
3716 
3717  //fill the D0 kaon info
3718  pt_track = selectedD0Kaon->Pt();
3719  momentum_track = selectedD0Kaon->P();
3720  numberOfITS = selectedD0Kaon->GetITSNcls();
3721  numberOfTPC = selectedD0Kaon->GetTPCNcls();
3722  totalNumberOfITS += numberOfITS;
3723  totalNumberOfTPC += numberOfTPC;
3724  TPCok = trackPIDHF->GetnSigmaTPC(selectedD0Kaon, kaonPIDnumber, nSigmaTPC);
3725  TOFok = trackPIDHF->GetnSigmaTOF(selectedD0Kaon, kaonPIDnumber, nSigmaTOF);
3726  if (TPCok != -1) nSigmaTPCtotal += nSigmaTPC * nSigmaTPC;
3727  if (TOFok != -1) nSigmaTOFtotal += nSigmaTOF * nSigmaTOF;
3728 
3729  daughterType = 1;
3730  histType = 4;
3731  if (!isDesiredCandidate)
3732  {
3733  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
3734  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
3735  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
3736  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
3737 
3738  for (Int_t j = 0; j < 10; ++j)
3739  {
3740  if (selectedD0Kaon->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
3741 
3742  }
3743 
3744  if (TPCok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(nSigmaTPC);
3745  if (TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][5])->Fill(nSigmaTOF);
3746  if (TPCok != -1 && TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][6])->Fill(sqrt(nSigmaTPC * nSigmaTPC + nSigmaTOF * nSigmaTOF));
3747  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0D0kaon);
3748  ((TH1F*)fDaughterHistogramArray[daughterType][histType][9])->Fill(selectedD0Kaon->Eta());
3749  ((TH2F*)fDaughterHistogramArray2D[daughterType][4])->Fill(ptBPlus, pt_track);
3750  }
3751 
3752  if (isDesiredCandidate)
3753  {
3754  histType = 5;
3755  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
3756  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
3757  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
3758  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
3759 
3760  for (Int_t j = 0; j < 10; ++j)
3761  {
3762  if (selectedD0Kaon->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
3763 
3764  }
3765 
3766  if (TPCok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(nSigmaTPC);
3767  if (TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][5])->Fill(nSigmaTOF);
3768  if (TPCok != -1 && TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][6])->Fill(sqrt(nSigmaTPC * nSigmaTPC + nSigmaTOF * nSigmaTOF));
3769  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0D0kaon);
3770  ((TH1F*)fDaughterHistogramArray[daughterType][histType][9])->Fill(selectedD0Kaon->Eta());
3771  ((TH2F*)fDaughterHistogramArray2D[daughterType][5])->Fill(ptBPlus, pt_track);
3772  }
3773 
3774  //we save the pdgcode of the used particle and its mother to check PID efficiency
3775  if (fUseMCInfo)
3776  {
3777  Float_t pdgCodeParticle = -1;
3778  Float_t pdgCodeParticleMother = -1;
3779  Int_t mcLabelParticle = -1;
3780  Int_t mcLabelParticleMother = -1;
3781  mcLabelParticle = selectedD0Kaon->GetLabel();
3782 
3783  if (mcLabelParticle >= 0) {
3784 
3785  AliAODMCParticle *mcTrackParticle = (AliAODMCParticle*)mcTrackArray->At(mcLabelParticle);
3786  pdgCodeParticle = TMath::Abs(mcTrackParticle->GetPdgCode());
3787  ((TH1F*)fDaughterHistogramArrayExtra[1][2])->Fill(pdgCodeParticle);
3788  mcLabelParticleMother = mcTrackParticle->GetMother();
3789 
3790  if (mcLabelParticleMother >= 0) {
3791  AliAODMCParticle *mcTrackParticleMother = (AliAODMCParticle*)mcTrackArray->At(mcLabelParticleMother);
3792  pdgCodeParticleMother = TMath::Abs(mcTrackParticleMother->GetPdgCode());
3793  ((TH1F*)fDaughterHistogramArrayExtra[1][3])->Fill(pdgCodeParticleMother);
3794  }
3795  }
3796  }
3797 
3798  //fill the BPlus pion info
3799  pt_track = selectedBPlusPion->Pt();
3800  momentum_track = selectedBPlusPion->P();
3801  numberOfITS = selectedBPlusPion->GetITSNcls();
3802  numberOfTPC = selectedBPlusPion->GetTPCNcls();
3803  totalNumberOfITS += numberOfITS;
3804  totalNumberOfTPC += numberOfTPC;
3805  TPCok = trackPIDHF->GetnSigmaTPC(selectedBPlusPion, pionPIDnumber, nSigmaTPC);
3806  TOFok = trackPIDHF->GetnSigmaTOF(selectedBPlusPion, pionPIDnumber, nSigmaTOF);
3807  if (TPCok != -1) nSigmaTPCtotal += nSigmaTPC * nSigmaTPC;
3808  if (TOFok != -1) nSigmaTOFtotal += nSigmaTOF * nSigmaTOF;
3809 
3810  daughterType = 2;
3811  histType = 4;
3812  if (!isDesiredCandidate)
3813  {
3814  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
3815  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
3816  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
3817  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
3818 
3819  for (Int_t j = 0; j < 10; ++j)
3820  {
3821  if (selectedBPlusPion->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
3822 
3823  }
3824 
3825  if (TPCok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(nSigmaTPC);
3826  if (TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][5])->Fill(nSigmaTOF);
3827  if (TPCok != -1 && TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][6])->Fill(sqrt(nSigmaTPC * nSigmaTPC + nSigmaTOF * nSigmaTOF));
3828  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0BPluspion);
3829  ((TH1F*)fDaughterHistogramArray[daughterType][histType][9])->Fill(selectedBPlusPion->Eta());
3830  ((TH2F*)fDaughterHistogramArray2D[daughterType][4])->Fill(ptBPlus, pt_track);
3831  }
3832 
3833  if (isDesiredCandidate)
3834  {
3835  histType = 5;
3836  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
3837  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
3838  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
3839  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
3840 
3841  for (Int_t j = 0; j < 10; ++j)
3842  {
3843  if (selectedBPlusPion->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
3844 
3845  }
3846 
3847  if (TPCok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(nSigmaTPC);
3848  if (TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][5])->Fill(nSigmaTOF);
3849  if (TPCok != -1 && TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][6])->Fill(sqrt(nSigmaTPC * nSigmaTPC + nSigmaTOF * nSigmaTOF));
3850  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0BPluspion);
3851  ((TH1F*)fDaughterHistogramArray[daughterType][histType][9])->Fill(selectedBPlusPion->Eta());
3852  ((TH2F*)fDaughterHistogramArray2D[daughterType][5])->Fill(ptBPlus, pt_track);
3853  }
3854 
3855  //we save the pdgcode of the used particle and its mother to check PID efficiency
3856  if (fUseMCInfo)
3857  {
3858  Float_t pdgCodeParticle = -1;
3859  Float_t pdgCodeParticleMother = -1;
3860  Int_t mcLabelParticle = -1;
3861  Int_t mcLabelParticleMother = -1;
3862  mcLabelParticle = selectedBPlusPion->GetLabel();
3863 
3864  if (mcLabelParticle >= 0) {
3865 
3866  AliAODMCParticle *mcTrackParticle = (AliAODMCParticle*)mcTrackArray->At(mcLabelParticle);
3867  pdgCodeParticle = TMath::Abs(mcTrackParticle->GetPdgCode());
3868  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][2])->Fill(pdgCodeParticle);
3869  mcLabelParticleMother = mcTrackParticle->GetMother();
3870 
3871  if (mcLabelParticleMother >= 0) {
3872  AliAODMCParticle *mcTrackParticleMother = (AliAODMCParticle*)mcTrackArray->At(mcLabelParticleMother);
3873  pdgCodeParticleMother = TMath::Abs(mcTrackParticleMother->GetPdgCode());
3874  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][3])->Fill(pdgCodeParticleMother);
3875  }
3876  }
3877  }
3878 
3879  if (!isDesiredCandidate)
3880  {
3881  ((TH1F*)(fOutputBPlusMC->FindObject("totalITSBackground")))->Fill(totalNumberOfITS);
3882  ((TH1F*)(fOutputBPlusMC->FindObject("totalTPCBackground")))->Fill(totalNumberOfTPC);
3883  ((TH1F*)(fOutputBPlusMC->FindObject("totalSigmaPIDBackground")))->Fill(sqrt(nSigmaTPCtotal + nSigmaTOFtotal));
3884  }
3885  if (isDesiredCandidate)
3886  {
3887  ((TH1F*)(fOutputBPlusMC->FindObject("totalITSSignal")))->Fill(totalNumberOfITS);
3888  ((TH1F*)(fOutputBPlusMC->FindObject("totalTPCSignal")))->Fill(totalNumberOfTPC);
3889  ((TH1F*)(fOutputBPlusMC->FindObject("totalSigmaPIDSignal")))->Fill(sqrt(nSigmaTPCtotal + nSigmaTOFtotal));
3890  }
3891 
3892  // we look at the invariant mass combinations of all daughter tracks
3893  AliExternalTrackParam trackBPlusPion;
3894  trackBPlusPion.CopyFromVTrack(selectedBPlusPion);
3895  AliExternalTrackParam trackD0Pion;
3896  trackD0Pion.CopyFromVTrack(selectedD0Pion);
3897  AliExternalTrackParam trackD0Kaon;
3898  trackD0Kaon.CopyFromVTrack(selectedD0Kaon);
3899 
3900  UInt_t prongs2[2] = {0};
3901  UInt_t prongs3[3] = {0};
3902 
3903  prongs2[0] = 211; prongs2[1] = 211;
3904  TwoTrackCombinationInfo(&trackD0Pion, &trackBPlusPion, primaryVertex, bz, isDesiredCandidate, "invmassD0PionBPlusPion", prongs2);
3905  prongs2[0] = 321; prongs2[1] = 211;
3906  TwoTrackCombinationInfo(&trackD0Kaon, &trackBPlusPion, primaryVertex, bz, isDesiredCandidate, "invmassD0KaonBPlusPion", prongs2);
3907  prongs3[0] = 211; prongs3[1] = 321; prongs3[2] = 211;
3908  ThreeTrackCombinationInfo(&trackD0Pion, &trackD0Kaon, &trackBPlusPion, primaryVertex, bz, isDesiredCandidate, "invmassD0PionD0KaonBPlusPion", prongs3);
3909 
3910  return;
3911 }
3912 //-------------------------------------------------------------------------------------
3914 {
3918 
3919  AliAODRecoDecayHF2Prong * D0 = (AliAODRecoDecayHF2Prong*)BPlus->GetDaughter(1);
3920 
3921  Double_t e[3] = {0};
3922  if (BPlus->Charge() == -1)
3923  {
3924  e[0] = D0->EProng(0, 211);
3925  e[1] = D0->EProng(1, 321);
3926  } else if (BPlus->Charge() == 1) {
3927  e[0] = D0->EProng(0, 321);
3928  e[1] = D0->EProng(1, 211);
3929  }
3930  e[2] = BPlus->EProng(0, 211);
3931 
3932  Double_t esum = e[0] + e[1] + e[2];
3933  Double_t invMassBPlus = TMath::Sqrt(esum * esum - BPlus->P2());
3934 
3935  Double_t invMassD0 = -1;
3936 
3937  if (BPlus->Charge() == -1) {invMassD0 = D0->InvMassD0();}
3938  else {invMassD0 = D0->InvMassD0bar();}
3939  if (invMassD0 == -1) {std::cout << "wrong invmass delta D0 BPlus" << std::endl;}
3940 
3941  return invMassBPlus - invMassD0;
3942 }
3943 //-------------------------------------------------------------------------------------
3944 void AliAnalysisTaskSEBPlustoD0Pi::FillD0Histograms(AliAODRecoDecayHF2Prong * selectedMother, AliAODVertex *primaryVertex, Double_t bz, Int_t motherType, Int_t histType, Int_t pdgCodeMother) {
3945 
3946  if (histType < 0) return;
3947 
3948  //In this function we fill the histograms of the reconstructed mothers
3949  Double_t ptMother = 0.0;
3950  Double_t momentumMother = 0.0;
3951  Double_t etaMother = 0.0;
3952  Double_t phiMother = 0.0;
3953  Double_t d0Mother = 0.0;
3954  Double_t d0firstTrack = 0.0;
3955  Double_t d0secondTrack = 0.0;
3956  Double_t pointingAngle = 0.0;
3957  Double_t impactProduct = 0.0;
3958  Double_t impactProductXY = 0.0;
3959  Double_t invariantMassMother = 0.0;
3960  Double_t invmassDelta = 0.0;
3961  Double_t dcaMother = 0.0;
3962  AliAODVertex * vertexMother = 0x0;
3963  Double_t vertexDistance = 0.0;
3964  Double_t decayTime = 0.0;
3965  Double_t angleMotherFirstDaughter = 0.0;
3966  Double_t angleMotherSecondDaughter = 0.0;
3967  Double_t ptFirstDaughter = 0.0;
3968  Double_t ptSecondDaughter = 0.0;
3969  UInt_t prongs[2], prongs2[2];
3970  Double_t angleBetweenBothDaughters = 0;
3971  Double_t cosThetaStar = 0;
3972  Double_t normDecayLength = 0;
3973  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(421)->Mass();
3974 
3975 
3976  prongs[0] = 211; prongs[1] = 321;
3977  prongs2[0] = 321; prongs2[1] = 211;
3978  AliAODTrack * firstDaughter = (AliAODTrack*)selectedMother->GetDaughter(0);
3979  AliAODTrack * secondDaughter = (AliAODTrack*)selectedMother->GetDaughter(1);
3980  vertexMother = selectedMother->GetSecondaryVtx();
3981  ptFirstDaughter = firstDaughter->Pt();
3982  ptSecondDaughter = secondDaughter->Pt();
3983 
3984  //Topomatic
3985  Double_t dd0pr1 = 0.;
3986  Double_t dd0pr2 = 0.;
3987  Double_t dd0max = 0.;
3988  Double_t dd0min = 0.;
3989  for (Int_t ipr = 0; ipr < 2; ipr++)
3990  {
3991  Double_t diffIP, errdiffIP;
3992  selectedMother->Getd0MeasMinusExpProng(ipr, bz, diffIP, errdiffIP);
3993  Double_t normdd0 = 0.;
3994  if (errdiffIP > 0.) normdd0 = diffIP / errdiffIP;
3995  if (ipr == 0) dd0pr1 = normdd0;
3996  if (ipr == 1) dd0pr2 = normdd0;
3997 
3998  }
3999  if (TMath::Abs(dd0pr1) > TMath::Abs(dd0pr2)) {dd0max = dd0pr1; dd0min = dd0pr2;}
4000  else {dd0max = dd0pr2; dd0min = dd0pr1;}
4001 
4002  AliExternalTrackParam motherTrack;
4003  motherTrack.CopyFromVTrack(selectedMother);
4004  Double_t d0z0[2], covd0z0[3], d0[2];
4005  motherTrack.PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
4006  d0[0] = d0z0[0];
4007 
4008  ptMother = selectedMother->Pt();
4009  momentumMother = selectedMother->P();
4010  etaMother = selectedMother->Eta();
4011  phiMother = selectedMother->Phi();
4012 
4013  d0Mother = TMath::Abs(d0[0]);
4014  d0firstTrack = TMath::Abs(selectedMother->Getd0Prong(0));
4015  d0secondTrack = TMath::Abs(selectedMother->Getd0Prong(1));
4016  pointingAngle = selectedMother->CosPointingAngle();
4017  impactProduct = selectedMother->Prodd0d0();
4018  impactProductXY = TMath::Abs(selectedMother->ImpParXY());
4019  invariantMassMother = selectedMother->InvMass(2, prongs);
4020  if (pdgCodeMother == -421) invariantMassMother = selectedMother->InvMass(2, prongs2);
4021 
4022  dcaMother = selectedMother->GetDCA();
4023  vertexDistance = vertexMother->DistanceToVertex(primaryVertex);
4024  angleMotherFirstDaughter = (selectedMother->Px() * firstDaughter->Px() + selectedMother->Py() * firstDaughter->Py() + selectedMother->Pz() * firstDaughter->Pz()) / (selectedMother->P() * firstDaughter->P());
4025  angleMotherSecondDaughter = (selectedMother->Px() * secondDaughter->Px() + selectedMother->Py() * secondDaughter->Py() + selectedMother->Pz() * secondDaughter->Pz()) / (selectedMother->P() * secondDaughter->P());
4026  cosThetaStar = selectedMother->CosThetaStar(0, 421, 211, 321);
4027  angleBetweenBothDaughters = (firstDaughter->Px() * secondDaughter->Px() + firstDaughter->Py() * secondDaughter->Py() + firstDaughter->Pz() * secondDaughter->Pz()) / (firstDaughter->P() * secondDaughter->P());
4028  normDecayLength = selectedMother->NormalizedDecayLength();
4029 
4030  Double_t pseudoProperDecayLength = ((vertexMother->GetX() - primaryVertex->GetX()) * selectedMother->Px() / TMath::Abs(selectedMother->Pt())) + ((vertexMother->GetY() - primaryVertex->GetY()) * selectedMother->Py() / TMath::Abs(selectedMother->Pt()));
4031  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother / ptMother;
4032  decayTime = vertexDistance / (299792458 * TMath::Sqrt(1 / ((pdgMassMother * pdgMassMother / (momentumMother * momentumMother)) + 1)));
4033 
4034  Double_t phi = selectedMother->Phi();
4035  Double_t theta = selectedMother->Theta();
4036  Double_t covMatrix[21];
4037  selectedMother->GetCovarianceXYZPxPyPz(covMatrix);
4038 
4039  Double_t cp = TMath::Cos(phi);
4040  Double_t sp = TMath::Sin(phi);
4041  Double_t ct = TMath::Cos(theta);
4042  Double_t st = TMath::Sin(theta);
4043 
4044  Double_t errorMomentum = covMatrix[9] * cp * cp * ct * ct // GetCovPxPx
4045  + covMatrix[13] * 2.*cp * sp * ct * ct // GetCovPxPy
4046  + covMatrix[18] * 2.*cp * ct * st // GetCovPxPz
4047  + covMatrix[14] * sp * sp * ct * ct // GetCovPyPy
4048  + covMatrix[19] * 2.*sp * ct * st // GetCovPyPz
4049  + covMatrix[20] * st * st; // GetCovPzPz
4050  Double_t normalizedDecayTime = selectedMother->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1 / ((pdgMassMother * pdgMassMother * errorMomentum * errorMomentum / (momentumMother * momentumMother)) + 1)));
4051 
4052  Double_t eKaon = selectedMother->EProng(1, 321);
4053  Double_t invMassKaon = TMath::Sqrt(eKaon * eKaon - secondDaughter->P() * secondDaughter->P());
4054  Double_t invMassD0 = selectedMother->InvMassD0();
4055  invmassDelta = invMassD0 - invMassKaon;
4056 
4057  Double_t vertexMotherX = vertexMother->GetX();
4058  Double_t vertexMotherY = vertexMother->GetY();
4059  Double_t vertexMotherZ = vertexMother->GetZ();
4060 
4061  Double_t cosPointingAngleXY = selectedMother->CosPointingAngleXY();
4062  Double_t distanceXYToVertex = vertexMother->DistanceXYToVertex(primaryVertex);
4063  Double_t normalizedDecayLengthXY = selectedMother->NormalizedDecayLengthXY();
4064 
4065  ((TH1F*)fMotherHistogramArray[motherType][histType][0])->Fill(ptMother);
4066  ((TH1F*)fMotherHistogramArray[motherType][histType][1])->Fill(ptFirstDaughter);
4067  ((TH1F*)fMotherHistogramArray[motherType][histType][2])->Fill(ptSecondDaughter);
4068  ((TH1F*)fMotherHistogramArray[motherType][histType][3])->Fill(etaMother);
4069  ((TH1F*)fMotherHistogramArray[motherType][histType][4])->Fill(phiMother);
4070  ((TH1F*)fMotherHistogramArray[motherType][histType][5])->Fill(d0Mother);
4071  ((TH1F*)fMotherHistogramArray[motherType][histType][6])->Fill(d0firstTrack);
4072  ((TH1F*)fMotherHistogramArray[motherType][histType][7])->Fill(d0secondTrack);
4073  ((TH1F*)fMotherHistogramArray[motherType][histType][8])->Fill(pointingAngle);
4074  ((TH1F*)fMotherHistogramArray[motherType][histType][9])->Fill(impactProduct);
4075  ((TH1F*)fMotherHistogramArray[motherType][histType][10])->Fill(impactProductXY);
4076  ((TH1F*)fMotherHistogramArray[motherType][histType][11])->Fill(invariantMassMother);
4077  ((TH1F*)fMotherHistogramArray[motherType][histType][12])->Fill(invmassDelta);
4078  ((TH1F*)fMotherHistogramArray[motherType][histType][13])->Fill(dcaMother);
4079  ((TH1F*)fMotherHistogramArray[motherType][histType][14])->Fill(vertexDistance);
4080  ((TH1F*)fMotherHistogramArray[motherType][histType][15])->Fill(normDecayLength);
4081  ((TH1F*)fMotherHistogramArray[motherType][histType][16])->Fill(pseudoProperDecayTime);
4082  ((TH1F*)fMotherHistogramArray[motherType][histType][17])->Fill(decayTime);
4083  ((TH1F*)fMotherHistogramArray[motherType][histType][18])->Fill(normalizedDecayTime);
4084  ((TH1F*)fMotherHistogramArray[motherType][histType][19])->Fill(angleMotherFirstDaughter);
4085  ((TH1F*)fMotherHistogramArray[motherType][histType][20])->Fill(angleMotherSecondDaughter);
4086  ((TH1F*)fMotherHistogramArray[motherType][histType][21])->Fill(angleBetweenBothDaughters);
4087  ((TH1F*)fMotherHistogramArray[motherType][histType][22])->Fill(cosThetaStar);
4088 
4089  ((TH1F*)fMotherHistogramArray[motherType][histType][23])->Fill(vertexMotherX);
4090  ((TH1F*)fMotherHistogramArray[motherType][histType][24])->Fill(vertexMotherY);
4091  ((TH1F*)fMotherHistogramArray[motherType][histType][25])->Fill(vertexMotherZ);
4092 
4093  ((TH1F*)fMotherHistogramArray[motherType][histType][36])->Fill(TMath::Abs(dd0pr1));
4094  ((TH1F*)fMotherHistogramArray[motherType][histType][37])->Fill(TMath::Abs(dd0pr2));
4095  ((TH1F*)fMotherHistogramArray[motherType][histType][38])->Fill(TMath::Abs(dd0max));
4096  ((TH1F*)fMotherHistogramArray[motherType][histType][39])->Fill(TMath::Abs(dd0min));
4097 
4098  ((TH1F*)fMotherHistogramArray[motherType][histType][40])->Fill(cosPointingAngleXY);
4099  ((TH1F*)fMotherHistogramArray[motherType][histType][41])->Fill(distanceXYToVertex);
4100  ((TH1F*)fMotherHistogramArray[motherType][histType][42])->Fill(normalizedDecayLengthXY);
4101  ((TH1F*)fMotherHistogramArray[motherType][histType][43])->Fill(vertexMother->GetChi2());
4102  ((TH1F*)fMotherHistogramArray[motherType][histType][44])->Fill(vertexMother->GetChi2perNDF());
4103 
4104 
4105  //we fill the 2D histograms
4106  Int_t nFirst = 0;
4107  Int_t nSecond = 1;
4108  Int_t nVariables = 10;
4109  Int_t nHistograms = nVariables * (nVariables - 1) / 2;
4110  for (Int_t k = 0; k < nHistograms; ++k)
4111  {
4112  Double_t firstVariable = 0.0;
4113  Double_t secondVariable = 0.0;
4114 
4115  if (nFirst == 0) firstVariable = d0firstTrack;
4116  if (nFirst == 1) firstVariable = d0secondTrack;
4117  if (nFirst == 2) firstVariable = d0Mother;
4118  if (nFirst == 3) firstVariable = pointingAngle;
4119  if (nFirst == 4) firstVariable = impactProduct;
4120  if (nFirst == 5) firstVariable = impactProductXY;
4121  if (nFirst == 6) firstVariable = vertexDistance;
4122  if (nFirst == 7) firstVariable = normDecayLength;
4123  if (nFirst == 8) firstVariable = cosPointingAngleXY;
4124  if (nFirst == 9) firstVariable = distanceXYToVertex;
4125  if (nFirst == 10) firstVariable = normalizedDecayLengthXY;
4126 
4127  if (nSecond == 0) secondVariable = d0firstTrack;
4128  if (nSecond == 1) secondVariable = d0secondTrack;
4129  if (nSecond == 2) secondVariable = d0Mother;
4130  if (nSecond == 3) secondVariable = pointingAngle;
4131  if (nSecond == 4) secondVariable = impactProduct;
4132  if (nSecond == 5) secondVariable = impactProductXY;
4133  if (nSecond == 6) secondVariable = vertexDistance;
4134  if (nSecond == 7) secondVariable = normDecayLength;
4135  if (nSecond == 8) secondVariable = cosPointingAngleXY;
4136  if (nSecond == 9) secondVariable = distanceXYToVertex;
4137  if (nSecond == 10) secondVariable = normalizedDecayLengthXY;
4138 
4139  ((TH2F*)fMotherHistogramArray2D[motherType][histType][k])->Fill(firstVariable, secondVariable);
4140 
4141  nSecond++;
4142  if (nSecond > nVariables)
4143  {
4144  nFirst++;
4145  nSecond = nFirst + 1;
4146  }
4147  }
4148 
4149  return;
4150 }
4151 //-------------------------------------------------------------------------------------
4152 void AliAnalysisTaskSEBPlustoD0Pi::FillBPlusHistograms(AliAODRecoDecayHF2Prong * selectedMother, AliAODVertex *primaryVertex, Double_t bz, Int_t motherType, Int_t histType) {
4153 
4154  //In this function we fill the histograms of the reconstructed mothers
4155  Double_t ptMother = 0.0;
4156  Double_t momentumMother = 0.0;
4157  Double_t etaMother = 0.0;
4158  Double_t phiMother = 0.0;
4159  Double_t d0Mother = 0.0;
4160  Double_t d0firstTrack = 0.0;
4161  Double_t d0secondTrack = 0.0;
4162  Double_t pointingAngle = 0.0;
4163  Double_t impactProduct = 0.0;
4164  Double_t impactProductXY = 0.0;
4165  Double_t invariantMassMother = 0.0;
4166  Double_t invmassDelta = 0.0;
4167  Double_t dcaMother = 0.0;
4168  AliAODVertex * vertexMother = 0x0;
4169  Double_t vertexDistance = 0.0;
4170  Double_t normDecayLength = 0.0;
4171  Double_t decayTime = 0.0;
4172  Double_t angleMotherFirstDaughter = 0.0;
4173  Double_t angleMotherSecondDaughter = 0.0;
4174  Double_t ptFirstDaughter = 0.0;
4175  Double_t ptSecondDaughter = 0.0;
4176  UInt_t prongs[2];
4177  Double_t cosThetaStar = 0;
4178  Double_t angleBetweenBothDaughters = 0;
4179  // Double_t d0MultiProduct = 0;
4180 
4181  Double_t pdgMassMother = 0;
4182 
4183  AliExternalTrackParam motherTrack;
4184  motherTrack.CopyFromVTrack(selectedMother);
4185  Double_t d0z0[2], covd0z0[3], d0[2];
4186  motherTrack.PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
4187  d0[0] = d0z0[0];
4188 
4189  //BPlus
4190  prongs[1] = 421; prongs[0] = 211;
4191  invmassDelta = DeltaInvMassBPlusKpipi(selectedMother);
4192  AliAODTrack * firstDaughter = (AliAODTrack*)selectedMother->GetDaughter(0);
4193  AliAODRecoDecayHF2Prong * secondDaughter = (AliAODRecoDecayHF2Prong*)selectedMother->GetDaughter(1);
4194 
4195  ptFirstDaughter = firstDaughter->Pt();
4196  ptSecondDaughter = secondDaughter->Pt();
4197  vertexMother = selectedMother->GetSecondaryVtx();
4198  angleMotherFirstDaughter = (selectedMother->Px() * firstDaughter->Px() + selectedMother->Py() * firstDaughter->Py() + selectedMother->Pz() * firstDaughter->Pz()) / (selectedMother->P() * firstDaughter->P());
4199  angleMotherSecondDaughter = (selectedMother->Px() * secondDaughter->Px() + selectedMother->Py() * secondDaughter->Py() + selectedMother->Pz() * secondDaughter->Pz()) / (selectedMother->P() * secondDaughter->P());
4200  angleBetweenBothDaughters = (firstDaughter->Px() * secondDaughter->Px() + firstDaughter->Py() * secondDaughter->Py() + firstDaughter->Pz() * secondDaughter->Pz()) / (firstDaughter->P() * secondDaughter->P());
4201  cosThetaStar = selectedMother->CosThetaStar(0, 521, 421, 211);
4202  pdgMassMother = TDatabasePDG::Instance()->GetParticle(521)->Mass();
4203  // d0MultiProduct = selectedMother->Getd0Prong(0) * secondDaughter->Getd0Prong(0) * secondDaughter->Getd0Prong(1);
4204 
4205  //Topomatic
4206  Double_t dd0pr1 = 0.;
4207  Double_t dd0pr2 = 0.;
4208  Double_t dd0max = 0.;
4209  Double_t dd0min = 0.;
4210  for (Int_t ipr = 0; ipr < 2; ipr++)
4211  {
4212  Double_t diffIP, errdiffIP;
4213  selectedMother->Getd0MeasMinusExpProng(ipr, bz, diffIP, errdiffIP);
4214  Double_t normdd0 = 0.;
4215  if (errdiffIP > 0.) normdd0 = diffIP / errdiffIP;
4216  if (ipr == 0) dd0pr1 = normdd0;
4217  if (ipr == 1) dd0pr2 = normdd0;
4218 
4219  // else if(TMath::Abs(normdd0)>TMath::Abs(dd0max)) dd0max=normdd0;
4220  }
4221  if (TMath::Abs(dd0pr1) > TMath::Abs(dd0pr2)) {dd0max = dd0pr1; dd0min = dd0pr2;}
4222  else {dd0max = dd0pr2; dd0min = dd0pr1;}
4223 
4224 
4225 
4226  ptMother = selectedMother->Pt();
4227  momentumMother = selectedMother->P();
4228  etaMother = selectedMother->Eta();
4229  phiMother = selectedMother->Phi();
4230  d0Mother = TMath::Abs(d0[0]);
4231 
4232  pointingAngle = selectedMother->CosPointingAngle();
4233  impactProduct = selectedMother->Prodd0d0();
4234  impactProductXY = TMath::Abs(selectedMother->ImpParXY());
4235  invariantMassMother = selectedMother->InvMass(2, prongs);
4236  dcaMother = selectedMother->GetDCA();
4237  vertexDistance = vertexMother->DistanceToVertex(primaryVertex);
4238  d0firstTrack = TMath::Abs(selectedMother->Getd0Prong(0));
4239  d0secondTrack = TMath::Abs(selectedMother->Getd0Prong(1));
4240  normDecayLength = selectedMother->NormalizedDecayLength();
4241 
4242  Double_t pseudoProperDecayLength = ((vertexMother->GetX() - primaryVertex->GetX()) * selectedMother->Px() / TMath::Abs(selectedMother->Pt())) + ((vertexMother->GetY() - primaryVertex->GetY()) * selectedMother->Py() / TMath::Abs(selectedMother->Pt()));
4243  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother / ptMother;
4244  decayTime = vertexDistance / (299792458 * TMath::Sqrt(1 / ((pdgMassMother * pdgMassMother / (momentumMother * momentumMother)) + 1)));
4245 
4246  Double_t phi = selectedMother->Phi();
4247  Double_t theta = selectedMother->Theta();
4248  Double_t covMatrix[21];
4249  selectedMother->GetCovarianceXYZPxPyPz(covMatrix);
4250 
4251  Double_t cp = TMath::Cos(phi);
4252  Double_t sp = TMath::Sin(phi);
4253  Double_t ct = TMath::Cos(theta);
4254  Double_t st = TMath::Sin(theta);
4255 
4256  Double_t errorMomentum = covMatrix[9] * cp * cp * ct * ct // GetCovPxPx
4257  + covMatrix[13] * 2.*cp * sp * ct * ct // GetCovPxPy
4258  + covMatrix[18] * 2.*cp * ct * st // GetCovPxPz
4259  + covMatrix[14] * sp * sp * ct * ct // GetCovPyPy
4260  + covMatrix[19] * 2.*sp * ct * st // GetCovPyPz
4261  + covMatrix[20] * st * st; // GetCovPzPz
4262  Double_t normalizedDecayTime = selectedMother->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1 / ((pdgMassMother * pdgMassMother * errorMomentum * errorMomentum / (momentumMother * momentumMother)) + 1)));
4263 
4264  Double_t vertexMotherX = vertexMother->GetX();
4265  Double_t vertexMotherY = vertexMother->GetY();
4266  Double_t vertexMotherZ = vertexMother->GetZ();
4267 
4268  Double_t cosPointingAngleXY = selectedMother->CosPointingAngleXY();
4269  Double_t distanceXYToVertex = vertexMother->DistanceXYToVertex(primaryVertex);
4270  Double_t normalizedDecayLengthXY = selectedMother->NormalizedDecayLengthXY();
4271 
4272  ((TH1F*)fMotherHistogramArray[motherType][histType][0])->Fill(ptMother);
4273  ((TH1F*)fMotherHistogramArray[motherType][histType][1])->Fill(ptFirstDaughter);
4274  ((TH1F*)fMotherHistogramArray[motherType][histType][2])->Fill(ptSecondDaughter);
4275  ((TH1F*)fMotherHistogramArray[motherType][histType][3])->Fill(etaMother);
4276  ((TH1F*)fMotherHistogramArray[motherType][histType][4])->Fill(phiMother);
4277  ((TH1F*)fMotherHistogramArray[motherType][histType][5])->Fill(d0Mother);
4278  ((TH1F*)fMotherHistogramArray[motherType][histType][6])->Fill(d0firstTrack);
4279  ((TH1F*)fMotherHistogramArray[motherType][histType][7])->Fill(d0secondTrack);
4280  ((TH1F*)fMotherHistogramArray[motherType][histType][8])->Fill(pointingAngle);
4281  ((TH1F*)fMotherHistogramArray[motherType][histType][9])->Fill(impactProduct);
4282  ((TH1F*)fMotherHistogramArray[motherType][histType][10])->Fill(impactProductXY);
4283  ((TH1F*)fMotherHistogramArray[motherType][histType][11])->Fill(invariantMassMother);
4284  ((TH1F*)fMotherHistogramArray[motherType][histType][12])->Fill(invmassDelta);
4285  ((TH1F*)fMotherHistogramArray[motherType][histType][13])->Fill(dcaMother);
4286  ((TH1F*)fMotherHistogramArray[motherType][histType][14])->Fill(vertexDistance);
4287  ((TH1F*)fMotherHistogramArray[motherType][histType][15])->Fill(normDecayLength);
4288  ((TH1F*)fMotherHistogramArray[motherType][histType][16])->Fill(pseudoProperDecayTime);
4289  ((TH1F*)fMotherHistogramArray[motherType][histType][17])->Fill(decayTime);
4290  ((TH1F*)fMotherHistogramArray[motherType][histType][18])->Fill(normalizedDecayTime);
4291  ((TH1F*)fMotherHistogramArray[motherType][histType][19])->Fill(angleMotherFirstDaughter);
4292  ((TH1F*)fMotherHistogramArray[motherType][histType][20])->Fill(angleMotherSecondDaughter);
4293  ((TH1F*)fMotherHistogramArray[motherType][histType][21])->Fill(angleBetweenBothDaughters);
4294  ((TH1F*)fMotherHistogramArray[motherType][histType][22])->Fill(cosThetaStar);
4295 
4296  ((TH1F*)fMotherHistogramArray[motherType][histType][23])->Fill(vertexMotherX);
4297  ((TH1F*)fMotherHistogramArray[motherType][histType][24])->Fill(vertexMotherY);
4298  ((TH1F*)fMotherHistogramArray[motherType][histType][25])->Fill(vertexMotherZ);
4299 
4300  ((TH1F*)fMotherHistogramArray[motherType][histType][36])->Fill(TMath::Abs(dd0pr1));
4301  ((TH1F*)fMotherHistogramArray[motherType][histType][37])->Fill(TMath::Abs(dd0pr2));
4302  ((TH1F*)fMotherHistogramArray[motherType][histType][38])->Fill(TMath::Abs(dd0max));
4303  ((TH1F*)fMotherHistogramArray[motherType][histType][39])->Fill(TMath::Abs(dd0min));
4304 
4305  ((TH1F*)fMotherHistogramArray[motherType][histType][40])->Fill(cosPointingAngleXY);
4306  ((TH1F*)fMotherHistogramArray[motherType][histType][41])->Fill(distanceXYToVertex);
4307  ((TH1F*)fMotherHistogramArray[motherType][histType][42])->Fill(normalizedDecayLengthXY);
4308  ((TH1F*)fMotherHistogramArray[motherType][histType][43])->Fill(vertexMother->GetChi2());
4309  ((TH1F*)fMotherHistogramArray[motherType][histType][44])->Fill(vertexMother->GetChi2perNDF());
4310 
4311 
4312  //we fill the 2D histograms
4313  Int_t nFirst = 0;
4314  Int_t nSecond = 1;
4315  Int_t nVariables = 10;
4316  Int_t nHistograms = nVariables * (nVariables - 1) / 2;
4317  for (Int_t k = 0; k < nHistograms; ++k)
4318  {
4319  Double_t firstVariable = 0.0;
4320  Double_t secondVariable = 0.0;
4321 
4322  if (nFirst == 0) firstVariable = d0firstTrack;
4323  if (nFirst == 1) firstVariable = d0secondTrack;
4324  if (nFirst == 2) firstVariable = d0Mother;
4325  if (nFirst == 3) firstVariable = pointingAngle;
4326  if (nFirst == 4) firstVariable = impactProduct;
4327  if (nFirst == 5) firstVariable = impactProductXY;
4328  if (nFirst == 6) firstVariable = vertexDistance;
4329  if (nFirst == 7) firstVariable = normDecayLength;
4330  if (nFirst == 8) firstVariable = cosPointingAngleXY;
4331  if (nFirst == 9) firstVariable = distanceXYToVertex;
4332  if (nFirst == 10) firstVariable = normalizedDecayLengthXY;
4333 
4334  if (nSecond == 0) secondVariable = d0firstTrack;
4335  if (nSecond == 1) secondVariable = d0secondTrack;
4336  if (nSecond == 2) secondVariable = d0Mother;
4337  if (nSecond == 3) secondVariable = pointingAngle;
4338  if (nSecond == 4) secondVariable = impactProduct;
4339  if (nSecond == 5) secondVariable = impactProductXY;
4340  if (nSecond == 6) secondVariable = vertexDistance;
4341  if (nSecond == 7) secondVariable = normDecayLength;
4342  if (nSecond == 8) secondVariable = cosPointingAngleXY;
4343  if (nSecond == 9) secondVariable = distanceXYToVertex;
4344  if (nSecond == 10) secondVariable = normalizedDecayLengthXY;
4345 
4346  ((TH2F*)fMotherHistogramArray2D[motherType][histType][k])->Fill(firstVariable, secondVariable);
4347 
4348  nSecond++;
4349  if (nSecond > nVariables)
4350  {
4351  nFirst++;
4352  nSecond = nFirst + 1;
4353  }
4354  }
4355 
4356 
4357  if (motherType == 1) {
4358  motherType = motherType - 1;
4359 
4360  AliAODRecoDecay* trackD0 = (AliAODRecoDecay*)selectedMother->GetDaughter(1);
4361  AliAODTrack * firstDaughterD0 = (AliAODTrack*)trackD0->GetDaughter(0);
4362  AliAODTrack * secondDaughterD0 = (AliAODTrack*)trackD0->GetDaughter(1);
4363 
4364  AliAODVertex * vertexBPlus = vertexMother;
4365  AliAODVertex * vertexD0 = trackD0->GetSecondaryVtx();
4366  vertexDistance = TMath::Abs(vertexBPlus->DistanceToVertex(vertexD0));
4367  pdgMassMother = TDatabasePDG::Instance()->GetParticle(421)->Mass();
4368 
4369  AliExternalTrackParam firstDaughterD0Track;
4370  AliExternalTrackParam secondDaughterD0Track;
4371 
4372  Double_t d0z0[2], covd0z0[3], d0[2];
4373 
4374  firstDaughterD0Track.CopyFromVTrack(firstDaughterD0);
4375  firstDaughterD0Track.PropagateToDCA(vertexBPlus, bz, 100., d0z0, covd0z0);
4376  d0[0] = d0z0[0];
4377 
4378  secondDaughterD0Track.CopyFromVTrack(secondDaughterD0);
4379  secondDaughterD0Track.PropagateToDCA(vertexBPlus, bz, 100., d0z0, covd0z0);
4380  d0[1] = d0z0[0];
4381 
4382  AliExternalTrackParam D0Track;
4383  D0Track.CopyFromVTrack(trackD0);
4384  Double_t d0z0D0[2], covd0z0D0[3], d0D0;
4385  D0Track.PropagateToDCA(vertexBPlus, bz, 100., d0z0D0, covd0z0D0);
4386  d0D0 = d0z0D0[0];
4387 
4388  Double_t impactProductToBPlus = d0[0] * d0[1];
4389  Double_t impactProductXYToBPlus = trackD0->ImpParXY(vertexBPlus);
4390 
4391  Double_t momentumMother = trackD0->P();
4392  Double_t pointingAngleToBPlus = trackD0->CosPointingAngle(vertexBPlus);
4393  Double_t d0FirstDaughterToBPlus = TMath::Abs(d0[0]);
4394  Double_t d0trackD0ToBPlus = TMath::Abs(d0[1]);
4395  Double_t normDecayLengthToBPlus = trackD0->NormalizedDecayLength(vertexBPlus);
4396 
4397  Double_t pseudoProperDecayLength = ((vertexD0->GetX() - vertexBPlus->GetX()) * trackD0->Px() / TMath::Abs(trackD0->Pt())) + ((vertexD0->GetY() - vertexBPlus->GetY()) * trackD0->Py() / TMath::Abs(trackD0->Pt()));
4398  Double_t pseudoProperDecayTimeToBPlus = pseudoProperDecayLength * pdgMassMother / ptMother;
4399  Double_t DecayTimeToBPlus = vertexDistance / (299792458 * TMath::Sqrt(1 / ((pdgMassMother * pdgMassMother / (momentumMother * momentumMother)) + 1)));
4400 
4401  Double_t phi = trackD0->Phi();
4402  Double_t theta = trackD0->Theta();
4403  Double_t covMatrix[21];
4404  trackD0->GetCovarianceXYZPxPyPz(covMatrix);
4405 
4406  Double_t cp = TMath::Cos(phi);
4407  Double_t sp = TMath::Sin(phi);
4408  Double_t ct = TMath::Cos(theta);
4409  Double_t st = TMath::Sin(theta);
4410 
4411  Double_t errorMomentum = covMatrix[9] * cp * cp * ct * ct // GetCovPxPx
4412  + covMatrix[13] * 2.*cp * sp * ct * ct // GetCovPxPy
4413  + covMatrix[18] * 2.*cp * ct * st // GetCovPxPz
4414  + covMatrix[14] * sp * sp * ct * ct // GetCovPyPy
4415  + covMatrix[19] * 2.*sp * ct * st // GetCovPyPz
4416  + covMatrix[20] * st * st; // GetCovPzPz
4417  Double_t normDecayTimeToBPlus = trackD0->NormalizedDecayLength(vertexBPlus) / (299792458 * TMath::Sqrt(1 / ((pdgMassMother * pdgMassMother * errorMomentum * errorMomentum / (momentumMother * momentumMother)) + 1)));
4418 
4419  ((TH1F*)fMotherHistogramArray[motherType][histType][26])->Fill(pointingAngleToBPlus);
4420  ((TH1F*)fMotherHistogramArray[motherType][histType][27])->Fill(d0D0);
4421  ((TH1F*)fMotherHistogramArray[motherType][histType][28])->Fill(d0FirstDaughterToBPlus);
4422  ((TH1F*)fMotherHistogramArray[motherType][histType][29])->Fill(d0trackD0ToBPlus);
4423  ((TH1F*)fMotherHistogramArray[motherType][histType][30])->Fill(impactProductToBPlus);
4424  ((TH1F*)fMotherHistogramArray[motherType][histType][31])->Fill(impactProductXYToBPlus);
4425  ((TH1F*)fMotherHistogramArray[motherType][histType][32])->Fill(normDecayLengthToBPlus);
4426  ((TH1F*)fMotherHistogramArray[motherType][histType][33])->Fill(pseudoProperDecayTimeToBPlus);
4427  ((TH1F*)fMotherHistogramArray[motherType][histType][34])->Fill(DecayTimeToBPlus);
4428  ((TH1F*)fMotherHistogramArray[motherType][histType][35])->Fill(normDecayTimeToBPlus);
4429 
4430 
4431 
4432  }
4433  return;
4434 }
4435 //-------------------------------------------------------------------------------------
4436 void AliAnalysisTaskSEBPlustoD0Pi::TwoTrackCombinationInfo(AliExternalTrackParam * firstTrack, AliExternalTrackParam * secondTrack, AliAODVertex * primaryVertex, Double_t bz, Bool_t isDesiredCandidate, TString histogram_name, UInt_t prongs[2]) {
4437 
4438  // we calculate the vertex position
4439  TObjArray daughterTracks;
4440 
4441  daughterTracks.Add(firstTrack);
4442  daughterTracks.Add(secondTrack);
4443 
4444  Double_t dispersion = 0;
4445  AliAODVertex *vertex = RecalculateVertex(primaryVertex, &daughterTracks, bz, dispersion);
4446  if (!vertex) {delete vertex; vertex = NULL; return;}
4447 
4448  Double_t xdummy = 0., ydummy = 0., dca;
4449  Double_t d0z0[2], covd0z0[3], d0[2], d0err[2];
4450 
4451  firstTrack->PropagateToDCA(vertex, bz, 100., d0z0, covd0z0);
4452  secondTrack->PropagateToDCA(vertex, bz, 100., d0z0, covd0z0);
4453  dca = secondTrack->GetDCA(firstTrack, bz, xdummy, ydummy);
4454 
4455  Double_t px[2], py[2], pz[2];
4456  px[0] = firstTrack->Px();
4457  py[0] = firstTrack->Py();
4458  pz[0] = firstTrack->Pz();
4459  px[1] = secondTrack->Px();
4460  py[1] = secondTrack->Py();
4461  pz[1] = secondTrack->Pz();
4462 
4463  firstTrack->PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
4464  d0[0] = d0z0[0];
4465  d0err[0] = TMath::Sqrt(covd0z0[0]);
4466  secondTrack->PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
4467  d0[1] = d0z0[0];
4468  d0err[1] = TMath::Sqrt(covd0z0[0]);
4469 
4470  AliAODRecoDecayHF2Prong * track = new AliAODRecoDecayHF2Prong(vertex, px, py, pz, d0, d0err, dca);
4471  if (!track)
4472  {
4473  delete vertex; vertex = NULL;
4474  delete track; track = NULL;
4475  return;
4476  }
4477 
4478  Double_t invariantMass = track->InvMass(2, prongs);
4479 
4480  TString fill = histogram_name;
4481  if (isDesiredCandidate) fill += "_MC";
4482  ((TH1F*)(fOutputBPlusMC->FindObject(fill)))->Fill(invariantMass);
4483 
4484  delete vertex; vertex = NULL;
4485  delete track; track = NULL;
4486  return;
4487 }
4488 //-------------------------------------------------------------------------------------
4489 void AliAnalysisTaskSEBPlustoD0Pi::ThreeTrackCombinationInfo(AliExternalTrackParam * firstTrack, AliExternalTrackParam * secondTrack, AliExternalTrackParam * thirdTrack, AliAODVertex * primaryVertex, Double_t bz, Bool_t isDesiredCandidate, TString histogram_name, UInt_t prongs[3]) {
4490 
4491  // we calculate the vertex position
4492  TObjArray daughterTracks;
4493 
4494  daughterTracks.Add(firstTrack);
4495  daughterTracks.Add(secondTrack);
4496  daughterTracks.Add(thirdTrack);
4497 
4498  Double_t dispersion = 0;
4499  AliAODVertex *vertex = RecalculateVertex(primaryVertex, &daughterTracks, bz, dispersion);
4500  if (!vertex) {delete vertex; vertex = NULL; return;}
4501 
4502  Double_t xdummy = 0., ydummy = 0., dca[3];
4503  Double_t d0z0[2], covd0z0[3], d0[3], d0err[3];
4504 
4505  firstTrack->PropagateToDCA(vertex, bz, 100., d0z0, covd0z0);
4506  secondTrack->PropagateToDCA(vertex, bz, 100., d0z0, covd0z0);
4507  thirdTrack->PropagateToDCA(vertex, bz, 100., d0z0, covd0z0);
4508 
4509  dca[0] = firstTrack->GetDCA(secondTrack, bz, xdummy, ydummy);
4510  dca[1] = firstTrack->GetDCA(thirdTrack, bz, xdummy, ydummy);
4511  dca[2] = secondTrack->GetDCA(thirdTrack, bz, xdummy, ydummy);
4512 
4513  Double_t px[3], py[3], pz[3];
4514  px[0] = firstTrack->Px();
4515  py[0] = firstTrack->Py();
4516  pz[0] = firstTrack->Pz();
4517  px[1] = secondTrack->Px();
4518  py[1] = secondTrack->Py();
4519  pz[1] = secondTrack->Pz();
4520  px[2] = thirdTrack->Px();
4521  py[2] = thirdTrack->Py();
4522  pz[2] = thirdTrack->Pz();
4523 
4524  firstTrack->PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
4525  d0[0] = d0z0[0];
4526  d0err[0] = TMath::Sqrt(covd0z0[0]);
4527  secondTrack->PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
4528  d0[1] = d0z0[0];
4529  d0err[1] = TMath::Sqrt(covd0z0[0]);
4530  thirdTrack->PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
4531  d0[2] = d0z0[0];
4532  d0err[2] = TMath::Sqrt(covd0z0[0]);
4533 
4534  // Double_t pos[3]; primaryVertex->GetXYZ(pos);
4535  // Double_t dist12=TMath::Sqrt((vertex12->GetX()-pos[0])*(vertex12->GetX()-pos[0])+(vertex12->GetY()-pos[1])*(vertex12->GetY()-pos[1])+(vertex12->GetZ()-pos[2])*(vertex12->GetZ()-pos[2]));
4536  // Double_t dist23=TMath::Sqrt((vertex23->GetX()-pos[0])*(vertex23->GetX()-pos[0])+(vertex23->GetY()-pos[1])*(vertex23->GetY()-pos[1])+(vertex23->GetZ()-pos[2])*(vertex23->GetZ()-pos[2]));
4537  Short_t charge = (Short_t)(firstTrack->Charge() + secondTrack->Charge() + thirdTrack->Charge());
4538 
4539  AliAODRecoDecayHF3Prong * track = new AliAODRecoDecayHF3Prong(vertex, px, py, pz, d0, d0err, dca, dispersion, 0.0, 0.0, charge); //dist12,dist23,charge);
4540  if (!track)
4541  {
4542  delete vertex; vertex = NULL;
4543  delete track; track = NULL;
4544  return;
4545  }
4546 
4547  Double_t invariantMass = track->InvMass(3, prongs);
4548 
4549  TString fill = histogram_name;
4550  if (isDesiredCandidate) fill += "_MC";
4551  ((TH1F*)(fOutputBPlusMC->FindObject(fill)))->Fill(invariantMass);
4552 
4553  delete vertex; vertex = NULL;
4554  delete track; track = NULL;
4555  return;
4556 }
4557 //-------------------------------------------------------------------------------------
4558 Int_t AliAnalysisTaskSEBPlustoD0Pi::MatchCandidateToMonteCarlo(Int_t pdgabs, AliAODRecoDecayHF2Prong * candidate, TClonesArray *mcArray, TMatrix * BPlustoD0PiLabelMatrix) const
4559 {
4560  //
4561  // Check if this candidate is matched to a MC signal
4562  // If no, return -1
4563  // If yes, return label (>=0) of the AliAODMCParticle
4564 
4565 
4566  // Check number of daughters
4567  Int_t ndg = candidate->GetNDaughters();
4568  if (!ndg) { AliError("No daughters available"); return -1;}
4569  if (ndg != 2) return -1;
4570 
4571  // loop on daughters and write the labels
4572  Int_t dgLabels[2] = { -1};
4573  Int_t pdgDg[2] = {0};
4574  // Int_t signalPosition = -1;
4575  if (pdgabs == 421)
4576  {
4577  AliAODTrack *trk0 = (AliAODTrack*)candidate->GetDaughter(0);
4578  dgLabels[0] = trk0->GetLabel();
4579  AliAODTrack *trk1 = (AliAODTrack*)candidate->GetDaughter(1);
4580  dgLabels[1] = trk1->GetLabel();
4581  pdgDg[0] = 211; pdgDg[1] = 321;
4582  // signalPosition = 3;
4583  }
4584  else if (pdgabs == 521)
4585  {
4586  AliAODTrack *trk0 = (AliAODTrack*)candidate->GetDaughter(0);
4587  dgLabels[0] = trk0->GetLabel();
4588  dgLabels[1] = MatchCandidateToMonteCarlo(421, (AliAODRecoDecayHF2Prong*)candidate->GetDaughter(1), mcArray, BPlustoD0PiLabelMatrix);
4589  pdgDg[0] = 211; pdgDg[1] = 421;
4590  // signalPosition = 4;
4591  }
4592  else
4593  {
4594  std::cout << "Wrong pdg supplied for function to match candidate to monte carlo signal." << std::endl;
4595  return -1;
4596  }
4597  if (dgLabels[0] == -1) return -1;
4598  if (dgLabels[1] == -1) return -1;
4599 
4600 
4601  Int_t labMom[2] = {0, 0};
4602  Int_t i, j, lab, labMother, pdgMother, pdgPart;
4603  AliAODMCParticle *part = 0;
4604  AliAODMCParticle *mother = 0;
4605  Double_t pxSumDgs = 0., pySumDgs = 0., pzSumDgs = 0.;
4606  Bool_t pdgUsed[2] = {kFALSE, kFALSE};
4607 
4608  // loop on daughter labels
4609  for (i = 0; i < ndg; i++)
4610  {
4611  labMom[i] = -1;
4612  lab = TMath::Abs(dgLabels[i]);
4613  if (lab < 0)
4614  {
4615  printf("daughter with negative label %d\n", lab);
4616  return -1;
4617  }
4618  part = (AliAODMCParticle*)mcArray->At(lab);
4619  if (!part)
4620  {
4621  printf("no MC particle\n");
4622  return -1;
4623  }
4624 
4625  // check the PDG of the daughter
4626  pdgPart = TMath::Abs(part->GetPdgCode());
4627  for (j = 0; j < ndg; j++)
4628  {
4629  if (!pdgUsed[j] && pdgPart == pdgDg[j])
4630  {
4631  pdgUsed[j] = kTRUE;
4632  break;
4633  }
4634  }
4635 
4636 
4637  mother = part;
4638  while (mother->GetMother() >= 0)
4639  {
4640  labMother = mother->GetMother();
4641  mother = (AliAODMCParticle*)mcArray->At(labMother);
4642  if (!mother)
4643  {
4644  printf("no MC mother particle\n");
4645  break;
4646  }
4647  pdgMother = TMath::Abs(mother->GetPdgCode());
4648  if (pdgMother == pdgabs)
4649  {
4650  labMom[i] = labMother;
4651  // keep sum of daughters' momenta, to check for mom conservation
4652  pxSumDgs += part->Px();
4653  pySumDgs += part->Py();
4654  pzSumDgs += part->Pz();
4655  break;
4656  }
4657  else break;
4658  }
4659  if (labMom[i] == -1) return -1; // mother PDG not ok for this daughter
4660  } // end loop on daughters
4661 
4662  // check if the candidate is signal
4663  labMother = labMom[0];
4664  // all labels have to be the same and !=-1
4665  for (i = 0; i < ndg; i++)
4666  {
4667  if (labMom[i] == -1) return -1;
4668  if (labMom[i] != labMother) return -1;
4669  }
4670 
4671  // check that all daughter PDGs are matched
4672  for (i = 0; i < ndg; i++)
4673  {
4674  if (pdgUsed[i] == kFALSE) return -1;
4675  }
4676 
4677  // Check for mom conservation
4678  mother = (AliAODMCParticle*)mcArray->At(labMother);
4679  Double_t pxMother = mother->Px();
4680  Double_t pyMother = mother->Py();
4681  Double_t pzMother = mother->Pz();
4682 
4683 
4684  // check the number of daughters (we are not looking at resonant decay)
4685  if(mother->GetNDaughters() != 2) return -1;
4686 
4687  // if momentum conservation is not within 0.5%, show warning. This can be due to large propagation distance through magnetic field.
4688  if ((TMath::Abs(pxMother - pxSumDgs) / (TMath::Abs(pxMother) + 1.e-13)) > 0.005 ||
4689  (TMath::Abs(pyMother - pySumDgs) / (TMath::Abs(pyMother) + 1.e-13)) > 0.005 ||
4690  (TMath::Abs(pzMother - pzSumDgs) / (TMath::Abs(pzMother) + 1.e-13)) > 0.005)
4691  {
4692  std::cout << std::endl << " Momentum difference for decay pdgabs = " << pdgabs << "daughters = " << mother->GetNDaughters() << std::endl;
4693  std::cout << "pxMother = " << pxMother << "pyMother = " << pyMother << "pzMother = " << pzMother << std::endl;
4694  std::cout << "pxSumDgs = " << pxSumDgs << "pySumDgs = " << pySumDgs << "pzSumDgs = " << pzSumDgs << std::endl;
4695  }
4696 
4697  // Check if label matches a signal label
4698  // Int_t bIsSignal = kFALSE;
4699  // TMatrix &particleMatrix = *BPlustoD0PiLabelMatrix;
4700  // for (Int_t k = 0; k < BPlustoD0PiLabelMatrix->GetNrows(); ++k)
4701  // {
4702  // if(labMother == (Int_t)particleMatrix(k,signalPosition))
4703  // {
4704  // bIsSignal = kTRUE;
4705  // break;
4706  // }
4707  // }
4708  // if(!bIsSignal) return -1;
4709 
4710  return labMother;
4711 }
4712 //-------------------------------------------------------------------------------------
4713 Int_t AliAnalysisTaskSEBPlustoD0Pi::IsTrackInjected(AliAODTrack *part, AliAODMCHeader *header, TClonesArray *arrayMC) {
4714 
4716 
4717  Int_t lab = part->GetLabel();
4718  if (lab < 0) {delete ggg; ggg = nullptr; return 1;} //
4719  TString nameGen = ggg->GetGenerator(lab, header);
4720  TString empty = "";
4721  Int_t countControl = 0;
4722  while (nameGen.IsWhitespace()) {
4723  AliAODMCParticle *mcpart = (AliAODMCParticle*)arrayMC->At(lab);
4724  if (!mcpart) {
4725  printf("AliVertexingHFUtils::IsTrackInjected - BREAK: No valid AliAODMCParticle at label %i\n", lab);
4726  break;
4727  }
4728  Int_t mother = mcpart->GetMother();
4729  if (mother < 0) {
4730  // printf("AliVertexingHFUtils::IsTrackInjected - BREAK: Reached primary particle without valid mother\n");
4731  break;
4732  }
4733  lab = mother;
4734  nameGen = ggg->GetGenerator(mother, header);
4735  countControl++;
4736  if (countControl >= 10) { // 10 = arbitrary number; protection from infinite loops
4737  printf("AliVertexingHFUtils::IsTrackInjected - BREAK: Protection from infinite loop active\n");
4738  break;
4739  }
4740  }
4741  if (nameGen.IsWhitespace() || nameGen.Contains("ijing")) {delete ggg; ggg = nullptr; return 0;}
4742 
4743  delete ggg; ggg = nullptr;
4744  return 1;
4745 }
4746 //-------------------------------------------------------------------------------------
4747 Bool_t AliAnalysisTaskSEBPlustoD0Pi::IsCandidateInjected(AliAODRecoDecayHF2Prong *selectedBPlus, AliAODMCHeader *header, TClonesArray *arrayMC) {
4748 
4749  AliAODTrack* selectedBPlusPion = (AliAODTrack*)selectedBPlus->GetDaughter(0);
4750  AliAODRecoDecayHF2Prong* selectedD0 = (AliAODRecoDecayHF2Prong*)selectedBPlus->GetDaughter(1);
4751 
4752  AliAODTrack* selectedD0FirstDaughter = (AliAODTrack*)selectedD0->GetDaughter(0);
4753  AliAODTrack* selectedD0SecondDaughter = (AliAODTrack*)selectedD0->GetDaughter(1);
4754 
4755  if (IsTrackInjected(selectedBPlusPion, header, arrayMC)) return kTRUE;
4756  if (IsTrackInjected(selectedD0FirstDaughter, header, arrayMC)) return kTRUE;
4757  if (IsTrackInjected(selectedD0SecondDaughter, header, arrayMC)) return kTRUE;
4758 
4759  return kFALSE;
4760 }
4761 //-------------------------------------------------------------------------------------
4762 void AliAnalysisTaskSEBPlustoD0Pi::CutOptimizationLoop(Int_t variable, Int_t nVariables, Int_t nCuts, Int_t ptBin, Int_t fillNumber, Bool_t isDesiredCandidate) {
4763 
4764  for (Int_t iCut = 0; iCut < nCuts; ++iCut)
4765  {
4766  Int_t cutVariable = fCuts->GetCutIndexForCutOptimization(variable);
4767  Bool_t isUpperCut = fCuts->GetIsUpperCutForCutOptimization(variable);
4768  Float_t cutValue = fCuts->GetCutForCutOptimization(iCut, variable, ptBin);
4769  if(fCutVariableValueArray[cutVariable] > cutValue && isUpperCut == kTRUE) continue;
4770  if(fCutVariableValueArray[cutVariable] < cutValue && isUpperCut == kFALSE) continue;
4771 
4772  Int_t fill = iCut * TMath::Power(nCuts,variable) + fillNumber;
4773  if( (variable + 1) == nVariables)
4774  {
4775  TString ptBinMother = "";
4776  ptBinMother += "_ptbin_";
4777  ptBinMother += fPtBinLimits[ptBin];
4778  ptBinMother += "_to_";
4779  ptBinMother += fPtBinLimits[ptBin+1];
4780 
4781  TString name_cut_optimization_signal = "cut_optimization_signal";
4782  name_cut_optimization_signal += ptBinMother;
4783 
4784  TString name_cut_optimization_background = "cut_optimization_background";
4785  name_cut_optimization_background += ptBinMother;
4786 
4787  if(isDesiredCandidate) ((TH1F*)(fOutputBPlusMC->FindObject(name_cut_optimization_signal)))->Fill(fill);
4788  if(!isDesiredCandidate) ((TH1F*)(fOutputBPlusMC->FindObject(name_cut_optimization_background)))->Fill(fill);
4789  }
4790  else{CutOptimizationLoop(variable + 1, nVariables, nCuts, ptBin, fill, isDesiredCandidate);}
4791  }
4792  return;
4793 }
4794 //-------------------------------------------------------------------------------------
4796 
4797  if(!candidateBPlus){
4798  std::cout<<"candidateBPlus null"<<std::endl;
4799  return;
4800  }
4801 
4802  AliAODRecoDecayHF2Prong* candidateD0 = (AliAODRecoDecayHF2Prong*)candidateBPlus->GetDaughter(1);
4803  if(!candidateD0){
4804  std::cout<<"candidateD0 null"<<std::endl;
4805  return;
4806  }
4807 
4808  AliAODTrack *candidatePion = (AliAODTrack*)candidateBPlus->GetDaughter(0);
4809  if(!candidatePion){
4810  std::cout<<"candidatePion null 1"<<std::endl;
4811  return;
4812  }
4813 
4814  AliAODTrack *candidateFirstDaughter = (AliAODTrack*)candidateD0->GetDaughter(0);
4815  if(!candidateFirstDaughter){
4816  std::cout<<"candidatePion null 2"<<std::endl;
4817  return;
4818  }
4819 
4820  AliAODTrack *candidateSecondDaughter = (AliAODTrack*)candidateD0->GetDaughter(1);
4821  if(!candidateSecondDaughter){
4822  std::cout<<"candidateKaon null"<<std::endl;
4823  return;
4824  }
4825 
4826  AliAODVertex * vertexBPlus = candidateBPlus->GetSecondaryVtx();
4827  if(!vertexBPlus){
4828  std::cout<<"vertexBPlus null"<<std::endl;
4829  return;
4830  }
4831 
4832  AliAODVertex * vertexD0 = candidateD0->GetSecondaryVtx();
4833  if(!vertexD0){
4834  std::cout<<"vertexD0 null"<<std::endl;
4835  return;
4836  }
4837 
4838 
4839  AliAODVertex * primaryVertex = aod->GetPrimaryVertex();
4840  if(!primaryVertex){
4841  std::cout<<"primaryVertex null"<<std::endl;
4842  return;
4843  }
4844 
4845  //get the magnetic field
4846  Double_t bz = (Double_t)aod->GetMagneticField();
4847 
4848 
4849  // save D0 variable information
4850  if(kTRUE)
4851  {
4852  // D0mass
4853  Double_t mD0PDG = TDatabasePDG::Instance()->GetParticle(421)->Mass();
4854 
4855  // D0 window - invariant mass
4856  Int_t chargeBPlus = candidateBPlus->Charge();
4857  UInt_t prongs[2];
4858  if(chargeBPlus==1)
4859  {
4860  prongs[0] = 211;
4861  prongs[1] = 321;
4862  }
4863  else if (chargeBPlus==-1)
4864  {
4865  prongs[1] = 211;
4866  prongs[0] = 321;
4867  }
4868  else
4869  {
4870  std::cout << "Wrong charge BPlus." << std::endl;
4871  return;
4872  }
4873  Double_t invMassD0 = candidateD0->InvMass(2,prongs);
4874  Double_t invMassDifference = TMath::Abs(mD0PDG - invMassD0);
4875 
4876  Double_t pointingAngle = candidateD0->CosPointingAngle();
4877  Double_t dcaMother = candidateD0->GetDCA();
4878  Double_t ptMother = candidateD0->Pt();
4879  Double_t momentumMother = candidateD0->P();
4880  Double_t ptPion = candidateFirstDaughter->Pt();
4881  Double_t ptKaon = candidateSecondDaughter->Pt();
4882 
4883  AliExternalTrackParam motherTrack;
4884  motherTrack.CopyFromVTrack(candidateD0);
4885  Double_t d0z0[2],covd0z0[3],d0[2];
4886  motherTrack.PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
4887  d0[0] = d0z0[0];
4888  Double_t d0Mother = TMath::Abs(d0[0]);
4889  Double_t d0firstTrack = TMath::Abs(candidateD0->Getd0Prong(0));
4890  Double_t d0secondTrack = TMath::Abs(candidateD0->Getd0Prong(1));
4891 
4892  Double_t impactProduct = candidateD0->Prodd0d0();
4893  Double_t impactProductXY = TMath::Abs(candidateD0->ImpParXY());
4894 
4895  Double_t angleBetweenBothDaughters = (candidateSecondDaughter->Px() * candidateFirstDaughter->Px() + candidateSecondDaughter->Py() * candidateFirstDaughter->Py() + candidateSecondDaughter->Pz() * candidateFirstDaughter->Pz()) /(candidateSecondDaughter->P() * candidateFirstDaughter->P());
4896  Double_t angleMotherFirstDaughter = (candidateD0->Px() * candidateFirstDaughter->Px() + candidateD0->Py() * candidateFirstDaughter->Py() + candidateD0->Pz() * candidateFirstDaughter->Pz()) /(candidateD0->P() * candidateFirstDaughter->P());
4897  Double_t angleMotherSecondDaughter = (candidateD0->Px() * candidateSecondDaughter->Px() + candidateD0->Py() * candidateSecondDaughter->Py() + candidateD0->Pz() * candidateSecondDaughter->Pz()) /(candidateD0->P() * candidateSecondDaughter->P());
4898 
4899  Double_t cosThetaStar = candidateD0->CosThetaStar(0,421,211,321);
4900  Double_t vertexDistance = vertexD0->DistanceToVertex(primaryVertex);
4901  Double_t normDecayLength = candidateD0->NormalizedDecayLength();
4902  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(421)->Mass();
4903  Double_t pseudoProperDecayLength = ((vertexD0->GetX() - primaryVertex->GetX()) * candidateD0->Px() / TMath::Abs(candidateD0->Pt())) + ((vertexD0->GetY() - primaryVertex->GetY()) * candidateD0->Py() / TMath::Abs(candidateD0->Pt()));
4904  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother/ptMother;
4905  Double_t decayTime = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
4906 
4907  Double_t phi = candidateD0->Phi();
4908  Double_t theta = candidateD0->Theta();
4909  Double_t covMatrix[21];
4910  candidateD0->GetCovarianceXYZPxPyPz(covMatrix);
4911 
4912  Double_t cp = TMath::Cos(phi);
4913  Double_t sp = TMath::Sin(phi);
4914  Double_t ct = TMath::Cos(theta);
4915  Double_t st = TMath::Sin(theta);
4916 
4917  Double_t errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
4918  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
4919  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
4920  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
4921  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
4922  +covMatrix[20]*st*st; // GetCovPzPz
4923  Double_t normalizedDecayTime = candidateD0->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
4924 
4925  Double_t cosPointingAngleXY = candidateD0->CosPointingAngleXY();
4926  Double_t distanceXYToVertex = vertexD0->DistanceXYToVertex(primaryVertex);
4927  Double_t normalizedDecayLengthXY = candidateD0->NormalizedDecayLengthXY();
4928  Double_t chi2Vertex = vertexD0->GetChi2perNDF();
4929 
4930 
4931  //Topomatic
4932  Double_t dd0pr1=0.;
4933  Double_t dd0pr2=0.;
4934  Double_t dd0max=0.;
4935  Double_t dd0min=0.;
4936  for(Int_t ipr=0; ipr<2; ipr++)
4937  {
4938  Double_t diffIP, errdiffIP;
4939  candidateD0->Getd0MeasMinusExpProng(ipr,bz,diffIP,errdiffIP);
4940  Double_t normdd0=0.;
4941  if(errdiffIP>0.) normdd0=diffIP/errdiffIP;
4942  if(ipr==0) dd0pr1=normdd0;
4943  if(ipr==1) dd0pr2=normdd0;
4944  }
4945  if(TMath::Abs(dd0pr1)>TMath::Abs(dd0pr2)) {dd0max=dd0pr1; dd0min=dd0pr2;}
4946  else {dd0max=dd0pr2; dd0min=dd0pr1;}
4947 
4948 
4949  // We apply the cuts
4950  Int_t nCutIndex = 0;
4951 
4952  // "inv. mass width [GeV]" --------------------------------------------
4953  nCutIndex = 0;
4954  fCutVariableValueArray[nCutIndex] = invMassDifference;
4955  //---------------------------------------------------------------------
4956 
4957  // "delta mass width [GeV]" -------------------------------------------
4958  nCutIndex = 1; // not used for D0
4959  fCutVariableValueArray[nCutIndex] = 0;
4960  //---------------------------------------------------------------------
4961 
4962  // "pointing angle [Cos(theta)]" --------------------------------------
4963  nCutIndex = 2;
4964  fCutVariableValueArray[nCutIndex] = pointingAngle;
4965  //---------------------------------------------------------------------
4966 
4967  // "dca [cm]" ---------------------------------------------------------
4968  nCutIndex = 3;
4969  fCutVariableValueArray[nCutIndex] = dcaMother;
4970  //---------------------------------------------------------------------
4971 
4972  // "Pt D0 [GeV/c]" ----------------------------------------------------
4973  nCutIndex = 4;
4974  fCutVariableValueArray[nCutIndex] = ptMother;
4975  //---------------------------------------------------------------------
4976 
4977  // "Pt Kaon [GeV/c]" -------------------------------------------------
4978  nCutIndex = 5;
4979  fCutVariableValueArray[nCutIndex] = ptKaon;
4980  //---------------------------------------------------------------------
4981 
4982  // "Pt Pion [GeV/c]" --------------------------------------------------
4983  nCutIndex = 6;
4984  fCutVariableValueArray[nCutIndex] = ptPion;
4985  //---------------------------------------------------------------------
4986 
4987  // "d0 D0 [cm]" -------------------------------------------------------
4988  nCutIndex = 7;
4989  fCutVariableValueArray[nCutIndex] = d0Mother;
4990  //---------------------------------------------------------------------
4991 
4992  // "d0 Kaon [cm]"-----------------------------------------------------
4993  nCutIndex = 8;
4994  fCutVariableValueArray[nCutIndex] = d0firstTrack;
4995  //---------------------------------------------------------------------
4996 
4997  // "d0 Pion [cm]" -----------------------------------------------------
4998  nCutIndex = 9;
4999  fCutVariableValueArray[nCutIndex] = d0secondTrack;
5000  //---------------------------------------------------------------------
5001 
5002  // "d0d0 [cm^2]" ------------------------------------------------------
5003  nCutIndex = 10;
5004  fCutVariableValueArray[nCutIndex] = impactProduct;
5005  //---------------------------------------------------------------------
5006 
5007  // "d0d0 XY [cm^2]" ---------------------------------------------------
5008  nCutIndex = 11;
5009  fCutVariableValueArray[nCutIndex] = impactProductXY;
5010  //---------------------------------------------------------------------
5011 
5012  // "angle between both daughters" -------------------------------------
5013  nCutIndex = 12;
5014  fCutVariableValueArray[nCutIndex] = angleBetweenBothDaughters;
5015  //---------------------------------------------------------------------
5016 
5017  // "angle mother with first daughter" ---------------------------------
5018  nCutIndex = 13;
5019  fCutVariableValueArray[nCutIndex] = angleMotherFirstDaughter;
5020  //---------------------------------------------------------------------
5021 
5022  // "angle mother with second daughter" --------------------------------
5023  nCutIndex = 14;
5024  fCutVariableValueArray[nCutIndex] = angleMotherSecondDaughter;
5025  //---------------------------------------------------------------------
5026 
5027  // "cosThetaStar" -----------------------------------------------------
5028  nCutIndex = 15;
5029  fCutVariableValueArray[nCutIndex] = cosThetaStar;
5030  //---------------------------------------------------------------------
5031 
5032  // "vertexDistance" ---------------------------------------------------
5033  nCutIndex = 16;
5034  fCutVariableValueArray[nCutIndex] = vertexDistance;
5035  //---------------------------------------------------------------------
5036 
5037  // "pseudoProperDecayTime" --------------------------------------------
5038  nCutIndex = 17;
5039  fCutVariableValueArray[nCutIndex] = pseudoProperDecayTime;
5040  //---------------------------------------------------------------------
5041 
5042  // "DecayTime" --------------------------------------------------------
5043  nCutIndex = 18;
5044  fCutVariableValueArray[nCutIndex] = decayTime;
5045  //---------------------------------------------------------------------
5046 
5047  // "normalizedDecayTime" ----------------------------------------------------
5048  nCutIndex = 19;
5049  fCutVariableValueArray[nCutIndex] = normalizedDecayTime;
5050  //---------------------------------------------------------------------
5051 
5052  // "normDecayLength" --------------------------------------------------
5053  nCutIndex = 20;
5054  fCutVariableValueArray[nCutIndex] = normDecayLength;
5055  //---------------------------------------------------------------------
5056 
5057  // "topomatic first daughter" -----------------------------------------
5058  nCutIndex = 21;
5059  fCutVariableValueArray[nCutIndex] = dd0pr1;
5060  //---------------------------------------------------------------------
5061 
5062  // "topomatic second daughter" ----------------------------------------
5063  nCutIndex = 22;
5064  fCutVariableValueArray[nCutIndex] = dd0pr2;
5065  //---------------------------------------------------------------------
5066 
5067  // "topomatic max" ----------------------------------------------------
5068  nCutIndex = 23;
5069  fCutVariableValueArray[nCutIndex] = dd0max;
5070  //---------------------------------------------------------------------
5071 
5072  // "topomatic min" ----------------------------------------------------
5073  nCutIndex = 24;
5074  fCutVariableValueArray[nCutIndex] = dd0min;
5075  //---------------------------------------------------------------------
5076 
5077  // "pointing angle XY" ----------------------------------------------------
5078  nCutIndex = 25;
5079  fCutVariableValueArray[nCutIndex] = cosPointingAngleXY;
5080  //---------------------------------------------------------------------
5081 
5082  // "vertex distance XY" ----------------------------------------------------
5083  nCutIndex = 26;
5084  fCutVariableValueArray[nCutIndex] = distanceXYToVertex;
5085  //---------------------------------------------------------------------
5086 
5087  // "normalized decay length XY" ----------------------------------------------------
5088  nCutIndex = 27;
5089  fCutVariableValueArray[nCutIndex] = normalizedDecayLengthXY;
5090  //---------------------------------------------------------------------
5091 
5092  // "chi squared per NDF" ----------------------------------------------------
5093  nCutIndex = 28;
5094  fCutVariableValueArray[nCutIndex] = chi2Vertex;
5095  //---------------------------------------------------------------------
5096 
5097 
5098 
5099  AliAODRecoDecay* candidateD0toBPlus = (AliAODRecoDecay*)candidateD0;
5100  AliExternalTrackParam firstDaughterD0Track;
5101  AliExternalTrackParam secondDaughterD0Track;
5102 
5103  Double_t d0z0DSVert[2],covd0z0DSVert[3],d0DSVert[2];
5104 
5105  firstDaughterD0Track.CopyFromVTrack(candidateFirstDaughter);
5106  firstDaughterD0Track.PropagateToDCA(vertexBPlus,bz,100.,d0z0DSVert,covd0z0DSVert);
5107  d0DSVert[0] = d0z0DSVert[0];
5108 
5109  secondDaughterD0Track.CopyFromVTrack(candidateSecondDaughter);
5110  secondDaughterD0Track.PropagateToDCA(vertexBPlus,bz,100.,d0z0DSVert,covd0z0DSVert);
5111  d0DSVert[1] = d0z0DSVert[0];
5112 
5113  AliExternalTrackParam D0Track;
5114  D0Track.CopyFromVTrack(candidateD0);
5115  Double_t d0z0D0DSVert[2],covd0z0D0DSVert[3],d0D0DSVert;
5116  motherTrack.PropagateToDCA(vertexBPlus,bz,100.,d0z0D0DSVert,covd0z0D0DSVert);
5117  d0D0DSVert = TMath::Abs(d0z0D0DSVert[0]);
5118 
5119  Double_t impactProductToBPlus = d0DSVert[0]*d0DSVert[1];
5120  Double_t impactProductXYToBPlus = candidateD0toBPlus->ImpParXY(vertexBPlus);
5121 
5122  Double_t pointingAngleToBPlus = candidateD0toBPlus->CosPointingAngle(vertexBPlus);
5123  Double_t d0FirstDaughterToBPlus = TMath::Abs(d0DSVert[0]);
5124  Double_t d0SecondDaughterToBPlus = TMath::Abs(d0DSVert[1]);
5125  Double_t normDecayLengthToBPlus = candidateD0toBPlus->NormalizedDecayLength(vertexBPlus);
5126 
5127  Double_t pseudoProperDecayLengthDSVert = ((vertexD0->GetX() - vertexBPlus->GetX()) * candidateD0->Px() / TMath::Abs(candidateD0->Pt())) + ((vertexD0->GetY() - vertexBPlus->GetY()) * candidateD0->Py() / TMath::Abs(candidateD0->Pt()));
5128  Double_t pseudoProperDecayTimeToBPlus = pseudoProperDecayLengthDSVert * pdgMassMother/ptMother;
5129  Double_t DecayTimeToBPlus = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
5130 
5131  Double_t phiDSVert = candidateD0->Phi();
5132  Double_t thetaDSVert = candidateD0->Theta();
5133  Double_t covMatrixDSVert[21];
5134  candidateD0->GetCovarianceXYZPxPyPz(covMatrixDSVert);
5135 
5136  cp = TMath::Cos(phiDSVert);
5137  sp = TMath::Sin(phiDSVert);
5138  ct = TMath::Cos(thetaDSVert);
5139  st = TMath::Sin(thetaDSVert);
5140 
5141  errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
5142  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
5143  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
5144  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
5145  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
5146  +covMatrix[20]*st*st; // GetCovPzPz
5147  Double_t normalizedDecayTimeToBPlus = candidateD0toBPlus->NormalizedDecayLength(vertexBPlus) / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
5148 
5149  // "pointingAngleToBPlus" ---------------------------------------------
5150  nCutIndex = 29;
5151  fCutVariableValueArray[nCutIndex] = pointingAngleToBPlus;
5152  //---------------------------------------------------------------------
5153 
5154  // "d0MotherToBPlus" --------------------------------------------------
5155  nCutIndex = 30;
5156  fCutVariableValueArray[nCutIndex] = d0D0DSVert;
5157  //---------------------------------------------------------------------
5158 
5159  // "d0FirstDaughterToBPlus" -------------------------------------------
5160  nCutIndex = 31;
5161  fCutVariableValueArray[nCutIndex] = d0FirstDaughterToBPlus;
5162  //---------------------------------------------------------------------
5163 
5164  // "d0SecondDaughterToBPlus" ------------------------------------------
5165  nCutIndex = 32;
5166  fCutVariableValueArray[nCutIndex] = d0SecondDaughterToBPlus;
5167  //---------------------------------------------------------------------
5168 
5169  // "impactProductToBPlus" ---------------------------------------------
5170  nCutIndex = 33;
5171  fCutVariableValueArray[nCutIndex] = impactProductToBPlus;
5172  //---------------------------------------------------------------------
5173 
5174  // "impactProductXYToBPlus" -------------------------------------------
5175  nCutIndex = 34;
5176  fCutVariableValueArray[nCutIndex] = impactProductXYToBPlus;
5177  //---------------------------------------------------------------------
5178 
5179  // "normDecayLengthToBPlus" -------------------------------------------
5180  nCutIndex = 35;
5181  fCutVariableValueArray[nCutIndex] = normDecayLengthToBPlus;
5182  //---------------------------------------------------------------------
5183 
5184  // "pseudoProperDecayTimeToBPlus" -------------------------------------
5185  nCutIndex = 36;
5186  fCutVariableValueArray[nCutIndex] = pseudoProperDecayTimeToBPlus;
5187  //---------------------------------------------------------------------
5188 
5189  // "DecayTimeToBPlus" -------------------------------------------------
5190  nCutIndex = 37;
5191  fCutVariableValueArray[nCutIndex] = DecayTimeToBPlus;
5192  //---------------------------------------------------------------------
5193 
5194  // "normalizedDecayTimeToBPlus" ---------------------------------------------
5195  nCutIndex = 38;
5196  fCutVariableValueArray[nCutIndex] = normalizedDecayTimeToBPlus;
5197  //---------------------------------------------------------------------
5198  }
5199 
5200  // save B0 variable information
5201  if(kTRUE)
5202  {
5203  // We obtain the variable values in the section below
5204  // D0Mass and BPlusmass
5205  Double_t mD0PDG = TDatabasePDG::Instance()->GetParticle(421)->Mass();
5206  Double_t mBPlusPDG = TDatabasePDG::Instance()->GetParticle(521)->Mass();
5207 
5208  // delta mass PDG
5209  Double_t deltaPDG = mBPlusPDG - mD0PDG;
5210 
5211  // Half width BPlus mass
5212  UInt_t prongs[2];
5213  prongs[0] = 211; prongs[1] = 421;
5214  Double_t invMassBPlus = candidateBPlus->InvMass(2,prongs);
5215  Double_t invMassDifference = TMath::Abs(mBPlusPDG - invMassBPlus);
5216  Double_t invMassDelta = TMath::Abs(deltaPDG-(DeltaInvMassBPlusKpipi(candidateBPlus)));
5217 
5218  Double_t pointingAngle = candidateBPlus->CosPointingAngle();
5219  Double_t dcaMother = candidateBPlus->GetDCA();
5220  Double_t ptMother = candidateBPlus->Pt();
5221  Double_t momentumMother = candidateBPlus->P();
5222  Double_t ptD0 = candidateD0->Pt();
5223  Double_t ptPion = candidatePion->Pt();
5224 
5225  AliExternalTrackParam motherTrack;
5226  motherTrack.CopyFromVTrack(candidateBPlus);
5227  Double_t d0z0[2],covd0z0[3],d0[2];
5228  motherTrack.PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
5229  d0[0] = d0z0[0];
5230  Double_t d0Mother = TMath::Abs(d0[0]);
5231  Double_t d0firstTrack = TMath::Abs(candidateBPlus->Getd0Prong(0));
5232  Double_t d0secondTrack = TMath::Abs(candidateBPlus->Getd0Prong(1));
5233 
5234  Double_t impactProduct = candidateBPlus->Prodd0d0();
5235  Double_t impactProductXY = TMath::Abs(candidateBPlus->ImpParXY());
5236 
5237  Double_t angleBetweenBothDaughters = (candidateD0->Px() * candidatePion->Px() + candidateD0->Py() * candidatePion->Py() + candidateD0->Pz() * candidatePion->Pz()) /(candidateD0->P() * candidatePion->P());
5238  Double_t angleMotherFirstDaughter = (candidateBPlus->Px() * candidatePion->Px() + candidateBPlus->Py() * candidatePion->Py() + candidateBPlus->Pz() * candidatePion->Pz()) /(candidateBPlus->P() * candidatePion->P());
5239  Double_t angleMotherSecondDaughter = (candidateBPlus->Px() * candidateD0->Px() + candidateBPlus->Py() * candidateD0->Py() + candidateBPlus->Pz() * candidateD0->Pz()) /(candidateBPlus->P() * candidateD0->P());
5240 
5241  Double_t cosThetaStar = candidateBPlus->CosThetaStar(0,521,211,421);
5242  Double_t vertexDistance = vertexBPlus->DistanceToVertex(primaryVertex);
5243  Double_t normDecayLength = candidateBPlus->NormalizedDecayLength();
5244  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(521)->Mass();
5245  Double_t pseudoProperDecayLength = ((vertexBPlus->GetX() - primaryVertex->GetX()) * candidateBPlus->Px() / TMath::Abs(candidateBPlus->Pt())) + ((vertexBPlus->GetY() - primaryVertex->GetY()) * candidateBPlus->Py() / TMath::Abs(candidateBPlus->Pt()));
5246  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother/ptMother;
5247  Double_t decayTime = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
5248 
5249  Double_t phi = candidateBPlus->Phi();
5250  Double_t theta = candidateBPlus->Theta();
5251  Double_t covMatrix[21];
5252  candidateBPlus->GetCovarianceXYZPxPyPz(covMatrix);
5253 
5254  Double_t cp = TMath::Cos(phi);
5255  Double_t sp = TMath::Sin(phi);
5256  Double_t ct = TMath::Cos(theta);
5257  Double_t st = TMath::Sin(theta);
5258 
5259  Double_t errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
5260  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
5261  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
5262  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
5263  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
5264  +covMatrix[20]*st*st; // GetCovPzPz
5265  Double_t normalizedDecayTime = candidateBPlus->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
5266 
5267  Double_t cosPointingAngleXY = candidateBPlus->CosPointingAngleXY();
5268  Double_t distanceXYToVertex = vertexBPlus->DistanceXYToVertex(primaryVertex);
5269  Double_t normalizedDecayLengthXY = candidateBPlus->NormalizedDecayLengthXY();
5270  Double_t chi2Vertex = vertexBPlus->GetChi2perNDF();
5271 
5272  //Topomatic
5273  Double_t dd0pr1=0.;
5274  Double_t dd0pr2=0.;
5275  Double_t dd0max=0.;
5276  Double_t dd0min=0.;
5277  for(Int_t ipr=0; ipr<2; ipr++)
5278  {
5279  Double_t diffIP, errdiffIP;
5280  candidateBPlus->Getd0MeasMinusExpProng(ipr,bz,diffIP,errdiffIP);
5281  Double_t normdd0=0.;
5282  if(errdiffIP>0.) normdd0=diffIP/errdiffIP;
5283  if(ipr==0) dd0pr1=normdd0;
5284  if(ipr==1) dd0pr2=normdd0;
5285  }
5286  if(TMath::Abs(dd0pr1)>TMath::Abs(dd0pr2)) {dd0max=dd0pr1; dd0min=dd0pr2;}
5287  else {dd0max=dd0pr2; dd0min=dd0pr1;}
5288 
5289 
5290  // We apply the cuts
5291  Int_t nCutIndex = 0;
5292 
5293  // "inv. mass width [GeV]" --------------------------------------------
5294  nCutIndex = 39;
5295  fCutVariableValueArray[nCutIndex] = invMassDifference;
5296  //---------------------------------------------------------------------
5297 
5298  // "delta mass width [GeV]" -------------------------------------------
5299  nCutIndex = 40;
5300  fCutVariableValueArray[nCutIndex] = invMassDelta;
5301  //---------------------------------------------------------------------
5302 
5303  // "pointing angle [Cos(theta)]" --------------------------------------
5304  nCutIndex = 41;
5305  fCutVariableValueArray[nCutIndex] = pointingAngle;
5306  //---------------------------------------------------------------------
5307 
5308  // "dca [cm]" ---------------------------------------------------------
5309  nCutIndex = 42;
5310  fCutVariableValueArray[nCutIndex] = dcaMother;
5311  //---------------------------------------------------------------------
5312 
5313  // "Pt BPlus [GeV/c]" ----------------------------------------------------
5314  nCutIndex = 43;
5315  fCutVariableValueArray[nCutIndex] = ptMother;
5316  //---------------------------------------------------------------------
5317 
5318  // "Pt D0 [GeV/c]" -------------------------------------------------
5319  nCutIndex = 44;
5320  fCutVariableValueArray[nCutIndex] = ptD0;
5321  //---------------------------------------------------------------------
5322 
5323  // "Pt Pion [GeV/c]" --------------------------------------------------
5324  nCutIndex = 45;
5325  fCutVariableValueArray[nCutIndex] = ptPion;
5326  //---------------------------------------------------------------------
5327 
5328  // "d0 BPlus [cm]" -------------------------------------------------------
5329  nCutIndex = 46;
5330  fCutVariableValueArray[nCutIndex] = d0Mother;
5331  //---------------------------------------------------------------------
5332 
5333  // "d0 D0 [cm]"-----------------------------------------------------
5334  nCutIndex = 47;
5335  fCutVariableValueArray[nCutIndex] = d0firstTrack;
5336  //---------------------------------------------------------------------
5337 
5338  // "d0 Pion [cm]" -----------------------------------------------------
5339  nCutIndex = 48;
5340  fCutVariableValueArray[nCutIndex] = d0secondTrack;
5341  //---------------------------------------------------------------------
5342 
5343  // "d0d0 [cm^2]" ------------------------------------------------------
5344  nCutIndex = 49;
5345  fCutVariableValueArray[nCutIndex] = impactProduct;
5346  //---------------------------------------------------------------------
5347 
5348  // "d0d0 XY [cm^2]" ---------------------------------------------------
5349  nCutIndex = 50;
5350  fCutVariableValueArray[nCutIndex] = impactProductXY;
5351  //---------------------------------------------------------------------
5352 
5353  // "angle between both daughters" -------------------------------------
5354  nCutIndex = 51;
5355  fCutVariableValueArray[nCutIndex] = angleBetweenBothDaughters;
5356  //---------------------------------------------------------------------
5357 
5358  // "angle mother with first daughter" ---------------------------------
5359  nCutIndex = 52;
5360  fCutVariableValueArray[nCutIndex] = angleMotherFirstDaughter;
5361  //---------------------------------------------------------------------
5362 
5363  // "angle mother with second daughter" --------------------------------
5364  nCutIndex = 53;
5365  fCutVariableValueArray[nCutIndex] = angleMotherSecondDaughter;
5366  //---------------------------------------------------------------------
5367 
5368  // "cosThetaStar" -----------------------------------------------------
5369  nCutIndex = 54;
5370  fCutVariableValueArray[nCutIndex] = cosThetaStar;
5371  //---------------------------------------------------------------------
5372 
5373  // "vertexDistance" ---------------------------------------------------
5374  nCutIndex = 55;
5375  fCutVariableValueArray[nCutIndex] = vertexDistance;
5376  //---------------------------------------------------------------------
5377 
5378  // "pseudoProperDecayTime" --------------------------------------------
5379  nCutIndex = 56;
5380  fCutVariableValueArray[nCutIndex] = pseudoProperDecayTime;
5381  //---------------------------------------------------------------------
5382 
5383  // "DecayTime" --------------------------------------------------------
5384  nCutIndex = 57;
5385  fCutVariableValueArray[nCutIndex] = decayTime;
5386  //---------------------------------------------------------------------
5387 
5388  // "normalizedDecayTime" ----------------------------------------------------
5389  nCutIndex = 58;
5390  fCutVariableValueArray[nCutIndex] = normalizedDecayTime;
5391  //---------------------------------------------------------------------
5392 
5393  // "normDecayLength" --------------------------------------------------
5394  nCutIndex = 59;
5395  fCutVariableValueArray[nCutIndex] = normDecayLength;
5396  //---------------------------------------------------------------------
5397 
5398  // "topomatic first daughter" -----------------------------------------
5399  nCutIndex = 60;
5400  fCutVariableValueArray[nCutIndex] = dd0pr1;
5401  //---------------------------------------------------------------------
5402 
5403  // "topomatic second daughter" ----------------------------------------
5404  nCutIndex = 61;
5405  fCutVariableValueArray[nCutIndex] = dd0pr2;
5406  //---------------------------------------------------------------------
5407 
5408  // "topomatic max" ----------------------------------------------------
5409  nCutIndex = 62;
5410  fCutVariableValueArray[nCutIndex] = dd0max;
5411  //---------------------------------------------------------------------
5412 
5413  // "topomatic min" ----------------------------------------------------
5414  nCutIndex = 63;
5415  fCutVariableValueArray[nCutIndex] = dd0min;
5416  //---------------------------------------------------------------------
5417 
5418  // "pointing angle XY" ----------------------------------------------------
5419  nCutIndex = 64;
5420  fCutVariableValueArray[nCutIndex] = cosPointingAngleXY;
5421  //---------------------------------------------------------------------
5422 
5423  // "vertex distance XY" ----------------------------------------------------
5424  nCutIndex = 65;
5425  fCutVariableValueArray[nCutIndex] = distanceXYToVertex;
5426  //---------------------------------------------------------------------
5427 
5428  // "normalized decay length XY" ----------------------------------------------------
5429  nCutIndex = 66;
5430  fCutVariableValueArray[nCutIndex] = normalizedDecayLengthXY;
5431  //---------------------------------------------------------------------
5432 
5433  // "chi squared per NDF" ----------------------------------------------------
5434  nCutIndex = 67;
5435  fCutVariableValueArray[nCutIndex] = chi2Vertex;
5436  }
5437  return;
5438 }
Int_t charge
Double_t NormalizedDecayLengthXY() const
Double_t NormalizedDecayLength() const
Int_t IsTrackInjected(AliAODTrack *part, AliAODMCHeader *header, TClonesArray *arrayMC)
virtual Int_t IsSelected(TObject *obj, Int_t selectionLevel, AliAODEvent *aod, Bool_t *bCutArray)
double Double_t
Definition: External.C:58
ULong64_t GetTriggerMask()
Definition: AliRDHFCuts.h:69
Double_t DeltaInvMassBPlusKpipi(AliAODRecoDecayHF2Prong *BPlus) const
Float_t * GetPtBinLimitsD0forD0ptbin() const
Definition: External.C:236
void Getd0MeasMinusExpProng(Int_t ip, Double_t magf, Double_t &d0diff, Double_t &errd0diff) const
Int_t GetnSigmaTOF(AliAODTrack *track, Int_t species, Double_t &sigma) const
void GetSoftSelectionArrayITSD0SecondDaughter(Bool_t array[7]=0)
Bool_t D0FirstDaughterSelection(AliAODTrack *aodTrack, AliAODVertex *primaryVertex, Double_t bz, TClonesArray *mcTrackArray, TMatrix *B0toDStarPiLabelMatrix, AliAODMCHeader *header)
Int_t GetnSigmaTPC(AliAODTrack *track, Int_t species, Double_t &sigma) const
Double_t bz
Double_t ImpParXY() const
char Char_t
Definition: External.C:18
static TString GetGenerator(Int_t label, AliAODMCHeader *header)
Int_t GetWhyRejection() const
Definition: AliRDHFCuts.h:315
Double_t CosPointingAngleXY() const
Bool_t FillRecoCand(AliVEvent *event, AliAODRecoDecayHF3Prong *rd3)
void BPlustoD0PiSignalTracksInMC(TClonesArray *mcTrackArray, AliAODEvent *aodevent, TMatrix *BPlustoD0PiLabelMatrix, TList *listout)
Int_t IsD0forD0ptbinSelected(TObject *obj, Int_t selectionLevel, AliAODEvent *aod, Bool_t *bCutArray)
AliAODPidHF * GetPidHF() const
Definition: AliRDHFCuts.h:247
virtual void Terminate(Option_t *option)
AliAODVertex * RecalculateVertex(const AliVVertex *primary, TObjArray *tracks, Double_t bField, Double_t dispersion)
void BPlusPionSelection(AliAODEvent *aodEvent, AliAODVertex *primaryVertex, Double_t bz, TClonesArray *mcTrackArray, TMatrix *BPlustoD0PiLabelMatrix, AliAODMCHeader *header)
Bool_t D0SecondDaughterSelection(AliAODTrack *aodTrack, AliAODVertex *primaryVertex, Double_t bz, TClonesArray *mcTrackArray, TMatrix *B0toDStarPiLabelMatrix, AliAODMCHeader *header)
void TwoTrackCombinationInfo(AliExternalTrackParam *firstTrack, AliExternalTrackParam *secondTrack, AliAODVertex *primaryVertex, Double_t bz, Bool_t isDesiredCandidate, TString histogram_name, UInt_t prongs[2])
Int_t PtBinD0forD0ptbin(Double_t pt) const
Bool_t GetIsUpperCutForCutOptimization(Int_t nVariable) const
int Int_t
Definition: External.C:63
Definition: External.C:204
unsigned int UInt_t
Definition: External.C:33
void GetHardSelectionArrayITSD0FirstDaughter(Bool_t array[7]=0)
float Float_t
Definition: External.C:68
virtual Int_t SelectPID(AliAODTrack *track, Int_t type)
AliESDtrackCuts * GetTrackCuts() const
Definition: AliRDHFCuts.h:262
Int_t MatchCandidateToMonteCarlo(Int_t pdgabs, AliAODRecoDecayHF2Prong *candidate, TClonesArray *mcArray, TMatrix *B0toDStarPiLabelMatrix) const
void SetProngIDs(Int_t nIDs, UShort_t *id)
void GetHardSelectionArrayITSD0SecondDaughter(Bool_t array[7]=0)
void ThreeTrackCombinationInfo(AliExternalTrackParam *firstTrack, AliExternalTrackParam *secondTrack, AliExternalTrackParam *thirdTrack, AliAODVertex *primaryVertex, Double_t bz, Bool_t isDesiredCandidate, TString histogram_name, UInt_t prongs[3])
void CutOptimizationLoop(Int_t variable, Int_t nVariables, Int_t nCuts, Int_t ptBin, Int_t fillNumber, Bool_t isDesiredCandidate)
Float_t GetCutForCutOptimization(Int_t nCutIndex, Int_t nVariable, Int_t ptBin)
void SetPrimaryVtxRef(TObject *vtx)
primary vertex
short Short_t
Definition: External.C:23
Float_t fCutVariableValueArray[99]
[fnPtBinsD0forD0ptbinLimits]
void GetSoftSelectionArrayITSD0FirstDaughter(Bool_t array[7]=0)
virtual void UserCreateOutputObjects()
Implementation of interface methods.
Bool_t AreDaughtersSelected(AliAODRecoDecayHF *rd, const AliAODEvent *aod=0x0) const
Bool_t IsEventSelected(AliVEvent *event)
void FillBPlusHistograms(AliAODRecoDecayHF2Prong *selectedMother, AliAODVertex *primaryVertex, Double_t bz, Int_t motherType, Int_t histType)
void CutOptimizationVariableValues(AliAODRecoDecayHF2Prong *candidateBPlus, AliAODEvent *aod)
void FillD0Histograms(AliAODRecoDecayHF2Prong *selectedMother, AliAODVertex *primaryVertex, Double_t bz, Int_t motherType, Int_t histType, Int_t pdgCodeMother=-1)
void FillFinalTrackHistograms(AliAODRecoDecayHF2Prong *selectedBPlus, AliAODVertex *primaryVertex, Double_t bz, Bool_t isDesiredCandidate, TClonesArray *mcTrackArray)
void GetSoftSelectionArrayITSBPlusPion(Bool_t array[7]=0)
Float_t * GetPtBinLimits() const
Definition: AliRDHFCuts.h:248
Bool_t IsCandidateInjected(AliAODRecoDecayHF2Prong *part, AliAODMCHeader *header, TClonesArray *arrayMC)
void GetHardSelectionArrayITSBPlusPion(Bool_t array[7]=0)
Double_t GetSigmaForCutOptimization(Int_t iPtBin) const
unsigned short UShort_t
Definition: External.C:28