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