AliPhysics  vAN-20150827 (3e81cbb)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
AliAnalysisTaskSELc2V0bachelorTMVA.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: AliAnalysisTaskSELc2V0bachelorTMVA.cxx 62231 2013-04-29 09:47:26Z fprino $ */
17 
18 //
19 //
20 // Base class for Lc2V0 Analysis to be used with TMVA
21 //
22 //
23 
24 //------------------------------------------------------------------------------------------
25 //
26 // Author: C. Zampolli (from AliAnalysisTaskSELc2V0bachelor class by A.De Caro, P. Pagano)
27 //
28 //------------------------------------------------------------------------------------------
29 
30 #include <TSystem.h>
31 #include <TParticle.h>
32 #include <TParticlePDG.h>
33 #include <TH1F.h>
34 #include <TH1I.h>
35 #include <TH2F.h>
36 #include <TTree.h>
37 #include "TROOT.h"
38 #include <TDatabasePDG.h>
39 #include "TVector3.h"
40 
41 #include <AliAnalysisDataSlot.h>
42 #include <AliAnalysisDataContainer.h>
43 #include "AliStack.h"
44 #include "AliMCEvent.h"
45 #include "AliAnalysisManager.h"
46 #include "AliAODMCHeader.h"
47 #include "AliAODHandler.h"
48 #include "AliLog.h"
49 #include "AliAODVertex.h"
50 #include "AliAODRecoDecay.h"
51 #include "AliAODRecoDecayHF.h"
52 #include "AliAODRecoCascadeHF.h"
53 #include "AliAnalysisVertexingHF.h"
54 #include "AliESDtrack.h"
55 #include "AliAODTrack.h"
56 #include "AliAODv0.h"
57 #include "AliAODMCParticle.h"
58 #include "AliAnalysisTaskSE.h"
61 #include "AliAODPidHF.h"
62 #include "AliPIDResponse.h"
63 #include "AliPIDCombined.h"
64 #include "AliTOFPIDResponse.h"
65 #include "AliInputEventHandler.h"
67 #include "AliKFParticle.h"
68 #include "AliKFVertex.h"
69 #include "AliExternalTrackParam.h"
70 #include "AliESDtrack.h"
71 
72 using std::cout;
73 using std::endl;
74 
78 
79 //__________________________________________________________________________
81 AliAnalysisTaskSE(),
82  fUseMCInfo(kFALSE),
83  fOutput(0),
84  fCEvents(0),
85  fPIDResponse(0),
86  fPIDCombined(0),
87  fIsK0sAnalysis(kFALSE),
88  fCounter(0),
89  fAnalCuts(0),
90  fListCuts(0),
91  fUseOnTheFlyV0(kFALSE),
92  fIsEventSelected(kFALSE),
93  fVariablesTreeSgn(0),
94  fVariablesTreeBkg(0),
95  fCandidateVariables(),
96  fIspA(kFALSE),
97  fHistoEvents(0),
98  fHistoLc(0),
99  fHistoLcOnTheFly(0),
100  fFillOnlySgn(kFALSE),
101  fHistoLcBeforeCuts(0),
102  fHistoFiducialAcceptance(0),
103  fHistoCodesSgn(0),
104  fHistoCodesBkg(0),
105  fHistoLcpKpiBeforeCuts(0),
106  fVtx1(0),
107 
108  fHistoDistanceLcToPrimVtx(0),
109  fHistoDistanceV0ToPrimVtx(0),
110  fHistoDistanceV0ToLc(0),
111 
112  fHistoDistanceLcToPrimVtxSgn(0),
113  fHistoDistanceV0ToPrimVtxSgn(0),
114  fHistoDistanceV0ToLcSgn(0),
115 
116  fHistoVtxLcResidualToPrimVtx(0),
117  fHistoVtxV0ResidualToPrimVtx(0),
118  fHistoVtxV0ResidualToLc(0),
119 
120  fHistoMassV0All(0),
121  fHistoDecayLengthV0All(0),
122  fHistoLifeTimeV0All(0),
123 
124  fHistoMassV0True(0),
125  fHistoDecayLengthV0True(0),
126  fHistoLifeTimeV0True(0),
127 
128  fHistoMassV0TrueFromAOD(0),
129 
130  fHistoMassV0TrueK0S(0),
131  fHistoDecayLengthV0TrueK0S(0),
132  fHistoLifeTimeV0TrueK0S(0),
133 
134  fHistoMassV0TrueK0SFromAOD(0),
135 
136  fHistoMassLcAll(0),
137  fHistoDecayLengthLcAll(0),
138  fHistoLifeTimeLcAll(0),
139 
140  fHistoMassLcTrue(0),
141  fHistoDecayLengthLcTrue(0),
142  fHistoLifeTimeLcTrue(0),
143 
144  fHistoMassLcTrueFromAOD(0),
145 
146  fHistoMassV0fromLcAll(0),
147  fHistoDecayLengthV0fromLcAll(0),
148  fHistoLifeTimeV0fromLcAll(0),
149 
150  fHistoMassV0fromLcTrue(0),
151  fHistoDecayLengthV0fromLcTrue(0),
152  fHistoLifeTimeV0fromLcTrue(0),
153 
154  fHistoMassLcSgn(0),
155  fHistoMassLcSgnFromAOD(0),
156  fHistoDecayLengthLcSgn(0),
157  fHistoLifeTimeLcSgn(0),
158 
159  fHistoMassV0fromLcSgn(0),
160  fHistoDecayLengthV0fromLcSgn(0),
161  fHistoLifeTimeV0fromLcSgn(0),
162 
163  fHistoKF(0),
164  fHistoKFV0(0),
165  fHistoKFLc(0),
166 
167  fHistoMassKFV0(0),
168  fHistoDecayLengthKFV0(0),
169  fHistoLifeTimeKFV0(0),
170 
171  fHistoMassKFLc(0),
172  fHistoDecayLengthKFLc(0),
173  fHistoLifeTimeKFLc(0),
174 
175  fHistoArmenterosPodolanskiV0KF(0),
176  fHistoArmenterosPodolanskiV0KFSgn(0),
177  fHistoArmenterosPodolanskiV0AOD(0),
178  fHistoArmenterosPodolanskiV0AODSgn(0),
179 
180  fOutputKF(0),
181  fmcLabelLc(-1),
182  ftopoConstraint(kTRUE),
183  fCallKFVertexing(kFALSE),
184  fKeepingOnlyHIJINGBkg(kFALSE),
185  fUtils(0),
186  fHistoBackground(0),
187  fCutKFChi2NDF(999999.),
188  fCutKFDeviationFromVtx(999999.),
189  fCutKFDeviationFromVtxV0(0.),
190  fCurrentEvent(-1),
191  fBField(0),
192  fKeepingOnlyPYTHIABkg(kFALSE),
193  fHistoMCLcK0SpGen(0x0),
194  fHistoMCLcK0SpGenAcc(0x0),
195  fHistoMCLcK0SpGenLimAcc(0x0),
196  fTriggerMask(0)
197 {
198  //
200  //
201 }
202 //___________________________________________________________________________
204  AliRDHFCutsLctoV0* analCuts, Bool_t useOnTheFly) :
205  AliAnalysisTaskSE(name),
206  fUseMCInfo(kFALSE),
207  fOutput(0),
208  fCEvents(0),
209  fPIDResponse(0),
210  fPIDCombined(0),
211  fIsK0sAnalysis(kFALSE),
212  fCounter(0),
213  fAnalCuts(analCuts),
214  fListCuts(0),
215  fUseOnTheFlyV0(useOnTheFly),
216  fIsEventSelected(kFALSE),
217  fVariablesTreeSgn(0),
218  fVariablesTreeBkg(0),
219  fCandidateVariables(),
220  fIspA(kFALSE),
221  fHistoEvents(0),
222  fHistoLc(0),
223  fHistoLcOnTheFly(0),
224  fFillOnlySgn(kFALSE),
225  fHistoLcBeforeCuts(0),
226  fHistoFiducialAcceptance(0),
227  fHistoCodesSgn(0),
228  fHistoCodesBkg(0),
229  fHistoLcpKpiBeforeCuts(0),
230  fVtx1(0),
231 
232  fHistoDistanceLcToPrimVtx(0),
233  fHistoDistanceV0ToPrimVtx(0),
234  fHistoDistanceV0ToLc(0),
235 
236  fHistoDistanceLcToPrimVtxSgn(0),
237  fHistoDistanceV0ToPrimVtxSgn(0),
238  fHistoDistanceV0ToLcSgn(0),
239 
240  fHistoVtxLcResidualToPrimVtx(0),
241  fHistoVtxV0ResidualToPrimVtx(0),
242  fHistoVtxV0ResidualToLc(0),
243 
244  fHistoMassV0All(0),
245  fHistoDecayLengthV0All(0),
246  fHistoLifeTimeV0All(0),
247 
248  fHistoMassV0True(0),
249  fHistoDecayLengthV0True(0),
250  fHistoLifeTimeV0True(0),
251 
252  fHistoMassV0TrueFromAOD(0),
253 
254  fHistoMassV0TrueK0S(0),
255  fHistoDecayLengthV0TrueK0S(0),
256  fHistoLifeTimeV0TrueK0S(0),
257 
258  fHistoMassV0TrueK0SFromAOD(0),
259 
260  fHistoMassLcAll(0),
261  fHistoDecayLengthLcAll(0),
262  fHistoLifeTimeLcAll(0),
263 
264  fHistoMassLcTrue(0),
265  fHistoDecayLengthLcTrue(0),
266  fHistoLifeTimeLcTrue(0),
267 
268  fHistoMassLcTrueFromAOD(0),
269 
270  fHistoMassV0fromLcAll(0),
271  fHistoDecayLengthV0fromLcAll(0),
272  fHistoLifeTimeV0fromLcAll(0),
273 
274  fHistoMassV0fromLcTrue(0),
275  fHistoDecayLengthV0fromLcTrue(0),
276  fHistoLifeTimeV0fromLcTrue(0),
277 
278  fHistoMassLcSgn(0),
279  fHistoMassLcSgnFromAOD(0),
280  fHistoDecayLengthLcSgn(0),
281  fHistoLifeTimeLcSgn(0),
282 
283  fHistoMassV0fromLcSgn(0),
284  fHistoDecayLengthV0fromLcSgn(0),
285  fHistoLifeTimeV0fromLcSgn(0),
286 
287  fHistoKF(0),
288  fHistoKFV0(0),
289  fHistoKFLc(0),
290 
291  fHistoMassKFV0(0),
292  fHistoDecayLengthKFV0(0),
293  fHistoLifeTimeKFV0(0),
294 
295  fHistoMassKFLc(0),
296  fHistoDecayLengthKFLc(0),
297  fHistoLifeTimeKFLc(0),
298 
299  fHistoArmenterosPodolanskiV0KF(0),
300  fHistoArmenterosPodolanskiV0KFSgn(0),
301  fHistoArmenterosPodolanskiV0AOD(0),
302  fHistoArmenterosPodolanskiV0AODSgn(0),
303 
304  fOutputKF(0),
305  fmcLabelLc(-1),
306  ftopoConstraint(kTRUE),
307  fCallKFVertexing(kFALSE),
308  fKeepingOnlyHIJINGBkg(kFALSE),
309  fUtils(0),
310  fHistoBackground(0),
311  fCutKFChi2NDF(999999.),
312  fCutKFDeviationFromVtx(999999.),
313  fCutKFDeviationFromVtxV0(0.),
314  fCurrentEvent(-1),
315  fBField(0),
316  fKeepingOnlyPYTHIABkg(kFALSE),
317  fHistoMCLcK0SpGen(0x0),
318  fHistoMCLcK0SpGenAcc(0x0),
319  fHistoMCLcK0SpGenLimAcc(0x0),
320  fTriggerMask(0)
321 {
322  //
324  //
325  Info("AliAnalysisTaskSELc2V0bachelorTMVA","Calling Constructor");
326 
327  DefineOutput(1, TList::Class()); // Tree signal + Tree Bkg + histoEvents
328  DefineOutput(2, AliNormalizationCounter::Class()); // normalization counter object
329  DefineOutput(3, TList::Class()); // Cuts
330  DefineOutput(4, TTree::Class()); // Tree signal + Tree Bkg + histoEvents
331  DefineOutput(5, TTree::Class()); // Tree signal + Tree Bkg + histoEvents
332  DefineOutput(6, TList::Class()); // Tree signal + Tree Bkg + histoEvents
333 
334 }
335 
336 //___________________________________________________________________________
338  //
340  //
341  Info("~AliAnalysisTaskSELc2V0bachelorTMVA","Calling Destructor");
342 
343  if (fOutput) {
344  delete fOutput;
345  fOutput = 0;
346  }
347 
348  if (fPIDResponse) {
349  delete fPIDResponse;
350  }
351 
352  if (fPIDCombined) {
353  delete fPIDCombined;
354  }
355 
356  if (fCounter) {
357  delete fCounter;
358  fCounter = 0;
359  }
360 
361  if (fAnalCuts) {
362  delete fAnalCuts;
363  fAnalCuts = 0;
364  }
365 
366  if (fListCuts) {
367  delete fListCuts;
368  fListCuts = 0;
369  }
370 
371  if(fVariablesTreeSgn){
372  delete fVariablesTreeSgn;
373  fVariablesTreeSgn = 0;
374  }
375 
376  if(fVariablesTreeBkg){
377  delete fVariablesTreeBkg;
378  fVariablesTreeBkg = 0;
379  }
380 
381  if (fOutputKF) {
382  delete fOutputKF;
383  fOutputKF = 0;
384  }
385 
386  if (fUtils) {
387  delete fUtils;
388  fUtils = 0;
389  }
390 
391 }
392 //_________________________________________________
394  //
396  //
397 
398  fIsEventSelected=kFALSE;
399 
400  if (fDebug > 1) AliInfo("Init");
401 
402  fListCuts = new TList();
403  fListCuts->SetOwner();
405  PostData(3,fListCuts);
406 
408 
409  return;
410 }
411 
412 //________________________________________ terminate ___________________________
414 {
418 
419  AliInfo("Terminate");
420  AliAnalysisTaskSE::Terminate();
421 
422  fOutput = dynamic_cast<TList*> (GetOutputData(1));
423  if (!fOutput) {
424  AliError("fOutput not available");
425  return;
426  }
427 
428 
429  //AliDebug(2, Form("At MC level, %f Lc --> K0S + p were found", fHistoMCLcK0SpGen->GetEntries()));
430  //AliDebug(2, Form("At MC level, %f Lc --> K0S + p were found in the acceptance", fHistoMCLcK0SpGenAcc->GetEntries()));
431  //AliDebug(2, Form("At Reco level, %lld Lc --> K0S + p were found", fVariablesTreeSgn->GetEntries()));
432  if(fHistoMCLcK0SpGen) {
433  AliInfo(Form("At MC level, %f Lc --> K0S + p were found", fHistoMCLcK0SpGen->GetEntries()));
434  } else {
435  AliInfo("fHistoMCLcK0SpGen not available");
436  }
438  AliInfo(Form("At MC level, %f Lc --> K0S + p were found in the acceptance", fHistoMCLcK0SpGenAcc->GetEntries()));
439  } else {
440  AliInfo("fHistoMCLcK0SpGenAcc not available");
441  }
442  if(fVariablesTreeSgn) {
443  AliInfo(Form("At Reco level, %lld Lc --> K0S + p were found", fVariablesTreeSgn->GetEntries()));
444  } else {
445  AliInfo("fVariablesTreeSgn not available");
446  }
447 
448  fOutputKF = dynamic_cast<TList*> (GetOutputData(6));
449  if (!fOutputKF) {
450  AliError("fOutputKF not available");
451  return;
452  }
453 
454  return;
455 }
456 
457 //___________________________________________________________________________
460  AliInfo(Form("CreateOutputObjects of task %s\n", GetName()));
461 
462  //slot #1
463  //OpenFile(1);
464  fOutput = new TList();
465  fOutput->SetOwner();
466  fOutput->SetName("listTrees");
467 
468  // Output slot 1: list of 2 trees (Sgn + Bkg) of the candidate variables
469  const char* nameoutput = GetOutputSlot(1)->GetContainer()->GetName();
470  fVariablesTreeSgn = new TTree(Form("%s_Sgn", nameoutput), "Candidates variables tree, Signal");
471  fVariablesTreeBkg = new TTree(Form("%s_Bkg", nameoutput), "Candidates variables tree, Background");
472  Int_t nVar = 86;
473  fCandidateVariables = new Float_t [nVar];
474  TString * fCandidateVariableNames = new TString[nVar];
475  fCandidateVariableNames[0]="massLc2K0Sp";
476  fCandidateVariableNames[1]="massLc2Lambdapi";
477  fCandidateVariableNames[2]="massK0S";
478  fCandidateVariableNames[3]="massLambda";
479  fCandidateVariableNames[4]="massLambdaBar";
480  fCandidateVariableNames[5]="cosPAK0S";
481  fCandidateVariableNames[6]="dcaV0";
482  fCandidateVariableNames[7]="tImpParBach";
483  fCandidateVariableNames[8]="tImpParV0";
484  fCandidateVariableNames[9]="nSigmaTPCpr";
485  fCandidateVariableNames[10]="nSigmaTPCpi";
486  fCandidateVariableNames[11]="nSigmaTPCka";
487  fCandidateVariableNames[12]="nSigmaTOFpr";
488  fCandidateVariableNames[13]="nSigmaTOFpi";
489  fCandidateVariableNames[14]="nSigmaTOFka";
490  fCandidateVariableNames[15]="bachelorPt";
491  fCandidateVariableNames[16]="V0positivePt";
492  fCandidateVariableNames[17]="V0negativePt";
493  fCandidateVariableNames[18]="dcaV0pos";
494  fCandidateVariableNames[19]="dcaV0neg";
495  fCandidateVariableNames[20]="v0Pt";
496  fCandidateVariableNames[21]="massGamma";
497  fCandidateVariableNames[22]="LcPt";
498  fCandidateVariableNames[23]="combinedProtonProb";
499  fCandidateVariableNames[24]="LcEta";
500  fCandidateVariableNames[25]="V0positiveEta";
501  fCandidateVariableNames[26]="V0negativeEta";
502  fCandidateVariableNames[27]="TPCProtonProb";
503  fCandidateVariableNames[28]="TOFProtonProb";
504  fCandidateVariableNames[29]="bachelorEta";
505  fCandidateVariableNames[30]="LcP";
506  fCandidateVariableNames[31]="bachelorP";
507  fCandidateVariableNames[32]="v0P";
508  fCandidateVariableNames[33]="V0positiveP";
509  fCandidateVariableNames[34]="V0negativeP";
510  fCandidateVariableNames[35]="LcY";
511  fCandidateVariableNames[36]="v0Y";
512  fCandidateVariableNames[37]="bachelorY";
513  fCandidateVariableNames[38]="V0positiveY";
514  fCandidateVariableNames[39]="V0negativeY";
515  fCandidateVariableNames[40]="v0Eta";
516  fCandidateVariableNames[41]="DecayLengthLc";
517  fCandidateVariableNames[42]="DecayLengthK0S";
518  fCandidateVariableNames[43]="CtLc";
519  fCandidateVariableNames[44]="CtK0S";
520  fCandidateVariableNames[45]="bachCode";
521  fCandidateVariableNames[46]="k0SCode";
522 
523  fCandidateVariableNames[47]="V0KFmass";
524  fCandidateVariableNames[48]="V0KFdecayLength";
525  fCandidateVariableNames[49]="V0KFlifeTime";
526 
527  fCandidateVariableNames[50]="V0KFmassErr";
528  fCandidateVariableNames[51]="V0KFdecayTimeErr";
529  fCandidateVariableNames[52]="V0KFlifeTimeErr";
530 
531  fCandidateVariableNames[53]="LcKFmass";
532  fCandidateVariableNames[54]="LcKFdecayLength";
533  fCandidateVariableNames[55]="LcKFlifeTime";
534 
535  fCandidateVariableNames[56]="LcKFmassErr";
536  fCandidateVariableNames[57]="LcKFdecayTimeErr";
537  fCandidateVariableNames[58]="LcKFlifeTimeErr";
538 
539  fCandidateVariableNames[59]="LcKFDistToPrimVtx";
540  fCandidateVariableNames[60]="V0KFDistToPrimVtx";
541  fCandidateVariableNames[61]="V0KFDistToLc";
542  fCandidateVariableNames[62]="alphaArmKF";
543  fCandidateVariableNames[63]="ptArmKF";
544  fCandidateVariableNames[64]="alphaArm";
545  fCandidateVariableNames[65]="ptArm";
546 
547  fCandidateVariableNames[66]="ITSrefitV0pos";
548  fCandidateVariableNames[67]="ITSrefitV0neg";
549 
550  fCandidateVariableNames[68]="TPCClV0pos";
551  fCandidateVariableNames[69]="TPCClV0neg";
552 
553  fCandidateVariableNames[70]="v0Xcoord";
554  fCandidateVariableNames[71]="v0Ycoord";
555  fCandidateVariableNames[72]="v0Zcoord";
556  fCandidateVariableNames[73]="primVtxX";
557  fCandidateVariableNames[74]="primVtxY";
558  fCandidateVariableNames[75]="primVtxZ";
559 
560  fCandidateVariableNames[76]="ITSclBach";
561  fCandidateVariableNames[77]="SPDclBach";
562 
563  fCandidateVariableNames[78]="ITSclV0pos";
564  fCandidateVariableNames[79]="SPDclV0pos";
565  fCandidateVariableNames[80]="ITSclV0neg";
566  fCandidateVariableNames[81]="SPDclV0neg";
567 
568  fCandidateVariableNames[82]="alphaArmLc";
569  fCandidateVariableNames[83]="alphaArmLcCharge";
570  fCandidateVariableNames[84]="ptArmLc";
571 
572  fCandidateVariableNames[85]="CosThetaStar";
573 
574 
575  for(Int_t ivar=0; ivar<nVar; ivar++){
576  fVariablesTreeSgn->Branch(fCandidateVariableNames[ivar].Data(),&fCandidateVariables[ivar],Form("%s/f",fCandidateVariableNames[ivar].Data()));
577  fVariablesTreeBkg->Branch(fCandidateVariableNames[ivar].Data(),&fCandidateVariables[ivar],Form("%s/f",fCandidateVariableNames[ivar].Data()));
578  }
579 
580  fHistoEvents = new TH1F("fHistoEvents", "fHistoEvents", 2, -0.5, 1.5);
581  TString labelEv[2] = {"NotSelected", "Selected"};
582  for (Int_t ibin = 1; ibin <= fHistoEvents->GetNbinsX(); ibin++){
583  fHistoEvents->GetXaxis()->SetBinLabel(ibin, labelEv[ibin-1].Data());
584  }
585 
586  fHistoLc = new TH1F("fHistoLc", "fHistoLc", 2, -0.5, 1.5);
587 
588  fHistoLcOnTheFly = new TH1F("fHistoLcOnTheFly", "fHistoLcOnTheFly", 4, -0.5, 3.5);
589  TString labelOnTheFly[4] = {"OnTheFly-Bkg", "OfflineBkg", "OnTheFly-Sgn", "OfflineSgn"};
590  for (Int_t ibin = 1; ibin <= fHistoLcOnTheFly->GetNbinsX(); ibin++){
591  fHistoLcOnTheFly->GetXaxis()->SetBinLabel(ibin, labelOnTheFly[ibin-1].Data());
592  }
593 
594  fHistoLcBeforeCuts = new TH1F("fHistoLcBeforeCuts", "fHistoLcBeforeCuts", 2, -0.5, 1.5);
595  TString labelBeforeCuts[2] = {"Bkg", "Sgn"};
596  for (Int_t ibin = 1; ibin <= fHistoLcBeforeCuts->GetNbinsX(); ibin++){
597  fHistoLcBeforeCuts->GetXaxis()->SetBinLabel(ibin, labelBeforeCuts[ibin-1].Data());
598  fHistoLc->GetXaxis()->SetBinLabel(ibin, labelBeforeCuts[ibin-1].Data());
599  }
600 
601  fHistoFiducialAcceptance = new TH1F("fHistoFiducialAcceptance", "fHistoFiducialAcceptance", 4, -0.5, 3.5);
602  TString labelAcc[4] = {"NotOk-Bkg", "Ok-Bkg", "NotOk-Sgn", "Ok-Sgn"};
603  for (Int_t ibin = 1; ibin <= fHistoFiducialAcceptance->GetNbinsX(); ibin++){
604  fHistoFiducialAcceptance->GetXaxis()->SetBinLabel(ibin, labelAcc[ibin-1].Data());
605  }
606 
607  fHistoCodesSgn = new TH2F("fHistoCodesSgn", "fHistoCodes for Signal; bachelor; K0S", 7, -1.5, 5.5, 9, -1.5, 7.5);
608  fHistoCodesBkg = new TH2F("fHistoCodesBkg", "fHistoCodes for Background; bachelor; K0S", 7, -1.5, 5.5, 9, -1.5, 7.5);
609 
610  TString labelx[7] = { "kBachInvalid", "kBachFake", "kBachNoProton", "kBachPrimary", "kBachNoLambdaMother",
611  "kBachDifferentLambdaMother", "kBachCorrectLambdaMother"};
612  TString labely[9] = { "kK0SInvalid", "kK0SFake", "kK0SNoK0S", "kK0SWithoutMother", "kK0SNotFromK0",
613  "kK0Primary", "kK0NoLambdaMother", "kK0DifferentLambdaMother", "kK0CorrectLambdaMother"};
614 
615  for (Int_t ibin = 1; ibin <= fHistoCodesSgn->GetNbinsX(); ibin++){
616  fHistoCodesSgn->GetXaxis()->SetBinLabel(ibin, labelx[ibin-1].Data());
617  fHistoCodesBkg->GetXaxis()->SetBinLabel(ibin, labelx[ibin-1].Data());
618  }
619  for (Int_t ibin = 1; ibin <= fHistoCodesSgn->GetNbinsY(); ibin++){
620  fHistoCodesSgn->GetYaxis()->SetBinLabel(ibin, labely[ibin-1].Data());
621  fHistoCodesBkg->GetYaxis()->SetBinLabel(ibin, labely[ibin-1].Data());
622  }
623 
624  fHistoLcpKpiBeforeCuts = new TH1F("fHistoLcpKpiBeforeCuts", "fHistoLcpKpiBeforeCuts", 2, -0.5, 1.5);
625  for (Int_t ibin = 1; ibin <= fHistoLcpKpiBeforeCuts->GetNbinsX(); ibin++){
626  fHistoLcpKpiBeforeCuts->GetXaxis()->SetBinLabel(ibin, labelBeforeCuts[ibin-1].Data());
627  }
628 
629  fHistoBackground = new TH1F("fHistoBackground", "fHistoBackground", 4, -0.5, 3.5);
630  TString labelBkg[4] = {"Injected", "Non-injected", "Non-PYTHIA", "PYTHIA"};
631  for (Int_t ibin = 1; ibin <= fHistoBackground->GetNbinsX(); ibin++){
632  fHistoBackground->GetXaxis()->SetBinLabel(ibin, labelBkg[ibin-1].Data());
633  }
634 
635  //fOutput->Add(fVariablesTreeSgn);
636  //fOutput->Add(fVariablesTreeBkg);
637 
638  const Float_t ptbins[15] = {0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 12., 17., 25., 35.};
639 
640  fHistoMCLcK0SpGen = new TH1F("fHistoMCLcK0SpGen", "fHistoMCLcK0SpGen", 14, ptbins);
641  fHistoMCLcK0SpGenAcc = new TH1F("fHistoMCLcK0SpGenAcc", "fHistoMCLcK0SpGenAcc", 14, ptbins);
642  fHistoMCLcK0SpGenLimAcc = new TH1F("fHistoMCLcK0SpGenLimAcc", "fHistoMCLcK0SpGenLimAcc", 14, ptbins);
643 
644  fOutput->Add(fHistoEvents);
645  fOutput->Add(fHistoLc);
649  fOutput->Add(fHistoCodesSgn);
650  fOutput->Add(fHistoCodesBkg);
656 
657  PostData(1, fOutput);
658  PostData(4, fVariablesTreeSgn);
659  PostData(5, fVariablesTreeBkg);
660  AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
661  AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
662  fPIDResponse = inputHandler->GetPIDResponse();
663 
664  if (fAnalCuts->GetIsUsePID()){
665  /*
666  fAnalCuts->GetPidHF()->SetPidResponse(fPIDResponse);
667  fAnalCuts->GetPidV0pos()->SetPidResponse(fPIDResponse);
668  fAnalCuts->GetPidV0neg()->SetPidResponse(fPIDResponse);
669  fAnalCuts->GetPidHF()->SetOldPid(kFALSE);
670  fAnalCuts->GetPidV0pos()->SetOldPid(kFALSE);
671  fAnalCuts->GetPidV0neg()->SetOldPid(kFALSE);
672  */
673  fAnalCuts->SetUsePID(kFALSE); // I don't want to use the PID through the cut object, but I will use the PID response directly!!!
674  }
675 
676  // Setting properties of PID
677  fPIDCombined=new AliPIDCombined;
678  fPIDCombined->SetDefaultTPCPriors();
679  fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTPC+AliPIDResponse::kDetTOF);
680  //fPIDCombined->SetPriorDistribution((AliPID::EParticleType)ispec,fPriors[ispec]);
681 
682  fCounter = new AliNormalizationCounter("NormalizationCounter");
683  fCounter->Init();
684  PostData(2, fCounter);
685 
686  // Histograms from KF
687 
688  if (fCallKFVertexing){
689  fHistoDistanceLcToPrimVtx = new TH1D("fHistoDistanceLcToPrimVtx", "Lc distance to Prim Vertex from KF; distance [cm]", 1000, 0., 1);
690  fHistoDistanceV0ToPrimVtx = new TH1D("fHistoDistanceV0ToPrimVtx", "V0 distance to Prim Vertex from KF; distance [cm]", 1000, 0., 100.);
691  fHistoDistanceV0ToLc = new TH1D("fHistoDistanceV0ToLc", "V0 distance to Lc Vertex from KF; distance [cm]", 1000, 0., 100.);
692 
693  fHistoDistanceLcToPrimVtxSgn = new TH1D("fHistoDistanceLcToPrimVtxSgn", "Lc Sgn distance to Prim Vertex from KF; distance [cm]", 1000, 0., 1);
694  fHistoDistanceV0ToPrimVtxSgn = new TH1D("fHistoDistanceV0ToPrimVtxSgn", "V0 Sgn distance to Prim Vertex from KF; distance [cm]", 1000, 0., 100.);
695  fHistoDistanceV0ToLcSgn = new TH1D("fHistoDistanceV0ToLcSgn", "V0 Sgn distance to Lc Vertex from KF; distance [cm]", 1000, 0., 100.);
696 
697  fHistoVtxLcResidualToPrimVtx = new TH1D("fHistoVtxLcResidualToPrimVtx", "Residual between MC and KF (MC - KF): Lc to Prim Vtx; distance [cm]", 1000, -5., 5.);
698  fHistoVtxV0ResidualToPrimVtx = new TH1D("fHistoVtxV0ResidualToPrimVtx", "Residual between MC and KF (MC - KF): V0 to Prim Vtx; distance [cm]", 1000, -5., 5.);
699  fHistoVtxV0ResidualToLc = new TH1D("fHistoVtxV0ResidualToLc", "Residual between MC and KF: V0 to Lc (MC - KF); distance [cm]", 1000, -5., 5.);
700 
701  fHistoMassV0All = new TH1D("fHistoMassV0All", "V0 Mass; mass", 500, 0.4, 0.6);
702  fHistoDecayLengthV0All = new TH1D("fHistoDecayLengthV0All", "V0 Decay Length; decayLength", 500, -10, 10.0);
703  fHistoLifeTimeV0All = new TH1D("fHistoLifeTimeV0All", "V0 Life Time; lifeTime", 500, -10.0, 10.0);
704 
705  fHistoMassV0True = new TH1D("fHistoMassV0True", "True V0 Mass; mass", 500, 0.4, 0.6);
706  fHistoDecayLengthV0True = new TH1D("fHistoDecayLengthV0True", "True V0 Decay Length; decayLength", 500, -10, 10.0);
707  fHistoLifeTimeV0True = new TH1D("fHistoLifeTimeV0True", "True V0 Life Time; lifeTime", 500, -10.0, 10.0);
708 
709  fHistoMassV0TrueFromAOD = new TH1D("fHistoMassV0TrueFormAOD", "True V0 Mass (AOD); mass", 500, 0.4, 0.6);
710 
711  fHistoMassV0TrueK0S = new TH1D("fHistoMassV0TrueK0S", "True V0-K0S Mass; mass", 500, 0.4, 0.6);
712  fHistoDecayLengthV0TrueK0S = new TH1D("fHistoDecayLengthV0TrueK0S", "True V0-K0S Decay Length; decayLength", 500, -10, 10.0);
713  fHistoLifeTimeV0TrueK0S = new TH1D("fHistoLifeTimeV0TrueK0S", "True V0-K0S Life Time; lifeTime", 500, -10.0, 10.0);
714 
715  fHistoMassV0TrueK0SFromAOD = new TH1D("fHistoMassV0TrueK0SFormAOD", "True V0-K0S Mass (AOD); mass", 500, 0.4, 0.6);
716 
717  fHistoMassLcAll = new TH1D("fHistoMassLcAll", "Lc Mass; mass", 500, 2.0, 3.0);
718  fHistoDecayLengthLcAll = new TH1D("fHistoDecayLengthLcAll", "Lc Decay Length; decayLenght", 100000, -0.1, 0.1);
719  fHistoLifeTimeLcAll = new TH1D("fHistoLifeTimeLcAll", "Lc Life Time; lifeTime", 100000, -0.1, 0.1);
720 
721  fHistoMassLcTrue = new TH1D("fHistoMassLcTrue", "True Lc Mass; mass", 500, 2.0, 3.0);
722  fHistoDecayLengthLcTrue = new TH1D("fHistoDecayLengthLcTrue", "True Lc Decay Length; decayLength", 100000, -0.1, 0.1);
723  fHistoLifeTimeLcTrue = new TH1D("fHistoLifeTimeLcTrue", "True Lc Life Time; lifeTime", 100000, -0.1, 0.1);
724 
725  fHistoMassLcTrueFromAOD = new TH1D("fHistoMassLcTrueFromAOD", "True Lc Mass (AOD); mass", 500, 2.0, 3.0);
726 
727  fHistoMassV0fromLcAll = new TH1D("fHistoMassV0fromLcAll", "V0 mass from Lc built in KF; mass", 500, 0.4, 0.6);
728  fHistoDecayLengthV0fromLcAll = new TH1D("fHistoDecayLengthV0fromLcAll", "V0 Decay Length from Lc built in KF; decayLength", 500, 0, 10.0);
729  fHistoLifeTimeV0fromLcAll = new TH1D("fHistoLifeTimeV0fromLcAll", "V0 Life Time from Lc built in KF; lifeTime", 500, 0.0, 3.0);
730 
731  fHistoMassV0fromLcTrue = new TH1D("fHistoMassV0fromLcTrue", "V0 mass from true Lc built in KF; mass", 500, 0.4, 0.6);
732  fHistoDecayLengthV0fromLcTrue= new TH1D("fHistoDecayLengthV0fromLcTrue", "V0 Decay Length from true Lc built in KF; decayLength", 500, 0, 10.0);
733  fHistoLifeTimeV0fromLcTrue = new TH1D("fHistoLifeTimeV0fromLcTrue", "V0 Life Time from true Lc built in KF; lifeTime", 500, 0.0, 3.0);
734 
735  fHistoMassLcSgn = new TH1D("fHistoMassLcSgn", "True Lc Signal Mass; mass", 500, 2.0, 3.0);
736  fHistoMassLcSgnFromAOD = new TH1D("fHistoMassLcSgnFromAOD", "True Lc Signal Mass (AOD); mass", 500, 2.0, 3.0);
737  fHistoDecayLengthLcSgn = new TH1D("fHistoDecayLengthLcSgn", "True Lc Signal Decay Length; decayLength", 100000, -0.1, 0.1);
738  fHistoLifeTimeLcSgn = new TH1D("fHistoLifeTimeLcSgn", "True Lc Signal Life Time; lifeTime", 100000, -0.1, 0.1);
739 
740  fHistoMassV0fromLcSgn = new TH1D("fHistoMassV0fromLcSgn", "V0 from True Lc Signal Mass; mass", 500, 0.4, 0.6);
741  fHistoDecayLengthV0fromLcSgn = new TH1D("fHistoDecayLengthV0fromLcSgn", "V0 True Lc Signal Decay Length; decayLength", 500, 0, 10.0);
742  fHistoLifeTimeV0fromLcSgn = new TH1D("fHistoLifeTimeV0fromLcSgn", "V0 True Lc Signal Life Time; lifeTime", 500, 0.0, 3.0);
743 
744  fHistoKF = new TH2D("fHistoKF", "Summary from KF; V0 KF; Lc KF", 16, -0.5, 15.5, 16, -0.5, 15.5);
745  fHistoKFV0 = new TH1D("fHistoKFV0", "Summary from KF; V0 KF", 16, -0.5, 15.5);
746  fHistoKFLc = new TH1D("fHistoKFLc", "Summary from KF; V0 KF", 16, -0.5, 15.5);
747  TString axisLabel[16] = {"AllOk", "M_NotOk", "Sm_NotOk", "Dl_NotOk",
748  "Lt_NotOk", "M_Sm_NotOk", "M_Dl_NotOk", "M_Lt_NotOk",
749  "Dl_Sm_NotOk", "Dl_Lt_NotOk", "Sm_Lt_NotOk", "M_Sm_Dl_NotOk",
750  "M_Sm_Lt_NotOk", "Sm_Dl_Lt_NotOk", "M_Dl_Lt_NotOk", "All_NotOk"};
751 
752  for (Int_t ibin = 1; ibin <=16; ibin++){
753  fHistoKF->GetXaxis()->SetBinLabel(ibin, axisLabel[ibin-1].Data());
754  fHistoKF->GetYaxis()->SetBinLabel(ibin, axisLabel[ibin-1].Data());
755  fHistoKFV0->GetXaxis()->SetBinLabel(ibin, axisLabel[ibin-1].Data());
756  fHistoKFLc->GetXaxis()->SetBinLabel(ibin, axisLabel[ibin-1].Data());
757  }
758 
759  fHistoMassKFV0 = new TH2D("fHistoMassKFV0", "mass vs sigmaMass for V0; mass; sigmaMass", 500, 0.4, 0.6, 500, 0., 10);
760  fHistoDecayLengthKFV0 = new TH2D("fHistoDecayLengthKFV0", "decayLength vs sigmaDecayLength for V0; decayLength; sigmaDecayLength", 500, -10, 10, 500, 0., 10);
761  fHistoLifeTimeKFV0 = new TH2D("fHistoLifeTimeKFV0", "lifeTime vs sigmalifeTime for V0; lifeTime; sigmaLifeTime", 500, -10, 10, 500, 0., 10);
762 
763  fHistoMassKFLc = new TH2D("fHistoMassKFLc", "mass vs sigmaMass for Lc; mass; sigmaMass", 500, 0.4, 0.6, 500, 0., 10);
764  fHistoDecayLengthKFLc = new TH2D("fHistoDecayLengthKFLc", "decayLength vs sigmaDecayLength for Lc; decayLength; sigmaDecayLength", 500, -10, 10, 500, 0., 10);
765  fHistoLifeTimeKFLc = new TH2D("fHistoLifeTimeKFLc", "lifeTime vs sigmalifeTime for Lc; lifeTime; sigmaLifeTime", 500, -10, 10, 500, 0., 10);
766 
767  fHistoArmenterosPodolanskiV0KF = new TH2D("fHistoArmenterosPodolanskiV0KF", "V0 ArmenterosPodolanski from KF; #alpha; Qt", 1000, -1, 1, 1000, 0, 1);
768  fHistoArmenterosPodolanskiV0KFSgn = new TH2D("fHistoArmenterosPodolanskiV0KFSgn", "V0 (signal) ArmenterosPodolanski from KF; #alpha; Qt", 1000, -1, 1, 1000, 0, 1);
769  fHistoArmenterosPodolanskiV0AOD = new TH2D("fHistoArmenterosPodolanskiV0AOD", "V0 ArmenterosPodolanski from AOD; #alpha; Qt", 1000, -1, 1, 1000, 0, 1);
770  fHistoArmenterosPodolanskiV0AODSgn = new TH2D("fHistoArmenterosPodolanskiV0AODSgn", "V0 (signal) ArmenterosPodolanski from AOD; #alpha; Qt", 1000, -1, 1, 1000, 0, 1);
771  }
772 
773  fOutputKF = new TList();
774  fOutputKF->SetOwner();
775  fOutputKF->SetName("listHistoKF");
776 
777  if (fCallKFVertexing){
781 
785 
789 
793 
797 
799 
803 
805 
809 
813 
815 
819 
823 
828 
832 
833  fOutputKF->Add(fHistoKF);
834  fOutputKF->Add(fHistoKFV0);
835  fOutputKF->Add(fHistoKFLc);
836 
840 
844 
849  }
850 
851  PostData(6, fOutputKF);
852 
853  return;
854 }
855 
856 //_________________________________________________
858 {
860  if (!fInputEvent) {
861  AliError("NO EVENT FOUND!");
862  return;
863  }
864 
865  fCurrentEvent++;
866  AliDebug(2, Form("Processing event = %d", fCurrentEvent));
867  AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(fInputEvent);
868  TClonesArray *arrayLctopKos=0;
869 
870  TClonesArray *array3Prong = 0;
871 
872  if (!aodEvent && AODEvent() && IsStandardAOD()) {
873  // In case there is an AOD handler writing a standard AOD, use the AOD
874  // event in memory rather than the input (ESD) event.
875  aodEvent = dynamic_cast<AliAODEvent*> (AODEvent());
876  // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
877  // have to taken from the AOD event hold by the AliAODExtension
878  AliAODHandler* aodHandler = (AliAODHandler*)
879  ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
880 
881  if (aodHandler->GetExtensions()) {
882  AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
883  AliAODEvent *aodFromExt = ext->GetAOD();
884  arrayLctopKos=(TClonesArray*)aodFromExt->GetList()->FindObject("CascadesHF");
885 
886  array3Prong=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm3Prong");
887  }
888  } else {
889  arrayLctopKos=(TClonesArray*)aodEvent->GetList()->FindObject("CascadesHF");
890 
891  array3Prong=(TClonesArray*)aodEvent->GetList()->FindObject("Charm3Prong");
892  }
893 
894  if ( !fUseMCInfo && fIspA) {
897  }
898 
899  Int_t runnumber = aodEvent->GetRunNumber();
900  if (aodEvent->GetTriggerMask() == 0 && (runnumber >= 195344 && runnumber <= 195677)){
901  AliDebug(3,"Event rejected because of null trigger mask");
902  return;
903  }
904 
906 
907  // mc analysis
908  TClonesArray *mcArray = 0;
909  AliAODMCHeader *mcHeader=0;
910 
911  if (fUseMCInfo) {
912  // MC array need for matching
913  mcArray = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(AliAODMCParticle::StdBranchName()));
914  if (!mcArray) {
915  AliError("Could not find Monte-Carlo in AOD");
916  return;
917  }
918  // load MC header
919  mcHeader = (AliAODMCHeader*)aodEvent->GetList()->FindObject(AliAODMCHeader::StdBranchName());
920  if (!mcHeader) {
921  AliError("AliAnalysisTaskSELc2V0bachelorTMVA::UserExec: MC header branch not found!\n");
922  return;
923  }
924 
925  Double_t zMCVertex = mcHeader->GetVtxZ();
926  if (TMath::Abs(zMCVertex) > fAnalCuts->GetMaxVtxZ()){
927  AliDebug(3,Form("z coordinate of MC vertex = %f, it was required to be within [-%f, +%f], skipping event", zMCVertex, fAnalCuts->GetMaxVtxZ(), fAnalCuts->GetMaxVtxZ()));
928  AliInfo(Form("z coordinate of MC vertex = %f, it was required to be within [-%f, +%f], skipping event", zMCVertex, fAnalCuts->GetMaxVtxZ(), fAnalCuts->GetMaxVtxZ()));
929  return;
930  }
931 
932  //Printf("Filling MC histo");
933  FillMCHisto(mcArray);
934  }
935 
936  // AOD primary vertex
937  fVtx1 = (AliAODVertex*)aodEvent->GetPrimaryVertex();
938  if (!fVtx1) return;
939  if (fVtx1->GetNContributors()<1) return;
940 
942 
943  if ( !fIsEventSelected ) {
944  fHistoEvents->Fill(0);
945  return; // don't take into account not selected events
946  }
947  fHistoEvents->Fill(1);
948 
949  // Setting magnetic field for KF vertexing
950  fBField = aodEvent->GetMagneticField();
951  AliKFParticle::SetField(fBField);
952 
953  Int_t nSelectedAnal = 0;
954  if (fIsK0sAnalysis) {
955  MakeAnalysisForLc2prK0S(arrayLctopKos, mcArray,
956  nSelectedAnal, fAnalCuts,
957  array3Prong, mcHeader);
958  }
959  fCounter->StoreCandidates(aodEvent,nSelectedAnal,kFALSE);
960 
961  PostData(1, fOutput);
962  PostData(2, fCounter);
963  PostData(4, fVariablesTreeSgn);
964  PostData(5, fVariablesTreeBkg);
965  PostData(6, fOutputKF);
966 
967 }
968 //-------------------------------------------------------------------------------
970 
972  for (Int_t iPart=0; iPart<mcArray->GetEntriesFast(); iPart++) {
973  AliAODMCParticle* mcPart = dynamic_cast<AliAODMCParticle*>(mcArray->At(iPart));
974  if (!mcPart){
975  AliError("Failed casting particle from MC array!, Skipping particle");
976  continue;
977  }
978  Int_t pdg = mcPart->GetPdgCode();
979  if (TMath::Abs(pdg) != 4122){
980  AliDebug(2, Form("MC particle %d is not a Lc: its pdg code is %d", iPart, pdg));
981  continue;
982  }
983  AliDebug(2, Form("Step 0 ok: MC particle %d is a Lc: its pdg code is %d", iPart, pdg));
984  Int_t labeldaugh0 = mcPart->GetDaughter(0);
985  Int_t labeldaugh1 = mcPart->GetDaughter(1);
986  if (labeldaugh0 <= 0 || labeldaugh1 <= 0){
987  AliDebug(2, Form("The MC particle doesn't have correct daughters, skipping!!"));
988  continue;
989  }
990  else if (labeldaugh1 - labeldaugh0 == 1){
991  AliDebug(2, Form("Step 1 ok: The MC particle has correct daughters!!"));
992  AliAODMCParticle* daugh0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(labeldaugh0));
993  AliAODMCParticle* daugh1 = dynamic_cast<AliAODMCParticle*>(mcArray->At(labeldaugh1));
994  if(!daugh0 || !daugh1){
995  AliDebug(2,"Particle daughters not properly retrieved!");
996  return;
997  }
998  Int_t pdgCodeDaugh0 = TMath::Abs(daugh0->GetPdgCode());
999  Int_t pdgCodeDaugh1 = TMath::Abs(daugh1->GetPdgCode());
1000  AliAODMCParticle* bachelorMC = daugh0;
1001  AliAODMCParticle* v0MC = daugh1;
1002  AliDebug(2, Form("pdgCodeDaugh0 = %d, pdgCodeDaugh1 = %d", pdgCodeDaugh0, pdgCodeDaugh1));
1003  if ((pdgCodeDaugh0 == 311 && pdgCodeDaugh1 == 2212) || (pdgCodeDaugh0 == 2212 && pdgCodeDaugh1 == 311)){
1004  // we are in the case of Lc --> K0 + p; now we have to check if the K0 decays in K0S, and if this goes in pi+pi-
1006  if (pdgCodeDaugh0 == 311 && pdgCodeDaugh1 == 2212) {
1007  bachelorMC = daugh1;
1008  v0MC = daugh0;
1009  }
1010  AliDebug(2, Form("Number of Daughters of v0 = %d", v0MC->GetNDaughters()));
1011  if (v0MC->GetNDaughters() != 1) {
1012  AliDebug(2, "The K0 does not decay in 1 body only! Impossible... Continuing...");
1013  continue;
1014  }
1015  else { // So far: Lc --> K0 + p, K0 with 1 daughter
1016  AliDebug(2, "Step 2 ok: The K0 does decay in 1 body only! ");
1017  Int_t labelK0daugh = v0MC->GetDaughter(0);
1018  AliAODMCParticle* partK0S = dynamic_cast<AliAODMCParticle*>(mcArray->At(labelK0daugh));
1019  if(!partK0S){
1020  AliError("Error while casting particle! returning a NULL array");
1021  continue;
1022  }
1023  else { // So far: Lc --> K0 + p, K0 with 1 daughter that we can access
1024  if (partK0S->GetNDaughters() != 2 || TMath::Abs(partK0S->GetPdgCode() != 310)){
1025  AliDebug(2, "The K0 daughter is not a K0S or does not decay in 2 bodies");
1026  continue;
1027  }
1028  else { // So far: Lc --> K0 + p, K0 --> K0S, K0S in 2 bodies
1029  AliDebug(2, "Step 3 ok: The K0 daughter is a K0S and does decay in 2 bodies");
1030  Int_t labelK0Sdaugh0 = partK0S->GetDaughter(0);
1031  Int_t labelK0Sdaugh1 = partK0S->GetDaughter(1);
1032  AliAODMCParticle* daughK0S0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(labelK0Sdaugh0));
1033  AliAODMCParticle* daughK0S1 = dynamic_cast<AliAODMCParticle*>(mcArray->At(labelK0Sdaugh1));
1034  if (!daughK0S0 || ! daughK0S1){
1035  AliDebug(2, "Could not access K0S daughters, continuing...");
1036  continue;
1037  }
1038  else { // So far: Lc --> K0 + p, K0 --> K0S, K0S in 2 bodies that we can access
1039  AliDebug(2, "Step 4 ok: Could access K0S daughters, continuing...");
1040  Int_t pdgK0Sdaugh0 = daughK0S0->GetPdgCode();
1041  Int_t pdgK0Sdaugh1 = daughK0S1->GetPdgCode();
1042  if (TMath::Abs(pdgK0Sdaugh0) != 211 || TMath::Abs(pdgK0Sdaugh1) != 211){
1043  AliDebug(2, "The K0S does not decay in pi+pi-, continuing");
1044  //AliInfo("The K0S does not decay in pi+pi-, continuing");
1045  }
1046  else { // Full chain: Lc --> K0 + p, K0 --> K0S, K0S --> pi+pi-
1047  if (fAnalCuts->IsInFiducialAcceptance(mcPart->Pt(), mcPart->Y())) {
1048  AliDebug(2, Form("----> Filling histo with pt = %f", mcPart->Pt()));
1049  if(TMath::Abs(mcPart->Y()) < 0.5) fHistoMCLcK0SpGenLimAcc->Fill(mcPart->Pt());
1050  //AliInfo(Form("\nparticle = %d, Filling MC Gen histo\n", iPart));
1051  fHistoMCLcK0SpGen->Fill(mcPart->Pt());
1052  if(!(TMath::Abs(bachelorMC->Eta()) > 0.9 || bachelorMC->Pt() < 0.1 ||
1053  TMath::Abs(daughK0S0->Eta()) > 0.9 || daughK0S0->Pt() < 0.1 ||
1054  TMath::Abs(daughK0S1->Eta()) > 0.9 || daughK0S1->Pt() < 0.1)) {
1055  fHistoMCLcK0SpGenAcc->Fill(mcPart->Pt());
1056  }
1057  }
1058  else {
1059  AliDebug(2, "not in fiducial acceptance! Skipping");
1060  continue;
1061  }
1062  }
1063  }
1064  }
1065  }
1066  }
1067  }
1068  }
1069  } // closing loop over mcArray
1070 
1071  return;
1072 
1073 }
1074 
1075 //-------------------------------------------------------------------------------
1077  TClonesArray *mcArray,
1078  Int_t &nSelectedAnal,
1079  AliRDHFCutsLctoV0 *cutsAnal, TClonesArray *array3Prong,
1080  AliAODMCHeader* aodheader){
1082 
1083  Int_t pdgCand = 4122;
1084  Int_t pdgDgLctoV0bachelor[2]={2212, 310};
1085  Int_t pdgDgV0toDaughters[2]={211, 211};
1086 
1087  Int_t pdgDgLctopKpi[3]={2212, 321, 211};
1088 
1089  // loop to search for candidates Lc->p+K+pi
1090  Int_t n3Prong = array3Prong->GetEntriesFast();
1091  Int_t nCascades= arrayLctopKos->GetEntriesFast();
1092 
1093  //AliInfo(Form("\n\n\n\n3 prong candidates = %d, ncascades = %d \n\n\n\n\n", n3Prong, nCascades));
1094  for (Int_t i3Prong = 0; i3Prong < n3Prong; i3Prong++) {
1095  AliAODRecoDecayHF3Prong *d = (AliAODRecoDecayHF3Prong*)array3Prong->UncheckedAt(i3Prong);
1096  //Filling a control histogram with no cuts
1097  if (fUseMCInfo) {
1098 
1099  // find associated MC particle for Lc -> p+K+pi
1100  Int_t mcLabel = d->MatchToMC(4122, mcArray, 3, pdgDgLctopKpi);
1101  //Int_t mcLabelTemp = d->MatchToMC(4122, mcArray);
1102  //Printf("mcLabel = %d, mcLabelTemp = %d", mcLabel, mcLabelTemp);
1103  if (mcLabel >= 0) {
1104 
1105  AliAODMCParticle *partLcpKpi = dynamic_cast<AliAODMCParticle*>(mcArray->At(mcLabel));
1106  if(partLcpKpi){
1107  Int_t pdgCode = partLcpKpi->GetPdgCode();
1108  AliDebug(2,Form(" ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ MClabel=%d ~~~~~~~~~~ pdgCode=%d", mcLabel, pdgCode));
1109  //AliInfo(Form(" ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ MClabel=%d ~~~~~~~~~~ pdgCode=%d", mcLabel, pdgCode));
1110  fHistoLcpKpiBeforeCuts->Fill(1);
1111 
1112  }
1113  }
1114  else {
1115  //AliInfo(Form(" ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ MClabel=%d ~~~~~~~~~~", mcLabel));
1116  fHistoLcpKpiBeforeCuts->Fill(0);
1117  }
1118  }
1119  }
1120 
1121  // loop over cascades to search for candidates Lc->p+K0S
1122 
1123  for (Int_t iLctopK0s = 0; iLctopK0s < nCascades; iLctopK0s++) {
1124 
1125  // Lc candidates and K0s from Lc
1126  AliAODRecoCascadeHF* lcK0spr = dynamic_cast<AliAODRecoCascadeHF*>(arrayLctopKos->At(iLctopK0s));
1127  if (!lcK0spr) {
1128  AliDebug(2,Form("Cascade %d doens't exist, skipping",iLctopK0s));
1129  continue;
1130  }
1131 
1132  //Filling a control histogram with no cuts
1133  if (fUseMCInfo) {
1134 
1135  Int_t pdgCode=-2;
1136 
1137  // find associated MC particle for Lc -> p+K0 and K0S->pi+pi
1138  fmcLabelLc = lcK0spr->MatchToMC(pdgCand, pdgDgLctoV0bachelor[1], pdgDgLctoV0bachelor, pdgDgV0toDaughters, mcArray, kTRUE);
1139  if (fmcLabelLc>=0) {
1140  AliDebug(2, Form("----> cascade number %d (total cascade number = %d) is a Lc!", iLctopK0s, nCascades));
1141 
1142  AliAODMCParticle *partLc = dynamic_cast<AliAODMCParticle*>(mcArray->At(fmcLabelLc));
1143  if(partLc){
1144  pdgCode = partLc->GetPdgCode();
1145  if (pdgCode<0) AliDebug(2,Form(" ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ MClabel=%d ~~~~~~~~~~ pdgCode=%d", fmcLabelLc, pdgCode));
1146  pdgCode = TMath::Abs(pdgCode);
1147  fHistoLcBeforeCuts->Fill(1);
1148 
1149  }
1150  }
1151  else {
1152  fHistoLcBeforeCuts->Fill(0);
1153  pdgCode=-1;
1154  }
1155  }
1156 
1157  //if (!lcK0spr->GetSecondaryVtx()) {
1158  // AliInfo("No secondary vertex");
1159  //continue;
1160  //}
1161 
1162  if (lcK0spr->GetNDaughters()!=2) {
1163  AliDebug(2,Form("Cascade %d has not 2 daughters (nDaughters=%d)",iLctopK0s,lcK0spr->GetNDaughters()));
1164  continue;
1165  }
1166 
1167  AliAODv0 * v0part = dynamic_cast<AliAODv0*>(lcK0spr->Getv0());
1168  AliAODTrack * bachPart = dynamic_cast<AliAODTrack*>(lcK0spr->GetBachelor());
1169  if (!v0part || !bachPart) {
1170  AliDebug(2,Form("Cascade %d has no V0 or no bachelor object",iLctopK0s));
1171  continue;
1172  }
1173 
1174 
1175  if (!v0part->GetSecondaryVtx()) {
1176  AliDebug(2,Form("No secondary vertex for V0 by cascade %d",iLctopK0s));
1177  continue;
1178  }
1179 
1180  if (v0part->GetNDaughters()!=2) {
1181  AliDebug(2,Form("current V0 has not 2 daughters (onTheFly=%d, nDaughters=%d)",v0part->GetOnFlyStatus(),v0part->GetNDaughters()));
1182  continue;
1183  }
1184 
1185  AliAODTrack * v0Pos = dynamic_cast<AliAODTrack*>(lcK0spr->Getv0PositiveTrack());
1186  AliAODTrack * v0Neg = dynamic_cast<AliAODTrack*>(lcK0spr->Getv0NegativeTrack());
1187  if (!v0Neg || !v0Pos) {
1188  AliDebug(2,Form("V0 by cascade %d has no V0positive of V0negative object",iLctopK0s));
1189  continue;
1190  }
1191 
1192 
1193  if (v0Pos->Charge() == v0Neg->Charge()) {
1194  AliDebug(2,Form("V0 by cascade %d has daughters with the same sign: IMPOSSIBLE!",iLctopK0s));
1195  continue;
1196  }
1197 
1198  Int_t isLc = 0;
1199 
1200  if (fUseMCInfo) {
1201 
1202  Int_t pdgCode=-2;
1203 
1204  // find associated MC particle for Lc -> p+K0 and K0S->pi+pi
1205  Int_t mcLabel = lcK0spr->MatchToMC(pdgCand, pdgDgLctoV0bachelor[1], pdgDgLctoV0bachelor, pdgDgV0toDaughters, mcArray, kTRUE);
1206  if (mcLabel>=0) {
1207  AliDebug(2,Form(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~cascade number %d (total cascade number = %d)", iLctopK0s, nCascades));
1208 
1209  AliAODMCParticle *partLc = dynamic_cast<AliAODMCParticle*>(mcArray->At(mcLabel));
1210  if(partLc){
1211  pdgCode = partLc->GetPdgCode();
1212  if (pdgCode<0) AliDebug(2,Form(" ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ MClabel=%d ~~~~~~~~~~ pdgCode=%d", mcLabel, pdgCode));
1213  pdgCode = TMath::Abs(pdgCode);
1214  isLc = 1;
1215  fHistoLc->Fill(1);
1216 
1217  }
1218  }
1219  else {
1220  fHistoLc->Fill(0);
1221  pdgCode=-1;
1222  }
1223  }
1224  AliDebug(2, Form("\n\n\n Analysing candidate %d\n", iLctopK0s));
1225  AliDebug(2, Form(">>>>>>>>>> Candidate is background, fFillOnlySgn = %d --> SKIPPING", fFillOnlySgn));
1226  if (!isLc) {
1227  if (fFillOnlySgn) { // if it is background, and we want only signal, we do not fill the tree
1228  continue;
1229  }
1230  else { // checking if we want to fill the background
1231  if (fKeepingOnlyHIJINGBkg){
1232  // we have decided to fill the background only when the candidate has the daugthers that all come from HIJING underlying event!
1233  Bool_t isCandidateInjected = fUtils->HasCascadeCandidateAnyDaughInjected(lcK0spr, aodheader, mcArray);
1234  if (!isCandidateInjected){
1235  AliDebug(2, "The candidate is from HIJING (i.e. not injected), keeping it to fill background");
1236  fHistoBackground->Fill(1);
1237  }
1238  else {
1239  AliDebug(2, "The candidate is NOT from HIJING, we skip it when filling background");
1240  fHistoBackground->Fill(0);
1241  continue;
1242  }
1243  }
1244  else if (fKeepingOnlyPYTHIABkg){
1245  // we have decided to fill the background only when the candidate has the daugthers that all come from HIJING underlying event!
1246  AliAODTrack *bachelor = (AliAODTrack*)lcK0spr->GetBachelor();
1247  AliAODTrack *v0pos = (AliAODTrack*)lcK0spr->Getv0PositiveTrack();
1248  AliAODTrack *v0neg = (AliAODTrack*)lcK0spr->Getv0NegativeTrack();
1249  if (!bachelor || !v0pos || !v0neg) {
1250  AliDebug(2, "Cannot retrieve one of the tracks while checking origin, continuing");
1251  continue;
1252  }
1253  else {
1254  Int_t labelbachelor = TMath::Abs(bachelor->GetLabel());
1255  Int_t labelv0pos = TMath::Abs(v0pos->GetLabel());
1256  Int_t labelv0neg = TMath::Abs(v0neg->GetLabel());
1257  AliAODMCParticle* MCbachelor = (AliAODMCParticle*)mcArray->At(labelbachelor);
1258  AliAODMCParticle* MCv0pos = (AliAODMCParticle*)mcArray->At(labelv0pos);
1259  AliAODMCParticle* MCv0neg = (AliAODMCParticle*)mcArray->At(labelv0neg);
1260  if (!MCbachelor || !MCv0pos || !MCv0neg) {
1261  AliDebug(2, "Cannot retrieve MC particle for one of the tracks while checking origin, continuing");
1262  continue;
1263  }
1264  else {
1265  Int_t isBachelorFromPythia = fUtils->CheckOrigin(mcArray, MCbachelor, kTRUE);
1266  Int_t isv0posFromPythia = fUtils->CheckOrigin(mcArray, MCv0pos, kTRUE);
1267  Int_t isv0negFromPythia = fUtils->CheckOrigin(mcArray, MCv0neg, kTRUE);
1268  if (isBachelorFromPythia != 0 && isv0posFromPythia != 0 && isv0negFromPythia != 0){
1269  AliDebug(2, "The candidate is from PYTHIA (i.e. all daughters originate from a quark), keeping it to fill background");
1270  fHistoBackground->Fill(2);
1271  }
1272  else {
1273  AliDebug(2, "The candidate is NOT from PYTHIA, we skip it when filling background");
1274  fHistoBackground->Fill(3);
1275  continue;
1276  }
1277  }
1278  }
1279  }
1280  }
1281  }
1282 
1283  FillLc2pK0Sspectrum(lcK0spr, isLc, nSelectedAnal, cutsAnal, mcArray, iLctopK0s);
1284 
1285  }
1286 
1287  return;
1288 
1289 }
1290 //________________________________________________________________________
1292  Int_t isLc,
1293  Int_t &nSelectedAnal,
1294  AliRDHFCutsLctoV0 *cutsAnal,
1295  TClonesArray *mcArray, Int_t iLctopK0s){
1296  //
1298  //
1299 
1300  /*
1301  if (!part->GetOwnPrimaryVtx()) {
1302  //Printf("No primary vertex for Lc found!!");
1303  part->SetOwnPrimaryVtx(fVtx1);
1304  }
1305  else {
1306  //Printf("Yu-huuuu!!! primary vertex for Lc found!!");
1307  }
1308  */
1309  Double_t invmassLc = part->InvMassLctoK0sP();
1310 
1311  AliAODv0 * v0part = part->Getv0();
1312  Bool_t onFlyV0 = v0part->GetOnFlyStatus(); // on-the-flight V0s
1313  if (onFlyV0){ // on-the-fly V0
1314  if (isLc) { // Lc
1315  fHistoLcOnTheFly->Fill(2.);
1316  }
1317  else { // not Lc
1318  fHistoLcOnTheFly->Fill(0.);
1319  }
1320  }
1321  else { // offline V0
1322  if (isLc) { // Lc
1323  fHistoLcOnTheFly->Fill(3.);
1324  }
1325  else { // not Lc
1326  fHistoLcOnTheFly->Fill(1.);
1327  }
1328  }
1329 
1330  Double_t dcaV0 = v0part->GetDCA();
1331  Double_t invmassK0s = v0part->MassK0Short();
1332 
1333  if ( (cutsAnal->IsInFiducialAcceptance(part->Pt(),part->Y(4122))) ) {
1334  if (isLc) {
1335  fHistoFiducialAcceptance->Fill(3.);
1336  }
1337  else {
1338  fHistoFiducialAcceptance->Fill(1.);
1339  }
1340  }
1341  else {
1342  if (isLc) {
1343  fHistoFiducialAcceptance->Fill(2.);
1344  }
1345  else {
1346  fHistoFiducialAcceptance->Fill(0.);
1347  }
1348  }
1349 
1350  Int_t isInV0window = (((cutsAnal->IsSelectedSingleCut(part, AliRDHFCuts::kCandidate, 2)) & (AliRDHFCutsLctoV0::kLcToK0Spr)) == (AliRDHFCutsLctoV0::kLcToK0Spr)); // cut on V0 invMass
1351 
1352  if (isInV0window == 0) {
1353  AliDebug(2, "No: The candidate has NOT passed the V0 window cuts!");
1354  if (isLc) Printf("SIGNAL candidate rejected: V0 window cuts");
1355  return;
1356  }
1357  else AliDebug(2, "Yes: The candidate has passed the mass cuts!");
1358 
1359  Bool_t isInCascadeWindow = (((cutsAnal->IsSelectedSingleCut(part, AliRDHFCuts::kCandidate, 0)) & (AliRDHFCutsLctoV0::kLcToK0Spr)) == (AliRDHFCutsLctoV0::kLcToK0Spr)); // cut on Lc->p+K0S invMass
1360 
1361  if (!isInCascadeWindow) {
1362  AliDebug(2, "No: The candidate has NOT passed the cascade window cuts!");
1363  if (isLc) Printf("SIGNAL candidate rejected: cascade window cuts");
1364  return;
1365  }
1366  else AliDebug(2, "Yes: The candidate has passed the cascade window cuts!");
1367 
1368  Bool_t isCandidateSelectedCuts = (((cutsAnal->IsSelected(part, AliRDHFCuts::kCandidate)) & (AliRDHFCutsLctoV0::kLcToK0Spr)) == (AliRDHFCutsLctoV0::kLcToK0Spr)); // kinematic/topological cuts
1369  AliDebug(2, Form("recoAnalysisCuts = %d", cutsAnal->IsSelected(part, AliRDHFCuts::kCandidate) & (AliRDHFCutsLctoV0::kLcToK0Spr)));
1370  if (!isCandidateSelectedCuts){
1371  AliDebug(2, "No: Analysis cuts kCandidate level NOT passed");
1372  if (isLc) Printf("SIGNAL candidate rejected");
1373  return;
1374  }
1375  else {
1376  AliDebug(2, "Yes: Analysis cuts kCandidate level passed");
1377  }
1378 
1379  AliAODTrack *bachelor = (AliAODTrack*)part->GetBachelor();
1380  if (!bachelor) {
1381  AliDebug(2, Form("Very weird, the bachelor is not there... returning for this candidate"));
1382  return;
1383  }
1384 
1385  //Bool_t isBachelorID = (((cutsAnal->IsSelected(part,AliRDHFCuts::kPID))&(AliRDHFCutsLctoV0::kLcToK0Spr))==(AliRDHFCutsLctoV0::kLcToK0Spr)); // ID x bachelor
1386  Double_t probTPCTOF[AliPID::kSPECIES]={-1.};
1387 
1388  UInt_t detUsed = fPIDCombined->ComputeProbabilities(bachelor, fPIDResponse, probTPCTOF);
1389  AliDebug(2, Form("detUsed (TPCTOF case) = %d", detUsed));
1390  Double_t probProton = -1.;
1391  // Double_t probPion = -1.;
1392  // Double_t probKaon = -1.;
1393  if (detUsed == (UInt_t)fPIDCombined->GetDetectorMask() ) {
1394  AliDebug(2, Form("We have found the detector mask for TOF + TPC: probProton will be set to %f", probTPCTOF[AliPID::kProton]));
1395  probProton = probTPCTOF[AliPID::kProton];
1396  // probPion = probTPCTOF[AliPID::kPion];
1397  // probKaon = probTPCTOF[AliPID::kKaon];
1398  }
1399  else { // if you don't have both TOF and TPC, try only TPC
1400  fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTPC);
1401  AliDebug(2, "We did not find the detector mask for TOF + TPC, let's see only TPC");
1402  detUsed = fPIDCombined->ComputeProbabilities(bachelor, fPIDResponse, probTPCTOF);
1403  AliDebug(2,Form(" detUsed (TPC case) = %d", detUsed));
1404  if (detUsed == (UInt_t)fPIDCombined->GetDetectorMask()) {
1405  probProton = probTPCTOF[AliPID::kProton];
1406  // probPion = probTPCTOF[AliPID::kPion];
1407  // probKaon = probTPCTOF[AliPID::kKaon];
1408  AliDebug(2, Form("TPC only worked: probProton will be set to %f", probTPCTOF[AliPID::kProton]));
1409  }
1410  else {
1411  AliDebug(2, "Only TPC did not work...");
1412  }
1413  // resetting mask to ask for both TPC+TOF
1414  fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTPC+AliPIDResponse::kDetTOF);
1415  }
1416  AliDebug(2, Form("probProton = %f", probProton));
1417 
1418  // now we get the TPC and TOF single PID probabilities (only for Proton, or the tree will explode :) )
1419  Double_t probProtonTPC = -1.;
1420  Double_t probProtonTOF = -1.;
1421  Double_t pidTPC[AliPID::kSPECIES]={-1.};
1422  Double_t pidTOF[AliPID::kSPECIES]={-1.};
1423  Int_t respTPC = fPIDResponse->ComputePIDProbability(AliPIDResponse::kDetTPC, bachelor, AliPID::kSPECIES, pidTPC);
1424  Int_t respTOF = fPIDResponse->ComputePIDProbability(AliPIDResponse::kDetTOF, bachelor, AliPID::kSPECIES, pidTOF);
1425  if (respTPC == AliPIDResponse::kDetPidOk) probProtonTPC = pidTPC[AliPID::kProton];
1426  if (respTOF == AliPIDResponse::kDetPidOk) probProtonTOF = pidTOF[AliPID::kProton];
1427 
1428  // checking V0 status (on-the-fly vs offline)
1429  if ( !( !onFlyV0 || (onFlyV0 && fUseOnTheFlyV0) ) ) {
1430  AliDebug(2, "On-the-fly discarded");
1431  return;
1432  }
1433 
1435  nSelectedAnal++;
1436  }
1437 
1438  if ( !(cutsAnal->IsInFiducialAcceptance(part->Pt(),part->Y(4122))) ) return;
1439 
1440  if ( !( ( (cutsAnal->IsSelected(part, AliRDHFCuts::kTracks)) & (AliRDHFCutsLctoV0::kLcToK0Spr)) == (AliRDHFCutsLctoV0::kLcToK0Spr) ) ) { // esd track cuts
1441  if (isLc) Printf("SIGNAL candidate rejected");
1442  AliDebug(2, "No: Analysis cuts kTracks level NOT passed");
1443  return;
1444  }
1445  else {
1446  AliDebug(2, "Yes: Analysis cuts kTracks level passed");
1447  }
1448 
1449  Int_t pdgCand = 4122;
1450  Int_t pdgDgLctoV0bachelor[2]={211, 3122}; // case of wrong decay! Lc --> L + pi
1451  Int_t pdgDgV0toDaughters[2]={2212, 211}; // case of wrong decay! Lc --> L + pi
1452  Int_t isLc2LBarpi=0, isLc2Lpi=0;
1453  Int_t currentLabel = part->GetLabel();
1454  Int_t mcLabel = 0;
1455  if (fUseMCInfo) {
1456  mcLabel = part->MatchToMC(pdgCand, pdgDgLctoV0bachelor[1], pdgDgLctoV0bachelor, pdgDgV0toDaughters, mcArray, kTRUE);
1457  if (mcLabel>=0) {
1458  if (bachelor->Charge()==-1) isLc2LBarpi=1;
1459  if (bachelor->Charge()==+1) isLc2Lpi=1;
1460  }
1461  }
1462 
1463  Int_t pdgDg2prong[2] = {211, 211};
1464  Int_t labelK0S = 0;
1465  Int_t isK0S = 0;
1466  if (fUseMCInfo) {
1467  labelK0S = v0part->MatchToMC(310, mcArray, 2, pdgDg2prong);
1468  if (labelK0S>=0) isK0S = 1;
1469  }
1470 
1471  pdgDg2prong[0] = 211;
1472  pdgDg2prong[1] = 2212;
1473  Int_t isLambda = 0;
1474  Int_t isLambdaBar = 0;
1475  Int_t lambdaLabel = 0;
1476  if (fUseMCInfo) {
1477  lambdaLabel = v0part->MatchToMC(3122, mcArray, 2, pdgDg2prong);
1478  if (lambdaLabel>=0) {
1479  AliAODMCParticle *lambdaTrack = (AliAODMCParticle*)mcArray->At(lambdaLabel);
1480  if (lambdaTrack->GetPdgCode()==3122) isLambda = 1;
1481  else if (lambdaTrack->GetPdgCode()==-3122) isLambdaBar = 1;
1482  }
1483  }
1484 
1485  pdgDg2prong[0] = 11;
1486  pdgDg2prong[1] = 11;
1487  Int_t isGamma = 0;
1488  Int_t gammaLabel = 0;
1489  if (fUseMCInfo) {
1490  gammaLabel = v0part->MatchToMC(22, mcArray, 2, pdgDg2prong);
1491  if (gammaLabel>=0) {
1492  AliAODMCParticle *gammaTrack = (AliAODMCParticle*)mcArray->At(gammaLabel);
1493  if (gammaTrack->GetPdgCode()==22) isGamma = 1;
1494  }
1495  }
1496 
1497  Int_t pdgTemp = -1;
1498  if (currentLabel != -1){
1499  AliAODMCParticle *tempPart = (AliAODMCParticle*)mcArray->At(currentLabel);
1500  pdgTemp = tempPart->GetPdgCode();
1501  }
1502  if (isLc) AliDebug(2, Form("Signal: Candidate is a Lc in K0s+p"));
1503  else if (isLc2LBarpi) AliDebug(2, Form("Background: Candidate is a Lc in Lbar + pi"));
1504  else if (isLc2Lpi) AliDebug(2, Form("Background: Candidate is a Lc in L + pi"));
1505  else AliDebug(2, Form("Pure bkg: Candidate has pdg = %d", pdgTemp));
1506  if (isK0S) AliDebug(2, Form("V0 is a K0S"));
1507  else if (isLambda) AliDebug(2, Form("V0 is a Lambda"));
1508  else if (isLambdaBar) AliDebug(2, Form("V0 is a LambdaBar"));
1509  else if (isGamma) AliDebug(2, Form("V0 is a Gamma"));
1510  //else AliDebug(2, Form("V0 is something else!!"));
1511 
1512  Double_t invmassLc2Lpi = part->InvMassLctoLambdaPi();
1513  Double_t invmassLambda = v0part->MassLambda();
1514  Double_t invmassLambdaBar = v0part->MassAntiLambda();
1515 
1516  //Double_t nSigmaITSpr=-999.;
1517  Double_t nSigmaTPCpr=-999.;
1518  Double_t nSigmaTOFpr=-999.;
1519 
1520  //Double_t nSigmaITSpi=-999.;
1521  Double_t nSigmaTPCpi=-999.;
1522  Double_t nSigmaTOFpi=-999.;
1523 
1524  //Double_t nSigmaITSka=-999.;
1525  Double_t nSigmaTPCka=-999.;
1526  Double_t nSigmaTOFka=-999.;
1527 
1528  /*
1529  cutsAnal->GetPidHF()->GetnSigmaITS(bachelor,4,nSigmaITSpr);
1530  cutsAnal->GetPidHF()->GetnSigmaTPC(bachelor,4,nSigmaTPCpr);
1531  cutsAnal->GetPidHF()->GetnSigmaTOF(bachelor,4,nSigmaTOFpr);
1532  cutsAnal->GetPidHF()->GetnSigmaITS(bachelor,2,nSigmaITSpi);
1533  cutsAnal->GetPidHF()->GetnSigmaTPC(bachelor,2,nSigmaTPCpi);
1534  cutsAnal->GetPidHF()->GetnSigmaTOF(bachelor,2,nSigmaTOFpi);
1535  cutsAnal->GetPidHF()->GetnSigmaITS(bachelor,3,nSigmaITSka);
1536  cutsAnal->GetPidHF()->GetnSigmaTPC(bachelor,3,nSigmaTPCka);
1537  cutsAnal->GetPidHF()->GetnSigmaTOF(bachelor,3,nSigmaTOFka);
1538  */
1539 
1540  nSigmaTPCpi = fPIDResponse->NumberOfSigmasTPC(bachelor,(AliPID::kPion));
1541  nSigmaTPCka = fPIDResponse->NumberOfSigmasTPC(bachelor,(AliPID::kKaon));
1542  nSigmaTPCpr = fPIDResponse->NumberOfSigmasTPC(bachelor,(AliPID::kProton));
1543  nSigmaTOFpi = fPIDResponse->NumberOfSigmasTOF(bachelor,(AliPID::kPion));
1544  nSigmaTOFka = fPIDResponse->NumberOfSigmasTOF(bachelor,(AliPID::kKaon));
1545  nSigmaTOFpr = fPIDResponse->NumberOfSigmasTOF(bachelor,(AliPID::kProton));
1546 
1547 
1548  // Fill candidate variable Tree (track selection, V0 invMass selection)
1549  if (!onFlyV0 && isInV0window && isInCascadeWindow && part->CosV0PointingAngle()>0.99 && TMath::Abs(nSigmaTPCpr) <= 3 && v0part->Getd0Prong(0) < 20 && v0part->Getd0Prong(1) < 20) {
1550 
1551  fCandidateVariables[0] = invmassLc;
1552  fCandidateVariables[1] = invmassLc2Lpi;
1553  fCandidateVariables[2] = invmassK0s;
1554  fCandidateVariables[3] = invmassLambda;
1555  fCandidateVariables[4] = invmassLambdaBar;
1557  fCandidateVariables[6] = dcaV0;
1558  fCandidateVariables[7] = part->Getd0Prong(0);
1559  fCandidateVariables[8] = part->Getd0Prong(1);
1560  fCandidateVariables[9] = nSigmaTPCpr;
1561  fCandidateVariables[10] = nSigmaTPCpi;
1562  fCandidateVariables[11] = nSigmaTPCka;
1563  fCandidateVariables[12] = nSigmaTOFpr;
1564  fCandidateVariables[13] = nSigmaTOFpi;
1565  fCandidateVariables[14] = nSigmaTOFka;
1566  fCandidateVariables[15] = bachelor->Pt();
1567  AliAODTrack *v0pos = (AliAODTrack*)part->Getv0PositiveTrack();
1568  fCandidateVariables[16] = v0pos->Pt();
1569  AliAODTrack *v0neg = (AliAODTrack*)part->Getv0NegativeTrack();
1570  fCandidateVariables[17] = v0neg->Pt();
1571  fCandidateVariables[18] = v0part->Getd0Prong(0);
1572  fCandidateVariables[19] = v0part->Getd0Prong(1);
1573  fCandidateVariables[20] = v0part->Pt();
1574  fCandidateVariables[21] = v0part->InvMass2Prongs(0,1,11,11);
1575  fCandidateVariables[22] = part->Pt();
1576  fCandidateVariables[23] = probProton;
1577  fCandidateVariables[24] = part->Eta();
1578  fCandidateVariables[25] = v0pos->Eta();
1579  fCandidateVariables[26] = v0neg->Eta();
1580  fCandidateVariables[27] = probProtonTPC;
1581  fCandidateVariables[28] = probProtonTOF;
1582  fCandidateVariables[29] = bachelor->Eta();
1583 
1584  fCandidateVariables[30] = part->P();
1585  fCandidateVariables[31] = bachelor->P();
1586  fCandidateVariables[32] = v0part->P();
1587  fCandidateVariables[33] = v0pos->P();
1588  fCandidateVariables[34] = v0neg->P();
1589 
1590  fCandidateVariables[35] = part->Y(4122);
1591  fCandidateVariables[36] = bachelor->Y(2212);
1592  fCandidateVariables[37] = v0part->Y(310);
1593  fCandidateVariables[38] = v0pos->Y(211);
1594  fCandidateVariables[39] = v0neg->Y(211);
1595 
1596  fCandidateVariables[40] = v0part->Eta();
1597 
1598  fCandidateVariables[41] = part->DecayLength();
1599  fCandidateVariables[42] = part->DecayLengthV0();
1600  fCandidateVariables[43] = part->Ct(4122);
1601  fCandidateVariables[44] = v0part->Ct(310, v0part->GetSecondaryVtx());
1602 
1603  EBachelor bachCode = kBachInvalid;
1604  EK0S k0SCode = kK0SInvalid;
1605  if (fUseMCInfo) {
1606  bachCode = CheckBachelor(part, bachelor, mcArray);
1607  k0SCode = CheckK0S(part, v0part, mcArray);
1608  }
1609 
1610  fCandidateVariables[45] = bachCode;
1611  fCandidateVariables[46] = k0SCode;
1612 
1613  Double_t V0KF[3] = {-999999, -999999, -999999};
1614  Double_t errV0KF[3] = {-999999, -999999, -999999};
1615  Double_t LcKF[3] = {-999999, -999999, -999999};
1616  Double_t errLcKF[3] = {-999999, -999999, -999999};
1617  Double_t distances[3] = {-999999, -999999, -999999};
1618  Double_t armPolKF[2] = {-999999, -999999};
1619 
1620  if (fCallKFVertexing){
1621  Int_t kfResult = CallKFVertexing(part, v0part, bachelor, mcArray, &V0KF[0], &errV0KF[0], &LcKF[0], &errLcKF[0], &distances[0], &armPolKF[0]);
1622  AliDebug(2, Form("Result from KF = %d", kfResult));
1623  }
1624 
1625  /*
1626  for (Int_t i = 0; i< 3; i++){
1627  Printf("i = %d, V0KF = %f, errV0KF = %f, LcKF = %f, errLcKF = %f", V0KF[i], errV0KF[i], LcKF[i], errLcKF[i]);
1628  }
1629  */
1630 
1631  fCandidateVariables[47] = V0KF[0];
1632  fCandidateVariables[48] = V0KF[1];
1633  fCandidateVariables[49] = V0KF[2];
1634 
1635  fCandidateVariables[50] = errV0KF[0];
1636  fCandidateVariables[51] = errV0KF[1];
1637  fCandidateVariables[52] = errV0KF[2];
1638 
1639  fCandidateVariables[53] = LcKF[0];
1640  fCandidateVariables[54] = LcKF[1];
1641  fCandidateVariables[55] = LcKF[2];
1642 
1643  fCandidateVariables[56] = errLcKF[0];
1644  fCandidateVariables[57] = errLcKF[1];
1645  fCandidateVariables[58] = errLcKF[2];
1646 
1647  fCandidateVariables[59] = distances[0];
1648  fCandidateVariables[60] = distances[1];
1649  fCandidateVariables[61] = distances[2];
1650  fCandidateVariables[62] = armPolKF[0];
1651  fCandidateVariables[63] = armPolKF[1];
1652  fCandidateVariables[64] = v0part->AlphaV0();
1653  fCandidateVariables[65] = v0part->PtArmV0();
1654 
1655  AliDebug(2, Form("v0pos->GetStatus() & AliESDtrack::kITSrefit= %d, v0neg->GetStatus() & AliESDtrack::kITSrefit = %d, v0pos->GetTPCClusterInfo(2, 1)= %f, v0neg->GetTPCClusterInfo(2, 1) = %f", (Int_t)(v0pos->GetStatus() & AliESDtrack::kITSrefit), (Int_t)(v0pos->GetStatus() & AliESDtrack::kITSrefit), v0pos->GetTPCClusterInfo(2, 1), v0neg->GetTPCClusterInfo(2, 1)));
1656  fCandidateVariables[66] = v0pos->GetStatus() & AliESDtrack::kITSrefit;
1657  fCandidateVariables[67] = v0neg->GetStatus() & AliESDtrack::kITSrefit;
1658  fCandidateVariables[68] = v0pos->GetTPCClusterInfo(2, 1);
1659  fCandidateVariables[69] = v0neg->GetTPCClusterInfo(2, 1);
1660 
1661  fCandidateVariables[70] = v0part->Xv();
1662  fCandidateVariables[71] = v0part->Yv();
1663  fCandidateVariables[72] = v0part->Zv();
1664 
1665  fCandidateVariables[73] = fVtx1->GetX();
1666  fCandidateVariables[74] = fVtx1->GetY();
1667  fCandidateVariables[75] = fVtx1->GetZ();
1668 
1669  fCandidateVariables[76] = bachelor->GetITSNcls();
1670  fCandidateVariables[77] = bachelor->HasPointOnITSLayer(0) + bachelor->HasPointOnITSLayer(1);
1671 
1672  fCandidateVariables[78] = v0pos->GetITSNcls();
1673  fCandidateVariables[79] = v0pos->HasPointOnITSLayer(0) + v0pos->HasPointOnITSLayer(1);
1674 
1675  fCandidateVariables[80] = v0neg->GetITSNcls();
1676  fCandidateVariables[81] = v0neg->HasPointOnITSLayer(0) + v0neg->HasPointOnITSLayer(1);
1677 
1678  TVector3 mom1(bachelor->Px(), bachelor->Py(), bachelor->Pz());
1679  TVector3 mom2(v0part->Px(), v0part->Py(), v0part->Pz());
1680  TVector3 momTot(part->Px(), part->Py(), part->Pz());
1681 
1682  Double_t Ql1 = mom1.Dot(momTot)/momTot.Mag();
1683  Double_t Ql2 = mom2.Dot(momTot)/momTot.Mag();
1684 
1685  Double_t alphaArmLc = (Ql1 - Ql2)/(Ql1 + Ql2);
1686  Double_t alphaArmLcCharge = ( bachelor->Charge() > 0 ? (Ql1 - Ql2)/(Ql1 + Ql2) : (Ql2 - Ql1)/(Ql1 + Ql2) );
1687  Double_t ptArmLc = mom1.Perp(momTot);
1688 
1689  fCandidateVariables[82] = alphaArmLc;
1690  fCandidateVariables[83] = alphaArmLcCharge;
1691  fCandidateVariables[84] = ptArmLc;
1692 
1693  Double_t massK0SPDG = TDatabasePDG::Instance()->GetParticle(310)->Mass(); // mass K0S PDG
1694  Double_t massPrPDG = TDatabasePDG::Instance()->GetParticle(2212)->Mass(); // mass Proton PDG
1695  Double_t massLcPDG = TDatabasePDG::Instance()->GetParticle(4122)->Mass(); // mass Lc PDG
1696 
1697  Double_t pStar = TMath::Sqrt((massLcPDG*massLcPDG-massPrPDG*massPrPDG-massK0SPDG*massK0SPDG)*(massLcPDG*massLcPDG-massPrPDG*massPrPDG-massK0SPDG*massK0SPDG)-4.*massPrPDG*massPrPDG*massK0SPDG*massK0SPDG)/(2.*massLcPDG);
1698  Double_t e = part->E(4122);
1699  Double_t beta = part->P()/e;
1700  Double_t gamma = e/massLcPDG;
1701 
1702  Double_t cts = (Ql1/gamma-beta*TMath::Sqrt(pStar*pStar+massPrPDG*massPrPDG))/pStar;
1703 
1704  fCandidateVariables[85] = cts;
1705 
1706  if (fUseMCInfo) {
1707  if (isLc){
1708  AliDebug(2, Form("Reco particle %d --> Filling Sgn", iLctopK0s));
1709  fVariablesTreeSgn->Fill();
1710  fHistoCodesSgn->Fill(bachCode, k0SCode);
1711  }
1712  else {
1713  if (fFillOnlySgn == kFALSE){
1714  AliDebug(2, "Filling Bkg");
1715  fVariablesTreeBkg->Fill();
1716  fHistoCodesBkg->Fill(bachCode, k0SCode);
1717  }
1718  }
1719  }
1720  else {
1721  fVariablesTreeSgn->Fill();
1722  }
1723  }
1724 
1725  return;
1726 
1727 }
1728 
1729 //________________________________________________________________________
1730 Int_t AliAnalysisTaskSELc2V0bachelorTMVA::CallKFVertexing(AliAODRecoCascadeHF *cascade, AliAODv0* v0part, AliAODTrack* bach, TClonesArray *mcArray,
1731  Double_t* V0KF, Double_t* errV0KF, Double_t* LcKF, Double_t* errLcKF,
1732  Double_t* distances, Double_t* armPolKF) {
1733 
1734  //
1737  //
1738 
1739  Int_t codeKFV0 = -1, codeKFLc = -1;
1740 
1741  AliKFVertex primVtxCopy;
1742  Int_t nt = 0, ntcheck = 0;
1743  Double_t pos[3] = {0., 0., 0.};
1744 
1745  fVtx1->GetXYZ(pos);
1746  Int_t contr = fVtx1->GetNContributors();
1747  Double_t covmatrix[6] = {0.};
1748  fVtx1->GetCovarianceMatrix(covmatrix);
1749  Double_t chi2 = fVtx1->GetChi2();
1750  AliESDVertex primaryESDVtxCopy(pos, covmatrix, chi2, contr, "Vertex");
1751 
1752  // topological constraint
1753  primVtxCopy = AliKFVertex(primaryESDVtxCopy);
1754  nt = primaryESDVtxCopy.GetNContributors();
1755  ntcheck = nt;
1756 
1757  Int_t pdg[2] = {211, -211};
1758  Int_t pdgLc[2] = {2212, 310};
1759 
1760  Int_t pdgDgV0toDaughters[2] = {211, 211};
1761 
1762  Int_t mcLabelV0 = v0part->MatchToMC(310, mcArray, 2, pdgDgV0toDaughters);
1763 
1764  // the KF vertex for the V0 has to be built with the prongs of the V0!
1765  Bool_t isMCokV0 = kTRUE, isBkgV0 = kFALSE;
1766  AliKFParticle V0, positiveV0KF, negativeV0KF;
1767  Int_t labelsv0daugh[2] = {-1, -1};
1768  Int_t idv0daugh[2] = {-1, -1};
1769  AliExternalTrackParam* esdv0Daugh1 = 0x0;
1770  AliExternalTrackParam* esdv0Daugh2 = 0x0;
1771  for(Int_t ipr= 0; ipr < 2; ipr++){ // 0 is positive, 1 is negative
1772  AliAODTrack *aodTrack = (AliAODTrack*)v0part->GetDaughter(ipr);
1773  if(!aodTrack) {
1774  AliDebug(2, "No V0 daughters available");
1775  return -1;
1776  }
1777  Double_t xyz[3], pxpypz[3], cv[21];
1778  Short_t sign;
1779  aodTrack->GetXYZ(xyz);
1780  aodTrack->PxPyPz(pxpypz);
1781  aodTrack->GetCovarianceXYZPxPyPz(cv);
1782  sign = aodTrack->Charge();
1783  AliExternalTrackParam tmp1( xyz, pxpypz, cv, sign);
1784 
1785  if (ipr == 0) esdv0Daugh1 = new AliExternalTrackParam( xyz, pxpypz, cv, sign);
1786  else esdv0Daugh2 = new AliExternalTrackParam( xyz, pxpypz, cv, sign);
1787  labelsv0daugh[ipr] = TMath::Abs(aodTrack->GetLabel());
1788  idv0daugh[ipr] = aodTrack->GetID();
1789  if (labelsv0daugh[ipr] == -1) isBkgV0 = kTRUE;
1790 
1791  //Printf("v0 daughter %d has label %d", ipr, labelsv0daugh[ipr]);
1792 
1793  AliKFParticle daughterKF(*aodTrack, pdg[ipr]); // we assume that the PDG is correct
1794  if (aodTrack->Charge() > 0) { // assigning positive and negative track to KF V0 for Armenteros-Podolanski plot
1795  positiveV0KF = daughterKF;
1796  }
1797  else {
1798  negativeV0KF = daughterKF;
1799  }
1800  }
1801 
1802  Double_t xn=0., xp=0.;//, dca;
1803  AliDebug(2, Form("bField = %f, esdv0Daugh1 = %p, esdv0Daugh2 = %p", fBField, esdv0Daugh1, esdv0Daugh2));
1804  // dca = esdv0Daugh1->GetDCA(esdv0Daugh2, fBField, xn, xp);
1805 
1806  AliExternalTrackParam tr1(*esdv0Daugh1);
1807  AliExternalTrackParam tr2(*esdv0Daugh2);
1808  tr1.PropagateTo(xn, fBField);
1809  tr2.PropagateTo(xp, fBField);
1810 
1811  AliKFParticle daughterKF1(tr1, 211);
1812  AliKFParticle daughterKF2(tr2, 211);
1813  V0.AddDaughter(positiveV0KF);
1814  V0.AddDaughter(negativeV0KF);
1815  //V0.AddDaughter(daughterKF1);
1816  //V0.AddDaughter(daughterKF2);
1817 
1818  delete esdv0Daugh1;
1819  delete esdv0Daugh2;
1820  esdv0Daugh1=0;
1821  esdv0Daugh2=0;
1822  // Checking the quality of the KF V0 vertex
1823  if( V0.GetNDF() < 1 ) {
1824  //Printf("Number of degrees of freedom < 1, continuing");
1825  return -1;
1826  }
1827  if( TMath::Sqrt(TMath::Abs(V0.GetChi2()/V0.GetNDF())) > fCutKFChi2NDF ) {
1828  //Printf("Chi2 per DOF too big, continuing");
1829  return -1;
1830  }
1831 
1832  if(ftopoConstraint && nt > 0){
1833  for(Int_t ipr = 0; ipr < 2; ipr++){ // 0 is positive, 1 is negative
1834  AliAODTrack *aodTrack = (AliAODTrack*)v0part->GetDaughter(ipr);
1835  //* subtruct daughters from primary vertex
1836  if(!aodTrack->GetUsedForPrimVtxFit()) {
1837  //Printf("Track %d was not used for primary vertex, continuing", i);
1838  continue;
1839  }
1840  AliKFParticle daughterKF(*aodTrack, pdg[ipr]); // we assume that the PDG is correct
1841  primVtxCopy -= daughterKF;
1842  ntcheck--;
1843  }
1844  }
1845 
1846  // Check V0 Chi^2 deviation from primary vertex // not needed for V0 for Lc decay!!
1847  /*
1848  if( V0.GetDeviationFromVertex( primVtxCopy ) < fCutKFDeviationFromVtxV0) {
1849  //Printf("Deviation from vertex too big, continuing");
1850  return -1;
1851  }
1852  */
1853 
1854  //* Get V0 invariant mass
1855  Double_t massV0 = 999999, sigmaMassV0 = 999999;
1856  Int_t retMV0 = V0.GetMass( massV0, sigmaMassV0 );
1857  if( retMV0 ) {
1858  if (massV0 < 0) {
1859  codeKFV0 = 1; // Mass not ok
1860  if (sigmaMassV0 > 1e19) codeKFV0 = 5; // Mass and SigmaMass not ok
1861  }
1862  else if (sigmaMassV0 > 1e19) codeKFV0 = 2; // SigmaMass not ok
1863  }
1864  fHistoMassKFV0->Fill(massV0, sigmaMassV0);
1865 
1866  if (massV0 < 0.4) Printf("\n\n>>>>>>>>>> Found the Funny V0 (mass = %f, sigma = %f, AOD mass = %f): labels of the tracks = %d, %d, id = %d and %d", massV0, sigmaMassV0, v0part->MassK0Short(), labelsv0daugh[0], labelsv0daugh[1], idv0daugh[0], idv0daugh[1]);
1867  if (massV0 > 0.55) Printf("\n\n>>>>>>>>>> Found the Funny V0 (mass = %f, , sigma = %f, AOD mass = %f): labels of the tracks = %d, %d, id = %d and %d", massV0, sigmaMassV0, v0part->MassK0Short(), labelsv0daugh[0], labelsv0daugh[1], idv0daugh[0], idv0daugh[1]);
1868 
1869  Printf("Vertices: KF: x = %f, y = %f, z = %f", V0.GetX(), V0.GetY(), V0.GetZ());
1870  Printf("Vertices: AOD: x = %f, y = %f, z = %f", v0part->Xv(), v0part->Yv(), v0part->Zv());
1871 
1872  //Printf("Got MC vtx for V0");
1873  if (fUseMCInfo && TMath::Abs(labelsv0daugh[0] - labelsv0daugh[1]) == 1) {
1874  AliAODMCParticle* tmpdaughv01 = dynamic_cast<AliAODMCParticle*>(mcArray->At(labelsv0daugh[0]));
1875  AliAODMCParticle* tmpdaughv02 = dynamic_cast<AliAODMCParticle*>(mcArray->At(labelsv0daugh[1]));
1876  if (!tmpdaughv01 && labelsv0daugh[0] > 0){
1877  AliDebug(2, "Could not access MC info for first daughter of V0, continuing");
1878  }
1879  if (!tmpdaughv02 && labelsv0daugh[1] > 0){
1880  AliDebug(2, "Could not access MC info for second daughter of V0, continuing");
1881  }
1882  if(tmpdaughv01){
1883  Double_t xPionMC = tmpdaughv01->Xv(); //Production vertex of Pion --> Where K0S decays
1884  Double_t yPionMC = tmpdaughv01->Yv();
1885  Double_t zPionMC = tmpdaughv01->Zv();
1886  //Printf("Got MC vtx for Pion");
1887  Printf("Vertices: MC: x = %f, y = %f, z = %f", xPionMC, yPionMC, zPionMC);
1888  }
1889  }
1890  else {
1891  Printf("Not a true V0");
1892  }
1893  //massV0=-1;//return -1;// !!!!
1894 
1895  // now use what we just try with the bachelor, to build the Lc
1896 
1897  // topological constraint
1898  nt = primVtxCopy.GetNContributors();
1899  ntcheck = nt;
1900 
1901  Bool_t isMCokLc = kTRUE, isBkgLc = kFALSE;
1902  AliKFParticle Lc;
1903  Int_t labelsLcdaugh[2] = {-1, -1};
1904  labelsLcdaugh[0] = TMath::Abs(bach->GetLabel());
1905  labelsLcdaugh[1] = mcLabelV0;
1906 
1907  if (bach->Charge() < 0) pdgLc[0] = -pdgLc[0];
1908  AliKFParticle daughterKFLc(*bach, pdgLc[0]);
1909  Lc.AddDaughter(daughterKFLc);
1910  TParticlePDG* particlePDG = TDatabasePDG::Instance()->GetParticle(310);
1911  Double_t massPDGK0S = particlePDG->Mass();
1912  V0.SetMassConstraint(massPDGK0S);
1913  Lc.AddDaughter(V0);
1914  if( Lc.GetNDF() < 1 ) {
1915  AliDebug(2, Form("Lc: Number of degrees of freedom < 1 (%d), continuing", Lc.GetNDF()));
1916  return -1;
1917  }
1918  if( TMath::Sqrt(TMath::Abs(Lc.GetChi2()/Lc.GetNDF())) > fCutKFChi2NDF) {
1919  AliDebug(2, Form("Lc: Chi2 per DOF too big, continuing (%f)", TMath::Sqrt(TMath::Abs(Lc.GetChi2()/Lc.GetNDF()))));
1920  return -1;
1921  }
1922 
1923  if(ftopoConstraint && nt > 0){
1924  //* subtruct daughters from primary vertex
1925  if(!bach->GetUsedForPrimVtxFit()) {
1926  AliDebug(3, "Lc: Bachelor was not used for primary vertex, not subtracting it from primary vertex");
1927  }
1928  else{
1929  primVtxCopy -= daughterKFLc;
1930  ntcheck--;
1931  }
1932  /* the V0 was added above, so it is ok to remove it without checking
1933  if(!V0->GetUsedForPrimVtxFit()) {
1934  Printf("Lc: V0 was not used for primary vertex, continuing");
1935  continue;
1936  }
1937  */
1938  //primVtxCopy -= V0;
1939  //ntcheck--;
1940  }
1941 
1942  // Check Lc Chi^2 deviation from primary vertex
1943  /*
1944  if( Lc.GetDeviationFromVertex( primVtxCopy ) > fCutKFDeviationFromVtx) {
1945  AliDebug(2, Form("Lc: Deviation from vertex too big, continuing (%f)", Lc.GetDeviationFromVertex( primVtxCopy )));
1946  return -1;
1947  }
1948 
1949  if(ftopoConstraint){
1950  if(ntcheck>0) {
1951  // Add Lc to primary vertex to improve the primary vertex resolution
1952  primVtxCopy += Lc;
1953  Lc.SetProductionVertex(primVtxCopy);
1954  }
1955  }
1956  */
1957  //* Check chi^2
1958  if( TMath::Sqrt( TMath::Abs(Lc.GetChi2()/Lc.GetNDF())) > fCutKFChi2NDF) {
1959  AliDebug(2, Form("Lc: Final Chi2 per DOF too big, continuing (%f)", TMath::Sqrt( TMath::Abs(Lc.GetChi2()/Lc.GetNDF()))));
1960  return -1;
1961  }
1962 
1963  if(ftopoConstraint){
1964  V0.SetProductionVertex(Lc);
1965  }
1966 
1967  // After setting the vertex of the V0, getting/filling some info
1968 
1969  //* Get V0 decayLength
1970  Double_t decayLengthV0 = 999999, sigmaDecayLengthV0 = 999999;
1971  Int_t retDLV0 = V0.GetDecayLength( decayLengthV0, sigmaDecayLengthV0 );
1972  if( retDLV0 ) {
1973  if (sigmaDecayLengthV0 > 1e19) {
1974  codeKFV0 = 3; // DecayLength not ok
1975  if (massV0 < 0) {
1976  codeKFV0 = 6; // DecayLength and Mass not ok
1977  if (sigmaMassV0 > 1e19) codeKFV0 = 11; // DecayLength and Mass and SigmaMass not ok
1978  }
1979  else if (sigmaMassV0 > 1e19) codeKFV0 = 8; // DecayLength and SigmaMass not ok
1980  }
1981  }
1982  fHistoDecayLengthKFV0->Fill(decayLengthV0, sigmaDecayLengthV0);
1983 
1984  //* Get V0 life time
1985  Double_t lifeTimeV0 = 999999, sigmaLifeTimeV0 = 999999;
1986  Int_t retTLV0 = V0.GetLifeTime( lifeTimeV0, sigmaLifeTimeV0 );
1987  if( retTLV0 ) {
1988  if (sigmaLifeTimeV0 > 1e19) {
1989  codeKFV0 = 4; // LifeTime not ok
1990  if (sigmaDecayLengthV0 > 1e19) {
1991  codeKFV0 = 9; // LifeTime and DecayLength not ok
1992  if (massV0 < 0) {
1993  codeKFV0 = 14; // LifeTime and DecayLength and Mass not ok
1994  if (sigmaMassV0 > 1e19) codeKFV0 = 15; // LifeTime and DecayLength and Mass and SigmaMass not ok
1995  }
1996  else if (sigmaMassV0 > 1e19) codeKFV0 = 13; // LifeTime and DecayLength and SigmaMass not ok
1997  }
1998  else if (massV0 < 0) { // LifeTime and Mass and SigmaMass not ok
1999  codeKFV0 = 7; // LifeTime and Mass not ok
2000  if (sigmaMassV0 > 1e19) codeKFV0 = 12; // LifeTime and Mass and SigmaMass not ok
2001  }
2002  else if (sigmaMassV0 > 1e19) codeKFV0 = 10; // LifeTime and SigmaMass not ok
2003  }
2004  }
2005  fHistoLifeTimeKFV0->Fill(lifeTimeV0, sigmaLifeTimeV0);
2006 
2007  if (codeKFV0 == -1) codeKFV0 = 0;
2008  fHistoKFV0->Fill(codeKFV0);
2009 
2010  AliDebug(2, Form("V0: mass = %f, decay length = %f, life time = %f", massV0, decayLengthV0, lifeTimeV0 ));
2011 
2012  fHistoMassV0All->Fill(massV0);
2013  fHistoDecayLengthV0All->Fill(decayLengthV0);
2014  fHistoLifeTimeV0All->Fill(lifeTimeV0);
2015 
2016  Double_t qtAlphaV0[2] = {0., 0.};
2017  Double_t vtxV0KF[3] = {V0.GetX(), V0.GetY(), V0.GetZ()};
2018  positiveV0KF.TransportToPoint(vtxV0KF);
2019  negativeV0KF.TransportToPoint(vtxV0KF);
2020  V0.GetArmenterosPodolanski(positiveV0KF, negativeV0KF, qtAlphaV0);
2021  AliDebug(2, Form("Armenteros-Podolanski variables: alpha = %f, qt = %f", qtAlphaV0[1], qtAlphaV0[0]));
2022  fHistoArmenterosPodolanskiV0KF->Fill(qtAlphaV0[1], qtAlphaV0[0]);
2023  fHistoArmenterosPodolanskiV0AOD->Fill(v0part->AlphaV0(), v0part->PtArmV0());
2024  armPolKF[0] = qtAlphaV0[1];
2025  armPolKF[1] = qtAlphaV0[0];
2026 
2027  // Checking MC info for V0
2028 
2029  AliAODMCParticle *motherV0 = 0x0;
2030  AliAODMCParticle *daughv01 = 0x0;
2031  AliAODMCParticle *daughv02 = 0x0;
2032 
2033  if (fUseMCInfo) {
2034  daughv01 = dynamic_cast<AliAODMCParticle*>(mcArray->At(labelsv0daugh[0]));
2035  daughv02 = dynamic_cast<AliAODMCParticle*>(mcArray->At(labelsv0daugh[1]));
2036  if (!daughv01 && labelsv0daugh[0] > 0){
2037  AliDebug(2, "Could not access MC info for first daughter of V0, continuing");
2038  isMCokV0 = kFALSE;
2039  }
2040  if (!daughv02 && labelsv0daugh[1] > 0){
2041  AliDebug(2, "Could not access MC info for second daughter of V0, continuing");
2042  isMCokV0 = kFALSE;
2043  }
2044  if (isMCokV0){
2045  if( daughv01->GetMother() == daughv02->GetMother() && daughv01->GetMother()>=0 ){
2046  AliDebug(3, Form("The mother has label %d", daughv01->GetMother()));
2047  motherV0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(daughv01->GetMother()));
2048  if( motherV0 && TMath::Abs(motherV0->GetPdgCode()) != 21 ){ // These are all V0 that are truly V0, not only K0S, but no gluons
2049  if( motherV0->GetNDaughters() == 2 ){
2050  fHistoMassV0True->Fill(massV0);
2051  fHistoDecayLengthV0True->Fill(decayLengthV0);
2052  fHistoLifeTimeV0True->Fill(lifeTimeV0);
2053  fHistoMassV0TrueFromAOD->Fill(v0part->MassK0Short());
2054  if (TMath::Abs(motherV0->GetPdgCode()) == 310){ // These are true V0 that are also K0S
2055  fHistoMassV0TrueK0S->Fill(massV0);
2056  fHistoDecayLengthV0TrueK0S->Fill(decayLengthV0);
2057  fHistoLifeTimeV0TrueK0S->Fill(lifeTimeV0);
2058  fHistoMassV0TrueK0SFromAOD->Fill(v0part->MassK0Short());
2059  }
2060  }
2061  AliDebug(2, Form("PDG V0 = %d, pi = %d, pj = %d, ndaughters = %d, mc mass = %f, reco mass = %f, v0 mass = %f", motherV0->GetPdgCode(), daughv01->GetPdgCode(), daughv02->GetPdgCode(), motherV0->GetNDaughters(), motherV0->GetCalcMass(), massV0, v0part->MassK0Short()));
2062  }
2063  else if (!motherV0){
2064  AliDebug(3, "could not access MC info for mother, continuing");
2065  }
2066  else {
2067  AliDebug(3, "MC mother is a gluon, continuing");
2068  }
2069  }
2070  else {
2071  AliDebug(3, "Background V0!");
2072  isBkgV0 = kTRUE;
2073  }
2074  }
2075  }
2076 
2077  AliDebug(2, Form("isMCokV0 = %d, isBkgV0 = %d", (Int_t)isMCokV0, (Int_t)isBkgV0));
2078 
2079  // Going back to Lc
2080 
2081  //* Get Lc invariant mass
2082  Double_t massLc = 999999, sigmaMassLc= 999999;
2083  Int_t retMLc = Lc.GetMass( massLc, sigmaMassLc );
2084  if( retMLc ) {
2085  AliDebug(3, Form("----> Could not get mass (%e), and sigma(%e) for Lc, continuing", massLc, sigmaMassLc));
2086  if (massLc < 0) {
2087  codeKFLc = 1; // Mass not ok
2088  if (sigmaMassLc > 1e19) codeKFLc = 5; // Mass and SigmaMass not ok
2089  }
2090  else if (sigmaMassLc > 1e19) codeKFLc = 2; // SigmaMass not ok
2091  }
2092  fHistoMassKFLc->Fill(massLc, sigmaMassLc);
2093 
2094  //* Get Lc Decay length
2095  Double_t decayLengthLc = 999999, sigmaDecayLengthLc = 999999;
2096  Int_t retDLLc = Lc.GetDecayLength( decayLengthLc, sigmaDecayLengthLc );
2097  if( retDLLc ) {
2098  AliDebug(3, "----> Lc: Could not get decay length, and sigma");
2099  if (sigmaDecayLengthLc > 1e19) {
2100  codeKFLc = 3; // DecayLength not ok
2101  if (massLc < 0) {
2102  codeKFLc = 6; // DecayLength and Mass not ok
2103  if (sigmaMassLc > 1e19) codeKFLc = 11; // DecayLength and Mass and SigmaMass not ok
2104  }
2105  else if (sigmaMassLc > 1e19) codeKFLc = 8; // DecayLength and SigmaMass not ok
2106  }
2107  }
2108  AliDebug(3, Form("retDLLc = %d, with decayLength = %f and error = %e", retDLLc, decayLengthLc, sigmaDecayLengthLc));
2109 
2110  fHistoDecayLengthKFLc->Fill(decayLengthLc, sigmaDecayLengthLc);
2111 
2112  //* Get Lc life time
2113  Double_t lifeTimeLc = 999999, sigmaLifeTimeLc = 999999;
2114  Int_t retTLLc = Lc.GetLifeTime( lifeTimeLc, sigmaLifeTimeLc );
2115  if( retTLLc ) {
2116  AliDebug(3, "----> Lc: Could not get lifeTime, and sigma");
2117  if (sigmaLifeTimeLc > 1e19) {
2118  codeKFLc = 4; // LifeTime not ok
2119  if (sigmaDecayLengthLc > 1e19) {
2120  codeKFLc = 9; // LifeTime and DecayLength not ok
2121  if (massLc < 0) {
2122  codeKFLc = 14; // LifeTime and DecayLength and Mass not ok
2123  if (sigmaMassLc > 1e19) codeKFLc = 15; // LifeTime and DecayLength and Mass and SigmaMass not ok
2124  }
2125  else if (sigmaMassLc > 1e19) codeKFLc = 13; // LifeTime and DecayLength and SigmaMass not ok
2126  }
2127  else if (massLc < 0) { // LifeTime and Mass and SigmaMass not ok
2128  codeKFLc = 7; // LifeTime and Mass not ok
2129  if (sigmaMassLc > 1e19) codeKFLc = 12; // LifeTime and Mass and SigmaMass not ok
2130  }
2131  else if (sigmaMassLc > 1e19) codeKFLc = 10; // LifeTime and SigmaMass not ok
2132  }
2133  }
2134 
2135  fHistoLifeTimeKFLc->Fill(lifeTimeLc, sigmaLifeTimeLc);
2136 
2137  AliDebug(2, Form("Lc: mass = %f (error = %e), decay length = %f (error = %e), life time = %f (error = %e) --> codeKFLc = %d", massLc, sigmaMassLc, decayLengthLc, sigmaDecayLengthLc, lifeTimeLc, sigmaLifeTimeLc, codeKFLc));
2138 
2139  if (codeKFLc == -1) codeKFLc = 0;
2140  fHistoKFLc->Fill(codeKFLc);
2141 
2142  fHistoKF->Fill(codeKFV0, codeKFLc);
2143 
2144  // here we fill the histgrams for all the reconstructed KF vertices for the cascade
2145  fHistoMassLcAll->Fill(massLc);
2146  fHistoDecayLengthLcAll->Fill(decayLengthLc);
2147  fHistoLifeTimeLcAll->Fill(lifeTimeLc);
2148 
2149  fHistoMassV0fromLcAll->Fill(massV0);
2150  fHistoDecayLengthV0fromLcAll->Fill(decayLengthV0);
2151  fHistoLifeTimeV0fromLcAll->Fill(lifeTimeV0);
2152 
2153  Double_t xV0 = V0.GetX();
2154  Double_t yV0 = V0.GetY();
2155  Double_t zV0 = V0.GetZ();
2156 
2157  Double_t xLc = Lc.GetX();
2158  Double_t yLc = Lc.GetY();
2159  Double_t zLc = Lc.GetZ();
2160 
2161  Double_t xPrimVtx = primVtxCopy.GetX();
2162  Double_t yPrimVtx = primVtxCopy.GetY();
2163  Double_t zPrimVtx = primVtxCopy.GetZ();
2164 
2165  Double_t distanceLcToPrimVtx = TMath::Sqrt((xPrimVtx - xLc) * (xPrimVtx - xLc) +
2166  (yPrimVtx - yLc) * (yPrimVtx - yLc) +
2167  (zPrimVtx - zLc) * (zPrimVtx - zLc));
2168 
2169  Double_t distanceV0ToPrimVtx = TMath::Sqrt((xPrimVtx - xV0) * (xPrimVtx - xV0) +
2170  (yPrimVtx - yV0) * (yPrimVtx - yV0) +
2171  (zPrimVtx - zV0) * (zPrimVtx - zV0));
2172 
2173  Double_t distanceV0ToLc = TMath::Sqrt((xLc - xV0)*(xLc - xV0) +
2174  (yLc - yV0)*(yLc - yV0) +
2175  (zLc - zV0)*(zLc - zV0));
2176 
2177  //Printf("distanceLcToPrimVtx = %e, distanceV0ToPrimVtx= %f, distanceV0ToLc = %f", distanceLcToPrimVtx, distanceV0ToPrimVtx, distanceV0ToLc);
2178 
2179  fHistoDistanceLcToPrimVtx->Fill(distanceLcToPrimVtx);
2180  fHistoDistanceV0ToPrimVtx->Fill(distanceV0ToPrimVtx);
2181  fHistoDistanceV0ToLc->Fill(distanceV0ToLc);
2182 
2183  distances[0] = distanceLcToPrimVtx;
2184  distances[1] = distanceV0ToPrimVtx;
2185  distances[2] = distanceV0ToLc;
2186 
2187  if (fUseMCInfo) {
2188 
2189  AliAODMCParticle *daughv01Lc = 0x0;
2190  AliAODMCParticle *K0S = 0x0;
2191  AliAODMCParticle *daughv02Lc = 0x0;
2192 
2193  if (labelsLcdaugh[0] >= 0) {
2194  // Printf("Getting Bachelor from label %d", labelsLcdaugh[1]);
2195  daughv01Lc = dynamic_cast<AliAODMCParticle*>(mcArray->At(labelsLcdaugh[0]));
2196  if (!daughv01Lc){
2197  AliDebug(3, "Could not access MC info for first daughter of Lc");
2198  isMCokLc = kFALSE;
2199  }
2200  else {
2201  AliDebug(2, Form("The bachelor has label = %d", daughv01Lc->GetLabel()));
2202  if (TMath::Abs(daughv01Lc->GetPdgCode()) != 2212) isBkgLc = kTRUE;
2203  }
2204  }
2205  else { // The bachelor is a fake
2206  isBkgLc = kTRUE;
2207  }
2208 
2209  if (labelsLcdaugh[1] >= 0) {
2210  //Printf("Getting K0S");
2211  K0S = dynamic_cast<AliAODMCParticle*>(mcArray->At(labelsLcdaugh[1]));
2212  if (!K0S) {
2213  AliDebug(3, "Could not access MC info for second daughter of Lc");
2214  isMCokLc = kFALSE;
2215  }
2216  else{
2217  if (TMath::Abs(K0S->GetPdgCode()) != 310) isBkgLc = kTRUE;
2218  }
2219  }
2220  else{
2221  AliDebug(2, "The K0S is not true --> it does not have a label, continuing...");
2222  isBkgLc = kTRUE;
2223  }
2224 
2225  if (!isBkgLc){ // so far, we only checked that the V0 and the bachelor are not fake, and in particular, we know that the V0 is a K0S since we used the MatchToMC method
2226  if (isMCokLc) { // We can then access its MC info, and it might then be that also the Lc is a true Lc
2227  Int_t iK0 = K0S->GetMother();
2228  if (iK0 < 0) {
2229  Printf("The K0S has no mother... IMPOSSIBLE"); // the K0S MUST have a mother!
2230  }
2231  else { // The K0S has a mother
2232  daughv02Lc = dynamic_cast<AliAODMCParticle*>(mcArray->At(iK0));
2233  if (!daughv02Lc){
2234  AliDebug(3, "Could not access MC info for second daughter of Lc");
2235  }
2236  else { // we can access safely the K0S mother in the MC
2237  if( daughv01Lc && (daughv01Lc->GetMother() == daughv02Lc->GetMother()) && (daughv01Lc->GetMother()>=0) ){ // This is a true cascade! bachelor and V0 come from the same mother
2238  //Printf("Lc: The mother has label %d", daughv01Lc->GetMother());
2239  AliAODMCParticle *motherLc = dynamic_cast<AliAODMCParticle*>(mcArray->At(daughv01Lc->GetMother()));
2240  Int_t pdgMum = 0, pdgBach = 0, pdgV0 = 0;
2241  if (motherLc) pdgMum = motherLc->GetPdgCode();
2242  if (daughv01Lc) pdgBach = daughv01Lc->GetPdgCode();
2243  if (daughv02Lc) pdgV0 = daughv02Lc->GetPdgCode();
2244  AliDebug(2, Form("pdgMum = %d, pdgBach = %d, pdgV0 = %d", pdgMum, pdgBach, pdgV0));
2245 
2246  if( motherLc && TMath::Abs(motherLc->GetPdgCode()) != 21 ){ // These are true cascades, we don't know yet if they are Lc
2247  fHistoMassLcTrue->Fill(massLc);
2248  fHistoDecayLengthLcTrue->Fill(decayLengthLc);
2249  fHistoLifeTimeLcTrue->Fill(lifeTimeLc);
2250  fHistoMassLcTrueFromAOD->Fill(cascade->InvMassLctoK0sP());
2251 
2252  fHistoMassV0fromLcTrue->Fill(massV0);
2253  fHistoDecayLengthV0fromLcTrue->Fill(decayLengthV0);
2254  fHistoLifeTimeV0fromLcTrue->Fill(lifeTimeV0);
2255 
2256  if (TMath::Abs(motherLc->GetPdgCode()) == 4122 && TMath::Abs(motherV0->GetPdgCode()) == 310 && TMath::Abs(daughv01Lc->GetPdgCode()) == 2212){ // This is Lc --> K0S + p (the check on the PDG code of the V0 is useless, since we used MathcToMC with it, but fine...
2257  AliDebug(2, Form("IT IS SIGNAL!!! with label = %d", motherLc->GetLabel()));
2258 
2259  fHistoArmenterosPodolanskiV0KFSgn->Fill(qtAlphaV0[1], qtAlphaV0[0]);
2260  fHistoArmenterosPodolanskiV0AODSgn->Fill(v0part->AlphaV0(), v0part->PtArmV0());
2261 
2262  fHistoDistanceLcToPrimVtxSgn->Fill(distanceLcToPrimVtx);
2263  fHistoDistanceV0ToPrimVtxSgn->Fill(distanceV0ToPrimVtx);
2264  fHistoDistanceV0ToLcSgn->Fill(distanceV0ToLc);
2265 
2266  fHistoMassLcSgn->Fill(massLc);
2267  fHistoMassLcSgnFromAOD->Fill(cascade->InvMassLctoK0sP());
2268 
2269  fHistoDecayLengthLcSgn->Fill(decayLengthLc);
2270  fHistoLifeTimeLcSgn->Fill(lifeTimeLc);
2271 
2272  fHistoMassV0fromLcSgn->Fill(massV0);
2273  fHistoDecayLengthV0fromLcSgn->Fill(decayLengthV0);
2274  fHistoLifeTimeV0fromLcSgn->Fill(lifeTimeV0);
2275  }
2276  else {
2277  isBkgLc = kTRUE; // it is not a Lc, since the pdg != 4122
2278  }
2279 
2280  // if we got here, we can compare with MC information; this part is done also for cases where the cascade is not a Lc!
2281  // First, we compare the vtx of the Lc
2282  Double_t xLcMC = motherLc->Xv();
2283  Double_t yLcMC = motherLc->Yv();
2284  Double_t zLcMC = motherLc->Zv();
2285  //Printf("Got MC vtx for Lc");
2286  Double_t xProtonMC = daughv01Lc->Xv();
2287  Double_t yProtonMC = daughv01Lc->Yv();
2288  Double_t zProtonMC = daughv01Lc->Zv();
2289  //Printf("Got MC vtx for Proton");
2290 
2291  Double_t vtxLcResidualToPrimVtx = TMath::Sqrt((xLcMC - xProtonMC) * (xLcMC - xProtonMC) +
2292  (yLcMC - yProtonMC) * (yLcMC - yProtonMC) +
2293  (zLcMC - zProtonMC) * (zLcMC - zProtonMC)) - distanceLcToPrimVtx;
2294 
2295  // Then, we compare the vtx of the K0s
2296  Double_t xV0MC = motherV0->Xv(); //Production vertex of K0S --> Where Lc decays
2297  Double_t yV0MC = motherV0->Yv();
2298  Double_t zV0MC = motherV0->Zv();
2299 
2300  //Printf("Got MC vtx for V0");
2301  Double_t xPionMC = daughv01->Xv(); //Production vertex of Pion --> Where K0S decays
2302  Double_t yPionMC = daughv01->Yv();
2303  Double_t zPionMC = daughv01->Zv();
2304  //Printf("Got MC vtx for Pion");
2305  Printf("Vertices: MC: x = %f, y = %f, z = %f", xPionMC, yPionMC, zPionMC);
2306 
2307  Double_t vtxV0ResidualToLc = TMath::Sqrt((xV0MC - xPionMC) * (xV0MC - xPionMC) +
2308  (yV0MC - yPionMC) * (yV0MC - yPionMC) +
2309  (zV0MC - zPionMC) * (zV0MC - zPionMC)) - distanceV0ToLc;
2310 
2311  // Then, the K0S vertex wrt primary vertex
2312 
2313  Double_t vtxV0ResidualToPrimVtx = TMath::Sqrt((xPionMC - xLcMC) * (xPionMC - xLcMC) +
2314  (yPionMC - yLcMC) * (yPionMC - yLcMC) +
2315  (zPionMC - zLcMC) * (zPionMC - zLcMC)) - distanceV0ToPrimVtx;
2316 
2317  fHistoVtxLcResidualToPrimVtx->Fill(vtxLcResidualToPrimVtx);
2318  fHistoVtxV0ResidualToLc->Fill(vtxV0ResidualToLc);
2319  fHistoVtxV0ResidualToPrimVtx->Fill(vtxV0ResidualToPrimVtx);
2320 
2321  } //closing: if( motherLc && TMath::Abs(motherLc->GetPdgCode()) != 21 )
2322  else if (!motherLc){
2323  AliDebug(2, "We could not access MC info for Lc mother, so we did nothing");
2324  }
2325  else {
2326  AliDebug(2, "MC Lc mother is a gluon, so we did nothing");
2327  }
2328  } //closing: if( daughv01Lc->GetMother() == daughv02Lc->GetMother() && daughv01Lc->GetMother()>=0 )
2329  else {
2330  isBkgLc = kTRUE; // it cannot be a Lc, since the daughters do not have the same mother
2331  }
2332  } // closing: else { // we can access safely the K0S mother in the MC
2333  } // closing: else { // The K0S has a mother
2334  } // closing isMCLcok
2335  } // closing !isBkgLc
2336  } // closing fUseMCInfo
2337 
2338  //Printf("retMV0 = %d, retMLc = %d", retMV0, retMLc);
2339  if ( retMV0 == 0 && retMLc == 0){
2340  V0KF[0] = massV0;
2341  errV0KF[0] = sigmaMassV0;
2342  V0KF[1] = decayLengthV0;
2343  errV0KF[1] = sigmaDecayLengthV0;
2344  V0KF[2] = lifeTimeV0;
2345  errV0KF[2] = sigmaLifeTimeV0;
2346  LcKF[0] = massLc;
2347  errLcKF[0] = sigmaMassLc;
2348  LcKF[1] = decayLengthLc;
2349  errLcKF[1] = sigmaDecayLengthLc;
2350  LcKF[2] = lifeTimeLc;
2351  errLcKF[2] = sigmaLifeTimeLc;
2352  }
2353 
2354  return 1;
2355 
2356 }
2357 //________________________________________________________________________
2359  AliAODTrack* bachelor,
2360  TClonesArray *mcArray ){
2361 
2362  //Printf("In CheckBachelor");
2363 
2366 
2367  Int_t label = bachelor->GetLabel();
2368  if (label == -1) {
2369  return kBachFake;
2370  }
2371 
2372  AliAODMCParticle *mcpart = dynamic_cast<AliAODMCParticle*>(mcArray->At(TMath::Abs(label)));
2373  if (!mcpart) return kBachInvalid;
2374  Int_t pdg = mcpart->PdgCode();
2375  if (TMath::Abs(pdg) != 2212) {
2376  AliDebug(2, Form("Bachelor is not a p, but a particle with pdg code = %d", pdg));
2377  return kBachNoProton;
2378  }
2379  else { // it is a proton
2380  //Int_t labelLc = part->GetLabel();
2381  Int_t labelLc = FindLcLabel(part, mcArray);
2382  //Printf(">>>>>>>>>>>>> label for Lc = %d", labelLc);
2383  Int_t bachelorMotherLabel = mcpart->GetMother();
2384  //Printf(">>>>>>>>>>>>> label for bachelorMother = %d", bachelorMotherLabel);
2385  if (bachelorMotherLabel == -1) {
2386  return kBachPrimary;
2387  }
2388  AliAODMCParticle *bachelorMother = dynamic_cast<AliAODMCParticle*>(mcArray->At(bachelorMotherLabel));
2389  if (!bachelorMother) return kBachInvalid;
2390  Int_t pdgMother = bachelorMother->PdgCode();
2391  if (TMath::Abs(pdgMother) != 4122) {
2392  AliDebug(2, Form("The proton does not come from a Lc, but from a particle with pdgcode = %d", pdgMother));
2393  return kBachNoLambdaMother;
2394  }
2395  else { // it comes from Lc
2396  if (labelLc != bachelorMotherLabel){
2397  //AliInfo(Form("The proton comes from a Lc, but it is not the candidate we are analyzing (label Lc = %d, label p mother = %d", labelLc, bachelorMotherLabel));
2398  AliDebug(2, Form("The proton comes from a Lc, but it is not the candidate we are analyzing"));
2400  }
2401  else { // it comes from the correct Lc
2402  AliDebug(2, Form("The proton comes from a Lc, and it is EXACTLY the candidate we are analyzing"));
2403  return kBachCorrectLambdaMother;
2404  }
2405  }
2406  }
2407 
2408  return kBachInvalid;
2409 
2410 }
2411 
2412 //________________________________________________________________________
2414  AliAODv0* v0part,
2415  //AliAODTrack* v0part,
2416  TClonesArray *mcArray ){
2417 
2420 
2421  //Printf(" CheckK0S");
2422 
2423  //Int_t labelMatchToMC = v0part->MatchToMC(310, mcArray);
2424  //Int_t label = v0part->GetLabel();
2425  Int_t labelFind = FindV0Label(v0part, mcArray);
2426  //Printf("\n >>>>>>>>>>>>> label for V0 = %d, from MatchToMC = %d, from Find = %d", label, labelMatchToMC, labelFind);
2427  if (labelFind == -1) {
2428  return kK0SFake;
2429  }
2430 
2431  AliAODMCParticle *mcpart = dynamic_cast<AliAODMCParticle*>(mcArray->At(labelFind));
2432  if (!mcpart) return kK0SInvalid;
2433  Int_t pdg = mcpart->PdgCode();
2434  if (TMath::Abs(pdg) != 310) {
2435  AliDebug(2, Form("K0Spart is not a K0S, but a particle with pdg code = %d", pdg));
2436  //AliInfo(Form("K0Spart is not a K0S, but a particle with pdg code = %d", pdg));
2437  return kK0SNoK0S;
2438  }
2439  else { // it is a K0S
2440  //Int_t labelLc = part->GetLabel();
2441  Int_t labelLc = FindLcLabel(part, mcArray);
2442  Int_t K0SpartMotherLabel = mcpart->GetMother();
2443  if (K0SpartMotherLabel == -1) {
2444  return kK0SWithoutMother;
2445  }
2446  AliAODMCParticle *K0SpartMother = dynamic_cast<AliAODMCParticle*>(mcArray->At(K0SpartMotherLabel)); // should be a K0 in case of signal
2447  if (!K0SpartMother) return kK0SInvalid;
2448  Int_t pdgMotherK0S = K0SpartMother->PdgCode();
2449  if (TMath::Abs(pdgMotherK0S) != 311) {
2450  AliDebug(2, Form("The K0S does not come from a K0, but from a particle with pdgcode = %d", pdgMotherK0S));
2451  //AliInfo(Form("The K0S does not come from a K0, but from a particle with pdgcode = %d", pdgMotherK0S));
2452  return kK0SNotFromK0;
2453  }
2454  else { // the K0S comes from a K0
2455  Int_t K0MotherLabel = K0SpartMother->GetMother(); // mother of K0 --> Lc in case of signal
2456  if (K0MotherLabel == -1) {
2457  return kK0Primary;
2458  }
2459  AliAODMCParticle *K0Mother = dynamic_cast<AliAODMCParticle*>(mcArray->At(K0MotherLabel));
2460  if (!K0Mother) return kK0SInvalid;
2461  Int_t pdgK0Mother = K0Mother->PdgCode();
2462  if (TMath::Abs(pdgK0Mother) != 4122) { // the K0 does not come from a Lc
2463  AliDebug(2, Form("The K0 does not come from a Lc, but from a particle with pdgcode = %d", pdgK0Mother));
2464  //AliInfo(Form("The K0 does not come from a Lc, but from a particle with pdgcode = %d", pdgK0Mother));
2465  return kK0NoLambdaMother;
2466  }
2467  else { // the K0 comes from Lc
2468  if (labelLc != K0MotherLabel){ // The K0 comes from a different Lc
2469  AliDebug(2, Form("The K0S comes from a Lc, but it is not the candidate we are analyzing"));
2470  //AliInfo(Form("The K0S comes from a Lc, but it is not the candidate we are analyzing"));
2471  return kK0DifferentLambdaMother;
2472  }
2473  else { // it comes from the correct Lc
2474  AliDebug(2, Form("The K0S comes from a Lc, and it is EXACTLY the candidate we are analyzing"));
2475  //AliInfo(Form("The K0S comes from a Lc, and it is EXACTLY the candidate we are analyzing"));
2476  return kK0CorrectLambdaMother;
2477  }
2478  }
2479  }
2480  }
2481 
2482  return kK0SInvalid;
2483 
2484 }
2485 
2486 //----------------------------------------------------------------------------
2487 Int_t AliAnalysisTaskSELc2V0bachelorTMVA::FindV0Label(AliAODRecoDecay* v0part, TClonesArray *mcArray) const
2488 {
2489 
2490  //Printf(" FindV0Label");
2491 
2493 
2494  Int_t labMother[2]={-1, -1};
2495  AliAODMCParticle *part=0;
2496  AliAODMCParticle *mother=0;
2497  Int_t dgLabels = -1;
2498 
2499  Int_t ndg = v0part->GetNDaughters();
2500  if (ndg != 2) {
2501  AliFatal(Form("IMPOSSIBLE!! There are %d daughters, but they should be 2!", ndg));
2502  }
2503 
2504  for(Int_t i = 0; i < 2; i++) {
2505  AliAODTrack *trk = (AliAODTrack*)v0part->GetDaughter(i);
2506  dgLabels = trk->GetLabel();
2507  if (dgLabels == -1) {
2508  //printf("daughter with negative label %d\n", dgLabels);
2509  return -1;
2510  }
2511  part = (AliAODMCParticle*)mcArray->At(TMath::Abs(dgLabels));
2512  if (!part) {
2513  //printf("no MC particle\n");
2514  return -1;
2515  }
2516  labMother[i] = part->GetMother();
2517  if (labMother[i] != -1){
2518  mother = (AliAODMCParticle*)mcArray->At(labMother[i]);
2519  if(!mother) {
2520  //printf("no MC mother particle\n");
2521  return -1;
2522  }
2523  }
2524  else {
2525  return -1;
2526  }
2527  }
2528 
2529  if (labMother[0] == labMother[1]) return labMother[0];
2530 
2531  else return -1;
2532 
2533 }
2534 
2535 //----------------------------------------------------------------------------
2536 Int_t AliAnalysisTaskSELc2V0bachelorTMVA::FindLcLabel(AliAODRecoCascadeHF* cascade, TClonesArray *mcArray) const
2537 {
2538 
2540 
2541  //Printf(" FindLcLabel");
2542 
2543  AliAODMCParticle *part=0;
2544  AliAODMCParticle *mother=0;
2545  AliAODMCParticle *grandmother=0;
2546  Int_t dgLabels = -1;
2547 
2548  Int_t ndg = cascade->GetNDaughters();
2549  if (ndg != 2) {
2550  AliFatal(Form("IMPOSSIBLE!! There are %d daughters, but they should be 2!", ndg));
2551  }
2552 
2553  // daughter 0 --> bachelor, daughter 1 --> V0
2554  AliAODTrack *trk = (AliAODTrack*)cascade->GetDaughter(0); // bachelor
2555  dgLabels = trk->GetLabel();
2556  if (dgLabels == -1 ) {
2557  //printf("daughter with negative label %d\n", dgLabels);
2558  return -1;
2559  }
2560  part = (AliAODMCParticle*)mcArray->At(TMath::Abs(dgLabels));
2561  if (!part) {
2562  //printf("no MC particle\n");
2563  return -1;
2564  }
2565  Int_t labMotherBach = part->GetMother();
2566  if (labMotherBach == -1){
2567  return -1;
2568  }
2569  mother = (AliAODMCParticle*)mcArray->At(labMotherBach);
2570  if(!mother) {
2571  //printf("no MC mother particle\n");
2572  return -1;
2573  }
2574 
2575  AliAODv0 *v0 = (AliAODv0*)cascade->GetDaughter(1); // V0
2576  dgLabels = FindV0Label(v0, mcArray);
2577  if (dgLabels == -1 ) {
2578  //printf("daughter with negative label (v0 was a fake) %d\n", dgLabels);
2579  return -1;
2580  }
2581  part = (AliAODMCParticle*)mcArray->At(TMath::Abs(dgLabels));
2582  if (!part) {
2583  //printf("no MC particle\n");
2584  return -1;
2585  }
2586  Int_t labMotherv0 = part->GetMother();
2587  if (labMotherv0 == -1){
2588  return -1;
2589  }
2590  mother = (AliAODMCParticle*)mcArray->At(labMotherv0);
2591  if(!mother) {
2592  //printf("no MC mother particle\n");
2593  return -1;
2594  }
2595  Int_t labGrandMotherv0 = mother->GetMother();
2596  if (labGrandMotherv0 == -1){
2597  return -1;
2598  }
2599  grandmother = (AliAODMCParticle*)mcArray->At(labGrandMotherv0);
2600  if(!grandmother) {
2601  //printf("no MC mother particle\n");
2602  return -1;
2603  }
2604 
2605  //Printf("labMotherBach = %d, labMotherv0 = %d, labGrandMotherv0 = %d", labMotherBach, labMotherv0, labGrandMotherv0);
2606  if (labGrandMotherv0 == labMotherBach) return labMotherBach;
2607 
2608  else return -1;
2609 
2610 }
2611 
2612 
2613 
2614 
2615 
2616 
Int_t IsSelectedSingleCut(TObject *obj, Int_t selectionLevel, Int_t cutIndex)
virtual Int_t IsSelected(TObject *obj, Int_t selectionLevel)
Int_t pdg
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
TH1D * fHistoDistanceV0ToLc
! KF: distance V0 vertex from Lc vertex
TH2D * fHistoArmenterosPodolanskiV0KFSgn
! KF: Armeteros-Podolanski plot for V0 from signal Lc from KF
TH1D * fHistoKFV0
! KF: V0 code from KF (mass, decaylength, lifetime considered)
TH1D * fHistoDecayLengthLcTrue
! KF: decay length for true cascades reconstructed with KF
void StoreCandidates(AliVEvent *, Int_t nCand=0, Bool_t flagFilter=kTRUE)
TH1F * fHistoLc
! histogram with number of Lc
Double_t Ct(UInt_t pdg) const
Int_t MatchToMC(Int_t pdgabs, Int_t pdgabs2prong, Int_t *pdgDg, Int_t *pdgDg2prong, TClonesArray *mcArray, Bool_t isV0=kFALSE) const
AliAODTrack * Getv0NegativeTrack() const
TH2D * fHistoLifeTimeKFLc
! KF: life time vs life time error for Lc from KF
AliPIDCombined * fPIDCombined
! combined PID response object
TH2D * fHistoArmenterosPodolanskiV0AODSgn
! KF: AOD Armeteros-Podolanski plot for V0 from signal Lc from KF
TH1D * fHistoVtxV0ResidualToPrimVtx
! KF: residual wrt MC of distance V0 vertex from primary vertex (MC - KF)
AliAODv0 * Getv0() const
TH1F * fHistoLcpKpiBeforeCuts
! histogram number of true Lc–>pKpi (3 prong) before any cut
Bool_t fKeepingOnlyPYTHIABkg
magnetic field of current event
Double_t InvMassLctoLambdaPi() const
TH1D * fHistoDecayLengthV0All
! KF: decay length for all V0 reconstructed with KF
virtual void UserCreateOutputObjects()
Implementation of interface methods.
TH1D * fHistoDecayLengthLcAll
! KF: decay length for all Lc reconstructed with KF
Bool_t fKeepingOnlyHIJINGBkg
flag to decide whether to call or not KF
TH1D * fHistoLifeTimeV0All
! KF: life time for all V0 reconstructed with KF
Float_t * fCandidateVariables
! variables to be written to the tree
TH1D * fHistoMassV0TrueK0S
! KF: mass for true V0 which are really K0S reconstructed with KF
TH2D * fHistoDecayLengthKFLc
! KF: decay length vs decay length error for Lc from KF
TList * fOutputKF
! User output1: list of histograms from KF
AliNormalizationCounter * fCounter
switch between Lpi and K0sp
Bool_t fIsEventSelected
flag to analyze also on-the-fly V0 candidates
static Int_t CheckOrigin(TClonesArray *arrayMC, AliAODMCParticle *mcPart, Bool_t searchUpToQuark=kTRUE)
Double_t GetMaxVtxZ() const
Definition: AliRDHFCuts.h:241
TH1D * fHistoDecayLengthV0fromLcAll
! KF: decay length of V0 for all cascades reconstructed with KF
Double_t InvMassLctoK0sP() const
TH1D * fHistoMassV0TrueK0SFromAOD
! KF: AOD mass for true V0 which are really K0S reconstructed with KF
TH1F * fHistoLcOnTheFly
! histogram with number of Lc with on-the-fly V0
TH1D * fHistoLifeTimeLcTrue
! KF: life time for true cascades reconstructed with KF
TH1D * fHistoKFLc
! KF: Lc code from KF (mass, decaylength, lifetime considered)
TH2D * fHistoKF
! KF: V0 code vs Lc code from KF (mass, decaylength, lifetime considered)
Int_t CallKFVertexing(AliAODRecoCascadeHF *cascade, AliAODv0 *v0part, AliAODTrack *bach, TClonesArray *mcArray, Double_t *V0KF, Double_t *errV0KF, Double_t *LcKF, Double_t *errLcKF, Double_t *distances, Double_t *armPolKF)
AliAODTrack * Getv0PositiveTrack() const
TH1D * fHistoLifeTimeLcSgn
! KF: life time of signal Lc reconstructed with KF
TH1D * fHistoDistanceV0ToPrimVtx
! KF: distance V0 vertex from primary vertex
TH1D * fHistoMassLcSgnFromAOD
! KF: AOD mass of signal Lc reconstructed with KF
TH1D * fHistoMassLcAll
! KF: mass for all Lc reconstructed with KF
TH1D * fHistoDistanceV0ToLcSgn
! KF: distance for signal Lc of V0 vertex from Lc vertex
TH1D * fHistoMassV0fromLcAll
! KF: mass of V0 for all cascades reconstructed with KF
TH1D * fHistoDecayLengthLcSgn
! KF: decay length of signal Lc reconstructed with KF
TH1F * fHistoMCLcK0SpGenAcc
! histo with MC Lc –> K0S + p
TH1D * fHistoMassLcTrueFromAOD
! KF: AOD mass for true cascades reconstructed with KF
TH1D * fHistoMassV0fromLcSgn
! KF: mass of V0 for signal Lc reconstructed with KF
AliAODTrack * GetBachelor() const
Int_t FindLcLabel(AliAODRecoCascadeHF *cascade, TClonesArray *mcArray) const
TH1D * fHistoLifeTimeV0fromLcAll
! KF: life time of V0 for all cascades reconstructed with KF
TH2D * fHistoLifeTimeKFV0
! KF: life time vs life time error for V0 from KF
TH1D * fHistoMassV0TrueFromAOD
! KF: AOD mass for true V0 reconstructed with KF
Double_t fBField
current event number - for debug purposes
TH2D * fHistoDecayLengthKFV0
! KF: decay length vs decay length error for V0 from KF
Bool_t HasCascadeCandidateAnyDaughInjected(AliAODRecoCascadeHF *cand, AliAODMCHeader *header, TClonesArray *arrayMC)
TH1D * fHistoDecayLengthV0True
! KF: decay length for true V0 reconstructed with KF
TH1F * fHistoFiducialAcceptance
! histogram to check FiducialAcceptance cut
TH2F * fHistoCodesBkg
! histogram with codes for bachelor and V0 for background
Double_t CosV0PointingAngle() const
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
TH1D * fHistoLifeTimeV0fromLcTrue
! KF: life time of V0 for true cascades reconstructed with KF
AliVertexingHFUtils * fUtils
flag to fill bkg with only candidates that have daughters generated by HIJING (to be used for enriche...
EBachelor CheckBachelor(AliAODRecoCascadeHF *part, AliAODTrack *bachelor, TClonesArray *mcArray)
TH1D * fHistoDecayLengthV0fromLcSgn
! KF: decay length of V0 for signal Lc reconstructed with KF
void MakeAnalysisForLc2prK0S(TClonesArray *arrayLctopK0s, TClonesArray *mcArray, Int_t &nSelectedAnal, AliRDHFCutsLctoV0 *cutsAnal, TClonesArray *array3Prong, AliAODMCHeader *aodheader)
Bool_t IsEventSelected(AliVEvent *event)
TH1F * fHistoLcBeforeCuts
flag to fill only signal (speeding up processing)
TH1D * fHistoDecayLengthV0TrueK0S
! KF: decay length for true V0 which are really K0S reconstructed with KF
void SetUsePID(Bool_t flag=kTRUE)
Definition: AliRDHFCuts.h:204
TH1D * fHistoLifeTimeLcAll
! KF: life time for all Lc reconstructed with KF
TH1D * fHistoMassV0All
! KF: mass for all V0 reconstructed with KF
TH1D * fHistoMassLcTrue
! KF: mass for true cascades reconstructed with KF
TH1D * fHistoLifeTimeV0True
! KF: life time for true V0 reconstructed with KF
TH1F * fHistoMCLcK0SpGenLimAcc
! histo with MC Lc –> K0S + p
TH2D * fHistoArmenterosPodolanskiV0AOD
! KF: AOD Armeteros-Podolanski plot for all V0 from KF
TH1D * fHistoVtxV0ResidualToLc
! KF: residual wrt MC of distance V0 vertex from Lc vertex (MC - KF)
TH1D * fHistoDistanceV0ToPrimVtxSgn
! KF: distance for signal Lc of V0 vertex from primary vertex
TH2D * fHistoArmenterosPodolanskiV0KF
! KF: Armeteros-Podolanski plot for all V0 from KF
TH1D * fHistoDecayLengthV0fromLcTrue
! KF: decay length of V0 for true cascades reconstructed with KF
Bool_t GetIsUsePID() const
Definition: AliRDHFCuts.h:253
TH1D * fHistoLifeTimeV0fromLcSgn
! KF: life time of V0 for signal Lc reconstructed with KF
void StoreEvent(AliVEvent *, AliRDHFCuts *, Bool_t mc=kFALSE, Int_t multiplicity=-9999)
TTree * fVariablesTreeBkg
! tree of the candidate variables after track selection (Background)
Double_t DecayLengthV0() const
void SetTriggerClass(TString trclass0, TString trclass1="")
Definition: AliRDHFCuts.h:192
TH1D * fHistoDistanceLcToPrimVtxSgn
! KF: distance of signal Lc vertex from primary vertex
AliPIDResponse * fPIDResponse
! PID response object
virtual Bool_t IsInFiducialAcceptance(Double_t pt, Double_t y) const
TList * fListCuts
Cuts - sent to output slot 5.
EK0S CheckK0S(AliAODRecoCascadeHF *part, AliAODv0 *v0part, TClonesArray *mcArray)
TH1D * fHistoLifeTimeV0TrueK0S
! KF: life time for true V0 which are really K0S reconstructed with KF
TH1F * fHistoMCLcK0SpGen
flag to allow to use only PYTHIA tracks for background
Double_t DecayLength() const
TH2D * fHistoMassKFLc
! KF: mass vs mass error for Lc from KF
Bool_t fCallKFVertexing
flag to use topological constraints in KF
Int_t fCurrentEvent
cut for KF on distance to primary vtx for V0
void FillLc2pK0Sspectrum(AliAODRecoCascadeHF *part, Int_t isLc, Int_t &nSelectedAnal, AliRDHFCutsLctoV0 *cutsAnal, TClonesArray *mcArray, Int_t iLctopK0s)
histos
TH1D * fHistoVtxLcResidualToPrimVtx
! KF: residual wrt MC of distance Lc vertex from primary vertex (MC - KF)
void SetTriggerMask(ULong64_t mask=0)
Definition: AliRDHFCuts.h:63
TH1D * fHistoMassV0True
! KF: mass for true V0 reconstructed with KF
TH2D * fHistoMassKFV0
! KF: mass vs mass error for V0 from KF
Int_t FindV0Label(AliAODRecoDecay *v0part, TClonesArray *mcArray) const
TH1D * fHistoMassLcSgn
! KF: mass of signal Lc reconstructed with KF
TH2F * fHistoCodesSgn
! histogram with codes for bachelor and V0 for signal
TH1D * fHistoMassV0fromLcTrue
! KF: mass of V0 for true cascades reconstructed with KF
Class with functions useful for different D2H analyses //.
TH1F * fHistoBackground
AliVertexingHFUtils used to check the generator of a specific candidate.