AliPhysics  4c9ecbb (4c9ecbb)
AliAnalysisTaskSELc2V0bachelor.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appeuear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 
16 /* $Id$ */
17 
18 //
19 //
20 // Base class for Lc2V0 Analysis
21 //
22 //
23 // The Lc spectra study is done 2D histograms:
24 // cascade_invariantMass VS cascade_pT
25 //
26 // Cuts have been centralized in AliRDHFCutsLctoV0 class
27 //
28 //-------------------------------------------------------------------------
29 //
30 // Authors: A.De Caro(a,b), P. Pagano(b)
31 // (a) Centro 'E.Fermi' - Roma
32 // (b) INFN and University of Salerno
33 //
34 // Contatcs: decaro@sa.infn.it
35 // paola.pagano@sa.infn.it
36 //-------------------------------------------------------------------------
37 
38 #include <TSystem.h>
39 #include <TParticle.h>
40 #include <TParticlePDG.h>
41 #include <TH1F.h>
42 #include <TH2F.h>
43 #include <TH3F.h>
44 #include <THnSparse.h>
45 #include <TTree.h>
46 #include "TROOT.h"
47 #include <TDatabasePDG.h>
48 #include <AliAnalysisDataSlot.h>
49 #include <AliAnalysisDataContainer.h>
50 #include "AliMCEvent.h"
51 #include "AliAnalysisManager.h"
52 #include "AliAODMCHeader.h"
53 #include "AliAODHandler.h"
54 #include "AliLog.h"
55 #include "AliExternalTrackParam.h"
56 #include "AliAODVertex.h"
57 #include "AliAODRecoDecay.h"
58 #include "AliAODRecoDecayHF.h"
59 #include "AliAODRecoCascadeHF.h"
60 #include "AliAnalysisVertexingHF.h"
61 #include "AliESDtrack.h"
62 #include "AliAODTrack.h"
63 #include "AliAODv0.h"
64 #include "AliAODMCParticle.h"
65 #include "AliAnalysisTaskSE.h"
68 #include "AliAODPidHF.h"
69 #include "AliInputEventHandler.h"
70 #include "AliESDtrackCuts.h"
71 #include "AliNeutralTrackParam.h"
72 #include "AliVertexingHFUtils.h"
73 
74 using std::cout;
75 using std::endl;
76 
80 
81 //__________________________________________________________________________
83  fUseMCInfo(kFALSE),
84  fOutput(0),
85  fOutputAll(0),
86  fOutputPIDBach(0),
87  fCEvents(0),
88  fEventCounter(0),
89  fCounter(0),
90  fAnalCuts(0),
91  fUseOnTheFlyV0(kFALSE),
92  fAODProtection(1),
93  fIsEventSelected(kFALSE),
94  fWriteVariableTree(kFALSE),
95  fVariablesTree(0),
96  fCandidateVariables(),
97  fVtx1(0),
98  fBzkG(0),
99  fAdditionalChecks(kFALSE),
100  fFillSubSampleHist(kFALSE),
101  fTrackRotation(kFALSE),
102  fOutputPIDBachTR(0),
103  fMinAngleForRot(5*TMath::Pi()/6),
104  fMaxAngleForRot(7*TMath::Pi()/6),
105  fMinMass(0),
106  fMaxMass(0),
107  fNRotations(9),
108  fPtMinToFillTheTree(0.),
109  fPtMaxToFillTheTree(999.),
110  fUseTPCPIDtoFillTree(kFALSE),
111  fSign(2),
112  fCheckOrigin(kFALSE),
113  fReconstructSecVtx(kFALSE),
114  fDoSingleAnalysisForSystK0SP(0),
115  fGenerateBGEventFromTracks(0),
116  fNumberOfEventsForMixing (10),
117  fNzVtxBins (0),
118  fNCentBins (0),
119  fNOfPools(1),
120  fPoolIndex(-9999),
121  fNextResVec(),
122  fReservoirsReady(),
123  fReservoirP()
124 {
125  //
127  //
128 
129  Double_t mLcPDG = TDatabasePDG::Instance()->GetParticle(4122)->Mass();
130  fMinMass=mLcPDG-0.250;
131  fMaxMass=mLcPDG+0.250;
132  for(Int_t i=0;i<100;i++){
133  fZvtxBins[i] = 9999; fCentBins[i] = 9999;
134  }
135 }
136 //___________________________________________________________________________
138  AliRDHFCutsLctoV0* analCuts, Bool_t useOnTheFly,
139  Bool_t writeVariableTree, Bool_t additionalChecks, Bool_t trackRotation, Bool_t useTPCpid, Char_t sign, Bool_t origin) :
140  AliAnalysisTaskSE(name),
141  fUseMCInfo(kFALSE),
142  fOutput(0),
143  fOutputAll(0),
144  fOutputPIDBach(0),
145  fCEvents(0),
146  fEventCounter(0),
147  fCounter(0),
148  fAnalCuts(analCuts),
149  fUseOnTheFlyV0(useOnTheFly),
150  fAODProtection(1),
151  fIsEventSelected(kFALSE),
152  fWriteVariableTree(writeVariableTree),
153  fVariablesTree(0),
155  fVtx1(0),
156  fBzkG(0),
157  fAdditionalChecks(additionalChecks),
158  fFillSubSampleHist(kFALSE),
159  fTrackRotation(trackRotation),
160  fOutputPIDBachTR(0),
161  fMinAngleForRot(5*TMath::Pi()/6),
162  fMaxAngleForRot(7*TMath::Pi()/6),
163  fMinMass(0),
164  fMaxMass(0),
165  fNRotations(9),
167  fPtMaxToFillTheTree(999.),
168  fUseTPCPIDtoFillTree(useTPCpid),
169  fSign(sign),
170  fCheckOrigin(origin),
171  fReconstructSecVtx(kFALSE),
175  fNzVtxBins (0),
176  fNCentBins (0),
177  fNOfPools(1),
178  fPoolIndex(-9999),
179  fNextResVec(),
181  fReservoirP()
182 {
183  //
185  //
186  Info("AliAnalysisTaskSELc2V0bachelor","Calling Constructor");
187 
189  AliInfo(Form("You cannot initialize fWriteVariableTree=%d and fTrackRotation=%d => fTrackRotation=0",fWriteVariableTree,fTrackRotation));
190  fTrackRotation=kFALSE;
191  }
192 
193  for(Int_t i=0;i<100;i++){
194  fZvtxBins[i] = -9999; fCentBins[i] = -9999;
195  }
196 
197  Double_t mLcPDG = TDatabasePDG::Instance()->GetParticle(4122)->Mass();
198  fMinMass=mLcPDG-0.250;
199  fMaxMass=mLcPDG+0.250;
200 
201  DefineOutput(1,TList::Class()); //conters
202  DefineOutput(2,AliNormalizationCounter::Class());
203  DefineOutput(3,AliRDHFCutsLctoV0::Class());
204  if (!writeVariableTree) {
205  DefineOutput(4,TList::Class()); //All Entries output
206  DefineOutput(5,TList::Class()); //3sigma PID output
207  if (trackRotation) {
208  DefineOutput(6,TList::Class()); //All Entries output
209  }
210  } else {
211  // Output slot #4 keeps a tree of the candidate variables after track selection
212  DefineOutput(4,TTree::Class()); //My private output
213  }
214 
215  if (fWriteVariableTree) fSign=2;
216 
217 }
218 
219 //___________________________________________________________________________
221  //
223  //
224  Info("~AliAnalysisTaskSELc2V0bachelor","Calling Destructor");
225 
226  if (fOutput) {
227  delete fOutput;
228  fOutput = 0;
229  }
230 
231  if (fOutputAll) {
232  delete fOutputAll;
233  fOutputAll = 0;
234  }
235 
236  if (fOutputPIDBach) {
237  delete fOutputPIDBach;
238  fOutputPIDBach = 0;
239  }
240 
241  if (fCounter) {
242  delete fCounter;
243  fCounter = 0;
244  }
245 
246  if (fAnalCuts) {
247  delete fAnalCuts;
248  fAnalCuts = 0;
249  }
250 
251  if (fVariablesTree) {
252  delete fVariablesTree;
253  fVariablesTree = 0;
254  }
255 
256  if (fOutputPIDBachTR) {
257  delete fOutputPIDBachTR;
258  fOutputPIDBachTR = 0;
259  }
260 
261 }
262 //_________________________________________________
264  //
266  //
267 
268  fIsEventSelected=kFALSE;
269 
270  if (fDebug > 1) AliInfo("Init");
271 
272  PostData(3,fAnalCuts);
273 
274  return;
275 }
276 
277 //_________________________________________________
279 {
281  if (!fInputEvent) {
282  AliError("NO EVENT FOUND!");
283  return;
284  }
285 
286  AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(fInputEvent);
287 
288  if(fAODProtection>=0)
289  {
290  // Protection against different number of events in the AOD and deltaAOD
291  // In case of discrepancy the event is rejected.
292  Int_t matchingAODdeltaAODlevel = AliRDHFCuts::CheckMatchingAODdeltaAODevents();
293  if (matchingAODdeltaAODlevel<0 || (matchingAODdeltaAODlevel==0 && fAODProtection==1)) {
294  // AOD/deltaAOD trees have different number of entries || TProcessID do not match while it was required
295  fCEvents->Fill(19);
296  return;
297  }
298  }
299 
300  TClonesArray *arrayLctopKos=0;
301 
302  if (!aodEvent && AODEvent() && IsStandardAOD()) {
303  // In case there is an AOD handler writing a standard AOD, use the AOD
304  // event in memory rather than the input (ESD) event.
305  aodEvent = dynamic_cast<AliAODEvent*> (AODEvent());
306  // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
307  // have to taken from the AOD event hold by the AliAODExtension
308  AliAODHandler* aodHandler = (AliAODHandler*)
309  ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
310 
311  if (aodHandler->GetExtensions()) {
312  AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
313  AliAODEvent *aodFromExt = ext->GetAOD();
314  arrayLctopKos=(TClonesArray*)aodFromExt->GetList()->FindObject("CascadesHF");
315  }
316  } else {
317  arrayLctopKos=(TClonesArray*)aodEvent->GetList()->FindObject("CascadesHF");
318  }
319 
320  fCEvents->Fill(1);
321 
322  if (fUseMCInfo)
324 
325  // AOD primary vertex
326  fVtx1 = (AliAODVertex*)aodEvent->GetPrimaryVertex();
327  if (!fVtx1) return;
328 
329  fIsEventSelected = fAnalCuts->IsEventSelected(aodEvent); // better to initialize before CheckEventSelection call
330 
331  CheckEventSelection(aodEvent);
332 
333 
334  // fix for temporary bug in ESDfilter
335  fBzkG = (Double_t)aodEvent->GetMagneticField();
337  if (TMath::Abs(fBzkG)<0.001) return;
338  fCEvents->Fill(2);
339 
340  if (!arrayLctopKos) {
341  AliInfo("Could not find array of HF cascades, skipping the event");
342  return;
343  } else {
344  if (arrayLctopKos->GetEntriesFast()) {
345  AliInfo(Form("Found %d cascades",arrayLctopKos->GetEntriesFast()));
346  }
347  }
348  fCEvents->Fill(3);
349 
350  // mc analysis
351  TClonesArray *mcArray = 0;
352  AliAODMCHeader *mcHeader=0;
353 
354  if (fUseMCInfo) {
355  // MC array need for maching
356  mcArray = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(AliAODMCParticle::StdBranchName()));
357  if (!mcArray) {
358  AliError("Could not find Monte-Carlo in AOD");
359  return;
360  }
361  fCEvents->Fill(4); // in case of MC events
362 
363  // load MC header
364  mcHeader = (AliAODMCHeader*)aodEvent->GetList()->FindObject(AliAODMCHeader::StdBranchName());
365  if (!mcHeader) {
366  AliError("AliAnalysisTaskSELc2V0bachelor::UserExec: MC header branch not found!\n");
367  return;
368  }
369  fCEvents->Fill(5); // in case of MC events
370 
371  Double_t zMCVertex = mcHeader->GetVtxZ();
372  if (TMath::Abs(zMCVertex) > fAnalCuts->GetMaxVtxZ()) {
373  AliDebug(2,Form("Event rejected: abs(zVtxMC)=%f > fAnalCuts->GetMaxVtxZ()=%f",zMCVertex,fAnalCuts->GetMaxVtxZ()));
374  return;
375  } else {
376  fCEvents->Fill(17); // in case of MC events
377  }
378  }
379 
380  Int_t runnumber = aodEvent->GetRunNumber();
381  if (aodEvent->GetTriggerMask() == 0 && (runnumber >= 195344 && runnumber <= 195677)){
382  AliDebug(3,"Event rejected because of null trigger mask");
383  return;
384  }
385 
386  fCounter->StoreEvent(aodEvent,fAnalCuts,fUseMCInfo); // it is very important that it stays BEFORE any other event selection
387 
388  if (fVtx1->GetNContributors()>0) // this check is done in IsEventSelected
389  fCEvents->Fill(6);
390 
391  if ( !fIsEventSelected ) return; // don't take into account not selected events
392  fCEvents->Fill(7);
393 
395  MakeSingleAnalysisForSystK0SP(aodEvent,mcArray,fAnalCuts);
396  if(fDoSingleAnalysisForSystK0SP==2) return;
397  }
398 
400  DoEventMixing(aodEvent,mcArray,fAnalCuts);
401  }else if(fGenerateBGEventFromTracks==2){
402  DoRotationFromTrack(aodEvent,mcArray,fAnalCuts);
403  }
404 
405  fEventCounter++;
406 
407  Int_t nSelectedAnal = 0;
408  MakeAnalysisForLc2prK0S(aodEvent,arrayLctopKos,mcArray, nSelectedAnal, fAnalCuts);
409 
410  if (nSelectedAnal)
412 
413  fCounter->StoreCandidates(aodEvent,nSelectedAnal,kTRUE);
414  fCounter->StoreCandidates(aodEvent,nSelectedAnal,kFALSE);
415 
416  PostData(1,fOutput);
417  PostData(2,fCounter);
418  if (!fWriteVariableTree) {
419  PostData(4,fOutputAll);
420  PostData(5,fOutputPIDBach);
421  if (fTrackRotation)
422  PostData(6,fOutputPIDBachTR);
423  } else {
424  PostData(4,fVariablesTree);
425  }
426 
427  fIsEventSelected=kFALSE;
428 
429  return;
430 }
431 
432 //________________________________________ terminate ___________________________
434 {
435  // The Terminate() function is the last function to be called during
436  // a query. It always runs on the client, it can be used to present
437  // the results graphically or save the results to file.
438 
439  //AliInfo("Terminate","");
440  AliAnalysisTaskSE::Terminate();
441 
442  fOutput = dynamic_cast<TList*> (GetOutputData(1));
443  if (!fOutput) {
444  AliError("fOutput not available");
445  return;
446  }
447 
448  //fCEvents = dynamic_cast<TH1F*>(fOutput->FindObject("fCEvents"));
449  if (!fWriteVariableTree) {
450  fOutputAll = dynamic_cast<TList*> (GetOutputData(4));
451  if (!fOutputAll) {
452  AliError("fOutputAll not available");
453  return;
454  }
455 
456  fOutputPIDBach = dynamic_cast<TList*> (GetOutputData(5));
457  if (!fOutputPIDBach) {
458  AliError("fOutputPIDBach not available");
459  return;
460  }
461 
462  if (fTrackRotation) {
463  fOutputPIDBachTR = dynamic_cast<TList*> (GetOutputData(6));
464  if (!fOutputPIDBachTR) {
465  AliError("fOutputPIDBachTR not available");
466  return;
467  }
468  }
469 
470  } else {
471  fVariablesTree = dynamic_cast<TTree*> (GetOutputData(4));
472  if (!fVariablesTree) {
473  AliError("fVariablesTree not available");
474  return;
475  }
476  }
477 
478  return;
479 }
480 //___________________________________________________________________________
483  AliInfo(Form("CreateOutputObjects of task %s\n", GetName()));
484 
485  fOutput = new TList();
486  fOutput->SetOwner();
487  fOutput->SetName("chist0");
488  DefineGeneralHistograms(); // define general histograms
489  PostData(1,fOutput);
490 
491  fCounter = new AliNormalizationCounter("NormalizationCounter");
492  fCounter->Init();
493  PostData(2,fCounter);
494 
495  if (!fWriteVariableTree) {
496 
497  fOutputAll = new TList();
498  fOutputAll->SetOwner();
499  fOutputAll->SetName("listAll");
500 
501  fOutputPIDBach = new TList();
502  fOutputPIDBach->SetOwner();
503  fOutputPIDBach->SetName("listPIDBach");
504 
505  if (fTrackRotation) {
506  fOutputPIDBachTR = new TList();
507  fOutputPIDBachTR->SetOwner();
508  fOutputPIDBachTR->SetName("listPIDBachTR");
509  }
510 
511  DefineK0SHistos(); // define analysis histograms
512  if (fUseMCInfo && fCheckOrigin) DefineSignalHistosSeparatedPerOrigin(); // define analysis histograms for SNG separated for origin
513 
514  PostData(4,fOutputAll);
515  PostData(5,fOutputPIDBach);
516 
517  if (fTrackRotation)
518  PostData(6,fOutputPIDBachTR);
519 
520  }
521  else {
523  PostData(4,fVariablesTree);
524  }
525 
527  fNzVtxBins = 10;
528  for(Int_t i=0;i<11;i++){
529  fZvtxBins[i] = -10.+2.*(Double_t)i;
530  }
531 
532  fNCentBins = 10;
533  for(Int_t i=0;i<11;i++){
534  fCentBins[i] = 10.*(Double_t)i;
535  }
536 
538  fReservoirP.resize(fNOfPools,std::vector<std::vector<TVector *> > (fNumberOfEventsForMixing));
539  fNextResVec.resize(fNOfPools,0);
540  fReservoirsReady.resize(fNOfPools,kFALSE);
541 
542  for(Int_t s=0; s<fNOfPools; s++) {
543  for(Int_t k=0;k<fNumberOfEventsForMixing;k++){
544  fReservoirP[s][k].clear();
545  }
546  }
547  }else if(fGenerateBGEventFromTracks==2){
548  fNzVtxBins = 1;
549  fZvtxBins[0] = -10.; fZvtxBins[1] = 10.;
550  fNCentBins = 1;
551  fCentBins[0] = 0.; fCentBins[1] = 100.;
552  fNOfPools=1;
553  fReservoirP.resize(fNOfPools,std::vector<std::vector<TVector *> > (1));
554  fNextResVec.resize(fNOfPools,0);
555  fReservoirsReady.resize(fNOfPools,kFALSE);
556  fReservoirP[0][0].clear();
557  }
558 
559  return;
560 }
561 
562 //-------------------------------------------------------------------------------
563 void AliAnalysisTaskSELc2V0bachelor::MakeAnalysisForLc2prK0S(AliAODEvent *aodEvent,TClonesArray *arrayLctopKos,
564  TClonesArray *mcArray,
565  Int_t &nSelectedAnal,
566  AliRDHFCutsLctoV0 *cutsAnal)
567 {
568 
570 
571  Int_t pdgCand = 4122;
572  Int_t pdgDgLctoV0bachelor[2]={2212,310}; // always 1st bachelor, 2nd V0
573  Int_t pdgDgV0toDaughters[2]={211,211};
574 
575  // loop over cascades to search for candidates Lc->p+K0S
576  Int_t nCascades= arrayLctopKos->GetEntriesFast();
577  if (nCascades==0) {
578  AliInfo("Could not find cascades, skipping the event");
579  return;
580  }
582  for (Int_t iLctopK0S = 0; iLctopK0S<nCascades; iLctopK0S++) {
583 
584  ((TH1F*)(fOutput->FindObject("hCandidateSelection")))->Fill(0);
585 
586  // Lc candidates and K0S from Lc
587  AliAODRecoCascadeHF* lcK0Spr = dynamic_cast<AliAODRecoCascadeHF*>(arrayLctopKos->At(iLctopK0S));
588  if (!lcK0Spr) {
589  AliDebug(2,Form("Cascade %d doens't exist, skipping",iLctopK0S));
590  continue;
591  }
592 
593  if (!(lcK0Spr->CheckCascadeFlags())) {
594  AliDebug(2,Form("Cascade %d is not flagged as Lc candidate",iLctopK0S));
595  continue;
596  }
597 
598  Bool_t unsetvtx=kFALSE;
599  if (!lcK0Spr->GetOwnPrimaryVtx()) {
600  lcK0Spr->SetOwnPrimaryVtx(fVtx1);
601  unsetvtx=kTRUE;
602  }
603 
604  if(!vHF->FillRecoCasc(aodEvent,lcK0Spr,kFALSE)){//Fill the data members of the candidate only if they are empty.
605  fCEvents->Fill(18);//monitor how often this fails
606  continue;
607  }
608  if (fReconstructSecVtx) {
609  if (!(vHF->RecoSecondaryVertexForCascades(aodEvent, lcK0Spr))) {
610  continue;
611  }
612  }
613  if (!lcK0Spr->GetSecondaryVtx()) {
614  AliInfo("No secondary vertex"); // it will be done in AliRDHFCutsLctoV0::IsSelected
615  continue;
616  }
617 
618  if (lcK0Spr->GetNDaughters()!=2) {
619  AliDebug(2,Form("Cascade %d has not 2 daughters (nDaughters=%d)",iLctopK0S,lcK0Spr->GetNDaughters())); // it will be done in AliRDHFCutsLctoV0::IsSelected
620  continue;
621  }
622 
623  if ( (fSign == 0 && lcK0Spr->Charge()<0) ||
624  (fSign == 1 && lcK0Spr->Charge()>0) ) {
625  AliDebug(2,Form("Charge of the cascade %d is different with respect to the required one",iLctopK0S)); //
626  continue;
627  }
628 
629  AliAODv0 * v0part = dynamic_cast<AliAODv0*>(lcK0Spr->Getv0());
630  AliAODTrack * bachPart = dynamic_cast<AliAODTrack*>(lcK0Spr->GetBachelor());
631  if (!v0part || !bachPart) {
632  AliDebug(2,Form("Cascade %d has no V0 or no bachelor object",iLctopK0S)); // it will be done in AliRDHFCutsLctoV0::IsSelected
633  continue;
634  }
635 
636  if (!v0part->GetSecondaryVtx()) {
637  AliDebug(2,Form("No secondary vertex for V0 by cascade %d",iLctopK0S)); // it will be done in AliRDHFCutsLctoV0::IsSelected
638  continue;
639  }
640 
641  if (v0part->GetNDaughters()!=2) {
642  AliDebug(2,Form("current V0 has not 2 daughters (onTheFly=%d, nDaughters=%d)",v0part->GetOnFlyStatus(),v0part->GetNDaughters())); // it will be done in AliRDHFCutsLctoV0::IsSelected
643  continue;
644  }
645 
646  AliAODTrack * v0Pos = dynamic_cast<AliAODTrack*>(lcK0Spr->Getv0PositiveTrack());
647  AliAODTrack * v0Neg = dynamic_cast<AliAODTrack*>(lcK0Spr->Getv0NegativeTrack());
648  if (!v0Neg || !v0Pos) {
649  AliDebug(2,Form("V0 by cascade %d has no V0positive of V0negative object",iLctopK0S)); // it will be done in AliRDHFCutsLctoV0::IsSelected
650  continue;
651  }
652 
653  ((TH1F*)(fOutput->FindObject("hCandidateSelection")))->Fill(1);
654 
655  if (v0Pos->Charge() == v0Neg->Charge()) continue;
656 
657  ((TH1F*)(fOutput->FindObject("hCandidateSelection")))->Fill(2);
658 
659  Int_t isLc = 0;
660  Int_t originLc = -1; // -1 -> RD; 0 -> BKG; 1 -> form c; 2 -> from b; 3 -> not from quark
661 
662  if (fUseMCInfo) {
663 
664  Int_t pdgCode=-2;
665 
666  // find associated MC particle for Lc -> p+K0 and K0S->pi+pi
667  Int_t mcLabel = lcK0Spr->MatchToMC(pdgCand,pdgDgLctoV0bachelor[1],pdgDgLctoV0bachelor,pdgDgV0toDaughters,mcArray,kTRUE);
668  if (mcLabel!=-1) {
669  AliDebug(2,Form(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~cascade number %d (total cascade number = %d)", iLctopK0S,nCascades));
670 
671  AliAODMCParticle *partLc = dynamic_cast<AliAODMCParticle*>(mcArray->At(mcLabel));
672  if (partLc) {
673  pdgCode = partLc->GetPdgCode();
674  if (pdgCode<0) AliDebug(2,Form(" ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ MClabel=%d ~~~~~~~~~~ pdgCode=%d", mcLabel, pdgCode));
675  pdgCode = TMath::Abs(pdgCode);
676  isLc = 1;
678  Int_t pdgMom = util->CheckOrigin(mcArray,partLc,kFALSE);
679  if (pdgMom == 4) {
680  originLc=1; // from c
681  } else if (pdgMom == 5) {
682  originLc=2; // form b
683  } else {
684  Int_t isThereaQuark=util->CheckOrigin(mcArray,partLc,kTRUE);
685  if (isThereaQuark<=0) originLc=3; // not from q
686  }
687  delete util;
688  }
689  } else {
690  AliDebug(2,Form("No MC candidate (cascade number %d -total cascade number = %d -)", iLctopK0S,nCascades));
691  pdgCode=-1;
692  }
693  } else {
694  originLc=-1; // real data
695  }
696 
697  FillLc2pK0Sspectrum(lcK0Spr, isLc,
698  nSelectedAnal, cutsAnal,
699  mcArray, originLc);
700 
701  if (unsetvtx) lcK0Spr->UnsetOwnPrimaryVtx();
702 
703  }
704 
705  delete vHF;
706  AliDebug(2, Form("Found %d Reco particles that are Lc!!", nSelectedAnal));
707 
708  return;
709 }
710 
711 //________________________________________________________________________
713  Int_t isLc,
714  Int_t &nSelectedAnal,
715  AliRDHFCutsLctoV0 *cutsAnal,
716  TClonesArray *mcArray,
717  Int_t originLc)
718 {
719  //
721  //
722 
723  TString fillthis="";
724 
725  AliAODTrack *bachelor = (AliAODTrack*)part->GetBachelor();
726  Double_t momBach = bachelor->P();
727 
728  AliAODv0 * v0part = (AliAODv0*)part->Getv0();
729  Bool_t onFlyV0 = v0part->GetOnFlyStatus(); // on-the-flight V0s
730 
731  Bool_t areCutsUsingPID = cutsAnal->GetIsUsePID();
732  cutsAnal->SetUsePID(kFALSE);
733  Bool_t isInCascadeWindow = (((cutsAnal->IsSelectedSingleCut(part,AliRDHFCuts::kCandidate,0))&(AliRDHFCutsLctoV0::kLcToK0Spr))==(AliRDHFCutsLctoV0::kLcToK0Spr)); // cut on Lc->p+K0S invMass
734  cutsAnal->SetUsePID(areCutsUsingPID);
735 
736  if ( onFlyV0 && !fUseOnTheFlyV0 ) return;
737 
739 
740  // track rotation
741  if (fTrackRotation) {
742  if (onFlyV0) {
743  TrackRotation(cutsAnal,part,"");
744  }
745  else {
746  TrackRotation(cutsAnal,part,"Offline");
747  }
748  if (fUseMCInfo) {
749  if (isLc==1) {
750  if (onFlyV0) {
751  TrackRotation(cutsAnal,part,"Sgn");
752  }
753  else {
754  TrackRotation(cutsAnal,part,"OfflineSgn");
755  }
756  }// sgn
757  else { // bkg
758  if (onFlyV0) {
759  TrackRotation(cutsAnal,part,"Bkg");
760  }
761  else {
762  TrackRotation(cutsAnal,part,"OfflineBkg");
763  }
764  }
765  } // if fUseMCInfo
766  } // if fTrackRotation
767 
768 
769 
770 
771  if ( !(cutsAnal->IsInFiducialAcceptance(part->Pt(),part->Y(4122))) ) return;
772 
774 
775  if ( ( ( (cutsAnal->IsSelected(part,AliRDHFCuts::kAll))&(AliRDHFCutsLctoV0::kLcToK0Spr)) == (AliRDHFCutsLctoV0::kLcToK0Spr) ) ) nSelectedAnal++;
776 
777  // Fill candidate variable Tree (track selection, V0 invMass selection)
778  if ( fWriteVariableTree ) {
779  Double_t invmassK0S = v0part->MassK0Short();
780  Double_t mk0sPDG = TDatabasePDG::Instance()->GetParticle(310)->Mass();
781  Double_t nSigmaTPCpr=-999.;
782  cutsAnal->GetPidHF()->GetnSigmaTPC(bachelor,4,nSigmaTPCpr);
783  if ( !onFlyV0 && isInCascadeWindow &&
784  part->CosV0PointingAngle()>0.99 && TMath::Abs(invmassK0S-mk0sPDG)<=0.05 &&
785  part->Pt()>=fPtMinToFillTheTree && part->Pt()<fPtMaxToFillTheTree &&
786  (!fUseTPCPIDtoFillTree || (fUseTPCPIDtoFillTree && TMath::Abs(nSigmaTPCpr)<cutsAnal->GetNTPCSigmaCutForPreselection())))
787  FillTheTree(part,cutsAnal,mcArray,isLc,originLc);
788  return;
789  }
790 
791  cutsAnal->SetUsePID(kFALSE);
792  Bool_t isCandidateSelectedCuts = (((cutsAnal->IsSelected(part,AliRDHFCuts::kCandidate))&(AliRDHFCutsLctoV0::kLcToK0Spr))==(AliRDHFCutsLctoV0::kLcToK0Spr)); // kinematic/topological cuts
793  cutsAnal->SetUsePID(areCutsUsingPID);
794  Bool_t isBachelorID = (((cutsAnal->IsSelected(part,AliRDHFCuts::kPID))&(AliRDHFCutsLctoV0::kLcToK0Spr))==(AliRDHFCutsLctoV0::kLcToK0Spr)); // ID x bachelor
795 
796  //if (((cutsAnal->IsSelected(part,AliRDHFCuts::kCandidate))&(AliRDHFCutsLctoV0::kLcToK0Spr))==(AliRDHFCutsLctoV0::kLcToK0Spr)) {
798  if (fUseMCInfo && isLc && !fWriteVariableTree) {
799  Int_t pdgCand1 = 4122;
800  Int_t pdgDgLctoV0bachelor1[2]={2212,310};
801  Int_t pdgDgV0toDaughters1[2]={211,211};
802  Int_t mcLabel1=part->MatchToMC(pdgCand1,pdgDgLctoV0bachelor1[1],pdgDgLctoV0bachelor1,pdgDgV0toDaughters1,mcArray,kTRUE);
803  AliDebug(2,Form(" Found true MC candidate: Lc->pK0S(%d) - onTheFly=%1d",mcLabel1,onFlyV0));
804  }
805  }
806 
807  Double_t nSigmaTPCpr=-999.;
808  cutsAnal->GetPidHF()->GetnSigmaTPC(bachelor,4,nSigmaTPCpr);
809  Double_t nSigmaTOFpr=-999.;
810  cutsAnal->GetPidHF()->GetnSigmaTOF(bachelor,4,nSigmaTOFpr);
811 
812  Double_t nSigmaTPCpi=-999.;
813  cutsAnal->GetPidHF()->GetnSigmaTPC(bachelor,2,nSigmaTPCpi);
814  Double_t nSigmaTOFpi=-999.;
815  cutsAnal->GetPidHF()->GetnSigmaTOF(bachelor,2,nSigmaTOFpi);
816 
817  Double_t nSigmaTPCka=-999.;
818  cutsAnal->GetPidHF()->GetnSigmaTPC(bachelor,3,nSigmaTPCka);
819  Double_t nSigmaTOFka=-999.;
820  cutsAnal->GetPidHF()->GetnSigmaTOF(bachelor,3,nSigmaTOFka);
821 
822  if (onFlyV0) {
823 
824  fillthis="histArmPodK0S";
825  FillArmPodDistribution(v0part,fillthis,isCandidateSelectedCuts,isBachelorID);
826 
827  fillthis="histArmPodLc";
828  FillArmPodDistribution(part,fillthis,isCandidateSelectedCuts,isBachelorID);
829 
830  //if (isCandidateSelectedCuts) {
831  FillAnalysisHistograms(part,cutsAnal,"");
832  //}
833  }
834  else {
835 
836  fillthis="histArmPodK0SOffline";
837  FillArmPodDistribution(v0part,fillthis,isCandidateSelectedCuts,isBachelorID);
838 
839  fillthis="histArmPodLcOffline";
840  FillArmPodDistribution(part,fillthis,isCandidateSelectedCuts,isBachelorID);
841 
842  FillAnalysisHistograms(part,cutsAnal,"Offline");
843  if (isCandidateSelectedCuts) {
844  fillthis="histoprotonBachSigmaVspTOF";
845  ((TH2F*)(fOutput->FindObject(fillthis)))->Fill(momBach,nSigmaTOFpr);
846  fillthis="histoprotonBachSigmaVspTPC";
847  ((TH2F*)(fOutput->FindObject(fillthis)))->Fill(momBach,nSigmaTPCpr);
848  //FillAnalysisHistograms(part,cutsAnal,"Offline");
849  }
850  }
851  if (fUseMCInfo) {
852  if (isLc==1) {
853  if (onFlyV0) {
854 
855  fillthis="histArmPodK0SSgn";
856  FillArmPodDistribution(v0part,fillthis,isCandidateSelectedCuts,isBachelorID);
857 
858  fillthis="histArmPodLcSgn";
859  FillArmPodDistribution(part,fillthis,isCandidateSelectedCuts,isBachelorID);
860 
861  //if (isCandidateSelectedCuts) {
862  FillAnalysisHistograms(part,cutsAnal,"Sgn");
863  //}
864  if (fCheckOrigin) {
865  switch (originLc) {
866  case 1:
867  FillAnalysisHistograms(part,cutsAnal,"SgnC");
868  break;
869  case 2:
870  FillAnalysisHistograms(part,cutsAnal,"SgnB");
871  break;
872  case 3:
873  FillAnalysisHistograms(part,cutsAnal,"SgnNoQ");
874  break;
875  }
876  }
877  }
878  else {
879 
880  fillthis="histArmPodK0SOfflineSgn";
881  FillArmPodDistribution(v0part,fillthis,isCandidateSelectedCuts,isBachelorID);
882 
883  fillthis="histArmPodLcOfflineSgn";
884  FillArmPodDistribution(part,fillthis,isCandidateSelectedCuts,isBachelorID);
885 
886  if (isCandidateSelectedCuts) {
887  fillthis="histoprotonBachSigmaVspTOFsgn";
888  ((TH2F*)(fOutput->FindObject(fillthis)))->Fill(momBach,nSigmaTOFpr);
889  fillthis="histoprotonBachSigmaVspTPCsgn";
890  ((TH2F*)(fOutput->FindObject(fillthis)))->Fill(momBach,nSigmaTPCpr);
891  //FillAnalysisHistograms(part,cutsAnal,"OfflineSgn");
892  }
893 
894  if (fCheckOrigin) {
895  switch (originLc) {
896  case 1:
897  FillAnalysisHistograms(part,cutsAnal,"OfflineSgnC");
898  break;
899  case 2:
900  FillAnalysisHistograms(part,cutsAnal,"OfflineSgnB");
901  break;
902  case 3:
903  FillAnalysisHistograms(part,cutsAnal,"OfflineSgnNoQ");
904  break;
905  }
906  }
907  FillAnalysisHistograms(part,cutsAnal,"OfflineSgn");
908 
909  }
910  }// sgn
911  else { // bkg
912  if (onFlyV0) {
913 
914  fillthis="histArmPodK0SBkg";
915  FillArmPodDistribution(v0part,fillthis,isCandidateSelectedCuts,isBachelorID);
916 
917  fillthis="histArmPodLcBkg";
918  FillArmPodDistribution(part,fillthis,isCandidateSelectedCuts,isBachelorID);
919 
920  //if (isCandidateSelectedCuts) {
921  FillAnalysisHistograms(part,cutsAnal,"Bkg");
922  //}
923  }
924  else {
925 
926  fillthis="histArmPodK0SOfflineBkg";
927  FillArmPodDistribution(v0part,fillthis,isCandidateSelectedCuts,isBachelorID);
928 
929  fillthis="histArmPodLcOfflineBkg";
930  FillArmPodDistribution(part,fillthis,isCandidateSelectedCuts,isBachelorID);
931 
932  FillAnalysisHistograms(part,cutsAnal,"OfflineBkg");
933  if (isCandidateSelectedCuts) {
934  fillthis="histoprotonBachSigmaVspTOFbkg";
935  ((TH2F*)(fOutput->FindObject(fillthis)))->Fill(momBach,nSigmaTOFpr);
936  fillthis="histoprotonBachSigmaVspTPCbkg";
937  ((TH2F*)(fOutput->FindObject(fillthis)))->Fill(momBach,nSigmaTPCpr);
938  //FillAnalysisHistograms(part,cutsAnal,"OfflineBkg");
939  }
940  }
941  }
942  } // if fUseMCInfo
943 
944  return;
945 }
946 
947 //----------------------------------------------------
949 {
950 
951  Double_t mLcPDG = TDatabasePDG::Instance()->GetParticle(4122)->Mass();
952  Double_t mK0SPDG = TDatabasePDG::Instance()->GetParticle(310)->Mass();
953  Double_t mMinLambdaPDG = TDatabasePDG::Instance()->GetParticle(2212)->Mass()+
954  TDatabasePDG::Instance()->GetParticle(211)->Mass();
955  Double_t mLPDG = TDatabasePDG::Instance()->GetParticle(3122)->Mass();
956 
957  TString nameHisto=" ", nameHistoSgn=" ", nameHistoBkg=" ";
958  TString titleHisto=" ", titleHistoSgn=" ", titleHistoBkg=" ";
959 
960  // pt(Lc)
961  Double_t *binLimpTLc=new Double_t[11+1]; // 11 pT(Lc) bins
962  binLimpTLc[ 0]= 0.;
963  binLimpTLc[ 1]= 1.;
964  binLimpTLc[ 2]= 2.;
965  binLimpTLc[ 3]= 3.;
966  binLimpTLc[ 4]= 4.;
967  binLimpTLc[ 5]= 5.;
968  binLimpTLc[ 6]= 6.;
969  binLimpTLc[ 7]= 8.;
970  binLimpTLc[ 8]=12.;
971  binLimpTLc[ 9]=17.;
972  binLimpTLc[10]=25.;
973  binLimpTLc[11]=35.;
974 
975  // pt(prong)
976  Double_t *binLimpTprong=new Double_t[41+1]; // 41 pT(prong) bins
977  binLimpTprong[ 0]= 0.0;
978  binLimpTprong[ 1]= 0.1;
979  binLimpTprong[ 2]= 0.2;
980  binLimpTprong[ 3]= 0.3;
981  binLimpTprong[ 4]= 0.4;
982  binLimpTprong[ 5]= 0.5;
983  binLimpTprong[ 6]= 0.6;
984  binLimpTprong[ 7]= 0.7;
985  binLimpTprong[ 8]= 0.8;
986  binLimpTprong[ 9]= 0.9;
987  binLimpTprong[10]= 1.0;
988  binLimpTprong[11]= 1.2;
989  binLimpTprong[12]= 1.4;
990  binLimpTprong[13]= 1.6;
991  binLimpTprong[14]= 1.8;
992  binLimpTprong[15]= 2.0;
993  binLimpTprong[16]= 2.2;
994  binLimpTprong[17]= 2.4;
995  binLimpTprong[18]= 2.6;
996  binLimpTprong[19]= 2.8;
997  binLimpTprong[20]= 3.0;
998  binLimpTprong[21]= 3.5;
999  binLimpTprong[22]= 4.0;
1000  binLimpTprong[23]= 4.5;
1001  binLimpTprong[24]= 5.0;
1002  binLimpTprong[25]= 5.5;
1003  binLimpTprong[26]= 6.0;
1004  binLimpTprong[27]= 6.5;
1005  binLimpTprong[28]= 7.0;
1006  binLimpTprong[29]= 7.5;
1007  binLimpTprong[30]= 8.0;
1008  binLimpTprong[31]= 9.0;
1009  binLimpTprong[32]=10.0;
1010  binLimpTprong[33]=11.0;
1011  binLimpTprong[34]=12.0;
1012  binLimpTprong[35]=13.0;
1013  binLimpTprong[36]=14.0;
1014  binLimpTprong[37]=15.0;
1015  binLimpTprong[38]=20.0;
1016  binLimpTprong[39]=25.0;
1017  binLimpTprong[40]=30.0;
1018  binLimpTprong[41]=35.0;
1019 
1020  if (fUseOnTheFlyV0) {
1021 
1022  // V0 invariant masses (on-the-fly)
1023  nameHisto="histK0SMass";
1024  titleHisto="K^{0}_{S} invariant mass VS p_{T}; p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(#pi^{+},#pi^{-}) [GeV/c^{2}]; Entries";
1025  TH2F* spectrumK0SMass = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,1000,mK0SPDG-0.050,mK0SPDG+0.050);
1026 
1027  // Lc invariant masses (x K0S on-the-fly)
1028  nameHisto="histLcMassByK0S";
1029  titleHisto="#Lambda_{c} invariant mass (by K^{0}_{S}) vs p_{T}; m_{inv}(p,K^{0}_{S}) [GeV/c^{2}]; p_{T}(#Lambda_{c}) [GeV/c]";
1030  TH2F* spectrumLcMassByK0S = new TH2F(nameHisto.Data(),titleHisto.Data(),1000,mLcPDG-0.250,mLcPDG+0.250,11,binLimpTLc);
1031 
1032  nameHisto="histpK0Svsp";
1033  titleHisto="p(K^{0}_{S}) vs p(p); p(p) [GeV/c]; p(K^{0}_{S}) [GeV/c]";
1034  TH2F* momentumDistributionK0Svsp = new TH2F(nameHisto.Data(),titleHisto.Data(),41,binLimpTprong,41,binLimpTprong);
1035 
1036  nameHisto="histArmPodK0S";
1037  titleHisto="V0-candidate Armenteros-Podolanski distribution; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1038  TH2F* armenterosPodK0S = new TH2F(nameHisto.Data(),titleHisto.Data(),200,-1.,1.,300,0.,0.3);
1039 
1040  nameHisto="histArmPodLc";
1041  titleHisto="#Lambda_{c}-candidate Armenteros-Podolanski distribution; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1042  TH2F* armenterosPodLc = new TH2F(nameHisto.Data(),titleHisto.Data(),200,-4.,4.,800,0.,1.6);
1043 
1044  TH2F* allspectrumK0SMass = (TH2F*)spectrumK0SMass->Clone();
1045  TH2F* allspectrumLcMassByK0S = (TH2F*)spectrumLcMassByK0S->Clone();
1046  TH2F* allmomentumDistributionK0Svsp = (TH2F*)momentumDistributionK0Svsp->Clone();
1047  TH2F* allArmenterosPodK0S = (TH2F*)armenterosPodK0S->Clone();
1048  TH2F* allArmenterosPodLc = (TH2F*)armenterosPodLc->Clone();
1049 
1050  TH2F* pidBachspectrumK0SMass = (TH2F*)spectrumK0SMass->Clone();
1051  TH2F* pidBachspectrumLcMassByK0S = (TH2F*)spectrumLcMassByK0S->Clone();
1052  TH2F* pidBachmomentumDistributionK0Svsp = (TH2F*)momentumDistributionK0Svsp->Clone();
1053  TH2F* pidBachArmenterosPodK0S = (TH2F*)armenterosPodK0S->Clone();
1054  TH2F* pidBachArmenterosPodLc = (TH2F*)armenterosPodLc->Clone();
1055 
1056  fOutputAll->Add(allspectrumK0SMass);
1057  fOutputAll->Add(allspectrumLcMassByK0S);
1058  fOutputAll->Add(allmomentumDistributionK0Svsp);
1059  fOutputAll->Add(allArmenterosPodK0S);
1060  fOutputAll->Add(allArmenterosPodLc);
1061 
1062  fOutputPIDBach->Add(pidBachspectrumK0SMass);
1063  fOutputPIDBach->Add(pidBachspectrumLcMassByK0S);
1064  fOutputPIDBach->Add(pidBachmomentumDistributionK0Svsp);
1065  fOutputPIDBach->Add(pidBachArmenterosPodK0S);
1066  fOutputPIDBach->Add(pidBachArmenterosPodLc);
1067 
1068  nameHisto="histArmPodK0S0";
1069  titleHisto="V0-candidate Armenteros-Podolanski distribution; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1070  TH2F* armenterosPodK0S0 = new TH2F(nameHisto.Data(),titleHisto.Data(),200,-1.,1.,300,0.,0.3);
1071  nameHisto="histArmPodLc0";
1072  titleHisto="#Lambda_{c}-candidate Armenteros-Podolanski distribution; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1073  TH2F* armenterosPodLc0 = new TH2F(nameHisto.Data(),titleHisto.Data(),200,-4.,4.,800,0.,1.6);
1074  fOutputAll->Add(armenterosPodK0S0);
1075  fOutputAll->Add(armenterosPodLc0);
1076 
1077 
1078  if (fTrackRotation) {
1079  TH2F* pidBachTRspectrumLcMassByK0S = (TH2F*)spectrumLcMassByK0S->Clone();
1080  fOutputPIDBachTR->Add(pidBachTRspectrumLcMassByK0S);
1081  }
1082 
1083 
1084 
1085  nameHisto="histptK0S";
1086  titleHisto="p_{T}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(K^{0}_{S}) [GeV/c]; Entries";
1087  TH2F* ptK0S = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,41,binLimpTprong);
1088 
1089  nameHisto="histptP";
1090  titleHisto="p_{T}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(p) [GeV/c]; Entries";
1091  TH2F* ptP = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,41,binLimpTprong);
1092 
1093  nameHisto="histptPip";
1094  titleHisto="p_{T}(#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{+}) [GeV/c]; Entries";
1095  TH2F* ptPiP = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,41,binLimpTprong);
1096 
1097  nameHisto="histptPim";
1098  titleHisto="p_{T}(#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{-}) [GeV/c]; Entries";
1099  TH2F* ptPiM = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,41,binLimpTprong);
1100 
1101  nameHisto="histLambdaMass";
1102  titleHisto="m_{inv}(p,#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(p,#pi^{-}) [GeV/c^{2}]; Entries";
1103  TH2F* massLambda = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,1000,mMinLambdaPDG,mMinLambdaPDG+0.5);
1104 
1105  nameHisto="histLambdaBarMass";
1106  titleHisto="m_{inv}(#bar{p},#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(#bar{p},#pi^{+}) [GeV/c^{2}]; Entries";
1107  TH2F* massLambdaBar = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,1000,mMinLambdaPDG,mMinLambdaPDG+0.5);
1108 
1109  nameHisto="histGammaMass";
1110  titleHisto="m_{inv}(e^{+},e^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(e^{+},e^{-}) [GeV/c^{2}]; Entries";
1111  TH2F* massGamma = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,100,0.,1.);
1112 
1113  nameHisto="histD0K0S";
1114  titleHisto="d_{0}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(K^{0}_{S}) [#sigmas]; Entries";
1115  TH2F* d0K0S = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,1000,-1.,1.);
1116 
1117  nameHisto="histD0P";
1118  titleHisto="d_{0}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(p) [cm]; Entries";
1119  TH2F* d0P = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,1000,-1.,1.);
1120 
1121  nameHisto="histCosPAK0S";
1122  titleHisto="K^{0}_{S} cosine of pointing angle wrt primary vertex vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
1123  TH2F *cosPAK0S = new TH2F(nameHisto.Data(),titleHisto.Data(),41,binLimpTprong,100,0.99,1.);
1124 
1125  nameHisto="histCosThetaProtonCMS";
1126  titleHisto="cosien of proton emission angle in Lc rest frame; p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
1127  TH2F *cosThePr = new TH2F(nameHisto.Data(),titleHisto.Data(),41,binLimpTprong,100,-1.,1.);
1128 
1129  nameHisto="histResignedD0";
1130  titleHisto="Proton d0 with different sign convention; p_{T}(#Lambda_{c}) [GeV/c]; d0 [cm]; Entries";
1131  TH2F *resignedD0 = new TH2F(nameHisto.Data(),titleHisto.Data(),41,binLimpTprong,100,-0.1,0.1);
1132 
1133  TH2F* allptK0S = (TH2F*)ptK0S->Clone();
1134  TH2F* allptP = (TH2F*)ptP->Clone();
1135  TH2F* allptPiP = (TH2F*)ptPiP->Clone();
1136  TH2F* allptPiM = (TH2F*)ptPiM->Clone();
1137  TH2F* allmassLambda = (TH2F*)massLambda->Clone();
1138  TH2F* allmassLambdaBar = (TH2F*)massLambdaBar->Clone();
1139  TH2F* allmassGamma = (TH2F*)massGamma->Clone();
1140  TH2F* alld0K0S = (TH2F*)d0K0S->Clone();
1141  TH2F* alld0P = (TH2F*)d0P->Clone();
1142  TH2F* allcosPAK0S = (TH2F*)cosPAK0S->Clone();
1143  TH2F* allcosThePr = (TH2F*)cosThePr->Clone();
1144  TH2F* allresignedD0 = (TH2F*)resignedD0->Clone();
1145 
1146  TH2F* pidptK0S = (TH2F*)ptK0S->Clone();
1147  TH2F* pidptP = (TH2F*)ptP->Clone();
1148  TH2F* pidptPiP = (TH2F*)ptPiP->Clone();
1149  TH2F* pidptPiM = (TH2F*)ptPiM->Clone();
1150  TH2F* pidmassLambda = (TH2F*)massLambda->Clone();
1151  TH2F* pidmassLambdaBar = (TH2F*)massLambdaBar->Clone();
1152  TH2F* pidmassGamma = (TH2F*)massGamma->Clone();
1153  TH2F* pidd0K0S = (TH2F*)d0K0S->Clone();
1154  TH2F* pidd0P = (TH2F*)d0P->Clone();
1155  TH2F* pidcosPAK0S = (TH2F*)cosPAK0S->Clone();
1156  TH2F* pidcosThePr = (TH2F*)cosThePr->Clone();
1157  TH2F* pidresignedD0 = (TH2F*)resignedD0->Clone();
1158 
1159  fOutputAll->Add(allptK0S);
1160  fOutputAll->Add(allptP);
1161  fOutputAll->Add(allptPiP);
1162  fOutputAll->Add(allptPiM);
1163  fOutputAll->Add(allmassLambda);
1164  fOutputAll->Add(allmassLambdaBar);
1165  fOutputAll->Add(allmassGamma);
1166  fOutputAll->Add(alld0K0S);
1167  fOutputAll->Add(alld0P);
1168  fOutputAll->Add(allcosPAK0S);
1169  fOutputAll->Add(allcosThePr);
1170  fOutputAll->Add(allresignedD0);
1171 
1172  fOutputPIDBach->Add(pidptK0S);
1173  fOutputPIDBach->Add(pidptP);
1174  fOutputPIDBach->Add(pidptPiP);
1175  fOutputPIDBach->Add(pidptPiM);
1176  fOutputPIDBach->Add(pidmassLambda);
1177  fOutputPIDBach->Add(pidmassLambdaBar);
1178  fOutputPIDBach->Add(pidmassGamma);
1179  fOutputPIDBach->Add(pidd0K0S);
1180  fOutputPIDBach->Add(pidd0P);
1181  fOutputPIDBach->Add(pidcosPAK0S);
1182  fOutputPIDBach->Add(pidcosThePr);
1183  fOutputPIDBach->Add(pidresignedD0);
1184 
1185  if (fTrackRotation) {
1186 
1187  TH2F* pidTRptK0S = (TH2F*)ptK0S->Clone();
1188  TH2F* pidTRptP = (TH2F*)ptP->Clone();
1189  TH2F* pidTRptPiP = (TH2F*)ptPiP->Clone();
1190  TH2F* pidTRptPiM = (TH2F*)ptPiM->Clone();
1191  TH2F* pidTRmassLambda = (TH2F*)massLambda->Clone();
1192  TH2F* pidTRmassLambdaBar = (TH2F*)massLambdaBar->Clone();
1193  TH2F* pidTRmassGamma = (TH2F*)massGamma->Clone();
1194  TH2F* pidTRcosPAK0S = (TH2F*)cosPAK0S->Clone();
1195  TH2F* pidTRcosThePr = (TH2F*)cosThePr->Clone();
1196  TH2F* pidTRresignedD0 = (TH2F*)resignedD0->Clone();
1197  fOutputPIDBachTR->Add(pidTRptK0S);
1198  fOutputPIDBachTR->Add(pidTRptP);
1199  fOutputPIDBachTR->Add(pidTRptPiP);
1200  fOutputPIDBachTR->Add(pidTRptPiM);
1201  fOutputPIDBachTR->Add(pidTRmassLambda);
1202  fOutputPIDBachTR->Add(pidTRmassLambdaBar);
1203  fOutputPIDBachTR->Add(pidTRmassGamma);
1204  fOutputPIDBachTR->Add(pidTRcosPAK0S);
1205  fOutputPIDBachTR->Add(pidTRcosThePr);
1206  fOutputPIDBachTR->Add(pidTRresignedD0);
1207 
1208  }
1209 
1210  }
1211 
1212  // V0 invariant masses (offline)
1213  nameHisto="histK0SMassOffline";
1214  titleHisto="K^{0}_{S} invariant mass VS p_{T}; p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(#pi^{+},#pi^{-}) [GeV/c^{2}]; Entries";
1215  TH2F* spectrumK0SMassOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,1000,mK0SPDG-0.050,mK0SPDG+0.050);
1216 
1217  // Lc invariant masses (x K0S offline)
1218  nameHisto="histLcMassByK0SOffline";
1219  titleHisto="#Lambda_{c} invariant mass (by K^{0}_{S}) vs p_{T}; m_{inv}(p,K^{0}_{S}) [GeV/c^{2}]; p_{T}(#Lambda_{c}) [GeV/c]";
1220  TH2F* spectrumLcMassOfflineByK0S = new TH2F(nameHisto.Data(),titleHisto.Data(),1000,mLcPDG-0.250,mLcPDG+0.250,11,binLimpTLc);
1221 
1222  nameHisto="histpK0SvspOffline";
1223  titleHisto="p(K^{0}_{S}) vs p(p); p(p) [GeV/c]; p(K^{0}_{S}) [GeV/c]";
1224  TH2F* momentumDistributionK0SvspOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),41,binLimpTprong,41,binLimpTprong);
1225 
1226  nameHisto="histArmPodK0SOffline";
1227  titleHisto="V0-candidate Armenteros-Podolanski distribution; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1228  TH2F* armenterosPodK0SOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),200,-1.,1.,300,0.,0.3);
1229 
1230  nameHisto="histArmPodLcOffline";
1231  titleHisto="#Lambda_{c}-candidate Armenteros-Podolanski distribution; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1232  TH2F* armenterosPodLcOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),200,-4.,4.,800,0.,1.6);
1233 
1234  TH2F* allspectrumK0SMassOffline = (TH2F*)spectrumK0SMassOffline->Clone();
1235  TH2F* allspectrumLcMassOfflineByK0S = (TH2F*)spectrumLcMassOfflineByK0S->Clone();
1236  TH2F* allmomentumDistributionK0SvspOffline = (TH2F*)momentumDistributionK0SvspOffline->Clone();
1237  TH2F* allArmenterosPodK0SOffline = (TH2F*)armenterosPodK0SOffline->Clone();
1238  TH2F* allArmenterosPodLcOffline = (TH2F*)armenterosPodLcOffline->Clone();
1239 
1240  TH2F* pidBachspectrumK0SMassOffline = (TH2F*)spectrumK0SMassOffline->Clone();
1241  TH2F* pidBachspectrumLcMassOfflineByK0S = (TH2F*)spectrumLcMassOfflineByK0S->Clone();
1242  TH2F* pidBachmomentumDistributionK0SvspOffline = (TH2F*)momentumDistributionK0SvspOffline->Clone();
1243  TH2F* pidBachArmenterosPodK0SOffline = (TH2F*)armenterosPodK0SOffline->Clone();
1244  TH2F* pidBachArmenterosPodLcOffline = (TH2F*)armenterosPodLcOffline->Clone();
1245 
1246  fOutputAll->Add(allspectrumK0SMassOffline);
1247  fOutputAll->Add(allspectrumLcMassOfflineByK0S);
1248  fOutputAll->Add(allmomentumDistributionK0SvspOffline);
1249  fOutputAll->Add(allArmenterosPodK0SOffline);
1250  fOutputAll->Add(allArmenterosPodLcOffline);
1251 
1252  fOutputPIDBach->Add(pidBachspectrumK0SMassOffline);
1253  fOutputPIDBach->Add(pidBachspectrumLcMassOfflineByK0S);
1254  fOutputPIDBach->Add(pidBachmomentumDistributionK0SvspOffline);
1255  fOutputPIDBach->Add(pidBachArmenterosPodK0SOffline);
1256  fOutputPIDBach->Add(pidBachArmenterosPodLcOffline);
1257 
1258  if(fFillSubSampleHist){
1259  nameHisto="histLcMassByK0SSubSampleOffline";
1260  titleHisto="#Lambda_{c} invariant mass (by K^{0}_{S}) vs p_{T} vs Sub ID";
1261  Int_t bins_subsample[3]= {1000,24,25};
1262  Double_t xmin_subsample[3]={mLcPDG-0.25,0,-0.5};
1263  Double_t xmax_subsample[3]={mLcPDG+0.25,24.,24.5};
1264  THnSparse *spectrumLcMassOfflineByK0SSubSample = new THnSparseF(nameHisto.Data(),titleHisto.Data(),3,bins_subsample,xmin_subsample,xmax_subsample);
1265  fOutputPIDBach->Add(spectrumLcMassOfflineByK0SSubSample);
1266  }
1267 
1269  nameHisto="histLcMassBGByK0SOffline";
1270  titleHisto="#Lambda_{c} invariant mass (by K^{0}_{S}) vs p_{T}; m_{inv}(p,K^{0}_{S}) [GeV/c^{2}]; p_{T}(#Lambda_{c}) [GeV/c]";
1271  TH2F* spectrumLcMassBGOfflineByK0S = new TH2F(nameHisto.Data(),titleHisto.Data(),1000,mLcPDG-0.250,mLcPDG+0.250,11,binLimpTLc);
1272  fOutputPIDBach->Add(spectrumLcMassBGOfflineByK0S);
1273  }
1274 
1275  nameHisto="histArmPodK0SOffline0";
1276  titleHisto="V0-candidate Armenteros-Podolanski distribution; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1277  TH2F* armenterosPodK0SOffline0 = new TH2F(nameHisto.Data(),titleHisto.Data(),200,-1.,1.,300,0.,0.3);
1278  nameHisto="histArmPodLcOffline0";
1279  titleHisto="#Lambda_{c}-candidate Armenteros-Podolanski distribution; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1280  TH2F* armenterosPodLcOffline0 = new TH2F(nameHisto.Data(),titleHisto.Data(),200,-4.,4.,800,0.,1.6);
1281  fOutputAll->Add(armenterosPodK0SOffline0);
1282  fOutputAll->Add(armenterosPodLcOffline0);
1283 
1284  if (fTrackRotation) {
1285  TH2F* pidBachTRspectrumLcMassOfflineByK0S = (TH2F*)spectrumLcMassOfflineByK0S->Clone();
1286  fOutputPIDBachTR->Add(pidBachTRspectrumLcMassOfflineByK0S);
1287  }
1288 
1289 
1290 
1291 
1292  nameHisto="histptK0SOffline";
1293  titleHisto="p_{T}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(K^{0}_{S}) [GeV/c]; Entries";
1294  TH2F* ptK0SOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,41,binLimpTprong);
1295 
1296  nameHisto="histptPOffline";
1297  titleHisto="p_{T}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(p) [GeV/c]; Entries";
1298  TH2F* ptPOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,41,binLimpTprong);
1299 
1300  nameHisto="histptPipOffline";
1301  titleHisto="p_{T}(#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{+}) [GeV/c]; Entries";
1302  TH2F* ptPiPOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,41,binLimpTprong);
1303 
1304  nameHisto="histptPimOffline";
1305  titleHisto="p_{T}(#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{-}) [GeV/c]; Entries";
1306  TH2F* ptPiMOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,41,binLimpTprong);
1307 
1308  nameHisto="histLambdaMassOffline";
1309  titleHisto="m_{inv}(p,#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(p,#pi^{-}) [GeV/c^{2}]; Entries";
1310  TH2F* massLambdaOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,1000,mMinLambdaPDG,mMinLambdaPDG+0.5);
1311 
1312  nameHisto="histLambdaBarMassOffline";
1313  titleHisto="m_{inv}(#bar{p},#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(#bar{p},#pi^{+}) [GeV/c^{2}]; Entries";
1314  TH2F* massLambdaBarOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,1000,mMinLambdaPDG,mMinLambdaPDG+0.5);
1315 
1316  nameHisto="histGammaMassOffline";
1317  titleHisto="m_{inv}(e^{+},e^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(e^{+},e^{-}) [GeV/c^{2}]; Entries";
1318  TH2F* massGammaOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,100,0.,1.);
1319 
1320  nameHisto="histD0K0SOffline";
1321  titleHisto="d_{0}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(K^{0}_{S}) [#sigmas]; Entries";
1322  TH2F* d0K0SOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,1000,-1.,1.);
1323 
1324  nameHisto="histD0POffline";
1325  titleHisto="d_{0}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(p) [cm]; Entries";
1326  TH2F* d0POffline = new TH2F(nameHisto.Data(),titleHisto.Data(),11,binLimpTLc,1000,-1.,1.);
1327 
1328  nameHisto="histCosPAK0SOffline";
1329  titleHisto="K^{0}_{S} cosine of pointing angle wrt primary vertex vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
1330  TH2F *cosPAK0SOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),41,binLimpTprong,100,0.99,1.);
1331 
1332  nameHisto="histCosThetaProtonCMSOffline";
1333  titleHisto="cosien of proton emission angle in Lc rest frame; p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
1334  TH2F *cosThePrOffline = new TH2F(nameHisto.Data(),titleHisto.Data(),41,binLimpTprong,100,-1.,1.);
1335 
1336  nameHisto="histResignedD0Offline";
1337  titleHisto="Proton d0 with different sign convention; p_{T}(#Lambda_{c}) [GeV/c]; d0 [cm]; Entries";
1338  TH2F *resignedD0Offline = new TH2F(nameHisto.Data(),titleHisto.Data(),41,binLimpTprong,100,-0.1,0.1);
1339 
1340 
1341  TH2F* allptK0SOffline = (TH2F*)ptK0SOffline->Clone();
1342  TH2F* allptPOffline = (TH2F*)ptPOffline->Clone();
1343  TH2F* allptPiPOffline = (TH2F*)ptPiPOffline->Clone();
1344  TH2F* allptPiMOffline = (TH2F*)ptPiMOffline->Clone();
1345  TH2F* allmassLambdaOffline = (TH2F*)massLambdaOffline->Clone();
1346  TH2F* allmassLambdaBarOffline = (TH2F*)massLambdaBarOffline->Clone();
1347  TH2F* allmassGammaOffline = (TH2F*)massGammaOffline->Clone();
1348  TH2F* alld0K0SOffline = (TH2F*)d0K0SOffline->Clone();
1349  TH2F* alld0POffline = (TH2F*)d0POffline->Clone();
1350  TH2F* allcosPAK0SOffline = (TH2F*)cosPAK0SOffline->Clone();
1351  TH2F* allcosThePrOffline = (TH2F*)cosThePrOffline->Clone();
1352  TH2F* allresignedD0Offline = (TH2F*)resignedD0Offline->Clone();
1353 
1354  TH2F* pidptK0SOffline = (TH2F*)ptK0SOffline->Clone();
1355  TH2F* pidptPOffline = (TH2F*)ptPOffline->Clone();
1356  TH2F* pidptPiPOffline = (TH2F*)ptPiPOffline->Clone();
1357  TH2F* pidptPiMOffline = (TH2F*)ptPiMOffline->Clone();
1358  TH2F* pidmassLambdaOffline = (TH2F*)massLambdaOffline->Clone();
1359  TH2F* pidmassLambdaBarOffline = (TH2F*)massLambdaBarOffline->Clone();
1360  TH2F* pidmassGammaOffline = (TH2F*)massGammaOffline->Clone();
1361  TH2F* pidd0K0SOffline = (TH2F*)d0K0SOffline->Clone();
1362  TH2F* pidd0POffline = (TH2F*)d0POffline->Clone();
1363  TH2F* pidcosPAK0SOffline = (TH2F*)cosPAK0SOffline->Clone();
1364  TH2F* pidcosThePrOffline = (TH2F*)cosThePrOffline->Clone();
1365  TH2F* pidresignedD0Offline = (TH2F*)resignedD0Offline->Clone();
1366 
1367  fOutputAll->Add(allptK0SOffline);
1368  fOutputAll->Add(allptPOffline);
1369  fOutputAll->Add(allptPiPOffline);
1370  fOutputAll->Add(allptPiMOffline);
1371  fOutputAll->Add(allmassLambdaOffline);
1372  fOutputAll->Add(allmassLambdaBarOffline);
1373  fOutputAll->Add(allmassGammaOffline);
1374  fOutputAll->Add(alld0K0SOffline);
1375  fOutputAll->Add(alld0POffline);
1376  fOutputAll->Add(allcosPAK0SOffline);
1377  fOutputAll->Add(allcosThePrOffline);
1378  fOutputAll->Add(allresignedD0Offline);
1379 
1380  fOutputPIDBach->Add(pidptK0SOffline);
1381  fOutputPIDBach->Add(pidptPOffline);
1382  fOutputPIDBach->Add(pidptPiPOffline);
1383  fOutputPIDBach->Add(pidptPiMOffline);
1384  fOutputPIDBach->Add(pidmassLambdaOffline);
1385  fOutputPIDBach->Add(pidmassLambdaBarOffline);
1386  fOutputPIDBach->Add(pidmassGammaOffline);
1387  fOutputPIDBach->Add(pidd0K0SOffline);
1388  fOutputPIDBach->Add(pidd0POffline);
1389  fOutputPIDBach->Add(pidcosPAK0SOffline);
1390  fOutputPIDBach->Add(pidcosThePrOffline);
1391  fOutputPIDBach->Add(pidresignedD0Offline);
1392 
1393  if (fTrackRotation) {
1394 
1395  TH2F* pidTRptK0SOffline = (TH2F*)ptK0SOffline->Clone();
1396  TH2F* pidTRptPOffline = (TH2F*)ptPOffline->Clone();
1397  TH2F* pidTRptPiPOffline = (TH2F*)ptPiPOffline->Clone();
1398  TH2F* pidTRptPiMOffline = (TH2F*)ptPiMOffline->Clone();
1399  TH2F* pidTRmassLambdaOffline = (TH2F*)massLambdaOffline->Clone();
1400  TH2F* pidTRmassLambdaBarOffline = (TH2F*)massLambdaBarOffline->Clone();
1401  TH2F* pidTRmassGammaOffline = (TH2F*)massGammaOffline->Clone();
1402  TH2F* pidTRcosPAK0SOffline = (TH2F*)cosPAK0SOffline->Clone();
1403  TH2F* pidTRcosThePrOffline = (TH2F*)cosThePrOffline->Clone();
1404  TH2F* pidTRresignedD0Offline = (TH2F*)resignedD0Offline->Clone();
1405  fOutputPIDBachTR->Add(pidTRptK0SOffline);
1406  fOutputPIDBachTR->Add(pidTRptPOffline);
1407  fOutputPIDBachTR->Add(pidTRptPiPOffline);
1408  fOutputPIDBachTR->Add(pidTRptPiMOffline);
1409  fOutputPIDBachTR->Add(pidTRmassLambdaOffline);
1410  fOutputPIDBachTR->Add(pidTRmassLambdaBarOffline);
1411  fOutputPIDBachTR->Add(pidTRmassGammaOffline);
1412  fOutputPIDBachTR->Add(pidTRcosPAK0SOffline);
1413  fOutputPIDBachTR->Add(pidTRcosThePrOffline);
1414  fOutputPIDBachTR->Add(pidTRresignedD0Offline);
1415 
1416  }
1417 
1418 
1419 
1420 
1421 
1422  if (fUseMCInfo) {
1423 
1424  if (fUseOnTheFlyV0) {
1425 
1426  nameHistoSgn="histK0SMassSgn";
1427  nameHistoBkg="histK0SMassBkg";
1428  titleHistoSgn="K^{0}_{S} - sgn: invariant mass VS p_{T} - MC; p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(#pi^{+},#pi^{-}) [GeV/c^{2}]; Entries";
1429  titleHistoBkg="K^{0}_{S} - bkg: invariant mass VS p_{T} - MC; p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(#pi^{+},#pi^{-}) [GeV/c^{2}]; Entries";
1430  TH2F* spectrumK0SMassSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,1000,mK0SPDG-0.050,mK0SPDG+0.050);
1431  TH2F* spectrumK0SMassBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,1000,mK0SPDG-0.050,mK0SPDG+0.050);
1432 
1433  nameHistoSgn="histLcMassByK0SSgn";
1434  nameHistoBkg="histLcMassByK0SBkg";
1435  titleHistoSgn="#Lambda_{c} - sgn: invariant mass (by K^{0}_{S}) vs p_{T} - MC; m_{inv}(p,K^{0}_{S}) [GeV/c^{2}]; p_{T}(#Lambda_{c}) [GeV/c]";
1436  titleHistoBkg="#Lambda_{c} - bkg: invariant mass (by K^{0}_{S}) vs p_{T} - MC; m_{inv}(p,K^{0}_{S}) [GeV/c^{2}]; p_{T}(#Lambda_{c}) [GeV/c]";
1437  TH2F* spectrumLcMassByK0SSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),1000,mLcPDG-0.250,mLcPDG+0.250,11,binLimpTLc);
1438  TH2F* spectrumLcMassByK0SBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),1000,mLcPDG-0.250,mLcPDG+0.250,11,binLimpTLc);
1439 
1440  nameHistoSgn="histpK0SvspSgn";
1441  nameHistoBkg="histpK0SvspBkg";
1442  titleHistoSgn="#Lambda_{c} - sgn: K^{0}_{S} vs p Total Momentum Distribution - MC; p(p) [GeV/c]; p(K^{0}_{S}) [GeV/c]";
1443  titleHistoBkg="#Lambda_{c} - bkg: K^{0}_{S} vs p Total Momentum Distribution - MC; p(p) [GeV/c]; p(K^{0}_{S}) [GeV/c]";
1444  TH2F* momentumDistributionK0SvspSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),41,binLimpTprong,41,binLimpTprong);
1445  TH2F* momentumDistributionK0SvspBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),41,binLimpTprong,41,binLimpTprong);
1446 
1447  // armenteros-podolanski plots K0S
1448  nameHistoSgn="histArmPodK0SSgn";
1449  nameHistoBkg="histArmPodK0SBkg";
1450  titleHistoSgn="V0-candidate Armenteros-Podolanski distribution (sgn); #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1451  titleHistoBkg="V0-candidate Armenteros-Podolanski distribution (bkg); #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1452  TH2F* armenterosPodK0SSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),200,-1.,1.,300,0.,0.3);
1453  TH2F* armenterosPodK0SBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),200,-1.,1.,300,0.,0.3);
1454 
1455  nameHistoSgn="histArmPodLcSgn";
1456  nameHistoBkg="histArmPodLcBkg";
1457  titleHistoSgn="#Lambda_{c}-candidate Armenteros-Podolanski distribution (sgn); #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1458  titleHistoBkg="#Lambda_{c}-candidate Armenteros-Podolanski distribution (bkg); #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1459  TH2F* armenterosPodLcSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),200,-4.,4.,800,0.,1.6);
1460  TH2F* armenterosPodLcBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),200,-4.,4.,800,0.,1.6);
1461 
1462  TH2F* allspectrumK0SMassSgn = (TH2F*)spectrumK0SMassSgn->Clone();
1463  TH2F* allspectrumK0SMassBkg = (TH2F*)spectrumK0SMassBkg->Clone();
1464  TH2F* allspectrumLcMassByK0SSgn = (TH2F*)spectrumLcMassByK0SSgn->Clone();
1465  TH2F* allspectrumLcMassByK0SBkg = (TH2F*)spectrumLcMassByK0SBkg->Clone();
1466  TH2F* allmomentumDistributionK0SvspSgn = (TH2F*)momentumDistributionK0SvspSgn->Clone();
1467  TH2F* allmomentumDistributionK0SvspBkg = (TH2F*)momentumDistributionK0SvspBkg->Clone();
1468  TH2F* allArmenterosPodK0SSgn = (TH2F*)armenterosPodK0SSgn->Clone();
1469  TH2F* allArmenterosPodK0SBkg = (TH2F*)armenterosPodK0SBkg->Clone();
1470  TH2F* allArmenterosPodLcSgn = (TH2F*)armenterosPodLcSgn->Clone();
1471  TH2F* allArmenterosPodLcBkg = (TH2F*)armenterosPodLcBkg->Clone();
1472 
1473  TH2F* pidBachspectrumK0SMassSgn = (TH2F*)spectrumK0SMassSgn->Clone();
1474  TH2F* pidBachspectrumK0SMassBkg = (TH2F*)spectrumK0SMassBkg->Clone();
1475  TH2F* pidBachspectrumLcMassByK0SSgn = (TH2F*)spectrumLcMassByK0SSgn->Clone();
1476  TH2F* pidBachspectrumLcMassByK0SBkg = (TH2F*)spectrumLcMassByK0SBkg->Clone();
1477  TH2F* pidBachmomentumDistributionK0SvspSgn = (TH2F*)momentumDistributionK0SvspSgn->Clone();
1478  TH2F* pidBachmomentumDistributionK0SvspBkg = (TH2F*)momentumDistributionK0SvspBkg->Clone();
1479  TH2F* pidBachArmenterosPodK0SSgn = (TH2F*)armenterosPodK0SSgn->Clone();
1480  TH2F* pidBachArmenterosPodK0SBkg = (TH2F*)armenterosPodK0SBkg->Clone();
1481  TH2F* pidBachArmenterosPodLcSgn = (TH2F*)armenterosPodLcSgn->Clone();
1482  TH2F* pidBachArmenterosPodLcBkg = (TH2F*)armenterosPodLcBkg->Clone();
1483 
1484  fOutputAll->Add(allspectrumK0SMassSgn);
1485  fOutputAll->Add(allspectrumK0SMassBkg);
1486  fOutputAll->Add(allspectrumLcMassByK0SSgn);
1487  fOutputAll->Add(allspectrumLcMassByK0SBkg);
1488  fOutputAll->Add(allmomentumDistributionK0SvspSgn);
1489  fOutputAll->Add(allmomentumDistributionK0SvspBkg);
1490  fOutputAll->Add(allArmenterosPodK0SSgn);
1491  fOutputAll->Add(allArmenterosPodK0SBkg);
1492  fOutputAll->Add(allArmenterosPodLcSgn);
1493  fOutputAll->Add(allArmenterosPodLcBkg);
1494 
1495  fOutputPIDBach->Add(pidBachspectrumK0SMassSgn);
1496  fOutputPIDBach->Add(pidBachspectrumK0SMassBkg);
1497  fOutputPIDBach->Add(pidBachspectrumLcMassByK0SSgn);
1498  fOutputPIDBach->Add(pidBachspectrumLcMassByK0SBkg);
1499  fOutputPIDBach->Add(pidBachmomentumDistributionK0SvspSgn);
1500  fOutputPIDBach->Add(pidBachmomentumDistributionK0SvspBkg);
1501  fOutputPIDBach->Add(pidBachArmenterosPodK0SSgn);
1502  fOutputPIDBach->Add(pidBachArmenterosPodK0SBkg);
1503  fOutputPIDBach->Add(pidBachArmenterosPodLcSgn);
1504  fOutputPIDBach->Add(pidBachArmenterosPodLcBkg);
1505 
1506  nameHistoSgn="histArmPodK0SSgn0";
1507  nameHistoBkg="histArmPodK0SBkg0";
1508  titleHistoSgn="V0-candidate Armenteros-Podolanski distribution (sgn); #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1509  titleHistoBkg="V0-candidate Armenteros-Podolanski distribution (bkg); #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1510  TH2F* armenterosPodK0SSgn0 = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),200,-1.,1.,300,0.,0.3);
1511  TH2F* armenterosPodK0SBkg0 = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),200,-1.,1.,300,0.,0.3);
1512  fOutputAll->Add(armenterosPodK0SSgn0);
1513  fOutputAll->Add(armenterosPodK0SBkg0);
1514  nameHistoSgn="histArmPodLcSgn0";
1515  nameHistoBkg="histArmPodLcBkg0";
1516  titleHistoSgn="#Lambda_{c}-candidate Armenteros-Podolanski distribution (sgn); #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1517  titleHistoBkg="#Lambda_{c}-candidate Armenteros-Podolanski distribution (bkg); #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1518  TH2F* armenterosPodLcSgn0 = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),200,-4.,4.,800,0.,1.6);
1519  TH2F* armenterosPodLcBkg0 = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),200,-4.,4.,800,0.,1.6);
1520  fOutputAll->Add(armenterosPodLcSgn0);
1521  fOutputAll->Add(armenterosPodLcBkg0);
1522 
1523  if (fTrackRotation) {
1524  TH2F* pidBachTRspectrumLcMassByK0SSgn = (TH2F*)spectrumLcMassByK0SSgn->Clone();
1525  TH2F* pidBachTRspectrumLcMassByK0SBkg = (TH2F*)spectrumLcMassByK0SBkg->Clone();
1526  fOutputPIDBachTR->Add(pidBachTRspectrumLcMassByK0SSgn);
1527  fOutputPIDBachTR->Add(pidBachTRspectrumLcMassByK0SBkg);
1528  }
1529 
1530 
1531 
1532  nameHistoSgn="histptK0SSgn";
1533  nameHistoBkg="histptK0SBkg";
1534  titleHistoSgn="p_{T}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(K^{0}_{S}) [GeV/c]; Entries";
1535  titleHistoBkg="p_{T}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(K^{0}_{S}) [GeV/c]; Entries";
1536  TH2F* ptK0SSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,41,binLimpTprong);
1537  TH2F* ptK0SBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,41,binLimpTprong);
1538 
1539  nameHistoSgn="histptPSgn";
1540  nameHistoBkg="histptPBkg";
1541  titleHistoSgn="p_{T}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(p) [GeV/c]; Entries";
1542  titleHistoBkg="p_{T}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(p) [GeV/c]; Entries";
1543  TH2F* ptPSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,41,binLimpTprong);
1544  TH2F* ptPBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,41,binLimpTprong);
1545 
1546  nameHistoSgn="histptPipSgn";
1547  nameHistoBkg="histptPipBkg";
1548  titleHistoSgn="p_{T}(#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{+}) [GeV/c]; Entries";
1549  titleHistoBkg="p_{T}(#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{+}) [GeV/c]; Entries";
1550  TH2F* ptPiPSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,41,binLimpTprong);
1551  TH2F* ptPiPBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,41,binLimpTprong);
1552 
1553  nameHistoSgn="histptPimSgn";
1554  nameHistoBkg="histptPimBkg";
1555  titleHistoSgn="p_{T}(#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{-}) [GeV/c]; Entries";
1556  titleHistoBkg="p_{T}(#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{-}) [GeV/c]; Entries";
1557  TH2F* ptPiMSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,41,binLimpTprong);
1558  TH2F* ptPiMBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,41,binLimpTprong);
1559 
1560  nameHistoSgn="histLambdaMassSgn";
1561  nameHistoBkg="histLambdaMassBkg";
1562  titleHistoSgn="m_{inv}(p,#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(p,#pi^{-}) [GeV/c^{2}]; Entries";
1563  titleHistoBkg="m_{inv}(p,#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(p,#pi^{-}) [GeV/c^{2}]; Entries";
1564  TH2F* massLambdaSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,1000,mMinLambdaPDG,mMinLambdaPDG+0.5);
1565  TH2F* massLambdaBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,1000,mMinLambdaPDG,mMinLambdaPDG+0.5);
1566 
1567  nameHistoSgn="histLambdaBarMassSgn";
1568  nameHistoBkg="histLambdaBarMassBkg";
1569  titleHistoSgn="m_{inv}(#bar{p},#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(#bar{p},#pi^{+}) [GeV/c^{2}]; Entries";
1570  titleHistoBkg="m_{inv}(#bar{p},#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(#bar{p},#pi^{+}) [GeV/c^{2}]; Entries";
1571  TH2F* massLambdaBarSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,1000,mMinLambdaPDG,mMinLambdaPDG+0.5);
1572  TH2F* massLambdaBarBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,1000,mMinLambdaPDG,mMinLambdaPDG+0.5);
1573 
1574  nameHistoSgn="histGammaMassSgn";
1575  nameHistoBkg="histGammaMassBkg";
1576  titleHistoSgn="m_{inv}(e^{+},e^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(e^{+},e^{-}) [GeV/c^{2}]; Entries";
1577  titleHistoBkg="m_{inv}(e^{+},e^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(e^{+},e^{-}) [GeV/c^{2}]; Entries";
1578  TH2F* massGammaSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,100,0.,1.);
1579  TH2F* massGammaBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,100,0.,1.);
1580 
1581  nameHistoSgn="histD0K0SSgn";
1582  nameHistoBkg="histD0K0SBkg";
1583  titleHistoSgn="d_{0}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(K^{0}_{S}) [#sigmas]; Entries";
1584  titleHistoBkg="d_{0}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(K^{0}_{S}) [#sigmas]; Entries";
1585  TH2F* d0K0SSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,1000,-1.,1.);
1586  TH2F* d0K0SBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,1000,-1.,1.);
1587 
1588  nameHistoSgn="histD0PSgn";
1589  nameHistoBkg="histD0PBkg";
1590  titleHistoSgn="d_{0}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(p) [cm]; Entries";
1591  titleHistoBkg="d_{0}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(p) [cm]; Entries";
1592  TH2F* d0PSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,1000,-1.,1.);
1593  TH2F* d0PBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,1000,-1.,1.);
1594 
1595  nameHistoSgn="histCosPAK0SSgn";
1596  nameHistoBkg="histCosPAK0SBkg";
1597  titleHistoSgn="K^{0}_{S} cosine of pointing angle wrt primary vertex vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
1598  titleHistoBkg="K^{0}_{S} cosine of pointing angle wrt primary vertex vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
1599  TH2F *cosPAK0SSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),41,binLimpTprong,100,0.99,1.);
1600  TH2F *cosPAK0SBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),41,binLimpTprong,100,0.99,1.);
1601 
1602  nameHistoSgn="histCosThetaProtonCMSSgn";
1603  nameHistoBkg="histCosThetaProtonCMSBkg";
1604  titleHistoSgn="cosien of proton emission angle in Lc rest frame; p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
1605  titleHistoBkg="cosien of proton emission angle in Lc rest frame; p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
1606  TH2F *cosThePrSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),41,binLimpTprong,100,-1.,1.);
1607  TH2F *cosThePrBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),41,binLimpTprong,100,-1.,1.);
1608 
1609 
1610  nameHistoSgn="histResignedD0Sgn";
1611  nameHistoBkg="histResignedD0Bkg";
1612  titleHistoSgn="Proton d0 with different sign convention; p_{T}(#Lambda_{c}) [GeV/c]; d0 [cm]; Entries";
1613  titleHistoBkg="Proton d0 with different sign convention; p_{T}(#Lambda_{c}) [GeV/c]; d0 [cm]; Entries";
1614  TH2F *resignedD0Sgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),41,binLimpTprong,100,-0.1,0.1);
1615  TH2F *resignedD0Bkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),41,binLimpTprong,100,-0.1,0.1);
1616 
1617  TH2F* allptK0SSgn = (TH2F*)ptK0SSgn->Clone();
1618  TH2F* allptK0SBkg = (TH2F*)ptK0SBkg->Clone();
1619  TH2F* allptPSgn = (TH2F*)ptPSgn->Clone();
1620  TH2F* allptPBkg = (TH2F*)ptPBkg->Clone();
1621  TH2F* allptPiPSgn = (TH2F*)ptPiPSgn->Clone();
1622  TH2F* allptPiPBkg = (TH2F*)ptPiPBkg->Clone();
1623  TH2F* allptPiMSgn = (TH2F*)ptPiMSgn->Clone();
1624  TH2F* allptPiMBkg = (TH2F*)ptPiMBkg->Clone();
1625  TH2F* allmassLambdaSgn = (TH2F*)massLambdaSgn->Clone();
1626  TH2F* allmassLambdaBkg = (TH2F*)massLambdaBkg->Clone();
1627  TH2F* allmassLambdaBarSgn = (TH2F*)massLambdaBarSgn->Clone();
1628  TH2F* allmassLambdaBarBkg = (TH2F*)massLambdaBarBkg->Clone();
1629  TH2F* allmassGammaSgn = (TH2F*)massGammaSgn->Clone();
1630  TH2F* allmassGammaBkg = (TH2F*)massGammaBkg->Clone();
1631  TH2F* alld0K0SSgn = (TH2F*)d0K0SSgn->Clone();
1632  TH2F* alld0K0SBkg = (TH2F*)d0K0SBkg->Clone();
1633  TH2F* alld0PSgn = (TH2F*)d0PSgn->Clone();
1634  TH2F* alld0PBkg = (TH2F*)d0PBkg->Clone();
1635  TH2F* allcosPAK0SSgn = (TH2F*)cosPAK0SSgn->Clone();
1636  TH2F* allcosPAK0SBkg = (TH2F*)cosPAK0SBkg->Clone();
1637  TH2F* allcosThePrSgn = (TH2F*)cosThePrSgn->Clone();
1638  TH2F* allcosThePrBkg = (TH2F*)cosThePrBkg->Clone();
1639  TH2F* allresignedD0Sgn = (TH2F*)resignedD0Sgn->Clone();
1640  TH2F* allresignedD0Bkg = (TH2F*)resignedD0Bkg->Clone();
1641 
1642  TH2F* pidptK0SSgn = (TH2F*)ptK0SSgn->Clone();
1643  TH2F* pidptK0SBkg = (TH2F*)ptK0SBkg->Clone();
1644  TH2F* pidptPSgn = (TH2F*)ptPSgn->Clone();
1645  TH2F* pidptPBkg = (TH2F*)ptPBkg->Clone();
1646  TH2F* pidptPiPSgn = (TH2F*)ptPiPSgn->Clone();
1647  TH2F* pidptPiPBkg = (TH2F*)ptPiPBkg->Clone();
1648  TH2F* pidptPiMSgn = (TH2F*)ptPiMSgn->Clone();
1649  TH2F* pidptPiMBkg = (TH2F*)ptPiMBkg->Clone();
1650  TH2F* pidmassLambdaSgn = (TH2F*)massLambdaSgn->Clone();
1651  TH2F* pidmassLambdaBkg = (TH2F*)massLambdaBkg->Clone();
1652  TH2F* pidmassLambdaBarSgn = (TH2F*)massLambdaBarSgn->Clone();
1653  TH2F* pidmassLambdaBarBkg = (TH2F*)massLambdaBarBkg->Clone();
1654  TH2F* pidmassGammaSgn = (TH2F*)massGammaSgn->Clone();
1655  TH2F* pidmassGammaBkg = (TH2F*)massGammaBkg->Clone();
1656  TH2F* pidd0K0SSgn = (TH2F*)d0K0SSgn->Clone();
1657  TH2F* pidd0K0SBkg = (TH2F*)d0K0SBkg->Clone();
1658  TH2F* pidd0PSgn = (TH2F*)d0PSgn->Clone();
1659  TH2F* pidd0PBkg = (TH2F*)d0PBkg->Clone();
1660  TH2F* pidcosPAK0SSgn = (TH2F*)cosPAK0SSgn->Clone();
1661  TH2F* pidcosPAK0SBkg = (TH2F*)cosPAK0SBkg->Clone();
1662  TH2F* pidcosThePrSgn = (TH2F*)cosThePrSgn->Clone();
1663  TH2F* pidcosThePrBkg = (TH2F*)cosThePrBkg->Clone();
1664  TH2F* pidresignedD0Sgn = (TH2F*)resignedD0Sgn->Clone();
1665  TH2F* pidresignedD0Bkg = (TH2F*)resignedD0Bkg->Clone();
1666 
1667  fOutputAll->Add(allptK0SSgn);
1668  fOutputAll->Add(allptK0SBkg);
1669  fOutputAll->Add(allptPSgn);
1670  fOutputAll->Add(allptPBkg);
1671  fOutputAll->Add(allptPiPSgn);
1672  fOutputAll->Add(allptPiPBkg);
1673  fOutputAll->Add(allptPiMSgn);
1674  fOutputAll->Add(allptPiMBkg);
1675  fOutputAll->Add(allmassLambdaSgn);
1676  fOutputAll->Add(allmassLambdaBkg);
1677  fOutputAll->Add(allmassLambdaBarSgn);
1678  fOutputAll->Add(allmassLambdaBarBkg);
1679  fOutputAll->Add(allmassGammaSgn);
1680  fOutputAll->Add(allmassGammaBkg);
1681  fOutputAll->Add(alld0K0SSgn);
1682  fOutputAll->Add(alld0K0SBkg);
1683  fOutputAll->Add(alld0PSgn);
1684  fOutputAll->Add(alld0PBkg);
1685  fOutputAll->Add(allcosPAK0SSgn);
1686  fOutputAll->Add(allcosPAK0SBkg);
1687  fOutputAll->Add(allcosThePrSgn);
1688  fOutputAll->Add(allcosThePrBkg);
1689  fOutputAll->Add(allresignedD0Sgn);
1690  fOutputAll->Add(allresignedD0Bkg);
1691 
1692  fOutputPIDBach->Add(pidptK0SSgn);
1693  fOutputPIDBach->Add(pidptK0SBkg);
1694  fOutputPIDBach->Add(pidptPSgn);
1695  fOutputPIDBach->Add(pidptPBkg);
1696  fOutputPIDBach->Add(pidptPiPSgn);
1697  fOutputPIDBach->Add(pidptPiPBkg);
1698  fOutputPIDBach->Add(pidptPiMSgn);
1699  fOutputPIDBach->Add(pidptPiMBkg);
1700  fOutputPIDBach->Add(pidmassLambdaSgn);
1701  fOutputPIDBach->Add(pidmassLambdaBkg);
1702  fOutputPIDBach->Add(pidmassLambdaBarSgn);
1703  fOutputPIDBach->Add(pidmassLambdaBarBkg);
1704  fOutputPIDBach->Add(pidmassGammaSgn);
1705  fOutputPIDBach->Add(pidmassGammaBkg);
1706  fOutputPIDBach->Add(pidd0K0SSgn);
1707  fOutputPIDBach->Add(pidd0K0SBkg);
1708  fOutputPIDBach->Add(pidd0PSgn);
1709  fOutputPIDBach->Add(pidd0PBkg);
1710  fOutputPIDBach->Add(pidcosPAK0SSgn);
1711  fOutputPIDBach->Add(pidcosPAK0SBkg);
1712  fOutputPIDBach->Add(pidcosThePrSgn);
1713  fOutputPIDBach->Add(pidcosThePrBkg);
1714  fOutputPIDBach->Add(pidresignedD0Sgn);
1715  fOutputPIDBach->Add(pidresignedD0Bkg);
1716 
1717  if (fTrackRotation) {
1718 
1719  TH2F* pidTRptK0SSgn = (TH2F*)ptK0SSgn->Clone();
1720  TH2F* pidTRptK0SBkg = (TH2F*)ptK0SBkg->Clone();
1721  TH2F* pidTRptPSgn = (TH2F*)ptPSgn->Clone();
1722  TH2F* pidTRptPBkg = (TH2F*)ptPBkg->Clone();
1723  TH2F* pidTRptPiPSgn = (TH2F*)ptPiPSgn->Clone();
1724  TH2F* pidTRptPiPBkg = (TH2F*)ptPiPBkg->Clone();
1725  TH2F* pidTRptPiMSgn = (TH2F*)ptPiMSgn->Clone();
1726  TH2F* pidTRptPiMBkg = (TH2F*)ptPiMBkg->Clone();
1727  TH2F* pidTRmassLambdaSgn = (TH2F*)massLambdaSgn->Clone();
1728  TH2F* pidTRmassLambdaBkg = (TH2F*)massLambdaBkg->Clone();
1729  TH2F* pidTRmassLambdaBarSgn = (TH2F*)massLambdaBarSgn->Clone();
1730  TH2F* pidTRmassLambdaBarBkg = (TH2F*)massLambdaBarBkg->Clone();
1731  TH2F* pidTRmassGammaSgn = (TH2F*)massGammaSgn->Clone();
1732  TH2F* pidTRmassGammaBkg = (TH2F*)massGammaBkg->Clone();
1733  TH2F* pidTRcosPAK0SSgn = (TH2F*)cosPAK0SSgn->Clone();
1734  TH2F* pidTRcosPAK0SBkg = (TH2F*)cosPAK0SBkg->Clone();
1735  TH2F* pidTRcosThePrSgn = (TH2F*)cosThePrSgn->Clone();
1736  TH2F* pidTRcosThePrBkg = (TH2F*)cosThePrBkg->Clone();
1737  TH2F* pidTRresignedD0Sgn = (TH2F*)resignedD0Sgn->Clone();
1738  TH2F* pidTRresignedD0Bkg = (TH2F*)resignedD0Bkg->Clone();
1739  fOutputPIDBachTR->Add(pidTRptK0SSgn);
1740  fOutputPIDBachTR->Add(pidTRptK0SBkg);
1741  fOutputPIDBachTR->Add(pidTRptPSgn);
1742  fOutputPIDBachTR->Add(pidTRptPBkg);
1743  fOutputPIDBachTR->Add(pidTRptPiPSgn);
1744  fOutputPIDBachTR->Add(pidTRptPiPBkg);
1745  fOutputPIDBachTR->Add(pidTRptPiMSgn);
1746  fOutputPIDBachTR->Add(pidTRptPiMBkg);
1747  fOutputPIDBachTR->Add(pidTRmassLambdaSgn);
1748  fOutputPIDBachTR->Add(pidTRmassLambdaBkg);
1749  fOutputPIDBachTR->Add(pidTRmassLambdaBarSgn);
1750  fOutputPIDBachTR->Add(pidTRmassLambdaBarBkg);
1751  fOutputPIDBachTR->Add(pidTRmassGammaSgn);
1752  fOutputPIDBachTR->Add(pidTRmassGammaBkg);
1753  fOutputPIDBachTR->Add(pidTRcosPAK0SSgn);
1754  fOutputPIDBachTR->Add(pidTRcosPAK0SBkg);
1755  fOutputPIDBachTR->Add(pidTRcosThePrSgn);
1756  fOutputPIDBachTR->Add(pidTRcosThePrBkg);
1757  fOutputPIDBachTR->Add(pidTRresignedD0Sgn);
1758  fOutputPIDBachTR->Add(pidTRresignedD0Bkg);
1759 
1760  }
1761 
1762 
1763  } // useOnTheFly
1764 
1765 
1766  nameHistoSgn="histK0SMassOfflineSgn";
1767  nameHistoBkg="histK0SMassOfflineBkg";
1768  titleHistoSgn="K^{0}_{S} - sgn: invariant mass VS p_{T} - MC; p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(#pi^{+},#pi^{-}) [GeV/c^{2}]; Entries";
1769  titleHistoBkg="K^{0}_{S} - bkg: invariant mass VS p_{T} - MC; p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(#pi^{+},#pi^{-}) [GeV/c^{2}]; Entries";
1770  TH2F* spectrumK0SMassOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,1000,mK0SPDG-0.050,mK0SPDG+0.050);
1771  TH2F* spectrumK0SMassOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,1000,mK0SPDG-0.050,mK0SPDG+0.050);
1772 
1773  nameHistoSgn="histLcMassByK0SOfflineSgn";
1774  nameHistoBkg="histLcMassByK0SOfflineBkg";
1775  titleHistoSgn="#Lambda_{c} - sgn: invariant mass (by K^{0}_{S}) vs p_{T} - MC; m_{inv}(p,K^{0}_{S}) [GeV/c^{2}]; p_{T}(#Lambda_{c}) [GeV/c]";
1776  titleHistoBkg="#Lambda_{c} - bkg: invariant mass (by K^{0}_{S}) vs p_{T} - MC; m_{inv}(p,K^{0}_{S}) [GeV/c^{2}]; p_{T}(#Lambda_{c}) [GeV/c]";
1777  TH2F* spectrumLcMassOfflineByK0SSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),1000,mLcPDG-0.250,mLcPDG+0.250,11,binLimpTLc);
1778  TH2F* spectrumLcMassOfflineByK0SBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),1000,mLcPDG-0.250,mLcPDG+0.250,11,binLimpTLc);
1779 
1780  nameHistoSgn="histpK0SvspOfflineSgn";
1781  nameHistoBkg="histpK0SvspOfflineBkg";
1782  titleHistoSgn="#Lambda_{c} - sgn: K^{0}_{S} vs p Total Momentum Distribution - Offline - MC; p(p) [GeV/c]; p(K^{0}_{S}) [GeV/c]";
1783  titleHistoBkg="#Lambda_{c} - bkg: K^{0}_{S} vs p Total Momentum Distribution - Offline - MC; p(p) [GeV/c]; p(K^{0}_{S}) [GeV/c]";
1784  TH2F* momentumDistributionK0SvspOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),41,binLimpTprong,41,binLimpTprong);
1785  TH2F* momentumDistributionK0SvspOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),41,binLimpTprong,41,binLimpTprong);
1786 
1787  // armenteros-podolanski plots K0S (offline)
1788  nameHistoSgn="histArmPodK0SOfflineSgn";
1789  nameHistoBkg="histArmPodK0SOfflineBkg";
1790  titleHistoSgn="V0-candidate Armenteros-Podolanski distribution (sgn) -offline-; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1791  titleHistoBkg="V0-candidate Armenteros-Podolanski distribution (bkg) -offline-; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1792  TH2F* armenterosPodK0SOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),200,-1.,1.,300,0.,0.3);
1793  TH2F* armenterosPodK0SOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),200,-1.,1.,300,0.,0.3);
1794 
1795  nameHistoSgn="histArmPodLcOfflineSgn";
1796  nameHistoBkg="histArmPodLcOfflineBkg";
1797  titleHistoSgn="#Lambda_{c}-candidate Armenteros-Podolanski distribution (sgn) -offline-; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1798  titleHistoBkg="#Lambda_{c}-candidate Armenteros-Podolanski distribution (bkg) -offline-; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1799  TH2F* armenterosPodLcOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),200,-4.,4.,800,0.,1.6);
1800  TH2F* armenterosPodLcOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),200,-4.,4.,800,0.,1.6);
1801 
1802 
1803  TH2F* allspectrumK0SMassOfflineSgn = (TH2F*)spectrumK0SMassOfflineSgn->Clone();
1804  TH2F* allspectrumK0SMassOfflineBkg = (TH2F*) spectrumK0SMassOfflineBkg->Clone();
1805  TH2F* allspectrumLcMassOfflineByK0SSgn = (TH2F*)spectrumLcMassOfflineByK0SSgn->Clone();
1806  TH2F* allspectrumLcMassOfflineByK0SBkg = (TH2F*) spectrumLcMassOfflineByK0SBkg->Clone();
1807  TH2F* allmomentumDistributionK0SvspOfflineSgn = (TH2F*)momentumDistributionK0SvspOfflineSgn->Clone();
1808  TH2F* allmomentumDistributionK0SvspOfflineBkg = (TH2F*)momentumDistributionK0SvspOfflineBkg->Clone();
1809  TH2F* allArmenterosPodK0SOfflineSgn = (TH2F*)armenterosPodK0SOfflineSgn->Clone();
1810  TH2F* allArmenterosPodK0SOfflineBkg = (TH2F*)armenterosPodK0SOfflineBkg->Clone();
1811  TH2F* allArmenterosPodLcOfflineSgn = (TH2F*)armenterosPodLcOfflineSgn->Clone();
1812  TH2F* allArmenterosPodLcOfflineBkg = (TH2F*)armenterosPodLcOfflineBkg->Clone();
1813 
1814  TH2F* pidBachspectrumLcMassOfflineByK0SSgn = (TH2F*)spectrumLcMassOfflineByK0SSgn->Clone();
1815  TH2F* pidBachspectrumLcMassOfflineByK0SBkg = (TH2F*) spectrumLcMassOfflineByK0SBkg->Clone();
1816  TH2F* pidBachspectrumK0SMassOfflineSgn = (TH2F*)spectrumK0SMassOfflineSgn->Clone();
1817  TH2F* pidBachspectrumK0SMassOfflineBkg = (TH2F*) spectrumK0SMassOfflineBkg->Clone();
1818  TH2F* pidBachmomentumDistributionK0SvspOfflineSgn = (TH2F*)momentumDistributionK0SvspOfflineSgn->Clone();
1819  TH2F* pidBachmomentumDistributionK0SvspOfflineBkg = (TH2F*)momentumDistributionK0SvspOfflineBkg->Clone();
1820  TH2F* pidBachArmenterosPodK0SOfflineSgn = (TH2F*)armenterosPodK0SOfflineSgn->Clone();
1821  TH2F* pidBachArmenterosPodK0SOfflineBkg = (TH2F*)armenterosPodK0SOfflineBkg->Clone();
1822  TH2F* pidBachArmenterosPodLcOfflineSgn = (TH2F*)armenterosPodLcOfflineSgn->Clone();
1823  TH2F* pidBachArmenterosPodLcOfflineBkg = (TH2F*)armenterosPodLcOfflineBkg->Clone();
1824 
1825  fOutputAll->Add(allspectrumK0SMassOfflineSgn);
1826  fOutputAll->Add(allspectrumK0SMassOfflineBkg);
1827  fOutputAll->Add(allspectrumLcMassOfflineByK0SSgn);
1828  fOutputAll->Add(allspectrumLcMassOfflineByK0SBkg);
1829  fOutputAll->Add(allmomentumDistributionK0SvspOfflineSgn);
1830  fOutputAll->Add(allmomentumDistributionK0SvspOfflineBkg);
1831  fOutputAll->Add(allArmenterosPodK0SOfflineSgn);
1832  fOutputAll->Add(allArmenterosPodK0SOfflineBkg);
1833  fOutputAll->Add(allArmenterosPodLcOfflineSgn);
1834  fOutputAll->Add(allArmenterosPodLcOfflineBkg);
1835 
1836  fOutputPIDBach->Add(pidBachspectrumK0SMassOfflineSgn);
1837  fOutputPIDBach->Add(pidBachspectrumK0SMassOfflineBkg);
1838  fOutputPIDBach->Add(pidBachspectrumLcMassOfflineByK0SSgn);
1839  fOutputPIDBach->Add(pidBachspectrumLcMassOfflineByK0SBkg);
1840  fOutputPIDBach->Add(pidBachmomentumDistributionK0SvspOfflineSgn);
1841  fOutputPIDBach->Add(pidBachmomentumDistributionK0SvspOfflineBkg);
1842  fOutputPIDBach->Add(pidBachArmenterosPodK0SOfflineSgn);
1843  fOutputPIDBach->Add(pidBachArmenterosPodK0SOfflineBkg);
1844  fOutputPIDBach->Add(pidBachArmenterosPodLcOfflineSgn);
1845  fOutputPIDBach->Add(pidBachArmenterosPodLcOfflineBkg);
1846 
1847  nameHistoSgn="histArmPodK0SOfflineSgn0";
1848  nameHistoBkg="histArmPodK0SOfflineBkg0";
1849  titleHistoSgn="V0-candidate Armenteros-Podolanski distribution (sgn) -offline-; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1850  titleHistoBkg="V0-candidate Armenteros-Podolanski distribution (bkg) -offline-; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1851  TH2F* armenterosPodK0SOfflineSgn0 = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),200,-1.,1.,300,0.,0.3);
1852  TH2F* armenterosPodK0SOfflineBkg0 = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),200,-1.,1.,300,0.,0.3);
1853  nameHistoSgn="histArmPodLcOfflineSgn0";
1854  nameHistoBkg="histArmPodLcOfflineBkg0";
1855  titleHistoSgn="#Lambda_{c}-candidate Armenteros-Podolanski distribution (sgn) -offline-; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1856  titleHistoBkg="#Lambda_{c}-candidate Armenteros-Podolanski distribution (bkg) -offline-; #frac{p_{L}^{+}-p_{L}^{-}}{p_{L}^{+}+p_{L}^{-}}; p_{T}^{+} [GeV/c]";
1857  TH2F* armenterosPodLcOfflineSgn0 = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),200,-4.,4.,800,0.,1.6);
1858  TH2F* armenterosPodLcOfflineBkg0 = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),200,-4.,4.,800,0.,1.6);
1859  fOutputAll->Add(armenterosPodK0SOfflineSgn0);
1860  fOutputAll->Add(armenterosPodK0SOfflineBkg0);
1861  fOutputAll->Add(armenterosPodLcOfflineSgn0);
1862  fOutputAll->Add(armenterosPodLcOfflineBkg0);
1863 
1864  if (fTrackRotation) {
1865  TH2F* pidBachTRspectrumLcMassOfflineByK0SSgn = (TH2F*)spectrumLcMassOfflineByK0SSgn->Clone();
1866  TH2F* pidBachTRspectrumLcMassOfflineByK0SBkg = (TH2F*) spectrumLcMassOfflineByK0SBkg->Clone();
1867  fOutputPIDBachTR->Add(pidBachTRspectrumLcMassOfflineByK0SSgn);
1868  fOutputPIDBachTR->Add(pidBachTRspectrumLcMassOfflineByK0SBkg);
1869  }
1870 
1871 
1872 
1873 
1874  nameHistoSgn="histptK0SOfflineSgn";
1875  nameHistoBkg="histptK0SOfflineBkg";
1876  titleHistoSgn="p_{T}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(K^{0}_{S}) [GeV/c]; Entries";
1877  titleHistoBkg="p_{T}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(K^{0}_{S}) [GeV/c]; Entries";
1878  TH2F* ptK0SOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,41,binLimpTprong);
1879  TH2F* ptK0SOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,41,binLimpTprong);
1880 
1881  nameHistoSgn="histptPOfflineSgn";
1882  nameHistoBkg="histptPOfflineBkg";
1883  titleHistoSgn="p_{T}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(p) [GeV/c]; Entries";
1884  titleHistoBkg="p_{T}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(p) [GeV/c]; Entries";
1885  TH2F* ptPOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,41,binLimpTprong);
1886  TH2F* ptPOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,41,binLimpTprong);
1887 
1888  nameHistoSgn="histptPipOfflineSgn";
1889  nameHistoBkg="histptPipOfflineBkg";
1890  titleHistoSgn="p_{T}(#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{+}) [GeV/c]; Entries";
1891  titleHistoBkg="p_{T}(#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{+}) [GeV/c]; Entries";
1892  TH2F* ptPiPOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,41,binLimpTprong);
1893  TH2F* ptPiPOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,41,binLimpTprong);
1894 
1895  nameHistoSgn="histptPimOfflineSgn";
1896  nameHistoBkg="histptPimOfflineBkg";
1897  titleHistoSgn="p_{T}(#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{-}) [GeV/c]; Entries";
1898  titleHistoBkg="p_{T}(#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{-}) [GeV/c]; Entries";
1899  TH2F* ptPiMOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,41,binLimpTprong);
1900  TH2F* ptPiMOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,41,binLimpTprong);
1901 
1902  nameHistoSgn="histLambdaMassOfflineSgn";
1903  nameHistoBkg="histLambdaMassOfflineBkg";
1904  titleHistoSgn="m_{inv}(p,#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(p,#pi^{-}) [GeV/c^{2}]; Entries";
1905  titleHistoBkg="m_{inv}(p,#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(p,#pi^{-}) [GeV/c^{2}]; Entries";
1906  TH2F* massLambdaOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,1000,mMinLambdaPDG,mMinLambdaPDG+0.5);
1907  TH2F* massLambdaOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,1000,mMinLambdaPDG,mMinLambdaPDG+0.5);
1908 
1909  nameHistoSgn="histLambdaBarMassOfflineSgn";
1910  nameHistoBkg="histLambdaBarMassOfflineBkg";
1911  titleHistoSgn="m_{inv}(#bar{p},#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(#bar{p},#pi^{+}) [GeV/c^{2}]; Entries";
1912  titleHistoBkg="m_{inv}(#bar{p},#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(#bar{p},#pi^{+}) [GeV/c^{2}]; Entries";
1913  TH2F* massLambdaBarOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,1000,mMinLambdaPDG,mMinLambdaPDG+0.5);
1914  TH2F* massLambdaBarOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,1000,mMinLambdaPDG,mMinLambdaPDG+0.5);
1915 
1916  nameHistoSgn="histGammaMassOfflineSgn";
1917  nameHistoBkg="histGammaMassOfflineBkg";
1918  titleHistoSgn="m_{inv}(e^{+},e^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(e^{+},e^{-}) [GeV/c^{2}]; Entries";
1919  titleHistoBkg="m_{inv}(e^{+},e^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; m_{inv}(e^{+},e^{-}) [GeV/c^{2}]; Entries";
1920  TH2F* massGammaOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,100,0.,1.);
1921  TH2F* massGammaOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,100,0.,1.);
1922 
1923  nameHistoSgn="histD0K0SOfflineSgn";
1924  nameHistoBkg="histD0K0SOfflineBkg";
1925  titleHistoSgn="d_{0}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(K^{0}_{S}) [#sigmas]; Entries";
1926  titleHistoBkg="d_{0}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(K^{0}_{S}) [#sigmas]; Entries";
1927  TH2F* d0K0SOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,1000,-1.,1.);
1928  TH2F* d0K0SOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,1000,-1.,1.);
1929 
1930  nameHistoSgn="histD0POfflineSgn";
1931  nameHistoBkg="histD0POfflineBkg";
1932  titleHistoSgn="d_{0}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(p) [cm]; Entries";
1933  titleHistoBkg="d_{0}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(p) [cm]; Entries";
1934  TH2F* d0POfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),11,binLimpTLc,1000,-1.,1.);
1935  TH2F* d0POfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),11,binLimpTLc,1000,-1.,1.);
1936 
1937  nameHistoSgn="histCosPAK0SOfflineSgn";
1938  nameHistoBkg="histCosPAK0SOfflineBkg";
1939  titleHistoSgn="K^{0}_{S} cosine of pointing angle wrt primary vertex vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
1940  titleHistoBkg="K^{0}_{S} cosine of pointing angle wrt primary vertex vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
1941  TH2F *cosPAK0SOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),41,binLimpTprong,100,0.99,1.);
1942  TH2F *cosPAK0SOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),41,binLimpTprong,100,0.99,1.);
1943 
1944  nameHistoSgn="histCosThetaProtonCMSOfflineSgn";
1945  nameHistoBkg="histCosThetaProtonCMSOfflineBkg";
1946  titleHistoSgn="cosien of proton emission angle in Lc rest frame; p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
1947  titleHistoBkg="cosien of proton emission angle in Lc rest frame; p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
1948  TH2F *cosThePrOfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),41,binLimpTprong,100,-1.,1.);
1949  TH2F *cosThePrOfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),41,binLimpTprong,100,-1.,1.);
1950 
1951 
1952  nameHistoSgn="histResignedD0OfflineSgn";
1953  nameHistoBkg="histResignedD0OfflineBkg";
1954  titleHistoSgn="Proton d0 with different sign convention; p_{T}(#Lambda_{c}) [GeV/c]; d0 [cm]; Entries";
1955  titleHistoBkg="Proton d0 with different sign convention; p_{T}(#Lambda_{c}) [GeV/c]; d0 [cm]; Entries";
1956  TH2F *resignedD0OfflineSgn = new TH2F(nameHistoSgn.Data(),titleHistoSgn.Data(),41,binLimpTprong,100,-0.1,0.1);
1957  TH2F *resignedD0OfflineBkg = new TH2F(nameHistoBkg.Data(),titleHistoBkg.Data(),41,binLimpTprong,100,-0.1,0.1);
1958 
1959  TH2F* allptK0SOfflineSgn = (TH2F*)ptK0SOfflineSgn->Clone();
1960  TH2F* allptK0SOfflineBkg = (TH2F*)ptK0SOfflineBkg->Clone();
1961  TH2F* allptPOfflineSgn = (TH2F*)ptPOfflineSgn->Clone();
1962  TH2F* allptPOfflineBkg = (TH2F*)ptPOfflineBkg->Clone();
1963  TH2F* allptPiPOfflineSgn = (TH2F*)ptPiPOfflineSgn->Clone();
1964  TH2F* allptPiPOfflineBkg = (TH2F*)ptPiPOfflineBkg->Clone();
1965  TH2F* allptPiMOfflineSgn = (TH2F*)ptPiMOfflineSgn->Clone();
1966  TH2F* allptPiMOfflineBkg = (TH2F*)ptPiMOfflineBkg->Clone();
1967  TH2F* allmassLambdaOfflineSgn = (TH2F*)massLambdaOfflineSgn->Clone();
1968  TH2F* allmassLambdaOfflineBkg = (TH2F*)massLambdaOfflineBkg->Clone();
1969  TH2F* allmassLambdaBarOfflineSgn = (TH2F*)massLambdaBarOfflineSgn->Clone();
1970  TH2F* allmassLambdaBarOfflineBkg = (TH2F*)massLambdaBarOfflineBkg->Clone();
1971  TH2F* allmassGammaOfflineSgn = (TH2F*)massGammaOfflineSgn->Clone();
1972  TH2F* allmassGammaOfflineBkg = (TH2F*)massGammaOfflineBkg->Clone();
1973  TH2F* alld0K0SOfflineSgn = (TH2F*)d0K0SOfflineSgn->Clone();
1974  TH2F* alld0K0SOfflineBkg = (TH2F*)d0K0SOfflineBkg->Clone();
1975  TH2F* alld0POfflineSgn = (TH2F*)d0POfflineSgn->Clone();
1976  TH2F* alld0POfflineBkg = (TH2F*)d0POfflineBkg->Clone();
1977  TH2F* allcosPAK0SOfflineSgn = (TH2F*)cosPAK0SOfflineSgn->Clone();
1978  TH2F* allcosPAK0SOfflineBkg = (TH2F*)cosPAK0SOfflineBkg->Clone();
1979  TH2F* allcosThePrOfflineSgn = (TH2F*)cosThePrOfflineSgn->Clone();
1980  TH2F* allcosThePrOfflineBkg = (TH2F*)cosThePrOfflineBkg->Clone();
1981  TH2F* allresignedD0OfflineSgn = (TH2F*)resignedD0OfflineSgn->Clone();
1982  TH2F* allresignedD0OfflineBkg = (TH2F*)resignedD0OfflineBkg->Clone();
1983 
1984  TH2F* pidptK0SOfflineSgn = (TH2F*)ptK0SOfflineSgn->Clone();
1985  TH2F* pidptK0SOfflineBkg = (TH2F*)ptK0SOfflineBkg->Clone();
1986  TH2F* pidptPOfflineSgn = (TH2F*)ptPOfflineSgn->Clone();
1987  TH2F* pidptPOfflineBkg = (TH2F*)ptPOfflineBkg->Clone();
1988  TH2F* pidptPiPOfflineSgn = (TH2F*)ptPiPOfflineSgn->Clone();
1989  TH2F* pidptPiPOfflineBkg = (TH2F*)ptPiPOfflineBkg->Clone();
1990  TH2F* pidptPiMOfflineSgn = (TH2F*)ptPiMOfflineSgn->Clone();
1991  TH2F* pidptPiMOfflineBkg = (TH2F*)ptPiMOfflineBkg->Clone();
1992  TH2F* pidmassLambdaOfflineSgn = (TH2F*)massLambdaOfflineSgn->Clone();
1993  TH2F* pidmassLambdaOfflineBkg = (TH2F*)massLambdaOfflineBkg->Clone();
1994  TH2F* pidmassLambdaBarOfflineSgn = (TH2F*)massLambdaBarOfflineSgn->Clone();
1995  TH2F* pidmassLambdaBarOfflineBkg = (TH2F*)massLambdaBarOfflineBkg->Clone();
1996  TH2F* pidmassGammaOfflineSgn = (TH2F*)massGammaOfflineSgn->Clone();
1997  TH2F* pidmassGammaOfflineBkg = (TH2F*)massGammaOfflineBkg->Clone();
1998  TH2F* pidd0K0SOfflineSgn = (TH2F*)d0K0SOfflineSgn->Clone();
1999  TH2F* pidd0K0SOfflineBkg = (TH2F*)d0K0SOfflineBkg->Clone();
2000  TH2F* pidd0POfflineSgn = (TH2F*)d0POfflineSgn->Clone();
2001  TH2F* pidd0POfflineBkg = (TH2F*)d0POfflineBkg->Clone();
2002  TH2F* pidcosPAK0SOfflineSgn = (TH2F*)cosPAK0SOfflineSgn->Clone();
2003  TH2F* pidcosPAK0SOfflineBkg = (TH2F*)cosPAK0SOfflineBkg->Clone();
2004  TH2F* pidcosThePrOfflineSgn = (TH2F*)cosThePrOfflineSgn->Clone();
2005  TH2F* pidcosThePrOfflineBkg = (TH2F*)cosThePrOfflineBkg->Clone();
2006  TH2F* pidresignedD0OfflineSgn = (TH2F*)resignedD0OfflineSgn->Clone();
2007  TH2F* pidresignedD0OfflineBkg = (TH2F*)resignedD0OfflineBkg->Clone();
2008 
2009  fOutputAll->Add(allptK0SOfflineSgn);
2010  fOutputAll->Add(allptK0SOfflineBkg);
2011  fOutputAll->Add(allptPOfflineSgn);
2012  fOutputAll->Add(allptPOfflineBkg);
2013  fOutputAll->Add(allptPiPOfflineSgn);
2014  fOutputAll->Add(allptPiPOfflineBkg);
2015  fOutputAll->Add(allptPiMOfflineSgn);
2016  fOutputAll->Add(allptPiMOfflineBkg);
2017  fOutputAll->Add(allmassLambdaOfflineSgn);
2018  fOutputAll->Add(allmassLambdaOfflineBkg);
2019  fOutputAll->Add(allmassLambdaBarOfflineSgn);
2020  fOutputAll->Add(allmassLambdaBarOfflineBkg);
2021  fOutputAll->Add(allmassGammaOfflineSgn);
2022  fOutputAll->Add(allmassGammaOfflineBkg);
2023  fOutputAll->Add(alld0K0SOfflineSgn);
2024  fOutputAll->Add(alld0K0SOfflineBkg);
2025  fOutputAll->Add(alld0POfflineSgn);
2026  fOutputAll->Add(alld0POfflineBkg);
2027  fOutputAll->Add(allcosPAK0SOfflineSgn);
2028  fOutputAll->Add(allcosPAK0SOfflineBkg);
2029  fOutputAll->Add(allcosThePrOfflineSgn);
2030  fOutputAll->Add(allcosThePrOfflineBkg);
2031  fOutputAll->Add(allresignedD0OfflineSgn);
2032  fOutputAll->Add(allresignedD0OfflineBkg);
2033 
2034  fOutputPIDBach->Add(pidptK0SOfflineSgn);
2035  fOutputPIDBach->Add(pidptK0SOfflineBkg);
2036  fOutputPIDBach->Add(pidptPOfflineSgn);
2037  fOutputPIDBach->Add(pidptPOfflineBkg);
2038  fOutputPIDBach->Add(pidptPiPOfflineSgn);
2039  fOutputPIDBach->Add(pidptPiPOfflineBkg);
2040  fOutputPIDBach->Add(pidptPiMOfflineSgn);
2041  fOutputPIDBach->Add(pidptPiMOfflineBkg);
2042  fOutputPIDBach->Add(pidmassLambdaOfflineSgn);
2043  fOutputPIDBach->Add(pidmassLambdaOfflineBkg);
2044  fOutputPIDBach->Add(pidmassLambdaBarOfflineSgn);
2045  fOutputPIDBach->Add(pidmassLambdaBarOfflineBkg);
2046  fOutputPIDBach->Add(pidmassGammaOfflineSgn);
2047  fOutputPIDBach->Add(pidmassGammaOfflineBkg);
2048  fOutputPIDBach->Add(pidd0K0SOfflineSgn);
2049  fOutputPIDBach->Add(pidd0K0SOfflineBkg);
2050  fOutputPIDBach->Add(pidd0POfflineSgn);
2051  fOutputPIDBach->Add(pidd0POfflineBkg);
2052  fOutputPIDBach->Add(pidcosPAK0SOfflineSgn);
2053  fOutputPIDBach->Add(pidcosPAK0SOfflineBkg);
2054  fOutputPIDBach->Add(pidcosThePrOfflineSgn);
2055  fOutputPIDBach->Add(pidcosThePrOfflineBkg);
2056  fOutputPIDBach->Add(pidresignedD0OfflineSgn);
2057  fOutputPIDBach->Add(pidresignedD0OfflineBkg);
2058 
2059  if (fTrackRotation) {
2060 
2061  TH2F* pidTRptK0SOfflineSgn = (TH2F*)ptK0SOfflineSgn->Clone();
2062  TH2F* pidTRptK0SOfflineBkg = (TH2F*)ptK0SOfflineBkg->Clone();
2063  TH2F* pidTRptPOfflineSgn = (TH2F*)ptPOfflineSgn->Clone();
2064  TH2F* pidTRptPOfflineBkg = (TH2F*)ptPOfflineBkg->Clone();
2065  TH2F* pidTRptPiPOfflineSgn = (TH2F*)ptPiPOfflineSgn->Clone();
2066  TH2F* pidTRptPiPOfflineBkg = (TH2F*)ptPiPOfflineBkg->Clone();
2067  TH2F* pidTRptPiMOfflineSgn = (TH2F*)ptPiMOfflineSgn->Clone();
2068  TH2F* pidTRptPiMOfflineBkg = (TH2F*)ptPiMOfflineBkg->Clone();
2069  TH2F* pidTRmassLambdaOfflineSgn = (TH2F*)massLambdaOfflineSgn->Clone();
2070  TH2F* pidTRmassLambdaOfflineBkg = (TH2F*)massLambdaOfflineBkg->Clone();
2071  TH2F* pidTRmassLambdaBarOfflineSgn = (TH2F*)massLambdaBarOfflineSgn->Clone();
2072  TH2F* pidTRmassLambdaBarOfflineBkg = (TH2F*)massLambdaBarOfflineBkg->Clone();
2073  TH2F* pidTRmassGammaOfflineSgn = (TH2F*)massGammaOfflineSgn->Clone();
2074  TH2F* pidTRmassGammaOfflineBkg = (TH2F*)massGammaOfflineBkg->Clone();
2075  TH2F* pidTRcosPAK0SOfflineSgn = (TH2F*)cosPAK0SOfflineSgn->Clone();
2076  TH2F* pidTRcosPAK0SOfflineBkg = (TH2F*)cosPAK0SOfflineBkg->Clone();
2077  TH2F* pidTRcosThePrOfflineSgn = (TH2F*)cosThePrOfflineSgn->Clone();
2078  TH2F* pidTRcosThePrOfflineBkg = (TH2F*)cosThePrOfflineBkg->Clone();
2079  TH2F* pidTRresignedD0OfflineSgn = (TH2F*)resignedD0OfflineSgn->Clone();
2080  TH2F* pidTRresignedD0OfflineBkg = (TH2F*)resignedD0OfflineBkg->Clone();
2081  fOutputPIDBachTR->Add(pidTRptK0SOfflineSgn);
2082  fOutputPIDBachTR->Add(pidTRptK0SOfflineBkg);
2083  fOutputPIDBachTR->Add(pidTRptPOfflineSgn);
2084  fOutputPIDBachTR->Add(pidTRptPOfflineBkg);
2085  fOutputPIDBachTR->Add(pidTRptPiPOfflineSgn);
2086  fOutputPIDBachTR->Add(pidTRptPiPOfflineBkg);
2087  fOutputPIDBachTR->Add(pidTRptPiMOfflineSgn);
2088  fOutputPIDBachTR->Add(pidTRptPiMOfflineBkg);
2089  fOutputPIDBachTR->Add(pidTRmassLambdaOfflineSgn);
2090  fOutputPIDBachTR->Add(pidTRmassLambdaOfflineBkg);
2091  fOutputPIDBachTR->Add(pidTRmassLambdaBarOfflineSgn);
2092  fOutputPIDBachTR->Add(pidTRmassLambdaBarOfflineBkg);
2093  fOutputPIDBachTR->Add(pidTRmassGammaOfflineSgn);
2094  fOutputPIDBachTR->Add(pidTRmassGammaOfflineBkg);
2095  fOutputPIDBachTR->Add(pidTRcosPAK0SOfflineSgn);
2096  fOutputPIDBachTR->Add(pidTRcosPAK0SOfflineBkg);
2097  fOutputPIDBachTR->Add(pidTRcosThePrOfflineSgn);
2098  fOutputPIDBachTR->Add(pidTRcosThePrOfflineBkg);
2099  fOutputPIDBachTR->Add(pidTRresignedD0OfflineSgn);
2100  fOutputPIDBachTR->Add(pidTRresignedD0OfflineBkg);
2101 
2102  }
2103 
2104  } // useMCinfo
2105 
2106 
2107  if (fTrackRotation) {
2108 
2109  TH3F *phiVSthetaVSpt = new TH3F("phiVSthetaVSpt","",35,0.,35.,360,0.,2.*TMath::Pi(),100,40.*TMath::DegToRad(),140.*TMath::DegToRad());
2110  TH3F *phiVSthetaVSptRot = new TH3F("phiVSthetaVSptRot","",35,0.,35.,360,0.,2.*TMath::Pi(),100,40.*TMath::DegToRad(),140.*TMath::DegToRad());
2111  TH3F *phiVSthetaVSptOffline = new TH3F("phiVSthetaVSptOffline","",35,0.,35.,360,0.,2.*TMath::Pi(),100,40.*TMath::DegToRad(),140.*TMath::DegToRad());
2112  TH3F *phiVSthetaVSptRotOffline = new TH3F("phiVSthetaVSptRotOffline","",35,0.,35.,360,0.,2.*TMath::Pi(),100,40.*TMath::DegToRad(),140.*TMath::DegToRad());
2113  fOutputPIDBachTR->Add(phiVSthetaVSpt);
2114  fOutputPIDBachTR->Add(phiVSthetaVSptRot);
2115  fOutputPIDBachTR->Add(phiVSthetaVSptOffline);
2116  fOutputPIDBachTR->Add(phiVSthetaVSptRotOffline);
2117 
2118  TH1F *hNormRotated=new TH1F("hNormRotated","",fNRotations+1,-0.5,fNRotations+0.5);
2119  TH1F *hNormRotatedOffline=new TH1F("hNormRotatedOffline","",fNRotations+1,-0.5,fNRotations+0.5);
2120  /*
2121  hNormRotated->Sumw2();
2122  hNormRotatedOffline->Sumw2();
2123 
2124  hNormRotated->SetMinimum(0);
2125  hNormRotatedOffline->SetMinimum(0);
2126  */
2127 
2128  fOutputPIDBachTR->Add(hNormRotated);
2129  fOutputPIDBachTR->Add(hNormRotatedOffline);
2130 
2131  if (fUseMCInfo) {
2132 
2133  TH3F *phiVSthetaVSptSgn = new TH3F("phiVSthetaVSptSgn","",35,0.,35.,360,0.,2.*TMath::Pi(),100,40.*TMath::DegToRad(),140.*TMath::DegToRad());
2134  TH3F *phiVSthetaVSptRotSgn = new TH3F("phiVSthetaVSptRotSgn","",35,0.,35.,360,0.,2.*TMath::Pi(),100,40.*TMath::DegToRad(),140.*TMath::DegToRad());
2135  TH3F *phiVSthetaVSptOfflineSgn = new TH3F("phiVSthetaVSptOfflineSgn","",35,0.,35.,360,0.,2.*TMath::Pi(),100,40.*TMath::DegToRad(),140.*TMath::DegToRad());
2136  TH3F *phiVSthetaVSptRotOfflineSgn = new TH3F("phiVSthetaVSptRotOfflineSgn","",35,0.,35.,360,0.,2.*TMath::Pi(),100,40.*TMath::DegToRad(),140.*TMath::DegToRad());
2137  fOutputPIDBachTR->Add(phiVSthetaVSptSgn);
2138  fOutputPIDBachTR->Add(phiVSthetaVSptRotSgn);
2139  fOutputPIDBachTR->Add(phiVSthetaVSptOfflineSgn);
2140  fOutputPIDBachTR->Add(phiVSthetaVSptRotOfflineSgn);
2141 
2142  TH3F *phiVSthetaVSptBkg = new TH3F("phiVSthetaVSptBkg","",35,0.,35.,360,0.,2.*TMath::Pi(),100,40.*TMath::DegToRad(),140.*TMath::DegToRad());
2143  TH3F *phiVSthetaVSptRotBkg = new TH3F("phiVSthetaVSptRotBkg","",35,0.,35.,360,0.,2.*TMath::Pi(),100,40.*TMath::DegToRad(),140.*TMath::DegToRad());
2144  TH3F *phiVSthetaVSptOfflineBkg = new TH3F("phiVSthetaVSptOfflineBkg","",35,0.,35.,360,0.,2.*TMath::Pi(),100,40.*TMath::DegToRad(),140.*TMath::DegToRad());
2145  TH3F *phiVSthetaVSptRotOfflineBkg = new TH3F("phiVSthetaVSptRotOfflineBkg","",35,0.,35.,360,0.,2.*TMath::Pi(),100,40.*TMath::DegToRad(),140.*TMath::DegToRad());
2146  fOutputPIDBachTR->Add(phiVSthetaVSptBkg);
2147  fOutputPIDBachTR->Add(phiVSthetaVSptRotBkg);
2148  fOutputPIDBachTR->Add(phiVSthetaVSptOfflineBkg);
2149  fOutputPIDBachTR->Add(phiVSthetaVSptRotOfflineBkg);
2150 
2151  TH1F *hNormRotatedSgn=new TH1F("hNormRotatedSgn","",fNRotations+1,-0.5,fNRotations+0.5);
2152  TH1F *hNormRotatedOfflineSgn=new TH1F("hNormRotatedOfflineSgn","",fNRotations+1,-0.5,fNRotations+0.5);
2153  TH1F *hNormRotatedBkg=new TH1F("hNormRotatedBkg","",fNRotations+1,-0.5,fNRotations+0.5);
2154  TH1F *hNormRotatedOfflineBkg=new TH1F("hNormRotatedOfflineBkg","",fNRotations+1,-0.5,fNRotations+0.5);
2155  /*
2156  hNormRotatedSgn->Sumw2();
2157  hNormRotatedOfflineSgn->Sumw2();
2158  hNormRotatedBkg->Sumw2();
2159  hNormRotatedOfflineBkg->Sumw2();
2160 
2161  hNormRotatedSgn->SetMinimum(0);
2162  hNormRotatedOfflineSgn->SetMinimum(0);
2163  hNormRotatedBkg->SetMinimum(0);
2164  hNormRotatedOfflineBkg->SetMinimum(0);
2165  */
2166 
2167  fOutputPIDBachTR->Add(hNormRotatedSgn);
2168  fOutputPIDBachTR->Add(hNormRotatedOfflineSgn);
2169  fOutputPIDBachTR->Add(hNormRotatedBkg);
2170  fOutputPIDBachTR->Add(hNormRotatedOfflineBkg);
2171 
2172  }
2173 
2174  Int_t nMassBins=(Int_t)(fMaxMass*1000.-fMinMass*1000.);
2175  Double_t maxm=fMinMass+nMassBins*0.001;
2176  TH3F *hMassVsPtVsY=new TH3F("hMassVsPtVsY","",nMassBins,fMinMass,maxm,15,0.,15.,20,-1.,1.);
2177  TH3F *hMassVsPtVsYOffline=new TH3F("hMassVsPtVsYOffline","",nMassBins,fMinMass,maxm,15,0.,15.,20,-1.,1.);
2178  /*
2179  hMassVsPtVsY->Sumw2();
2180  hMassVsPtVsYOffline->Sumw2();
2181 
2182  hMassVsPtVsY->SetMinimum(0);
2183  hMassVsPtVsYOffline->SetMinimum(0);
2184  */
2185 
2186  fOutputPIDBachTR->Add(hMassVsPtVsY);
2187  fOutputPIDBachTR->Add(hMassVsPtVsYOffline);
2188 
2189  if (fUseMCInfo) {
2190 
2191  TH3F *hMassVsPtVsYSgn=new TH3F("hMassVsPtVsYSgn","",nMassBins,fMinMass,maxm,15,0.,15.,20,-1.,1.);
2192  TH3F *hMassVsPtVsYOfflineSgn=new TH3F("hMassVsPtVsYOfflineSgn","",nMassBins,fMinMass,maxm,15,0.,15.,20,-1.,1.);
2193  TH3F *hMassVsPtVsYBkg=new TH3F("hMassVsPtVsYBkg","",nMassBins,fMinMass,maxm,15,0.,15.,20,-1.,1.);
2194  TH3F *hMassVsPtVsYOfflineBkg=new TH3F("hMassVsPtVsYOfflineBkg","",nMassBins,fMinMass,maxm,15,0.,15.,20,-1.,1.);
2195 
2196  /*
2197  hMassVsPtVsYSgn->Sumw2();
2198  hMassVsPtVsYOfflineSgn->Sumw2();
2199  hMassVsPtVsYBkg->Sumw2();
2200  hMassVsPtVsYOfflineBkg->Sumw2();
2201 
2202  hMassVsPtVsYSgn->SetMinimum(0);
2203  hMassVsPtVsYOfflineSgn->SetMinimum(0);
2204  hMassVsPtVsYBkg->SetMinimum(0);
2205  hMassVsPtVsYOfflineBkg->SetMinimum(0);
2206  */
2207 
2208  fOutputPIDBachTR->Add(hMassVsPtVsYSgn);
2209  fOutputPIDBachTR->Add(hMassVsPtVsYOfflineSgn);
2210  fOutputPIDBachTR->Add(hMassVsPtVsYBkg);
2211  fOutputPIDBachTR->Add(hMassVsPtVsYOfflineBkg);
2212 
2213  }
2214 
2215  TH3F *hMassVsPtVsYRot=new TH3F("hMassVsPtVsYRot","",nMassBins,fMinMass,maxm,15,0.,15.,20,-1.,1.);
2216  TH3F *hMassVsPtVsYRotOffline=new TH3F("hMassVsPtVsYRotOffline","",nMassBins,fMinMass,maxm,15,0.,15.,20,-1.,1.);
2217  /*
2218  hMassVsPtVsYRot->Sumw2();
2219  hMassVsPtVsYRotOffline->Sumw2();
2220 
2221  hMassVsPtVsYRot->SetMinimum(0);
2222  hMassVsPtVsYRotOffline->SetMinimum(0);
2223  */
2224 
2225  fOutputPIDBachTR->Add(hMassVsPtVsYRot);
2226  fOutputPIDBachTR->Add(hMassVsPtVsYRotOffline);
2227 
2228  if (fUseMCInfo) {
2229 
2230  TH3F *hMassVsPtVsYRotSgn=new TH3F("hMassVsPtVsYRotSgn","",nMassBins,fMinMass,maxm,15,0.,15.,20,-1.,1.);
2231  TH3F *hMassVsPtVsYRotOfflineSgn=new TH3F("hMassVsPtVsYRotOfflineSgn","",nMassBins,fMinMass,maxm,15,0.,15.,20,-1.,1.);
2232  TH3F *hMassVsPtVsYRotBkg=new TH3F("hMassVsPtVsYRotBkg","",nMassBins,fMinMass,maxm,15,0.,15.,20,-1.,1.);
2233  TH3F *hMassVsPtVsYRotOfflineBkg=new TH3F("hMassVsPtVsYRotOfflineBkg","",nMassBins,fMinMass,maxm,15,0.,15.,20,-1.,1.);
2234  /*
2235  hMassVsPtVsYRotSgn->Sumw2();
2236  hMassVsPtVsYRotOfflineSgn->Sumw2();
2237  hMassVsPtVsYRotBkg->Sumw2();
2238  hMassVsPtVsYRotOfflineBkg->Sumw2();
2239 
2240  hMassVsPtVsYRotSgn->SetMinimum(0);
2241  hMassVsPtVsYRotOfflineSgn->SetMinimum(0);
2242  hMassVsPtVsYRotBkg->SetMinimum(0);
2243  hMassVsPtVsYRotOfflineBkg->SetMinimum(0);
2244  */
2245 
2246  fOutputPIDBachTR->Add(hMassVsPtVsYRotSgn);
2247  fOutputPIDBachTR->Add(hMassVsPtVsYRotOfflineSgn);
2248  fOutputPIDBachTR->Add(hMassVsPtVsYRotBkg);
2249  fOutputPIDBachTR->Add(hMassVsPtVsYRotOfflineBkg);
2250 
2251  }
2252 
2253  TH1F *hDeltaMass=new TH1F("hDeltaMass","",100,-0.4,0.4);
2254  TH1F *hDeltaMassOffline=new TH1F("hDeltaMassOffline","",100,-0.4,0.4);
2255  /*
2256  hDeltaMass->Sumw2();
2257  hDeltaMassOffline->Sumw2();
2258 
2259  hDeltaMass->SetMinimum(0);
2260  hDeltaMassOffline->SetMinimum(0);
2261  */
2262 
2263  fOutputPIDBachTR->Add(hDeltaMass);
2264  fOutputPIDBachTR->Add(hDeltaMassOffline);
2265 
2266  if (fUseMCInfo) {
2267 
2268  TH1F *hDeltaMassSgn=new TH1F("hDeltaMassSgn","",100,-0.4,0.4);
2269  TH1F *hDeltaMassOfflineSgn=new TH1F("hDeltaMassOfflineSgn","",100,-0.4,0.4);
2270  TH1F *hDeltaMassBkg=new TH1F("hDeltaMassBkg","",100,-0.4,0.4);
2271  TH1F *hDeltaMassOfflineBkg=new TH1F("hDeltaMassOfflineBkg","",100,-0.4,0.4);
2272  /*
2273  hDeltaMassSgn->Sumw2();
2274  hDeltaMassOfflineSgn->Sumw2();
2275  hDeltaMassBkg->Sumw2();
2276  hDeltaMassOfflineBkg->Sumw2();
2277 
2278  hDeltaMassSgn->SetMinimum(0);
2279  hDeltaMassOfflineSgn->SetMinimum(0);
2280  hDeltaMassBkg->SetMinimum(0);
2281  hDeltaMassOfflineBkg->SetMinimum(0);
2282  */
2283 
2284  fOutputPIDBachTR->Add(hDeltaMassSgn);
2285  fOutputPIDBachTR->Add(hDeltaMassOfflineSgn);
2286  fOutputPIDBachTR->Add(hDeltaMassBkg);
2287  fOutputPIDBachTR->Add(hDeltaMassOfflineBkg);
2288 
2289  }
2290 
2291  /*
2292  Int_t binSparseDMassRot[5]={nMassBins,100,24,40,20};
2293  Double_t edgeLowSparseDMassRot[5]={fMinMass,-0.4,0.,-4.,0};
2294  Double_t edgeHighSparseDMassRot[5]={maxm,0.4,12.,4.,3.14};
2295  THnSparse *hDeltaMassFullAnalysis=new THnSparseF("hDeltaMassFullAnalysis","hDeltaMassFullAnalysis;inv mass (GeV/c);#Delta inv mass (GeV/c); p_{T}^{#Lambda_{c}} (GeV/c); #Delta p_{T} (GeV/c); daughter angle (2prongs) (rad);",5,binSparseDMassRot,edgeLowSparseDMassRot,edgeHighSparseDMassRot);
2296  THnSparse *hDeltaMassFullAnalysisOffline=new THnSparseF("fDeltaMassFullAnalysisOffline","hDeltaMassFullAnalysisOffline;inv mass (GeV/c);#Delta inv mass (GeV/c); p_{T}^{#Lambda_{c}} (GeV/c); #Delta p_{T} (GeV/c); daughter angle (2prongs) (rad);",5,binSparseDMassRot,edgeLowSparseDMassRot,edgeHighSparseDMassRot);
2297 
2298  fOutputPIDBachTR->Add(hDeltaMassFullAnalysis);
2299  fOutputPIDBachTR->Add(hDeltaMassFullAnalysisOffline);
2300 
2301  if (fUseMCInfo) {
2302 
2303  THnSparse *hDeltaMassFullAnalysisSgn=new THnSparseF("hDeltaMassFullAnalysisSgn","hDeltaMassFullAnalysisSgn;inv mass (GeV/c);#Delta inv mass (GeV/c); p_{T}^{#Lambda_{c}} (GeV/c); #Delta p_{T} (GeV/c); daughter angle (2prongs) (rad);",5,binSparseDMassRot,edgeLowSparseDMassRot,edgeHighSparseDMassRot);
2304  THnSparse *hDeltaMassFullAnalysisOfflineSgn=new THnSparseF("fDeltaMassFullAnalysisOfflineSgn","hDeltaMassFullAnalysisOfflineSgn;inv mass (GeV/c);#Delta inv mass (GeV/c); p_{T}^{#Lambda_{c}} (GeV/c); #Delta p_{T} (GeV/c); daughter angle (2prongs) (rad);",5,binSparseDMassRot,edgeLowSparseDMassRot,edgeHighSparseDMassRot);
2305 
2306  THnSparse *hDeltaMassFullAnalysisBkg=new THnSparseF("hDeltaMassFullAnalysisBkg","hDeltaMassFullAnalysisBkg;inv mass (GeV/c);#Delta inv mass (GeV/c); p_{T}^{#Lambda_{c}} (GeV/c); #Delta p_{T} (GeV/c); daughter angle (2prongs) (rad);",5,binSparseDMassRot,edgeLowSparseDMassRot,edgeHighSparseDMassRot);
2307  THnSparse *hDeltaMassFullAnalysisOfflineBkg=new THnSparseF("fDeltaMassFullAnalysisOfflineBkg","hDeltaMassFullAnalysisOfflineBkg;inv mass (GeV/c);#Delta inv mass (GeV/c); p_{T}^{#Lambda_{c}} (GeV/c); #Delta p_{T} (GeV/c); daughter angle (2prongs) (rad);",5,binSparseDMassRot,edgeLowSparseDMassRot,edgeHighSparseDMassRot);
2308 
2309  fOutputPIDBachTR->Add(hDeltaMassFullAnalysisSgn);
2310  fOutputPIDBachTR->Add(hDeltaMassFullAnalysisOfflineSgn);
2311  fOutputPIDBachTR->Add(hDeltaMassFullAnalysisBkg);
2312  fOutputPIDBachTR->Add(hDeltaMassFullAnalysisOfflineBkg);
2313 
2314  }
2315  */
2316 
2317  }
2318 
2320  TH2D *hMassvsPtInclusiveK0S = new TH2D("hMassvsPtInclusiveK0S","",100,mK0SPDG-0.05,mK0SPDG+0.05,20,0.,10.);
2321  TH2D *hMassvsPtInclusiveK0SSgn = new TH2D("hMassvsPtInclusiveK0SSgn","",100,mK0SPDG-0.05,mK0SPDG+0.05,20,0.,10.);
2322  TH3D *hMassvsPtInclusiveLambda = new TH3D("hMassvsPtInclusiveLambda","",100,mLPDG-0.025,mLPDG+0.025,20,0.,10.,62,0.,62);
2323  TH3D *hMassvsPtInclusiveLambdaLoosePID = new TH3D("hMassvsPtInclusiveLambdaLoosePID","",100,mLPDG-0.025,mLPDG+0.025,20,0.,10.,62,0.,62);
2324  TH3D *hMassvsPtInclusiveLambdaSgn = new TH3D("hMassvsPtInclusiveLambdaSgn","",100,mLPDG-0.025,mLPDG+0.025,20,0.,10.,62,0.,62);
2325  TH3D *hMassvsPtInclusiveLambdaLoosePIDSgn = new TH3D("hMassvsPtInclusiveLambdaLoosePIDSgn","",100,mLPDG-0.025,mLPDG+0.025,20,0.,10.,62,0.,62);
2326  TH3D *hMassvsPtInclusiveLambdaPID = (TH3D*)hMassvsPtInclusiveLambda->Clone();
2327  TH3D *hMassvsPtInclusiveLambdaPIDSgn = (TH3D*)hMassvsPtInclusiveLambdaSgn->Clone();
2328  TH3D *hMassvsPtInclusiveLambdaCosThetaStarPID = new TH3D("hMassvsPtInclusiveLambdaCosThetaStarPID","",100,mLPDG-0.025,mLPDG+0.025,20,0.,10.,40,-1.,1.);
2329  TH3D *hMassvsPtInclusiveLambdaCosThetaStarPIDSgn = new TH3D("hMassvsPtInclusiveLambdaCosThetaStarPIDSgn","",100,mLPDG-0.025,mLPDG+0.025,20,0.,10.,40,-1.,1.);
2330  fOutputAll->Add(hMassvsPtInclusiveK0S);
2331  fOutputAll->Add(hMassvsPtInclusiveK0SSgn);
2332  fOutputAll->Add(hMassvsPtInclusiveLambda);
2333  fOutputAll->Add(hMassvsPtInclusiveLambdaLoosePID);
2334  fOutputPIDBach->Add(hMassvsPtInclusiveLambdaPID);
2335  fOutputAll->Add(hMassvsPtInclusiveLambdaSgn);
2336  fOutputAll->Add(hMassvsPtInclusiveLambdaLoosePIDSgn);
2337  fOutputPIDBach->Add(hMassvsPtInclusiveLambdaPIDSgn);
2338  fOutputPIDBach->Add(hMassvsPtInclusiveLambdaCosThetaStarPID);
2339  fOutputPIDBach->Add(hMassvsPtInclusiveLambdaCosThetaStarPIDSgn);
2340  }
2341 
2342  /*
2343  fOutputAll->Print();
2344  fOutputPIDBach->Print();
2345  if (fTrackRotation) fOutputPIDBachTR->Print();
2346  */
2347  return;
2348 }
2349 
2350 //-------------------------------------------------------------------------------
2352  TClonesArray *mcArray,
2353  AliRDHFCutsLctoV0 *cutsAnal)
2354 {
2355 
2356  //
2357  // make single analysis for the systematics studies
2358  // 1: Inclusive K0s (Tracking, K0S cut variation)
2359  // 2: Proton from Lambda (PID, Tracking TPC(not yet))
2360  //
2361 
2362  Double_t mLPDG = TDatabasePDG::Instance()->GetParticle(3122)->Mass();
2363 
2364  //Int_t nTracks = aodEvent->GetNumberOfTracks();
2365  Int_t nV0s = aodEvent->GetNumberOfV0s();
2366 
2367  Double_t pos[3]; fVtx1->GetXYZ(pos);
2368  Double_t cov[6]; fVtx1->GetCovarianceMatrix(cov);
2369  const AliESDVertex vESD(pos,cov,100.,100);
2370 
2371  AliESDtrackCuts *trkCuts = fAnalCuts->GetTrackCuts();
2372  AliESDtrackCuts *v0trkCuts = fAnalCuts->GetTrackCutsV0daughters();
2373  const Float_t *cutVars = fAnalCuts->GetCuts();
2374 
2375  //1: Inclusive K0s
2376  for (Int_t iv0 = 0; iv0<nV0s; iv0++) {
2377  AliAODv0 *v0 = aodEvent->GetV0(iv0);
2378  if(!v0) continue;
2379  AliAODTrack *ptrk = dynamic_cast<AliAODTrack*>(v0->GetDaughter(0));
2380  if (!ptrk) continue;
2381  AliAODTrack *ntrk = dynamic_cast<AliAODTrack*>(v0->GetDaughter(1));
2382  if (!ntrk) continue;
2383 
2384  Float_t etaMin=0, etaMax=0; v0trkCuts->GetEtaRange(etaMin,etaMax);
2385  if ( (ptrk->Eta()<=etaMin || ptrk->Eta()>=etaMax) ||
2386  (ntrk->Eta()<=etaMin || ntrk->Eta()>=etaMax) ) continue;
2387  Float_t ptMin=0, ptMax=0; v0trkCuts->GetPtRange(ptMin,ptMax);
2388  if ( (ptrk->Pt()<=ptMin || ptrk->Pt()>=ptMax) ||
2389  (ntrk->Pt()<=ptMin || ntrk->Pt()>=ptMax) ) continue;
2390 
2391  // Condition on nTPCclusters
2392  if (v0trkCuts->GetMinNClusterTPC()>0) {
2393  if ( ( ( ptrk->GetTPCClusterInfo(2,1) ) < v0trkCuts->GetMinNClusterTPC() ) ||
2394  ( ( ntrk->GetTPCClusterInfo(2,1) ) < v0trkCuts->GetMinNClusterTPC() ) ) continue;
2395  }
2396 
2397  if (v0trkCuts->GetMinRatioCrossedRowsOverFindableClustersTPC()>0.5) {
2398  Float_t ratioCrossedRowsOverFindableClustersTPCPos = 1.0;
2399  Float_t ratioCrossedRowsOverFindableClustersTPCNeg = 1.0;
2400  if (ptrk->GetTPCNclsF()>0) {
2401  ratioCrossedRowsOverFindableClustersTPCPos = ptrk->GetTPCClusterInfo(2,1) / ptrk->GetTPCNclsF();
2402  }
2403  if (ntrk->GetTPCNclsF()>0) {
2404  ratioCrossedRowsOverFindableClustersTPCNeg = ntrk->GetTPCClusterInfo(2,1) / ntrk->GetTPCNclsF();
2405  }
2406  if ( ( ( ratioCrossedRowsOverFindableClustersTPCPos ) < v0trkCuts->GetMinRatioCrossedRowsOverFindableClustersTPC() ) ||
2407  ( ( ratioCrossedRowsOverFindableClustersTPCNeg ) < v0trkCuts->GetMinRatioCrossedRowsOverFindableClustersTPC() ) ) continue;
2408  }
2409 
2410  // kTPCrefit status
2411  if (v0->GetOnFlyStatus()==kFALSE) { // only for offline V0s
2412  if (v0trkCuts->GetRequireTPCRefit()) {
2413  if( !(ptrk->GetStatus() & AliESDtrack::kTPCrefit)) continue;
2414  if( !(ntrk->GetStatus() & AliESDtrack::kTPCrefit)) continue;
2415  }
2416  }
2417 
2418  AliESDtrack esdTrackP(ptrk);
2419  esdTrackP.SetTPCClusterMap(ptrk->GetTPCClusterMap());
2420  esdTrackP.SetTPCSharedMap(ptrk->GetTPCSharedMap());
2421  esdTrackP.SetTPCPointsF(ptrk->GetTPCNclsF());
2422  esdTrackP.RelateToVertex(&vESD,0.,3.);
2423 
2424  AliESDtrack esdTrackN(ntrk);
2425  esdTrackN.SetTPCClusterMap(ntrk->GetTPCClusterMap());
2426  esdTrackN.SetTPCSharedMap(ntrk->GetTPCSharedMap());
2427  esdTrackN.SetTPCPointsF(ntrk->GetTPCNclsF());
2428  esdTrackN.RelateToVertex(&vESD,0.,3.);
2429 
2430  //appliyng TPC crossed rows pT dependent cut
2432  if(tmptxt.Contains("pt")){
2433  tmptxt.ReplaceAll("pt","x");
2434  TF1 funcCutMin("funcCutMin",tmptxt);
2435  Float_t nCrossedRowsTPCP = esdTrackP.GetTPCCrossedRows();
2436  Float_t nCrossedRowsTPCN = esdTrackN.GetTPCCrossedRows();
2437  if(nCrossedRowsTPCP<funcCutMin.Eval(esdTrackP.Pt())) continue;
2438  if(nCrossedRowsTPCN<funcCutMin.Eval(esdTrackN.Pt())) continue;
2439  }
2440 
2441  //appliyng NTPCcls/NTPCcrossedRows cut
2443  Float_t nCrossedRowsTPCP = esdTrackP.GetTPCCrossedRows();
2444  Float_t nCrossedRowsTPCN = esdTrackN.GetTPCCrossedRows();
2445  Float_t nClustersTPCP = esdTrackP.GetTPCNcls();
2446  Float_t nClustersTPCN = esdTrackN.GetTPCNcls();
2447  if(nCrossedRowsTPCP!=0){
2448  Float_t ratioP = nClustersTPCP/nCrossedRowsTPCP;
2449  if(ratioP<fAnalCuts->GetMinRatioClsOverCrossRowsTPC()) continue;
2450  }
2451  else continue;
2452  if(nCrossedRowsTPCN!=0){
2453  Float_t ratioN = nClustersTPCN/nCrossedRowsTPCN;
2454  if(ratioN<fAnalCuts->GetMinRatioClsOverCrossRowsTPC()) continue;
2455  }
2456  else continue;
2457  }
2458 
2459  //appliyng TPCsignalN/NTPCcrossedRows cut
2461  Float_t nCrossedRowsTPCP = esdTrackP.GetTPCCrossedRows();
2462  Float_t nCrossedRowsTPCN = esdTrackN.GetTPCCrossedRows();
2463  Float_t nTPCsignalP = esdTrackP.GetTPCsignalN();
2464  Float_t nTPCsignalN = esdTrackN.GetTPCsignalN();
2465  if(nCrossedRowsTPCP!=0){
2466  Float_t ratioP = nTPCsignalP/nCrossedRowsTPCP;
2467  if(ratioP<fAnalCuts->GetMinRatioSignalNOverCrossRowsTPC()) continue;
2468  }
2469  else continue;
2470  if(nCrossedRowsTPCN!=0){
2471  Float_t ratioN = nTPCsignalN/nCrossedRowsTPCN;
2472  if(ratioN<fAnalCuts->GetMinRatioSignalNOverCrossRowsTPC()) continue;
2473  }
2474  else continue;
2475  }
2476 
2477  // kink condition
2478  if (!v0trkCuts->GetAcceptKinkDaughters()) {
2479  AliAODVertex *maybeKinkPos = (AliAODVertex*)ptrk->GetProdVertex();
2480  AliAODVertex *maybeKinkNeg = (AliAODVertex*)ntrk->GetProdVertex();
2481  if (maybeKinkPos->GetType()==AliAODVertex::kKink ||
2482  maybeKinkNeg->GetType()==AliAODVertex::kKink) continue;
2483  }
2484 
2485  //RDHF cuts
2486  if(ptrk->Pt()<cutVars[fAnalCuts->GetGlobalIndex(5,0)] || ntrk->Pt()<cutVars[fAnalCuts->GetGlobalIndex(6,0)]) continue;
2487  if(v0->GetDCA()>cutVars[fAnalCuts->GetGlobalIndex(8,0)]) continue;
2488  if(v0->CosPointingAngle(pos)<cutVars[fAnalCuts->GetGlobalIndex(9,0)]) continue;
2489  if(v0->DcaV0ToPrimVertex()>cutVars[fAnalCuts->GetGlobalIndex(11,0)]) continue;
2490  if((v0->PtArmV0()/TMath::Abs(v0->AlphaV0())<cutVars[fAnalCuts->GetGlobalIndex(19,0)])) continue;
2491 
2492  if(TMath::Abs(v0->MassLambda()-mLPDG) < cutVars[fAnalCuts->GetGlobalIndex(13,0)]) continue;
2493  if(TMath::Abs(v0->MassAntiLambda()-mLPDG) < cutVars[fAnalCuts->GetGlobalIndex(13,0)]) continue;
2494  if(v0->InvMass2Prongs(0,1,11,11) < cutVars[fAnalCuts->GetGlobalIndex(13,0)]) continue;
2495 
2496  ((TH2D*)(fOutputAll->FindObject("hMassvsPtInclusiveK0S")))->Fill(v0->MassK0Short(),v0->Pt());
2497 
2498  if(fUseMCInfo){
2499  Int_t pdgdgv0[2]={211,211};
2500  Int_t labV0 = v0->MatchToMC(310,mcArray,2,pdgdgv0); // the V0
2501  if(labV0>=0){
2502  AliAODMCParticle *mcv0 = (AliAODMCParticle*) mcArray->At(labV0);
2503  if(mcv0){
2504  ((TH2D*)(fOutputAll->FindObject("hMassvsPtInclusiveK0SSgn")))->Fill(v0->MassK0Short(),v0->Pt());
2505  }
2506  }
2507  }
2508  }
2509 
2510  //2: Proton from Lambda
2511  for (Int_t iv0 = 0; iv0<nV0s; iv0++) {
2512  AliAODv0 *v0 = aodEvent->GetV0(iv0);
2513  if(!v0) continue;
2514  AliAODTrack *ptrk = dynamic_cast<AliAODTrack*>(v0->GetDaughter(0));
2515  if (!ptrk) continue;
2516  AliAODTrack *ntrk = dynamic_cast<AliAODTrack*>(v0->GetDaughter(1));
2517  if (!ntrk) continue;
2518 
2519  Float_t etaMin=0, etaMax=0; trkCuts->GetEtaRange(etaMin,etaMax);
2520  if ( (ptrk->Eta()<=etaMin || ptrk->Eta()>=etaMax) ||
2521  (ntrk->Eta()<=etaMin || ntrk->Eta()>=etaMax) ) continue;
2522  Float_t ptMin=0, ptMax=0; trkCuts->GetPtRange(ptMin,ptMax);
2523  if ( (ptrk->Pt()<=ptMin || ptrk->Pt()>=ptMax) ||
2524  (ntrk->Pt()<=ptMin || ntrk->Pt()>=ptMax) ) continue;
2525 
2526 
2527  // kTPCrefit status
2528  if (v0->GetOnFlyStatus()==kFALSE) { // only for offline V0s
2529  if (trkCuts->GetRequireTPCRefit()) {
2530  if( !(ptrk->GetStatus() & AliESDtrack::kTPCrefit)) continue;
2531  if( !(ntrk->GetStatus() & AliESDtrack::kTPCrefit)) continue;
2532  }
2533  }
2534 
2535  // kink condition
2536  if (!trkCuts->GetAcceptKinkDaughters()) {
2537  AliAODVertex *maybeKinkPos = (AliAODVertex*)ptrk->GetProdVertex();
2538  AliAODVertex *maybeKinkNeg = (AliAODVertex*)ntrk->GetProdVertex();
2539  if (maybeKinkPos->GetType()==AliAODVertex::kKink ||
2540  maybeKinkNeg->GetType()==AliAODVertex::kKink) continue;
2541  }
2542 
2543  //Should decay before TPC
2544  Double_t dR = TMath::Sqrt(v0->DecayVertexV0X()*v0->DecayVertexV0X()+v0->DecayVertexV0Y()*v0->DecayVertexV0Y());
2545  if(dR>40.) continue;
2546  if(dR<2.) continue;
2547 
2548  //Use the topological cuts for K0s to improve S/B
2549  if(v0->GetDCA()>cutVars[fAnalCuts->GetGlobalIndex(8,0)]) continue;
2550  if(v0->CosPointingAngle(pos)<cutVars[fAnalCuts->GetGlobalIndex(9,0)]) continue;
2551 
2552 
2553  Int_t LType = 0;
2554  if(TMath::Abs(v0->MassLambda()-mLPDG)<0.02) LType += 1;
2555  if(TMath::Abs(v0->MassAntiLambda()-mLPDG)<0.02) LType += 2;
2556  if(LType==3) continue;//to avoid complexity
2557 
2558  AliAODMCParticle *mcv0 = 0x0;
2559  if(fUseMCInfo){
2560  Int_t pdgdgv0[2]={2212,211};
2561  Int_t labV0 = v0->MatchToMC(3122,mcArray,2,pdgdgv0); // the V0
2562  if(labV0>=0){
2563  mcv0 = (AliAODMCParticle*) mcArray->At(labV0);
2564  }
2565  }
2566 
2567  AliESDtrack esdTrackP(ptrk);
2568  esdTrackP.SetTPCClusterMap(ptrk->GetTPCClusterMap());
2569  esdTrackP.SetTPCSharedMap(ptrk->GetTPCSharedMap());
2570  esdTrackP.SetTPCPointsF(ptrk->GetTPCNclsF());
2571  esdTrackP.RelateToVertex(&vESD,0.,3.);
2572 
2573  AliESDtrack esdTrackN(ntrk);
2574  esdTrackN.SetTPCClusterMap(ntrk->GetTPCClusterMap());
2575  esdTrackN.SetTPCSharedMap(ntrk->GetTPCSharedMap());
2576  esdTrackN.SetTPCPointsF(ntrk->GetTPCNclsF());
2577  esdTrackN.RelateToVertex(&vESD,0.,3.);
2578 
2579  // Condition on nTPCclusters
2580  if (trkCuts->GetMinNClusterTPC()>0) {
2581  if(LType==1){
2582  if ( ( ( ptrk->GetTPCClusterInfo(2,1) ) < trkCuts->GetMinNClusterTPC() ) ||
2583  ( ( ntrk->GetTPCClusterInfo(2,1) ) < 70 ) ) continue;
2584  }
2585  if(LType==2){
2586  if ( ( ( ntrk->GetTPCClusterInfo(2,1) ) < trkCuts->GetMinNClusterTPC() ) ||
2587  ( ( ptrk->GetTPCClusterInfo(2,1) ) < 70 ) ) continue;
2588  }
2589  }
2590 
2591  if (trkCuts->GetMinRatioCrossedRowsOverFindableClustersTPC()>0.5) {
2592  Float_t ratioCrossedRowsOverFindableClustersTPCPos = 1.0;
2593  Float_t ratioCrossedRowsOverFindableClustersTPCNeg = 1.0;
2594  if (ptrk->GetTPCNclsF()>0) {
2595  ratioCrossedRowsOverFindableClustersTPCPos = ptrk->GetTPCClusterInfo(2,1) / ptrk->GetTPCNclsF();
2596  }
2597  if (ntrk->GetTPCNclsF()>0) {
2598  ratioCrossedRowsOverFindableClustersTPCNeg = ntrk->GetTPCClusterInfo(2,1) / ntrk->GetTPCNclsF();
2599  }
2600  if(LType==1){
2601  if ( ( ( ratioCrossedRowsOverFindableClustersTPCPos ) < trkCuts->GetMinRatioCrossedRowsOverFindableClustersTPC() ) ||
2602  ( ( ratioCrossedRowsOverFindableClustersTPCNeg ) < 0.8 ) ) continue;
2603  }
2604  if(LType==2){
2605  if ( ( ( ratioCrossedRowsOverFindableClustersTPCNeg ) < trkCuts->GetMinRatioCrossedRowsOverFindableClustersTPC() ) ||
2606  ( ( ratioCrossedRowsOverFindableClustersTPCPos ) < 0.8 ) ) continue;
2607  }
2608  }
2609 
2610  //appliyng TPC crossed rows pT dependent cut
2612  if(tmptxt.Contains("pt")){
2613  tmptxt.ReplaceAll("pt","x");
2614  TF1 funcCutMin("funcCutMin",tmptxt);
2615  Float_t nCrossedRowsTPCP = esdTrackP.GetTPCCrossedRows();
2616  Float_t nCrossedRowsTPCN = esdTrackN.GetTPCCrossedRows();
2617  if(LType==1 && nCrossedRowsTPCP<funcCutMin.Eval(esdTrackP.Pt())) continue;
2618  if(LType==2 && nCrossedRowsTPCN<funcCutMin.Eval(esdTrackN.Pt())) continue;
2619  }
2620 
2621  //appliyng NTPCcls/NTPCcrossedRows cut
2623  Float_t nCrossedRowsTPCP = esdTrackP.GetTPCCrossedRows();
2624  Float_t nCrossedRowsTPCN = esdTrackN.GetTPCCrossedRows();
2625  Float_t nClustersTPCP = esdTrackP.GetTPCNcls();
2626  Float_t nClustersTPCN = esdTrackN.GetTPCNcls();
2627  if(LType==1){
2628  if(nCrossedRowsTPCP!=0){
2629  Float_t ratioP = nClustersTPCP/nCrossedRowsTPCP;
2630  if(ratioP<fAnalCuts->GetMinRatioClsOverCrossRowsTPC()) continue;
2631  }
2632  else continue;
2633 
2634  }
2635  if(LType==2){
2636  if(nCrossedRowsTPCN!=0){
2637  Float_t ratioN = nClustersTPCN/nCrossedRowsTPCN;
2638  if(ratioN<fAnalCuts->GetMinRatioClsOverCrossRowsTPC()) continue;
2639  }
2640  else continue;
2641  }
2642  }
2643 
2644  //appliyng TPCsignalN/NTPCcrossedRows cut
2646  Float_t nCrossedRowsTPCP = esdTrackP.GetTPCCrossedRows();
2647  Float_t nCrossedRowsTPCN = esdTrackN.GetTPCCrossedRows();
2648  Float_t nTPCsignalP = esdTrackP.GetTPCsignalN();
2649  Float_t nTPCsignalN = esdTrackN.GetTPCsignalN();
2650  if(LType==1){
2651  if(nCrossedRowsTPCP!=0){
2652  Float_t ratioP = nTPCsignalP/nCrossedRowsTPCP;
2653  if(ratioP<fAnalCuts->GetMinRatioSignalNOverCrossRowsTPC()) continue;
2654  }
2655  else continue;
2656  }
2657  if(LType==2){
2658  if(nCrossedRowsTPCN!=0){
2659  Float_t ratioN = nTPCsignalN/nCrossedRowsTPCN;
2660  if(ratioN<fAnalCuts->GetMinRatioSignalNOverCrossRowsTPC()) continue;
2661  }
2662  else continue;
2663  }
2664  }
2665 
2666  if(LType==1){
2667  Double_t nTPCsigmas=-9999, nTOFsigmas=-9999;
2668  fAnalCuts->GetPidHF()->GetnSigmaTPC(ptrk,4,nTPCsigmas);
2669  fAnalCuts->GetPidHF()->GetnSigmaTOF(ptrk,4,nTOFsigmas);
2670  Bool_t PIDOK=kFALSE;
2671  switch(fAnalCuts->GetPidSelectionFlag()){
2672  case 10:
2673  if(TMath::Abs(nTPCsigmas)<3. && TMath::Abs(nTOFsigmas)<3.){
2674  PIDOK = !(ptrk->Pt()>fAnalCuts->GetLowPtCut()&& nTOFsigmas<-2.)&&!(ptrk->Pt()>fAnalCuts->GetLowPtCut()&&nTPCsigmas>2.);
2675  }
2676  break;
2677  }
2678  ((TH3D*)(fOutputAll->FindObject("hMassvsPtInclusiveLambda")))->Fill(v0->MassLambda(),ptrk->Pt(),dR);
2679  if(TMath::Abs(nTPCsigmas)<5&&TMath::Abs(nTOFsigmas)<5){
2680  ((TH3D*)(fOutputAll->FindObject("hMassvsPtInclusiveLambdaLoosePID")))->Fill(v0->MassLambda(),ptrk->Pt(),dR);
2681  }
2682 
2683  Double_t bachcosthe = -9999;
2684  if(PIDOK){
2685  ((TH3D*)(fOutputPIDBach->FindObject("hMassvsPtInclusiveLambda")))->Fill(v0->MassLambda(),ptrk->Pt(),dR);
2686  TLorentzVector vpr, vpi,vlam;
2687  vpr.SetXYZM(ptrk->Px(),ptrk->Py(),ptrk->Pz(),0.938272081);
2688  vpi.SetXYZM(ntrk->Px(),ntrk->Py(),ntrk->Pz(),0.13957061);
2689  vlam = vpr + vpi;
2690  TVector3 vboost = vlam.BoostVector();
2691  vpr.Boost(-vboost);
2692  bachcosthe = cos(vpr.Angle(vlam.Vect()));
2693  ((TH3D*)(fOutputPIDBach->FindObject("hMassvsPtInclusiveLambdaCosThetaStarPID")))->Fill(v0->MassLambda(),ptrk->Pt(),bachcosthe);
2694  }
2695 
2696  if(fUseMCInfo && mcv0){
2697  ((TH3D*)(fOutputAll->FindObject("hMassvsPtInclusiveLambdaSgn")))->Fill(v0->MassLambda(),ptrk->Pt(),dR);
2698  if(TMath::Abs(nTPCsigmas)<5&&TMath::Abs(nTOFsigmas)<5){
2699  ((TH3D*)(fOutputAll->FindObject("hMassvsPtInclusiveLambdaLoosePIDSgn")))->Fill(v0->MassLambda(),ptrk->Pt(),dR);
2700  }
2701  if(PIDOK){
2702  ((TH3D*)(fOutputPIDBach->FindObject("hMassvsPtInclusiveLambdaSgn")))->Fill(v0->MassLambda(),ptrk->Pt(),dR);
2703  ((TH3D*)(fOutputPIDBach->FindObject("hMassvsPtInclusiveLambdaCosThetaStarPIDSgn")))->Fill(v0->MassLambda(),ptrk->Pt(),bachcosthe);
2704  }
2705 
2706  }
2707  }
2708  if(LType==2){
2709  Double_t nTPCsigmas=-9999, nTOFsigmas=-9999;
2710  fAnalCuts->GetPidHF()->GetnSigmaTPC(ntrk,4,nTPCsigmas);
2711  fAnalCuts->GetPidHF()->GetnSigmaTOF(ntrk,4,nTOFsigmas);
2712  Bool_t PIDOK=kFALSE;
2713  switch(fAnalCuts->GetPidSelectionFlag()){
2714  case 10:
2715  if(TMath::Abs(nTPCsigmas)<3. && TMath::Abs(nTOFsigmas)<3.){
2716  PIDOK = !(ptrk->Pt()>fAnalCuts->GetLowPtCut()&& nTOFsigmas<-2.)&&!(ptrk->Pt()>fAnalCuts->GetLowPtCut()&&nTPCsigmas>2.);
2717  }
2718  break;
2719  }
2720  ((TH3D*)(fOutputAll->FindObject("hMassvsPtInclusiveLambda")))->Fill(v0->MassAntiLambda(),ntrk->Pt(),dR);
2721  if(TMath::Abs(nTPCsigmas)<5&&TMath::Abs(nTOFsigmas)<5){
2722  ((TH3D*)(fOutputAll->FindObject("hMassvsPtInclusiveLambdaLoosePID")))->Fill(v0->MassAntiLambda(),ntrk->Pt(),dR);
2723  }
2724 
2725  Double_t bachcosthe = -9999;
2726  if(PIDOK){
2727  ((TH3D*)(fOutputPIDBach->FindObject("hMassvsPtInclusiveLambda")))->Fill(v0->MassAntiLambda(),ntrk->Pt(),dR);
2728  TLorentzVector vpr, vpi,vlam;
2729  vpr.SetXYZM(ntrk->Px(),ntrk->Py(),ntrk->Pz(),0.938272081);
2730  vpi.SetXYZM(ptrk->Px(),ptrk->Py(),ptrk->Pz(),0.13957061);
2731  vlam = vpr + vpi;
2732  TVector3 vboost = vlam.BoostVector();
2733  vpr.Boost(-vboost);
2734  bachcosthe = cos(vpr.Angle(vlam.Vect()));
2735  ((TH3D*)(fOutputPIDBach->FindObject("hMassvsPtInclusiveLambdaCosThetaStarPID")))->Fill(v0->MassLambda(),ntrk->Pt(),bachcosthe);
2736  }
2737  if(fUseMCInfo && mcv0){
2738  ((TH3D*)(fOutputAll->FindObject("hMassvsPtInclusiveLambdaSgn")))->Fill(v0->MassAntiLambda(),ntrk->Pt(),dR);
2739  if(TMath::Abs(nTPCsigmas)<5&&TMath::Abs(nTOFsigmas)<5){
2740  ((TH3D*)(fOutputAll->FindObject("hMassvsPtInclusiveLambdaLoosePIDSgn")))->Fill(v0->MassAntiLambda(),ntrk->Pt(),dR);
2741  }
2742  if(PIDOK){
2743  ((TH3D*)(fOutputPIDBach->FindObject("hMassvsPtInclusiveLambdaSgn")))->Fill(v0->MassAntiLambda(),ntrk->Pt(),dR);
2744  ((TH3D*)(fOutputPIDBach->FindObject("hMassvsPtInclusiveLambdaCosThetaStarPIDSgn")))->Fill(v0->MassLambda(),ntrk->Pt(),bachcosthe);
2745  }
2746  }
2747  }
2748  }
2749  return;
2750 }
2751 
2752 //---------------------------
2753 void AliAnalysisTaskSELc2V0bachelor::DoEventMixing(AliAODEvent *aodEvent,TClonesArray *mcArray,AliRDHFCutsLctoV0 *cutsAnal)
2754 {
2755  Double_t vtxz = fVtx1->GetZ();
2756  Double_t centrality = cutsAnal->GetCentrality(aodEvent);
2757  fPoolIndex=GetPoolIndex(vtxz,centrality);
2758  if(fPoolIndex<0) return;
2759 
2760  Int_t nextRes( fNextResVec[fPoolIndex] );
2761  while(!fReservoirP[fPoolIndex][nextRes].empty()){
2762  delete fReservoirP[fPoolIndex][nextRes].back();
2763  fReservoirP[fPoolIndex][nextRes].pop_back();
2764  }
2765 
2766  //Fill proton in the pool
2767  Int_t nTracks = aodEvent->GetNumberOfTracks();
2768  for (Int_t itrk = 0; itrk<nTracks; itrk++) {
2769  AliAODTrack *trk = (AliAODTrack*)aodEvent->GetTrack(itrk);
2770  if(!trk) continue;
2771  if(!cutsAnal->ApplySingleProtonCuts(trk,aodEvent)) continue;
2772 
2773  // Get AliExternalTrackParam out of the AliAODTracks
2774  Double_t xyz[3], pxpypz[3], cv[21]; Short_t sign;
2775  trk->PxPyPz(pxpypz);
2776  trk->GetXYZ(xyz);
2777  trk->GetCovarianceXYZPxPyPz(cv);
2778  sign=trk->Charge();
2779 
2780  TVector *varvec = new TVector(34);
2781  for(Int_t ic=0;ic<3;ic++){
2782  (*varvec)[ic] = pxpypz[ic];
2783  }
2784  for(Int_t ic=0;ic<3;ic++){
2785  (*varvec)[ic+3] = xyz[ic];
2786  }
2787  for(Int_t ic=0;ic<21;ic++){
2788  (*varvec)[ic+6] = cv[ic];
2789  }
2790  (*varvec)[27] = sign;
2791  (*varvec)[28] = fVtx1->GetX();
2792  (*varvec)[29] = fVtx1->GetY();
2793  (*varvec)[30] = fVtx1->GetZ();
2794 
2795  Double_t d0z0bach[2],covd0z0bach[3];
2796  trk->PropagateToDCA(fVtx1,fBzkG,kVeryBig,d0z0bach,covd0z0bach);
2797  (*varvec)[31] = d0z0bach[0];
2798  (*varvec)[32] = TMath::Sqrt(covd0z0bach[0]);
2799  (*varvec)[33] = (Float_t)trk->HasPointOnITSLayer(0);
2800 
2801  fReservoirP[fPoolIndex][nextRes].push_back(varvec);
2802  }
2803 
2804  // Do the event mixing for fPoolIndex
2805  Int_t KiddiePool = fReservoirP[fPoolIndex].size();
2806  if( !fReservoirsReady[fPoolIndex] ) KiddiePool = nextRes;
2807 
2808  if( KiddiePool>0 )
2809  {
2810  for(Int_t j=0;j<KiddiePool;j++){
2811  if( j!=nextRes )
2812  {
2813  FillMixedBackground(fReservoirP[fPoolIndex][j],aodEvent,cutsAnal);
2814  }
2815  }
2816  }
2817 
2818  // Rolling buffer
2819  nextRes++;
2820  if( nextRes>=fNumberOfEventsForMixing ){
2821  nextRes = 0;
2822  fReservoirsReady[fPoolIndex] = kTRUE;
2823  }
2824  fNextResVec[fPoolIndex] = nextRes;
2825 }
2826 
2827 //---------------------------
2829 {
2830 
2831  while(!fReservoirP[0][0].empty()){
2832  delete fReservoirP[0][0].back();
2833  fReservoirP[0][0].pop_back();
2834  }
2835 
2836  //Fill proton in the pool
2837  Int_t nTracks = aodEvent->GetNumberOfTracks();
2839  for (Int_t itrk = 0; itrk<nTracks; itrk++) {
2840  AliAODTrack *trk = (AliAODTrack*)aodEvent->GetTrack(itrk);
2841  if(!trk) continue;
2842  if(!cutsAnal->ApplySingleProtonCuts(trk,aodEvent)) continue;
2843 
2844  // Get AliExternalTrackParam out of the AliAODTracks
2845  Double_t xyz[3], pxpypz[3], pxpypznew[3], cv[21]; Short_t sign;
2846  trk->PxPyPz(pxpypz);
2847  trk->GetXYZ(xyz);
2848  trk->GetCovarianceXYZPxPyPz(cv);
2849  sign=trk->Charge();
2850 
2851  Double_t d0z0bach[2],covd0z0bach[3];
2852  trk->PropagateToDCA(fVtx1,fBzkG,kVeryBig,d0z0bach,covd0z0bach);
2853 
2854  for(Int_t irot=0;irot<fNRotations;irot++){
2855  Double_t phirot=fMinAngleForRot+rotStep*irot;
2856  Double_t tmpx=pxpypz[0];
2857  Double_t tmpy=pxpypz[1];
2858  pxpypznew[0] = tmpx*TMath::Cos(phirot)-tmpy*TMath::Sin(phirot);
2859  pxpypznew[1] = tmpx*TMath::Sin(phirot)+tmpy*TMath::Cos(phirot);
2860  pxpypznew[2] = pxpypz[2];
2861 
2862  TVector *varvec = new TVector(34);
2863  for(Int_t ic=0;ic<3;ic++){
2864  (*varvec)[ic] = pxpypznew[ic];
2865  }
2866  for(Int_t ic=0;ic<3;ic++){
2867  (*varvec)[ic+3] = xyz[ic];
2868  }
2869  for(Int_t ic=0;ic<21;ic++){
2870  (*varvec)[ic+6] = cv[ic];
2871  }
2872  (*varvec)[27] = sign;
2873  (*varvec)[28] = fVtx1->GetX();
2874  (*varvec)[29] = fVtx1->GetY();
2875  (*varvec)[30] = fVtx1->GetZ();
2876 
2877  (*varvec)[31] = d0z0bach[0];
2878  (*varvec)[32] = TMath::Sqrt(covd0z0bach[0]);
2879  (*varvec)[33] = (Float_t)trk->HasPointOnITSLayer(0);
2880 
2881  fReservoirP[0][0].push_back(varvec);
2882  }
2883  }
2884 
2885  FillMixedBackground(fReservoirP[0][0],aodEvent,cutsAnal);
2886 }
2887 
2888 //---------------------------
2889 void AliAnalysisTaskSELc2V0bachelor::FillMixedBackground(std::vector<TVector * > mixTypeP, AliAODEvent *aodEvent, AliRDHFCutsLctoV0 *cutsAnal)
2890 {
2891  //
2892  // Fill background
2893  //
2894  Double_t mLcPDG = TDatabasePDG::Instance()->GetParticle(4122)->Mass();
2895  Double_t mPrPDG = TDatabasePDG::Instance()->GetParticle(2212)->Mass();
2896  Double_t mK0SPDG = TDatabasePDG::Instance()->GetParticle(310)->Mass();
2897  Int_t nPr = mixTypeP.size();
2898  Int_t nV0s = aodEvent->GetNumberOfV0s();
2899 
2900  for(Int_t iv0=0;iv0<nV0s;iv0++){
2901  AliAODv0 *v0 = aodEvent->GetV0(iv0);
2902  if(!v0) continue;
2903  if(!cutsAnal->ApplySingleK0Cuts(v0,aodEvent)) continue;
2904 
2905  AliNeutralTrackParam *trackV0=NULL;
2906  const AliVTrack *trackVV0 = dynamic_cast<const AliVTrack*>(v0);
2907  if(trackVV0) trackV0 = new AliNeutralTrackParam(trackVV0);
2908 
2909  Double_t d0z0v0[2],covd0z0v0[2];
2910  trackV0->PropagateToDCA(fVtx1,fBzkG,kVeryBig,d0z0v0,covd0z0v0);
2911 
2912  for(Int_t ip=0;ip<nPr;ip++){
2913  TVector *pvars = mixTypeP[ip];
2914  if(!pvars) continue;
2915 
2916  Double_t xyzP[3], pxpypzP[3], cvP[21]; Short_t signP;
2917  Double_t vtxP[3];
2918  Double_t d0Pr, d0errPr;
2919 
2920  vtxP[0] = (*pvars)[28]; vtxP[1] = (*pvars)[29]; vtxP[2] = (*pvars)[30];
2921  Double_t vtxthis[3];
2922  fVtx1->GetXYZ(vtxthis);
2923 
2924  d0Pr = (*pvars)[31]; d0errPr = (*pvars)[32];
2925 
2926  for(Int_t ic=0;ic<3;ic++){
2927  pxpypzP[ic] = (*pvars)[ic];
2928  }
2929  for(Int_t ic=0;ic<3;ic++){
2930  xyzP[ic] = (*pvars)[ic+3] +(vtxthis[ic]-vtxP[ic]);
2931  }
2932  for(Int_t ic=0;ic<21;ic++){
2933  cvP[ic] = (*pvars)[ic+6];
2934  }
2935  signP = (*pvars)[27];
2936 
2937  Bool_t spdfirst = (*pvars)[33];
2938 
2939  Double_t pxp = pxpypzP[0];
2940  Double_t pyp = pxpypzP[1];
2941  Double_t pzp = pxpypzP[2];
2942  Double_t Ep = TMath::Sqrt(pow(pxp,2)+pow(pyp,2)+pow(pzp,2)+pow(mPrPDG,2));
2943  Double_t pxv0 = v0->Px();
2944  Double_t pyv0 = v0->Py();
2945  Double_t pzv0 = v0->Pz();
2946  Double_t Ev0 = TMath::Sqrt(pow(pxv0,2)+pow(pyv0,2)+pow(pzv0,2)+pow(mK0SPDG,2));
2947  Double_t pxtot = pxp+pxv0;
2948  Double_t pytot = pyp+pyv0;
2949  Double_t pztot = pzp+pzv0;
2950  Double_t Etot = Ep+Ev0;
2951 
2952  Double_t pttot = sqrt(pxtot*pxtot+pytot*pytot);
2953  Double_t tmass = sqrt(pow(Etot,2)-pow(pxtot,2)-pow(pytot,2)-pow(pztot,2));
2954 
2955  if(TMath::Abs(tmass-mLcPDG)>0.20) continue;
2956  if(pttot<4.) continue;
2957 
2958  AliExternalTrackParam *trkp = new AliExternalTrackParam(xyzP,pxpypzP,cvP,signP);
2959 
2960  Double_t d0[2],d0err[2];
2961 // Double_t d0z0bach[2],covd0z0bach[3];
2962 // trkp->PropagateToDCA(fVtx1,fBzkG,kVeryBig,d0z0bach,covd0z0bach);
2963 // d0[0]= d0z0bach[0];
2964 // d0err[0] = TMath::Sqrt(covd0z0bach[0]);
2965  d0[0]= d0Pr;
2966  d0err[0] = d0errPr;
2967 
2968  d0[1]= d0z0v0[0];
2969  d0err[1] = TMath::Sqrt(covd0z0v0[0]);
2970 
2971  Double_t px[2],py[2],pz[2];
2972  px[0] = trkp->Px(); py[0] = trkp->Py(); pz[0] = trkp->Pz();
2973  px[1] = v0->Px(); py[1] = v0->Py(); pz[1] = v0->Pz();
2974 
2975  //
2976  // FindVertexForCascades is assumed to be FALSE in the filtering
2977  // Use Primary vertex as secondary Vtx and dca is 0
2978  //
2979  Double_t pos[3],cov[6],chi2perNDF;
2980  fVtx1->GetXYZ(pos);
2981  fVtx1->GetCovarianceMatrix(cov);
2982  chi2perNDF = fVtx1->GetChi2perNDF();
2983  AliAODVertex *secVert = new AliAODVertex(pos,cov,chi2perNDF,0x0,-1,AliAODVertex::kUndef,2);
2984  Double_t dca = 0.;
2985 
2986  AliAODRecoCascadeHF *theCascade = new AliAODRecoCascadeHF(secVert,signP,px,py,pz,d0,d0err,dca);
2987  theCascade->SetOwnPrimaryVtx(fVtx1);
2988  UShort_t id[2]={(UShort_t)trkp->GetID(),(UShort_t)trackV0->GetID()};
2989  theCascade->SetProngIDs(2,id);
2990  theCascade->GetSecondaryVtx()->AddDaughter(trkp);
2991  theCascade->GetSecondaryVtx()->AddDaughter(v0);
2992 
2993  if ( cutsAnal->IsInFiducialAcceptance(theCascade->Pt(),theCascade->Y(4122)) ){
2994  if(cutsAnal->ApplyCandidateCuts(theCascade,aodEvent,(Bool_t)spdfirst))
2995  {
2996  ((TH2D*)(fOutputPIDBach->FindObject("histLcMassBGByK0SOffline")))->Fill(theCascade->InvMassLctoK0sP(),theCascade->Pt());
2997  }
2998  }
2999 
3000  delete trkp;
3001  delete secVert;
3002  delete theCascade;
3003  }
3004  delete trackV0;
3005  }
3006  return;
3007 }
3008 
3009 
3010 //---------------------------
3012  //
3013  // check in which of the pools the current event falls
3014  //
3015  Int_t theBinZ=-9999;
3016  for(Int_t iz=0;iz<fNzVtxBins;iz++){
3017  if(zvert>=fZvtxBins[iz] && zvert<fZvtxBins[iz+1]) {
3018  theBinZ = iz;
3019  break;
3020  }
3021  }
3022  if(theBinZ<0) return -1;
3023 
3024  Int_t theBinM=-9999;
3025  for(Int_t ic=0;ic<fNCentBins;ic++){
3026  if(mult>=fCentBins[ic] && mult<fCentBins[ic+1]){
3027  theBinM = ic;
3028  break;
3029  }
3030  }
3031  if(theBinM<0) return -2;
3032 
3033  return fNCentBins*theBinZ+theBinM;
3034 }
3035 
3036 //---------------------------
3038  //
3040  //
3041 
3042  TClonesArray *arrayLctopKos=0;
3043  if (!aodEvent){
3044  if(AODEvent() && IsStandardAOD()) {
3045  // In case there is an AOD handler writing a standard AOD, use the AOD
3046  // event in memory rather than the input (ESD) event.
3047  aodEvent = dynamic_cast<AliAODEvent*> (AODEvent());
3048  // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
3049  // have to taken from the AOD event hold by the AliAODExtension
3050  AliAODHandler* aodHandler = (AliAODHandler*)
3051  ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
3052 
3053  if (aodHandler->GetExtensions()) {
3054  AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
3055  AliAODEvent *aodFromExt = ext->GetAOD();
3056  arrayLctopKos=(TClonesArray*)aodFromExt->GetList()->FindObject("CascadesHF");
3057  }
3058  }
3059  } else {
3060  arrayLctopKos=(TClonesArray*)aodEvent->GetList()->FindObject("CascadesHF");
3061  }
3062 
3063  Float_t zVertex = fVtx1->GetZ();
3064  TString titleVtx=fVtx1->GetTitle();
3065 
3066  if (TMath::Abs(fBzkG)>=0.001) {
3067 
3068  if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ2")))->Fill(zVertex);
3069 
3070  if (arrayLctopKos) {
3071 
3072  if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ3")))->Fill(zVertex);
3073 
3074  // mc analysis
3075  TClonesArray *mcArray = 0;
3076  AliAODMCHeader *mcHeader=0;
3077 
3078  if (fUseMCInfo) {
3079  // MC array need for maching
3080  mcArray = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(AliAODMCParticle::StdBranchName()));
3081 
3082  if (mcArray) {
3083  // load MC header
3084  if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ4")))->Fill(zVertex);
3085  mcHeader = (AliAODMCHeader*)aodEvent->GetList()->FindObject(AliAODMCHeader::StdBranchName());
3086 
3087  if (mcHeader && fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ5")))->Fill(zVertex);
3088 
3089  // check on MC Lc Daughter
3090  if (fAdditionalChecks) {
3091  for (Int_t iii=0; iii<mcArray->GetEntries(); iii++)
3092  SearchLcDaughter(mcArray,iii);
3093  }
3094 
3095  }
3096 
3097  }
3098 
3099  if (fVtx1->GetNContributors()>0) {
3100  if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ6")))->Fill(zVertex);
3101 
3102  TString firedTriggerClasses = aodEvent->GetFiredTriggerClasses(); // trigger class
3103  ULong64_t fTriggerMask=AliVEvent::kAnyINT;
3104  Bool_t check1 = kFALSE;
3105  if ( !fUseMCInfo && // don't do for MC...
3106  (aodEvent->GetRunNumber()<136851 || aodEvent->GetRunNumber()>139517) ) { // ...and for PbPb 2010 data
3107  if ( !(firedTriggerClasses.Contains("CINT1")) ) {
3108  AliInfo(Form(" ======================== firedTriggerClasses.Data() = %s",firedTriggerClasses.Data()));
3109  fCEvents->Fill(8);
3110  if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ8")))->Fill(zVertex);
3111  check1 = kTRUE;
3112  }
3113  }
3114 
3115  Bool_t isSelectedAAA = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & fTriggerMask);
3116  if (!isSelectedAAA) {
3117  fCEvents->Fill(9);
3118  if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ9")))->Fill(zVertex);
3119  }
3120 
3121  if (!isSelectedAAA || check1) {
3122  fCEvents->Fill(16);
3123  if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ16")))->Fill(zVertex);
3124  }
3125 
3126  fTriggerMask=AliVEvent::kAny;
3127  Bool_t isSelectedBBB = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & fTriggerMask);
3128  if (!isSelectedBBB) {
3129  fCEvents->Fill(10);
3130  if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ10")))->Fill(zVertex);
3131  }
3132 
3133  if (titleVtx.Contains("Z")) {
3134  fCEvents->Fill(11);
3135  if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ11")))->Fill(zVertex);
3136  }
3137  else if (titleVtx.Contains("3D")) {
3138  fCEvents->Fill(12);
3139  if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ12")))->Fill(zVertex);
3140  } else {
3141  fCEvents->Fill(13);
3142  if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ13")))->Fill(zVertex);
3143  }
3144 
3145  if (TMath::Abs(zVertex)<=fAnalCuts->GetMaxVtxZ()) {
3146  fCEvents->Fill(14);
3147  if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ14")))->Fill(zVertex);
3148  }
3149 
3150  if ( fIsEventSelected ) {
3151  if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ7")))->Fill(zVertex);
3152  } else {
3153  fCEvents->Fill(15);
3154  if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ15")))->Fill(zVertex);
3155  }
3156 
3157  } // nContributors>=1
3158  } // analysisArray exists
3159  } // magnetic field exists
3160 
3161  return;
3162 }
3163 
3164 //-----------------
3169 
3170  Float_t zVertex = fVtx1->GetZ();
3171  TString titleVtx=fVtx1->GetTitle();
3172  TString firedTriggerClasses = aodEvent->GetFiredTriggerClasses(); // trigger class
3173  ULong64_t fTriggerMask=AliVEvent::kAnyINT;
3174 
3175  ((TH1F*)(fOutput->FindObject("hEventsWithCandidates")))->Fill(6);
3176  if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ6a")))->Fill(zVertex);
3177 
3178  Bool_t check1a = kFALSE;
3179  if ( !fUseMCInfo && // don't do for MC...
3180  (aodEvent->GetRunNumber()<136851 || aodEvent->GetRunNumber()>139517) ) { // ...and for PbPb 2010 data
3181  if ( !(firedTriggerClasses.Contains("CINT1")) ) {
3182  AliInfo(Form(" ======================== firedTriggerClasses.Data() = %s",firedTriggerClasses.Data()));
3183  ((TH1F*)(fOutput->FindObject("hEventsWithCandidates")))->Fill(8);
3184  if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ8a")))->Fill(zVertex);
3185  check1a = kTRUE;
3186  }
3187  }
3188 
3189  Bool_t isSelectedAAAa = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & fTriggerMask);
3190  if (!isSelectedAAAa) {
3191  ((TH1F*)(fOutput->FindObject("hEventsWithCandidates")))->Fill(9);
3192  if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ9a")))->Fill(zVertex);
3193  }
3194 
3195  if (!isSelectedAAAa || check1a) {
3196  ((TH1F*)(fOutput->FindObject("hEventsWithCandidates")))->Fill(16);
3197  if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ16a")))->Fill(zVertex);
3198  }
3199 
3200  fTriggerMask=AliVEvent::kAny;
3201  Bool_t isSelectedBBBa = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & fTriggerMask);
3202  if (!isSelectedBBBa) {
3203  ((TH1F*)(fOutput->FindObject("hEventsWithCandidates")))->Fill(10);
3204  if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ10a")))->Fill(zVertex);
3205  }
3206 
3207  if (titleVtx.Contains("Z")) {
3208  ((TH1F*)(fOutput->FindObject("hEventsWithCandidates")))->Fill(11);
3209  if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ11a")))->Fill(zVertex);
3210  }
3211  else if (titleVtx.Contains("3D")) {
3212  ((TH1F*)(fOutput->FindObject("hEventsWithCandidates")))->Fill(12);
3213  if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ12a")))->Fill(zVertex);
3214  } else {
3215  ((TH1F*)(fOutput->FindObject("hEventsWithCandidates")))->Fill(13);
3216  if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ13a")))->Fill(zVertex);
3217  }
3218 
3219  if (TMath::Abs(zVertex)<=fAnalCuts->GetMaxVtxZ()) {
3220  ((TH1F*)(fOutput->FindObject("hEventsWithCandidates")))->Fill(14);
3221  if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ14a")))->Fill(zVertex);
3222  }
3223 
3224  if ( fIsEventSelected ) {
3225  ((TH1F*)(fOutput->FindObject("hEventsWithCandidates")))->Fill(7);
3226  if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ7a")))->Fill(zVertex);
3227  } else {
3228  ((TH1F*)(fOutput->FindObject("hEventsWithCandidates")))->Fill(15);
3229  if (fAdditionalChecks) ((TH1F*)(fOutput->FindObject("hZ15a")))->Fill(zVertex);
3230  }
3231 
3232  return;
3233 }
3234 
3235 //-----------------------------
3237  Int_t *pdgDgLc2bacV0, Int_t *pdgDgV0,
3238  TClonesArray *mcArray) {
3239  //
3241  //
3242 
3243  // bachelor
3244  AliAODTrack *bachelor = (AliAODTrack*)lc2bacV0->GetBachelor();
3245  if (!bachelor) return -1;
3246  Int_t labBachelor = TMath::Abs(bachelor->GetLabel());
3247  if (labBachelor<0) return -1;
3248  AliAODMCParticle *partBachelor = (AliAODMCParticle*)mcArray->At(labBachelor);
3249  if (!partBachelor) return -1;
3250  if (TMath::Abs(partBachelor->GetPdgCode())!=pdgDgLc2bacV0[0]) return -1;
3251 
3252  Int_t labBacMother = partBachelor->GetMother();
3253  if (labBacMother<0) return -1;
3254  AliAODMCParticle *partBacMother = (AliAODMCParticle*)mcArray->At(labBacMother);
3255  if (!partBacMother) return -1;
3256  if (TMath::Abs(partBacMother->GetPdgCode())!=4122) return -1;
3257 
3258  // V0
3259  AliAODTrack *posV0Daugh = (AliAODTrack*)lc2bacV0->Getv0PositiveTrack();
3260  AliAODTrack *negV0Daugh = (AliAODTrack*)lc2bacV0->Getv0NegativeTrack();
3261  if (!posV0Daugh || !negV0Daugh) return -1;
3262 
3263  Int_t labV0pos = TMath::Abs(posV0Daugh->GetLabel());
3264  Int_t labV0neg = TMath::Abs(negV0Daugh->GetLabel());
3265  if (labV0pos<0 || labV0neg<0) return -1;
3266 
3267  AliAODMCParticle *partV0pos = (AliAODMCParticle*)mcArray->At(labV0neg);
3268  AliAODMCParticle *partV0neg = (AliAODMCParticle*)mcArray->At(labV0pos);
3269  if (!partV0pos || !partV0neg) return -1;
3270 
3271  if ( ! ( (TMath::Abs(partV0pos->GetPdgCode())==pdgDgV0[0] &&
3272  TMath::Abs(partV0neg->GetPdgCode())==pdgDgV0[1]) ||
3273  (TMath::Abs(partV0pos->GetPdgCode())==pdgDgV0[1] &&
3274  TMath::Abs(partV0neg->GetPdgCode())==pdgDgV0[0]) ) ) return -1;
3275  Int_t labV0posMother = partV0pos->GetMother();
3276  Int_t labV0negMother = partV0neg->GetMother();
3277 
3278  if (labV0posMother<0 || labV0negMother<0) return -1;
3279  if (labV0posMother!=labV0negMother) return -1;
3280 
3281  AliAODMCParticle *motherV0 = (AliAODMCParticle*)mcArray->At(labV0posMother);
3282  if (!motherV0) return-1;
3283 
3284  if (TMath::Abs(motherV0->GetPdgCode())!=pdgDgLc2bacV0[1]) return -1;
3285  Int_t labV0mother = motherV0->GetMother();
3286  if (labV0mother<0) return -1;
3287  AliAODMCParticle *gMotherV0 = (AliAODMCParticle*)mcArray->At(labV0mother);
3288  if (!gMotherV0) return-1;
3289 
3290  if ( !(pdgDgLc2bacV0[1]==310 && TMath::Abs(gMotherV0->GetPdgCode())==311) &&
3291  !(pdgDgLc2bacV0[1]==3122 && TMath::Abs(motherV0->GetPdgCode())==3122) ) return -1;
3292 
3293  if ( (pdgDgLc2bacV0[1]==310 && TMath::Abs(gMotherV0->GetPdgCode())==311) ) {
3294  Int_t labV0GMother = gMotherV0->GetMother();
3295  if (labV0GMother<0) return -1;
3296  AliAODMCParticle *ggMotherV0 = (AliAODMCParticle*)mcArray->At(labV0GMother);
3297  if (!ggMotherV0) return-1;
3298 
3299  if (TMath::Abs(ggMotherV0->GetPdgCode())!=4122) return -1;
3300  gMotherV0 = (AliAODMCParticle*)ggMotherV0;
3301  labV0mother=labV0GMother;
3302  }
3303  else if (pdgDgLc2bacV0[1]==3122 && TMath::Abs(motherV0->GetPdgCode())==3122) {
3304  if (TMath::Abs(gMotherV0->GetPdgCode())!=4122) return -1;
3305  }
3306 
3307  if (labBacMother!=labV0mother) {
3308  return -1;
3309  }
3310 
3311  return labBacMother;
3312 
3313 }
3314 
3315 //________________________________________________________________
3317  //
3319  //
3320 
3321  Int_t indexToBeReturned=-999;
3322 
3323  Int_t pdgLc=4122;
3324  Int_t pdgLambda=3122;
3325  Int_t pdgV0=310;
3326  Int_t pdgK0=311;
3327  Int_t pdgBachelor=2212;
3328  Int_t pdgBachelorPi=211;
3329 
3330  TString fillthis="";
3331  fillthis="histMcStatLc";
3332 
3333  AliAODMCParticle *searchLc = dynamic_cast<AliAODMCParticle*>(arrayMC->At(iii));
3334  if(!searchLc) return -999;
3335  if (TMath::Abs(searchLc->GetPdgCode()) != pdgLc) return -999;
3336 
3337  ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(0);
3338  indexToBeReturned = 0;
3339 
3340  ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(TMath::Nint(searchLc->Charge()/3.)*1);
3341  indexToBeReturned = TMath::Nint(searchLc->Charge()/3.)*1;
3342 
3343  Int_t nDaughLc = searchLc->GetNDaughters();
3344  if (nDaughLc!=2) {
3345  ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(TMath::Nint(searchLc->Charge()/3.)*10);
3346  indexToBeReturned = TMath::Nint(searchLc->Charge()/3.)*10;
3347  return indexToBeReturned;
3348  }
3349 
3350  Int_t index1=searchLc->GetDaughter(0);
3351  Int_t index2=searchLc->GetDaughter(1);
3352  if (index1<=0 || index2<=0) {
3353  return -999;
3354  }
3355 
3356  AliAODMCParticle *daugh1 = dynamic_cast<AliAODMCParticle*>(arrayMC->At(index1));
3357  AliAODMCParticle *daugh2 = dynamic_cast<AliAODMCParticle*>(arrayMC->At(index2));
3358  if (!daugh1 || !daugh2) return -999;
3359 
3360  Int_t daughPdg1 = TMath::Abs(daugh1->GetPdgCode());
3361  Int_t daughPdg2 = TMath::Abs(daugh2->GetPdgCode());
3362  if ( !( (daughPdg1==pdgBachelor && daughPdg2==pdgK0) ||
3363  (daughPdg2==pdgBachelor && daughPdg1==pdgK0) ||
3364  (daughPdg1==pdgLambda && daughPdg2==pdgBachelorPi) ||
3365  (daughPdg2==pdgLambda && daughPdg1==pdgBachelorPi) ) ) {
3366  ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(TMath::Nint(searchLc->Charge()/3.)*10);
3367  indexToBeReturned = TMath::Nint(searchLc->Charge()/3.)*10;
3368  return indexToBeReturned;
3369  }
3370 
3371  if (daughPdg1==pdgK0 || daughPdg1==pdgLambda) {
3372  index1=searchLc->GetDaughter(1);
3373  index2=searchLc->GetDaughter(0);
3374  }
3375  daugh1 = dynamic_cast<AliAODMCParticle*>(arrayMC->At(index1));
3376  daugh2 = dynamic_cast<AliAODMCParticle*>(arrayMC->At(index2));
3377  if (!daugh1 || !daugh2) return -999;
3378 
3379  daughPdg1=TMath::Abs(daugh1->GetPdgCode());
3380  daughPdg2=TMath::Abs(daugh2->GetPdgCode());
3381 
3382  if ( daughPdg1==pdgBachelor && daughPdg2==pdgK0 ) { // Lc+ -> p K0bar
3383 
3384  ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(TMath::Nint(searchLc->Charge()/3.)*2);
3385  indexToBeReturned = TMath::Nint(searchLc->Charge()/3.)*2;
3386 
3387  Int_t nDaughK0 = daugh2->GetNDaughters();
3388  if (nDaughK0!=1) return -999;
3389 
3390  Int_t indexK0daugh=daugh2->GetDaughter(0);
3391  if (indexK0daugh<=0) return -999;
3392 
3393  AliAODMCParticle *daughK0 = dynamic_cast<AliAODMCParticle*>(arrayMC->At(indexK0daugh));
3394  if (!daughK0) return -999;
3395 
3396  Int_t daughK0Pdg=TMath::Abs(daughK0->GetPdgCode());
3397  if (daughK0Pdg!=pdgV0) {
3398  ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(TMath::Nint(searchLc->Charge()/3.)*4); // K0L
3399  indexToBeReturned = TMath::Nint(searchLc->Charge()/3.)*4;
3400  return indexToBeReturned;
3401  }
3402  ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(TMath::Nint(searchLc->Charge()/3.)*3); // K0S
3403  indexToBeReturned = TMath::Nint(searchLc->Charge()/3.)*3;
3404 
3405  Int_t nDaughK0S = daughK0->GetNDaughters();
3406  if (nDaughK0S!=2) {
3407  ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(TMath::Nint(searchLc->Charge()/3.)*5); // other decays for K0S
3408  indexToBeReturned = TMath::Nint(searchLc->Charge()/3.)*5;
3409  return indexToBeReturned;
3410  }
3411 
3412  index1=daughK0->GetDaughter(0);
3413  index2=daughK0->GetDaughter(1);
3414  if(index1<=0 || index2<=0) {
3415  return -999;
3416  }
3417 
3418  AliAODMCParticle *daughK0S1 = dynamic_cast<AliAODMCParticle*>(arrayMC->At(index1));
3419  AliAODMCParticle *daughK0S2 = dynamic_cast<AliAODMCParticle*>(arrayMC->At(index2));
3420  if (!daughK0S1 || !daughK0S2) return -999;
3421 
3422  Int_t daughK0S1pdg=TMath::Abs(daughK0S1->GetPdgCode());
3423  Int_t daughK0S2pdg=TMath::Abs(daughK0S2->GetPdgCode());
3424 
3425  if ( daughK0S1pdg==211 && daughK0S2pdg==211 ) {
3426  ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(TMath::Nint(searchLc->Charge()/3.)*6); // K0S -> pi+ pi-
3427  indexToBeReturned = TMath::Nint(searchLc->Charge()/3.)*6;
3428  } else {
3429  ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(TMath::Nint(searchLc->Charge()/3.)*5); // other decays for K0S
3430  indexToBeReturned = TMath::Nint(searchLc->Charge()/3.)*5;
3431  }
3432 
3433  } //if (daughPdg1==pdgBachelor && daughPdg2==pdgK0)
3434  else if ( daughPdg1==pdgBachelorPi && daughPdg2==pdgLambda ) { // Lc+ -> pi+ Lambda
3435 
3436  ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(TMath::Nint(searchLc->Charge()/3.)*7);
3437  indexToBeReturned = TMath::Nint(searchLc->Charge()/3.)*7;
3438 
3439  Int_t nDaughL = daugh2->GetNDaughters();
3440  if (nDaughL!=2) {
3441  ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(TMath::Nint(searchLc->Charge()/3.)*8);
3442  indexToBeReturned = TMath::Nint(searchLc->Charge()/3.)*8;
3443  return indexToBeReturned;
3444  }
3445 
3446  index1=daugh2->GetDaughter(0);
3447  index2=daugh2->GetDaughter(1);
3448  if(index1<=0 || index2<=0) {
3449  return -999;
3450  }
3451 
3452  AliAODMCParticle *daughL1 = dynamic_cast<AliAODMCParticle*>(arrayMC->At(index1));
3453  AliAODMCParticle *daughL2 = dynamic_cast<AliAODMCParticle*>(arrayMC->At(index2));
3454  if (!daughL1 || !daughL2) return -999;
3455 
3456  Int_t daughL1pdg=TMath::Abs(daughL1->GetPdgCode());
3457  Int_t daughL2pdg=TMath::Abs(daughL2->GetPdgCode());
3458  if ( (daughL1pdg==211 && daughL2pdg==2212) ||
3459  (daughL2pdg==211 && daughL1pdg==2212) ) {
3460  ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(TMath::Nint(searchLc->Charge()/3.)*9);
3461  indexToBeReturned = TMath::Nint(searchLc->Charge()/3.)*9;
3462  } else {
3463  ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(TMath::Nint(searchLc->Charge()/3.)*8);
3464  indexToBeReturned = TMath::Nint(searchLc->Charge()/3.)*8;
3465  }
3466 
3467  } //else if (daughPdg1==pdgBachelorPi && daughPdg2==pdgLambda)
3468 
3469  return indexToBeReturned;
3470 }
3471 
3472 //________________________________________________________________
3474  TString histoTitle,
3475  Bool_t isCandidateSelectedCuts,
3476  Bool_t isBachelorID) {
3477  //
3479  //
3480 
3481  Double_t alpha = vZero->Alpha();//AlphaV0();
3482  Double_t qT = vZero->QtProng();//PtArmV0();
3483 
3484  ((TH2F*)(fOutputAll->FindObject(histoTitle+"0")))->Fill(alpha,qT);
3485  if (isCandidateSelectedCuts) {
3486  ((TH2F*)(fOutputAll->FindObject(histoTitle)))->Fill(alpha,qT);
3487  if (isBachelorID)
3488  ((TH2F*)(fOutputPIDBach->FindObject(histoTitle)))->Fill(alpha,qT);
3489  }
3490 
3491 }
3492 
3493 //-------------------------------------------------------------------------------
3495  //
3497  //
3498 
3499  Bool_t areCutsUsingPID = cutsAnal->GetIsUsePID();
3500 
3501  AliAODv0 * v0part = (AliAODv0*)part->Getv0();
3502  Bool_t onFlyV0 = v0part->GetOnFlyStatus(); // on-the-flight V0s
3503 
3504  AliAODTrack *bachelor = (AliAODTrack*)part->GetBachelor();
3505 
3506  if ( !onFlyV0 )
3507  ((TH1F*)(fOutput->FindObject("hCandidateSelection")))->Fill(3); // it counts number of candidates coming from offline V0s
3508 
3509  if ( cutsAnal->IsInFiducialAcceptance(part->Pt(),part->Y(4122)) )
3510  ((TH1F*)(fOutput->FindObject("hCandidateSelection")))->Fill(4);
3512  ((TH1F*)(fOutput->FindObject("hCandidateSelection")))->Fill(5);
3513  cutsAnal->SetUsePID(kFALSE);
3515  ((TH1F*)(fOutput->FindObject("hCandidateSelection")))->Fill(6);
3516  cutsAnal->SetUsePID(areCutsUsingPID);
3518  ((TH1F*)(fOutput->FindObject("hCandidateSelection")))->Fill(7);
3520  ((TH1F*)(fOutput->FindObject("hCandidateSelection")))->Fill(8);
3522  ((TH1F*)(fOutput->FindObject("hCandidateSelection")))->Fill(9);
3523 
3524  if ( cutsAnal->IsInFiducialAcceptance(part->Pt(),part->Y(4122)) ) {
3525 
3527 
3528  Int_t aaa = cutsAnal->IsSelected(part,AliRDHFCuts::kTracks);
3529  if ( (aaa&AliRDHFCutsLctoV0::kLcToK0Spr)==AliRDHFCutsLctoV0::kLcToK0Spr ) {
3530  if ( ( (aaa&AliRDHFCutsLctoV0::kLcToLpi)==AliRDHFCutsLctoV0::kLcToLpi && bachelor->Charge()<0) ||
3531  ( (aaa&AliRDHFCutsLctoV0::kLcToLBarpi)==AliRDHFCutsLctoV0::kLcToLBarpi && bachelor->Charge()>0) )
3532  ((TH1F*)(fOutput->FindObject("hSwitchOnCandidates1")))->Fill( -aaa );
3533  else
3534  ((TH1F*)(fOutput->FindObject("hSwitchOnCandidates1")))->Fill( aaa );
3535  }
3536 
3537  cutsAnal->SetUsePID(kFALSE);
3538  aaa = cutsAnal->IsSelected(part,AliRDHFCuts::kCandidate);
3539  if ((aaa&AliRDHFCutsLctoV0::kLcToK0Spr)==AliRDHFCutsLctoV0::kLcToK0Spr) {
3540  if ( ( (aaa&AliRDHFCutsLctoV0::kLcToLpi)==AliRDHFCutsLctoV0::kLcToLpi && bachelor->Charge()<0) ||
3541  ( (aaa&AliRDHFCutsLctoV0::kLcToLBarpi)==AliRDHFCutsLctoV0::kLcToLBarpi && bachelor->Charge()>0) )
3542  ((TH1F*)(fOutput->FindObject("hSwitchOnCandidates2")))->Fill( -aaa );
3543  else
3544  ((TH1F*)(fOutput->FindObject("hSwitchOnCandidates2")))->Fill( aaa );
3545  }
3546  cutsAnal->SetUsePID(areCutsUsingPID);
3547 
3548  aaa = cutsAnal->IsSelected(part,AliRDHFCuts::kPID);
3549  if ((aaa&AliRDHFCutsLctoV0::kLcToK0Spr)==AliRDHFCutsLctoV0::kLcToK0Spr) {
3550  if ( ( (aaa&AliRDHFCutsLctoV0::kLcToLpi)==AliRDHFCutsLctoV0::kLcToLpi && bachelor->Charge()<0) ||
3551  ( (aaa&AliRDHFCutsLctoV0::kLcToLBarpi)==AliRDHFCutsLctoV0::kLcToLBarpi && bachelor->Charge()>0) )
3552  ((TH1F*)(fOutput->FindObject("hSwitchOnCandidates3")))->Fill( -aaa );
3553  else
3554  ((TH1F*)(fOutput->FindObject("hSwitchOnCandidates3")))->Fill( aaa );
3555  }
3556 
3557  aaa = cutsAnal->IsSelected(part,AliRDHFCuts::kAll);
3558  if ((aaa&AliRDHFCutsLctoV0::kLcToK0Spr)==AliRDHFCutsLctoV0::kLcToK0Spr) {
3559  if ( ( (aaa&AliRDHFCutsLctoV0::kLcToLpi)==AliRDHFCutsLctoV0::kLcToLpi && bachelor->Charge()<0) ||
3560  ( (aaa&AliRDHFCutsLctoV0::kLcToLBarpi)==AliRDHFCutsLctoV0::kLcToLBarpi && bachelor->Charge()>0) )
3561  ((TH1F*)(fOutput->FindObject("hSwitchOnCandidates4")))->Fill( -aaa );
3562  else
3563  ((TH1F*)(fOutput->FindObject("hSwitchOnCandidates4")))->Fill( aaa );
3564  }
3565 
3566  }
3567  }
3568 
3569  return;
3570 }
3571 
3572 //-------------------------------------------------------------------------------
3573 void AliAnalysisTaskSELc2V0bachelor::FillTheTree(AliAODRecoCascadeHF *part, AliRDHFCutsLctoV0 *cutsAnal, TClonesArray *mcArray, Int_t isLc, Int_t checkLcOrigin) {
3574  //
3576  //
3577 
3578  Double_t mk0sPDG = TDatabasePDG::Instance()->GetParticle(310)->Mass();
3579  Double_t mLPDG = TDatabasePDG::Instance()->GetParticle(3122)->Mass();
3580 
3581  Double_t invmassLc = part->InvMassLctoK0sP();
3582  Double_t invmassLc2Lpi = part->InvMassLctoLambdaPi();
3583 
3584  AliAODTrack *bachelor = (AliAODTrack*)part->GetBachelor();
3585 
3586  AliAODv0 * v0part = (AliAODv0*)part->Getv0();
3587  Double_t dcaV0ptp = v0part->GetDCA();
3588  Double_t invmassK0S = v0part->MassK0Short();
3589  Double_t invmassLambda = v0part->MassLambda();
3590  Double_t invmassLambdaBar = v0part->MassAntiLambda();
3591 
3592  Int_t isLc2LBarpi=0, isLc2Lpi=0;
3593  Int_t mcLabel = -1;
3594  Int_t isDp2K0Spi=0, isDs2K0SK=0;
3595  Int_t mcLabel2 = -1;
3596  Int_t mcLabel3 = -1;
3597  Int_t isKstar12K0Spi=0, isKstar22K0Spi=0;
3598  Int_t mcLabel4 = -1;
3599  Int_t mcLabel5 = -1;
3600  Double_t ptCandByMC = 0.;//fmcPartCandidate->Pt();
3601  Double_t yCandByMC = 0.;//fmcPartCandidate->Y();
3602  if (fUseMCInfo) {
3603  if (isLc) {
3604  Int_t pdgCand0 = 4122;
3605  Int_t pdgDgLctoV0bachelor0[2]={2212,310};
3606  Int_t pdgDgV0toDaughters0[2]={211,211};
3607  Int_t mcLabelLc2pK0S = part->MatchToMC(pdgCand0,pdgDgLctoV0bachelor0[1],pdgDgLctoV0bachelor0,pdgDgV0toDaughters0,mcArray,kTRUE);
3608  AliAODMCParticle *lambdaCpartMC = (AliAODMCParticle*)mcArray->At(mcLabelLc2pK0S);
3609  if (lambdaCpartMC) {
3610  ptCandByMC = lambdaCpartMC->Pt();
3611  yCandByMC = lambdaCpartMC->Y();
3612  }
3613  }
3614 
3615  Int_t pdgCand = 4122;
3616  Int_t pdgDgLctoV0bachelor[2]={211,3122};
3617  Int_t pdgDgV0toDaughters[2]={2212,211};
3618  mcLabel = part->MatchToMC(pdgCand,pdgDgLctoV0bachelor[1],pdgDgLctoV0bachelor,pdgDgV0toDaughters,mcArray,kTRUE);
3619  if (mcLabel!=-1) {
3620  if (bachelor->Charge()<0) isLc2LBarpi=1;
3621  if (bachelor->Charge()>0) isLc2Lpi=1;
3622  AliAODMCParticle *lambdaCpartMC = (AliAODMCParticle*)mcArray->At(mcLabel);
3623  if (lambdaCpartMC) {
3624  ptCandByMC = lambdaCpartMC->Pt();
3625  yCandByMC = lambdaCpartMC->Y();
3626  }
3627  }
3628 
3629  Int_t pdgCand2 = 411; // D+ -> pi+ K0S
3630  Int_t pdgCand3 = 431; // Ds+ -> K+ K0S
3631  Int_t pdgDgCand2[2]={211,310};
3632  Int_t pdgDgCand3[2]={321,310};
3633  pdgDgV0toDaughters[0]=211;
3634  pdgDgV0toDaughters[1]=211;
3635  mcLabel2 = part->MatchToMC(pdgCand2,pdgDgCand2[1],pdgDgCand2,pdgDgV0toDaughters,mcArray,kTRUE);
3636  mcLabel3 = part->MatchToMC(pdgCand3,pdgDgCand3[1],pdgDgCand3,pdgDgV0toDaughters,mcArray,kTRUE);
3637  if (mcLabel2!=-1) {
3638  isDp2K0Spi=1;
3639  AliAODMCParticle *lambdaCpartMC = (AliAODMCParticle*)mcArray->At(mcLabel2);
3640  if (lambdaCpartMC) {
3641  ptCandByMC = lambdaCpartMC->Pt();
3642  yCandByMC = lambdaCpartMC->Y();
3643  }
3644  }
3645  if (mcLabel3!=-1) {
3646  isDs2K0SK=1;
3647  AliAODMCParticle *lambdaCpartMC = (AliAODMCParticle*)mcArray->At(mcLabel3);
3648  if (lambdaCpartMC) {
3649  ptCandByMC = lambdaCpartMC->Pt();
3650  yCandByMC = lambdaCpartMC->Y();
3651  }
3652  }
3653 
3654  Int_t pdgCand4 = 313; // K*(892)+ -> pi+ K0S
3655  Int_t pdgCand5 = 325; // K*(1430)+ -> pi+ K0S
3656  Int_t pdgDgCand4[2]={211,310};
3657  Int_t pdgDgCand5[2]={211,310};
3658  pdgDgV0toDaughters[0]=211;
3659  pdgDgV0toDaughters[1]=211;
3660  mcLabel4 = part->MatchToMC(pdgCand4,pdgDgCand4[1],pdgDgCand4,pdgDgV0toDaughters,mcArray,kTRUE);
3661  mcLabel5 = part->MatchToMC(pdgCand5,pdgDgCand5[1],pdgDgCand5,pdgDgV0toDaughters,mcArray,kTRUE);
3662  if (mcLabel4!=-1) {
3663  isKstar12K0Spi=1;
3664  AliAODMCParticle *lambdaCpartMC = (AliAODMCParticle*)mcArray->At(mcLabel4);
3665  if (lambdaCpartMC) {
3666  ptCandByMC = lambdaCpartMC->Pt();
3667  yCandByMC = lambdaCpartMC->Y();
3668  }
3669  }
3670  if (mcLabel5!=-1) {
3671  isKstar22K0Spi=1;
3672  AliAODMCParticle *lambdaCpartMC = (AliAODMCParticle*)mcArray->At(mcLabel5);
3673  if (lambdaCpartMC) {
3674  ptCandByMC = lambdaCpartMC->Pt();
3675  yCandByMC = lambdaCpartMC->Y();
3676  }
3677  }
3678  }
3679 
3680  Int_t isLcByMC = isLc+isLc2LBarpi*2+isLc2Lpi*4+isDp2K0Spi*8+isDs2K0SK*16+isKstar12K0Spi*32+isKstar22K0Spi*64;
3681 
3682  Bool_t isMCparticleInFiducialAcceptance = kTRUE;
3683  if (isLc || isLc2LBarpi || isLc2Lpi || isDp2K0Spi || isDs2K0SK || isKstar12K0Spi || isKstar22K0Spi) {
3684  isMCparticleInFiducialAcceptance = cutsAnal->IsInFiducialAcceptance(ptCandByMC,yCandByMC);
3685  }
3686 
3687  Int_t isK0S = 0;
3688  Int_t isLambda = 0;
3689  Int_t isLambdaBar = 0;
3690  Int_t isGamma = 0;
3691  if (fUseMCInfo) {
3692  Int_t pdgDg2prong[2] = {211, 211};
3693  Int_t labelK0S = v0part->MatchToMC(310,mcArray,2,pdgDg2prong);
3694  if (labelK0S>=0) isK0S = 1;
3695 
3696  pdgDg2prong[0] = 211;
3697  pdgDg2prong[1] = 2212;
3698  Int_t lambdaLabel = v0part->MatchToMC(3122,mcArray,2,pdgDg2prong);
3699  if (lambdaLabel>=0) {
3700  AliAODMCParticle *lambdaTrack = (AliAODMCParticle*)mcArray->At(lambdaLabel);
3701  if (lambdaTrack->GetPdgCode()==3122) isLambda = 1;
3702  else if (lambdaTrack->GetPdgCode()==-3122) isLambdaBar = 1;
3703  }
3704 
3705  pdgDg2prong[0] = 11;
3706  pdgDg2prong[1] = 11;
3707  Int_t gammaLabel = v0part->MatchToMC(22,mcArray,2,pdgDg2prong);
3708  if (gammaLabel>=0) {
3709  AliAODMCParticle *gammaTrack = (AliAODMCParticle*)mcArray->At(gammaLabel);
3710  if (gammaTrack->GetPdgCode()==22) isGamma = 1;
3711  }
3712  }
3713 
3714  Int_t isV0ByMC = isK0S+isLambdaBar*2+isLambda*4+isGamma*8;
3715 
3716  Int_t isBachelorSelected = (bachelor->TestFilterMask(BIT(4)))*1 + (!(bachelor->TestFilterMask(BIT(4))))*2;
3717  isBachelorSelected += (bachelor->GetLabel()<0)*4 + (bachelor->GetLabel()>=0)*8;
3718  if ( ( !(bachelor->HasPointOnITSLayer(0)) && !(bachelor->HasPointOnITSLayer(1)) ) )
3719  isBachelorSelected += 16;
3720  else {
3721  if ( bachelor->HasPointOnITSLayer(0) && !(bachelor->HasPointOnITSLayer(1)) )
3722  isBachelorSelected += 32;
3723  else if ( !(bachelor->HasPointOnITSLayer(0)) && bachelor->HasPointOnITSLayer(1) )
3724  isBachelorSelected += 64;
3725  else
3726  isBachelorSelected += 128;
3727  }
3728 
3729  AliAODTrack *v0pos = (AliAODTrack*)part->Getv0PositiveTrack();
3730  AliAODTrack *v0neg = (AliAODTrack*)part->Getv0NegativeTrack();
3731 
3732  Int_t areV0daughtersSelected = (v0pos->TestFilterMask(BIT(4)))*1 + (!(v0pos->TestFilterMask(BIT(4))))*2;
3733  areV0daughtersSelected += (v0pos->GetLabel()<0)*4 + (v0pos->GetLabel()>=0)*8;
3734  areV0daughtersSelected += (v0pos->HasPointOnITSLayer(0))*16;
3735  areV0daughtersSelected += (v0pos->HasPointOnITSLayer(1))*32;
3736  areV0daughtersSelected += (v0pos->HasPointOnITSLayer(2))*64;
3737  areV0daughtersSelected += (v0pos->HasPointOnITSLayer(3))*128;
3738  areV0daughtersSelected += (v0pos->HasPointOnITSLayer(4))*256;
3739  areV0daughtersSelected += (v0pos->HasPointOnITSLayer(5))*512;
3740 
3741  areV0daughtersSelected += (v0neg->TestFilterMask(BIT(4)))*1024 + (!(v0neg->TestFilterMask(BIT(4))))*2048;
3742  areV0daughtersSelected += (v0neg->GetLabel()<0)*4096 + (v0neg->GetLabel()>=0)*8192;
3743  areV0daughtersSelected += (v0neg->HasPointOnITSLayer(0))*16384;
3744  areV0daughtersSelected += (v0neg->HasPointOnITSLayer(1))*32768;
3745  areV0daughtersSelected += (v0neg->HasPointOnITSLayer(2))*65536;
3746  areV0daughtersSelected += (v0neg->HasPointOnITSLayer(3))*131072;
3747  areV0daughtersSelected += (v0neg->HasPointOnITSLayer(4))*262144;
3748  areV0daughtersSelected += (v0neg->HasPointOnITSLayer(5))*524288;
3749 
3750  Double_t nSigmaITSpr=-999.;
3751  cutsAnal->GetPidHF()->GetnSigmaITS(bachelor,4,nSigmaITSpr);
3752  Double_t nSigmaTPCpr=-999.;
3753  cutsAnal->GetPidHF()->GetnSigmaTPC(bachelor,4,nSigmaTPCpr);
3754  Double_t nSigmaTOFpr=-999.;
3755  cutsAnal->GetPidHF()->GetnSigmaTOF(bachelor,4,nSigmaTOFpr);
3756 
3757  Double_t nSigmaITSpi=-999.;
3758  cutsAnal->GetPidHF()->GetnSigmaITS(bachelor,2,nSigmaITSpi);
3759  Double_t nSigmaTPCpi=-999.;
3760  cutsAnal->GetPidHF()->GetnSigmaTPC(bachelor,2,nSigmaTPCpi);
3761  Double_t nSigmaTOFpi=-999.;
3762  cutsAnal->GetPidHF()->GetnSigmaTOF(bachelor,2,nSigmaTOFpi);
3763 
3764  Double_t nSigmaITSka=-999.;
3765  cutsAnal->GetPidHF()->GetnSigmaITS(bachelor,3,nSigmaITSka);
3766  Double_t nSigmaTPCka=-999.;
3767  cutsAnal->GetPidHF()->GetnSigmaTPC(bachelor,3,nSigmaTPCka);
3768  Double_t nSigmaTOFka=-999.;
3769  cutsAnal->GetPidHF()->GetnSigmaTOF(bachelor,3,nSigmaTOFka);
3770 
3771 
3772  Int_t flagToCheckCandidate = 1*(TMath::Abs(invmassK0S-mk0sPDG)<=0.050);
3773  flagToCheckCandidate+=2*((TMath::Abs(invmassLambdaBar-mLPDG)<=0.050) && (bachelor->Charge()<0));
3774  flagToCheckCandidate+=4*((TMath::Abs(invmassLambda-mLPDG)<=0.050) && (bachelor->Charge()>0));
3775  flagToCheckCandidate+=8*((TMath::Abs(invmassLambdaBar-mLPDG)<=0.050) && (bachelor->Charge()>0));
3776  flagToCheckCandidate+=16*((TMath::Abs(invmassLambda-mLPDG)<=0.050) && (bachelor->Charge()<0));
3777 
3778  fCandidateVariables[ 0] = fUseMCInfo+isLcByMC; // 0: real data; 1: bkg; 2: Lc->K0S+p; 3: Lc->LambdaBar+pbar; 5: Lc->Lambda+p; 9: D+->K0S+pi; 17: Ds+->K0S+K; 33: K*+->K0S+pi; 65: K*+->K0S+K
3779  fCandidateVariables[ 1] = fUseMCInfo+isV0ByMC; // 0: real data; 1: bkg; 2: K0S->pi+pi; 3: LambdaBar->pbar+pi+; 5: Lambda->p+pi-
3780  fCandidateVariables[ 2] = isBachelorSelected;
3781  fCandidateVariables[ 3] = areV0daughtersSelected;
3782  fCandidateVariables[ 4] = flagToCheckCandidate;
3783  fCandidateVariables[ 5] = invmassLc;
3784  fCandidateVariables[ 6] = invmassLc2Lpi;
3785  fCandidateVariables[ 7] = part->InvMass2Prongs(0,1,211,310); // D+ -> pi+ K0S
3786  fCandidateVariables[ 8] = part->InvMass2Prongs(0,1,321,310); // D+S -> K+ K0S
3787  fCandidateVariables[ 9] = invmassK0S;
3788  fCandidateVariables[10] = invmassLambda;
3789  fCandidateVariables[11] = invmassLambdaBar;
3790  fCandidateVariables[12] = v0part->InvMass2Prongs(0,1,11,11);
3791  fCandidateVariables[13] = part->GetDCA();
3792  fCandidateVariables[14] = dcaV0ptp;
3793  fCandidateVariables[15] = part->Getd0Prong(0);
3794  fCandidateVariables[16] = part->Getd0Prong(1);
3795  fCandidateVariables[17] = v0part->Getd0Prong(0);
3796  fCandidateVariables[18] = v0part->Getd0Prong(1);
3797  fCandidateVariables[19] = part->CosPointingAngle();
3799  fCandidateVariables[21] = v0part->RadiusSecVtx();
3800  fCandidateVariables[22] = nSigmaITSpr;
3801  fCandidateVariables[23] = nSigmaITSpi;
3802  fCandidateVariables[24] = nSigmaITSka;
3803  fCandidateVariables[25] = nSigmaTPCpr;
3804  fCandidateVariables[26] = nSigmaTPCpi;
3805  fCandidateVariables[27] = nSigmaTPCka;
3806  fCandidateVariables[28] = nSigmaTOFpr;
3807  fCandidateVariables[29] = nSigmaTOFpi;
3808  fCandidateVariables[30] = nSigmaTOFka;
3809  fCandidateVariables[31] = part->Y(4122);
3810  fCandidateVariables[32] = bachelor->Eta();
3811  fCandidateVariables[33] = v0pos->Eta();
3812  fCandidateVariables[34] = v0neg->Eta();
3813  fCandidateVariables[35] = part->P();
3814  fCandidateVariables[36] = part->Pt();
3815  fCandidateVariables[37] = v0part->P();
3816  fCandidateVariables[38] = v0part->Pt();
3817  fCandidateVariables[39] = bachelor->P();
3818  fCandidateVariables[40] = bachelor->Pt();
3819  fCandidateVariables[41] = v0pos->P();
3820  fCandidateVariables[42] = v0pos->Pt();
3821  fCandidateVariables[43] = v0neg->P();
3822  fCandidateVariables[44] = v0neg->Pt();
3823  fCandidateVariables[45] = part->DecayLength();
3824  fCandidateVariables[46] = part->DecayLengthV0();
3827  fCandidateVariables[49] = part->DecayLengthXY();
3828  fCandidateVariables[50] = part->DecayLengthXYV0();
3833 
3834  Double_t dcaForLc=0.;
3835  if (fAdditionalChecks) {
3836  Double_t xVtxLc=0, yVtxLc=0, zVtxLc=0;
3837  Double_t xLcMC=0,yLcMC=0,zLcMC=0;
3838  Double_t pxVtxBachelor=0, pyVtxBachelor=0, pzVtxBachelor=0;
3839  dcaForLc = PropagateToDCA(v0part,bachelor,fBzkG, xVtxLc, yVtxLc, zVtxLc, pxVtxBachelor, pyVtxBachelor, pzVtxBachelor);
3840  if (isLc) {
3841  Int_t pdgCand0 = 4122;
3842  Int_t pdgDgLctoV0bachelor0[2]={2212,310};
3843  Int_t pdgDgV0toDaughters0[2]={211,211};
3844  Int_t mcLabel0 = part->MatchToMC(pdgCand0,pdgDgLctoV0bachelor0[1],pdgDgLctoV0bachelor0,pdgDgV0toDaughters0,mcArray,kTRUE);
3845  AliAODMCParticle *partLc = dynamic_cast<AliAODMCParticle*>(mcArray->At(mcLabel0));
3846  if(partLc){
3847  AliAODMCParticle *partLcDaug0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(partLc->GetDaughter(0)));
3848  if(partLcDaug0){
3849  xLcMC=partLcDaug0->Xv(), yLcMC=partLcDaug0->Yv(), zLcMC=partLcDaug0->Zv();
3850  }
3851  }
3852  } else if (isLc2LBarpi || isLc2Lpi) {
3853  AliAODMCParticle *partLc = dynamic_cast<AliAODMCParticle*>(mcArray->At(mcLabel));
3854  AliAODMCParticle *partLcDaug0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(partLc->GetDaughter(0)));
3855  xLcMC=partLcDaug0->Xv(), yLcMC=partLcDaug0->Yv(), zLcMC=partLcDaug0->Zv();
3856  } else if (isDp2K0Spi) {
3857  AliAODMCParticle *partLc = dynamic_cast<AliAODMCParticle*>(mcArray->At(mcLabel2));
3858  AliAODMCParticle *partLcDaug0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(partLc->GetDaughter(0)));
3859  xLcMC=partLcDaug0->Xv(), yLcMC=partLcDaug0->Yv(), zLcMC=partLcDaug0->Zv();
3860  } else if (isDs2K0SK) {
3861  AliAODMCParticle *partLc = dynamic_cast<AliAODMCParticle*>(mcArray->At(mcLabel3));
3862  AliAODMCParticle *partLcDaug0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(partLc->GetDaughter(0)));
3863  xLcMC=partLcDaug0->Xv(), yLcMC=partLcDaug0->Yv(), zLcMC=partLcDaug0->Zv();
3864  } else if (isKstar12K0Spi) {
3865  AliAODMCParticle *partLc = dynamic_cast<AliAODMCParticle*>(mcArray->At(mcLabel4));
3866  AliAODMCParticle *partLcDaug0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(partLc->GetDaughter(0)));
3867  xLcMC=partLcDaug0->Xv(), yLcMC=partLcDaug0->Yv(), zLcMC=partLcDaug0->Zv();
3868  } else if (isKstar22K0Spi) {
3869  AliAODMCParticle *partLc = dynamic_cast<AliAODMCParticle*>(mcArray->At(mcLabel5));
3870  AliAODMCParticle *partLcDaug0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(partLc->GetDaughter(0)));
3871  xLcMC=partLcDaug0->Xv(), yLcMC=partLcDaug0->Yv(), zLcMC=partLcDaug0->Zv();
3872  }
3873 
3874  fCandidateVariables[75]=part->GetSecVtxX();
3875  fCandidateVariables[76]=part->GetSecVtxY();
3876  fCandidateVariables[77]=part->GetSecVtxZ();
3877  fCandidateVariables[78]=xVtxLc;
3878  fCandidateVariables[79]=yVtxLc;
3879  fCandidateVariables[80]=zVtxLc;
3880  fCandidateVariables[81]=xLcMC;
3881  fCandidateVariables[82]=yLcMC;
3882  fCandidateVariables[83]=zLcMC;
3883  fCandidateVariables[84]=bachelor->Px();
3884  fCandidateVariables[85]=bachelor->Py();
3885  fCandidateVariables[86]=pxVtxBachelor;
3886  fCandidateVariables[87]=pyVtxBachelor;
3887  fCandidateVariables[88]=pzVtxBachelor;
3888  fCandidateVariables[89]=v0part->Px();
3889  fCandidateVariables[90]=v0part->Py();
3890  fCandidateVariables[91]=v0part->Pz();
3891  fCandidateVariables[92]=fVtx1->GetX();
3892  fCandidateVariables[93]=fVtx1->GetY();
3893  fCandidateVariables[94]=fVtx1->GetZ();
3894  }
3895 
3896  fCandidateVariables[55]=dcaForLc;
3897 
3898  fCandidateVariables[56]=part->CosThetaStar(0,4122,2212,310);
3899  fCandidateVariables[57]=part->CosThetaStar(1,4122,2212,310);
3900  fCandidateVariables[58]=v0part->Eta();
3901  fCandidateVariables[59]=v0part->Y(310);
3902  fCandidateVariables[60]=bachelor->Charge();
3903  fCandidateVariables[61]=isMCparticleInFiducialAcceptance;
3904 
3905  fCandidateVariables[62] = part->InvMass2Prongs(0,1,211,310); // Kstar( 892)+ -> pi+K0S
3906  fCandidateVariables[63] = part->InvMass2Prongs(0,1,321,310); // Kstar(1430)+ -> pi+K0S
3907 
3908  fCandidateVariables[64]=-1;
3909  fCandidateVariables[65]=-1;
3910  fCandidateVariables[66]=-1;
3911  fCandidateVariables[67]=-1;
3912  fCandidateVariables[68]=-1;
3913  if (fUseMCInfo) {
3914  if (bachelor->GetLabel()!=-1) {
3915  AliAODMCParticle *partBachelor = dynamic_cast<AliAODMCParticle*>(mcArray->At(TMath::Abs(bachelor->GetLabel())));
3916  if(partBachelor) fCandidateVariables[64]=partBachelor->GetPdgCode();
3917  }
3918  if (bachelor->GetLabel()!=-1 &&
3919  v0pos->GetLabel()!=-1 &&
3920  v0neg->GetLabel()!=-1) {
3921  const Int_t ndg=3;
3922  Int_t dgLabels[ndg]={TMath::Abs(bachelor->GetLabel()),
3923  TMath::Abs(v0pos->GetLabel()),
3924  TMath::Abs(v0neg->GetLabel())};
3925  Int_t ndgCk=0;
3926  Int_t *pdgDg=0;
3927  Int_t absLabelMother=-1;
3928  Int_t nDauCand=-1;
3930  dgLabels,ndg,ndgCk,pdgDg,absLabelMother,nDauCand);
3931  }
3932  if (v0pos->GetLabel()!=-1) {
3933  AliAODMCParticle *part1 = dynamic_cast<AliAODMCParticle*>(mcArray->At(TMath::Abs(v0pos->GetLabel())));
3934  if(part1) fCandidateVariables[66]=part1->GetPdgCode();
3935  }
3936  if (v0neg->GetLabel()!=-1) {
3937  AliAODMCParticle *part2 = dynamic_cast<AliAODMCParticle*>(mcArray->At(TMath::Abs(v0neg->GetLabel())));
3938  if(part2) fCandidateVariables[67]=part2->GetPdgCode();
3939  }
3940  if (v0pos->GetLabel()!=-1 &&
3941  v0neg->GetLabel()!=-1) {
3942  const Int_t ndg=2;
3943  Int_t dgLabels[ndg]={TMath::Abs(v0pos->GetLabel()),
3944  TMath::Abs(v0neg->GetLabel())};
3945  Int_t ndgCk=0;
3946  Int_t *pdgDg=0;
3947  Int_t absLabelMother=-1;
3948  Int_t nDauCand=-1;
3950  dgLabels,ndg,ndgCk,pdgDg,absLabelMother,nDauCand);
3951  }
3952  }
3953 
3954  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
3955  AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler();
3956  AliPIDResponse *pidResponse=inputHandler->GetPIDResponse();
3957  fCandidateVariables[69]=pidResponse->GetTOFResponse().GetStartTimeMask(bachelor->P());
3958 
3959  AliPIDCombined *objectPIDCombined=new AliPIDCombined;
3960  objectPIDCombined->SetDefaultTPCPriors();
3961  objectPIDCombined->SetDetectorMask(AliPIDResponse::kDetTPC+AliPIDResponse::kDetTOF);
3962 
3963  Double_t probTPCTOF[AliPID::kSPECIES]={-1.};
3964  UInt_t detUsed = objectPIDCombined->ComputeProbabilities(bachelor, pidResponse, probTPCTOF);
3965 
3966  Double_t probProton = -1.;
3967  // Double_t probPion = -1.;
3968  // Double_t probKaon = -1.;
3969  if (detUsed == (UInt_t)objectPIDCombined->GetDetectorMask() ) {
3970  AliDebug(2, Form("We have found the detector mask for TOF + TPC: probProton will be set to %f", probTPCTOF[AliPID::kProton]));
3971  probProton = probTPCTOF[AliPID::kProton];
3972  // probPion = probTPCTOF[AliPID::kPion];
3973  // probKaon = probTPCTOF[AliPID::kKaon];
3974  }
3975  else { // if you don't have both TOF and TPC, try only TPC
3976  objectPIDCombined->SetDetectorMask(AliPIDResponse::kDetTPC);
3977  AliDebug(2, "We did not find the detector mask for TOF + TPC, let's see only TPC");
3978  detUsed = objectPIDCombined->ComputeProbabilities(bachelor, pidResponse, probTPCTOF);
3979  AliDebug(2,Form(" detUsed (TPC case) = %d", detUsed));
3980  if (detUsed == (UInt_t)objectPIDCombined->GetDetectorMask()) {
3981  probProton = probTPCTOF[AliPID::kProton];
3982  // probPion = probTPCTOF[AliPID::kPion];
3983  // probKaon = probTPCTOF[AliPID::kKaon];
3984  AliDebug(2, Form("TPC only worked: probProton will be set to %f", probTPCTOF[AliPID::kProton]));
3985  }
3986  else {
3987  AliDebug(2, "Only TPC did not work...");
3988  }
3989  // resetting mask to ask for both TPC+TOF
3990  objectPIDCombined->SetDetectorMask(AliPIDResponse::kDetTPC+AliPIDResponse::kDetTOF);
3991  }
3992  AliDebug(2, Form("probProton = %f", probProton));
3993 
3994  // now we get the TPC and TOF single PID probabilities (only for Proton, or the tree will explode :) )
3995  Double_t probProtonTPC = -1.;
3996  Double_t probProtonTOF = -1.;
3997  Double_t pidTPC[AliPID::kSPECIES]={-1.};
3998  Double_t pidTOF[AliPID::kSPECIES]={-1.};
3999  Int_t respTPC = pidResponse->ComputePIDProbability(AliPIDResponse::kDetTPC, bachelor, AliPID::kSPECIES, pidTPC);
4000  Int_t respTOF = pidResponse->ComputePIDProbability(AliPIDResponse::kDetTOF, bachelor, AliPID::kSPECIES, pidTOF);
4001  if (respTPC == AliPIDResponse::kDetPidOk) probProtonTPC = pidTPC[AliPID::kProton];
4002  if (respTOF == AliPIDResponse::kDetPidOk) probProtonTOF = pidTOF[AliPID::kProton];
4003 
4004  fCandidateVariables[70]=probProton;
4005  fCandidateVariables[71]=probProtonTPC;
4006  fCandidateVariables[72]=probProtonTOF;
4007 
4008  fCandidateVariables[73]=checkLcOrigin;
4009 
4010  fCandidateVariables[74]=v0part->QtProng();
4011 
4012  delete objectPIDCombined;
4013 
4014  fVariablesTree->Fill();
4015 
4016  return;
4017 }
4018 
4019 //-------------------------------------------------------------------------------
4021  //
4023  //
4024 
4025  const char* nameoutput = GetOutputSlot(4)->GetContainer()->GetName();
4026  fVariablesTree = new TTree(nameoutput,"Candidates variables tree");
4027  Int_t nVar = 75;
4028  if (fAdditionalChecks) nVar = 95;
4030  TString * fCandidateVariableNames = new TString[nVar];
4031  fCandidateVariableNames[ 0]="isLcByMC";
4032  fCandidateVariableNames[ 1]="isV0ByMC";
4033  fCandidateVariableNames[ 2]="flagToCheckBachelor";
4034  fCandidateVariableNames[ 3]="flagToCheckV0daughters";
4035  fCandidateVariableNames[ 4]="flagToCheckCandidate";
4036  fCandidateVariableNames[ 5]="massLc2K0Sp";
4037  fCandidateVariableNames[ 6]="massLc2Lambdapi";
4038  fCandidateVariableNames[ 7]="massD2K0Spi"; // D+ -> pi+ K0S
4039  fCandidateVariableNames[ 8]="massDS2K0SK"; // D+S -> K+ K0S
4040  fCandidateVariableNames[ 9]="massK0S";
4041  fCandidateVariableNames[10]="massLambda";
4042  fCandidateVariableNames[11]="massLambdaBar";
4043  fCandidateVariableNames[12]="massGamma";
4044  fCandidateVariableNames[13]="dcaLcptp"; // DCA Lc prong-to-prong
4045  fCandidateVariableNames[14]="dcaV0ptp";
4046  fCandidateVariableNames[15]="tImpParBach";
4047  fCandidateVariableNames[16]="tImpParV0";
4048  fCandidateVariableNames[17]="dcaV0postoPV";
4049  fCandidateVariableNames[18]="dcaV0negtoPV";
4050  fCandidateVariableNames[19]="cosPALc";
4051  fCandidateVariableNames[20]="cosPAK0S";
4052  fCandidateVariableNames[21]="rhoV0";
4053  fCandidateVariableNames[22]="nSigmaITSpr";
4054  fCandidateVariableNames[23]="nSigmaITSpi";
4055  fCandidateVariableNames[24]="nSigmaITSka";
4056  fCandidateVariableNames[25]="nSigmaTPCpr";
4057  fCandidateVariableNames[26]="nSigmaTPCpi";
4058  fCandidateVariableNames[27]="nSigmaTPCka";
4059  fCandidateVariableNames[28]="nSigmaTOFpr";
4060  fCandidateVariableNames[29]="nSigmaTOFpi";
4061  fCandidateVariableNames[30]="nSigmaTOFka";
4062  fCandidateVariableNames[31]="yLc";
4063  fCandidateVariableNames[32]="etaBach"; // etaBachelor
4064  fCandidateVariableNames[33]="etaV0pos"; // etaV0pos
4065  fCandidateVariableNames[34]="etaV0neg"; // etaV0neg
4066  fCandidateVariableNames[35]="LcP"; // @ DCA
4067  fCandidateVariableNames[36]="LcPt"; // @ DCA
4068  fCandidateVariableNames[37]="v0P"; // @ V0 DCA
4069  fCandidateVariableNames[38]="v0Pt"; // @ V0 DCA
4070  fCandidateVariableNames[39]="bachelorP"; // @ prim vtx
4071  fCandidateVariableNames[40]="bachelorPt"; // @ prim vtx
4072  fCandidateVariableNames[41]="V0positiveP"; // @ prim vtx
4073  fCandidateVariableNames[42]="V0positivePt"; // @ prim vtx
4074  fCandidateVariableNames[43]="V0negativeP"; // @ prim vtx
4075  fCandidateVariableNames[44]="V0negativePt"; // @ prim vtx
4076  fCandidateVariableNames[45]="decayLengthLc";
4077  fCandidateVariableNames[46]="decayLengthV0";
4078  fCandidateVariableNames[47]="cosPALcXY"; // cosPA XY x Lc
4079  fCandidateVariableNames[48]="cosPAV0XY"; // cosPA XY x V0
4080  fCandidateVariableNames[49]="decayLengthLcXY"; // decay length XY x Lc
4081  fCandidateVariableNames[50]="decayLengthV0XY"; // decay length XY x V0
4082  fCandidateVariableNames[51]="normalizedDecayLengthLc"; // normalized decay length x Lc
4083  fCandidateVariableNames[52]="normalizedDecayLengthV0"; // normalized decay length x V0
4084  fCandidateVariableNames[53]="normalizedDecayLengthXYLc"; // normalized decay length XY x Lc
4085  fCandidateVariableNames[54]="normalizedDecayLengthXYV0"; // normalized decay length XY x V0
4086  fCandidateVariableNames[55]="newLcDCA";
4087 
4088  fCandidateVariableNames[56]="cosThetaStarBachelor";
4089  fCandidateVariableNames[57]="cosThetaStarV0";
4090  fCandidateVariableNames[58]="etaV0";
4091  fCandidateVariableNames[59]="yV0";
4092  fCandidateVariableNames[60]="bachelorCharge";
4093  fCandidateVariableNames[61]="isMCparticleInFiducialAcceptance";
4094 
4095  fCandidateVariableNames[62]="massKstar12K0Spi"; // Kstar( 892)+ -> pi+ K0S
4096  fCandidateVariableNames[63]="massKstar22K0Spi"; // Kstar(1430)+ -> pi+ K0S
4097  fCandidateVariableNames[64]="pdgBachelor"; // pdg MC bachelor
4098  fCandidateVariableNames[65]="pdgCandidate"; // pdg MC candidate recovered via new method
4099  fCandidateVariableNames[66]="pdgV0pos"; // pdg MC V0 positive
4100  fCandidateVariableNames[67]="pdgV0neg"; // pdg MC V0 negative
4101  fCandidateVariableNames[68]="pdgV0Candidate"; // pdg MC V0candidate recovered via new method
4102  fCandidateVariableNames[69]="startTimeMask"; // start time mask
4103 
4104  fCandidateVariableNames[70]="combinedProtonProb";
4105  fCandidateVariableNames[71]="TPCProtonProb";
4106  fCandidateVariableNames[72]="TOFProtonProb";
4107  fCandidateVariableNames[73]="checkLcOrigin";
4108 
4109  fCandidateVariableNames[74]="qtProng0V0";
4110 
4111  if (fAdditionalChecks) {
4112  fCandidateVariableNames[75]="xVtxLcBad";
4113  fCandidateVariableNames[76]="yVtxLcBad";
4114  fCandidateVariableNames[77]="zVtxLcBad";
4115  fCandidateVariableNames[78]="xVtxLcGood";
4116  fCandidateVariableNames[79]="yVtxLcGood";
4117  fCandidateVariableNames[80]="zVtxLcGood";
4118  fCandidateVariableNames[81]="xVtxLcMC";
4119  fCandidateVariableNames[82]="yVtxLcMC";
4120  fCandidateVariableNames[83]="zVtxLcMC";
4121  fCandidateVariableNames[84]="pxVtxBachelorBad";
4122  fCandidateVariableNames[85]="pyVtxBachelorBad";
4123  fCandidateVariableNames[86]="pxVtxBachelorGood";
4124  fCandidateVariableNames[87]="pyVtxBachelorGood";
4125  fCandidateVariableNames[88]="pzVtxBachelorGood";
4126  fCandidateVariableNames[89]="pxVtxV0";
4127  fCandidateVariableNames[90]="pyVtxV0";
4128  fCandidateVariableNames[91]="pzVtxV0";
4129  fCandidateVariableNames[92]="xPvtx";
4130  fCandidateVariableNames[93]="yPvtx";
4131  fCandidateVariableNames[94]="zPvtx";
4132  }
4133 
4134  for (Int_t ivar=0; ivar<nVar; ivar++) {
4135  fVariablesTree->Branch(fCandidateVariableNames[ivar].Data(),&fCandidateVariables[ivar],Form("%s/f",fCandidateVariableNames[ivar].Data()));
4136  }
4137 
4138  return;
4139 }
4140 
4141 //__________________________________________________________________________
4143  //
4145  //
4146 
4147  fCEvents = new TH1F("fCEvents","conter",20,0,20);
4148  fCEvents->SetStats(kTRUE);
4149  fCEvents->GetXaxis()->SetBinLabel(1,"X1");
4150  fCEvents->GetXaxis()->SetBinLabel(2,"Analyzed events");
4151  fCEvents->GetXaxis()->SetBinLabel(3,"AliAODVertex exists");
4152  fCEvents->GetXaxis()->SetBinLabel(4,"CascadesHF exists");
4153  fCEvents->GetXaxis()->SetBinLabel(5,"MCarray exists");
4154  fCEvents->GetXaxis()->SetBinLabel(6,"MCheader exists");
4155  fCEvents->GetXaxis()->SetBinLabel(7,"GetNContributors()>0");
4156  fCEvents->GetXaxis()->SetBinLabel(8,"IsEventSelected");
4157  fCEvents->GetXaxis()->SetBinLabel(9,"triggerClass!=CINT1");
4158  fCEvents->GetXaxis()->SetBinLabel(10,"triggerMask!=kAnyINT");
4159  fCEvents->GetXaxis()->SetBinLabel(11,"triggerMask!=kAny");
4160  fCEvents->GetXaxis()->SetBinLabel(12,"vtxTitle.Contains(Z)");
4161  fCEvents->GetXaxis()->SetBinLabel(13,"vtxTitle.Contains(3D)");
4162  fCEvents->GetXaxis()->SetBinLabel(14,"vtxTitle.Doesn'tContain(Z-3D)");
4163  fCEvents->GetXaxis()->SetBinLabel(15,Form("zVtx<=%2.0fcm",fAnalCuts->GetMaxVtxZ()));
4164  fCEvents->GetXaxis()->SetBinLabel(16,"!IsEventSelected");
4165  fCEvents->GetXaxis()->SetBinLabel(17,"triggerMask!=kAnyINT || triggerClass!=CINT1");
4166  fCEvents->GetXaxis()->SetBinLabel(18,Form("zVtxMC<=%2.0fcm",fAnalCuts->GetMaxVtxZ()));
4167  fCEvents->GetXaxis()->SetBinLabel(19,"Re-Fill Fail");
4168  fCEvents->GetXaxis()->SetBinLabel(20,"AOD Mismatch");
4169  //fCEvents->GetXaxis()->SetTitle("");
4170  fCEvents->GetYaxis()->SetTitle("counts");
4171 
4172  fOutput->Add(fCEvents);
4173  TString fillthis="";
4174 
4175  if (fUseMCInfo && fAdditionalChecks) {
4176  fillthis="histMcStatLc";
4177  TH1F* mcStatisticLc = new TH1F(fillthis.Data(),"#Lambda_{c} generated and their decays",21,-10.5,10.5);
4178  fOutput->Add(mcStatisticLc);
4179  }
4180 
4181  //fillthis="histopionV0SigmaVspTOF";
4182  //TH2F *hpionV0SigmaVspTOF=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);
4183  fillthis="histoprotonBachSigmaVspTOF";
4184  TH2F *hprotonBachSigmaVspTOF=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);
4185 
4186  //fOutput->Add(hpionV0SigmaVspTOF);
4187  fOutput->Add(hprotonBachSigmaVspTOF);
4188 
4189  //fillthis="histopionV0SigmaVspTPC";
4190  //TH2F *hpionV0SigmaVspTPC=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);
4191  fillthis="histoprotonBachSigmaVspTPC";
4192  TH2F *hprotonBachSigmaVspTPC=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);
4193 
4194  //fOutput->Add(hpionV0SigmaVspTPC);
4195  fOutput->Add(hprotonBachSigmaVspTPC);
4196 
4197  if (fUseMCInfo) {
4198 
4199  //fillthis="histopionV0SigmaVspTOFsgn";
4200  //TH2F *hpionV0SigmaVspTOFsgn=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);
4201  fillthis="histoprotonBachSigmaVspTOFsgn";
4202  TH2F *hprotonBachSigmaVspTOFsgn=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);
4203 
4204  //fOutput->Add(hpionV0SigmaVspTOFsgn);
4205  fOutput->Add(hprotonBachSigmaVspTOFsgn);
4206 
4207  //fillthis="histopionV0SigmaVspTPCsgn";
4208  //TH2F *hpionV0SigmaVspTPCsgn=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);
4209  fillthis="histoprotonBachSigmaVspTPCsgn";
4210  TH2F *hprotonBachSigmaVspTPCsgn=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);
4211 
4212  //fOutput->Add(hpionV0SigmaVspTPCsgn);
4213  fOutput->Add(hprotonBachSigmaVspTPCsgn);
4214 
4215 
4216  //fillthis="histopionV0SigmaVspTOFbkg";
4217  //TH2F *hpionV0SigmaVspTOFbkg=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);
4218  fillthis="histoprotonBachSigmaVspTOFbkg";
4219  TH2F *hprotonBachSigmaVspTOFbkg=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);
4220 
4221  //fOutput->Add(hpionV0SigmaVspTOFbkg);
4222  fOutput->Add(hprotonBachSigmaVspTOFbkg);
4223 
4224  //fillthis="histopionV0SigmaVspTPCbkg";
4225  //TH2F *hpionV0SigmaVspTPCbkg=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);
4226  fillthis="histoprotonBachSigmaVspTPCbkg";
4227  TH2F *hprotonBachSigmaVspTPCbkg=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);
4228 
4229  //fOutput->Add(hpionV0SigmaVspTPCbkg);
4230  fOutput->Add(hprotonBachSigmaVspTPCbkg);
4231 
4232  }
4233 
4234  if (fAdditionalChecks) {
4235 
4236  TH1F *hZ2 = new TH1F("hZ2","",100,-50.,50.);
4237  fOutput->Add(hZ2);
4238  TH1F *hZ3 = new TH1F("hZ3","",100,-50.,50.);
4239  fOutput->Add(hZ3);
4240  TH1F *hZ4 = new TH1F("hZ4","",100,-50.,50.);
4241  fOutput->Add(hZ4);
4242  TH1F *hZ5 = new TH1F("hZ5","",100,-50.,50.);
4243  fOutput->Add(hZ5);
4244  TH1F *hZ6 = new TH1F("hZ6","",100,-50.,50.);
4245  fOutput->Add(hZ6);
4246  TH1F *hZ7 = new TH1F("hZ7","",100,-50.,50.);
4247  fOutput->Add(hZ7);
4248  TH1F *hZ8 = new TH1F("hZ8","",100,-50.,50.);
4249  fOutput->Add(hZ8);
4250  TH1F *hZ9 = new TH1F("hZ9","",100,-50.,50.);
4251  fOutput->Add(hZ9);
4252  TH1F *hZ10 = new TH1F("hZ10","",100,-50.,50.);
4253  fOutput->Add(hZ10);
4254  TH1F *hZ11 = new TH1F("hZ11","",100,-50.,50.);
4255  fOutput->Add(hZ11);
4256  TH1F *hZ12 = new TH1F("hZ12","",100,-50.,50.);
4257  fOutput->Add(hZ12);
4258  TH1F *hZ13 = new TH1F("hZ13","",100,-50.,50.);
4259  fOutput->Add(hZ13);
4260  TH1F *hZ14 = new TH1F("hZ14","",100,-50.,50.);
4261  fOutput->Add(hZ14);
4262  TH1F *hZ15 = new TH1F("hZ15","",100,-50.,50.);
4263  fOutput->Add(hZ15);
4264  TH1F *hZ16 = new TH1F("hZ16","",100,-50.,50.);
4265  fOutput->Add(hZ16);
4266  }
4267 
4268  TH1F *hCandidateSelection = new TH1F("hCandidateSelection","",10,-0.5,9.5);
4269  hCandidateSelection->GetXaxis()->SetBinLabel(1,"IsEventSelected");
4270  hCandidateSelection->GetXaxis()->SetBinLabel(2,"IsSecondaryVtx");
4271  hCandidateSelection->GetXaxis()->SetBinLabel(3,"V0toPosNeg");
4272  hCandidateSelection->GetXaxis()->SetBinLabel(4,"offlineV0");
4273  hCandidateSelection->GetXaxis()->SetBinLabel(5,"isInFiducialAcceptance");
4274  hCandidateSelection->GetXaxis()->SetBinLabel(6,"analCuts::kTracks");
4275  hCandidateSelection->GetXaxis()->SetBinLabel(7,"analCuts::kCandidateNoPID");
4276  hCandidateSelection->GetXaxis()->SetBinLabel(8,"analCuts::kPID");
4277  hCandidateSelection->GetXaxis()->SetBinLabel(9,"analCuts::kCandidateWithPID");
4278  hCandidateSelection->GetXaxis()->SetBinLabel(10,"analCuts::kAll");
4279  fOutput->Add(hCandidateSelection);
4280 
4281  TH1F *hEventsWithCandidates = new TH1F("hEventsWithCandidates","conter",11,5.5,16.5);
4282  hEventsWithCandidates->GetXaxis()->SetBinLabel(1,"GetNContributors()>0");
4283  hEventsWithCandidates->GetXaxis()->SetBinLabel(2,"IsEventSelected");
4284  hEventsWithCandidates->GetXaxis()->SetBinLabel(3,"triggerClass!=CINT1");
4285  hEventsWithCandidates->GetXaxis()->SetBinLabel(4,"triggerMask!=kAnyINT");
4286  hEventsWithCandidates->GetXaxis()->SetBinLabel(5,"triggerMask!=kAny");
4287  hEventsWithCandidates->GetXaxis()->SetBinLabel(6,"vtxTitle.Contains(Z)");
4288  hEventsWithCandidates->GetXaxis()->SetBinLabel(7,"vtxTitle.Contains(3D)");
4289  hEventsWithCandidates->GetXaxis()->SetBinLabel(8,"vtxTitle.Doesn'tContain(Z-3D)");
4290  hEventsWithCandidates->GetXaxis()->SetBinLabel(9,Form("zVtx<=%2.0fcm",fAnalCuts->GetMaxVtxZ()));
4291  hEventsWithCandidates->GetXaxis()->SetBinLabel(10,"!IsEventSelected");
4292  hEventsWithCandidates->GetXaxis()->SetBinLabel(11,"triggerMask!=kAnyINT || triggerClass!=CINT1");
4293  fOutput->Add(hEventsWithCandidates);
4294 
4295  if (fAdditionalChecks) {
4296 
4297  TH1F *hZ6a = new TH1F("hZ6a","",100,-50.,50.);
4298  fOutput->Add(hZ6a);
4299  TH1F *hZ7a = new TH1F("hZ7a","",100,-50.,50.);
4300  fOutput->Add(hZ7a);
4301  TH1F *hZ8a = new TH1F("hZ8a","",100,-50.,50.);
4302  fOutput->Add(hZ8a);
4303  TH1F *hZ9a = new TH1F("hZ9a","",100,-50.,50.);
4304  fOutput->Add(hZ9a);
4305  TH1F *hZ10a = new TH1F("hZ10a","",100,-50.,50.);
4306  fOutput->Add(hZ10a);
4307  TH1F *hZ11a = new TH1F("hZ11a","",100,-50.,50.);
4308  fOutput->Add(hZ11a);
4309  TH1F *hZ12a = new TH1F("hZ12a","",100,-50.,50.);
4310  fOutput->Add(hZ12a);
4311  TH1F *hZ13a = new TH1F("hZ13a","",100,-50.,50.);
4312  fOutput->Add(hZ13a);
4313  TH1F *hZ14a = new TH1F("hZ14a","",100,-50.,50.);
4314  fOutput->Add(hZ14a);
4315  TH1F *hZ15a = new TH1F("hZ15a","",100,-50.,50.);
4316  fOutput->Add(hZ15a);
4317  TH1F *hZ16a = new TH1F("hZ16a","",100,-50.,50.);
4318  fOutput->Add(hZ16a);
4319  }
4320 
4321  TH1F *hSwitchOnCandidates1 = new TH1F("hSwitchOnCandidates1","",15,-7.5,7.5);
4322  fOutput->Add(hSwitchOnCandidates1);
4323  TH1F *hSwitchOnCandidates2 = new TH1F("hSwitchOnCandidates2","",15,-7.5,7.5);
4324  fOutput->Add(hSwitchOnCandidates2);
4325  TH1F *hSwitchOnCandidates3 = new TH1F("hSwitchOnCandidates3","",15,-7.5,7.5);
4326  fOutput->Add(hSwitchOnCandidates3);
4327  TH1F *hSwitchOnCandidates4 = new TH1F("hSwitchOnCandidates4","",15,-7.5,7.5);
4328  fOutput->Add(hSwitchOnCandidates4);
4329 
4330  return;
4331 }
4332 
4333 //________________________________________________________________________
4335  //
4336  // This is to fill analysis histograms
4337  //
4338 
4339  TString fillthis="";
4340 
4341  Bool_t isBachelorID = (((cutsAnal->IsSelected(part,AliRDHFCuts::kPID))&(AliRDHFCutsLctoV0::kLcToK0Spr))==(AliRDHFCutsLctoV0::kLcToK0Spr)); // ID x bachelor
4342 
4343  Bool_t areCutsUsingPID = cutsAnal->GetIsUsePID();
4344  cutsAnal->SetUsePID(kFALSE);
4345 
4346  Double_t invmassLc = part->InvMassLctoK0sP();
4347  Double_t lambdacpt = part->Pt();
4348 
4349  AliAODTrack *bachelor = (AliAODTrack*)part->GetBachelor();
4350  Double_t momBach = bachelor->P();
4351  Double_t ptBach = bachelor->Pt();
4352 
4353  AliAODv0 *v0part = (AliAODv0*)part->Getv0();
4354  Double_t momK0S = v0part->P();
4355  Double_t ptK0S = v0part->Pt();
4356  //Double_t dcaV0ptp = v0part->GetDCA();
4357  Double_t invmassK0S = v0part->MassK0Short();
4358 
4359  AliAODTrack *v0pos = (AliAODTrack*)part->Getv0PositiveTrack();
4360  Double_t ptV0pos = v0pos->Pt();
4361  AliAODTrack *v0neg = (AliAODTrack*)part->Getv0NegativeTrack();
4362  Double_t ptV0neg = v0neg->Pt();
4363 
4364  if (!appendthis.Contains("SgnC") && !appendthis.Contains("SgnB") && !appendthis.Contains("SgnNoQ")) {
4365  fillthis="histpK0Svsp"+appendthis;
4366  //cout << fillthis << endl;
4368  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(momBach,momK0S);
4369  if (isBachelorID) ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(momBach,momK0S);
4370  }
4371  }
4372 
4373  fillthis="histLcMassByK0S"+appendthis;
4374  //cout << fillthis << endl;
4376  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(invmassLc,lambdacpt);
4377  if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(invmassLc,lambdacpt);
4378  }
4379 
4380  if(fFillSubSampleHist && appendthis=="Offline"){
4381  fillthis="histLcMassByK0SSubSample"+appendthis;
4383  Double_t contsp[3];contsp[0]=invmassLc;contsp[1]=lambdacpt;contsp[2]=(Double_t)(fEventCounter%24);
4384  if (isBachelorID)((THnSparse*)(fOutputPIDBach->FindObject(fillthis)))->Fill(contsp);
4385  }
4386  }
4387 
4388  if (!appendthis.Contains("SgnC") && !appendthis.Contains("SgnB") && !appendthis.Contains("SgnNoQ")) {
4389  fillthis="histK0SMass"+appendthis;
4390  // cout << fillthis << endl;
4391  cutsAnal->SetExcludedCut(2);
4393  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(lambdacpt,invmassK0S);
4394  if (isBachelorID) ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(lambdacpt,invmassK0S);
4395  }
4396  cutsAnal->SetExcludedCut(-1);
4397  }
4398 
4399  fillthis="histptK0S"+appendthis;
4400  //cout << fillthis << endl;
4401  cutsAnal->SetExcludedCut(15);
4403  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(lambdacpt,ptK0S);
4404  if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(lambdacpt,ptK0S);
4405  }
4406 
4407  fillthis="histptP"+appendthis;
4408  //cout << fillthis << endl;
4409  cutsAnal->SetExcludedCut(4);
4411  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(lambdacpt,ptBach);
4412  if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(lambdacpt,ptBach);
4413  }
4414 
4415  fillthis="histptPip"+appendthis;
4416  //cout << fillthis << endl;
4417  cutsAnal->SetExcludedCut(5);
4419  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(lambdacpt,ptV0pos);
4420  if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(lambdacpt,ptV0pos);
4421  }
4422 
4423  fillthis="histptPim"+appendthis;
4424  //cout << fillthis << endl;
4425  cutsAnal->SetExcludedCut(6);
4427  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(lambdacpt,ptV0neg);
4428  if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(lambdacpt,ptV0neg);
4429  }
4430 
4431  if (!appendthis.Contains("SgnC") && !appendthis.Contains("SgnB") && !appendthis.Contains("SgnNoQ")) {
4432  fillthis="histLambdaMass"+appendthis;
4433  // cout << fillthis << endl;
4434  cutsAnal->SetExcludedCut(13);
4436  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(lambdacpt,v0part->MassLambda());
4437  if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(lambdacpt,v0part->MassLambda());
4438  }
4439 
4440  fillthis="histLambdaBarMass"+appendthis;
4441  // cout << fillthis << endl;
4442  cutsAnal->SetExcludedCut(13);
4444  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(lambdacpt,v0part->MassAntiLambda());
4445  if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(lambdacpt,v0part->MassAntiLambda());
4446  }
4447 
4448  fillthis="histGammaMass"+appendthis;
4449  // cout << fillthis << endl;
4450  cutsAnal->SetExcludedCut(14);
4452  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(lambdacpt,v0part->InvMass2Prongs(0,1,11,11));
4453  if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(lambdacpt,v0part->InvMass2Prongs(0,1,11,11));
4454  }
4455  }
4456 
4457  fillthis="histD0K0S"+appendthis;
4458  //cout << fillthis << endl;
4459  cutsAnal->SetExcludedCut(11);
4461  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(lambdacpt,part->Getd0Prong(1));
4462  if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(lambdacpt,part->Getd0Prong(1));
4463  }
4464 
4465  fillthis="histD0P"+appendthis;
4466  //cout << fillthis << endl;
4467  cutsAnal->SetExcludedCut(10);
4469  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(lambdacpt,part->Getd0Prong(0));
4470  if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(lambdacpt,part->Getd0Prong(0));
4471  }
4472 
4473  fillthis="histCosPAK0S"+appendthis;
4474  //cout << fillthis << endl;
4475  cutsAnal->SetExcludedCut(9);
4477  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(lambdacpt,part->CosV0PointingAngle());
4478  if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(lambdacpt,part->CosV0PointingAngle());
4479  }
4480 
4481  fillthis="histCosThetaProtonCMS"+appendthis;
4482  //cout << fillthis << endl;
4483  cutsAnal->SetExcludedCut(16);
4485  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(lambdacpt,cutsAnal->GetProtonEmissionAngleCMS(part));
4486  if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(lambdacpt,cutsAnal->GetProtonEmissionAngleCMS(part));
4487  }
4488 
4489  fillthis="histResignedD0"+appendthis;
4490  //cout << fillthis << endl;
4491  cutsAnal->SetExcludedCut(18);
4493  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(lambdacpt,cutsAnal->GetReSignedd0(part));
4494  if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(lambdacpt,cutsAnal->GetReSignedd0(part));
4495  }
4496 
4497  cutsAnal->SetExcludedCut(-1);
4498 
4499  cutsAnal->SetUsePID(areCutsUsingPID);
4500 
4501  return;
4502 }
4503 //---------------------------
4505  Double_t &xVtxLc, Double_t &yVtxLc, Double_t &zVtxLc,
4506  Double_t &pxVtxBachelor, Double_t &pyVtxBachelor, Double_t &pzVtxBachelor) {
4507  //--------------------------------------------------------------------
4510  //--------------------------------------------------------------------
4511 
4512  // Get AliExternalTrackParam out of the AliAODTracks
4513  Double_t xyz[3], pxpypz[3], cv[21]; Short_t sign;
4514  bachelor->PxPyPz(pxpypz);
4515  bachelor->XvYvZv(xyz);
4516  bachelor->GetCovarianceXYZPxPyPz(cv);
4517  sign=bachelor->Charge();
4518  AliExternalTrackParam *t = new AliExternalTrackParam(xyz,pxpypz,cv,sign);
4519 
4520  Double_t alpha=t->GetAlpha(), cs1=TMath::Cos(alpha), sn1=TMath::Sin(alpha);
4521  //Double_t alpha = GetAlpha(xyz,pxpypz), cs1=TMath::Cos(alpha), sn1=TMath::Sin(alpha);
4522 
4523  // position and momentum of bachelor
4524  Double_t x1=xyz[0], y1=xyz[1], z1=xyz[2];
4525  Double_t px1=pxpypz[0], py1=pxpypz[1], pz1=pxpypz[2];
4526 
4527  // position and momentum of V0
4528  Double_t x2=v->DecayVertexV0X(),
4529  y2=v->DecayVertexV0Y(),
4530  z2=v->DecayVertexV0Z();
4531  Double_t px2=v->Px(),
4532  py2=v->Py(),
4533  pz2=v->Pz();
4534 
4535  /*
4536  AliAODTrack *trackP = (AliAODTrack*) v->GetDaughter(0);
4537  //Double_t pxpypzP[3]; trackP->PxPyPz(pxpypzP);
4538  //Double_t xyzP[3]; trackP->XvYvZv(xyzP);
4539  Double_t cvP[21]; trackP->GetCovarianceXYZPxPyPz(cvP);
4540  //Short_t signP=trackP->Charge();
4541  //AliExternalTrackParam *tP = new AliExternalTrackParam(xyzP,pxpypzP,cvP,signP);
4542 
4543  // Get AliExternalTrackParam out of the AliAODTrack
4544  AliAODTrack *trackN = (AliAODTrack*) v->GetDaughter(1);
4545  //Double_t pxpypzN[3]; trackN->PxPyPz(pxpypzN);
4546  //Double_t xyzN[3]; trackN->XvYvZv(xyzN);
4547  Double_t cvN[21]; trackN->GetCovarianceXYZPxPyPz(cvN);
4548  //Short_t signN=trackN->Charge();
4549  //AliExternalTrackParam *tN = new AliExternalTrackParam(xyzN,pxpypzN,cvN,signN);
4550 
4551  Double_t xyzV0[3]={x2,y2,z2};
4552  Double_t pxpypzV0[3]={px2,py2,pz2};
4553  Double_t cvV0[21]; for (Int_t ii=0; ii<21; ii++) cvV0[ii]=cvP[ii]+cvN[ii];
4554  AliNeutralTrackParam *trackV0 = new AliNeutralTrackParam(xyzV0,pxpypzV0,cvV0,0);
4555  */
4556 
4557  // calculation dca
4558  Double_t dd= Det(x2-x1,y2-y1,z2-z1,px1,py1,pz1,px2,py2,pz2);
4559  Double_t ax= Det(py1,pz1,py2,pz2);
4560  Double_t ay=-Det(px1,pz1,px2,pz2);
4561  Double_t az= Det(px1,py1,px2,py2);
4562 
4563  Double_t dca=TMath::Abs(dd)/TMath::Sqrt(ax*ax + ay*ay + az*az);
4564 
4565  // bachelor point @ the DCA
4566  Double_t t1 = Det(x2-x1,y2-y1,z2-z1,px2,py2,pz2,ax,ay,az)/
4567  Det(px1,py1,pz1,px2,py2,pz2,ax,ay,az);
4568  x1 += px1*t1; y1 += py1*t1; z1 += pz1*t1;
4569 
4570  //propagate track to the point of DCA
4571  Double_t rho1=x1*cs1 + y1*sn1;
4572  if (!t->PropagateTo(rho1,b)) {
4573  Error("PropagateToDCA","Propagation failed !");
4574  delete t; t=NULL;
4575  return 1.e+33;
4576  }
4577 
4578  Double_t pBachelorDCA[3]; t->GetPxPyPz(pBachelorDCA);
4579  pxVtxBachelor=pBachelorDCA[0], pyVtxBachelor=pBachelorDCA[1], pzVtxBachelor=pBachelorDCA[2];
4580 
4581  delete t; t=NULL;
4582 
4583  // V0 point @ the DCA
4584  Double_t t2 = Det(x1-x2,y1-y2,z1-z2,px1,py1,pz1,ax,ay,az)/
4585  Det(px2,py2,pz2,px1,py1,pz1,ax,ay,az);
4586  x2 += px2*t2; y2 += py2*t2; z2 += pz2*t2;
4587 
4588 
4589  // Lc decay vtx
4590  xVtxLc = 0.5*(x1+x2);
4591  yVtxLc = 0.5*(y1+y2);
4592  zVtxLc = 0.5*(z1+z2);
4593 
4594  return dca;
4595 
4596 }
4597 
4598 //---------------------------
4600 {
4601  //
4603  //
4604 
4605  Double_t alpha = 0.;
4606 
4607  const double kSafe = 1e-5;
4608  Double_t radPos2 = xyz[0]*xyz[0]+xyz[1]*xyz[1];
4609  Double_t radMax = 45.; // approximately ITS outer radius
4610  if (radPos2 < radMax*radMax) { // inside the ITS
4611  alpha = TMath::ATan2(pxpypz[1],pxpypz[0]);
4612  } else { // outside the ITS
4613  Float_t phiPos = TMath::Pi()+TMath::ATan2(-xyz[1], -xyz[0]);
4614  alpha =
4615  TMath::DegToRad()*(20*((((Int_t)(phiPos*TMath::RadToDeg()))/20))+10);
4616  }
4617 
4618  Double_t cs=TMath::Cos(alpha), sn=TMath::Sin(alpha);
4619  // protection: avoid alpha being too close to 0 or +-pi/2
4620  if (TMath::Abs(sn)<2*kSafe) {
4621  if (alpha>0) alpha += alpha< TMath::Pi()/2. ? 2*kSafe : -2*kSafe;
4622  else alpha += alpha>-TMath::Pi()/2. ? -2*kSafe : 2*kSafe;
4623  cs=TMath::Cos(alpha);
4624  sn=TMath::Sin(alpha);
4625  }
4626  else if (TMath::Abs(cs)<2*kSafe) {
4627  if (alpha>0) alpha += alpha> TMath::Pi()/2. ? 2*kSafe : -2*kSafe;
4628  else alpha += alpha>-TMath::Pi()/2. ? 2*kSafe : -2*kSafe;
4629  cs=TMath::Cos(alpha);
4630  sn=TMath::Sin(alpha);
4631  }
4632 
4633 
4634  return alpha;
4635 }
4636 
4637 //---------------------------
4639  Double_t a10, Double_t a11) const {
4640  //--------------------------------------------------------------------
4643  //--------------------------------------------------------------------
4644  return a00*a11 - a01*a10;
4645 }
4646 
4647 //---------------------------
4649  Double_t a10,Double_t a11,Double_t a12,
4650  Double_t a20,Double_t a21,Double_t a22) const {
4651  //--------------------------------------------------------------------
4654  //--------------------------------------------------------------------
4655  return a00*Det(a11,a12,a21,a22)-a01*Det(a10,a12,a20,a22)+a02*Det(a10,a11,a20,a21);
4656 }
4657 
4658 //----------------------------------------------------------------------------
4660  TClonesArray *mcArray)
4661 {
4662  //
4666  //
4667 
4668  AliAODv0 *theV0 = dynamic_cast<AliAODv0*>(candidate->Getv0()); // the V0
4669  AliVTrack *trk = dynamic_cast<AliVTrack*>(candidate->GetBachelor()); // the bachelor
4670  if (!trk || !theV0) return -1;
4671 
4672  if (trk->GetLabel()==-1) return -1;
4673  Int_t bachLabels = TMath::Abs(trk->GetLabel());
4674  AliAODMCParticle*bachelorMC = dynamic_cast<AliAODMCParticle*>(mcArray->At(bachLabels));
4675  if (!bachelorMC) return -1;
4676  if (TMath::Abs(bachelorMC->GetPdgCode())!=2212) return -1;
4677  Int_t indexMotherBach = bachelorMC->GetMother();
4678  if (indexMotherBach==-1) return -1;
4679 
4680  Int_t pdgDg2prong[2] = {211,211};
4681  Int_t lab2Prong = theV0->MatchToMC(310,mcArray,2,pdgDg2prong); // the V0
4682  if(lab2Prong<0) return -1;
4683  AliAODMCParticle*partK0S = dynamic_cast<AliAODMCParticle*>(mcArray->At(lab2Prong));
4684  if (!partK0S) return -1;
4685  Int_t indexMotherK0S = partK0S->GetMother();
4686  if (indexMotherK0S==-1) return -1;
4687  AliAODMCParticle*partK0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(indexMotherK0S));
4688  if (!partK0) return -1;
4689  Int_t indexMotherK0 = partK0->GetMother();
4690  if (indexMotherK0==-1) return -1;
4691 
4692  if (indexMotherBach!=indexMotherK0) return -1; // p e K0S sono fratelli
4693 
4694  AliAODMCParticle*partLc = dynamic_cast<AliAODMCParticle*>(mcArray->At(indexMotherK0));
4695  if (!partLc) return -1;
4696  Int_t ndg2 = partLc->GetDaughter(1)-partLc->GetDaughter(0)+1;
4697  if (ndg2==2) return -1;
4698 
4699  TString stringaCheck = Form(">>>>>>>> %d -> ",partLc->GetPdgCode());
4700  for(Int_t ii=0; ii<ndg2; ii++) {
4701  AliAODMCParticle* partDau=(AliAODMCParticle*)(mcArray->At(partLc->GetDaughter(0)+ii));
4702  stringaCheck.Append(Form(" %d",partDau->GetPdgCode()));
4703  }
4704  //printf("%s \n",stringaCheck.Data());
4705 
4706  return indexMotherBach;
4707 
4708 }
4709 //--------------------------------------------------------------------------
4711  Int_t dgLabels[10],Int_t ndg,
4712  Int_t &ndgCk, Int_t *pdgDg, Int_t &absLabelMother, Int_t &nDauCand) const
4713 {
4719 
4720  Int_t lab=-1,labMother=-1,pdgMother=0;
4721  AliAODMCParticle *part=0;
4722  AliAODMCParticle *mother=0;
4723 
4724  // loop on daughter labels
4725  TArrayI **labelMother = new TArrayI*[ndg];
4726  for(Int_t i=0; i<ndg; i++) labelMother[i] = new TArrayI(0);
4727  for(Int_t i=0; i<ndg; i++) {
4728  lab = TMath::Abs(dgLabels[i]);
4729  if(lab<0) {
4730  AliDebug(2,Form("daughter with negative label %d",lab));
4731  delete [] labelMother;
4732  return 0;
4733  }
4734  part = (AliAODMCParticle*)mcArray->At(lab);
4735  if(!part) {
4736  AliDebug(2,"no MC particle");
4737  delete [] labelMother;
4738  return 0;
4739  }
4740 
4741  mother = part;
4742  while(mother->GetMother()>=0) {
4743  labMother=mother->GetMother();
4744  mother = (AliAODMCParticle*)mcArray->At(labMother);
4745  if(!mother) {
4746  AliDebug(2,"no MC mother particle");
4747  break;
4748  }
4749  pdgMother = TMath::Abs(mother->GetPdgCode());
4750  if (pdgMother<10 || (pdgMother>18 && pdgMother<111)) {
4751  break;
4752  }
4753  labelMother[i]->Set(labelMother[i]->GetSize()+1);
4754  labelMother[i]->AddAt(labMother,labelMother[i]->GetSize()-1);
4755  }
4756 
4757  } // end loop on daughters
4758 
4759 
4760  TString stringaCheck;
4761  for(Int_t i=0; i<ndg; i++) {
4762  AliAODMCParticle*part0 = (AliAODMCParticle*)mcArray->At(TMath::Abs(dgLabels[i]));
4763  stringaCheck.Append(Form("part[%d]->GetLabel()=%d(%d) | ",i,dgLabels[i],part0->GetPdgCode()));
4764  stringaCheck.Append(Form("labelMother[%d] = ",i));
4765  for (Int_t jj=0;jj<labelMother[i]->GetSize(); jj++)
4766  stringaCheck.Append(Form("%d, ",labelMother[i]->At(jj)));
4767  }
4768  AliDebug(2,Form("%s \n",stringaCheck.Data()));
4769  Int_t pdgToBeReturned=0;
4770 
4771  TString stringaCheck2;
4772  ndgCk=ndg;
4773  pdgDg = new Int_t[ndgCk];
4774  for (Int_t index=1; index<ndg; index++) {
4775  Bool_t found=kFALSE;
4776  for (Int_t jj=0;jj<labelMother[index]->GetSize(); jj++) {
4777  for (Int_t ii=0;ii<labelMother[0]->GetSize(); ii++) {
4778  if (labelMother[0]->At(ii)==labelMother[index]->At(jj) &&
4779  labelMother[0]->At(ii)!=0 && labelMother[0]->At(ii)!=1 && !found) {
4780  mother = (AliAODMCParticle*)mcArray->At(labelMother[0]->At(ii));
4781  pdgToBeReturned=mother->GetPdgCode();
4782  absLabelMother=labelMother[0]->At(ii);
4783  AliDebug(2,Form("FOUND label for the mother of this candidate: %d (PDG=%d)\n",labelMother[0]->At(ii),pdgToBeReturned));
4784  //mother->Print();
4785  nDauCand=mother->GetNDaughters();
4786  found = kTRUE;
4787  AliAODMCParticle *partMC = (AliAODMCParticle*)mcArray->At(dgLabels[0]);
4788  pdgDg[0]=partMC->GetPdgCode();
4789  partMC = (AliAODMCParticle*)mcArray->At(dgLabels[index]);
4790  pdgDg[index]=partMC->GetPdgCode();
4791  if (index==1) stringaCheck2.Append(Form("found daughters -> %d(%d)",dgLabels[0],pdgDg[0]));
4792  stringaCheck2.Append(Form(" %d(%d)",dgLabels[index],pdgDg[index]));
4793  break;
4794  }
4795  }
4796  if (found) break;
4797  }
4798  }
4799  stringaCheck2.Prepend(Form("Ecco quanto trovato: %d(%d) with %d daughters; ",absLabelMother,pdgToBeReturned,nDauCand));
4800  AliDebug(2,Form("%s \n",stringaCheck2.Data()));
4801 
4802  delete [] labelMother;
4803  delete [] pdgDg;
4804 
4805  return pdgToBeReturned;
4806 
4807 }
4808 
4810 {
4811 
4812  AliAODRecoCascadeHF *partCopy = new AliAODRecoCascadeHF(*part);
4813 
4814  Double_t px[2]={partCopy->PxProng(0),partCopy->PxProng(1)};
4815  Double_t py[2]={partCopy->PyProng(0),partCopy->PyProng(1)};
4816  Double_t pz[2]={partCopy->PzProng(0),partCopy->PzProng(1)};
4817 
4818  Double_t pt = partCopy->Pt();
4819  Int_t pdgD=4122;
4820  UInt_t pdgLc2pK0S[2]={2212,310};
4821  Double_t minv2 = partCopy->InvMass2(2,pdgLc2pK0S);
4822  Double_t mass=TMath::Sqrt(minv2);
4823  Double_t rapid = partCopy->Y(pdgD);
4824 
4825  TString fillthis;
4826 
4828  fillthis="hMassVsPtVsY"+appendthis;
4829  //cout << fillthis << endl;
4830  ((TH3F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(mass,pt,rapid);
4831 
4832  fillthis="phiVSthetaVSpt"+appendthis;
4833  //cout << fillthis << endl;
4834  ((TH3F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(pt,part->Phi(),part->Theta());
4835  }
4836 
4837  Int_t nRotated=0;
4838  Double_t massRot=0;// calculated later only if candidate is acceptable
4839  // Double_t angleProngXY=TMath::ACos((px[0]*px[1]+py[0]*py[1])/TMath::Sqrt((px[0]*px[0]+py[0]*py[0])*(px[1]*px[1]+py[1]*py[1])));
4840  // Double_t ptOrig=pt;
4841  Double_t rotStep=(fMaxAngleForRot-fMinAngleForRot)/(fNRotations-1); // -1 is to ensure that the last rotation is done with angle=fMaxAngleForRot
4842 
4843  for(Int_t irot=0; irot<fNRotations; irot++){
4844  Double_t phirot=fMinAngleForRot+rotStep*irot;
4845  Double_t tmpx=px[0];
4846  Double_t tmpy=py[0];
4847  px[0]=tmpx*TMath::Cos(phirot)-tmpy*TMath::Sin(phirot);
4848  py[0]=tmpx*TMath::Sin(phirot)+tmpy*TMath::Cos(phirot);
4849  partCopy->SetPxPyPzProngs(2,px,py,pz);
4850  pt = partCopy->Pt();
4851  minv2 = partCopy->InvMass2(2,pdgLc2pK0S);
4852  massRot=TMath::Sqrt(minv2);
4853  rapid = partCopy->Y(pdgD);
4854  //if(minv2>fMinMass*fMinMass && minv2<fMaxMass*fMaxMass){
4855  if ( cuts->IsInFiducialAcceptance(pt,partCopy->Y(4122)) ) {
4857 
4858  fillthis="histLcMassByK0S"+appendthis;
4859  //cout << fillthis << endl;
4860  ((TH2F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(massRot,pt);
4861 
4862  fillthis="hMassVsPtVsYRot"+appendthis;
4863  //cout << fillthis << endl;
4864  ((TH3F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(mass,pt,rapid);
4865 
4866  fillthis="phiVSthetaVSptRot"+appendthis;
4867  //cout << fillthis << endl;
4868  ((TH3F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(pt,partCopy->Phi(),partCopy->Theta());
4869 
4870  fillthis="hDeltaMass"+appendthis;
4871  //cout << fillthis << endl;
4872  ((TH1F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(massRot-mass);
4873  //if(fFullAnalysis){
4874  //Double_t pointRot[5]={mass,massRot-mass,ptOrig,pt-ptOrig,angleProngXY};
4875  //fillthis="hDeltaMassFullAnalysis"+appendthis;
4877  //((THnSparse*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(pointRot);
4878  //}
4879  nRotated++;
4880  //}
4881  }
4882 
4883  // fill additional histos for track-rotated candidates
4884  fillthis="histptK0S"+appendthis;
4885  //cout << fillthis << endl;
4886  cuts->SetExcludedCut(15);
4888  ((TH2F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(pt,TMath::Sqrt(px[1]*px[1]+py[1]*py[1]));
4889  }
4890 
4891  fillthis="histptP"+appendthis;
4892  //cout << fillthis << endl;
4893  cuts->SetExcludedCut(4);
4895  ((TH2F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(pt,TMath::Sqrt(px[0]*px[0]+py[0]*py[0]));
4896  }
4897 
4898  fillthis="histptPip"+appendthis;
4899  //cout << fillthis << endl;
4900  cuts->SetExcludedCut(5);
4902  ((TH2F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(pt,(partCopy->Getv0PositiveTrack())->Pt());
4903  }
4904 
4905  fillthis="histptPim"+appendthis;
4906  //cout << fillthis << endl;
4907  cuts->SetExcludedCut(6);
4909  ((TH2F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(pt,(partCopy->Getv0NegativeTrack())->Pt());
4910  }
4911 
4912  fillthis="histLambdaMass"+appendthis;
4913  //cout << fillthis << endl;
4914  cuts->SetExcludedCut(13);
4916  ((TH2F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(pt,(partCopy->Getv0())->MassLambda());
4917  }
4918 
4919  fillthis="histLambdaBarMass"+appendthis;
4920  //cout << fillthis << endl;
4921  cuts->SetExcludedCut(13);
4923  ((TH2F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(pt,(partCopy->Getv0())->MassAntiLambda());
4924  }
4925 
4926  fillthis="histGammaMass"+appendthis;
4927  //cout << fillthis << endl;
4928  cuts->SetExcludedCut(14);
4930  ((TH2F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(pt,(partCopy->Getv0())->InvMass2Prongs(0,1,11,11));
4931  }
4932 
4933  fillthis="histCosPAK0S"+appendthis;
4934  //cout << fillthis << endl;
4935  cuts->SetExcludedCut(9);
4937  ((TH2F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(pt,partCopy->CosV0PointingAngle());
4938  }
4939 
4940  fillthis="histCosThetaProtonCMS"+appendthis;
4941  //cout << fillthis << endl;
4942  cuts->SetExcludedCut(16);
4944  ((TH2F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(pt,cuts->GetProtonEmissionAngleCMS(partCopy));
4945  }
4946 
4947  fillthis="histResignedD0"+appendthis;
4948  //cout << fillthis << endl;
4949  cuts->SetExcludedCut(18);
4951  ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(pt,cuts->GetReSignedd0(partCopy));
4952  }
4953  cuts->SetExcludedCut(-1);
4954 
4955  } // isInFiducialAcceptance
4956 
4957  px[0]=tmpx;
4958  py[0]=tmpy;
4959  }
4960  fillthis="hNormRotated"+appendthis;
4961  //cout << fillthis << endl;
4962  ((TH1F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(nRotated);
4963 
4964  delete partCopy;
4965 
4966  return;
4967 
4968 }
4969 
4970 //----------------------------------------------------
4972 {
4973  //
4974  // Define analysis histograms for SNG separated for origin (from c, from b and from no-quark)
4975  //
4976 
4977  if (!fUseMCInfo) return;
4978  if (!fCheckOrigin) return;
4979 
4980  Double_t mLcPDG = TDatabasePDG::Instance()->GetParticle(4122)->Mass();
4981  Double_t mK0SPDG = TDatabasePDG::Instance()->GetParticle(310)->Mass();
4982  Double_t mMinLambdaPDG = TDatabasePDG::Instance()->GetParticle(2212)->Mass()+
4983  TDatabasePDG::Instance()->GetParticle(211)->Mass();
4984 
4985  TString nameHistoSgnC=" ", nameHistoSgnB=" ", nameHistoSgnNoQ=" ";
4986  TString titleHistoSgnC=" ", titleHistoSgnB=" ", titleHistoSgnNoQ=" ";
4987 
4988  // pt(Lc)
4989  Double_t *binLimpTLc=new Double_t[11+1]; // 11 pT(Lc) bins
4990  binLimpTLc[ 0]= 0.;
4991  binLimpTLc[ 1]= 1.;
4992  binLimpTLc[ 2]= 2.;
4993  binLimpTLc[ 3]= 3.;
4994  binLimpTLc[ 4]= 4.;
4995  binLimpTLc[ 5]= 5.;
4996  binLimpTLc[ 6]= 6.;
4997  binLimpTLc[ 7]= 8.;
4998  binLimpTLc[ 8]=12.;
4999  binLimpTLc[ 9]=17.;
5000  binLimpTLc[10]=25.;
5001  binLimpTLc[11]=35.;
5002 
5003  // pt(prong)
5004  Double_t *binLimpTprong=new Double_t[41+1]; // 41 pT(prong) bins
5005  binLimpTprong[ 0]= 0.0;
5006  binLimpTprong[ 1]= 0.1;
5007  binLimpTprong[ 2]= 0.2;
5008  binLimpTprong[ 3]= 0.3;
5009  binLimpTprong[ 4]= 0.4;
5010  binLimpTprong[ 5]= 0.5;
5011  binLimpTprong[ 6]= 0.6;
5012  binLimpTprong[ 7]= 0.7;
5013  binLimpTprong[ 8]= 0.8;
5014  binLimpTprong[ 9]= 0.9;
5015  binLimpTprong[10]= 1.0;
5016  binLimpTprong[11]= 1.2;
5017  binLimpTprong[12]= 1.4;
5018  binLimpTprong[13]= 1.6;
5019  binLimpTprong[14]= 1.8;
5020  binLimpTprong[15]= 2.0;
5021  binLimpTprong[16]= 2.2;
5022  binLimpTprong[17]= 2.4;
5023  binLimpTprong[18]= 2.6;
5024  binLimpTprong[19]= 2.8;
5025  binLimpTprong[20]= 3.0;
5026  binLimpTprong[21]= 3.5;
5027  binLimpTprong[22]= 4.0;
5028  binLimpTprong[23]= 4.5;
5029  binLimpTprong[24]= 5.0;
5030  binLimpTprong[25]= 5.5;
5031  binLimpTprong[26]= 6.0;
5032  binLimpTprong[27]= 6.5;
5033  binLimpTprong[28]= 7.0;
5034  binLimpTprong[29]= 7.5;
5035  binLimpTprong[30]= 8.0;
5036  binLimpTprong[31]= 9.0;
5037  binLimpTprong[32]=10.0;
5038  binLimpTprong[33]=11.0;
5039  binLimpTprong[34]=12.0;
5040  binLimpTprong[35]=13.0;
5041  binLimpTprong[36]=14.0;
5042  binLimpTprong[37]=15.0;
5043  binLimpTprong[38]=20.0;
5044  binLimpTprong[39]=25.0;
5045  binLimpTprong[40]=30.0;
5046  binLimpTprong[41]=35.0;
5047 
5048  if (fUseOnTheFlyV0) {
5049 
5050  nameHistoSgnC="histLcMassByK0SSgnC";
5051  nameHistoSgnB="histLcMassByK0SSgnB";
5052  nameHistoSgnNoQ="histLcMassByK0SSgnNoQ";
5053  titleHistoSgnC="#Lambda_{c} #leftarrow c - sgn: invariant mass (by K^{0}_{S}) vs p_{T} - MC; m_{inv}(p,K^{0}_{S}) [GeV/c^{2}]; p_{T}(#Lambda_{c}) [GeV/c]";
5054  titleHistoSgnB="#Lambda_{c} #leftarrow b - sgn: invariant mass (by K^{0}_{S}) vs p_{T} - MC; m_{inv}(p,K^{0}_{S}) [GeV/c^{2}]; p_{T}(#Lambda_{c}) [GeV/c]";
5055  titleHistoSgnNoQ="#Lambda_{c} #leftarrow no quark - sgn: invariant mass (by K^{0}_{S}) vs p_{T} - MC; m_{inv}(p,K^{0}_{S}) [GeV/c^{2}]; p_{T}(#Lambda_{c}) [GeV/c]";
5056  TH2F* spectrumLcMassByK0SSgnC = new TH2F(nameHistoSgnC.Data(),titleHistoSgnC.Data(),1000,mLcPDG-0.250,mLcPDG+0.250,11,binLimpTLc);
5057  TH2F* spectrumLcMassByK0SSgnB = new TH2F(nameHistoSgnB.Data(),titleHistoSgnB.Data(),1000,mLcPDG-0.250,mLcPDG+0.250,11,binLimpTLc);
5058  TH2F* spectrumLcMassByK0SSgnNoQ = new TH2F(nameHistoSgnNoQ.Data(),titleHistoSgnNoQ.Data(),1000,mLcPDG-0.250,mLcPDG+0.250,11,binLimpTLc);
5059 
5060  TH2F* allspectrumLcMassByK0SSgnC = (TH2F*)spectrumLcMassByK0SSgnC->Clone();
5061  TH2F* allspectrumLcMassByK0SSgnB = (TH2F*) spectrumLcMassByK0SSgnB->Clone();
5062  TH2F* allspectrumLcMassByK0SSgnNoQ = (TH2F*) spectrumLcMassByK0SSgnNoQ->Clone();
5063  TH2F* pidBachspectrumLcMassByK0SSgnC = (TH2F*)spectrumLcMassByK0SSgnC->Clone();
5064  TH2F* pidBachspectrumLcMassByK0SSgnB = (TH2F*) spectrumLcMassByK0SSgnB->Clone();
5065  TH2F* pidBachspectrumLcMassByK0SSgnNoQ = (TH2F*) spectrumLcMassByK0SSgnNoQ->Clone();
5066 
5067  fOutputAll->Add(allspectrumLcMassByK0SSgnC);
5068  fOutputAll->Add(allspectrumLcMassByK0SSgnB);
5069  fOutputAll->Add(allspectrumLcMassByK0SSgnNoQ);
5070  fOutputPIDBach->Add(pidBachspectrumLcMassByK0SSgnC);
5071  fOutputPIDBach->Add(pidBachspectrumLcMassByK0SSgnB);
5072  fOutputPIDBach->Add(pidBachspectrumLcMassByK0SSgnNoQ);
5073 
5074  nameHistoSgnC="histptK0SSgnC";
5075  nameHistoSgnB="histptK0SSgnB";
5076  nameHistoSgnNoQ="histptK0SSgnNoQ";
5077  titleHistoSgnC="p_{T}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(K^{0}_{S}) [GeV/c]; Entries";
5078  titleHistoSgnB="p_{T}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(K^{0}_{S}) [GeV/c]; Entries";
5079  titleHistoSgnNoQ="p_{T}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(K^{0}_{S}) [GeV/c]; Entries";
5080  TH2F* ptK0SSgnC = new TH2F(nameHistoSgnC.Data(),titleHistoSgnC.Data(),11,binLimpTLc,41,binLimpTprong);
5081  TH2F* ptK0SSgnB = new TH2F(nameHistoSgnB.Data(),titleHistoSgnB.Data(),11,binLimpTLc,41,binLimpTprong);
5082  TH2F* ptK0SSgnNoQ = new TH2F(nameHistoSgnNoQ.Data(),titleHistoSgnNoQ.Data(),11,binLimpTLc,41,binLimpTprong);
5083 
5084  nameHistoSgnC="histptPSgnC";
5085  nameHistoSgnB="histptPSgnB";
5086  nameHistoSgnNoQ="histptPSgnNoQ";
5087  titleHistoSgnC="p_{T}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(p) [GeV/c]; Entries";
5088  titleHistoSgnB="p_{T}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(p) [GeV/c]; Entries";
5089  titleHistoSgnNoQ="p_{T}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(p) [GeV/c]; Entries";
5090  TH2F* ptPSgnC = new TH2F(nameHistoSgnC.Data(),titleHistoSgnC.Data(),11,binLimpTLc,41,binLimpTprong);
5091  TH2F* ptPSgnB = new TH2F(nameHistoSgnB.Data(),titleHistoSgnB.Data(),11,binLimpTLc,41,binLimpTprong);
5092  TH2F* ptPSgnNoQ = new TH2F(nameHistoSgnNoQ.Data(),titleHistoSgnNoQ.Data(),11,binLimpTLc,41,binLimpTprong);
5093 
5094  nameHistoSgnC="histptPipSgnC";
5095  nameHistoSgnB="histptPipSgnB";
5096  nameHistoSgnNoQ="histptPipSgnNoQ";
5097  titleHistoSgnC="p_{T}(#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{+}) [GeV/c]; Entries";
5098  titleHistoSgnB="p_{T}(#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{+}) [GeV/c]; Entries";
5099  titleHistoSgnNoQ="p_{T}(#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{+}) [GeV/c]; Entries";
5100  TH2F* ptPiPSgnC = new TH2F(nameHistoSgnC.Data(),titleHistoSgnC.Data(),11,binLimpTLc,41,binLimpTprong);
5101  TH2F* ptPiPSgnB = new TH2F(nameHistoSgnB.Data(),titleHistoSgnB.Data(),11,binLimpTLc,41,binLimpTprong);
5102  TH2F* ptPiPSgnNoQ = new TH2F(nameHistoSgnNoQ.Data(),titleHistoSgnB.Data(),11,binLimpTLc,41,binLimpTprong);
5103 
5104  nameHistoSgnC="histptPimSgnC";
5105  nameHistoSgnB="histptPimSgnB";
5106  nameHistoSgnNoQ="histptPimSgnNoQ";
5107  titleHistoSgnC="p_{T}(#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{-}) [GeV/c]; Entries";
5108  titleHistoSgnB="p_{T}(#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{-}) [GeV/c]; Entries";
5109  titleHistoSgnNoQ="p_{T}(#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{-}) [GeV/c]; Entries";
5110  TH2F* ptPiMSgnC = new TH2F(nameHistoSgnC.Data(),titleHistoSgnC.Data(),11,binLimpTLc,41,binLimpTprong);
5111  TH2F* ptPiMSgnB = new TH2F(nameHistoSgnB.Data(),titleHistoSgnB.Data(),11,binLimpTLc,41,binLimpTprong);
5112  TH2F* ptPiMSgnNoQ = new TH2F(nameHistoSgnNoQ.Data(),titleHistoSgnB.Data(),11,binLimpTLc,41,binLimpTprong);
5113 
5114  nameHistoSgnC="histD0K0SSgnC";
5115  nameHistoSgnB="histD0K0SSgnB";
5116  nameHistoSgnNoQ="histD0K0SSgnNoQ";
5117  titleHistoSgnC="d_{0}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(K^{0}_{S}) [#sigmas]; Entries";
5118  titleHistoSgnB="d_{0}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(K^{0}_{S}) [#sigmas]; Entries";
5119  titleHistoSgnNoQ="d_{0}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(K^{0}_{S}) [#sigmas]; Entries";
5120  TH2F* d0K0SSgnC = new TH2F(nameHistoSgnC.Data(),titleHistoSgnC.Data(),11,binLimpTLc,1000,-1.,1.);
5121  TH2F* d0K0SSgnB = new TH2F(nameHistoSgnB.Data(),titleHistoSgnB.Data(),11,binLimpTLc,1000,-1.,1.);
5122  TH2F* d0K0SSgnNoQ = new TH2F(nameHistoSgnNoQ.Data(),titleHistoSgnNoQ.Data(),11,binLimpTLc,1000,-1.,1.);
5123 
5124  nameHistoSgnC="histD0PSgnC";
5125  nameHistoSgnB="histD0PSgnB";
5126  nameHistoSgnNoQ="histD0PSgnNoQ";
5127  titleHistoSgnC="d_{0}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(p) [cm]; Entries";
5128  titleHistoSgnB="d_{0}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(p) [cm]; Entries";
5129  titleHistoSgnNoQ="d_{0}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(p) [cm]; Entries";
5130  TH2F* d0PSgnC = new TH2F(nameHistoSgnC.Data(),titleHistoSgnC.Data(),11,binLimpTLc,1000,-1.,1.);
5131  TH2F* d0PSgnB = new TH2F(nameHistoSgnB.Data(),titleHistoSgnB.Data(),11,binLimpTLc,1000,-1.,1.);
5132  TH2F* d0PSgnNoQ = new TH2F(nameHistoSgnNoQ.Data(),titleHistoSgnNoQ.Data(),11,binLimpTLc,1000,-1.,1.);
5133 
5134  nameHistoSgnC="histCosPAK0SSgnC";
5135  nameHistoSgnB="histCosPAK0SSgnB";
5136  nameHistoSgnNoQ="histCosPAK0SSgnNoQ";
5137  titleHistoSgnC="K^{0}_{S} cosine of pointing angle wrt primary vertex vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
5138  titleHistoSgnB="K^{0}_{S} cosine of pointing angle wrt primary vertex vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
5139  titleHistoSgnNoQ="K^{0}_{S} cosine of pointing angle wrt primary vertex vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
5140  TH2F *cosPAK0SSgnC = new TH2F(nameHistoSgnC.Data(),titleHistoSgnC.Data(),41,binLimpTprong,100,0.99,1.);
5141  TH2F *cosPAK0SSgnB = new TH2F(nameHistoSgnB.Data(),titleHistoSgnB.Data(),41,binLimpTprong,100,0.99,1.);
5142  TH2F *cosPAK0SSgnNoQ = new TH2F(nameHistoSgnNoQ.Data(),titleHistoSgnNoQ.Data(),41,binLimpTprong,100,0.99,1.);
5143 
5144  nameHistoSgnC="histCosThetaProtonCMSSgnC";
5145  nameHistoSgnB="histCosThetaProtonCMSSgnB";
5146  nameHistoSgnNoQ="histCosThetaProtonCMSSgnNoQ";
5147  titleHistoSgnC="cosien of proton emission angle in Lc rest frame; p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
5148  titleHistoSgnB="cosien of proton emission angle in Lc rest frame; p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
5149  titleHistoSgnNoQ="cosien of proton emission angle in Lc rest frame; p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
5150  TH2F *cosThePrSgnC = new TH2F(nameHistoSgnC.Data(),titleHistoSgnC.Data(),41,binLimpTprong,100,-1.,1.);
5151  TH2F *cosThePrSgnB = new TH2F(nameHistoSgnB.Data(),titleHistoSgnB.Data(),41,binLimpTprong,100,-1.,1.);
5152  TH2F *cosThePrSgnNoQ = new TH2F(nameHistoSgnNoQ.Data(),titleHistoSgnNoQ.Data(),41,binLimpTprong,100,-1.,1.);
5153 
5154  nameHistoSgnC="histResignedD0SgnC";
5155  nameHistoSgnB="histResignedD0SgnB";
5156  nameHistoSgnNoQ="histResignedD0SgnNoQ";
5157  titleHistoSgnC="Proton d0 with different sign convention; p_{T}(#Lambda_{c}) [GeV/c]; d0 [cm]; Entries";
5158  titleHistoSgnB="Proton d0 with different sign convention; p_{T}(#Lambda_{c}) [GeV/c]; d0 [cm]; Entries";
5159  titleHistoSgnNoQ="Proton d0 with different sign convention; p_{T}(#Lambda_{c}) [GeV/c]; d0 [cm]; Entries";
5160  TH2F *resignedD0SgnC = new TH2F(nameHistoSgnC.Data(),titleHistoSgnC.Data(),41,binLimpTprong,100,-0.1,0.1);
5161  TH2F *resignedD0SgnB = new TH2F(nameHistoSgnB.Data(),titleHistoSgnB.Data(),41,binLimpTprong,100,-0.1,0.1);
5162  TH2F *resignedD0SgnNoQ = new TH2F(nameHistoSgnNoQ.Data(),titleHistoSgnNoQ.Data(),41,binLimpTprong,100,-0.1,0.1);
5163 
5164  TH2F* allptK0SSgnC = (TH2F*)ptK0SSgnC->Clone();
5165  TH2F* allptK0SSgnB = (TH2F*)ptK0SSgnB->Clone();
5166  TH2F* allptK0SSgnNoQ = (TH2F*)ptK0SSgnNoQ->Clone();
5167  TH2F* allptPSgnC = (TH2F*)ptPSgnC->Clone();
5168  TH2F* allptPSgnB = (TH2F*)ptPSgnB->Clone();
5169  TH2F* allptPSgnNoQ = (TH2F*)ptPSgnNoQ->Clone();
5170  TH2F* allptPiPSgnC = (TH2F*)ptPiPSgnC->Clone();
5171  TH2F* allptPiPSgnB = (TH2F*)ptPiPSgnB->Clone();
5172  TH2F* allptPiPSgnNoQ = (TH2F*)ptPiPSgnNoQ->Clone();
5173  TH2F* allptPiMSgnC = (TH2F*)ptPiMSgnC->Clone();
5174  TH2F* allptPiMSgnB = (TH2F*)ptPiMSgnB->Clone();
5175  TH2F* allptPiMSgnNoQ = (TH2F*)ptPiMSgnNoQ->Clone();
5176  TH2F* alld0K0SSgnC = (TH2F*)d0K0SSgnC->Clone();
5177  TH2F* alld0K0SSgnB = (TH2F*)d0K0SSgnB->Clone();
5178  TH2F* alld0K0SSgnNoQ = (TH2F*)d0K0SSgnNoQ->Clone();
5179  TH2F* alld0PSgnC = (TH2F*)d0PSgnC->Clone();
5180  TH2F* alld0PSgnB = (TH2F*)d0PSgnB->Clone();
5181  TH2F* alld0PSgnNoQ = (TH2F*)d0PSgnNoQ->Clone();
5182  TH2F* allcosPAK0SSgnC = (TH2F*)cosPAK0SSgnC->Clone();
5183  TH2F* allcosPAK0SSgnB = (TH2F*)cosPAK0SSgnB->Clone();
5184  TH2F* allcosPAK0SSgnNoQ = (TH2F*)cosPAK0SSgnNoQ->Clone();
5185  TH2F* allcosThePrSgnC = (TH2F*)cosThePrSgnC->Clone();
5186  TH2F* allcosThePrSgnB = (TH2F*)cosThePrSgnB->Clone();
5187  TH2F* allcosThePrSgnNoQ = (TH2F*)cosThePrSgnNoQ->Clone();
5188  TH2F* allresignedD0SgnC = (TH2F*)resignedD0SgnC->Clone();
5189  TH2F* allresignedD0SgnB = (TH2F*)resignedD0SgnB->Clone();
5190  TH2F* allresignedD0SgnNoQ = (TH2F*)resignedD0SgnNoQ->Clone();
5191 
5192  TH2F* pidptK0SSgnC = (TH2F*)ptK0SSgnC->Clone();
5193  TH2F* pidptK0SSgnB = (TH2F*)ptK0SSgnB->Clone();
5194  TH2F* pidptK0SSgnNoQ = (TH2F*)ptK0SSgnNoQ->Clone();
5195  TH2F* pidptPSgnC = (TH2F*)ptPSgnC->Clone();
5196  TH2F* pidptPSgnB = (TH2F*)ptPSgnB->Clone();
5197  TH2F* pidptPSgnNoQ = (TH2F*)ptPSgnNoQ->Clone();
5198  TH2F* pidptPiPSgnC = (TH2F*)ptPiPSgnC->Clone();
5199  TH2F* pidptPiPSgnB = (TH2F*)ptPiPSgnB->Clone();
5200  TH2F* pidptPiPSgnNoQ = (TH2F*)ptPiPSgnNoQ->Clone();
5201  TH2F* pidptPiMSgnC = (TH2F*)ptPiMSgnC->Clone();
5202  TH2F* pidptPiMSgnB = (TH2F*)ptPiMSgnB->Clone();
5203  TH2F* pidptPiMSgnNoQ = (TH2F*)ptPiMSgnNoQ->Clone();
5204  TH2F* pidd0K0SSgnC = (TH2F*)d0K0SSgnC->Clone();
5205  TH2F* pidd0K0SSgnB = (TH2F*)d0K0SSgnB->Clone();
5206  TH2F* pidd0K0SSgnNoQ = (TH2F*)d0K0SSgnNoQ->Clone();
5207  TH2F* pidd0PSgnC = (TH2F*)d0PSgnC->Clone();
5208  TH2F* pidd0PSgnB = (TH2F*)d0PSgnB->Clone();
5209  TH2F* pidd0PSgnNoQ = (TH2F*)d0PSgnNoQ->Clone();
5210  TH2F* pidcosPAK0SSgnC = (TH2F*)cosPAK0SSgnC->Clone();
5211  TH2F* pidcosPAK0SSgnB = (TH2F*)cosPAK0SSgnB->Clone();
5212  TH2F* pidcosPAK0SSgnNoQ = (TH2F*)cosPAK0SSgnNoQ->Clone();
5213  TH2F* pidcosThePrSgnC = (TH2F*)cosThePrSgnC->Clone();
5214  TH2F* pidcosThePrSgnB = (TH2F*)cosThePrSgnB->Clone();
5215  TH2F* pidcosThePrSgnNoQ = (TH2F*)cosThePrSgnNoQ->Clone();
5216  TH2F* pidresignedD0SgnC = (TH2F*)resignedD0SgnC->Clone();
5217  TH2F* pidresignedD0SgnB = (TH2F*)resignedD0SgnB->Clone();
5218  TH2F* pidresignedD0SgnNoQ = (TH2F*)resignedD0SgnNoQ->Clone();
5219 
5220  fOutputAll->Add(allptK0SSgnC);
5221  fOutputAll->Add(allptK0SSgnB);
5222  fOutputAll->Add(allptK0SSgnNoQ);
5223  fOutputAll->Add(allptPSgnC);
5224  fOutputAll->Add(allptPSgnB);
5225  fOutputAll->Add(allptPSgnNoQ);
5226  fOutputAll->Add(allptPiPSgnC);
5227  fOutputAll->Add(allptPiPSgnB);
5228  fOutputAll->Add(allptPiPSgnNoQ);
5229  fOutputAll->Add(allptPiMSgnC);
5230  fOutputAll->Add(allptPiMSgnB);
5231  fOutputAll->Add(allptPiMSgnNoQ);
5232  fOutputAll->Add(alld0K0SSgnC);
5233  fOutputAll->Add(alld0K0SSgnB);
5234  fOutputAll->Add(alld0K0SSgnNoQ);
5235  fOutputAll->Add(alld0PSgnC);
5236  fOutputAll->Add(alld0PSgnB);
5237  fOutputAll->Add(alld0PSgnNoQ);
5238  fOutputAll->Add(allcosPAK0SSgnC);
5239  fOutputAll->Add(allcosPAK0SSgnB);
5240  fOutputAll->Add(allcosPAK0SSgnNoQ);
5241  fOutputAll->Add(allcosThePrSgnC);
5242