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