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