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