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