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