AliPhysics  41af4b0 (41af4b0)
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  Bool_t isMCparticleInFiducialAcceptance = kTRUE;
3603  if (fUseMCInfo) {
3604  if (isLc) {
3605  Int_t pdgCand0 = 4122;
3606  Int_t pdgDgLctoV0bachelor0[2]={2212,310};
3607  Int_t pdgDgV0toDaughters0[2]={211,211};
3608  Int_t mcLabelLc2pK0S = part->MatchToMC(pdgCand0,pdgDgLctoV0bachelor0[1],pdgDgLctoV0bachelor0,pdgDgV0toDaughters0,mcArray,kTRUE);
3609  AliAODMCParticle *lambdaCpartMC = (AliAODMCParticle*)mcArray->At(mcLabelLc2pK0S);
3610  if (lambdaCpartMC) {
3611  ptCandByMC = lambdaCpartMC->Pt();
3612  yCandByMC = lambdaCpartMC->Y();
3613  }
3614  }
3615 
3616  Int_t pdgCand = 4122;
3617  Int_t pdgDgLctoV0bachelor[2]={211,3122};
3618  Int_t pdgDgV0toDaughters[2]={2212,211};
3619  mcLabel = part->MatchToMC(pdgCand,pdgDgLctoV0bachelor[1],pdgDgLctoV0bachelor,pdgDgV0toDaughters,mcArray,kTRUE);
3620  if (mcLabel!=-1) {
3621  if (bachelor->Charge()<0) isLc2LBarpi=1;
3622  if (bachelor->Charge()>0) isLc2Lpi=1;
3623  AliAODMCParticle *lambdaCpartMC = (AliAODMCParticle*)mcArray->At(mcLabel);
3624  if (lambdaCpartMC) {
3625  ptCandByMC = lambdaCpartMC->Pt();
3626  yCandByMC = lambdaCpartMC->Y();
3627  }
3628  }
3629 
3630  Int_t pdgCand2 = 411; // D+ -> pi+ K0S
3631  Int_t pdgCand3 = 431; // Ds+ -> K+ K0S
3632  Int_t pdgDgCand2[2]={211,310};
3633  Int_t pdgDgCand3[2]={321,310};
3634  pdgDgV0toDaughters[0]=211;
3635  pdgDgV0toDaughters[1]=211;
3636  mcLabel2 = part->MatchToMC(pdgCand2,pdgDgCand2[1],pdgDgCand2,pdgDgV0toDaughters,mcArray,kTRUE);
3637  mcLabel3 = part->MatchToMC(pdgCand3,pdgDgCand3[1],pdgDgCand3,pdgDgV0toDaughters,mcArray,kTRUE);
3638  if (mcLabel2!=-1) {
3639  isDp2K0Spi=1;
3640  AliAODMCParticle *lambdaCpartMC = (AliAODMCParticle*)mcArray->At(mcLabel2);
3641  if (lambdaCpartMC) {
3642  ptCandByMC = lambdaCpartMC->Pt();
3643  yCandByMC = lambdaCpartMC->Y();
3644  }
3645  }
3646  if (mcLabel3!=-1) {
3647  isDs2K0SK=1;
3648  AliAODMCParticle *lambdaCpartMC = (AliAODMCParticle*)mcArray->At(mcLabel3);
3649  if (lambdaCpartMC) {
3650  ptCandByMC = lambdaCpartMC->Pt();
3651  yCandByMC = lambdaCpartMC->Y();
3652  }
3653  }
3654 
3655  Int_t pdgCand4 = 313; // K*(892)+ -> pi+ K0S
3656  Int_t pdgCand5 = 325; // K*(1430)+ -> pi+ K0S
3657  Int_t pdgDgCand4[2]={211,310};
3658  Int_t pdgDgCand5[2]={211,310};
3659  pdgDgV0toDaughters[0]=211;
3660  pdgDgV0toDaughters[1]=211;
3661  mcLabel4 = part->MatchToMC(pdgCand4,pdgDgCand4[1],pdgDgCand4,pdgDgV0toDaughters,mcArray,kTRUE);
3662  mcLabel5 = part->MatchToMC(pdgCand5,pdgDgCand5[1],pdgDgCand5,pdgDgV0toDaughters,mcArray,kTRUE);
3663  if (mcLabel4!=-1) {
3664  isKstar12K0Spi=1;
3665  AliAODMCParticle *lambdaCpartMC = (AliAODMCParticle*)mcArray->At(mcLabel4);
3666  if (lambdaCpartMC) {
3667  ptCandByMC = lambdaCpartMC->Pt();
3668  yCandByMC = lambdaCpartMC->Y();
3669  }
3670  }
3671  if (mcLabel5!=-1) {
3672  isKstar22K0Spi=1;
3673  AliAODMCParticle *lambdaCpartMC = (AliAODMCParticle*)mcArray->At(mcLabel5);
3674  if (lambdaCpartMC) {
3675  ptCandByMC = lambdaCpartMC->Pt();
3676  yCandByMC = lambdaCpartMC->Y();
3677  }
3678  }
3679  if (isLc || isLc2LBarpi || isLc2Lpi || isDp2K0Spi || isDs2K0SK || isKstar12K0Spi || isKstar22K0Spi) {
3680  isMCparticleInFiducialAcceptance = cutsAnal->IsInFiducialAcceptance(ptCandByMC,yCandByMC);
3681  }
3682  }
3683 
3684  Int_t isLcByMC = isLc+isLc2LBarpi*2+isLc2Lpi*4+isDp2K0Spi*8+isDs2K0SK*16+isKstar12K0Spi*32+isKstar22K0Spi*64;
3685 
3686  Int_t isK0S = 0;
3687  Int_t isLambda = 0;
3688  Int_t isLambdaBar = 0;
3689  Int_t isGamma = 0;
3690  if (fUseMCInfo) {
3691  Int_t pdgDg2prong[2] = {211, 211};
3692  Int_t labelK0S = v0part->MatchToMC(310,mcArray,2,pdgDg2prong);
3693  if (labelK0S>=0) isK0S = 1;
3694 
3695  pdgDg2prong[0] = 211;
3696  pdgDg2prong[1] = 2212;
3697  Int_t lambdaLabel = v0part->MatchToMC(3122,mcArray,2,pdgDg2prong);
3698  if (lambdaLabel>=0) {
3699  AliAODMCParticle *lambdaTrack = (AliAODMCParticle*)mcArray->At(lambdaLabel);
3700  if (lambdaTrack->GetPdgCode()==3122) isLambda = 1;
3701  else if (lambdaTrack->GetPdgCode()==-3122) isLambdaBar = 1;
3702  }
3703 
3704  pdgDg2prong[0] = 11;
3705  pdgDg2prong[1] = 11;
3706  Int_t gammaLabel = v0part->MatchToMC(22,mcArray,2,pdgDg2prong);
3707  if (gammaLabel>=0) {
3708  AliAODMCParticle *gammaTrack = (AliAODMCParticle*)mcArray->At(gammaLabel);
3709  if (gammaTrack->GetPdgCode()==22) isGamma = 1;
3710  }
3711  }
3712 
3713  Int_t isV0ByMC = isK0S+isLambdaBar*2+isLambda*4+isGamma*8;
3714 
3715  Int_t isBachelorSelected = (bachelor->TestFilterMask(BIT(4)))*1 + (!(bachelor->TestFilterMask(BIT(4))))*2;
3716  isBachelorSelected += (bachelor->GetLabel()<0)*4 + (bachelor->GetLabel()>=0)*8;
3717  if ( ( !(bachelor->HasPointOnITSLayer(0)) && !(bachelor->HasPointOnITSLayer(1)) ) )
3718  isBachelorSelected += 16;
3719  else {
3720  if ( bachelor->HasPointOnITSLayer(0) && !(bachelor->HasPointOnITSLayer(1)) )
3721  isBachelorSelected += 32;
3722  else if ( !(bachelor->HasPointOnITSLayer(0)) && bachelor->HasPointOnITSLayer(1) )
3723  isBachelorSelected += 64;
3724  else
3725  isBachelorSelected += 128;
3726  }
3727 
3728  AliAODTrack *v0pos = (AliAODTrack*)part->Getv0PositiveTrack();
3729  AliAODTrack *v0neg = (AliAODTrack*)part->Getv0NegativeTrack();
3730 
3731  Int_t areV0daughtersSelected = (v0pos->TestFilterMask(BIT(4)))*1 + (!(v0pos->TestFilterMask(BIT(4))))*2;
3732  areV0daughtersSelected += (v0pos->GetLabel()<0)*4 + (v0pos->GetLabel()>=0)*8;
3733  areV0daughtersSelected += (v0pos->HasPointOnITSLayer(0))*16;
3734  areV0daughtersSelected += (v0pos->HasPointOnITSLayer(1))*32;
3735  areV0daughtersSelected += (v0pos->HasPointOnITSLayer(2))*64;
3736  areV0daughtersSelected += (v0pos->HasPointOnITSLayer(3))*128;
3737  areV0daughtersSelected += (v0pos->HasPointOnITSLayer(4))*256;
3738  areV0daughtersSelected += (v0pos->HasPointOnITSLayer(5))*512;
3739 
3740  areV0daughtersSelected += (v0neg->TestFilterMask(BIT(4)))*1024 + (!(v0neg->TestFilterMask(BIT(4))))*2048;
3741  areV0daughtersSelected += (v0neg->GetLabel()<0)*4096 + (v0neg->GetLabel()>=0)*8192;
3742  areV0daughtersSelected += (v0neg->HasPointOnITSLayer(0))*16384;
3743  areV0daughtersSelected += (v0neg->HasPointOnITSLayer(1))*32768;
3744  areV0daughtersSelected += (v0neg->HasPointOnITSLayer(2))*65536;
3745  areV0daughtersSelected += (v0neg->HasPointOnITSLayer(3))*131072;
3746  areV0daughtersSelected += (v0neg->HasPointOnITSLayer(4))*262144;
3747  areV0daughtersSelected += (v0neg->HasPointOnITSLayer(5))*524288;
3748 
3749  Double_t nSigmaITSpr=-999.;
3750  cutsAnal->GetPidHF()->GetnSigmaITS(bachelor,4,nSigmaITSpr);
3751  Double_t nSigmaTPCpr=-999.;
3752  cutsAnal->GetPidHF()->GetnSigmaTPC(bachelor,4,nSigmaTPCpr);
3753  Double_t nSigmaTOFpr=-999.;
3754  cutsAnal->GetPidHF()->GetnSigmaTOF(bachelor,4,nSigmaTOFpr);
3755 
3756  Double_t nSigmaITSpi=-999.;
3757  cutsAnal->GetPidHF()->GetnSigmaITS(bachelor,2,nSigmaITSpi);
3758  Double_t nSigmaTPCpi=-999.;
3759  cutsAnal->GetPidHF()->GetnSigmaTPC(bachelor,2,nSigmaTPCpi);
3760  Double_t nSigmaTOFpi=-999.;
3761  cutsAnal->GetPidHF()->GetnSigmaTOF(bachelor,2,nSigmaTOFpi);
3762 
3763  Double_t nSigmaITSka=-999.;
3764  cutsAnal->GetPidHF()->GetnSigmaITS(bachelor,3,nSigmaITSka);
3765  Double_t nSigmaTPCka=-999.;
3766  cutsAnal->GetPidHF()->GetnSigmaTPC(bachelor,3,nSigmaTPCka);
3767  Double_t nSigmaTOFka=-999.;
3768  cutsAnal->GetPidHF()->GetnSigmaTOF(bachelor,3,nSigmaTOFka);
3769 
3770  Int_t flagToCheckCandidate = 1*(TMath::Abs(invmassK0S-mk0sPDG)<=0.050);
3771  flagToCheckCandidate+=2*((TMath::Abs(invmassLambdaBar-mLPDG)<=0.050) && (bachelor->Charge()<0));
3772  flagToCheckCandidate+=4*((TMath::Abs(invmassLambda-mLPDG)<=0.050) && (bachelor->Charge()>0));
3773  flagToCheckCandidate+=8*((TMath::Abs(invmassLambdaBar-mLPDG)<=0.050) && (bachelor->Charge()>0));
3774  flagToCheckCandidate+=16*((TMath::Abs(invmassLambda-mLPDG)<=0.050) && (bachelor->Charge()<0));
3775 
3776  Int_t iVariable=0;
3777 
3778  fCandidateVariables[iVariable++] = 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[iVariable++] = fUseMCInfo+isV0ByMC; // 0: real data; 1: bkg; 2: K0S->pi+pi; 3: LambdaBar->pbar+pi+; 5: Lambda->p+pi-
3780 
3781  fCandidateVariables[iVariable++] = isBachelorSelected;
3782  fCandidateVariables[iVariable++] = areV0daughtersSelected;
3783  fCandidateVariables[iVariable++] = flagToCheckCandidate;
3784  fCandidateVariables[iVariable++] = invmassLc;
3785  fCandidateVariables[iVariable++] = invmassLc2Lpi;
3786  fCandidateVariables[iVariable++] = part->InvMass2Prongs(0,1,211,310); // D+ -> pi+ K0S
3787  fCandidateVariables[iVariable++] = part->InvMass2Prongs(0,1,321,310); // D+S -> K+ K0S
3788  fCandidateVariables[iVariable++] = invmassK0S;
3789  fCandidateVariables[iVariable++] = invmassLambda;
3790  fCandidateVariables[iVariable++] = invmassLambdaBar;
3791  fCandidateVariables[iVariable++] = v0part->InvMass2Prongs(0,1,11,11);
3792  fCandidateVariables[iVariable++] = part->Getd0Prong(0);
3793  fCandidateVariables[iVariable++] = part->Getd0Prong(1);
3794  fCandidateVariables[iVariable++] = part->CosV0PointingAngle();
3795  fCandidateVariables[iVariable++] = part->Pt();
3796  fCandidateVariables[iVariable++] = v0part->Pt();
3797  fCandidateVariables[iVariable++] = bachelor->P();
3798  fCandidateVariables[iVariable++] = bachelor->Pt();
3799  fCandidateVariables[iVariable++] = v0pos->Pt();
3800  fCandidateVariables[iVariable++] = v0neg->Pt();
3801  fCandidateVariables[iVariable++] = bachelor->Charge();
3802  fCandidateVariables[iVariable++] = v0part->QtProng();
3803  fCandidateVariables[iVariable++] = v0part->Alpha();
3804  fCandidateVariables[iVariable++] = nSigmaTPCpr;
3805  fCandidateVariables[iVariable++] = nSigmaTOFpr;
3806 
3807  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
3808  AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler();
3809 
3810  AliPIDResponse *pidResponse = (AliPIDResponse*)inputHandler->GetPIDResponse();
3811 
3812  AliPIDCombined *objectPIDCombined=new AliPIDCombined;
3813  objectPIDCombined->SetDefaultTPCPriors();
3814  objectPIDCombined->SetDetectorMask(AliPIDResponse::kDetTPC+AliPIDResponse::kDetTOF);
3815 
3816  Double_t probTPCTOF[AliPID::kSPECIES]={-1.};
3817  UInt_t detUsed = objectPIDCombined->ComputeProbabilities(bachelor, pidResponse, probTPCTOF);
3818 
3819  Double_t probProton = -1.;
3820  // Double_t probPion = -1.;
3821  // Double_t probKaon = -1.;
3822  if (detUsed == (UInt_t)objectPIDCombined->GetDetectorMask() ) {
3823  AliDebug(2, Form("We have found the detector mask for TOF + TPC: probProton will be set to %f", probTPCTOF[AliPID::kProton]));
3824  probProton = probTPCTOF[AliPID::kProton];
3825  // probPion = probTPCTOF[AliPID::kPion];
3826  // probKaon = probTPCTOF[AliPID::kKaon];
3827  }
3828  else { // if you don't have both TOF and TPC, try only TPC
3829  objectPIDCombined->SetDetectorMask(AliPIDResponse::kDetTPC);
3830  AliDebug(2, "We did not find the detector mask for TOF + TPC, let's see only TPC");
3831  detUsed = objectPIDCombined->ComputeProbabilities(bachelor, pidResponse, probTPCTOF);
3832  AliDebug(2,Form(" detUsed (TPC case) = %d", detUsed));
3833  if (detUsed == (UInt_t)objectPIDCombined->GetDetectorMask()) {
3834  probProton = probTPCTOF[AliPID::kProton];
3835  // probPion = probTPCTOF[AliPID::kPion];
3836  // probKaon = probTPCTOF[AliPID::kKaon];
3837  AliDebug(2, Form("TPC only worked: probProton will be set to %f", probTPCTOF[AliPID::kProton]));
3838  }
3839  else {
3840  AliDebug(2, "Only TPC did not work...");
3841  }
3842  // resetting mask to ask for both TPC+TOF
3843  objectPIDCombined->SetDetectorMask(AliPIDResponse::kDetTPC+AliPIDResponse::kDetTOF);
3844  }
3845  AliDebug(2, Form("probProton = %f", probProton));
3846 
3847  // now we get the TPC and TOF single PID probabilities (only for Proton, or the tree will explode :) )
3848  Double_t probProtonTPC = -1.;
3849  Double_t probProtonTOF = -1.;
3850  Double_t pidTPC[AliPID::kSPECIES]={-1.};
3851  Double_t pidTOF[AliPID::kSPECIES]={-1.};
3852  Int_t respTPC = pidResponse->ComputePIDProbability(AliPIDResponse::kDetTPC, bachelor, AliPID::kSPECIES, pidTPC);
3853  Int_t respTOF = pidResponse->ComputePIDProbability(AliPIDResponse::kDetTOF, bachelor, AliPID::kSPECIES, pidTOF);
3854  if (respTPC == AliPIDResponse::kDetPidOk) probProtonTPC = pidTPC[AliPID::kProton];
3855  if (respTOF == AliPIDResponse::kDetPidOk) probProtonTOF = pidTOF[AliPID::kProton];
3856 
3857  fCandidateVariables[iVariable++] = probProton;
3858  fCandidateVariables[iVariable++] = probProtonTPC;
3859  fCandidateVariables[iVariable++] = probProtonTOF;
3860 
3861  if (fUseMCInfo) {
3862  fCandidateVariables[iVariable++] = isMCparticleInFiducialAcceptance;
3863 
3864  if (bachelor->GetLabel()!=-1) {
3865  AliAODMCParticle *partBachelor = dynamic_cast<AliAODMCParticle*>(mcArray->At(TMath::Abs(bachelor->GetLabel())));
3866  if (partBachelor) fCandidateVariables[iVariable++] = partBachelor->GetPdgCode();
3867  else fCandidateVariables[iVariable++] = -1;
3868  }
3869  else fCandidateVariables[iVariable++] = -1;
3870 
3871  if (bachelor->GetLabel()!=-1 &&
3872  v0pos->GetLabel()!=-1 &&
3873  v0neg->GetLabel()!=-1) {
3874  const Int_t ndg=3;
3875  Int_t dgLabels[ndg]={TMath::Abs(bachelor->GetLabel()),
3876  TMath::Abs(v0pos->GetLabel()),
3877  TMath::Abs(v0neg->GetLabel())};
3878  Int_t ndgCk=0;
3879  Int_t *pdgDg=0;
3880  Int_t absLabelMother=-1;
3881  Int_t nDauCand=-1;
3882  fCandidateVariables[iVariable++] = SearchForCommonMother(mcArray,
3883  dgLabels,ndg,ndgCk,pdgDg,absLabelMother,nDauCand);
3884  }
3885  else fCandidateVariables[iVariable++] = -1;
3886 
3887  if (v0pos->GetLabel()!=-1) {
3888  AliAODMCParticle *part1 = dynamic_cast<AliAODMCParticle*>(mcArray->At(TMath::Abs(v0pos->GetLabel())));
3889  if (part1) fCandidateVariables[iVariable++] = part1->GetPdgCode();
3890  else fCandidateVariables[iVariable++] = -1;
3891  }
3892  else fCandidateVariables[iVariable++] = -1;
3893 
3894  if (v0neg->GetLabel()!=-1) {
3895  AliAODMCParticle *part2 = dynamic_cast<AliAODMCParticle*>(mcArray->At(TMath::Abs(v0neg->GetLabel())));
3896  if (part2) fCandidateVariables[iVariable++] = part2->GetPdgCode();
3897  else fCandidateVariables[iVariable++] = -1;
3898  }
3899  else fCandidateVariables[iVariable++] = -1;
3900 
3901  if (v0pos->GetLabel()!=-1 &&
3902  v0neg->GetLabel()!=-1) {
3903  const Int_t ndg=2;
3904  Int_t dgLabels[ndg]={TMath::Abs(v0pos->GetLabel()),
3905  TMath::Abs(v0neg->GetLabel())};
3906  Int_t ndgCk=0;
3907  Int_t *pdgDg=0;
3908  Int_t absLabelMother=-1;
3909  Int_t nDauCand=-1;
3910  fCandidateVariables[iVariable++] = SearchForCommonMother(mcArray,
3911  dgLabels,ndg,ndgCk,pdgDg,absLabelMother,nDauCand);
3912  }
3913  else fCandidateVariables[iVariable++] = -1;
3914 
3915  fCandidateVariables[iVariable++] = checkLcOrigin;
3916 
3917  }
3918 
3919 
3920  if (fAdditionalChecks) { // ------------------------------siamo qui!
3921  fCandidateVariables[iVariable++] = part->P();
3922  fCandidateVariables[iVariable++] = v0part->P();
3923  fCandidateVariables[iVariable++] = v0pos->P();
3924  fCandidateVariables[iVariable++] = v0neg->P();
3925  fCandidateVariables[iVariable++] = nSigmaTPCpi;
3926  fCandidateVariables[iVariable++] = nSigmaTPCka;
3927  fCandidateVariables[iVariable++] = nSigmaTOFpi;
3928  fCandidateVariables[iVariable++] = nSigmaTOFka;
3929  fCandidateVariables[iVariable++] = pidResponse->GetTOFResponse().GetStartTimeMask(bachelor->P());
3930 
3931  fCandidateVariables[iVariable++] = part->GetDCA();
3932  fCandidateVariables[iVariable++] = v0part->GetDCA();
3933  fCandidateVariables[iVariable++] = v0part->Getd0Prong(0);
3934  fCandidateVariables[iVariable++] = v0part->Getd0Prong(1);
3935  fCandidateVariables[iVariable++] = part->CosPointingAngle();
3936  fCandidateVariables[iVariable++] = v0part->RadiusSecVtx();
3937  fCandidateVariables[iVariable++] = nSigmaITSpr;
3938  fCandidateVariables[iVariable++] = nSigmaITSpi;
3939  fCandidateVariables[iVariable++] = nSigmaITSka;
3940  fCandidateVariables[iVariable++] = part->Y(4122);
3941  fCandidateVariables[iVariable++] = bachelor->Eta();
3942  fCandidateVariables[iVariable++] = v0pos->Eta();
3943  fCandidateVariables[iVariable++] = v0neg->Eta();
3944 
3945  fCandidateVariables[iVariable++] = part->DecayLength();
3946  fCandidateVariables[iVariable++] = part->DecayLengthV0();
3947  fCandidateVariables[iVariable++] = part->CosPointingAngleXY();
3948  fCandidateVariables[iVariable++] = part->CosV0PointingAngleXY();
3949  fCandidateVariables[iVariable++] = part->DecayLengthXY();
3950  fCandidateVariables[iVariable++] = part->DecayLengthXYV0();
3951  fCandidateVariables[iVariable++] = part->NormalizedDecayLength();
3952  fCandidateVariables[iVariable++] = part->NormalizedV0DecayLength();
3953  fCandidateVariables[iVariable++] = part->NormalizedDecayLengthXY();
3954  fCandidateVariables[iVariable++] = part->NormalizedV0DecayLengthXY();
3955 
3956  Double_t xVtxLc=0, yVtxLc=0, zVtxLc=0;
3957  Double_t pxVtxBachelor=0, pyVtxBachelor=0, pzVtxBachelor=0;
3958  Double_t dcaForLc = PropagateToDCA(v0part,bachelor,fBzkG, xVtxLc, yVtxLc, zVtxLc, pxVtxBachelor, pyVtxBachelor, pzVtxBachelor);
3959  fCandidateVariables[iVariable++] = dcaForLc;
3960 
3961  fCandidateVariables[iVariable++] = part->CosThetaStar(0,4122,2212,310);
3962  fCandidateVariables[iVariable++] = part->CosThetaStar(1,4122,2212,310);
3963  fCandidateVariables[iVariable++] = v0part->Eta();
3964  fCandidateVariables[iVariable++] = v0part->Y(310);
3965  fCandidateVariables[iVariable++] = part->InvMass2Prongs(0,1,211,310); // Kstar( 892)+ -> pi+K0S
3966  fCandidateVariables[iVariable++] = part->InvMass2Prongs(0,1,321,310); // Kstar(1430)+ -> pi+K0S
3967 
3968  fCandidateVariables[iVariable++] = part->GetSecVtxX();
3969  fCandidateVariables[iVariable++] = part->GetSecVtxY();
3970  fCandidateVariables[iVariable++] = part->GetSecVtxZ();
3971 
3972  fCandidateVariables[iVariable++] = xVtxLc;
3973  fCandidateVariables[iVariable++] = yVtxLc;
3974  fCandidateVariables[iVariable++] = zVtxLc;
3975 
3976  fCandidateVariables[iVariable++] = bachelor->Px();
3977  fCandidateVariables[iVariable++] = bachelor->Py();
3978  fCandidateVariables[iVariable++] = pxVtxBachelor;
3979  fCandidateVariables[iVariable++] = pyVtxBachelor;
3980  fCandidateVariables[iVariable++] = pzVtxBachelor;
3981  fCandidateVariables[iVariable++] = v0part->Px();
3982  fCandidateVariables[iVariable++] = v0part->Py();
3983  fCandidateVariables[iVariable++] = v0part->Pz();
3984  fCandidateVariables[iVariable++] = fVtx1->GetX();
3985  fCandidateVariables[iVariable++] = fVtx1->GetY();
3986  fCandidateVariables[iVariable++] = fVtx1->GetZ();
3987 
3988  if (fUseMCInfo) {
3989  Double_t xLcMC=0,yLcMC=0,zLcMC=0;
3990  if (isLc) {
3991  Int_t pdgCand0 = 4122;
3992  Int_t pdgDgLctoV0bachelor0[2]={2212,310};
3993  Int_t pdgDgV0toDaughters0[2]={211,211};
3994  Int_t mcLabel0 = part->MatchToMC(pdgCand0,pdgDgLctoV0bachelor0[1],pdgDgLctoV0bachelor0,pdgDgV0toDaughters0,mcArray,kTRUE);
3995  AliAODMCParticle *partLc = dynamic_cast<AliAODMCParticle*>(mcArray->At(mcLabel0));
3996  if(partLc){
3997  AliAODMCParticle *partLcDaug0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(partLc->GetDaughter(0)));
3998  if(partLcDaug0){
3999  xLcMC=partLcDaug0->Xv(), yLcMC=partLcDaug0->Yv(), zLcMC=partLcDaug0->Zv();
4000  }
4001  }
4002  } else if (isLc2LBarpi || isLc2Lpi) {
4003  AliAODMCParticle *partLc = dynamic_cast<AliAODMCParticle*>(mcArray->At(mcLabel));
4004  AliAODMCParticle *partLcDaug0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(partLc->GetDaughter(0)));
4005  xLcMC=partLcDaug0->Xv(), yLcMC=partLcDaug0->Yv(), zLcMC=partLcDaug0->Zv();
4006  } else if (isDp2K0Spi) {
4007  AliAODMCParticle *partLc = dynamic_cast<AliAODMCParticle*>(mcArray->At(mcLabel2));
4008  AliAODMCParticle *partLcDaug0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(partLc->GetDaughter(0)));
4009  xLcMC=partLcDaug0->Xv(), yLcMC=partLcDaug0->Yv(), zLcMC=partLcDaug0->Zv();
4010  } else if (isDs2K0SK) {
4011  AliAODMCParticle *partLc = dynamic_cast<AliAODMCParticle*>(mcArray->At(mcLabel3));
4012  AliAODMCParticle *partLcDaug0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(partLc->GetDaughter(0)));
4013  xLcMC=partLcDaug0->Xv(), yLcMC=partLcDaug0->Yv(), zLcMC=partLcDaug0->Zv();
4014  } else if (isKstar12K0Spi) {
4015  AliAODMCParticle *partLc = dynamic_cast<AliAODMCParticle*>(mcArray->At(mcLabel4));
4016  AliAODMCParticle *partLcDaug0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(partLc->GetDaughter(0)));
4017  xLcMC=partLcDaug0->Xv(), yLcMC=partLcDaug0->Yv(), zLcMC=partLcDaug0->Zv();
4018  } else if (isKstar22K0Spi) {
4019  AliAODMCParticle *partLc = dynamic_cast<AliAODMCParticle*>(mcArray->At(mcLabel5));
4020  AliAODMCParticle *partLcDaug0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(partLc->GetDaughter(0)));
4021  xLcMC=partLcDaug0->Xv(), yLcMC=partLcDaug0->Yv(), zLcMC=partLcDaug0->Zv();
4022  }
4023 
4024  fCandidateVariables[iVariable++] = xLcMC;
4025  fCandidateVariables[iVariable++] = yLcMC;
4026  fCandidateVariables[iVariable++] = zLcMC;
4027  }
4028 
4029  }
4030 
4031  delete objectPIDCombined;
4032 
4033  fVariablesTree->Fill();
4034 
4035  AliWarning(Form("IL NUMERO DI VARIABILI E' %d",iVariable));
4036 
4037  return;
4038 }
4039 
4040 //-------------------------------------------------------------------------------
4042  //
4044  //
4045 
4046  const char* nameoutput = GetOutputSlot(4)->GetContainer()->GetName();
4047  fVariablesTree = new TTree(nameoutput,"Candidates variables tree");
4048  Int_t nVar = 30;
4049  if (fUseMCInfo) nVar += 7;
4050  if (fAdditionalChecks) {
4051  nVar += 56;
4052  if (fUseMCInfo) nVar += 3;
4053  }
4055  Int_t ii=0;
4056  TString * fCandidateVariableNames = new TString[nVar];
4057  fCandidateVariableNames[ii++]="isLcByMC";
4058  fCandidateVariableNames[ii++]="isV0ByMC";
4059  fCandidateVariableNames[ii++]="flagToCheckBachelor";
4060  fCandidateVariableNames[ii++]="flagToCheckV0daughters";
4061  fCandidateVariableNames[ii++]="flagToCheckCandidate";
4062  fCandidateVariableNames[ii++]="massLc2K0Sp";
4063  fCandidateVariableNames[ii++]="massLc2Lambdapi";
4064  fCandidateVariableNames[ii++]="massD2K0Spi"; // D+ -> pi+ K0S
4065  fCandidateVariableNames[ii++]="massDS2K0SK"; // D+S -> K+ K0S
4066  fCandidateVariableNames[ii++]="massK0S";
4067  fCandidateVariableNames[ii++]="massLambda";
4068  fCandidateVariableNames[ii++]="massLambdaBar";
4069  fCandidateVariableNames[ii++]="massGamma";
4070  fCandidateVariableNames[ii++]="tImpParBach";
4071  fCandidateVariableNames[ii++]="tImpParV0";
4072  fCandidateVariableNames[ii++]="cosPAK0S";
4073  fCandidateVariableNames[ii++]="LcPt"; // @ DCA
4074  fCandidateVariableNames[ii++]="v0Pt"; // @ V0 DCA
4075  fCandidateVariableNames[ii++]="bachelorP"; // @ prim vtx
4076  fCandidateVariableNames[ii++]="bachelorPt"; // @ prim vtx
4077  fCandidateVariableNames[ii++]="V0positivePt"; // @ prim vtx
4078  fCandidateVariableNames[ii++]="V0negativePt"; // @ prim vtx
4079  fCandidateVariableNames[ii++]="bachelorCharge";
4080  fCandidateVariableNames[ii++]="qtProng0V0";
4081  fCandidateVariableNames[ii++]="alphaArm";
4082  fCandidateVariableNames[ii++]="nSigmaTPCpr";
4083  fCandidateVariableNames[ii++]="nSigmaTOFpr";
4084  fCandidateVariableNames[ii++]="combinedProtonProb";
4085  fCandidateVariableNames[ii++]="TPCProtonProb";
4086  fCandidateVariableNames[ii++]="TOFProtonProb";
4087  if (fUseMCInfo) {
4088  fCandidateVariableNames[ii++]="isMCparticleInFiducialAcceptance";
4089  fCandidateVariableNames[ii++]="pdgBachelor"; // pdg MC bachelor
4090  fCandidateVariableNames[ii++]="pdgCandidate"; // pdg MC candidate recovered via new method
4091  fCandidateVariableNames[ii++]="pdgV0pos"; // pdg MC V0 positive
4092  fCandidateVariableNames[ii++]="pdgV0neg"; // pdg MC V0 negative
4093  fCandidateVariableNames[ii++]="pdgV0Candidate"; // pdg MC V0candidate recovered via new method
4094  fCandidateVariableNames[ii++]="checkLcOrigin";
4095  }
4096 
4097  if (fAdditionalChecks) { // ------------------------------siamo qui!
4098  fCandidateVariableNames[ii++]="LcP"; // @ DCA
4099  fCandidateVariableNames[ii++]="v0P"; // @ V0 DCA
4100  fCandidateVariableNames[ii++]="V0positiveP"; // @ prim vtx
4101  fCandidateVariableNames[ii++]="V0negativeP"; // @ prim vtx
4102  fCandidateVariableNames[ii++]="nSigmaTPCpi";
4103  fCandidateVariableNames[ii++]="nSigmaTPCka";
4104  fCandidateVariableNames[ii++]="nSigmaTOFpi";
4105  fCandidateVariableNames[ii++]="nSigmaTOFka";
4106  fCandidateVariableNames[ii++]="startTimeMask"; // start time mask
4107  fCandidateVariableNames[ii++]="dcaLcptp"; // DCA Lc prong-to-prong
4108  fCandidateVariableNames[ii++]="dcaV0ptp";
4109  fCandidateVariableNames[ii++]="dcaV0postoPV";
4110  fCandidateVariableNames[ii++]="dcaV0negtoPV";
4111  fCandidateVariableNames[ii++]="cosPALc";
4112  fCandidateVariableNames[ii++]="rhoV0";
4113  fCandidateVariableNames[ii++]="nSigmaITSpr";
4114  fCandidateVariableNames[ii++]="nSigmaITSpi";
4115  fCandidateVariableNames[ii++]="nSigmaITSka";
4116  fCandidateVariableNames[ii++]="yLc";
4117  fCandidateVariableNames[ii++]="etaBach"; // etaBachelor
4118  fCandidateVariableNames[ii++]="etaV0pos"; // etaV0pos
4119  fCandidateVariableNames[ii++]="etaV0neg"; // etaV0neg
4120  fCandidateVariableNames[ii++]="decayLengthLc";
4121  fCandidateVariableNames[ii++]="decayLengthV0";
4122  fCandidateVariableNames[ii++]="cosPALcXY"; // cosPA XY x Lc
4123  fCandidateVariableNames[ii++]="cosPAV0XY"; // cosPA XY x V0
4124  fCandidateVariableNames[ii++]="decayLengthLcXY"; // decay length XY x Lc
4125  fCandidateVariableNames[ii++]="decayLengthV0XY"; // decay length XY x V0
4126  fCandidateVariableNames[ii++]="normalizedDecayLengthLc"; // normalized decay length x Lc
4127  fCandidateVariableNames[ii++]="normalizedDecayLengthV0"; // normalized decay length x V0
4128  fCandidateVariableNames[ii++]="normalizedDecayLengthXYLc"; // normalized decay length XY x Lc
4129  fCandidateVariableNames[ii++]="normalizedDecayLengthXYV0"; // normalized decay length XY x V0
4130  fCandidateVariableNames[ii++]="newLcDCA";
4131  fCandidateVariableNames[ii++]="cosThetaStarBachelor";
4132  fCandidateVariableNames[ii++]="cosThetaStarV0";
4133  fCandidateVariableNames[ii++]="etaV0";
4134  fCandidateVariableNames[ii++]="yV0";
4135  fCandidateVariableNames[ii++]="massKstar12K0Spi"; // Kstar( 892)+ -> pi+ K0S
4136  fCandidateVariableNames[ii++]="massKstar22K0Spi"; // Kstar(1430)+ -> pi+ K0S
4137  fCandidateVariableNames[ii++]="xVtxLcBad";
4138  fCandidateVariableNames[ii++]="yVtxLcBad";
4139  fCandidateVariableNames[ii++]="zVtxLcBad";
4140  fCandidateVariableNames[ii++]="xVtxLcGood";
4141  fCandidateVariableNames[ii++]="yVtxLcGood";
4142  fCandidateVariableNames[ii++]="zVtxLcGood";
4143  fCandidateVariableNames[ii++]="pxVtxBachelorBad";
4144  fCandidateVariableNames[ii++]="pyVtxBachelorBad";
4145  fCandidateVariableNames[ii++]="pxVtxBachelorGood";
4146  fCandidateVariableNames[ii++]="pyVtxBachelorGood";
4147  fCandidateVariableNames[ii++]="pzVtxBachelorGood";
4148  fCandidateVariableNames[ii++]="pxVtxV0";
4149  fCandidateVariableNames[ii++]="pyVtxV0";
4150  fCandidateVariableNames[ii++]="pzVtxV0";
4151  fCandidateVariableNames[ii++]="xPvtx";
4152  fCandidateVariableNames[ii++]="yPvtx";
4153  fCandidateVariableNames[ii++]="zPvtx";
4154  if (fUseMCInfo) {
4155  fCandidateVariableNames[ii++]="xVtxLcMC";
4156  fCandidateVariableNames[ii++]="yVtxLcMC";
4157  fCandidateVariableNames[ii++]="zVtxLcMC";
4158  }
4159  }
4160 
4161  if (ii!=nVar) AliError(Form("Please, check the number of tree variables: %d vs %d",nVar,ii));
4162 
4163  for (Int_t ivar=0; ivar<nVar; ivar++) {
4164  fVariablesTree->Branch(fCandidateVariableNames[ivar].Data(),&fCandidateVariables[ivar],Form("%s/f",fCandidateVariableNames[ivar].Data()));
4165  }
4166 
4167  return;
4168 }
4169 
4170 //__________________________________________________________________________
4172  //
4174  //
4175 
4176  fCEvents = new TH1F("fCEvents","conter",20,0,20);
4177  fCEvents->SetStats(kTRUE);
4178  fCEvents->GetXaxis()->SetBinLabel(1,"X1");
4179  fCEvents->GetXaxis()->SetBinLabel(2,"Analyzed events");
4180  fCEvents->GetXaxis()->SetBinLabel(3,"AliAODVertex exists");
4181  fCEvents->GetXaxis()->SetBinLabel(4,"CascadesHF exists");
4182  fCEvents->GetXaxis()->SetBinLabel(5,"MCarray exists");
4183  fCEvents->GetXaxis()->SetBinLabel(6,"MCheader exists");
4184  fCEvents->GetXaxis()->SetBinLabel(7,"GetNContributors()>0");
4185  fCEvents->GetXaxis()->SetBinLabel(8,"IsEventSelected");
4186  fCEvents->GetXaxis()->SetBinLabel(9,"triggerClass!=CINT1");
4187  fCEvents->GetXaxis()->SetBinLabel(10,"triggerMask!=kAnyINT");
4188  fCEvents->GetXaxis()->SetBinLabel(11,"triggerMask!=kAny");
4189  fCEvents->GetXaxis()->SetBinLabel(12,"vtxTitle.Contains(Z)");
4190  fCEvents->GetXaxis()->SetBinLabel(13,"vtxTitle.Contains(3D)");
4191  fCEvents->GetXaxis()->SetBinLabel(14,"vtxTitle.Doesn'tContain(Z-3D)");
4192  fCEvents->GetXaxis()->SetBinLabel(15,Form("zVtx<=%2.0fcm",fAnalCuts->GetMaxVtxZ()));
4193  fCEvents->GetXaxis()->SetBinLabel(16,"!IsEventSelected");
4194  fCEvents->GetXaxis()->SetBinLabel(17,"triggerMask!=kAnyINT || triggerClass!=CINT1");
4195  fCEvents->GetXaxis()->SetBinLabel(18,Form("zVtxMC<=%2.0fcm",fAnalCuts->GetMaxVtxZ()));
4196  fCEvents->GetXaxis()->SetBinLabel(19,"Re-Fill Fail");
4197  fCEvents->GetXaxis()->SetBinLabel(20,"AOD Mismatch");
4198  //fCEvents->GetXaxis()->SetTitle("");
4199  fCEvents->GetYaxis()->SetTitle("counts");
4200 
4201  fOutput->Add(fCEvents);
4202  TString fillthis="";
4203 
4204  if (fUseMCInfo && fAdditionalChecks) {
4205  fillthis="histMcStatLc";
4206  TH1F* mcStatisticLc = new TH1F(fillthis.Data(),"#Lambda_{c} generated and their decays",21,-10.5,10.5);
4207  fOutput->Add(mcStatisticLc);
4208  }
4209 
4210  //fillthis="histopionV0SigmaVspTOF";
4211  //TH2F *hpionV0SigmaVspTOF=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);
4212  fillthis="histoprotonBachSigmaVspTOF";
4213  TH2F *hprotonBachSigmaVspTOF=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);
4214 
4215  //fOutput->Add(hpionV0SigmaVspTOF);
4216  fOutput->Add(hprotonBachSigmaVspTOF);
4217 
4218  //fillthis="histopionV0SigmaVspTPC";
4219  //TH2F *hpionV0SigmaVspTPC=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);
4220  fillthis="histoprotonBachSigmaVspTPC";
4221  TH2F *hprotonBachSigmaVspTPC=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);
4222 
4223  //fOutput->Add(hpionV0SigmaVspTPC);
4224  fOutput->Add(hprotonBachSigmaVspTPC);
4225 
4226  if (fUseMCInfo) {
4227 
4228  //fillthis="histopionV0SigmaVspTOFsgn";
4229  //TH2F *hpionV0SigmaVspTOFsgn=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);
4230  fillthis="histoprotonBachSigmaVspTOFsgn";
4231  TH2F *hprotonBachSigmaVspTOFsgn=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);
4232 
4233  //fOutput->Add(hpionV0SigmaVspTOFsgn);
4234  fOutput->Add(hprotonBachSigmaVspTOFsgn);
4235 
4236  //fillthis="histopionV0SigmaVspTPCsgn";
4237  //TH2F *hpionV0SigmaVspTPCsgn=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);
4238  fillthis="histoprotonBachSigmaVspTPCsgn";
4239  TH2F *hprotonBachSigmaVspTPCsgn=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);
4240 
4241  //fOutput->Add(hpionV0SigmaVspTPCsgn);
4242  fOutput->Add(hprotonBachSigmaVspTPCsgn);
4243 
4244 
4245  //fillthis="histopionV0SigmaVspTOFbkg";
4246  //TH2F *hpionV0SigmaVspTOFbkg=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);
4247  fillthis="histoprotonBachSigmaVspTOFbkg";
4248  TH2F *hprotonBachSigmaVspTOFbkg=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);
4249 
4250  //fOutput->Add(hpionV0SigmaVspTOFbkg);
4251  fOutput->Add(hprotonBachSigmaVspTOFbkg);
4252 
4253  //fillthis="histopionV0SigmaVspTPCbkg";
4254  //TH2F *hpionV0SigmaVspTPCbkg=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);
4255  fillthis="histoprotonBachSigmaVspTPCbkg";
4256  TH2F *hprotonBachSigmaVspTPCbkg=new TH2F(fillthis.Data(),fillthis.Data(),300,0.,30.,100,-5.,5.);
4257 
4258  //fOutput->Add(hpionV0SigmaVspTPCbkg);
4259  fOutput->Add(hprotonBachSigmaVspTPCbkg);
4260 
4261  }
4262 
4263  if (fAdditionalChecks) {
4264 
4265  TH1F *hZ2 = new TH1F("hZ2","",100,-50.,50.);
4266  fOutput->Add(hZ2);
4267  TH1F *hZ3 = new TH1F("hZ3","",100,-50.,50.);
4268  fOutput->Add(hZ3);
4269  TH1F *hZ4 = new TH1F("hZ4","",100,-50.,50.);
4270  fOutput->Add(hZ4);
4271  TH1F *hZ5 = new TH1F("hZ5","",100,-50.,50.);
4272  fOutput->Add(hZ5);
4273  TH1F *hZ6 = new TH1F("hZ6","",100,-50.,50.);
4274  fOutput->Add(hZ6);
4275  TH1F *hZ7 = new TH1F("hZ7","",100,-50.,50.);
4276  fOutput->Add(hZ7);
4277  TH1F *hZ8 = new TH1F("hZ8","",100,-50.,50.);
4278  fOutput->Add(hZ8);
4279  TH1F *hZ9 = new TH1F("hZ9","",100,-50.,50.);
4280  fOutput->Add(hZ9);
4281  TH1F *hZ10 = new TH1F("hZ10","",100,-50.,50.);
4282  fOutput->Add(hZ10);
4283  TH1F *hZ11 = new TH1F("hZ11","",100,-50.,50.);
4284  fOutput->Add(hZ11);
4285  TH1F *hZ12 = new TH1F("hZ12","",100,-50.,50.);
4286  fOutput->Add(hZ12);
4287  TH1F *hZ13 = new TH1F("hZ13","",100,-50.,50.);
4288  fOutput->Add(hZ13);
4289  TH1F *hZ14 = new TH1F("hZ14","",100,-50.,50.);
4290  fOutput->Add(hZ14);
4291  TH1F *hZ15 = new TH1F("hZ15","",100,-50.,50.);
4292  fOutput->Add(hZ15);
4293  TH1F *hZ16 = new TH1F("hZ16","",100,-50.,50.);
4294  fOutput->Add(hZ16);
4295  }
4296 
4297  TH1F *hCandidateSelection = new TH1F("hCandidateSelection","",10,-0.5,9.5);
4298  hCandidateSelection->GetXaxis()->SetBinLabel(1,"IsEventSelected");
4299  hCandidateSelection->GetXaxis()->SetBinLabel(2,"IsSecondaryVtx");
4300  hCandidateSelection->GetXaxis()->SetBinLabel(3,"V0toPosNeg");
4301  hCandidateSelection->GetXaxis()->SetBinLabel(4,"offlineV0");
4302  hCandidateSelection->GetXaxis()->SetBinLabel(5,"isInFiducialAcceptance");
4303  hCandidateSelection->GetXaxis()->SetBinLabel(6,"analCuts::kTracks");
4304  hCandidateSelection->GetXaxis()->SetBinLabel(7,"analCuts::kCandidateNoPID");
4305  hCandidateSelection->GetXaxis()->SetBinLabel(8,"analCuts::kPID");
4306  hCandidateSelection->GetXaxis()->SetBinLabel(9,"analCuts::kCandidateWithPID");
4307  hCandidateSelection->GetXaxis()->SetBinLabel(10,"analCuts::kAll");
4308  fOutput->Add(hCandidateSelection);
4309 
4310  TH1F *hEventsWithCandidates = new TH1F("hEventsWithCandidates","conter",11,5.5,16.5);
4311  hEventsWithCandidates->GetXaxis()->SetBinLabel(1,"GetNContributors()>0");
4312  hEventsWithCandidates->GetXaxis()->SetBinLabel(2,"IsEventSelected");
4313  hEventsWithCandidates->GetXaxis()->SetBinLabel(3,"triggerClass!=CINT1");
4314  hEventsWithCandidates->GetXaxis()->SetBinLabel(4,"triggerMask!=kAnyINT");
4315  hEventsWithCandidates->GetXaxis()->SetBinLabel(5,"triggerMask!=kAny");
4316  hEventsWithCandidates->GetXaxis()->SetBinLabel(6,"vtxTitle.Contains(Z)");
4317  hEventsWithCandidates->GetXaxis()->SetBinLabel(7,"vtxTitle.Contains(3D)");
4318  hEventsWithCandidates->GetXaxis()->SetBinLabel(8,"vtxTitle.Doesn'tContain(Z-3D)");
4319  hEventsWithCandidates->GetXaxis()->SetBinLabel(9,Form("zVtx<=%2.0fcm",fAnalCuts->GetMaxVtxZ()));
4320  hEventsWithCandidates->GetXaxis()->SetBinLabel(10,"!IsEventSelected");
4321  hEventsWithCandidates->GetXaxis()->SetBinLabel(11,"triggerMask!=kAnyINT || triggerClass!=CINT1");
4322  fOutput->Add(hEventsWithCandidates);
4323 
4324  if (fAdditionalChecks) {
4325 
4326  TH1F *hZ6a = new TH1F("hZ6a","",100,-50.,50.);
4327  fOutput->Add(hZ6a);
4328  TH1F *hZ7a = new TH1F("hZ7a","",100,-50.,50.);
4329  fOutput->Add(hZ7a);
4330  TH1F *hZ8a = new TH1F("hZ8a","",100,-50.,50.);
4331  fOutput->Add(hZ8a);
4332  TH1F *hZ9a = new TH1F("hZ9a","",100,-50.,50.);
4333  fOutput->Add(hZ9a);
4334  TH1F *hZ10a = new TH1F("hZ10a","",100,-50.,50.);
4335  fOutput->Add(hZ10a);
4336  TH1F *hZ11a = new TH1F("hZ11a","",100,-50.,50.);
4337  fOutput->Add(hZ11a);
4338  TH1F *hZ12a = new TH1F("hZ12a","",100,-50.,50.);
4339  fOutput->Add(hZ12a);
4340  TH1F *hZ13a = new TH1F("hZ13a","",100,-50.,50.);
4341  fOutput->Add(hZ13a);
4342  TH1F *hZ14a = new TH1F("hZ14a","",100,-50.,50.);
4343  fOutput->Add(hZ14a);
4344  TH1F *hZ15a = new TH1F("hZ15a","",100,-50.,50.);
4345  fOutput->Add(hZ15a);
4346  TH1F *hZ16a = new TH1F("hZ16a","",100,-50.,50.);
4347  fOutput->Add(hZ16a);
4348  }
4349 
4350  TH1F *hSwitchOnCandidates1 = new TH1F("hSwitchOnCandidates1","",15,-7.5,7.5);
4351  fOutput->Add(hSwitchOnCandidates1);
4352  TH1F *hSwitchOnCandidates2 = new TH1F("hSwitchOnCandidates2","",15,-7.5,7.5);
4353  fOutput->Add(hSwitchOnCandidates2);
4354  TH1F *hSwitchOnCandidates3 = new TH1F("hSwitchOnCandidates3","",15,-7.5,7.5);
4355  fOutput->Add(hSwitchOnCandidates3);
4356  TH1F *hSwitchOnCandidates4 = new TH1F("hSwitchOnCandidates4","",15,-7.5,7.5);
4357  fOutput->Add(hSwitchOnCandidates4);
4358 
4359  return;
4360 }
4361 
4362 //________________________________________________________________________
4364  //
4365  // This is to fill analysis histograms
4366  //
4367 
4368  TString fillthis="";
4369 
4370  Bool_t isBachelorID = (((cutsAnal->IsSelected(part,AliRDHFCuts::kPID))&(AliRDHFCutsLctoV0::kLcToK0Spr))==(AliRDHFCutsLctoV0::kLcToK0Spr)); // ID x bachelor
4371 
4372  Bool_t areCutsUsingPID = cutsAnal->GetIsUsePID();
4373  cutsAnal->SetUsePID(kFALSE);
4374 
4375  Double_t invmassLc = part->InvMassLctoK0sP();
4376  Double_t lambdacpt = part->Pt();
4377 
4378  AliAODTrack *bachelor = (AliAODTrack*)part->GetBachelor();
4379  Double_t momBach = bachelor->P();
4380  Double_t ptBach = bachelor->Pt();
4381 
4382  AliAODv0 *v0part = (AliAODv0*)part->Getv0();
4383  Double_t momK0S = v0part->P();
4384  Double_t ptK0S = v0part->Pt();
4385  //Double_t dcaV0ptp = v0part->GetDCA();
4386  Double_t invmassK0S = v0part->MassK0Short();
4387 
4388  AliAODTrack *v0pos = (AliAODTrack*)part->Getv0PositiveTrack();
4389  Double_t ptV0pos = v0pos->Pt();
4390  AliAODTrack *v0neg = (AliAODTrack*)part->Getv0NegativeTrack();
4391  Double_t ptV0neg = v0neg->Pt();
4392 
4393  if (!appendthis.Contains("SgnC") && !appendthis.Contains("SgnB") && !appendthis.Contains("SgnNoQ")) {
4394  fillthis="histpK0Svsp"+appendthis;
4395  //cout << fillthis << endl;
4397  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(momBach,momK0S);
4398  if (isBachelorID) ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(momBach,momK0S);
4399  }
4400  }
4401 
4402  fillthis="histLcMassByK0S"+appendthis;
4403  //cout << fillthis << endl;
4405  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(invmassLc,lambdacpt);
4406  if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(invmassLc,lambdacpt);
4407  }
4408 
4409  if(fFillSubSampleHist && appendthis=="Offline"){
4410  fillthis="histLcMassByK0SSubSample"+appendthis;
4412  Double_t contsp[3];contsp[0]=invmassLc;contsp[1]=lambdacpt;contsp[2]=(Double_t)(fEventCounter%24);
4413  if (isBachelorID)((THnSparse*)(fOutputPIDBach->FindObject(fillthis)))->Fill(contsp);
4414  }
4415  }
4416 
4417  if (!appendthis.Contains("SgnC") && !appendthis.Contains("SgnB") && !appendthis.Contains("SgnNoQ")) {
4418  fillthis="histK0SMass"+appendthis;
4419  // cout << fillthis << endl;
4420  cutsAnal->SetExcludedCut(2);
4422  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(lambdacpt,invmassK0S);
4423  if (isBachelorID) ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(lambdacpt,invmassK0S);
4424  }
4425  cutsAnal->SetExcludedCut(-1);
4426  }
4427 
4428  fillthis="histptK0S"+appendthis;
4429  //cout << fillthis << endl;
4430  cutsAnal->SetExcludedCut(15);
4432  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(lambdacpt,ptK0S);
4433  if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(lambdacpt,ptK0S);
4434  }
4435 
4436  fillthis="histptP"+appendthis;
4437  //cout << fillthis << endl;
4438  cutsAnal->SetExcludedCut(4);
4440  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(lambdacpt,ptBach);
4441  if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(lambdacpt,ptBach);
4442  }
4443 
4444  fillthis="histptPip"+appendthis;
4445  //cout << fillthis << endl;
4446  cutsAnal->SetExcludedCut(5);
4448  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(lambdacpt,ptV0pos);
4449  if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(lambdacpt,ptV0pos);
4450  }
4451 
4452  fillthis="histptPim"+appendthis;
4453  //cout << fillthis << endl;
4454  cutsAnal->SetExcludedCut(6);
4456  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(lambdacpt,ptV0neg);
4457  if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(lambdacpt,ptV0neg);
4458  }
4459 
4460  if (!appendthis.Contains("SgnC") && !appendthis.Contains("SgnB") && !appendthis.Contains("SgnNoQ")) {
4461  fillthis="histLambdaMass"+appendthis;
4462  // cout << fillthis << endl;
4463  cutsAnal->SetExcludedCut(13);
4465  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(lambdacpt,v0part->MassLambda());
4466  if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(lambdacpt,v0part->MassLambda());
4467  }
4468 
4469  fillthis="histLambdaBarMass"+appendthis;
4470  // cout << fillthis << endl;
4471  cutsAnal->SetExcludedCut(13);
4473  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(lambdacpt,v0part->MassAntiLambda());
4474  if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(lambdacpt,v0part->MassAntiLambda());
4475  }
4476 
4477  fillthis="histGammaMass"+appendthis;
4478  // cout << fillthis << endl;
4479  cutsAnal->SetExcludedCut(14);
4481  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(lambdacpt,v0part->InvMass2Prongs(0,1,11,11));
4482  if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(lambdacpt,v0part->InvMass2Prongs(0,1,11,11));
4483  }
4484  }
4485 
4486  fillthis="histD0K0S"+appendthis;
4487  //cout << fillthis << endl;
4488  cutsAnal->SetExcludedCut(11);
4490  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(lambdacpt,part->Getd0Prong(1));
4491  if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(lambdacpt,part->Getd0Prong(1));
4492  }
4493 
4494  fillthis="histD0P"+appendthis;
4495  //cout << fillthis << endl;
4496  cutsAnal->SetExcludedCut(10);
4498  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(lambdacpt,part->Getd0Prong(0));
4499  if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(lambdacpt,part->Getd0Prong(0));
4500  }
4501 
4502  fillthis="histCosPAK0S"+appendthis;
4503  //cout << fillthis << endl;
4504  cutsAnal->SetExcludedCut(9);
4506  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(lambdacpt,part->CosV0PointingAngle());
4507  if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(lambdacpt,part->CosV0PointingAngle());
4508  }
4509 
4510  fillthis="histCosThetaProtonCMS"+appendthis;
4511  //cout << fillthis << endl;
4512  cutsAnal->SetExcludedCut(16);
4514  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(lambdacpt,cutsAnal->GetProtonEmissionAngleCMS(part));
4515  if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(lambdacpt,cutsAnal->GetProtonEmissionAngleCMS(part));
4516  }
4517 
4518  fillthis="histResignedD0"+appendthis;
4519  //cout << fillthis << endl;
4520  cutsAnal->SetExcludedCut(18);
4522  ((TH2F*)(fOutputAll->FindObject(fillthis)))->Fill(lambdacpt,cutsAnal->GetReSignedd0(part));
4523  if (isBachelorID)((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(lambdacpt,cutsAnal->GetReSignedd0(part));
4524  }
4525 
4526  cutsAnal->SetExcludedCut(-1);
4527 
4528  cutsAnal->SetUsePID(areCutsUsingPID);
4529 
4530  return;
4531 }
4532 //---------------------------
4534  Double_t &xVtxLc, Double_t &yVtxLc, Double_t &zVtxLc,
4535  Double_t &pxVtxBachelor, Double_t &pyVtxBachelor, Double_t &pzVtxBachelor) {
4536  //--------------------------------------------------------------------
4539  //--------------------------------------------------------------------
4540 
4541  // Get AliExternalTrackParam out of the AliAODTracks
4542  Double_t xyz[3], pxpypz[3], cv[21]; Short_t sign;
4543  bachelor->PxPyPz(pxpypz);
4544  bachelor->XvYvZv(xyz);
4545  bachelor->GetCovarianceXYZPxPyPz(cv);
4546  sign=bachelor->Charge();
4547  AliExternalTrackParam *t = new AliExternalTrackParam(xyz,pxpypz,cv,sign);
4548 
4549  Double_t alpha=t->GetAlpha(), cs1=TMath::Cos(alpha), sn1=TMath::Sin(alpha);
4550  //Double_t alpha = GetAlpha(xyz,pxpypz), cs1=TMath::Cos(alpha), sn1=TMath::Sin(alpha);
4551 
4552  // position and momentum of bachelor
4553  Double_t x1=xyz[0], y1=xyz[1], z1=xyz[2];
4554  Double_t px1=pxpypz[0], py1=pxpypz[1], pz1=pxpypz[2];
4555 
4556  // position and momentum of V0
4557  Double_t x2=v->DecayVertexV0X(),
4558  y2=v->DecayVertexV0Y(),
4559  z2=v->DecayVertexV0Z();
4560  Double_t px2=v->Px(),
4561  py2=v->Py(),
4562  pz2=v->Pz();
4563 
4564  /*
4565  AliAODTrack *trackP = (AliAODTrack*) v->GetDaughter(0);
4566  //Double_t pxpypzP[3]; trackP->PxPyPz(pxpypzP);
4567  //Double_t xyzP[3]; trackP->XvYvZv(xyzP);
4568  Double_t cvP[21]; trackP->GetCovarianceXYZPxPyPz(cvP);
4569  //Short_t signP=trackP->Charge();
4570  //AliExternalTrackParam *tP = new AliExternalTrackParam(xyzP,pxpypzP,cvP,signP);
4571 
4572  // Get AliExternalTrackParam out of the AliAODTrack
4573  AliAODTrack *trackN = (AliAODTrack*) v->GetDaughter(1);
4574  //Double_t pxpypzN[3]; trackN->PxPyPz(pxpypzN);
4575  //Double_t xyzN[3]; trackN->XvYvZv(xyzN);
4576  Double_t cvN[21]; trackN->GetCovarianceXYZPxPyPz(cvN);
4577  //Short_t signN=trackN->Charge();
4578  //AliExternalTrackParam *tN = new AliExternalTrackParam(xyzN,pxpypzN,cvN,signN);
4579 
4580  Double_t xyzV0[3]={x2,y2,z2};
4581  Double_t pxpypzV0[3]={px2,py2,pz2};
4582  Double_t cvV0[21]; for (Int_t ii=0; ii<21; ii++) cvV0[ii]=cvP[ii]+cvN[ii];
4583  AliNeutralTrackParam *trackV0 = new AliNeutralTrackParam(xyzV0,pxpypzV0,cvV0,0);
4584  */
4585 
4586  // calculation dca
4587  Double_t dd= Det(x2-x1,y2-y1,z2-z1,px1,py1,pz1,px2,py2,pz2);
4588  Double_t ax= Det(py1,pz1,py2,pz2);
4589  Double_t ay=-Det(px1,pz1,px2,pz2);
4590  Double_t az= Det(px1,py1,px2,py2);
4591 
4592  Double_t dca=TMath::Abs(dd)/TMath::Sqrt(ax*ax + ay*ay + az*az);
4593 
4594  // bachelor point @ the DCA
4595  Double_t t1 = Det(x2-x1,y2-y1,z2-z1,px2,py2,pz2,ax,ay,az)/
4596  Det(px1,py1,pz1,px2,py2,pz2,ax,ay,az);
4597  x1 += px1*t1; y1 += py1*t1; z1 += pz1*t1;
4598 
4599  //propagate track to the point of DCA
4600  Double_t rho1=x1*cs1 + y1*sn1;
4601  if (!t->PropagateTo(rho1,b)) {
4602  Error("PropagateToDCA","Propagation failed !");
4603  delete t; t=NULL;
4604  return 1.e+33;
4605  }
4606 
4607  Double_t pBachelorDCA[3]; t->GetPxPyPz(pBachelorDCA);
4608  pxVtxBachelor=pBachelorDCA[0], pyVtxBachelor=pBachelorDCA[1], pzVtxBachelor=pBachelorDCA[2];
4609 
4610  delete t; t=NULL;
4611 
4612  // V0 point @ the DCA
4613  Double_t t2 = Det(x1-x2,y1-y2,z1-z2,px1,py1,pz1,ax,ay,az)/
4614  Det(px2,py2,pz2,px1,py1,pz1,ax,ay,az);
4615  x2 += px2*t2; y2 += py2*t2; z2 += pz2*t2;
4616 
4617 
4618  // Lc decay vtx
4619  xVtxLc = 0.5*(x1+x2);
4620  yVtxLc = 0.5*(y1+y2);
4621  zVtxLc = 0.5*(z1+z2);
4622 
4623  return dca;
4624 
4625 }
4626 
4627 //---------------------------
4629 {
4630  //
4632  //
4633 
4634  Double_t alpha = 0.;
4635 
4636  const double kSafe = 1e-5;
4637  Double_t radPos2 = xyz[0]*xyz[0]+xyz[1]*xyz[1];
4638  Double_t radMax = 45.; // approximately ITS outer radius
4639  if (radPos2 < radMax*radMax) { // inside the ITS
4640  alpha = TMath::ATan2(pxpypz[1],pxpypz[0]);
4641  } else { // outside the ITS
4642  Float_t phiPos = TMath::Pi()+TMath::ATan2(-xyz[1], -xyz[0]);
4643  alpha =
4644  TMath::DegToRad()*(20*((((Int_t)(phiPos*TMath::RadToDeg()))/20))+10);
4645  }
4646 
4647  Double_t cs=TMath::Cos(alpha), sn=TMath::Sin(alpha);
4648  // protection: avoid alpha being too close to 0 or +-pi/2
4649  if (TMath::Abs(sn)<2*kSafe) {
4650  if (alpha>0) alpha += alpha< TMath::Pi()/2. ? 2*kSafe : -2*kSafe;
4651  else alpha += alpha>-TMath::Pi()/2. ? -2*kSafe : 2*kSafe;
4652  cs=TMath::Cos(alpha);
4653  sn=TMath::Sin(alpha);
4654  }
4655  else if (TMath::Abs(cs)<2*kSafe) {
4656  if (alpha>0) alpha += alpha> TMath::Pi()/2. ? 2*kSafe : -2*kSafe;
4657  else alpha += alpha>-TMath::Pi()/2. ? 2*kSafe : -2*kSafe;
4658  cs=TMath::Cos(alpha);
4659  sn=TMath::Sin(alpha);
4660  }
4661 
4662 
4663  return alpha;
4664 }
4665 
4666 //---------------------------
4668  Double_t a10, Double_t a11) const {
4669  //--------------------------------------------------------------------
4672  //--------------------------------------------------------------------
4673  return a00*a11 - a01*a10;
4674 }
4675 
4676 //---------------------------
4678  Double_t a10,Double_t a11,Double_t a12,
4679  Double_t a20,Double_t a21,Double_t a22) const {
4680  //--------------------------------------------------------------------
4683  //--------------------------------------------------------------------
4684  return a00*Det(a11,a12,a21,a22)-a01*Det(a10,a12,a20,a22)+a02*Det(a10,a11,a20,a21);
4685 }
4686 
4687 //----------------------------------------------------------------------------
4689  TClonesArray *mcArray)
4690 {
4691  //
4695  //
4696 
4697  AliAODv0 *theV0 = dynamic_cast<AliAODv0*>(candidate->Getv0()); // the V0
4698  AliVTrack *trk = dynamic_cast<AliVTrack*>(candidate->GetBachelor()); // the bachelor
4699  if (!trk || !theV0) return -1;
4700 
4701  if (trk->GetLabel()==-1) return -1;
4702  Int_t bachLabels = TMath::Abs(trk->GetLabel());
4703  AliAODMCParticle*bachelorMC = dynamic_cast<AliAODMCParticle*>(mcArray->At(bachLabels));
4704  if (!bachelorMC) return -1;
4705  if (TMath::Abs(bachelorMC->GetPdgCode())!=2212) return -1;
4706  Int_t indexMotherBach = bachelorMC->GetMother();
4707  if (indexMotherBach==-1) return -1;
4708 
4709  Int_t pdgDg2prong[2] = {211,211};
4710  Int_t lab2Prong = theV0->MatchToMC(310,mcArray,2,pdgDg2prong); // the V0
4711  if(lab2Prong<0) return -1;
4712  AliAODMCParticle*partK0S = dynamic_cast<AliAODMCParticle*>(mcArray->At(lab2Prong));
4713  if (!partK0S) return -1;
4714  Int_t indexMotherK0S = partK0S->GetMother();
4715  if (indexMotherK0S==-1) return -1;
4716  AliAODMCParticle*partK0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(indexMotherK0S));
4717  if (!partK0) return -1;
4718  Int_t indexMotherK0 = partK0->GetMother();
4719  if (indexMotherK0==-1) return -1;
4720 
4721  if (indexMotherBach!=indexMotherK0) return -1; // p e K0S sono fratelli
4722 
4723  AliAODMCParticle*partLc = dynamic_cast<AliAODMCParticle*>(mcArray->At(indexMotherK0));
4724  if (!partLc) return -1;
4725  Int_t ndg2 = partLc->GetDaughter(1)-partLc->GetDaughter(0)+1;
4726  if (ndg2==2) return -1;
4727 
4728  TString stringaCheck = Form(">>>>>>>> %d -> ",partLc->GetPdgCode());
4729  for(Int_t ii=0; ii<ndg2; ii++) {
4730  AliAODMCParticle* partDau=(AliAODMCParticle*)(mcArray->At(partLc->GetDaughter(0)+ii));
4731  stringaCheck.Append(Form(" %d",partDau->GetPdgCode()));
4732  }
4733  //printf("%s \n",stringaCheck.Data());
4734 
4735  return indexMotherBach;
4736 
4737 }
4738 //--------------------------------------------------------------------------
4740  Int_t dgLabels[10],Int_t ndg,
4741  Int_t &ndgCk, Int_t *pdgDg, Int_t &absLabelMother, Int_t &nDauCand) const
4742 {
4748 
4749  Int_t lab=-1,labMother=-1,pdgMother=0;
4750  AliAODMCParticle *part=0;
4751  AliAODMCParticle *mother=0;
4752 
4753  // loop on daughter labels
4754  TArrayI **labelMother = new TArrayI*[ndg];
4755  for(Int_t i=0; i<ndg; i++) labelMother[i] = new TArrayI(0);
4756  for(Int_t i=0; i<ndg; i++) {
4757  lab = TMath::Abs(dgLabels[i]);
4758  if(lab<0) {
4759  AliDebug(2,Form("daughter with negative label %d",lab));
4760  delete [] labelMother;
4761  return 0;
4762  }
4763  part = (AliAODMCParticle*)mcArray->At(lab);
4764  if(!part) {
4765  AliDebug(2,"no MC particle");
4766  delete [] labelMother;
4767  return 0;
4768  }
4769 
4770  mother = part;
4771  while(mother->GetMother()>=0) {
4772  labMother=mother->GetMother();
4773  mother = (AliAODMCParticle*)mcArray->At(labMother);
4774  if(!mother) {
4775  AliDebug(2,"no MC mother particle");
4776  break;
4777  }
4778  pdgMother = TMath::Abs(mother->GetPdgCode());
4779  if (pdgMother<10 || (pdgMother>18 && pdgMother<111)) {
4780  break;
4781  }
4782  labelMother[i]->Set(labelMother[i]->GetSize()+1);
4783  labelMother[i]->AddAt(labMother,labelMother[i]->GetSize()-1);
4784  }
4785 
4786  } // end loop on daughters
4787 
4788 
4789  TString stringaCheck;
4790  for(Int_t i=0; i<ndg; i++) {
4791  AliAODMCParticle*part0 = (AliAODMCParticle*)mcArray->At(TMath::Abs(dgLabels[i]));
4792  stringaCheck.Append(Form("part[%d]->GetLabel()=%d(%d) | ",i,dgLabels[i],part0->GetPdgCode()));
4793  stringaCheck.Append(Form("labelMother[%d] = ",i));
4794  for (Int_t jj=0;jj<labelMother[i]->GetSize(); jj++)
4795  stringaCheck.Append(Form("%d, ",labelMother[i]->At(jj)));
4796  }
4797  AliDebug(2,Form("%s \n",stringaCheck.Data()));
4798  Int_t pdgToBeReturned=0;
4799 
4800  TString stringaCheck2;
4801  ndgCk=ndg;
4802  pdgDg = new Int_t[ndgCk];
4803  for (Int_t index=1; index<ndg; index++) {
4804  Bool_t found=kFALSE;
4805  for (Int_t jj=0;jj<labelMother[index]->GetSize(); jj++) {
4806  for (Int_t ii=0;ii<labelMother[0]->GetSize(); ii++) {
4807  if (labelMother[0]->At(ii)==labelMother[index]->At(jj) &&
4808  labelMother[0]->At(ii)!=0 && labelMother[0]->At(ii)!=1 && !found) {
4809  mother = (AliAODMCParticle*)mcArray->At(labelMother[0]->At(ii));
4810  pdgToBeReturned=mother->GetPdgCode();
4811  absLabelMother=labelMother[0]->At(ii);
4812  AliDebug(2,Form("FOUND label for the mother of this candidate: %d (PDG=%d)\n",labelMother[0]->At(ii),pdgToBeReturned));
4813  //mother->Print();
4814  nDauCand=mother->GetNDaughters();
4815  found = kTRUE;
4816  AliAODMCParticle *partMC = (AliAODMCParticle*)mcArray->At(dgLabels[0]);
4817  pdgDg[0]=partMC->GetPdgCode();
4818  partMC = (AliAODMCParticle*)mcArray->At(dgLabels[index]);
4819  pdgDg[index]=partMC->GetPdgCode();
4820  if (index==1) stringaCheck2.Append(Form("found daughters -> %d(%d)",dgLabels[0],pdgDg[0]));
4821  stringaCheck2.Append(Form(" %d(%d)",dgLabels[index],pdgDg[index]));
4822  break;
4823  }
4824  }
4825  if (found) break;
4826  }
4827  }
4828  stringaCheck2.Prepend(Form("Ecco quanto trovato: %d(%d) with %d daughters; ",absLabelMother,pdgToBeReturned,nDauCand));
4829  AliDebug(2,Form("%s \n",stringaCheck2.Data()));
4830 
4831  delete [] labelMother;
4832  delete [] pdgDg;
4833 
4834  return pdgToBeReturned;
4835 
4836 }
4837 
4839 {
4840 
4841  AliAODRecoCascadeHF *partCopy = new AliAODRecoCascadeHF(*part);
4842 
4843  Double_t px[2]={partCopy->PxProng(0),partCopy->PxProng(1)};
4844  Double_t py[2]={partCopy->PyProng(0),partCopy->PyProng(1)};
4845  Double_t pz[2]={partCopy->PzProng(0),partCopy->PzProng(1)};
4846 
4847  Double_t pt = partCopy->Pt();
4848  Int_t pdgD=4122;
4849  UInt_t pdgLc2pK0S[2]={2212,310};
4850  Double_t minv2 = partCopy->InvMass2(2,pdgLc2pK0S);
4851  Double_t mass=TMath::Sqrt(minv2);
4852  Double_t rapid = partCopy->Y(pdgD);
4853 
4854  TString fillthis;
4855 
4857  fillthis="hMassVsPtVsY"+appendthis;
4858  //cout << fillthis << endl;
4859  ((TH3F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(mass,pt,rapid);
4860 
4861  fillthis="phiVSthetaVSpt"+appendthis;
4862  //cout << fillthis << endl;
4863  ((TH3F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(pt,part->Phi(),part->Theta());
4864  }
4865 
4866  Int_t nRotated=0;
4867  Double_t massRot=0;// calculated later only if candidate is acceptable
4868  // 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])));
4869  // Double_t ptOrig=pt;
4870  Double_t rotStep=(fMaxAngleForRot-fMinAngleForRot)/(fNRotations-1); // -1 is to ensure that the last rotation is done with angle=fMaxAngleForRot
4871 
4872  for(Int_t irot=0; irot<fNRotations; irot++){
4873  Double_t phirot=fMinAngleForRot+rotStep*irot;
4874  Double_t tmpx=px[0];
4875  Double_t tmpy=py[0];
4876  px[0]=tmpx*TMath::Cos(phirot)-tmpy*TMath::Sin(phirot);
4877  py[0]=tmpx*TMath::Sin(phirot)+tmpy*TMath::Cos(phirot);
4878  partCopy->SetPxPyPzProngs(2,px,py,pz);
4879  pt = partCopy->Pt();
4880  minv2 = partCopy->InvMass2(2,pdgLc2pK0S);
4881  massRot=TMath::Sqrt(minv2);
4882  rapid = partCopy->Y(pdgD);
4883  //if(minv2>fMinMass*fMinMass && minv2<fMaxMass*fMaxMass){
4884  if ( cuts->IsInFiducialAcceptance(pt,partCopy->Y(4122)) ) {
4886 
4887  fillthis="histLcMassByK0S"+appendthis;
4888  //cout << fillthis << endl;
4889  ((TH2F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(massRot,pt);
4890 
4891  fillthis="hMassVsPtVsYRot"+appendthis;
4892  //cout << fillthis << endl;
4893  ((TH3F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(mass,pt,rapid);
4894 
4895  fillthis="phiVSthetaVSptRot"+appendthis;
4896  //cout << fillthis << endl;
4897  ((TH3F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(pt,partCopy->Phi(),partCopy->Theta());
4898 
4899  fillthis="hDeltaMass"+appendthis;
4900  //cout << fillthis << endl;
4901  ((TH1F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(massRot-mass);
4902  //if(fFullAnalysis){
4903  //Double_t pointRot[5]={mass,massRot-mass,ptOrig,pt-ptOrig,angleProngXY};
4904  //fillthis="hDeltaMassFullAnalysis"+appendthis;
4906  //((THnSparse*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(pointRot);
4907  //}
4908  nRotated++;
4909  //}
4910  }
4911 
4912  // fill additional histos for track-rotated candidates
4913  fillthis="histptK0S"+appendthis;
4914  //cout << fillthis << endl;
4915  cuts->SetExcludedCut(15);
4917  ((TH2F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(pt,TMath::Sqrt(px[1]*px[1]+py[1]*py[1]));
4918  }
4919 
4920  fillthis="histptP"+appendthis;
4921  //cout << fillthis << endl;
4922  cuts->SetExcludedCut(4);
4924  ((TH2F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(pt,TMath::Sqrt(px[0]*px[0]+py[0]*py[0]));
4925  }
4926 
4927  fillthis="histptPip"+appendthis;
4928  //cout << fillthis << endl;
4929  cuts->SetExcludedCut(5);
4931  ((TH2F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(pt,(partCopy->Getv0PositiveTrack())->Pt());
4932  }
4933 
4934  fillthis="histptPim"+appendthis;
4935  //cout << fillthis << endl;
4936  cuts->SetExcludedCut(6);
4938  ((TH2F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(pt,(partCopy->Getv0NegativeTrack())->Pt());
4939  }
4940 
4941  fillthis="histLambdaMass"+appendthis;
4942  //cout << fillthis << endl;
4943  cuts->SetExcludedCut(13);
4945  ((TH2F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(pt,(partCopy->Getv0())->MassLambda());
4946  }
4947 
4948  fillthis="histLambdaBarMass"+appendthis;
4949  //cout << fillthis << endl;
4950  cuts->SetExcludedCut(13);
4952  ((TH2F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(pt,(partCopy->Getv0())->MassAntiLambda());
4953  }
4954 
4955  fillthis="histGammaMass"+appendthis;
4956  //cout << fillthis << endl;
4957  cuts->SetExcludedCut(14);
4959  ((TH2F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(pt,(partCopy->Getv0())->InvMass2Prongs(0,1,11,11));
4960  }
4961 
4962  fillthis="histCosPAK0S"+appendthis;
4963  //cout << fillthis << endl;
4964  cuts->SetExcludedCut(9);
4966  ((TH2F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(pt,partCopy->CosV0PointingAngle());
4967  }
4968 
4969  fillthis="histCosThetaProtonCMS"+appendthis;
4970  //cout << fillthis << endl;
4971  cuts->SetExcludedCut(16);
4973  ((TH2F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(pt,cuts->GetProtonEmissionAngleCMS(partCopy));
4974  }
4975 
4976  fillthis="histResignedD0"+appendthis;
4977  //cout << fillthis << endl;
4978  cuts->SetExcludedCut(18);
4980  ((TH2F*)(fOutputPIDBach->FindObject(fillthis)))->Fill(pt,cuts->GetReSignedd0(partCopy));
4981  }
4982  cuts->SetExcludedCut(-1);
4983 
4984  } // isInFiducialAcceptance
4985 
4986  px[0]=tmpx;
4987  py[0]=tmpy;
4988  }
4989  fillthis="hNormRotated"+appendthis;
4990  //cout << fillthis << endl;
4991  ((TH1F*)(fOutputPIDBachTR->FindObject(fillthis)))->Fill(nRotated);
4992 
4993  delete partCopy;
4994 
4995  return;
4996 
4997 }
4998 
4999 //----------------------------------------------------
5001 {
5002  //
5003  // Define analysis histograms for SNG separated for origin (from c, from b and from no-quark)
5004  //
5005 
5006  if (!fUseMCInfo) return;
5007  if (!fCheckOrigin) return;
5008 
5009  Double_t mLcPDG = TDatabasePDG::Instance()->GetParticle(4122)->Mass();
5010  Double_t mK0SPDG = TDatabasePDG::Instance()->GetParticle(310)->Mass();
5011  Double_t mMinLambdaPDG = TDatabasePDG::Instance()->GetParticle(2212)->Mass()+
5012  TDatabasePDG::Instance()->GetParticle(211)->Mass();
5013 
5014  TString nameHistoSgnC=" ", nameHistoSgnB=" ", nameHistoSgnNoQ=" ";
5015  TString titleHistoSgnC=" ", titleHistoSgnB=" ", titleHistoSgnNoQ=" ";
5016 
5017  // pt(Lc)
5018  Double_t *binLimpTLc=new Double_t[11+1]; // 11 pT(Lc) bins
5019  binLimpTLc[ 0]= 0.;
5020  binLimpTLc[ 1]= 1.;
5021  binLimpTLc[ 2]= 2.;
5022  binLimpTLc[ 3]= 3.;
5023  binLimpTLc[ 4]= 4.;
5024  binLimpTLc[ 5]= 5.;
5025  binLimpTLc[ 6]= 6.;
5026  binLimpTLc[ 7]= 8.;
5027  binLimpTLc[ 8]=12.;
5028  binLimpTLc[ 9]=17.;
5029  binLimpTLc[10]=25.;
5030  binLimpTLc[11]=35.;
5031 
5032  // pt(prong)
5033  Double_t *binLimpTprong=new Double_t[41+1]; // 41 pT(prong) bins
5034  binLimpTprong[ 0]= 0.0;
5035  binLimpTprong[ 1]= 0.1;
5036  binLimpTprong[ 2]= 0.2;
5037  binLimpTprong[ 3]= 0.3;
5038  binLimpTprong[ 4]= 0.4;
5039  binLimpTprong[ 5]= 0.5;
5040  binLimpTprong[ 6]= 0.6;
5041  binLimpTprong[ 7]= 0.7;
5042  binLimpTprong[ 8]= 0.8;
5043  binLimpTprong[ 9]= 0.9;
5044  binLimpTprong[10]= 1.0;
5045  binLimpTprong[11]= 1.2;
5046  binLimpTprong[12]= 1.4;
5047  binLimpTprong[13]= 1.6;
5048  binLimpTprong[14]= 1.8;
5049  binLimpTprong[15]= 2.0;
5050  binLimpTprong[16]= 2.2;
5051  binLimpTprong[17]= 2.4;
5052  binLimpTprong[18]= 2.6;
5053  binLimpTprong[19]= 2.8;
5054  binLimpTprong[20]= 3.0;
5055  binLimpTprong[21]= 3.5;
5056  binLimpTprong[22]= 4.0;
5057  binLimpTprong[23]= 4.5;
5058  binLimpTprong[24]= 5.0;
5059  binLimpTprong[25]= 5.5;
5060  binLimpTprong[26]= 6.0;
5061  binLimpTprong[27]= 6.5;
5062  binLimpTprong[28]= 7.0;
5063  binLimpTprong[29]= 7.5;
5064  binLimpTprong[30]= 8.0;
5065  binLimpTprong[31]= 9.0;
5066  binLimpTprong[32]=10.0;
5067  binLimpTprong[33]=11.0;
5068  binLimpTprong[34]=12.0;
5069  binLimpTprong[35]=13.0;
5070  binLimpTprong[36]=14.0;
5071  binLimpTprong[37]=15.0;
5072  binLimpTprong[38]=20.0;
5073  binLimpTprong[39]=25.0;
5074  binLimpTprong[40]=30.0;
5075  binLimpTprong[41]=35.0;
5076 
5077  if (fUseOnTheFlyV0) {
5078 
5079  nameHistoSgnC="histLcMassByK0SSgnC";
5080  nameHistoSgnB="histLcMassByK0SSgnB";
5081  nameHistoSgnNoQ="histLcMassByK0SSgnNoQ";
5082  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]";
5083  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]";
5084  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]";
5085  TH2F* spectrumLcMassByK0SSgnC = new TH2F(nameHistoSgnC.Data(),titleHistoSgnC.Data(),1000,mLcPDG-0.250,mLcPDG+0.250,11,binLimpTLc);
5086  TH2F* spectrumLcMassByK0SSgnB = new TH2F(nameHistoSgnB.Data(),titleHistoSgnB.Data(),1000,mLcPDG-0.250,mLcPDG+0.250,11,binLimpTLc);
5087  TH2F* spectrumLcMassByK0SSgnNoQ = new TH2F(nameHistoSgnNoQ.Data(),titleHistoSgnNoQ.Data(),1000,mLcPDG-0.250,mLcPDG+0.250,11,binLimpTLc);
5088 
5089  TH2F* allspectrumLcMassByK0SSgnC = (TH2F*)spectrumLcMassByK0SSgnC->Clone();
5090  TH2F* allspectrumLcMassByK0SSgnB = (TH2F*) spectrumLcMassByK0SSgnB->Clone();
5091  TH2F* allspectrumLcMassByK0SSgnNoQ = (TH2F*) spectrumLcMassByK0SSgnNoQ->Clone();
5092  TH2F* pidBachspectrumLcMassByK0SSgnC = (TH2F*)spectrumLcMassByK0SSgnC->Clone();
5093  TH2F* pidBachspectrumLcMassByK0SSgnB = (TH2F*) spectrumLcMassByK0SSgnB->Clone();
5094  TH2F* pidBachspectrumLcMassByK0SSgnNoQ = (TH2F*) spectrumLcMassByK0SSgnNoQ->Clone();
5095 
5096  fOutputAll->Add(allspectrumLcMassByK0SSgnC);
5097  fOutputAll->Add(allspectrumLcMassByK0SSgnB);
5098  fOutputAll->Add(allspectrumLcMassByK0SSgnNoQ);
5099  fOutputPIDBach->Add(pidBachspectrumLcMassByK0SSgnC);
5100  fOutputPIDBach->Add(pidBachspectrumLcMassByK0SSgnB);
5101  fOutputPIDBach->Add(pidBachspectrumLcMassByK0SSgnNoQ);
5102 
5103  nameHistoSgnC="histptK0SSgnC";
5104  nameHistoSgnB="histptK0SSgnB";
5105  nameHistoSgnNoQ="histptK0SSgnNoQ";
5106  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";
5107  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";
5108  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";
5109  TH2F* ptK0SSgnC = new TH2F(nameHistoSgnC.Data(),titleHistoSgnC.Data(),11,binLimpTLc,41,binLimpTprong);
5110  TH2F* ptK0SSgnB = new TH2F(nameHistoSgnB.Data(),titleHistoSgnB.Data(),11,binLimpTLc,41,binLimpTprong);
5111  TH2F* ptK0SSgnNoQ = new TH2F(nameHistoSgnNoQ.Data(),titleHistoSgnNoQ.Data(),11,binLimpTLc,41,binLimpTprong);
5112 
5113  nameHistoSgnC="histptPSgnC";
5114  nameHistoSgnB="histptPSgnB";
5115  nameHistoSgnNoQ="histptPSgnNoQ";
5116  titleHistoSgnC="p_{T}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(p) [GeV/c]; Entries";
5117  titleHistoSgnB="p_{T}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(p) [GeV/c]; Entries";
5118  titleHistoSgnNoQ="p_{T}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(p) [GeV/c]; Entries";
5119  TH2F* ptPSgnC = new TH2F(nameHistoSgnC.Data(),titleHistoSgnC.Data(),11,binLimpTLc,41,binLimpTprong);
5120  TH2F* ptPSgnB = new TH2F(nameHistoSgnB.Data(),titleHistoSgnB.Data(),11,binLimpTLc,41,binLimpTprong);
5121  TH2F* ptPSgnNoQ = new TH2F(nameHistoSgnNoQ.Data(),titleHistoSgnNoQ.Data(),11,binLimpTLc,41,binLimpTprong);
5122 
5123  nameHistoSgnC="histptPipSgnC";
5124  nameHistoSgnB="histptPipSgnB";
5125  nameHistoSgnNoQ="histptPipSgnNoQ";
5126  titleHistoSgnC="p_{T}(#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{+}) [GeV/c]; Entries";
5127  titleHistoSgnB="p_{T}(#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{+}) [GeV/c]; Entries";
5128  titleHistoSgnNoQ="p_{T}(#pi^{+}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{+}) [GeV/c]; Entries";
5129  TH2F* ptPiPSgnC = new TH2F(nameHistoSgnC.Data(),titleHistoSgnC.Data(),11,binLimpTLc,41,binLimpTprong);
5130  TH2F* ptPiPSgnB = new TH2F(nameHistoSgnB.Data(),titleHistoSgnB.Data(),11,binLimpTLc,41,binLimpTprong);
5131  TH2F* ptPiPSgnNoQ = new TH2F(nameHistoSgnNoQ.Data(),titleHistoSgnB.Data(),11,binLimpTLc,41,binLimpTprong);
5132 
5133  nameHistoSgnC="histptPimSgnC";
5134  nameHistoSgnB="histptPimSgnB";
5135  nameHistoSgnNoQ="histptPimSgnNoQ";
5136  titleHistoSgnC="p_{T}(#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{-}) [GeV/c]; Entries";
5137  titleHistoSgnB="p_{T}(#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{-}) [GeV/c]; Entries";
5138  titleHistoSgnNoQ="p_{T}(#pi^{-}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; p_{T}(#pi^{-}) [GeV/c]; Entries";
5139  TH2F* ptPiMSgnC = new TH2F(nameHistoSgnC.Data(),titleHistoSgnC.Data(),11,binLimpTLc,41,binLimpTprong);
5140  TH2F* ptPiMSgnB = new TH2F(nameHistoSgnB.Data(),titleHistoSgnB.Data(),11,binLimpTLc,41,binLimpTprong);
5141  TH2F* ptPiMSgnNoQ = new TH2F(nameHistoSgnNoQ.Data(),titleHistoSgnB.Data(),11,binLimpTLc,41,binLimpTprong);
5142 
5143  nameHistoSgnC="histD0K0SSgnC";
5144  nameHistoSgnB="histD0K0SSgnB";
5145  nameHistoSgnNoQ="histD0K0SSgnNoQ";
5146  titleHistoSgnC="d_{0}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(K^{0}_{S}) [#sigmas]; Entries";
5147  titleHistoSgnB="d_{0}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(K^{0}_{S}) [#sigmas]; Entries";
5148  titleHistoSgnNoQ="d_{0}(K^{0}_{S}) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(K^{0}_{S}) [#sigmas]; Entries";
5149  TH2F* d0K0SSgnC = new TH2F(nameHistoSgnC.Data(),titleHistoSgnC.Data(),11,binLimpTLc,1000,-1.,1.);
5150  TH2F* d0K0SSgnB = new TH2F(nameHistoSgnB.Data(),titleHistoSgnB.Data(),11,binLimpTLc,1000,-1.,1.);
5151  TH2F* d0K0SSgnNoQ = new TH2F(nameHistoSgnNoQ.Data(),titleHistoSgnNoQ.Data(),11,binLimpTLc,1000,-1.,1.);
5152 
5153  nameHistoSgnC="histD0PSgnC";
5154  nameHistoSgnB="histD0PSgnB";
5155  nameHistoSgnNoQ="histD0PSgnNoQ";
5156  titleHistoSgnC="d_{0}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(p) [cm]; Entries";
5157  titleHistoSgnB="d_{0}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(p) [cm]; Entries";
5158  titleHistoSgnNoQ="d_{0}(p) vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; d_{0}(p) [cm]; Entries";
5159  TH2F* d0PSgnC = new TH2F(nameHistoSgnC.Data(),titleHistoSgnC.Data(),11,binLimpTLc,1000,-1.,1.);
5160  TH2F* d0PSgnB = new TH2F(nameHistoSgnB.Data(),titleHistoSgnB.Data(),11,binLimpTLc,1000,-1.,1.);
5161  TH2F* d0PSgnNoQ = new TH2F(nameHistoSgnNoQ.Data(),titleHistoSgnNoQ.Data(),11,binLimpTLc,1000,-1.,1.);
5162 
5163  nameHistoSgnC="histCosPAK0SSgnC";
5164  nameHistoSgnB="histCosPAK0SSgnB";
5165  nameHistoSgnNoQ="histCosPAK0SSgnNoQ";
5166  titleHistoSgnC="K^{0}_{S} cosine of pointing angle wrt primary vertex vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
5167  titleHistoSgnB="K^{0}_{S} cosine of pointing angle wrt primary vertex vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
5168  titleHistoSgnNoQ="K^{0}_{S} cosine of pointing angle wrt primary vertex vs p_{T}(#Lambda_{c}); p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
5169  TH2F *cosPAK0SSgnC = new TH2F(nameHistoSgnC.Data(),titleHistoSgnC.Data(),41,binLimpTprong,100,0.99,1.);
5170  TH2F *cosPAK0SSgnB = new TH2F(nameHistoSgnB.Data(),titleHistoSgnB.Data(),41,binLimpTprong,100,0.99,1.);
5171  TH2F *cosPAK0SSgnNoQ = new TH2F(nameHistoSgnNoQ.Data(),titleHistoSgnNoQ.Data(),41,binLimpTprong,100,0.99,1.);
5172 
5173  nameHistoSgnC="histCosThetaProtonCMSSgnC";
5174  nameHistoSgnB="histCosThetaProtonCMSSgnB";
5175  nameHistoSgnNoQ="histCosThetaProtonCMSSgnNoQ";
5176  titleHistoSgnC="cosien of proton emission angle in Lc rest frame; p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
5177  titleHistoSgnB="cosien of proton emission angle in Lc rest frame; p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
5178  titleHistoSgnNoQ="cosien of proton emission angle in Lc rest frame; p_{T}(#Lambda_{c}) [GeV/c]; cosine; Entries";
5179  TH2F *cosThePrSgnC = new TH2F(nameHistoSgnC.Data(),titleHistoSgnC.Data(),41,binLimpTprong,100,-1.,1.);
5180  TH2F *cosThePrSgnB = new TH2F(nameHistoSgnB.Data(),titleHistoSgnB.Data(),41,binLimpTprong,100,-1.,1.);
5181  TH2F *cosThePrSgnNoQ = new TH2F(nameHistoSgnNoQ.Data(),titleHistoSgnNoQ.Data(),41,binLimpTprong,100,-1.,1.);
5182 
5183  nameHistoSgnC="histResignedD0SgnC";
5184  nameHistoSgnB="histResignedD0SgnB";
5185  nameHistoSgnNoQ="histResignedD0SgnNoQ";
5186  titleHistoSgnC="Proton d0 with different sign convention; p_{T}(#Lambda_{c}) [GeV/c]; d0 [cm]; Entries";
5187  titleHistoSgnB="Proton d0 with different sign convention; p_{T}(#Lambda_{c}) [GeV/c]; d0 [cm]; Entries";
5188  titleHistoSgnNoQ="Proton d0 with different sign convention; p_{T}(#Lambda_{c}) [GeV/c]; d0 [cm]; Entries";
5189  TH2F *resignedD0SgnC = new TH2F(nameHistoSgnC.Data(),titleHistoSgnC.Data(),41,binLimpTprong,100,-0.1,0.1);
5190  TH2F *resignedD0SgnB = new TH2F(nameHistoSgnB.Data(),titleHistoSgnB.Data(),41,binLimpTprong,100,-0.1,0.1);
5191  TH2F *resignedD0SgnNoQ = new TH2F(nameHistoSgnNoQ.Data(),titleHistoSgnNoQ.Data(),41,binLimpTprong,100,-0.1,0.1);
5192 
5193  TH2F* allptK0SSgnC = (TH2F*)ptK0SSgnC->Clone();
5194  TH2F* allptK0SSgnB = (TH2F*)ptK0SSgnB->Clone();
5195  TH2F* allptK0SSgnNoQ = (TH2F*)ptK0SSgnNoQ->Clone();
5196  TH2F* allptPSgnC = (TH2F*)ptPSgnC->Clone();
5197  TH2F* allptPSgnB = (TH2F*)ptPSgnB->Clone();
5198  TH2F* allptPSgnNoQ = (TH2F*)ptPSgnNoQ->Clone();
5199  TH2F* allptPiPSgnC = (TH2F*)ptPiPSgnC->Clone();
5200  TH2F* allptPiPSgnB = (TH2F*)ptPiPSgnB->Clone();
5201  TH2F* allptPiPSgnNoQ = (TH2F*)ptPiPSgnNoQ->Clone();
5202  TH2F* allptPiMSgnC = (TH2F*)ptPiMSgnC->Clone();
5203  TH2F* allptPiMSgnB = (TH2F*)ptPiMSgnB->Clone();
5204  TH2F* allptPiMSgnNoQ = (TH2F*)ptPiMSgnNoQ->Clone();
5205  TH2F* alld0K0SSgnC = (TH2F*)d0K0SSgnC->Clone();
5206  TH2F* alld0K0SSgnB = (TH2F*)d0K0SSgnB->Clone();
5207  TH2F* alld0K0SSgnNoQ = (TH2F*)d0K0SSgnNoQ->Clone();
5208  TH2F* alld0PSgnC = (TH2F*)d0PSgnC->Clone();
5209  TH2F* alld0PSgnB = (TH2F*)d0PSgnB->Clone();
5210  TH2F* alld0PSgnNoQ = (TH2F*)d0PSgnNoQ->Clone();
5211  TH2F* allcosPAK0SSgnC = (TH2F*)cosPAK0SSgnC->Clone();
5212  TH2F* allcosPAK0SSgnB = (TH2F*)cosPAK0SSgnB->Clone();
5213  TH2F* allcosPAK0SSgnNoQ = (TH2F*)cosPAK0SSgnNoQ->Clone();
5214  TH2F* allcosThePrSgnC = (TH2F*)cosThePrSgnC->Clone();
5215  TH2F* allcosThePrSgnB = (TH2F*)cosThePrSgnB->Clone();
5216  TH2F* allcosThePrSgnNoQ = (TH2F*)cosThePrSgnNoQ->Clone();
5217  TH2F* allresignedD0SgnC = (TH2F*)resignedD0SgnC->Clone();
5218  TH2F* allresignedD0SgnB = (TH2F*)resignedD0SgnB->Clone();
5219  TH2F* allresignedD0SgnNoQ = (TH2F*)resignedD0SgnNoQ->Clone();
5220 
5221  TH2F* pidptK0SSgnC = (TH2F*)ptK0SSgnC->Clone();
5222  TH2F* pidptK0SSgnB = (TH2F*)ptK0SSgnB->Clone();
5223  TH2F* pidptK0SSgnNoQ = (TH2F*)ptK0SSgnNoQ->Clone();
5224  TH2F* pidptPSgnC = (TH2F*)ptPSgnC->Clone();
5225  TH2F* pidptPSgnB = (TH2F*)ptPSgnB->Clone();
5226  TH2F* pidptPSgnNoQ = (TH2F*)ptPSgnNoQ->Clone();
5227  TH2F* pidptPiPSgnC = (TH2F*)ptPiPSgnC->Clone();
5228  TH2F* pidptPiPSgnB = (TH2F*)ptPiPSgnB->Clone();
5229  TH2F* pidptPiPSgnNoQ = (TH2F*)ptPiPSgnNoQ->Clone();
5230  TH2F* pidptPiMSgnC = (TH2F*)ptPiMSgnC->Clone();
5231  TH2F* pidptPiMSgnB = (TH2F*)ptPiMSgnB->Clone();
5232  TH2F* pidptPiMSgnNoQ = (TH2F*)ptPiMSgnNoQ->Clone();
5233  TH2F* pidd0K0SSgnC = (TH2F*)d0K0SSgnC->Clone();
5234  TH2F* pidd0K0SSgnB = (TH2F*)d0K0SSgnB->Clone();
5235  TH2F* pidd0K0SSgnNoQ = (TH2F*)d0K0SSgnNoQ->Clone();
5236  TH2F* pidd0PSgnC = (TH2F*)d0PSgnC->Clone();
5237  TH2F* pidd0PSgnB = (TH2F*)d0PSgnB->Clone();
5238  TH2F* pidd0PSgnNoQ = (TH2F*)d0PSgnNoQ->Clone();
5239  TH2F* pidcosPAK0SSgnC = (TH2F*)cosPAK0SSgnC->Clone();
5240  TH2F* pidcosPAK0SSgnB = (TH2F*)cosPAK0SSgnB->Clone();
5241  TH2F* pidcosPAK0SSgnNoQ = (TH2F*)cosPAK0SSgnNoQ->Clone();
5242  TH2F* pidcosThePrSgnC = (TH2F*)cosThePrSgnC->Clone();
5243  TH2F* pidcosThePrSgnB = (TH2F*)cosThePrSgnB->Clone();
5244  TH2F* pidcosThePrSgnNoQ = (TH2F*)cosThePrSgnNoQ->Clone();
5245  TH2F* pidresignedD0SgnC = (TH2F*)resignedD0SgnC->Clone();
5246