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