AliPhysics  master (3d17d9d)
AliAnalysisTaskSEB0toDPi.cxx
Go to the documentation of this file.
1 
2 
3 /**************************************************************************
4  * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
5  * *
6  * Author: The ALICE Off-line Project. *
7  * Contributors are mentioned in the code where appropriate. *
8  * *
9  * Permission to use, copy, modify and distribute this software and its *
10  * documentation strictly for non-commercial purposes is hereby granted *
11  * without fee, provided that the above copyright notice appears in all *
12  * copies and that both the copyright notice and this permission notice *
13  * appeuear in the supporting documentation. The authors make no claims *
14  * about the suitability of this software for any purpose. It is *
15  * provided "as is" without express or implied warranty. *
16  **************************************************************************/
17 
18 /* $Id$ */
19 
20 //
21 //
22 // Base class for (B0 -> DPlus pi-> K pi pi pi) Analysis
23 //
24 //
25 // Cuts are centralized in AliRDHFCutsB0toDPi
26 // Like sign + track rotation backgrounds are implemented in the macro
27 //
28 //-----------------------------------------------------------------------
29 //
30 // Author Lennart van Doremalen
31 // Utrecht University - l.v.r.vandoremalen@uu.nl
32 //
33 //-----------------------------------------------------------------------
34 
35 #include <TSystem.h>
36 #include <TChain.h>
37 #include <TParticle.h>
38 #include "TROOT.h"
39 #include <TDatabasePDG.h>
40 #include <AliAnalysisDataSlot.h>
41 #include <AliAnalysisDataContainer.h>
42 #include "AliRDHFCutsB0toDPi.h"
43 #include "AliStack.h"
44 #include "AliMCEvent.h"
45 #include "AliAnalysisManager.h"
46 #include "AliAODMCHeader.h"
47 #include "AliAODHandler.h"
48 #include "AliLog.h"
49 #include "AliVertex.h"
50 #include "AliVVertex.h"
51 #include "AliESDVertex.h"
52 #include "AliAODVertex.h"
53 #include "AliVertexerTracks.h"
54 #include "AliExternalTrackParam.h"
55 #include "AliNeutralTrackParam.h"
56 #include "AliAODRecoDecay.h"
57 #include "AliAODRecoDecayHF.h"
60 #include "AliAnalysisVertexingHF.h"
61 #include "AliVertexingHFUtils.h"
62 #include "AliESDtrack.h"
63 #include "AliAODMCParticle.h"
64 #include "AliAODEvent.h"
66 #include "AliAODInputHandler.h"
67 #include <vector>
68 #include <TMatrix.h>
69 #include <TVector3.h>
70 #include <TArrayI.h>
71 #include <bitset>
72 #include <TH3F.h>
73 
75 ClassImp(AliAnalysisTaskSEB0toDPi);
77 
78 //__________________________________________________________________________
81  fEvents(0),
82  fUseMCInfo(kFALSE),
83  fShowMask(0),
84  fShowRejection(0),
85  fQuickSignalAnalysis(0),
86  fHistMassWindow(0.125),
87  fDegreePerRotation(0),
88  fNumberOfRotations(0),
89  fPerformCutOptimization(0),
90  fRemoveInjected(0),
91  fUseSideBands(0),
92  fSideBandLow(0),
93  fSideBandHigh(0),
94  fSaveTRHists(0),
95  fOutput(0),
96  fListCuts(0),
97  fOutputB0Results(0),
98  fOutputDPlusKaon(0),
99  fOutputDPlusPions(0),
100  fOutputB0Pion(0),
101  fOutputDPlus(0),
102  fOutputB0(0),
103  fOutputDPlus_DPlusPt(0),
104  fCuts(0),
105  fCEvents(0),
106  fCTrigger(0),
107  fCRejected(0),
108  fTriggerClassesCorrelated(0),
109  fTriggerSubClasses(0),
110  fB0PionTracks(0x0),
111  fDPlusTracks(0x0),
112  // fDPlusPionTracks(0x0),
113  fnPtBins(0),
114  fnPtBinLimits(0),
115  fPtBinLimits(0x0),
116  fnPtBinsDPlusforDPlusptbin(0),
117  fnPtBinsDPlusforDPlusptbinLimits(0),
118  fPtBinLimitsDPlusforDPlusptbin(0x0),
119  fCutVariableValueArray(),
120  fDaughterHistogramArray(),
121  fDaughterHistogramArray2D(),
122  fDaughterHistogramArrayExtra(),
123  fMotherHistogramArray(),
124  fMotherHistogramArray2D(),
125  fMotherHistogramArrayExtra(),
126  fResultsHistogramArray(),
127  fResultsHistogramArray2D()
128 {
129  //
131  //
132 
133 }
134 //___________________________________________________________________________
136  AliAnalysisTaskSE(name),
137  fEvents(0),
138  fUseMCInfo(kFALSE),
139  fShowMask(0),
140  fShowRejection(0),
142  fHistMassWindow(0.125),
146  fRemoveInjected(0),
147  fUseSideBands(0),
148  fSideBandLow(0),
149  fSideBandHigh(0),
150  fSaveTRHists(0),
151  fOutput(0),
152  fListCuts(0),
153  fOutputB0Results(0),
154  fOutputDPlusKaon(0),
156  fOutputB0Pion(0),
157  fOutputDPlus(0),
158  fOutputB0(0),
160  fCuts(0),
161  fCEvents(0),
162  fCTrigger(0),
163  fCRejected(0),
166  fB0PionTracks(0x0),
167  fDPlusTracks(0x0),
168  // fDPlusPionTracks(0x0),
169  fnPtBins(0),
170  fnPtBinLimits(0),
171  fPtBinLimits(0x0),
184 {
185  //
187  //
188 
189  Info("AliAnalysisTaskSEB0toDPi", "Calling Constructor");
190 
191  fCuts = cuts;
192 
193  DefineInput(0, TChain::Class());
194  DefineOutput(1, TList::Class()); // General information
195  DefineOutput(2, TList::Class()); // Cuts
196  DefineOutput(3, TList::Class()); // DPlus kaon output
197  DefineOutput(4, TList::Class()); // DPlus pions output
198  DefineOutput(5, TList::Class()); // B0 pion output
199  DefineOutput(6, TList::Class()); // DPlus output
200  DefineOutput(7, TList::Class()); // B0 output
201  DefineOutput(8, TList::Class()); // DPlus DPlusPt output
202  DefineOutput(9, TList::Class()); // B0 results output
203 
204 }
205 
206 //___________________________________________________________________________
208  //
210  //
211  Info("~AliAnalysisTaskSEB0toDPi", "Calling Destructor");
212 
213  delete fOutput;
214  delete fOutputDPlusKaon;
215  delete fOutputDPlusPions;
216  delete fOutputB0Pion;
217  delete fOutputDPlus;
218  delete fOutputB0;
219  delete fOutputDPlus_DPlusPt;
220  delete fOutputB0Results;
221  delete fCuts;
222  delete fCEvents;
223  delete fCTrigger;
224  delete fCRejected;
226  delete fTriggerSubClasses,
227  delete fDPlusTracks;
228  // delete fDPlusPionTracks;
229  delete fB0PionTracks;
230  delete fListCuts;
231  delete fPtBinLimits;
233  for (Int_t i = 0; i < 4; i++) {
234  for (Int_t j = 0; j < 6; j++) {
235  for (Int_t k = 0; k < 15; k++) {
236  delete fDaughterHistogramArray[i][j][k]; fDaughterHistogramArray[i][j][k] = nullptr;
237  }
238  }
239  }
240  for (Int_t i = 0; i < 4; i++) {
241  for (Int_t j = 0; j < 6; j++) {
242  delete fDaughterHistogramArray2D[i][j]; fDaughterHistogramArray2D[i][j] = nullptr;
243  }
244  }
245  for (Int_t i = 0; i < 4; i++) {
246  for (Int_t j = 0; j < 6; j++) {
247  delete fDaughterHistogramArrayExtra[i][j]; fDaughterHistogramArrayExtra[i][j] = nullptr;
248  }
249  }
250  for (Int_t i = 0; i < 6; i++) {
251  for (Int_t j = 0; j < 99; j++) {
252  for (Int_t k = 0; k < 60; k++) {
253  delete fMotherHistogramArray[i][j][k]; fMotherHistogramArray[i][j][k] = nullptr;
254  }
255  }
256  }
257  for (Int_t i = 0; i < 6; i++) {
258  for (Int_t j = 0; j < 99; j++) {
259  for (Int_t k = 0; k < 60; k++) {
260  delete fMotherHistogramArray2D[i][j][k]; fMotherHistogramArray2D[i][j][k] = nullptr;
261  }
262  }
263  }
264  for (Int_t i = 0; i < 7; i++) {
265  for (Int_t j = 0; j < 10; j++) {
266  delete fMotherHistogramArrayExtra[i][j]; fMotherHistogramArrayExtra[i][j] = nullptr;
267  }
268  }
269  for (Int_t i = 0; i < 20; i++) {
270  for (Int_t j = 0; j < 99; j++) {
271  delete fResultsHistogramArray[i][j]; fResultsHistogramArray[i][j] = nullptr;
272  }
273  }
274  for (Int_t i = 0; i < 20; i++) {
275  for (Int_t j = 0; j < 99; j++) {
276  delete fResultsHistogramArray2D[i][j]; fResultsHistogramArray2D[i][j] = nullptr;
277  }
278  }
279 }
280 //_________________________________________________
282  //
284  //
285 
286  if (fDebug > 1) printf("AliAnalysisTaskSEB0toDPi::Init() \n");
287 
288  return;
289 }
290 //_________________________________________________
292 
293  //==================================================================================
294  // USER EXECUTION FUNCTION - start
295  //==================================================================================
296  //
297  // This is the main function that has to be altered to do heavy flavour analysis.
298  //
299  //==================================================================================
300 
301  if (!fInputEvent)
302  {
303  Error("UserExec", "NO EVENT FOUND!");
304  return;
305  }
306 
307  if (fEvents % 500 == 0)
308  {
309  std::cout << "\r" << "Analysing event number: " << fEvents << std::endl;
310  }
311 
312  fEvents++;
313 
314  // Show trigger mask
315  if (fShowMask)
316  {
317  std::bitset<32> maskEV(((AliAODInputHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected());
318  std::cout << "Event mask: " << maskEV << std::endl;
319  std::cout << "Trigger mask: " << std::bitset<32>(fCuts->GetTriggerMask()) << std::endl;
320  }
321 
322  AliInputEventHandler *fInputHandler = (AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
323  //save trigger information
324  for (int i = 0; i < 36; ++i)
325  {
326  ULong64_t compareValue = BIT(i);
327  // std::cout << "Compare mask: " << std::bitset<32>(compareValue) << std::endl;
328  Bool_t trigger1 = kFALSE;
329  Bool_t trigger2 = kFALSE;
330 
331  if (fInputHandler->IsEventSelected() & compareValue)
332  {
333  // std::cout << "Match!" << std::endl;
334  fCTrigger->Fill(i + 1);
335  if (i == 1) trigger1 = kTRUE;
336  if (i == 10) trigger2 = kTRUE;
337  }
338  if (trigger1 && trigger2) fCTrigger->Fill(35);
339  }
340 
341 
342  //==================================================================================
343  // EVENT INITIALIZATION - start
344  //==================================================================================
345 
346  TClonesArray *array3Prong = 0;
347  AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(fInputEvent);
348 
349  fCEvents->Fill(1);
350 
351  if(!aodEvent && AODEvent() && IsStandardAOD()) {
352  // In case there is an AOD handler writing a standard AOD, use the AOD
353  // event in memory rather than the input (ESD) event.
354  aodEvent = dynamic_cast<AliAODEvent*> (AODEvent());
355  // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
356  // have to taken from the AOD event hold by the AliAODExtension
357  AliAODHandler* aodHandler = (AliAODHandler*)
358  ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
359  if(aodHandler->GetExtensions()) {
360  AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
361  AliAODEvent *aodFromExt = ext->GetAOD();
362  array3Prong=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm3Prong");
363  }
364  } else {
365  array3Prong=(TClonesArray*)aodEvent->GetList()->FindObject("Charm3Prong");
366  }
367 
368 
369  // fix for temporary bug in ESDfilter
370  // the AODs with null vertex pointer didn't pass the PhysSel
371  if (!aodEvent->GetPrimaryVertex() || TMath::Abs(aodEvent->GetMagneticField()) < 0.001) return;
372  fCEvents->Fill(2);
373 
374  // trigger class for PbPb C0SMH-B-NOPF-ALLNOTRD
375  TString trigclass = aodEvent->GetFiredTriggerClasses();
376  if (trigclass.Contains("C0SMH-B-NOPF-ALLNOTRD") || trigclass.Contains("C0SMH-B-NOPF-ALL")) fCEvents->Fill(5);
377 
378  //Save EMCAL trigger information
379  // TString firedTrigClass = aodEvent->GetFiredTriggerClasses();
380 
381  // if (fInputHandler->IsEventSelected() & AliVEvent::kMB)fTriggerClassesCorrelated->Fill(0);
382  // if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)fTriggerClassesCorrelated->Fill(1);
383  // if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)fTriggerClassesCorrelated->Fill(2);
384  // if ((fInputHandler->IsEventSelected() & AliVEvent::kEMC7) && firedTrigClass.Contains("EMC"))fTriggerClassesCorrelated->Fill(3);
385  // if (firedTrigClass.Contains("7EJE") || firedTrigClass.Contains("8EJE")) fTriggerClassesCorrelated->Fill(4);
386  // if (firedTrigClass.Contains("7EJ1") || firedTrigClass.Contains("8EJ1")) fTriggerClassesCorrelated->Fill(5);
387  // if (firedTrigClass.Contains("7EJ2") || firedTrigClass.Contains("8EJ2")) fTriggerClassesCorrelated->Fill(6);
388  // if (firedTrigClass.Contains("7EGA") || firedTrigClass.Contains("8EGA")) fTriggerClassesCorrelated->Fill(7);
389  // if (firedTrigClass.Contains("7EG1") || firedTrigClass.Contains("8EG1")) fTriggerClassesCorrelated->Fill(8);
390  // if (firedTrigClass.Contains("7EG2") || firedTrigClass.Contains("8EG2")) fTriggerClassesCorrelated->Fill(9);
391  // if ((fInputHandler->IsEventSelected() & AliVEvent::kEMC7) && firedTrigClass.Contains("DMC"))fTriggerClassesCorrelated->Fill(10);
392  // if (firedTrigClass.Contains("7DJE") || firedTrigClass.Contains("8DJE")) fTriggerClassesCorrelated->Fill(11);
393  // if (firedTrigClass.Contains("7DJ1") || firedTrigClass.Contains("8DJ1")) fTriggerClassesCorrelated->Fill(12);
394  // if (firedTrigClass.Contains("7DJ2") || firedTrigClass.Contains("8DJ2")) fTriggerClassesCorrelated->Fill(13);
395  // if (firedTrigClass.Contains("7DGA") || firedTrigClass.Contains("8DGA")) fTriggerClassesCorrelated->Fill(14);
396  // if (firedTrigClass.Contains("7DG1") || firedTrigClass.Contains("8DG1")) fTriggerClassesCorrelated->Fill(15);
397  // if (firedTrigClass.Contains("7DG2") || firedTrigClass.Contains("8DG2")) fTriggerClassesCorrelated->Fill(16);
398 
399  // if ((fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE) && firedTrigClass.Contains("7EJE")) fTriggerSubClasses->Fill(0);
400  // if ((fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE) && firedTrigClass.Contains("7EJ1")) fTriggerSubClasses->Fill(1);
401  // if ((fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE) && firedTrigClass.Contains("7EJ2")) fTriggerSubClasses->Fill(2);
402  // if ((fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA) && firedTrigClass.Contains("7EGA")) fTriggerSubClasses->Fill(3);
403  // if ((fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA) && firedTrigClass.Contains("7EG1")) fTriggerSubClasses->Fill(4);
404  // if ((fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA) && firedTrigClass.Contains("7EG2")) fTriggerSubClasses->Fill(5);
405  // if ((fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE) && firedTrigClass.Contains("7DJE")) fTriggerSubClasses->Fill(6);
406  // if ((fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE) && firedTrigClass.Contains("7DJ1")) fTriggerSubClasses->Fill(7);
407  // if ((fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE) && firedTrigClass.Contains("7DJ2")) fTriggerSubClasses->Fill(8);
408  // if ((fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA) && firedTrigClass.Contains("7DGA")) fTriggerSubClasses->Fill(9);
409  // if ((fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA) && firedTrigClass.Contains("7DG1")) fTriggerSubClasses->Fill(10);
410  // if ((fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA) && firedTrigClass.Contains("7DG2")) fTriggerSubClasses->Fill(11);
411  // if ((fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE) && firedTrigClass.Contains("8EJE")) fTriggerSubClasses->Fill(12);
412  // if ((fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE) && firedTrigClass.Contains("8EJ1")) fTriggerSubClasses->Fill(13);
413  // if ((fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE) && firedTrigClass.Contains("8EJ2")) fTriggerSubClasses->Fill(14);
414  // if ((fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA) && firedTrigClass.Contains("8EGA")) fTriggerSubClasses->Fill(15);
415  // if ((fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA) && firedTrigClass.Contains("8EG1")) fTriggerSubClasses->Fill(16);
416  // if ((fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA) && firedTrigClass.Contains("8EG2")) fTriggerSubClasses->Fill(17);
417  // if ((fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE) && firedTrigClass.Contains("8DJE")) fTriggerSubClasses->Fill(18);
418  // if ((fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE) && firedTrigClass.Contains("8DJ1")) fTriggerSubClasses->Fill(19);
419  // if ((fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE) && firedTrigClass.Contains("8DJ2")) fTriggerSubClasses->Fill(20);
420  // if ((fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA) && firedTrigClass.Contains("8DGA")) fTriggerSubClasses->Fill(21);
421  // if ((fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA) && firedTrigClass.Contains("8DG1")) fTriggerSubClasses->Fill(22);
422  // if ((fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA) && firedTrigClass.Contains("8DG2")) fTriggerSubClasses->Fill(23);
423 
424  fCRejected->Fill(0);
425  if (!fCuts->IsEventSelected(aodEvent))
426  {
427  if (fShowRejection) std::cout << "Event rejected by code: " << fCuts->GetWhyRejection() << std::endl;
428  fCRejected->Fill(fCuts->GetWhyRejection() + 1);
429  return;
430  }
431 
432  fCEvents->Fill(3);
433 
434  //get the magnetic field
435  Double_t bz = (Double_t)aodEvent->GetMagneticField();
436 
437  // AOD primary vertex
438  AliAODVertex *primaryVertex = (AliAODVertex*)aodEvent->GetPrimaryVertex();
439  if (!primaryVertex) return;
440  if (primaryVertex->GetNContributors() < 1) return;
441  fCEvents->Fill(4);
442 
443  if (!array3Prong){
444  AliInfo("Could not find array of Charm3Prong, skipping the event");
445  return;
446  }
447  else AliDebug(2, Form("Found %d vertices",array3Prong->GetEntriesFast()));
448  if (array3Prong->GetEntriesFast()==0) return;
449 
450  AliAODMCHeader *mcHeader = 0;
451  if (fUseMCInfo)
452  {
453  mcHeader = (AliAODMCHeader*)aodEvent->GetList()->FindObject(AliAODMCHeader::StdBranchName());
454  if (!mcHeader) {
455  printf(" MC header branch not found!\n");
456  return;
457  }
458  }
459 
460 
461  //==================================================================================
462  // EVENT INITIALIZATION - end
463  //==================================================================================
464  // GET TRUE MC INFO - start
465  //==================================================================================
466 
467  TClonesArray *mcTrackArray = nullptr;
468  if (fUseMCInfo) mcTrackArray = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(AliAODMCParticle::StdBranchName()));
469  if (fUseMCInfo && !mcTrackArray) return;
470 
471  //Here we create an array and vectors that we use to look how many B0s can be reconstructed after each cut
472  TMatrix * B0toDPiLabelMatrix = new TMatrix(0, 6);
473 
474  //we fill the array with all B0->DPlusPi tracks
475  if (fUseMCInfo) {
476  B0toDPiSignalTracksInMC(mcTrackArray, aodEvent, B0toDPiLabelMatrix, fOutputB0Results);
477  }
478 
479  //==================================================================================
480  // GET TRUE MC INFO - end
481  //==================================================================================
482  // PARTICLE SELECTION LOOP - start
483  //==================================================================================
484  //
485  // Here we select and reconstruct the particles for the B0 -> DPlus + Pion decay.
486  //
487  //==================================================================================
488 
489 
490  // TClonesArray * DPlusTrackArray = new TClonesArray("AliAODRecoDecayHF3Prong", 5000);;
491  // DaughterSelection(aodEvent, primaryVertex, bz, mcTrackArray, B0toDPiLabelMatrix, mcHeader, 0, fDPlusKaonTracks);
492  // DaughterSelection(aodEvent, primaryVertex, bz, mcTrackArray, B0toDPiLabelMatrix, mcHeader, 1, fDPlusPionTracks);
493 
494  DPlusSelection(aodEvent, primaryVertex, bz, mcTrackArray, B0toDPiLabelMatrix, array3Prong, mcHeader);
495 
496  if ((Int_t)fDPlusTracks->size() > 0)
497  {
498  DaughterSelection(aodEvent, primaryVertex, bz, mcTrackArray, B0toDPiLabelMatrix, mcHeader, 2, fB0PionTracks);
499 
500  if ((Int_t)fB0PionTracks->size() > 0)
501  {
502  B0Selection(aodEvent, primaryVertex, bz, mcTrackArray, B0toDPiLabelMatrix, array3Prong, mcHeader);
503  }
504  }
505 
506 
507  // for all entries of array get vertex and delete.
508  // for (int i = 0; i < DPlusTrackArray->GetEntriesFast(); ++i) {
509  // AliAODVertex * vertex = (AliAODVertex*)((AliAODRecoDecayHF3Prong*)(*DPlusTrackArray)[i])->GetOwnSecondaryVtx();
510  // delete vertex; vertex = NULL;
511  // }
512  // DPlusTrackArray->Clear("C");
513  // delete DPlusTrackArray;
514 
515  // Clear arrays and memory management:
516  fB0PionTracks->erase(fB0PionTracks->begin(), fB0PionTracks->end());
517  fDPlusTracks->erase(fDPlusTracks->begin(), fDPlusTracks->end());
518  // fDPlusKaonTracks->erase(fDPlusKaonTracks->begin(), fDPlusKaonTracks->end());
519  // fDPlusPionTracks->erase(fDPlusPionTracks->begin(), fDPlusPionTracks->end());
520 
521 
522 
523  delete B0toDPiLabelMatrix; B0toDPiLabelMatrix = NULL;
524 
525  //==================================================================================
526  // PARTICLE SELECTION LOOP - end
527  //==================================================================================
528 
529  PostData(1, fOutput);
530  PostData(3, fOutputDPlusKaon);
531  PostData(4, fOutputDPlusPions);
532  PostData(5, fOutputB0Pion);
533  PostData(6, fOutputDPlus);
534  PostData(7, fOutputB0);
535  PostData(8, fOutputDPlus_DPlusPt);
536  PostData(9, fOutputB0Results);
537 
538 
539  //==================================================================================
540  // USER EXECUTION FUNCTION - end
541  //==================================================================================
542 
543 }
544 //___________________________________ terminate ___________________________
549 
550  //Info("Terminate","");
551  AliAnalysisTaskSE::Terminate();
552 
553  fOutput = dynamic_cast<TList*> (GetOutputData(1));
554  if (!fOutput) {
555  printf("ERROR: fOutput not available\n");
556  return;
557  }
558 
559  fCEvents = dynamic_cast<TH1F*>(fOutput->FindObject("fCEvents"));
560  fCTrigger = dynamic_cast<TH1F*>(fOutput->FindObject("fCTrigger"));
561  fCRejected = dynamic_cast<TH1F*>(fOutput->FindObject("fCRejected"));
562  fTriggerClassesCorrelated = dynamic_cast<TH1F*>(fOutput->FindObject("fTriggerClassesCorrelated"));
563  fTriggerSubClasses = dynamic_cast<TH1F*>(fOutput->FindObject("fTriggerSubClasses"));
564 
565  fListCuts = dynamic_cast<TList*> (GetOutputData(2));
566  if (!fListCuts) {
567  printf("ERROR: fListCuts not available\n");
568  return;
569  }
570  fOutputDPlusKaon = dynamic_cast<TList*> (GetOutputData(3));
571  if (!fOutputDPlusKaon) {
572  printf("ERROR: fOutputDPlusKaon not available\n");
573  return;
574  }
575  fOutputDPlusPions = dynamic_cast<TList*> (GetOutputData(4));
576  if (!fOutputDPlusPions) {
577  printf("ERROR: fOutputDPlusPions not available\n");
578  return;
579  }
580  fOutputB0Pion = dynamic_cast<TList*> (GetOutputData(5));
581  if (!fOutputB0Pion) {
582  printf("ERROR: fOutputB0Pion not available\n");
583  return;
584  }
585  fOutputDPlus = dynamic_cast<TList*> (GetOutputData(6));
586  if (!fOutputDPlus) {
587  printf("ERROR: fOutputDPlus not available\n");
588  return;
589  }
590  fOutputB0 = dynamic_cast<TList*> (GetOutputData(7));
591  if (!fOutputB0) {
592  printf("ERROR: fOutputB0 not available\n");
593  return;
594  }
595  fOutputDPlus_DPlusPt = dynamic_cast<TList*> (GetOutputData(8));
596  if (!fOutputDPlus_DPlusPt) {
597  printf("ERROR: fOutputDPlus_DPlusPt not available\n");
598  return;
599  }
600  fOutputB0Results = dynamic_cast<TList*> (GetOutputData(9));
601  if (!fOutputB0Results) {
602  printf("ERROR: fOutputB0Results not available\n");
603  return;
604  }
605  return;
606 }
607 
608 //___________________________________________________________________________
611  Info("UserCreateOutputObjects", "CreateOutputObjects of task %s\n", GetName());
612 
613  fOutput = new TList();
614  fOutput->SetOwner();
615  fOutput->SetName("General_information");
616 
617  fOutputDPlusKaon = new TList();
618  fOutputDPlusKaon->SetOwner();
619  fOutputDPlusKaon->SetName("listDPlusKaon");
620 
621  fOutputDPlusPions = new TList();
622  fOutputDPlusPions->SetOwner();
623  fOutputDPlusPions->SetName("listDPlusPions");
624 
625  fOutputB0Pion = new TList();
626  fOutputB0Pion->SetOwner();
627  fOutputB0Pion->SetName("listB0Pion");
628 
629  fOutputDPlus = new TList();
630  fOutputDPlus->SetOwner();
631  fOutputDPlus->SetName("listDPlus");
632 
633  fOutputB0 = new TList();
634  fOutputB0->SetOwner();
635  fOutputB0->SetName("listB0");
636 
637  fOutputDPlus_DPlusPt = new TList();
638  fOutputDPlus_DPlusPt->SetOwner();
639  fOutputDPlus_DPlusPt->SetName("listDPlus_DPlusPt");
640 
641  fOutputB0Results = new TList();
642  fOutputB0Results->SetOwner();
643  fOutputB0Results->SetName("listB0Results");
644 
645  // we prepare vectors that will save the positions of the daughter tracks in the track list during the reconstruction
646  fB0PionTracks = new std::vector<Int_t>;
647  // fDPlusPionTracks = new std::vector<Int_t>;
648  fDPlusTracks = new std::vector<Int_t>;
649 
650  // we get information on the pt bins
652  fnPtBinLimits = fnPtBins + 1;
654 
658 
659  std::cout << "Nr. of B0 meson bins: " << fCuts->GetNPtBins() << " limits: " << std::endl;
660  for (int i = 0; i < fnPtBinLimits; ++i)
661  {
662  std::cout << fPtBinLimits[i] << " " << std::endl;
663  }
664  std::cout << std::endl;
665  std::cout << "Nr. of DPlus meson bins: " << fCuts->GetNPtBinsDPlusforDPlusptbin() << " limits: " << std::endl;
666  for (int i = 0; i < fnPtBinsDPlusforDPlusptbinLimits; ++i)
667  {
668  std::cout << fPtBinLimitsDPlusforDPlusptbin[i] << " " << std::endl;
669  }
670  std::cout << std::endl;
671 
672  fListCuts = new TList();
673  fListCuts->SetOwner();
674  fListCuts->SetName("Cuts");
675  AliRDHFCutsB0toDPi* copyfCuts = new AliRDHFCutsB0toDPi(*fCuts);
676  fListCuts->Add(copyfCuts);
677 
678  // define histograms
680 
681  // Post the data
682  PostData(1, fOutput);
683  PostData(2, fListCuts);
684  PostData(3, fOutputDPlusKaon);
685  PostData(4, fOutputDPlusPions);
686  PostData(5, fOutputB0Pion);
687  PostData(6, fOutputDPlus);
688  PostData(7, fOutputB0);
689  PostData(8, fOutputDPlus_DPlusPt);
690  PostData(9, fOutputB0Results);
691 
692  return;
693 }
694 //___________________________________ histograms _______________________________________
696 
698 
699  fCEvents = new TH1F("fCEvents", "Event counter", 13, 0, 13);
700  fCEvents->SetStats(kTRUE);
701  fCEvents->GetXaxis()->SetTitle("");
702  fCEvents->GetYaxis()->SetTitle("Number");
703  fCEvents->GetXaxis()->SetBinLabel(2, "total nr. of events");
704  fCEvents->GetXaxis()->SetBinLabel(3, "good prim vtx and B field");
705  fCEvents->GetXaxis()->SetBinLabel(4, "total events selected");
706  fCEvents->GetXaxis()->SetBinLabel(5, "nr. vtx contributors");
707  fCEvents->GetXaxis()->SetBinLabel(6, "trigger for PbPb");
708  fCEvents->GetXaxis()->SetBinLabel(7, "no z vtx");
709  fCEvents->GetXaxis()->SetBinLabel(8, "");
710  fCEvents->GetXaxis()->SetBinLabel(9, "");
711  fCEvents->GetXaxis()->SetBinLabel(10, "");
712  fCEvents->GetXaxis()->SetBinLabel(11, "");
713  fCEvents->GetXaxis()->SetBinLabel(12, "nr. of DPlus fail to be rec");
714  fOutput->Add(fCEvents);
715 
716  fCTrigger = new TH1F("fCTrigger", "Trigger counter", 36, 0, 36);
717  fCTrigger->SetStats(kTRUE);
718  fCTrigger->GetXaxis()->SetTitle("");
719  fCTrigger->GetYaxis()->SetTitle("Number");
720  fCTrigger->GetXaxis()->SetBinLabel(1, "total nr. of events");
721  fCTrigger->GetXaxis()->SetBinLabel(2, "Bit 0 - kMB/kINT1");
722  fCTrigger->GetXaxis()->SetBinLabel(3, "Bit 1 - kINT7");
723  fCTrigger->GetXaxis()->SetBinLabel(4, "Bit 2 - kMUON");
724  fCTrigger->GetXaxis()->SetBinLabel(5, "Bit 3 - kHighMult/kHighMultSPD");
725  fCTrigger->GetXaxis()->SetBinLabel(6, "Bit 4 - kEMC1");
726  fCTrigger->GetXaxis()->SetBinLabel(7, "Bit 5 - kCINT5/kINT5");
727  fCTrigger->GetXaxis()->SetBinLabel(8, "Bit 6 - kCMUS5/kMUSPB/kINT7inMUON");
728  fCTrigger->GetXaxis()->SetBinLabel(9, "Bit 7 - kMuonSingleHighPt7/kMUSH7/kMUSHPB");
729  fCTrigger->GetXaxis()->SetBinLabel(10, "Bit 8 - kMuonLikeLowPt7/kMUL7/kMuonLikePB");
730  fCTrigger->GetXaxis()->SetBinLabel(11, "Bit 9 - kMuonUnlikeLowPt7/kMUU7/kMuonUnlikePB");
731  fCTrigger->GetXaxis()->SetBinLabel(12, "Bit 10 - kEMC7/kEMC8");
732  fCTrigger->GetXaxis()->SetBinLabel(13, "Bit 11 - kMUS7/kMuonSingleLowPt7");
733  fCTrigger->GetXaxis()->SetBinLabel(14, "Bit 12 - kPHI1");
734  fCTrigger->GetXaxis()->SetBinLabel(15, "Bit 13 - kPHI7/kPHI8/kPHOSPb");
735  fCTrigger->GetXaxis()->SetBinLabel(16, "Bit 14 - kEMCEJE");
736  fCTrigger->GetXaxis()->SetBinLabel(17, "Bit 15 - kEMCEGA");
737  fCTrigger->GetXaxis()->SetBinLabel(18, "Bit 16 - kHighMultV0/kCentral");
738  fCTrigger->GetXaxis()->SetBinLabel(19, "Bit 17 - kSemiCentral");
739  fCTrigger->GetXaxis()->SetBinLabel(20, "Bit 18 - kDG/kDG5");
740  fCTrigger->GetXaxis()->SetBinLabel(21, "Bit 19 - kZED");
741  fCTrigger->GetXaxis()->SetBinLabel(22, "Bit 20 - kSPI7/kSPI");
742  fCTrigger->GetXaxis()->SetBinLabel(23, "Bit 21 - kINT8");
743  fCTrigger->GetXaxis()->SetBinLabel(24, "Bit 22 - kMuonSingleLowPt8");
744  fCTrigger->GetXaxis()->SetBinLabel(25, "Bit 23 - kMuonSingleHighPt8");
745  fCTrigger->GetXaxis()->SetBinLabel(26, "Bit 24 - kMuonLikeLowPt8");
746  fCTrigger->GetXaxis()->SetBinLabel(27, "Bit 25 - kMuonUnlikeLowPt8");
747  fCTrigger->GetXaxis()->SetBinLabel(28, "Bit 26 - kMuonUnlikeLowPt0");
748  fCTrigger->GetXaxis()->SetBinLabel(29, "Bit 27 - kUserDefined");
749  fCTrigger->GetXaxis()->SetBinLabel(30, "Bit 28 - kTRD");
750  fCTrigger->GetXaxis()->SetBinLabel(31, "Bit 29 - ...");
751  fCTrigger->GetXaxis()->SetBinLabel(32, "Bit 30 - kFastOnly");
752  fCTrigger->GetXaxis()->SetBinLabel(33, "Bit 31 - ...");
753  fCTrigger->GetXaxis()->SetBinLabel(34, "Bit 32 - ...");
754  fCTrigger->GetXaxis()->SetBinLabel(35, "kINT7 && kEMC7");
755  fOutput->Add(fCTrigger);
756 
757  fCRejected = new TH1F("fCRejected", "Rejected counter", 35, 0, 35);
758  fCRejected->SetStats(kTRUE);
759  fCRejected->GetXaxis()->SetTitle("");
760  fCRejected->GetYaxis()->SetTitle("Number");
761  fCRejected->GetXaxis()->SetBinLabel(1, "total nr. of events");
762  fCRejected->GetXaxis()->SetBinLabel(2, "0");
763  fCRejected->GetXaxis()->SetBinLabel(3, "1");
764  fCRejected->GetXaxis()->SetBinLabel(4, "2");
765  fCRejected->GetXaxis()->SetBinLabel(5, "3");
766  fCRejected->GetXaxis()->SetBinLabel(6, "4");
767  fCRejected->GetXaxis()->SetBinLabel(7, "5");
768  fCRejected->GetXaxis()->SetBinLabel(8, "6");
769  fCRejected->GetXaxis()->SetBinLabel(9, "7");
770  fCRejected->GetXaxis()->SetBinLabel(10, "8");
771  fCRejected->GetXaxis()->SetBinLabel(11, "9");
772  fCRejected->GetXaxis()->SetBinLabel(12, "10");
773  fCRejected->GetXaxis()->SetBinLabel(13, "11");
774  fCRejected->GetXaxis()->SetBinLabel(14, "12");
775  fCRejected->GetXaxis()->SetBinLabel(15, "13");
776  fCRejected->GetXaxis()->SetBinLabel(16, "14");
777  fCRejected->GetXaxis()->SetBinLabel(17, "15");
778  fCRejected->GetXaxis()->SetBinLabel(18, "16");
779  fCRejected->GetXaxis()->SetBinLabel(19, "17");
780  fCRejected->GetXaxis()->SetBinLabel(20, "18");
781  fCRejected->GetXaxis()->SetBinLabel(21, "19");
782  fCRejected->GetXaxis()->SetBinLabel(22, "20");
783  fCRejected->GetXaxis()->SetBinLabel(23, "21");
784  fCRejected->GetXaxis()->SetBinLabel(24, "22");
785  fCRejected->GetXaxis()->SetBinLabel(25, "23");
786  fCRejected->GetXaxis()->SetBinLabel(26, "24");
787  fCRejected->GetXaxis()->SetBinLabel(27, "25");
788  fCRejected->GetXaxis()->SetBinLabel(28, "26");
789  fCRejected->GetXaxis()->SetBinLabel(29, "27");
790  fCRejected->GetXaxis()->SetBinLabel(30, "28");
791  fCRejected->GetXaxis()->SetBinLabel(31, "29");
792  fCRejected->GetXaxis()->SetBinLabel(32, "30");
793  fCRejected->GetXaxis()->SetBinLabel(33, "31");
794  fCRejected->GetXaxis()->SetBinLabel(34, "32");
795  fOutput->Add(fCRejected);
796 
797  fTriggerClassesCorrelated = new TH1F("TriggerCorrelations", "Triggers Correlated with EMCal triggers", 17, -0.5, 16.5);
798  fTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 1, "kMB");
799  fTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 2, "kINT7");
800  fTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 3, "kEMC1");
801  fTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 4, "kEMC7");
802  fTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 5, "kEMCEJE");
803  fTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 6, "kEMCEJ1");
804  fTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 7, "kEMCEJ2");
805  fTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 8, "kEMCEGA");
806  fTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 9, "kEMCEG1");
807  fTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 10, "kEMCEG2");
808  fTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 11, "kDMC7");
809  fTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 12, "kDMCDJE");
810  fTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 13, "kDMCDJ1");
811  fTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 14, "kDMCDJ2");
812  fTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 15, "kDMCDGA");
813  fTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 16, "kDMCDG1");
814  fTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 17, "kDMCDG2");
816 
817  fTriggerSubClasses = new TH1F("Subtriggers", "Subtriggers Correlated with EMCal triggers", 24, -0.5, 23.5);
818  fTriggerSubClasses->GetXaxis()->SetBinLabel( 1, "kEMC_7EJE");
819  fTriggerSubClasses->GetXaxis()->SetBinLabel( 2, "kEMC_7EJ1");
820  fTriggerSubClasses->GetXaxis()->SetBinLabel( 3, "kEMC_7EJ2");
821  fTriggerSubClasses->GetXaxis()->SetBinLabel( 4, "kEMC_7EGA");
822  fTriggerSubClasses->GetXaxis()->SetBinLabel( 5, "kEMC_7EG1");
823  fTriggerSubClasses->GetXaxis()->SetBinLabel( 6, "kEMC_7EG2");
824  fTriggerSubClasses->GetXaxis()->SetBinLabel( 7, "kDMC_7DJE");
825  fTriggerSubClasses->GetXaxis()->SetBinLabel( 8, "kDMC_7DJ1");
826  fTriggerSubClasses->GetXaxis()->SetBinLabel( 9, "kDMC_7DJ2");
827  fTriggerSubClasses->GetXaxis()->SetBinLabel( 10, "kDMC_7DGA");
828  fTriggerSubClasses->GetXaxis()->SetBinLabel( 11, "kDMC_7DG1");
829  fTriggerSubClasses->GetXaxis()->SetBinLabel( 12, "kDMC_7DG2");
830  fTriggerSubClasses->GetXaxis()->SetBinLabel( 13, "kEMC_8EJE");
831  fTriggerSubClasses->GetXaxis()->SetBinLabel( 14, "kEMC_8EJ1");
832  fTriggerSubClasses->GetXaxis()->SetBinLabel( 15, "kEMC_8EJ2");
833  fTriggerSubClasses->GetXaxis()->SetBinLabel( 16, "kEMC_8EGA");
834  fTriggerSubClasses->GetXaxis()->SetBinLabel( 17, "kEMC_8EG1");
835  fTriggerSubClasses->GetXaxis()->SetBinLabel( 18, "kEMC_8EG2");
836  fTriggerSubClasses->GetXaxis()->SetBinLabel( 19, "kDMC_8DJE");
837  fTriggerSubClasses->GetXaxis()->SetBinLabel( 20, "kDMC_8DJ1");
838  fTriggerSubClasses->GetXaxis()->SetBinLabel( 21, "kDMC_8DJ2");
839  fTriggerSubClasses->GetXaxis()->SetBinLabel( 22, "kDMC_8DGA");
840  fTriggerSubClasses->GetXaxis()->SetBinLabel( 23, "kDMC_8DG1");
841  fTriggerSubClasses->GetXaxis()->SetBinLabel( 24, "kDMC_8DG2");
843 
844 
845  //====================================================
846 
847  TString name_mc_B0_pt = "mc_B0_pt";
848  TH1F* hist_mc_B0_pt = new TH1F(name_mc_B0_pt.Data(), "Pt monte carlo B0 in B0->D*#pi; #it{p}_{T} (GeV/#it{c}); Entries", 400, 0, 20);
849  hist_mc_B0_pt->Sumw2();
850  hist_mc_B0_pt->SetLineColor(6);
851  hist_mc_B0_pt->SetMarkerStyle(20);
852  hist_mc_B0_pt->SetMarkerSize(0.6);
853  hist_mc_B0_pt->SetMarkerColor(6);
854  TH1F* histogram_mc_B0_pt = (TH1F*)hist_mc_B0_pt->Clone();
855  fOutputB0Results->Add(histogram_mc_B0_pt);
856  fResultsHistogramArray[0][0] = histogram_mc_B0_pt;
857 
858  TString name_mc_B0_pion_pt = "mc_B0_pion_pt";
859  TH1F* hist_mc_B0_pion_pt = new TH1F(name_mc_B0_pion_pt.Data(), "Pt monte carlo first pion of B0 in B0->D*#pi; #it{p}_{T} (GeV/#it{c}); Entries", 400, 0, 20);
860  hist_mc_B0_pion_pt->Sumw2();
861  hist_mc_B0_pion_pt->SetLineColor(6);
862  hist_mc_B0_pion_pt->SetMarkerStyle(20);
863  hist_mc_B0_pion_pt->SetMarkerSize(0.6);
864  hist_mc_B0_pion_pt->SetMarkerColor(6);
865  TH1F* histogram_mc_B0_pion_pt = (TH1F*)hist_mc_B0_pion_pt->Clone();
866  fOutputB0Results->Add(histogram_mc_B0_pion_pt);
867  fResultsHistogramArray[0][1] = histogram_mc_B0_pion_pt;
868 
869  TString name_mc_DPlus_pt = "mc_DPlus_pt";
870  TH1F* hist_mc_DPlus_pt = new TH1F(name_mc_DPlus_pt.Data(), "Pt monte carlo DPlus in B0->D*#pi; #it{p}_{T} (GeV/#it{c}); Entries", 400, 0, 20);
871  hist_mc_DPlus_pt->Sumw2();
872  hist_mc_DPlus_pt->SetLineColor(6);
873  hist_mc_DPlus_pt->SetMarkerStyle(20);
874  hist_mc_DPlus_pt->SetMarkerSize(0.6);
875  hist_mc_DPlus_pt->SetMarkerColor(6);
876  TH1F* histogram_mc_DPlus_pt = (TH1F*)hist_mc_DPlus_pt->Clone();
877  fOutputB0Results->Add(histogram_mc_DPlus_pt);
878  fResultsHistogramArray[0][2] = histogram_mc_DPlus_pt;
879 
880  TString name_mc_DPlus_first_pion_pt = "mc_DPlus_first_pion_pt";
881  TH1F* hist_mc_DPlus_first_pion_pt = new TH1F(name_mc_DPlus_first_pion_pt.Data(), "Pt monte carlo first pion of DPlus in B0->D*#pi; #it{p}_{T} (GeV/#it{c}); Entries", 400, 0, 20);
882  hist_mc_DPlus_first_pion_pt->Sumw2();
883  hist_mc_DPlus_first_pion_pt->SetLineColor(6);
884  hist_mc_DPlus_first_pion_pt->SetMarkerStyle(20);
885  hist_mc_DPlus_first_pion_pt->SetMarkerSize(0.6);
886  hist_mc_DPlus_first_pion_pt->SetMarkerColor(6);
887  TH1F* histogram_mc_DPlus_first_pion_pt = (TH1F*)hist_mc_DPlus_first_pion_pt->Clone();
888  fOutputB0Results->Add(histogram_mc_DPlus_first_pion_pt);
889  fResultsHistogramArray[0][3] = histogram_mc_DPlus_first_pion_pt;
890 
891  TString name_mc_DPlus_second_pion_pt = "mc_DPlus_second_pion_pt";
892  TH1F* hist_mc_DPlus_second_pion_pt = new TH1F(name_mc_DPlus_second_pion_pt.Data(), "Pt monte carlo second pion of DPlus in B0->D*#pi; #it{p}_{T} (GeV/#it{c}); Entries", 400, 0, 20);
893  hist_mc_DPlus_second_pion_pt->Sumw2();
894  hist_mc_DPlus_second_pion_pt->SetLineColor(6);
895  hist_mc_DPlus_second_pion_pt->SetMarkerStyle(20);
896  hist_mc_DPlus_second_pion_pt->SetMarkerSize(0.6);
897  hist_mc_DPlus_second_pion_pt->SetMarkerColor(6);
898  TH1F* histogram_mc_DPlus_second_pion_pt = (TH1F*)hist_mc_DPlus_second_pion_pt->Clone();
899  fOutputB0Results->Add(histogram_mc_DPlus_second_pion_pt);
900  fResultsHistogramArray[0][4] = histogram_mc_DPlus_second_pion_pt;
901 
902  TString name_mc_DPlus_kaon_pt = "mc_DPlus_kaon_pt";
903  TH1F* hist_mc_DPlus_kaon_pt = new TH1F(name_mc_DPlus_kaon_pt.Data(), "Pt monte carlo kaon of DPlus in B0->D*#pi; #it{p}_{T} (GeV/#it{c}); Entries", 400, 0, 20);
904  hist_mc_DPlus_kaon_pt->Sumw2();
905  hist_mc_DPlus_kaon_pt->SetLineColor(6);
906  hist_mc_DPlus_kaon_pt->SetMarkerStyle(20);
907  hist_mc_DPlus_kaon_pt->SetMarkerSize(0.6);
908  hist_mc_DPlus_kaon_pt->SetMarkerColor(6);
909  TH1F* histogram_mc_DPlus_kaon_pt = (TH1F*)hist_mc_DPlus_kaon_pt->Clone();
910  fOutputB0Results->Add(histogram_mc_DPlus_kaon_pt);
911  fResultsHistogramArray[0][5] = histogram_mc_DPlus_kaon_pt;
912 
913  TString name_mc_B0_rapidity_true = "mc_B0_rapidity_true";
914  TH1F* hist_mc_B0_rapidity_true = new TH1F(name_mc_B0_rapidity_true.Data(), "rapidity_true monte carlo B0 in B0->D*#pi; Y; Entries", 5000, -20, 20);
915  hist_mc_B0_rapidity_true->Sumw2();
916  hist_mc_B0_rapidity_true->SetLineColor(6);
917  hist_mc_B0_rapidity_true->SetMarkerStyle(20);
918  hist_mc_B0_rapidity_true->SetMarkerSize(0.6);
919  hist_mc_B0_rapidity_true->SetMarkerColor(6);
920  TH1F* histogram_mc_B0_rapidity_true = (TH1F*)hist_mc_B0_rapidity_true->Clone();
921  fOutputB0Results->Add(histogram_mc_B0_rapidity_true);
922  fResultsHistogramArray[0][7] = histogram_mc_B0_rapidity_true;
923 
924  TString name_mc_B0_pion_rapidity_true = "mc_B0_pion_rapidity_true";
925  TH1F* hist_mc_B0_pion_rapidity_true = new TH1F(name_mc_B0_pion_rapidity_true.Data(), "rapidity_true monte carlo first pion of B0 in B0->D*#pi; Y; Entries", 5000, -20, 20);
926  hist_mc_B0_pion_rapidity_true->Sumw2();
927  hist_mc_B0_pion_rapidity_true->SetLineColor(6);
928  hist_mc_B0_pion_rapidity_true->SetMarkerStyle(20);
929  hist_mc_B0_pion_rapidity_true->SetMarkerSize(0.6);
930  hist_mc_B0_pion_rapidity_true->SetMarkerColor(6);
931  TH1F* histogram_mc_B0_pion_rapidity_true = (TH1F*)hist_mc_B0_pion_rapidity_true->Clone();
932  fOutputB0Results->Add(histogram_mc_B0_pion_rapidity_true);
933  fResultsHistogramArray[0][8] = histogram_mc_B0_pion_rapidity_true;
934 
935  TString name_mc_DPlus_rapidity_true = "mc_DPlus_rapidity_true";
936  TH1F* hist_mc_DPlus_rapidity_true = new TH1F(name_mc_DPlus_rapidity_true.Data(), "rapidity_true monte carlo DPlus in B0->D*#pi; Y; Entries", 5000, -20, 20);
937  hist_mc_DPlus_rapidity_true->Sumw2();
938  hist_mc_DPlus_rapidity_true->SetLineColor(6);
939  hist_mc_DPlus_rapidity_true->SetMarkerStyle(20);
940  hist_mc_DPlus_rapidity_true->SetMarkerSize(0.6);
941  hist_mc_DPlus_rapidity_true->SetMarkerColor(6);
942  TH1F* histogram_mc_DPlus_rapidity_true = (TH1F*)hist_mc_DPlus_rapidity_true->Clone();
943  fOutputB0Results->Add(histogram_mc_DPlus_rapidity_true);
944  fResultsHistogramArray[0][9] = histogram_mc_DPlus_rapidity_true;
945 
946  TString name_mc_DPlus_first_pion_rapidity_true = "mc_DPlus_first_pion_rapidity_true";
947  TH1F* hist_mc_DPlus_first_pion_rapidity_true = new TH1F(name_mc_DPlus_first_pion_rapidity_true.Data(), "rapidity_true monte carlo first pion of DPlus in B0->D*#pi; Y; Entries", 5000, -20, 20);
948  hist_mc_DPlus_first_pion_rapidity_true->Sumw2();
949  hist_mc_DPlus_first_pion_rapidity_true->SetLineColor(6);
950  hist_mc_DPlus_first_pion_rapidity_true->SetMarkerStyle(20);
951  hist_mc_DPlus_first_pion_rapidity_true->SetMarkerSize(0.6);
952  hist_mc_DPlus_first_pion_rapidity_true->SetMarkerColor(6);
953  TH1F* histogram_mc_DPlus_first_pion_rapidity_true = (TH1F*)hist_mc_DPlus_first_pion_rapidity_true->Clone();
954  fOutputB0Results->Add(histogram_mc_DPlus_first_pion_rapidity_true);
955  fResultsHistogramArray[0][10] = histogram_mc_DPlus_first_pion_rapidity_true;
956 
957  TString name_mc_DPlus_second_pion_rapidity_true = "mc_DPlus_second_pion_rapidity_true";
958  TH1F* hist_mc_DPlus_second_pion_rapidity_true = new TH1F(name_mc_DPlus_second_pion_rapidity_true.Data(), "rapidity_true monte carlo second pion of DPlus in B0->D*#pi; Y; Entries", 5000, -20, 20);
959  hist_mc_DPlus_second_pion_rapidity_true->Sumw2();
960  hist_mc_DPlus_second_pion_rapidity_true->SetLineColor(6);
961  hist_mc_DPlus_second_pion_rapidity_true->SetMarkerStyle(20);
962  hist_mc_DPlus_second_pion_rapidity_true->SetMarkerSize(0.6);
963  hist_mc_DPlus_second_pion_rapidity_true->SetMarkerColor(6);
964  TH1F* histogram_mc_DPlus_second_pion_rapidity_true = (TH1F*)hist_mc_DPlus_second_pion_rapidity_true->Clone();
965  fOutputB0Results->Add(histogram_mc_DPlus_second_pion_rapidity_true);
966  fResultsHistogramArray[0][11] = histogram_mc_DPlus_second_pion_rapidity_true;
967 
968  TString name_mc_DPlus_kaon_rapidity_true = "mc_DPlus_kaon_rapidity_true";
969  TH1F* hist_mc_DPlus_kaon_rapidity_true = new TH1F(name_mc_DPlus_kaon_rapidity_true.Data(), "rapidity_true monte carlo kaon of DPlus in B0->D*#pi; Y; Entries", 5000, -20, 20);
970  hist_mc_DPlus_kaon_rapidity_true->Sumw2();
971  hist_mc_DPlus_kaon_rapidity_true->SetLineColor(6);
972  hist_mc_DPlus_kaon_rapidity_true->SetMarkerStyle(20);
973  hist_mc_DPlus_kaon_rapidity_true->SetMarkerSize(0.6);
974  hist_mc_DPlus_kaon_rapidity_true->SetMarkerColor(6);
975  TH1F* histogram_mc_DPlus_kaon_rapidity_true = (TH1F*)hist_mc_DPlus_kaon_rapidity_true->Clone();
976  fOutputB0Results->Add(histogram_mc_DPlus_kaon_rapidity_true);
977  fResultsHistogramArray[0][12] = histogram_mc_DPlus_kaon_rapidity_true;
978 
979  TString name_mc_B0_pseudorapidity_true = "mc_B0_pseudorapidity_true";
980  TH1F* hist_mc_B0_pseudorapidity_true = new TH1F(name_mc_B0_pseudorapidity_true.Data(), "pseudorapidity_true monte carlo B0 in B0->D*#pi; #eta; Entries", 5000, -20, 20);
981  hist_mc_B0_pseudorapidity_true->Sumw2();
982  hist_mc_B0_pseudorapidity_true->SetLineColor(6);
983  hist_mc_B0_pseudorapidity_true->SetMarkerStyle(20);
984  hist_mc_B0_pseudorapidity_true->SetMarkerSize(0.6);
985  hist_mc_B0_pseudorapidity_true->SetMarkerColor(6);
986  TH1F* histogram_mc_B0_pseudorapidity_true = (TH1F*)hist_mc_B0_pseudorapidity_true->Clone();
987  fOutputB0Results->Add(histogram_mc_B0_pseudorapidity_true);
988  fResultsHistogramArray[0][14] = histogram_mc_B0_pseudorapidity_true;
989 
990  TString name_mc_B0_pion_pseudorapidity_true = "mc_B0_pion_pseudorapidity_true";
991  TH1F* hist_mc_B0_pion_pseudorapidity_true = new TH1F(name_mc_B0_pion_pseudorapidity_true.Data(), "pseudorapidity_true monte carlo first pion of B0 in B0->D*#pi; #eta; Entries", 5000, -20, 20);
992  hist_mc_B0_pion_pseudorapidity_true->Sumw2();
993  hist_mc_B0_pion_pseudorapidity_true->SetLineColor(6);
994  hist_mc_B0_pion_pseudorapidity_true->SetMarkerStyle(20);
995  hist_mc_B0_pion_pseudorapidity_true->SetMarkerSize(0.6);
996  hist_mc_B0_pion_pseudorapidity_true->SetMarkerColor(6);
997  TH1F* histogram_mc_B0_pion_pseudorapidity_true = (TH1F*)hist_mc_B0_pion_pseudorapidity_true->Clone();
998  fOutputB0Results->Add(histogram_mc_B0_pion_pseudorapidity_true);
999  fResultsHistogramArray[0][15] = histogram_mc_B0_pion_pseudorapidity_true;
1000 
1001  TString name_mc_DPlus_pseudorapidity_true = "mc_DPlus_pseudorapidity_true";
1002  TH1F* hist_mc_DPlus_pseudorapidity_true = new TH1F(name_mc_DPlus_pseudorapidity_true.Data(), "pseudorapidity_true monte carlo DPlus in B0->D*#pi; #eta; Entries", 5000, -20, 20);
1003  hist_mc_DPlus_pseudorapidity_true->Sumw2();
1004  hist_mc_DPlus_pseudorapidity_true->SetLineColor(6);
1005  hist_mc_DPlus_pseudorapidity_true->SetMarkerStyle(20);
1006  hist_mc_DPlus_pseudorapidity_true->SetMarkerSize(0.6);
1007  hist_mc_DPlus_pseudorapidity_true->SetMarkerColor(6);
1008  TH1F* histogram_mc_DPlus_pseudorapidity_true = (TH1F*)hist_mc_DPlus_pseudorapidity_true->Clone();
1009  fOutputB0Results->Add(histogram_mc_DPlus_pseudorapidity_true);
1010  fResultsHistogramArray[0][16] = histogram_mc_DPlus_pseudorapidity_true;
1011 
1012  TString name_mc_DPlus_first_pion_pseudorapidity_true = "mc_DPlus_first_pion_pseudorapidity_true";
1013  TH1F* hist_mc_DPlus_first_pion_pseudorapidity_true = new TH1F(name_mc_DPlus_first_pion_pseudorapidity_true.Data(), "pseudorapidity_true monte carlo first pion of DPlus in B0->D*#pi; #eta; Entries", 5000, -20, 20);
1014  hist_mc_DPlus_first_pion_pseudorapidity_true->Sumw2();
1015  hist_mc_DPlus_first_pion_pseudorapidity_true->SetLineColor(6);
1016  hist_mc_DPlus_first_pion_pseudorapidity_true->SetMarkerStyle(20);
1017  hist_mc_DPlus_first_pion_pseudorapidity_true->SetMarkerSize(0.6);
1018  hist_mc_DPlus_first_pion_pseudorapidity_true->SetMarkerColor(6);
1019  TH1F* histogram_mc_DPlus_first_pion_pseudorapidity_true = (TH1F*)hist_mc_DPlus_first_pion_pseudorapidity_true->Clone();
1020  fOutputB0Results->Add(histogram_mc_DPlus_first_pion_pseudorapidity_true);
1021  fResultsHistogramArray[0][17] = histogram_mc_DPlus_first_pion_pseudorapidity_true;
1022 
1023  TString name_mc_DPlus_second_pion_pseudorapidity_true = "mc_DPlus_second_pion_pseudorapidity_true";
1024  TH1F* hist_mc_DPlus_second_pion_pseudorapidity_true = new TH1F(name_mc_DPlus_second_pion_pseudorapidity_true.Data(), "pseudorapidity_true monte carlo second pion of DPlus in B0->D*#pi; #eta; Entries", 5000, -20, 20);
1025  hist_mc_DPlus_second_pion_pseudorapidity_true->Sumw2();
1026  hist_mc_DPlus_second_pion_pseudorapidity_true->SetLineColor(6);
1027  hist_mc_DPlus_second_pion_pseudorapidity_true->SetMarkerStyle(20);
1028  hist_mc_DPlus_second_pion_pseudorapidity_true->SetMarkerSize(0.6);
1029  hist_mc_DPlus_second_pion_pseudorapidity_true->SetMarkerColor(6);
1030  TH1F* histogram_mc_DPlus_second_pion_pseudorapidity_true = (TH1F*)hist_mc_DPlus_second_pion_pseudorapidity_true->Clone();
1031  fOutputB0Results->Add(histogram_mc_DPlus_second_pion_pseudorapidity_true);
1032  fResultsHistogramArray[0][18] = histogram_mc_DPlus_second_pion_pseudorapidity_true;
1033 
1034  TString name_mc_DPlus_kaon_pseudorapidity_true = "mc_DPlus_kaon_pseudorapidity_true";
1035  TH1F* hist_mc_DPlus_kaon_pseudorapidity_true = new TH1F(name_mc_DPlus_kaon_pseudorapidity_true.Data(), "pseudorapidity_true monte carlo kaon of DPlus in B0->D*#pi; #eta; Entries", 5000, -20, 20);
1036  hist_mc_DPlus_kaon_pseudorapidity_true->Sumw2();
1037  hist_mc_DPlus_kaon_pseudorapidity_true->SetLineColor(6);
1038  hist_mc_DPlus_kaon_pseudorapidity_true->SetMarkerStyle(20);
1039  hist_mc_DPlus_kaon_pseudorapidity_true->SetMarkerSize(0.6);
1040  hist_mc_DPlus_kaon_pseudorapidity_true->SetMarkerColor(6);
1041  TH1F* histogram_mc_DPlus_kaon_pseudorapidity_true = (TH1F*)hist_mc_DPlus_kaon_pseudorapidity_true->Clone();
1042  fOutputB0Results->Add(histogram_mc_DPlus_kaon_pseudorapidity_true);
1043  fResultsHistogramArray[0][19] = histogram_mc_DPlus_kaon_pseudorapidity_true;
1044 
1046  {
1047  Int_t nCuts = fCuts->GetnCutsForOptimization();
1049  Int_t nCutOptimizationBins = TMath::Power(nCuts, nVariables);
1051 
1052  for (Int_t k = 0; k < fnPtBins; ++k)
1053  {
1054  TString ptBinMother = "";
1055  ptBinMother += "_ptbin_";
1056  ptBinMother += fPtBinLimits[k];
1057  ptBinMother += "_to_";
1058  ptBinMother += fPtBinLimits[k + 1];
1059 
1060  TString name_cut_optimization_signal = "cut_optimization_signal";
1061  name_cut_optimization_signal += ptBinMother;
1062  TH2F* hist_cut_optimization_signal = new TH2F(name_cut_optimization_signal.Data(), "Total signal for different cuts; Cut number; Entries", nCutOptimizationBins, 0, nCutOptimizationBins, 2 * nSigmaBins, -nSigmaBins, nSigmaBins);
1063  hist_cut_optimization_signal->Sumw2();
1064  hist_cut_optimization_signal->SetLineColor(6);
1065  hist_cut_optimization_signal->SetMarkerStyle(20);
1066  hist_cut_optimization_signal->SetMarkerSize(0.6);
1067  hist_cut_optimization_signal->SetMarkerColor(6);
1068  TH2F* histogram_cut_optimization_signal = (TH2F*)hist_cut_optimization_signal->Clone();
1069  fOutputB0Results->Add(histogram_cut_optimization_signal);
1070  fResultsHistogramArray2D[0][k] = histogram_cut_optimization_signal;
1071 
1072  TString name_cut_optimization_background = "cut_optimization_background";
1073  name_cut_optimization_background += ptBinMother;
1074  TH2F* hist_cut_optimization_background = new TH2F(name_cut_optimization_background.Data(), "Total background for different cuts; Cut number; Entries", nCutOptimizationBins, 0, nCutOptimizationBins, 2 * nSigmaBins, -nSigmaBins, nSigmaBins);
1075  hist_cut_optimization_background->Sumw2();
1076  hist_cut_optimization_background->SetLineColor(6);
1077  hist_cut_optimization_background->SetMarkerStyle(20);
1078  hist_cut_optimization_background->SetMarkerSize(0.6);
1079  hist_cut_optimization_background->SetMarkerColor(6);
1080  TH2F* histogram_cut_optimization_background = (TH2F*)hist_cut_optimization_background->Clone();
1081  fOutputB0Results->Add(histogram_cut_optimization_background);
1082  fResultsHistogramArray2D[1][k] = histogram_cut_optimization_background;
1083  }
1084  }
1085 
1086 
1087  //==================================================
1088 
1089  TString name_B0s_in_analysis = "B0_in_analysis";
1090  TH1F* hist_B0s_in_analysis = new TH1F(name_B0s_in_analysis.Data(), "Number of B0s to kpipipi in the Analysis; Entries", 20, 0, 20);
1091  hist_B0s_in_analysis->Sumw2();
1092  hist_B0s_in_analysis->SetLineColor(6);
1093  hist_B0s_in_analysis->SetMarkerStyle(20);
1094  hist_B0s_in_analysis->SetMarkerSize(0.6);
1095  hist_B0s_in_analysis->SetMarkerColor(6);
1096  hist_B0s_in_analysis->SetStats(kTRUE);
1097  hist_B0s_in_analysis->GetXaxis()->SetBinLabel(1, "no. of B0");
1098  hist_B0s_in_analysis->GetXaxis()->SetBinLabel(2, "no. of B0 to kpipipi");
1099  hist_B0s_in_analysis->GetXaxis()->SetBinLabel(3, "no. with all tracks in event");
1100  hist_B0s_in_analysis->GetXaxis()->SetBinLabel(4, "no. ...");
1101  hist_B0s_in_analysis->GetXaxis()->SetBinLabel(5, "no. ...");
1102  hist_B0s_in_analysis->GetXaxis()->SetBinLabel(6, "no. ...");
1103  hist_B0s_in_analysis->GetXaxis()->SetBinLabel(7, "no. ...");
1104  hist_B0s_in_analysis->GetXaxis()->SetBinLabel(8, "no. ...");
1105  TH1F* hist_B0s_in_analysis_mc = (TH1F*)hist_B0s_in_analysis->Clone();
1106  fOutputB0Results->Add(hist_B0s_in_analysis_mc);
1107  fResultsHistogramArray[3][0] = hist_B0s_in_analysis_mc;
1108 
1109  TString name_B0_per_bin = "B0_per_bin";
1110  TH1F* hist_B0_per_bin = new TH1F(name_B0_per_bin.Data(), "Number of B0 to kpipi in the Analysis per bin; Entries", fnPtBins, 0, fnPtBins);
1111  for (Int_t i = 0; i < fnPtBins; ++i)
1112  {
1113  TString bin_name = "";
1114  bin_name += fPtBinLimits[i];
1115  bin_name += "-";
1116  bin_name += fPtBinLimits[i + 1];
1117  hist_B0_per_bin->GetXaxis()->SetBinLabel(i + 1, bin_name);
1118  }
1119  TH1F* hist_B0_per_bin_mc = (TH1F*)hist_B0_per_bin->Clone();
1120  fOutputB0Results->Add(hist_B0_per_bin_mc);
1121  fResultsHistogramArray[3][1] = hist_B0_per_bin_mc;
1122 
1123  TString name_B0_per_bin_in_Acc = "B0_per_bin_in_Acc";
1124  TH1F* hist_B0_per_bin_in_Acc = new TH1F(name_B0_per_bin_in_Acc.Data(), "Number of B0 to kpipi in the Analysis per bin with all daughters in acceptance; Entries", fnPtBins, 0, fnPtBins);
1125  for (Int_t i = 0; i < fnPtBins; ++i)
1126  {
1127  TString bin_name = "";
1128  bin_name += fPtBinLimits[i];
1129  bin_name += "-";
1130  bin_name += fPtBinLimits[i + 1];
1131  hist_B0_per_bin_in_Acc->GetXaxis()->SetBinLabel(i + 1, bin_name);
1132  }
1133  TH1F* hist_B0_per_bin_in_Acc_mc = (TH1F*)hist_B0_per_bin_in_Acc->Clone();
1134  fOutputB0Results->Add(hist_B0_per_bin_in_Acc_mc);
1135  fResultsHistogramArray[3][2] = hist_B0_per_bin_in_Acc_mc;
1136 
1137  TString name_Reconstructed_B0_per_bin_in_Acc = "Reconstructed_B0_per_bin_in_Acc";
1138  TH1F* hist_Reconstructed_B0_per_bin_in_Acc = new TH1F(name_Reconstructed_B0_per_bin_in_Acc.Data(), "Number of reconstructed B0 in the Analysis per bin with all daughters in acceptance; Entries", fnPtBins, 0, fnPtBins);
1139  for (Int_t i = 0; i < fnPtBins; ++i)
1140  {
1141  TString bin_name = "";
1142  bin_name += fPtBinLimits[i];
1143  bin_name += "-";
1144  bin_name += fPtBinLimits[i + 1];
1145  hist_Reconstructed_B0_per_bin_in_Acc->GetXaxis()->SetBinLabel(i + 1, bin_name);
1146  }
1147  TH1F* hist_Reconstructed_B0_per_bin_in_Acc_mc = (TH1F*)hist_Reconstructed_B0_per_bin_in_Acc->Clone();
1148  fOutputB0Results->Add(hist_Reconstructed_B0_per_bin_in_Acc_mc);
1149  fResultsHistogramArray[3][3] = hist_Reconstructed_B0_per_bin_in_Acc_mc;
1150 
1151  //======================================================================================================================================================
1152 
1153  //we make the histograms for the Pions and Kaon
1154  for (Int_t i = 0; i < 3; i++) {
1155 
1156  TString add_name = "";
1157  TList * listout = 0x0;
1158  if (i == 0) listout = fOutputDPlusKaon;
1159  if (i == 1) listout = fOutputDPlusPions;
1160  if (i == 2) listout = fOutputB0Pion;
1161 
1162  for (Int_t j = 0; j < 6; j++) {
1163  if (j == 0) add_name = "";
1164  if (j == 1) add_name = "Signal";
1165  if (j == 2) add_name = "Cut";
1166  if (j == 3) add_name = "SignalCut";
1167  if (j == 4) add_name = "Result";
1168  if (j == 5) add_name = "SignalResult";
1169 
1170  TString name_Histogram = "";
1171  TString discription_Histogram = "";
1172  Int_t numberOfBins = 0;
1173  Double_t lowerBound = 0.0;
1174  Double_t upperBound = 0.0;
1175 
1176  for (Int_t k = 0; k < 11; ++k)
1177  {
1178  if (k == 0) {name_Histogram = "ptTrack"; discription_Histogram = "pt track; #it{p}_{T} (GeV/#it{c}); Entries"; numberOfBins = 600; lowerBound = 0; upperBound = 30;}
1179  if (k == 1) {name_Histogram = "momentumTrack"; discription_Histogram = "momentum track; p (GeV/#it{c}); Entries"; numberOfBins = 600; lowerBound = 0; upperBound = 30;}
1180  if (k == 2) {name_Histogram = "numberOfITS"; discription_Histogram = "Number of ITS clusters track; [#]; Entries"; numberOfBins = 10; lowerBound = -0.5; upperBound = 9.5;}
1181  if (k == 3) {name_Histogram = "numberOfTPC"; discription_Histogram = "Number of TPC clusters track; [#]; Entries"; numberOfBins = 601; lowerBound = -0.5; upperBound = 600.5;}
1182  if (k == 4) {name_Histogram = "pointsOnITS"; discription_Histogram = "Number of ITS clusters track per layer; [#]; Entries"; numberOfBins = 10; lowerBound = -0.5; upperBound = 9.5;}
1183  if (k == 5) {name_Histogram = "nSigmaTPC"; discription_Histogram = "n sigma TPC for track PID; sigma; Entries"; numberOfBins = 500; lowerBound = -5; upperBound = 5;}
1184  if (k == 6) {name_Histogram = "nSigmaTOF"; discription_Histogram = "n sigma TOF for track PID; sigma; Entries"; numberOfBins = 500; lowerBound = -5; upperBound = 5;}
1185  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;}
1186  if (k == 8) {name_Histogram = "impactParameter"; discription_Histogram = "Impact Parameter track; (cm); Entries"; numberOfBins = 2000; lowerBound = 0; upperBound = 0.5;}
1187  if (k == 9) {name_Histogram = "NormalizedImpactParameter"; discription_Histogram = "Normalized Impact Parameter track; (cm); Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 100;}
1188  if (k == 10) {name_Histogram = "EtaTrack"; discription_Histogram = "Eta Track; Entries"; numberOfBins = 1000; lowerBound = -3; upperBound = 3;}
1189 
1190  name_Histogram += add_name;
1191  TH1F* histogram = new TH1F(name_Histogram.Data(), discription_Histogram.Data(), numberOfBins, lowerBound, upperBound);
1192  histogram->Sumw2();
1193  if (j % 2 == 0) histogram->SetLineColor(6);
1194  if (j % 2 == 1) histogram->SetLineColor(4);
1195  histogram->SetMarkerStyle(20);
1196  histogram->SetMarkerSize(0.6);
1197  if (j % 2 == 0) histogram->SetMarkerColor(6);
1198  if (j % 2 == 1) histogram->SetMarkerColor(4);
1199  TH1F* histogram_Clone = (TH1F*)histogram->Clone();
1200  listout->Add(histogram_Clone);
1201  fDaughterHistogramArray[i][j][k] = histogram_Clone;
1202  }
1203 
1204  TString numberofparticlesperevent = "numberofparticlesperevent";
1205  numberofparticlesperevent += add_name;
1206  TH1F* hist_numberofparticlesperevent = new TH1F(numberofparticlesperevent.Data(), "Number of particles per event; number of particles in one event; Entries", 100, 0, 100);
1207  hist_numberofparticlesperevent->Sumw2();
1208  hist_numberofparticlesperevent->SetLineColor(6);
1209  hist_numberofparticlesperevent->SetMarkerStyle(20);
1210  hist_numberofparticlesperevent->SetMarkerSize(0.6);
1211  hist_numberofparticlesperevent->SetMarkerColor(6);
1212  TH1F* histogram_numberofparticlesperevent = (TH1F*)hist_numberofparticlesperevent->Clone();
1213  listout->Add(histogram_numberofparticlesperevent);
1214  fDaughterHistogramArray[i][j][10] = histogram_numberofparticlesperevent;
1215  }
1216 
1217  TH1F * effectOfCuts = new TH1F("effectOfCuts", "Removal counter", 18, 0, 18);
1218  effectOfCuts->SetStats(kTRUE);
1219  effectOfCuts->GetXaxis()->SetTitle("Cut number");
1220  effectOfCuts->GetYaxis()->SetTitle("Particles cut");
1221  effectOfCuts->GetXaxis()->SetBinLabel(1, "total");
1222  effectOfCuts->GetXaxis()->SetBinLabel(2, "1");
1223  effectOfCuts->GetXaxis()->SetBinLabel(3, "2");
1224  effectOfCuts->GetXaxis()->SetBinLabel(4, "3");
1225  effectOfCuts->GetXaxis()->SetBinLabel(5, "4");
1226  effectOfCuts->GetXaxis()->SetBinLabel(6, "5");
1227  effectOfCuts->GetXaxis()->SetBinLabel(7, "6");
1228  effectOfCuts->GetXaxis()->SetBinLabel(8, "7");
1229  effectOfCuts->GetXaxis()->SetBinLabel(9, "8");
1230  effectOfCuts->GetXaxis()->SetBinLabel(10, "9");
1231  effectOfCuts->GetXaxis()->SetBinLabel(11, "10");
1232  effectOfCuts->GetXaxis()->SetBinLabel(12, "11");
1233  effectOfCuts->GetXaxis()->SetBinLabel(13, "12");
1234  effectOfCuts->GetXaxis()->SetBinLabel(14, "13");
1235  effectOfCuts->GetXaxis()->SetBinLabel(15, "14");
1236  effectOfCuts->GetXaxis()->SetBinLabel(16, "15");
1237  effectOfCuts->GetXaxis()->SetBinLabel(17, "16");
1238  effectOfCuts->GetXaxis()->SetBinLabel(18, "17");
1239  listout->Add(effectOfCuts);
1240  fDaughterHistogramArrayExtra[i][0] = effectOfCuts;
1241 
1242  TH1F * effectOfCutsSignal = new TH1F("effectOfCutsSignal", "Removal counter", 18, 0, 18);
1243  effectOfCutsSignal->SetStats(kTRUE);
1244  effectOfCutsSignal->GetXaxis()->SetTitle("Cut number");
1245  effectOfCutsSignal->GetYaxis()->SetTitle("Particles cut");
1246  effectOfCutsSignal->GetXaxis()->SetBinLabel(1, "total");
1247  effectOfCutsSignal->GetXaxis()->SetBinLabel(2, "1");
1248  effectOfCutsSignal->GetXaxis()->SetBinLabel(3, "2");
1249  effectOfCutsSignal->GetXaxis()->SetBinLabel(4, "3");
1250  effectOfCutsSignal->GetXaxis()->SetBinLabel(5, "4");
1251  effectOfCutsSignal->GetXaxis()->SetBinLabel(6, "5");
1252  effectOfCutsSignal->GetXaxis()->SetBinLabel(7, "6");
1253  effectOfCutsSignal->GetXaxis()->SetBinLabel(8, "7");
1254  effectOfCutsSignal->GetXaxis()->SetBinLabel(9, "8");
1255  effectOfCutsSignal->GetXaxis()->SetBinLabel(10, "9");
1256  effectOfCutsSignal->GetXaxis()->SetBinLabel(11, "10");
1257  effectOfCutsSignal->GetXaxis()->SetBinLabel(12, "11");
1258  effectOfCutsSignal->GetXaxis()->SetBinLabel(13, "12");
1259  effectOfCutsSignal->GetXaxis()->SetBinLabel(14, "13");
1260  effectOfCutsSignal->GetXaxis()->SetBinLabel(15, "14");
1261  effectOfCutsSignal->GetXaxis()->SetBinLabel(16, "15");
1262  effectOfCutsSignal->GetXaxis()->SetBinLabel(17, "16");
1263  effectOfCutsSignal->GetXaxis()->SetBinLabel(18, "17");
1264  listout->Add(effectOfCutsSignal);
1265  fDaughterHistogramArrayExtra[i][1] = effectOfCutsSignal;
1266 
1267  TString name_particle_pdg = "particle_pdg";
1268  TH1F* hist_particle_pdg = new TH1F(name_particle_pdg.Data(), "Pdg code particle; pdg code; Entries", 2000, -0.5, 1999.5);
1269  hist_particle_pdg->Sumw2();
1270  hist_particle_pdg->SetLineColor(6);
1271  hist_particle_pdg->SetMarkerStyle(20);
1272  hist_particle_pdg->SetMarkerSize(0.6);
1273  hist_particle_pdg->SetMarkerColor(6);
1274  TH1F* histogram_particle_pdg = (TH1F*)hist_particle_pdg->Clone();
1275  listout->Add(histogram_particle_pdg);
1276  fDaughterHistogramArrayExtra[i][2] = histogram_particle_pdg;
1277 
1278  TString name_particle_mother_pdg = "particle_mother_pdg";
1279  TH1F* hist_particle_mother_pdg = new TH1F(name_particle_mother_pdg.Data(), "Pdg code particle mother; pdg code; Entries", 2000, -0.5, 1999.5);
1280  hist_particle_mother_pdg->Sumw2();
1281  hist_particle_mother_pdg->SetLineColor(6);
1282  hist_particle_mother_pdg->SetMarkerStyle(20);
1283  hist_particle_mother_pdg->SetMarkerSize(0.6);
1284  hist_particle_mother_pdg->SetMarkerColor(6);
1285  TH1F* histogram_particle_mother_pdg = (TH1F*)hist_particle_mother_pdg->Clone();
1286  listout->Add(histogram_particle_mother_pdg);
1287  fDaughterHistogramArrayExtra[i][3] = histogram_particle_mother_pdg;
1288 
1289  TString name_ptB0_vs_ptTrack = "ptB0_vs_ptTrackBackground";
1290  TH2F* hist_ptB0_vs_ptTrack = new TH2F(name_ptB0_vs_ptTrack.Data(), "Pt B0 vs Pt ; #it{p}_{T} B0 (GeV/#it{c}); #it{p}_{T} track (GeV/#it{c})", 100, 0, 30, 100, 0, 30);
1291  hist_ptB0_vs_ptTrack->Sumw2();
1292  hist_ptB0_vs_ptTrack->SetLineColor(6);
1293  hist_ptB0_vs_ptTrack->SetMarkerStyle(20);
1294  hist_ptB0_vs_ptTrack->SetMarkerSize(0.6);
1295  hist_ptB0_vs_ptTrack->SetMarkerColor(6);
1296  TH2F* histogram_ptB0_vs_ptTrack = (TH2F*)hist_ptB0_vs_ptTrack->Clone();
1297  listout->Add(histogram_ptB0_vs_ptTrack);
1298  fDaughterHistogramArray2D[i][4] = histogram_ptB0_vs_ptTrack;
1299 
1300  TString name_ptB0_vs_ptTrackSignal = "ptB0_vs_ptTrackSignal";
1301  TH2F* hist_ptB0_vs_ptTrackSignal = new TH2F(name_ptB0_vs_ptTrackSignal.Data(), "Pt B0 vs Pt ; #it{p}_{T} B0 (GeV/#it{c}); #it{p}_{T} track (GeV/#it{c})", 100, 0, 30, 100, 0, 30);
1302  hist_ptB0_vs_ptTrackSignal->Sumw2();
1303  hist_ptB0_vs_ptTrackSignal->SetLineColor(4);
1304  hist_ptB0_vs_ptTrackSignal->SetMarkerStyle(20);
1305  hist_ptB0_vs_ptTrackSignal->SetMarkerSize(0.6);
1306  hist_ptB0_vs_ptTrackSignal->SetMarkerColor(6);
1307  TH2F* histogram_ptB0_vs_ptTrackSignal = (TH2F*)hist_ptB0_vs_ptTrackSignal->Clone();
1308  listout->Add(histogram_ptB0_vs_ptTrackSignal);
1309  fDaughterHistogramArray2D[i][5] = histogram_ptB0_vs_ptTrackSignal;
1310  }
1311 
1312  //we make the histograms for the reconstructed particles
1313  for (Int_t i = 0; i < 3; i++) {
1314 
1315  TString add_name = "";
1316  TList * listout = 0x0;
1317  Int_t nHistogramSets = 0;
1318  if (i == 0) {listout = fOutputDPlus; nHistogramSets = 6 + 2 * fnPtBins;}
1319  if (i == 1) {listout = fOutputB0; nHistogramSets = 6 + 2 * fnPtBins;}
1320  if (i == 2) {listout = fOutputDPlus_DPlusPt; nHistogramSets = 2 * fnPtBinsDPlusforDPlusptbin;}
1321 
1322 
1323  for (Int_t j = 0; j < nHistogramSets; j++) {
1324  if (i < 2)
1325  {
1326  if (j == 0) add_name = "Uncut";
1327  if (j == 1) add_name = "SignalUncut";
1328  if (j == 2) add_name = "Cut";
1329  if (j == 3) add_name = "SignalCut";
1330  if (j == 4) add_name = "Result";
1331  if (j == 5) add_name = "SignalResult";
1332  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];}
1333  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];}
1334  }
1335  if (i == 2)
1336  {
1337  if (j % 2 == 0) {add_name = "_ptbin_"; add_name += fPtBinLimitsDPlusforDPlusptbin[j / 2]; add_name += "_to_"; add_name += fPtBinLimitsDPlusforDPlusptbin[1 + j / 2];}
1338  if (j % 2 == 1) {add_name = "Signal_ptbin_"; add_name += fPtBinLimitsDPlusforDPlusptbin[(j - 1) / 2]; add_name += "_to_"; add_name += fPtBinLimitsDPlusforDPlusptbin[1 + (j - 1) / 2];}
1339  }
1340 
1341  TList * listCandidates = new TList();
1342  listCandidates->SetOwner();
1343  listCandidates->SetName(add_name);
1344  listout->Add(listCandidates);
1345 
1346  TString name_Histogram = "";
1347  TString discription_Histogram = "";
1348  Int_t numberOfBins = 0;
1349  Double_t lowerBound = 0.0;
1350  Double_t upperBound = 0.0;
1351  // Int_t numberOfBinsTwo = 0;
1352  // Double_t lowerBoundTwo = 0.0;
1353  // Double_t upperBoundTwo = 0.0;
1354 
1355  if (i == 0 || i == 2)
1356  {
1357  for (Int_t k = 0; k < 49; ++k)
1358  {
1359  if (k == 0) {name_Histogram = "invariantMassMother"; discription_Histogram = "mass mother candidate; m (GeV/#it{c}^{2}); Entries"; numberOfBins = 10000; lowerBound = 0; upperBound = 10;}
1360  if (k == 1) {name_Histogram = "deltaMassMother"; discription_Histogram = "mass mother candidate; m (GeV/#it{c}^{2}); Entries"; numberOfBins = 10000; lowerBound = 0; upperBound = 10;}
1361  if (k == 2) {name_Histogram = "ptMother"; discription_Histogram = "pt mother; #it{p}_{T} (GeV/#it{c}); Entries"; numberOfBins = 300; lowerBound = 0; upperBound = 30;}
1362  if (k == 3) {name_Histogram = "ptFirstDaughter"; discription_Histogram = "pt first daughter; #it{p}_{T} (GeV/#it{c}); Entries"; numberOfBins = 300; lowerBound = 0; upperBound = 30;}
1363  if (k == 4) {name_Histogram = "ptSecondDaughter"; discription_Histogram = "pt second daughter; #it{p}_{T} (GeV/#it{c}); Entries"; numberOfBins = 300; lowerBound = 0; upperBound = 30;}
1364  if (k == 5) {name_Histogram = "ptThirdDaughter"; discription_Histogram = "pt third daughter; #it{p}_{T} (GeV/#it{c}); Entries"; numberOfBins = 300; lowerBound = 0; upperBound = 30;}
1365  if (k == 6) {name_Histogram = "d0Mother"; discription_Histogram = "d0 mother; (cm); Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 1.0;}
1366  if (k == 7) {name_Histogram = "d0FirstDaughter"; discription_Histogram = "d0 first daughter; (cm); Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 1;}
1367  if (k == 8) {name_Histogram = "d0SecondDaughter"; discription_Histogram = "d0 second daughter; (cm); Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 1;}
1368  if (k == 9) {name_Histogram = "d0ThirdDaughter"; discription_Histogram = "d0 third daughter; (cm); Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 1;}
1369  if (k == 10) {name_Histogram = "pointingAngleMother"; discription_Histogram = "pointing angle; (Cos(#theta)); Entries"; numberOfBins = 100; lowerBound = -1; upperBound = 1;}
1370  if (k == 11) {name_Histogram = "pointingAngleMotherXY"; discription_Histogram = "pointing angle XY; (Cos(#theta)); Entries"; numberOfBins = 1000; lowerBound = -1; upperBound = 1;}
1371  if (k == 12) {name_Histogram = "impactProduct123"; discription_Histogram = "impact product123; (cm^{3}); Entries"; numberOfBins = 500; lowerBound = -0.001; upperBound = 0.001;}
1372  if (k == 13) {name_Histogram = "impactProduct12"; discription_Histogram = "impact product12; (cm^{2}); Entries"; numberOfBins = 500; lowerBound = -0.01; upperBound = 0.01;}
1373  if (k == 14) {name_Histogram = "impactProduct13"; discription_Histogram = "impact product13; (cm^{2}); Entries"; numberOfBins = 500; lowerBound = -0.01; upperBound = 0.01;}
1374  if (k == 15) {name_Histogram = "impactProduct23"; discription_Histogram = "impact product23; (cm^{2}); Entries"; numberOfBins = 500; lowerBound = -0.01; upperBound = 0.01;}
1375  if (k == 16) {name_Histogram = "impactProductXY"; discription_Histogram = "impact product XY; (cm^{3}); Entries"; numberOfBins = 200; lowerBound = 0; upperBound = 0.5;}
1376  if (k == 17) {name_Histogram = "dcaMother12"; discription_Histogram = "dca mother12; distance (cm); Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 0.25;}
1377  if (k == 18) {name_Histogram = "dcaMother13"; discription_Histogram = "dca mother13; distance (cm); Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 0.25;}
1378  if (k == 19) {name_Histogram = "dcaMother23"; discription_Histogram = "dca mother23; distance (cm); Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 0.25;}
1379  if (k == 20) {name_Histogram = "vertexDistance"; discription_Histogram = "vertex distance between mother and primary vertex; distance (cm); Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 1;}
1380  if (k == 21) {name_Histogram = "vertexDistanceXY"; discription_Histogram = "vertex distance between mother and primary vertex XY; distance (cm); Entries"; numberOfBins = 1000; lowerBound = 0; upperBound = 10;}
1381  if (k == 22) {name_Histogram = "normDecayLength"; discription_Histogram = "Normalized decay length w.r.t primary vertex; (cm); Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 50;}
1382  if (k == 23) {name_Histogram = "normDecayLengthXY"; discription_Histogram = "Normalized decay length w.r.t primary vertex XY; (cm); Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 50;}
1383  if (k == 24) {name_Histogram = "pseudoProperDecayTime"; discription_Histogram = "Pseudo Proper Decay Time w.r.t primary vertex; [a.u.]; Entries"; numberOfBins = 1000; lowerBound = -10; upperBound = 10;}
1384  if (k == 25) {name_Histogram = "DecayTime"; discription_Histogram = "Decay Time w.r.t primary vertex; [a.u.]; Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 0.00000001;}
1385  if (k == 26) {name_Histogram = "normDecayTime"; discription_Histogram = "Normalized Decay Time w.r.t primary vertex; [a.u.]; Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 0.0000001;}
1386  if (k == 27) {name_Histogram = "smallestAngleMotherDaughter"; discription_Histogram = "smallest flight angle mother and daughter; (Cos(#phi)); Entries"; numberOfBins = 100; lowerBound = -1; upperBound = 1;}
1387  if (k == 28) {name_Histogram = "largestAngleMotherDaughter"; discription_Histogram = "largest flight angle mother and daughter; (Cos(#phi)); Entries"; numberOfBins = 100; lowerBound = -1; upperBound = 1;}
1388  if (k == 29) {name_Histogram = "AngleDifference"; discription_Histogram = "Angle Difference (largest - smallest); (Cos(#phi)); Entries"; numberOfBins = 100; lowerBound = -2.0; upperBound = 2;}
1389  if (k == 30) {name_Histogram = "Normd0FirstDaughter"; discription_Histogram = "norm d0 first daughter; (cm); Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 100;}
1390  if (k == 31) {name_Histogram = "Normd0SecondDaughter"; discription_Histogram = "norm d0 second daughter; (cm); Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 100;}
1391  if (k == 32) {name_Histogram = "Normd0ThirdDaughter"; discription_Histogram = "norm d0 third daughter; (cm); Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 100;}
1392  if (k == 33) {name_Histogram = "Normd0Mother"; discription_Histogram = "norm d0 mother; (cm); Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 500;}
1393  if (k == 34) {name_Histogram = "NormimpactProduct"; discription_Histogram = "norm impact product; (cm^{3}); Entries"; numberOfBins = 500; lowerBound = -200; upperBound = 200;}
1394  if (k == 35) {name_Histogram = "dist12"; discription_Histogram = "dist12; (cm); Entries"; numberOfBins = 500; lowerBound = -3; upperBound = 3;}
1395  if (k == 36) {name_Histogram = "dist23"; discription_Histogram = "dist23; (cm); Entries"; numberOfBins = 500; lowerBound = -3; upperBound = 3;}
1396  if (k == 37) {name_Histogram = "sigmavertex"; discription_Histogram = "sigmavertex; []; Entries"; numberOfBins = 500; lowerBound = -200; upperBound = 200;}
1397 
1398  if (k == 38) {name_Histogram = "pointingAngleToB0"; discription_Histogram = "Pointing angle w.r.t. B0 decay vertex; (Cos(#theta)); Entries"; numberOfBins = 200; lowerBound = -1; upperBound = 1;}
1399  if (k == 39) {name_Histogram = "d0MotherToB0"; discription_Histogram = "d0 Mother w.r.t. B0 decay vertex; (cm); Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 1;}
1400  if (k == 40) {name_Histogram = "d0FirstDaughterToB0"; discription_Histogram = "d0 first daughter w.r.t. B0 decay vertex; (cm); Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 1;}
1401  if (k == 41) {name_Histogram = "d0SecondDaughterToB0"; discription_Histogram = "d0 second daughter w.r.t. B0 decay vertex; (cm); Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 1;}
1402  if (k == 42) {name_Histogram = "d0ThirdDaughterToB0"; discription_Histogram = "d0 third daughter w.r.t. B0 decay vertex; (cm); Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 1;}
1403  if (k == 43) {name_Histogram = "impactProductToB0"; discription_Histogram = "impact product w.r.t. B0 decay vertex; (cm^{3}); Entries"; numberOfBins = 400; lowerBound = -0.005; upperBound = 0.005;}
1404  if (k == 44) {name_Histogram = "impactProductXYToB0"; discription_Histogram = "impact product XY w.r.t. B0 decay vertex; (cm^{2}); Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 0.5;}
1405  if (k == 45) {name_Histogram = "normDecayLengthToB0"; discription_Histogram = "Normalized decay length w.r.t. B0 decay vertex; (cm); Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 50;}
1406  if (k == 46) {name_Histogram = "pseudoProperDecayTimeToB0"; discription_Histogram = "Pseudo Proper Decay Time w.r.t B0 vertex; [a.u.]; Entries"; numberOfBins = 1000; lowerBound = -1; upperBound = 1;}
1407  if (k == 47) {name_Histogram = "DecayTimeToB0"; discription_Histogram = "Decay Time w.r.t B0 vertex; [a.u.]; Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 0.00000001;}
1408  if (k == 48) {name_Histogram = "normDecayTimeToB0"; discription_Histogram = "Normalized Decay Time w.r.t B0 vertex; [a.u.]; Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 0.00000001;}
1409 
1410  name_Histogram += add_name;
1411  TH1F* histogram = new TH1F(name_Histogram.Data(), discription_Histogram.Data(), numberOfBins, lowerBound, upperBound);
1412  histogram->Sumw2();
1413  if (j % 2 == 0) histogram->SetLineColor(6);
1414  if (j % 2 == 1) histogram->SetLineColor(4);
1415  histogram->SetMarkerStyle(20);
1416  histogram->SetMarkerSize(0.6);
1417  if (j % 2 == 0) histogram->SetMarkerColor(6);
1418  if (j % 2 == 1) histogram->SetMarkerColor(4);
1419  TH1F* histogram_Clone = (TH1F*)histogram->Clone();
1420  listCandidates->Add(histogram_Clone);
1421  fMotherHistogramArray[i][j][k] = histogram_Clone;
1422  }
1423  }
1424 
1425  if (i == 1)
1426  {
1427  for (Int_t k = 0; k < 28; ++k)
1428  {
1429  if (k == 0) {name_Histogram = "invariantMassMother"; discription_Histogram = "mass mother candidate; m (GeV/#it{c}^{2}); Entries"; numberOfBins = 10000; lowerBound = 0; upperBound = 10;}
1430  if (k == 1) {name_Histogram = "deltaMassMother"; discription_Histogram = "mass mother candidate; m (GeV/#it{c}^{2}); Entries"; numberOfBins = 10000; lowerBound = 0; upperBound = 10;}
1431  if (k == 2) {name_Histogram = "ptMother"; discription_Histogram = "pt mother; #it{p}_{T} (GeV/#it{c}); Entries"; numberOfBins = 300; lowerBound = 0; upperBound = 30;}
1432  if (k == 3) {name_Histogram = "ptFirstDaughter"; discription_Histogram = "pt first daughter; #it{p}_{T} (GeV/#it{c}); Entries"; numberOfBins = 300; lowerBound = 0; upperBound = 30;}
1433  if (k == 4) {name_Histogram = "ptSecondDaughter"; discription_Histogram = "pt second daughter; #it{p}_{T} (GeV/#it{c}); Entries"; numberOfBins = 300; lowerBound = 0; upperBound = 30;}
1434  if (k == 5) {name_Histogram = "d0Mother"; discription_Histogram = "d0 mother; (cm); Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 1.0;}
1435  if (k == 6) {name_Histogram = "d0FirstDaughter"; discription_Histogram = "d0 first daughter; (cm); Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 1;}
1436  if (k == 7) {name_Histogram = "d0SecondDaughter"; discription_Histogram = "d0 second daughter; (cm); Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 1;}
1437  if (k == 8) {name_Histogram = "pointingAngleMother"; discription_Histogram = "pointing angle; (Cos(#theta)); Entries"; numberOfBins = 100; lowerBound = -1; upperBound = 1;}
1438  if (k == 9) {name_Histogram = "pointingAngleMotherXY"; discription_Histogram = "pointing angle XY; (Cos(#theta)); Entries"; numberOfBins = 1000; lowerBound = -1; upperBound = 1;}
1439  if (k == 10) {name_Histogram = "impactProduct"; discription_Histogram = "impact product; (cm^{2}); Entries"; numberOfBins = 500; lowerBound = -0.01; upperBound = 0.01;}
1440  if (k == 11) {name_Histogram = "impactProductXY"; discription_Histogram = "impact product XY; (cm^{2}); Entries"; numberOfBins = 200; lowerBound = 0; upperBound = 0.5;}
1441  if (k == 12) {name_Histogram = "dcaMother"; discription_Histogram = "dca mother; distance (cm); Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 0.25;}
1442  if (k == 13) {name_Histogram = "vertexDistance"; discription_Histogram = "vertex distance between mother and primary vertex; distance (cm); Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 1;}
1443  if (k == 14) {name_Histogram = "vertexDistanceXY"; discription_Histogram = "vertex distance between mother and primary vertex XY; distance (cm); Entries"; numberOfBins = 1000; lowerBound = 0; upperBound = 10;}
1444  if (k == 15) {name_Histogram = "normDecayLength"; discription_Histogram = "Normalized decay length w.r.t primary vertex; (cm); Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 50;}
1445  if (k == 16) {name_Histogram = "normDecayLengthXY"; discription_Histogram = "Normalized decay length w.r.t primary vertex XY; (cm); Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 50;}
1446  if (k == 17) {name_Histogram = "pseudoProperDecayTime"; discription_Histogram = "Pseudo Proper Decay Time w.r.t primary vertex; [a.u.]; Entries"; numberOfBins = 1000; lowerBound = -10; upperBound = 10;}
1447  if (k == 18) {name_Histogram = "DecayTime"; discription_Histogram = "Decay Time w.r.t primary vertex; [a.u.]; Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 0.00000001;}
1448  if (k == 19) {name_Histogram = "normDecayTime"; discription_Histogram = "Normalized Decay Time w.r.t primary vertex; [a.u.]; Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 0.0000001;}
1449  if (k == 20) {name_Histogram = "angleMotherFirstDaughter"; discription_Histogram = "flight angle mother and first daughter; [Cos(#phi)]; Entries"; numberOfBins = 100; lowerBound = -1; upperBound = 1;}
1450  if (k == 21) {name_Histogram = "angleMotherSecondDaughter"; discription_Histogram = "flight angle mother and second daughter; [Cos(#phi)]; Entries"; numberOfBins = 100; lowerBound = 0.5; upperBound = 1;}
1451  if (k == 22) {name_Histogram = "angleBetweenBothDaughters"; discription_Histogram = "angle between both daughters; [Cos(#phi)]; Entries"; numberOfBins = 100; lowerBound = -1; upperBound = 1;}
1452  if (k == 23) {name_Histogram = "cosThetaStar"; discription_Histogram = "cosThetaStar; [Cos(#theta*)]; Entries"; numberOfBins = 200; lowerBound = -2; upperBound = 2;}
1453  if (k == 24) {name_Histogram = "Normd0FirstDaughter"; discription_Histogram = "norm d0 first daughter; (cm); Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 100;}
1454  if (k == 25) {name_Histogram = "Normd0SecondDaughter"; discription_Histogram = "norm d0 second daughter; (cm); Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 100;}
1455  if (k == 26) {name_Histogram = "Normd0Mother"; discription_Histogram = "norm d0 mother; (cm); Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 500;}
1456  if (k == 27) {name_Histogram = "NormimpactProduct"; discription_Histogram = "norm impact product; (cm^{2}); Entries"; numberOfBins = 500; lowerBound = -200; upperBound = 200;}
1457 
1458 
1459  name_Histogram += add_name;
1460  TH1F* histogram = new TH1F(name_Histogram.Data(), discription_Histogram.Data(), numberOfBins, lowerBound, upperBound);
1461  histogram->Sumw2();
1462  if (j % 2 == 0) histogram->SetLineColor(6);
1463  if (j % 2 == 1) histogram->SetLineColor(4);
1464  histogram->SetMarkerStyle(20);
1465  histogram->SetMarkerSize(0.6);
1466  if (j % 2 == 0) histogram->SetMarkerColor(6);
1467  if (j % 2 == 1) histogram->SetMarkerColor(4);
1468  TH1F* histogram_Clone = (TH1F*)histogram->Clone();
1469  listCandidates->Add(histogram_Clone);
1470  fMotherHistogramArray[i][j][k] = histogram_Clone;
1471  }
1472  }
1473 
1474  TList * listOther = new TList();
1475  listOther->SetOwner();
1476  listOther->SetName("OtherHistograms");
1477  listCandidates->Add(listOther);
1478  for (Int_t k = 49; k < 56; ++k)
1479  {
1480 
1481  if (k == 49) {name_Histogram = "yMother"; discription_Histogram = "eta mother; #eta; Entries"; numberOfBins = 100; lowerBound = -10; upperBound = 10;}
1482  if (k == 50) {name_Histogram = "etaMother"; discription_Histogram = "eta mother; #eta; Entries"; numberOfBins = 100; lowerBound = -2; upperBound = 2;}
1483  if (k == 51) {name_Histogram = "phiMother"; discription_Histogram = "phi mother; #phi; Entries"; numberOfBins = 25; lowerBound = 0; upperBound = 2 * TMath::Pi();}
1484  if (k == 52) {name_Histogram = "vertexX"; discription_Histogram = "Vertex position; (cm); Entries"; numberOfBins = 500; lowerBound = -5; upperBound = 5;}
1485  if (k == 53) {name_Histogram = "vertexY"; discription_Histogram = "Vertex position; (cm); Entries"; numberOfBins = 500; lowerBound = -5; upperBound = 5;}
1486  if (k == 54) {name_Histogram = "vertexZ"; discription_Histogram = "Vertex position; (cm); Entries"; numberOfBins = 500; lowerBound = -20; upperBound = 20;}
1487  if (k == 55) {name_Histogram = "vertexChi2NDF"; discription_Histogram = "#Chi^{2} per NDF Vertex; [#Chi^{2}/NDF]; Entries"; numberOfBins = 1000; lowerBound = 0; upperBound = 50;}
1488 
1489  name_Histogram += add_name;
1490  TH1F* histogram = new TH1F(name_Histogram.Data(), discription_Histogram.Data(), numberOfBins, lowerBound, upperBound);
1491  histogram->Sumw2();
1492  if (j % 2 == 0) histogram->SetLineColor(6);
1493  if (j % 2 == 1) histogram->SetLineColor(4);
1494  histogram->SetMarkerStyle(20);
1495  histogram->SetMarkerSize(0.6);
1496  if (j % 2 == 0) histogram->SetMarkerColor(6);
1497  if (j % 2 == 1) histogram->SetMarkerColor(4);
1498  TH1F* histogram_Clone = (TH1F*)histogram->Clone();
1499  listOther->Add(histogram_Clone);
1500  fMotherHistogramArray[i][j][k] = histogram_Clone;
1501  }
1502 
1503  // optional code for 2D histograms, to be updated for this decay
1504  // name_Histogram = "";
1505  // discription_Histogram = "";
1506  // numberOfBins = 0;
1507  // lowerBound = 0.0;
1508  // upperBound = 0.0;
1509  // numberOfBinsTwo = 0;
1510  // lowerBoundTwo = 0.0;
1511  // upperBoundTwo = 0.0;
1512 
1513  // //we make the 2D histograms for the reconstructed particles
1514  // Int_t nFirst = 0;
1515  // Int_t nSecond = 1;
1516  // Int_t nVariables = 10;
1517  // Int_t nHistograms = nVariables * (nVariables - 1) / 2;
1518 
1519  // TList * list2D = new TList();
1520  // list2D->SetOwner();
1521  // TString name2D = "2D_Histograms";
1522  // name2D += add_name;
1523  // list2D->SetName(name2D);
1524  // listCandidates->Add(list2D);
1525 
1526  // for (Int_t k = 0; k < nHistograms; ++k)
1527  // {
1528  // numberOfBins = 50; numberOfBinsTwo = 50;
1529  // if (nFirst == 0) {name_Histogram = "dPlusFirstDaughter"; discription_Histogram = "dPlus first daughter (cm);"; lowerBound = 0; upperBound = 1;}
1530  // if (nFirst == 1) {name_Histogram = "dPlusSecondDaughter"; discription_Histogram = "dPlus second daughter (cm);"; lowerBound = 0; upperBound = 1;}
1531  // if (nFirst == 2) {name_Histogram = "d0Mother"; discription_Histogram = "dPlus mother (cm);"; lowerBound = 0; upperBound = 1;}
1532  // if (nFirst == 3) {name_Histogram = "pointingAngleMother"; discription_Histogram = "pointing angle (Cos(#theta));"; lowerBound = -1; upperBound = 1;}
1533  // if (nFirst == 4) {name_Histogram = "impactProduct"; discription_Histogram = "impact product (cm^{2});"; lowerBound = -0.01; upperBound = 0.01;}
1534  // if (nFirst == 5) {name_Histogram = "impactProductXY"; discription_Histogram = "impact product XY (cm^{2});"; lowerBound = 0; upperBound = 0.5;}
1535  // if (nFirst == 6) {name_Histogram = "vertexDistance"; discription_Histogram = "vertex distance between mother and primary vertex (cm);"; lowerBound = 0; upperBound = 1;}
1536  // if (nFirst == 7) {name_Histogram = "normDecayLength"; discription_Histogram = "Normalized decay length w.r.t primary vertex (cm);"; lowerBound = 0; upperBound = 50;}
1537  // if (nFirst == 8) {name_Histogram = "pointingAngleMotherXY"; discription_Histogram = "pointing angle XY (Cos(#theta));"; lowerBound = -1; upperBound = 1;}
1538  // if (nFirst == 9) {name_Histogram = "vertexDistanceXY"; discription_Histogram = "vertex distance between mother and primary vertex XY (cm);"; lowerBound = 0; upperBound = 1;}
1539  // if (nFirst == 10) {name_Histogram = "normDecayLengthXY"; discription_Histogram = "Normalized decay length w.r.t primary vertex XY (cm);"; lowerBound = 0; upperBound = 50;}
1540 
1541  // if (nSecond == 0) {name_Histogram += "dPlusFirstDaughter"; discription_Histogram += "dPlus first daughter (cm);"; lowerBoundTwo = 0; upperBoundTwo = 1;}
1542  // if (nSecond == 1) {name_Histogram += "dPlusSecondDaughter"; discription_Histogram += "dPlus second daughter (cm);"; lowerBoundTwo = 0; upperBoundTwo = 1;}
1543  // if (nSecond == 2) {name_Histogram += "d0Mother"; discription_Histogram += "dPlus mother (cm);"; lowerBoundTwo = 0; upperBoundTwo = 1;}
1544  // if (nSecond == 3) {name_Histogram += "pointingAngleMother"; discription_Histogram += "pointing angle (Cos(#theta));"; lowerBoundTwo = -1; upperBoundTwo = 1;}
1545  // if (nSecond == 4) {name_Histogram += "impactProduct"; discription_Histogram += "impact product (cm^{2});"; lowerBoundTwo = -0.01; upperBoundTwo = 0.01;}
1546  // if (nSecond == 5) {name_Histogram += "impactProductXY"; discription_Histogram += "impact product XY (cm^{2});"; lowerBoundTwo = 0; upperBoundTwo = 0.5;}
1547  // if (nSecond == 6) {name_Histogram += "vertexDistance"; discription_Histogram += "vertex distance between mother and primary vertex (cm);"; lowerBoundTwo = 0; upperBoundTwo = 1;}
1548  // if (nSecond == 7) {name_Histogram += "normDecayLength"; discription_Histogram += "Normalized decay length w.r.t primary vertex (cm);"; lowerBoundTwo = 0; upperBoundTwo = 50;}
1549  // if (nSecond == 8) {name_Histogram += "_pointingAngleMotherXY"; discription_Histogram += "pointing angle XY (Cos(#theta));"; lowerBoundTwo = -1; upperBoundTwo = 1;}
1550  // if (nSecond == 9) {name_Histogram += "_vertexDistanceXY"; discription_Histogram += "vertex distance between mother and primary vertex XY (cm);"; lowerBoundTwo = 0; upperBoundTwo = 1;}
1551  // if (nSecond == 10) {name_Histogram += "_normDecayLengthXY"; discription_Histogram += "Normalized decay length w.r.t primary vertex XY (cm);"; lowerBoundTwo = 0; upperBoundTwo = 50;}
1552 
1553  // name_Histogram += add_name;
1554  // TH2F* histogram = new TH2F(name_Histogram.Data(), discription_Histogram.Data(), numberOfBins, lowerBound, upperBound, numberOfBinsTwo, lowerBoundTwo, upperBoundTwo);
1555  // histogram->Sumw2();
1556  // if (j % 2 == 0) histogram->SetLineColor(6);
1557  // if (j % 2 == 1) histogram->SetLineColor(4);
1558  // histogram->SetMarkerStyle(20);
1559  // histogram->SetMarkerSize(0.6);
1560  // histogram->SetMarkerColor(6);
1561  // TH2F* histogram_Clone = (TH2F*)histogram->Clone();
1562  // list2D->Add(histogram_Clone);
1563  // fMotherHistogramArray2D[i][j][k] = histogram_Clone;
1564 
1565  // nSecond++;
1566  // if (nSecond > nVariables)
1567  // {
1568  // nFirst++;
1569  // nSecond = nFirst + 1;
1570  // }
1571  // }
1572  }
1573 
1574  TH1F * effectOfCuts = new TH1F("effectOfCuts", "Removal counter", 100, 0, 100);
1575  effectOfCuts->SetStats(kTRUE);
1576  effectOfCuts->GetXaxis()->SetTitle("Cut number");
1577  effectOfCuts->GetYaxis()->SetTitle("Particles cut");
1578  effectOfCuts->GetXaxis()->SetBinLabel(1, "total");
1579  for (Int_t i = 1; i < 100; ++i)
1580  {
1581  TString integerText = "";
1582  integerText += i;
1583  effectOfCuts->GetXaxis()->SetBinLabel(i + 1, integerText);
1584  }
1585  listout->Add(effectOfCuts);
1586  fMotherHistogramArrayExtra[i][0] = effectOfCuts;
1587 
1588  TH1F * effectOfCutsSignal = new TH1F("effectOfCutsSignal", "Removal counter", 100, 0, 100);
1589  effectOfCutsSignal->SetStats(kTRUE);
1590  effectOfCutsSignal->GetXaxis()->SetTitle("Cut number");
1591  effectOfCutsSignal->GetYaxis()->SetTitle("Particles cut");
1592  effectOfCutsSignal->GetXaxis()->SetBinLabel(1, "total");
1593  for (Int_t i = 1; i < 100; ++i)
1594  {
1595  TString integerText = "";
1596  integerText += i;
1597  effectOfCutsSignal->GetXaxis()->SetBinLabel(i + 1, integerText);
1598  }
1599  listout->Add(effectOfCutsSignal);
1600  fMotherHistogramArrayExtra[i][1] = effectOfCutsSignal;
1601 
1602  TString name_particle_pdg = "particle_pdg";
1603  TH1F* hist_particle_pdg = new TH1F(name_particle_pdg.Data(), "Pdg code particle; pdg code; Entries", 2000, -0.5, 1999.5);
1604  hist_particle_pdg->Sumw2();
1605  hist_particle_pdg->SetLineColor(6);
1606  hist_particle_pdg->SetMarkerStyle(20);
1607  hist_particle_pdg->SetMarkerSize(0.6);
1608  hist_particle_pdg->SetMarkerColor(6);
1609  TH1F* histogram_particle_pdg = (TH1F*)hist_particle_pdg->Clone();
1610  listout->Add(histogram_particle_pdg);
1611  fMotherHistogramArrayExtra[i][2] = histogram_particle_pdg;
1612 
1613  TString name_particle_mother_pdg = "particle_mother_pdg";
1614  TH1F* hist_particle_mother_pdg = new TH1F(name_particle_mother_pdg.Data(), "Pdg code particle mother; pdg code; Entries", 2000, -0.5, 1999.5);
1615  hist_particle_mother_pdg->Sumw2();
1616  hist_particle_mother_pdg->SetLineColor(6);
1617  hist_particle_mother_pdg->SetMarkerStyle(20);
1618  hist_particle_mother_pdg->SetMarkerSize(0.6);
1619  hist_particle_mother_pdg->SetMarkerColor(6);
1620  TH1F* histogram_particle_mother_pdg = (TH1F*)hist_particle_mother_pdg->Clone();
1621  listout->Add(histogram_particle_mother_pdg);
1622  fMotherHistogramArrayExtra[i][3] = histogram_particle_mother_pdg;
1623 
1624  TString name_distance_vertex_from_real = "distance_vertex_from_real";
1625  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);
1626  hist_distance_vertex_from_real->Sumw2();
1627  hist_distance_vertex_from_real->SetLineColor(6);
1628  hist_distance_vertex_from_real->SetMarkerStyle(20);
1629  hist_distance_vertex_from_real->SetMarkerSize(0.6);
1630  hist_distance_vertex_from_real->SetMarkerColor(6);
1631  TH1F* histogram_distance_vertex_from_real = (TH1F*)hist_distance_vertex_from_real->Clone();
1632  listout->Add(histogram_distance_vertex_from_real);
1633  fMotherHistogramArrayExtra[i][4] = histogram_distance_vertex_from_real;
1634 
1635  TString name_distance_vertex_from_real_new = "distance_vertex_from_real_new";
1636  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);
1637  hist_distance_vertex_from_real_new->Sumw2();
1638  hist_distance_vertex_from_real_new->SetLineColor(6);
1639  hist_distance_vertex_from_real_new->SetMarkerStyle(20);
1640  hist_distance_vertex_from_real_new->SetMarkerSize(0.6);
1641  hist_distance_vertex_from_real_new->SetMarkerColor(6);
1642  TH1F* histogram_distance_vertex_from_real_new = (TH1F*)hist_distance_vertex_from_real_new->Clone();
1643  listout->Add(histogram_distance_vertex_from_real_new);
1644  fMotherHistogramArrayExtra[i][5] = histogram_distance_vertex_from_real_new;
1645 
1646  TString name_momentum_resolution = "momentum_resolution";
1647  TH1F* hist_momentum_resolution = new TH1F(name_momentum_resolution.Data(), "Momentum resolution; difference between real and reconstructed momentum (GeV/#it{c}); Entries", 1000, 0, 1);
1648  hist_momentum_resolution->Sumw2();
1649  hist_momentum_resolution->SetLineColor(6);
1650  hist_momentum_resolution->SetMarkerStyle(20);
1651  hist_momentum_resolution->SetMarkerSize(0.6);
1652  hist_momentum_resolution->SetMarkerColor(6);
1653  TH1F* histogram_momentum_resolution = (TH1F*)hist_momentum_resolution->Clone();
1654  listout->Add(histogram_momentum_resolution);
1655  fMotherHistogramArrayExtra[i][6] = histogram_momentum_resolution;
1656  }
1657 
1658 
1659 
1660  //we make the histograms for the same sign method histograms and the pt bins
1661  for (Int_t i = 0; i < 7; ++i) {
1662  TString typeListName = "";
1663  if (i == 0) typeListName = "MassPlots";
1664  if (i == 1) typeListName = "MassPlots_SameSign";
1665  if (i == 2) typeListName = "MassPlots_SignSum";
1666  if (i == 3) typeListName = "MassPlots_Background_rotation";
1667  if (i == 4) typeListName = "MassPlots_HIJING_Background";
1668  if (i == 5) typeListName = "MassPlots_HIJING_Signal";
1669  if (i == 6) typeListName = "MassPlots_HIJING_Background_rotation";
1670 
1671  TList * listMassPlots = new TList();
1672  listMassPlots->SetOwner();
1673  listMassPlots->SetName(typeListName);
1674  fOutputB0Results->Add(listMassPlots);
1675 
1676  for (Int_t k = 0; k < fnPtBins + 3; ++k) {
1677  TString ptBinMother = "";
1678  if (k == 0) ptBinMother = "";
1679  if (k == 1) ptBinMother = "_ptbin_3_to_inf";
1680  if (k == 2) ptBinMother = "_ptbin_6_to_inf";
1681  if (k > 2) {ptBinMother += "_ptbin_"; ptBinMother += fPtBinLimits[k - 3]; ptBinMother += "_to_"; ptBinMother += fPtBinLimits[k - 2];}
1682 
1683  TString name_invariantMassMother = "invariantMassB0";
1684  name_invariantMassMother += ptBinMother;
1685  TH1F* hist_invariantMassMother = new TH1F(name_invariantMassMother.Data(), "mass mother candidate; m [GeV/c^2]; Entries", 2000, 0, 20);
1686  hist_invariantMassMother->Sumw2();
1687  hist_invariantMassMother->SetLineColor(6);
1688  hist_invariantMassMother->SetMarkerStyle(20);
1689  hist_invariantMassMother->SetMarkerSize(0.6);
1690  hist_invariantMassMother->SetMarkerColor(6);
1691  TH1F* histogram_invariantMassMother = (TH1F*)hist_invariantMassMother->Clone();
1692  listMassPlots->Add(histogram_invariantMassMother);
1693  fResultsHistogramArray[4 + i][k] = histogram_invariantMassMother;
1694  }
1695  for (Int_t k = 0; k < fnPtBins + 3; ++k) {
1696  TString ptBinMother = "";
1697  if (k == 0) ptBinMother = "";
1698  if (k == 1) ptBinMother = "_ptbin_3_to_inf";
1699  if (k == 2) ptBinMother = "_ptbin_6_to_inf";
1700  if (k > 2) {ptBinMother += "_ptbin_"; ptBinMother += fPtBinLimits[k - 3]; ptBinMother += "_to_"; ptBinMother += fPtBinLimits[k - 2];}
1701 
1702  TString name_deltainvariantMassMother = "deltainvariantMassB0";
1703  name_deltainvariantMassMother += ptBinMother;
1704  TH1F* hist_deltainvariantMassMother = new TH1F(name_deltainvariantMassMother.Data(), "delta mass mother candidate; m [GeV/c^2]; Entries", 2000, 0, 20);
1705  hist_deltainvariantMassMother->Sumw2();
1706  hist_deltainvariantMassMother->SetLineColor(6);
1707  hist_deltainvariantMassMother->SetMarkerStyle(20);
1708  hist_deltainvariantMassMother->SetMarkerSize(0.6);
1709  hist_deltainvariantMassMother->SetMarkerColor(6);
1710  TH1F* histogram_deltainvariantMassMother = (TH1F*)hist_deltainvariantMassMother->Clone();
1711  listMassPlots->Add(histogram_deltainvariantMassMother);
1712  fResultsHistogramArray[4 + i][k + fnPtBins + 3] = histogram_deltainvariantMassMother;
1713  }
1714  }
1715 
1716 
1717  TString name_cutEffectBackground = "cutEffectBackground";
1718  TH2F* hist_cutEffectBackground = new TH2F(name_cutEffectBackground.Data(), "Effect of Cuts on background; cut number; cut number", 99, 0, 99, 99, 0, 99);
1719  for (int i = 0; i < 99; ++i)
1720  {
1721  TString integerText = "";
1722  integerText += i;
1723  hist_cutEffectBackground->GetXaxis()->SetBinLabel(i + 1, integerText);
1724  hist_cutEffectBackground->GetYaxis()->SetBinLabel(i + 1, integerText);
1725  }
1726  TH2F* histogram_cutEffectBackground = (TH2F*)hist_cutEffectBackground->Clone();
1727  fOutputB0Results->Add(histogram_cutEffectBackground);
1728  fResultsHistogramArray2D[2][0] = histogram_cutEffectBackground;
1729 
1730 
1731  TString name_cutEffectSignal = "cutEffectSignal";
1732  TH2F* hist_cutEffectSignal = new TH2F(name_cutEffectSignal.Data(), "Effect of Cuts on Signal; cut number; cut number", 99, 0, 99, 99, 0, 99);
1733  for (Int_t i = 0; i < 99; ++i)
1734  {
1735  TString integerText = "";
1736  integerText += i;
1737  hist_cutEffectSignal->GetXaxis()->SetBinLabel(i + 1, integerText);
1738  hist_cutEffectSignal->GetYaxis()->SetBinLabel(i + 1, integerText);
1739  }
1740  TH2F* histogram_cutEffectSignal = (TH2F*)hist_cutEffectSignal->Clone();
1741  fOutputB0Results->Add(histogram_cutEffectSignal);
1742  fResultsHistogramArray2D[2][1] = histogram_cutEffectSignal;
1743 
1744  TString name_cutEffectUniqueBackground = "cutEffectUniqueBackground";
1745  TH1F* hist_cutEffectUniqueBackground = new TH1F(name_cutEffectUniqueBackground.Data(), "Effect of Cuts on Signal; cut number; cut number", 99, 0, 99);
1746  for (Int_t i = 0; i < 99; ++i)
1747  {
1748  TString integerText = "";
1749  integerText += i;
1750  hist_cutEffectUniqueBackground->GetXaxis()->SetBinLabel(i + 1, integerText);
1751  }
1752  TH1F* histogram_cutEffectUniqueBackground = (TH1F*)hist_cutEffectUniqueBackground->Clone();
1753  fOutputB0Results->Add(histogram_cutEffectUniqueBackground);
1754  fResultsHistogramArray[13][0] = histogram_cutEffectUniqueBackground;
1755 
1756  TString name_cutEffectUniqueSignal = "cutEffectUniqueSignal";
1757  TH1F* hist_cutEffectUniqueSignal = new TH1F(name_cutEffectUniqueSignal.Data(), "Effect of Cuts on Signal; cut number; cut number", 99, 0, 99);
1758  for (Int_t i = 0; i < 99; ++i)
1759  {
1760  TString integerText = "";
1761  integerText += i;
1762  hist_cutEffectUniqueSignal->GetXaxis()->SetBinLabel(i + 1, integerText);
1763  }
1764  TH1F* histogram_cutEffectUniqueSignal = (TH1F*)hist_cutEffectUniqueSignal->Clone();
1765  fOutputB0Results->Add(histogram_cutEffectUniqueSignal);
1766  fResultsHistogramArray[13][1] = histogram_cutEffectUniqueSignal;
1767 
1768  TString name_totalITSBackground = "totalITSBackground";
1769  TH1F* hist_totalITSBackground = new TH1F(name_totalITSBackground.Data(), "Total nr. of ITS hits for the daughters; number [#]; Entries", 30, 0, 30);
1770  hist_totalITSBackground->Sumw2();
1771  hist_totalITSBackground->SetLineColor(6);
1772  hist_totalITSBackground->SetMarkerStyle(20);
1773  hist_totalITSBackground->SetMarkerSize(0.6);
1774  hist_totalITSBackground->SetMarkerColor(6);
1775  TH1F* histogram_totalITSBackground = (TH1F*)hist_totalITSBackground->Clone();
1776  fOutputB0Results->Add(histogram_totalITSBackground);
1777  fResultsHistogramArray[11][0] = histogram_totalITSBackground;
1778 
1779  TString name_totalITSSignal = "totalITSSignal";
1780  TH1F* hist_totalITSSignal = new TH1F(name_totalITSSignal.Data(), "Total nr. of ITS hits for the daughters; number [#]; Entries", 30, 0, 30);
1781  hist_totalITSSignal->Sumw2();
1782  hist_totalITSSignal->SetLineColor(6);
1783  hist_totalITSSignal->SetMarkerStyle(20);
1784  hist_totalITSSignal->SetMarkerSize(0.6);
1785  hist_totalITSSignal->SetMarkerColor(6);
1786  TH1F* histogram_totalITSSignal = (TH1F*)hist_totalITSSignal->Clone();
1787  fOutputB0Results->Add(histogram_totalITSSignal);
1788  fResultsHistogramArray[11][1] = histogram_totalITSSignal;
1789 
1790  TString name_totalTPCBackground = "totalTPCBackground";
1791  TH1F* hist_totalTPCBackground = new TH1F(name_totalTPCBackground.Data(), "Total nr. of TPC hits for the daughters; number [#]; Entries", 1000, 0, 1000);
1792  hist_totalTPCBackground->Sumw2();
1793  hist_totalTPCBackground->SetLineColor(6);
1794  hist_totalTPCBackground->SetMarkerStyle(20);
1795  hist_totalTPCBackground->SetMarkerSize(0.6);
1796  hist_totalTPCBackground->SetMarkerColor(6);
1797  TH1F* histogram_totalTPCBackground = (TH1F*)hist_totalTPCBackground->Clone();
1798  fOutputB0Results->Add(histogram_totalTPCBackground);
1799  fResultsHistogramArray[11][2] = histogram_totalTPCBackground;
1800 
1801  TString name_totalTPCSignal = "totalTPCSignal";
1802  TH1F* hist_totalTPCSignal = new TH1F(name_totalTPCSignal.Data(), "Total nr. of TPC hits for the daughters; number [#]; Entries", 1000, 0, 1000);
1803  hist_totalTPCSignal->Sumw2();
1804  hist_totalTPCSignal->SetLineColor(6);
1805  hist_totalTPCSignal->SetMarkerStyle(20);
1806  hist_totalTPCSignal->SetMarkerSize(0.6);
1807  hist_totalTPCSignal->SetMarkerColor(6);
1808  TH1F* histogram_totalTPCSignal = (TH1F*)hist_totalTPCSignal->Clone();
1809  fOutputB0Results->Add(histogram_totalTPCSignal);
1810  fResultsHistogramArray[11][3] = histogram_totalTPCSignal;
1811 
1812  TString name_totalSigmaPIDBackground = "totalSigmaPIDBackground";
1813  TH1F* hist_totalSigmaPIDBackground = new TH1F(name_totalSigmaPIDBackground.Data(), "Total sigma of TPC and TOF PID for the daughters; number [#]; Entries", 1000, 0, 100);
1814  hist_totalSigmaPIDBackground->Sumw2();
1815  hist_totalSigmaPIDBackground->SetLineColor(6);
1816  hist_totalSigmaPIDBackground->SetMarkerStyle(20);
1817  hist_totalSigmaPIDBackground->SetMarkerSize(0.6);
1818  hist_totalSigmaPIDBackground->SetMarkerColor(6);
1819  TH1F* histogram_totalSigmaPIDBackground = (TH1F*)hist_totalSigmaPIDBackground->Clone();
1820  fOutputB0Results->Add(histogram_totalSigmaPIDBackground);
1821  fResultsHistogramArray[11][4] = histogram_totalSigmaPIDBackground;
1822 
1823  TString name_totalSigmaPIDSignal = "totalSigmaPIDSignal";
1824  TH1F* hist_totalSigmaPIDSignal = new TH1F(name_totalSigmaPIDSignal.Data(), "Total sigma of TPC and TOF PID for the daughters; number [#]; Entries", 1000, 0, 100);
1825  hist_totalSigmaPIDSignal->Sumw2();
1826  hist_totalSigmaPIDSignal->SetLineColor(6);
1827  hist_totalSigmaPIDSignal->SetMarkerStyle(20);
1828  hist_totalSigmaPIDSignal->SetMarkerSize(0.6);
1829  hist_totalSigmaPIDSignal->SetMarkerColor(6);
1830  TH1F* histogram_totalSigmaPIDSignal = (TH1F*)hist_totalSigmaPIDSignal->Clone();
1831  fOutputB0Results->Add(histogram_totalSigmaPIDSignal);
1832  fResultsHistogramArray[11][5] = histogram_totalSigmaPIDSignal;
1833 
1834  // Optional code to check invariant mass of daughter combinations, to be added for this decay
1835  // for (int i = 0; i < 3; ++i)
1836  // {
1837  // TString name_Histogram;
1838  // TString discription_Histogram;
1839  // if (i == 0) {name_Histogram = "invmassDPlusPionB0Pion"; discription_Histogram = "Invariant mass DPlus Pion and B0 Pion; inv. mass (GeV/#it{c}^{2}); Entries";}
1840  // if (i == 1) {name_Histogram = "invmassDPlusKaonB0Pion"; discription_Histogram = "Invariant mass DPlus Kaon and B0 Pion; inv. mass (GeV/#it{c}^{2}); Entries";}
1841  // if (i == 2) {name_Histogram = "invmassDPlusPionDPlusKaonB0Pion"; discription_Histogram = "Invariant mass DPlus Pion, DPlus Kaon, and B0 Pion; inv. mass (GeV/#it{c}^{2}); Entries";}
1842 
1843  // for (int j = 0; j < 2; ++j)
1844  // {
1845  // TString add_name = "";
1846  // if (j == 1) add_name = "_Signal";
1847  // name_Histogram += add_name;
1848  // TH1F* histogram = new TH1F(name_Histogram.Data(), discription_Histogram.Data(), 1000, 0, 30);
1849  // histogram->Sumw2();
1850  // if (j % 2 == 0) histogram->SetLineColor(6);
1851  // if (j % 2 == 1) histogram->SetLineColor(4);
1852  // histogram->SetMarkerStyle(20);
1853  // histogram->SetMarkerSize(0.6);
1854  // if (j % 2 == 0) histogram->SetMarkerColor(6);
1855  // if (j % 2 == 1) histogram->SetMarkerColor(4);
1856  // TH1F* histogram_Clone = (TH1F*)histogram->Clone();
1857  // fOutputB0Results->Add(histogram_Clone);
1858  // fResultsHistogramArray[12][2*i + j] = histogram_Clone;
1859  // }
1860  // }
1861 
1862  return;
1863 }
1864 //-------------------------------------------------------------------------------------
1865 AliAODVertex* AliAnalysisTaskSEB0toDPi::RecalculateVertex(const AliVVertex *primary, TObjArray *tracks, Double_t bField, Double_t dispersion, Bool_t optUseFitter, Bool_t optPropagate, Bool_t optUseDiamondConstraint, Int_t nprongs) {
1866  //
1867  // Helper function to recalculate a vertex.
1868  //
1869 
1870  AliESDVertex *vertexESD = 0;
1871  AliAODVertex *vertexAOD = 0;
1872 
1873  AliVertexerTracks vertexer;
1874  vertexer.SetFieldkG(bField);
1875 
1876  vertexer.SetVtxStart((AliESDVertex*)primary); //primary vertex
1877  vertexESD = (AliESDVertex*)vertexer.VertexForSelectedESDTracks(tracks, optUseFitter, optPropagate, optUseDiamondConstraint);
1878 
1879  // delete vertexer; vertexer=NULL;
1880 
1881  if (!vertexESD) return vertexAOD;
1882 
1883 
1884  if (vertexESD->GetNContributors() != tracks->GetEntriesFast())
1885  {
1886  delete vertexESD; vertexESD = nullptr;
1887  return vertexAOD;
1888  }
1889 
1890  // convert to AliAODVertex
1891  Double_t pos[3], cov[6], chi2perNDF;
1892  for (Int_t a = 0; a < 3; a++)pos[a] = 0.;
1893  for (Int_t b = 0; b < 6; b++)cov[b] = 0.;
1894  chi2perNDF = 0;
1895 
1896  vertexESD->GetXYZ(pos); // position
1897  vertexESD->GetCovMatrix(cov); //covariance matrix
1898 
1899 
1900  Double_t vertRadius2 = pos[0] * pos[0] + pos[1] * pos[1];
1901  if (vertRadius2 > 8.) //(2.82)^2 radius beam pipe
1902  {
1903  delete vertexESD; vertexESD = nullptr;
1904  return vertexAOD;
1905  }
1906 
1907  chi2perNDF = vertexESD->GetChi2toNDF();
1908  dispersion = vertexESD->GetDispersion();
1909  delete vertexESD; vertexESD = nullptr;
1910  // Int_t nprongs = 2; //tracks->GetEntriesFast();
1911  vertexAOD = new AliAODVertex(pos, cov, chi2perNDF, 0x0, -1, AliAODVertex::kUndef, nprongs);
1912 
1913  return vertexAOD;
1914 }
1915 //-------------------------------------------------------------------------------------
1916 void AliAnalysisTaskSEB0toDPi::B0toDPiSignalTracksInMC(TClonesArray * mcTrackArray, AliAODEvent* /*aodevent*/, TMatrix * B0toDPiLabelMatrix, TList *listout) {
1917 
1918  TMatrix &particleMatrix = *B0toDPiLabelMatrix;
1919  for (Int_t i = 0; i < mcTrackArray->GetEntriesFast(); i++) {
1920 
1921  Int_t mcLabelKaonDPlus = 0;
1922  Int_t mcLabelFirstPionDPlus = 0;
1923  Int_t mcLabelSecondPionDPlus = 0;
1924  Int_t mcLabelPionB0 = 0;
1925  Int_t mcLabelDPlus = 0;
1926  Int_t mcLabelB0 = 0;
1927 
1928  Double_t ptMC[6] = {0.0};
1929  Double_t yMC[6] = {0.0};
1930  Double_t pseudoYMC[6] = {0.0};
1931 
1932  Bool_t mckaonDPlusPresent = kFALSE;
1933  Bool_t mcFirstPionDPlusPresent = kFALSE;
1934  Bool_t mcSecondPionDPlusPresent = kFALSE;
1935  Bool_t mcPionB0Present = kFALSE;
1936 
1937  AliAODMCParticle *mcTrackParticle = dynamic_cast< AliAODMCParticle*>(mcTrackArray->At(i));
1938  if (!mcTrackParticle) {std::cout << "no particle" << std::endl; continue;}
1939  Int_t pdgCodeMC = TMath::Abs(mcTrackParticle->GetPdgCode());
1940 
1941  if (pdgCodeMC == 511)
1942  { //if the track is a B0 we look at its daughters
1943 
1944  mcLabelB0 = i;
1945  Int_t nDaughterB0 = mcTrackParticle->GetNDaughters();
1946  ptMC[0] = mcTrackParticle->Pt();
1947  yMC[0] = mcTrackParticle->Y();
1948  pseudoYMC[0] = mcTrackParticle->Eta();
1949 
1950  // "B0_in_analysis";
1951  ((TH1F*)fResultsHistogramArray[3][0])->Fill(0);
1952 
1953  if (nDaughterB0 == 2)
1954  {
1955  ((TH1F*)fResultsHistogramArray[3][0])->Fill(3);
1956  for (Int_t iDaughterB0 = 0; iDaughterB0 < 2; iDaughterB0++)
1957  {
1958  AliAODMCParticle* daughterB0 = (AliAODMCParticle*)mcTrackArray->At(mcTrackParticle->GetDaughterLabel(0) + iDaughterB0);
1959  if (!daughterB0) { break;}
1960  Int_t pdgCodeDaughterB0 = TMath::Abs(daughterB0->GetPdgCode());
1961  ((TH1F*)fResultsHistogramArray[3][0])->Fill(4);
1962  if (pdgCodeDaughterB0 == 211) //if the track is a pion we save its monte carlo label
1963  {
1964  ((TH1F*)fResultsHistogramArray[3][0])->Fill(5);
1965  mcLabelPionB0 = mcTrackParticle->GetDaughterLabel(0) + iDaughterB0;
1966  mcPionB0Present = kTRUE;
1967  ptMC[1] = daughterB0->Pt();
1968  yMC[1] = daughterB0->Y();
1969  pseudoYMC[1] = daughterB0->Eta();
1970 
1971  } else if (pdgCodeDaughterB0 == 411) //if the track is a DPlus we look at its daughters
1972  {
1973  ((TH1F*)fResultsHistogramArray[3][0])->Fill(7);
1974  mcLabelDPlus = mcTrackParticle->GetDaughterLabel(0) + iDaughterB0;
1975  Int_t nDaughterDPlus = daughterB0->GetNDaughters();
1976  ptMC[2] = daughterB0->Pt();
1977  yMC[2] = daughterB0->Y();
1978  pseudoYMC[2] = daughterB0->Eta();
1979 
1980  if (nDaughterDPlus == 3)
1981  {
1982  Int_t numberOfDPlusPions = 0;
1983  ((TH1F*)fResultsHistogramArray[3][0])->Fill(8);
1984  for (Int_t iDaughterDPlus = 0; iDaughterDPlus < 3; iDaughterDPlus++)
1985  {
1986  AliAODMCParticle* daughterDPlus = (AliAODMCParticle*)mcTrackArray->At(daughterB0->GetDaughterLabel(0) + iDaughterDPlus);
1987  if (!daughterDPlus) break;
1988  Int_t pdgCodeDaughterDPlus = TMath::Abs(daughterDPlus->GetPdgCode());
1989 
1990  if (pdgCodeDaughterDPlus == 211) //if the track is a pion we save its monte carlo label
1991  {
1992  numberOfDPlusPions++;
1993  if (numberOfDPlusPions == 1)
1994  {
1995  ((TH1F*)fResultsHistogramArray[3][0])->Fill(9);
1996  mcLabelFirstPionDPlus = daughterB0->GetDaughterLabel(0) + iDaughterDPlus;
1997  ptMC[3] = daughterDPlus->Pt();
1998  yMC[3] = daughterDPlus->Y();
1999  pseudoYMC[3] = daughterDPlus->Eta();
2000  mcFirstPionDPlusPresent = kTRUE;
2001  }
2002  if (numberOfDPlusPions == 2)
2003  {
2004  ((TH1F*)fResultsHistogramArray[3][0])->Fill(10);
2005  mcLabelSecondPionDPlus = daughterB0->GetDaughterLabel(0) + iDaughterDPlus;
2006  ptMC[4] = daughterDPlus->Pt();
2007  yMC[4] = daughterDPlus->Y();
2008  pseudoYMC[4] = daughterDPlus->Eta();
2009  mcSecondPionDPlusPresent = kTRUE;
2010  }
2011  } else if (pdgCodeDaughterDPlus == 321) //if the track is a kaon we save its monte carlo label
2012  {
2013  ((TH1F*)fResultsHistogramArray[3][0])->Fill(11);
2014  mcLabelKaonDPlus = daughterB0->GetDaughterLabel(0) + iDaughterDPlus;
2015  mckaonDPlusPresent = kTRUE;
2016  ptMC[5] = daughterDPlus->Pt();
2017  yMC[5] = daughterDPlus->Y();
2018  pseudoYMC[5] = daughterDPlus->Eta();
2019  } else break;
2020  }
2021  }
2022  } else break;
2023  }
2024  }
2025  }
2026  if (mckaonDPlusPresent && mcFirstPionDPlusPresent && mcSecondPionDPlusPresent && mcPionB0Present) {
2027 
2028  // "B0_in_analysis";
2029  ((TH1F*)fResultsHistogramArray[3][0])->Fill(1);
2030 
2031 
2032  for (Int_t j = 0; j < fnPtBins; ++j)
2033  {
2034  // "B0_per_bin";
2035  if (fPtBinLimits[j] < ptMC[0] && ptMC[0] < fPtBinLimits[j + 1]) {((TH1F*)fResultsHistogramArray[3][1])->Fill(j); break;}
2036  }
2037 
2038  ((TH1F*)fResultsHistogramArray[0][0])->Fill(ptMC[0]);
2039  ((TH1F*)fResultsHistogramArray[0][1])->Fill(ptMC[1]);
2040  ((TH1F*)fResultsHistogramArray[0][2])->Fill(ptMC[2]);
2041  ((TH1F*)fResultsHistogramArray[0][3])->Fill(ptMC[3]);
2042  ((TH1F*)fResultsHistogramArray[0][4])->Fill(ptMC[4]);
2043  ((TH1F*)fResultsHistogramArray[0][5])->Fill(ptMC[5]);
2044 
2045  ((TH1F*)fResultsHistogramArray[0][7])->Fill(yMC[0]);
2046  ((TH1F*)fResultsHistogramArray[0][8])->Fill(yMC[1]);
2047  ((TH1F*)fResultsHistogramArray[0][9])->Fill(yMC[2]);
2048  ((TH1F*)fResultsHistogramArray[0][10])->Fill(yMC[3]);
2049  ((TH1F*)fResultsHistogramArray[0][11])->Fill(yMC[4]);
2050  ((TH1F*)fResultsHistogramArray[0][12])->Fill(yMC[5]);
2051 
2052  ((TH1F*)fResultsHistogramArray[0][14])->Fill(pseudoYMC[0]);
2053  ((TH1F*)fResultsHistogramArray[0][15])->Fill(pseudoYMC[1]);
2054  ((TH1F*)fResultsHistogramArray[0][16])->Fill(pseudoYMC[2]);
2055  ((TH1F*)fResultsHistogramArray[0][17])->Fill(pseudoYMC[3]);
2056  ((TH1F*)fResultsHistogramArray[0][18])->Fill(pseudoYMC[4]);
2057  ((TH1F*)fResultsHistogramArray[0][19])->Fill(pseudoYMC[5]);
2058 
2059  // We check if the tracks are in acceptance
2060  if (ptMC[1] < 0.1 || TMath::Abs(pseudoYMC[1]) > 0.9 ) continue;
2061  if (ptMC[3] < 0.1 || TMath::Abs(pseudoYMC[3]) > 0.9 ) continue;
2062  if (ptMC[4] < 0.1 || TMath::Abs(pseudoYMC[4]) > 0.9 ) continue;
2063  if (ptMC[5] < 0.1 || TMath::Abs(pseudoYMC[5]) > 0.9 ) continue;
2064 
2065 
2066  // We check if the B0 is in the fiducial region
2067  if (TMath::Abs(yMC[0]) > 0.8) continue;
2068 
2069  Int_t rows = B0toDPiLabelMatrix->GetNrows();
2070 
2071  B0toDPiLabelMatrix->ResizeTo(rows + 1, 6);
2072  particleMatrix(rows, 0) = mcLabelKaonDPlus;
2073  particleMatrix(rows, 1) = mcLabelFirstPionDPlus;
2074  particleMatrix(rows, 2) = mcLabelSecondPionDPlus;
2075  particleMatrix(rows, 3) = mcLabelPionB0;
2076  particleMatrix(rows, 4) = mcLabelDPlus;
2077  particleMatrix(rows, 5) = mcLabelB0;
2078 
2079  // "B0_in_analysis";
2080  ((TH1F*)fResultsHistogramArray[3][0])->Fill(2);
2081 
2082  for (Int_t j = 0; j < fnPtBins; ++j)
2083  {
2084  // "B0_per_bin_in_Acc";
2085  if (fPtBinLimits[j] < ptMC[0] && ptMC[0] < fPtBinLimits[j + 1]) {((TH1F*)fResultsHistogramArray[3][2])->Fill(j); break;}
2086  }
2087  }
2088  }
2089 
2090 
2091  return;
2092 }
2093 //-------------------------------------------------------------------------------------
2094 void AliAnalysisTaskSEB0toDPi::DaughterSelection(AliAODEvent* aodEvent, AliAODVertex *primaryVertex, Double_t bz, TClonesArray * mcTrackArray, TMatrix * B0toDPiLabelMatrix, AliAODMCHeader * header, Int_t daughterType, std::vector<Int_t> * trackVector) {
2095 
2096  //we keep track of the number of particles we could use and how many we actually use after cuts
2097  Int_t numberofparticles = 0;
2098  Int_t numberofparticlesused = 0;
2099 
2100  Int_t particleType = 2;
2101  if (daughterType == 0) particleType = 3;
2102 
2103  //we loop over all tracks in the event
2104  for (Int_t i = 0; i < aodEvent->GetNumberOfTracks(); i++) {
2105  AliAODTrack* aodTrack = dynamic_cast<AliAODTrack*>(aodEvent->GetTrack(i));
2106  if (!aodTrack) AliFatal("Not a standard AOD");
2107 
2108  //quick quality cut
2109  if (aodTrack->GetITSNcls() < 1) continue;
2110  if (aodTrack->GetTPCNcls() < 1) continue;
2111  if (aodTrack->GetStatus()&AliESDtrack::kITSpureSA) continue;
2112  if (!(aodTrack->GetStatus()&AliESDtrack::kITSin)) continue;
2113  if (aodTrack->GetID() < 0) continue;
2114  Double_t covtest[21];
2115  if (!aodTrack->GetCovarianceXYZPxPyPz(covtest)) continue;
2116 
2117  Double_t pos[3], cov[6];
2118  primaryVertex->GetXYZ(pos);
2119  primaryVertex->GetCovarianceMatrix(cov);
2120  const AliESDVertex vESD(pos, cov, 100., 100);
2121  if (!fCuts->IsDaughterSelected(aodTrack, &vESD, fCuts->GetTrackCuts(), aodEvent)) continue;
2122 
2123  Int_t mcLabelParticle = -1;
2124  mcLabelParticle = aodTrack->GetLabel();
2125 
2126  numberofparticles++;
2127 
2128  //we check if the particle is a signal track
2129  Bool_t isDesiredCandidate = kFALSE;
2130  Int_t labelPosition1 = 0;
2131  Int_t labelPosition2 = 0;
2132  if (daughterType == 1) { labelPosition1 = 1; labelPosition2 = 2;}
2133  if (daughterType == 2) { labelPosition1 = 3;}
2134  if (fUseMCInfo) {
2135  TMatrix &particleMatrix = *B0toDPiLabelMatrix;
2136  for (Int_t k = 0; k < B0toDPiLabelMatrix->GetNrows(); ++k) {
2137  if (mcLabelParticle == (Int_t)particleMatrix(k, labelPosition1)) {
2138  isDesiredCandidate = kTRUE;
2139  break;
2140  }
2141  if (labelPosition2 > 0)
2142  {
2143  if (mcLabelParticle == (Int_t)particleMatrix(k, labelPosition2)) {
2144  isDesiredCandidate = kTRUE;
2145  break;
2146  }
2147  }
2148  }
2149  }
2150 
2151  if (fUseMCInfo) {
2152  if (IsTrackInjected(aodTrack, header, mcTrackArray) && !isDesiredCandidate && fQuickSignalAnalysis == 2) continue;
2153  }
2154 
2155  Int_t histType = 0;
2156  FillDaughterHistograms(aodTrack, daughterType, histType, 0.0, primaryVertex, bz, isDesiredCandidate, mcTrackArray);
2157 
2158  AliExternalTrackParam particleTrack;
2159  particleTrack.CopyFromVTrack(aodTrack);
2160  Double_t d0[2], covd0[3];
2161  particleTrack.PropagateToDCA(primaryVertex, bz, 100., d0, covd0);
2162 
2163  //we apply a number of cuts on the particle
2164  Bool_t bCut = kFALSE;
2165 
2166  //we apply cut from the cutfile
2167  if (!(fCuts->SelectPID(aodTrack, particleType))) {
2168  if (isDesiredCandidate) {
2169  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][1])->Fill(2);
2170  } else ((TH1F*)fDaughterHistogramArrayExtra[daughterType][0])->Fill(2);
2171  bCut = kTRUE;
2172  }
2173 
2174  if (aodTrack->GetITSNcls() < fCuts->GetMinITSNclsDaughterType(daughterType)) {
2175  if (isDesiredCandidate) {
2176  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][1])->Fill(3);
2177  } else ((TH1F*)fDaughterHistogramArrayExtra[daughterType][0])->Fill(3);
2178  bCut = kTRUE;
2179  }
2180 
2181  if (aodTrack->GetTPCNcls() < fCuts->GetMinTPCNclsDaughterType(daughterType)) {
2182  if (isDesiredCandidate) {
2183  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][1])->Fill(4);
2184  } else ((TH1F*)fDaughterHistogramArrayExtra[daughterType][0])->Fill(4);
2185  bCut = kTRUE;
2186  }
2187 
2188  if (fCuts->UseITSRefitDaughterType(daughterType) == kTRUE) {
2189  if (!(aodTrack->GetStatus()&AliESDtrack::kITSrefit)) {
2190  if (isDesiredCandidate) {
2191  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][1])->Fill(5);
2192  } else ((TH1F*)fDaughterHistogramArrayExtra[daughterType][0])->Fill(5);
2193  bCut = kTRUE;
2194  }
2195  }
2196 
2197  if (fCuts->UseTPCRefitDaughterType(daughterType) == kTRUE) {
2198  if ((!(aodTrack->GetStatus()&AliESDtrack::kTPCrefit))) {
2199  if (isDesiredCandidate) {
2200  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][1])->Fill(6);
2201  } else ((TH1F*)fDaughterHistogramArrayExtra[daughterType][0])->Fill(6);
2202  bCut = kTRUE;
2203  }
2204  }
2205 
2206  if (fCuts->UseFilterBitDaughterType(daughterType) == kTRUE) {
2207  if (!(aodTrack->TestFilterMask(BIT(fCuts->GetFilterBitDaughterType(daughterType))))) {
2208  if (isDesiredCandidate) {
2209  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][1])->Fill(7);
2210  } else ((TH1F*)fDaughterHistogramArrayExtra[daughterType][0])->Fill(7);
2211  bCut = kTRUE;
2212  }
2213  }
2214 
2215 
2216  if (aodTrack->Pt() < fCuts->GetMinPtDaughterType(daughterType)) {
2217  if (isDesiredCandidate) {
2218  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][1])->Fill(8);
2219  } else ((TH1F*)fDaughterHistogramArrayExtra[daughterType][0])->Fill(8);
2220  bCut = kTRUE;
2221  }
2222 
2223 
2224  if (TMath::Abs(d0[0]) < fCuts->GetMind0DaughterType(daughterType)) {
2225  if (isDesiredCandidate) {
2226  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][1])->Fill(12);
2227  } else ((TH1F*)fDaughterHistogramArrayExtra[daughterType][0])->Fill(12);
2228  bCut = kTRUE;
2229  }
2230 
2231  if (TMath::Abs(d0[0] / TMath::Sqrt(covd0[0])) < fCuts->GetMinNormd0DaughterType(daughterType)) {
2232  if (isDesiredCandidate) {
2233  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][1])->Fill(13);
2234  } else ((TH1F*)fDaughterHistogramArrayExtra[daughterType][0])->Fill(13);
2235  bCut = kTRUE;
2236  }
2237 
2238  if (TMath::Abs(aodTrack->Eta()) > fCuts->GetMaxAbsEtaDaughterType(daughterType)) {
2239  if (isDesiredCandidate) {
2240  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][1])->Fill(9);
2241  } else ((TH1F*)fDaughterHistogramArrayExtra[daughterType][0])->Fill(9);
2242  bCut = kTRUE;
2243  }
2244 
2245  Bool_t bHardSelectionArrayITS[7] = {kFALSE};
2246  fCuts->GetHardSelectionArrayITSDaughterType(daughterType, bHardSelectionArrayITS);
2247  Bool_t bSoftSelectionArrayITS[7] = {kFALSE};
2248  fCuts->GetSoftSelectionArrayITSDaughterType(daughterType, bSoftSelectionArrayITS);
2249 
2250  Bool_t bHardITSPass = kTRUE;
2251  for (Int_t j = 0; j < 7; ++j)
2252  {
2253  if (bHardSelectionArrayITS[j])
2254  {
2255  if (!aodTrack->HasPointOnITSLayer(j)) bHardITSPass = kFALSE;
2256  }
2257  }
2258 
2259  Int_t nCounterSoftSelection = 0;
2260  Bool_t bSoftITSPass = kTRUE;
2261  for (Int_t j = 0; j < 7; ++j)
2262  {
2263  if (bSoftSelectionArrayITS[j])
2264  {
2265  if (aodTrack->HasPointOnITSLayer(j)) nCounterSoftSelection++;
2266  }
2267  }
2268  if (nCounterSoftSelection < fCuts->GetNSoftITSCutDaughterType(daughterType)) bSoftITSPass = kFALSE;
2269 
2270  if (!bHardITSPass) {
2271  if (isDesiredCandidate) {
2272  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][1])->Fill(10);
2273  } else ((TH1F*)fDaughterHistogramArrayExtra[daughterType][0])->Fill(10);
2274  bCut = kTRUE;
2275  }
2276 
2277  if (!bSoftITSPass) {
2278  if (isDesiredCandidate) {
2279  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][1])->Fill(11);
2280  } else ((TH1F*)fDaughterHistogramArrayExtra[daughterType][0])->Fill(11);
2281  bCut = kTRUE;
2282  }
2283 
2284  if (!isDesiredCandidate && fQuickSignalAnalysis == 1) bCut = kTRUE;
2285 
2286  if (bCut) {
2287  if (isDesiredCandidate) {
2288  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][1])->Fill(0);
2289  } else ((TH1F*)fDaughterHistogramArrayExtra[daughterType][0])->Fill(0);
2290  continue;
2291  }
2292 
2293  //we fill histograms with track information of the tracks that pass the cuts
2294  histType = 2;
2295  FillDaughterHistograms(aodTrack, daughterType, histType, 0.0, primaryVertex, bz, isDesiredCandidate, mcTrackArray);
2296 
2297  trackVector->push_back(i);
2298  numberofparticlesused++;
2299  }
2300 
2301  ((TH1F*)fDaughterHistogramArray[daughterType][0][10])->Fill(numberofparticles);
2302  ((TH1F*)fDaughterHistogramArray[daughterType][1][10])->Fill(numberofparticlesused);
2303  return;
2304 }
2305 //-------------------------------------------------------------------------------------
2306 Bool_t AliAnalysisTaskSEB0toDPi::DPlusDaughterSelection(AliAODTrack* aodTrack, AliAODEvent* aodEvent, AliAODVertex *primaryVertex, Double_t bz, TClonesArray * mcTrackArray, TMatrix * B0toDPiLabelMatrix, AliAODMCHeader * header, Int_t daughterType) {
2307 
2308  Int_t particleType = 2;
2309  if (daughterType == 0) particleType = 3;
2310 
2311  //quick quality cut
2312  if (aodTrack->GetITSNcls() < 1) return kFALSE;
2313  if (aodTrack->GetTPCNcls() < 1) return kFALSE;
2314  if (aodTrack->GetStatus()&AliESDtrack::kITSpureSA) return kFALSE;
2315  if (!(aodTrack->GetStatus()&AliESDtrack::kITSin)) return kFALSE;
2316  if (aodTrack->GetID() < 0) return kFALSE;
2317  Double_t covtest[21];
2318  if (!aodTrack->GetCovarianceXYZPxPyPz(covtest)) return kFALSE;
2319 
2320  Double_t pos[3], cov[6];
2321  primaryVertex->GetXYZ(pos);
2322  primaryVertex->GetCovarianceMatrix(cov);
2323  const AliESDVertex vESD(pos, cov, 100., 100);
2324  if (!fCuts->IsDaughterSelected(aodTrack, &vESD, fCuts->GetTrackCuts(), aodEvent)) return kFALSE;
2325 
2326  Int_t mcLabelParticle = -1;
2327  mcLabelParticle = aodTrack->GetLabel();
2328 
2329  //we check if the particle is a signal track
2330  Bool_t isDesiredCandidate = kFALSE;
2331  Int_t labelPosition1 = 0;
2332  Int_t labelPosition2 = 0;
2333  if (daughterType == 1) { labelPosition1 = 1; labelPosition2 = 2;}
2334  if (daughterType == 2) { labelPosition1 = 3;}
2335  if (fUseMCInfo) {
2336  TMatrix &particleMatrix = *B0toDPiLabelMatrix;
2337  for (Int_t k = 0; k < B0toDPiLabelMatrix->GetNrows(); ++k) {
2338  if (mcLabelParticle == (Int_t)particleMatrix(k, labelPosition1)) {
2339  isDesiredCandidate = kTRUE;
2340  break;
2341  }
2342  if (labelPosition2 > 0)
2343  {
2344  if (mcLabelParticle == (Int_t)particleMatrix(k, labelPosition2)) {
2345  isDesiredCandidate = kTRUE;
2346  break;
2347  }
2348  }
2349  }
2350  }
2351 
2352  if (fUseMCInfo) {
2353  if (IsTrackInjected(aodTrack, header, mcTrackArray) && !isDesiredCandidate && fQuickSignalAnalysis == 2) return kFALSE;
2354  }
2355 
2356  Int_t histType = 0;
2357  FillDaughterHistograms(aodTrack, daughterType, histType, 0.0, primaryVertex, bz, isDesiredCandidate, mcTrackArray);
2358 
2359  AliExternalTrackParam particleTrack;
2360  particleTrack.CopyFromVTrack(aodTrack);
2361  Double_t d0[2], covd0[3];
2362  particleTrack.PropagateToDCA(primaryVertex, bz, 100., d0, covd0);
2363 
2364  //we apply a number of cuts on the particle
2365  Bool_t bCut = kFALSE;
2366 
2367  //we apply cut from the cutfile
2368  if (!(fCuts->SelectPID(aodTrack, particleType))) {
2369  if (isDesiredCandidate) {
2370  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][1])->Fill(2);
2371  } else ((TH1F*)fDaughterHistogramArrayExtra[daughterType][0])->Fill(2);
2372  bCut = kTRUE;
2373  }
2374 
2375  if (aodTrack->GetITSNcls() < fCuts->GetMinITSNclsDaughterType(daughterType)) {
2376  if (isDesiredCandidate) {
2377  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][1])->Fill(3);
2378  } else ((TH1F*)fDaughterHistogramArrayExtra[daughterType][0])->Fill(3);
2379  bCut = kTRUE;
2380  }
2381 
2382  if (aodTrack->GetTPCNcls() < fCuts->GetMinTPCNclsDaughterType(daughterType)) {
2383  if (isDesiredCandidate) {
2384  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][1])->Fill(4);
2385  } else ((TH1F*)fDaughterHistogramArrayExtra[daughterType][0])->Fill(4);
2386  bCut = kTRUE;
2387  }
2388 
2389  if (fCuts->UseITSRefitDaughterType(daughterType) == kTRUE) {
2390  if (!(aodTrack->GetStatus()&AliESDtrack::kITSrefit)) {
2391  if (isDesiredCandidate) {
2392  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][1])->Fill(5);
2393  } else ((TH1F*)fDaughterHistogramArrayExtra[daughterType][0])->Fill(5);
2394  bCut = kTRUE;
2395  }
2396  }
2397 
2398  if (fCuts->UseTPCRefitDaughterType(daughterType) == kTRUE) {
2399  if ((!(aodTrack->GetStatus()&AliESDtrack::kTPCrefit))) {
2400  if (isDesiredCandidate) {
2401  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][1])->Fill(6);
2402  } else ((TH1F*)fDaughterHistogramArrayExtra[daughterType][0])->Fill(6);
2403  bCut = kTRUE;
2404  }
2405  }
2406 
2407  if (fCuts->UseFilterBitDaughterType(daughterType) == kTRUE) {
2408  if (!(aodTrack->TestFilterMask(BIT(fCuts->GetFilterBitDaughterType(daughterType))))) {
2409  if (isDesiredCandidate) {
2410  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][1])->Fill(7);
2411  } else ((TH1F*)fDaughterHistogramArrayExtra[daughterType][0])->Fill(7);
2412  bCut = kTRUE;
2413  }
2414  }
2415 
2416 
2417  if (aodTrack->Pt() < fCuts->GetMinPtDaughterType(daughterType)) {
2418  if (isDesiredCandidate) {
2419  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][1])->Fill(8);
2420  } else ((TH1F*)fDaughterHistogramArrayExtra[daughterType][0])->Fill(8);
2421  bCut = kTRUE;
2422  }
2423 
2424 
2425  if (TMath::Abs(d0[0]) < fCuts->GetMind0DaughterType(daughterType)) {
2426  if (isDesiredCandidate) {
2427  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][1])->Fill(12);
2428  } else ((TH1F*)fDaughterHistogramArrayExtra[daughterType][0])->Fill(12);
2429  bCut = kTRUE;
2430  }
2431 
2432  if (TMath::Abs(d0[0] / TMath::Sqrt(covd0[0])) < fCuts->GetMinNormd0DaughterType(daughterType)) {
2433  if (isDesiredCandidate) {
2434  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][1])->Fill(13);
2435  } else ((TH1F*)fDaughterHistogramArrayExtra[daughterType][0])->Fill(13);
2436  bCut = kTRUE;
2437  }
2438 
2439  if (TMath::Abs(aodTrack->Eta()) > fCuts->GetMaxAbsEtaDaughterType(daughterType)) {
2440  if (isDesiredCandidate) {
2441  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][1])->Fill(9);
2442  } else ((TH1F*)fDaughterHistogramArrayExtra[daughterType][0])->Fill(9);
2443  bCut = kTRUE;
2444  }
2445 
2446  Bool_t bHardSelectionArrayITS[7] = {kFALSE};
2447  fCuts->GetHardSelectionArrayITSDaughterType(daughterType, bHardSelectionArrayITS);
2448  Bool_t bSoftSelectionArrayITS[7] = {kFALSE};
2449  fCuts->GetSoftSelectionArrayITSDaughterType(daughterType, bSoftSelectionArrayITS);
2450 
2451  Bool_t bHardITSPass = kTRUE;
2452  for (Int_t j = 0; j < 7; ++j)
2453  {
2454  if (bHardSelectionArrayITS[j])
2455  {
2456  if (!aodTrack->HasPointOnITSLayer(j)) bHardITSPass = kFALSE;
2457  }
2458  }
2459 
2460  Int_t nCounterSoftSelection = 0;
2461  Bool_t bSoftITSPass = kTRUE;
2462  for (Int_t j = 0; j < 7; ++j)
2463  {
2464  if (bSoftSelectionArrayITS[j])
2465  {
2466  if (aodTrack->HasPointOnITSLayer(j)) nCounterSoftSelection++;
2467  }
2468  }
2469  if (nCounterSoftSelection < fCuts->GetNSoftITSCutDaughterType(daughterType)) bSoftITSPass = kFALSE;
2470 
2471  if (!bHardITSPass) {
2472  if (isDesiredCandidate) {
2473  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][1])->Fill(10);
2474  } else ((TH1F*)fDaughterHistogramArrayExtra[daughterType][0])->Fill(10);
2475  bCut = kTRUE;
2476  }
2477 
2478  if (!bSoftITSPass) {
2479  if (isDesiredCandidate) {
2480  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][1])->Fill(11);
2481  } else ((TH1F*)fDaughterHistogramArrayExtra[daughterType][0])->Fill(11);
2482  bCut = kTRUE;
2483  }
2484 
2485  if (!isDesiredCandidate && fQuickSignalAnalysis == 1) bCut = kTRUE;
2486 
2487  if (bCut) {
2488  if (isDesiredCandidate) {
2489  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][1])->Fill(0);
2490  } else ((TH1F*)fDaughterHistogramArrayExtra[daughterType][0])->Fill(0);
2491  return kFALSE;
2492  }
2493 
2494  //we fill histograms with track information of the tracks that pass the cuts
2495  histType = 2;
2496  FillDaughterHistograms(aodTrack, daughterType, histType, 0.0, primaryVertex, bz, isDesiredCandidate, mcTrackArray);
2497 
2498  // ((TH1F*)fDaughterHistogramArray[daughterType][0][10])->Fill(numberofparticles);
2499  // ((TH1F*)fDaughterHistogramArray[daughterType][1][10])->Fill(numberofparticlesused);
2500  return kTRUE;
2501 }
2502 //-------------------------------------------------------------------------------------
2503 void AliAnalysisTaskSEB0toDPi::DPlusSelection(AliAODEvent* aodEvent, AliAODVertex *primaryVertex, Double_t bz, TClonesArray * mcTrackArray, TMatrix * B0toDPiLabelMatrix, TClonesArray * DPlusTrackArray, AliAODMCHeader * header) {
2504 
2506 
2507  //next we loop over all the DPlus candidates
2508  for (Int_t j = 0; j < DPlusTrackArray->GetEntriesFast(); j++)
2509  {
2510 
2511  //we get the track of the DPlus
2512  AliAODRecoDecayHF3Prong * trackDPlus = (AliAODRecoDecayHF3Prong*)(DPlusTrackArray->At(j));
2513  if (!trackDPlus) {std::cout << "found none" << std::endl; continue;}
2514  if (trackDPlus == nullptr) {std::cout << "found nullptr" << std::endl; continue;}
2515 
2516  if (!(vHF->FillRecoCand(aodEvent, trackDPlus))) //Fill the data members of the candidate only if they are empty.
2517  {
2518  fCEvents->Fill(12); //monitor how often this fails
2519  continue;
2520  }
2521 
2522  AliAODTrack * trackDPlusFirstPion = (AliAODTrack*)(trackDPlus->GetDaughter(0));
2523  AliAODTrack * trackDPlusKaon = (AliAODTrack*)(trackDPlus->GetDaughter(1));
2524  AliAODTrack * trackDPlusSecondPion = (AliAODTrack*)(trackDPlus->GetDaughter(2));
2525  if (!DPlusDaughterSelection(trackDPlusFirstPion, aodEvent, primaryVertex, bz, mcTrackArray, B0toDPiLabelMatrix, header, 1)) continue;
2526  if (!DPlusDaughterSelection(trackDPlusKaon, aodEvent, primaryVertex, bz, mcTrackArray, B0toDPiLabelMatrix, header, 0)) continue;
2527  if (!DPlusDaughterSelection(trackDPlusSecondPion, aodEvent, primaryVertex, bz, mcTrackArray, B0toDPiLabelMatrix, header, 1)) continue;
2528 
2529  //we check if the IDs of the tracks are different
2530  UShort_t idProng0 = trackDPlusKaon->GetID();
2531  UShort_t idProng1 = trackDPlusFirstPion->GetID();
2532  UShort_t idProng2 = trackDPlusSecondPion->GetID();
2533 
2534  if (idProng0 == idProng1 || idProng0 == idProng2 || idProng1 == idProng2) continue;
2535 
2536  //we check if the particles have the correct charge
2537  if (trackDPlusKaon->Charge() == -1 && !(trackDPlusFirstPion->Charge() == 1 && trackDPlusSecondPion->Charge() == 1)) continue;
2538  if (trackDPlusKaon->Charge() == 1 && !(trackDPlusFirstPion->Charge() == -1 && trackDPlusSecondPion->Charge() == -1)) continue;
2539 
2540  AliAODVertex *vertexMother = (AliAODVertex*)trackDPlus->GetSecondaryVtx();
2541 
2542  //we check if the track is a desired candidate
2543  Int_t pdgCodeMother = -1;
2544  Bool_t isDesiredCandidate = kFALSE;
2545  Int_t motherType, histType;
2546  motherType = 0;
2547  Int_t mcLabelDPlus = -1;
2548 
2549  if (fUseMCInfo)
2550  {
2551  mcLabelDPlus = MatchCandidateToMonteCarlo(411, trackDPlus, mcTrackArray, B0toDPiLabelMatrix, kTRUE);
2552 
2553  if (mcLabelDPlus >= 0)
2554  {
2555  isDesiredCandidate = kTRUE;
2556 
2557  Int_t mcLabelFirstTrack = -1;
2558  mcLabelFirstTrack = trackDPlusKaon->GetLabel();
2559 
2560  if (mcLabelFirstTrack >= 0)
2561  {
2562  AliAODMCParticle *mcParticleFirstTrack = (AliAODMCParticle*)mcTrackArray->At(mcLabelFirstTrack);
2563  AliAODMCParticle *mcMotherParticle = (AliAODMCParticle*)mcTrackArray->At(mcLabelDPlus);
2564 
2565  if (mcParticleFirstTrack && mcMotherParticle)
2566  {
2567  pdgCodeMother = mcMotherParticle->GetPdgCode();
2568 
2569  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()));
2570  ((TH1F*)fMotherHistogramArrayExtra[motherType][4])->Fill(vertex_distance);
2571 
2572  // Double_t vertex_distance_new = TMath::Sqrt((vertexMotherNew->GetX() - mcParticleFirstTrack->Xv()) * (vertexMotherNew->GetX() - mcParticleFirstTrack->Xv()) + (vertexMotherNew->GetY() - mcParticleFirstTrack->Yv()) * (vertexMotherNew->GetY() - mcParticleFirstTrack->Yv()) + (vertexMotherNew->GetZ() - mcParticleFirstTrack->Zv()) * (vertexMotherNew->GetZ() - mcParticleFirstTrack->Zv()));
2573  // ((TH1F*)fMotherHistogramArrayExtra[motherType][5])->Fill(vertex_distance_new);
2574 
2575  Double_t momentum_resolution = TMath::Sqrt((trackDPlus->Px() - mcMotherParticle->Px()) * (trackDPlus->Px() - mcMotherParticle->Px()) + (trackDPlus->Py() - mcMotherParticle->Py()) * (trackDPlus->Py() - mcMotherParticle->Py()) + (trackDPlus->Pz() - mcMotherParticle->Pz()) * (trackDPlus->Pz() - mcMotherParticle->Pz()));
2576  ((TH1F*)fMotherHistogramArrayExtra[motherType][6])->Fill(momentum_resolution);
2577  }
2578  }
2579  }
2580  }
2581 
2582  // We fill the histograms
2583  histType = 0;
2584  FillDPlusHistograms(trackDPlus, primaryVertex, bz, motherType, histType);
2585  if (isDesiredCandidate && fUseMCInfo) {
2586  histType = 1;
2587  FillDPlusHistograms(trackDPlus, primaryVertex, bz, motherType, histType, pdgCodeMother);
2588  }
2589 
2590  // Here we apply cuts on the particle
2591  Bool_t cutMother = kFALSE;
2592 
2593  Bool_t bCutArray[39] = {0};
2594  Int_t cutReturnValue = fCuts->IsDPlusforDPlusptbinSelected(trackDPlus, 0, aodEvent, bCutArray);
2595  if (cutReturnValue == -1) cutMother = kTRUE;
2596  if (cutReturnValue == 0) cutMother = kTRUE;
2597  for (Int_t n = 0; n < 39; ++n)
2598  {
2599  if (bCutArray[n] == kTRUE) {
2600  if (isDesiredCandidate) {
2601  ((TH1F*)fMotherHistogramArrayExtra[motherType][1])->Fill(n + 1);
2602  } else ((TH1F*)fMotherHistogramArrayExtra[motherType][0])->Fill(n + 1);
2603  cutMother = kTRUE;
2604  }
2605  }
2606 
2607  if (!fCuts->AreDaughtersSelected(trackDPlus, aodEvent)) cutMother = kTRUE;
2608 
2609  if (!isDesiredCandidate && fQuickSignalAnalysis == 1) cutMother = kTRUE;
2610 
2611  if (cutMother) {
2612  if (isDesiredCandidate) {
2613  ((TH1F*)fMotherHistogramArrayExtra[motherType][1])->Fill(0);
2614  } else ((TH1F*)fMotherHistogramArrayExtra[motherType][0])->Fill(0);
2615  continue;
2616  }
2617 
2618  // We fill the cut histograms
2619  histType = 2;
2620  FillDPlusHistograms(trackDPlus, primaryVertex, bz, motherType, histType);
2621  if (isDesiredCandidate && fUseMCInfo) {
2622  histType = 3;
2623  FillDPlusHistograms(trackDPlus, primaryVertex, bz, motherType, histType, pdgCodeMother);
2624  }
2625 
2626  //we save the location of the DPlus candidate
2627  fDPlusTracks->push_back(j);
2628  }
2629 
2630  delete vHF; vHF = nullptr;
2631  return;
2632 }
2633 //-------------------------------------------------------------------------------------
2634 void AliAnalysisTaskSEB0toDPi::B0Selection(AliAODEvent* aodEvent, AliAODVertex *primaryVertex, Double_t bz, TClonesArray * mcTrackArray, TMatrix * B0toDPiLabelMatrix, TClonesArray * DPlusTrackArray, AliAODMCHeader * header) {
2635 
2636  //we loop over all the DPlus candidates
2637  for (Int_t j = 0; j < (Int_t)fDPlusTracks->size(); j++)
2638  {
2639 
2640  //Save current Object count
2641  Int_t ObjectNumber = TProcessID::GetObjectCount();
2642 
2643  //we get the track of the DPlus
2644  AliAODRecoDecayHF3Prong * trackDPlus = (AliAODRecoDecayHF3Prong*)(DPlusTrackArray->At(fDPlusTracks->at(j)));
2645  if (!trackDPlus) {std::cout << "found none" << std::endl; continue;}
2646  if (trackDPlus == nullptr) {std::cout << "found nullptr" << std::endl; continue;}
2647 
2648  //we loop over all the B0 pion candidates
2649  for (Int_t i = 0; i < (Int_t)fB0PionTracks->size(); i++)
2650  {
2651 
2652  //we get the track of the B0 daughter
2653  AliAODTrack * trackB0Pion = dynamic_cast<AliAODTrack*>(aodEvent->GetTrack(fB0PionTracks->at(i)));
2654  if (!trackB0Pion) continue;
2655 
2656  //we check if the IDs of the tracks are different
2657  AliAODTrack* threeProngdaughter0 = (AliAODTrack*)trackDPlus->GetDaughter(0);
2658  AliAODTrack* threeProngdaughter1 = (AliAODTrack*)trackDPlus->GetDaughter(1);
2659  AliAODTrack* threeProngdaughter2 = (AliAODTrack*)trackDPlus->GetDaughter(2);
2660  UShort_t idProng0 = threeProngdaughter0->GetID();
2661  UShort_t idProng1 = threeProngdaughter1->GetID();
2662  UShort_t idProng2 = threeProngdaughter2->GetID();
2663 
2664  UShort_t idPion1 = trackB0Pion->GetID();
2665 
2666  if (idPion1 == idProng0 || idPion1 == idProng1 || idPion1 == idProng2) continue;
2667 
2668  // UInt_t prongsDPlus[3];
2669  // prongsDPlus[0] = 321;
2670  // prongsDPlus[1] = 211;
2671  // prongsDPlus[2] = 211;
2672 
2673  // //we check if the particles have the correct charge
2674  Bool_t bWrongSign = kFALSE;
2675  if (trackDPlus->Charge() == -1 && trackB0Pion->Charge() == -1) bWrongSign = kTRUE;
2676  if (trackDPlus->Charge() == 1 && trackB0Pion->Charge() == 1) bWrongSign = kTRUE;
2677 
2678  if (trackDPlus->Charge() == 0 || trackB0Pion->Charge() == 0) continue;
2679 
2680  Int_t pdgDPlus = -1; // not relevant for DPlus
2681 
2682  //location B0 pion rotation around PV
2683  for (Int_t iRot = 0; iRot < fNumberOfRotations + 1; ++iRot)
2684  {
2685  //we create a copy of the track that we will rotate
2686  AliAODTrack * trackB0PionRotated = new AliAODTrack(*trackB0Pion);
2687 
2688  //for iRot == 0, we use the original unrotated track. For iRot > 0 we rotate the track and set the label to -1
2689  if (iRot != 0)
2690  {
2691  //should still check if track is already at PV
2692  Double_t dPhiRotated = trackB0PionRotated->Phi() + TMath::Pi() - (TMath::Pi() * fDegreePerRotation * fNumberOfRotations / (180.0 * 2.0)) + (TMath::Pi() * fDegreePerRotation * iRot / 180.0);
2693  trackB0PionRotated->SetPhi(dPhiRotated);
2694  }
2695 
2696  //we use the B0 pion and DPlus track to reconstruct the vertex for the B0
2697  AliExternalTrackParam firstTrack;
2698  firstTrack.CopyFromVTrack(trackDPlus);
2699  AliExternalTrackParam secondTrack;
2700  secondTrack.CopyFromVTrack(trackB0PionRotated);
2701 
2702  UInt_t prongs[2];
2703  prongs[0] = 411;
2704  prongs[1] = 211;
2705 
2706  UShort_t id[2];
2707  id[0] = firstTrack.GetID();
2708  id[1] = secondTrack.GetID();
2709 
2710 
2711  // we calculate the vertex of the mother candidate
2712  TObjArray daughterTracks;
2713  daughterTracks.Add(&firstTrack);
2714  daughterTracks.Add(&secondTrack);
2715 
2716  Double_t dispersion = 0;
2717  AliAODVertex *vertexMother = RecalculateVertex(primaryVertex, &daughterTracks, bz, dispersion, kTRUE, kTRUE, kFALSE, 2);
2718  if (!vertexMother)
2719  {
2720  delete vertexMother; vertexMother = nullptr;
2721  delete trackB0PionRotated; trackB0PionRotated = nullptr;
2722  continue;
2723  }
2724 
2725  //use the new vertex to create the B0 candidate
2726  Double_t xdummy = 0., ydummy = 0., dca;
2727  Double_t d0z0[2], covd0z0[3], d0[3], d0err[3];
2728 
2729  firstTrack.PropagateToDCA(vertexMother, bz, 100., d0z0, covd0z0);
2730  secondTrack.PropagateToDCA(vertexMother, bz, 100., d0z0, covd0z0);
2731 
2732  //we reconstruct the mother decay prong
2733  Double_t px[2], py[2], pz[2];
2734  px[0] = firstTrack.Px();
2735  py[0] = firstTrack.Py();
2736  pz[0] = firstTrack.Pz();
2737  px[1] = secondTrack.Px();
2738  py[1] = secondTrack.Py();
2739  pz[1] = secondTrack.Pz();
2740 
2741  firstTrack.PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
2742  d0[0] = d0z0[0];
2743  d0err[0] = TMath::Sqrt(covd0z0[0]);
2744  secondTrack.PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
2745  d0[1] = d0z0[0];
2746  d0err[1] = TMath::Sqrt(covd0z0[0]);
2747 
2748  dca = firstTrack.GetDCA(&secondTrack, bz, xdummy, ydummy);
2749 
2750  Short_t chargeMother = trackDPlus->Charge() + trackB0PionRotated->Charge();
2751 
2752  AliAODRecoDecayHF2Prong trackB0(vertexMother, px, py, pz, d0, d0err, dca);
2753 
2754  trackB0.SetCharge(chargeMother);
2755 
2756  trackB0.GetSecondaryVtx()->AddDaughter(trackDPlus);
2757  trackB0.GetSecondaryVtx()->AddDaughter(trackB0PionRotated);
2758  trackB0.SetPrimaryVtxRef((AliAODVertex*)aodEvent->GetPrimaryVertex());
2759  trackB0.SetProngIDs(2, id);
2760 
2761  // Fiducial cut
2762  if (TMath::Abs(trackB0.Y(511)) > 0.8) {
2763  delete vertexMother; vertexMother = nullptr;
2764  delete trackB0PionRotated; trackB0PionRotated = nullptr;
2765  continue;
2766  }
2767 
2768  // We check if the signal is injected, optionally we can reject injected signals
2769  Bool_t bIsInjected = kFALSE;
2770  if (fUseMCInfo) {
2771  bIsInjected = IsCandidateInjected(&trackB0, header, mcTrackArray);
2772  if (fRemoveInjected && bIsInjected) {
2773  delete vertexMother; vertexMother = nullptr;
2774  delete trackB0PionRotated; trackB0PionRotated = nullptr;
2775  continue;
2776  }
2777  }
2778 
2779  // We check if the B0 candidate is a true signal in Monte Carlo
2780  Bool_t isDesiredCandidate = kFALSE;
2781  Int_t mcLabelB0 = -1;
2782 
2783  Int_t motherType, histType;
2784  motherType = 1;
2785 
2786  if (fUseMCInfo)
2787  {
2788  mcLabelB0 = MatchCandidateToMonteCarlo(511, &trackB0, mcTrackArray, B0toDPiLabelMatrix);
2789  if (mcLabelB0 >= 0 && trackB0PionRotated->GetLabel() >= 0 && iRot == 0)
2790  {
2791  isDesiredCandidate = kTRUE;
2792  }
2793  }
2794 
2795  histType = 0;
2796 
2797  if (isDesiredCandidate)
2798  {
2799  AliAODMCParticle *mcTrackB0Pion = (AliAODMCParticle*)mcTrackArray->At(trackB0Pion->GetLabel());
2800  AliAODMCParticle *mcTrackB0 = (AliAODMCParticle*)mcTrackArray->At(mcLabelB0);
2801 
2802  // Double_t vertex_distance = TMath::Sqrt((vertexMotherTemp->GetX() - mcTrackB0Pion->Xv()) * (vertexMotherTemp->GetX() - mcTrackB0Pion->Xv()) + (vertexMotherTemp->GetY() - mcTrackB0Pion->Yv()) * (vertexMotherTemp->GetY() - mcTrackB0Pion->Yv()) + (vertexMotherTemp->GetZ() - mcTrackB0Pion->Zv()) * (vertexMotherTemp->GetZ() - mcTrackB0Pion->Zv()));
2803  // ((TH1F*)fMotherHistogramArrayExtra[motherType][4])->Fill(vertex_distance);
2804 
2805  Double_t vertex_distance_new = TMath::Sqrt((vertexMother->GetX() - mcTrackB0Pion->Xv()) * (vertexMother->GetX() - mcTrackB0Pion->Xv()) + (vertexMother->GetY() - mcTrackB0Pion->Yv()) * (vertexMother->GetY() - mcTrackB0Pion->Yv()) + (vertexMother->GetZ() - mcTrackB0Pion->Zv()) * (vertexMother->GetZ() - mcTrackB0Pion->Zv()));
2806  ((TH1F*)fMotherHistogramArrayExtra[motherType][5])->Fill(vertex_distance_new);
2807 
2808  Double_t momentum_resolution = TMath::Sqrt((trackB0.Px() - mcTrackB0->Px()) * (trackB0.Px() - mcTrackB0->Px()) + (trackB0.Py() - mcTrackB0->Py()) * (trackB0.Py() - mcTrackB0->Py()) + (trackB0.Pz() - mcTrackB0->Pz()) * (trackB0.Pz() - mcTrackB0->Pz()));
2809  ((TH1F*)fMotherHistogramArrayExtra[motherType][6])->Fill(momentum_resolution);
2810  }
2811 
2812  Bool_t bFillUncutHistograms = kTRUE;
2813  if (iRot != 0 && !fSaveTRHists) bFillUncutHistograms = kFALSE;
2814  if (iRot == 0 && fSaveTRHists) bFillUncutHistograms = kFALSE;
2815 
2816  if (!bWrongSign && bFillUncutHistograms)
2817  {
2818  // We fill the histograms
2819  histType = 0;
2820  FillB0Histograms(&trackB0, primaryVertex, bz, motherType, histType);
2821 
2822  if (isDesiredCandidate)
2823  {
2824  histType = 1;
2825  FillB0Histograms(&trackB0, primaryVertex, bz, motherType, histType);
2826  }
2827  }
2828 
2829 
2830  // We apply cuts
2831  Bool_t cutMother = kFALSE;
2832 
2833  Bool_t bCutArray[78] = {0};
2834  Int_t numberOfCuts = 78;
2835  Int_t cutReturnValue = fCuts->IsSelected(&trackB0, 0, aodEvent, bCutArray);
2836  if (cutReturnValue == -1) cutMother = kTRUE;
2837  if (cutReturnValue == 0) cutMother = kTRUE;
2838 
2839 
2840  // We save information about the cuts
2841  TString histName = "";
2842  Double_t invariantMassMother = trackB0.InvMass(2, prongs);
2843  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(511)->Mass();
2844  Double_t massWindow = fHistMassWindow; //GeV/c^2
2845 
2846  for (Int_t n = 0; n < 78; ++n)
2847  {
2848  if (bCutArray[n] == kTRUE) {
2849  if (isDesiredCandidate) {
2850  ((TH1F*)fMotherHistogramArrayExtra[motherType][1])->Fill(n + 1);
2851  } else ((TH1F*)fMotherHistogramArrayExtra[motherType][0])->Fill(n + 1);
2852  cutMother = kTRUE;
2853  }
2854  }
2855 
2856  if (TMath::Abs(invariantMassMother - pdgMassMother) < massWindow) {
2857  for (Int_t l = 0; l < numberOfCuts; ++l) //total
2858  {
2859  if (bCutArray[l] == kFALSE) continue;
2860  for (Int_t m = 0; m < numberOfCuts; ++m)
2861  {
2862  if (bCutArray[m] == kFALSE) continue;
2863  if (isDesiredCandidate == kFALSE) ((TH2F*)(fResultsHistogramArray2D[2][0]))->Fill(l, m);
2864  if (isDesiredCandidate == kTRUE) ((TH2F*)(fResultsHistogramArray2D[2][1]))->Fill(l, m);
2865  }
2866  }
2867 
2868  for (Int_t l = 0; l < numberOfCuts; ++l) //unique
2869  {
2870  if (bCutArray[l] == kFALSE) continue;
2871  Bool_t bFill = kTRUE;
2872  for (Int_t m = 0; m < numberOfCuts; ++m)
2873  {
2874  if (l == m) continue;
2875  if (bCutArray[m] == kTRUE)
2876  {
2877  bFill = kFALSE;
2878  break;
2879  }
2880 
2881  }
2882  if (bFill == kTRUE)
2883  {
2884  if (isDesiredCandidate == kFALSE) ((TH1F*)(fResultsHistogramArray[13][0]))->Fill(l);
2885  if (isDesiredCandidate == kTRUE) ((TH1F*)(fResultsHistogramArray[13][1]))->Fill(l);
2886  }
2887  }
2888  }
2889 
2890 
2891  if (!isDesiredCandidate && fQuickSignalAnalysis == 1) cutMother = kTRUE;
2892 
2893  if (cutMother)
2894  {
2895  if (isDesiredCandidate)
2896  {
2897  ((TH1F*)fMotherHistogramArrayExtra[motherType][1])->Fill(0);
2898  } else ((TH1F*)fMotherHistogramArrayExtra[motherType][0])->Fill(0);
2899  delete vertexMother; vertexMother = nullptr;
2900  delete trackB0PionRotated; trackB0PionRotated = nullptr;
2901  continue;
2902  }
2903 
2904  if (!bWrongSign)
2905  {
2906  histType = 2;
2907  FillB0Histograms(&trackB0, primaryVertex, bz, motherType, histType);
2908  if (fUseMCInfo && isDesiredCandidate)
2909  {
2910  //fill mc histograms
2911  histType = 3;
2912  FillB0Histograms(&trackB0, primaryVertex, bz, motherType, histType);
2913  }
2914  }
2915 
2916  Bool_t bFillhistograms = kFALSE;
2917  Bool_t bPassMassWindow = (TMath::Abs(invariantMassMother - pdgMassMother) < massWindow);
2918  Bool_t bPassSideBand = (TMath::Abs(invariantMassMother - pdgMassMother) > fSideBandLow) && (TMath::Abs(invariantMassMother - pdgMassMother) < fSideBandHigh);
2919  if (isDesiredCandidate && bPassMassWindow) bFillhistograms = kTRUE;
2920  if (!isDesiredCandidate && bPassMassWindow && !fUseSideBands) bFillhistograms = kTRUE;
2921  if (!isDesiredCandidate && bPassSideBand && fUseSideBands) bFillhistograms = kTRUE;
2922  if (iRot != 0 && !fSaveTRHists) bFillhistograms = kFALSE;
2923  if (iRot == 0 && fSaveTRHists) bFillhistograms = kFALSE;
2924 
2925  if (bFillhistograms)
2926  {
2927  if (!bWrongSign)
2928  {
2929  FillFinalTrackHistograms(&trackB0, primaryVertex, bz, isDesiredCandidate, mcTrackArray);
2930  if (!isDesiredCandidate)
2931  {
2932  motherType = 0; histType = 4; FillDPlusHistograms(trackDPlus, primaryVertex, bz, motherType, histType, pdgDPlus);
2933  motherType = 1; histType = 4; FillB0Histograms(&trackB0, primaryVertex, bz, motherType, histType);
2934  }
2935  if (isDesiredCandidate)
2936  {
2937  motherType = 0; histType = 5; FillDPlusHistograms(trackDPlus, primaryVertex, bz, motherType, histType, pdgDPlus);
2938  motherType = 1; histType = 5; FillB0Histograms(&trackB0, primaryVertex, bz, motherType, histType);
2939  }
2940  }
2941  }
2942 
2943 
2944  // Here we fill the histograms per pt bin and apply the same sign method
2945  TString ptBinMother = "";
2946  Int_t ptBin = fCuts->PtBin(trackB0.Pt());
2947  ptBinMother += "_ptbin_"; ptBinMother += fPtBinLimits[ptBin]; ptBinMother += "_to_"; ptBinMother += fPtBinLimits[ptBin + 1];
2948  histType = 6 + 2 * ptBin;
2949 
2950  Int_t dPlusPtBin = fCuts->PtBinDPlusforDPlusptbin(trackDPlus->Pt());
2951  Int_t histTypeDPlus = 2 * dPlusPtBin;
2952 
2953 
2954  if (bFillhistograms)
2955  {
2956  if (!bWrongSign && histType > 5)
2957  {
2958  if (!isDesiredCandidate)
2959  {
2960  motherType = 0; FillDPlusHistograms(trackDPlus, primaryVertex, bz, motherType, histType, pdgDPlus);
2961  motherType = 1; FillB0Histograms(&trackB0, primaryVertex, bz, motherType, histType);
2962  motherType = 2; FillDPlusHistograms(trackDPlus, primaryVertex, bz, motherType, histTypeDPlus, pdgDPlus);
2963  }
2964 
2965  if (isDesiredCandidate)
2966  {
2967  histType += 1;
2968  motherType = 0; FillDPlusHistograms(trackDPlus, primaryVertex, bz, motherType, histType, pdgDPlus);
2969  motherType = 1; FillB0Histograms(&trackB0, primaryVertex, bz, motherType, histType);
2970  motherType = 2; FillDPlusHistograms(trackDPlus, primaryVertex, bz, motherType, histTypeDPlus + 1, pdgDPlus);
2971  }
2972  }
2973  }
2974 
2975  // after the (loose) cut on candidates we can get data for cut optimization
2976  if (!bWrongSign && fPerformCutOptimization)
2977  {
2978  Double_t sigmaWindowForCutOptimization = fCuts->GetSigmaForCutOptimization(ptBin);
2980  Double_t massDifference = TMath::Abs(invariantMassMother - pdgMassMother);
2981 
2982  if (massDifference < nSigmaBins * sigmaWindowForCutOptimization)
2983  {
2984  Int_t nSigmaBin = 0;
2985  if (invariantMassMother < pdgMassMother)
2986  {
2987  for (Int_t iSigma = 0; iSigma < nSigmaBins; ++iSigma)
2988  {
2989  if ((massDifference > iSigma * sigmaWindowForCutOptimization) && (massDifference < (iSigma + 1) * sigmaWindowForCutOptimization)) {nSigmaBin = -(iSigma + 1); break;}
2990  }
2991  }
2992  if (invariantMassMother > pdgMassMother)
2993  {
2994  for (Int_t iSigma = 0; iSigma < nSigmaBins; ++iSigma)
2995  {
2996  if ((massDifference > iSigma * sigmaWindowForCutOptimization) && (massDifference < (iSigma + 1) * sigmaWindowForCutOptimization)) {nSigmaBin = iSigma; break;}
2997  }
2998  }
2999 
3000  Int_t nStartVariable = 0;
3001  Int_t nStartFillNumber = 0;
3003  Int_t nCuts = fCuts->GetnCutsForOptimization();
3004  CutOptimizationVariableValues(&trackB0, aodEvent);
3005  CutOptimizationLoop(nStartVariable, nVariables, nCuts, ptBin, nStartFillNumber, isDesiredCandidate, nSigmaBin);
3006  }
3007  }
3008 
3009  if (isDesiredCandidate) ((TH1F*)fResultsHistogramArray[3][3])->Fill(ptBin);
3010 
3011  Double_t invmassDelta = DeltaInvMassB0Kpipipi(&trackB0);
3012 
3013  // Fill invariant mass histograms
3014  for (Int_t m = 0; m < 7; ++m)
3015  {
3016  Int_t fillfactor = 1;
3017  if (bWrongSign && !(m == 1 || m == 2)) continue;
3018  if (!bWrongSign && m == 1) continue;
3019  if (bWrongSign && m == 2) fillfactor = -1;
3020  if (iRot > 0 && !(m == 3 || m == 6)) continue;
3021  if (iRot == 0 && (m == 3 || m == 6)) continue;
3022  if (m > 3 && bIsInjected) continue;
3023  if (m == 4 && isDesiredCandidate) continue;
3024  if (m == 5 && !isDesiredCandidate) continue;
3025  if (m == 6 && isDesiredCandidate) continue;
3026 
3027  ((TH1F*)fResultsHistogramArray[4 + m][0])->Fill(invariantMassMother, fillfactor);
3028  ((TH1F*)fResultsHistogramArray[4 + m][0 + fnPtBins + 3])->Fill(invmassDelta, fillfactor);
3029 
3030  if (ptBin > 0)
3031  {
3032  ((TH1F*)fResultsHistogramArray[4 + m][1])->Fill(invariantMassMother, fillfactor);
3033  ((TH1F*)fResultsHistogramArray[4 + m][1 + fnPtBins + 3])->Fill(invmassDelta, fillfactor);
3034  }
3035  if (ptBin > 1)
3036  {
3037  ((TH1F*)fResultsHistogramArray[4 + m][2])->Fill(invariantMassMother, fillfactor);
3038  ((TH1F*)fResultsHistogramArray[4 + m][2 + fnPtBins + 3])->Fill(invmassDelta, fillfactor);
3039  }
3040 
3041  ((TH1F*)fResultsHistogramArray[4 + m][ptBin + 3])->Fill(invariantMassMother, fillfactor);
3042  ((TH1F*)fResultsHistogramArray[4 + m][ptBin + 3 + fnPtBins + 3])->Fill(invmassDelta, fillfactor);
3043  }
3044  delete vertexMother; vertexMother = nullptr;
3045  delete trackB0PionRotated; trackB0PionRotated = nullptr;
3046  }
3047  }
3048  //Restore Object count
3049  //To save space in the table keeping track of all referenced objects,
3050  //we reset the object count to what it was at the beginning of the loop.
3051  TProcessID::SetObjectCount(ObjectNumber);
3052  }
3053 
3054  return;
3055 }
3056 //-------------------------------------------------------------------------------------
3057 void AliAnalysisTaskSEB0toDPi::FillDaughterHistograms(AliAODTrack* daughterTrack, Int_t daughterType, Int_t histType, Double_t ptB0, AliAODVertex *primaryVertex, Double_t bz, Bool_t isDesiredCandidate, TClonesArray * mcTrackArray) {
3058 
3059  //In this function we fill histograms with the properties of all the daughters of our selected signal candidate
3060 
3061  Int_t particleType = 2;
3062  if (daughterType == 0) particleType = 3;
3063 
3064  Double_t pt_track = 0;
3065  Double_t momentum_track = 0;
3066  Int_t numberOfITS = 0;
3067  Int_t numberOfTPC = 0;
3068  Int_t totalNumberOfITS = 0;
3069  Int_t totalNumberOfTPC = 0;
3070  Double_t nSigmaTPC = 0;
3071  Double_t nSigmaTOF = 0;
3072  Double_t nSigmaTPCtotal = 0;
3073  Double_t nSigmaTOFtotal = 0;
3074  Int_t TPCok = 0;
3075  Int_t TOFok = 0;
3076 
3077  if (isDesiredCandidate) histType++;
3078 
3079  AliExternalTrackParam particleTrack;
3080  particleTrack.CopyFromVTrack(daughterTrack);
3081  Double_t d0[2], covd0[3];
3082  particleTrack.PropagateToDCA(primaryVertex, bz, 100., d0, covd0);
3083 
3084  AliAODPidHF* trackPIDHF = (AliAODPidHF*)fCuts->GetPidHF();
3085 
3086  //fill the DPlus pion info
3087  pt_track = daughterTrack->Pt();
3088  momentum_track = daughterTrack->P();
3089  numberOfITS = daughterTrack->GetITSNcls();
3090  numberOfTPC = daughterTrack->GetTPCNcls();
3091  totalNumberOfITS += numberOfITS;
3092  totalNumberOfTPC += numberOfTPC;
3093  if (trackPIDHF) TPCok = trackPIDHF->GetnSigmaTPC(daughterTrack, particleType, nSigmaTPC);
3094  if (trackPIDHF) TOFok = trackPIDHF->GetnSigmaTOF(daughterTrack, particleType, nSigmaTOF);
3095  if (TPCok != -1) nSigmaTPCtotal += nSigmaTPC * nSigmaTPC;
3096  if (TOFok != -1) nSigmaTOFtotal += nSigmaTOF * nSigmaTOF;
3097 
3098  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
3099  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
3100  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
3101  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
3102 
3103  for (Int_t j = 0; j < 10; ++j)
3104  {
3105  if (daughterTrack->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
3106 
3107  }
3108 
3109  if (TPCok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][5])->Fill(nSigmaTPC);
3110  if (TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][6])->Fill(nSigmaTOF);
3111  if (TPCok != -1 && TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][7])->Fill(TMath::Sqrt(nSigmaTPC * nSigmaTPC + nSigmaTOF * nSigmaTOF));
3112  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(TMath::Abs(d0[0]));
3113  ((TH1F*)fDaughterHistogramArray[daughterType][histType][9])->Fill(TMath::Abs(d0[0] / TMath::Sqrt(covd0[0])));
3114  ((TH1F*)fDaughterHistogramArray[daughterType][histType][10])->Fill(daughterTrack->Eta());
3115 
3116  if (ptB0 > 0.0) ((TH2F*)fDaughterHistogramArray2D[daughterType][4])->Fill(ptB0, pt_track);
3117 
3118 
3119  //we save the pdgcode of the used particle and its mother to check PID efficiency
3120  if (fUseMCInfo)
3121  {
3122  Float_t pdgCodeParticle = -1;
3123  Float_t pdgCodeParticleMother = -1;
3124  Int_t mcLabelParticle = -1;
3125  Int_t mcLabelParticleMother = -1;
3126  mcLabelParticle = daughterTrack->GetLabel();
3127 
3128  if (mcLabelParticle >= 0) {
3129 
3130  AliAODMCParticle *mcTrackParticle = (AliAODMCParticle*)mcTrackArray->At(mcLabelParticle);
3131  pdgCodeParticle = TMath::Abs(mcTrackParticle->GetPdgCode());
3132  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][2])->Fill(pdgCodeParticle);
3133  mcLabelParticleMother = mcTrackParticle->GetMother();
3134 
3135  if (mcLabelParticleMother >= 0) {
3136  AliAODMCParticle *mcTrackParticleMother = (AliAODMCParticle*)mcTrackArray->At(mcLabelParticleMother);
3137  pdgCodeParticleMother = TMath::Abs(mcTrackParticleMother->GetPdgCode());
3138  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][3])->Fill(pdgCodeParticleMother);
3139  }
3140  }
3141  }
3142  return;
3143 }
3144 //-------------------------------------------------------------------------------------
3145 void AliAnalysisTaskSEB0toDPi::FillFinalTrackHistograms(AliAODRecoDecayHF2Prong * selectedB0, AliAODVertex *primaryVertex, Double_t bz, Bool_t isDesiredCandidate, TClonesArray * mcTrackArray) {
3146 
3147  //In this function we fill histograms with the properties of all the daughters of our selected signal candidate
3148 
3149  AliAODRecoDecayHF3Prong* selectedDPlus = (AliAODRecoDecayHF3Prong*)selectedB0->GetDaughter(0);
3150  AliAODTrack* selectedB0Pion = (AliAODTrack*)selectedB0->GetDaughter(1);
3151 
3152  AliAODTrack* selectedDPlusKaon = (AliAODTrack*)selectedDPlus->GetDaughter(1);
3153  AliAODTrack* selectedDPlusFirstPion = (AliAODTrack*)selectedDPlus->GetDaughter(0);
3154  AliAODTrack* selectedDPlusSecondPion = (AliAODTrack*)selectedDPlus->GetDaughter(2);
3155 
3156 
3157  FillDaughterHistograms(selectedB0Pion, 2, 4, selectedB0->Pt(), primaryVertex, bz, isDesiredCandidate, mcTrackArray);
3158  FillDaughterHistograms(selectedDPlusKaon, 0, 4, selectedB0->Pt(), primaryVertex, bz, isDesiredCandidate, mcTrackArray);
3159  FillDaughterHistograms(selectedDPlusFirstPion, 1, 4, selectedB0->Pt(), primaryVertex, bz, isDesiredCandidate, mcTrackArray);
3160  FillDaughterHistograms(selectedDPlusSecondPion, 1, 4, selectedB0->Pt(), primaryVertex, bz, isDesiredCandidate, mcTrackArray);
3161 
3162  // not yet implemented for this decay
3163  // if (!isDesiredCandidate)
3164  // {
3165  // ((TH1F*)(fResultsHistogramArray[11][0]))->Fill(totalNumberOfITS);
3166  // ((TH1F*)(fResultsHistogramArray[11][2]))->Fill(totalNumberOfTPC);
3167  // ((TH1F*)(fResultsHistogramArray[11][4]))->Fill(TMath::Sqrt(nSigmaTPCtotal + nSigmaTOFtotal));
3168  // }
3169  // if (isDesiredCandidate)
3170  // {
3171  // ((TH1F*)(fResultsHistogramArray[11][1]))->Fill(totalNumberOfITS);
3172  // ((TH1F*)(fResultsHistogramArray[11][3]))->Fill(totalNumberOfTPC);
3173  // ((TH1F*)(fResultsHistogramArray[11][5]))->Fill(TMath::Sqrt(nSigmaTPCtotal + nSigmaTOFtotal));
3174  // }
3175 
3176  // we look at the invariant mass combinations of all daughter tracks
3177  // AliExternalTrackParam trackB0Pion;
3178  // trackB0Pion.CopyFromVTrack(selectedB0Pion);
3179  // AliExternalTrackParam trackDPlusPion;
3180  // trackDPlusPion.CopyFromVTrack(selectedDPlusPion);
3181  // AliExternalTrackParam trackDPlusKaon;
3182  // trackDPlusKaon.CopyFromVTrack(selectedDPlusKaon);
3183 
3184  // UInt_t prongs2[2] = {0};
3185  // UInt_t prongs3[3] = {0};
3186 
3187  // prongs2[0] = 211; prongs2[1] = 211;
3188  // TwoTrackCombinationInfo(&trackDPlusPion, &trackB0Pion, primaryVertex, bz, isDesiredCandidate, 0, prongs2);
3189  // prongs2[0] = 321; prongs2[1] = 211;
3190  // TwoTrackCombinationInfo(&trackDPlusKaon, &trackB0Pion, primaryVertex, bz, isDesiredCandidate, 2, prongs2);
3191  // prongs3[0] = 211; prongs3[1] = 321; prongs3[2] = 211;
3192  // ThreeTrackCombinationInfo(&trackDPlusPion, &trackDPlusKaon, &trackB0Pion, primaryVertex, bz, isDesiredCandidate, 4, prongs3);
3193 
3194  return;
3195 }
3196 //-------------------------------------------------------------------------------------
3198 {
3202 
3203  AliAODRecoDecayHF3Prong * DPlus = (AliAODRecoDecayHF3Prong*)Bzero->GetDaughter(0);
3204 
3205  Double_t e[4] = {0};
3206  e[0] = DPlus->EProng(0, 211); // to be done: Check effect of taking energies of DPlus daughters at B vertex by propagating D to B first ////////////////////////////////////////////////////////////////////////////////////////////////////////
3207  e[1] = DPlus->EProng(1, 321);
3208  e[2] = DPlus->EProng(2, 211);
3209  e[3] = Bzero->EProng(1, 211);
3210 
3211  Double_t esum = e[0] + e[1] + e[2] + e[3];
3212  Double_t invMassB0 = TMath::Sqrt(esum * esum - Bzero->P2());
3213 
3214  Double_t eD[3] = {0};
3215  eD[0] = DPlus->EProng(0, 211);
3216  eD[1] = DPlus->EProng(1, 321);
3217  eD[2] = DPlus->EProng(2, 211);
3218 
3219  Double_t esumD = eD[0] + eD[1] + eD[2];
3220  Double_t invMassDPlus = TMath::Sqrt(esumD * esumD - DPlus->P2());
3221 
3222  return invMassB0 - invMassDPlus;
3223 }
3224 //-------------------------------------------------------------------------------------
3225 void AliAnalysisTaskSEB0toDPi::FillDPlusHistograms(AliAODRecoDecayHF3Prong * selectedMother, AliAODVertex *primaryVertex, Double_t bz, Int_t motherType, Int_t histType, Int_t pdgCodeMother) {
3226 
3227  if (histType < 0) return;
3228 
3229  //In this function we fill the histograms of the reconstructed mothers
3230  Double_t ptMother = 0.0;
3231  Double_t momentumMother = 0.0;
3232  Double_t etaMother = 0.0;
3233  Double_t phiMother = 0.0;
3234  Double_t d0Mother = 0.0;
3235  Double_t d0firstTrack = 0.0;
3236  Double_t d0secondTrack = 0.0;
3237  Double_t d0thirdTrack = 0.0;
3238  Double_t pointingAngle = 0.0;
3239  Double_t impactProduct123 = 0.0;
3240  Double_t impactProduct12 = 0.0;
3241  Double_t impactProduct13 = 0.0;
3242  Double_t impactProduct23 = 0.0;
3243  Double_t impactProductXY = 0.0;
3244  Double_t invariantMassMother = 0.0;
3245  Double_t invmassDelta = 0.0;
3246  Double_t dcaMother12 = 0.0;
3247  Double_t dcaMother13 = 0.0;
3248  Double_t dcaMother23 = 0.0;
3249  AliAODVertex * vertexMother = 0x0;
3250  Double_t vertexDistance = 0.0;
3251  Double_t decayTime = 0.0;
3252  Double_t ptFirstDaughter = 0.0;
3253  Double_t ptSecondDaughter = 0.0;
3254  Double_t ptThirdDaughter = 0.0;
3255  UInt_t prongs[3];
3256 
3257  Double_t angleMotherFirstDaughter = 0.0;
3258  Double_t angleMotherSecondDaughter = 0.0;
3259  Double_t angleMotherThirdDaughter = 0.0;
3260 
3261  Double_t smallestAngleMotherDaughter = 0.0;
3262  Double_t largestAngleMotherDaughter = 0.0;
3263 
3264  Double_t normDecayLength = 0;
3265  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(411)->Mass();
3266 
3267  prongs[0] = 211;
3268  prongs[1] = 321;
3269  prongs[2] = 211;
3270 
3271  AliAODTrack * firstDaughter = (AliAODTrack*)selectedMother->GetDaughter(0);
3272  AliAODTrack * secondDaughter = (AliAODTrack*)selectedMother->GetDaughter(1);
3273  AliAODTrack * thirdDaughter = (AliAODTrack*)selectedMother->GetDaughter(2);
3274 
3275  vertexMother = selectedMother->GetSecondaryVtx();
3276  ptFirstDaughter = firstDaughter->Pt();
3277  ptSecondDaughter = secondDaughter->Pt();
3278  ptThirdDaughter = thirdDaughter->Pt();
3279 
3280  AliExternalTrackParam motherTrack;
3281  motherTrack.CopyFromVTrack(selectedMother);
3282  Double_t d0z0[2], covd0z0[3], d0[2];
3283  motherTrack.PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
3284  d0[0] = d0z0[0];
3285 
3286  ptMother = selectedMother->Pt();
3287  momentumMother = selectedMother->P();
3288  etaMother = selectedMother->Eta();
3289  phiMother = selectedMother->Phi();
3290 
3291  d0Mother = TMath::Abs(d0[0]);
3292  d0firstTrack = TMath::Abs(selectedMother->Getd0Prong(0));
3293  d0secondTrack = TMath::Abs(selectedMother->Getd0Prong(1));
3294  d0thirdTrack = TMath::Abs(selectedMother->Getd0Prong(2));
3295  pointingAngle = selectedMother->CosPointingAngle();
3296  impactProduct123 = selectedMother->Getd0Prong(0) * selectedMother->Getd0Prong(1) * selectedMother->Getd0Prong(2);
3297  impactProduct12 = selectedMother->Getd0Prong(0) * selectedMother->Getd0Prong(1);
3298  impactProduct13 = selectedMother->Getd0Prong(0) * selectedMother->Getd0Prong(2);
3299  impactProduct23 = selectedMother->Getd0Prong(1) * selectedMother->Getd0Prong(2);
3300 
3301  impactProductXY = TMath::Abs(selectedMother->ImpParXY());
3302  invariantMassMother = selectedMother->InvMass(3, prongs);
3303 
3304  dcaMother12 = selectedMother->GetDCA(0);
3305  dcaMother13 = selectedMother->GetDCA(1);
3306  dcaMother23 = selectedMother->GetDCA(2);
3307 
3308  vertexDistance = vertexMother->DistanceToVertex(primaryVertex);
3309 
3310  angleMotherFirstDaughter = (selectedMother->Px() * firstDaughter->Px() + selectedMother->Py() * firstDaughter->Py() + selectedMother->Pz() * firstDaughter->Pz()) / (selectedMother->P() * firstDaughter->P());
3311  angleMotherSecondDaughter = (selectedMother->Px() * secondDaughter->Px() + selectedMother->Py() * secondDaughter->Py() + selectedMother->Pz() * secondDaughter->Pz()) / (selectedMother->P() * secondDaughter->P());
3312  angleMotherThirdDaughter = (selectedMother->Px() * secondDaughter->Px() + selectedMother->Py() * secondDaughter->Py() + selectedMother->Pz() * secondDaughter->Pz()) / (selectedMother->P() * secondDaughter->P());
3313 
3314  if (angleMotherFirstDaughter > angleMotherSecondDaughter) {smallestAngleMotherDaughter = angleMotherSecondDaughter;} else {smallestAngleMotherDaughter = angleMotherFirstDaughter;}
3315  if (angleMotherThirdDaughter < smallestAngleMotherDaughter) smallestAngleMotherDaughter = angleMotherThirdDaughter;
3316  if (angleMotherFirstDaughter > angleMotherSecondDaughter) {largestAngleMotherDaughter = angleMotherFirstDaughter;} else {largestAngleMotherDaughter = angleMotherSecondDaughter;}
3317  if (angleMotherThirdDaughter > largestAngleMotherDaughter) largestAngleMotherDaughter = angleMotherThirdDaughter;
3318 
3319  normDecayLength = selectedMother->NormalizedDecayLength();
3320 
3321  Double_t pseudoProperDecayLength = ((vertexMother->GetX() - primaryVertex->GetX()) * selectedMother->Px() / TMath::Abs(selectedMother->Pt())) + ((vertexMother->GetY() - primaryVertex->GetY()) * selectedMother->Py() / TMath::Abs(selectedMother->Pt()));
3322  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother / ptMother;
3323  decayTime = vertexDistance / (299792458 * TMath::Sqrt(1 / ((pdgMassMother * pdgMassMother / (momentumMother * momentumMother)) + 1)));
3324 
3325  Double_t phi = selectedMother->Phi();
3326  Double_t theta = selectedMother->Theta();
3327  Double_t covMatrix[21];
3328  selectedMother->GetCovarianceXYZPxPyPz(covMatrix);
3329 
3330  Double_t cp = TMath::Cos(phi);
3331  Double_t sp = TMath::Sin(phi);
3332  Double_t ct = TMath::Cos(theta);
3333  Double_t st = TMath::Sin(theta);
3334 
3335  Double_t errorMomentum = covMatrix[9] * cp * cp * ct * ct // GetCovPxPx
3336  + covMatrix[13] * 2.*cp * sp * ct * ct // GetCovPxPy
3337  + covMatrix[18] * 2.*cp * ct * st // GetCovPxPz
3338  + covMatrix[14] * sp * sp * ct * ct // GetCovPyPy
3339  + covMatrix[19] * 2.*sp * ct * st // GetCovPyPz
3340  + covMatrix[20] * st * st; // GetCovPzPz
3341  Double_t normalizedDecayTime = selectedMother->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1 / ((pdgMassMother * pdgMassMother * errorMomentum * errorMomentum / (momentumMother * momentumMother)) + 1)));
3342 
3343  Double_t eKaon1 = selectedMother->EProng(1, 321);
3344  Double_t ePion2 = selectedMother->EProng(2, 211);
3345  Double_t eSum = eKaon1 + ePion2;
3346  Double_t pxPions = (selectedMother->PxProng(1) + selectedMother->PxProng(2)) * (selectedMother->PxProng(1) + selectedMother->PxProng(2));
3347  Double_t pyPions = (selectedMother->PyProng(1) + selectedMother->PyProng(2)) * (selectedMother->PyProng(1) + selectedMother->PyProng(2));
3348  Double_t pzPions = (selectedMother->PzProng(1) + selectedMother->PzProng(2)) * (selectedMother->PzProng(1) + selectedMother->PzProng(2));
3349  Double_t pSum = pxPions + pyPions + pzPions;
3350  Double_t invMassPions = TMath::Sqrt(eSum * eSum - pSum);
3351  Double_t invMassDPlus = selectedMother->InvMass(3, prongs);;
3352  invmassDelta = invMassDPlus - invMassPions;
3353 
3354  Double_t vertexMotherX = vertexMother->GetX();
3355  Double_t vertexMotherY = vertexMother->GetY();
3356  Double_t vertexMotherZ = vertexMother->GetZ();
3357 
3358  Double_t cosPointingAngleXY = selectedMother->CosPointingAngleXY();
3359  Double_t distanceXYToVertex = vertexMother->DistanceXYToVertex(primaryVertex);
3360  Double_t normalizedDecayLengthXY = selectedMother->NormalizedDecayLengthXY();
3361 
3362  ((TH1F*)fMotherHistogramArray[motherType][histType][0])->Fill(invariantMassMother);
3363  ((TH1F*)fMotherHistogramArray[motherType][histType][1])->Fill(invmassDelta);
3364  ((TH1F*)fMotherHistogramArray[motherType][histType][2])->Fill(ptMother);
3365  ((TH1F*)fMotherHistogramArray[motherType][histType][3])->Fill(ptFirstDaughter);
3366  ((TH1F*)fMotherHistogramArray[motherType][histType][4])->Fill(ptSecondDaughter);
3367  ((TH1F*)fMotherHistogramArray[motherType][histType][5])->Fill(ptThirdDaughter);
3368  ((TH1F*)fMotherHistogramArray[motherType][histType][6])->Fill(d0Mother);
3369  ((TH1F*)fMotherHistogramArray[motherType][histType][7])->Fill(d0firstTrack);
3370  ((TH1F*)fMotherHistogramArray[motherType][histType][8])->Fill(d0secondTrack);
3371  ((TH1F*)fMotherHistogramArray[motherType][histType][9])->Fill(d0thirdTrack);
3372  ((TH1F*)fMotherHistogramArray[motherType][histType][10])->Fill(pointingAngle);
3373  ((TH1F*)fMotherHistogramArray[motherType][histType][11])->Fill(cosPointingAngleXY);
3374  ((TH1F*)fMotherHistogramArray[motherType][histType][12])->Fill(impactProduct123);
3375  ((TH1F*)fMotherHistogramArray[motherType][histType][13])->Fill(impactProduct12);
3376  ((TH1F*)fMotherHistogramArray[motherType][histType][14])->Fill(impactProduct13);
3377  ((TH1F*)fMotherHistogramArray[motherType][histType][15])->Fill(impactProduct23);
3378  ((TH1F*)fMotherHistogramArray[motherType][histType][16])->Fill(impactProductXY);
3379  ((TH1F*)fMotherHistogramArray[motherType][histType][17])->Fill(dcaMother12);
3380  ((TH1F*)fMotherHistogramArray[motherType][histType][18])->Fill(dcaMother13);
3381  ((TH1F*)fMotherHistogramArray[motherType][histType][19])->Fill(dcaMother23);
3382  ((TH1F*)fMotherHistogramArray[motherType][histType][20])->Fill(vertexDistance);
3383  ((TH1F*)fMotherHistogramArray[motherType][histType][21])->Fill(distanceXYToVertex);
3384  ((TH1F*)fMotherHistogramArray[motherType][histType][22])->Fill(normDecayLength);
3385  ((TH1F*)fMotherHistogramArray[motherType][histType][23])->Fill(normalizedDecayLengthXY);
3386  ((TH1F*)fMotherHistogramArray[motherType][histType][24])->Fill(pseudoProperDecayTime);
3387  ((TH1F*)fMotherHistogramArray[motherType][histType][25])->Fill(decayTime);
3388  ((TH1F*)fMotherHistogramArray[motherType][histType][26])->Fill(normalizedDecayTime);
3389 
3390  ((TH1F*)fMotherHistogramArray[motherType][histType][27])->Fill(smallestAngleMotherDaughter);
3391  ((TH1F*)fMotherHistogramArray[motherType][histType][28])->Fill(largestAngleMotherDaughter);
3392  ((TH1F*)fMotherHistogramArray[motherType][histType][29])->Fill(largestAngleMotherDaughter - smallestAngleMotherDaughter);
3393 
3394  ((TH1F*)fMotherHistogramArray[motherType][histType][30])->Fill(TMath::Abs(selectedMother->Getd0Prong(0) / selectedMother->Getd0errProng(0)));
3395  ((TH1F*)fMotherHistogramArray[motherType][histType][31])->Fill(TMath::Abs(selectedMother->Getd0Prong(1) / selectedMother->Getd0errProng(1)));
3396  ((TH1F*)fMotherHistogramArray[motherType][histType][32])->Fill(TMath::Abs(selectedMother->Getd0Prong(2) / selectedMother->Getd0errProng(2)));
3397  ((TH1F*)fMotherHistogramArray[motherType][histType][33])->Fill(TMath::Abs(d0[0] / TMath::Sqrt(covd0z0[0])));
3398  ((TH1F*)fMotherHistogramArray[motherType][histType][34])->Fill((selectedMother->Getd0Prong(0) / selectedMother->Getd0errProng(0)) * (selectedMother->Getd0Prong(1) / selectedMother->Getd0errProng(1)) * (selectedMother->Getd0Prong(2) / selectedMother->Getd0errProng(2)));
3399 
3400  ((TH1F*)fMotherHistogramArray[motherType][histType][35])->Fill(selectedMother->GetDist12toPrim());
3401  ((TH1F*)fMotherHistogramArray[motherType][histType][36])->Fill(selectedMother->GetDist23toPrim());
3402  ((TH1F*)fMotherHistogramArray[motherType][histType][37])->Fill(selectedMother->GetSigmaVert());
3403 
3404  ((TH1F*)fMotherHistogramArray[motherType][histType][49])->Fill(selectedMother->Y(411));
3405  ((TH1F*)fMotherHistogramArray[motherType][histType][50])->Fill(etaMother);
3406  ((TH1F*)fMotherHistogramArray[motherType][histType][51])->Fill(phiMother);
3407  ((TH1F*)fMotherHistogramArray[motherType][histType][52])->Fill(vertexMotherX);
3408  ((TH1F*)fMotherHistogramArray[motherType][histType][53])->Fill(vertexMotherY);
3409  ((TH1F*)fMotherHistogramArray[motherType][histType][54])->Fill(vertexMotherZ);
3410  ((TH1F*)fMotherHistogramArray[motherType][histType][55])->Fill(vertexMother->GetChi2perNDF());
3411 
3412  //we fill the 2D histograms // to be done
3413  // Int_t nFirst = 0;
3414  // Int_t nSecond = 1;
3415  // Int_t nVariables = 10;
3416  // Int_t nHistograms = nVariables * (nVariables - 1) / 2;
3417  // for (Int_t k = 0; k < nHistograms; ++k)
3418  // {
3419  // Double_t firstVariable = 0.0;
3420  // Double_t secondVariable = 0.0;
3421 
3422  // if (nFirst == 0) firstVariable = d0firstTrack;
3423  // if (nFirst == 1) firstVariable = d0secondTrack;
3424  // if (nFirst == 2) firstVariable = d0Mother;
3425  // if (nFirst == 3) firstVariable = pointingAngle;
3426  // if (nFirst == 4) firstVariable = impactProduct;
3427  // if (nFirst == 5) firstVariable = impactProductXY;
3428  // if (nFirst == 6) firstVariable = vertexDistance;
3429  // if (nFirst == 7) firstVariable = normDecayLength;
3430  // if (nFirst == 8) firstVariable = cosPointingAngleXY;
3431  // if (nFirst == 9) firstVariable = distanceXYToVertex;
3432  // if (nFirst == 10) firstVariable = normalizedDecayLengthXY;
3433 
3434  // if (nSecond == 0) secondVariable = d0firstTrack;
3435  // if (nSecond == 1) secondVariable = d0secondTrack;
3436  // if (nSecond == 2) secondVariable = d0Mother;
3437  // if (nSecond == 3) secondVariable = pointingAngle;
3438  // if (nSecond == 4) secondVariable = impactProduct;
3439  // if (nSecond == 5) secondVariable = impactProductXY;
3440  // if (nSecond == 6) secondVariable = vertexDistance;
3441  // if (nSecond == 7) secondVariable = normDecayLength;
3442  // if (nSecond == 8) secondVariable = cosPointingAngleXY;
3443  // if (nSecond == 9) secondVariable = distanceXYToVertex;
3444  // if (nSecond == 10) secondVariable = normalizedDecayLengthXY;
3445 
3446  // ((TH2F*)fMotherHistogramArray2D[motherType][histType][k])->Fill(firstVariable, secondVariable);
3447 
3448  // nSecond++;
3449  // if (nSecond > nVariables)
3450  // {
3451  // nFirst++;
3452  // nSecond = nFirst + 1;
3453  // }
3454  // }
3455 
3456  return;
3457 }
3458 //-------------------------------------------------------------------------------------
3459 void AliAnalysisTaskSEB0toDPi::FillB0Histograms(AliAODRecoDecayHF2Prong * selectedMother, AliAODVertex *primaryVertex, Double_t bz, Int_t motherType, Int_t histType) {
3460 
3461  //In this function we fill the histograms of the reconstructed mothers
3462  Double_t ptMother = 0.0;
3463  Double_t momentumMother = 0.0;
3464  Double_t etaMother = 0.0;
3465  Double_t phiMother = 0.0;
3466  Double_t d0Mother = 0.0;
3467  Double_t d0firstTrack = 0.0;
3468  Double_t d0secondTrack = 0.0;
3469  Double_t pointingAngle = 0.0;
3470  Double_t impactProduct = 0.0;
3471  Double_t impactProductXY = 0.0;
3472  Double_t invariantMassMother = 0.0;
3473  Double_t invmassDelta = 0.0;
3474  Double_t dcaMother = 0.0;
3475  AliAODVertex * vertexMother = 0x0;
3476  Double_t vertexDistance = 0.0;
3477  Double_t decayTime = 0.0;
3478  Double_t ptFirstDaughter = 0.0;
3479  Double_t ptSecondDaughter = 0.0;
3480  UInt_t prongs[2];
3481 
3482  Double_t cosThetaStar = 0;
3483  Double_t angleMotherFirstDaughter = 0.0;
3484  Double_t angleMotherSecondDaughter = 0.0;
3485  Double_t angleBetweenBothDaughters = 0;
3486 
3487  Double_t normDecayLength = 0;
3488  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(511)->Mass();
3489 
3490  prongs[0] = 411;
3491  prongs[1] = 211;
3492 
3493  AliAODRecoDecayHF3Prong * firstDaughter = (AliAODRecoDecayHF3Prong*)selectedMother->GetDaughter(0);
3494  AliAODTrack * secondDaughter = (AliAODTrack*)selectedMother->GetDaughter(1);
3495 
3496  vertexMother = selectedMother->GetSecondaryVtx();
3497  ptFirstDaughter = firstDaughter->Pt();
3498  ptSecondDaughter = secondDaughter->Pt();
3499 
3500  AliExternalTrackParam motherTrack;
3501  motherTrack.CopyFromVTrack(selectedMother);
3502  Double_t d0z0[2], covd0z0[3], d0[2];
3503  motherTrack.PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
3504  d0[0] = d0z0[0];
3505 
3506  ptMother = selectedMother->Pt();
3507  momentumMother = selectedMother->P();
3508  etaMother = selectedMother->Eta();
3509  phiMother = selectedMother->Phi();
3510 
3511  d0Mother = TMath::Abs(d0[0]);
3512  d0firstTrack = TMath::Abs(selectedMother->Getd0Prong(0));
3513  d0secondTrack = TMath::Abs(selectedMother->Getd0Prong(1));
3514  pointingAngle = selectedMother->CosPointingAngle();
3515  impactProduct = selectedMother->Getd0Prong(0) * selectedMother->Getd0Prong(1);
3516 
3517  impactProductXY = TMath::Abs(selectedMother->ImpParXY());
3518  invariantMassMother = selectedMother->InvMass(2, prongs);
3519 
3520  dcaMother = selectedMother->GetDCA();
3521 
3522  vertexDistance = vertexMother->DistanceToVertex(primaryVertex);
3523 
3524  angleMotherFirstDaughter = (selectedMother->Px() * firstDaughter->Px() + selectedMother->Py() * firstDaughter->Py() + selectedMother->Pz() * firstDaughter->Pz()) / (selectedMother->P() * firstDaughter->P());
3525  angleMotherSecondDaughter = (selectedMother->Px() * secondDaughter->Px() + selectedMother->Py() * secondDaughter->Py() + selectedMother->Pz() * secondDaughter->Pz()) / (selectedMother->P() * secondDaughter->P());
3526  angleBetweenBothDaughters = (firstDaughter->Px() * secondDaughter->Px() + firstDaughter->Py() * secondDaughter->Py() + firstDaughter->Pz() * secondDaughter->Pz()) / (firstDaughter->P() * secondDaughter->P());
3527 
3528  cosThetaStar = selectedMother->CosThetaStar(0, 511, 411, 211);
3529  normDecayLength = selectedMother->NormalizedDecayLength();
3530 
3531  Double_t pseudoProperDecayLength = ((vertexMother->GetX() - primaryVertex->GetX()) * selectedMother->Px() / TMath::Abs(selectedMother->Pt())) + ((vertexMother->GetY() - primaryVertex->GetY()) * selectedMother->Py() / TMath::Abs(selectedMother->Pt()));
3532  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother / ptMother;
3533  decayTime = vertexDistance / (299792458 * TMath::Sqrt(1 / ((pdgMassMother * pdgMassMother / (momentumMother * momentumMother)) + 1)));
3534 
3535  Double_t phi = selectedMother->Phi();
3536  Double_t theta = selectedMother->Theta();
3537  Double_t covMatrix[21];
3538  selectedMother->GetCovarianceXYZPxPyPz(covMatrix);
3539 
3540  Double_t cp = TMath::Cos(phi);
3541  Double_t sp = TMath::Sin(phi);
3542  Double_t ct = TMath::Cos(theta);
3543  Double_t st = TMath::Sin(theta);
3544 
3545  Double_t errorMomentum = covMatrix[9] * cp * cp * ct * ct // GetCovPxPx
3546  + covMatrix[13] * 2.*cp * sp * ct * ct // GetCovPxPy
3547  + covMatrix[18] * 2.*cp * ct * st // GetCovPxPz
3548  + covMatrix[14] * sp * sp * ct * ct // GetCovPyPy
3549  + covMatrix[19] * 2.*sp * ct * st // GetCovPyPz
3550  + covMatrix[20] * st * st; // GetCovPzPz
3551  Double_t normalizedDecayTime = selectedMother->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1 / ((pdgMassMother * pdgMassMother * errorMomentum * errorMomentum / (momentumMother * momentumMother)) + 1)));
3552 
3553  invmassDelta = DeltaInvMassB0Kpipipi(selectedMother);
3554 
3555  Double_t vertexMotherX = vertexMother->GetX();
3556  Double_t vertexMotherY = vertexMother->GetY();
3557  Double_t vertexMotherZ = vertexMother->GetZ();
3558 
3559  Double_t cosPointingAngleXY = selectedMother->CosPointingAngleXY();
3560  Double_t distanceXYToVertex = vertexMother->DistanceXYToVertex(primaryVertex);
3561  Double_t normalizedDecayLengthXY = selectedMother->NormalizedDecayLengthXY();
3562 
3563  ((TH1F*)fMotherHistogramArray[motherType][histType][0])->Fill(invariantMassMother);
3564  ((TH1F*)fMotherHistogramArray[motherType][histType][1])->Fill(invmassDelta);
3565  ((TH1F*)fMotherHistogramArray[motherType][histType][2])->Fill(ptMother);
3566  ((TH1F*)fMotherHistogramArray[motherType][histType][3])->Fill(ptFirstDaughter);
3567  ((TH1F*)fMotherHistogramArray[motherType][histType][4])->Fill(ptSecondDaughter);
3568  ((TH1F*)fMotherHistogramArray[motherType][histType][5])->Fill(d0Mother);
3569  ((TH1F*)fMotherHistogramArray[motherType][histType][6])->Fill(d0firstTrack);
3570  ((TH1F*)fMotherHistogramArray[motherType][histType][7])->Fill(d0secondTrack);
3571  ((TH1F*)fMotherHistogramArray[motherType][histType][8])->Fill(pointingAngle);
3572  ((TH1F*)fMotherHistogramArray[motherType][histType][9])->Fill(cosPointingAngleXY);
3573  ((TH1F*)fMotherHistogramArray[motherType][histType][10])->Fill(impactProduct);
3574  ((TH1F*)fMotherHistogramArray[motherType][histType][11])->Fill(impactProductXY);
3575  ((TH1F*)fMotherHistogramArray[motherType][histType][12])->Fill(dcaMother);
3576  ((TH1F*)fMotherHistogramArray[motherType][histType][13])->Fill(vertexDistance);
3577  ((TH1F*)fMotherHistogramArray[motherType][histType][14])->Fill(distanceXYToVertex);
3578  ((TH1F*)fMotherHistogramArray[motherType][histType][15])->Fill(normDecayLength);
3579  ((TH1F*)fMotherHistogramArray[motherType][histType][16])->Fill(normalizedDecayLengthXY);
3580  ((TH1F*)fMotherHistogramArray[motherType][histType][17])->Fill(pseudoProperDecayTime);
3581  ((TH1F*)fMotherHistogramArray[motherType][histType][18])->Fill(decayTime);
3582  ((TH1F*)fMotherHistogramArray[motherType][histType][19])->Fill(normalizedDecayTime);
3583 
3584  ((TH1F*)fMotherHistogramArray[motherType][histType][20])->Fill(angleMotherFirstDaughter);
3585  ((TH1F*)fMotherHistogramArray[motherType][histType][21])->Fill(angleMotherSecondDaughter);
3586  ((TH1F*)fMotherHistogramArray[motherType][histType][22])->Fill(angleBetweenBothDaughters);
3587  ((TH1F*)fMotherHistogramArray[motherType][histType][23])->Fill(cosThetaStar);
3588 
3589  ((TH1F*)fMotherHistogramArray[motherType][histType][24])->Fill(TMath::Abs(selectedMother->Getd0Prong(0) / selectedMother->Getd0errProng(0)));
3590  ((TH1F*)fMotherHistogramArray[motherType][histType][25])->Fill(TMath::Abs(selectedMother->Getd0Prong(1) / selectedMother->Getd0errProng(1)));
3591  ((TH1F*)fMotherHistogramArray[motherType][histType][26])->Fill(TMath::Abs(d0[0] / TMath::Sqrt(covd0z0[0])));
3592  ((TH1F*)fMotherHistogramArray[motherType][histType][27])->Fill((selectedMother->Getd0Prong(0) / selectedMother->Getd0errProng(0)) * (selectedMother->Getd0Prong(1) / selectedMother->Getd0errProng(1)));
3593 
3594 
3595  ((TH1F*)fMotherHistogramArray[motherType][histType][49])->Fill(selectedMother->Y(511));
3596  ((TH1F*)fMotherHistogramArray[motherType][histType][50])->Fill(etaMother);
3597  ((TH1F*)fMotherHistogramArray[motherType][histType][51])->Fill(phiMother);
3598  ((TH1F*)fMotherHistogramArray[motherType][histType][52])->Fill(vertexMotherX);
3599  ((TH1F*)fMotherHistogramArray[motherType][histType][53])->Fill(vertexMotherY);
3600  ((TH1F*)fMotherHistogramArray[motherType][histType][54])->Fill(vertexMotherZ);
3601  ((TH1F*)fMotherHistogramArray[motherType][histType][55])->Fill(vertexMother->GetChi2perNDF());
3602 
3603  //we fill the 2D histograms // to be done
3604  // Int_t nFirst = 0;
3605  // Int_t nSecond = 1;
3606  // Int_t nVariables = 10;
3607  // Int_t nHistograms = nVariables * (nVariables - 1) / 2;
3608  // for (Int_t k = 0; k < nHistograms; ++k)
3609  // {
3610  // Double_t firstVariable = 0.0;
3611  // Double_t secondVariable = 0.0;
3612 
3613  // if (nFirst == 0) firstVariable = d0firstTrack;
3614  // if (nFirst == 1) firstVariable = d0secondTrack;
3615  // if (nFirst == 2) firstVariable = d0Mother;
3616  // if (nFirst == 3) firstVariable = pointingAngle;
3617  // if (nFirst == 4) firstVariable = impactProduct;
3618  // if (nFirst == 5) firstVariable = impactProductXY;
3619  // if (nFirst == 6) firstVariable = vertexDistance;
3620  // if (nFirst == 7) firstVariable = normDecayLength;
3621  // if (nFirst == 8) firstVariable = cosPointingAngleXY;
3622  // if (nFirst == 9) firstVariable = distanceXYToVertex;
3623  // if (nFirst == 10) firstVariable = normalizedDecayLengthXY;
3624 
3625  // if (nSecond == 0) secondVariable = d0firstTrack;
3626  // if (nSecond == 1) secondVariable = d0secondTrack;
3627  // if (nSecond == 2) secondVariable = d0Mother;
3628  // if (nSecond == 3) secondVariable = pointingAngle;
3629  // if (nSecond == 4) secondVariable = impactProduct;
3630  // if (nSecond == 5) secondVariable = impactProductXY;
3631  // if (nSecond == 6) secondVariable = vertexDistance;
3632  // if (nSecond == 7) secondVariable = normDecayLength;
3633  // if (nSecond == 8) secondVariable = cosPointingAngleXY;
3634  // if (nSecond == 9) secondVariable = distanceXYToVertex;
3635  // if (nSecond == 10) secondVariable = normalizedDecayLengthXY;
3636 
3637  // ((TH2F*)fMotherHistogramArray2D[motherType][histType][k])->Fill(firstVariable, secondVariable);
3638 
3639  // nSecond++;
3640  // if (nSecond > nVariables)
3641  // {
3642  // nFirst++;
3643  // nSecond = nFirst + 1;
3644  // }
3645  // }
3646 
3647 
3648  if (motherType == 1) {
3649  motherType = motherType - 1;
3650 
3651  AliAODRecoDecay* trackDPlus = (AliAODRecoDecay*)selectedMother->GetDaughter(0);
3652  AliAODTrack * firstDaughterDPlus = (AliAODTrack*)trackDPlus->GetDaughter(0);
3653  AliAODTrack * secondDaughterDPlus = (AliAODTrack*)trackDPlus->GetDaughter(1);
3654  AliAODTrack * thirdDaughterDPlus = (AliAODTrack*)trackDPlus->GetDaughter(2);
3655 
3656  AliAODVertex * vertexB0 = vertexMother;
3657  AliAODVertex * vertexDPlus = trackDPlus->GetSecondaryVtx();
3658  vertexDistance = TMath::Abs(vertexB0->DistanceToVertex(vertexDPlus));
3659  pdgMassMother = TDatabasePDG::Instance()->GetParticle(411)->Mass();
3660 
3661  AliExternalTrackParam firstDaughterDPlusTrack;
3662  AliExternalTrackParam secondDaughterDPlusTrack;
3663  AliExternalTrackParam thirdDaughterDPlusTrack;
3664 
3665  Double_t d0z0[2], covd0z0[3], d0[3];
3666 
3667  firstDaughterDPlusTrack.CopyFromVTrack(firstDaughterDPlus);
3668  firstDaughterDPlusTrack.PropagateToDCA(vertexB0, bz, 100., d0z0, covd0z0);
3669  d0[0] = d0z0[0];
3670 
3671  secondDaughterDPlusTrack.CopyFromVTrack(secondDaughterDPlus);
3672  secondDaughterDPlusTrack.PropagateToDCA(vertexB0, bz, 100., d0z0, covd0z0);
3673  d0[1] = d0z0[0];
3674 
3675  thirdDaughterDPlusTrack.CopyFromVTrack(thirdDaughterDPlus);
3676  thirdDaughterDPlusTrack.PropagateToDCA(vertexB0, bz, 100., d0z0, covd0z0);
3677  d0[2] = d0z0[0];
3678 
3679  AliExternalTrackParam DPlusTrack;
3680  DPlusTrack.CopyFromVTrack(trackDPlus);
3681  Double_t d0z0DPlus[2], covd0z0DPlus[3], d0DPlus;
3682  DPlusTrack.PropagateToDCA(vertexB0, bz, 100., d0z0DPlus, covd0z0DPlus);
3683  d0DPlus = d0z0DPlus[0];
3684 
3685  Double_t impactProductToB0 = d0[0] * d0[1] * d0[2];
3686  Double_t impactProductXYToB0 = trackDPlus->ImpParXY(vertexB0);
3687 
3688  Double_t momentumMother = trackDPlus->P();
3689  Double_t pointingAngleToB0 = trackDPlus->CosPointingAngle(vertexB0);
3690  Double_t d0FirstDaughterToB0 = TMath::Abs(d0[0]);
3691  Double_t d0SecondDaughterToB0 = TMath::Abs(d0[1]);
3692  Double_t d0ThirdDaughterToB0 = TMath::Abs(d0[2]);
3693 
3694  Double_t normDecayLengthToB0 = trackDPlus->NormalizedDecayLength(vertexB0);
3695 
3696  Double_t pseudoProperDecayLength = ((vertexDPlus->GetX() - vertexB0->GetX()) * trackDPlus->Px() / TMath::Abs(trackDPlus->Pt())) + ((vertexDPlus->GetY() - vertexB0->GetY()) * trackDPlus->Py() / TMath::Abs(trackDPlus->Pt()));
3697  Double_t pseudoProperDecayTimeToB0 = pseudoProperDecayLength * pdgMassMother / ptMother;
3698  Double_t DecayTimeToB0 = vertexDistance / (299792458 * TMath::Sqrt(1 / ((pdgMassMother * pdgMassMother / (momentumMother * momentumMother)) + 1)));
3699 
3700  Double_t phi = trackDPlus->Phi();
3701  Double_t theta = trackDPlus->Theta();
3702  Double_t covMatrix[21];
3703  trackDPlus->GetCovarianceXYZPxPyPz(covMatrix);
3704 
3705  Double_t cp = TMath::Cos(phi);
3706  Double_t sp = TMath::Sin(phi);
3707  Double_t ct = TMath::Cos(theta);
3708  Double_t st = TMath::Sin(theta);
3709 
3710  Double_t errorMomentum = covMatrix[9] * cp * cp * ct * ct // GetCovPxPx
3711  + covMatrix[13] * 2.*cp * sp * ct * ct // GetCovPxPy
3712  + covMatrix[18] * 2.*cp * ct * st // GetCovPxPz
3713  + covMatrix[14] * sp * sp * ct * ct // GetCovPyPy
3714  + covMatrix[19] * 2.*sp * ct * st // GetCovPyPz
3715  + covMatrix[20] * st * st; // GetCovPzPz
3716  Double_t normDecayTimeToB0 = trackDPlus->NormalizedDecayLength(vertexB0) / (299792458 * TMath::Sqrt(1 / ((pdgMassMother * pdgMassMother * errorMomentum * errorMomentum / (momentumMother * momentumMother)) + 1)));
3717 
3718  ((TH1F*)fMotherHistogramArray[motherType][histType][38])->Fill(pointingAngleToB0);
3719  ((TH1F*)fMotherHistogramArray[motherType][histType][39])->Fill(d0DPlus);
3720  ((TH1F*)fMotherHistogramArray[motherType][histType][40])->Fill(d0FirstDaughterToB0);
3721  ((TH1F*)fMotherHistogramArray[motherType][histType][41])->Fill(d0SecondDaughterToB0);
3722  ((TH1F*)fMotherHistogramArray[motherType][histType][42])->Fill(d0ThirdDaughterToB0);
3723  ((TH1F*)fMotherHistogramArray[motherType][histType][43])->Fill(impactProductToB0);
3724  ((TH1F*)fMotherHistogramArray[motherType][histType][44])->Fill(impactProductXYToB0);
3725  ((TH1F*)fMotherHistogramArray[motherType][histType][45])->Fill(normDecayLengthToB0);
3726  ((TH1F*)fMotherHistogramArray[motherType][histType][46])->Fill(pseudoProperDecayTimeToB0);
3727  ((TH1F*)fMotherHistogramArray[motherType][histType][47])->Fill(DecayTimeToB0);
3728  ((TH1F*)fMotherHistogramArray[motherType][histType][48])->Fill(normDecayTimeToB0);
3729 
3730 
3731 
3732  }
3733  return;
3734 }
3735 //-------------------------------------------------------------------------------------
3736 void AliAnalysisTaskSEB0toDPi::TwoTrackCombinationInfo(AliExternalTrackParam * firstTrack, AliExternalTrackParam * secondTrack, AliAODVertex * primaryVertex, Double_t bz, Bool_t isDesiredCandidate, Int_t histogramNumber, UInt_t prongs[2]) {
3737 
3738  // we calculate the vertex position
3739  TObjArray daughterTracks;
3740 
3741  daughterTracks.Add(firstTrack);
3742  daughterTracks.Add(secondTrack);
3743 
3744  Double_t dispersion = 0;
3745  AliAODVertex *vertex = RecalculateVertex(primaryVertex, &daughterTracks, bz, dispersion, kTRUE, kTRUE, kFALSE, 3);
3746  if (!vertex) {delete vertex; vertex = NULL; return;}
3747 
3748  Double_t xdummy = 0., ydummy = 0., dca;
3749  Double_t d0z0[2], covd0z0[3], d0[2], d0err[2];
3750 
3751  firstTrack->PropagateToDCA(vertex, bz, 100., d0z0, covd0z0);
3752  secondTrack->PropagateToDCA(vertex, bz, 100., d0z0, covd0z0);
3753  dca = secondTrack->GetDCA(firstTrack, bz, xdummy, ydummy);
3754 
3755  Double_t px[2], py[2], pz[2];
3756  px[0] = firstTrack->Px();
3757  py[0] = firstTrack->Py();
3758  pz[0] = firstTrack->Pz();
3759  px[1] = secondTrack->Px();
3760  py[1] = secondTrack->Py();
3761  pz[1] = secondTrack->Pz();
3762 
3763  firstTrack->PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
3764  d0[0] = d0z0[0];
3765  d0err[0] = TMath::Sqrt(covd0z0[0]);
3766  secondTrack->PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
3767  d0[1] = d0z0[0];
3768  d0err[1] = TMath::Sqrt(covd0z0[0]);
3769 
3770  AliAODRecoDecayHF2Prong * track = new AliAODRecoDecayHF2Prong(vertex, px, py, pz, d0, d0err, dca);
3771  if (!track)
3772  {
3773  delete vertex; vertex = NULL;
3774  delete track; track = NULL;
3775  return;
3776  }
3777 
3778  Double_t invariantMass = track->InvMass(2, prongs);
3779 
3780  if (!isDesiredCandidate) ((TH1F*)(fResultsHistogramArray[12][histogramNumber]))->Fill(invariantMass);
3781  if (isDesiredCandidate) ((TH1F*)(fResultsHistogramArray[12][histogramNumber + 1]))->Fill(invariantMass);
3782 
3783  delete vertex; vertex = NULL;
3784  delete track; track = NULL;
3785  return;
3786 }
3787 //-------------------------------------------------------------------------------------
3788 void AliAnalysisTaskSEB0toDPi::ThreeTrackCombinationInfo(AliExternalTrackParam * firstTrack, AliExternalTrackParam * secondTrack, AliExternalTrackParam * thirdTrack, AliAODVertex * primaryVertex, Double_t bz, Bool_t isDesiredCandidate, Int_t histogramNumber, UInt_t prongs[3]) {
3789 
3790  // we calculate the vertex position
3791  TObjArray daughterTracks;
3792 
3793  daughterTracks.Add(firstTrack);
3794  daughterTracks.Add(secondTrack);
3795  daughterTracks.Add(thirdTrack);
3796 
3797  Double_t dispersion = 0;
3798  AliAODVertex *vertex = RecalculateVertex(primaryVertex, &daughterTracks, bz, dispersion, kTRUE, kTRUE, kFALSE, 3);
3799  if (!vertex) {delete vertex; vertex = NULL; return;}
3800 
3801  Double_t xdummy = 0., ydummy = 0., dca[3];
3802  Double_t d0z0[2], covd0z0[3], d0[3], d0err[3];
3803 
3804  firstTrack->PropagateToDCA(vertex, bz, 100., d0z0, covd0z0);
3805  secondTrack->PropagateToDCA(vertex, bz, 100., d0z0, covd0z0);
3806  thirdTrack->PropagateToDCA(vertex, bz, 100., d0z0, covd0z0);
3807 
3808  dca[0] = firstTrack->GetDCA(secondTrack, bz, xdummy, ydummy);
3809  dca[1] = firstTrack->GetDCA(thirdTrack, bz, xdummy, ydummy);
3810  dca[2] = secondTrack->GetDCA(thirdTrack, bz, xdummy, ydummy);
3811 
3812  Double_t px[3], py[3], pz[3];
3813  px[0] = firstTrack->Px();
3814  py[0] = firstTrack->Py();
3815  pz[0] = firstTrack->Pz();
3816  px[1] = secondTrack->Px();
3817  py[1] = secondTrack->Py();
3818  pz[1] = secondTrack->Pz();
3819  px[2] = thirdTrack->Px();
3820  py[2] = thirdTrack->Py();
3821  pz[2] = thirdTrack->Pz();
3822 
3823  firstTrack->PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
3824  d0[0] = d0z0[0];
3825  d0err[0] = TMath::Sqrt(covd0z0[0]);
3826  secondTrack->PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
3827  d0[1] = d0z0[0];
3828  d0err[1] = TMath::Sqrt(covd0z0[0]);
3829  thirdTrack->PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
3830  d0[2] = d0z0[0];
3831  d0err[2] = TMath::Sqrt(covd0z0[0]);
3832 
3833  // Double_t pos[3]; primaryVertex->GetXYZ(pos);
3834  // 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]));
3835  // 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]));
3836  Short_t charge = (Short_t)(firstTrack->Charge() + secondTrack->Charge() + thirdTrack->Charge());
3837 
3838  AliAODRecoDecayHF3Prong * track = new AliAODRecoDecayHF3Prong(vertex, px, py, pz, d0, d0err, dca, dispersion, 0.0, 0.0, charge); //dist12,dist23,charge);
3839  if (!track)
3840  {
3841  delete vertex; vertex = NULL;
3842  delete track; track = NULL;
3843  return;
3844  }
3845 
3846  Double_t invariantMass = track->InvMass(3, prongs);
3847 
3848  if (!isDesiredCandidate) ((TH1F*)(fResultsHistogramArray[12][histogramNumber]))->Fill(invariantMass);
3849  if (isDesiredCandidate) ((TH1F*)(fResultsHistogramArray[12][histogramNumber + 1]))->Fill(invariantMass);
3850 
3851  delete vertex; vertex = NULL;
3852  delete track; track = NULL;
3853  return;
3854 }
3855 //-------------------------------------------------------------------------------------
3856 Int_t AliAnalysisTaskSEB0toDPi::MatchCandidateToMonteCarlo(Int_t pdgabs, AliAODRecoDecayHF * candidate, TClonesArray *mcArray, TMatrix * B0toDPiLabelMatrix, Bool_t bCheckLabel) const
3857 {
3858  //
3859  // Check if this candidate is matched to a MC signal
3860  // If no, return -1
3861  // If yes, return label (>=0) of the AliAODMCParticle
3862 
3863  // Check number of daughters
3864  Int_t ndg = candidate->GetNDaughters();
3865  if (!ndg) { AliError("No daughters available"); return -1;}
3866 
3867  // loop on daughters and write the labels
3868  Int_t dgLabels[3] = { -1};
3869  Int_t pdgDg[3] = {0};
3870  Int_t signalPosition = -1;
3871  if (pdgabs == 411)
3872  {
3873  if (ndg != 3) return -1;
3874  AliAODTrack *trk0 = (AliAODTrack*)candidate->GetDaughter(0);
3875  dgLabels[0] = trk0->GetLabel();
3876  AliAODTrack *trk1 = (AliAODTrack*)candidate->GetDaughter(1);
3877  dgLabels[1] = trk1->GetLabel();
3878  AliAODTrack *trk2 = (AliAODTrack*)candidate->GetDaughter(2);
3879  dgLabels[2] = trk2->GetLabel();
3880  pdgDg[0] = 211; pdgDg[1] = 321; pdgDg[2] = 211;
3881  signalPosition = 4;
3882  }
3883  else if (pdgabs == 511)
3884  {
3885  if (ndg != 2) return -1;
3886  dgLabels[0] = MatchCandidateToMonteCarlo(411, (AliAODRecoDecayHF3Prong*)candidate->GetDaughter(0), mcArray, B0toDPiLabelMatrix);
3887  AliAODTrack *trk1 = (AliAODTrack*)candidate->GetDaughter(1);
3888  dgLabels[1] = trk1->GetLabel();
3889  pdgDg[0] = 411; pdgDg[1] = 211; pdgDg[2] = -1;
3890  signalPosition = 5;
3891  }
3892  else
3893  {
3894  std::cout << "Wrong pdg supplied for function to match candidate to monte carlo signal." << std::endl;
3895  return -1;
3896  }
3897  if (dgLabels[0] == -1) return -1;
3898  if (dgLabels[1] == -1) return -1;
3899 
3900  Int_t labMom[3] = {0, 0, 0};
3901  Int_t i, j, lab, labMother, pdgMother, pdgPart;
3902  AliAODMCParticle *part = 0;
3903  AliAODMCParticle *mother = 0;
3904  Double_t pxSumDgs = 0., pySumDgs = 0., pzSumDgs = 0.;
3905  Bool_t pdgUsed[3] = {kFALSE, kFALSE, kFALSE};
3906 
3907  // loop on daughter labels
3908  for (i = 0; i < ndg; i++)
3909  {
3910  labMom[i] = -1;
3911  lab = TMath::Abs(dgLabels[i]);
3912  if (lab < 0)
3913  {
3914  printf("daughter with negative label %d\n", lab);
3915  return -1;
3916  }
3917  part = (AliAODMCParticle*)mcArray->At(lab);
3918  if (!part)
3919  {
3920  printf("no MC particle\n");
3921  return -1;
3922  }
3923 
3924  // check the PDG of the daughter
3925  pdgPart = TMath::Abs(part->GetPdgCode());
3926  for (j = 0; j < ndg; j++)
3927  {
3928  if (!pdgUsed[j] && pdgPart == pdgDg[j])
3929  {
3930  pdgUsed[j] = kTRUE;
3931  break;
3932  }
3933  }
3934 
3935 
3936  mother = part;
3937  while (mother->GetMother() >= 0)
3938  {
3939  labMother = mother->GetMother();
3940  mother = (AliAODMCParticle*)mcArray->At(labMother);
3941  if (!mother)
3942  {
3943  printf("no MC mother particle\n");
3944  break;
3945  }
3946  pdgMother = TMath::Abs(mother->GetPdgCode());
3947  if (pdgMother == pdgabs)
3948  {
3949  labMom[i] = labMother;
3950  // keep sum of daughters' momenta, to check for mom conservation
3951  pxSumDgs += part->Px();
3952  pySumDgs += part->Py();
3953  pzSumDgs += part->Pz();
3954  break;
3955  }
3956  else break;
3957  }
3958  if (labMom[i] == -1) return -1; // mother PDG not ok for this daughter
3959  } // end loop on daughters
3960 
3961 
3962  // check if the candidate is signal
3963  labMother = labMom[0];
3964  // all labels have to be the same and !=-1
3965  for (i = 0; i < ndg; i++)
3966  {
3967  if (labMom[i] == -1) return -1;
3968  if (labMom[i] != labMother) return -1;
3969  }
3970 
3971  // check that all daughter PDGs are matched
3972  for (i = 0; i < ndg; i++)
3973  {
3974  if (pdgUsed[i] == kFALSE) return -1;
3975  }
3976 
3977  // Check for mom conservation
3978  mother = (AliAODMCParticle*)mcArray->At(labMother);
3979  Double_t pxMother = mother->Px();
3980  Double_t pyMother = mother->Py();
3981  Double_t pzMother = mother->Pz();
3982 
3983 
3984  // check the number of daughters (we are not looking at resonant decay)
3985  if (pdgabs == 411 && mother->GetNDaughters() != 3) return -1;
3986  if (pdgabs == 511 && mother->GetNDaughters() != 2) return -1;
3987 
3988  // if momentum conservation is not within 0.5%, show warning. This can be due to large propagation distance through magnetic field.
3989  if ((TMath::Abs(pxMother - pxSumDgs) / (TMath::Abs(pxMother) + 1.e-13)) > 0.005 ||
3990  (TMath::Abs(pyMother - pySumDgs) / (TMath::Abs(pyMother) + 1.e-13)) > 0.005 ||
3991  (TMath::Abs(pzMother - pzSumDgs) / (TMath::Abs(pzMother) + 1.e-13)) > 0.005)
3992  {
3993  std::cout << std::endl << " Momentum difference for decay pdgabs = " << pdgabs << "daughters = " << mother->GetNDaughters() << std::endl;
3994  std::cout << "pxMother = " << pxMother << "pyMother = " << pyMother << "pzMother = " << pzMother << std::endl;
3995  std::cout << "pxSumDgs = " << pxSumDgs << "pySumDgs = " << pySumDgs << "pzSumDgs = " << pzSumDgs << std::endl;
3996  }
3997 
3998  // Check if label matches a signal label
3999  if (bCheckLabel)
4000  {
4001  Int_t bIsSignal = kFALSE;
4002  TMatrix &particleMatrix = *B0toDPiLabelMatrix;
4003  for (Int_t k = 0; k < B0toDPiLabelMatrix->GetNrows(); ++k)
4004  {
4005  if (labMother == (Int_t)particleMatrix(k, signalPosition))
4006  {
4007  bIsSignal = kTRUE;
4008  break;
4009  }
4010  }
4011  if (!bIsSignal) return -1;
4012  }
4013 
4014  return labMother;
4015 }
4016 //-------------------------------------------------------------------------------------
4017 Int_t AliAnalysisTaskSEB0toDPi::IsTrackInjected(AliAODTrack *part, AliAODMCHeader *header, TClonesArray *arrayMC) {
4018 
4020 
4021  Int_t lab = part->GetLabel();
4022  if (lab < 0) {delete ggg; ggg = nullptr; return 1;} //
4023  TString nameGen = ggg->GetGenerator(lab, header);
4024  TString empty = "";
4025  Int_t countControl = 0;
4026  while (nameGen.IsWhitespace()) {
4027  AliAODMCParticle *mcpart = (AliAODMCParticle*)arrayMC->At(lab);
4028  if (!mcpart) {
4029  printf("AliVertexingHFUtils::IsTrackInjected - BREAK: No valid AliAODMCParticle at label %i\n", lab);
4030  break;
4031  }
4032  Int_t mother = mcpart->GetMother();
4033  if (mother < 0) {
4034  // printf("AliVertexingHFUtils::IsTrackInjected - BREAK: Reached primary particle without valid mother\n");
4035  break;
4036  }
4037  lab = mother;
4038  nameGen = ggg->GetGenerator(mother, header);
4039  countControl++;
4040  if (countControl >= 10) { // 10 = arbitrary number; protection from infinite loops
4041  printf("AliVertexingHFUtils::IsTrackInjected - BREAK: Protection from infinite loop active\n");
4042  break;
4043  }
4044  }
4045  if (nameGen.IsWhitespace() || nameGen.Contains("ijing")) {delete ggg; ggg = nullptr; return 0;}
4046 
4047  delete ggg; ggg = nullptr;
4048  return 1;
4049 }
4050 //-------------------------------------------------------------------------------------
4051 Bool_t AliAnalysisTaskSEB0toDPi::IsCandidateInjected(AliAODRecoDecayHF2Prong *selectedB0, AliAODMCHeader *header, TClonesArray *arrayMC) {
4052 
4053 
4054  AliAODRecoDecayHF3Prong* selectedDPlus = (AliAODRecoDecayHF3Prong*)selectedB0->GetDaughter(0);
4055  AliAODTrack* selectedB0Pion = (AliAODTrack*)selectedB0->GetDaughter(1);
4056 
4057  AliAODTrack* selectedDPlusFirstDaughter = (AliAODTrack*)selectedDPlus->GetDaughter(0);
4058  AliAODTrack* selectedDPlusSecondDaughter = (AliAODTrack*)selectedDPlus->GetDaughter(1);
4059  AliAODTrack* selectedDPlusThirdDaughter = (AliAODTrack*)selectedDPlus->GetDaughter(2);
4060 
4061  if (IsTrackInjected(selectedB0Pion, header, arrayMC)) return kTRUE;
4062  if (IsTrackInjected(selectedDPlusFirstDaughter, header, arrayMC)) return kTRUE;
4063  if (IsTrackInjected(selectedDPlusSecondDaughter, header, arrayMC)) return kTRUE;
4064  if (IsTrackInjected(selectedDPlusThirdDaughter, header, arrayMC)) return kTRUE;
4065 
4066  return kFALSE;
4067 }
4068 //-------------------------------------------------------------------------------------
4069 void AliAnalysisTaskSEB0toDPi::CutOptimizationLoop(Int_t variable, Int_t nVariables, Int_t nCuts, Int_t ptBin, Int_t fillNumber, Bool_t isDesiredCandidate, Int_t nSigmaBin) {
4070 
4071  for (Int_t iCut = 0; iCut < nCuts; ++iCut)
4072  {
4073  Int_t cutVariable = fCuts->GetCutIndexForCutOptimization(variable);
4074  Bool_t isUpperCut = fCuts->GetIsUpperCutForCutOptimization(variable);
4075  Float_t cutValue = fCuts->GetCutForCutOptimization(iCut, variable, ptBin);
4076  if (fCutVariableValueArray[cutVariable] > cutValue && isUpperCut == kTRUE) continue;
4077  if (fCutVariableValueArray[cutVariable] < cutValue && isUpperCut == kFALSE) continue;
4078 
4079  Int_t fill = iCut * TMath::Power(nCuts, variable) + fillNumber;
4080  if ( (variable + 1) == nVariables)
4081  {
4082  if (isDesiredCandidate) ((TH2F*)(fResultsHistogramArray2D[0][ptBin]))->Fill(fill, nSigmaBin);
4083  if (!isDesiredCandidate) ((TH2F*)(fResultsHistogramArray2D[1][ptBin]))->Fill(fill, nSigmaBin);
4084  }
4085  else {CutOptimizationLoop(variable + 1, nVariables, nCuts, ptBin, fill, isDesiredCandidate, nSigmaBin);}
4086  }
4087  return;
4088 }
4089 //-------------------------------------------------------------------------------------
4091 
4092  if (!candidateB0) {
4093  std::cout << "candidateB0 null" << std::endl;
4094  return;
4095  }
4096 
4097  AliAODRecoDecayHF3Prong* candidateDPlus = (AliAODRecoDecayHF3Prong*)candidateB0->GetDaughter(0);
4098  if (!candidateDPlus) {
4099  std::cout << "candidateDPlus null" << std::endl;
4100  return;
4101  }
4102 
4103  AliAODTrack *candidateB0Pion = (AliAODTrack*)candidateB0->GetDaughter(1);
4104  if (!candidateB0Pion) {
4105  std::cout << "candidateB0Pion null" << std::endl;
4106  return;
4107  }
4108 
4109  AliAODTrack *candidateFirstDaughter = (AliAODTrack*)candidateDPlus->GetDaughter(0);
4110  if (!candidateFirstDaughter) {
4111  std::cout << "candidatePion null" << std::endl;
4112  return;
4113  }
4114 
4115  AliAODTrack *candidateSecondDaughter = (AliAODTrack*)candidateDPlus->GetDaughter(1);
4116  if (!candidateSecondDaughter) {
4117  std::cout << "candidateKaon null" << std::endl;
4118  return;
4119  }
4120 
4121  AliAODTrack *candidateThirdDaughter = (AliAODTrack*)candidateDPlus->GetDaughter(2);
4122  if (!candidateSecondDaughter) {
4123  std::cout << "candidatePion null" << std::endl;
4124  return;
4125  }
4126 
4127  AliAODVertex * vertexB0 = candidateB0->GetSecondaryVtx();
4128  if (!vertexB0) {
4129  std::cout << "vertexB0 null" << std::endl;
4130  return;
4131  }
4132 
4133  AliAODVertex * vertexDPlus = candidateDPlus->GetSecondaryVtx();
4134  if (!vertexDPlus) {
4135  std::cout << "vertexDPlus null" << std::endl;
4136  return;
4137  }
4138 
4139  AliAODVertex * primaryVertex = aod->GetPrimaryVertex();
4140  if (!primaryVertex) {
4141  std::cout << "primaryVertex null" << std::endl;
4142  return;
4143  }
4144 
4145  //get the magnetic field
4146  Double_t bz = (Double_t)aod->GetMagneticField();
4147 
4148 
4149  // save DPlus variable information
4150  if (kTRUE)
4151  {
4152  // DPlusmass
4153  Double_t mDPlusPDG = TDatabasePDG::Instance()->GetParticle(411)->Mass();
4154  Double_t mPionPDG = TDatabasePDG::Instance()->GetParticle(211)->Mass();
4155 
4156  // DPlus window - invariant mass
4157  UInt_t prongs[3];
4158  prongs[0] = 211;
4159  prongs[1] = 321;
4160  prongs[2] = 211;
4161 
4162  // delta mass PDG
4163  Double_t deltaPDG = mDPlusPDG - 2 * mPionPDG;
4164 
4165  Double_t invMassDPlus = candidateDPlus->InvMass(3, prongs);
4166  Double_t invMassDifference = TMath::Abs(mDPlusPDG - invMassDPlus);
4167  Double_t eKaon1 = candidateDPlus->EProng(1, 321);
4168  Double_t ePion2 = candidateDPlus->EProng(2, 211);
4169  Double_t eSum = eKaon1 + ePion2;
4170  Double_t pxPions = (candidateDPlus->PxProng(1) + candidateDPlus->PxProng(2)) * (candidateDPlus->PxProng(1) + candidateDPlus->PxProng(2));
4171  Double_t pyPions = (candidateDPlus->PyProng(1) + candidateDPlus->PyProng(2)) * (candidateDPlus->PyProng(1) + candidateDPlus->PyProng(2));
4172  Double_t pzPions = (candidateDPlus->PzProng(1) + candidateDPlus->PzProng(2)) * (candidateDPlus->PzProng(1) + candidateDPlus->PzProng(2));
4173  Double_t pSum = pxPions + pyPions + pzPions;
4174  Double_t invMassPions = TMath::Sqrt(eSum * eSum - pSum);
4175  Double_t invMassDelta = invMassDPlus - invMassPions;
4176  Double_t invMassDeltaDifference = TMath::Abs(deltaPDG - invMassDelta);
4177 
4178  Double_t pointingAngle = candidateDPlus->CosPointingAngle();
4179  Double_t dcaMother12 = candidateDPlus->GetDCA(0);
4180  Double_t dcaMother13 = candidateDPlus->GetDCA(1);
4181  Double_t dcaMother23 = candidateDPlus->GetDCA(2);
4182  Double_t ptMother = candidateDPlus->Pt();
4183  Double_t momentumMother = candidateDPlus->P();
4184  Double_t ptKaon = candidateSecondDaughter->Pt();
4185  Double_t ptFirstPion = candidateFirstDaughter->Pt();
4186  Double_t ptSecondPion = candidateThirdDaughter->Pt();
4187 
4188  AliExternalTrackParam motherTrack;
4189  motherTrack.CopyFromVTrack(candidateDPlus);
4190  Double_t d0z0[2], covd0z0[3], d0[2];
4191  motherTrack.PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
4192  d0[0] = d0z0[0];
4193  Double_t d0Mother = TMath::Abs(d0[0]);
4194  Double_t d0firstTrack = TMath::Abs(candidateDPlus->Getd0Prong(0));
4195  Double_t d0secondTrack = TMath::Abs(candidateDPlus->Getd0Prong(1));
4196  Double_t d0thirdTrack = TMath::Abs(candidateDPlus->Getd0Prong(2));
4197 
4198  Double_t impactProduct123 = candidateDPlus->Getd0Prong(0) * candidateDPlus->Getd0Prong(1) * candidateDPlus->Getd0Prong(2);
4199  Double_t impactProduct12 = candidateDPlus->Getd0Prong(0) * candidateDPlus->Getd0Prong(1);
4200  Double_t impactProduct13 = candidateDPlus->Getd0Prong(0) * candidateDPlus->Getd0Prong(2);
4201  Double_t impactProduct23 = candidateDPlus->Getd0Prong(1) * candidateDPlus->Getd0Prong(2);
4202  Double_t impactProductXY = TMath::Abs(candidateDPlus->ImpParXY());
4203 
4204  Double_t angleMotherFirstDaughter = (candidateDPlus->Px() * candidateFirstDaughter->Px() + candidateDPlus->Py() * candidateFirstDaughter->Py() + candidateDPlus->Pz() * candidateFirstDaughter->Pz()) / (candidateDPlus->P() * candidateFirstDaughter->P());
4205  Double_t angleMotherSecondDaughter = (candidateDPlus->Px() * candidateSecondDaughter->Px() + candidateDPlus->Py() * candidateSecondDaughter->Py() + candidateDPlus->Pz() * candidateSecondDaughter->Pz()) / (candidateDPlus->P() * candidateSecondDaughter->P());
4206  Double_t angleMotherThirdDaughter = (candidateDPlus->Px() * candidateThirdDaughter->Px() + candidateDPlus->Py() * candidateThirdDaughter->Py() + candidateDPlus->Pz() * candidateThirdDaughter->Pz()) / (candidateDPlus->P() * candidateThirdDaughter->P());
4207 
4208  Double_t smallestAngleMotherDaughter = 0.0;
4209  Double_t largestAngleMotherDaughter = 0.0;
4210 
4211  if (angleMotherFirstDaughter > angleMotherSecondDaughter) {smallestAngleMotherDaughter = angleMotherSecondDaughter;} else {smallestAngleMotherDaughter = angleMotherFirstDaughter;}
4212  if (angleMotherThirdDaughter < smallestAngleMotherDaughter) smallestAngleMotherDaughter = angleMotherThirdDaughter;
4213  if (angleMotherFirstDaughter > angleMotherSecondDaughter) {largestAngleMotherDaughter = angleMotherFirstDaughter;} else {largestAngleMotherDaughter = angleMotherSecondDaughter;}
4214  if (angleMotherThirdDaughter > largestAngleMotherDaughter) largestAngleMotherDaughter = angleMotherThirdDaughter;
4215 
4216  Double_t vertexDistance = vertexDPlus->DistanceToVertex(primaryVertex);
4217  Double_t normDecayLength = candidateDPlus->NormalizedDecayLength();
4218  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(411)->Mass();
4219  Double_t pseudoProperDecayLength = ((vertexDPlus->GetX() - primaryVertex->GetX()) * candidateDPlus->Px() / TMath::Abs(candidateDPlus->Pt())) + ((vertexDPlus->GetY() - primaryVertex->GetY()) * candidateDPlus->Py() / TMath::Abs(candidateDPlus->Pt()));
4220  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother / ptMother;
4221  Double_t decayTime = vertexDistance / (299792458 * TMath::Sqrt(1 / ((pdgMassMother * pdgMassMother / (momentumMother * momentumMother)) + 1)));
4222 
4223  Double_t phi = candidateDPlus->Phi();
4224  Double_t theta = candidateDPlus->Theta();
4225  Double_t covMatrix[21];
4226  candidateDPlus->GetCovarianceXYZPxPyPz(covMatrix);
4227 
4228  Double_t cp = TMath::Cos(phi);
4229  Double_t sp = TMath::Sin(phi);
4230  Double_t ct = TMath::Cos(theta);
4231  Double_t st = TMath::Sin(theta);
4232 
4233  Double_t errorMomentum = covMatrix[9] * cp * cp * ct * ct // GetCovPxPx
4234  + covMatrix[13] * 2.*cp * sp * ct * ct // GetCovPxPy
4235  + covMatrix[18] * 2.*cp * ct * st // GetCovPxPz
4236  + covMatrix[14] * sp * sp * ct * ct // GetCovPyPy
4237  + covMatrix[19] * 2.*sp * ct * st // GetCovPyPz
4238  + covMatrix[20] * st * st; // GetCovPzPz
4239  Double_t normalizedDecayTime = candidateDPlus->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1 / ((pdgMassMother * pdgMassMother * errorMomentum * errorMomentum / (momentumMother * momentumMother)) + 1)));
4240 
4241  Double_t cosPointingAngleXY = candidateDPlus->CosPointingAngleXY();
4242  Double_t distanceXYToVertex = vertexDPlus->DistanceXYToVertex(primaryVertex);
4243  Double_t normalizedDecayLengthXY = candidateDPlus->NormalizedDecayLengthXY();
4244  Double_t chi2Vertex = vertexDPlus->GetChi2perNDF();
4245 
4246 
4247  Double_t Normalizedd0DPlusfirstdaughter = TMath::Abs(candidateDPlus->Getd0Prong(0) / candidateDPlus->Getd0errProng(0));
4248  Double_t Normalizedd0DPlusseconddaughter = TMath::Abs(candidateDPlus->Getd0Prong(1) / candidateDPlus->Getd0errProng(1));
4249  Double_t Normalizedd0DPlusthirddaughter = TMath::Abs(candidateDPlus->Getd0Prong(2) / candidateDPlus->Getd0errProng(2));
4250  Double_t Normalizedd0DPlus = TMath::Abs(candidateB0->Getd0Prong(1) / candidateB0->Getd0errProng(1));
4251  Double_t NormalizedimpactproductDPlus = (candidateDPlus->Getd0Prong(0) / candidateDPlus->Getd0errProng(0)) * (candidateDPlus->Getd0Prong(1) / candidateDPlus->Getd0errProng(1)) * (candidateDPlus->Getd0Prong(2) / candidateDPlus->Getd0errProng(2));
4252 
4253  Double_t Dist12 = candidateDPlus->GetDist12toPrim();
4254  Double_t Dist23 = candidateDPlus->GetDist23toPrim();
4255  Double_t SigmaVertex = candidateDPlus->GetSigmaVert();
4256 
4257  // We apply the cuts
4258  Int_t nCutIndex = 0;
4259 
4260  // "inv. mass width [GeV]" --------------------------------------------
4261  nCutIndex = 0;
4262  fCutVariableValueArray[nCutIndex] = invMassDifference;
4263  //---------------------------------------------------------------------
4264 
4265  // "delta mass width [GeV]" -------------------------------------------
4266  nCutIndex = 1;
4267  fCutVariableValueArray[nCutIndex] = invMassDeltaDifference;
4268  //---------------------------------------------------------------------
4269 
4270  // "pointing angle [Cos(theta)]" --------------------------------------
4271  nCutIndex = 2;
4272  fCutVariableValueArray[nCutIndex] = pointingAngle;
4273  //---------------------------------------------------------------------
4274 
4275  // "pointing angle XY" ----------------------------------------------------
4276  nCutIndex = 3;
4277  fCutVariableValueArray[nCutIndex] = cosPointingAngleXY;
4278  //---------------------------------------------------------------------
4279 
4280  // "dca12 (cm)" ---------------------------------------------------------
4281  nCutIndex = 4;
4282  fCutVariableValueArray[nCutIndex] = dcaMother12;
4283  //---------------------------------------------------------------------
4284 
4285  // "dca13 (cm)" ---------------------------------------------------------
4286  nCutIndex = 5;
4287  fCutVariableValueArray[nCutIndex] = dcaMother13;
4288  //---------------------------------------------------------------------
4289 
4290  // "dca23 (cm)" ---------------------------------------------------------
4291  nCutIndex = 6;
4292  fCutVariableValueArray[nCutIndex] = dcaMother23;
4293  //---------------------------------------------------------------------
4294 
4295  // "Pt DPlus [GeV/c]" ----------------------------------------------------
4296  nCutIndex = 7;
4297  fCutVariableValueArray[nCutIndex] = ptMother;
4298  //---------------------------------------------------------------------
4299 
4300  // "Pt Kaon [GeV/c]" -------------------------------------------------
4301  nCutIndex = 8;
4302  fCutVariableValueArray[nCutIndex] = ptKaon;
4303  //---------------------------------------------------------------------
4304 
4305  // "Pt First Pion [GeV/c]" --------------------------------------------------
4306  nCutIndex = 9;
4307  fCutVariableValueArray[nCutIndex] = ptFirstPion;
4308  //---------------------------------------------------------------------
4309 
4310  // "Pt Second Pion [GeV/c]" --------------------------------------------------
4311  nCutIndex = 10;
4312  fCutVariableValueArray[nCutIndex] = ptSecondPion;
4313  //---------------------------------------------------------------------
4314 
4315  // "d0 DPlus (cm)" -------------------------------------------------------
4316  nCutIndex = 11;
4317  fCutVariableValueArray[nCutIndex] = d0Mother;
4318  //---------------------------------------------------------------------
4319 
4320  // "d0 Kaon (cm)"-----------------------------------------------------
4321  nCutIndex = 12;
4322  fCutVariableValueArray[nCutIndex] = d0firstTrack;
4323  //---------------------------------------------------------------------
4324 
4325  // "d0 First Pion (cm)" -----------------------------------------------------
4326  nCutIndex = 13;
4327  fCutVariableValueArray[nCutIndex] = d0secondTrack;
4328  //---------------------------------------------------------------------
4329 
4330  // "d0 Second Pion (cm)" -----------------------------------------------------
4331  nCutIndex = 14;
4332  fCutVariableValueArray[nCutIndex] = d0thirdTrack;
4333  //---------------------------------------------------------------------
4334 
4335  // "d0d0d0 [cm^3]" ------------------------------------------------------
4336  nCutIndex = 15;
4337  fCutVariableValueArray[nCutIndex] = impactProduct123;
4338  //---------------------------------------------------------------------
4339 
4340  // "d0d0 [cm^2]" ------------------------------------------------------
4341  nCutIndex = 16;
4342  fCutVariableValueArray[nCutIndex] = impactProduct12;
4343  //---------------------------------------------------------------------
4344 
4345  // "d0d0 [cm^2]" ------------------------------------------------------
4346  nCutIndex = 17;
4347  fCutVariableValueArray[nCutIndex] = impactProduct13;
4348  //---------------------------------------------------------------------
4349 
4350  // "d0d0 [cm^2]" ------------------------------------------------------
4351  nCutIndex = 18;
4352  fCutVariableValueArray[nCutIndex] = impactProduct23;
4353  //---------------------------------------------------------------------
4354 
4355  // "d0 XY [cm^2]" ---------------------------------------------------
4356  nCutIndex = 19;
4357  fCutVariableValueArray[nCutIndex] = impactProductXY;
4358  //---------------------------------------------------------------------
4359 
4360  // "smallestAngleMotherDaughter" -------------------------------------
4361  nCutIndex = 20;
4362  fCutVariableValueArray[nCutIndex] = smallestAngleMotherDaughter;
4363  //---------------------------------------------------------------------
4364 
4365  // "largestAngleMotherDaughter" ---------------------------------
4366  nCutIndex = 21;
4367  fCutVariableValueArray[nCutIndex] = largestAngleMotherDaughter;
4368  //---------------------------------------------------------------------
4369 
4370  // "angle difference" --------------------------------
4371  nCutIndex = 22;
4372  fCutVariableValueArray[nCutIndex] = largestAngleMotherDaughter - smallestAngleMotherDaughter;
4373  //---------------------------------------------------------------------
4374 
4375  // "vertexDistance" ---------------------------------------------------
4376  nCutIndex = 23;
4377  fCutVariableValueArray[nCutIndex] = vertexDistance;
4378  //---------------------------------------------------------------------
4379 
4380  // "vertex distance XY" ----------------------------------------------------
4381  nCutIndex = 24;
4382  fCutVariableValueArray[nCutIndex] = distanceXYToVertex;
4383  //---------------------------------------------------------------------
4384 
4385  // "pseudoProperDecayTime" --------------------------------------------
4386  nCutIndex = 25;
4387  fCutVariableValueArray[nCutIndex] = pseudoProperDecayTime;
4388  //---------------------------------------------------------------------
4389 
4390  // "DecayTime" --------------------------------------------------------
4391  nCutIndex = 26;
4392  fCutVariableValueArray[nCutIndex] = decayTime;
4393  //---------------------------------------------------------------------
4394 
4395  // "normalizedDecayTime" ----------------------------------------------------
4396  nCutIndex = 27;
4397  fCutVariableValueArray[nCutIndex] = normalizedDecayTime;
4398  //---------------------------------------------------------------------
4399 
4400  // "normDecayLength" --------------------------------------------------
4401  nCutIndex = 28;
4402  fCutVariableValueArray[nCutIndex] = normDecayLength;
4403  //---------------------------------------------------------------------
4404 
4405  // "normalized decay length XY" ----------------------------------------------------
4406  nCutIndex = 29;
4407  fCutVariableValueArray[nCutIndex] = normalizedDecayLengthXY;
4408  //---------------------------------------------------------------------
4409 
4410  // "chi squared per NDF" ----------------------------------------------------
4411  nCutIndex = 30;
4412  fCutVariableValueArray[nCutIndex] = chi2Vertex;
4413  //---------------------------------------------------------------------
4414 
4415  // "Normalizedd0DPlusfirstdaughter" ----------------------------------------------------
4416  nCutIndex = 31;
4417  fCutVariableValueArray[nCutIndex] = Normalizedd0DPlusfirstdaughter;
4418  //---------------------------------------------------------------------
4419 
4420  // "Normalizedd0DPlusseconddaughter" ----------------------------------------------------
4421  nCutIndex = 32;
4422  fCutVariableValueArray[nCutIndex] = Normalizedd0DPlusseconddaughter;
4423  //---------------------------------------------------------------------
4424 
4425  // "Normalizedd0DPlusthirddaughter" ----------------------------------------------------
4426  nCutIndex = 33;
4427  fCutVariableValueArray[nCutIndex] = Normalizedd0DPlusthirddaughter;
4428  //---------------------------------------------------------------------
4429 
4430  // "Normalizedd0DPlus" ----------------------------------------------------
4431  nCutIndex = 34;
4432  fCutVariableValueArray[nCutIndex] = Normalizedd0DPlus;
4433  //---------------------------------------------------------------------
4434 
4435  // "NormalizedimpactproductDPlus" ----------------------------------------------------
4436  nCutIndex = 35;
4437  fCutVariableValueArray[nCutIndex] = NormalizedimpactproductDPlus;
4438  //---------------------------------------------------------------------
4439 
4440  // "Dist12" ----------------------------------------------------
4441  nCutIndex = 36;
4442  fCutVariableValueArray[nCutIndex] = Dist12;
4443  //---------------------------------------------------------------------
4444 
4445  // "Dist23" ----------------------------------------------------
4446  nCutIndex = 37;
4447  fCutVariableValueArray[nCutIndex] = Dist23;
4448  //---------------------------------------------------------------------
4449 
4450  // "Sigma vertex" ----------------------------------------------------
4451  nCutIndex = 38;
4452  fCutVariableValueArray[nCutIndex] = SigmaVertex;
4453  //---------------------------------------------------------------------
4454 
4455 
4456 
4457  AliAODRecoDecay* candidateDPlustoB0 = (AliAODRecoDecay*)candidateDPlus;
4458  AliExternalTrackParam firstDaughterDPlusTrack;
4459  AliExternalTrackParam secondDaughterDPlusTrack;
4460  AliExternalTrackParam thirdDaughterDPlusTrack;
4461 
4462  Double_t d0z0DSVert[2], covd0z0DSVert[3], d0DSVert[3];
4463 
4464  firstDaughterDPlusTrack.CopyFromVTrack(candidateFirstDaughter);
4465  firstDaughterDPlusTrack.PropagateToDCA(vertexB0, bz, 100., d0z0DSVert, covd0z0DSVert);
4466  d0DSVert[0] = d0z0DSVert[0];
4467 
4468  secondDaughterDPlusTrack.CopyFromVTrack(candidateSecondDaughter);
4469  secondDaughterDPlusTrack.PropagateToDCA(vertexB0, bz, 100., d0z0DSVert, covd0z0DSVert);
4470  d0DSVert[1] = d0z0DSVert[0];
4471 
4472  thirdDaughterDPlusTrack.CopyFromVTrack(candidateThirdDaughter);
4473  thirdDaughterDPlusTrack.PropagateToDCA(vertexB0, bz, 100., d0z0DSVert, covd0z0DSVert);
4474  d0DSVert[2] = d0z0DSVert[0];
4475 
4476  AliExternalTrackParam DPlusTrack;
4477  DPlusTrack.CopyFromVTrack(candidateDPlus);
4478  Double_t d0z0D0DSVert[2], covd0z0D0DSVert[3];
4479  motherTrack.PropagateToDCA(vertexB0, bz, 100., d0z0D0DSVert, covd0z0D0DSVert);
4480  Double_t d0d0DSVert = TMath::Abs(d0z0D0DSVert[0]);
4481 
4482  Double_t impactProductToB0 = d0DSVert[0] * d0DSVert[1] * d0DSVert[2];
4483  Double_t impactProductXYToB0 = candidateDPlustoB0->ImpParXY(vertexB0);
4484 
4485  Double_t pointingAngleToB0 = candidateDPlustoB0->CosPointingAngle(vertexB0);
4486  Double_t d0FirstDaughterToB0 = TMath::Abs(d0DSVert[0]);
4487  Double_t d0SecondDaughterToB0 = TMath::Abs(d0DSVert[1]);
4488  Double_t d0ThirdDaughterToB0 = TMath::Abs(d0DSVert[2]);
4489  Double_t normDecayLengthToB0 = candidateDPlustoB0->NormalizedDecayLength(vertexB0);
4490 
4491  Double_t pseudoProperDecayLengthDSVert = ((vertexDPlus->GetX() - vertexB0->GetX()) * candidateDPlus->Px() / TMath::Abs(candidateDPlus->Pt())) + ((vertexDPlus->GetY() - vertexB0->GetY()) * candidateDPlus->Py() / TMath::Abs(candidateDPlus->Pt()));
4492  Double_t pseudoProperDecayTimeToB0 = pseudoProperDecayLengthDSVert * pdgMassMother / ptMother;
4493  Double_t DecayTimeToB0 = vertexDistance / (299792458 * TMath::Sqrt(1 / ((pdgMassMother * pdgMassMother / (momentumMother * momentumMother)) + 1)));
4494 
4495  Double_t phiDSVert = candidateDPlus->Phi();
4496  Double_t thetaDSVert = candidateDPlus->Theta();
4497  Double_t covMatrixDSVert[21];
4498  candidateDPlus->GetCovarianceXYZPxPyPz(covMatrixDSVert);
4499 
4500  cp = TMath::Cos(phiDSVert);
4501  sp = TMath::Sin(phiDSVert);
4502  ct = TMath::Cos(thetaDSVert);
4503  st = TMath::Sin(thetaDSVert);
4504 
4505  errorMomentum = covMatrix[9] * cp * cp * ct * ct // GetCovPxPx
4506  + covMatrix[13] * 2.*cp * sp * ct * ct // GetCovPxPy
4507  + covMatrix[18] * 2.*cp * ct * st // GetCovPxPz
4508  + covMatrix[14] * sp * sp * ct * ct // GetCovPyPy
4509  + covMatrix[19] * 2.*sp * ct * st // GetCovPyPz
4510  + covMatrix[20] * st * st; // GetCovPzPz
4511  Double_t normalizedDecayTimeToB0 = candidateDPlustoB0->NormalizedDecayLength(vertexB0) / (299792458 * TMath::Sqrt(1 / ((pdgMassMother * pdgMassMother * errorMomentum * errorMomentum / (momentumMother * momentumMother)) + 1)));
4512 
4513  // "pointingAngleToB0" ---------------------------------------------
4514  nCutIndex = 39;
4515  fCutVariableValueArray[nCutIndex] = pointingAngleToB0;
4516  //---------------------------------------------------------------------
4517 
4518  // "d0MotherToB0" --------------------------------------------------
4519  nCutIndex = 40;
4520  fCutVariableValueArray[nCutIndex] = d0d0DSVert;
4521  //---------------------------------------------------------------------
4522 
4523  // "d0FirstDaughterToB0" -------------------------------------------
4524  nCutIndex = 41;
4525  fCutVariableValueArray[nCutIndex] = d0FirstDaughterToB0;
4526  //---------------------------------------------------------------------
4527 
4528  // "d0SecondDaughterToB0" ------------------------------------------
4529  nCutIndex = 42;
4530  fCutVariableValueArray[nCutIndex] = d0SecondDaughterToB0;
4531  //---------------------------------------------------------------------
4532 
4533  // "d0ThirdDaughterToB0" ------------------------------------------
4534  nCutIndex = 43;
4535  fCutVariableValueArray[nCutIndex] = d0ThirdDaughterToB0;
4536  //---------------------------------------------------------------------
4537 
4538  // "impactProductToB0" ---------------------------------------------
4539  nCutIndex = 44;
4540  fCutVariableValueArray[nCutIndex] = impactProductToB0;
4541  //---------------------------------------------------------------------
4542 
4543  // "impactProductXYToB0" -------------------------------------------
4544  nCutIndex = 45;
4545  fCutVariableValueArray[nCutIndex] = impactProductXYToB0;
4546  //---------------------------------------------------------------------
4547 
4548  // "normDecayLengthToB0" -------------------------------------------
4549  nCutIndex = 46;
4550  fCutVariableValueArray[nCutIndex] = normDecayLengthToB0;
4551  //---------------------------------------------------------------------
4552 
4553  // "pseudoProperDecayTimeToB0" -------------------------------------
4554  nCutIndex = 47;
4555  fCutVariableValueArray[nCutIndex] = pseudoProperDecayTimeToB0;
4556  //---------------------------------------------------------------------
4557 
4558  // "DecayTimeToB0" -------------------------------------------------
4559  nCutIndex = 48;
4560  fCutVariableValueArray[nCutIndex] = DecayTimeToB0;
4561  //---------------------------------------------------------------------
4562 
4563  // "normalizedDecayTimeToB0" ---------------------------------------------
4564  nCutIndex = 49;
4565  fCutVariableValueArray[nCutIndex] = normalizedDecayTimeToB0;
4566  //---------------------------------------------------------------------
4567  }
4568 
4569  // save B0 variable information
4570  if (kTRUE)
4571  {
4572  // We obtain the variable values in the section below
4573  // DPlusMass and B0mass
4574  Double_t mDPlusPDG = TDatabasePDG::Instance()->GetParticle(411)->Mass();
4575  Double_t mB0PDG = TDatabasePDG::Instance()->GetParticle(511)->Mass();
4576 
4577  // delta mass PDG
4578  Double_t deltaPDG = mB0PDG - mDPlusPDG;
4579 
4580  // Half width B0 mass
4581  UInt_t prongs[2];
4582  prongs[0] = 411; prongs[1] = 211;
4583  Double_t invMassB0 = candidateB0->InvMass(2, prongs);
4584  Double_t invMassDifference = TMath::Abs(mB0PDG - invMassB0);
4585  Double_t invMassDelta = TMath::Abs(deltaPDG - (DeltaInvMassB0Kpipipi(candidateB0)));
4586 
4587  Double_t pointingAngle = candidateB0->CosPointingAngle();
4588  Double_t dcaMother = candidateB0->GetDCA();
4589  Double_t ptMother = candidateB0->Pt();
4590  Double_t momentumMother = candidateB0->P();
4591  Double_t ptDPlus = candidateDPlus->Pt();
4592  Double_t ptPion = candidateB0Pion->Pt();
4593 
4594  AliExternalTrackParam motherTrack;
4595  motherTrack.CopyFromVTrack(candidateB0);
4596  Double_t d0z0[2], covd0z0[3], d0[2];
4597  motherTrack.PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
4598  d0[0] = d0z0[0];
4599  Double_t d0Mother = TMath::Abs(d0[0]);
4600  Double_t d0firstTrack = TMath::Abs(candidateB0->Getd0Prong(0));
4601  Double_t d0secondTrack = TMath::Abs(candidateB0->Getd0Prong(1));
4602 
4603  Double_t impactProduct = candidateB0->Getd0Prong(0) * candidateB0->Getd0Prong(1);
4604  Double_t impactProductXY = TMath::Abs(candidateB0->ImpParXY());
4605 
4606  Double_t angleMotherFirstDaughter = (candidateB0->Px() * candidateDPlus->Px() + candidateB0->Py() * candidateDPlus->Py() + candidateB0->Pz() * candidateDPlus->Pz()) / (candidateB0->P() * candidateDPlus->P());
4607  Double_t angleMotherSecondDaughter = (candidateB0->Px() * candidateB0Pion->Px() + candidateB0->Py() * candidateB0Pion->Py() + candidateB0->Pz() * candidateB0Pion->Pz()) / (candidateB0->P() * candidateB0Pion->P());
4608 
4609  Double_t angleBetweenBothDaughters = (candidateDPlus->Px() * candidateB0Pion->Px() + candidateDPlus->Py() * candidateB0Pion->Py() + candidateDPlus->Pz() * candidateB0Pion->Pz()) / (candidateDPlus->P() * candidateB0Pion->P());
4610 
4611  Double_t cosThetaStar = candidateB0->CosThetaStar(0, 511, 411, 211);
4612 
4613  Double_t vertexDistance = vertexB0->DistanceToVertex(primaryVertex);
4614  Double_t normDecayLength = candidateB0->NormalizedDecayLength();
4615  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(511)->Mass();
4616  Double_t pseudoProperDecayLength = ((vertexB0->GetX() - primaryVertex->GetX()) * candidateB0->Px() / TMath::Abs(candidateB0->Pt())) + ((vertexB0->GetY() - primaryVertex->GetY()) * candidateB0->Py() / TMath::Abs(candidateB0->Pt()));
4617  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother / ptMother;
4618  Double_t decayTime = vertexDistance / (299792458 * TMath::Sqrt(1 / ((pdgMassMother * pdgMassMother / (momentumMother * momentumMother)) + 1)));
4619 
4620  Double_t phi = candidateB0->Phi();
4621  Double_t theta = candidateB0->Theta();
4622  Double_t covMatrix[21];
4623  candidateB0->GetCovarianceXYZPxPyPz(covMatrix);
4624 
4625  Double_t cp = TMath::Cos(phi);
4626  Double_t sp = TMath::Sin(phi);
4627  Double_t ct = TMath::Cos(theta);
4628  Double_t st = TMath::Sin(theta);
4629 
4630  Double_t errorMomentum = covMatrix[9] * cp * cp * ct * ct // GetCovPxPx
4631  + covMatrix[13] * 2.*cp * sp * ct * ct // GetCovPxPy
4632  + covMatrix[18] * 2.*cp * ct * st // GetCovPxPz
4633  + covMatrix[14] * sp * sp * ct * ct // GetCovPyPy
4634  + covMatrix[19] * 2.*sp * ct * st // GetCovPyPz
4635  + covMatrix[20] * st * st; // GetCovPzPz
4636  Double_t normalizedDecayTime = candidateB0->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1 / ((pdgMassMother * pdgMassMother * errorMomentum * errorMomentum / (momentumMother * momentumMother)) + 1)));
4637 
4638  Double_t cosPointingAngleXY = candidateB0->CosPointingAngleXY();
4639  Double_t distanceXYToVertex = vertexB0->DistanceXYToVertex(primaryVertex);
4640  Double_t normalizedDecayLengthXY = candidateB0->NormalizedDecayLengthXY();
4641  Double_t chi2Vertex = vertexB0->GetChi2perNDF();
4642 
4643  Double_t Normalizedd0B0pion = TMath::Abs(candidateB0->Getd0Prong(1) / candidateB0->Getd0errProng(1));
4644  Double_t Normalizedd0B0 = TMath::Abs(d0[0] / TMath::Sqrt(covd0z0[0]));
4645  Double_t NormalizedimpactproductB0 = (candidateB0->Getd0Prong(0) / candidateB0->Getd0errProng(0)) * (candidateB0->Getd0Prong(1) / candidateB0->Getd0errProng(1));
4646 
4647 
4648  // We apply the cuts
4649  Int_t nCutIndex = 0;
4650 
4651  // "inv. mass width [GeV]" --------------------------------------------
4652  nCutIndex = 50;
4653  fCutVariableValueArray[nCutIndex] = invMassDifference;
4654  //---------------------------------------------------------------------
4655 
4656  // "delta mass width [GeV]" -------------------------------------------
4657  nCutIndex = 51;
4658  fCutVariableValueArray[nCutIndex] = invMassDelta;
4659  //---------------------------------------------------------------------
4660 
4661  // "pointing angle [Cos(theta)]" --------------------------------------
4662  nCutIndex = 52;
4663  fCutVariableValueArray[nCutIndex] = pointingAngle;
4664  //---------------------------------------------------------------------
4665 
4666  // "pointing angle XY" ----------------------------------------------------
4667  nCutIndex = 53;
4668  fCutVariableValueArray[nCutIndex] = cosPointingAngleXY;
4669  //---------------------------------------------------------------------
4670 
4671  // "dca12 (cm)" ---------------------------------------------------------
4672  nCutIndex = 54;
4673  fCutVariableValueArray[nCutIndex] = dcaMother;
4674  //---------------------------------------------------------------------
4675 
4676  // "Pt B0 [GeV/c]" ----------------------------------------------------
4677  nCutIndex = 55;
4678  fCutVariableValueArray[nCutIndex] = ptMother;
4679  //---------------------------------------------------------------------
4680 
4681  // "Pt DPlus [GeV/c]" -------------------------------------------------
4682  nCutIndex = 56;
4683  fCutVariableValueArray[nCutIndex] = ptDPlus;
4684  //---------------------------------------------------------------------
4685 
4686  // "Pt Pion [GeV/c]" --------------------------------------------------
4687  nCutIndex = 57;
4688  fCutVariableValueArray[nCutIndex] = ptPion;
4689  //---------------------------------------------------------------------
4690 
4691  // "d0 B0 (cm)" -------------------------------------------------------
4692  nCutIndex = 58;
4693  fCutVariableValueArray[nCutIndex] = d0Mother;
4694  //---------------------------------------------------------------------
4695 
4696  // "d0 DPlus (cm)"-----------------------------------------------------
4697  nCutIndex = 59;
4698  fCutVariableValueArray[nCutIndex] = d0firstTrack;
4699  //---------------------------------------------------------------------
4700 
4701  // "d0 First Pion (cm)" -----------------------------------------------------
4702  nCutIndex = 60;
4703  fCutVariableValueArray[nCutIndex] = d0secondTrack;
4704  //---------------------------------------------------------------------
4705 
4706  // "d0d0d0 [cm^2]" ------------------------------------------------------
4707  nCutIndex = 61;
4708  fCutVariableValueArray[nCutIndex] = impactProduct;
4709  //---------------------------------------------------------------------
4710 
4711  // "d0 XY [cm^2]" ---------------------------------------------------
4712  nCutIndex = 62;
4713  fCutVariableValueArray[nCutIndex] = impactProductXY;
4714  //---------------------------------------------------------------------
4715 
4716  // "angleMotherFirstDaughter" -------------------------------------
4717  nCutIndex = 63;
4718  fCutVariableValueArray[nCutIndex] = angleMotherFirstDaughter;
4719  //---------------------------------------------------------------------
4720 
4721  // "angleMotherSecondDaughter" ---------------------------------
4722  nCutIndex = 64;
4723  fCutVariableValueArray[nCutIndex] = angleMotherSecondDaughter;
4724  //---------------------------------------------------------------------
4725 
4726  // "angleBetweenBothDaughters" --------------------------------
4727  nCutIndex = 65;
4728  fCutVariableValueArray[nCutIndex] = angleBetweenBothDaughters;
4729  //---------------------------------------------------------------------
4730 
4731  // "cosThetaStar" --------------------------------
4732  nCutIndex = 66;
4733  fCutVariableValueArray[nCutIndex] = cosThetaStar;
4734  //---------------------------------------------------------------------
4735 
4736  // "vertexDistance" ---------------------------------------------------
4737  nCutIndex = 67;
4738  fCutVariableValueArray[nCutIndex] = vertexDistance;
4739  //---------------------------------------------------------------------
4740 
4741  // "vertex distance XY" ----------------------------------------------------
4742  nCutIndex = 68;
4743  fCutVariableValueArray[nCutIndex] = distanceXYToVertex;
4744  //---------------------------------------------------------------------
4745 
4746  // "pseudoProperDecayTime" --------------------------------------------
4747  nCutIndex = 69;
4748  fCutVariableValueArray[nCutIndex] = pseudoProperDecayTime;
4749  //---------------------------------------------------------------------
4750 
4751  // "DecayTime" --------------------------------------------------------
4752  nCutIndex = 70;
4753  fCutVariableValueArray[nCutIndex] = decayTime;
4754  //---------------------------------------------------------------------
4755 
4756  // "normalizedDecayTime" ----------------------------------------------------
4757  nCutIndex = 71;
4758  fCutVariableValueArray[nCutIndex] = normalizedDecayTime;
4759  //---------------------------------------------------------------------
4760 
4761  // "normDecayLength" --------------------------------------------------
4762  nCutIndex = 72;
4763  fCutVariableValueArray[nCutIndex] = normDecayLength;
4764  //---------------------------------------------------------------------
4765 
4766  // "normalized decay length XY" ----------------------------------------------------
4767  nCutIndex = 73;
4768  fCutVariableValueArray[nCutIndex] = normalizedDecayLengthXY;
4769  //---------------------------------------------------------------------
4770 
4771  // "chi squared per NDF" ----------------------------------------------------
4772  nCutIndex = 74;
4773  fCutVariableValueArray[nCutIndex] = chi2Vertex;
4774 
4775  // "Normalizedd0B0Pion" ----------------------------------------------------
4776  nCutIndex = 75;
4777  fCutVariableValueArray[nCutIndex] = Normalizedd0B0pion;
4778  //---------------------------------------------------------------------
4779 
4780  // "Normalizedd0B0" ----------------------------------------------------
4781  nCutIndex = 76;
4782  fCutVariableValueArray[nCutIndex] = Normalizedd0B0;
4783  //---------------------------------------------------------------------
4784 
4785  // "NormalizedimpactproductB0" ----------------------------------------------------
4786  nCutIndex = 77;
4787  fCutVariableValueArray[nCutIndex] = NormalizedimpactproductB0;
4788  //---------------------------------------------------------------------
4789 
4790  }
4791  return;
4792 }
4793 
Int_t charge
Double_t NormalizedDecayLengthXY() const
void B0toDPiSignalTracksInMC(TClonesArray *mcTrackArray, AliAODEvent *aodevent, TMatrix *B0toDPlusPiLabelMatrix, TList *listout)
Double_t NormalizedDecayLength() const
void ThreeTrackCombinationInfo(AliExternalTrackParam *firstTrack, AliExternalTrackParam *secondTrack, AliExternalTrackParam *thirdTrack, AliAODVertex *primaryVertex, Double_t bz, Bool_t isDesiredCandidate, Int_t histogramNumber, UInt_t prongs[3])
Int_t PtBin(Float_t pt) const
Definition: AliRDHFCuts.h:330
double Double_t
Definition: External.C:58
ULong64_t GetTriggerMask()
Definition: AliRDHFCuts.h:73
TList * fOutputDPlusPions
! User output
Definition: External.C:236
Int_t GetnSigmaTOF(AliAODTrack *track, Int_t species, Double_t &sigma) const
Int_t GetMinITSNclsDaughterType(Int_t nDaughterType) const
TList * fOutputDPlusKaon
! User output
Bool_t UseFilterBitDaughterType(Int_t nDaughterType) const
virtual Int_t IsSelected(TObject *obj, Int_t selectionLevel)
Double_t DeltaInvMassB0Kpipipi(AliAODRecoDecayHF2Prong *Bzero) const
Int_t GetnSigmaTPC(AliAODTrack *track, Int_t species, Double_t &sigma) const
TH2F * fMotherHistogramArray2D[6][99][60]
Double_t bz
Double_t ImpParXY() const
char Char_t
Definition: External.C:18
Int_t GetCutIndexForCutOptimization(Int_t nVariable) const
TList * fOutputB0Results
! User output
virtual void UserExec(Option_t *option)
void FillB0Histograms(AliAODRecoDecayHF2Prong *selectedMother, AliAODVertex *primaryVertex, Double_t bz, Int_t motherType, Int_t histType)
static TString GetGenerator(Int_t label, AliAODMCHeader *header)
Bool_t UseITSRefitDaughterType(Int_t nDaughterType) const
Bool_t IsCandidateInjected(AliAODRecoDecayHF2Prong *part, AliAODMCHeader *header, TClonesArray *arrayMC)
Int_t IsDPlusforDPlusptbinSelected(TObject *obj, Int_t selectionLevel, AliAODEvent *aod, Bool_t *bCutArray)
Int_t GetFilterBitDaughterType(Int_t nDaughterType) const
Int_t GetWhyRejection() const
Definition: AliRDHFCuts.h:341
Int_t fnPtBinsDPlusforDPlusptbin
[fnPtBinLimits]
Double_t CosPointingAngleXY() const
Bool_t FillRecoCand(AliVEvent *event, AliAODRecoDecayHF3Prong *rd3)
void TwoTrackCombinationInfo(AliExternalTrackParam *firstTrack, AliExternalTrackParam *secondTrack, AliAODVertex *primaryVertex, Double_t bz, Bool_t isDesiredCandidate, Int_t histogramNumber, UInt_t prongs[2])
void FillFinalTrackHistograms(AliAODRecoDecayHF2Prong *selectedB0, AliAODVertex *primaryVertex, Double_t bz, Bool_t isDesiredCandidate, TClonesArray *mcTrackArray)
Bool_t GetIsUpperCutForCutOptimization(Int_t nVariable) const
Bool_t UseTPCRefitDaughterType(Int_t nDaughterType) const
Int_t MatchCandidateToMonteCarlo(Int_t pdgabs, AliAODRecoDecayHF *candidate, TClonesArray *mcArray, TMatrix *B0toDStarPiLabelMatrix, Bool_t bCheckLabel=kFALSE) const
AliAODPidHF * GetPidHF() const
Definition: AliRDHFCuts.h:264
TList * fOutputB0Pion
! User output
AliAODVertex * RecalculateVertex(const AliVVertex *primary, TObjArray *tracks, Double_t bField, Double_t dispersion, Bool_t optUseFitter, Bool_t optPropagate, Bool_t optUseDiamondConstraint, Int_t nprongs)
TList * fOutputDPlus
! User output
virtual Int_t SelectPID(AliAODTrack *track, Int_t type)
Double_t GetMaxAbsEtaDaughterType(Int_t nDaughterType) const
Float_t GetCutForCutOptimization(Int_t nCutIndex, Int_t nVariable, Int_t ptBin)
Int_t GetNPtBinsDPlusforDPlusptbin() const
Float_t fCutVariableValueArray[99]
[fnPtBinsDPlusforDPlusptbinLimits]
int Int_t
Definition: External.C:63
std::vector< Int_t > * fDPlusTracks
Int_t GetnVariablesForCutOptimization()
unsigned int UInt_t
Definition: External.C:33
Double_t GetSigmaForCutOptimization(Int_t iPtBin) const
void GetSoftSelectionArrayITSDaughterType(Int_t nDaughterType, Bool_t array[7]=0) const
float Float_t
Definition: External.C:68
void DPlusSelection(AliAODEvent *aodEvent, AliAODVertex *primaryVertex, Double_t bz, TClonesArray *mcTrackArray, TMatrix *B0toDPlusPiLabelMatrix, TClonesArray *DPlusTrackArray, AliAODMCHeader *header)
TList * fOutputDPlus_DPlusPt
! User output
Double_t GetSigmaVert(const AliAODEvent *aod=0x0)
AliESDtrackCuts * GetTrackCuts() const
Definition: AliRDHFCuts.h:279
void SetProngIDs(Int_t nIDs, UShort_t *id)
Int_t GetNumberOfSigmaBinsForCutOptimization() const
Double_t Getd0errProng(Int_t ip) const
prongs
void B0Selection(AliAODEvent *aodEvent, AliAODVertex *primaryVertex, Double_t bz, TClonesArray *mcTrackArray, TMatrix *B0toDPlusPiLabelMatrix, TClonesArray *DPlusTrackArray, AliAODMCHeader *header)
Double_t GetMinPtDaughterType(Int_t nDaughterType) const
Int_t GetMinTPCNclsDaughterType(Int_t nDaughterType) const
virtual void UserCreateOutputObjects()
Implementation of interface methods.
Double_t GetMind0DaughterType(Int_t nDaughterType) const
void SetPrimaryVtxRef(TObject *vtx)
primary vertex
short Short_t
Definition: External.C:23
Int_t IsTrackInjected(AliAODTrack *part, AliAODMCHeader *header, TClonesArray *arrayMC)
void DaughterSelection(AliAODEvent *aodEvent, AliAODVertex *primaryVertex, Double_t bz, TClonesArray *mcTrackArray, TMatrix *B0toDPiLabelMatrix, AliAODMCHeader *header, Int_t daughterType, std::vector< Int_t > *trackVector)
std::vector< Int_t > * fB0PionTracks
Bool_t AreDaughtersSelected(AliAODRecoDecayHF *rd, const AliAODEvent *aod=0x0) const
Bool_t IsEventSelected(AliVEvent *event)
void CutOptimizationLoop(Int_t variable, Int_t nVariables, Int_t nCuts, Int_t ptBin, Int_t fillNumber, Bool_t isDesiredCandidate, Int_t nSigmaBin)
Float_t * GetPtBinLimits() const
Definition: AliRDHFCuts.h:265
void GetHardSelectionArrayITSDaughterType(Int_t nDaughterType, Bool_t array[7]=0) const
Bool_t DPlusDaughterSelection(AliAODTrack *aodTrack, AliAODEvent *aodEvent, AliAODVertex *primaryVertex, Double_t bz, TClonesArray *mcTrackArray, TMatrix *B0toDPiLabelMatrix, AliAODMCHeader *header, Int_t daughterType)
void CutOptimizationVariableValues(AliAODRecoDecayHF2Prong *candidateB0, AliAODEvent *aod)
unsigned short UShort_t
Definition: External.C:28
const char Option_t
Definition: External.C:48
Int_t GetNPtBins() const
Definition: AliRDHFCuts.h:266
bool Bool_t
Definition: External.C:53
Double_t CosPointingAngle() const
Float_t * GetPtBinLimitsDPlusforDPlusptbin() const
Double_t GetMinNormd0DaughterType(Int_t nDaughterType) const
Bool_t IsDaughterSelected(AliAODTrack *track, const AliESDVertex *primary, AliESDtrackCuts *cuts, const AliAODEvent *aod=0x0) const
virtual void Terminate(Option_t *option)
void FillDaughterHistograms(AliAODTrack *daughterTrack, Int_t daughterType, Int_t histType, Double_t ptB0, AliAODVertex *primaryVertex, Double_t bz, Bool_t isDesiredCandidate, TClonesArray *mcTrackArray)
void FillDPlusHistograms(AliAODRecoDecayHF3Prong *selectedMother, AliAODVertex *primaryVertex, Double_t bz, Int_t motherType, Int_t histType, Int_t pdgCodeMother=-1)
Int_t PtBinDPlusforDPlusptbin(Double_t pt) const
Class with functions useful for different D2H analyses //.