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