AliPhysics  master (3d17d9d)
AliAnalysisTaskSEBPlustoD0Pi.cxx
Go to the documentation of this file.
1 
2 
3 /**************************************************************************
4  * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
5  * *
6  * Author: The ALICE Off-line Project. *
7  * Contributors are mentioned in the code where appropriate. *
8  * *
9  * Permission to use, copy, modify and distribute this software and its *
10  * documentation strictly for non-commercial purposes is hereby granted *
11  * without fee, provided that the above copyright notice appears in all *
12  * copies and that both the copyright notice and this permission notice *
13  * appeuear in the supporting documentation. The authors make no claims *
14  * about the suitability of this software for any purpose. It is *
15  * provided "as is" without express or implied warranty. *
16  **************************************************************************/
17 
18 /* $Id$ */
19 
20 //
21 //
22 // Base class for (BPlus -> D0 pi-> K pi pi) Analysis
23 //
24 //
25 // Cuts are centralized in AliRDHFCutsBPlustoD0Pi
26 // Like sign + track rotation backgrounds are implemented in the macro
27 //
28 //-----------------------------------------------------------------------
29 //
30 // Author Lennart van Doremalen
31 // Utrecht University - l.v.r.vandoremalen@uu.nl
32 //
33 //-----------------------------------------------------------------------
34 
35 #include <TSystem.h>
36 #include <TChain.h>
37 #include <TParticle.h>
38 #include "TROOT.h"
39 #include <TDatabasePDG.h>
40 #include <AliAnalysisDataSlot.h>
41 #include <AliAnalysisDataContainer.h>
42 #include "AliRDHFCutsBPlustoD0Pi.h"
43 #include "AliStack.h"
44 #include "AliMCEvent.h"
45 #include "AliAnalysisManager.h"
46 #include "AliAODMCHeader.h"
47 #include "AliAODHandler.h"
48 #include "AliLog.h"
49 #include "AliVertex.h"
50 #include "AliVVertex.h"
51 #include "AliESDVertex.h"
52 #include "AliAODVertex.h"
53 #include "AliVertexerTracks.h"
54 #include "AliExternalTrackParam.h"
55 #include "AliNeutralTrackParam.h"
56 #include "AliAODRecoDecay.h"
57 #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 
77 
78 //__________________________________________________________________________
81  fEvents(0),
82  fUseMCInfo(kFALSE),
83  fShowMask(0),
84  fShowRejection(0),
85  fQuickSignalAnalysis(0),
86  fHistMassWindow(0.125),
87  fDegreePerRotation(0),
88  fNumberOfRotations(0),
89  fPerformCutOptimization(0),
90  fRemoveInjected(0),
91  fOutput(0),
92  fListCuts(0),
93  fOutputBPlusResults(0),
94  fOutputD0FirstDaughter(0),
95  fOutputD0SecondDaughter(0),
96  fOutputBPlusPion(0),
97  fOutputD0(0),
98  fOutputBPlus(0),
99  fOutputD0_D0Pt(0),
100  fCuts(0),
101  fCEvents(0),
102  fCTrigger(0),
103  fCRejected(0),
104  fBPlusPionTracks(0x0),
105  fD0Tracks(0x0),
106  fnPtBins(0),
107  fnPtBinLimits(0),
108  fPtBinLimits(0x0),
109  fnPtBinsD0forD0ptbin(0),
110  fnPtBinsD0forD0ptbinLimits(0),
111  fPtBinLimitsD0forD0ptbin(0x0),
112  fCutVariableValueArray(),
113  fDaughterHistogramArray(),
114  fDaughterHistogramArray2D(),
115  fDaughterHistogramArrayExtra(),
116  fMotherHistogramArray(),
117  fMotherHistogramArray2D(),
118  fMotherHistogramArrayExtra(),
119  fResultsHistogramArray(),
120  fResultsHistogramArray2D()
121 {
122  //
124  //
125 
126 }
127 //___________________________________________________________________________
129  AliAnalysisTaskSE(name),
130  fEvents(0),
131  fUseMCInfo(kFALSE),
132  fShowMask(0),
133  fShowRejection(0),
135  fHistMassWindow(0.125),
139  fRemoveInjected(0),
140  fOutput(0),
141  fListCuts(0),
145  fOutputBPlusPion(0),
146  fOutputD0(0),
147  fOutputBPlus(0),
148  fOutputD0_D0Pt(0),
149  fCuts(0),
150  fCEvents(0),
151  fCTrigger(0),
152  fCRejected(0),
153  fBPlusPionTracks(0x0),
154  fD0Tracks(0x0),
155  fnPtBins(0),
156  fnPtBinLimits(0),
157  fPtBinLimits(0x0),
170 {
171  //
173  //
174 
175  Info("AliAnalysisTaskSEBPlustoD0Pi", "Calling Constructor");
176 
177  fCuts = cuts;
178 
179  DefineInput(0, TChain::Class());
180  DefineOutput(1, TList::Class()); //conters
181  DefineOutput(2, TList::Class()); //My private output
182  DefineOutput(3, TList::Class()); // D0 pion output
183  DefineOutput(4, TList::Class()); // D0 kaon output
184  DefineOutput(5, TList::Class()); // BPlus pion output
185  DefineOutput(6, TList::Class()); // D0 output
186  DefineOutput(7, TList::Class()); // BPlus output
187  DefineOutput(8, TList::Class()); // BPlus output
188  DefineOutput(9, TList::Class()); // BPlusMC output
189 }
190 
191 //___________________________________________________________________________
193  //
195  //
196  Info("~AliAnalysisTaskSEBPlustoD0Pi", "Calling Destructor");
197 
198  delete fOutput;
199  delete fOutputD0FirstDaughter;
201  delete fOutputBPlusPion;
202  delete fOutputD0;
203  delete fOutputBPlus;
204  delete fOutputD0_D0Pt;
205  delete fOutputBPlusResults;
206  delete fCuts;
207  delete fCEvents;
208  delete fCTrigger;
209  delete fCRejected;
210  delete fD0Tracks;
211  delete fBPlusPionTracks;
212  delete fListCuts;
213  delete fPtBinLimits;
215  for (Int_t i = 0; i < 4; i++) {
216  for (Int_t j = 0; j < 6; j++) {
217  for (Int_t k = 0; k < 15; k++) {
218  delete fDaughterHistogramArray[i][j][k]; fDaughterHistogramArray[i][j][k] = nullptr;
219  }
220  }
221  }
222  for (Int_t i = 0; i < 4; i++) {
223  for (Int_t j = 0; j < 6; j++) {
224  delete fDaughterHistogramArray2D[i][j]; fDaughterHistogramArray2D[i][j] = nullptr;
225  }
226  }
227  for (Int_t i = 0; i < 4; i++) {
228  for (Int_t j = 0; j < 6; j++) {
229  delete fDaughterHistogramArrayExtra[i][j]; fDaughterHistogramArrayExtra[i][j] = nullptr;
230  }
231  }
232  for (Int_t i = 0; i < 6; i++) {
233  for (Int_t j = 0; j < 99; j++) {
234  for (Int_t k = 0; k < 60; k++) {
235  delete fMotherHistogramArray[i][j][k]; fMotherHistogramArray[i][j][k] = nullptr;
236  }
237  }
238  }
239  for (Int_t i = 0; i < 6; i++) {
240  for (Int_t j = 0; j < 99; j++) {
241  for (Int_t k = 0; k < 60; k++) {
242  delete fMotherHistogramArray2D[i][j][k]; fMotherHistogramArray2D[i][j][k] = nullptr;
243  }
244  }
245  }
246  for (Int_t i = 0; i < 7; i++) {
247  for (Int_t j = 0; j < 10; j++) {
248  delete fMotherHistogramArrayExtra[i][j]; fMotherHistogramArrayExtra[i][j] = nullptr;
249  }
250  }
251  for (Int_t i = 0; i < 20; i++) {
252  for (Int_t j = 0; j < 99; j++) {
253  delete fResultsHistogramArray[i][j]; fResultsHistogramArray[i][j] = nullptr;
254  }
255  }
256  for (Int_t i = 0; i < 20; i++) {
257  for (Int_t j = 0; j < 99; j++) {
258  delete fResultsHistogramArray2D[i][j]; fResultsHistogramArray2D[i][j] = nullptr;
259  }
260  }
261 }
262 //_________________________________________________
264  //
266  //
267 
268  if (fDebug > 1) printf("AliAnalysisTaskSEBPlustoD0Pi::Init() \n");
269 
270  return;
271 }
272 //_________________________________________________
274 
275  //==================================================================================
276  // USER EXECUTION FUNCTION - start
277  //==================================================================================
278  //
279  // This is the main function that has to be altered to do heavy flavour analysis.
280  //
281  //==================================================================================
282 
283  if (!fInputEvent)
284  {
285  Error("UserExec", "NO EVENT FOUND!");
286  return;
287  }
288 
289  if (fEvents % 500 == 0)
290  {
291  std::cout << "\r" << "Analysing event number: " << fEvents << std::endl;
292  }
293 
294  fEvents++;
295 
296  // Show trigger mask
297  if (fShowMask)
298  {
299  std::bitset<32> maskEV(((AliAODInputHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected());
300  std::cout << "Event mask: " << maskEV << std::endl;
301  std::cout << "Trigger mask: " << std::bitset<32>(fCuts->GetTriggerMask()) << std::endl;
302  }
303 
304  //save trigger information
305  for (int i = 0; i < 36; ++i)
306  {
307  ULong64_t compareValue = BIT(i);
308  // std::cout << "Compare mask: " << std::bitset<32>(compareValue) << std::endl;
309  Bool_t trigger1 = kFALSE;
310  Bool_t trigger2 = kFALSE;
311 
312  if (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & compareValue)
313  {
314  // std::cout << "Match!" << std::endl;
315  fCTrigger->Fill(i+1);
316  if(i==1) trigger1 = kTRUE;
317  if(i==10) trigger2 = kTRUE;
318  }
319  if(trigger1 && trigger2) fCTrigger->Fill(35);
320  }
321 
322 
323 
324  //==================================================================================
325  // EVENT INITIALIZATION - start
326  //==================================================================================
327 
328 
329  AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(fInputEvent);
330  TClonesArray * D0TracksFromFriendFile = 0;
331  fCEvents->Fill(1);
332 
333  if (!aodEvent && AODEvent() && IsStandardAOD())
334  {
335  // In case there is an AOD handler writing a standard AOD, use the AOD
336  // event in memory rather than the input (ESD) event.
337  aodEvent = dynamic_cast<AliAODEvent*> (AODEvent());
338  // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
339  // have to be taken from the AOD event hold by the AliAODExtension
340  AliAODHandler* aodHandler = (AliAODHandler*)((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
341  if (aodHandler->GetExtensions())
342  {
343  AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
344  AliAODEvent *aodFromExt = ext->GetAOD();
345  D0TracksFromFriendFile = (TClonesArray*)aodFromExt->GetList()->FindObject("D0toKpi");
346  }
347  } else {
348  D0TracksFromFriendFile = (TClonesArray*)aodEvent->GetList()->FindObject("D0toKpi");
349  }
350 
351  // fix for temporary bug in ESDfilter
352  // the AODs with null vertex pointer didn't pass the PhysSel
353  if (!aodEvent->GetPrimaryVertex() || TMath::Abs(aodEvent->GetMagneticField()) < 0.001) return;
354  fCEvents->Fill(2);
355 
356  // trigger class for PbPb C0SMH-B-NOPF-ALLNOTRD
357  TString trigclass = aodEvent->GetFiredTriggerClasses();
358  if (trigclass.Contains("C0SMH-B-NOPF-ALLNOTRD") || trigclass.Contains("C0SMH-B-NOPF-ALL")) fCEvents->Fill(5);
359 
360  fCRejected->Fill(0);
361  if (!fCuts->IsEventSelected(aodEvent))
362  {
363  if (fShowRejection) std::cout << "Event rejected by code: " << fCuts->GetWhyRejection() << std::endl;
364  fCRejected->Fill(fCuts->GetWhyRejection() + 1);
365  return;
366  }
367 
368  fCEvents->Fill(3);
369 
370  //get the magnetic field
371  Double_t bz = (Double_t)aodEvent->GetMagneticField();
372 
373  // AOD primary vertex
374  AliAODVertex *primaryVertex = (AliAODVertex*)aodEvent->GetPrimaryVertex();
375  if (!primaryVertex) return;
376  if (primaryVertex->GetNContributors() < 1) return;
377  fCEvents->Fill(4);
378 
379  if (!D0TracksFromFriendFile)
380  {
381  AliInfo("Could not find array of HF vertices, skipping the event");
382  return;
383  }
384  else AliDebug(2, Form("Found %d vertices", D0TracksFromFriendFile->GetEntriesFast()));
385 
386  AliAODMCHeader *mcHeader = 0;
387  if (fUseMCInfo)
388  {
389  mcHeader = (AliAODMCHeader*)aodEvent->GetList()->FindObject(AliAODMCHeader::StdBranchName());
390  if (!mcHeader) {
391  printf(" MC header branch not found!\n");
392  return;
393  }
394  }
395 
396 
397  //==================================================================================
398  // EVENT INITIALIZATION - end
399  //==================================================================================
400  // GET TRUE MC INFO - start
401  //==================================================================================
402 
403  TClonesArray *mcTrackArray = nullptr;
404  if (fUseMCInfo) mcTrackArray = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(AliAODMCParticle::StdBranchName()));
405  if (fUseMCInfo && !mcTrackArray) return;
406 
407  //Here we create an array and vectors that we use to look how many BPluss can be reconstructed after each cut
408  TMatrix * BPlustoD0PiLabelMatrix = new TMatrix(0, 5);
409 
410  //we fill the array with all BPlus->D0Pi tracks
411  if (fUseMCInfo) {
412  BPlustoD0PiSignalTracksInMC(mcTrackArray, aodEvent, BPlustoD0PiLabelMatrix, fOutputBPlusResults);
413  }
414 
415  //==================================================================================
416  // GET TRUE MC INFO - end
417  //==================================================================================
418  // PARTICLE SELECTION LOOP - start
419  //==================================================================================
420  //
421  // Here we select and reconstruct the particles for the BPlus -> D0 + Pion decay.
422  //
423  //==================================================================================
424 
425  D0Selection(aodEvent, primaryVertex, bz, mcTrackArray, BPlustoD0PiLabelMatrix, D0TracksFromFriendFile, mcHeader);
426 
427  if((Int_t)fD0Tracks->size() > 0)
428  {
429  BPlusPionSelection(aodEvent, primaryVertex, bz, mcTrackArray, BPlustoD0PiLabelMatrix, mcHeader);
430 
431  if((Int_t)fBPlusPionTracks->size() > 0)
432  {
433  BPlusSelection(aodEvent, primaryVertex, bz, mcTrackArray, BPlustoD0PiLabelMatrix, D0TracksFromFriendFile, mcHeader);
434  }
435  }
436 
437  // Clear arrays and memory management:
438  fD0Tracks->erase(fD0Tracks->begin(), fD0Tracks->end());
439  fBPlusPionTracks->erase(fBPlusPionTracks->begin(), fBPlusPionTracks->end());
440 
441  delete BPlustoD0PiLabelMatrix; BPlustoD0PiLabelMatrix = NULL;
442 
443  //==================================================================================
444  // PARTICLE SELECTION LOOP - end
445  //==================================================================================
446 
447  PostData(1, fOutput);
448  PostData(3, fOutputD0FirstDaughter);
449  PostData(4, fOutputD0SecondDaughter);
450  PostData(5, fOutputBPlusPion);
451  PostData(6, fOutputD0);
452  PostData(7, fOutputBPlus);
453  PostData(8, fOutputD0_D0Pt);
454  PostData(9, fOutputBPlusResults);
455 
456 
457  //==================================================================================
458  // USER EXECUTION FUNCTION - end
459  //==================================================================================
460 
461 }
462 //___________________________________ terminate ___________________________
467 
468  //Info("Terminate","");
469  AliAnalysisTaskSE::Terminate();
470 
471  fOutput = dynamic_cast<TList*> (GetOutputData(1));
472  if (!fOutput) {
473  printf("ERROR: fOutput not available\n");
474  return;
475  }
476 
477  fCEvents = dynamic_cast<TH1F*>(fOutput->FindObject("fCEvents"));
478  fCTrigger = dynamic_cast<TH1F*>(fOutput->FindObject("fCTrigger"));
479  fCRejected = dynamic_cast<TH1F*>(fOutput->FindObject("fCRejected"));
480 
481 
482  fListCuts = dynamic_cast<TList*> (GetOutputData(2));
483  if (!fListCuts) {
484  printf("ERROR: fListCuts not available\n");
485  return;
486  }
487  fOutputD0FirstDaughter = dynamic_cast<TList*> (GetOutputData(3));
488  if (!fOutputD0FirstDaughter) {
489  printf("ERROR: fOutputD0FirstDaughter not available\n");
490  return;
491  }
492  fOutputD0SecondDaughter = dynamic_cast<TList*> (GetOutputData(4));
494  printf("ERROR: fOutputD0SecondDaughter not available\n");
495  return;
496  }
497  fOutputBPlusPion = dynamic_cast<TList*> (GetOutputData(5));
498  if (!fOutputBPlusPion) {
499  printf("ERROR: fOutputBPlusPion not available\n");
500  return;
501  }
502  fOutputD0 = dynamic_cast<TList*> (GetOutputData(6));
503  if (!fOutputD0) {
504  printf("ERROR: fOutputD0 not available\n");
505  return;
506  }
507  fOutputBPlus = dynamic_cast<TList*> (GetOutputData(7));
508  if (!fOutputBPlus) {
509  printf("ERROR: fOutputBPlus not available\n");
510  return;
511  }
512  fOutputD0_D0Pt = dynamic_cast<TList*> (GetOutputData(8));
513  if (!fOutputD0_D0Pt) {
514  printf("ERROR: fOutputD0_D0Pt not available\n");
515  return;
516  }
517  fOutputBPlusResults = dynamic_cast<TList*> (GetOutputData(9));
518  if (!fOutputBPlusResults) {
519  printf("ERROR: fOutputBPlusResults not available\n");
520  return;
521  }
522  return;
523 }
524 
525 //___________________________________________________________________________
528  Info("UserCreateOutputObjects", "CreateOutputObjects of task %s\n", GetName());
529 
530  fOutput = new TList();
531  fOutput->SetOwner();
532  fOutput->SetName("General_information");
533 
535  fOutputD0FirstDaughter->SetOwner();
536  fOutputD0FirstDaughter->SetName("listD0Pion");
537 
539  fOutputD0SecondDaughter->SetOwner();
540  fOutputD0SecondDaughter->SetName("listD0Kaon");
541 
542  fOutputBPlusPion = new TList();
543  fOutputBPlusPion->SetOwner();
544  fOutputBPlusPion->SetName("listBPlusPion");
545 
546  fOutputD0 = new TList();
547  fOutputD0->SetOwner();
548  fOutputD0->SetName("listD0");
549 
550  fOutputBPlus = new TList();
551  fOutputBPlus->SetOwner();
552  fOutputBPlus->SetName("listBPlus");
553 
554  fOutputD0_D0Pt = new TList();
555  fOutputD0_D0Pt->SetOwner();
556  fOutputD0_D0Pt->SetName("listD0_D0Pt");
557 
558  fOutputBPlusResults = new TList();
559  fOutputBPlusResults->SetOwner();
560  fOutputBPlusResults->SetName("listBPlusResults");
561 
562  // we prepare vectors that will save the positions of the daughter tracks in the track list during the reconstruction
563  fBPlusPionTracks = new std::vector<Int_t>;
564  fD0Tracks = new std::vector<Int_t>;
565 
566  // we get information on the pt bins
568  fnPtBinLimits = fnPtBins + 1;
570 
574 
575  std::cout << "Nr. of BPlus 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 
588  fListCuts = new TList();
589  fListCuts->SetOwner();
590  fListCuts->SetName("Cuts");
592  fListCuts->Add(copyfCuts);
593 
594  // define histograms
596 
597  // Post the data
598  PostData(1, fOutput);
599  PostData(2, fListCuts);
600  PostData(3, fOutputD0FirstDaughter);
601  PostData(4, fOutputD0SecondDaughter);
602  PostData(5, fOutputBPlusPion);
603  PostData(6, fOutputD0);
604  PostData(7, fOutputBPlus);
605  PostData(8, fOutputD0_D0Pt);
606  PostData(9, fOutputBPlusResults);
607 
608  return;
609 }
610 //___________________________________ histograms _______________________________________
612 
614 
615  fCEvents = new TH1F("fCEvents", "Event counter", 13, 0, 13);
616  fCEvents->SetStats(kTRUE);
617  fCEvents->GetXaxis()->SetTitle("");
618  fCEvents->GetYaxis()->SetTitle("Number");
619  fCEvents->GetXaxis()->SetBinLabel(2, "total nr. of events");
620  fCEvents->GetXaxis()->SetBinLabel(3, "good prim vtx and B field");
621  fCEvents->GetXaxis()->SetBinLabel(4, "total events selected");
622  fCEvents->GetXaxis()->SetBinLabel(5, "nr. vtx contributors");
623  fCEvents->GetXaxis()->SetBinLabel(6, "trigger for PbPb");
624  fCEvents->GetXaxis()->SetBinLabel(7, "no z vtx");
625  fCEvents->GetXaxis()->SetBinLabel(8, "");
626  fCEvents->GetXaxis()->SetBinLabel(9, "");
627  fCEvents->GetXaxis()->SetBinLabel(10, "");
628  fCEvents->GetXaxis()->SetBinLabel(11, "");
629  fCEvents->GetXaxis()->SetBinLabel(12, "nr. of D0 fail to be rec");
630  fOutput->Add(fCEvents);
631 
632  fCTrigger= new TH1F("fCTrigger", "Trigger counter", 36, 0, 36);
633  fCTrigger->SetStats(kTRUE);
634  fCTrigger->GetXaxis()->SetTitle("");
635  fCTrigger->GetYaxis()->SetTitle("Number");
636  fCTrigger->GetXaxis()->SetBinLabel(1, "total nr. of events");
637  fCTrigger->GetXaxis()->SetBinLabel(2, "Bit 0 - kMB/kINT1");
638  fCTrigger->GetXaxis()->SetBinLabel(3, "Bit 1 - kINT7");
639  fCTrigger->GetXaxis()->SetBinLabel(4, "Bit 2 - kMUON");
640  fCTrigger->GetXaxis()->SetBinLabel(5, "Bit 3 - kHighMult/kHighMultSPD");
641  fCTrigger->GetXaxis()->SetBinLabel(6, "Bit 4 - kEMC1");
642  fCTrigger->GetXaxis()->SetBinLabel(7, "Bit 5 - kCINT5/kINT5");
643  fCTrigger->GetXaxis()->SetBinLabel(8, "Bit 6 - kCMUS5/kMUSPB/kINT7inMUON");
644  fCTrigger->GetXaxis()->SetBinLabel(9, "Bit 7 - kMuonSingleHighPt7/kMUSH7/kMUSHPB");
645  fCTrigger->GetXaxis()->SetBinLabel(10, "Bit 8 - kMuonLikeLowPt7/kMUL7/kMuonLikePB");
646  fCTrigger->GetXaxis()->SetBinLabel(11, "Bit 9 - kMuonUnlikeLowPt7/kMUU7/kMuonUnlikePB");
647  fCTrigger->GetXaxis()->SetBinLabel(12, "Bit 10 - kEMC7/kEMC8");
648  fCTrigger->GetXaxis()->SetBinLabel(13, "Bit 11 - kMUS7/kMuonSingleLowPt7");
649  fCTrigger->GetXaxis()->SetBinLabel(14, "Bit 12 - kPHI1");
650  fCTrigger->GetXaxis()->SetBinLabel(15, "Bit 13 - kPHI7/kPHI8/kPHOSPb");
651  fCTrigger->GetXaxis()->SetBinLabel(16, "Bit 14 - kEMCEJE");
652  fCTrigger->GetXaxis()->SetBinLabel(17, "Bit 15 - kEMCEGA");
653  fCTrigger->GetXaxis()->SetBinLabel(18, "Bit 16 - kHighMultV0/kCentral");
654  fCTrigger->GetXaxis()->SetBinLabel(19, "Bit 17 - kSemiCentral");
655  fCTrigger->GetXaxis()->SetBinLabel(20, "Bit 18 - kDG/kDG5");
656  fCTrigger->GetXaxis()->SetBinLabel(21, "Bit 19 - kZED");
657  fCTrigger->GetXaxis()->SetBinLabel(22, "Bit 20 - kSPI7/kSPI");
658  fCTrigger->GetXaxis()->SetBinLabel(23, "Bit 21 - kINT8");
659  fCTrigger->GetXaxis()->SetBinLabel(24, "Bit 22 - kMuonSingleLowPt8");
660  fCTrigger->GetXaxis()->SetBinLabel(25, "Bit 23 - kMuonSingleHighPt8");
661  fCTrigger->GetXaxis()->SetBinLabel(26, "Bit 24 - kMuonLikeLowPt8");
662  fCTrigger->GetXaxis()->SetBinLabel(27, "Bit 25 - kMuonUnlikeLowPt8");
663  fCTrigger->GetXaxis()->SetBinLabel(28, "Bit 26 - kMuonUnlikeLowPt0");
664  fCTrigger->GetXaxis()->SetBinLabel(29, "Bit 27 - kUserDefined");
665  fCTrigger->GetXaxis()->SetBinLabel(30, "Bit 28 - kTRD");
666  fCTrigger->GetXaxis()->SetBinLabel(31, "Bit 29 - ...");
667  fCTrigger->GetXaxis()->SetBinLabel(32, "Bit 30 - kFastOnly");
668  fCTrigger->GetXaxis()->SetBinLabel(33, "Bit 31 - ...");
669  fCTrigger->GetXaxis()->SetBinLabel(34, "Bit 32 - ...");
670  fCTrigger->GetXaxis()->SetBinLabel(35, "kINT7 && kEMC7");
671  fOutput->Add(fCTrigger);
672 
673  fCRejected= new TH1F("fCRejected", "Rejected counter", 35, 0, 35);
674  fCRejected->SetStats(kTRUE);
675  fCRejected->GetXaxis()->SetTitle("");
676  fCRejected->GetYaxis()->SetTitle("Number");
677  fCRejected->GetXaxis()->SetBinLabel(1, "total nr. of events");
678  fCRejected->GetXaxis()->SetBinLabel(2, "0");
679  fCRejected->GetXaxis()->SetBinLabel(3, "1");
680  fCRejected->GetXaxis()->SetBinLabel(4, "2");
681  fCRejected->GetXaxis()->SetBinLabel(5, "3");
682  fCRejected->GetXaxis()->SetBinLabel(6, "4");
683  fCRejected->GetXaxis()->SetBinLabel(7, "5");
684  fCRejected->GetXaxis()->SetBinLabel(8, "6");
685  fCRejected->GetXaxis()->SetBinLabel(9, "7");
686  fCRejected->GetXaxis()->SetBinLabel(10, "8");
687  fCRejected->GetXaxis()->SetBinLabel(11, "9");
688  fCRejected->GetXaxis()->SetBinLabel(12, "10");
689  fCRejected->GetXaxis()->SetBinLabel(13, "11");
690  fCRejected->GetXaxis()->SetBinLabel(14, "12");
691  fCRejected->GetXaxis()->SetBinLabel(15, "13");
692  fCRejected->GetXaxis()->SetBinLabel(16, "14");
693  fCRejected->GetXaxis()->SetBinLabel(17, "15");
694  fCRejected->GetXaxis()->SetBinLabel(18, "16");
695  fCRejected->GetXaxis()->SetBinLabel(19, "17");
696  fCRejected->GetXaxis()->SetBinLabel(20, "18");
697  fCRejected->GetXaxis()->SetBinLabel(21, "19");
698  fCRejected->GetXaxis()->SetBinLabel(22, "20");
699  fCRejected->GetXaxis()->SetBinLabel(23, "21");
700  fCRejected->GetXaxis()->SetBinLabel(24, "22");
701  fCRejected->GetXaxis()->SetBinLabel(25, "23");
702  fCRejected->GetXaxis()->SetBinLabel(26, "24");
703  fCRejected->GetXaxis()->SetBinLabel(27, "25");
704  fCRejected->GetXaxis()->SetBinLabel(28, "26");
705  fCRejected->GetXaxis()->SetBinLabel(29, "27");
706  fCRejected->GetXaxis()->SetBinLabel(30, "28");
707  fCRejected->GetXaxis()->SetBinLabel(31, "29");
708  fCRejected->GetXaxis()->SetBinLabel(32, "30");
709  fCRejected->GetXaxis()->SetBinLabel(33, "31");
710  fCRejected->GetXaxis()->SetBinLabel(34, "32");
711  fOutput->Add(fCRejected);
712 
713  //====================================================
714 
715  TString name_mc_BPlus_pt = "mc_BPlus_pt";
716  TH1F* hist_mc_BPlus_pt = new TH1F(name_mc_BPlus_pt.Data(), "Pt monte carlo BPlus in BPlus->D*#pi; p_{T} [GeV/c]; Entries", 400, 0, 20);
717  hist_mc_BPlus_pt->Sumw2();
718  hist_mc_BPlus_pt->SetLineColor(6);
719  hist_mc_BPlus_pt->SetMarkerStyle(20);
720  hist_mc_BPlus_pt->SetMarkerSize(0.6);
721  hist_mc_BPlus_pt->SetMarkerColor(6);
722  TH1F* histogram_mc_BPlus_pt = (TH1F*)hist_mc_BPlus_pt->Clone();
723  fOutputBPlusResults->Add(histogram_mc_BPlus_pt);
724  fResultsHistogramArray[0][0] = histogram_mc_BPlus_pt;
725 
726  TString name_mc_BPlus_pion_pt = "mc_BPlus_pion_pt";
727  TH1F* hist_mc_BPlus_pion_pt = new TH1F(name_mc_BPlus_pion_pt.Data(), "Pt monte carlo pion of BPlus in BPlus->D*#pi; p_{T} [GeV/c]; Entries", 400, 0, 20);
728  hist_mc_BPlus_pion_pt->Sumw2();
729  hist_mc_BPlus_pion_pt->SetLineColor(6);
730  hist_mc_BPlus_pion_pt->SetMarkerStyle(20);
731  hist_mc_BPlus_pion_pt->SetMarkerSize(0.6);
732  hist_mc_BPlus_pion_pt->SetMarkerColor(6);
733  TH1F* histogram_mc_BPlus_pion_pt = (TH1F*)hist_mc_BPlus_pion_pt->Clone();
734  fOutputBPlusResults->Add(histogram_mc_BPlus_pion_pt);
735  fResultsHistogramArray[0][1] = histogram_mc_BPlus_pion_pt;
736 
737  TString name_mc_D0_pt = "mc_D0_pt";
738  TH1F* hist_mc_D0_pt = new TH1F(name_mc_D0_pt.Data(), "Pt monte carlo D0 in BPlus->D*#pi; p_{T} [GeV/c]; Entries", 400, 0, 20);
739  hist_mc_D0_pt->Sumw2();
740  hist_mc_D0_pt->SetLineColor(6);
741  hist_mc_D0_pt->SetMarkerStyle(20);
742  hist_mc_D0_pt->SetMarkerSize(0.6);
743  hist_mc_D0_pt->SetMarkerColor(6);
744  TH1F* histogram_mc_D0_pt = (TH1F*)hist_mc_D0_pt->Clone();
745  fOutputBPlusResults->Add(histogram_mc_D0_pt);
746  fResultsHistogramArray[0][2] = histogram_mc_D0_pt;
747 
748  TString name_mc_D0_pion_pt = "mc_D0_pion_pt";
749  TH1F* hist_mc_D0_pion_pt = new TH1F(name_mc_D0_pion_pt.Data(), "Pt monte carlo pion of D0 in BPlus->D*#pi; p_{T} [GeV/c]; Entries", 400, 0, 20);
750  hist_mc_D0_pion_pt->Sumw2();
751  hist_mc_D0_pion_pt->SetLineColor(6);
752  hist_mc_D0_pion_pt->SetMarkerStyle(20);
753  hist_mc_D0_pion_pt->SetMarkerSize(0.6);
754  hist_mc_D0_pion_pt->SetMarkerColor(6);
755  TH1F* histogram_mc_D0_pion_pt = (TH1F*)hist_mc_D0_pion_pt->Clone();
756  fOutputBPlusResults->Add(histogram_mc_D0_pion_pt);
757  fResultsHistogramArray[0][3] = histogram_mc_D0_pion_pt;
758 
759  TString name_mc_D0_kaon_pt = "mc_D0_kaon_pt";
760  TH1F* hist_mc_D0_kaon_pt = new TH1F(name_mc_D0_kaon_pt.Data(), "Pt monte carlo kaon of D0 in BPlus->D*#pi; p_{T} [GeV/c]; Entries", 400, 0, 20);
761  hist_mc_D0_kaon_pt->Sumw2();
762  hist_mc_D0_kaon_pt->SetLineColor(6);
763  hist_mc_D0_kaon_pt->SetMarkerStyle(20);
764  hist_mc_D0_kaon_pt->SetMarkerSize(0.6);
765  hist_mc_D0_kaon_pt->SetMarkerColor(6);
766  TH1F* histogram_mc_D0_kaon_pt = (TH1F*)hist_mc_D0_kaon_pt->Clone();
767  fOutputBPlusResults->Add(histogram_mc_D0_kaon_pt);
768  fResultsHistogramArray[0][4] = histogram_mc_D0_kaon_pt;
769 
770  TString name_mc_BPlus_rapidity_true = "mc_BPlus_rapidity_true";
771  TH1F* hist_mc_BPlus_rapidity_true = new TH1F(name_mc_BPlus_rapidity_true.Data(), "rapidity_true monte carlo BPlus in BPlus->D*#pi; Y; Entries", 5000, -20, 20);
772  hist_mc_BPlus_rapidity_true->Sumw2();
773  hist_mc_BPlus_rapidity_true->SetLineColor(6);
774  hist_mc_BPlus_rapidity_true->SetMarkerStyle(20);
775  hist_mc_BPlus_rapidity_true->SetMarkerSize(0.6);
776  hist_mc_BPlus_rapidity_true->SetMarkerColor(6);
777  TH1F* histogram_mc_BPlus_rapidity_true = (TH1F*)hist_mc_BPlus_rapidity_true->Clone();
778  fOutputBPlusResults->Add(histogram_mc_BPlus_rapidity_true);
779  fResultsHistogramArray[0][5] = histogram_mc_BPlus_rapidity_true;
780 
781  TString name_mc_BPlus_pion_rapidity_true = "mc_BPlus_pion_rapidity_true";
782  TH1F* hist_mc_BPlus_pion_rapidity_true = new TH1F(name_mc_BPlus_pion_rapidity_true.Data(), "rapidity_true monte carlo pion of BPlus in BPlus->D*#pi; Y; Entries", 5000, -20, 20);
783  hist_mc_BPlus_pion_rapidity_true->Sumw2();
784  hist_mc_BPlus_pion_rapidity_true->SetLineColor(6);
785  hist_mc_BPlus_pion_rapidity_true->SetMarkerStyle(20);
786  hist_mc_BPlus_pion_rapidity_true->SetMarkerSize(0.6);
787  hist_mc_BPlus_pion_rapidity_true->SetMarkerColor(6);
788  TH1F* histogram_mc_BPlus_pion_rapidity_true = (TH1F*)hist_mc_BPlus_pion_rapidity_true->Clone();
789  fOutputBPlusResults->Add(histogram_mc_BPlus_pion_rapidity_true);
790  fResultsHistogramArray[0][6] = histogram_mc_BPlus_pion_rapidity_true;
791 
792  TString name_mc_D0_rapidity_true = "mc_D0_rapidity_true";
793  TH1F* hist_mc_D0_rapidity_true = new TH1F(name_mc_D0_rapidity_true.Data(), "rapidity_true monte carlo D0 in BPlus->D*#pi; Y; Entries", 5000, -20, 20);
794  hist_mc_D0_rapidity_true->Sumw2();
795  hist_mc_D0_rapidity_true->SetLineColor(6);
796  hist_mc_D0_rapidity_true->SetMarkerStyle(20);
797  hist_mc_D0_rapidity_true->SetMarkerSize(0.6);
798  hist_mc_D0_rapidity_true->SetMarkerColor(6);
799  TH1F* histogram_mc_D0_rapidity_true = (TH1F*)hist_mc_D0_rapidity_true->Clone();
800  fOutputBPlusResults->Add(histogram_mc_D0_rapidity_true);
801  fResultsHistogramArray[0][7] = histogram_mc_D0_rapidity_true;
802 
803  TString name_mc_D0_pion_rapidity_true = "mc_D0_pion_rapidity_true";
804  TH1F* hist_mc_D0_pion_rapidity_true = new TH1F(name_mc_D0_pion_rapidity_true.Data(), "rapidity_true monte carlo pion of D0 in BPlus->D*#pi; Y; Entries", 5000, -20, 20);
805  hist_mc_D0_pion_rapidity_true->Sumw2();
806  hist_mc_D0_pion_rapidity_true->SetLineColor(6);
807  hist_mc_D0_pion_rapidity_true->SetMarkerStyle(20);
808  hist_mc_D0_pion_rapidity_true->SetMarkerSize(0.6);
809  hist_mc_D0_pion_rapidity_true->SetMarkerColor(6);
810  TH1F* histogram_mc_D0_pion_rapidity_true = (TH1F*)hist_mc_D0_pion_rapidity_true->Clone();
811  fOutputBPlusResults->Add(histogram_mc_D0_pion_rapidity_true);
812  fResultsHistogramArray[0][8] = histogram_mc_D0_pion_rapidity_true;
813 
814  TString name_mc_D0_kaon_rapidity_true = "mc_D0_kaon_rapidity_true";
815  TH1F* hist_mc_D0_kaon_rapidity_true = new TH1F(name_mc_D0_kaon_rapidity_true.Data(), "rapidity_true monte carlo kaon of D0 in BPlus->D*#pi; Y; Entries", 5000, -20, 20);
816  hist_mc_D0_kaon_rapidity_true->Sumw2();
817  hist_mc_D0_kaon_rapidity_true->SetLineColor(6);
818  hist_mc_D0_kaon_rapidity_true->SetMarkerStyle(20);
819  hist_mc_D0_kaon_rapidity_true->SetMarkerSize(0.6);
820  hist_mc_D0_kaon_rapidity_true->SetMarkerColor(6);
821  TH1F* histogram_mc_D0_kaon_rapidity_true = (TH1F*)hist_mc_D0_kaon_rapidity_true->Clone();
822  fOutputBPlusResults->Add(histogram_mc_D0_kaon_rapidity_true);
823  fResultsHistogramArray[0][9] = histogram_mc_D0_kaon_rapidity_true;
824 
825  TString name_mc_BPlus_pseudorapidity_true = "mc_BPlus_pseudorapidity_true";
826  TH1F* hist_mc_BPlus_pseudorapidity_true = new TH1F(name_mc_BPlus_pseudorapidity_true.Data(), "pseudorapidity_true monte carlo BPlus in BPlus->D*#pi; #eta; Entries", 5000, -20, 20);
827  hist_mc_BPlus_pseudorapidity_true->Sumw2();
828  hist_mc_BPlus_pseudorapidity_true->SetLineColor(6);
829  hist_mc_BPlus_pseudorapidity_true->SetMarkerStyle(20);
830  hist_mc_BPlus_pseudorapidity_true->SetMarkerSize(0.6);
831  hist_mc_BPlus_pseudorapidity_true->SetMarkerColor(6);
832  TH1F* histogram_mc_BPlus_pseudorapidity_true = (TH1F*)hist_mc_BPlus_pseudorapidity_true->Clone();
833  fOutputBPlusResults->Add(histogram_mc_BPlus_pseudorapidity_true);
834  fResultsHistogramArray[0][10] = histogram_mc_BPlus_pseudorapidity_true;
835 
836  TString name_mc_BPlus_pion_pseudorapidity_true = "mc_BPlus_pion_pseudorapidity_true";
837  TH1F* hist_mc_BPlus_pion_pseudorapidity_true = new TH1F(name_mc_BPlus_pion_pseudorapidity_true.Data(), "pseudorapidity_true monte carlo pion of BPlus in BPlus->D*#pi; #eta; Entries", 5000, -20, 20);
838  hist_mc_BPlus_pion_pseudorapidity_true->Sumw2();
839  hist_mc_BPlus_pion_pseudorapidity_true->SetLineColor(6);
840  hist_mc_BPlus_pion_pseudorapidity_true->SetMarkerStyle(20);
841  hist_mc_BPlus_pion_pseudorapidity_true->SetMarkerSize(0.6);
842  hist_mc_BPlus_pion_pseudorapidity_true->SetMarkerColor(6);
843  TH1F* histogram_mc_BPlus_pion_pseudorapidity_true = (TH1F*)hist_mc_BPlus_pion_pseudorapidity_true->Clone();
844  fOutputBPlusResults->Add(histogram_mc_BPlus_pion_pseudorapidity_true);
845  fResultsHistogramArray[0][11] = histogram_mc_BPlus_pion_pseudorapidity_true;
846 
847  TString name_mc_D0_pseudorapidity_true = "mc_D0_pseudorapidity_true";
848  TH1F* hist_mc_D0_pseudorapidity_true = new TH1F(name_mc_D0_pseudorapidity_true.Data(), "pseudorapidity_true monte carlo D0 in BPlus->D*#pi; #eta; Entries", 5000, -20, 20);
849  hist_mc_D0_pseudorapidity_true->Sumw2();
850  hist_mc_D0_pseudorapidity_true->SetLineColor(6);
851  hist_mc_D0_pseudorapidity_true->SetMarkerStyle(20);
852  hist_mc_D0_pseudorapidity_true->SetMarkerSize(0.6);
853  hist_mc_D0_pseudorapidity_true->SetMarkerColor(6);
854  TH1F* histogram_mc_D0_pseudorapidity_true = (TH1F*)hist_mc_D0_pseudorapidity_true->Clone();
855  fOutputBPlusResults->Add(histogram_mc_D0_pseudorapidity_true);
856  fResultsHistogramArray[0][12] = histogram_mc_D0_pseudorapidity_true;
857 
858  TString name_mc_D0_pion_pseudorapidity_true = "mc_D0_pion_pseudorapidity_true";
859  TH1F* hist_mc_D0_pion_pseudorapidity_true = new TH1F(name_mc_D0_pion_pseudorapidity_true.Data(), "pseudorapidity_true monte carlo pion of D0 in BPlus->D*#pi; #eta; Entries", 5000, -20, 20);
860  hist_mc_D0_pion_pseudorapidity_true->Sumw2();
861  hist_mc_D0_pion_pseudorapidity_true->SetLineColor(6);
862  hist_mc_D0_pion_pseudorapidity_true->SetMarkerStyle(20);
863  hist_mc_D0_pion_pseudorapidity_true->SetMarkerSize(0.6);
864  hist_mc_D0_pion_pseudorapidity_true->SetMarkerColor(6);
865  TH1F* histogram_mc_D0_pion_pseudorapidity_true = (TH1F*)hist_mc_D0_pion_pseudorapidity_true->Clone();
866  fOutputBPlusResults->Add(histogram_mc_D0_pion_pseudorapidity_true);
867  fResultsHistogramArray[0][13] = histogram_mc_D0_pion_pseudorapidity_true;
868 
869  TString name_mc_D0_kaon_pseudorapidity_true = "mc_D0_kaon_pseudorapidity_true";
870  TH1F* hist_mc_D0_kaon_pseudorapidity_true = new TH1F(name_mc_D0_kaon_pseudorapidity_true.Data(), "pseudorapidity_true monte carlo kaon of D0 in BPlus->D*#pi; #eta; Entries", 5000, -20, 20);
871  hist_mc_D0_kaon_pseudorapidity_true->Sumw2();
872  hist_mc_D0_kaon_pseudorapidity_true->SetLineColor(6);
873  hist_mc_D0_kaon_pseudorapidity_true->SetMarkerStyle(20);
874  hist_mc_D0_kaon_pseudorapidity_true->SetMarkerSize(0.6);
875  hist_mc_D0_kaon_pseudorapidity_true->SetMarkerColor(6);
876  TH1F* histogram_mc_D0_kaon_pseudorapidity_true = (TH1F*)hist_mc_D0_kaon_pseudorapidity_true->Clone();
877  fOutputBPlusResults->Add(histogram_mc_D0_kaon_pseudorapidity_true);
878  fResultsHistogramArray[0][14] = histogram_mc_D0_kaon_pseudorapidity_true;
879 
881  {
884  Int_t nCutOptimizationBins = TMath::Power(nCuts, nVariables);
886 
887  for (Int_t k = 0; k < fnPtBins; ++k)
888  {
889  TString ptBinMother = "";
890  ptBinMother += "_ptbin_";
891  ptBinMother += fPtBinLimits[k];
892  ptBinMother += "_to_";
893  ptBinMother += fPtBinLimits[k + 1];
894 
895  TString name_cut_optimization_signal = "cut_optimization_signal";
896  name_cut_optimization_signal += ptBinMother;
897  TH2F* hist_cut_optimization_signal = new TH2F(name_cut_optimization_signal.Data(), "Total signal for different cuts; Cut number; Entries", nCutOptimizationBins, 0, nCutOptimizationBins, 2 * nSigmaBins, -nSigmaBins, nSigmaBins);
898  hist_cut_optimization_signal->Sumw2();
899  hist_cut_optimization_signal->SetLineColor(6);
900  hist_cut_optimization_signal->SetMarkerStyle(20);
901  hist_cut_optimization_signal->SetMarkerSize(0.6);
902  hist_cut_optimization_signal->SetMarkerColor(6);
903  TH2F* histogram_cut_optimization_signal = (TH2F*)hist_cut_optimization_signal->Clone();
904  fOutputBPlusResults->Add(histogram_cut_optimization_signal);
905  fResultsHistogramArray2D[0][k] = histogram_cut_optimization_signal;
906 
907  TString name_cut_optimization_background = "cut_optimization_background";
908  name_cut_optimization_background += ptBinMother;
909  TH2F* hist_cut_optimization_background = new TH2F(name_cut_optimization_background.Data(), "Total background for different cuts; Cut number; Entries", nCutOptimizationBins, 0, nCutOptimizationBins, 2 * nSigmaBins, -nSigmaBins, nSigmaBins);
910  hist_cut_optimization_background->Sumw2();
911  hist_cut_optimization_background->SetLineColor(6);
912  hist_cut_optimization_background->SetMarkerStyle(20);
913  hist_cut_optimization_background->SetMarkerSize(0.6);
914  hist_cut_optimization_background->SetMarkerColor(6);
915  TH2F* histogram_cut_optimization_background = (TH2F*)hist_cut_optimization_background->Clone();
916  fOutputBPlusResults->Add(histogram_cut_optimization_background);
917  fResultsHistogramArray2D[1][k] = histogram_cut_optimization_background;
918  }
919  }
920 
921 
922  //==================================================
923 
924  TString name_BPluss_in_analysis = "BPlus_in_analysis";
925  TH1F* hist_BPluss_in_analysis = new TH1F(name_BPluss_in_analysis.Data(), "Number of BPluss to kpipipi in the Analysis; Entries", 10, 0, 10);
926  hist_BPluss_in_analysis->Sumw2();
927  hist_BPluss_in_analysis->SetLineColor(6);
928  hist_BPluss_in_analysis->SetMarkerStyle(20);
929  hist_BPluss_in_analysis->SetMarkerSize(0.6);
930  hist_BPluss_in_analysis->SetMarkerColor(6);
931  hist_BPluss_in_analysis->SetStats(kTRUE);
932  hist_BPluss_in_analysis->GetXaxis()->SetBinLabel(1, "no. of BPlus");
933  hist_BPluss_in_analysis->GetXaxis()->SetBinLabel(2, "no. of BPlus to kpipi");
934  hist_BPluss_in_analysis->GetXaxis()->SetBinLabel(3, "no. with all tracks in event");
935  hist_BPluss_in_analysis->GetXaxis()->SetBinLabel(4, "no. ...");
936  hist_BPluss_in_analysis->GetXaxis()->SetBinLabel(5, "no. ...");
937  hist_BPluss_in_analysis->GetXaxis()->SetBinLabel(6, "no. ...");
938  hist_BPluss_in_analysis->GetXaxis()->SetBinLabel(7, "no. ...");
939  hist_BPluss_in_analysis->GetXaxis()->SetBinLabel(8, "no. ...");
940  TH1F* hist_BPluss_in_analysis_mc = (TH1F*)hist_BPluss_in_analysis->Clone();
941  fOutputBPlusResults->Add(hist_BPluss_in_analysis_mc);
942  fResultsHistogramArray[3][0] = hist_BPluss_in_analysis_mc;
943 
944  TString name_BPlus_per_bin = "BPlus_per_bin";
945  TH1F* hist_BPlus_per_bin = new TH1F(name_BPlus_per_bin.Data(), "Number of BPlus to kpipi in the Analysis per bin; Entries", fnPtBins, 0, fnPtBins);
946  for (Int_t i = 0; i < fnPtBins; ++i)
947  {
948  TString bin_name = "";
949  bin_name += fPtBinLimits[i];
950  bin_name += "-";
951  bin_name += fPtBinLimits[i + 1];
952  hist_BPlus_per_bin->GetXaxis()->SetBinLabel(i + 1, bin_name);
953  }
954  TH1F* hist_BPlus_per_bin_mc = (TH1F*)hist_BPlus_per_bin->Clone();
955  fOutputBPlusResults->Add(hist_BPlus_per_bin_mc);
956  fResultsHistogramArray[3][1] = hist_BPlus_per_bin_mc;
957 
958  TString name_BPlus_per_bin_in_Acc = "BPlus_per_bin_in_Acc";
959  TH1F* hist_BPlus_per_bin_in_Acc = new TH1F(name_BPlus_per_bin_in_Acc.Data(), "Number of BPlus to kpipi in the Analysis per bin with all daughters in acceptance; Entries", fnPtBins, 0, fnPtBins);
960  for (Int_t i = 0; i < fnPtBins; ++i)
961  {
962  TString bin_name = "";
963  bin_name += fPtBinLimits[i];
964  bin_name += "-";
965  bin_name += fPtBinLimits[i + 1];
966  hist_BPlus_per_bin_in_Acc->GetXaxis()->SetBinLabel(i + 1, bin_name);
967  }
968  TH1F* hist_BPlus_per_bin_in_Acc_mc = (TH1F*)hist_BPlus_per_bin_in_Acc->Clone();
969  fOutputBPlusResults->Add(hist_BPlus_per_bin_in_Acc_mc);
970  fResultsHistogramArray[3][2] = hist_BPlus_per_bin_in_Acc_mc;
971 
972  //======================================================================================================================================================
973 
974  //we make the histograms for the Pions and Kaon
975  for (Int_t i = 0; i < 3; i++) {
976 
977  TString add_name = "";
978  TList * listout = 0x0;
979  if (i == 0) listout = fOutputD0FirstDaughter;
980  if (i == 1) listout = fOutputD0SecondDaughter;
981  if (i == 2) listout = fOutputBPlusPion;
982 
983  for (Int_t j = 0; j < 6; j++) {
984  if (j == 0) add_name = "";
985  if (j == 1) add_name = "Signal";
986  if (j == 2) add_name = "Cut";
987  if (j == 3) add_name = "SignalCut";
988  if (j == 4) add_name = "Result";
989  if (j == 5) add_name = "SignalResult";
990 
991  TString name_Histogram = "";
992  TString discription_Histogram = "";
993  Int_t numberOfBins = 0;
994  Double_t lowerBound = 0.0;
995  Double_t upperBound = 0.0;
996 
997  for (Int_t k = 0; k < 10; ++k)
998  {
999  if (k == 0) {name_Histogram = "ptTrack"; discription_Histogram = "pt track; p_{T} [GeV/c]; Entries"; numberOfBins = 600; lowerBound = 0; upperBound = 30;}
1000  if (k == 1) {name_Histogram = "momentumTrack"; discription_Histogram = "momentum track; p [GeV/c]; Entries"; numberOfBins = 600; lowerBound = 0; upperBound = 30;}
1001  if (k == 2) {name_Histogram = "numberOfITS"; discription_Histogram = "Number of ITS clusters track; [#]; Entries"; numberOfBins = 10; lowerBound = -0.5; upperBound = 9.5;}
1002  if (k == 3) {name_Histogram = "numberOfTPC"; discription_Histogram = "Number of TPC clusters track; [#]; Entries"; numberOfBins = 601; lowerBound = -0.5; upperBound = 600.5;}
1003  if (k == 4) {name_Histogram = "pointsOnITS"; discription_Histogram = "Number of ITS clusters track per layer; [#]; Entries"; numberOfBins = 10; lowerBound = -0.5; upperBound = 9.5;}
1004  if (k == 5) {name_Histogram = "nSigmaTPC"; discription_Histogram = "n sigma TPC for track PID; sigma; Entries"; numberOfBins = 500; lowerBound = -5; upperBound = 5;}
1005  if (k == 6) {name_Histogram = "nSigmaTOF"; discription_Histogram = "n sigma TOF for track PID; sigma; Entries"; numberOfBins = 500; lowerBound = -5; upperBound = 5;}
1006  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;}
1007  if (k == 8) {name_Histogram = "impactParameter"; discription_Histogram = "Impact Parameter track; [cm]; Entries"; numberOfBins = 2000; lowerBound = 0; upperBound = 0.5;}
1008  if (k == 9) {name_Histogram = "EtaTrack"; discription_Histogram = "Eta Track; Entries"; numberOfBins = 1000; lowerBound = -3; upperBound = 3;}
1009 
1010  name_Histogram += add_name;
1011  TH1F* histogram = new TH1F(name_Histogram.Data(), discription_Histogram.Data(), numberOfBins, lowerBound, upperBound);
1012  histogram->Sumw2();
1013  if (j % 2 == 0) histogram->SetLineColor(6);
1014  if (j % 2 == 1) histogram->SetLineColor(4);
1015  histogram->SetMarkerStyle(20);
1016  histogram->SetMarkerSize(0.6);
1017  if (j % 2 == 0) histogram->SetMarkerColor(6);
1018  if (j % 2 == 1) histogram->SetMarkerColor(4);
1019  TH1F* histogram_Clone = (TH1F*)histogram->Clone();
1020  listout->Add(histogram_Clone);
1021  fDaughterHistogramArray[i][j][k] = histogram_Clone;
1022  }
1023 
1024  TString numberofparticlesperevent = "numberofparticlesperevent";
1025  numberofparticlesperevent += add_name;
1026  TH1F* hist_numberofparticlesperevent = new TH1F(numberofparticlesperevent.Data(), "Number of particles per event; number of particles in one event; Entries", 100, 0, 100);
1027  hist_numberofparticlesperevent->Sumw2();
1028  hist_numberofparticlesperevent->SetLineColor(6);
1029  hist_numberofparticlesperevent->SetMarkerStyle(20);
1030  hist_numberofparticlesperevent->SetMarkerSize(0.6);
1031  hist_numberofparticlesperevent->SetMarkerColor(6);
1032  TH1F* histogram_numberofparticlesperevent = (TH1F*)hist_numberofparticlesperevent->Clone();
1033  listout->Add(histogram_numberofparticlesperevent);
1034  fDaughterHistogramArray[i][j][10] = histogram_numberofparticlesperevent;
1035  }
1036 
1037  TH1F * effectOfCuts = new TH1F("effectOfCuts", "Removal counter", 18, 0, 18);
1038  effectOfCuts->SetStats(kTRUE);
1039  effectOfCuts->GetXaxis()->SetTitle("Cut number");
1040  effectOfCuts->GetYaxis()->SetTitle("Particles cut");
1041  effectOfCuts->GetXaxis()->SetBinLabel(1, "total");
1042  effectOfCuts->GetXaxis()->SetBinLabel(2, "1");
1043  effectOfCuts->GetXaxis()->SetBinLabel(3, "2");
1044  effectOfCuts->GetXaxis()->SetBinLabel(4, "3");
1045  effectOfCuts->GetXaxis()->SetBinLabel(5, "4");
1046  effectOfCuts->GetXaxis()->SetBinLabel(6, "5");
1047  effectOfCuts->GetXaxis()->SetBinLabel(7, "6");
1048  effectOfCuts->GetXaxis()->SetBinLabel(8, "7");
1049  effectOfCuts->GetXaxis()->SetBinLabel(9, "8");
1050  effectOfCuts->GetXaxis()->SetBinLabel(10, "9");
1051  effectOfCuts->GetXaxis()->SetBinLabel(11, "10");
1052  effectOfCuts->GetXaxis()->SetBinLabel(12, "11");
1053  effectOfCuts->GetXaxis()->SetBinLabel(13, "12");
1054  effectOfCuts->GetXaxis()->SetBinLabel(14, "13");
1055  effectOfCuts->GetXaxis()->SetBinLabel(15, "14");
1056  effectOfCuts->GetXaxis()->SetBinLabel(16, "15");
1057  effectOfCuts->GetXaxis()->SetBinLabel(17, "16");
1058  effectOfCuts->GetXaxis()->SetBinLabel(18, "17");
1059  listout->Add(effectOfCuts);
1060  fDaughterHistogramArrayExtra[i][0] = effectOfCuts;
1061 
1062  TH1F * effectOfCutsSignal = new TH1F("effectOfCutsSignal", "Removal counter", 18, 0, 18);
1063  effectOfCutsSignal->SetStats(kTRUE);
1064  effectOfCutsSignal->GetXaxis()->SetTitle("Cut number");
1065  effectOfCutsSignal->GetYaxis()->SetTitle("Particles cut");
1066  effectOfCutsSignal->GetXaxis()->SetBinLabel(1, "total");
1067  effectOfCutsSignal->GetXaxis()->SetBinLabel(2, "1");
1068  effectOfCutsSignal->GetXaxis()->SetBinLabel(3, "2");
1069  effectOfCutsSignal->GetXaxis()->SetBinLabel(4, "3");
1070  effectOfCutsSignal->GetXaxis()->SetBinLabel(5, "4");
1071  effectOfCutsSignal->GetXaxis()->SetBinLabel(6, "5");
1072  effectOfCutsSignal->GetXaxis()->SetBinLabel(7, "6");
1073  effectOfCutsSignal->GetXaxis()->SetBinLabel(8, "7");
1074  effectOfCutsSignal->GetXaxis()->SetBinLabel(9, "8");
1075  effectOfCutsSignal->GetXaxis()->SetBinLabel(10, "9");
1076  effectOfCutsSignal->GetXaxis()->SetBinLabel(11, "10");
1077  effectOfCutsSignal->GetXaxis()->SetBinLabel(12, "11");
1078  effectOfCutsSignal->GetXaxis()->SetBinLabel(13, "12");
1079  effectOfCutsSignal->GetXaxis()->SetBinLabel(14, "13");
1080  effectOfCutsSignal->GetXaxis()->SetBinLabel(15, "14");
1081  effectOfCutsSignal->GetXaxis()->SetBinLabel(16, "15");
1082  effectOfCutsSignal->GetXaxis()->SetBinLabel(17, "16");
1083  effectOfCutsSignal->GetXaxis()->SetBinLabel(18, "17");
1084  listout->Add(effectOfCutsSignal);
1085  fDaughterHistogramArrayExtra[i][1] = effectOfCutsSignal;
1086 
1087  TString name_particle_pdg = "particle_pdg";
1088  TH1F* hist_particle_pdg = new TH1F(name_particle_pdg.Data(), "Pdg code particle; pdg code; Entries", 2000, -0.5, 1999.5);
1089  hist_particle_pdg->Sumw2();
1090  hist_particle_pdg->SetLineColor(6);
1091  hist_particle_pdg->SetMarkerStyle(20);
1092  hist_particle_pdg->SetMarkerSize(0.6);
1093  hist_particle_pdg->SetMarkerColor(6);
1094  TH1F* histogram_particle_pdg = (TH1F*)hist_particle_pdg->Clone();
1095  listout->Add(histogram_particle_pdg);
1096  fDaughterHistogramArrayExtra[i][2] = histogram_particle_pdg;
1097 
1098  TString name_particle_mother_pdg = "particle_mother_pdg";
1099  TH1F* hist_particle_mother_pdg = new TH1F(name_particle_mother_pdg.Data(), "Pdg code particle mother; pdg code; Entries", 2000, -0.5, 1999.5);
1100  hist_particle_mother_pdg->Sumw2();
1101  hist_particle_mother_pdg->SetLineColor(6);
1102  hist_particle_mother_pdg->SetMarkerStyle(20);
1103  hist_particle_mother_pdg->SetMarkerSize(0.6);
1104  hist_particle_mother_pdg->SetMarkerColor(6);
1105  TH1F* histogram_particle_mother_pdg = (TH1F*)hist_particle_mother_pdg->Clone();
1106  listout->Add(histogram_particle_mother_pdg);
1107  fDaughterHistogramArrayExtra[i][3] = histogram_particle_mother_pdg;
1108 
1109  TString name_ptBPlus_vs_ptTrack = "ptBPlus_vs_ptTrackBackground";
1110  TH2F* hist_ptBPlus_vs_ptTrack = new TH2F(name_ptBPlus_vs_ptTrack.Data(), "Pt BPlus vs Pt ; p_{T} BPlus [GeV/c]; p_{T} track [GeV/c]", 100, 0, 30, 100, 0, 30);
1111  hist_ptBPlus_vs_ptTrack->Sumw2();
1112  hist_ptBPlus_vs_ptTrack->SetLineColor(6);
1113  hist_ptBPlus_vs_ptTrack->SetMarkerStyle(20);
1114  hist_ptBPlus_vs_ptTrack->SetMarkerSize(0.6);
1115  hist_ptBPlus_vs_ptTrack->SetMarkerColor(6);
1116  TH2F* histogram_ptBPlus_vs_ptTrack = (TH2F*)hist_ptBPlus_vs_ptTrack->Clone();
1117  listout->Add(histogram_ptBPlus_vs_ptTrack);
1118  fDaughterHistogramArray2D[i][4] = histogram_ptBPlus_vs_ptTrack;
1119 
1120  TString name_ptBPlus_vs_ptTrackSignal = "ptBPlus_vs_ptTrackSignal";
1121  TH2F* hist_ptBPlus_vs_ptTrackSignal = new TH2F(name_ptBPlus_vs_ptTrackSignal.Data(), "Pt BPlus vs Pt ; p_{T} BPlus [GeV/c]; p_{T} track [GeV/c]", 100, 0, 30, 100, 0, 30);
1122  hist_ptBPlus_vs_ptTrackSignal->Sumw2();
1123  hist_ptBPlus_vs_ptTrackSignal->SetLineColor(4);
1124  hist_ptBPlus_vs_ptTrackSignal->SetMarkerStyle(20);
1125  hist_ptBPlus_vs_ptTrackSignal->SetMarkerSize(0.6);
1126  hist_ptBPlus_vs_ptTrackSignal->SetMarkerColor(6);
1127  TH2F* histogram_ptBPlus_vs_ptTrackSignal = (TH2F*)hist_ptBPlus_vs_ptTrackSignal->Clone();
1128  listout->Add(histogram_ptBPlus_vs_ptTrackSignal);
1129  fDaughterHistogramArray2D[i][5] = histogram_ptBPlus_vs_ptTrackSignal;
1130  }
1131 
1132  //we make the histograms for the reconstructed particles
1133  for (Int_t i = 0; i < 3; i++) {
1134 
1135  TString add_name = "";
1136  TList * listout = 0x0;
1137  Int_t nHistogramSets = 0;
1138  if (i == 0) {listout = fOutputD0; nHistogramSets = 6 + 2 * fnPtBins;}
1139  if (i == 1) {listout = fOutputBPlus; nHistogramSets = 6 + 2 * fnPtBins;}
1140  if (i == 2) {listout = fOutputD0_D0Pt; nHistogramSets = 2 * fnPtBinsD0forD0ptbin;}
1141 
1142 
1143  for (Int_t j = 0; j < nHistogramSets; j++) {
1144  if (i < 2)
1145  {
1146  if (j == 0) add_name = "Uncut";
1147  if (j == 1) add_name = "SignalUncut";
1148  if (j == 2) add_name = "Cut";
1149  if (j == 3) add_name = "SignalCut";
1150  if (j == 4) add_name = "Result";
1151  if (j == 5) add_name = "SignalResult";
1152  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];}
1153  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];}
1154  }
1155  if (i == 2)
1156  {
1157  if (j % 2 == 0) {add_name = "_ptbin_"; add_name += fPtBinLimitsD0forD0ptbin[j / 2]; add_name += "_to_"; add_name += fPtBinLimitsD0forD0ptbin[1 + j / 2];}
1158  if (j % 2 == 1) {add_name = "Signal_ptbin_"; add_name += fPtBinLimitsD0forD0ptbin[(j - 1) / 2]; add_name += "_to_"; add_name += fPtBinLimitsD0forD0ptbin[1 + (j - 1) / 2];}
1159  }
1160 
1161  TList * listCandidates = new TList();
1162  listCandidates->SetOwner();
1163  listCandidates->SetName(add_name);
1164  listout->Add(listCandidates);
1165 
1166  TString name_Histogram = "";
1167  TString discription_Histogram = "";
1168  Int_t numberOfBins = 0;
1169  Double_t lowerBound = 0.0;
1170  Double_t upperBound = 0.0;
1171  Int_t numberOfBinsTwo = 0;
1172  Double_t lowerBoundTwo = 0.0;
1173  Double_t upperBoundTwo = 0.0;
1174 
1175  for (Int_t k = 0; k < 49; ++k)
1176  {
1177  if (k == 0) {name_Histogram = "ptMother"; discription_Histogram = "pt mother; p_{T} [GeV/c]; Entries"; numberOfBins = 300; lowerBound = 0; upperBound = 30;}
1178  if (k == 1) {name_Histogram = "ptFirstDaughter"; discription_Histogram = "pt first daughter; p_{T} [GeV/c]; Entries"; numberOfBins = 300; lowerBound = 0; upperBound = 30;}
1179  if (k == 2) {name_Histogram = "ptSecondDaughter"; discription_Histogram = "pt second daughter; p_{T} [GeV/c]; Entries"; numberOfBins = 300; lowerBound = 0; upperBound = 30;}
1180  if (k == 3) {name_Histogram = "etaMother"; discription_Histogram = "eta mother; #eta; Entries"; numberOfBins = 100; lowerBound = -2; upperBound = 2;}
1181  if (k == 4) {name_Histogram = "phiMother"; discription_Histogram = "phi mother; #phi; Entries"; numberOfBins = 25; lowerBound = 0; upperBound = 2 * TMath::Pi();}
1182  if (k == 5) {name_Histogram = "d0Mother"; discription_Histogram = "d0 mother; [cm]; Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 1.0;}
1183  if (k == 6) {name_Histogram = "d0FirstDaughter"; discription_Histogram = "d0 first daughter; [cm]; Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 1;}
1184 
1185  if (k == 7) {name_Histogram = "d0SecondDaughter"; discription_Histogram = "d0 second daughter; [cm]; Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 1;}
1186 
1187  if (k == 8) {name_Histogram = "pointingAngleMother"; discription_Histogram = "pointing angle; [Cos(#theta)]; Entries"; numberOfBins = 100; lowerBound = -1; upperBound = 1;}
1188  if (k == 9) {name_Histogram = "impactProduct"; discription_Histogram = "impact product; [cm^{2}]; Entries"; numberOfBins = 500; lowerBound = -0.01; upperBound = 0.01;}
1189  if (k == 10) {name_Histogram = "impactProductXY"; discription_Histogram = "impact product XY; [cm^{2}]; Entries"; numberOfBins = 200; lowerBound = 0; upperBound = 0.5;}
1190  if (k == 11) {name_Histogram = "invariantMassMother"; discription_Histogram = "mass mother candidate; m [GeV/c^{2}]; Entries"; numberOfBins = 10000; lowerBound = 0; upperBound = 10;}
1191  if (k == 12) {name_Histogram = "deltaMassMother"; discription_Histogram = "mass mother candidate; m [GeV/c^{2}]; Entries"; numberOfBins = 10000; lowerBound = 0; upperBound = 10;}
1192  if (k == 13) {name_Histogram = "dcaMother"; discription_Histogram = "dca mother; distance [cm]; Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 0.25;}
1193  if (k == 14) {name_Histogram = "vertexDistance"; discription_Histogram = "vertex distance between mother and primary vertex; distance [cm]; Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 1;}
1194  if (k == 15) {name_Histogram = "normDecayLength"; discription_Histogram = "Normalized decay length w.r.t primary vertex; [cm]; Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 50;}
1195  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;}
1196  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;}
1197  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;}
1198  if (k == 19) {name_Histogram = "angleMotherFirstDaughter"; discription_Histogram = "flight angle mother and first daughter; [Cos(#phi)]; Entries"; numberOfBins = 100; lowerBound = -1; upperBound = 1;}
1199  if (k == 20) {name_Histogram = "angleMotherSecondDaughter"; discription_Histogram = "flight angle mother and second daughter; [Cos(#phi)]; Entries"; numberOfBins = 100; lowerBound = 0.5; upperBound = 1;}
1200  if (k == 21) {name_Histogram = "angleBetweenBothDaughters"; discription_Histogram = "angle between both daughters; [Cos(#phi)]; Entries"; numberOfBins = 100; lowerBound = -1; upperBound = 1;}
1201  if (k == 22) {name_Histogram = "cosThetaStar"; discription_Histogram = "cosThetaStar; [Cos(#theta*)]; Entries"; numberOfBins = 200; lowerBound = -2; upperBound = 2;}
1202  if (k == 23) {name_Histogram = "vertexX"; discription_Histogram = "Vertex position; [cm]; Entries"; numberOfBins = 500; lowerBound = -5; upperBound = 5;}
1203  if (k == 24) {name_Histogram = "vertexY"; discription_Histogram = "Vertex position; [cm]; Entries"; numberOfBins = 500; lowerBound = -5; upperBound = 5;}
1204  if (k == 25) {name_Histogram = "vertexZ"; discription_Histogram = "Vertex position; [cm]; Entries"; numberOfBins = 500; lowerBound = -20; upperBound = 20;}
1205 
1206 
1207  if (k == 26) {
1208  if (i == 0) {name_Histogram = "pointingAngleToBPlus"; discription_Histogram = "Pointing angle w.r.t. BPlus decay vertex; [Cos(#theta)]; Entries"; numberOfBins = 200; lowerBound = -1; upperBound = 1;}
1209  else continue;
1210  }
1211  if (k == 27) {
1212  if (i == 0) {name_Histogram = "d0MotherToBPlus"; discription_Histogram = "d0 Mother w.r.t. BPlus decay vertex; [cm]; Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 1;}
1213  else continue;
1214  }
1215  if (k == 28) {
1216  if (i == 0) {name_Histogram = "d0FirstDaughterToBPlus"; discription_Histogram = "d0 first daughter w.r.t. BPlus decay vertex; [cm]; Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 1;}
1217  else continue;
1218  }
1219  if (k == 29) {
1220  if (i == 0) {name_Histogram = "d0SecondDaughterToBPlus"; discription_Histogram = "d0 second daughter w.r.t. BPlus decay vertex; [cm]; Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 1;}
1221  else continue;
1222  }
1223  if (k == 30) {
1224  if (i == 0) {name_Histogram = "impactProductToBPlus"; discription_Histogram = "impact product w.r.t. BPlus decay vertex; [cm]; Entries"; numberOfBins = 400; lowerBound = -0.02; upperBound = 0.02;}
1225  else continue;
1226  }
1227  if (k == 31) {
1228  if (i == 0) {name_Histogram = "impactProductXYToBPlus"; discription_Histogram = "impact product XY w.r.t. BPlus decay vertex; [cm^{2}]; Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 0.5;}
1229  else continue;
1230  }
1231  if (k == 32) {
1232  if (i == 0) {name_Histogram = "normDecayLengthToBPlus"; discription_Histogram = "Normalized decay length w.r.t. BPlus decay vertex; [cm]; Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 50;}
1233  else continue;
1234  }
1235  if (k == 33) {
1236  if (i == 0) {name_Histogram = "pseudoProperDecayTimeToBPlus"; discription_Histogram = "Pseudo Proper Decay Time w.r.t BPlus vertex; [a.u.]; Entries"; numberOfBins = 1000; lowerBound = -1; upperBound = 1;}
1237  else continue;
1238  }
1239  if (k == 34) {
1240  if (i == 0) {name_Histogram = "DecayTimeToBPlus"; discription_Histogram = "Decay Time w.r.t BPlus vertex; [a.u.]; Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 0.00000001;}
1241  else continue;
1242  }
1243  if (k == 35) {
1244  if (i == 0) {name_Histogram = "normDecayTimeToBPlus"; discription_Histogram = "Normalized Decay Time w.r.t BPlus vertex; [a.u.]; Entries"; numberOfBins = 100; lowerBound = 0; upperBound = 0.00000001;}
1245  else continue;
1246  }
1247 
1248  if (k == 36) {name_Histogram = "topomaticFirstDaughter"; discription_Histogram = "topomatic d0 first daughter; [cm]; Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 20;}
1249  if (k == 37) {name_Histogram = "topomaticSecondDaughter"; discription_Histogram = "topomatic d0 second daughter; [cm]; Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 20;}
1250  if (k == 38) {name_Histogram = "topomaticMax"; discription_Histogram = "Max topomatic; [cm]; Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 20;}
1251  if (k == 39) {name_Histogram = "topomaticMin"; discription_Histogram = "Min topomatic; [cm]; Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 20;}
1252  if (k == 40) {name_Histogram = "pointingAngleMotherXY"; discription_Histogram = "pointing angle XY; [Cos(#theta)]; Entries"; numberOfBins = 1000; lowerBound = -1; upperBound = 1;}
1253  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;}
1254  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;}
1255  if (k == 43) {name_Histogram = "vertexChi2"; discription_Histogram = "#Chi^{2} Vertex; [#Chi^{2}]; Entries"; numberOfBins = 1000; lowerBound = 0; upperBound = 50;}
1256  if (k == 44) {name_Histogram = "vertexChi2NDF"; discription_Histogram = "#Chi^{2} per NDF Vertex; [#Chi^{2}/NDF]; Entries"; numberOfBins = 1000; lowerBound = 0; upperBound = 50;}
1257 
1258  if (k == 45) {name_Histogram = "Normd0FirstDaughter"; discription_Histogram = "norm d0 first daughter; [cm]; Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 100;}
1259  if (k == 46) {name_Histogram = "Normd0SecondDaughter"; discription_Histogram = "norm d0 second daughter; [cm]; Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 100;}
1260  if (k == 47) {name_Histogram = "Normd0Mother"; discription_Histogram = "norm d0 mother; [cm]; Entries"; numberOfBins = 500; lowerBound = 0; upperBound = 100;}
1261  if (k == 48) {name_Histogram = "NormimpactProduct"; discription_Histogram = "norm impact product; [cm^{2}]; Entries"; numberOfBins = 500; lowerBound = -200; upperBound = 200;}
1262 
1263  name_Histogram += add_name;
1264  TH1F* histogram = new TH1F(name_Histogram.Data(), discription_Histogram.Data(), numberOfBins, lowerBound, upperBound);
1265  histogram->Sumw2();
1266  if (j % 2 == 0) histogram->SetLineColor(6);
1267  if (j % 2 == 1) histogram->SetLineColor(4);
1268  histogram->SetMarkerStyle(20);
1269  histogram->SetMarkerSize(0.6);
1270  if (j % 2 == 0) histogram->SetMarkerColor(6);
1271  if (j % 2 == 1) histogram->SetMarkerColor(4);
1272  TH1F* histogram_Clone = (TH1F*)histogram->Clone();
1273  listCandidates->Add(histogram_Clone);
1274  fMotherHistogramArray[i][j][k] = histogram_Clone;
1275  }
1276 
1277 
1278  name_Histogram = "";
1279  discription_Histogram = "";
1280  numberOfBins = 0;
1281  lowerBound = 0.0;
1282  upperBound = 0.0;
1283  numberOfBinsTwo = 0;
1284  lowerBoundTwo = 0.0;
1285  upperBoundTwo = 0.0;
1286 
1287  //we make the 2D histograms for the reconstructed particles
1288  Int_t nFirst = 0;
1289  Int_t nSecond = 1;
1290  Int_t nVariables = 10;
1291  Int_t nHistograms = nVariables * (nVariables - 1) / 2;
1292 
1293  TList * list2D = new TList();
1294  list2D->SetOwner();
1295  TString name2D = "2D_Histograms";
1296  name2D += add_name;
1297  list2D->SetName(name2D);
1298  listCandidates->Add(list2D);
1299 
1300  for (Int_t k = 0; k < nHistograms; ++k)
1301  {
1302  numberOfBins = 50; numberOfBinsTwo = 50;
1303  if (nFirst == 0) {name_Histogram = "d0FirstDaughter"; discription_Histogram = "d0 first daughter [cm];"; lowerBound = 0; upperBound = 1;}
1304  if (nFirst == 1) {name_Histogram = "d0SecondDaughter"; discription_Histogram = "d0 second daughter [cm];"; lowerBound = 0; upperBound = 1;}
1305  if (nFirst == 2) {name_Histogram = "d0Mother"; discription_Histogram = "d0 mother [cm];"; lowerBound = 0; upperBound = 1;}
1306  if (nFirst == 3) {name_Histogram = "pointingAngleMother"; discription_Histogram = "pointing angle [Cos(#theta)];"; lowerBound = -1; upperBound = 1;}
1307  if (nFirst == 4) {name_Histogram = "impactProduct"; discription_Histogram = "impact product [cm^{2}];"; lowerBound = -0.01; upperBound = 0.01;}
1308  if (nFirst == 5) {name_Histogram = "impactProductXY"; discription_Histogram = "impact product XY [cm^{2}];"; lowerBound = 0; upperBound = 0.5;}
1309  if (nFirst == 6) {name_Histogram = "vertexDistance"; discription_Histogram = "vertex distance between mother and primary vertex [cm];"; lowerBound = 0; upperBound = 1;}
1310  if (nFirst == 7) {name_Histogram = "normDecayLength"; discription_Histogram = "Normalized decay length w.r.t primary vertex [cm];"; lowerBound = 0; upperBound = 50;}
1311  if (nFirst == 8) {name_Histogram = "pointingAngleMotherXY"; discription_Histogram = "pointing angle XY [Cos(#theta)];"; lowerBound = -1; upperBound = 1;}
1312  if (nFirst == 9) {name_Histogram = "vertexDistanceXY"; discription_Histogram = "vertex distance between mother and primary vertex XY [cm];"; lowerBound = 0; upperBound = 1;}
1313  if (nFirst == 10) {name_Histogram = "normDecayLengthXY"; discription_Histogram = "Normalized decay length w.r.t primary vertex XY [cm];"; lowerBound = 0; upperBound = 50;}
1314 
1315  if (nSecond == 0) {name_Histogram += "d0FirstDaughter"; discription_Histogram += "d0 first daughter [cm];"; lowerBoundTwo = 0; upperBoundTwo = 1;}
1316  if (nSecond == 1) {name_Histogram += "d0SecondDaughter"; discription_Histogram += "d0 second daughter [cm];"; lowerBoundTwo = 0; upperBoundTwo = 1;}
1317  if (nSecond == 2) {name_Histogram += "d0Mother"; discription_Histogram += "d0 mother [cm];"; lowerBoundTwo = 0; upperBoundTwo = 1;}
1318  if (nSecond == 3) {name_Histogram += "pointingAngleMother"; discription_Histogram += "pointing angle [Cos(#theta)];"; lowerBoundTwo = -1; upperBoundTwo = 1;}
1319  if (nSecond == 4) {name_Histogram += "impactProduct"; discription_Histogram += "impact product [cm^{2}];"; lowerBoundTwo = -0.01; upperBoundTwo = 0.01;}
1320  if (nSecond == 5) {name_Histogram += "impactProductXY"; discription_Histogram += "impact product XY [cm^{2}];"; lowerBoundTwo = 0; upperBoundTwo = 0.5;}
1321  if (nSecond == 6) {name_Histogram += "vertexDistance"; discription_Histogram += "vertex distance between mother and primary vertex [cm];"; lowerBoundTwo = 0; upperBoundTwo = 1;}
1322  if (nSecond == 7) {name_Histogram += "normDecayLength"; discription_Histogram += "Normalized decay length w.r.t primary vertex [cm];"; lowerBoundTwo = 0; upperBoundTwo = 50;}
1323  if (nSecond == 8) {name_Histogram += "_pointingAngleMotherXY"; discription_Histogram += "pointing angle XY [Cos(#theta)];"; lowerBoundTwo = -1; upperBoundTwo = 1;}
1324  if (nSecond == 9) {name_Histogram += "_vertexDistanceXY"; discription_Histogram += "vertex distance between mother and primary vertex XY [cm];"; lowerBoundTwo = 0; upperBoundTwo = 1;}
1325  if (nSecond == 10) {name_Histogram += "_normDecayLengthXY"; discription_Histogram += "Normalized decay length w.r.t primary vertex XY [cm];"; lowerBoundTwo = 0; upperBoundTwo = 50;}
1326 
1327  name_Histogram += add_name;
1328  TH2F* histogram = new TH2F(name_Histogram.Data(), discription_Histogram.Data(), numberOfBins, lowerBound, upperBound, numberOfBinsTwo, lowerBoundTwo, upperBoundTwo);
1329  histogram->Sumw2();
1330  if (j % 2 == 0) histogram->SetLineColor(6);
1331  if (j % 2 == 1) histogram->SetLineColor(4);
1332  histogram->SetMarkerStyle(20);
1333  histogram->SetMarkerSize(0.6);
1334  histogram->SetMarkerColor(6);
1335  TH2F* histogram_Clone = (TH2F*)histogram->Clone();
1336  list2D->Add(histogram_Clone);
1337  fMotherHistogramArray2D[i][j][k] = histogram_Clone;
1338 
1339  nSecond++;
1340  if (nSecond > nVariables)
1341  {
1342  nFirst++;
1343  nSecond = nFirst + 1;
1344  }
1345  }
1346  }
1347 
1348  TH1F * effectOfCuts = new TH1F("effectOfCuts", "Removal counter", 100, 0, 100);
1349  effectOfCuts->SetStats(kTRUE);
1350  effectOfCuts->GetXaxis()->SetTitle("Cut number");
1351  effectOfCuts->GetYaxis()->SetTitle("Particles cut");
1352  effectOfCuts->GetXaxis()->SetBinLabel(1, "total");
1353  for (Int_t i = 1; i < 100; ++i)
1354  {
1355  TString integerText = "";
1356  integerText += i - 1;
1357  effectOfCuts->GetXaxis()->SetBinLabel(i + 1, integerText);
1358  }
1359  listout->Add(effectOfCuts);
1360  fMotherHistogramArrayExtra[i][0] = effectOfCuts;
1361 
1362  TH1F * effectOfCutsSignal = new TH1F("effectOfCutsSignal", "Removal counter", 100, 0, 100);
1363  effectOfCutsSignal->SetStats(kTRUE);
1364  effectOfCutsSignal->GetXaxis()->SetTitle("Cut number");
1365  effectOfCutsSignal->GetYaxis()->SetTitle("Particles cut");
1366  effectOfCutsSignal->GetXaxis()->SetBinLabel(1, "total");
1367  for (Int_t i = 1; i < 100; ++i)
1368  {
1369  TString integerText = "";
1370  integerText += i - 1;
1371  effectOfCutsSignal->GetXaxis()->SetBinLabel(i + 1, integerText);
1372  }
1373  listout->Add(effectOfCutsSignal);
1374  fMotherHistogramArrayExtra[i][1] = effectOfCutsSignal;
1375 
1376  TString name_particle_pdg = "particle_pdg";
1377  TH1F* hist_particle_pdg = new TH1F(name_particle_pdg.Data(), "Pdg code particle; pdg code; Entries", 2000, -0.5, 1999.5);
1378  hist_particle_pdg->Sumw2();
1379  hist_particle_pdg->SetLineColor(6);
1380  hist_particle_pdg->SetMarkerStyle(20);
1381  hist_particle_pdg->SetMarkerSize(0.6);
1382  hist_particle_pdg->SetMarkerColor(6);
1383  TH1F* histogram_particle_pdg = (TH1F*)hist_particle_pdg->Clone();
1384  listout->Add(histogram_particle_pdg);
1385  fMotherHistogramArrayExtra[i][2] = histogram_particle_pdg;
1386 
1387  TString name_particle_mother_pdg = "particle_mother_pdg";
1388  TH1F* hist_particle_mother_pdg = new TH1F(name_particle_mother_pdg.Data(), "Pdg code particle mother; pdg code; Entries", 2000, -0.5, 1999.5);
1389  hist_particle_mother_pdg->Sumw2();
1390  hist_particle_mother_pdg->SetLineColor(6);
1391  hist_particle_mother_pdg->SetMarkerStyle(20);
1392  hist_particle_mother_pdg->SetMarkerSize(0.6);
1393  hist_particle_mother_pdg->SetMarkerColor(6);
1394  TH1F* histogram_particle_mother_pdg = (TH1F*)hist_particle_mother_pdg->Clone();
1395  listout->Add(histogram_particle_mother_pdg);
1396  fMotherHistogramArrayExtra[i][3] = histogram_particle_mother_pdg;
1397 
1398  TString name_distance_vertex_from_real = "distance_vertex_from_real";
1399  TH1F* hist_distance_vertex_from_real = new TH1F(name_distance_vertex_from_real.Data(), "Distance reconstructed vertex from real vertex; distance [cm]; Entries", 500, 0, 0.5);
1400  hist_distance_vertex_from_real->Sumw2();
1401  hist_distance_vertex_from_real->SetLineColor(6);
1402  hist_distance_vertex_from_real->SetMarkerStyle(20);
1403  hist_distance_vertex_from_real->SetMarkerSize(0.6);
1404  hist_distance_vertex_from_real->SetMarkerColor(6);
1405  TH1F* histogram_distance_vertex_from_real = (TH1F*)hist_distance_vertex_from_real->Clone();
1406  listout->Add(histogram_distance_vertex_from_real);
1407  fMotherHistogramArrayExtra[i][4] = histogram_distance_vertex_from_real;
1408 
1409  TString name_distance_vertex_from_real_new = "distance_vertex_from_real_new";
1410  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", 500, 0, 0.5);
1411  hist_distance_vertex_from_real_new->Sumw2();
1412  hist_distance_vertex_from_real_new->SetLineColor(6);
1413  hist_distance_vertex_from_real_new->SetMarkerStyle(20);
1414  hist_distance_vertex_from_real_new->SetMarkerSize(0.6);
1415  hist_distance_vertex_from_real_new->SetMarkerColor(6);
1416  TH1F* histogram_distance_vertex_from_real_new = (TH1F*)hist_distance_vertex_from_real_new->Clone();
1417  listout->Add(histogram_distance_vertex_from_real_new);
1418  fMotherHistogramArrayExtra[i][5] = histogram_distance_vertex_from_real_new;
1419 
1420  TString name_momentum_resolution = "momentum_resolution";
1421  TH1F* hist_momentum_resolution = new TH1F(name_momentum_resolution.Data(), "Momentum resolution; difference between real and reconstructed momentum [GeV/c]; Entries", 1000, 0, 1);
1422  hist_momentum_resolution->Sumw2();
1423  hist_momentum_resolution->SetLineColor(6);
1424  hist_momentum_resolution->SetMarkerStyle(20);
1425  hist_momentum_resolution->SetMarkerSize(0.6);
1426  hist_momentum_resolution->SetMarkerColor(6);
1427  TH1F* histogram_momentum_resolution = (TH1F*)hist_momentum_resolution->Clone();
1428  listout->Add(histogram_momentum_resolution);
1429  fMotherHistogramArrayExtra[i][6] = histogram_momentum_resolution;
1430  }
1431 
1432 
1433 
1434  //we make the histograms for the same sign method histograms and the pt bins
1435  for (Int_t i = 0; i < 7; ++i) {
1436  TString typeListName = "";
1437  if (i == 0) typeListName = "MassPlots";
1438  if (i == 1) typeListName = "MassPlots_SameSign";
1439  if (i == 2) typeListName = "MassPlots_SignSum";
1440  if (i == 3) typeListName = "MassPlots_Background_rotation";
1441  if (i == 4) typeListName = "MassPlots_HIJING_Background";
1442  if (i == 5) typeListName = "MassPlots_HIJING_Signal";
1443  if (i == 6) typeListName = "MassPlots_HIJING_Background_rotation";
1444 
1445  TList * listMassPlots = new TList();
1446  listMassPlots->SetOwner();
1447  listMassPlots->SetName(typeListName);
1448  fOutputBPlusResults->Add(listMassPlots);
1449 
1450  for (Int_t k = 0; k < fnPtBins + 3; ++k) {
1451  TString ptBinMother = "";
1452  if (k == 0) ptBinMother = "";
1453  if (k == 1) ptBinMother = "_ptbin_3_to_inf";
1454  if (k == 2) ptBinMother = "_ptbin_6_to_inf";
1455  if (k > 2) {ptBinMother += "_ptbin_"; ptBinMother += fPtBinLimits[k - 3]; ptBinMother += "_to_"; ptBinMother += fPtBinLimits[k - 2];}
1456 
1457  TString name_invariantMassMother = "invariantMassBPlus";
1458  name_invariantMassMother += ptBinMother;
1459  TH1F* hist_invariantMassMother = new TH1F(name_invariantMassMother.Data(), "mass mother candidate; m [GeV/c^2]; Entries", 2000, 0, 20);
1460  hist_invariantMassMother->Sumw2();
1461  hist_invariantMassMother->SetLineColor(6);
1462  hist_invariantMassMother->SetMarkerStyle(20);
1463  hist_invariantMassMother->SetMarkerSize(0.6);
1464  hist_invariantMassMother->SetMarkerColor(6);
1465  TH1F* histogram_invariantMassMother = (TH1F*)hist_invariantMassMother->Clone();
1466  listMassPlots->Add(histogram_invariantMassMother);
1467  fResultsHistogramArray[4 + i][k] = histogram_invariantMassMother;
1468  }
1469  for (Int_t k = 0; k < fnPtBins + 3; ++k) {
1470  TString ptBinMother = "";
1471  if (k == 0) ptBinMother = "";
1472  if (k == 1) ptBinMother = "_ptbin_3_to_inf";
1473  if (k == 2) ptBinMother = "_ptbin_6_to_inf";
1474  if (k > 2) {ptBinMother += "_ptbin_"; ptBinMother += fPtBinLimits[k - 3]; ptBinMother += "_to_"; ptBinMother += fPtBinLimits[k - 2];}
1475 
1476  TString name_deltainvariantMassMother = "deltainvariantMassBPlus";
1477  name_deltainvariantMassMother += ptBinMother;
1478  TH1F* hist_deltainvariantMassMother = new TH1F(name_deltainvariantMassMother.Data(), "delta mass mother candidate; m [GeV/c^2]; Entries", 2000, 0, 20);
1479  hist_deltainvariantMassMother->Sumw2();
1480  hist_deltainvariantMassMother->SetLineColor(6);
1481  hist_deltainvariantMassMother->SetMarkerStyle(20);
1482  hist_deltainvariantMassMother->SetMarkerSize(0.6);
1483  hist_deltainvariantMassMother->SetMarkerColor(6);
1484  TH1F* histogram_deltainvariantMassMother = (TH1F*)hist_deltainvariantMassMother->Clone();
1485  listMassPlots->Add(histogram_deltainvariantMassMother);
1486  fResultsHistogramArray[4 + i][k + fnPtBins + 3] = histogram_deltainvariantMassMother;
1487  }
1488  }
1489 
1490 
1491  TString name_cutEffectBackground = "cutEffectBackground";
1492  TH2F* hist_cutEffectBackground = new TH2F(name_cutEffectBackground.Data(), "Effect of Cuts on background; cut number; cut number", 99, 0, 99, 99, 0, 99);
1493  for (int i = 0; i < 99; ++i)
1494  {
1495  TString integerText = "";
1496  integerText += i;
1497  hist_cutEffectBackground->GetXaxis()->SetBinLabel(i + 1, integerText);
1498  hist_cutEffectBackground->GetYaxis()->SetBinLabel(i + 1, integerText);
1499  }
1500  TH2F* histogram_cutEffectBackground = (TH2F*)hist_cutEffectBackground->Clone();
1501  fOutputBPlusResults->Add(histogram_cutEffectBackground);
1502  fResultsHistogramArray2D[2][0] = histogram_cutEffectBackground;
1503 
1504 
1505  TString name_cutEffectSignal = "cutEffectSignal";
1506  TH2F* hist_cutEffectSignal = new TH2F(name_cutEffectSignal.Data(), "Effect of Cuts on Signal; cut number; cut number", 99, 0, 99, 99, 0, 99);
1507  for (Int_t i = 0; i < 99; ++i)
1508  {
1509  TString integerText = "";
1510  integerText += i;
1511  hist_cutEffectSignal->GetXaxis()->SetBinLabel(i + 1, integerText);
1512  hist_cutEffectSignal->GetYaxis()->SetBinLabel(i + 1, integerText);
1513  }
1514  TH2F* histogram_cutEffectSignal = (TH2F*)hist_cutEffectSignal->Clone();
1515  fOutputBPlusResults->Add(histogram_cutEffectSignal);
1516  fResultsHistogramArray2D[2][1] = histogram_cutEffectSignal;
1517 
1518  TString name_cutEffectUniqueBackground = "cutEffectUniqueBackground";
1519  TH1F* hist_cutEffectUniqueBackground = new TH1F(name_cutEffectUniqueBackground.Data(), "Effect of Cuts on Signal; cut number; cut number", 99, 0, 99);
1520  for (Int_t i = 0; i < 99; ++i)
1521  {
1522  TString integerText = "";
1523  integerText += i;
1524  hist_cutEffectUniqueBackground->GetXaxis()->SetBinLabel(i + 1, integerText);
1525  }
1526  TH1F* histogram_cutEffectUniqueBackground = (TH1F*)hist_cutEffectUniqueBackground->Clone();
1527  fOutputBPlusResults->Add(histogram_cutEffectUniqueBackground);
1528  fResultsHistogramArray[13][0] = histogram_cutEffectUniqueBackground;
1529 
1530  TString name_cutEffectUniqueSignal = "cutEffectUniqueSignal";
1531  TH1F* hist_cutEffectUniqueSignal = new TH1F(name_cutEffectUniqueSignal.Data(), "Effect of Cuts on Signal; cut number; cut number", 99, 0, 99);
1532  for (Int_t i = 0; i < 99; ++i)
1533  {
1534  TString integerText = "";
1535  integerText += i;
1536  hist_cutEffectUniqueSignal->GetXaxis()->SetBinLabel(i + 1, integerText);
1537  }
1538  TH1F* histogram_cutEffectUniqueSignal = (TH1F*)hist_cutEffectUniqueSignal->Clone();
1539  fOutputBPlusResults->Add(histogram_cutEffectUniqueSignal);
1540  fResultsHistogramArray[13][1] = histogram_cutEffectUniqueSignal;
1541 
1542  TString name_totalITSBackground = "totalITSBackground";
1543  TH1F* hist_totalITSBackground = new TH1F(name_totalITSBackground.Data(), "Total nr. of ITS hits for the daughters; number [#]; Entries", 30, 0, 30);
1544  hist_totalITSBackground->Sumw2();
1545  hist_totalITSBackground->SetLineColor(6);
1546  hist_totalITSBackground->SetMarkerStyle(20);
1547  hist_totalITSBackground->SetMarkerSize(0.6);
1548  hist_totalITSBackground->SetMarkerColor(6);
1549  TH1F* histogram_totalITSBackground = (TH1F*)hist_totalITSBackground->Clone();
1550  fOutputBPlusResults->Add(histogram_totalITSBackground);
1551  fResultsHistogramArray[11][0] = histogram_totalITSBackground;
1552 
1553  TString name_totalITSSignal = "totalITSSignal";
1554  TH1F* hist_totalITSSignal = new TH1F(name_totalITSSignal.Data(), "Total nr. of ITS hits for the daughters; number [#]; Entries", 30, 0, 30);
1555  hist_totalITSSignal->Sumw2();
1556  hist_totalITSSignal->SetLineColor(6);
1557  hist_totalITSSignal->SetMarkerStyle(20);
1558  hist_totalITSSignal->SetMarkerSize(0.6);
1559  hist_totalITSSignal->SetMarkerColor(6);
1560  TH1F* histogram_totalITSSignal = (TH1F*)hist_totalITSSignal->Clone();
1561  fOutputBPlusResults->Add(histogram_totalITSSignal);
1562  fResultsHistogramArray[11][1] = histogram_totalITSSignal;
1563 
1564  TString name_totalTPCBackground = "totalTPCBackground";
1565  TH1F* hist_totalTPCBackground = new TH1F(name_totalTPCBackground.Data(), "Total nr. of TPC hits for the daughters; number [#]; Entries", 1000, 0, 1000);
1566  hist_totalTPCBackground->Sumw2();
1567  hist_totalTPCBackground->SetLineColor(6);
1568  hist_totalTPCBackground->SetMarkerStyle(20);
1569  hist_totalTPCBackground->SetMarkerSize(0.6);
1570  hist_totalTPCBackground->SetMarkerColor(6);
1571  TH1F* histogram_totalTPCBackground = (TH1F*)hist_totalTPCBackground->Clone();
1572  fOutputBPlusResults->Add(histogram_totalTPCBackground);
1573  fResultsHistogramArray[11][2] = histogram_totalTPCBackground;
1574 
1575  TString name_totalTPCSignal = "totalTPCSignal";
1576  TH1F* hist_totalTPCSignal = new TH1F(name_totalTPCSignal.Data(), "Total nr. of TPC hits for the daughters; number [#]; Entries", 1000, 0, 1000);
1577  hist_totalTPCSignal->Sumw2();
1578  hist_totalTPCSignal->SetLineColor(6);
1579  hist_totalTPCSignal->SetMarkerStyle(20);
1580  hist_totalTPCSignal->SetMarkerSize(0.6);
1581  hist_totalTPCSignal->SetMarkerColor(6);
1582  TH1F* histogram_totalTPCSignal = (TH1F*)hist_totalTPCSignal->Clone();
1583  fOutputBPlusResults->Add(histogram_totalTPCSignal);
1584  fResultsHistogramArray[11][3] = histogram_totalTPCSignal;
1585 
1586  TString name_totalSigmaPIDBackground = "totalSigmaPIDBackground";
1587  TH1F* hist_totalSigmaPIDBackground = new TH1F(name_totalSigmaPIDBackground.Data(), "Total sigma of TPC and TOF PID for the daughters; number [#]; Entries", 1000, 0, 100);
1588  hist_totalSigmaPIDBackground->Sumw2();
1589  hist_totalSigmaPIDBackground->SetLineColor(6);
1590  hist_totalSigmaPIDBackground->SetMarkerStyle(20);
1591  hist_totalSigmaPIDBackground->SetMarkerSize(0.6);
1592  hist_totalSigmaPIDBackground->SetMarkerColor(6);
1593  TH1F* histogram_totalSigmaPIDBackground = (TH1F*)hist_totalSigmaPIDBackground->Clone();
1594  fOutputBPlusResults->Add(histogram_totalSigmaPIDBackground);
1595  fResultsHistogramArray[11][4] = histogram_totalSigmaPIDBackground;
1596 
1597  TString name_totalSigmaPIDSignal = "totalSigmaPIDSignal";
1598  TH1F* hist_totalSigmaPIDSignal = new TH1F(name_totalSigmaPIDSignal.Data(), "Total sigma of TPC and TOF PID for the daughters; number [#]; Entries", 1000, 0, 100);
1599  hist_totalSigmaPIDSignal->Sumw2();
1600  hist_totalSigmaPIDSignal->SetLineColor(6);
1601  hist_totalSigmaPIDSignal->SetMarkerStyle(20);
1602  hist_totalSigmaPIDSignal->SetMarkerSize(0.6);
1603  hist_totalSigmaPIDSignal->SetMarkerColor(6);
1604  TH1F* histogram_totalSigmaPIDSignal = (TH1F*)hist_totalSigmaPIDSignal->Clone();
1605  fOutputBPlusResults->Add(histogram_totalSigmaPIDSignal);
1606  fResultsHistogramArray[11][5] = histogram_totalSigmaPIDSignal;
1607 
1608  for (int i = 0; i < 3; ++i)
1609  {
1610  TString name_Histogram;
1611  TString discription_Histogram;
1612  if (i == 0) {name_Histogram = "invmassD0PionBPlusPion"; discription_Histogram = "Invariant mass D0 Pion and BPlus Pion; inv. mass [GeV/c^{2}]; Entries";}
1613  if (i == 1) {name_Histogram = "invmassD0KaonBPlusPion"; discription_Histogram = "Invariant mass D0 Kaon and BPlus Pion; inv. mass [GeV/c^{2}]; Entries";}
1614  if (i == 2) {name_Histogram = "invmassD0PionD0KaonBPlusPion"; discription_Histogram = "Invariant mass D0 Pion, D0 Kaon, and BPlus Pion; inv. mass [GeV/c^{2}]; Entries";}
1615 
1616  for (int j = 0; j < 2; ++j)
1617  {
1618  TString add_name = "";
1619  if (j == 1) add_name = "_Signal";
1620  name_Histogram += add_name;
1621  TH1F* histogram = new TH1F(name_Histogram.Data(), discription_Histogram.Data(), 1000, 0, 30);
1622  histogram->Sumw2();
1623  if (j % 2 == 0) histogram->SetLineColor(6);
1624  if (j % 2 == 1) histogram->SetLineColor(4);
1625  histogram->SetMarkerStyle(20);
1626  histogram->SetMarkerSize(0.6);
1627  if (j % 2 == 0) histogram->SetMarkerColor(6);
1628  if (j % 2 == 1) histogram->SetMarkerColor(4);
1629  TH1F* histogram_Clone = (TH1F*)histogram->Clone();
1630  fOutputBPlusResults->Add(histogram_Clone);
1631  fResultsHistogramArray[12][2*i + j] = histogram_Clone;
1632  }
1633  }
1634 
1635 
1636 
1637  return;
1638 }
1639 //-------------------------------------------------------------------------------------
1640 AliAODVertex* AliAnalysisTaskSEBPlustoD0Pi::RecalculateVertex(const AliVVertex *primary, TObjArray *tracks, Double_t bField, Double_t dispersion, Bool_t optUseFitter, Bool_t optPropagate, Bool_t optUseDiamondConstraint) {
1641  //
1642  // Helper function to recalculate a vertex.
1643  //
1644 
1645  AliESDVertex *vertexESD = 0;
1646  AliAODVertex *vertexAOD = 0;
1647 
1648  AliVertexerTracks vertexer;
1649  vertexer.SetFieldkG(bField);
1650 
1651  vertexer.SetVtxStart((AliESDVertex*)primary); //primary vertex
1652  vertexESD = (AliESDVertex*)vertexer.VertexForSelectedESDTracks(tracks, optUseFitter, optPropagate, optUseDiamondConstraint);
1653 
1654  // delete vertexer; vertexer=NULL;
1655 
1656  if (!vertexESD) return vertexAOD;
1657 
1658 
1659  if (vertexESD->GetNContributors() != tracks->GetEntriesFast())
1660  {
1661  delete vertexESD; vertexESD = nullptr;
1662  return vertexAOD;
1663  }
1664 
1665  // convert to AliAODVertex
1666  Double_t pos[3], cov[6], chi2perNDF;
1667  for (Int_t a = 0; a < 3; a++)pos[a] = 0.;
1668  for (Int_t b = 0; b < 6; b++)cov[b] = 0.;
1669  chi2perNDF = 0;
1670 
1671  vertexESD->GetXYZ(pos); // position
1672  vertexESD->GetCovMatrix(cov); //covariance matrix
1673 
1674 
1675  Double_t vertRadius2 = pos[0] * pos[0] + pos[1] * pos[1];
1676  if (vertRadius2 > 8.) //(2.82)^2 radius beam pipe
1677  {
1678  delete vertexESD; vertexESD = nullptr;
1679  return vertexAOD;
1680  }
1681 
1682  chi2perNDF = vertexESD->GetChi2toNDF();
1683  dispersion = vertexESD->GetDispersion();
1684  delete vertexESD; vertexESD = nullptr;
1685  Int_t nprongs = 2; //tracks->GetEntriesFast();
1686  vertexAOD = new AliAODVertex(pos, cov, chi2perNDF, 0x0, -1, AliAODVertex::kUndef, nprongs);
1687 
1688  return vertexAOD;
1689 }
1690 //-------------------------------------------------------------------------------------
1691 void AliAnalysisTaskSEBPlustoD0Pi::BPlustoD0PiSignalTracksInMC(TClonesArray * mcTrackArray, AliAODEvent* /*aodevent*/, TMatrix * BPlustoD0PiLabelMatrix, TList *listout) {
1692 
1693  TMatrix &particleMatrix = *BPlustoD0PiLabelMatrix;
1694  for (Int_t i = 0; i < mcTrackArray->GetEntriesFast(); i++) {
1695 
1696  Int_t mcLabelPionBPlus = 0;
1697  Int_t mcLabelPionD0 = 0;
1698  Int_t mcLabelKaon = 0;
1699  Int_t mcLabelD0 = 0;
1700  Int_t mcLabelBPlus = 0;
1701 
1702  Double_t ptMC[5] = {0.0};
1703  Double_t yMC[5] = {0.0};
1704  Double_t pseudoYMC[5] = {0.0};
1705 
1706  Bool_t mcPionBPlusPresent = kFALSE;
1707  Bool_t mcPionD0Present = kFALSE;
1708  Bool_t mcKaonPresent = kFALSE;
1709 
1710 
1711  AliAODMCParticle *mcTrackParticle = dynamic_cast< AliAODMCParticle*>(mcTrackArray->At(i));
1712  if (!mcTrackParticle) {std::cout << "no particle" << std::endl; continue;}
1713  Int_t pdgCodeMC = TMath::Abs(mcTrackParticle->GetPdgCode());
1714 
1715  if (pdgCodeMC == 521)
1716  { //if the track is a BPlus we look at its daughters
1717 
1718  mcLabelBPlus = i;
1719  Int_t nDaughterBPlus = mcTrackParticle->GetNDaughters();
1720  ptMC[0] = mcTrackParticle->Pt();
1721  yMC[0] = mcTrackParticle->Y();
1722  pseudoYMC[0] = mcTrackParticle->Eta();
1723 
1724  // TString fillthis = "BPlus_in_analysis";
1725  ((TH1F*)fResultsHistogramArray[3][0])->Fill(0);
1726 
1727  if (nDaughterBPlus == 2)
1728  {
1729  for (Int_t iDaughterBPlus = 0; iDaughterBPlus < 2; iDaughterBPlus++)
1730  {
1731  AliAODMCParticle* daughterBPlus = (AliAODMCParticle*)mcTrackArray->At(mcTrackParticle->GetDaughterLabel(iDaughterBPlus));
1732  if (!daughterBPlus) break;
1733  Int_t pdgCodeDaughterBPlus = TMath::Abs(daughterBPlus->GetPdgCode());
1734 
1735  if (pdgCodeDaughterBPlus == 211) //if the track is a pion we save its monte carlo label
1736  {
1737  mcLabelPionBPlus = mcTrackParticle->GetDaughterLabel(iDaughterBPlus);
1738  mcPionBPlusPresent = kTRUE;
1739  ptMC[1] = daughterBPlus->Pt();
1740  yMC[1] = daughterBPlus->Y();
1741  pseudoYMC[1] = daughterBPlus->Eta();
1742  } else if (pdgCodeDaughterBPlus == 421) //if the track is a D0 we look at its daughters
1743  {
1744  mcLabelD0 = mcTrackParticle->GetDaughterLabel(iDaughterBPlus);
1745  Int_t nDaughterD0 = daughterBPlus->GetNDaughters();
1746  ptMC[2] = daughterBPlus->Pt();
1747  yMC[2] = daughterBPlus->Y();
1748  pseudoYMC[2] = daughterBPlus->Eta();
1749 
1750  if (nDaughterD0 == 2)
1751  {
1752  for (Int_t iDaughterD0 = 0; iDaughterD0 < 2; iDaughterD0++)
1753  {
1754  AliAODMCParticle* daughterD0 = (AliAODMCParticle*)mcTrackArray->At(daughterBPlus->GetDaughterLabel(iDaughterD0));
1755  if (!daughterD0) break;
1756  Int_t pdgCodeDaughterD0 = TMath::Abs(daughterD0->GetPdgCode());
1757  if (pdgCodeDaughterD0 == 211) //if the track is a pion we save its monte carlo label
1758  {
1759  mcLabelPionD0 = daughterBPlus->GetDaughterLabel(iDaughterD0);
1760  ptMC[3] = daughterD0->Pt();
1761  yMC[3] = daughterD0->Y();
1762  pseudoYMC[3] = daughterD0->Eta();
1763  mcPionD0Present = kTRUE;
1764  } else if (pdgCodeDaughterD0 == 321) //if the track is a kaon we save its monte carlo label
1765  {
1766  mcLabelKaon = daughterBPlus->GetDaughterLabel(iDaughterD0);
1767  mcKaonPresent = kTRUE;
1768  ptMC[4] = daughterD0->Pt();
1769  yMC[4] = daughterD0->Y();
1770  pseudoYMC[4] = daughterD0->Eta();
1771  } else break;
1772  }
1773  }
1774  } else break;
1775  }
1776  }
1777  }
1778  if (mcPionBPlusPresent && mcPionD0Present && mcKaonPresent) {
1779 
1780  // TString fillthis = "BPlus_in_analysis";
1781  ((TH1F*)fResultsHistogramArray[3][0])->Fill(1);
1782 
1783 
1784  for (Int_t j = 0; j < fnPtBins; ++j)
1785  {
1786  // fillthis = "BPlus_per_bin";
1787  if (fPtBinLimits[j] < ptMC[0] && ptMC[0] < fPtBinLimits[j + 1]) {((TH1F*)fResultsHistogramArray[3][1])->Fill(j); break;}
1788  }
1789 
1790  ((TH1F*)fResultsHistogramArray[0][0])->Fill(ptMC[0]);
1791  ((TH1F*)fResultsHistogramArray[0][1])->Fill(ptMC[1]);
1792  ((TH1F*)fResultsHistogramArray[0][2])->Fill(ptMC[2]);
1793  ((TH1F*)fResultsHistogramArray[0][3])->Fill(ptMC[3]);
1794  ((TH1F*)fResultsHistogramArray[0][4])->Fill(ptMC[4]);
1795 
1796  ((TH1F*)fResultsHistogramArray[0][5])->Fill(yMC[0]);
1797  ((TH1F*)fResultsHistogramArray[0][6])->Fill(yMC[1]);
1798  ((TH1F*)fResultsHistogramArray[0][7])->Fill(yMC[2]);
1799  ((TH1F*)fResultsHistogramArray[0][8])->Fill(yMC[3]);
1800  ((TH1F*)fResultsHistogramArray[0][9])->Fill(yMC[4]);
1801 
1802  ((TH1F*)fResultsHistogramArray[0][10])->Fill(pseudoYMC[0]);
1803  ((TH1F*)fResultsHistogramArray[0][11])->Fill(pseudoYMC[1]);
1804  ((TH1F*)fResultsHistogramArray[0][12])->Fill(pseudoYMC[2]);
1805  ((TH1F*)fResultsHistogramArray[0][13])->Fill(pseudoYMC[3]);
1806  ((TH1F*)fResultsHistogramArray[0][14])->Fill(pseudoYMC[4]);
1807 
1808  // We check if the tracks are in acceptance
1809  if (ptMC[1] < 0.1 || TMath::Abs(pseudoYMC[1]) > 0.8 ) continue;
1810  if (ptMC[3] < 0.1 || TMath::Abs(pseudoYMC[3]) > 0.8 ) continue;
1811  if (ptMC[4] < 0.1 || TMath::Abs(pseudoYMC[4]) > 0.8 ) continue;
1812 
1813  // We check if the BPlus is in the fiducial region
1814  if (TMath::Abs(yMC[0]) > 0.8) continue;
1815 
1816  Int_t rows = BPlustoD0PiLabelMatrix->GetNrows();
1817 
1818  BPlustoD0PiLabelMatrix->ResizeTo(rows + 1, 5);
1819  particleMatrix(rows, 0) = mcLabelPionBPlus;
1820  particleMatrix(rows, 1) = mcLabelPionD0;
1821  particleMatrix(rows, 2) = mcLabelKaon;
1822  particleMatrix(rows, 3) = mcLabelD0;
1823  particleMatrix(rows, 4) = mcLabelBPlus;
1824 
1825  // fillthis = "BPlus_in_analysis";
1826  ((TH1F*)fResultsHistogramArray[3][0])->Fill(2);
1827 
1828 
1829 
1830  for (Int_t j = 0; j < fnPtBins; ++j)
1831  {
1832  // fillthis = "BPlus_per_bin_in_Acc";
1833  if (fPtBinLimits[j] < ptMC[0] && ptMC[0] < fPtBinLimits[j + 1]) {((TH1F*)fResultsHistogramArray[3][2])->Fill(j); break;}
1834  }
1835  }
1836  }
1837 
1838 
1839  return;
1840 }
1841 //-------------------------------------------------------------------------------------
1842 Bool_t AliAnalysisTaskSEBPlustoD0Pi::D0FirstDaughterSelection(AliAODTrack* aodTrack, AliAODVertex *primaryVertex, Double_t bz, TClonesArray * mcTrackArray, TMatrix * BPlustoD0PiLabelMatrix, AliAODMCHeader * header, AliAODEvent* aodEvent) {
1843 
1844  // we select the D0 pion and save its information
1845  if (!aodTrack) AliFatal("Not a standard AOD");
1846 
1847  //quick quality cut
1848  if (aodTrack->GetITSNcls() < 1) return kFALSE;
1849  // if (aodTrack->GetTPCNcls() < 1) return kFALSE;
1850  if (aodTrack->GetStatus()&AliESDtrack::kITSpureSA) return kFALSE;
1851  if (!(aodTrack->GetStatus()&AliESDtrack::kITSin)) return kFALSE;
1852  if (aodTrack->GetID() < 0) return kFALSE;
1853  Double_t covtest[21];
1854  if (!aodTrack->GetCovarianceXYZPxPyPz(covtest)) return kFALSE;
1855 
1856  Int_t mcLabelParticle = -1;
1857  mcLabelParticle = aodTrack->GetLabel();
1858 
1859  // we fill histograms with information of the track
1860  Double_t pt_track = aodTrack->Pt();
1861  Double_t momentum_track = aodTrack->P();
1862  Int_t numberOfITS = aodTrack->GetITSNcls();
1863  Int_t numberOfTPC = aodTrack->GetTPCNcls();
1864 
1865  AliExternalTrackParam particleTrack;
1866  particleTrack.CopyFromVTrack(aodTrack);
1867  Double_t d0[2], covd0[3];
1868  particleTrack.PropagateToDCA(primaryVertex, bz, 100., d0, covd0);
1869 
1870  //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
1871  Bool_t isDesiredCandidate = kFALSE;
1872  if (fUseMCInfo) {
1873  TMatrix &particleMatrix = *BPlustoD0PiLabelMatrix;
1874  for (Int_t k = 0; k < BPlustoD0PiLabelMatrix->GetNrows(); ++k) {
1875  if (mcLabelParticle == (Int_t)particleMatrix(k, 1) || mcLabelParticle == (Int_t)particleMatrix(k, 2)) {
1876  isDesiredCandidate = kTRUE;
1877  break;
1878  }
1879  }
1880  }
1881 
1882  if (fUseMCInfo) {
1883  if (IsTrackInjected(aodTrack, header, mcTrackArray) && !isDesiredCandidate && fQuickSignalAnalysis == 2) return kFALSE;
1884  }
1885 
1886  Int_t daughterType = 0;
1887 
1888 
1889  Int_t histType = 0;
1890  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
1891  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
1892  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
1893  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
1894 
1895  for (Int_t j = 0; j < 10; ++j)
1896  {
1897  if (aodTrack->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
1898 
1899  }
1900  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0[0]);
1901 
1902  if (isDesiredCandidate)
1903  {
1904  histType = 1;
1905  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
1906  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
1907  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
1908  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
1909 
1910  for (Int_t j = 0; j < 10; ++j)
1911  {
1912  if (aodTrack->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
1913 
1914  }
1915  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0[0]);
1916  }
1917 
1918  //we apply a number of cuts on the particle
1919  Bool_t bCut = kFALSE;
1920 
1921  //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
1922 
1923  if (aodTrack->GetITSNcls() < fCuts->GetMinITSNclsD0FirstDaughter()) {
1924  if (isDesiredCandidate) {
1925  ((TH1F*)fDaughterHistogramArrayExtra[0][1])->Fill(3);
1926  } else ((TH1F*)fDaughterHistogramArrayExtra[0][0])->Fill(3);
1927  bCut = kTRUE;
1928  }
1929 
1930  // TPC cluster cut turned off, cut is done with crossed row method instead using the IsThisDaughterSelected function
1931  // if (aodTrack->GetTPCNcls() < fCuts->GetMinTPCNclsD0FirstDaughter()) {
1932  if (!fCuts->IsThisDaughterSelected(aodTrack,primaryVertex,aodEvent)) {
1933  if (isDesiredCandidate) {
1934  ((TH1F*)fDaughterHistogramArrayExtra[0][1])->Fill(4);
1935  } else ((TH1F*)fDaughterHistogramArrayExtra[0][0])->Fill(4);
1936  bCut = kTRUE;
1937  }
1938 
1939  if (fCuts->UseITSRefitD0FirstDaughter() == kTRUE) {
1940  if (!(aodTrack->GetStatus()&AliESDtrack::kITSrefit)) {
1941  if (isDesiredCandidate) {
1942  ((TH1F*)fDaughterHistogramArrayExtra[0][1])->Fill(5);
1943  } else ((TH1F*)fDaughterHistogramArrayExtra[0][0])->Fill(5);
1944  bCut = kTRUE;
1945  }
1946  }
1947 
1948  if (fCuts->UseTPCRefitD0FirstDaughter() == kTRUE) {
1949  if ((!(aodTrack->GetStatus()&AliESDtrack::kTPCrefit))) {
1950  if (isDesiredCandidate) {
1951  ((TH1F*)fDaughterHistogramArrayExtra[0][1])->Fill(6);
1952  } else ((TH1F*)fDaughterHistogramArrayExtra[0][0])->Fill(6);
1953  bCut = kTRUE;
1954  }
1955  }
1956 
1957  if (fCuts->UseFilterBitD0FirstDaughter() == kTRUE) {
1958  if (!(aodTrack->TestFilterMask(BIT(fCuts->GetFilterBitD0FirstDaughter())))) {
1959  if (isDesiredCandidate) {
1960  ((TH1F*)fDaughterHistogramArrayExtra[0][1])->Fill(7);
1961  } else ((TH1F*)fDaughterHistogramArrayExtra[0][0])->Fill(7);
1962  bCut = kTRUE;
1963  }
1964  }
1965 
1966  if (aodTrack->Pt() < fCuts->GetMinPtD0FirstDaughter()) {
1967  if (isDesiredCandidate) {
1968  ((TH1F*)fDaughterHistogramArrayExtra[0][1])->Fill(8);
1969  } else ((TH1F*)fDaughterHistogramArrayExtra[0][0])->Fill(8);
1970  bCut = kTRUE;
1971  }
1972 
1973  if (TMath::Abs(d0[0]) < fCuts->GetMind0D0FirstDaughter()) {
1974  if (isDesiredCandidate) {
1975  ((TH1F*)fDaughterHistogramArrayExtra[0][1])->Fill(12);
1976  } else ((TH1F*)fDaughterHistogramArrayExtra[0][0])->Fill(12);
1977  bCut = kTRUE;
1978  }
1979 
1980  if (TMath::Abs(aodTrack->Eta()) > fCuts->GetMaxAbsEtaD0FirstDaughter()) {
1981  if (isDesiredCandidate) {
1982  ((TH1F*)fDaughterHistogramArrayExtra[0][1])->Fill(9);
1983  } else ((TH1F*)fDaughterHistogramArrayExtra[0][0])->Fill(9);
1984  bCut = kTRUE;
1985  }
1986 
1987  Bool_t bHardSelectionArrayITS[7] = {kFALSE};
1988  fCuts->GetHardSelectionArrayITSD0FirstDaughter(bHardSelectionArrayITS);
1989  Bool_t bSoftSelectionArrayITS[7] = {kFALSE};
1990  fCuts->GetSoftSelectionArrayITSD0FirstDaughter(bSoftSelectionArrayITS);
1991 
1992  Bool_t bHardITSPass = kTRUE;
1993  for (Int_t j = 0; j < 7; ++j)
1994  {
1995  if (bHardSelectionArrayITS[j])
1996  {
1997  if (!aodTrack->HasPointOnITSLayer(j)) bHardITSPass = kFALSE;
1998  }
1999  }
2000 
2001  Int_t nCounterSoftSelection = 0;
2002  Bool_t bSoftITSPass = kTRUE;
2003  for (Int_t j = 0; j < 7; ++j)
2004  {
2005  if (bSoftSelectionArrayITS[j])
2006  {
2007  if (aodTrack->HasPointOnITSLayer(j)) nCounterSoftSelection++;
2008  }
2009  }
2010  if (nCounterSoftSelection < fCuts->GetNSoftITSCutD0FirstDaughter()) bSoftITSPass = kFALSE;
2011 
2012  if (!bHardITSPass) {
2013  if (isDesiredCandidate) {
2014  ((TH1F*)fDaughterHistogramArrayExtra[0][1])->Fill(10);
2015  } else ((TH1F*)fDaughterHistogramArrayExtra[0][0])->Fill(10);
2016  bCut = kTRUE;
2017  }
2018 
2019  if (!bSoftITSPass) {
2020  if (isDesiredCandidate) {
2021  ((TH1F*)fDaughterHistogramArrayExtra[0][1])->Fill(11);
2022  } else ((TH1F*)fDaughterHistogramArrayExtra[0][0])->Fill(11);
2023  bCut = kTRUE;
2024  }
2025 
2026  if (!isDesiredCandidate && fQuickSignalAnalysis == 1) {
2027  if (isDesiredCandidate) {
2028  ((TH1F*)fDaughterHistogramArrayExtra[0][1])->Fill(13);
2029  } else ((TH1F*)fDaughterHistogramArrayExtra[0][0])->Fill(13);
2030  bCut = kTRUE;
2031  }
2032 
2033  if (bCut) {
2034  if (isDesiredCandidate) {
2035  ((TH1F*)fDaughterHistogramArrayExtra[0][1])->Fill(0);
2036  } else ((TH1F*)fDaughterHistogramArrayExtra[0][0])->Fill(0);
2037  return kFALSE;
2038  }
2039 
2040  //we fill histograms with track information of the tracks that pass the cuts
2041  histType = 2;
2042  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
2043  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
2044  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
2045  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
2046 
2047  for (Int_t j = 0; j < 10; ++j)
2048  {
2049  if (aodTrack->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
2050 
2051  }
2052  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0[0]);
2053 
2054  if (isDesiredCandidate)
2055  {
2056  histType = 3;
2057  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
2058  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
2059  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
2060  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
2061 
2062  for (Int_t j = 0; j < 10; ++j)
2063  {
2064  if (aodTrack->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
2065 
2066  }
2067  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0[0]);
2068  }
2069 
2070  return kTRUE;
2071 }
2072 //-------------------------------------------------------------------------------------
2073 Bool_t AliAnalysisTaskSEBPlustoD0Pi::D0SecondDaughterSelection(AliAODTrack* aodTrack, AliAODVertex *primaryVertex, Double_t bz, TClonesArray * mcTrackArray, TMatrix * BPlustoD0PiLabelMatrix, AliAODMCHeader * header, AliAODEvent* aodEvent) {
2074 
2075  // we select the D0 pion and save its information
2076  if (!aodTrack) AliFatal("Not a standard AOD");
2077 
2078  //quick quality cut
2079  if (aodTrack->GetITSNcls() < 1) return kFALSE;
2080  // if (aodTrack->GetTPCNcls() < 1) return kFALSE;
2081  if (aodTrack->GetStatus()&AliESDtrack::kITSpureSA) return kFALSE;
2082  if (!(aodTrack->GetStatus()&AliESDtrack::kITSin)) return kFALSE;
2083  if (aodTrack->GetID() < 0) return kFALSE;
2084  Double_t covtest[21];
2085  if (!aodTrack->GetCovarianceXYZPxPyPz(covtest)) return kFALSE;
2086 
2087  Int_t mcLabelParticle = -1;
2088  mcLabelParticle = aodTrack->GetLabel();
2089 
2090  // we fill histograms with information of the track
2091  Double_t pt_track = aodTrack->Pt();
2092  Double_t momentum_track = aodTrack->P();
2093  Int_t numberOfITS = aodTrack->GetITSNcls();
2094  Int_t numberOfTPC = aodTrack->GetTPCNcls();
2095 
2096  AliExternalTrackParam particleTrack;
2097  particleTrack.CopyFromVTrack(aodTrack);
2098  Double_t d0[2], covd0[3];
2099  particleTrack.PropagateToDCA(primaryVertex, bz, 100., d0, covd0);
2100 
2101  //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
2102  Bool_t isDesiredCandidate = kFALSE;
2103  if (fUseMCInfo) {
2104  TMatrix &particleMatrix = *BPlustoD0PiLabelMatrix;
2105  for (Int_t k = 0; k < BPlustoD0PiLabelMatrix->GetNrows(); ++k) {
2106  if (mcLabelParticle == (Int_t)particleMatrix(k, 1) || mcLabelParticle == (Int_t)particleMatrix(k, 2)) {
2107  isDesiredCandidate = kTRUE;
2108  break;
2109  }
2110  }
2111  }
2112 
2113  if (fUseMCInfo) {
2114  if (IsTrackInjected(aodTrack, header, mcTrackArray) && !isDesiredCandidate && fQuickSignalAnalysis == 2) return kFALSE;
2115  }
2116 
2117  Int_t daughterType = 1;
2118 
2119 
2120  Int_t histType = 0;
2121  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
2122  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
2123  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
2124  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
2125 
2126  for (Int_t j = 0; j < 10; ++j)
2127  {
2128  if (aodTrack->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
2129 
2130  }
2131  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0[0]);
2132 
2133  if (isDesiredCandidate)
2134  {
2135  histType = 1;
2136  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
2137  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
2138  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
2139  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
2140 
2141  for (Int_t j = 0; j < 10; ++j)
2142  {
2143  if (aodTrack->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
2144  }
2145  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0[0]);
2146  }
2147 
2148  //we apply a number of cuts on the particle
2149  Bool_t bCut = kFALSE;
2150 
2151  //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
2152 
2153  if (aodTrack->GetITSNcls() < fCuts->GetMinITSNclsD0SecondDaughter()) {
2154  if (isDesiredCandidate) {
2155  ((TH1F*)fDaughterHistogramArrayExtra[1][1])->Fill(3);
2156  } else ((TH1F*)fDaughterHistogramArrayExtra[1][0])->Fill(3);
2157  bCut = kTRUE;
2158  }
2159 
2160  // TPC cluster cut turned off, cut is done with crossed row method instead using the IsThisDaughterSelected function
2161  // if (aodTrack->GetTPCNcls() < fCuts->GetMinTPCNclsD0SecondDaughter()) {
2162  if (!fCuts->IsThisDaughterSelected(aodTrack,primaryVertex,aodEvent)) {
2163  if (isDesiredCandidate) {
2164  ((TH1F*)fDaughterHistogramArrayExtra[1][1])->Fill(4);
2165  } else ((TH1F*)fDaughterHistogramArrayExtra[1][0])->Fill(4);
2166  bCut = kTRUE;
2167  }
2168 
2169  if (fCuts->UseITSRefitD0SecondDaughter() == kTRUE) {
2170  if (!(aodTrack->GetStatus()&AliESDtrack::kITSrefit)) {
2171  if (isDesiredCandidate) {
2172  ((TH1F*)fDaughterHistogramArrayExtra[1][1])->Fill(5);
2173  } else ((TH1F*)fDaughterHistogramArrayExtra[1][0])->Fill(5);
2174  bCut = kTRUE;
2175  }
2176  }
2177 
2178  if (fCuts->UseTPCRefitD0SecondDaughter() == kTRUE) {
2179  if ((!(aodTrack->GetStatus()&AliESDtrack::kTPCrefit))) {
2180  if (isDesiredCandidate) {
2181  ((TH1F*)fDaughterHistogramArrayExtra[1][1])->Fill(6);
2182  } else ((TH1F*)fDaughterHistogramArrayExtra[1][0])->Fill(6);
2183  bCut = kTRUE;
2184  }
2185  }
2186 
2187  if (fCuts->UseFilterBitD0SecondDaughter() == kTRUE) {
2188  if (!(aodTrack->TestFilterMask(BIT(fCuts->GetFilterBitD0SecondDaughter())))) {
2189  if (isDesiredCandidate) {
2190  ((TH1F*)fDaughterHistogramArrayExtra[1][1])->Fill(7);
2191  } else ((TH1F*)fDaughterHistogramArrayExtra[1][0])->Fill(7);
2192  bCut = kTRUE;
2193  }
2194  }
2195 
2196  if (aodTrack->Pt() < fCuts->GetMinPtD0SecondDaughter()) {
2197  if (isDesiredCandidate) {
2198  ((TH1F*)fDaughterHistogramArrayExtra[1][1])->Fill(8);
2199  } else ((TH1F*)fDaughterHistogramArrayExtra[1][0])->Fill(8);
2200  bCut = kTRUE;
2201  }
2202 
2203  if (TMath::Abs(d0[0]) < fCuts->GetMind0D0SecondDaughter()) {
2204  if (isDesiredCandidate) {
2205  ((TH1F*)fDaughterHistogramArrayExtra[1][1])->Fill(12);
2206  } else ((TH1F*)fDaughterHistogramArrayExtra[1][0])->Fill(12);
2207  bCut = kTRUE;
2208  }
2209 
2210  if (TMath::Abs(aodTrack->Eta()) > fCuts->GetMaxAbsEtaD0SecondDaughter()) {
2211  if (isDesiredCandidate) {
2212  ((TH1F*)fDaughterHistogramArrayExtra[1][1])->Fill(9);
2213  } else ((TH1F*)fDaughterHistogramArrayExtra[1][0])->Fill(9);
2214  bCut = kTRUE;
2215  }
2216 
2217  Bool_t bHardSelectionArrayITS[7] = {kFALSE};
2218  fCuts->GetHardSelectionArrayITSD0SecondDaughter(bHardSelectionArrayITS);
2219  Bool_t bSoftSelectionArrayITS[7] = {kFALSE};
2220  fCuts->GetSoftSelectionArrayITSD0SecondDaughter(bSoftSelectionArrayITS);
2221 
2222  Bool_t bHardITSPass = kTRUE;
2223  for (Int_t j = 0; j < 7; ++j)
2224  {
2225  if (bHardSelectionArrayITS[j])
2226  {
2227  if (!aodTrack->HasPointOnITSLayer(j)) bHardITSPass = kFALSE;
2228  }
2229  }
2230 
2231  Int_t nCounterSoftSelection = 0;
2232  Bool_t bSoftITSPass = kTRUE;
2233  for (Int_t j = 0; j < 7; ++j)
2234  {
2235  if (bSoftSelectionArrayITS[j])
2236  {
2237  if (aodTrack->HasPointOnITSLayer(j)) nCounterSoftSelection++;
2238  }
2239  }
2240  if (nCounterSoftSelection < fCuts->GetNSoftITSCutD0SecondDaughter()) bSoftITSPass = kFALSE;
2241 
2242  if (!bHardITSPass) {
2243  if (isDesiredCandidate) {
2244  ((TH1F*)fDaughterHistogramArrayExtra[1][1])->Fill(10);
2245  } else ((TH1F*)fDaughterHistogramArrayExtra[1][0])->Fill(10);
2246  bCut = kTRUE;
2247  }
2248 
2249  if (!bSoftITSPass) {
2250  if (isDesiredCandidate) {
2251  ((TH1F*)fDaughterHistogramArrayExtra[1][1])->Fill(11);
2252  } else ((TH1F*)fDaughterHistogramArrayExtra[1][0])->Fill(11);
2253  bCut = kTRUE;
2254  }
2255 
2256  if (!isDesiredCandidate && fQuickSignalAnalysis == 1) bCut = kTRUE;
2257 
2258  if (bCut) {
2259  if (isDesiredCandidate) {
2260  ((TH1F*)fDaughterHistogramArrayExtra[1][1])->Fill(0);
2261  } else ((TH1F*)fDaughterHistogramArrayExtra[1][0])->Fill(0);
2262  return kFALSE;
2263  }
2264 
2265  //we fill histograms with track information of the tracks that pass the cuts
2266  histType = 2;
2267  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
2268  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
2269  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
2270  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
2271 
2272  for (Int_t j = 0; j < 10; ++j)
2273  {
2274  if (aodTrack->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
2275 
2276  }
2277  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0[0]);
2278 
2279  if (isDesiredCandidate)
2280  {
2281  histType = 3;
2282  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
2283  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
2284  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
2285  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
2286 
2287  for (Int_t j = 0; j < 10; ++j)
2288  {
2289  if (aodTrack->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
2290 
2291  }
2292  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0[0]);
2293  }
2294 
2295  return kTRUE;
2296 }
2297 //-------------------------------------------------------------------------------------
2298 void AliAnalysisTaskSEBPlustoD0Pi::BPlusPionSelection(AliAODEvent* aodEvent, AliAODVertex *primaryVertex, Double_t bz, TClonesArray * mcTrackArray, TMatrix * BPlustoD0PiLabelMatrix, AliAODMCHeader * header) {
2299 
2300  //we keep track of the number of particles we could use and how many we actually use after cuts
2301  Int_t numberofparticles = 0;
2302  Int_t numberofparticlesused = 0;
2303 
2304  TString fillthis = "";
2305 
2306  //we loop over all tracks in the event
2307  for (Int_t i = 0; i < aodEvent->GetNumberOfTracks(); i++) {
2308  AliAODTrack* aodTrack = dynamic_cast<AliAODTrack*>(aodEvent->GetTrack(i));
2309  if (!aodTrack) AliFatal("Not a standard AOD");
2310 
2311  //quick quality cut
2312  if (aodTrack->GetITSNcls() < 1) continue;
2313  // if (aodTrack->GetTPCNcls() < 1) continue;
2314  if (aodTrack->GetStatus()&AliESDtrack::kITSpureSA) continue;
2315  if (!(aodTrack->GetStatus()&AliESDtrack::kITSin)) continue;
2316  if (aodTrack->GetID() < 0) continue;
2317  Double_t covtest[21];
2318  if (!aodTrack->GetCovarianceXYZPxPyPz(covtest)) continue;
2319 
2320  // Double_t pos[3],cov[6];
2321  // primaryVertex->GetXYZ(pos);
2322  // primaryVertex->GetCovarianceMatrix(cov);
2323  // const AliESDVertex vESD(pos,cov,100.,100);
2324  // if(!fCuts->IsDaughterSelected(aodTrack,&vESD,fCuts->GetTrackCuts(),aodEvent)) continue;
2325 
2326  Int_t mcLabelParticle = -1;
2327  mcLabelParticle = aodTrack->GetLabel();
2328 
2329  numberofparticles++;
2330 
2331  // we fill histograms with information of the track
2332  Double_t pt_track = aodTrack->Pt();
2333  Double_t momentum_track = aodTrack->P();
2334  Int_t numberOfITS = aodTrack->GetITSNcls();
2335  Int_t numberOfTPC = aodTrack->GetTPCNcls();
2336  Double_t nSigmaTPC = 0;
2337  Double_t nSigmaTOF = 0;
2338  Int_t pionPIDnumber = 2;
2339  Int_t TPCok = 0;
2340  Int_t TOFok = 0;
2341 
2342  AliAODPidHF* trackPIDHF = (AliAODPidHF*)fCuts->GetPidHF();
2343  if(trackPIDHF) TPCok = trackPIDHF->GetnSigmaTPC(aodTrack, pionPIDnumber, nSigmaTPC);
2344  if(trackPIDHF) TOFok = trackPIDHF->GetnSigmaTOF(aodTrack, pionPIDnumber, nSigmaTOF);
2345 
2346  AliExternalTrackParam particleTrack;
2347  particleTrack.CopyFromVTrack(aodTrack);
2348  Double_t d0[2], covd0[3];
2349  particleTrack.PropagateToDCA(primaryVertex, bz, 100., d0, covd0);
2350 
2351 
2352  //we check if the particle is a signal track
2353  Bool_t isDesiredCandidate = kFALSE;
2354  if (fUseMCInfo) {
2355  TMatrix &particleMatrix = *BPlustoD0PiLabelMatrix;
2356  for (Int_t k = 0; k < BPlustoD0PiLabelMatrix->GetNrows(); ++k) {
2357  if (mcLabelParticle == (Int_t)particleMatrix(k, 0)) {
2358  isDesiredCandidate = kTRUE;
2359  break;
2360  }
2361  }
2362  }
2363 
2364  if (fUseMCInfo) {
2365  if (IsTrackInjected(aodTrack, header, mcTrackArray) && !isDesiredCandidate && fQuickSignalAnalysis == 2) continue;
2366  }
2367 
2368  Int_t daughterType = 2;
2369 
2370  Int_t histType = 0;
2371  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
2372  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
2373  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
2374  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
2375 
2376  for (Int_t j = 0; j < 10; ++j)
2377  {
2378  if (aodTrack->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
2379 
2380  }
2381 
2382  if (TPCok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(nSigmaTPC);
2383  if (TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][5])->Fill(nSigmaTOF);
2384  if (TPCok != -1 && TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][6])->Fill(TMath::Sqrt(nSigmaTPC * nSigmaTPC + nSigmaTOF * nSigmaTOF));
2385  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0[0]);
2386 
2387  if (isDesiredCandidate)
2388  {
2389  histType = 1;
2390  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
2391  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
2392  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
2393  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
2394 
2395  for (Int_t j = 0; j < 10; ++j)
2396  {
2397  if (aodTrack->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
2398 
2399  }
2400 
2401  if (TPCok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(nSigmaTPC);
2402  if (TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][5])->Fill(nSigmaTOF);
2403  if (TPCok != -1 && TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][6])->Fill(TMath::Sqrt(nSigmaTPC * nSigmaTPC + nSigmaTOF * nSigmaTOF));
2404  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0[0]);
2405  }
2406 
2407 
2408  //we apply a number of cuts on the particle
2409  Bool_t bCut = kFALSE;
2410 
2411 
2412  //we apply a PID cut, 2 is used to indicate we look for a pion
2413  if (!(fCuts->SelectPID(aodTrack, 2))) {
2414  if (isDesiredCandidate) {
2415  ((TH1F*)fDaughterHistogramArrayExtra[2][1])->Fill(2);
2416  } else ((TH1F*)fDaughterHistogramArrayExtra[2][0])->Fill(2);
2417  bCut = kTRUE;
2418  }
2419 
2420  if (aodTrack->GetITSNcls() < fCuts->GetMinITSNclsBPlusPion()) {
2421  if (isDesiredCandidate) {
2422  ((TH1F*)fDaughterHistogramArrayExtra[2][1])->Fill(3);
2423  } else ((TH1F*)fDaughterHistogramArrayExtra[2][0])->Fill(3);
2424  bCut = kTRUE;
2425  }
2426 
2427  // TPC cluster cut turned off, cut is done with crossed row method instead using the IsThisDaughterSelected function
2428  // if (aodTrack->GetTPCNcls() < fCuts->GetMinTPCNclsBPlusPion()) {
2429  if (!fCuts->IsThisDaughterSelected(aodTrack,primaryVertex,aodEvent)) {
2430  if (isDesiredCandidate) {
2431  ((TH1F*)fDaughterHistogramArrayExtra[2][1])->Fill(4);
2432  } else ((TH1F*)fDaughterHistogramArrayExtra[2][0])->Fill(4);
2433  bCut = kTRUE;
2434  }
2435 
2436  if (fCuts->UseITSRefitBPlusPion() == kTRUE) {
2437  if (!(aodTrack->GetStatus()&AliESDtrack::kITSrefit)) {
2438  if (isDesiredCandidate) {
2439  ((TH1F*)fDaughterHistogramArrayExtra[2][1])->Fill(5);
2440  } else ((TH1F*)fDaughterHistogramArrayExtra[2][0])->Fill(5);
2441  bCut = kTRUE;
2442  }
2443  }
2444 
2445  if (fCuts->UseTPCRefitBPlusPion() == kTRUE) {
2446  if ((!(aodTrack->GetStatus()&AliESDtrack::kTPCrefit))) {
2447  if (isDesiredCandidate) {
2448  ((TH1F*)fDaughterHistogramArrayExtra[2][1])->Fill(6);
2449  } else ((TH1F*)fDaughterHistogramArrayExtra[2][0])->Fill(6);
2450  bCut = kTRUE;
2451  }
2452  }
2453 
2454  if (fCuts->UseFilterBitBPlusPion() == kTRUE) {
2455  if (!(aodTrack->TestFilterMask(BIT(fCuts->GetFilterBitBPlusPion())))) {
2456  if (isDesiredCandidate) {
2457  ((TH1F*)fDaughterHistogramArrayExtra[2][1])->Fill(7);
2458  } else ((TH1F*)fDaughterHistogramArrayExtra[2][0])->Fill(7);
2459  bCut = kTRUE;
2460  }
2461  }
2462 
2463 
2464  if (aodTrack->Pt() < fCuts->GetMinPtBPlusPion()) {
2465  if (isDesiredCandidate) {
2466  ((TH1F*)fDaughterHistogramArrayExtra[2][1])->Fill(8);
2467  } else ((TH1F*)fDaughterHistogramArrayExtra[2][0])->Fill(8);
2468  bCut = kTRUE;
2469  }
2470 
2471 
2472  if (TMath::Abs(d0[0]) < fCuts->GetMind0BPlusPion()) {
2473  if (isDesiredCandidate) {
2474  ((TH1F*)fDaughterHistogramArrayExtra[2][1])->Fill(12);
2475  } else ((TH1F*)fDaughterHistogramArrayExtra[2][0])->Fill(12);
2476  bCut = kTRUE;
2477  }
2478 
2479  if (TMath::Abs(aodTrack->Eta()) > fCuts->GetMaxAbsEtaBPlusPion()) {
2480  if (isDesiredCandidate) {
2481  ((TH1F*)fDaughterHistogramArrayExtra[2][1])->Fill(9);
2482  } else ((TH1F*)fDaughterHistogramArrayExtra[2][0])->Fill(9);
2483  bCut = kTRUE;
2484  }
2485 
2486  Bool_t bHardSelectionArrayITS[7] = {kFALSE};
2487  fCuts->GetHardSelectionArrayITSBPlusPion(bHardSelectionArrayITS);
2488  Bool_t bSoftSelectionArrayITS[7] = {kFALSE};
2489  fCuts->GetSoftSelectionArrayITSBPlusPion(bSoftSelectionArrayITS);
2490 
2491  Bool_t bHardITSPass = kTRUE;
2492  for (Int_t j = 0; j < 7; ++j)
2493  {
2494  if (bHardSelectionArrayITS[j])
2495  {
2496  if (!aodTrack->HasPointOnITSLayer(j)) bHardITSPass = kFALSE;
2497  }
2498  }
2499 
2500  Int_t nCounterSoftSelection = 0;
2501  Bool_t bSoftITSPass = kTRUE;
2502  for (Int_t j = 0; j < 7; ++j)
2503  {
2504  if (bSoftSelectionArrayITS[j])
2505  {
2506  if (aodTrack->HasPointOnITSLayer(j)) nCounterSoftSelection++;
2507  }
2508  }
2509  if (nCounterSoftSelection < fCuts->GetNSoftITSCutBPlusPion()) bSoftITSPass = kFALSE;
2510 
2511  if (!bHardITSPass) {
2512  if (isDesiredCandidate) {
2513  ((TH1F*)fDaughterHistogramArrayExtra[2][1])->Fill(10);
2514  } else ((TH1F*)fDaughterHistogramArrayExtra[2][0])->Fill(10);
2515  bCut = kTRUE;
2516  }
2517 
2518  if (!bSoftITSPass) {
2519  if (isDesiredCandidate) {
2520  ((TH1F*)fDaughterHistogramArrayExtra[2][1])->Fill(11);
2521  } else ((TH1F*)fDaughterHistogramArrayExtra[2][0])->Fill(11);
2522  bCut = kTRUE;
2523  }
2524 
2525 
2526  if (!isDesiredCandidate && fQuickSignalAnalysis == 1) bCut = kTRUE;
2527 
2528  if (bCut) {
2529  if (isDesiredCandidate) {
2530  ((TH1F*)fDaughterHistogramArrayExtra[2][1])->Fill(0);
2531  } else ((TH1F*)fDaughterHistogramArrayExtra[2][0])->Fill(0);
2532  continue;
2533  }
2534 
2535  //we fill histograms with track information of the tracks that pass the cuts
2536  histType = 2;
2537  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
2538  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
2539  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
2540  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
2541 
2542  for (Int_t j = 0; j < 10; ++j)
2543  {
2544  if (aodTrack->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
2545 
2546  }
2547 
2548  if (TPCok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(nSigmaTPC);
2549  if (TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][5])->Fill(nSigmaTOF);
2550  if (TPCok != -1 && TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][6])->Fill(TMath::Sqrt(nSigmaTPC * nSigmaTPC + nSigmaTOF * nSigmaTOF));
2551  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0[0]);
2552 
2553  if (isDesiredCandidate)
2554  {
2555  histType = 3;
2556  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
2557  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
2558  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
2559  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
2560 
2561  for (Int_t j = 0; j < 10; ++j)
2562  {
2563  if (aodTrack->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
2564 
2565  }
2566 
2567  if (TPCok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(nSigmaTPC);
2568  if (TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][5])->Fill(nSigmaTOF);
2569  if (TPCok != -1 && TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][6])->Fill(TMath::Sqrt(nSigmaTPC * nSigmaTPC + nSigmaTOF * nSigmaTOF));
2570  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0[0]);
2571  }
2572 
2573  fBPlusPionTracks->push_back(i);
2574  numberofparticlesused++;
2575  }
2576 
2577  // cout << "BPlus pions used: " << numberofparticlesused << endl;
2578 
2579  ((TH1F*)fDaughterHistogramArray[2][0][10])->Fill(numberofparticles);
2580  ((TH1F*)fDaughterHistogramArray[2][1][10])->Fill(numberofparticlesused);
2581  return;
2582 }
2583 //-------------------------------------------------------------------------------------
2584 void AliAnalysisTaskSEBPlustoD0Pi::D0Selection(AliAODEvent* aodEvent, AliAODVertex *primaryVertex, Double_t bz, TClonesArray * mcTrackArray, TMatrix * BPlustoD0PiLabelMatrix, TClonesArray * D0TracksFromFriendFile, AliAODMCHeader * header) {
2585 
2586  TString fillthis = "";
2587 
2589 
2590  //next we loop over all the D0 candidates
2591  for (Int_t j = 0; j < D0TracksFromFriendFile->GetEntriesFast(); j++)
2592  {
2593 
2594  //we get the track of the D0
2595  AliAODRecoDecayHF2Prong * trackD0 = (AliAODRecoDecayHF2Prong*)(D0TracksFromFriendFile->At(j));
2596  if (!trackD0) {std::cout << "found none" << std::endl; continue;}
2597  if (trackD0 == nullptr) {std::cout << "found nullptr" << std::endl; continue;}
2598 
2599  if (!(vHF->FillRecoCand(aodEvent, trackD0))) //Fill the data members of the candidate only if they are empty.
2600  {
2601  fCEvents->Fill(12); //monitor how often this fails
2602  continue;
2603  }
2604 
2605  AliAODTrack * trackFirstDaughter = (AliAODTrack*)(trackD0->GetDaughter(0));
2606  AliAODTrack * trackSecondDaughter = (AliAODTrack*)(trackD0->GetDaughter(1));
2607  if (!D0FirstDaughterSelection(trackFirstDaughter, primaryVertex, bz, mcTrackArray, BPlustoD0PiLabelMatrix, header, aodEvent)) continue;
2608  if (!D0SecondDaughterSelection(trackSecondDaughter, primaryVertex, bz, mcTrackArray, BPlustoD0PiLabelMatrix, header, aodEvent)) continue;
2609 
2610 
2611  AliAODVertex *vertexMother = (AliAODVertex*)trackD0->GetSecondaryVtx();
2612 
2613  //we check if the track is a desired candidate
2614  Int_t pdgCodeMother = -1;
2615  Bool_t isDesiredCandidate = kFALSE;
2616  Int_t motherType, histType;
2617  motherType = 0;
2618  Int_t mcLabelD0 = -1;
2619 
2620  if (fUseMCInfo)
2621  {
2622  mcLabelD0 = MatchCandidateToMonteCarlo(421, trackD0, mcTrackArray, BPlustoD0PiLabelMatrix, kTRUE);
2623 
2624  if (mcLabelD0 >= 0)
2625  {
2626  isDesiredCandidate = kTRUE;
2627 
2628  Int_t mcLabelFirstTrack = -1;
2629  mcLabelFirstTrack = trackFirstDaughter->GetLabel();
2630 
2631  if (mcLabelFirstTrack >= 0)
2632  {
2633  AliAODMCParticle *mcParticleFirstTrack = (AliAODMCParticle*)mcTrackArray->At(mcLabelFirstTrack);
2634  AliAODMCParticle *mcMotherParticle = (AliAODMCParticle*)mcTrackArray->At(mcLabelD0);
2635 
2636  if (mcParticleFirstTrack && mcMotherParticle)
2637  {
2638  pdgCodeMother = mcMotherParticle->GetPdgCode();
2639 
2640  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()));
2641  ((TH1F*)fMotherHistogramArrayExtra[motherType][4])->Fill(vertex_distance);
2642 
2643  // Double_t vertex_distance_new = TMath::Sqrt((vertexMotherNew->GetX() - mcParticleFirstTrack->Xv()) * (vertexMotherNew->GetX() - mcParticleFirstTrack->Xv()) + (vertexMotherNew->GetY() - mcParticleFirstTrack->Yv()) * (vertexMotherNew->GetY() - mcParticleFirstTrack->Yv()) + (vertexMotherNew->GetZ() - mcParticleFirstTrack->Zv()) * (vertexMotherNew->GetZ() - mcParticleFirstTrack->Zv()));
2644  // ((TH1F*)fMotherHistogramArrayExtra[motherType][5])->Fill(vertex_distance_new);
2645 
2646  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()));
2647  ((TH1F*)fMotherHistogramArrayExtra[motherType][6])->Fill(momentum_resolution);
2648  }
2649  }
2650  }
2651  }
2652 
2653  // We fill the histograms
2654  histType = 0;
2655  FillD0Histograms(trackD0, primaryVertex, bz, motherType, histType);
2656  if (isDesiredCandidate && fUseMCInfo) {
2657  histType = 1;
2658  FillD0Histograms(trackD0, primaryVertex, bz, motherType, histType, pdgCodeMother);
2659  }
2660 
2661  // Here we apply cuts on the particle
2662  Bool_t cutMother = kFALSE;
2663 
2664  Bool_t bCutArray[29] = {0};
2665  Int_t cutReturnValue = fCuts->IsD0forD0ptbinSelected(trackD0, 0, aodEvent, bCutArray);
2666  if (cutReturnValue == -1) cutMother = kTRUE;
2667  if (cutReturnValue == 0) cutMother = kTRUE;
2668  for (Int_t k = 0; k < 29; ++k)
2669  {
2670  if (bCutArray[k] == kTRUE) {
2671  if (isDesiredCandidate) {
2672  ((TH1F*)fMotherHistogramArrayExtra[motherType][1])->Fill(k + 1);
2673  } else ((TH1F*)fMotherHistogramArrayExtra[motherType][0])->Fill(k + 1);
2674  cutMother = kTRUE;
2675  }
2676  }
2677 
2678  if (!fCuts->AreDaughtersSelected(trackD0, aodEvent)) cutMother = kTRUE;
2679 
2680  if (!isDesiredCandidate && fQuickSignalAnalysis == 1) cutMother = kTRUE;
2681 
2682  if (cutMother) {
2683  if (isDesiredCandidate) {
2684  ((TH1F*)fMotherHistogramArrayExtra[motherType][1])->Fill(0);
2685  } else ((TH1F*)fMotherHistogramArrayExtra[motherType][0])->Fill(0);
2686  continue;
2687  }
2688 
2689  // We fill the cut histograms
2690  histType = 2;
2691  FillD0Histograms(trackD0, primaryVertex, bz, motherType, histType);
2692  if (isDesiredCandidate && fUseMCInfo) {
2693  histType = 3;
2694  FillD0Histograms(trackD0, primaryVertex, bz, motherType, histType, pdgCodeMother);
2695  }
2696 
2697  //we save the location of the D0 candidate
2698  fD0Tracks->push_back(j);
2699  }
2700 
2701  delete vHF; vHF = nullptr;
2702  return;
2703 }
2704 //-------------------------------------------------------------------------------------
2705 void AliAnalysisTaskSEBPlustoD0Pi::BPlusSelection(AliAODEvent* aodEvent, AliAODVertex *primaryVertex, Double_t bz, TClonesArray * mcTrackArray, TMatrix * BPlustoD0PiLabelMatrix, TClonesArray * D0TracksFromFriendFile, AliAODMCHeader * header) {
2706 
2707  TString fillthis = "";
2708 
2709  //we loop over all the D0 candidates
2710  for (Int_t j = 0; j < (Int_t)fD0Tracks->size(); j++)
2711  {
2712 
2713  //Save current Object count
2714  Int_t ObjectNumber = TProcessID::GetObjectCount();
2715 
2716  //we get the track of the D0
2717  AliAODRecoDecayHF2Prong * trackD0 = (AliAODRecoDecayHF2Prong*)(D0TracksFromFriendFile->At(fD0Tracks->at(j)));
2718  if (!trackD0) {std::cout << "found none" << std::endl; continue;}
2719  if (trackD0 == nullptr) {std::cout << "found nullptr" << std::endl; continue;}
2720 
2721  //we loop over all the BPlus pion candidates
2722  for (Int_t i = 0; i < (Int_t)fBPlusPionTracks->size(); i++)
2723  {
2724 
2725  //we get the track of the BPlus daughter
2726  AliAODTrack * trackBPlusPion = dynamic_cast<AliAODTrack*>(aodEvent->GetTrack(fBPlusPionTracks->at(i)));
2727  if (!trackBPlusPion) continue;
2728 
2729  //we check if the IDs of the tracks are different
2730  AliAODTrack* twoProngdaughter0 = (AliAODTrack*)trackD0->GetDaughter(0);
2731  AliAODTrack* twoProngdaughter1 = (AliAODTrack*)trackD0->GetDaughter(1);
2732  UShort_t idProng0 = twoProngdaughter0->GetID();
2733  UShort_t idProng1 = twoProngdaughter1->GetID();
2734 
2735  if (trackBPlusPion->GetID() == idProng0 || trackBPlusPion->GetID() == idProng1) continue;
2736 
2737  Int_t pdgD0 = 421;
2738  if (trackBPlusPion->Charge() == 1) pdgD0 = -421;
2739 
2740  //we check if the pions have the opposite charge
2741  //this only works if pid is turned on
2742  Bool_t bWrongSign = kFALSE;
2743  if (trackBPlusPion->Charge() == -1)
2744  {
2745  if ((fCuts->SelectPID(((AliAODTrack*)trackD0->GetDaughter(0)), 2)) && (fCuts->SelectPID(((AliAODTrack*)trackD0->GetDaughter(1)), 3))) bWrongSign = kFALSE;
2746  else if ((fCuts->SelectPID(((AliAODTrack*)trackD0->GetDaughter(0)), 3)) && (fCuts->SelectPID(((AliAODTrack*)trackD0->GetDaughter(1)), 2))) bWrongSign = kTRUE;
2747  else continue;
2748  } else if (trackBPlusPion->Charge() == 1) {
2749  pdgD0 = -421;
2750  if ((fCuts->SelectPID(((AliAODTrack*)trackD0->GetDaughter(0)), 3)) && (fCuts->SelectPID(((AliAODTrack*)trackD0->GetDaughter(1)), 2))) bWrongSign = kFALSE;
2751  else if ((fCuts->SelectPID(((AliAODTrack*)trackD0->GetDaughter(0)), 2)) && (fCuts->SelectPID(((AliAODTrack*)trackD0->GetDaughter(1)), 3))) bWrongSign = kTRUE;
2752  else continue;
2753  }
2754 
2755  //location BPlus pion rotation around PV
2756  for (Int_t iRot = 0; iRot < fNumberOfRotations + 1; ++iRot)
2757  {
2758  //we create a copy of the track that we will rotate
2759  AliAODTrack * trackBPlusPionRotated = new AliAODTrack(*trackBPlusPion);
2760 
2761  //for iRot == 0, we use the original unrotated track. For iRot > 0 we rotate the track and set the label to -1
2762  if (iRot != 0)
2763  {
2764  //should still check if track is already at PV
2765  Double_t dPhiRotated = trackBPlusPionRotated->Phi() + TMath::Pi() - (TMath::Pi() * fDegreePerRotation * fNumberOfRotations / (180.0 * 2.0)) + (TMath::Pi() * fDegreePerRotation * iRot / 180.0);
2766  trackBPlusPionRotated->SetPhi(dPhiRotated);
2767  }
2768 
2769  //we use the BPlus pion and D0 track to reconstruct the vertex for the BPlus
2770  AliExternalTrackParam firstTrack;
2771  firstTrack.CopyFromVTrack(trackBPlusPionRotated);
2772  AliExternalTrackParam secondTrack;
2773  secondTrack.CopyFromVTrack(trackD0);
2774 
2775  UInt_t prongs[2];
2776  prongs[1] = 421;
2777  prongs[0] = 211;
2778 
2779  UShort_t id[2];
2780  id[0] = firstTrack.GetID();
2781  id[1] = secondTrack.GetID();
2782 
2783  // we calculate the vertex of the mother candidate using two tracks
2784  TObjArray daughterTracks;
2785 
2786  daughterTracks.Add(&firstTrack);
2787  daughterTracks.Add(&secondTrack);
2788 
2789 
2790  Double_t dispersion = 0;
2791  AliAODVertex *vertexMother = RecalculateVertex(primaryVertex, &daughterTracks, bz, dispersion, kTRUE, kTRUE, kFALSE);
2792  if (!vertexMother)
2793  {
2794  delete vertexMother; vertexMother = nullptr;
2795  delete trackBPlusPionRotated; trackBPlusPionRotated = nullptr;
2796  continue;
2797  }
2798 
2799  //use the new vertex to create the BPlus candidate
2800  Double_t xdummy = 0., ydummy = 0., dca;
2801  Double_t d0z0[2], covd0z0[3], d0[2], d0err[2];
2802 
2803 
2804  firstTrack.PropagateToDCA(vertexMother, bz, 100., d0z0, covd0z0);
2805  secondTrack.PropagateToDCA(vertexMother, bz, 100., d0z0, covd0z0);
2806 
2807  //we reconstruct the mother decay prong
2808  Double_t px[2], py[2], pz[2];
2809  px[0] = firstTrack.Px();
2810  py[0] = firstTrack.Py();
2811  pz[0] = firstTrack.Pz();
2812  px[1] = secondTrack.Px();
2813  py[1] = secondTrack.Py();
2814  pz[1] = secondTrack.Pz();
2815 
2816  firstTrack.PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
2817  d0[0] = d0z0[0];
2818  d0err[0] = TMath::Sqrt(covd0z0[0]);
2819  secondTrack.PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
2820  d0[1] = d0z0[0];
2821  d0err[1] = TMath::Sqrt(covd0z0[0]);
2822 
2823 
2824  dca = secondTrack.GetDCA(&firstTrack, bz, xdummy, ydummy);
2825 
2826 
2827  Short_t chargeMother = trackD0->Charge() + trackBPlusPionRotated->Charge();
2828 
2829  AliAODRecoDecayHF2Prong trackBPlus(vertexMother, px, py, pz, d0, d0err, dca);
2830 
2831  trackBPlus.SetCharge(chargeMother);
2832  trackBPlus.GetSecondaryVtx()->AddDaughter(trackBPlusPionRotated);
2833  trackBPlus.GetSecondaryVtx()->AddDaughter(trackD0);
2834  trackBPlus.SetPrimaryVtxRef((AliAODVertex*)aodEvent->GetPrimaryVertex());
2835  trackBPlus.SetProngIDs(2, id);
2836 
2837  // Fiducial cut
2838  if (TMath::Abs(trackBPlus.Y(521)) > 0.8) {
2839  delete vertexMother; vertexMother = nullptr;
2840  delete trackBPlusPionRotated; trackBPlusPionRotated = nullptr;
2841  continue;
2842  }
2843 
2844  // We check if the signal is injected, optionally we can reject injected signals
2845  Bool_t bIsInjected = kFALSE;
2846  if (fUseMCInfo) {
2847  bIsInjected = IsCandidateInjected(&trackBPlus, header, mcTrackArray);
2848  if (fRemoveInjected && bIsInjected) {
2849  delete vertexMother; vertexMother = nullptr;
2850  delete trackBPlusPionRotated; trackBPlusPionRotated = nullptr;
2851  continue;
2852  }
2853  }
2854 
2855  // We check if the BPlus candidate is a true signal in Monte Carlo
2856  Bool_t isDesiredCandidate = kFALSE;
2857  Int_t mcLabelBPlus = -1;
2858  fillthis = "";
2859  Int_t motherType, histType;
2860  motherType = 1;
2861 
2862  if (fUseMCInfo)
2863  {
2864  mcLabelBPlus = MatchCandidateToMonteCarlo(521, &trackBPlus, mcTrackArray, BPlustoD0PiLabelMatrix);
2865  if (mcLabelBPlus >= 0 && trackBPlusPionRotated->GetLabel() >= 0 && iRot == 0)
2866  {
2867  isDesiredCandidate = kTRUE;
2868  }
2869  }
2870 
2871  histType = 0;
2872 
2873  if (isDesiredCandidate)
2874  {
2875  AliAODMCParticle *mcTrackBPlusPion = (AliAODMCParticle*)mcTrackArray->At(trackBPlusPion->GetLabel());
2876  AliAODMCParticle *mcTrackBPlus = (AliAODMCParticle*)mcTrackArray->At(mcLabelBPlus);
2877 
2878  // Double_t vertex_distance = TMath::Sqrt((vertexMotherTemp->GetX() - mcTrackBPlusPion->Xv()) * (vertexMotherTemp->GetX() - mcTrackBPlusPion->Xv()) + (vertexMotherTemp->GetY() - mcTrackBPlusPion->Yv()) * (vertexMotherTemp->GetY() - mcTrackBPlusPion->Yv()) + (vertexMotherTemp->GetZ() - mcTrackBPlusPion->Zv()) * (vertexMotherTemp->GetZ() - mcTrackBPlusPion->Zv()));
2879  // ((TH1F*)fMotherHistogramArrayExtra[motherType][4])->Fill(vertex_distance);
2880 
2881  Double_t vertex_distance_new = TMath::Sqrt((vertexMother->GetX() - mcTrackBPlusPion->Xv()) * (vertexMother->GetX() - mcTrackBPlusPion->Xv()) + (vertexMother->GetY() - mcTrackBPlusPion->Yv()) * (vertexMother->GetY() - mcTrackBPlusPion->Yv()) + (vertexMother->GetZ() - mcTrackBPlusPion->Zv()) * (vertexMother->GetZ() - mcTrackBPlusPion->Zv()));
2882  ((TH1F*)fMotherHistogramArrayExtra[motherType][5])->Fill(vertex_distance_new);
2883 
2884  Double_t momentum_resolution = TMath::Sqrt((trackBPlus.Px() - mcTrackBPlus->Px()) * (trackBPlus.Px() - mcTrackBPlus->Px()) + (trackBPlus.Py() - mcTrackBPlus->Py()) * (trackBPlus.Py() - mcTrackBPlus->Py()) + (trackBPlus.Pz() - mcTrackBPlus->Pz()) * (trackBPlus.Pz() - mcTrackBPlus->Pz()));
2885  ((TH1F*)fMotherHistogramArrayExtra[motherType][6])->Fill(momentum_resolution);
2886  }
2887 
2888  if (!bWrongSign)
2889  {
2890  // We fill the histograms
2891  histType = 0;
2892  FillBPlusHistograms(&trackBPlus, primaryVertex, bz, motherType, histType);
2893 
2894  if (isDesiredCandidate)
2895  {
2896  histType = 1;
2897  FillBPlusHistograms(&trackBPlus, primaryVertex, bz, motherType, histType);
2898  }
2899  }
2900 
2901 
2902  // We apply cuts
2903  Bool_t cutMother = kFALSE;
2904 
2905  Bool_t bCutArray[75] = {0};
2906  Int_t numberOfCuts = 75;
2907  Int_t cutReturnValue = fCuts->IsSelected(&trackBPlus, 0, aodEvent, bCutArray);
2908  if (cutReturnValue == -1) cutMother = kTRUE;
2909  if (cutReturnValue == 0) cutMother = kTRUE;
2910 
2911 
2912  // We save information about the cuts
2913  TString histName = "";
2914  Double_t invariantMassMother = trackBPlus.InvMass(2, prongs);
2915  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(521)->Mass();
2916  Double_t massWindow = fHistMassWindow; //GeV/c^2
2917 
2918  for (Int_t n = 0; n < 75; ++n)
2919  {
2920  if (bCutArray[n] == kTRUE) {
2921  if (isDesiredCandidate) {
2922  ((TH1F*)fMotherHistogramArrayExtra[motherType][1])->Fill(n + 1);
2923  } else ((TH1F*)fMotherHistogramArrayExtra[motherType][0])->Fill(n + 1);
2924  cutMother = kTRUE;
2925  }
2926  }
2927 
2928  if (TMath::Abs(invariantMassMother - pdgMassMother) < massWindow) {
2929  for (Int_t l = 0; l < numberOfCuts; ++l) //total
2930  {
2931  if (bCutArray[l] == kFALSE) continue;
2932  for (Int_t j = 0; j < numberOfCuts; ++j)
2933  {
2934  if (bCutArray[j] == kFALSE) continue;
2935  if (isDesiredCandidate == kFALSE) ((TH2F*)(fResultsHistogramArray2D[2][0]))->Fill(l, j);
2936  if (isDesiredCandidate == kTRUE) ((TH2F*)(fResultsHistogramArray2D[2][1]))->Fill(l, j);
2937  }
2938  }
2939 
2940  for (Int_t l = 0; l < numberOfCuts; ++l) //unique
2941  {
2942  if (bCutArray[l] == kFALSE) continue;
2943  Bool_t bFill = kTRUE;
2944  for (Int_t j = 0; j < numberOfCuts; ++j)
2945  {
2946  if (l == j) continue;
2947  if (bCutArray[j] == kTRUE)
2948  {
2949  bFill = kFALSE;
2950  break;
2951  }
2952 
2953  }
2954  if (bFill == kTRUE)
2955  {
2956  if (isDesiredCandidate == kFALSE) ((TH1F*)(fResultsHistogramArray[13][0]))->Fill(l);
2957  if (isDesiredCandidate == kTRUE) ((TH1F*)(fResultsHistogramArray[13][1]))->Fill(l);
2958  }
2959  }
2960  }
2961 
2962 
2963  if (!isDesiredCandidate && fQuickSignalAnalysis == 1) cutMother = kTRUE;
2964 
2965  if (cutMother)
2966  {
2967  if (isDesiredCandidate)
2968  {
2969  ((TH1F*)fMotherHistogramArrayExtra[motherType][1])->Fill(0);
2970  } else ((TH1F*)fMotherHistogramArrayExtra[motherType][0])->Fill(0);
2971  delete vertexMother; vertexMother = nullptr;
2972  delete trackBPlusPionRotated; trackBPlusPionRotated = nullptr;
2973  continue;
2974  }
2975 
2976  if (!bWrongSign)
2977  {
2978  histType = 2;
2979  FillBPlusHistograms(&trackBPlus, primaryVertex, bz, motherType, histType);
2980  if (fUseMCInfo && isDesiredCandidate)
2981  {
2982  //fill mc histograms
2983  histType = 3;
2984  FillBPlusHistograms(&trackBPlus, primaryVertex, bz, motherType, histType);
2985  }
2986  }
2987 
2988  if (TMath::Abs(invariantMassMother - pdgMassMother) < massWindow)
2989  {
2990  if (!bWrongSign)
2991  {
2992  FillFinalTrackHistograms(&trackBPlus, primaryVertex, bz, isDesiredCandidate, mcTrackArray);
2993  if (!isDesiredCandidate)
2994  {
2995  motherType = 0; histType = 4; FillD0Histograms(trackD0, primaryVertex, bz, motherType, histType, pdgD0);
2996  motherType = 1; histType = 4; FillBPlusHistograms(&trackBPlus, primaryVertex, bz, motherType, histType);
2997  }
2998  if (isDesiredCandidate)
2999  {
3000  motherType = 0; histType = 5; FillD0Histograms(trackD0, primaryVertex, bz, motherType, histType, pdgD0);
3001  motherType = 1; histType = 5; FillBPlusHistograms(&trackBPlus, primaryVertex, bz, motherType, histType);
3002  }
3003  }
3004  }
3005 
3006 
3007  // Here we fill the histograms per pt bin and apply the same sign method
3008  TString ptBinMother = "";
3009  Int_t ptBin = fCuts->PtBin(trackBPlus.Pt());
3010  ptBinMother += "_ptbin_"; ptBinMother += fPtBinLimits[ptBin]; ptBinMother += "_to_"; ptBinMother += fPtBinLimits[ptBin + 1];
3011  histType = 6 + 2 * ptBin;
3012 
3013  Int_t d0PtBin = fCuts->PtBinD0forD0ptbin(trackD0->Pt());
3014  Int_t histTypeD0 = 2 * d0PtBin;
3015 
3016 
3017  if (TMath::Abs(invariantMassMother - pdgMassMother) < massWindow)
3018  {
3019  if (!bWrongSign && histType > 5)
3020  {
3021  if (!isDesiredCandidate)
3022  {
3023  motherType = 0; FillD0Histograms(trackD0, primaryVertex, bz, motherType, histType, pdgD0);
3024  motherType = 1; FillBPlusHistograms(&trackBPlus, primaryVertex, bz, motherType, histType);
3025  motherType = 2; FillD0Histograms(trackD0, primaryVertex, bz, motherType, histTypeD0, pdgD0);
3026  }
3027 
3028  if (isDesiredCandidate)
3029  {
3030  histType += 1;
3031  motherType = 0; FillD0Histograms(trackD0, primaryVertex, bz, motherType, histType, pdgD0);
3032  motherType = 1; FillBPlusHistograms(&trackBPlus, primaryVertex, bz, motherType, histType);
3033  motherType = 2; FillD0Histograms(trackD0, primaryVertex, bz, motherType, histTypeD0 + 1, pdgD0);
3034  }
3035  }
3036  }
3037 
3038  // after the (loose) cut on candidates we can get data for cut optimization
3039  if (!bWrongSign && fPerformCutOptimization)
3040  {
3041  Double_t sigmaWindowForCutOptimization = fCuts->GetSigmaForCutOptimization(ptBin);
3043  Double_t massDifference = TMath::Abs(invariantMassMother - pdgMassMother);
3044 
3045  if (massDifference < nSigmaBins * sigmaWindowForCutOptimization)
3046  {
3047  Int_t nSigmaBin = 0;
3048  if (invariantMassMother < pdgMassMother)
3049  {
3050  for (Int_t iSigma = 0; iSigma < nSigmaBins; ++iSigma)
3051  {
3052  if ((massDifference > iSigma * sigmaWindowForCutOptimization) && (massDifference < (iSigma + 1) * sigmaWindowForCutOptimization)) {nSigmaBin = -(iSigma + 1); break;}
3053  }
3054  }
3055  if (invariantMassMother > pdgMassMother)
3056  {
3057  for (Int_t iSigma = 0; iSigma < nSigmaBins; ++iSigma)
3058  {
3059  if ((massDifference > iSigma * sigmaWindowForCutOptimization) && (massDifference < (iSigma + 1) * sigmaWindowForCutOptimization)) {nSigmaBin = iSigma; break;}
3060  }
3061  }
3062 
3063  Int_t nStartVariable = 0;
3064  Int_t nStartFillNumber = 0;
3066  Int_t nCuts = fCuts->GetnCutsForOptimization();
3067  CutOptimizationVariableValues(&trackBPlus, aodEvent);
3068  CutOptimizationLoop(nStartVariable, nVariables, nCuts, ptBin, nStartFillNumber, isDesiredCandidate, nSigmaBin);
3069  }
3070  }
3071 
3072 
3073  Double_t invmassDelta = DeltaInvMassBPlusKpipi(&trackBPlus);
3074 
3075  // Fill invariant mass histograms
3076  for (Int_t m = 0; m < 7; ++m)
3077  {
3078  Int_t fillfactor = 1;
3079  if (bWrongSign && !(m == 1 || m == 2)) continue;
3080  if (!bWrongSign && m == 1) continue;
3081  if (bWrongSign && m == 2) fillfactor = -1;
3082  if (iRot > 0 && !(m == 3 || m == 6)) continue;
3083  if (iRot == 0 && (m == 3 || m == 6)) continue;
3084  if (m > 3 && bIsInjected) continue;
3085  if (m == 4 && isDesiredCandidate) continue;
3086  if (m == 5 && !isDesiredCandidate) continue;
3087  if (m == 6 && isDesiredCandidate) continue;
3088 
3089  ((TH1F*)fResultsHistogramArray[4 + m][0])->Fill(invariantMassMother,fillfactor);
3090  ((TH1F*)fResultsHistogramArray[4 + m][0 + fnPtBins + 3])->Fill(invmassDelta,fillfactor);
3091 
3092  if (ptBin > 0)
3093  {
3094  ((TH1F*)fResultsHistogramArray[4 + m][1])->Fill(invariantMassMother,fillfactor);
3095  ((TH1F*)fResultsHistogramArray[4 + m][1 + fnPtBins + 3])->Fill(invmassDelta,fillfactor);
3096  }
3097  if (ptBin > 1)
3098  {
3099  ((TH1F*)fResultsHistogramArray[4 + m][2])->Fill(invariantMassMother,fillfactor);
3100  ((TH1F*)fResultsHistogramArray[4 + m][2 + fnPtBins + 3])->Fill(invmassDelta,fillfactor);
3101  }
3102 
3103  ((TH1F*)fResultsHistogramArray[4 + m][ptBin + 3])->Fill(invariantMassMother,fillfactor);
3104  ((TH1F*)fResultsHistogramArray[4 + m][ptBin + 3 + fnPtBins + 3])->Fill(invmassDelta,fillfactor);
3105  }
3106 
3107  delete vertexMother; vertexMother = NULL;
3108  delete trackBPlusPionRotated; trackBPlusPionRotated = nullptr;
3109  }
3110  }
3111 
3112  //Restore Object count
3113  //To save space in the table keeping track of all referenced objects,
3114  //we reset the object count to what it was at the beginning of the loop.
3115  TProcessID::SetObjectCount(ObjectNumber);
3116  }
3117  return;
3118 }
3119 //-------------------------------------------------------------------------------------
3120 void AliAnalysisTaskSEBPlustoD0Pi::FillFinalTrackHistograms(AliAODRecoDecayHF2Prong * selectedBPlus, AliAODVertex *primaryVertex, Double_t bz, Bool_t isDesiredCandidate, TClonesArray * mcTrackArray) {
3121 
3122  //In this function we fill histograms with the properties of all the daughters of our selected signal candidate
3123 
3124  AliAODTrack* selectedBPlusPion = (AliAODTrack*)selectedBPlus->GetDaughter(0);
3125  AliAODRecoDecayHF2Prong* selectedD0 = (AliAODRecoDecayHF2Prong*)selectedBPlus->GetDaughter(1);
3126 
3127  AliAODTrack* selectedD0Pion = 0x0;
3128  AliAODTrack* selectedD0Kaon = 0x0;
3129 
3130  if (selectedBPlus->Charge() == 1) selectedD0Pion = (AliAODTrack*)selectedD0->GetDaughter(0);
3131  if (selectedBPlus->Charge() == -1) selectedD0Pion = (AliAODTrack*)selectedD0->GetDaughter(1);
3132 
3133  if (selectedBPlus->Charge() == 1) selectedD0Kaon = (AliAODTrack*)selectedD0->GetDaughter(1);
3134  if (selectedBPlus->Charge() == -1) selectedD0Kaon = (AliAODTrack*)selectedD0->GetDaughter(0);
3135 
3136  Double_t d0BPluspion = TMath::Abs(selectedBPlus->Getd0Prong(0));
3137  Double_t d0D0pion = 0;
3138  Double_t d0D0kaon = 0;
3139 
3140  if (selectedBPlus->Charge() == 1) d0D0pion = selectedD0->Getd0Prong(0);
3141  if (selectedBPlus->Charge() == -1) d0D0pion = selectedD0->Getd0Prong(1);
3142 
3143  if (selectedBPlus->Charge() == 1) d0D0kaon = selectedD0->Getd0Prong(1);
3144  if (selectedBPlus->Charge() == -1) d0D0kaon = selectedD0->Getd0Prong(0);
3145 
3146  Double_t pt_track = 0;
3147  Double_t momentum_track = 0;
3148  Int_t numberOfITS = 0;
3149  Int_t numberOfTPC = 0;
3150  Int_t daughterType, histType;
3151  Int_t totalNumberOfITS = 0;
3152  Int_t totalNumberOfTPC = 0;
3153  Double_t nSigmaTPC = 0;
3154  Double_t nSigmaTOF = 0;
3155  Double_t nSigmaTPCtotal = 0;
3156  Double_t nSigmaTOFtotal = 0;
3157  Int_t pionPIDnumber = 2;
3158  Int_t kaonPIDnumber = 3;
3159  Int_t TPCok = 0;
3160  Int_t TOFok = 0;
3161 
3162  AliAODPidHF* trackPIDHF = (AliAODPidHF*)fCuts->GetPidHF();
3163 
3164  //fill the D0 pion info
3165  pt_track = selectedD0Pion->Pt();
3166  momentum_track = selectedD0Pion->P();
3167  numberOfITS = selectedD0Pion->GetITSNcls();
3168  numberOfTPC = selectedD0Pion->GetTPCNcls();
3169  totalNumberOfITS += numberOfITS;
3170  totalNumberOfTPC += numberOfTPC;
3171  if(trackPIDHF) TPCok = trackPIDHF->GetnSigmaTPC(selectedD0Pion, pionPIDnumber, nSigmaTPC);
3172  if(trackPIDHF) TOFok = trackPIDHF->GetnSigmaTOF(selectedD0Pion, pionPIDnumber, nSigmaTOF);
3173  if (TPCok != -1) nSigmaTPCtotal += nSigmaTPC * nSigmaTPC;
3174  if (TOFok != -1) nSigmaTOFtotal += nSigmaTOF * nSigmaTOF;
3175 
3176  Double_t ptBPlus = selectedBPlus->Pt();
3177 
3178  daughterType = 0;
3179  histType = 4;
3180  if (!isDesiredCandidate)
3181  {
3182  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
3183  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
3184  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
3185  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
3186 
3187  for (Int_t j = 0; j < 10; ++j)
3188  {
3189  if (selectedD0Pion->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
3190 
3191  }
3192 
3193  if (TPCok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(nSigmaTPC);
3194  if (TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][5])->Fill(nSigmaTOF);
3195  if (TPCok != -1 && TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][6])->Fill(TMath::Sqrt(nSigmaTPC * nSigmaTPC + nSigmaTOF * nSigmaTOF));
3196  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0D0pion);
3197  ((TH1F*)fDaughterHistogramArray[daughterType][histType][9])->Fill(selectedD0Pion->Eta());
3198  ((TH2F*)fDaughterHistogramArray2D[daughterType][4])->Fill(ptBPlus, pt_track);
3199  }
3200 
3201  if (isDesiredCandidate)
3202  {
3203  histType = 5;
3204  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
3205  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
3206  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
3207  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
3208 
3209  for (Int_t j = 0; j < 10; ++j)
3210  {
3211  if (selectedD0Pion->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
3212 
3213  }
3214 
3215  if (TPCok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(nSigmaTPC);
3216  if (TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][5])->Fill(nSigmaTOF);
3217  if (TPCok != -1 && TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][6])->Fill(TMath::Sqrt(nSigmaTPC * nSigmaTPC + nSigmaTOF * nSigmaTOF));
3218  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0D0pion);
3219  ((TH1F*)fDaughterHistogramArray[daughterType][histType][9])->Fill(selectedD0Pion->Eta());
3220  ((TH2F*)fDaughterHistogramArray2D[daughterType][5])->Fill(ptBPlus, pt_track);
3221  }
3222 
3223  //we save the pdgcode of the used particle and its mother to check PID efficiency
3224  if (fUseMCInfo)
3225  {
3226  Float_t pdgCodeParticle = -1;
3227  Float_t pdgCodeParticleMother = -1;
3228  Int_t mcLabelParticle = -1;
3229  Int_t mcLabelParticleMother = -1;
3230  mcLabelParticle = selectedD0Pion->GetLabel();
3231 
3232  if (mcLabelParticle >= 0) {
3233 
3234  AliAODMCParticle *mcTrackParticle = (AliAODMCParticle*)mcTrackArray->At(mcLabelParticle);
3235  pdgCodeParticle = TMath::Abs(mcTrackParticle->GetPdgCode());
3236  ((TH1F*)fDaughterHistogramArrayExtra[0][2])->Fill(pdgCodeParticle);
3237  mcLabelParticleMother = mcTrackParticle->GetMother();
3238 
3239  if (mcLabelParticleMother >= 0) {
3240  AliAODMCParticle *mcTrackParticleMother = (AliAODMCParticle*)mcTrackArray->At(mcLabelParticleMother);
3241  pdgCodeParticleMother = TMath::Abs(mcTrackParticleMother->GetPdgCode());
3242  ((TH1F*)fDaughterHistogramArrayExtra[0][3])->Fill(pdgCodeParticleMother);
3243  }
3244  }
3245  }
3246 
3247  //fill the D0 kaon info
3248  pt_track = selectedD0Kaon->Pt();
3249  momentum_track = selectedD0Kaon->P();
3250  numberOfITS = selectedD0Kaon->GetITSNcls();
3251  numberOfTPC = selectedD0Kaon->GetTPCNcls();
3252  totalNumberOfITS += numberOfITS;
3253  totalNumberOfTPC += numberOfTPC;
3254  if(trackPIDHF) TPCok = trackPIDHF->GetnSigmaTPC(selectedD0Kaon, kaonPIDnumber, nSigmaTPC);
3255  if(trackPIDHF) TOFok = trackPIDHF->GetnSigmaTOF(selectedD0Kaon, kaonPIDnumber, nSigmaTOF);
3256  if (TPCok != -1) nSigmaTPCtotal += nSigmaTPC * nSigmaTPC;
3257  if (TOFok != -1) nSigmaTOFtotal += nSigmaTOF * nSigmaTOF;
3258 
3259  daughterType = 1;
3260  histType = 4;
3261  if (!isDesiredCandidate)
3262  {
3263  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
3264  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
3265  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
3266  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
3267 
3268  for (Int_t j = 0; j < 10; ++j)
3269  {
3270  if (selectedD0Kaon->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
3271 
3272  }
3273 
3274  if (TPCok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(nSigmaTPC);
3275  if (TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][5])->Fill(nSigmaTOF);
3276  if (TPCok != -1 && TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][6])->Fill(TMath::Sqrt(nSigmaTPC * nSigmaTPC + nSigmaTOF * nSigmaTOF));
3277  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0D0kaon);
3278  ((TH1F*)fDaughterHistogramArray[daughterType][histType][9])->Fill(selectedD0Kaon->Eta());
3279  ((TH2F*)fDaughterHistogramArray2D[daughterType][4])->Fill(ptBPlus, pt_track);
3280  }
3281 
3282  if (isDesiredCandidate)
3283  {
3284  histType = 5;
3285  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
3286  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
3287  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
3288  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
3289 
3290  for (Int_t j = 0; j < 10; ++j)
3291  {
3292  if (selectedD0Kaon->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
3293 
3294  }
3295 
3296  if (TPCok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(nSigmaTPC);
3297  if (TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][5])->Fill(nSigmaTOF);
3298  if (TPCok != -1 && TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][6])->Fill(TMath::Sqrt(nSigmaTPC * nSigmaTPC + nSigmaTOF * nSigmaTOF));
3299  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0D0kaon);
3300  ((TH1F*)fDaughterHistogramArray[daughterType][histType][9])->Fill(selectedD0Kaon->Eta());
3301  ((TH2F*)fDaughterHistogramArray2D[daughterType][5])->Fill(ptBPlus, pt_track);
3302  }
3303 
3304  //we save the pdgcode of the used particle and its mother to check PID efficiency
3305  if (fUseMCInfo)
3306  {
3307  Float_t pdgCodeParticle = -1;
3308  Float_t pdgCodeParticleMother = -1;
3309  Int_t mcLabelParticle = -1;
3310  Int_t mcLabelParticleMother = -1;
3311  mcLabelParticle = selectedD0Kaon->GetLabel();
3312 
3313  if (mcLabelParticle >= 0) {
3314 
3315  AliAODMCParticle *mcTrackParticle = (AliAODMCParticle*)mcTrackArray->At(mcLabelParticle);
3316  pdgCodeParticle = TMath::Abs(mcTrackParticle->GetPdgCode());
3317  ((TH1F*)fDaughterHistogramArrayExtra[1][2])->Fill(pdgCodeParticle);
3318  mcLabelParticleMother = mcTrackParticle->GetMother();
3319 
3320  if (mcLabelParticleMother >= 0) {
3321  AliAODMCParticle *mcTrackParticleMother = (AliAODMCParticle*)mcTrackArray->At(mcLabelParticleMother);
3322  pdgCodeParticleMother = TMath::Abs(mcTrackParticleMother->GetPdgCode());
3323  ((TH1F*)fDaughterHistogramArrayExtra[1][3])->Fill(pdgCodeParticleMother);
3324  }
3325  }
3326  }
3327 
3328  //fill the BPlus pion info
3329  pt_track = selectedBPlusPion->Pt();
3330  momentum_track = selectedBPlusPion->P();
3331  numberOfITS = selectedBPlusPion->GetITSNcls();
3332  numberOfTPC = selectedBPlusPion->GetTPCNcls();
3333  totalNumberOfITS += numberOfITS;
3334  totalNumberOfTPC += numberOfTPC;
3335  if(trackPIDHF) TPCok = trackPIDHF->GetnSigmaTPC(selectedBPlusPion, pionPIDnumber, nSigmaTPC);
3336  if(trackPIDHF) TOFok = trackPIDHF->GetnSigmaTOF(selectedBPlusPion, pionPIDnumber, nSigmaTOF);
3337  if (TPCok != -1) nSigmaTPCtotal += nSigmaTPC * nSigmaTPC;
3338  if (TOFok != -1) nSigmaTOFtotal += nSigmaTOF * nSigmaTOF;
3339 
3340  daughterType = 2;
3341  histType = 4;
3342  if (!isDesiredCandidate)
3343  {
3344  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
3345  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
3346  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
3347  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
3348 
3349  for (Int_t j = 0; j < 10; ++j)
3350  {
3351  if (selectedBPlusPion->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
3352 
3353  }
3354 
3355  if (TPCok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(nSigmaTPC);
3356  if (TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][5])->Fill(nSigmaTOF);
3357  if (TPCok != -1 && TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][6])->Fill(TMath::Sqrt(nSigmaTPC * nSigmaTPC + nSigmaTOF * nSigmaTOF));
3358  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0BPluspion);
3359  ((TH1F*)fDaughterHistogramArray[daughterType][histType][9])->Fill(selectedBPlusPion->Eta());
3360  ((TH2F*)fDaughterHistogramArray2D[daughterType][4])->Fill(ptBPlus, pt_track);
3361  }
3362 
3363  if (isDesiredCandidate)
3364  {
3365  histType = 5;
3366  ((TH1F*)fDaughterHistogramArray[daughterType][histType][0])->Fill(pt_track);
3367  ((TH1F*)fDaughterHistogramArray[daughterType][histType][1])->Fill(momentum_track);
3368  ((TH1F*)fDaughterHistogramArray[daughterType][histType][2])->Fill(numberOfITS);
3369  ((TH1F*)fDaughterHistogramArray[daughterType][histType][3])->Fill(numberOfTPC);
3370 
3371  for (Int_t j = 0; j < 10; ++j)
3372  {
3373  if (selectedBPlusPion->HasPointOnITSLayer(j)) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(j);
3374 
3375  }
3376 
3377  if (TPCok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][4])->Fill(nSigmaTPC);
3378  if (TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][5])->Fill(nSigmaTOF);
3379  if (TPCok != -1 && TOFok != -1) ((TH1F*)fDaughterHistogramArray[daughterType][histType][6])->Fill(TMath::Sqrt(nSigmaTPC * nSigmaTPC + nSigmaTOF * nSigmaTOF));
3380  ((TH1F*)fDaughterHistogramArray[daughterType][histType][8])->Fill(d0BPluspion);
3381  ((TH1F*)fDaughterHistogramArray[daughterType][histType][9])->Fill(selectedBPlusPion->Eta());
3382  ((TH2F*)fDaughterHistogramArray2D[daughterType][5])->Fill(ptBPlus, pt_track);
3383  }
3384 
3385  //we save the pdgcode of the used particle and its mother to check PID efficiency
3386  if (fUseMCInfo)
3387  {
3388  Float_t pdgCodeParticle = -1;
3389  Float_t pdgCodeParticleMother = -1;
3390  Int_t mcLabelParticle = -1;
3391  Int_t mcLabelParticleMother = -1;
3392  mcLabelParticle = selectedBPlusPion->GetLabel();
3393 
3394  if (mcLabelParticle >= 0) {
3395 
3396  AliAODMCParticle *mcTrackParticle = (AliAODMCParticle*)mcTrackArray->At(mcLabelParticle);
3397  pdgCodeParticle = TMath::Abs(mcTrackParticle->GetPdgCode());
3398  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][2])->Fill(pdgCodeParticle);
3399  mcLabelParticleMother = mcTrackParticle->GetMother();
3400 
3401  if (mcLabelParticleMother >= 0) {
3402  AliAODMCParticle *mcTrackParticleMother = (AliAODMCParticle*)mcTrackArray->At(mcLabelParticleMother);
3403  pdgCodeParticleMother = TMath::Abs(mcTrackParticleMother->GetPdgCode());
3404  ((TH1F*)fDaughterHistogramArrayExtra[daughterType][3])->Fill(pdgCodeParticleMother);
3405  }
3406  }
3407  }
3408 
3409  if (!isDesiredCandidate)
3410  {
3411  ((TH1F*)(fResultsHistogramArray[11][0]))->Fill(totalNumberOfITS);
3412  ((TH1F*)(fResultsHistogramArray[11][2]))->Fill(totalNumberOfTPC);
3413  ((TH1F*)(fResultsHistogramArray[11][4]))->Fill(TMath::Sqrt(nSigmaTPCtotal + nSigmaTOFtotal));
3414  }
3415  if (isDesiredCandidate)
3416  {
3417  ((TH1F*)(fResultsHistogramArray[11][1]))->Fill(totalNumberOfITS);
3418  ((TH1F*)(fResultsHistogramArray[11][3]))->Fill(totalNumberOfTPC);
3419  ((TH1F*)(fResultsHistogramArray[11][5]))->Fill(TMath::Sqrt(nSigmaTPCtotal + nSigmaTOFtotal));
3420  }
3421 
3422  // we look at the invariant mass combinations of all daughter tracks
3423  AliExternalTrackParam trackBPlusPion;
3424  trackBPlusPion.CopyFromVTrack(selectedBPlusPion);
3425  AliExternalTrackParam trackD0Pion;
3426  trackD0Pion.CopyFromVTrack(selectedD0Pion);
3427  AliExternalTrackParam trackD0Kaon;
3428  trackD0Kaon.CopyFromVTrack(selectedD0Kaon);
3429 
3430  UInt_t prongs2[2] = {0};
3431  UInt_t prongs3[3] = {0};
3432 
3433  prongs2[0] = 211; prongs2[1] = 211;
3434  TwoTrackCombinationInfo(&trackD0Pion, &trackBPlusPion, primaryVertex, bz, isDesiredCandidate, 0, prongs2);
3435  prongs2[0] = 321; prongs2[1] = 211;
3436  TwoTrackCombinationInfo(&trackD0Kaon, &trackBPlusPion, primaryVertex, bz, isDesiredCandidate, 2, prongs2);
3437  prongs3[0] = 211; prongs3[1] = 321; prongs3[2] = 211;
3438  ThreeTrackCombinationInfo(&trackD0Pion, &trackD0Kaon, &trackBPlusPion, primaryVertex, bz, isDesiredCandidate, 4, prongs3);
3439 
3440  return;
3441 }
3442 //-------------------------------------------------------------------------------------
3444 {
3448 
3449  AliAODRecoDecayHF2Prong * D0 = (AliAODRecoDecayHF2Prong*)BPlus->GetDaughter(1);
3450 
3451  Double_t e[3] = {0};
3452  if (BPlus->Charge() == -1)
3453  {
3454  e[0] = D0->EProng(0, 211);
3455  e[1] = D0->EProng(1, 321);
3456  } else if (BPlus->Charge() == 1) {
3457  e[0] = D0->EProng(0, 321);
3458  e[1] = D0->EProng(1, 211);
3459  }
3460  e[2] = BPlus->EProng(0, 211);
3461 
3462  Double_t esum = e[0] + e[1] + e[2];
3463  Double_t invMassBPlus = TMath::Sqrt(esum * esum - BPlus->P2());
3464 
3465  Double_t invMassD0 = -1;
3466 
3467  if (BPlus->Charge() == -1) {invMassD0 = D0->InvMassD0();}
3468  else {invMassD0 = D0->InvMassD0bar();}
3469  if (invMassD0 == -1) {std::cout << "wrong invmass delta D0 BPlus" << std::endl;}
3470 
3471  return invMassBPlus - invMassD0;
3472 }
3473 //-------------------------------------------------------------------------------------
3474 void AliAnalysisTaskSEBPlustoD0Pi::FillD0Histograms(AliAODRecoDecayHF2Prong * selectedMother, AliAODVertex *primaryVertex, Double_t bz, Int_t motherType, Int_t histType, Int_t pdgCodeMother) {
3475 
3476  if (histType < 0) return;
3477 
3478  //In this function we fill the histograms of the reconstructed mothers
3479  Double_t ptMother = 0.0;
3480  Double_t momentumMother = 0.0;
3481  Double_t etaMother = 0.0;
3482  Double_t phiMother = 0.0;
3483  Double_t d0Mother = 0.0;
3484  Double_t d0firstTrack = 0.0;
3485  Double_t d0secondTrack = 0.0;
3486  Double_t pointingAngle = 0.0;
3487  Double_t impactProduct = 0.0;
3488  Double_t impactProductXY = 0.0;
3489  Double_t invariantMassMother = 0.0;
3490  Double_t invmassDelta = 0.0;
3491  Double_t dcaMother = 0.0;
3492  AliAODVertex * vertexMother = 0x0;
3493  Double_t vertexDistance = 0.0;
3494  Double_t decayTime = 0.0;
3495  Double_t angleMotherFirstDaughter = 0.0;
3496  Double_t angleMotherSecondDaughter = 0.0;
3497  Double_t ptFirstDaughter = 0.0;
3498  Double_t ptSecondDaughter = 0.0;
3499  UInt_t prongs[2], prongs2[2];
3500  Double_t angleBetweenBothDaughters = 0;
3501  Double_t cosThetaStar = 0;
3502  Double_t normDecayLength = 0;
3503  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(421)->Mass();
3504 
3505 
3506  prongs[0] = 211; prongs[1] = 321;
3507  prongs2[0] = 321; prongs2[1] = 211;
3508  AliAODTrack * firstDaughter = (AliAODTrack*)selectedMother->GetDaughter(0);
3509  AliAODTrack * secondDaughter = (AliAODTrack*)selectedMother->GetDaughter(1);
3510  vertexMother = selectedMother->GetSecondaryVtx();
3511  ptFirstDaughter = firstDaughter->Pt();
3512  ptSecondDaughter = secondDaughter->Pt();
3513 
3514  //Topomatic
3515  Double_t dd0pr1 = 0.;
3516  Double_t dd0pr2 = 0.;
3517  Double_t dd0max = 0.;
3518  Double_t dd0min = 0.;
3519  for (Int_t ipr = 0; ipr < 2; ipr++)
3520  {
3521  Double_t diffIP, errdiffIP;
3522  selectedMother->Getd0MeasMinusExpProng(ipr, bz, diffIP, errdiffIP);
3523  Double_t normdd0 = 0.;
3524  if (errdiffIP > 0.) normdd0 = diffIP / errdiffIP;
3525  if (ipr == 0) dd0pr1 = normdd0;
3526  if (ipr == 1) dd0pr2 = normdd0;
3527 
3528  }
3529  if (TMath::Abs(dd0pr1) > TMath::Abs(dd0pr2)) {dd0max = dd0pr1; dd0min = dd0pr2;}
3530  else {dd0max = dd0pr2; dd0min = dd0pr1;}
3531 
3532  AliExternalTrackParam motherTrack;
3533  motherTrack.CopyFromVTrack(selectedMother);
3534  Double_t d0z0[2], covd0z0[3], d0[2];
3535  motherTrack.PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
3536  d0[0] = d0z0[0];
3537 
3538  ptMother = selectedMother->Pt();
3539  momentumMother = selectedMother->P();
3540  etaMother = selectedMother->Eta();
3541  phiMother = selectedMother->Phi();
3542 
3543  d0Mother = TMath::Abs(d0[0]);
3544  d0firstTrack = TMath::Abs(selectedMother->Getd0Prong(0));
3545  d0secondTrack = TMath::Abs(selectedMother->Getd0Prong(1));
3546  pointingAngle = selectedMother->CosPointingAngle();
3547  impactProduct = selectedMother->Prodd0d0();
3548  impactProductXY = TMath::Abs(selectedMother->ImpParXY());
3549  invariantMassMother = selectedMother->InvMass(2, prongs);
3550  if (pdgCodeMother == -421) invariantMassMother = selectedMother->InvMass(2, prongs2);
3551 
3552  dcaMother = selectedMother->GetDCA();
3553  vertexDistance = vertexMother->DistanceToVertex(primaryVertex);
3554  angleMotherFirstDaughter = (selectedMother->Px() * firstDaughter->Px() + selectedMother->Py() * firstDaughter->Py() + selectedMother->Pz() * firstDaughter->Pz()) / (selectedMother->P() * firstDaughter->P());
3555  angleMotherSecondDaughter = (selectedMother->Px() * secondDaughter->Px() + selectedMother->Py() * secondDaughter->Py() + selectedMother->Pz() * secondDaughter->Pz()) / (selectedMother->P() * secondDaughter->P());
3556  cosThetaStar = selectedMother->CosThetaStar(0, 421, 211, 321);
3557  angleBetweenBothDaughters = (firstDaughter->Px() * secondDaughter->Px() + firstDaughter->Py() * secondDaughter->Py() + firstDaughter->Pz() * secondDaughter->Pz()) / (firstDaughter->P() * secondDaughter->P());
3558  normDecayLength = selectedMother->NormalizedDecayLength();
3559 
3560  Double_t pseudoProperDecayLength = ((vertexMother->GetX() - primaryVertex->GetX()) * selectedMother->Px() / TMath::Abs(selectedMother->Pt())) + ((vertexMother->GetY() - primaryVertex->GetY()) * selectedMother->Py() / TMath::Abs(selectedMother->Pt()));
3561  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother / ptMother;
3562  decayTime = vertexDistance / (299792458 * TMath::Sqrt(1 / ((pdgMassMother * pdgMassMother / (momentumMother * momentumMother)) + 1)));
3563 
3564  Double_t phi = selectedMother->Phi();
3565  Double_t theta = selectedMother->Theta();
3566  Double_t covMatrix[21];
3567  selectedMother->GetCovarianceXYZPxPyPz(covMatrix);
3568 
3569  Double_t cp = TMath::Cos(phi);
3570  Double_t sp = TMath::Sin(phi);
3571  Double_t ct = TMath::Cos(theta);
3572  Double_t st = TMath::Sin(theta);
3573 
3574  Double_t errorMomentum = covMatrix[9] * cp * cp * ct * ct // GetCovPxPx
3575  + covMatrix[13] * 2.*cp * sp * ct * ct // GetCovPxPy
3576  + covMatrix[18] * 2.*cp * ct * st // GetCovPxPz
3577  + covMatrix[14] * sp * sp * ct * ct // GetCovPyPy
3578  + covMatrix[19] * 2.*sp * ct * st // GetCovPyPz
3579  + covMatrix[20] * st * st; // GetCovPzPz
3580  Double_t normalizedDecayTime = selectedMother->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1 / ((pdgMassMother * pdgMassMother * errorMomentum * errorMomentum / (momentumMother * momentumMother)) + 1)));
3581 
3582  Double_t eKaon = selectedMother->EProng(1, 321);
3583  Double_t invMassKaon = TMath::Sqrt(eKaon * eKaon - secondDaughter->P() * secondDaughter->P());
3584  if (pdgCodeMother == -421) eKaon = selectedMother->EProng(0, 321);
3585  if (pdgCodeMother == -421) invMassKaon = TMath::Sqrt(eKaon * eKaon - firstDaughter->P() * firstDaughter->P());
3586  Double_t invMassD0 = selectedMother->InvMassD0();
3587  invmassDelta = invMassD0 - invMassKaon;
3588 
3589  Double_t vertexMotherX = vertexMother->GetX();
3590  Double_t vertexMotherY = vertexMother->GetY();
3591  Double_t vertexMotherZ = vertexMother->GetZ();
3592 
3593  Double_t cosPointingAngleXY = selectedMother->CosPointingAngleXY();
3594  Double_t distanceXYToVertex = vertexMother->DistanceXYToVertex(primaryVertex);
3595  Double_t normalizedDecayLengthXY = selectedMother->NormalizedDecayLengthXY();
3596 
3597  ((TH1F*)fMotherHistogramArray[motherType][histType][0])->Fill(ptMother);
3598  ((TH1F*)fMotherHistogramArray[motherType][histType][1])->Fill(ptFirstDaughter);
3599  ((TH1F*)fMotherHistogramArray[motherType][histType][2])->Fill(ptSecondDaughter);
3600  ((TH1F*)fMotherHistogramArray[motherType][histType][3])->Fill(etaMother);
3601  ((TH1F*)fMotherHistogramArray[motherType][histType][4])->Fill(phiMother);
3602  ((TH1F*)fMotherHistogramArray[motherType][histType][5])->Fill(d0Mother);
3603  ((TH1F*)fMotherHistogramArray[motherType][histType][6])->Fill(d0firstTrack);
3604  ((TH1F*)fMotherHistogramArray[motherType][histType][7])->Fill(d0secondTrack);
3605  ((TH1F*)fMotherHistogramArray[motherType][histType][8])->Fill(pointingAngle);
3606  ((TH1F*)fMotherHistogramArray[motherType][histType][9])->Fill(impactProduct);
3607  ((TH1F*)fMotherHistogramArray[motherType][histType][10])->Fill(impactProductXY);
3608  ((TH1F*)fMotherHistogramArray[motherType][histType][11])->Fill(invariantMassMother);
3609  ((TH1F*)fMotherHistogramArray[motherType][histType][12])->Fill(invmassDelta);
3610  ((TH1F*)fMotherHistogramArray[motherType][histType][13])->Fill(dcaMother);
3611  ((TH1F*)fMotherHistogramArray[motherType][histType][14])->Fill(vertexDistance);
3612  ((TH1F*)fMotherHistogramArray[motherType][histType][15])->Fill(normDecayLength);
3613  ((TH1F*)fMotherHistogramArray[motherType][histType][16])->Fill(pseudoProperDecayTime);
3614  ((TH1F*)fMotherHistogramArray[motherType][histType][17])->Fill(decayTime);
3615  ((TH1F*)fMotherHistogramArray[motherType][histType][18])->Fill(normalizedDecayTime);
3616  ((TH1F*)fMotherHistogramArray[motherType][histType][19])->Fill(angleMotherFirstDaughter);
3617  ((TH1F*)fMotherHistogramArray[motherType][histType][20])->Fill(angleMotherSecondDaughter);
3618  ((TH1F*)fMotherHistogramArray[motherType][histType][21])->Fill(angleBetweenBothDaughters);
3619  ((TH1F*)fMotherHistogramArray[motherType][histType][22])->Fill(cosThetaStar);
3620 
3621  ((TH1F*)fMotherHistogramArray[motherType][histType][23])->Fill(vertexMotherX);
3622  ((TH1F*)fMotherHistogramArray[motherType][histType][24])->Fill(vertexMotherY);
3623  ((TH1F*)fMotherHistogramArray[motherType][histType][25])->Fill(vertexMotherZ);
3624 
3625  ((TH1F*)fMotherHistogramArray[motherType][histType][36])->Fill(TMath::Abs(dd0pr1));
3626  ((TH1F*)fMotherHistogramArray[motherType][histType][37])->Fill(TMath::Abs(dd0pr2));
3627  ((TH1F*)fMotherHistogramArray[motherType][histType][38])->Fill(TMath::Abs(dd0max));
3628  ((TH1F*)fMotherHistogramArray[motherType][histType][39])->Fill(TMath::Abs(dd0min));
3629 
3630  ((TH1F*)fMotherHistogramArray[motherType][histType][40])->Fill(cosPointingAngleXY);
3631  ((TH1F*)fMotherHistogramArray[motherType][histType][41])->Fill(distanceXYToVertex);
3632  ((TH1F*)fMotherHistogramArray[motherType][histType][42])->Fill(normalizedDecayLengthXY);
3633  ((TH1F*)fMotherHistogramArray[motherType][histType][43])->Fill(vertexMother->GetChi2());
3634  ((TH1F*)fMotherHistogramArray[motherType][histType][44])->Fill(vertexMother->GetChi2perNDF());
3635 
3636  ((TH1F*)fMotherHistogramArray[motherType][histType][45])->Fill(TMath::Abs(selectedMother->Getd0Prong(0)/selectedMother->Getd0errProng(0)));
3637  ((TH1F*)fMotherHistogramArray[motherType][histType][46])->Fill(TMath::Abs(selectedMother->Getd0Prong(1)/selectedMother->Getd0errProng(1)));
3638  ((TH1F*)fMotherHistogramArray[motherType][histType][47])->Fill(TMath::Abs(d0[0]/covd0z0[0]));
3639  ((TH1F*)fMotherHistogramArray[motherType][histType][48])->Fill((selectedMother->Getd0Prong(0)/selectedMother->Getd0errProng(0)) * (selectedMother->Getd0Prong(1)/selectedMother->Getd0errProng(1)));
3640 
3641  //we fill the 2D histograms
3642  Int_t nFirst = 0;
3643  Int_t nSecond = 1;
3644  Int_t nVariables = 10;
3645  Int_t nHistograms = nVariables * (nVariables - 1) / 2;
3646  for (Int_t k = 0; k < nHistograms; ++k)
3647  {
3648  Double_t firstVariable = 0.0;
3649  Double_t secondVariable = 0.0;
3650 
3651  if (nFirst == 0) firstVariable = d0firstTrack;
3652  if (nFirst == 1) firstVariable = d0secondTrack;
3653  if (nFirst == 2) firstVariable = d0Mother;
3654  if (nFirst == 3) firstVariable = pointingAngle;
3655  if (nFirst == 4) firstVariable = impactProduct;
3656  if (nFirst == 5) firstVariable = impactProductXY;
3657  if (nFirst == 6) firstVariable = vertexDistance;
3658  if (nFirst == 7) firstVariable = normDecayLength;
3659  if (nFirst == 8) firstVariable = cosPointingAngleXY;
3660  if (nFirst == 9) firstVariable = distanceXYToVertex;
3661  if (nFirst == 10) firstVariable = normalizedDecayLengthXY;
3662 
3663  if (nSecond == 0) secondVariable = d0firstTrack;
3664  if (nSecond == 1) secondVariable = d0secondTrack;
3665  if (nSecond == 2) secondVariable = d0Mother;
3666  if (nSecond == 3) secondVariable = pointingAngle;
3667  if (nSecond == 4) secondVariable = impactProduct;
3668  if (nSecond == 5) secondVariable = impactProductXY;
3669  if (nSecond == 6) secondVariable = vertexDistance;
3670  if (nSecond == 7) secondVariable = normDecayLength;
3671  if (nSecond == 8) secondVariable = cosPointingAngleXY;
3672  if (nSecond == 9) secondVariable = distanceXYToVertex;
3673  if (nSecond == 10) secondVariable = normalizedDecayLengthXY;
3674 
3675  ((TH2F*)fMotherHistogramArray2D[motherType][histType][k])->Fill(firstVariable, secondVariable);
3676 
3677  nSecond++;
3678  if (nSecond > nVariables)
3679  {
3680  nFirst++;
3681  nSecond = nFirst + 1;
3682  }
3683  }
3684 
3685  return;
3686 }
3687 //-------------------------------------------------------------------------------------
3688 void AliAnalysisTaskSEBPlustoD0Pi::FillBPlusHistograms(AliAODRecoDecayHF2Prong * selectedMother, AliAODVertex *primaryVertex, Double_t bz, Int_t motherType, Int_t histType) {
3689 
3690  //In this function we fill the histograms of the reconstructed mothers
3691  Double_t ptMother = 0.0;
3692  Double_t momentumMother = 0.0;
3693  Double_t etaMother = 0.0;
3694  Double_t phiMother = 0.0;
3695  Double_t d0Mother = 0.0;
3696  Double_t d0firstTrack = 0.0;
3697  Double_t d0secondTrack = 0.0;
3698  Double_t pointingAngle = 0.0;
3699  Double_t impactProduct = 0.0;
3700  Double_t impactProductXY = 0.0;
3701  Double_t invariantMassMother = 0.0;
3702  Double_t invmassDelta = 0.0;
3703  Double_t dcaMother = 0.0;
3704  AliAODVertex * vertexMother = 0x0;
3705  Double_t vertexDistance = 0.0;
3706  Double_t normDecayLength = 0.0;
3707  Double_t decayTime = 0.0;
3708  Double_t angleMotherFirstDaughter = 0.0;
3709  Double_t angleMotherSecondDaughter = 0.0;
3710  Double_t ptFirstDaughter = 0.0;
3711  Double_t ptSecondDaughter = 0.0;
3712  UInt_t prongs[2];
3713  Double_t cosThetaStar = 0;
3714  Double_t angleBetweenBothDaughters = 0;
3715  // Double_t d0MultiProduct = 0;
3716 
3717  Double_t pdgMassMother = 0;
3718 
3719  AliExternalTrackParam motherTrack;
3720  motherTrack.CopyFromVTrack(selectedMother);
3721  Double_t d0z0[2], covd0z0[3], d0[2];
3722  motherTrack.PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
3723  d0[0] = d0z0[0];
3724 
3725  //BPlus
3726  prongs[1] = 421; prongs[0] = 211;
3727  invmassDelta = DeltaInvMassBPlusKpipi(selectedMother);
3728  AliAODTrack * firstDaughter = (AliAODTrack*)selectedMother->GetDaughter(0);
3729  AliAODRecoDecayHF2Prong * secondDaughter = (AliAODRecoDecayHF2Prong*)selectedMother->GetDaughter(1);
3730 
3731  ptFirstDaughter = firstDaughter->Pt();
3732  ptSecondDaughter = secondDaughter->Pt();
3733  vertexMother = selectedMother->GetSecondaryVtx();
3734  angleMotherFirstDaughter = (selectedMother->Px() * firstDaughter->Px() + selectedMother->Py() * firstDaughter->Py() + selectedMother->Pz() * firstDaughter->Pz()) / (selectedMother->P() * firstDaughter->P());
3735  angleMotherSecondDaughter = (selectedMother->Px() * secondDaughter->Px() + selectedMother->Py() * secondDaughter->Py() + selectedMother->Pz() * secondDaughter->Pz()) / (selectedMother->P() * secondDaughter->P());
3736  angleBetweenBothDaughters = (firstDaughter->Px() * secondDaughter->Px() + firstDaughter->Py() * secondDaughter->Py() + firstDaughter->Pz() * secondDaughter->Pz()) / (firstDaughter->P() * secondDaughter->P());
3737  cosThetaStar = selectedMother->CosThetaStar(0, 521, 421, 211);
3738  pdgMassMother = TDatabasePDG::Instance()->GetParticle(521)->Mass();
3739  // d0MultiProduct = selectedMother->Getd0Prong(0) * secondDaughter->Getd0Prong(0) * secondDaughter->Getd0Prong(1);
3740 
3741  //Topomatic
3742  Double_t dd0pr1 = 0.;
3743  Double_t dd0pr2 = 0.;
3744  Double_t dd0max = 0.;
3745  Double_t dd0min = 0.;
3746  for (Int_t ipr = 0; ipr < 2; ipr++)
3747  {
3748  Double_t diffIP, errdiffIP;
3749  selectedMother->Getd0MeasMinusExpProng(ipr, bz, diffIP, errdiffIP);
3750  Double_t normdd0 = 0.;
3751  if (errdiffIP > 0.) normdd0 = diffIP / errdiffIP;
3752  if (ipr == 0) dd0pr1 = normdd0;
3753  if (ipr == 1) dd0pr2 = normdd0;
3754 
3755  // else if(TMath::Abs(normdd0)>TMath::Abs(dd0max)) dd0max=normdd0;
3756  }
3757  if (TMath::Abs(dd0pr1) > TMath::Abs(dd0pr2)) {dd0max = dd0pr1; dd0min = dd0pr2;}
3758  else {dd0max = dd0pr2; dd0min = dd0pr1;}
3759 
3760 
3761 
3762  ptMother = selectedMother->Pt();
3763  momentumMother = selectedMother->P();
3764  etaMother = selectedMother->Eta();
3765  phiMother = selectedMother->Phi();
3766  d0Mother = TMath::Abs(d0[0]);
3767 
3768  pointingAngle = selectedMother->CosPointingAngle();
3769  impactProduct = selectedMother->Prodd0d0();
3770  impactProductXY = TMath::Abs(selectedMother->ImpParXY());
3771  invariantMassMother = selectedMother->InvMass(2, prongs);
3772  dcaMother = selectedMother->GetDCA();
3773  vertexDistance = vertexMother->DistanceToVertex(primaryVertex);
3774  d0firstTrack = TMath::Abs(selectedMother->Getd0Prong(0));
3775  d0secondTrack = TMath::Abs(selectedMother->Getd0Prong(1));
3776  normDecayLength = selectedMother->NormalizedDecayLength();
3777 
3778  Double_t pseudoProperDecayLength = ((vertexMother->GetX() - primaryVertex->GetX()) * selectedMother->Px() / TMath::Abs(selectedMother->Pt())) + ((vertexMother->GetY() - primaryVertex->GetY()) * selectedMother->Py() / TMath::Abs(selectedMother->Pt()));
3779  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother / ptMother;
3780  decayTime = vertexDistance / (299792458 * TMath::Sqrt(1 / ((pdgMassMother * pdgMassMother / (momentumMother * momentumMother)) + 1)));
3781 
3782  Double_t phi = selectedMother->Phi();
3783  Double_t theta = selectedMother->Theta();
3784  Double_t covMatrix[21];
3785  selectedMother->GetCovarianceXYZPxPyPz(covMatrix);
3786 
3787  Double_t cp = TMath::Cos(phi);
3788  Double_t sp = TMath::Sin(phi);
3789  Double_t ct = TMath::Cos(theta);
3790  Double_t st = TMath::Sin(theta);
3791 
3792  Double_t errorMomentum = covMatrix[9] * cp * cp * ct * ct // GetCovPxPx
3793  + covMatrix[13] * 2.*cp * sp * ct * ct // GetCovPxPy
3794  + covMatrix[18] * 2.*cp * ct * st // GetCovPxPz
3795  + covMatrix[14] * sp * sp * ct * ct // GetCovPyPy
3796  + covMatrix[19] * 2.*sp * ct * st // GetCovPyPz
3797  + covMatrix[20] * st * st; // GetCovPzPz
3798  Double_t normalizedDecayTime = selectedMother->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1 / ((pdgMassMother * pdgMassMother * errorMomentum * errorMomentum / (momentumMother * momentumMother)) + 1)));
3799 
3800  Double_t vertexMotherX = vertexMother->GetX();
3801  Double_t vertexMotherY = vertexMother->GetY();
3802  Double_t vertexMotherZ = vertexMother->GetZ();
3803 
3804  Double_t cosPointingAngleXY = selectedMother->CosPointingAngleXY();
3805  Double_t distanceXYToVertex = vertexMother->DistanceXYToVertex(primaryVertex);
3806  Double_t normalizedDecayLengthXY = selectedMother->NormalizedDecayLengthXY();
3807 
3808  ((TH1F*)fMotherHistogramArray[motherType][histType][0])->Fill(ptMother);
3809  ((TH1F*)fMotherHistogramArray[motherType][histType][1])->Fill(ptFirstDaughter);
3810  ((TH1F*)fMotherHistogramArray[motherType][histType][2])->Fill(ptSecondDaughter);
3811  ((TH1F*)fMotherHistogramArray[motherType][histType][3])->Fill(etaMother);
3812  ((TH1F*)fMotherHistogramArray[motherType][histType][4])->Fill(phiMother);
3813  ((TH1F*)fMotherHistogramArray[motherType][histType][5])->Fill(d0Mother);
3814  ((TH1F*)fMotherHistogramArray[motherType][histType][6])->Fill(d0firstTrack);
3815  ((TH1F*)fMotherHistogramArray[motherType][histType][7])->Fill(d0secondTrack);
3816  ((TH1F*)fMotherHistogramArray[motherType][histType][8])->Fill(pointingAngle);
3817  ((TH1F*)fMotherHistogramArray[motherType][histType][9])->Fill(impactProduct);
3818  ((TH1F*)fMotherHistogramArray[motherType][histType][10])->Fill(impactProductXY);
3819  ((TH1F*)fMotherHistogramArray[motherType][histType][11])->Fill(invariantMassMother);
3820  ((TH1F*)fMotherHistogramArray[motherType][histType][12])->Fill(invmassDelta);
3821  ((TH1F*)fMotherHistogramArray[motherType][histType][13])->Fill(dcaMother);
3822  ((TH1F*)fMotherHistogramArray[motherType][histType][14])->Fill(vertexDistance);
3823  ((TH1F*)fMotherHistogramArray[motherType][histType][15])->Fill(normDecayLength);
3824  ((TH1F*)fMotherHistogramArray[motherType][histType][16])->Fill(pseudoProperDecayTime);
3825  ((TH1F*)fMotherHistogramArray[motherType][histType][17])->Fill(decayTime);
3826  ((TH1F*)fMotherHistogramArray[motherType][histType][18])->Fill(normalizedDecayTime);
3827  ((TH1F*)fMotherHistogramArray[motherType][histType][19])->Fill(angleMotherFirstDaughter);
3828  ((TH1F*)fMotherHistogramArray[motherType][histType][20])->Fill(angleMotherSecondDaughter);
3829  ((TH1F*)fMotherHistogramArray[motherType][histType][21])->Fill(angleBetweenBothDaughters);
3830  ((TH1F*)fMotherHistogramArray[motherType][histType][22])->Fill(cosThetaStar);
3831 
3832  ((TH1F*)fMotherHistogramArray[motherType][histType][23])->Fill(vertexMotherX);
3833  ((TH1F*)fMotherHistogramArray[motherType][histType][24])->Fill(vertexMotherY);
3834  ((TH1F*)fMotherHistogramArray[motherType][histType][25])->Fill(vertexMotherZ);
3835 
3836  ((TH1F*)fMotherHistogramArray[motherType][histType][36])->Fill(TMath::Abs(dd0pr1));
3837  ((TH1F*)fMotherHistogramArray[motherType][histType][37])->Fill(TMath::Abs(dd0pr2));
3838  ((TH1F*)fMotherHistogramArray[motherType][histType][38])->Fill(TMath::Abs(dd0max));
3839  ((TH1F*)fMotherHistogramArray[motherType][histType][39])->Fill(TMath::Abs(dd0min));
3840 
3841  ((TH1F*)fMotherHistogramArray[motherType][histType][40])->Fill(cosPointingAngleXY);
3842  ((TH1F*)fMotherHistogramArray[motherType][histType][41])->Fill(distanceXYToVertex);
3843  ((TH1F*)fMotherHistogramArray[motherType][histType][42])->Fill(normalizedDecayLengthXY);
3844  ((TH1F*)fMotherHistogramArray[motherType][histType][43])->Fill(vertexMother->GetChi2());
3845  ((TH1F*)fMotherHistogramArray[motherType][histType][44])->Fill(vertexMother->GetChi2perNDF());
3846 
3847  ((TH1F*)fMotherHistogramArray[motherType][histType][45])->Fill(TMath::Abs(selectedMother->Getd0Prong(0)/selectedMother->Getd0errProng(0)));
3848  ((TH1F*)fMotherHistogramArray[motherType][histType][46])->Fill(TMath::Abs(selectedMother->Getd0Prong(1)/selectedMother->Getd0errProng(1)));
3849  ((TH1F*)fMotherHistogramArray[motherType][histType][47])->Fill(TMath::Abs(d0[0]/covd0z0[0]));
3850  ((TH1F*)fMotherHistogramArray[motherType][histType][48])->Fill((selectedMother->Getd0Prong(0)/selectedMother->Getd0errProng(0)) * (selectedMother->Getd0Prong(1)/selectedMother->Getd0errProng(1)));
3851 
3852 
3853  //we fill the 2D histograms
3854  Int_t nFirst = 0;
3855  Int_t nSecond = 1;
3856  Int_t nVariables = 10;
3857  Int_t nHistograms = nVariables * (nVariables - 1) / 2;
3858  for (Int_t k = 0; k < nHistograms; ++k)
3859  {
3860  Double_t firstVariable = 0.0;
3861  Double_t secondVariable = 0.0;
3862 
3863  if (nFirst == 0) firstVariable = d0firstTrack;
3864  if (nFirst == 1) firstVariable = d0secondTrack;
3865  if (nFirst == 2) firstVariable = d0Mother;
3866  if (nFirst == 3) firstVariable = pointingAngle;
3867  if (nFirst == 4) firstVariable = impactProduct;
3868  if (nFirst == 5) firstVariable = impactProductXY;
3869  if (nFirst == 6) firstVariable = vertexDistance;
3870  if (nFirst == 7) firstVariable = normDecayLength;
3871  if (nFirst == 8) firstVariable = cosPointingAngleXY;
3872  if (nFirst == 9) firstVariable = distanceXYToVertex;
3873  if (nFirst == 10) firstVariable = normalizedDecayLengthXY;
3874 
3875  if (nSecond == 0) secondVariable = d0firstTrack;
3876  if (nSecond == 1) secondVariable = d0secondTrack;
3877  if (nSecond == 2) secondVariable = d0Mother;
3878  if (nSecond == 3) secondVariable = pointingAngle;
3879  if (nSecond == 4) secondVariable = impactProduct;
3880  if (nSecond == 5) secondVariable = impactProductXY;
3881  if (nSecond == 6) secondVariable = vertexDistance;
3882  if (nSecond == 7) secondVariable = normDecayLength;
3883  if (nSecond == 8) secondVariable = cosPointingAngleXY;
3884  if (nSecond == 9) secondVariable = distanceXYToVertex;
3885  if (nSecond == 10) secondVariable = normalizedDecayLengthXY;
3886 
3887  ((TH2F*)fMotherHistogramArray2D[motherType][histType][k])->Fill(firstVariable, secondVariable);
3888 
3889  nSecond++;
3890  if (nSecond > nVariables)
3891  {
3892  nFirst++;
3893  nSecond = nFirst + 1;
3894  }
3895  }
3896 
3897 
3898  if (motherType == 1) {
3899  motherType = motherType - 1;
3900 
3901  AliAODRecoDecay* trackD0 = (AliAODRecoDecay*)selectedMother->GetDaughter(1);
3902  AliAODTrack * firstDaughterD0 = (AliAODTrack*)trackD0->GetDaughter(0);
3903  AliAODTrack * secondDaughterD0 = (AliAODTrack*)trackD0->GetDaughter(1);
3904 
3905  AliAODVertex * vertexBPlus = vertexMother;
3906  AliAODVertex * vertexD0 = trackD0->GetSecondaryVtx();
3907  vertexDistance = TMath::Abs(vertexBPlus->DistanceToVertex(vertexD0));
3908  pdgMassMother = TDatabasePDG::Instance()->GetParticle(421)->Mass();
3909 
3910  AliExternalTrackParam firstDaughterD0Track;
3911  AliExternalTrackParam secondDaughterD0Track;
3912 
3913  Double_t d0z0[2], covd0z0[3], d0[2];
3914 
3915  firstDaughterD0Track.CopyFromVTrack(firstDaughterD0);
3916  firstDaughterD0Track.PropagateToDCA(vertexBPlus, bz, 100., d0z0, covd0z0);
3917  d0[0] = d0z0[0];
3918 
3919  secondDaughterD0Track.CopyFromVTrack(secondDaughterD0);
3920  secondDaughterD0Track.PropagateToDCA(vertexBPlus, bz, 100., d0z0, covd0z0);
3921  d0[1] = d0z0[0];
3922 
3923  AliExternalTrackParam D0Track;
3924  D0Track.CopyFromVTrack(trackD0);
3925  Double_t d0z0D0[2], covd0z0D0[3], d0D0;
3926  D0Track.PropagateToDCA(vertexBPlus, bz, 100., d0z0D0, covd0z0D0);
3927  d0D0 = d0z0D0[0];
3928 
3929  Double_t impactProductToBPlus = d0[0] * d0[1];
3930  Double_t impactProductXYToBPlus = trackD0->ImpParXY(vertexBPlus);
3931 
3932  Double_t momentumMother = trackD0->P();
3933  Double_t pointingAngleToBPlus = trackD0->CosPointingAngle(vertexBPlus);
3934  Double_t d0FirstDaughterToBPlus = TMath::Abs(d0[0]);
3935  Double_t d0trackD0ToBPlus = TMath::Abs(d0[1]);
3936  Double_t normDecayLengthToBPlus = trackD0->NormalizedDecayLength(vertexBPlus);
3937 
3938  Double_t pseudoProperDecayLength = ((vertexD0->GetX() - vertexBPlus->GetX()) * trackD0->Px() / TMath::Abs(trackD0->Pt())) + ((vertexD0->GetY() - vertexBPlus->GetY()) * trackD0->Py() / TMath::Abs(trackD0->Pt()));
3939  Double_t pseudoProperDecayTimeToBPlus = pseudoProperDecayLength * pdgMassMother / ptMother;
3940  Double_t DecayTimeToBPlus = vertexDistance / (299792458 * TMath::Sqrt(1 / ((pdgMassMother * pdgMassMother / (momentumMother * momentumMother)) + 1)));
3941 
3942  Double_t phi = trackD0->Phi();
3943  Double_t theta = trackD0->Theta();
3944  Double_t covMatrix[21];
3945  trackD0->GetCovarianceXYZPxPyPz(covMatrix);
3946 
3947  Double_t cp = TMath::Cos(phi);
3948  Double_t sp = TMath::Sin(phi);
3949  Double_t ct = TMath::Cos(theta);
3950  Double_t st = TMath::Sin(theta);
3951 
3952  Double_t errorMomentum = covMatrix[9] * cp * cp * ct * ct // GetCovPxPx
3953  + covMatrix[13] * 2.*cp * sp * ct * ct // GetCovPxPy
3954  + covMatrix[18] * 2.*cp * ct * st // GetCovPxPz
3955  + covMatrix[14] * sp * sp * ct * ct // GetCovPyPy
3956  + covMatrix[19] * 2.*sp * ct * st // GetCovPyPz
3957  + covMatrix[20] * st * st; // GetCovPzPz
3958  Double_t normDecayTimeToBPlus = trackD0->NormalizedDecayLength(vertexBPlus) / (299792458 * TMath::Sqrt(1 / ((pdgMassMother * pdgMassMother * errorMomentum * errorMomentum / (momentumMother * momentumMother)) + 1)));
3959 
3960  ((TH1F*)fMotherHistogramArray[motherType][histType][26])->Fill(pointingAngleToBPlus);
3961  ((TH1F*)fMotherHistogramArray[motherType][histType][27])->Fill(d0D0);
3962  ((TH1F*)fMotherHistogramArray[motherType][histType][28])->Fill(d0FirstDaughterToBPlus);
3963  ((TH1F*)fMotherHistogramArray[motherType][histType][29])->Fill(d0trackD0ToBPlus);
3964  ((TH1F*)fMotherHistogramArray[motherType][histType][30])->Fill(impactProductToBPlus);
3965  ((TH1F*)fMotherHistogramArray[motherType][histType][31])->Fill(impactProductXYToBPlus);
3966  ((TH1F*)fMotherHistogramArray[motherType][histType][32])->Fill(normDecayLengthToBPlus);
3967  ((TH1F*)fMotherHistogramArray[motherType][histType][33])->Fill(pseudoProperDecayTimeToBPlus);
3968  ((TH1F*)fMotherHistogramArray[motherType][histType][34])->Fill(DecayTimeToBPlus);
3969  ((TH1F*)fMotherHistogramArray[motherType][histType][35])->Fill(normDecayTimeToBPlus);
3970 
3971 
3972 
3973  }
3974  return;
3975 }
3976 //-------------------------------------------------------------------------------------
3977 void AliAnalysisTaskSEBPlustoD0Pi::TwoTrackCombinationInfo(AliExternalTrackParam * firstTrack, AliExternalTrackParam * secondTrack, AliAODVertex * primaryVertex, Double_t bz, Bool_t isDesiredCandidate, Int_t histogramNumber, UInt_t prongs[2]) {
3978 
3979  // we calculate the vertex position
3980  TObjArray daughterTracks;
3981 
3982  daughterTracks.Add(firstTrack);
3983  daughterTracks.Add(secondTrack);
3984 
3985  Double_t dispersion = 0;
3986  AliAODVertex *vertex = RecalculateVertex(primaryVertex, &daughterTracks, bz, dispersion, kTRUE, kTRUE, kFALSE);
3987  if (!vertex) {delete vertex; vertex = NULL; return;}
3988 
3989  Double_t xdummy = 0., ydummy = 0., dca;
3990  Double_t d0z0[2], covd0z0[3], d0[2], d0err[2];
3991 
3992  firstTrack->PropagateToDCA(vertex, bz, 100., d0z0, covd0z0);
3993  secondTrack->PropagateToDCA(vertex, bz, 100., d0z0, covd0z0);
3994  dca = secondTrack->GetDCA(firstTrack, bz, xdummy, ydummy);
3995 
3996  Double_t px[2], py[2], pz[2];
3997  px[0] = firstTrack->Px();
3998  py[0] = firstTrack->Py();
3999  pz[0] = firstTrack->Pz();
4000  px[1] = secondTrack->Px();
4001  py[1] = secondTrack->Py();
4002  pz[1] = secondTrack->Pz();
4003 
4004  firstTrack->PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
4005  d0[0] = d0z0[0];
4006  d0err[0] = TMath::Sqrt(covd0z0[0]);
4007  secondTrack->PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
4008  d0[1] = d0z0[0];
4009  d0err[1] = TMath::Sqrt(covd0z0[0]);
4010 
4011  AliAODRecoDecayHF2Prong * track = new AliAODRecoDecayHF2Prong(vertex, px, py, pz, d0, d0err, dca);
4012  if (!track)
4013  {
4014  delete vertex; vertex = NULL;
4015  delete track; track = NULL;
4016  return;
4017  }
4018 
4019  Double_t invariantMass = track->InvMass(2, prongs);
4020 
4021  if (!isDesiredCandidate) ((TH1F*)(fResultsHistogramArray[12][histogramNumber]))->Fill(invariantMass);
4022  if (isDesiredCandidate) ((TH1F*)(fResultsHistogramArray[12][histogramNumber + 1]))->Fill(invariantMass);
4023 
4024  delete vertex; vertex = NULL;
4025  delete track; track = NULL;
4026  return;
4027 }
4028 //-------------------------------------------------------------------------------------
4029 void AliAnalysisTaskSEBPlustoD0Pi::ThreeTrackCombinationInfo(AliExternalTrackParam * firstTrack, AliExternalTrackParam * secondTrack, AliExternalTrackParam * thirdTrack, AliAODVertex * primaryVertex, Double_t bz, Bool_t isDesiredCandidate, Int_t histogramNumber, UInt_t prongs[3]) {
4030 
4031  // we calculate the vertex position
4032  TObjArray daughterTracks;
4033 
4034  daughterTracks.Add(firstTrack);
4035  daughterTracks.Add(secondTrack);
4036  daughterTracks.Add(thirdTrack);
4037 
4038  Double_t dispersion = 0;
4039  AliAODVertex *vertex = RecalculateVertex(primaryVertex, &daughterTracks, bz, dispersion, kTRUE, kTRUE, kFALSE);
4040  if (!vertex) {delete vertex; vertex = NULL; return;}
4041 
4042  Double_t xdummy = 0., ydummy = 0., dca[3];
4043  Double_t d0z0[2], covd0z0[3], d0[3], d0err[3];
4044 
4045  firstTrack->PropagateToDCA(vertex, bz, 100., d0z0, covd0z0);
4046  secondTrack->PropagateToDCA(vertex, bz, 100., d0z0, covd0z0);
4047  thirdTrack->PropagateToDCA(vertex, bz, 100., d0z0, covd0z0);
4048 
4049  dca[0] = firstTrack->GetDCA(secondTrack, bz, xdummy, ydummy);
4050  dca[1] = firstTrack->GetDCA(thirdTrack, bz, xdummy, ydummy);
4051  dca[2] = secondTrack->GetDCA(thirdTrack, bz, xdummy, ydummy);
4052 
4053  Double_t px[3], py[3], pz[3];
4054  px[0] = firstTrack->Px();
4055  py[0] = firstTrack->Py();
4056  pz[0] = firstTrack->Pz();
4057  px[1] = secondTrack->Px();
4058  py[1] = secondTrack->Py();
4059  pz[1] = secondTrack->Pz();
4060  px[2] = thirdTrack->Px();
4061  py[2] = thirdTrack->Py();
4062  pz[2] = thirdTrack->Pz();
4063 
4064  firstTrack->PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
4065  d0[0] = d0z0[0];
4066  d0err[0] = TMath::Sqrt(covd0z0[0]);
4067  secondTrack->PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
4068  d0[1] = d0z0[0];
4069  d0err[1] = TMath::Sqrt(covd0z0[0]);
4070  thirdTrack->PropagateToDCA(primaryVertex, bz, 100., d0z0, covd0z0);
4071  d0[2] = d0z0[0];
4072  d0err[2] = TMath::Sqrt(covd0z0[0]);
4073 
4074  // Double_t pos[3]; primaryVertex->GetXYZ(pos);
4075  // Double_t dist12=TMath::Sqrt((vertex12->GetX()-pos[0])*(vertex12->GetX()-pos[0])+(vertex12->GetY()-pos[1])*(vertex12->GetY()-pos[1])+(vertex12->GetZ()-pos[2])*(vertex12->GetZ()-pos[2]));
4076  // Double_t dist23=TMath::Sqrt((vertex23->GetX()-pos[0])*(vertex23->GetX()-pos[0])+(vertex23->GetY()-pos[1])*(vertex23->GetY()-pos[1])+(vertex23->GetZ()-pos[2])*(vertex23->GetZ()-pos[2]));
4077  Short_t charge = (Short_t)(firstTrack->Charge() + secondTrack->Charge() + thirdTrack->Charge());
4078 
4079  AliAODRecoDecayHF3Prong * track = new AliAODRecoDecayHF3Prong(vertex, px, py, pz, d0, d0err, dca, dispersion, 0.0, 0.0, charge); //dist12,dist23,charge);
4080  if (!track)
4081  {
4082  delete vertex; vertex = NULL;
4083  delete track; track = NULL;
4084  return;
4085  }
4086 
4087  Double_t invariantMass = track->InvMass(3, prongs);
4088 
4089  if (!isDesiredCandidate) ((TH1F*)(fResultsHistogramArray[12][histogramNumber]))->Fill(invariantMass);
4090  if (isDesiredCandidate) ((TH1F*)(fResultsHistogramArray[12][histogramNumber + 1]))->Fill(invariantMass);
4091 
4092  delete vertex; vertex = NULL;
4093  delete track; track = NULL;
4094  return;
4095 }
4096 //-------------------------------------------------------------------------------------
4097 Int_t AliAnalysisTaskSEBPlustoD0Pi::MatchCandidateToMonteCarlo(Int_t pdgabs, AliAODRecoDecayHF2Prong * candidate, TClonesArray *mcArray, TMatrix * BPlustoD0PiLabelMatrix, Bool_t bCheckLabel) const
4098 {
4099  //
4100  // Check if this candidate is matched to a MC signal
4101  // If no, return -1
4102  // If yes, return label (>=0) of the AliAODMCParticle
4103 
4104 
4105  // Check number of daughters
4106  Int_t ndg = candidate->GetNDaughters();
4107  if (!ndg) { AliError("No daughters available"); return -1;}
4108  if (ndg != 2) return -1;
4109 
4110  // loop on daughters and write the labels
4111  Int_t dgLabels[2] = { -1};
4112  Int_t pdgDg[2] = {0};
4113  Int_t signalPosition = -1;
4114  if (pdgabs == 421)
4115  {
4116  AliAODTrack *trk0 = (AliAODTrack*)candidate->GetDaughter(0);
4117  dgLabels[0] = trk0->GetLabel();
4118  AliAODTrack *trk1 = (AliAODTrack*)candidate->GetDaughter(1);
4119  dgLabels[1] = trk1->GetLabel();
4120  pdgDg[0] = 211; pdgDg[1] = 321;
4121  signalPosition = 3;
4122  }
4123  else if (pdgabs == 521)
4124  {
4125  AliAODTrack *trk0 = (AliAODTrack*)candidate->GetDaughter(0);
4126  dgLabels[0] = trk0->GetLabel();
4127  dgLabels[1] = MatchCandidateToMonteCarlo(421, (AliAODRecoDecayHF2Prong*)candidate->GetDaughter(1), mcArray, BPlustoD0PiLabelMatrix);
4128  pdgDg[0] = 211; pdgDg[1] = 421;
4129  signalPosition = 4;
4130  }
4131  else
4132  {
4133  std::cout << "Wrong pdg supplied for function to match candidate to monte carlo signal." << std::endl;
4134  return -1;
4135  }
4136  if (dgLabels[0] == -1) return -1;
4137  if (dgLabels[1] == -1) return -1;
4138 
4139 
4140  Int_t labMom[2] = {0, 0};
4141  Int_t i, j, lab, labMother, pdgMother, pdgPart;
4142  AliAODMCParticle *part = 0;
4143  AliAODMCParticle *mother = 0;
4144  Double_t pxSumDgs = 0., pySumDgs = 0., pzSumDgs = 0.;
4145  Bool_t pdgUsed[2] = {kFALSE, kFALSE};
4146 
4147  // loop on daughter labels
4148  for (i = 0; i < ndg; i++)
4149  {
4150  labMom[i] = -1;
4151  lab = TMath::Abs(dgLabels[i]);
4152  if (lab < 0)
4153  {
4154  printf("daughter with negative label %d\n", lab);
4155  return -1;
4156  }
4157  part = (AliAODMCParticle*)mcArray->At(lab);
4158  if (!part)
4159  {
4160  printf("no MC particle\n");
4161  return -1;
4162  }
4163 
4164  // check the PDG of the daughter
4165  pdgPart = TMath::Abs(part->GetPdgCode());
4166  for (j = 0; j < ndg; j++)
4167  {
4168  if (!pdgUsed[j] && pdgPart == pdgDg[j])
4169  {
4170  pdgUsed[j] = kTRUE;
4171  break;
4172  }
4173  }
4174 
4175 
4176  mother = part;
4177  while (mother->GetMother() >= 0)
4178  {
4179  labMother = mother->GetMother();
4180  mother = (AliAODMCParticle*)mcArray->At(labMother);
4181  if (!mother)
4182  {
4183  printf("no MC mother particle\n");
4184  break;
4185  }
4186  pdgMother = TMath::Abs(mother->GetPdgCode());
4187  if (pdgMother == pdgabs)
4188  {
4189  labMom[i] = labMother;
4190  // keep sum of daughters' momenta, to check for mom conservation
4191  pxSumDgs += part->Px();
4192  pySumDgs += part->Py();
4193  pzSumDgs += part->Pz();
4194  break;
4195  }
4196  else break;
4197  }
4198  if (labMom[i] == -1) return -1; // mother PDG not ok for this daughter
4199  } // end loop on daughters
4200 
4201  // check if the candidate is signal
4202  labMother = labMom[0];
4203  // all labels have to be the same and !=-1
4204  for (i = 0; i < ndg; i++)
4205  {
4206  if (labMom[i] == -1) return -1;
4207  if (labMom[i] != labMother) return -1;
4208  }
4209 
4210  // check that all daughter PDGs are matched
4211  for (i = 0; i < ndg; i++)
4212  {
4213  if (pdgUsed[i] == kFALSE) return -1;
4214  }
4215 
4216  // Check for mom conservation
4217  mother = (AliAODMCParticle*)mcArray->At(labMother);
4218  Double_t pxMother = mother->Px();
4219  Double_t pyMother = mother->Py();
4220  Double_t pzMother = mother->Pz();
4221 
4222 
4223  // check the number of daughters (we are not looking at resonant decay)
4224  if(mother->GetNDaughters() != 2) return -1;
4225 
4226  // if momentum conservation is not within 0.5%, show warning. This can be due to large propagation distance through magnetic field.
4227  if ((TMath::Abs(pxMother - pxSumDgs) / (TMath::Abs(pxMother) + 1.e-13)) > 0.005 ||
4228  (TMath::Abs(pyMother - pySumDgs) / (TMath::Abs(pyMother) + 1.e-13)) > 0.005 ||
4229  (TMath::Abs(pzMother - pzSumDgs) / (TMath::Abs(pzMother) + 1.e-13)) > 0.005)
4230  {
4231  std::cout << std::endl << " Momentum difference for decay pdgabs = " << pdgabs << "daughters = " << mother->GetNDaughters() << std::endl;
4232  std::cout << "pxMother = " << pxMother << "pyMother = " << pyMother << "pzMother = " << pzMother << std::endl;
4233  std::cout << "pxSumDgs = " << pxSumDgs << "pySumDgs = " << pySumDgs << "pzSumDgs = " << pzSumDgs << std::endl;
4234  }
4235 
4236  // Check if label matches a signal label
4237  if(bCheckLabel)
4238  {
4239  Int_t bIsSignal = kFALSE;
4240  TMatrix &particleMatrix = *BPlustoD0PiLabelMatrix;
4241  for (Int_t k = 0; k < BPlustoD0PiLabelMatrix->GetNrows(); ++k)
4242  {
4243  if(labMother == (Int_t)particleMatrix(k,signalPosition))
4244  {
4245  bIsSignal = kTRUE;
4246  break;
4247  }
4248  }
4249  if(!bIsSignal) return -1;
4250  }
4251 
4252 
4253  return labMother;
4254 }
4255 //-------------------------------------------------------------------------------------
4256 Int_t AliAnalysisTaskSEBPlustoD0Pi::IsTrackInjected(AliAODTrack *part, AliAODMCHeader *header, TClonesArray *arrayMC) {
4257 
4259 
4260  Int_t lab = part->GetLabel();
4261  if (lab < 0) {delete ggg; ggg = nullptr; return 1;} //
4262  TString nameGen = ggg->GetGenerator(lab, header);
4263  TString empty = "";
4264  Int_t countControl = 0;
4265  while (nameGen.IsWhitespace()) {
4266  AliAODMCParticle *mcpart = (AliAODMCParticle*)arrayMC->At(lab);
4267  if (!mcpart) {
4268  printf("AliVertexingHFUtils::IsTrackInjected - BREAK: No valid AliAODMCParticle at label %i\n", lab);
4269  break;
4270  }
4271  Int_t mother = mcpart->GetMother();
4272  if (mother < 0) {
4273  // printf("AliVertexingHFUtils::IsTrackInjected - BREAK: Reached primary particle without valid mother\n");
4274  break;
4275  }
4276  lab = mother;
4277  nameGen = ggg->GetGenerator(mother, header);
4278  countControl++;
4279  if (countControl >= 10) { // 10 = arbitrary number; protection from infinite loops
4280  printf("AliVertexingHFUtils::IsTrackInjected - BREAK: Protection from infinite loop active\n");
4281  break;
4282  }
4283  }
4284  if (nameGen.IsWhitespace() || nameGen.Contains("ijing")) {delete ggg; ggg = nullptr; return 0;}
4285 
4286  delete ggg; ggg = nullptr;
4287  return 1;
4288 }
4289 //-------------------------------------------------------------------------------------
4290 Bool_t AliAnalysisTaskSEBPlustoD0Pi::IsCandidateInjected(AliAODRecoDecayHF2Prong *selectedBPlus, AliAODMCHeader *header, TClonesArray *arrayMC) {
4291 
4292  AliAODTrack* selectedBPlusPion = (AliAODTrack*)selectedBPlus->GetDaughter(0);
4293  AliAODRecoDecayHF2Prong* selectedD0 = (AliAODRecoDecayHF2Prong*)selectedBPlus->GetDaughter(1);
4294 
4295  AliAODTrack* selectedD0FirstDaughter = (AliAODTrack*)selectedD0->GetDaughter(0);
4296  AliAODTrack* selectedD0SecondDaughter = (AliAODTrack*)selectedD0->GetDaughter(1);
4297 
4298  if (IsTrackInjected(selectedBPlusPion, header, arrayMC)) return kTRUE;
4299  if (IsTrackInjected(selectedD0FirstDaughter, header, arrayMC)) return kTRUE;
4300  if (IsTrackInjected(selectedD0SecondDaughter, header, arrayMC)) return kTRUE;
4301 
4302  return kFALSE;
4303 }
4304 //-------------------------------------------------------------------------------------
4305 void AliAnalysisTaskSEBPlustoD0Pi::CutOptimizationLoop(Int_t variable, Int_t nVariables, Int_t nCuts, Int_t ptBin, Int_t fillNumber, Bool_t isDesiredCandidate, Int_t nSigmaBin) {
4306 
4307  for (Int_t iCut = 0; iCut < nCuts; ++iCut)
4308  {
4309  Int_t cutVariable = fCuts->GetCutIndexForCutOptimization(variable);
4310  Bool_t isUpperCut = fCuts->GetIsUpperCutForCutOptimization(variable);
4311  Float_t cutValue = fCuts->GetCutForCutOptimization(iCut, variable, ptBin);
4312  if(fCutVariableValueArray[cutVariable] > cutValue && isUpperCut == kTRUE) continue;
4313  if(fCutVariableValueArray[cutVariable] < cutValue && isUpperCut == kFALSE) continue;
4314 
4315  Int_t fill = iCut * TMath::Power(nCuts,variable) + fillNumber;
4316  if( (variable + 1) == nVariables)
4317  {
4318  if(isDesiredCandidate) ((TH2F*)(fResultsHistogramArray2D[0][ptBin]))->Fill(fill,nSigmaBin);
4319  if(!isDesiredCandidate) ((TH2F*)(fResultsHistogramArray2D[1][ptBin]))->Fill(fill,nSigmaBin);
4320  }
4321  else{CutOptimizationLoop(variable + 1, nVariables, nCuts, ptBin, fill, isDesiredCandidate, nSigmaBin);}
4322  }
4323  return;
4324 }
4325 //-------------------------------------------------------------------------------------
4327 
4328  if(!candidateBPlus){
4329  std::cout<<"candidateBPlus null"<<std::endl;
4330  return;
4331  }
4332 
4333  AliAODRecoDecayHF2Prong* candidateD0 = (AliAODRecoDecayHF2Prong*)candidateBPlus->GetDaughter(1);
4334  if(!candidateD0){
4335  std::cout<<"candidateD0 null"<<std::endl;
4336  return;
4337  }
4338 
4339  AliAODTrack *candidatePion = (AliAODTrack*)candidateBPlus->GetDaughter(0);
4340  if(!candidatePion){
4341  std::cout<<"candidatePion null 1"<<std::endl;
4342  return;
4343  }
4344 
4345  AliAODTrack *candidateFirstDaughter = (AliAODTrack*)candidateD0->GetDaughter(0);
4346  if(!candidateFirstDaughter){
4347  std::cout<<"candidatePion null 2"<<std::endl;
4348  return;
4349  }
4350 
4351  AliAODTrack *candidateSecondDaughter = (AliAODTrack*)candidateD0->GetDaughter(1);
4352  if(!candidateSecondDaughter){
4353  std::cout<<"candidateKaon null"<<std::endl;
4354  return;
4355  }
4356 
4357  AliAODVertex * vertexBPlus = candidateBPlus->GetSecondaryVtx();
4358  if(!vertexBPlus){
4359  std::cout<<"vertexBPlus null"<<std::endl;
4360  return;
4361  }
4362 
4363  AliAODVertex * vertexD0 = candidateD0->GetSecondaryVtx();
4364  if(!vertexD0){
4365  std::cout<<"vertexD0 null"<<std::endl;
4366  return;
4367  }
4368 
4369 
4370  AliAODVertex * primaryVertex = aod->GetPrimaryVertex();
4371  if(!primaryVertex){
4372  std::cout<<"primaryVertex null"<<std::endl;
4373  return;
4374  }
4375 
4376  //get the magnetic field
4377  Double_t bz = (Double_t)aod->GetMagneticField();
4378 
4379 
4380  // save D0 variable information
4381  if(kTRUE)
4382  {
4383  // D0mass
4384  Double_t mD0PDG = TDatabasePDG::Instance()->GetParticle(421)->Mass();
4385 
4386  // D0 window - invariant mass
4387  Int_t chargeBPlus = candidateBPlus->Charge();
4388  UInt_t prongs[2];
4389  if (chargeBPlus == -1)
4390  {
4391  prongs[0] = 211;
4392  prongs[1] = 321;
4393  }
4394  else if (chargeBPlus == 1)
4395  {
4396  prongs[0] = 321;
4397  prongs[1] = 211;
4398  }
4399  else
4400  {
4401  std::cout << "Wrong charge BPlus." << std::endl;
4402  return;
4403  }
4404  Double_t invMassD0 = candidateD0->InvMass(2,prongs);
4405  Double_t invMassDifference = TMath::Abs(mD0PDG - invMassD0);
4406 
4407  Double_t pointingAngle = candidateD0->CosPointingAngle();
4408  Double_t dcaMother = candidateD0->GetDCA();
4409  Double_t ptMother = candidateD0->Pt();
4410  Double_t momentumMother = candidateD0->P();
4411  Double_t ptPion = candidateFirstDaughter->Pt();
4412  Double_t ptKaon = candidateSecondDaughter->Pt();
4413 
4414  AliExternalTrackParam motherTrack;
4415  motherTrack.CopyFromVTrack(candidateD0);
4416  Double_t d0z0[2],covd0z0[3],d0[2];
4417  motherTrack.PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
4418  d0[0] = d0z0[0];
4419  Double_t d0Mother = TMath::Abs(d0[0]);
4420  Double_t d0firstTrack = TMath::Abs(candidateD0->Getd0Prong(0));
4421  Double_t d0secondTrack = TMath::Abs(candidateD0->Getd0Prong(1));
4422 
4423  Double_t impactProduct = candidateD0->Prodd0d0();
4424  Double_t impactProductXY = TMath::Abs(candidateD0->ImpParXY());
4425 
4426  Double_t angleBetweenBothDaughters = (candidateSecondDaughter->Px() * candidateFirstDaughter->Px() + candidateSecondDaughter->Py() * candidateFirstDaughter->Py() + candidateSecondDaughter->Pz() * candidateFirstDaughter->Pz()) /(candidateSecondDaughter->P() * candidateFirstDaughter->P());
4427  Double_t angleMotherFirstDaughter = (candidateD0->Px() * candidateFirstDaughter->Px() + candidateD0->Py() * candidateFirstDaughter->Py() + candidateD0->Pz() * candidateFirstDaughter->Pz()) /(candidateD0->P() * candidateFirstDaughter->P());
4428  Double_t angleMotherSecondDaughter = (candidateD0->Px() * candidateSecondDaughter->Px() + candidateD0->Py() * candidateSecondDaughter->Py() + candidateD0->Pz() * candidateSecondDaughter->Pz()) /(candidateD0->P() * candidateSecondDaughter->P());
4429 
4430  Double_t cosThetaStar = candidateD0->CosThetaStar(0,421,211,321);
4431  Double_t vertexDistance = vertexD0->DistanceToVertex(primaryVertex);
4432  Double_t normDecayLength = candidateD0->NormalizedDecayLength();
4433  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(421)->Mass();
4434  Double_t pseudoProperDecayLength = ((vertexD0->GetX() - primaryVertex->GetX()) * candidateD0->Px() / TMath::Abs(candidateD0->Pt())) + ((vertexD0->GetY() - primaryVertex->GetY()) * candidateD0->Py() / TMath::Abs(candidateD0->Pt()));
4435  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother/ptMother;
4436  Double_t decayTime = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
4437 
4438  Double_t phi = candidateD0->Phi();
4439  Double_t theta = candidateD0->Theta();
4440  Double_t covMatrix[21];
4441  candidateD0->GetCovarianceXYZPxPyPz(covMatrix);
4442 
4443  Double_t cp = TMath::Cos(phi);
4444  Double_t sp = TMath::Sin(phi);
4445  Double_t ct = TMath::Cos(theta);
4446  Double_t st = TMath::Sin(theta);
4447 
4448  Double_t errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
4449  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
4450  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
4451  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
4452  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
4453  +covMatrix[20]*st*st; // GetCovPzPz
4454  Double_t normalizedDecayTime = candidateD0->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
4455 
4456  Double_t cosPointingAngleXY = candidateD0->CosPointingAngleXY();
4457  Double_t distanceXYToVertex = vertexD0->DistanceXYToVertex(primaryVertex);
4458  Double_t normalizedDecayLengthXY = candidateD0->NormalizedDecayLengthXY();
4459  Double_t chi2Vertex = vertexD0->GetChi2perNDF();
4460 
4461 
4462  //Topomatic
4463  Double_t dd0pr1=0.;
4464  Double_t dd0pr2=0.;
4465  Double_t dd0max=0.;
4466  Double_t dd0min=0.;
4467  for(Int_t ipr=0; ipr<2; ipr++)
4468  {
4469  Double_t diffIP, errdiffIP;
4470  candidateD0->Getd0MeasMinusExpProng(ipr,bz,diffIP,errdiffIP);
4471  Double_t normdd0=0.;
4472  if(errdiffIP>0.) normdd0=diffIP/errdiffIP;
4473  if(ipr==0) dd0pr1=normdd0;
4474  if(ipr==1) dd0pr2=normdd0;
4475  }
4476  if(TMath::Abs(dd0pr1)>TMath::Abs(dd0pr2)) {dd0max=dd0pr1; dd0min=dd0pr2;}
4477  else {dd0max=dd0pr2; dd0min=dd0pr1;}
4478 
4479 
4480  // We apply the cuts
4481  Int_t nCutIndex = 0;
4482 
4483  // "inv. mass width [GeV]" --------------------------------------------
4484  nCutIndex = 0;
4485  fCutVariableValueArray[nCutIndex] = invMassDifference;
4486  //---------------------------------------------------------------------
4487 
4488  // "delta mass width [GeV]" -------------------------------------------
4489  nCutIndex = 1; // not used for D0
4490  fCutVariableValueArray[nCutIndex] = 0;
4491  //---------------------------------------------------------------------
4492 
4493  // "pointing angle [Cos(theta)]" --------------------------------------
4494  nCutIndex = 2;
4495  fCutVariableValueArray[nCutIndex] = pointingAngle;
4496  //---------------------------------------------------------------------
4497 
4498  // "dca [cm]" ---------------------------------------------------------
4499  nCutIndex = 3;
4500  fCutVariableValueArray[nCutIndex] = dcaMother;
4501  //---------------------------------------------------------------------
4502 
4503  // "Pt D0 [GeV/c]" ----------------------------------------------------
4504  nCutIndex = 4;
4505  fCutVariableValueArray[nCutIndex] = ptMother;
4506  //---------------------------------------------------------------------
4507 
4508  // "Pt Kaon [GeV/c]" -------------------------------------------------
4509  nCutIndex = 5;
4510  fCutVariableValueArray[nCutIndex] = ptKaon;
4511  //---------------------------------------------------------------------
4512 
4513  // "Pt Pion [GeV/c]" --------------------------------------------------
4514  nCutIndex = 6;
4515  fCutVariableValueArray[nCutIndex] = ptPion;
4516  //---------------------------------------------------------------------
4517 
4518  // "d0 D0 [cm]" -------------------------------------------------------
4519  nCutIndex = 7;
4520  fCutVariableValueArray[nCutIndex] = d0Mother;
4521  //---------------------------------------------------------------------
4522 
4523  // "d0 Kaon [cm]"-----------------------------------------------------
4524  nCutIndex = 8;
4525  fCutVariableValueArray[nCutIndex] = d0firstTrack;
4526  //---------------------------------------------------------------------
4527 
4528  // "d0 Pion [cm]" -----------------------------------------------------
4529  nCutIndex = 9;
4530  fCutVariableValueArray[nCutIndex] = d0secondTrack;
4531  //---------------------------------------------------------------------
4532 
4533  // "d0d0 [cm^2]" ------------------------------------------------------
4534  nCutIndex = 10;
4535  fCutVariableValueArray[nCutIndex] = impactProduct;
4536  //---------------------------------------------------------------------
4537 
4538  // "d0d0 XY [cm^2]" ---------------------------------------------------
4539  nCutIndex = 11;
4540  fCutVariableValueArray[nCutIndex] = impactProductXY;
4541  //---------------------------------------------------------------------
4542 
4543  // "angle between both daughters" -------------------------------------
4544  nCutIndex = 12;
4545  fCutVariableValueArray[nCutIndex] = angleBetweenBothDaughters;
4546  //---------------------------------------------------------------------
4547 
4548  // "angle mother with first daughter" ---------------------------------
4549  nCutIndex = 13;
4550  fCutVariableValueArray[nCutIndex] = angleMotherFirstDaughter;
4551  //---------------------------------------------------------------------
4552 
4553  // "angle mother with second daughter" --------------------------------
4554  nCutIndex = 14;
4555  fCutVariableValueArray[nCutIndex] = angleMotherSecondDaughter;
4556  //---------------------------------------------------------------------
4557 
4558  // "cosThetaStar" -----------------------------------------------------
4559  nCutIndex = 15;
4560  fCutVariableValueArray[nCutIndex] = cosThetaStar;
4561  //---------------------------------------------------------------------
4562 
4563  // "vertexDistance" ---------------------------------------------------
4564  nCutIndex = 16;
4565  fCutVariableValueArray[nCutIndex] = vertexDistance;
4566  //---------------------------------------------------------------------
4567 
4568  // "pseudoProperDecayTime" --------------------------------------------
4569  nCutIndex = 17;
4570  fCutVariableValueArray[nCutIndex] = pseudoProperDecayTime;
4571  //---------------------------------------------------------------------
4572 
4573  // "DecayTime" --------------------------------------------------------
4574  nCutIndex = 18;
4575  fCutVariableValueArray[nCutIndex] = decayTime;
4576  //---------------------------------------------------------------------
4577 
4578  // "normalizedDecayTime" ----------------------------------------------------
4579  nCutIndex = 19;
4580  fCutVariableValueArray[nCutIndex] = normalizedDecayTime;
4581  //---------------------------------------------------------------------
4582 
4583  // "normDecayLength" --------------------------------------------------
4584  nCutIndex = 20;
4585  fCutVariableValueArray[nCutIndex] = normDecayLength;
4586  //---------------------------------------------------------------------
4587 
4588  // "topomatic first daughter" -----------------------------------------
4589  nCutIndex = 21;
4590  fCutVariableValueArray[nCutIndex] = dd0pr1;
4591  //---------------------------------------------------------------------
4592 
4593  // "topomatic second daughter" ----------------------------------------
4594  nCutIndex = 22;
4595  fCutVariableValueArray[nCutIndex] = dd0pr2;
4596  //---------------------------------------------------------------------
4597 
4598  // "topomatic max" ----------------------------------------------------
4599  nCutIndex = 23;
4600  fCutVariableValueArray[nCutIndex] = dd0max;
4601  //---------------------------------------------------------------------
4602 
4603  // "topomatic min" ----------------------------------------------------
4604  nCutIndex = 24;
4605  fCutVariableValueArray[nCutIndex] = dd0min;
4606  //---------------------------------------------------------------------
4607 
4608  // "pointing angle XY" ----------------------------------------------------
4609  nCutIndex = 25;
4610  fCutVariableValueArray[nCutIndex] = cosPointingAngleXY;
4611  //---------------------------------------------------------------------
4612 
4613  // "vertex distance XY" ----------------------------------------------------
4614  nCutIndex = 26;
4615  fCutVariableValueArray[nCutIndex] = distanceXYToVertex;
4616  //---------------------------------------------------------------------
4617 
4618  // "normalized decay length XY" ----------------------------------------------------
4619  nCutIndex = 27;
4620  fCutVariableValueArray[nCutIndex] = normalizedDecayLengthXY;
4621  //---------------------------------------------------------------------
4622 
4623  // "chi squared per NDF" ----------------------------------------------------
4624  nCutIndex = 28;
4625  fCutVariableValueArray[nCutIndex] = chi2Vertex;
4626  //---------------------------------------------------------------------
4627 
4628 
4629 
4630  AliAODRecoDecay* candidateD0toBPlus = (AliAODRecoDecay*)candidateD0;
4631  AliExternalTrackParam firstDaughterD0Track;
4632  AliExternalTrackParam secondDaughterD0Track;
4633 
4634  Double_t d0z0DSVert[2],covd0z0DSVert[3],d0DSVert[2];
4635 
4636  firstDaughterD0Track.CopyFromVTrack(candidateFirstDaughter);
4637  firstDaughterD0Track.PropagateToDCA(vertexBPlus,bz,100.,d0z0DSVert,covd0z0DSVert);
4638  d0DSVert[0] = d0z0DSVert[0];
4639 
4640  secondDaughterD0Track.CopyFromVTrack(candidateSecondDaughter);
4641  secondDaughterD0Track.PropagateToDCA(vertexBPlus,bz,100.,d0z0DSVert,covd0z0DSVert);
4642  d0DSVert[1] = d0z0DSVert[0];
4643 
4644  AliExternalTrackParam D0Track;
4645  D0Track.CopyFromVTrack(candidateD0);
4646  Double_t d0z0D0DSVert[2],covd0z0D0DSVert[3],d0D0DSVert;
4647  motherTrack.PropagateToDCA(vertexBPlus,bz,100.,d0z0D0DSVert,covd0z0D0DSVert);
4648  d0D0DSVert = TMath::Abs(d0z0D0DSVert[0]);
4649 
4650  Double_t impactProductToBPlus = d0DSVert[0]*d0DSVert[1];
4651  Double_t impactProductXYToBPlus = candidateD0toBPlus->ImpParXY(vertexBPlus);
4652 
4653  Double_t pointingAngleToBPlus = candidateD0toBPlus->CosPointingAngle(vertexBPlus);
4654  Double_t d0FirstDaughterToBPlus = TMath::Abs(d0DSVert[0]);
4655  Double_t d0SecondDaughterToBPlus = TMath::Abs(d0DSVert[1]);
4656  Double_t normDecayLengthToBPlus = candidateD0toBPlus->NormalizedDecayLength(vertexBPlus);
4657 
4658  Double_t pseudoProperDecayLengthDSVert = ((vertexD0->GetX() - vertexBPlus->GetX()) * candidateD0->Px() / TMath::Abs(candidateD0->Pt())) + ((vertexD0->GetY() - vertexBPlus->GetY()) * candidateD0->Py() / TMath::Abs(candidateD0->Pt()));
4659  Double_t pseudoProperDecayTimeToBPlus = pseudoProperDecayLengthDSVert * pdgMassMother/ptMother;
4660  Double_t DecayTimeToBPlus = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
4661 
4662  Double_t phiDSVert = candidateD0->Phi();
4663  Double_t thetaDSVert = candidateD0->Theta();
4664  Double_t covMatrixDSVert[21];
4665  candidateD0->GetCovarianceXYZPxPyPz(covMatrixDSVert);
4666 
4667  cp = TMath::Cos(phiDSVert);
4668  sp = TMath::Sin(phiDSVert);
4669  ct = TMath::Cos(thetaDSVert);
4670  st = TMath::Sin(thetaDSVert);
4671 
4672  errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
4673  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
4674  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
4675  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
4676  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
4677  +covMatrix[20]*st*st; // GetCovPzPz
4678  Double_t normalizedDecayTimeToBPlus = candidateD0toBPlus->NormalizedDecayLength(vertexBPlus) / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
4679 
4680  // "pointingAngleToBPlus" ---------------------------------------------
4681  nCutIndex = 29;
4682  fCutVariableValueArray[nCutIndex] = pointingAngleToBPlus;
4683  //---------------------------------------------------------------------
4684 
4685  // "d0MotherToBPlus" --------------------------------------------------
4686  nCutIndex = 30;
4687  fCutVariableValueArray[nCutIndex] = d0D0DSVert;
4688  //---------------------------------------------------------------------
4689 
4690  // "d0FirstDaughterToBPlus" -------------------------------------------
4691  nCutIndex = 31;
4692  fCutVariableValueArray[nCutIndex] = d0FirstDaughterToBPlus;
4693  //---------------------------------------------------------------------
4694 
4695  // "d0SecondDaughterToBPlus" ------------------------------------------
4696  nCutIndex = 32;
4697  fCutVariableValueArray[nCutIndex] = d0SecondDaughterToBPlus;
4698  //---------------------------------------------------------------------
4699 
4700  // "impactProductToBPlus" ---------------------------------------------
4701  nCutIndex = 33;
4702  fCutVariableValueArray[nCutIndex] = impactProductToBPlus;
4703  //---------------------------------------------------------------------
4704 
4705  // "impactProductXYToBPlus" -------------------------------------------
4706  nCutIndex = 34;
4707  fCutVariableValueArray[nCutIndex] = impactProductXYToBPlus;
4708  //---------------------------------------------------------------------
4709 
4710  // "normDecayLengthToBPlus" -------------------------------------------
4711  nCutIndex = 35;
4712  fCutVariableValueArray[nCutIndex] = normDecayLengthToBPlus;
4713  //---------------------------------------------------------------------
4714 
4715  // "pseudoProperDecayTimeToBPlus" -------------------------------------
4716  nCutIndex = 36;
4717  fCutVariableValueArray[nCutIndex] = pseudoProperDecayTimeToBPlus;
4718  //---------------------------------------------------------------------
4719 
4720  // "DecayTimeToBPlus" -------------------------------------------------
4721  nCutIndex = 37;
4722  fCutVariableValueArray[nCutIndex] = DecayTimeToBPlus;
4723  //---------------------------------------------------------------------
4724 
4725  // "normalizedDecayTimeToBPlus" ---------------------------------------------
4726  nCutIndex = 38;
4727  fCutVariableValueArray[nCutIndex] = normalizedDecayTimeToBPlus;
4728  //---------------------------------------------------------------------
4729  }
4730 
4731  // save B0 variable information
4732  if(kTRUE)
4733  {
4734  // We obtain the variable values in the section below
4735  // D0Mass and BPlusmass
4736  Double_t mD0PDG = TDatabasePDG::Instance()->GetParticle(421)->Mass();
4737  Double_t mBPlusPDG = TDatabasePDG::Instance()->GetParticle(521)->Mass();
4738 
4739  // delta mass PDG
4740  Double_t deltaPDG = mBPlusPDG - mD0PDG;
4741 
4742  // Half width BPlus mass
4743  UInt_t prongs[2];
4744  prongs[0] = 211; prongs[1] = 421;
4745  Double_t invMassBPlus = candidateBPlus->InvMass(2,prongs);
4746  Double_t invMassDifference = TMath::Abs(mBPlusPDG - invMassBPlus);
4747  Double_t invMassDelta = TMath::Abs(deltaPDG-(DeltaInvMassBPlusKpipi(candidateBPlus)));
4748 
4749  Double_t pointingAngle = candidateBPlus->CosPointingAngle();
4750  Double_t dcaMother = candidateBPlus->GetDCA();
4751  Double_t ptMother = candidateBPlus->Pt();
4752  Double_t momentumMother = candidateBPlus->P();
4753  Double_t ptD0 = candidateD0->Pt();
4754  Double_t ptPion = candidatePion->Pt();
4755 
4756  AliExternalTrackParam motherTrack;
4757  motherTrack.CopyFromVTrack(candidateBPlus);
4758  Double_t d0z0[2],covd0z0[3],d0[2];
4759  motherTrack.PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
4760  d0[0] = d0z0[0];
4761  Double_t d0Mother = TMath::Abs(d0[0]);
4762  Double_t d0firstTrack = TMath::Abs(candidateBPlus->Getd0Prong(0));
4763  Double_t d0secondTrack = TMath::Abs(candidateBPlus->Getd0Prong(1));
4764 
4765  Double_t impactProduct = candidateBPlus->Prodd0d0();
4766  Double_t impactProductXY = TMath::Abs(candidateBPlus->ImpParXY());
4767 
4768  Double_t angleBetweenBothDaughters = (candidateD0->Px() * candidatePion->Px() + candidateD0->Py() * candidatePion->Py() + candidateD0->Pz() * candidatePion->Pz()) /(candidateD0->P() * candidatePion->P());
4769  Double_t angleMotherFirstDaughter = (candidateBPlus->Px() * candidatePion->Px() + candidateBPlus->Py() * candidatePion->Py() + candidateBPlus->Pz() * candidatePion->Pz()) /(candidateBPlus->P() * candidatePion->P());
4770  Double_t angleMotherSecondDaughter = (candidateBPlus->Px() * candidateD0->Px() + candidateBPlus->Py() * candidateD0->Py() + candidateBPlus->Pz() * candidateD0->Pz()) /(candidateBPlus->P() * candidateD0->P());
4771 
4772  Double_t cosThetaStar = candidateBPlus->CosThetaStar(0,521,211,421);
4773  Double_t vertexDistance = vertexBPlus->DistanceToVertex(primaryVertex);
4774  Double_t normDecayLength = candidateBPlus->NormalizedDecayLength();
4775  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(521)->Mass();
4776  Double_t pseudoProperDecayLength = ((vertexBPlus->GetX() - primaryVertex->GetX()) * candidateBPlus->Px() / TMath::Abs(candidateBPlus->Pt())) + ((vertexBPlus->GetY() - primaryVertex->GetY()) * candidateBPlus->Py() / TMath::Abs(candidateBPlus->Pt()));
4777  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother/ptMother;
4778  Double_t decayTime = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
4779 
4780  Double_t phi = candidateBPlus->Phi();
4781  Double_t theta = candidateBPlus->Theta();
4782  Double_t covMatrix[21];
4783  candidateBPlus->GetCovarianceXYZPxPyPz(covMatrix);
4784 
4785  Double_t cp = TMath::Cos(phi);
4786  Double_t sp = TMath::Sin(phi);
4787  Double_t ct = TMath::Cos(theta);
4788  Double_t st = TMath::Sin(theta);
4789 
4790  Double_t errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
4791  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
4792  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
4793  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
4794  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
4795  +covMatrix[20]*st*st; // GetCovPzPz
4796  Double_t normalizedDecayTime = candidateBPlus->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
4797 
4798  Double_t cosPointingAngleXY = candidateBPlus->CosPointingAngleXY();
4799  Double_t distanceXYToVertex = vertexBPlus->DistanceXYToVertex(primaryVertex);
4800  Double_t normalizedDecayLengthXY = candidateBPlus->NormalizedDecayLengthXY();
4801  Double_t chi2Vertex = vertexBPlus->GetChi2perNDF();
4802 
4803  //Topomatic
4804  Double_t dd0pr1=0.;
4805  Double_t dd0pr2=0.;
4806  Double_t dd0max=0.;
4807  Double_t dd0min=0.;
4808  for(Int_t ipr=0; ipr<2; ipr++)
4809  {
4810  Double_t diffIP, errdiffIP;
4811  candidateBPlus->Getd0MeasMinusExpProng(ipr,bz,diffIP,errdiffIP);
4812  Double_t normdd0=0.;
4813  if(errdiffIP>0.) normdd0=diffIP/errdiffIP;
4814  if(ipr==0) dd0pr1=normdd0;
4815  if(ipr==1) dd0pr2=normdd0;
4816  }
4817  if(TMath::Abs(dd0pr1)>TMath::Abs(dd0pr2)) {dd0max=dd0pr1; dd0min=dd0pr2;}
4818  else {dd0max=dd0pr2; dd0min=dd0pr1;}
4819 
4820  Double_t Normalizedd0D0firstdaughter = TMath::Abs(candidateD0->Getd0Prong(0)/candidateD0->Getd0errProng(0));
4821  Double_t Normalizedd0D0seconddaughter = TMath::Abs(candidateD0->Getd0Prong(1)/candidateD0->Getd0errProng(1));
4822  Double_t Normalizedd0D0 = TMath::Abs(candidateBPlus->Getd0Prong(1)/candidateBPlus->Getd0errProng(1));
4823  Double_t Normalizedd0BPluspion = TMath::Abs(candidateBPlus->Getd0Prong(0)/candidateBPlus->Getd0errProng(0));
4824  Double_t Normalizedd0BPlus = TMath::Abs(d0[0]/covd0z0[0]);
4825  Double_t NormalizedimpactproductD0 = (candidateD0->Getd0Prong(0)/candidateD0->Getd0errProng(0)) * (candidateD0->Getd0Prong(1)/candidateD0->Getd0errProng(1));
4826  Double_t NormalizedimpactproductBPlus = (candidateBPlus->Getd0Prong(0)/candidateBPlus->Getd0errProng(0)) * (candidateBPlus->Getd0Prong(1)/candidateBPlus->Getd0errProng(1));
4827 
4828  // We apply the cuts
4829  Int_t nCutIndex = 0;
4830 
4831  // "inv. mass width [GeV]" --------------------------------------------
4832  nCutIndex = 39;
4833  fCutVariableValueArray[nCutIndex] = invMassDifference;
4834  //---------------------------------------------------------------------
4835 
4836  // "delta mass width [GeV]" -------------------------------------------
4837  nCutIndex = 40;
4838  fCutVariableValueArray[nCutIndex] = invMassDelta;
4839  //---------------------------------------------------------------------
4840 
4841  // "pointing angle [Cos(theta)]" --------------------------------------
4842  nCutIndex = 41;
4843  fCutVariableValueArray[nCutIndex] = pointingAngle;
4844  //---------------------------------------------------------------------
4845 
4846  // "dca [cm]" ---------------------------------------------------------
4847  nCutIndex = 42;
4848  fCutVariableValueArray[nCutIndex] = dcaMother;
4849  //---------------------------------------------------------------------
4850 
4851  // "Pt BPlus [GeV/c]" ----------------------------------------------------
4852  nCutIndex = 43;
4853  fCutVariableValueArray[nCutIndex] = ptMother;
4854  //---------------------------------------------------------------------
4855 
4856  // "Pt D0 [GeV/c]" -------------------------------------------------
4857  nCutIndex = 44;
4858  fCutVariableValueArray[nCutIndex] = ptD0;
4859  //---------------------------------------------------------------------
4860 
4861  // "Pt Pion [GeV/c]" --------------------------------------------------
4862  nCutIndex = 45;
4863  fCutVariableValueArray[nCutIndex] = ptPion;
4864  //---------------------------------------------------------------------
4865 
4866  // "d0 BPlus [cm]" -------------------------------------------------------
4867  nCutIndex = 46;
4868  fCutVariableValueArray[nCutIndex] = d0Mother;
4869  //---------------------------------------------------------------------
4870 
4871  // "d0 D0 [cm]"-----------------------------------------------------
4872  nCutIndex = 47;
4873  fCutVariableValueArray[nCutIndex] = d0firstTrack;
4874  //---------------------------------------------------------------------
4875 
4876  // "d0 Pion [cm]" -----------------------------------------------------
4877  nCutIndex = 48;
4878  fCutVariableValueArray[nCutIndex] = d0secondTrack;
4879  //---------------------------------------------------------------------
4880 
4881  // "d0d0 [cm^2]" ------------------------------------------------------
4882  nCutIndex = 49;
4883  fCutVariableValueArray[nCutIndex] = impactProduct;
4884  //---------------------------------------------------------------------
4885 
4886  // "d0d0 XY [cm^2]" ---------------------------------------------------
4887  nCutIndex = 50;
4888  fCutVariableValueArray[nCutIndex] = impactProductXY;
4889  //---------------------------------------------------------------------
4890 
4891  // "angle between both daughters" -------------------------------------
4892  nCutIndex = 51;
4893  fCutVariableValueArray[nCutIndex] = angleBetweenBothDaughters;
4894  //---------------------------------------------------------------------
4895 
4896  // "angle mother with first daughter" ---------------------------------
4897  nCutIndex = 52;
4898  fCutVariableValueArray[nCutIndex] = angleMotherFirstDaughter;
4899  //---------------------------------------------------------------------
4900 
4901  // "angle mother with second daughter" --------------------------------
4902  nCutIndex = 53;
4903  fCutVariableValueArray[nCutIndex] = angleMotherSecondDaughter;
4904  //---------------------------------------------------------------------
4905 
4906  // "cosThetaStar" -----------------------------------------------------
4907  nCutIndex = 54;
4908  fCutVariableValueArray[nCutIndex] = cosThetaStar;
4909  //---------------------------------------------------------------------
4910 
4911  // "vertexDistance" ---------------------------------------------------
4912  nCutIndex = 55;
4913  fCutVariableValueArray[nCutIndex] = vertexDistance;
4914  //---------------------------------------------------------------------
4915 
4916  // "pseudoProperDecayTime" --------------------------------------------
4917  nCutIndex = 56;
4918  fCutVariableValueArray[nCutIndex] = pseudoProperDecayTime;
4919  //---------------------------------------------------------------------
4920 
4921  // "DecayTime" --------------------------------------------------------
4922  nCutIndex = 57;
4923  fCutVariableValueArray[nCutIndex] = decayTime;
4924  //---------------------------------------------------------------------
4925 
4926  // "normalizedDecayTime" ----------------------------------------------------
4927  nCutIndex = 58;
4928  fCutVariableValueArray[nCutIndex] = normalizedDecayTime;
4929  //---------------------------------------------------------------------
4930 
4931  // "normDecayLength" --------------------------------------------------
4932  nCutIndex = 59;
4933  fCutVariableValueArray[nCutIndex] = normDecayLength;
4934  //---------------------------------------------------------------------
4935 
4936  // "topomatic first daughter" -----------------------------------------
4937  nCutIndex = 60;
4938  fCutVariableValueArray[nCutIndex] = dd0pr1;
4939  //---------------------------------------------------------------------
4940 
4941  // "topomatic second daughter" ----------------------------------------
4942  nCutIndex = 61;
4943  fCutVariableValueArray[nCutIndex] = dd0pr2;
4944  //---------------------------------------------------------------------
4945 
4946  // "topomatic max" ----------------------------------------------------
4947  nCutIndex = 62;
4948  fCutVariableValueArray[nCutIndex] = dd0max;
4949  //---------------------------------------------------------------------
4950 
4951  // "topomatic min" ----------------------------------------------------
4952  nCutIndex = 63;
4953  fCutVariableValueArray[nCutIndex] = dd0min;
4954  //---------------------------------------------------------------------
4955 
4956  // "pointing angle XY" ----------------------------------------------------
4957  nCutIndex = 64;
4958  fCutVariableValueArray[nCutIndex] = cosPointingAngleXY;
4959  //---------------------------------------------------------------------
4960 
4961  // "vertex distance XY" ----------------------------------------------------
4962  nCutIndex = 65;
4963  fCutVariableValueArray[nCutIndex] = distanceXYToVertex;
4964  //---------------------------------------------------------------------
4965 
4966  // "normalized decay length XY" ----------------------------------------------------
4967  nCutIndex = 66;
4968  fCutVariableValueArray[nCutIndex] = normalizedDecayLengthXY;
4969  //---------------------------------------------------------------------
4970 
4971  // "chi squared per NDF" ----------------------------------------------------
4972  nCutIndex = 67;
4973  fCutVariableValueArray[nCutIndex] = chi2Vertex;
4974 
4975  // "Normalizedd0D0firstdaughter" ----------------------------------------------------
4976  nCutIndex = 68;
4977  fCutVariableValueArray[nCutIndex] = Normalizedd0D0firstdaughter;
4978  //---------------------------------------------------------------------
4979 
4980  // "Normalizedd0D0seconddaughter" ----------------------------------------------------
4981  nCutIndex = 69;
4982  fCutVariableValueArray[nCutIndex] = Normalizedd0D0seconddaughter;
4983  //---------------------------------------------------------------------
4984 
4985  // "Normalizedd0D0" ----------------------------------------------------
4986  nCutIndex = 70;
4987  fCutVariableValueArray[nCutIndex] = Normalizedd0D0;
4988  //---------------------------------------------------------------------
4989 
4990  // "Normalizedd0BPluspion" ----------------------------------------------------
4991  nCutIndex = 71;
4992  fCutVariableValueArray[nCutIndex] = Normalizedd0BPluspion;
4993  //---------------------------------------------------------------------
4994 
4995  // "Normalizedd0BPlus" ----------------------------------------------------
4996  nCutIndex = 72;
4997  fCutVariableValueArray[nCutIndex] = Normalizedd0BPlus;
4998  //---------------------------------------------------------------------
4999 
5000  // "NormalizedimpactproductD0" ----------------------------------------------------
5001  nCutIndex = 73;
5002  fCutVariableValueArray[nCutIndex] = NormalizedimpactproductD0;
5003  //---------------------------------------------------------------------
5004 
5005  // "NormalizedimpactproductBPlus" ----------------------------------------------------
5006  nCutIndex = 74;
5007  fCutVariableValueArray[nCutIndex] = NormalizedimpactproductBPlus;
5008  //---------------------------------------------------------------------
5009  }
5010  return;
5011 }
5012 
Int_t charge
void ThreeTrackCombinationInfo(AliExternalTrackParam *firstTrack, AliExternalTrackParam *secondTrack, AliExternalTrackParam *thirdTrack, AliAODVertex *primaryVertex, Double_t bz, Bool_t isDesiredCandidate, Int_t histogramNumber, UInt_t prongs[3])
Double_t NormalizedDecayLengthXY() const
Double_t NormalizedDecayLength() const
Int_t IsTrackInjected(AliAODTrack *part, AliAODMCHeader *header, TClonesArray *arrayMC)
Int_t PtBin(Float_t pt) const
Definition: AliRDHFCuts.h:330
double Double_t
Definition: External.C:58
ULong64_t GetTriggerMask()
Definition: AliRDHFCuts.h:73
AliAODVertex * RecalculateVertex(const AliVVertex *primary, TObjArray *tracks, Double_t bField, Double_t dispersion, Bool_t optUseFitter, Bool_t optPropagate, Bool_t optUseDiamondConstraint)
Double_t DeltaInvMassBPlusKpipi(AliAODRecoDecayHF2Prong *BPlus) const
Float_t * GetPtBinLimitsD0forD0ptbin() const
Definition: External.C:236
void Getd0MeasMinusExpProng(Int_t ip, Double_t magf, Double_t &d0diff, Double_t &errd0diff) const
Int_t GetnSigmaTOF(AliAODTrack *track, Int_t species, Double_t &sigma) const
void GetSoftSelectionArrayITSD0SecondDaughter(Bool_t array[7]=0)
Int_t GetnSigmaTPC(AliAODTrack *track, Int_t species, Double_t &sigma) const
Double_t bz
Double_t ImpParXY() const
char Char_t
Definition: External.C:18
static TString GetGenerator(Int_t label, AliAODMCHeader *header)
Int_t GetWhyRejection() const
Definition: AliRDHFCuts.h:341
Double_t CosPointingAngleXY() const
Bool_t FillRecoCand(AliVEvent *event, AliAODRecoDecayHF3Prong *rd3)
void BPlustoD0PiSignalTracksInMC(TClonesArray *mcTrackArray, AliAODEvent *aodevent, TMatrix *BPlustoD0PiLabelMatrix, TList *listout)
Int_t IsD0forD0ptbinSelected(TObject *obj, Int_t selectionLevel, AliAODEvent *aod, Bool_t *bCutArray)
Bool_t IsThisDaughterSelected(AliAODTrack *track, AliAODVertex *primary, const AliAODEvent *aod)
AliAODPidHF * GetPidHF() const
Definition: AliRDHFCuts.h:264
virtual void Terminate(Option_t *option)
void BPlusPionSelection(AliAODEvent *aodEvent, AliAODVertex *primaryVertex, Double_t bz, TClonesArray *mcTrackArray, TMatrix *BPlustoD0PiLabelMatrix, AliAODMCHeader *header)
Int_t PtBinD0forD0ptbin(Double_t pt) const
Bool_t GetIsUpperCutForCutOptimization(Int_t nVariable) const
Bool_t D0SecondDaughterSelection(AliAODTrack *aodTrack, AliAODVertex *primaryVertex, Double_t bz, TClonesArray *mcTrackArray, TMatrix *B0toDStarPiLabelMatrix, AliAODMCHeader *header, AliAODEvent *aodEvent)
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
void GetHardSelectionArrayITSD0FirstDaughter(Bool_t array[7]=0)
float Float_t
Definition: External.C:68
virtual Int_t SelectPID(AliAODTrack *track, Int_t type)
void SetProngIDs(Int_t nIDs, UShort_t *id)
Double_t Getd0errProng(Int_t ip) const
prongs
void GetHardSelectionArrayITSD0SecondDaughter(Bool_t array[7]=0)
Float_t GetCutForCutOptimization(Int_t nCutIndex, Int_t nVariable, Int_t ptBin)
void SetPrimaryVtxRef(TObject *vtx)
primary vertex
Int_t GetNumberOfSigmaBinsForCutOptimization() const
short Short_t
Definition: External.C:23
Float_t fCutVariableValueArray[99]
[fnPtBinsD0forD0ptbinLimits]
void GetSoftSelectionArrayITSD0FirstDaughter(Bool_t array[7]=0)
virtual void UserCreateOutputObjects()
Implementation of interface methods.
Bool_t AreDaughtersSelected(AliAODRecoDecayHF *rd, const AliAODEvent *aod=0x0) const
Int_t MatchCandidateToMonteCarlo(Int_t pdgabs, AliAODRecoDecayHF2Prong *candidate, TClonesArray *mcArray, TMatrix *B0toDStarPiLabelMatrix, Bool_t bCheckLabel=kFALSE) const
virtual Int_t IsSelected(TObject *obj, Int_t selectionLevel, AliAODEvent *aod)
Bool_t IsEventSelected(AliVEvent *event)
void FillBPlusHistograms(AliAODRecoDecayHF2Prong *selectedMother, AliAODVertex *primaryVertex, Double_t bz, Int_t motherType, Int_t histType)
void CutOptimizationVariableValues(AliAODRecoDecayHF2Prong *candidateBPlus, AliAODEvent *aod)
void FillD0Histograms(AliAODRecoDecayHF2Prong *selectedMother, AliAODVertex *primaryVertex, Double_t bz, Int_t motherType, Int_t histType, Int_t pdgCodeMother=-1)
Bool_t D0FirstDaughterSelection(AliAODTrack *aodTrack, AliAODVertex *primaryVertex, Double_t bz, TClonesArray *mcTrackArray, TMatrix *B0toDStarPiLabelMatrix, AliAODMCHeader *header, AliAODEvent *aodEvent)
void FillFinalTrackHistograms(AliAODRecoDecayHF2Prong *selectedBPlus, AliAODVertex *primaryVertex, Double_t bz, Bool_t isDesiredCandidate, TClonesArray *mcTrackArray)
void GetSoftSelectionArrayITSBPlusPion(Bool_t array[7]=0)
Float_t * GetPtBinLimits() const
Definition: AliRDHFCuts.h:265
Bool_t IsCandidateInjected(AliAODRecoDecayHF2Prong *part, AliAODMCHeader *header, TClonesArray *arrayMC)
void GetHardSelectionArrayITSBPlusPion(Bool_t array[7]=0)
Double_t GetSigmaForCutOptimization(Int_t iPtBin) const
unsigned short UShort_t
Definition: External.C:28
const char Option_t
Definition: External.C:48
Int_t GetNPtBins() const
Definition: AliRDHFCuts.h:266
Int_t GetCutIndexForCutOptimization(Int_t nVariable) const
bool Bool_t
Definition: External.C:53
Double_t CosPointingAngle() const
virtual void UserExec(Option_t *option)
void TwoTrackCombinationInfo(AliExternalTrackParam *firstTrack, AliExternalTrackParam *secondTrack, AliAODVertex *primaryVertex, Double_t bz, Bool_t isDesiredCandidate, Int_t histogramNumber, UInt_t prongs[2])
Int_t GetNPtBinsD0forD0ptbin() const
void BPlusSelection(AliAODEvent *aodEvent, AliAODVertex *primaryVertex, Double_t bz, TClonesArray *mcTrackArray, TMatrix *BPlustoD0PiLabelMatrix, TClonesArray *D0TracksFromFriendFile, AliAODMCHeader *header)
void CutOptimizationLoop(Int_t variable, Int_t nVariables, Int_t nCuts, Int_t ptBin, Int_t fillNumber, Bool_t isDesiredCandidate, Int_t nSigmaBin)
void D0Selection(AliAODEvent *aodEvent, AliAODVertex *primaryVertex, Double_t bz, TClonesArray *mcTrackArray, TMatrix *BPlustoD0PiLabelMatrix, TClonesArray *D0TracksFromFriendFile, AliAODMCHeader *header)
Class with functions useful for different D2H analyses //.